From owner-svn-src-all@FreeBSD.ORG Sun Mar 17 03:04:44 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6ABD1F4B; Sun, 17 Mar 2013 03:04:44 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5CFBAE5C; Sun, 17 Mar 2013 03:04:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2H34iDH016882; Sun, 17 Mar 2013 03:04:44 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2H34hUu016878; Sun, 17 Mar 2013 03:04:43 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201303170304.r2H34hUu016878@svn.freebsd.org> From: Ian Lepore Date: Sun, 17 Mar 2013 03:04:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248407 - in head/sys/arm: broadcom/bcm2835 include ti ti/cpsw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Mar 2013 03:04:44 -0000 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 +/* + * 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;