Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/bhnd/cores/chipc/chipc.c
Show First 20 Lines • Show All 300 Lines • ▼ Show 20 Lines | chipc_add_children(struct chipc_softc *sc) | ||||
} else if (sc->caps.pwr_ctrl) { | } else if (sc->caps.pwr_ctrl) { | ||||
child = BUS_ADD_CHILD(sc->dev, 0, "bhnd_pwrctl", 0); | child = BUS_ADD_CHILD(sc->dev, 0, "bhnd_pwrctl", 0); | ||||
if (child == NULL) { | if (child == NULL) { | ||||
device_printf(sc->dev, "failed to add pwrctl\n"); | device_printf(sc->dev, "failed to add pwrctl\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
} | } | ||||
/* GPIO */ | |||||
child = BUS_ADD_CHILD(sc->dev, 0, "gpio", 0); | |||||
if (child == NULL) { | |||||
device_printf(sc->dev, "failed to add gpio\n"); | |||||
return (ENXIO); | |||||
} | |||||
error = chipc_set_mem_resource(sc, child, 0, 0, RM_MAX_END, 0, 0); | |||||
if (error) { | |||||
device_printf(sc->dev, "failed to set gpio memory resource: " | |||||
"%d\n", error); | |||||
return (error); | |||||
} | |||||
/* All remaining devices are SoC-only */ | /* All remaining devices are SoC-only */ | ||||
if (bhnd_get_attach_type(sc->dev) != BHND_ATTACH_NATIVE) | if (bhnd_get_attach_type(sc->dev) != BHND_ATTACH_NATIVE) | ||||
return (0); | return (0); | ||||
/* UARTs */ | /* UARTs */ | ||||
for (u_int i = 0; i < min(sc->caps.num_uarts, CHIPC_UART_MAX); i++) { | for (u_int i = 0; i < min(sc->caps.num_uarts, CHIPC_UART_MAX); i++) { | ||||
int irq_rid, mem_rid; | int irq_rid, mem_rid; | ||||
▲ Show 20 Lines • Show All 513 Lines • ▼ Show 20 Lines | if (!passthrough && isdefault) { | ||||
end = rle->end; | end = rle->end; | ||||
count = ulmax(count, rle->count); | count = ulmax(count, rle->count); | ||||
} | } | ||||
/* Locate a mapping region */ | /* Locate a mapping region */ | ||||
if ((cr = chipc_find_region(sc, start, end)) == NULL) { | if ((cr = chipc_find_region(sc, start, end)) == NULL) { | ||||
/* Resource requests outside our shared port regions can be | /* Resource requests outside our shared port regions can be | ||||
* delegated to our parent. */ | * delegated to our parent. */ | ||||
rv = bus_generic_rl_alloc_resource(dev, child, type, rid, | |||||
start, end, count, flags); | |||||
return (rv); | |||||
} | |||||
/* | |||||
* As a special case, children that map the complete ChipCommon register | |||||
* block are delegated to our parent. | |||||
* | |||||
* The rman API does not support sharing resources that are not | |||||
* identical in size; since we allocate subregions to various children, | |||||
* any children that need to map the entire register block (e.g. because | |||||
* they require access to discontiguous register ranges) must make the | |||||
* allocation through our parent, where we hold a compatible | |||||
* RF_SHAREABLE allocation. | |||||
*/ | |||||
if (cr == sc->core_region && cr->cr_addr == start && | |||||
cr->cr_end == end && cr->cr_count == count) | |||||
{ | |||||
rv = bus_generic_rl_alloc_resource(dev, child, type, rid, | rv = bus_generic_rl_alloc_resource(dev, child, type, rid, | ||||
start, end, count, flags); | start, end, count, flags); | ||||
return (rv); | return (rv); | ||||
} | } | ||||
/* Try to retain a region reference */ | /* Try to retain a region reference */ | ||||
if ((error = chipc_retain_region(sc, cr, RF_ALLOCATED))) | if ((error = chipc_retain_region(sc, cr, RF_ALLOCATED))) | ||||
return (NULL); | return (NULL); | ||||
▲ Show 20 Lines • Show All 575 Lines • Show Last 20 Lines |