Index: head/share/man/man4/Makefile =================================================================== --- head/share/man/man4/Makefile (revision 327197) +++ head/share/man/man4/Makefile (revision 327198) @@ -1,992 +1,993 @@ # @(#)Makefile 8.1 (Berkeley) 6/18/93 # $FreeBSD$ .include PACKAGE=runtime-manuals MAN= aac.4 \ aacraid.4 \ acpi.4 \ ${_acpi_asus.4} \ ${_acpi_asus_wmi.4} \ ${_acpi_dock.4} \ ${_acpi_fujitsu.4} \ ${_acpi_hp.4} \ ${_acpi_ibm.4} \ ${_acpi_panasonic.4} \ ${_acpi_rapidstart.4} \ ${_acpi_sony.4} \ acpi_thermal.4 \ ${_acpi_toshiba.4} \ acpi_video.4 \ ${_acpi_wmi.4} \ ada.4 \ adm6996fc.4 \ adv.4 \ adw.4 \ ae.4 \ ${_aesni.4} \ age.4 \ agp.4 \ aha.4 \ ahc.4 \ ahci.4 \ ahd.4 \ ${_aibs.4} \ aio.4 \ alc.4 \ ale.4 \ alpm.4 \ altera_atse.4 \ altera_avgen.4 \ altera_jtag_uart.4 \ altera_sdcard.4 \ altq.4 \ amdpm.4 \ ${_amdsbwd.4} \ ${_amdsmb.4} \ ${_amdsmn.4} \ ${_amdtemp.4} \ ${_bxe.4} \ amr.4 \ an.4 \ ${_aout.4} \ ${_apic.4} \ arcmsr.4 \ ${_armv8crypto.4} \ ${_asmc.4} \ ata.4 \ ath.4 \ ath_ahb.4 \ ath_hal.4 \ ath_pci.4 \ atkbd.4 \ atkbdc.4 \ atp.4 \ ${_atf_test_case.4} \ ${_atrtc.4} \ ${_attimer.4} \ audit.4 \ auditpipe.4 \ aue.4 \ + aw_mmc.4 \ aw_rtc.4 \ axe.4 \ axge.4 \ bce.4 \ bcma.4 \ bfe.4 \ bge.4 \ ${_bhyve.4} \ bhnd.4 \ bhnd_chipc.4 \ bhnd_pmu.4 \ bhndb.4 \ bhndb_pci.4 \ bktr.4 \ blackhole.4 \ bnxt.4 \ bpf.4 \ bridge.4 \ bt.4 \ bwi.4 \ bwn.4 \ ${_bytgpio.4} \ capsicum.4 \ cardbus.4 \ carp.4 \ cas.4 \ cc_cdg.4 \ cc_chd.4 \ cc_cubic.4 \ cc_dctcp.4 \ cc_hd.4 \ cc_htcp.4 \ cc_newreno.4 \ cc_vegas.4 \ ${_ccd.4} \ ccr.4 \ cd.4 \ cdce.4 \ cfi.4 \ cfumass.4 \ ch.4 \ chromebook_platform.4 \ ciss.4 \ cloudabi.4 \ cm.4 \ cmx.4 \ ${_coretemp.4} \ ${_cpuctl.4} \ cpufreq.4 \ crypto.4 \ ctl.4 \ cue.4 \ cxgb.4 \ cxgbe.4 \ cxgbev.4 \ cy.4 \ cyapa.4 \ da.4 \ dc.4 \ dcons.4 \ dcons_crom.4 \ ddb.4 \ de.4 \ devctl.4 \ disc.4 \ divert.4 \ ${_dpms.4} \ dpt.4 \ ds1307.4 \ ds3231.4 \ ${_dtrace_provs} \ dummynet.4 \ ed.4 \ edsc.4 \ ehci.4 \ em.4 \ ena.4 \ enc.4 \ epair.4 \ esp.4 \ est.4 \ et.4 \ etherswitch.4 \ eventtimers.4 \ exca.4 \ e6060sw.4 \ fd.4 \ fdc.4 \ fdt.4 \ fdtbus.4 \ ffclock.4 \ filemon.4 \ firewire.4 \ fpa.4 \ full.4 \ fwe.4 \ fwip.4 \ fwohci.4 \ fxp.4 \ gbde.4 \ gdb.4 \ gem.4 \ geom.4 \ geom_fox.4 \ geom_linux_lvm.4 \ geom_map.4 \ geom_uzip.4 \ gif.4 \ gpio.4 \ gpioiic.4 \ gpioled.4 \ gre.4 \ h_ertt.4 \ hifn.4 \ hme.4 \ hpet.4 \ ${_hpt27xx.4} \ ${_hptiop.4} \ ${_hptmv.4} \ ${_hptnr.4} \ ${_hptrr.4} \ ${_hv_kvp.4} \ ${_hv_netvsc.4} \ ${_hv_storvsc.4} \ ${_hv_utils.4} \ ${_hv_vmbus.4} \ ${_hv_vss.4} \ hwpmc.4 \ ichsmb.4 \ ${_ichwd.4} \ icmp.4 \ icmp6.4 \ ida.4 \ if_ipsec.4 \ ifmib.4 \ ig4.4 \ igmp.4 \ iic.4 \ iicbb.4 \ iicbus.4 \ iicsmb.4 \ iir.4 \ inet.4 \ inet6.4 \ intpm.4 \ intro.4 \ ${_io.4} \ ${_ioat.4} \ ip.4 \ ip6.4 \ ipfirewall.4 \ ipheth.4 \ ${_ipmi.4} \ ips.4 \ ipsec.4 \ ipw.4 \ ipwfw.4 \ isci.4 \ isl.4 \ ismt.4 \ isp.4 \ ispfw.4 \ iwi.4 \ iwifw.4 \ iwm.4 \ iwmfw.4 \ iwn.4 \ iwnfw.4 \ ixgb.4 \ ixgbe.4 \ ixl.4 \ ixlv.4 \ jedec_ts.4 \ jme.4 \ joy.4 \ kbdmux.4 \ keyboard.4 \ kld.4 \ ksyms.4 \ ksz8995ma.4 \ ktr.4 \ kue.4 \ lagg.4 \ le.4 \ led.4 \ lge.4 \ ${_linux.4} \ liquidio.4 \ lm75.4 \ lmc.4 \ lo.4 \ lp.4 \ lpbb.4 \ lpt.4 \ mac.4 \ mac_biba.4 \ mac_bsdextended.4 \ mac_ifoff.4 \ mac_lomac.4 \ mac_mls.4 \ mac_none.4 \ mac_partition.4 \ mac_portacl.4 \ mac_seeotheruids.4 \ mac_stub.4 \ mac_test.4 \ malo.4 \ md.4 \ mdio.4 \ me.4 \ mem.4 \ meteor.4 \ mfi.4 \ miibus.4 \ mk48txx.4 \ mld.4 \ mlx.4 \ mlx4en.4 \ mlx5en.4 \ mly.4 \ mmc.4 \ mmcsd.4 \ mn.4 \ mod_cc.4 \ mos.4 \ mouse.4 \ mpr.4 \ mps.4 \ mpt.4 \ mrsas.4 \ msk.4 \ mtio.4 \ multicast.4 \ mvs.4 \ mwl.4 \ mwlfw.4 \ mxge.4 \ my.4 \ nand.4 \ nandsim.4 \ ncr.4 \ ncv.4 \ ${_ndis.4} \ net80211.4 \ netfpga10g_nf10bmac.4 \ netgraph.4 \ netintro.4 \ netmap.4 \ ${_nfe.4} \ ${_nfsmb.4} \ ng_async.4 \ ngatmbase.4 \ ng_atmllc.4 \ ng_bpf.4 \ ng_bridge.4 \ ng_bt3c.4 \ ng_btsocket.4 \ ng_car.4 \ ng_ccatm.4 \ ng_cisco.4 \ ng_deflate.4 \ ng_device.4 \ nge.4 \ ng_echo.4 \ ng_eiface.4 \ ng_etf.4 \ ng_ether.4 \ ng_ether_echo.4 \ ng_frame_relay.4 \ ng_gif.4 \ ng_gif_demux.4 \ ng_h4.4 \ ng_hci.4 \ ng_hole.4 \ ng_hub.4 \ ng_iface.4 \ ng_ipfw.4 \ ng_ip_input.4 \ ng_ksocket.4 \ ng_l2cap.4 \ ng_l2tp.4 \ ng_lmi.4 \ ng_mppc.4 \ ng_nat.4 \ ng_netflow.4 \ ng_one2many.4 \ ng_patch.4 \ ng_ppp.4 \ ng_pppoe.4 \ ng_pptpgre.4 \ ng_pred1.4 \ ng_rfc1490.4 \ ng_socket.4 \ ng_source.4 \ ng_split.4 \ ng_sppp.4 \ ng_sscfu.4 \ ng_sscop.4 \ ng_tag.4 \ ng_tcpmss.4 \ ng_tee.4 \ ng_tty.4 \ ng_ubt.4 \ ng_UI.4 \ ng_uni.4 \ ng_vjc.4 \ ng_vlan.4 \ nmdm.4 \ nsp.4 \ ${_ntb.4} \ ${_ntb_hw_intel.4} \ ${_ntb_hw_plx.4} \ ${_ntb_transport.4} \ ${_nda.4} \ ${_if_ntb.4} \ null.4 \ numa.4 \ ${_nvd.4} \ ${_nvme.4} \ ${_nvram.4} \ ${_nvram2env.4} \ ${_nxge.4} \ oce.4 \ ohci.4 \ orm.4 \ ow.4 \ ow_temp.4 \ owc.4 \ ${_padlock.4} \ pass.4 \ pccard.4 \ pccbb.4 \ pcf.4 \ pci.4 \ pcib.4 \ pcic.4 \ pcm.4 \ pcn.4 \ ${_pf.4} \ ${_pflog.4} \ ${_pfsync.4} \ pim.4 \ pms.4 \ polling.4 \ ppbus.4 \ ppc.4 \ ppi.4 \ procdesc.4 \ proto.4 \ psm.4 \ pst.4 \ pt.4 \ pts.4 \ pty.4 \ puc.4 \ ${_qlxge.4} \ ${_qlxgb.4} \ ${_qlxgbe.4} \ ${_qlnxe.4} \ ral.4 \ random.4 \ rc.4 \ rctl.4 \ re.4 \ rgephy.4 \ rights.4 \ rl.4 \ rndtest.4 \ route.4 \ rp.4 \ rtwn.4 \ rtwnfw.4 \ rtwn_pci.4 \ rue.4 \ sa.4 \ safe.4 \ sbp.4 \ sbp_targ.4 \ scc.4 \ sched_4bsd.4 \ sched_ule.4 \ screen.4 \ scsi.4 \ sctp.4 \ sdhci.4 \ sem.4 \ send.4 \ ses.4 \ sf.4 \ ${_sfxge.4} \ sge.4 \ siba.4 \ siftr.4 \ siis.4 \ simplebus.4 \ sio.4 \ sis.4 \ sk.4 \ smb.4 \ smbus.4 \ smp.4 \ smsc.4 \ sn.4 \ snd_ad1816.4 \ snd_als4000.4 \ snd_atiixp.4 \ snd_cmi.4 \ snd_cs4281.4 \ snd_csa.4 \ snd_ds1.4 \ snd_emu10k1.4 \ snd_emu10kx.4 \ snd_envy24.4 \ snd_envy24ht.4 \ snd_es137x.4 \ snd_ess.4 \ snd_fm801.4 \ snd_gusc.4 \ snd_hda.4 \ snd_hdspe.4 \ snd_ich.4 \ snd_maestro3.4 \ snd_maestro.4 \ snd_mss.4 \ snd_neomagic.4 \ snd_sbc.4 \ snd_solo.4 \ snd_spicds.4 \ snd_t4dwave.4 \ snd_uaudio.4 \ snd_via8233.4 \ snd_via82c686.4 \ snd_vibes.4 \ snp.4 \ ${_spkr.4} \ splash.4 \ sppp.4 \ ste.4 \ stf.4 \ stg.4 \ stge.4 \ sym.4 \ syncache.4 \ syncer.4 \ syscons.4 \ sysmouse.4 \ tap.4 \ targ.4 \ tcp.4 \ tdfx.4 \ terasic_mtl.4 \ termios.4 \ textdump.4 \ ti.4 \ timecounters.4 \ tl.4 \ ${_tpm.4} \ trm.4 \ tty.4 \ tun.4 \ twa.4 \ twe.4 \ tws.4 \ tx.4 \ txp.4 \ udp.4 \ udplite.4 \ ure.4 \ vale.4 \ vga.4 \ vge.4 \ viapm.4 \ ${_viawd.4} \ ${_virtio.4} \ ${_virtio_balloon.4} \ ${_virtio_blk.4} \ ${_virtio_console.4} \ ${_virtio_random.4} \ ${_virtio_scsi.4} \ vkbd.4 \ vlan.4 \ vxlan.4 \ ${_vmx.4} \ vpo.4 \ vr.4 \ vt.4 \ vte.4 \ ${_vtnet.4} \ ${_vxge.4} \ watchdog.4 \ wb.4 \ ${_wbwd.4} \ wi.4 \ witness.4 \ wlan.4 \ wlan_acl.4 \ wlan_amrr.4 \ wlan_ccmp.4 \ wlan_tkip.4 \ wlan_wep.4 \ wlan_xauth.4 \ wmt.4 \ ${_wpi.4} \ wsp.4 \ xe.4 \ ${_xen.4} \ xhci.4 \ xl.4 \ ${_xnb.4} \ xpt.4 \ zero.4 MLINKS= ae.4 if_ae.4 MLINKS+=age.4 if_age.4 MLINKS+=agp.4 agpgart.4 MLINKS+=alc.4 if_alc.4 MLINKS+=ale.4 if_ale.4 MLINKS+=altera_atse.4 atse.4 MLINKS+=altera_sdcard.4 altera_sdcardc.4 MLINKS+=altq.4 ALTQ.4 MLINKS+=ath.4 if_ath.4 MLINKS+=ath_pci.4 if_ath_pci.4 MLINKS+=an.4 if_an.4 MLINKS+=aue.4 if_aue.4 MLINKS+=axe.4 if_axe.4 MLINKS+=bce.4 if_bce.4 MLINKS+=bfe.4 if_bfe.4 MLINKS+=bge.4 if_bge.4 MLINKS+=bktr.4 brooktree.4 MLINKS+=bnxt.4 if_bnxt.4 MLINKS+=bridge.4 if_bridge.4 MLINKS+=bwi.4 if_bwi.4 MLINKS+=bwn.4 if_bwn.4 MLINKS+=${_bxe.4} ${_if_bxe.4} MLINKS+=cas.4 if_cas.4 MLINKS+=cdce.4 if_cdce.4 MLINKS+=cfi.4 cfid.4 MLINKS+=cloudabi.4 cloudabi32.4 \ cloudabi.4 cloudabi64.4 MLINKS+=crypto.4 cryptodev.4 MLINKS+=cue.4 if_cue.4 MLINKS+=cxgb.4 if_cxgb.4 MLINKS+=cxgbe.4 if_cxgbe.4 \ cxgbe.4 vcxgbe.4 \ cxgbe.4 if_vcxgbe.4 \ cxgbe.4 cxl.4 \ cxgbe.4 if_cxl.4 \ cxgbe.4 vcxl.4 \ cxgbe.4 if_vcxl.4 \ cxgbe.4 cc.4 \ cxgbe.4 if_cc.4 \ cxgbe.4 vcc.4 \ cxgbe.4 if_vcc.4 MLINKS+=cxgbev.4 if_cxgbev.4 \ cxgbev.4 cxlv.4 \ cxgbev.4 if_cxlv.4 \ cxgbev.4 ccv.4 \ cxgbev.4 if_ccv.4 MLINKS+=dc.4 if_dc.4 MLINKS+=de.4 if_de.4 MLINKS+=disc.4 if_disc.4 MLINKS+=ed.4 if_ed.4 MLINKS+=edsc.4 if_edsc.4 MLINKS+=em.4 if_em.4 MLINKS+=enc.4 if_enc.4 MLINKS+=epair.4 if_epair.4 MLINKS+=et.4 if_et.4 MLINKS+=fd.4 stderr.4 \ fd.4 stdin.4 \ fd.4 stdout.4 MLINKS+=fdt.4 FDT.4 MLINKS+=firewire.4 ieee1394.4 MLINKS+=fwe.4 if_fwe.4 MLINKS+=fwip.4 if_fwip.4 MLINKS+=fxp.4 if_fxp.4 MLINKS+=gem.4 if_gem.4 MLINKS+=geom.4 GEOM.4 MLINKS+=gif.4 if_gif.4 MLINKS+=gpio.4 gpiobus.4 MLINKS+=gre.4 if_gre.4 MLINKS+=hme.4 if_hme.4 MLINKS+=hpet.4 acpi_hpet.4 MLINKS+=${_hptrr.4} ${_rr232x.4} MLINKS+=${_attimer.4} ${_i8254.4} MLINKS+=ip.4 rawip.4 MLINKS+=ipfirewall.4 ipaccounting.4 \ ipfirewall.4 ipacct.4 \ ipfirewall.4 ipfw.4 MLINKS+=ipheth.4 if_ipheth.4 MLINKS+=ipw.4 if_ipw.4 MLINKS+=iwi.4 if_iwi.4 MLINKS+=iwm.4 if_iwm.4 MLINKS+=iwn.4 if_iwn.4 MLINKS+=ixgb.4 if_ixgb.4 MLINKS+=ixgbe.4 ix.4 MLINKS+=ixgbe.4 if_ix.4 MLINKS+=ixgbe.4 if_ixgbe.4 MLINKS+=ixl.4 if_ixl.4 MLINKS+=ixlv.4 if_ixlv.4 MLINKS+=jme.4 if_jme.4 MLINKS+=kue.4 if_kue.4 MLINKS+=lagg.4 trunk.4 MLINKS+=lagg.4 if_lagg.4 MLINKS+=le.4 if_le.4 MLINKS+=lge.4 if_lge.4 MLINKS+=lmc.4 if_lmc.4 MLINKS+=lo.4 loop.4 MLINKS+=lp.4 plip.4 MLINKS+=malo.4 if_malo.4 MLINKS+=md.4 vn.4 MLINKS+=mem.4 kmem.4 MLINKS+=mfi.4 mfi_linux.4 \ mfi.4 mfip.4 MLINKS+=mlx5en.4 mce.4 MLINKS+=mn.4 if_mn.4 MLINKS+=mos.4 if_mos.4 MLINKS+=msk.4 if_msk.4 MLINKS+=mwl.4 if_mwl.4 MLINKS+=mxge.4 if_mxge.4 MLINKS+=my.4 if_my.4 MLINKS+=${_ndis.4} ${_if_ndis.4} MLINKS+=netfpga10g_nf10bmac.4 if_nf10bmac.4 MLINKS+=netintro.4 net.4 \ netintro.4 networking.4 MLINKS+=${_nfe.4} ${_if_nfe.4} MLINKS+=nge.4 if_nge.4 MLINKS+=${_nxge.4} ${_if_nxge.4} MLINKS+=ow.4 onewire.4 MLINKS+=pccbb.4 cbb.4 MLINKS+=pcm.4 snd.4 \ pcm.4 sound.4 MLINKS+=pcn.4 if_pcn.4 MLINKS+=pms.4 pmspcv.4 MLINKS+=ral.4 if_ral.4 MLINKS+=re.4 if_re.4 MLINKS+=rl.4 if_rl.4 MLINKS+=rtwn_pci.4 if_rtwn_pci.4 MLINKS+=rue.4 if_rue.4 MLINKS+=scsi.4 CAM.4 \ scsi.4 cam.4 \ scsi.4 scbus.4 \ scsi.4 SCSI.4 MLINKS+=sf.4 if_sf.4 MLINKS+=sge.4 if_sge.4 MLINKS+=sis.4 if_sis.4 MLINKS+=sk.4 if_sk.4 MLINKS+=smp.4 SMP.4 MLINKS+=smsc.4 if_smsc.4 MLINKS+=sn.4 if_sn.4 MLINKS+=snd_envy24.4 snd_ak452x.4 MLINKS+=snd_sbc.4 snd_sb16.4 \ snd_sbc.4 snd_sb8.4 MLINKS+=${_spkr.4} ${_speaker.4} MLINKS+=splash.4 screensaver.4 MLINKS+=ste.4 if_ste.4 MLINKS+=stf.4 if_stf.4 MLINKS+=stge.4 if_stge.4 MLINKS+=syncache.4 syncookies.4 MLINKS+=syscons.4 sc.4 MLINKS+=tap.4 if_tap.4 MLINKS+=tdfx.4 tdfx_linux.4 MLINKS+=ti.4 if_ti.4 MLINKS+=tl.4 if_tl.4 MLINKS+=tun.4 if_tun.4 MLINKS+=tx.4 if_tx.4 MLINKS+=txp.4 if_txp.4 MLINKS+=ure.4 if_ure.4 MLINKS+=vge.4 if_vge.4 MLINKS+=vlan.4 if_vlan.4 MLINKS+=vxlan.4 if_vxlan.4 MLINKS+=${_vmx.4} ${_if_vmx.4} MLINKS+=vpo.4 imm.4 MLINKS+=vr.4 if_vr.4 MLINKS+=vte.4 if_vte.4 MLINKS+=${_vtnet.4} ${_if_vtnet.4} MLINKS+=${_vxge.4} ${_if_vxge.4} MLINKS+=watchdog.4 SW_WATCHDOG.4 MLINKS+=wb.4 if_wb.4 MLINKS+=wi.4 if_wi.4 MLINKS+=${_wpi.4} ${_if_wpi.4} MLINKS+=xe.4 if_xe.4 MLINKS+=xl.4 if_xl.4 .if ${MACHINE_CPUARCH} == "aarch64" _armv8crypto.4= armv8crypto.4 .endif .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" _acpi_asus.4= acpi_asus.4 _acpi_asus_wmi.4= acpi_asus_wmi.4 _acpi_dock.4= acpi_dock.4 _acpi_fujitsu.4=acpi_fujitsu.4 _acpi_hp.4= acpi_hp.4 _acpi_ibm.4= acpi_ibm.4 _acpi_panasonic.4=acpi_panasonic.4 _acpi_rapidstart.4=acpi_rapidstart.4 _acpi_sony.4= acpi_sony.4 _acpi_toshiba.4=acpi_toshiba.4 _acpi_wmi.4= acpi_wmi.4 _aesni.4= aesni.4 _aout.4= aout.4 _apic.4= apic.4 _atrtc.4= atrtc.4 _attimer.4= attimer.4 _aibs.4= aibs.4 _amdsbwd.4= amdsbwd.4 _amdsmb.4= amdsmb.4 _amdsmn.4= amdsmn.4 _amdtemp.4= amdtemp.4 _asmc.4= asmc.4 _bxe.4= bxe.4 _bytgpio.4= bytgpio.4 _coretemp.4= coretemp.4 _cpuctl.4= cpuctl.4 _dpms.4= dpms.4 _hpt27xx.4= hpt27xx.4 _hptiop.4= hptiop.4 _hptmv.4= hptmv.4 _hptnr.4= hptnr.4 _hptrr.4= hptrr.4 _hv_kvp.4= hv_kvp.4 _hv_netvsc.4= hv_netvsc.4 _hv_storvsc.4= hv_storvsc.4 _hv_utils.4= hv_utils.4 _hv_vmbus.4= hv_vmbus.4 _hv_vss.4= hv_vss.4 _i8254.4= i8254.4 _ichwd.4= ichwd.4 _if_bxe.4= if_bxe.4 _if_ndis.4= if_ndis.4 _if_nfe.4= if_nfe.4 _if_nxge.4= if_nxge.4 _if_urtw.4= if_urtw.4 _if_vmx.4= if_vmx.4 _if_vtnet.4= if_vtnet.4 _if_vxge.4= if_vxge.4 _if_wpi.4= if_wpi.4 _ipmi.4= ipmi.4 _io.4= io.4 _linux.4= linux.4 _nda.4= nda.4 _ndis.4= ndis.4 _nfe.4= nfe.4 _nfsmb.4= nfsmb.4 _nvd.4= nvd.4 _nvme.4= nvme.4 _nvram.4= nvram.4 _nxge.4= nxge.4 _virtio.4= virtio.4 _virtio_balloon.4=virtio_balloon.4 _virtio_blk.4= virtio_blk.4 _virtio_console.4=virtio_console.4 _virtio_random.4= virtio_random.4 _virtio_scsi.4= virtio_scsi.4 _vmx.4= vmx.4 _vtnet.4= vtnet.4 _vxge.4= vxge.4 _padlock.4= padlock.4 _rr232x.4= rr232x.4 _speaker.4= speaker.4 _spkr.4= spkr.4 _tpm.4= tpm.4 _urtw.4= urtw.4 _viawd.4= viawd.4 _wbwd.4= wbwd.4 _wpi.4= wpi.4 _xen.4= xen.4 _xnb.4= xnb.4 .endif .if ${MACHINE_CPUARCH} == "amd64" _if_ntb.4= if_ntb.4 _ioat.4= ioat.4 _ntb.4= ntb.4 _ntb_hw_intel.4= ntb_hw_intel.4 _ntb_hw_plx.4= ntb_hw_plx.4 _ntb_transport.4=ntb_transport.4 _qlxge.4= qlxge.4 _qlxgb.4= qlxgb.4 _qlxgbe.4= qlxgbe.4 _qlnxe.4= qlnxe.4 _sfxge.4= sfxge.4 MLINKS+=qlxge.4 if_qlxge.4 MLINKS+=qlxgb.4 if_qlxgb.4 MLINKS+=qlxgbe.4 if_qlxgbe.4 MLINKS+=qlnxe.4 if_qlnxe.4 MLINKS+=sfxge.4 if_sfxge.4 .if ${MK_BHYVE} != "no" _bhyve.4= bhyve.4 .endif .endif .if ${MACHINE_CPUARCH} == "mips" _nvram2env.4= nvram2env.4 .endif .if exists(${.CURDIR}/man4.${MACHINE_CPUARCH}) SUBDIR= man4.${MACHINE_CPUARCH} .endif .if ${MK_BLUETOOTH} != "no" MAN+= ng_bluetooth.4 .endif .if ${MK_CCD} != "no" _ccd.4= ccd.4 .endif .if ${MK_CDDL} != "no" _dtrace_provs= dtrace_io.4 \ dtrace_ip.4 \ dtrace_lockstat.4 \ dtrace_proc.4 \ dtrace_sched.4 \ dtrace_tcp.4 \ dtrace_udp.4 .endif .if ${MK_ISCSI} != "no" MAN+= cfiscsi.4 MAN+= iscsi.4 MAN+= iscsi_initiator.4 MAN+= iser.4 .endif .if ${MK_OFED} != "no" MAN+= mlx4ib.4 MAN+= mlx5ib.4 .endif .if ${MK_TESTS} != "no" ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/doc _atf_test_case.4= atf-test-case.4 .endif .if ${MK_PF} != "no" _pf.4= pf.4 _pflog.4= pflog.4 _pfsync.4= pfsync.4 .endif .if ${MK_USB} != "no" MAN+= \ otus.4 \ otusfw.4 \ rsu.4 \ rsufw.4 \ rtwn_usb.4 \ rum.4 \ run.4 \ runfw.4 \ u3g.4 \ uark.4 \ uart.4 \ uath.4 \ ubsa.4 \ ubsec.4 \ ubser.4 \ ubtbcmfw.4 \ uchcom.4 \ ucom.4 \ ucycom.4 \ udav.4 \ udbp.4 \ udl.4 \ uep.4 \ ufm.4 \ ufoma.4 \ uftdi.4 \ ugen.4 \ ugold.4 \ uhci.4 \ uhid.4 \ uhso.4 \ uipaq.4 \ ukbd.4 \ uled.4 \ ulpt.4 \ umass.4 \ umcs.4 \ umct.4 \ umodem.4 \ umoscom.4 \ ums.4 \ unix.4 \ upgt.4 \ uplcom.4 \ ural.4 \ urio.4 \ urndis.4 \ ${_urtw.4} \ usb.4 \ usb_quirk.4 \ usb_template.4 \ usfs.4 \ uslcom.4 \ uvisor.4 \ uvscom.4 \ zyd.4 MLINKS+=otus.4 if_otus.4 MLINKS+=rsu.4 if_rsu.4 MLINKS+=rtwn_usb.4 if_rtwn_usb.4 MLINKS+=rum.4 if_rum.4 MLINKS+=run.4 if_run.4 MLINKS+=u3g.4 u3gstub.4 MLINKS+=uath.4 if_uath.4 MLINKS+=udav.4 if_udav.4 MLINKS+=upgt.4 if_upgt.4 MLINKS+=ural.4 if_ural.4 MLINKS+=urndis.4 if_urndis.4 MLINKS+=${_urtw.4} ${_if_urtw.4} MLINKS+=zyd.4 if_zyd.4 .endif .include Index: head/share/man/man4/aw_mmc.4 =================================================================== --- head/share/man/man4/aw_mmc.4 (nonexistent) +++ head/share/man/man4/aw_mmc.4 (revision 327198) @@ -0,0 +1,76 @@ +.\"- +.\" Copyright (c) 2017 Emmanuel Vadot +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd Dec 25, 2017 +.Dt AW_MMC 4 +.Os +.Sh NAME +.Nm aw_mmc +.Nd driver for the SD/MMC controller in Allwinner SoC +.Sh SYNOPSIS +.Cd "device mmc" +.Sh DESCRIPTION +The +.Nm +device driver provides support for the Allwinner SD/MMC host controller. +.Sh HARDWARE +The current version of the +.Nm +driver supports the SD/MMC controller with one of the following compatible strings : +.Pp +.Bl -bullet -compact +.It +allwinner,sun4i-a10-mmc +.It +allwinner,sun5i-a13-mmc +.It +allwinner,sun7i-a20-mmc +.It +allwinner,sun50i-a64-mmc +.El +.Sh SYSCTL VARIABLES +The following read-only variables are available via +.Xr sysctl 8 : +.Bl -tag -width indent +.It Va dev.aw_mmc.req_timeout +Request timeout in seconds (default: 10) . +.El +.Sh SEE ALSO +.Xr fdt 4 , +.Xr mmc 4 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 10.0 . +.Sh AUTHORS +The +.Nm +device driver was originally written by +.An Alexander Fedorov Aq Mt alexander.fedorov@rtlservice.com . +Later work and this manual page was done by +.An Emmanuel Vadot Aq Mt manu@freebsd.org . Property changes on: head/share/man/man4/aw_mmc.4 ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/arm/allwinner/a10_mmc.c =================================================================== --- head/sys/arm/allwinner/a10_mmc.c (revision 327197) +++ head/sys/arm/allwinner/a10_mmc.c (nonexistent) @@ -1,922 +0,0 @@ -/*- - * Copyright (c) 2013 Alexander Fedorov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#define A10_MMC_MEMRES 0 -#define A10_MMC_IRQRES 1 -#define A10_MMC_RESSZ 2 -#define A10_MMC_DMA_SEGS ((MAXPHYS / PAGE_SIZE) + 1) -#define A10_MMC_DMA_MAX_SIZE 0x2000 -#define A10_MMC_DMA_FTRGLEVEL 0x20070008 -#define A10_MMC_RESET_RETRY 1000 - -#define CARD_ID_FREQUENCY 400000 - -static struct ofw_compat_data compat_data[] = { - {"allwinner,sun4i-a10-mmc", 1}, - {"allwinner,sun5i-a13-mmc", 1}, - {"allwinner,sun7i-a20-mmc", 1}, - {"allwinner,sun50i-a64-mmc", 1}, - {NULL, 0} -}; - -struct a10_mmc_softc { - device_t a10_dev; - clk_t a10_clk_ahb; - clk_t a10_clk_mmc; - hwreset_t a10_rst_ahb; - int a10_bus_busy; - int a10_resid; - int a10_timeout; - struct callout a10_timeoutc; - struct mmc_host a10_host; - struct mmc_request * a10_req; - struct mtx a10_mtx; - struct resource * a10_res[A10_MMC_RESSZ]; - uint32_t a10_intr; - uint32_t a10_intr_wait; - void * a10_intrhand; - - /* Fields required for DMA access. */ - bus_addr_t a10_dma_desc_phys; - bus_dmamap_t a10_dma_map; - bus_dma_tag_t a10_dma_tag; - void * a10_dma_desc; - bus_dmamap_t a10_dma_buf_map; - bus_dma_tag_t a10_dma_buf_tag; - int a10_dma_map_err; -}; - -static struct resource_spec a10_mmc_res_spec[] = { - { SYS_RES_MEMORY, 0, RF_ACTIVE }, - { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE }, - { -1, 0, 0 } -}; - -static int a10_mmc_probe(device_t); -static int a10_mmc_attach(device_t); -static int a10_mmc_detach(device_t); -static int a10_mmc_setup_dma(struct a10_mmc_softc *); -static int a10_mmc_reset(struct a10_mmc_softc *); -static void a10_mmc_intr(void *); -static int a10_mmc_update_clock(struct a10_mmc_softc *, uint32_t); - -static int a10_mmc_update_ios(device_t, device_t); -static int a10_mmc_request(device_t, device_t, struct mmc_request *); -static int a10_mmc_get_ro(device_t, device_t); -static int a10_mmc_acquire_host(device_t, device_t); -static int a10_mmc_release_host(device_t, device_t); - -#define A10_MMC_LOCK(_sc) mtx_lock(&(_sc)->a10_mtx) -#define A10_MMC_UNLOCK(_sc) mtx_unlock(&(_sc)->a10_mtx) -#define A10_MMC_READ_4(_sc, _reg) \ - bus_read_4((_sc)->a10_res[A10_MMC_MEMRES], _reg) -#define A10_MMC_WRITE_4(_sc, _reg, _value) \ - bus_write_4((_sc)->a10_res[A10_MMC_MEMRES], _reg, _value) - -static int -a10_mmc_probe(device_t dev) -{ - - if (!ofw_bus_status_okay(dev)) - return (ENXIO); - if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) - return (ENXIO); - - device_set_desc(dev, "Allwinner Integrated MMC/SD controller"); - - return (BUS_PROBE_DEFAULT); -} - -static int -a10_mmc_attach(device_t dev) -{ - device_t child; - struct a10_mmc_softc *sc; - struct sysctl_ctx_list *ctx; - struct sysctl_oid_list *tree; - uint32_t bus_width; - phandle_t node; - int error; - - node = ofw_bus_get_node(dev); - sc = device_get_softc(dev); - sc->a10_dev = dev; - sc->a10_req = NULL; - if (bus_alloc_resources(dev, a10_mmc_res_spec, sc->a10_res) != 0) { - device_printf(dev, "cannot allocate device resources\n"); - return (ENXIO); - } - if (bus_setup_intr(dev, sc->a10_res[A10_MMC_IRQRES], - INTR_TYPE_MISC | INTR_MPSAFE, NULL, a10_mmc_intr, sc, - &sc->a10_intrhand)) { - bus_release_resources(dev, a10_mmc_res_spec, sc->a10_res); - device_printf(dev, "cannot setup interrupt handler\n"); - return (ENXIO); - } - mtx_init(&sc->a10_mtx, device_get_nameunit(sc->a10_dev), "a10_mmc", - MTX_DEF); - callout_init_mtx(&sc->a10_timeoutc, &sc->a10_mtx, 0); - - /* De-assert reset */ - if (hwreset_get_by_ofw_name(dev, 0, "ahb", &sc->a10_rst_ahb) == 0) { - error = hwreset_deassert(sc->a10_rst_ahb); - if (error != 0) { - device_printf(dev, "cannot de-assert reset\n"); - goto fail; - } - } - - /* Activate the module clock. */ - error = clk_get_by_ofw_name(dev, 0, "ahb", &sc->a10_clk_ahb); - if (error != 0) { - device_printf(dev, "cannot get ahb clock\n"); - goto fail; - } - error = clk_enable(sc->a10_clk_ahb); - if (error != 0) { - device_printf(dev, "cannot enable ahb clock\n"); - goto fail; - } - error = clk_get_by_ofw_name(dev, 0, "mmc", &sc->a10_clk_mmc); - if (error != 0) { - device_printf(dev, "cannot get mmc clock\n"); - goto fail; - } - error = clk_set_freq(sc->a10_clk_mmc, CARD_ID_FREQUENCY, - CLK_SET_ROUND_DOWN); - if (error != 0) { - device_printf(dev, "cannot init mmc clock\n"); - goto fail; - } - error = clk_enable(sc->a10_clk_mmc); - if (error != 0) { - device_printf(dev, "cannot enable mmc clock\n"); - goto fail; - } - - sc->a10_timeout = 10; - ctx = device_get_sysctl_ctx(dev); - tree = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); - SYSCTL_ADD_INT(ctx, tree, OID_AUTO, "req_timeout", CTLFLAG_RW, - &sc->a10_timeout, 0, "Request timeout in seconds"); - - /* Hardware reset */ - A10_MMC_WRITE_4(sc, A10_MMC_HWRST, 1); - DELAY(100); - A10_MMC_WRITE_4(sc, A10_MMC_HWRST, 0); - DELAY(500); - - /* Soft Reset controller. */ - if (a10_mmc_reset(sc) != 0) { - device_printf(dev, "cannot reset the controller\n"); - goto fail; - } - - if (a10_mmc_setup_dma(sc) != 0) { - device_printf(sc->a10_dev, "Couldn't setup DMA!\n"); - goto fail; - } - - if (OF_getencprop(node, "bus-width", &bus_width, sizeof(uint32_t)) <= 0) - bus_width = 4; - - sc->a10_host.f_min = 400000; - sc->a10_host.f_max = 52000000; - sc->a10_host.host_ocr = MMC_OCR_320_330 | MMC_OCR_330_340; - sc->a10_host.mode = mode_sd; - sc->a10_host.caps = MMC_CAP_HSPEED; - if (bus_width >= 4) - sc->a10_host.caps |= MMC_CAP_4_BIT_DATA; - if (bus_width >= 8) - sc->a10_host.caps |= MMC_CAP_8_BIT_DATA; - - child = device_add_child(dev, "mmc", -1); - if (child == NULL) { - device_printf(dev, "attaching MMC bus failed!\n"); - goto fail; - } - if (device_probe_and_attach(child) != 0) { - device_printf(dev, "attaching MMC child failed!\n"); - device_delete_child(dev, child); - goto fail; - } - - return (0); - -fail: - callout_drain(&sc->a10_timeoutc); - mtx_destroy(&sc->a10_mtx); - bus_teardown_intr(dev, sc->a10_res[A10_MMC_IRQRES], sc->a10_intrhand); - bus_release_resources(dev, a10_mmc_res_spec, sc->a10_res); - - return (ENXIO); -} - -static int -a10_mmc_detach(device_t dev) -{ - - return (EBUSY); -} - -static void -a10_dma_desc_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int err) -{ - struct a10_mmc_softc *sc; - - sc = (struct a10_mmc_softc *)arg; - if (err) { - sc->a10_dma_map_err = err; - return; - } - sc->a10_dma_desc_phys = segs[0].ds_addr; -} - -static int -a10_mmc_setup_dma(struct a10_mmc_softc *sc) -{ - int dma_desc_size, error; - - /* Allocate the DMA descriptor memory. */ - dma_desc_size = sizeof(struct a10_mmc_dma_desc) * A10_MMC_DMA_SEGS; - error = bus_dma_tag_create(bus_get_dma_tag(sc->a10_dev), - A10_MMC_DMA_ALIGN, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - dma_desc_size, 1, dma_desc_size, 0, NULL, NULL, &sc->a10_dma_tag); - if (error) - return (error); - error = bus_dmamem_alloc(sc->a10_dma_tag, &sc->a10_dma_desc, - BUS_DMA_WAITOK | BUS_DMA_ZERO, &sc->a10_dma_map); - if (error) - return (error); - - error = bus_dmamap_load(sc->a10_dma_tag, sc->a10_dma_map, - sc->a10_dma_desc, dma_desc_size, a10_dma_desc_cb, sc, 0); - if (error) - return (error); - if (sc->a10_dma_map_err) - return (sc->a10_dma_map_err); - - /* Create the DMA map for data transfers. */ - error = bus_dma_tag_create(bus_get_dma_tag(sc->a10_dev), - A10_MMC_DMA_ALIGN, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - A10_MMC_DMA_MAX_SIZE * A10_MMC_DMA_SEGS, A10_MMC_DMA_SEGS, - A10_MMC_DMA_MAX_SIZE, BUS_DMA_ALLOCNOW, NULL, NULL, - &sc->a10_dma_buf_tag); - if (error) - return (error); - error = bus_dmamap_create(sc->a10_dma_buf_tag, 0, - &sc->a10_dma_buf_map); - if (error) - return (error); - - return (0); -} - -static void -a10_dma_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int err) -{ - int i; - struct a10_mmc_dma_desc *dma_desc; - struct a10_mmc_softc *sc; - - sc = (struct a10_mmc_softc *)arg; - sc->a10_dma_map_err = err; - - if (err) - return; - - dma_desc = sc->a10_dma_desc; - for (i = 0; i < nsegs; i++) { - dma_desc[i].buf_size = segs[i].ds_len; - dma_desc[i].buf_addr = segs[i].ds_addr; - dma_desc[i].config = A10_MMC_DMA_CONFIG_CH | - A10_MMC_DMA_CONFIG_OWN; - if (i == 0) - dma_desc[i].config |= A10_MMC_DMA_CONFIG_FD; - if (i < (nsegs - 1)) { - dma_desc[i].config |= A10_MMC_DMA_CONFIG_DIC; - dma_desc[i].next = sc->a10_dma_desc_phys + - ((i + 1) * sizeof(struct a10_mmc_dma_desc)); - } else { - dma_desc[i].config |= A10_MMC_DMA_CONFIG_LD | - A10_MMC_DMA_CONFIG_ER; - dma_desc[i].next = 0; - } - } -} - -static int -a10_mmc_prepare_dma(struct a10_mmc_softc *sc) -{ - bus_dmasync_op_t sync_op; - int error; - struct mmc_command *cmd; - uint32_t val; - - cmd = sc->a10_req->cmd; - if (cmd->data->len > A10_MMC_DMA_MAX_SIZE * A10_MMC_DMA_SEGS) - return (EFBIG); - error = bus_dmamap_load(sc->a10_dma_buf_tag, sc->a10_dma_buf_map, - cmd->data->data, cmd->data->len, a10_dma_cb, sc, 0); - if (error) - return (error); - if (sc->a10_dma_map_err) - return (sc->a10_dma_map_err); - - if (cmd->data->flags & MMC_DATA_WRITE) - sync_op = BUS_DMASYNC_PREWRITE; - else - sync_op = BUS_DMASYNC_PREREAD; - bus_dmamap_sync(sc->a10_dma_buf_tag, sc->a10_dma_buf_map, sync_op); - bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE); - - /* Enable DMA */ - val = A10_MMC_READ_4(sc, A10_MMC_GCTL); - val &= ~A10_MMC_CTRL_FIFO_AC_MOD; - val |= A10_MMC_CTRL_DMA_ENB; - A10_MMC_WRITE_4(sc, A10_MMC_GCTL, val); - - /* Reset DMA */ - val |= A10_MMC_CTRL_DMA_RST; - A10_MMC_WRITE_4(sc, A10_MMC_GCTL, val); - - A10_MMC_WRITE_4(sc, A10_MMC_DMAC, A10_MMC_DMAC_IDMAC_SOFT_RST); - A10_MMC_WRITE_4(sc, A10_MMC_DMAC, - A10_MMC_DMAC_IDMAC_IDMA_ON | A10_MMC_DMAC_IDMAC_FIX_BURST); - - /* Enable RX or TX DMA interrupt */ - if (cmd->data->flags & MMC_DATA_WRITE) - val |= A10_MMC_IDST_TX_INT; - else - val |= A10_MMC_IDST_RX_INT; - A10_MMC_WRITE_4(sc, A10_MMC_IDIE, val); - - /* Set DMA descritptor list address */ - A10_MMC_WRITE_4(sc, A10_MMC_DLBA, sc->a10_dma_desc_phys); - - /* FIFO trigger level */ - A10_MMC_WRITE_4(sc, A10_MMC_FWLR, A10_MMC_DMA_FTRGLEVEL); - - return (0); -} - -static int -a10_mmc_reset(struct a10_mmc_softc *sc) -{ - int timeout; - - A10_MMC_WRITE_4(sc, A10_MMC_GCTL, A10_MMC_RESET); - timeout = 1000; - while (--timeout > 0) { - if ((A10_MMC_READ_4(sc, A10_MMC_GCTL) & A10_MMC_RESET) == 0) - break; - DELAY(100); - } - if (timeout == 0) - return (ETIMEDOUT); - - /* Set the timeout. */ - A10_MMC_WRITE_4(sc, A10_MMC_TMOR, - A10_MMC_TMOR_DTO_LMT_SHIFT(A10_MMC_TMOR_DTO_LMT_MASK) | - A10_MMC_TMOR_RTO_LMT_SHIFT(A10_MMC_TMOR_RTO_LMT_MASK)); - - /* Clear pending interrupts. */ - A10_MMC_WRITE_4(sc, A10_MMC_RISR, 0xffffffff); - A10_MMC_WRITE_4(sc, A10_MMC_IDST, 0xffffffff); - /* Unmask interrupts. */ - A10_MMC_WRITE_4(sc, A10_MMC_IMKR, - A10_MMC_INT_CMD_DONE | A10_MMC_INT_ERR_BIT | - A10_MMC_INT_DATA_OVER | A10_MMC_INT_AUTO_STOP_DONE); - /* Enable interrupts and AHB access. */ - A10_MMC_WRITE_4(sc, A10_MMC_GCTL, - A10_MMC_READ_4(sc, A10_MMC_GCTL) | A10_MMC_CTRL_INT_ENB); - - return (0); -} - -static void -a10_mmc_req_done(struct a10_mmc_softc *sc) -{ - struct mmc_command *cmd; - struct mmc_request *req; - uint32_t val, mask; - int retry; - - cmd = sc->a10_req->cmd; - if (cmd->error != MMC_ERR_NONE) { - /* Reset the FIFO and DMA engines. */ - mask = A10_MMC_CTRL_FIFO_RST | A10_MMC_CTRL_DMA_RST; - val = A10_MMC_READ_4(sc, A10_MMC_GCTL); - A10_MMC_WRITE_4(sc, A10_MMC_GCTL, val | mask); - - retry = A10_MMC_RESET_RETRY; - while (--retry > 0) { - val = A10_MMC_READ_4(sc, A10_MMC_GCTL); - if ((val & mask) == 0) - break; - DELAY(10); - } - if (retry == 0) - device_printf(sc->a10_dev, - "timeout resetting DMA/FIFO\n"); - a10_mmc_update_clock(sc, 1); - } - - req = sc->a10_req; - callout_stop(&sc->a10_timeoutc); - sc->a10_req = NULL; - sc->a10_intr = 0; - sc->a10_resid = 0; - sc->a10_dma_map_err = 0; - sc->a10_intr_wait = 0; - req->done(req); -} - -static void -a10_mmc_req_ok(struct a10_mmc_softc *sc) -{ - int timeout; - struct mmc_command *cmd; - uint32_t status; - - timeout = 1000; - while (--timeout > 0) { - status = A10_MMC_READ_4(sc, A10_MMC_STAR); - if ((status & A10_MMC_STAR_CARD_BUSY) == 0) - break; - DELAY(1000); - } - cmd = sc->a10_req->cmd; - if (timeout == 0) { - cmd->error = MMC_ERR_FAILED; - a10_mmc_req_done(sc); - return; - } - if (cmd->flags & MMC_RSP_PRESENT) { - if (cmd->flags & MMC_RSP_136) { - cmd->resp[0] = A10_MMC_READ_4(sc, A10_MMC_RESP3); - cmd->resp[1] = A10_MMC_READ_4(sc, A10_MMC_RESP2); - cmd->resp[2] = A10_MMC_READ_4(sc, A10_MMC_RESP1); - cmd->resp[3] = A10_MMC_READ_4(sc, A10_MMC_RESP0); - } else - cmd->resp[0] = A10_MMC_READ_4(sc, A10_MMC_RESP0); - } - /* All data has been transferred ? */ - if (cmd->data != NULL && (sc->a10_resid << 2) < cmd->data->len) - cmd->error = MMC_ERR_FAILED; - a10_mmc_req_done(sc); -} - -static void -a10_mmc_timeout(void *arg) -{ - struct a10_mmc_softc *sc; - - sc = (struct a10_mmc_softc *)arg; - if (sc->a10_req != NULL) { - device_printf(sc->a10_dev, "controller timeout\n"); - sc->a10_req->cmd->error = MMC_ERR_TIMEOUT; - a10_mmc_req_done(sc); - } else - device_printf(sc->a10_dev, - "Spurious timeout - no active request\n"); -} - -static void -a10_mmc_intr(void *arg) -{ - bus_dmasync_op_t sync_op; - struct a10_mmc_softc *sc; - struct mmc_data *data; - uint32_t idst, imask, rint; - - sc = (struct a10_mmc_softc *)arg; - A10_MMC_LOCK(sc); - rint = A10_MMC_READ_4(sc, A10_MMC_RISR); - idst = A10_MMC_READ_4(sc, A10_MMC_IDST); - imask = A10_MMC_READ_4(sc, A10_MMC_IMKR); - if (idst == 0 && imask == 0 && rint == 0) { - A10_MMC_UNLOCK(sc); - return; - } -#ifdef DEBUG - device_printf(sc->a10_dev, "idst: %#x, imask: %#x, rint: %#x\n", - idst, imask, rint); -#endif - if (sc->a10_req == NULL) { - device_printf(sc->a10_dev, - "Spurious interrupt - no active request, rint: 0x%08X\n", - rint); - goto end; - } - if (rint & A10_MMC_INT_ERR_BIT) { - device_printf(sc->a10_dev, "error rint: 0x%08X\n", rint); - if (rint & A10_MMC_INT_RESP_TIMEOUT) - sc->a10_req->cmd->error = MMC_ERR_TIMEOUT; - else - sc->a10_req->cmd->error = MMC_ERR_FAILED; - a10_mmc_req_done(sc); - goto end; - } - if (idst & A10_MMC_IDST_ERROR) { - device_printf(sc->a10_dev, "error idst: 0x%08x\n", idst); - sc->a10_req->cmd->error = MMC_ERR_FAILED; - a10_mmc_req_done(sc); - goto end; - } - - sc->a10_intr |= rint; - data = sc->a10_req->cmd->data; - if (data != NULL && (idst & A10_MMC_IDST_COMPLETE) != 0) { - if (data->flags & MMC_DATA_WRITE) - sync_op = BUS_DMASYNC_POSTWRITE; - else - sync_op = BUS_DMASYNC_POSTREAD; - bus_dmamap_sync(sc->a10_dma_buf_tag, sc->a10_dma_buf_map, - sync_op); - bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, - BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(sc->a10_dma_buf_tag, sc->a10_dma_buf_map); - sc->a10_resid = data->len >> 2; - } - if ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait) - a10_mmc_req_ok(sc); - -end: - A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst); - A10_MMC_WRITE_4(sc, A10_MMC_RISR, rint); - A10_MMC_UNLOCK(sc); -} - -static int -a10_mmc_request(device_t bus, device_t child, struct mmc_request *req) -{ - int blksz; - struct a10_mmc_softc *sc; - struct mmc_command *cmd; - uint32_t cmdreg; - int err; - - sc = device_get_softc(bus); - A10_MMC_LOCK(sc); - if (sc->a10_req) { - A10_MMC_UNLOCK(sc); - return (EBUSY); - } - sc->a10_req = req; - cmd = req->cmd; - cmdreg = A10_MMC_CMDR_LOAD; - if (cmd->opcode == MMC_GO_IDLE_STATE) - cmdreg |= A10_MMC_CMDR_SEND_INIT_SEQ; - if (cmd->flags & MMC_RSP_PRESENT) - cmdreg |= A10_MMC_CMDR_RESP_RCV; - if (cmd->flags & MMC_RSP_136) - cmdreg |= A10_MMC_CMDR_LONG_RESP; - if (cmd->flags & MMC_RSP_CRC) - cmdreg |= A10_MMC_CMDR_CHK_RESP_CRC; - - sc->a10_intr = 0; - sc->a10_resid = 0; - sc->a10_intr_wait = A10_MMC_INT_CMD_DONE; - cmd->error = MMC_ERR_NONE; - if (cmd->data != NULL) { - sc->a10_intr_wait |= A10_MMC_INT_DATA_OVER; - cmdreg |= A10_MMC_CMDR_DATA_TRANS | A10_MMC_CMDR_WAIT_PRE_OVER; - if (cmd->data->flags & MMC_DATA_MULTI) { - cmdreg |= A10_MMC_CMDR_STOP_CMD_FLAG; - sc->a10_intr_wait |= A10_MMC_INT_AUTO_STOP_DONE; - } - if (cmd->data->flags & MMC_DATA_WRITE) - cmdreg |= A10_MMC_CMDR_DIR_WRITE; - blksz = min(cmd->data->len, MMC_SECTOR_SIZE); - A10_MMC_WRITE_4(sc, A10_MMC_BKSR, blksz); - A10_MMC_WRITE_4(sc, A10_MMC_BYCR, cmd->data->len); - - err = a10_mmc_prepare_dma(sc); - if (err != 0) - device_printf(sc->a10_dev, "prepare_dma failed: %d\n", err); - } - - A10_MMC_WRITE_4(sc, A10_MMC_CAGR, cmd->arg); - A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode); - callout_reset(&sc->a10_timeoutc, sc->a10_timeout * hz, - a10_mmc_timeout, sc); - A10_MMC_UNLOCK(sc); - - return (0); -} - -static int -a10_mmc_read_ivar(device_t bus, device_t child, int which, - uintptr_t *result) -{ - struct a10_mmc_softc *sc; - - sc = device_get_softc(bus); - switch (which) { - default: - return (EINVAL); - case MMCBR_IVAR_BUS_MODE: - *(int *)result = sc->a10_host.ios.bus_mode; - break; - case MMCBR_IVAR_BUS_WIDTH: - *(int *)result = sc->a10_host.ios.bus_width; - break; - case MMCBR_IVAR_CHIP_SELECT: - *(int *)result = sc->a10_host.ios.chip_select; - break; - case MMCBR_IVAR_CLOCK: - *(int *)result = sc->a10_host.ios.clock; - break; - case MMCBR_IVAR_F_MIN: - *(int *)result = sc->a10_host.f_min; - break; - case MMCBR_IVAR_F_MAX: - *(int *)result = sc->a10_host.f_max; - break; - case MMCBR_IVAR_HOST_OCR: - *(int *)result = sc->a10_host.host_ocr; - break; - case MMCBR_IVAR_MODE: - *(int *)result = sc->a10_host.mode; - break; - case MMCBR_IVAR_OCR: - *(int *)result = sc->a10_host.ocr; - break; - case MMCBR_IVAR_POWER_MODE: - *(int *)result = sc->a10_host.ios.power_mode; - break; - case MMCBR_IVAR_VDD: - *(int *)result = sc->a10_host.ios.vdd; - break; - case MMCBR_IVAR_CAPS: - *(int *)result = sc->a10_host.caps; - break; - case MMCBR_IVAR_MAX_DATA: - *(int *)result = 65535; - break; - } - - return (0); -} - -static int -a10_mmc_write_ivar(device_t bus, device_t child, int which, - uintptr_t value) -{ - struct a10_mmc_softc *sc; - - sc = device_get_softc(bus); - switch (which) { - default: - return (EINVAL); - case MMCBR_IVAR_BUS_MODE: - sc->a10_host.ios.bus_mode = value; - break; - case MMCBR_IVAR_BUS_WIDTH: - sc->a10_host.ios.bus_width = value; - break; - case MMCBR_IVAR_CHIP_SELECT: - sc->a10_host.ios.chip_select = value; - break; - case MMCBR_IVAR_CLOCK: - sc->a10_host.ios.clock = value; - break; - case MMCBR_IVAR_MODE: - sc->a10_host.mode = value; - break; - case MMCBR_IVAR_OCR: - sc->a10_host.ocr = value; - break; - case MMCBR_IVAR_POWER_MODE: - sc->a10_host.ios.power_mode = value; - break; - case MMCBR_IVAR_VDD: - sc->a10_host.ios.vdd = value; - break; - /* These are read-only */ - case MMCBR_IVAR_CAPS: - case MMCBR_IVAR_HOST_OCR: - case MMCBR_IVAR_F_MIN: - case MMCBR_IVAR_F_MAX: - case MMCBR_IVAR_MAX_DATA: - return (EINVAL); - } - - return (0); -} - -static int -a10_mmc_update_clock(struct a10_mmc_softc *sc, uint32_t clkon) -{ - uint32_t cmdreg; - int retry; - uint32_t ckcr; - - ckcr = A10_MMC_READ_4(sc, A10_MMC_CKCR); - ckcr &= ~(A10_MMC_CKCR_CCLK_ENB | A10_MMC_CKCR_CCLK_CTRL); - - if (clkon) - ckcr |= A10_MMC_CKCR_CCLK_ENB; - - A10_MMC_WRITE_4(sc, A10_MMC_CKCR, ckcr); - - cmdreg = A10_MMC_CMDR_LOAD | A10_MMC_CMDR_PRG_CLK | - A10_MMC_CMDR_WAIT_PRE_OVER; - A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg); - retry = 0xfffff; - while (--retry > 0) { - if ((A10_MMC_READ_4(sc, A10_MMC_CMDR) & A10_MMC_CMDR_LOAD) == 0) { - A10_MMC_WRITE_4(sc, A10_MMC_RISR, 0xffffffff); - return (0); - } - DELAY(10); - } - A10_MMC_WRITE_4(sc, A10_MMC_RISR, 0xffffffff); - device_printf(sc->a10_dev, "timeout updating clock\n"); - - return (ETIMEDOUT); -} - -static int -a10_mmc_update_ios(device_t bus, device_t child) -{ - int error; - struct a10_mmc_softc *sc; - struct mmc_ios *ios; - uint32_t ckcr; - - sc = device_get_softc(bus); - - ios = &sc->a10_host.ios; - - /* Set the bus width. */ - switch (ios->bus_width) { - case bus_width_1: - A10_MMC_WRITE_4(sc, A10_MMC_BWDR, A10_MMC_BWDR1); - break; - case bus_width_4: - A10_MMC_WRITE_4(sc, A10_MMC_BWDR, A10_MMC_BWDR4); - break; - case bus_width_8: - A10_MMC_WRITE_4(sc, A10_MMC_BWDR, A10_MMC_BWDR8); - break; - } - - if (ios->clock) { - - /* Disable clock */ - error = a10_mmc_update_clock(sc, 0); - if (error != 0) - return (error); - - /* Reset the divider. */ - ckcr = A10_MMC_READ_4(sc, A10_MMC_CKCR); - ckcr &= ~A10_MMC_CKCR_CCLK_DIV; - A10_MMC_WRITE_4(sc, A10_MMC_CKCR, ckcr); - - /* Set the MMC clock. */ - error = clk_set_freq(sc->a10_clk_mmc, ios->clock, - CLK_SET_ROUND_DOWN); - if (error != 0) { - device_printf(sc->a10_dev, - "failed to set frequency to %u Hz: %d\n", - ios->clock, error); - return (error); - } - - /* Enable clock. */ - error = a10_mmc_update_clock(sc, 1); - if (error != 0) - return (error); - } - - - return (0); -} - -static int -a10_mmc_get_ro(device_t bus, device_t child) -{ - - return (0); -} - -static int -a10_mmc_acquire_host(device_t bus, device_t child) -{ - struct a10_mmc_softc *sc; - int error; - - sc = device_get_softc(bus); - A10_MMC_LOCK(sc); - while (sc->a10_bus_busy) { - error = msleep(sc, &sc->a10_mtx, PCATCH, "mmchw", 0); - if (error != 0) { - A10_MMC_UNLOCK(sc); - return (error); - } - } - sc->a10_bus_busy++; - A10_MMC_UNLOCK(sc); - - return (0); -} - -static int -a10_mmc_release_host(device_t bus, device_t child) -{ - struct a10_mmc_softc *sc; - - sc = device_get_softc(bus); - A10_MMC_LOCK(sc); - sc->a10_bus_busy--; - wakeup(sc); - A10_MMC_UNLOCK(sc); - - return (0); -} - -static device_method_t a10_mmc_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, a10_mmc_probe), - DEVMETHOD(device_attach, a10_mmc_attach), - DEVMETHOD(device_detach, a10_mmc_detach), - - /* Bus interface */ - DEVMETHOD(bus_read_ivar, a10_mmc_read_ivar), - DEVMETHOD(bus_write_ivar, a10_mmc_write_ivar), - - /* MMC bridge interface */ - DEVMETHOD(mmcbr_update_ios, a10_mmc_update_ios), - DEVMETHOD(mmcbr_request, a10_mmc_request), - DEVMETHOD(mmcbr_get_ro, a10_mmc_get_ro), - DEVMETHOD(mmcbr_acquire_host, a10_mmc_acquire_host), - DEVMETHOD(mmcbr_release_host, a10_mmc_release_host), - - DEVMETHOD_END -}; - -static devclass_t a10_mmc_devclass; - -static driver_t a10_mmc_driver = { - "a10_mmc", - a10_mmc_methods, - sizeof(struct a10_mmc_softc), -}; - -DRIVER_MODULE(a10_mmc, simplebus, a10_mmc_driver, a10_mmc_devclass, NULL, - NULL); -MMC_DECLARE_BRIDGE(a10_mmc); Property changes on: head/sys/arm/allwinner/a10_mmc.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/sys/arm/allwinner/a10_mmc.h =================================================================== --- head/sys/arm/allwinner/a10_mmc.h (revision 327197) +++ head/sys/arm/allwinner/a10_mmc.h (nonexistent) @@ -1,204 +0,0 @@ -/*- - * Copyright (c) 2013 Alexander Fedorov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _A10_MMC_H_ -#define _A10_MMC_H_ - -#define A10_MMC_GCTL 0x00 /* Control Register */ -#define A10_MMC_CKCR 0x04 /* Clock Control Register */ -#define A10_MMC_TMOR 0x08 /* Timeout Register */ -#define A10_MMC_BWDR 0x0C /* Bus Width Register */ -#define A10_MMC_BKSR 0x10 /* Block Size Register */ -#define A10_MMC_BYCR 0x14 /* Byte Count Register */ -#define A10_MMC_CMDR 0x18 /* Command Register */ -#define A10_MMC_CAGR 0x1C /* Argument Register */ -#define A10_MMC_RESP0 0x20 /* Response Register 0 */ -#define A10_MMC_RESP1 0x24 /* Response Register 1 */ -#define A10_MMC_RESP2 0x28 /* Response Register 2 */ -#define A10_MMC_RESP3 0x2C /* Response Register 3 */ -#define A10_MMC_IMKR 0x30 /* Interrupt Mask Register */ -#define A10_MMC_MISR 0x34 /* Masked Interrupt Status Register */ -#define A10_MMC_RISR 0x38 /* Raw Interrupt Status Register */ -#define A10_MMC_STAR 0x3C /* Status Register */ -#define A10_MMC_FWLR 0x40 /* FIFO Threshold Watermark Register */ -#define A10_MMC_FUNS 0x44 /* Function Select Register */ -#define A10_MMC_HWRST 0x78 /* Hardware reset (not documented) */ -#define A10_MMC_DMAC 0x80 /* IDMAC Control Register */ -#define A10_MMC_DLBA 0x84 /* IDMAC Desc List Base Address Reg */ -#define A10_MMC_IDST 0x88 /* IDMAC Status Register */ -#define A10_MMC_IDIE 0x8C /* IDMAC Interrupt Enable Register */ -#define A10_MMC_FIFO 0x100 /* FIFO Access Address (A10/A20) */ -#define A31_MMC_FIFO 0x200 /* FIFO Access Address (A31) */ - -/* A10_MMC_GCTL */ -#define A10_MMC_CTRL_SOFT_RST (1U << 0) -#define A10_MMC_CTRL_FIFO_RST (1U << 1) -#define A10_MMC_CTRL_DMA_RST (1U << 2) -#define A10_MMC_CTRL_INT_ENB (1U << 4) -#define A10_MMC_CTRL_DMA_ENB (1U << 5) -#define A10_MMC_CTRL_CD_DBC_ENB (1U << 8) -#define A10_MMC_CTRL_DDR_MOD_SEL (1U << 10) -#define A10_MMC_CTRL_FIFO_AC_MOD (1U << 31) -#define A10_MMC_RESET \ - (A10_MMC_CTRL_SOFT_RST | A10_MMC_CTRL_FIFO_RST | A10_MMC_CTRL_DMA_RST) - -/* A10_MMC_CKCR */ -#define A10_MMC_CKCR_CCLK_ENB (1U << 16) -#define A10_MMC_CKCR_CCLK_CTRL (1U << 17) -#define A10_MMC_CKCR_CCLK_DIV 0xff - -/* A10_MMC_TMOR */ -#define A10_MMC_TMOR_RTO_LMT_SHIFT(x) x /* Response timeout limit */ -#define A10_MMC_TMOR_RTO_LMT_MASK 0xff -#define A10_MMC_TMOR_DTO_LMT_SHIFT(x) (x << 8) /* Data timeout limit */ -#define A10_MMC_TMOR_DTO_LMT_MASK 0xffffff - -/* A10_MMC_BWDR */ -#define A10_MMC_BWDR1 0 -#define A10_MMC_BWDR4 1 -#define A10_MMC_BWDR8 2 - -/* A10_MMC_CMDR */ -#define A10_MMC_CMDR_RESP_RCV (1U << 6) -#define A10_MMC_CMDR_LONG_RESP (1U << 7) -#define A10_MMC_CMDR_CHK_RESP_CRC (1U << 8) -#define A10_MMC_CMDR_DATA_TRANS (1U << 9) -#define A10_MMC_CMDR_DIR_WRITE (1U << 10) -#define A10_MMC_CMDR_TRANS_MODE_STREAM (1U << 11) -#define A10_MMC_CMDR_STOP_CMD_FLAG (1U << 12) -#define A10_MMC_CMDR_WAIT_PRE_OVER (1U << 13) -#define A10_MMC_CMDR_STOP_ABT_CMD (1U << 14) -#define A10_MMC_CMDR_SEND_INIT_SEQ (1U << 15) -#define A10_MMC_CMDR_PRG_CLK (1U << 21) -#define A10_MMC_CMDR_RD_CEDATA_DEV (1U << 22) -#define A10_MMC_CMDR_CCS_EXP (1U << 23) -#define A10_MMC_CMDR_BOOT_MOD_SHIFT 24 -#define A10_MMC_CMDR_BOOT_MOD_NORMAL 0 -#define A10_MMC_CMDR_BOOT_MOD_MANDATORY 1 -#define A10_MMC_CMDR_BOOT_MOD_ALT 2 -#define A10_MMC_CMDR_EXP_BOOT_ACK (1U << 26) -#define A10_MMC_CMDR_BOOT_ABT (1U << 27) -#define A10_MMC_CMDR_VOL_SW (1U << 28) -#define A10_MMC_CMDR_LOAD (1U << 31) - -/* A10_MMC_IMKR and A10_MMC_RISR */ -#define A10_MMC_INT_RESP_ERR (1U << 1) -#define A10_MMC_INT_CMD_DONE (1U << 2) -#define A10_MMC_INT_DATA_OVER (1U << 3) -#define A10_MMC_INT_TX_DATA_REQ (1U << 4) -#define A10_MMC_INT_RX_DATA_REQ (1U << 5) -#define A10_MMC_INT_RESP_CRC_ERR (1U << 6) -#define A10_MMC_INT_DATA_CRC_ERR (1U << 7) -#define A10_MMC_INT_RESP_TIMEOUT (1U << 8) -#define A10_MMC_INT_BOOT_ACK_RECV (1U << 8) -#define A10_MMC_INT_DATA_TIMEOUT (1U << 9) -#define A10_MMC_INT_BOOT_START (1U << 9) -#define A10_MMC_INT_DATA_STARVE (1U << 10) -#define A10_MMC_INT_VOL_CHG_DONE (1U << 10) -#define A10_MMC_INT_FIFO_RUN_ERR (1U << 11) -#define A10_MMC_INT_CMD_BUSY (1U << 12) -#define A10_MMC_INT_DATA_START_ERR (1U << 13) -#define A10_MMC_INT_AUTO_STOP_DONE (1U << 14) -#define A10_MMC_INT_DATA_END_BIT_ERR (1U << 15) -#define A10_MMC_INT_SDIO (1U << 16) -#define A10_MMC_INT_CARD_INSERT (1U << 30) -#define A10_MMC_INT_CARD_REMOVE (1U << 31) -#define A10_MMC_INT_ERR_BIT \ - (A10_MMC_INT_RESP_ERR | A10_MMC_INT_RESP_CRC_ERR | \ - A10_MMC_INT_DATA_CRC_ERR | A10_MMC_INT_RESP_TIMEOUT | \ - A10_MMC_INT_FIFO_RUN_ERR | A10_MMC_INT_CMD_BUSY | \ - A10_MMC_INT_DATA_START_ERR | A10_MMC_INT_DATA_END_BIT_ERR) - -/* A10_MMC_STAR */ -#define A10_MMC_STAR_FIFO_RX_LEVEL (1U << 0) -#define A10_MMC_STAR_FIFO_TX_LEVEL (1U << 1) -#define A10_MMC_STAR_FIFO_EMPTY (1U << 2) -#define A10_MMC_STAR_FIFO_FULL (1U << 3) -#define A10_MMC_STAR_CARD_PRESENT (1U << 8) -#define A10_MMC_STAR_CARD_BUSY (1U << 9) -#define A10_MMC_STAR_FSM_BUSY (1U << 10) -#define A10_MMC_STAR_DMA_REQ (1U << 31) - -/* A10_MMC_FUNS */ -#define A10_MMC_CE_ATA_ON (0xceaaU << 16) -#define A10_MMC_SEND_IRQ_RESP (1U << 0) -#define A10_MMC_SDIO_RD_WAIT (1U << 1) -#define A10_MMC_ABT_RD_DATA (1U << 2) -#define A10_MMC_SEND_CC_SD (1U << 8) -#define A10_MMC_SEND_AUTOSTOP_CC_SD (1U << 9) -#define A10_MMC_CE_ATA_DEV_INT_ENB (1U << 10) - -/* IDMA CONTROLLER BUS MOD BIT FIELD */ -#define A10_MMC_DMAC_IDMAC_SOFT_RST (1U << 0) -#define A10_MMC_DMAC_IDMAC_FIX_BURST (1U << 1) -#define A10_MMC_DMAC_IDMAC_IDMA_ON (1U << 7) -#define A10_MMC_DMAC_IDMAC_REFETCH_DES (1U << 31) - -/* A10_MMC_IDST */ -#define A10_MMC_IDST_TX_INT (1U << 0) -#define A10_MMC_IDST_RX_INT (1U << 1) -#define A10_MMC_IDST_FATAL_BERR_INT (1U << 2) -#define A10_MMC_IDST_DES_UNAVL_INT (1U << 4) -#define A10_MMC_IDST_ERR_FLAG_SUM (1U << 5) -#define A10_MMC_IDST_NOR_INT_SUM (1U << 8) -#define A10_MMC_IDST_ABN_INT_SUM (1U << 9) -#define A10_MMC_IDST_HOST_ABT_INTX (1U << 10) -#define A10_MMC_IDST_HOST_ABT_INRX (1U << 10) -#define A10_MMC_IDST_IDLE (0U << 13) -#define A10_MMC_IDST_SUSPEND (1U << 13) -#define A10_MMC_IDST_DESC_RD (2U << 13) -#define A10_MMC_IDST_DESC_CHECK (3U << 13) -#define A10_MMC_IDST_RD_REQ_WAIT (4U << 13) -#define A10_MMC_IDST_WR_REQ_WAIT (5U << 13) -#define A10_MMC_IDST_RD (6U << 13) -#define A10_MMC_IDST_WR (7U << 13) -#define A10_MMC_IDST_DESC_CLOSE (8U << 13) -#define A10_MMC_IDST_ERROR \ - (A10_MMC_IDST_FATAL_BERR_INT | A10_MMC_IDST_ERR_FLAG_SUM | \ - A10_MMC_IDST_DES_UNAVL_INT | A10_MMC_IDST_ABN_INT_SUM) -#define A10_MMC_IDST_COMPLETE \ - (A10_MMC_IDST_TX_INT | A10_MMC_IDST_RX_INT) - -/* The DMA descriptor table. */ -struct a10_mmc_dma_desc { - uint32_t config; -#define A10_MMC_DMA_CONFIG_DIC (1U << 1) /* Disable Interrupt Completion */ -#define A10_MMC_DMA_CONFIG_LD (1U << 2) /* Last DES */ -#define A10_MMC_DMA_CONFIG_FD (1U << 3) /* First DES */ -#define A10_MMC_DMA_CONFIG_CH (1U << 4) /* CHAIN MOD */ -#define A10_MMC_DMA_CONFIG_ER (1U << 5) /* End of Ring (undocumented register) */ -#define A10_MMC_DMA_CONFIG_CES (1U << 30) /* Card Error Summary */ -#define A10_MMC_DMA_CONFIG_OWN (1U << 31) /* DES Own Flag */ - uint32_t buf_size; - uint32_t buf_addr; - uint32_t next; -}; - -#define A10_MMC_DMA_ALIGN 4 - -#endif /* _A10_MMC_H_ */ Property changes on: head/sys/arm/allwinner/a10_mmc.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/sys/arm/allwinner/aw_mmc.c =================================================================== --- head/sys/arm/allwinner/aw_mmc.c (nonexistent) +++ head/sys/arm/allwinner/aw_mmc.c (revision 327198) @@ -0,0 +1,922 @@ +/*- + * Copyright (c) 2013 Alexander Fedorov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#define AW_MMC_MEMRES 0 +#define AW_MMC_IRQRES 1 +#define AW_MMC_RESSZ 2 +#define AW_MMC_DMA_SEGS ((MAXPHYS / PAGE_SIZE) + 1) +#define AW_MMC_DMA_MAX_SIZE 0x2000 +#define AW_MMC_DMA_FTRGLEVEL 0x20070008 +#define AW_MMC_RESET_RETRY 1000 + +#define CARD_ID_FREQUENCY 400000 + +static struct ofw_compat_data compat_data[] = { + {"allwinner,sun4i-a10-mmc", 1}, + {"allwinner,sun5i-a13-mmc", 1}, + {"allwinner,sun7i-a20-mmc", 1}, + {"allwinner,sun50i-a64-mmc", 1}, + {NULL, 0} +}; + +struct aw_mmc_softc { + device_t aw_dev; + clk_t aw_clk_ahb; + clk_t aw_clk_mmc; + hwreset_t aw_rst_ahb; + int aw_bus_busy; + int aw_resid; + int aw_timeout; + struct callout aw_timeoutc; + struct mmc_host aw_host; + struct mmc_request * aw_req; + struct mtx aw_mtx; + struct resource * aw_res[AW_MMC_RESSZ]; + uint32_t aw_intr; + uint32_t aw_intr_wait; + void * aw_intrhand; + + /* Fields required for DMA access. */ + bus_addr_t aw_dma_desc_phys; + bus_dmamap_t aw_dma_map; + bus_dma_tag_t aw_dma_tag; + void * aw_dma_desc; + bus_dmamap_t aw_dma_buf_map; + bus_dma_tag_t aw_dma_buf_tag; + int aw_dma_map_err; +}; + +static struct resource_spec aw_mmc_res_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE }, + { -1, 0, 0 } +}; + +static int aw_mmc_probe(device_t); +static int aw_mmc_attach(device_t); +static int aw_mmc_detach(device_t); +static int aw_mmc_setup_dma(struct aw_mmc_softc *); +static int aw_mmc_reset(struct aw_mmc_softc *); +static void aw_mmc_intr(void *); +static int aw_mmc_update_clock(struct aw_mmc_softc *, uint32_t); + +static int aw_mmc_update_ios(device_t, device_t); +static int aw_mmc_request(device_t, device_t, struct mmc_request *); +static int aw_mmc_get_ro(device_t, device_t); +static int aw_mmc_acquire_host(device_t, device_t); +static int aw_mmc_release_host(device_t, device_t); + +#define AW_MMC_LOCK(_sc) mtx_lock(&(_sc)->aw_mtx) +#define AW_MMC_UNLOCK(_sc) mtx_unlock(&(_sc)->aw_mtx) +#define AW_MMC_READ_4(_sc, _reg) \ + bus_read_4((_sc)->aw_res[AW_MMC_MEMRES], _reg) +#define AW_MMC_WRITE_4(_sc, _reg, _value) \ + bus_write_4((_sc)->aw_res[AW_MMC_MEMRES], _reg, _value) + +static int +aw_mmc_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "Allwinner Integrated MMC/SD controller"); + + return (BUS_PROBE_DEFAULT); +} + +static int +aw_mmc_attach(device_t dev) +{ + device_t child; + struct aw_mmc_softc *sc; + struct sysctl_ctx_list *ctx; + struct sysctl_oid_list *tree; + uint32_t bus_width; + phandle_t node; + int error; + + node = ofw_bus_get_node(dev); + sc = device_get_softc(dev); + sc->aw_dev = dev; + sc->aw_req = NULL; + if (bus_alloc_resources(dev, aw_mmc_res_spec, sc->aw_res) != 0) { + device_printf(dev, "cannot allocate device resources\n"); + return (ENXIO); + } + if (bus_setup_intr(dev, sc->aw_res[AW_MMC_IRQRES], + INTR_TYPE_MISC | INTR_MPSAFE, NULL, aw_mmc_intr, sc, + &sc->aw_intrhand)) { + bus_release_resources(dev, aw_mmc_res_spec, sc->aw_res); + device_printf(dev, "cannot setup interrupt handler\n"); + return (ENXIO); + } + mtx_init(&sc->aw_mtx, device_get_nameunit(sc->aw_dev), "aw_mmc", + MTX_DEF); + callout_init_mtx(&sc->aw_timeoutc, &sc->aw_mtx, 0); + + /* De-assert reset */ + if (hwreset_get_by_ofw_name(dev, 0, "ahb", &sc->aw_rst_ahb) == 0) { + error = hwreset_deassert(sc->aw_rst_ahb); + if (error != 0) { + device_printf(dev, "cannot de-assert reset\n"); + goto fail; + } + } + + /* Activate the module clock. */ + error = clk_get_by_ofw_name(dev, 0, "ahb", &sc->aw_clk_ahb); + if (error != 0) { + device_printf(dev, "cannot get ahb clock\n"); + goto fail; + } + error = clk_enable(sc->aw_clk_ahb); + if (error != 0) { + device_printf(dev, "cannot enable ahb clock\n"); + goto fail; + } + error = clk_get_by_ofw_name(dev, 0, "mmc", &sc->aw_clk_mmc); + if (error != 0) { + device_printf(dev, "cannot get mmc clock\n"); + goto fail; + } + error = clk_set_freq(sc->aw_clk_mmc, CARD_ID_FREQUENCY, + CLK_SET_ROUND_DOWN); + if (error != 0) { + device_printf(dev, "cannot init mmc clock\n"); + goto fail; + } + error = clk_enable(sc->aw_clk_mmc); + if (error != 0) { + device_printf(dev, "cannot enable mmc clock\n"); + goto fail; + } + + sc->aw_timeout = 10; + ctx = device_get_sysctl_ctx(dev); + tree = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + SYSCTL_ADD_INT(ctx, tree, OID_AUTO, "req_timeout", CTLFLAG_RW, + &sc->aw_timeout, 0, "Request timeout in seconds"); + + /* Hardware reset */ + AW_MMC_WRITE_4(sc, AW_MMC_HWRST, 1); + DELAY(100); + AW_MMC_WRITE_4(sc, AW_MMC_HWRST, 0); + DELAY(500); + + /* Soft Reset controller. */ + if (aw_mmc_reset(sc) != 0) { + device_printf(dev, "cannot reset the controller\n"); + goto fail; + } + + if (aw_mmc_setup_dma(sc) != 0) { + device_printf(sc->aw_dev, "Couldn't setup DMA!\n"); + goto fail; + } + + if (OF_getencprop(node, "bus-width", &bus_width, sizeof(uint32_t)) <= 0) + bus_width = 4; + + sc->aw_host.f_min = 400000; + sc->aw_host.f_max = 52000000; + sc->aw_host.host_ocr = MMC_OCR_320_330 | MMC_OCR_330_340; + sc->aw_host.mode = mode_sd; + sc->aw_host.caps = MMC_CAP_HSPEED; + if (bus_width >= 4) + sc->aw_host.caps |= MMC_CAP_4_BIT_DATA; + if (bus_width >= 8) + sc->aw_host.caps |= MMC_CAP_8_BIT_DATA; + + child = device_add_child(dev, "mmc", -1); + if (child == NULL) { + device_printf(dev, "attaching MMC bus failed!\n"); + goto fail; + } + if (device_probe_and_attach(child) != 0) { + device_printf(dev, "attaching MMC child failed!\n"); + device_delete_child(dev, child); + goto fail; + } + + return (0); + +fail: + callout_drain(&sc->aw_timeoutc); + mtx_destroy(&sc->aw_mtx); + bus_teardown_intr(dev, sc->aw_res[AW_MMC_IRQRES], sc->aw_intrhand); + bus_release_resources(dev, aw_mmc_res_spec, sc->aw_res); + + return (ENXIO); +} + +static int +aw_mmc_detach(device_t dev) +{ + + return (EBUSY); +} + +static void +aw_dma_desc_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int err) +{ + struct aw_mmc_softc *sc; + + sc = (struct aw_mmc_softc *)arg; + if (err) { + sc->aw_dma_map_err = err; + return; + } + sc->aw_dma_desc_phys = segs[0].ds_addr; +} + +static int +aw_mmc_setup_dma(struct aw_mmc_softc *sc) +{ + int dma_desc_size, error; + + /* Allocate the DMA descriptor memory. */ + dma_desc_size = sizeof(struct aw_mmc_dma_desc) * AW_MMC_DMA_SEGS; + error = bus_dma_tag_create(bus_get_dma_tag(sc->aw_dev), + AW_MMC_DMA_ALIGN, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + dma_desc_size, 1, dma_desc_size, 0, NULL, NULL, &sc->aw_dma_tag); + if (error) + return (error); + error = bus_dmamem_alloc(sc->aw_dma_tag, &sc->aw_dma_desc, + BUS_DMA_WAITOK | BUS_DMA_ZERO, &sc->aw_dma_map); + if (error) + return (error); + + error = bus_dmamap_load(sc->aw_dma_tag, sc->aw_dma_map, + sc->aw_dma_desc, dma_desc_size, aw_dma_desc_cb, sc, 0); + if (error) + return (error); + if (sc->aw_dma_map_err) + return (sc->aw_dma_map_err); + + /* Create the DMA map for data transfers. */ + error = bus_dma_tag_create(bus_get_dma_tag(sc->aw_dev), + AW_MMC_DMA_ALIGN, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + AW_MMC_DMA_MAX_SIZE * AW_MMC_DMA_SEGS, AW_MMC_DMA_SEGS, + AW_MMC_DMA_MAX_SIZE, BUS_DMA_ALLOCNOW, NULL, NULL, + &sc->aw_dma_buf_tag); + if (error) + return (error); + error = bus_dmamap_create(sc->aw_dma_buf_tag, 0, + &sc->aw_dma_buf_map); + if (error) + return (error); + + return (0); +} + +static void +aw_dma_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int err) +{ + int i; + struct aw_mmc_dma_desc *dma_desc; + struct aw_mmc_softc *sc; + + sc = (struct aw_mmc_softc *)arg; + sc->aw_dma_map_err = err; + + if (err) + return; + + dma_desc = sc->aw_dma_desc; + for (i = 0; i < nsegs; i++) { + dma_desc[i].buf_size = segs[i].ds_len; + dma_desc[i].buf_addr = segs[i].ds_addr; + dma_desc[i].config = AW_MMC_DMA_CONFIG_CH | + AW_MMC_DMA_CONFIG_OWN; + if (i == 0) + dma_desc[i].config |= AW_MMC_DMA_CONFIG_FD; + if (i < (nsegs - 1)) { + dma_desc[i].config |= AW_MMC_DMA_CONFIG_DIC; + dma_desc[i].next = sc->aw_dma_desc_phys + + ((i + 1) * sizeof(struct aw_mmc_dma_desc)); + } else { + dma_desc[i].config |= AW_MMC_DMA_CONFIG_LD | + AW_MMC_DMA_CONFIG_ER; + dma_desc[i].next = 0; + } + } +} + +static int +aw_mmc_prepare_dma(struct aw_mmc_softc *sc) +{ + bus_dmasync_op_t sync_op; + int error; + struct mmc_command *cmd; + uint32_t val; + + cmd = sc->aw_req->cmd; + if (cmd->data->len > AW_MMC_DMA_MAX_SIZE * AW_MMC_DMA_SEGS) + return (EFBIG); + error = bus_dmamap_load(sc->aw_dma_buf_tag, sc->aw_dma_buf_map, + cmd->data->data, cmd->data->len, aw_dma_cb, sc, 0); + if (error) + return (error); + if (sc->aw_dma_map_err) + return (sc->aw_dma_map_err); + + if (cmd->data->flags & MMC_DATA_WRITE) + sync_op = BUS_DMASYNC_PREWRITE; + else + sync_op = BUS_DMASYNC_PREREAD; + bus_dmamap_sync(sc->aw_dma_buf_tag, sc->aw_dma_buf_map, sync_op); + bus_dmamap_sync(sc->aw_dma_tag, sc->aw_dma_map, BUS_DMASYNC_PREWRITE); + + /* Enable DMA */ + val = AW_MMC_READ_4(sc, AW_MMC_GCTL); + val &= ~AW_MMC_CTRL_FIFO_AC_MOD; + val |= AW_MMC_CTRL_DMA_ENB; + AW_MMC_WRITE_4(sc, AW_MMC_GCTL, val); + + /* Reset DMA */ + val |= AW_MMC_CTRL_DMA_RST; + AW_MMC_WRITE_4(sc, AW_MMC_GCTL, val); + + AW_MMC_WRITE_4(sc, AW_MMC_DMAC, AW_MMC_DMAC_IDMAC_SOFT_RST); + AW_MMC_WRITE_4(sc, AW_MMC_DMAC, + AW_MMC_DMAC_IDMAC_IDMA_ON | AW_MMC_DMAC_IDMAC_FIX_BURST); + + /* Enable RX or TX DMA interrupt */ + if (cmd->data->flags & MMC_DATA_WRITE) + val |= AW_MMC_IDST_TX_INT; + else + val |= AW_MMC_IDST_RX_INT; + AW_MMC_WRITE_4(sc, AW_MMC_IDIE, val); + + /* Set DMA descritptor list address */ + AW_MMC_WRITE_4(sc, AW_MMC_DLBA, sc->aw_dma_desc_phys); + + /* FIFO trigger level */ + AW_MMC_WRITE_4(sc, AW_MMC_FWLR, AW_MMC_DMA_FTRGLEVEL); + + return (0); +} + +static int +aw_mmc_reset(struct aw_mmc_softc *sc) +{ + int timeout; + + AW_MMC_WRITE_4(sc, AW_MMC_GCTL, AW_MMC_RESET); + timeout = 1000; + while (--timeout > 0) { + if ((AW_MMC_READ_4(sc, AW_MMC_GCTL) & AW_MMC_RESET) == 0) + break; + DELAY(100); + } + if (timeout == 0) + return (ETIMEDOUT); + + /* Set the timeout. */ + AW_MMC_WRITE_4(sc, AW_MMC_TMOR, + AW_MMC_TMOR_DTO_LMT_SHIFT(AW_MMC_TMOR_DTO_LMT_MASK) | + AW_MMC_TMOR_RTO_LMT_SHIFT(AW_MMC_TMOR_RTO_LMT_MASK)); + + /* Clear pending interrupts. */ + AW_MMC_WRITE_4(sc, AW_MMC_RISR, 0xffffffff); + AW_MMC_WRITE_4(sc, AW_MMC_IDST, 0xffffffff); + /* Unmask interrupts. */ + AW_MMC_WRITE_4(sc, AW_MMC_IMKR, + AW_MMC_INT_CMD_DONE | AW_MMC_INT_ERR_BIT | + AW_MMC_INT_DATA_OVER | AW_MMC_INT_AUTO_STOP_DONE); + /* Enable interrupts and AHB access. */ + AW_MMC_WRITE_4(sc, AW_MMC_GCTL, + AW_MMC_READ_4(sc, AW_MMC_GCTL) | AW_MMC_CTRL_INT_ENB); + + return (0); +} + +static void +aw_mmc_req_done(struct aw_mmc_softc *sc) +{ + struct mmc_command *cmd; + struct mmc_request *req; + uint32_t val, mask; + int retry; + + cmd = sc->aw_req->cmd; + if (cmd->error != MMC_ERR_NONE) { + /* Reset the FIFO and DMA engines. */ + mask = AW_MMC_CTRL_FIFO_RST | AW_MMC_CTRL_DMA_RST; + val = AW_MMC_READ_4(sc, AW_MMC_GCTL); + AW_MMC_WRITE_4(sc, AW_MMC_GCTL, val | mask); + + retry = AW_MMC_RESET_RETRY; + while (--retry > 0) { + val = AW_MMC_READ_4(sc, AW_MMC_GCTL); + if ((val & mask) == 0) + break; + DELAY(10); + } + if (retry == 0) + device_printf(sc->aw_dev, + "timeout resetting DMA/FIFO\n"); + aw_mmc_update_clock(sc, 1); + } + + req = sc->aw_req; + callout_stop(&sc->aw_timeoutc); + sc->aw_req = NULL; + sc->aw_intr = 0; + sc->aw_resid = 0; + sc->aw_dma_map_err = 0; + sc->aw_intr_wait = 0; + req->done(req); +} + +static void +aw_mmc_req_ok(struct aw_mmc_softc *sc) +{ + int timeout; + struct mmc_command *cmd; + uint32_t status; + + timeout = 1000; + while (--timeout > 0) { + status = AW_MMC_READ_4(sc, AW_MMC_STAR); + if ((status & AW_MMC_STAR_CARD_BUSY) == 0) + break; + DELAY(1000); + } + cmd = sc->aw_req->cmd; + if (timeout == 0) { + cmd->error = MMC_ERR_FAILED; + aw_mmc_req_done(sc); + return; + } + if (cmd->flags & MMC_RSP_PRESENT) { + if (cmd->flags & MMC_RSP_136) { + cmd->resp[0] = AW_MMC_READ_4(sc, AW_MMC_RESP3); + cmd->resp[1] = AW_MMC_READ_4(sc, AW_MMC_RESP2); + cmd->resp[2] = AW_MMC_READ_4(sc, AW_MMC_RESP1); + cmd->resp[3] = AW_MMC_READ_4(sc, AW_MMC_RESP0); + } else + cmd->resp[0] = AW_MMC_READ_4(sc, AW_MMC_RESP0); + } + /* All data has been transferred ? */ + if (cmd->data != NULL && (sc->aw_resid << 2) < cmd->data->len) + cmd->error = MMC_ERR_FAILED; + aw_mmc_req_done(sc); +} + +static void +aw_mmc_timeout(void *arg) +{ + struct aw_mmc_softc *sc; + + sc = (struct aw_mmc_softc *)arg; + if (sc->aw_req != NULL) { + device_printf(sc->aw_dev, "controller timeout\n"); + sc->aw_req->cmd->error = MMC_ERR_TIMEOUT; + aw_mmc_req_done(sc); + } else + device_printf(sc->aw_dev, + "Spurious timeout - no active request\n"); +} + +static void +aw_mmc_intr(void *arg) +{ + bus_dmasync_op_t sync_op; + struct aw_mmc_softc *sc; + struct mmc_data *data; + uint32_t idst, imask, rint; + + sc = (struct aw_mmc_softc *)arg; + AW_MMC_LOCK(sc); + rint = AW_MMC_READ_4(sc, AW_MMC_RISR); + idst = AW_MMC_READ_4(sc, AW_MMC_IDST); + imask = AW_MMC_READ_4(sc, AW_MMC_IMKR); + if (idst == 0 && imask == 0 && rint == 0) { + AW_MMC_UNLOCK(sc); + return; + } +#ifdef DEBUG + device_printf(sc->aw_dev, "idst: %#x, imask: %#x, rint: %#x\n", + idst, imask, rint); +#endif + if (sc->aw_req == NULL) { + device_printf(sc->aw_dev, + "Spurious interrupt - no active request, rint: 0x%08X\n", + rint); + goto end; + } + if (rint & AW_MMC_INT_ERR_BIT) { + device_printf(sc->aw_dev, "error rint: 0x%08X\n", rint); + if (rint & AW_MMC_INT_RESP_TIMEOUT) + sc->aw_req->cmd->error = MMC_ERR_TIMEOUT; + else + sc->aw_req->cmd->error = MMC_ERR_FAILED; + aw_mmc_req_done(sc); + goto end; + } + if (idst & AW_MMC_IDST_ERROR) { + device_printf(sc->aw_dev, "error idst: 0x%08x\n", idst); + sc->aw_req->cmd->error = MMC_ERR_FAILED; + aw_mmc_req_done(sc); + goto end; + } + + sc->aw_intr |= rint; + data = sc->aw_req->cmd->data; + if (data != NULL && (idst & AW_MMC_IDST_COMPLETE) != 0) { + if (data->flags & MMC_DATA_WRITE) + sync_op = BUS_DMASYNC_POSTWRITE; + else + sync_op = BUS_DMASYNC_POSTREAD; + bus_dmamap_sync(sc->aw_dma_buf_tag, sc->aw_dma_buf_map, + sync_op); + bus_dmamap_sync(sc->aw_dma_tag, sc->aw_dma_map, + BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(sc->aw_dma_buf_tag, sc->aw_dma_buf_map); + sc->aw_resid = data->len >> 2; + } + if ((sc->aw_intr & sc->aw_intr_wait) == sc->aw_intr_wait) + aw_mmc_req_ok(sc); + +end: + AW_MMC_WRITE_4(sc, AW_MMC_IDST, idst); + AW_MMC_WRITE_4(sc, AW_MMC_RISR, rint); + AW_MMC_UNLOCK(sc); +} + +static int +aw_mmc_request(device_t bus, device_t child, struct mmc_request *req) +{ + int blksz; + struct aw_mmc_softc *sc; + struct mmc_command *cmd; + uint32_t cmdreg; + int err; + + sc = device_get_softc(bus); + AW_MMC_LOCK(sc); + if (sc->aw_req) { + AW_MMC_UNLOCK(sc); + return (EBUSY); + } + sc->aw_req = req; + cmd = req->cmd; + cmdreg = AW_MMC_CMDR_LOAD; + if (cmd->opcode == MMC_GO_IDLE_STATE) + cmdreg |= AW_MMC_CMDR_SEND_INIT_SEQ; + if (cmd->flags & MMC_RSP_PRESENT) + cmdreg |= AW_MMC_CMDR_RESP_RCV; + if (cmd->flags & MMC_RSP_136) + cmdreg |= AW_MMC_CMDR_LONG_RESP; + if (cmd->flags & MMC_RSP_CRC) + cmdreg |= AW_MMC_CMDR_CHK_RESP_CRC; + + sc->aw_intr = 0; + sc->aw_resid = 0; + sc->aw_intr_wait = AW_MMC_INT_CMD_DONE; + cmd->error = MMC_ERR_NONE; + if (cmd->data != NULL) { + sc->aw_intr_wait |= AW_MMC_INT_DATA_OVER; + cmdreg |= AW_MMC_CMDR_DATA_TRANS | AW_MMC_CMDR_WAIT_PRE_OVER; + if (cmd->data->flags & MMC_DATA_MULTI) { + cmdreg |= AW_MMC_CMDR_STOP_CMD_FLAG; + sc->aw_intr_wait |= AW_MMC_INT_AUTO_STOP_DONE; + } + if (cmd->data->flags & MMC_DATA_WRITE) + cmdreg |= AW_MMC_CMDR_DIR_WRITE; + blksz = min(cmd->data->len, MMC_SECTOR_SIZE); + AW_MMC_WRITE_4(sc, AW_MMC_BKSR, blksz); + AW_MMC_WRITE_4(sc, AW_MMC_BYCR, cmd->data->len); + + err = aw_mmc_prepare_dma(sc); + if (err != 0) + device_printf(sc->aw_dev, "prepare_dma failed: %d\n", err); + } + + AW_MMC_WRITE_4(sc, AW_MMC_CAGR, cmd->arg); + AW_MMC_WRITE_4(sc, AW_MMC_CMDR, cmdreg | cmd->opcode); + callout_reset(&sc->aw_timeoutc, sc->aw_timeout * hz, + aw_mmc_timeout, sc); + AW_MMC_UNLOCK(sc); + + return (0); +} + +static int +aw_mmc_read_ivar(device_t bus, device_t child, int which, + uintptr_t *result) +{ + struct aw_mmc_softc *sc; + + sc = device_get_softc(bus); + switch (which) { + default: + return (EINVAL); + case MMCBR_IVAR_BUS_MODE: + *(int *)result = sc->aw_host.ios.bus_mode; + break; + case MMCBR_IVAR_BUS_WIDTH: + *(int *)result = sc->aw_host.ios.bus_width; + break; + case MMCBR_IVAR_CHIP_SELECT: + *(int *)result = sc->aw_host.ios.chip_select; + break; + case MMCBR_IVAR_CLOCK: + *(int *)result = sc->aw_host.ios.clock; + break; + case MMCBR_IVAR_F_MIN: + *(int *)result = sc->aw_host.f_min; + break; + case MMCBR_IVAR_F_MAX: + *(int *)result = sc->aw_host.f_max; + break; + case MMCBR_IVAR_HOST_OCR: + *(int *)result = sc->aw_host.host_ocr; + break; + case MMCBR_IVAR_MODE: + *(int *)result = sc->aw_host.mode; + break; + case MMCBR_IVAR_OCR: + *(int *)result = sc->aw_host.ocr; + break; + case MMCBR_IVAR_POWER_MODE: + *(int *)result = sc->aw_host.ios.power_mode; + break; + case MMCBR_IVAR_VDD: + *(int *)result = sc->aw_host.ios.vdd; + break; + case MMCBR_IVAR_CAPS: + *(int *)result = sc->aw_host.caps; + break; + case MMCBR_IVAR_MAX_DATA: + *(int *)result = 65535; + break; + } + + return (0); +} + +static int +aw_mmc_write_ivar(device_t bus, device_t child, int which, + uintptr_t value) +{ + struct aw_mmc_softc *sc; + + sc = device_get_softc(bus); + switch (which) { + default: + return (EINVAL); + case MMCBR_IVAR_BUS_MODE: + sc->aw_host.ios.bus_mode = value; + break; + case MMCBR_IVAR_BUS_WIDTH: + sc->aw_host.ios.bus_width = value; + break; + case MMCBR_IVAR_CHIP_SELECT: + sc->aw_host.ios.chip_select = value; + break; + case MMCBR_IVAR_CLOCK: + sc->aw_host.ios.clock = value; + break; + case MMCBR_IVAR_MODE: + sc->aw_host.mode = value; + break; + case MMCBR_IVAR_OCR: + sc->aw_host.ocr = value; + break; + case MMCBR_IVAR_POWER_MODE: + sc->aw_host.ios.power_mode = value; + break; + case MMCBR_IVAR_VDD: + sc->aw_host.ios.vdd = value; + break; + /* These are read-only */ + case MMCBR_IVAR_CAPS: + case MMCBR_IVAR_HOST_OCR: + case MMCBR_IVAR_F_MIN: + case MMCBR_IVAR_F_MAX: + case MMCBR_IVAR_MAX_DATA: + return (EINVAL); + } + + return (0); +} + +static int +aw_mmc_update_clock(struct aw_mmc_softc *sc, uint32_t clkon) +{ + uint32_t cmdreg; + int retry; + uint32_t ckcr; + + ckcr = AW_MMC_READ_4(sc, AW_MMC_CKCR); + ckcr &= ~(AW_MMC_CKCR_CCLK_ENB | AW_MMC_CKCR_CCLK_CTRL); + + if (clkon) + ckcr |= AW_MMC_CKCR_CCLK_ENB; + + AW_MMC_WRITE_4(sc, AW_MMC_CKCR, ckcr); + + cmdreg = AW_MMC_CMDR_LOAD | AW_MMC_CMDR_PRG_CLK | + AW_MMC_CMDR_WAIT_PRE_OVER; + AW_MMC_WRITE_4(sc, AW_MMC_CMDR, cmdreg); + retry = 0xfffff; + while (--retry > 0) { + if ((AW_MMC_READ_4(sc, AW_MMC_CMDR) & AW_MMC_CMDR_LOAD) == 0) { + AW_MMC_WRITE_4(sc, AW_MMC_RISR, 0xffffffff); + return (0); + } + DELAY(10); + } + AW_MMC_WRITE_4(sc, AW_MMC_RISR, 0xffffffff); + device_printf(sc->aw_dev, "timeout updating clock\n"); + + return (ETIMEDOUT); +} + +static int +aw_mmc_update_ios(device_t bus, device_t child) +{ + int error; + struct aw_mmc_softc *sc; + struct mmc_ios *ios; + uint32_t ckcr; + + sc = device_get_softc(bus); + + ios = &sc->aw_host.ios; + + /* Set the bus width. */ + switch (ios->bus_width) { + case bus_width_1: + AW_MMC_WRITE_4(sc, AW_MMC_BWDR, AW_MMC_BWDR1); + break; + case bus_width_4: + AW_MMC_WRITE_4(sc, AW_MMC_BWDR, AW_MMC_BWDR4); + break; + case bus_width_8: + AW_MMC_WRITE_4(sc, AW_MMC_BWDR, AW_MMC_BWDR8); + break; + } + + if (ios->clock) { + + /* Disable clock */ + error = aw_mmc_update_clock(sc, 0); + if (error != 0) + return (error); + + /* Reset the divider. */ + ckcr = AW_MMC_READ_4(sc, AW_MMC_CKCR); + ckcr &= ~AW_MMC_CKCR_CCLK_DIV; + AW_MMC_WRITE_4(sc, AW_MMC_CKCR, ckcr); + + /* Set the MMC clock. */ + error = clk_set_freq(sc->aw_clk_mmc, ios->clock, + CLK_SET_ROUND_DOWN); + if (error != 0) { + device_printf(sc->aw_dev, + "failed to set frequency to %u Hz: %d\n", + ios->clock, error); + return (error); + } + + /* Enable clock. */ + error = aw_mmc_update_clock(sc, 1); + if (error != 0) + return (error); + } + + + return (0); +} + +static int +aw_mmc_get_ro(device_t bus, device_t child) +{ + + return (0); +} + +static int +aw_mmc_acquire_host(device_t bus, device_t child) +{ + struct aw_mmc_softc *sc; + int error; + + sc = device_get_softc(bus); + AW_MMC_LOCK(sc); + while (sc->aw_bus_busy) { + error = msleep(sc, &sc->aw_mtx, PCATCH, "mmchw", 0); + if (error != 0) { + AW_MMC_UNLOCK(sc); + return (error); + } + } + sc->aw_bus_busy++; + AW_MMC_UNLOCK(sc); + + return (0); +} + +static int +aw_mmc_release_host(device_t bus, device_t child) +{ + struct aw_mmc_softc *sc; + + sc = device_get_softc(bus); + AW_MMC_LOCK(sc); + sc->aw_bus_busy--; + wakeup(sc); + AW_MMC_UNLOCK(sc); + + return (0); +} + +static device_method_t aw_mmc_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, aw_mmc_probe), + DEVMETHOD(device_attach, aw_mmc_attach), + DEVMETHOD(device_detach, aw_mmc_detach), + + /* Bus interface */ + DEVMETHOD(bus_read_ivar, aw_mmc_read_ivar), + DEVMETHOD(bus_write_ivar, aw_mmc_write_ivar), + + /* MMC bridge interface */ + DEVMETHOD(mmcbr_update_ios, aw_mmc_update_ios), + DEVMETHOD(mmcbr_request, aw_mmc_request), + DEVMETHOD(mmcbr_get_ro, aw_mmc_get_ro), + DEVMETHOD(mmcbr_acquire_host, aw_mmc_acquire_host), + DEVMETHOD(mmcbr_release_host, aw_mmc_release_host), + + DEVMETHOD_END +}; + +static devclass_t aw_mmc_devclass; + +static driver_t aw_mmc_driver = { + "aw_mmc", + aw_mmc_methods, + sizeof(struct aw_mmc_softc), +}; + +DRIVER_MODULE(aw_mmc, simplebus, aw_mmc_driver, aw_mmc_devclass, NULL, + NULL); +MMC_DECLARE_BRIDGE(aw_mmc); Property changes on: head/sys/arm/allwinner/aw_mmc.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/arm/allwinner/aw_mmc.h =================================================================== --- head/sys/arm/allwinner/aw_mmc.h (nonexistent) +++ head/sys/arm/allwinner/aw_mmc.h (revision 327198) @@ -0,0 +1,204 @@ +/*- + * Copyright (c) 2013 Alexander Fedorov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _AW_MMC_H_ +#define _AW_MMC_H_ + +#define AW_MMC_GCTL 0x00 /* Control Register */ +#define AW_MMC_CKCR 0x04 /* Clock Control Register */ +#define AW_MMC_TMOR 0x08 /* Timeout Register */ +#define AW_MMC_BWDR 0x0C /* Bus Width Register */ +#define AW_MMC_BKSR 0x10 /* Block Size Register */ +#define AW_MMC_BYCR 0x14 /* Byte Count Register */ +#define AW_MMC_CMDR 0x18 /* Command Register */ +#define AW_MMC_CAGR 0x1C /* Argument Register */ +#define AW_MMC_RESP0 0x20 /* Response Register 0 */ +#define AW_MMC_RESP1 0x24 /* Response Register 1 */ +#define AW_MMC_RESP2 0x28 /* Response Register 2 */ +#define AW_MMC_RESP3 0x2C /* Response Register 3 */ +#define AW_MMC_IMKR 0x30 /* Interrupt Mask Register */ +#define AW_MMC_MISR 0x34 /* Masked Interrupt Status Register */ +#define AW_MMC_RISR 0x38 /* Raw Interrupt Status Register */ +#define AW_MMC_STAR 0x3C /* Status Register */ +#define AW_MMC_FWLR 0x40 /* FIFO Threshold Watermark Register */ +#define AW_MMC_FUNS 0x44 /* Function Select Register */ +#define AW_MMC_HWRST 0x78 /* Hardware reset (not documented) */ +#define AW_MMC_DMAC 0x80 /* IDMAC Control Register */ +#define AW_MMC_DLBA 0x84 /* IDMAC Desc List Base Address Reg */ +#define AW_MMC_IDST 0x88 /* IDMAC Status Register */ +#define AW_MMC_IDIE 0x8C /* IDMAC Interrupt Enable Register */ +#define AW_MMC_FIFO 0x100 /* FIFO Access Address (A10/A20) */ +#define A31_MMC_FIFO 0x200 /* FIFO Access Address (A31) */ + +/* AW_MMC_GCTL */ +#define AW_MMC_CTRL_SOFT_RST (1U << 0) +#define AW_MMC_CTRL_FIFO_RST (1U << 1) +#define AW_MMC_CTRL_DMA_RST (1U << 2) +#define AW_MMC_CTRL_INT_ENB (1U << 4) +#define AW_MMC_CTRL_DMA_ENB (1U << 5) +#define AW_MMC_CTRL_CD_DBC_ENB (1U << 8) +#define AW_MMC_CTRL_DDR_MOD_SEL (1U << 10) +#define AW_MMC_CTRL_FIFO_AC_MOD (1U << 31) +#define AW_MMC_RESET \ + (AW_MMC_CTRL_SOFT_RST | AW_MMC_CTRL_FIFO_RST | AW_MMC_CTRL_DMA_RST) + +/* AW_MMC_CKCR */ +#define AW_MMC_CKCR_CCLK_ENB (1U << 16) +#define AW_MMC_CKCR_CCLK_CTRL (1U << 17) +#define AW_MMC_CKCR_CCLK_DIV 0xff + +/* AW_MMC_TMOR */ +#define AW_MMC_TMOR_RTO_LMT_SHIFT(x) x /* Response timeout limit */ +#define AW_MMC_TMOR_RTO_LMT_MASK 0xff +#define AW_MMC_TMOR_DTO_LMT_SHIFT(x) (x << 8) /* Data timeout limit */ +#define AW_MMC_TMOR_DTO_LMT_MASK 0xffffff + +/* AW_MMC_BWDR */ +#define AW_MMC_BWDR1 0 +#define AW_MMC_BWDR4 1 +#define AW_MMC_BWDR8 2 + +/* AW_MMC_CMDR */ +#define AW_MMC_CMDR_RESP_RCV (1U << 6) +#define AW_MMC_CMDR_LONG_RESP (1U << 7) +#define AW_MMC_CMDR_CHK_RESP_CRC (1U << 8) +#define AW_MMC_CMDR_DATA_TRANS (1U << 9) +#define AW_MMC_CMDR_DIR_WRITE (1U << 10) +#define AW_MMC_CMDR_TRANS_MODE_STREAM (1U << 11) +#define AW_MMC_CMDR_STOP_CMD_FLAG (1U << 12) +#define AW_MMC_CMDR_WAIT_PRE_OVER (1U << 13) +#define AW_MMC_CMDR_STOP_ABT_CMD (1U << 14) +#define AW_MMC_CMDR_SEND_INIT_SEQ (1U << 15) +#define AW_MMC_CMDR_PRG_CLK (1U << 21) +#define AW_MMC_CMDR_RD_CEDATA_DEV (1U << 22) +#define AW_MMC_CMDR_CCS_EXP (1U << 23) +#define AW_MMC_CMDR_BOOT_MOD_SHIFT 24 +#define AW_MMC_CMDR_BOOT_MOD_NORMAL 0 +#define AW_MMC_CMDR_BOOT_MOD_MANDATORY 1 +#define AW_MMC_CMDR_BOOT_MOD_ALT 2 +#define AW_MMC_CMDR_EXP_BOOT_ACK (1U << 26) +#define AW_MMC_CMDR_BOOT_ABT (1U << 27) +#define AW_MMC_CMDR_VOL_SW (1U << 28) +#define AW_MMC_CMDR_LOAD (1U << 31) + +/* AW_MMC_IMKR and AW_MMC_RISR */ +#define AW_MMC_INT_RESP_ERR (1U << 1) +#define AW_MMC_INT_CMD_DONE (1U << 2) +#define AW_MMC_INT_DATA_OVER (1U << 3) +#define AW_MMC_INT_TX_DATA_REQ (1U << 4) +#define AW_MMC_INT_RX_DATA_REQ (1U << 5) +#define AW_MMC_INT_RESP_CRC_ERR (1U << 6) +#define AW_MMC_INT_DATA_CRC_ERR (1U << 7) +#define AW_MMC_INT_RESP_TIMEOUT (1U << 8) +#define AW_MMC_INT_BOOT_ACK_RECV (1U << 8) +#define AW_MMC_INT_DATA_TIMEOUT (1U << 9) +#define AW_MMC_INT_BOOT_START (1U << 9) +#define AW_MMC_INT_DATA_STARVE (1U << 10) +#define AW_MMC_INT_VOL_CHG_DONE (1U << 10) +#define AW_MMC_INT_FIFO_RUN_ERR (1U << 11) +#define AW_MMC_INT_CMD_BUSY (1U << 12) +#define AW_MMC_INT_DATA_START_ERR (1U << 13) +#define AW_MMC_INT_AUTO_STOP_DONE (1U << 14) +#define AW_MMC_INT_DATA_END_BIT_ERR (1U << 15) +#define AW_MMC_INT_SDIO (1U << 16) +#define AW_MMC_INT_CARD_INSERT (1U << 30) +#define AW_MMC_INT_CARD_REMOVE (1U << 31) +#define AW_MMC_INT_ERR_BIT \ + (AW_MMC_INT_RESP_ERR | AW_MMC_INT_RESP_CRC_ERR | \ + AW_MMC_INT_DATA_CRC_ERR | AW_MMC_INT_RESP_TIMEOUT | \ + AW_MMC_INT_FIFO_RUN_ERR | AW_MMC_INT_CMD_BUSY | \ + AW_MMC_INT_DATA_START_ERR | AW_MMC_INT_DATA_END_BIT_ERR) + +/* AW_MMC_STAR */ +#define AW_MMC_STAR_FIFO_RX_LEVEL (1U << 0) +#define AW_MMC_STAR_FIFO_TX_LEVEL (1U << 1) +#define AW_MMC_STAR_FIFO_EMPTY (1U << 2) +#define AW_MMC_STAR_FIFO_FULL (1U << 3) +#define AW_MMC_STAR_CARD_PRESENT (1U << 8) +#define AW_MMC_STAR_CARD_BUSY (1U << 9) +#define AW_MMC_STAR_FSM_BUSY (1U << 10) +#define AW_MMC_STAR_DMA_REQ (1U << 31) + +/* AW_MMC_FUNS */ +#define AW_MMC_CE_ATA_ON (0xceaaU << 16) +#define AW_MMC_SEND_IRQ_RESP (1U << 0) +#define AW_MMC_SDIO_RD_WAIT (1U << 1) +#define AW_MMC_ABT_RD_DATA (1U << 2) +#define AW_MMC_SEND_CC_SD (1U << 8) +#define AW_MMC_SEND_AUTOSTOP_CC_SD (1U << 9) +#define AW_MMC_CE_ATA_DEV_INT_ENB (1U << 10) + +/* IDMA CONTROLLER BUS MOD BIT FIELD */ +#define AW_MMC_DMAC_IDMAC_SOFT_RST (1U << 0) +#define AW_MMC_DMAC_IDMAC_FIX_BURST (1U << 1) +#define AW_MMC_DMAC_IDMAC_IDMA_ON (1U << 7) +#define AW_MMC_DMAC_IDMAC_REFETCH_DES (1U << 31) + +/* AW_MMC_IDST */ +#define AW_MMC_IDST_TX_INT (1U << 0) +#define AW_MMC_IDST_RX_INT (1U << 1) +#define AW_MMC_IDST_FATAL_BERR_INT (1U << 2) +#define AW_MMC_IDST_DES_UNAVL_INT (1U << 4) +#define AW_MMC_IDST_ERR_FLAG_SUM (1U << 5) +#define AW_MMC_IDST_NOR_INT_SUM (1U << 8) +#define AW_MMC_IDST_ABN_INT_SUM (1U << 9) +#define AW_MMC_IDST_HOST_ABT_INTX (1U << 10) +#define AW_MMC_IDST_HOST_ABT_INRX (1U << 10) +#define AW_MMC_IDST_IDLE (0U << 13) +#define AW_MMC_IDST_SUSPEND (1U << 13) +#define AW_MMC_IDST_DESC_RD (2U << 13) +#define AW_MMC_IDST_DESC_CHECK (3U << 13) +#define AW_MMC_IDST_RD_REQ_WAIT (4U << 13) +#define AW_MMC_IDST_WR_REQ_WAIT (5U << 13) +#define AW_MMC_IDST_RD (6U << 13) +#define AW_MMC_IDST_WR (7U << 13) +#define AW_MMC_IDST_DESC_CLOSE (8U << 13) +#define AW_MMC_IDST_ERROR \ + (AW_MMC_IDST_FATAL_BERR_INT | AW_MMC_IDST_ERR_FLAG_SUM | \ + AW_MMC_IDST_DES_UNAVL_INT | AW_MMC_IDST_ABN_INT_SUM) +#define AW_MMC_IDST_COMPLETE \ + (AW_MMC_IDST_TX_INT | AW_MMC_IDST_RX_INT) + +/* The DMA descriptor table. */ +struct aw_mmc_dma_desc { + uint32_t config; +#define AW_MMC_DMA_CONFIG_DIC (1U << 1) /* Disable Interrupt Completion */ +#define AW_MMC_DMA_CONFIG_LD (1U << 2) /* Last DES */ +#define AW_MMC_DMA_CONFIG_FD (1U << 3) /* First DES */ +#define AW_MMC_DMA_CONFIG_CH (1U << 4) /* CHAIN MOD */ +#define AW_MMC_DMA_CONFIG_ER (1U << 5) /* End of Ring (undocumented register) */ +#define AW_MMC_DMA_CONFIG_CES (1U << 30) /* Card Error Summary */ +#define AW_MMC_DMA_CONFIG_OWN (1U << 31) /* DES Own Flag */ + uint32_t buf_size; + uint32_t buf_addr; + uint32_t next; +}; + +#define AW_MMC_DMA_ALIGN 4 + +#endif /* _AW_MMC_H_ */ Property changes on: head/sys/arm/allwinner/aw_mmc.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/arm/allwinner/files.allwinner =================================================================== --- head/sys/arm/allwinner/files.allwinner (revision 327197) +++ head/sys/arm/allwinner/files.allwinner (revision 327198) @@ -1,62 +1,62 @@ # $FreeBSD$ kern/kern_clocksource.c standard arm/allwinner/a10_ahci.c optional ahci arm/allwinner/a10_codec.c optional sound arm/allwinner/a10_dmac.c standard arm/allwinner/a31_dmac.c standard arm/allwinner/a10_ehci.c optional ehci arm/allwinner/aw_usbphy.c optional ehci | ohci arm/allwinner/a10_gpio.c optional gpio -arm/allwinner/a10_mmc.c optional mmc arm/allwinner/a10_sramc.c standard +arm/allwinner/aw_mmc.c optional mmc arm/allwinner/aw_nmi.c optional intrng arm/allwinner/aw_if_dwc.c optional dwc arm/allwinner/aw_rsb.c optional rsb | p2wi arm/allwinner/aw_rtc.c standard arm/allwinner/aw_ts.c standard arm/allwinner/aw_wdog.c standard arm/allwinner/aw_machdep.c standard arm/allwinner/aw_mp.c optional smp arm/allwinner/axp209.c optional axp209 arm/allwinner/axp81x.c optional axp81x arm/allwinner/if_awg.c optional awg arm/allwinner/if_emac.c optional emac arm/allwinner/sunxi_dma_if.m standard dev/iicbus/twsi/a10_twsi.c optional twsi dev/usb/controller/generic_ohci.c optional ohci dev/usb/controller/generic_usb_if.m optional ohci arm/allwinner/aw_sid.c standard arm/allwinner/aw_thermal.c standard dev/iicbus/sy8106a.c optional sy8106a arm/allwinner/aw_cir.c optional aw_cir evdev arm/allwinner/a10_fb.c optional vt arm/allwinner/a10_hdmi.c optional hdmi arm/allwinner/a10_hdmiaudio.c optional hdmi sound dev/hdmi/hdmi_if.m optional hdmi arm/allwinner/aw_reset.c standard arm/allwinner/aw_ccu.c standard arm/allwinner/clk/aw_ahbclk.c standard arm/allwinner/clk/aw_apbclk.c standard arm/allwinner/clk/aw_axiclk.c standard arm/allwinner/clk/aw_codecclk.c standard arm/allwinner/clk/aw_cpuclk.c standard arm/allwinner/clk/aw_cpusclk.c standard arm/allwinner/clk/aw_debeclk.c standard arm/allwinner/clk/aw_gate.c standard arm/allwinner/clk/aw_gmacclk.c standard arm/allwinner/clk/aw_hdmiclk.c standard arm/allwinner/clk/aw_lcdclk.c standard arm/allwinner/clk/aw_modclk.c standard arm/allwinner/clk/aw_mmcclk.c standard arm/allwinner/clk/aw_oscclk.c standard arm/allwinner/clk/aw_pll.c standard arm/allwinner/clk/aw_thsclk.c standard arm/allwinner/clk/aw_usbclk.c standard arm/allwinner/clkng/aw_ccung.c standard arm/allwinner/clkng/aw_clk_nkmp.c standard arm/allwinner/clkng/aw_clk_nm.c standard arm/allwinner/clkng/aw_clk_prediv_mux.c standard