mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-20 11:11:24 +00:00
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 <mst@semihalf.com> Obtained from: Semihalf
This commit is contained in:
parent
85bf4227a0
commit
2cf4c169db
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=301282
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user