diff options
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/Kconfig | 26 | ||||
-rw-r--r-- | drivers/gpio/Makefile | 4 | ||||
-rw-r--r-- | drivers/gpio/gpio-uclass.c | 28 | ||||
-rw-r--r-- | drivers/gpio/intel_gpio.c | 2 | ||||
-rw-r--r-- | drivers/gpio/mxs_gpio.c | 4 | ||||
-rw-r--r-- | drivers/gpio/omap_gpio.c | 4 | ||||
-rw-r--r-- | drivers/gpio/sandbox.c | 14 | ||||
-rw-r--r-- | drivers/gpio/sandbox_test.c | 21 | ||||
-rw-r--r-- | drivers/gpio/tegra_gpio.c | 10 |
9 files changed, 82 insertions, 31 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index e37ac9f4941..f0439e24178 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -2,7 +2,19 @@ # GPIO infrastructure and drivers # -menu "GPIO Support" +menuconfig GPIO + bool "GPIO support" + default y + help + Enable support for GPIOs (General-purpose Input/Output) in U-Boot. + GPIOs allow U-Boot to read the state of an input line (high or + low) and set the state of an output line. This can be used to + drive LEDs, control power to various system parts and read user + input. GPIOs can be useful to enable a 'sign-of-life' LED, + for example. Enable this option to build the drivers in + drivers/gpio as part of an U-Boot build. + +if GPIO config DM_GPIO bool "Enable Driver Model for GPIO drivers" @@ -39,7 +51,6 @@ config TPL_DM_GPIO config GPIO_HOG bool "Enable GPIO hog support" depends on DM_GPIO - default n help Enable gpio hog support The GPIO chip may contain GPIO hog definitions. GPIO hogging @@ -91,13 +102,11 @@ config CORTINA_GPIO config DWAPB_GPIO bool "DWAPB GPIO driver" depends on DM && DM_GPIO - default n help Support for the Designware APB GPIO driver. config AT91_GPIO bool "AT91 PIO GPIO driver" - default n help Say yes here to select AT91 PIO GPIO driver. AT91 PIO controller manages up to 32 fully programmable input/output @@ -110,7 +119,6 @@ config AT91_GPIO config ATMEL_PIO4 bool "ATMEL PIO4 driver" depends on DM_GPIO - default n help Say yes here to support the Atmel PIO4 driver. The PIO4 is new version of Atmel PIO controller, which manages @@ -150,13 +158,11 @@ config INTEL_ICH6_GPIO config IMX_RGPIO2P bool "i.MX7ULP RGPIO2P driver" depends on DM - default n help This driver supports i.MX7ULP Rapid GPIO2P controller. config IPROC_GPIO bool "Broadcom iProc GPIO driver(without pinconf)" - default n help The Broadcom iProc based SoCs- Cygnus, NS2, NS3, NSP and Stingray, use the same GPIO Controller IP hence this driver could be used @@ -168,14 +174,12 @@ config IPROC_GPIO config HSDK_CREG_GPIO bool "HSDK CREG GPIO griver" depends on DM_GPIO - default n help This driver supports CREG GPIOs on Synopsys HSDK SOC. config LPC32XX_GPIO bool "LPC32XX GPIO driver" depends on DM - default n help Support for the LPC32XX GPIO driver. @@ -203,7 +207,6 @@ config MSCC_SGPIO config MSM_GPIO bool "Qualcomm GPIO driver" depends on DM_GPIO - default n help Support GPIO controllers on Qualcomm Snapdragon family of SoCs. This controller have single bank (default name "soc"), every @@ -345,7 +348,6 @@ config GPIO_UNIPHIER config VYBRID_GPIO bool "Vybrid GPIO driver" depends on DM - default n help Say yes here to support Vybrid vf610 GPIOs. @@ -513,4 +515,4 @@ config NOMADIK_GPIO into a number of banks each with 32 GPIOs. The GPIOs for a device are defined in the device tree with one node for each bank. -endmenu +endif diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 58f4704f6bc..18917488c21 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -33,7 +33,7 @@ obj-$(CONFIG_ROCKCHIP_GPIO) += rk_gpio.o obj-$(CONFIG_RCAR_GPIO) += gpio-rcar.o obj-$(CONFIG_RZA1_GPIO) += gpio-rza1.o obj-$(CONFIG_S5P) += s5p_gpio.o -obj-$(CONFIG_SANDBOX_GPIO) += sandbox.o +obj-$(CONFIG_SANDBOX_GPIO) += sandbox.o sandbox_test.o obj-$(CONFIG_TEGRA_GPIO) += tegra_gpio.o obj-$(CONFIG_TEGRA186_GPIO) += tegra186_gpio.o obj-$(CONFIG_DA8XX_GPIO) += da8xx_gpio.o @@ -62,7 +62,7 @@ obj-$(CONFIG_OCTEON_GPIO) += octeon_gpio.o obj-$(CONFIG_MVEBU_GPIO) += mvebu_gpio.o obj-$(CONFIG_MSM_GPIO) += msm_gpio.o obj-$(CONFIG_$(SPL_)PCF8575_GPIO) += pcf8575_gpio.o -obj-$(CONFIG_PM8916_GPIO) += pm8916_gpio.o +obj-$(CONFIG_$(SPL_TPL_)PM8916_GPIO) += pm8916_gpio.o obj-$(CONFIG_MT7620_GPIO) += mt7620_gpio.o obj-$(CONFIG_MT7621_GPIO) += mt7621_gpio.o obj-$(CONFIG_MSCC_SGPIO) += mscc_sgpio.o diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 8c77777dbe3..bb2f23241ed 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -7,6 +7,7 @@ #include <common.h> #include <dm.h> +#include <dt-structs.h> #include <log.h> #include <dm/devres.h> #include <dm/device_compat.h> @@ -231,7 +232,7 @@ static int gpio_find_and_xlate(struct gpio_desc *desc, return gpio_xlate_offs_flags(desc->dev, desc, args); } -#if defined(CONFIG_GPIO_HOG) +#if CONFIG_IS_ENABLED(GPIO_HOG) struct gpio_hog_priv { struct gpio_desc gpiod; @@ -1137,7 +1138,7 @@ err: return ret; } -#if !CONFIG_IS_ENABLED(OF_PLATDATA) +#if CONFIG_IS_ENABLED(OF_REAL) static int _gpio_request_by_name_nodev(ofnode node, const char *list_name, int index, struct gpio_desc *desc, int flags, bool add_index) @@ -1226,6 +1227,27 @@ int gpio_get_list_count(struct udevice *dev, const char *list_name) } #endif /* OF_PLATDATA */ +#if CONFIG_IS_ENABLED(OF_PLATDATA) +int gpio_request_by_phandle(struct udevice *dev, + const struct phandle_2_arg *cells, + struct gpio_desc *desc, int flags) +{ + struct ofnode_phandle_args args; + struct udevice *gpio_dev; + const int index = 0; + int ret; + + ret = device_get_by_ofplat_idx(cells->idx, &gpio_dev); + if (ret) + return ret; + args.args[0] = cells->arg[0]; + args.args[1] = cells->arg[1]; + + return gpio_request_tail(ret, NULL, &args, NULL, index, desc, flags, + index > 0, gpio_dev); +} +#endif + int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc) { /* For now, we don't do any checking of dev */ @@ -1430,7 +1452,7 @@ static int gpio_post_bind(struct udevice *dev) } #endif - if (IS_ENABLED(CONFIG_GPIO_HOG)) { + if (CONFIG_IS_ENABLED(OF_REAL) && IS_ENABLED(CONFIG_GPIO_HOG)) { dev_for_each_subnode(node, dev) { if (ofnode_read_bool(node, "gpio-hog")) { const char *name = ofnode_get_name(node); diff --git a/drivers/gpio/intel_gpio.c b/drivers/gpio/intel_gpio.c index f15ce7b59ee..4a3ec6d6350 100644 --- a/drivers/gpio/intel_gpio.c +++ b/drivers/gpio/intel_gpio.c @@ -204,7 +204,7 @@ static const struct dm_gpio_ops gpio_intel_ops = { #endif }; -#if !CONFIG_IS_ENABLED(OF_PLATDATA) +#if CONFIG_IS_ENABLED(OF_REAL) static const struct udevice_id intel_intel_gpio_ids[] = { { .compatible = "intel,gpio" }, { } diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c index 7b9d88a8a75..1356f89ac2f 100644 --- a/drivers/gpio/mxs_gpio.c +++ b/drivers/gpio/mxs_gpio.c @@ -262,7 +262,7 @@ static int mxs_gpio_probe(struct udevice *dev) return 0; } -#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) +#if CONFIG_IS_ENABLED(OF_REAL) static int mxs_of_to_plat(struct udevice *dev) { struct mxs_gpio_plat *plat = dev_get_plat(dev); @@ -301,7 +301,7 @@ U_BOOT_DRIVER(fsl_imx23_gpio) = { .probe = mxs_gpio_probe, .priv_auto = sizeof(struct mxs_gpio_priv), .plat_auto = sizeof(struct mxs_gpio_plat), -#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) +#if CONFIG_IS_ENABLED(OF_REAL) .of_match = mxs_gpio_ids, .of_to_plat = mxs_of_to_plat, #endif diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index 316a28efa6b..50c4f75ddf5 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -336,7 +336,7 @@ static int omap_gpio_bind(struct udevice *dev) } #endif -#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) +#if CONFIG_IS_ENABLED(OF_REAL) static const struct udevice_id omap_gpio_ids[] = { { .compatible = "ti,omap3-gpio" }, { .compatible = "ti,omap4-gpio" }, @@ -362,7 +362,7 @@ U_BOOT_DRIVER(gpio_omap) = { .name = "gpio_omap", .id = UCLASS_GPIO, #if CONFIG_IS_ENABLED(OF_CONTROL) -#if !CONFIG_IS_ENABLED(OF_PLATDATA) +#if CONFIG_IS_ENABLED(OF_REAL) .of_match = omap_gpio_ids, .of_to_plat = of_match_ptr(omap_gpio_of_to_plat), .plat_auto = sizeof(struct omap_gpio_plat), diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c index d008fdd2224..106b2a7b27c 100644 --- a/drivers/gpio/sandbox.c +++ b/drivers/gpio/sandbox.c @@ -323,11 +323,13 @@ static const struct dm_gpio_ops gpio_sandbox_ops = { static int sandbox_gpio_of_to_plat(struct udevice *dev) { - struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + if (CONFIG_IS_ENABLED(OF_REAL)) { + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - uc_priv->gpio_count = dev_read_u32_default(dev, "sandbox,gpio-count", - 0); - uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); + uc_priv->gpio_count = + dev_read_u32_default(dev, "sandbox,gpio-count", 0); + uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); + } return 0; } @@ -371,6 +373,8 @@ U_BOOT_DRIVER(sandbox_gpio) = { DM_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias) +#if CONFIG_IS_ENABLED(PINCTRL) + /* pincontrol: used only to check GPIO pin configuration (pinmux command) */ struct sb_pinctrl_priv { @@ -579,3 +583,5 @@ U_BOOT_DRIVER(sandbox_pinctrl_gpio) = { .priv_auto = sizeof(struct sb_pinctrl_priv), ACPI_OPS_PTR(&pinctrl_sandbox_acpi_ops) }; + +#endif /* PINCTRL */ diff --git a/drivers/gpio/sandbox_test.c b/drivers/gpio/sandbox_test.c new file mode 100644 index 00000000000..c76e1997419 --- /dev/null +++ b/drivers/gpio/sandbox_test.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Sandbox driver for testing GPIOs with of-platdata + * + * Copyright 2021 Google LLC + */ + +#include <common.h> +#include <dm.h> +#include <asm-generic/gpio.h> + +static const struct udevice_id sandbox_gpio_test_ids[] = { + { .compatible = "sandbox,gpio-test" }, + { } +}; + +U_BOOT_DRIVER(sandbox_gpio_test) = { + .name = "sandbox_gpio_test", + .id = UCLASS_MISC, + .of_match = sandbox_gpio_test_ids, +}; diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c index 5d3af8a016d..e00f104b9f3 100644 --- a/drivers/gpio/tegra_gpio.c +++ b/drivers/gpio/tegra_gpio.c @@ -23,8 +23,8 @@ #include <dm/device-internal.h> #include <dt-bindings/gpio/gpio.h> -static const int CONFIG_SFIO = 0; -static const int CONFIG_GPIO = 1; +static const int CFG_SFIO = 0; +static const int CFG_GPIO = 1; static const int DIRECTION_INPUT = 0; static const int DIRECTION_OUTPUT = 1; @@ -54,7 +54,7 @@ static int get_config(unsigned gpio) debug("get_config: port = %d, bit = %d is %s\n", GPIO_FULLPORT(gpio), GPIO_BIT(gpio), type ? "GPIO" : "SFPIO"); - return type ? CONFIG_GPIO : CONFIG_SFIO; + return type ? CFG_GPIO : CFG_SFIO; } /* Config pin 'gpio' as GPIO or SFIO, based on 'type' */ @@ -68,7 +68,7 @@ static void set_config(unsigned gpio, int type) GPIO_FULLPORT(gpio), GPIO_BIT(gpio), type ? "GPIO" : "SFPIO"); u = readl(&bank->gpio_config[GPIO_PORT(gpio)]); - if (type != CONFIG_SFIO) + if (type != CFG_SFIO) u |= 1 << GPIO_BIT(gpio); else u &= ~(1 << GPIO_BIT(gpio)); @@ -216,7 +216,7 @@ void gpio_config_table(const struct tegra_gpio_config *config, int len) set_direction(config[i].gpio, DIRECTION_OUTPUT); break; } - set_config(config[i].gpio, CONFIG_GPIO); + set_config(config[i].gpio, CFG_GPIO); } } |