Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/pccbb/pccbb.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
static int cbb_cardbus_mem_open(device_t brdev, int win, | static int cbb_cardbus_mem_open(device_t brdev, int win, | ||||
uint32_t start, uint32_t end); | uint32_t start, uint32_t end); | ||||
static void cbb_cardbus_auto_open(struct cbb_softc *sc, int type); | static void cbb_cardbus_auto_open(struct cbb_softc *sc, int type); | ||||
static int cbb_cardbus_activate_resource(device_t brdev, device_t child, | static int cbb_cardbus_activate_resource(device_t brdev, device_t child, | ||||
int type, int rid, struct resource *res); | int type, int rid, struct resource *res); | ||||
static int cbb_cardbus_deactivate_resource(device_t brdev, | static int cbb_cardbus_deactivate_resource(device_t brdev, | ||||
device_t child, int type, int rid, struct resource *res); | device_t child, int type, int rid, struct resource *res); | ||||
static struct resource *cbb_cardbus_alloc_resource(device_t brdev, | static struct resource *cbb_cardbus_alloc_resource(device_t brdev, | ||||
device_t child, int type, int *rid, u_long start, | device_t child, int type, int *rid, rman_res_t start, | ||||
u_long end, u_long count, u_int flags); | rman_res_t end, rman_res_t count, u_int flags); | ||||
static int cbb_cardbus_release_resource(device_t brdev, device_t child, | static int cbb_cardbus_release_resource(device_t brdev, device_t child, | ||||
int type, int rid, struct resource *res); | int type, int rid, struct resource *res); | ||||
static int cbb_cardbus_power_enable_socket(device_t brdev, | static int cbb_cardbus_power_enable_socket(device_t brdev, | ||||
device_t child); | device_t child); | ||||
static int cbb_cardbus_power_disable_socket(device_t brdev, | static int cbb_cardbus_power_disable_socket(device_t brdev, | ||||
device_t child); | device_t child); | ||||
static int cbb_func_filt(void *arg); | static int cbb_func_filt(void *arg); | ||||
static void cbb_func_intr(void *arg); | static void cbb_func_intr(void *arg); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
cbb_destroy_res(struct cbb_softc *sc) | cbb_destroy_res(struct cbb_softc *sc) | ||||
{ | { | ||||
struct cbb_reslist *rle; | struct cbb_reslist *rle; | ||||
while ((rle = SLIST_FIRST(&sc->rl)) != NULL) { | while ((rle = SLIST_FIRST(&sc->rl)) != NULL) { | ||||
device_printf(sc->dev, "Danger Will Robinson: Resource " | device_printf(sc->dev, "Danger Will Robinson: Resource " | ||||
"left allocated! This is a bug... " | "left allocated! This is a bug... " | ||||
"(rid=%x, type=%d, addr=%lx)\n", rle->rid, rle->type, | "(rid=%x, type=%d, addr=%jx)\n", rle->rid, rle->type, | ||||
rman_get_start(rle->res)); | rman_get_start(rle->res)); | ||||
SLIST_REMOVE_HEAD(&sc->rl, link); | SLIST_REMOVE_HEAD(&sc->rl, link); | ||||
free(rle, M_DEVBUF); | free(rle, M_DEVBUF); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Disable function interrupts by telling the bridge to generate IRQ1 | * Disable function interrupts by telling the bridge to generate IRQ1 | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
if (ret != 0) | if (ret != 0) | ||||
return (ret); | return (ret); | ||||
cbb_cardbus_auto_open(device_get_softc(brdev), type); | cbb_cardbus_auto_open(device_get_softc(brdev), type); | ||||
return (0); | return (0); | ||||
} | } | ||||
static struct resource * | static struct resource * | ||||
cbb_cardbus_alloc_resource(device_t brdev, device_t child, int type, | cbb_cardbus_alloc_resource(device_t brdev, device_t child, int type, | ||||
int *rid, u_long start, u_long end, u_long count, u_int flags) | int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct cbb_softc *sc = device_get_softc(brdev); | struct cbb_softc *sc = device_get_softc(brdev); | ||||
int tmp; | int tmp; | ||||
struct resource *res; | struct resource *res; | ||||
u_long align; | rman_res_t align; | ||||
switch (type) { | switch (type) { | ||||
case SYS_RES_IRQ: | case SYS_RES_IRQ: | ||||
tmp = rman_get_start(sc->irq_res); | tmp = rman_get_start(sc->irq_res); | ||||
if (start > tmp || end < tmp || count != 1) { | if (start > tmp || end < tmp || count != 1) { | ||||
device_printf(child, "requested interrupt %ld-%ld," | device_printf(child, "requested interrupt %jd-%jd," | ||||
"count = %ld not supported by cbb\n", | "count = %jd not supported by cbb\n", | ||||
start, end, count); | start, end, count); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
start = end = tmp; | start = end = tmp; | ||||
flags |= RF_SHAREABLE; | flags |= RF_SHAREABLE; | ||||
break; | break; | ||||
case SYS_RES_IOPORT: | case SYS_RES_IOPORT: | ||||
if (start <= cbb_start_32_io) | if (start <= cbb_start_32_io) | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
int rid, struct resource *res) | int rid, struct resource *res) | ||||
{ | { | ||||
struct cbb_softc *sc = device_get_softc(brdev); | struct cbb_softc *sc = device_get_softc(brdev); | ||||
return (exca_deactivate_resource(&sc->exca[0], child, type, rid, res)); | return (exca_deactivate_resource(&sc->exca[0], child, type, rid, res)); | ||||
} | } | ||||
static struct resource * | static struct resource * | ||||
cbb_pcic_alloc_resource(device_t brdev, device_t child, int type, int *rid, | cbb_pcic_alloc_resource(device_t brdev, device_t child, int type, int *rid, | ||||
u_long start, u_long end, u_long count, u_int flags) | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct resource *res = NULL; | struct resource *res = NULL; | ||||
struct cbb_softc *sc = device_get_softc(brdev); | struct cbb_softc *sc = device_get_softc(brdev); | ||||
int align; | int align; | ||||
int tmp; | int tmp; | ||||
switch (type) { | switch (type) { | ||||
case SYS_RES_MEMORY: | case SYS_RES_MEMORY: | ||||
Show All 13 Lines | |||||
if (start < cbb_start_16_io) | if (start < cbb_start_16_io) | ||||
start = cbb_start_16_io; | start = cbb_start_16_io; | ||||
if (end < start) | if (end < start) | ||||
end = start; | end = start; | ||||
break; | break; | ||||
case SYS_RES_IRQ: | case SYS_RES_IRQ: | ||||
tmp = rman_get_start(sc->irq_res); | tmp = rman_get_start(sc->irq_res); | ||||
if (start > tmp || end < tmp || count != 1) { | if (start > tmp || end < tmp || count != 1) { | ||||
device_printf(child, "requested interrupt %ld-%ld," | device_printf(child, "requested interrupt %jd-%jd," | ||||
"count = %ld not supported by cbb\n", | "count = %jd not supported by cbb\n", | ||||
start, end, count); | start, end, count); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
flags |= RF_SHAREABLE; | flags |= RF_SHAREABLE; | ||||
start = end = rman_get_start(sc->irq_res); | start = end = rman_get_start(sc->irq_res); | ||||
break; | break; | ||||
} | } | ||||
res = BUS_ALLOC_RESOURCE(device_get_parent(brdev), child, type, rid, | res = BUS_ALLOC_RESOURCE(device_get_parent(brdev), child, type, rid, | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
rid, r)); | rid, r)); | ||||
else | else | ||||
return (cbb_cardbus_deactivate_resource(brdev, child, type, | return (cbb_cardbus_deactivate_resource(brdev, child, type, | ||||
rid, r)); | rid, r)); | ||||
} | } | ||||
struct resource * | struct resource * | ||||
cbb_alloc_resource(device_t brdev, device_t child, int type, int *rid, | cbb_alloc_resource(device_t brdev, device_t child, int type, int *rid, | ||||
u_long start, u_long end, u_long count, u_int flags) | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct cbb_softc *sc = device_get_softc(brdev); | struct cbb_softc *sc = device_get_softc(brdev); | ||||
if (sc->flags & CBB_16BIT_CARD) | if (sc->flags & CBB_16BIT_CARD) | ||||
return (cbb_pcic_alloc_resource(brdev, child, type, rid, | return (cbb_pcic_alloc_resource(brdev, child, type, rid, | ||||
start, end, count, flags)); | start, end, count, flags)); | ||||
else | else | ||||
return (cbb_cardbus_alloc_resource(brdev, child, type, rid, | return (cbb_cardbus_alloc_resource(brdev, child, type, rid, | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |