From 67a23aa29fe3bf47893969fb688c4aa01f9677b4 Mon Sep 17 00:00:00 2001 From: zbb Date: Fri, 3 Jun 2016 18:54:16 +0000 Subject: [PATCH] Use proper interface for FDT parsing and memory mapping in CESA Improvements after r301220. Bus space methods are not called so simple pmap_mapdev will suffice. Use OF_getencprop to get buffer with already converted endianess. Pointed out by: ian Submitted by: Michal Stanek Obtained from: Semihalf --- sys/dev/cesa/cesa.c | 23 ++++++++++++----------- sys/dev/cesa/cesa.h | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/sys/dev/cesa/cesa.c b/sys/dev/cesa/cesa.c index ec5a973d77b2..5b3b06c478f7 100644 --- a/sys/dev/cesa/cesa.c +++ b/sys/dev/cesa/cesa.c @@ -970,29 +970,30 @@ cesa_setup_sram(struct cesa_softc *sc) pcell_t sram_handle, sram_reg[2]; int rv; - rv = OF_getprop(ofw_bus_get_node(sc->sc_dev), "sram-handle", + rv = OF_getencprop(ofw_bus_get_node(sc->sc_dev), "sram-handle", (void *)&sram_handle, sizeof(sram_handle)); if (rv <= 0) return (rv); sram_ihandle = (ihandle_t)sram_handle; - sram_ihandle = fdt32_to_cpu(sram_ihandle); sram_node = OF_instance_to_package(sram_ihandle); - rv = OF_getprop(sram_node, "reg", (void *)sram_reg, sizeof(sram_reg)); + rv = OF_getencprop(sram_node, "reg", (void *)sram_reg, sizeof(sram_reg)); if (rv <= 0) return (rv); - sc->sc_sram_base_pa = fdt32_to_cpu(sram_reg[0]); + sc->sc_sram_base_pa = sram_reg[0]; /* Store SRAM size to be able to unmap in detach() */ - sc->sc_sram_size = fdt32_to_cpu(sram_reg[1]); + sc->sc_sram_size = sram_reg[1]; #if defined(SOC_MV_ARMADA38X) + void *sram_va; + /* SRAM memory was not mapped in platform_sram_devmap(), map it now */ - rv = bus_space_map(fdtbus_bs_tag, sc->sc_sram_base_pa, sc->sc_sram_size, - 0, &(sc->sc_sram_base_va)); - if (rv != 0) - return (rv); + sram_va = pmap_mapdev(sc->sc_sram_base_pa, sc->sc_sram_size); + if (sram_va == NULL) + return (ENOMEM); + sc->sc_sram_base_va = (vm_offset_t)sram_va; #endif return (0); } @@ -1246,7 +1247,7 @@ cesa_attach(device_t dev) bus_teardown_intr(dev, sc->sc_res[RES_CESA_IRQ], sc->sc_icookie); err2: #if defined(SOC_MV_ARMADA38X) - bus_space_unmap(fdtbus_bs_tag, sc->sc_sram_base_va, sc->sc_sram_size); + pmap_unmapdev(sc->sc_sram_base_va, sc->sc_sram_size); #endif err1: bus_release_resources(dev, cesa_res_spec, sc->sc_res); @@ -1297,7 +1298,7 @@ cesa_detach(device_t dev) #if defined(SOC_MV_ARMADA38X) /* Unmap SRAM memory */ - bus_space_unmap(fdtbus_bs_tag, sc->sc_sram_base_va, sc->sc_sram_size); + pmap_unmapdev(sc->sc_sram_base_va, sc->sc_sram_size); #endif /* Destroy mutexes */ mtx_destroy(&sc->sc_sessions_lock); diff --git a/sys/dev/cesa/cesa.h b/sys/dev/cesa/cesa.h index 4819d3d98b87..e8f6372d02de 100644 --- a/sys/dev/cesa/cesa.h +++ b/sys/dev/cesa/cesa.h @@ -267,7 +267,7 @@ struct cesa_softc { /* CESA SRAM Address */ bus_addr_t sc_sram_base_pa; - bus_space_handle_t sc_sram_base_va; + vm_offset_t sc_sram_base_va; bus_size_t sc_sram_size; };