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

Function bcm_bmips_attach

freebsd/mips/broadcom/bcm_bmips.c:106–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106static int
107bcm_bmips_attach(device_t dev)
108{
109 struct bcm_bmips_softc *sc;
110 int error;
111
112 sc = device_get_softc(dev);
113 sc->dev = dev;
114
115 /* Allocate our core's register block */
116 sc->mem_rid = 0;
117 sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid,
118 RF_ACTIVE);
119 if (sc->mem == NULL) {
120 device_printf(dev, "failed to allocate cpu register block\n");
121 error = ENXIO;
122 goto failed;
123 }
124
125 /* Determine the resource ID for our siba CFG0 registers */
126 sc->cfg_rid = bhnd_get_port_rid(dev, BHND_PORT_AGENT, 0, 0);
127 if (sc->cfg_rid == -1) {
128 device_printf(dev, "missing required cfg0 register block\n");
129 error = ENXIO;
130 goto failed;
131 }
132
133 /* Allocate our CFG0 register block */
134 sc->cfg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->cfg_rid,
135 RF_ACTIVE|RF_SHAREABLE);
136 if (sc->cfg == NULL) {
137 device_printf(dev, "failed to allocate cfg0 register block\n");
138 error = ENXIO;
139 goto failed;
140 }
141
142 /* Clear interrupt map */
143 bus_write_4(sc->cfg, SIBA_CFG0_INTVEC, 0x0); /* MIPS IRQ0 */
144 bus_write_4(sc->cfg, SIBA_CFG0_IPSFLAG, 0x0); /* MIPS IRQ1-4 */
145
146 /* Initialize the generic BHND MIPS driver state */
147 error = bcm_mips_attach(dev, BCM_BMIPS_NCPU_IRQS, BCM_BMIPS_TIMER_IRQ,
148 bcm_bmips_pic_intr);
149 if (error)
150 goto failed;
151
152 return (0);
153
154failed:
155 if (sc->mem != NULL)
156 bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem);
157
158 if (sc->cfg != NULL)
159 bus_release_resource(dev, SYS_RES_MEMORY, sc->cfg_rid, sc->cfg);
160
161 return (error);
162}
163

Callers

nothing calls this directly

Calls 5

device_get_softcFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_printfFunction · 0.85
bcm_mips_attachFunction · 0.85
bus_release_resourceFunction · 0.85

Tested by

no test coverage detected