svn commit: r248407 - in head/sys/arm: broadcom/bcm2835 include ti ti/cpsw

Ian Lepore ian at FreeBSD.org
Sun Mar 17 03:04:44 UTC 2013


Author: ian
Date: Sun Mar 17 03:04:43 2013
New Revision: 248407
URL: http://svnweb.freebsd.org/changeset/base/248407

Log:
  Add a macro that gets the physical address of a memory mapped device
  register from a bus space resource.
  
  Note that this macro is just for ARM, and is intended to have a short
  lifespan.  The DMA engines in some SoCs need the physical address of a
  memory-mapped device register as one of the arguments for the transfer.
  Several scattered ad-hoc solutions have been converted to use this macro,
  which now also serves to mark the places where a more complete fix needs
  to be applied (after that fix has been designed).

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
  head/sys/arm/include/bus.h
  head/sys/arm/ti/cpsw/if_cpsw.c
  head/sys/arm/ti/ti_mmchs.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c	Sun Mar 17 01:54:35 2013	(r248406)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c	Sun Mar 17 03:04:43 2013	(r248407)
@@ -173,7 +173,6 @@ bcm_sdhci_attach(device_t dev)
 	int default_freq;
 	void *buffer;
 	vm_paddr_t buffer_phys;
-	void *va;
 
 	sc->sc_dev = dev;
 	sc->sc_req = NULL;
@@ -284,9 +283,8 @@ bcm_sdhci_attach(device_t dev)
 
 	sc->sc_dma_buffer = buffer;
 	sc->sc_dma_buffer_phys = buffer_phys;
-	va = (void*)rman_get_start(sc->sc_mem_res);
-	sc->sc_sdhci_buffer_phys =
-	    pmap_kextract((vm_offset_t)va) + SDHCI_BUFFER;
+	sc->sc_sdhci_buffer_phys = BUS_SPACE_PHYSADDR(sc->sc_mem_res, 
+	    SDHCI_BUFFER);
 
 	bus_generic_probe(dev);
 	bus_generic_attach(dev);

Modified: head/sys/arm/include/bus.h
==============================================================================
--- head/sys/arm/include/bus.h	Sun Mar 17 01:54:35 2013	(r248406)
+++ head/sys/arm/include/bus.h	Sun Mar 17 03:04:43 2013	(r248407)
@@ -725,4 +725,12 @@ bs_c_8_proto(f);
 
 #include <machine/bus_dma.h>
 
+/*
+ * Get the physical address of a bus space memory-mapped resource.
+ * Doing this as a macro is a temporary solution until a more robust fix is
+ * designed.  It also serves to mark the locations needing that fix.
+ */
+#define BUS_SPACE_PHYSADDR(res, offs) \
+	(vtophys(rman_get_start(res)+(offs)))
+
 #endif /* _MACHINE_BUS_H_ */

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==============================================================================
--- head/sys/arm/ti/cpsw/if_cpsw.c	Sun Mar 17 01:54:35 2013	(r248406)
+++ head/sys/arm/ti/cpsw/if_cpsw.c	Sun Mar 17 03:04:43 2013	(r248407)
@@ -327,7 +327,7 @@ cpsw_debugf(const char *fmt, ...)
 #define	cpsw_cpdma_bd_offset(i)	(CPSW_CPPI_RAM_OFFSET + ((i)*16))
 
 #define	cpsw_cpdma_bd_paddr(sc, slot)				\
-	(slot->bd_offset + vtophys(rman_get_start(sc->res[0])))
+	BUS_SPACE_PHYSADDR(sc->res[0], slot->bd_offset)
 #define	cpsw_cpdma_read_bd(sc, slot, val)				\
 	bus_read_region_4(sc->res[0], slot->bd_offset, (uint32_t *) val, 4)
 #define	cpsw_cpdma_write_bd(sc, slot, val)				\

Modified: head/sys/arm/ti/ti_mmchs.c
==============================================================================
--- head/sys/arm/ti/ti_mmchs.c	Sun Mar 17 01:54:35 2013	(r248406)
+++ head/sys/arm/ti/ti_mmchs.c	Sun Mar 17 03:04:43 2013	(r248407)
@@ -1584,7 +1584,6 @@ static int
 ti_mmchs_activate(device_t dev)
 {
 	struct ti_mmchs_softc *sc = device_get_softc(dev);
-	unsigned long addr;
 	int rid;
 	int err;
 
@@ -1630,8 +1629,8 @@ ti_mmchs_activate(device_t dev)
 		panic("Unknown OMAP device\n");
 
 	/* Get the physical address of the MMC data register, needed for DMA */
-	addr = vtophys(rman_get_start(sc->sc_mem_res));
-	sc->sc_data_reg_paddr = addr + sc->sc_reg_off + MMCHS_DATA;
+	sc->sc_data_reg_paddr = BUS_SPACE_PHYSADDR(sc->sc_mem_res, 
+	    sc->sc_reg_off + MMCHS_DATA);
 
 	/* Set the initial power state to off */
 	sc->sc_cur_power_mode = power_off;


More information about the svn-src-all mailing list