Lines Matching +full:shared +full:- +full:pin

1 /*-
53 /* GPIO list for shared pins. */
96 * The GPIO pin is registerd and reseved for first consumer, all others share
106 busdev = GPIO_GET_BUS(gpio_pin->dev); in regnode_get_gpio_entry()
115 if (tmp->gpio_pin.dev == gpio_pin->dev && in regnode_get_gpio_entry()
116 tmp->gpio_pin.pin == gpio_pin->pin) { in regnode_get_gpio_entry()
117 tmp->use_cnt++; in regnode_get_gpio_entry()
124 /* Reserve pin. */ in regnode_get_gpio_entry()
126 rv = gpiobus_acquire_pin(busdev, gpio_pin->pin); in regnode_get_gpio_entry()
133 entry->gpio_pin = *gpio_pin; in regnode_get_gpio_entry()
134 entry->use_cnt = 1; in regnode_get_gpio_entry()
150 struct gpiobus_pin *pin; in regnode_fixed_init() local
156 sc->param = regnode_get_stdparam(regnode); in regnode_fixed_init()
157 if (sc->gpio_entry == NULL) in regnode_fixed_init()
159 pin = &sc->gpio_entry->gpio_pin; in regnode_fixed_init()
162 if (sc->gpio_open_drain) in regnode_fixed_init()
164 if (sc->param->boot_on || sc->param->always_on) { in regnode_fixed_init()
165 rv = GPIO_PIN_SET(pin->dev, pin->pin, sc->param->enable_active_high); in regnode_fixed_init()
167 device_printf(dev, "Cannot set GPIO pin: %d\n", in regnode_fixed_init()
168 pin->pin); in regnode_fixed_init()
173 rv = GPIO_PIN_SETFLAGS(pin->dev, pin->pin, flags); in regnode_fixed_init()
175 device_printf(dev, "Cannot configure GPIO pin: %d\n", pin->pin); in regnode_fixed_init()
184 * Take shared GPIO pins in account
191 struct gpiobus_pin *pin; in regnode_fixed_enable() local
198 if (sc->gpio_entry == NULL) in regnode_fixed_enable()
200 pin = &sc->gpio_entry->gpio_pin; in regnode_fixed_enable()
202 sc->gpio_entry->enable_cnt++; in regnode_fixed_enable()
203 if (sc->gpio_entry->enable_cnt > 1) in regnode_fixed_enable()
206 KASSERT(sc->gpio_entry->enable_cnt > 0, in regnode_fixed_enable()
208 sc->gpio_entry->enable_cnt--; in regnode_fixed_enable()
209 if (sc->gpio_entry->enable_cnt >= 1) in regnode_fixed_enable()
212 if (sc->gpio_entry->always_on && !enable) in regnode_fixed_enable()
214 if (!sc->param->enable_active_high) in regnode_fixed_enable()
216 rv = GPIO_PIN_SET(pin->dev, pin->pin, enable); in regnode_fixed_enable()
218 device_printf(dev, "Cannot set GPIO pin: %d\n", pin->pin); in regnode_fixed_enable()
221 *udelay = sc->param->enable_delay; in regnode_fixed_enable()
227 * Take shared GPIO pins in account
234 struct gpiobus_pin *pin; in regnode_fixed_stop() local
241 if (sc->gpio_entry == NULL) in regnode_fixed_stop()
243 if (sc->gpio_entry->always_on) in regnode_fixed_stop()
245 pin = &sc->gpio_entry->gpio_pin; in regnode_fixed_stop()
246 if (sc->gpio_entry->enable_cnt > 0) { in regnode_fixed_stop()
251 rv = GPIO_PIN_SET(pin->dev, pin->pin, in regnode_fixed_stop()
252 sc->param->enable_active_high ? false: true); in regnode_fixed_stop()
254 device_printf(dev, "Cannot set GPIO pin: %d\n", pin->pin); in regnode_fixed_stop()
257 *udelay = sc->param->enable_delay; in regnode_fixed_stop()
265 struct gpiobus_pin *pin; in regnode_fixed_status() local
272 if (sc->gpio_entry == NULL) { in regnode_fixed_status()
276 pin = &sc->gpio_entry->gpio_pin; in regnode_fixed_status()
278 rv = GPIO_PIN_GET(pin->dev, pin->pin, &val); in regnode_fixed_status()
280 if (!sc->param->enable_active_high ^ (val != 0)) in regnode_fixed_status()
292 *uvolt = sc->param->min_uvolt; in regnode_fixed_get_voltage()
303 &init_def->reg_init_def); in regnode_fixed_register()
309 sc->gpio_open_drain = init_def->gpio_open_drain; in regnode_fixed_register()
310 if (init_def->gpio_pin != NULL) { in regnode_fixed_register()
311 sc->gpio_entry = regnode_get_gpio_entry(init_def->gpio_pin); in regnode_fixed_register()
312 if (sc->gpio_entry == NULL) in regnode_fixed_register()
321 if (sc->gpio_entry != NULL) in regnode_fixed_register()
322 sc->gpio_entry->always_on |= sc->param->always_on; in regnode_fixed_register()
344 {"regulator-fixed", 1},
356 if (sc->gpio_prodxref == 0) in regfix_get_gpio()
359 node = ofw_bus_get_node(sc->dev); in regfix_get_gpio()
362 sc->gpio_pin.dev = OF_device_from_xref(sc->gpio_prodxref); in regfix_get_gpio()
363 if (sc->gpio_pin.dev == NULL) in regfix_get_gpio()
367 busdev = GPIO_GET_BUS(sc->gpio_pin.dev); in regfix_get_gpio()
371 rv = gpio_map_gpios(sc->gpio_pin.dev, node, in regfix_get_gpio()
372 OF_node_from_xref(sc->gpio_prodxref), sc->gpio_ncells, in regfix_get_gpio()
373 sc->gpio_cells, &(sc->gpio_pin.pin), &(sc->gpio_pin.flags)); in regfix_get_gpio()
375 device_printf(sc->dev, "Cannot map the gpio property.\n"); in regfix_get_gpio()
378 sc->init_def.gpio_pin = &sc->gpio_pin; in regfix_get_gpio()
389 node = ofw_bus_get_node(sc->dev); in regfix_parse_fdt()
390 init_def = &sc->init_def.reg_init_def; in regfix_parse_fdt()
392 rv = regulator_parse_ofw_stdparam(sc->dev, node, init_def); in regfix_parse_fdt()
394 device_printf(sc->dev, "Cannot parse standard parameters.\n"); in regfix_parse_fdt()
398 if (init_def->std_param.min_uvolt != init_def->std_param.max_uvolt) { in regfix_parse_fdt()
399 device_printf(sc->dev, "min_uvolt != max_uvolt\n"); in regfix_parse_fdt()
402 /* Fixed regulator uses 'startup-delay-us' property for enable_delay */ in regfix_parse_fdt()
403 rv = OF_getencprop(node, "startup-delay-us", in regfix_parse_fdt()
404 &init_def->std_param.enable_delay, in regfix_parse_fdt()
405 sizeof(init_def->std_param.enable_delay)); in regfix_parse_fdt()
407 init_def->std_param.enable_delay = 0; in regfix_parse_fdt()
408 /* GPIO pin */ in regfix_parse_fdt()
409 if (OF_hasprop(node, "gpio-open-drain")) in regfix_parse_fdt()
410 sc->init_def.gpio_open_drain = true; in regfix_parse_fdt()
414 rv = ofw_bus_parse_xref_list_alloc(node, "gpio", "#gpio-cells", 0, in regfix_parse_fdt()
415 &sc->gpio_prodxref, &sc->gpio_ncells, &sc->gpio_cells); in regfix_parse_fdt()
417 sc->gpio_prodxref = 0; in regfix_parse_fdt()
418 device_printf(sc->dev, "Malformed gpio property\n"); in regfix_parse_fdt()
433 if (sc->attach_done) in regfix_new_pass()
442 regnode_fixed_register(sc->dev, &sc->init_def); in regfix_new_pass()
443 sc->attach_done = true; in regfix_new_pass()
453 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) in regfix_probe()
475 sc->dev = dev; in regfix_attach()
483 sc->init_def.reg_init_def.id = 1; in regfix_attach()
484 sc->init_def.reg_init_def.flags = REGULATOR_FLAGS_STATIC; in regfix_attach()
492 regnode_fixed_register(sc->dev, &sc->init_def); in regfix_attach()
493 sc->attach_done = true; in regfix_attach()