MCPcopy Create free account
hub / github.com/F-Stack/f-stack / apb_attach

Function apb_attach

freebsd/mips/atheros/apb.c:113–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113static int
114apb_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
164static struct resource *
165apb_alloc_resource(device_t bus, device_t child, int type, int *rid,

Callers

nothing calls this directly

Calls 13

device_get_softcFunction · 0.85
device_set_descFunction · 0.85
rman_initFunction · 0.85
rman_manage_regionFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_printfFunction · 0.85
bus_setup_intrFunction · 0.85
bus_generic_probeFunction · 0.85
bus_generic_attachFunction · 0.85
apb_unmask_irqFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected