| 111 | } |
| 112 | |
| 113 | static int |
| 114 | apb_attach(device_t dev) |
| 115 | { |
| 116 | struct apb_softc *sc = device_get_softc(dev); |
| 117 | int rid = 0; |
| 118 | |
| 119 | device_set_desc(dev, "APB Bus bridge"); |
| 120 | |
| 121 | sc->apb_mem_rman.rm_type = RMAN_ARRAY; |
| 122 | sc->apb_mem_rman.rm_descr = "APB memory window"; |
| 123 | |
| 124 | if (rman_init(&sc->apb_mem_rman) != 0 || |
| 125 | rman_manage_region(&sc->apb_mem_rman, |
| 126 | AR71XX_APB_BASE, |
| 127 | AR71XX_APB_BASE + AR71XX_APB_SIZE - 1) != 0) |
| 128 | panic("apb_attach: failed to set up memory rman"); |
| 129 | |
| 130 | sc->apb_irq_rman.rm_type = RMAN_ARRAY; |
| 131 | sc->apb_irq_rman.rm_descr = "APB IRQ"; |
| 132 | |
| 133 | if (rman_init(&sc->apb_irq_rman) != 0 || |
| 134 | rman_manage_region(&sc->apb_irq_rman, |
| 135 | APB_IRQ_BASE, APB_IRQ_END) != 0) |
| 136 | panic("apb_attach: failed to set up IRQ rman"); |
| 137 | |
| 138 | if ((sc->sc_misc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, |
| 139 | RF_SHAREABLE | RF_ACTIVE)) == NULL) { |
| 140 | device_printf(dev, "unable to allocate IRQ resource\n"); |
| 141 | return (ENXIO); |
| 142 | } |
| 143 | |
| 144 | if ((bus_setup_intr(dev, sc->sc_misc_irq, INTR_TYPE_MISC, |
| 145 | apb_filter, NULL, sc, &sc->sc_misc_ih))) { |
| 146 | device_printf(dev, |
| 147 | "WARNING: unable to register interrupt handler\n"); |
| 148 | return (ENXIO); |
| 149 | } |
| 150 | |
| 151 | bus_generic_probe(dev); |
| 152 | bus_enumerate_hinted_children(dev); |
| 153 | bus_generic_attach(dev); |
| 154 | |
| 155 | /* |
| 156 | * Unmask performance counter IRQ |
| 157 | */ |
| 158 | apb_unmask_irq((void*)APB_INTR_PMC); |
| 159 | sc->sc_intr_counter[APB_INTR_PMC] = mips_intrcnt_create("apb irq5: pmc"); |
| 160 | |
| 161 | return (0); |
| 162 | } |
| 163 | |
| 164 | static struct resource * |
| 165 | apb_alloc_resource(device_t bus, device_t child, int type, int *rid, |
nothing calls this directly
no test coverage detected