Lines Matching +full:k2g +full:- +full:gpio

1 // SPDX-License-Identifier: GPL-2.0+
3 * GPIO driver for TI DaVinci DA8xx SOCs.
13 #include <asm/gpio.h>
14 #include <dt-bindings/gpio/gpio.h>
28 #define pinmux(x) (&davinci_syscfg_regs->pinmux[x])
313 int gpio_request(unsigned int gpio, const char *label) in gpio_request() argument
315 if (gpio >= MAX_NUM_GPIOS) in gpio_request()
316 return -1; in gpio_request()
318 if (gpio_registry[gpio].is_registered) in gpio_request()
319 return -1; in gpio_request()
321 gpio_registry[gpio].is_registered = 1; in gpio_request()
322 strncpy(gpio_registry[gpio].name, label, GPIO_NAME_SIZE); in gpio_request()
323 gpio_registry[gpio].name[GPIO_NAME_SIZE - 1] = 0; in gpio_request()
325 davinci_configure_pin_mux(&gpio_pinmux[gpio], 1); in gpio_request()
330 int gpio_free(unsigned int gpio) in gpio_free() argument
332 if (gpio >= MAX_NUM_GPIOS) in gpio_free()
333 return -1; in gpio_free()
335 if (!gpio_registry[gpio].is_registered) in gpio_free()
336 return -1; in gpio_free()
338 gpio_registry[gpio].is_registered = 0; in gpio_free()
339 gpio_registry[gpio].name[0] = '\0'; in gpio_free()
345 static int _gpio_direction_output(struct davinci_gpio *bank, unsigned int gpio, int value) in _gpio_direction_output() argument
347 clrbits_le32(&bank->dir, 1U << GPIO_BIT(gpio)); in _gpio_direction_output()
348 gpio_set_value(gpio, value); in _gpio_direction_output()
352 static int _gpio_direction_input(struct davinci_gpio *bank, unsigned int gpio) in _gpio_direction_input() argument
354 setbits_le32(&bank->dir, 1U << GPIO_BIT(gpio)); in _gpio_direction_input()
358 static int _gpio_get_value(struct davinci_gpio *bank, unsigned int gpio) in _gpio_get_value() argument
361 ip = in_le32(&bank->in_data) & (1U << GPIO_BIT(gpio)); in _gpio_get_value()
365 static int _gpio_set_value(struct davinci_gpio *bank, unsigned int gpio, int value) in _gpio_set_value() argument
368 bank->set_data = 1U << GPIO_BIT(gpio); in _gpio_set_value()
370 bank->clr_data = 1U << GPIO_BIT(gpio); in _gpio_set_value()
375 static int _gpio_get_dir(struct davinci_gpio *bank, unsigned int gpio) in _gpio_get_dir() argument
377 return in_le32(&bank->dir) & (1U << GPIO_BIT(gpio)); in _gpio_get_dir()
384 unsigned int gpio, dir, val; in gpio_info() local
387 for (gpio = 0; gpio < MAX_NUM_GPIOS; ++gpio) { in gpio_info()
388 bank = GPIO_BANK(gpio); in gpio_info()
389 dir = _gpio_get_dir(bank, gpio); in gpio_info()
390 val = gpio_get_value(gpio); in gpio_info()
393 gpio, dir ? " in" : "out", val, in gpio_info()
394 gpio_registry[gpio].is_registered ? 'x' : ' ', in gpio_info()
395 gpio_registry[gpio].name); in gpio_info()
399 int gpio_direction_input(unsigned int gpio) in gpio_direction_input() argument
403 bank = GPIO_BANK(gpio); in gpio_direction_input()
404 return _gpio_direction_input(bank, gpio); in gpio_direction_input()
407 int gpio_direction_output(unsigned int gpio, int value) in gpio_direction_output() argument
411 bank = GPIO_BANK(gpio); in gpio_direction_output()
412 return _gpio_direction_output(bank, gpio, value); in gpio_direction_output()
415 int gpio_get_value(unsigned int gpio) in gpio_get_value() argument
419 bank = GPIO_BANK(gpio); in gpio_get_value()
420 return _gpio_get_value(bank, gpio); in gpio_get_value()
423 int gpio_set_value(unsigned int gpio, int value) in gpio_set_value() argument
427 bank = GPIO_BANK(gpio); in gpio_set_value()
428 return _gpio_set_value(bank, gpio, value); in gpio_set_value()
444 addr = ((unsigned long)(struct davinci_gpio *)bank->base) + in davinci_get_gpio_bank()
454 * Fetch the address based on GPIO, but only pass the masked low 32-bits in davinci_gpio_direction_input()
502 desc->offset = args->args[0]; in davinci_gpio_xlate()
504 if (args->args[1] & GPIO_ACTIVE_LOW) in davinci_gpio_xlate()
505 desc->flags = GPIOD_ACTIVE_LOW; in davinci_gpio_xlate()
507 desc->flags = 0; in davinci_gpio_xlate()
525 const void *fdt = gd->fdt_blob; in davinci_gpio_probe()
528 uc_priv->bank_name = plat->port_name; in davinci_gpio_probe()
529 uc_priv->gpio_count = fdtdec_get_int(fdt, node, "ti,ngpio", -1); in davinci_gpio_probe()
530 bank->base = (struct davinci_gpio *)plat->base; in davinci_gpio_probe()
535 { .compatible = "ti,dm6441-gpio" },
536 { .compatible = "ti,k2g-gpio" },
547 return -EINVAL; in davinci_gpio_ofdata_to_platdata()
549 plat->base = addr; in davinci_gpio_ofdata_to_platdata()