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

Function rk_pinctrl_attach

freebsd/arm64/rockchip/rk_pinctrl.c:1223–1317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1221}
1222
1223static int
1224rk_pinctrl_attach(device_t dev)
1225{
1226 struct rk_pinctrl_softc *sc;
1227 phandle_t node;
1228 device_t cdev;
1229 char *gpio_name, *eptr;
1230 int rv;
1231
1232 sc = device_get_softc(dev);
1233 sc->dev = dev;
1234
1235 node = ofw_bus_get_node(dev);
1236
1237 if (OF_hasprop(node, "rockchip,grf") &&
1238 syscon_get_by_ofw_property(dev, node,
1239 "rockchip,grf", &sc->grf) != 0) {
1240 device_printf(dev, "cannot get grf driver handle\n");
1241 return (ENXIO);
1242 }
1243
1244 /* RK3399,RK3288 has banks in PMU. RK3328 does not have a PMU. */
1245 if (ofw_bus_node_is_compatible(node, "rockchip,rk3399-pinctrl") ||
1246 ofw_bus_node_is_compatible(node, "rockchip,rk3288-pinctrl")) {
1247 if (OF_hasprop(node, "rockchip,pmu") &&
1248 syscon_get_by_ofw_property(dev, node,
1249 "rockchip,pmu", &sc->pmu) != 0) {
1250 device_printf(dev, "cannot get pmu driver handle\n");
1251 return (ENXIO);
1252 }
1253 }
1254
1255 mtx_init(&sc->mtx, "rk pinctrl", "pinctrl", MTX_SPIN);
1256
1257 sc->conf = (struct rk_pinctrl_conf *)ofw_bus_search_compatible(dev,
1258 compat_data)->ocd_data;
1259
1260 fdt_pinctrl_register(dev, "rockchip,pins");
1261
1262 simplebus_init(dev, node);
1263
1264 bus_generic_probe(dev);
1265
1266 /* Attach child devices */
1267 for (node = OF_child(node); node > 0; node = OF_peer(node)) {
1268 if (!ofw_bus_node_is_compatible(node, "rockchip,gpio-bank"))
1269 continue;
1270
1271 rv = OF_getprop_alloc(node, "name", (void **)&gpio_name);
1272 if (rv <= 0) {
1273 device_printf(sc->dev, "Cannot GPIO subdevice name.\n");
1274 continue;
1275 }
1276
1277 cdev = simplebus_add_device(dev, node, 0, NULL, -1, NULL);
1278 if (cdev == NULL) {
1279 device_printf(dev, " Cannot add GPIO subdevice: %s\n",
1280 gpio_name);

Callers

nothing calls this directly

Calls 8

device_get_softcFunction · 0.85
device_printfFunction · 0.85
mtx_initFunction · 0.85
bus_generic_probeFunction · 0.85
device_probe_and_attachFunction · 0.85
strsepFunction · 0.85
rk_pinctrl_register_gpioFunction · 0.85
bus_generic_attachFunction · 0.85

Tested by

no test coverage detected