Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bhnd/bcma/bcma.c
Show First 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | bcma_suspend_core(device_t dev, device_t child) | ||||
if (dinfo->res_agent == NULL) | if (dinfo->res_agent == NULL) | ||||
return (ENODEV); | return (ENODEV); | ||||
// TODO - perform suspend | // TODO - perform suspend | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
static uint32_t | |||||
bcma_read_config(device_t dev, device_t child, bus_size_t offset, u_int width) | |||||
{ | |||||
struct bcma_devinfo *dinfo; | |||||
struct bhnd_resource *r; | |||||
/* Must be a directly attached child core */ | |||||
if (device_get_parent(child) != dev) | |||||
return (UINT32_MAX); | |||||
/* Fetch the agent registers */ | |||||
dinfo = device_get_ivars(child); | |||||
if ((r = dinfo->res_agent) == NULL) | |||||
return (UINT32_MAX); | |||||
/* Verify bounds */ | |||||
if (offset > rman_get_size(r->res)) | |||||
return (UINT32_MAX); | |||||
if (rman_get_size(r->res) - offset < width) | |||||
return (UINT32_MAX); | |||||
switch (width) { | |||||
case 1: | |||||
return (bhnd_bus_read_1(r, offset)); | |||||
case 2: | |||||
return (bhnd_bus_read_2(r, offset)); | |||||
case 4: | |||||
return (bhnd_bus_read_4(r, offset)); | |||||
default: | |||||
return (UINT32_MAX); | |||||
} | |||||
} | |||||
static void | |||||
bcma_write_config(device_t dev, device_t child, bus_size_t offset, uint32_t val, | |||||
u_int width) | |||||
{ | |||||
struct bcma_devinfo *dinfo; | |||||
struct bhnd_resource *r; | |||||
/* Must be a directly attached child core */ | |||||
if (device_get_parent(child) != dev) | |||||
return; | |||||
/* Fetch the agent registers */ | |||||
dinfo = device_get_ivars(child); | |||||
if ((r = dinfo->res_agent) == NULL) | |||||
return; | |||||
/* Verify bounds */ | |||||
if (offset > rman_get_size(r->res)) | |||||
return; | |||||
if (rman_get_size(r->res) - offset < width) | |||||
return; | |||||
switch (width) { | |||||
case 1: | |||||
bhnd_bus_write_1(r, offset, val); | |||||
break; | |||||
case 2: | |||||
bhnd_bus_write_2(r, offset, val); | |||||
break; | |||||
case 4: | |||||
bhnd_bus_write_4(r, offset, val); | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
static u_int | static u_int | ||||
bcma_get_port_count(device_t dev, device_t child, bhnd_port_type type) | bcma_get_port_count(device_t dev, device_t child, bhnd_port_type type) | ||||
{ | { | ||||
struct bcma_devinfo *dinfo; | struct bcma_devinfo *dinfo; | ||||
/* delegate non-bus-attached devices to our parent */ | /* delegate non-bus-attached devices to our parent */ | ||||
if (device_get_parent(child) != dev) | if (device_get_parent(child) != dev) | ||||
return (BHND_BUS_GET_PORT_COUNT(device_get_parent(dev), child, | return (BHND_BUS_GET_PORT_COUNT(device_get_parent(dev), child, | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | while (!error) { | ||||
/* The dinfo instance now owns the corecfg value */ | /* The dinfo instance now owns the corecfg value */ | ||||
corecfg = NULL; | corecfg = NULL; | ||||
/* If pins are floating or the hardware is otherwise | /* If pins are floating or the hardware is otherwise | ||||
* unpopulated, the device shouldn't be used. */ | * unpopulated, the device shouldn't be used. */ | ||||
if (bhnd_is_hw_disabled(child)) | if (bhnd_is_hw_disabled(child)) | ||||
device_disable(child); | device_disable(child); | ||||
/* Issue bus callback for fully initialized child. */ | |||||
BHND_BUS_CHILD_ADDED(bus, child); | |||||
} | } | ||||
/* Hit EOF parsing cores? */ | /* Hit EOF parsing cores? */ | ||||
if (error == ENOENT) | if (error == ENOENT) | ||||
return (0); | return (0); | ||||
failed: | failed: | ||||
if (corecfg != NULL) | if (corecfg != NULL) | ||||
Show All 15 Lines | static device_method_t bcma_methods[] = { | ||||
DEVMETHOD(bus_get_resource_list, bcma_get_resource_list), | DEVMETHOD(bus_get_resource_list, bcma_get_resource_list), | ||||
/* BHND interface */ | /* BHND interface */ | ||||
DEVMETHOD(bhnd_bus_find_hostb_device, bcma_find_hostb_device), | DEVMETHOD(bhnd_bus_find_hostb_device, bcma_find_hostb_device), | ||||
DEVMETHOD(bhnd_bus_alloc_devinfo, bcma_alloc_bhnd_dinfo), | DEVMETHOD(bhnd_bus_alloc_devinfo, bcma_alloc_bhnd_dinfo), | ||||
DEVMETHOD(bhnd_bus_free_devinfo, bcma_free_bhnd_dinfo), | DEVMETHOD(bhnd_bus_free_devinfo, bcma_free_bhnd_dinfo), | ||||
DEVMETHOD(bhnd_bus_reset_core, bcma_reset_core), | DEVMETHOD(bhnd_bus_reset_core, bcma_reset_core), | ||||
DEVMETHOD(bhnd_bus_suspend_core, bcma_suspend_core), | DEVMETHOD(bhnd_bus_suspend_core, bcma_suspend_core), | ||||
DEVMETHOD(bhnd_bus_read_config, bcma_read_config), | |||||
DEVMETHOD(bhnd_bus_write_config, bcma_write_config), | |||||
DEVMETHOD(bhnd_bus_get_port_count, bcma_get_port_count), | DEVMETHOD(bhnd_bus_get_port_count, bcma_get_port_count), | ||||
DEVMETHOD(bhnd_bus_get_region_count, bcma_get_region_count), | DEVMETHOD(bhnd_bus_get_region_count, bcma_get_region_count), | ||||
DEVMETHOD(bhnd_bus_get_port_rid, bcma_get_port_rid), | DEVMETHOD(bhnd_bus_get_port_rid, bcma_get_port_rid), | ||||
DEVMETHOD(bhnd_bus_decode_port_rid, bcma_decode_port_rid), | DEVMETHOD(bhnd_bus_decode_port_rid, bcma_decode_port_rid), | ||||
DEVMETHOD(bhnd_bus_get_region_addr, bcma_get_region_addr), | DEVMETHOD(bhnd_bus_get_region_addr, bcma_get_region_addr), | ||||
DEVMETHOD_END | DEVMETHOD_END | ||||
}; | }; | ||||
DEFINE_CLASS_1(bhnd, bcma_driver, bcma_methods, sizeof(struct bcma_softc), bhnd_driver); | DEFINE_CLASS_1(bhnd, bcma_driver, bcma_methods, sizeof(struct bcma_softc), bhnd_driver); | ||||
MODULE_VERSION(bcma, 1); | MODULE_VERSION(bcma, 1); | ||||
MODULE_DEPEND(bcma, bhnd, 1, 1, 1); | MODULE_DEPEND(bcma, bhnd, 1, 1, 1); |