Changeset View
Changeset View
Standalone View
Standalone View
head/sys/arm/mv/mv_common.c
Show First 20 Lines • Show All 2,374 Lines • ▼ Show 20 Lines | #endif | ||||
cpu_win_tbl[t].remap = ~0; | cpu_win_tbl[t].remap = ~0; | ||||
cpu_wins_no++; | cpu_wins_no++; | ||||
debugf("sram: base = 0x%0lx size = 0x%0lx\n", sram_base, sram_size); | debugf("sram: base = 0x%0lx size = 0x%0lx\n", sram_base, sram_size); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
fdt_win_setup(void) | fdt_win_process(phandle_t child) | ||||
{ | { | ||||
phandle_t node, child, sb; | int i; | ||||
struct soc_node_spec *soc_node; | struct soc_node_spec *soc_node; | ||||
int addr_cells, size_cells; | |||||
pcell_t reg[8]; | |||||
u_long size, base; | u_long size, base; | ||||
int err, i; | |||||
sb = 0; | |||||
node = OF_finddevice("/"); | |||||
if (node == -1) | |||||
panic("fdt_win_setup: no root node"); | |||||
/* | |||||
* Traverse through all children of root and simple-bus nodes. | |||||
* For each found device retrieve decode windows data (if applicable). | |||||
*/ | |||||
child = OF_child(node); | |||||
while (child != 0) { | |||||
for (i = 0; soc_nodes[i].compat != NULL; i++) { | for (i = 0; soc_nodes[i].compat != NULL; i++) { | ||||
soc_node = &soc_nodes[i]; | soc_node = &soc_nodes[i]; | ||||
/* Setup only for enabled devices */ | /* Setup only for enabled devices */ | ||||
if (ofw_bus_node_status_okay(child) == 0) | if (ofw_bus_node_status_okay(child) == 0) | ||||
continue; | continue; | ||||
if (!ofw_bus_node_is_compatible(child,soc_node->compat)) | if (!ofw_bus_node_is_compatible(child, soc_node->compat)) | ||||
continue; | continue; | ||||
err = fdt_regsize(child, &base, &size); | if (fdt_addrsize_cells(OF_parent(child), &addr_cells, | ||||
if (err != 0) | &size_cells)) | ||||
return (err); | return (ENXIO); | ||||
if ((sizeof(pcell_t) * (addr_cells + size_cells)) > sizeof(reg)) | |||||
return (ENOMEM); | |||||
if (OF_getprop(child, "reg", ®, sizeof(reg)) <= 0) | |||||
return (EINVAL); | |||||
if (addr_cells <= 2) | |||||
base = fdt_data_get(®[0], addr_cells); | |||||
else | |||||
base = fdt_data_get(®[addr_cells - 2], 2); | |||||
size = fdt_data_get(®[addr_cells], size_cells); | |||||
base = (base & 0x000fffff) | fdt_immr_va; | base = (base & 0x000fffff) | fdt_immr_va; | ||||
if (soc_node->decode_handler != NULL) | if (soc_node->decode_handler != NULL) | ||||
soc_node->decode_handler(base); | soc_node->decode_handler(base); | ||||
else | else | ||||
return (ENXIO); | return (ENXIO); | ||||
if (MV_DUMP_WIN && (soc_node->dump_handler != NULL)) | if (MV_DUMP_WIN && (soc_node->dump_handler != NULL)) | ||||
soc_node->dump_handler(base); | soc_node->dump_handler(base); | ||||
} | |||||
return (0); | |||||
} | |||||
static int | |||||
fdt_win_setup(void) | |||||
{ | |||||
phandle_t node, child, sb; | |||||
phandle_t child_pci; | |||||
int err; | |||||
sb = 0; | |||||
node = OF_finddevice("/"); | |||||
if (node == -1) | |||||
panic("fdt_win_setup: no root node"); | |||||
/* | |||||
* Traverse through all children of root and simple-bus nodes. | |||||
* For each found device retrieve decode windows data (if applicable). | |||||
*/ | |||||
child = OF_child(node); | |||||
while (child != 0) { | |||||
/* Lookup for callback and run */ | |||||
err = fdt_win_process(child); | |||||
if (err != 0) | |||||
return (err); | |||||
/* Process Marvell Armada-XP/38x PCIe controllers */ | |||||
if (ofw_bus_node_is_compatible(child, "marvell,armada-370-pcie")) { | |||||
child_pci = OF_child(child); | |||||
while (child_pci != 0) { | |||||
err = fdt_win_process(child_pci); | |||||
if (err != 0) | |||||
return (err); | |||||
child_pci = OF_peer(child_pci); | |||||
} | |||||
} | } | ||||
/* | /* | ||||
* Once done with root-level children let's move down to | * Once done with root-level children let's move down to | ||||
* simple-bus and its children. | * simple-bus and its children. | ||||
*/ | */ | ||||
child = OF_peer(child); | child = OF_peer(child); | ||||
if ((child == 0) && (node == OF_finddevice("/"))) { | if ((child == 0) && (node == OF_finddevice("/"))) { | ||||
▲ Show 20 Lines • Show All 170 Lines • Show Last 20 Lines |