From 3e215d0a19c2a0c389bd9117573b6dd8e46f96a8 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Sat, 18 Feb 2012 01:04:55 -0700 Subject: gpio: tegra: Hide tegra_gpio_enable/disable() Recent pinctrl discussions concluded that gpiolib APIs should in fact do whatever is required to mux a GPIO onto pins, by calling pinctrl APIs if required. This change implements this for the Tegra GPIO driver, and removes calls to the Tegra-specific APIs from drivers and board files. Cc: Chris Ball Cc: linux-mmc@vger.kernel.org Signed-off-by: Stephen Warren Acked-by: Chris Ball # for sdhci-tegra.c Acked-by: Linus Walleij Acked-by: Olof Johansson --- arch/arm/mach-tegra/board-pinmux.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) (limited to 'arch/arm/mach-tegra/board-pinmux.c') diff --git a/arch/arm/mach-tegra/board-pinmux.c b/arch/arm/mach-tegra/board-pinmux.c index adc3efe979b3..3015b5a38936 100644 --- a/arch/arm/mach-tegra/board-pinmux.c +++ b/arch/arm/mach-tegra/board-pinmux.c @@ -18,7 +18,6 @@ #include #include -#include #include #include "board-pinmux.h" @@ -26,18 +25,6 @@ struct tegra_board_pinmux_conf *confs[2]; -static void tegra_board_pinmux_setup_gpios(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(confs); i++) { - if (!confs[i]) - continue; - - tegra_gpio_config(confs[i]->gpios, confs[i]->gpio_count); - } -} - static void tegra_board_pinmux_setup_pinmux(void) { int i; @@ -57,29 +44,17 @@ static void tegra_board_pinmux_setup_pinmux(void) static int tegra_board_pinmux_bus_notify(struct notifier_block *nb, unsigned long event, void *vdev) { - static bool had_gpio; - static bool had_pinmux; - struct device *dev = vdev; - const char *devname; if (event != BUS_NOTIFY_BOUND_DRIVER) return NOTIFY_DONE; - devname = dev_name(dev); + if (strcmp(dev_name(dev), PINMUX_DEV)) + return NOTIFY_DONE; - if (!had_gpio && !strcmp(devname, GPIO_DEV)) { - tegra_board_pinmux_setup_gpios(); - had_gpio = true; - } else if (!had_pinmux && !strcmp(devname, PINMUX_DEV)) { - tegra_board_pinmux_setup_pinmux(); - had_pinmux = true; - } + tegra_board_pinmux_setup_pinmux(); - if (had_gpio && had_pinmux) - return NOTIFY_STOP_MASK; - else - return NOTIFY_DONE; + return NOTIFY_STOP_MASK; } static struct notifier_block nb = { -- cgit v1.2.1 From f30d12b3ffb321c9d29bd1588940704d9bed2643 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Tue, 13 Dec 2011 15:21:01 -0700 Subject: ARM: tegra: Switch to new pinctrl driver * Rename old pinmux and new pinctrl platform driver and DT match table entries, so the new driver gets instantiated. * Re-write board-pinmux.c, so that it uses pinctrl APIs to configura the pinmux. * Re-write board-*-pinmux.c so that the pinmux configuration tables are in pinctrl format. Ventana's pin mux table needed some edits on top of the basic format conversion, since some mux options that were previously marked as reserved are now valid in the new pinctrl driver. Attempting to use the old reserved names will result in a failure. Specifically, groups lpw0, lpw2, lsc1, lsck, and lsda were changed from function rsvd4 to displaya, and group pta was changed from function rsvd2 to hdmi. All boards' pin mux tables needed some edits on top of the based format conversion, since function i2c was split into i2c1 (first general I2C controller) and i2cp (power I2C controller) to better align function definitions with HW blocks. Due to the split of mux tables into pure mux and pull/tristate tables, many entries in the separate Seaboard/Ventana tables could be merged into the common table, since the entries differed only in the portion in one of the tables, not both. Most pin groups allow configuration of mux, tri-state, and pull. However, some don't allow pull configuration, which is instead configured by new groups that only allow pull configuration. This is a reflection of the true HW capabilities, which weren't fully represented by the old pinmux driver. This required adding new pull table entries for those new groups, and setting many other entries' pull configuration to TEGRA_PINCONFIG_DONT_SET. Signed-off-by: Stephen Warren Acked-by: Linus Walleij Acked-by: Olof Johansson --- arch/arm/mach-tegra/board-pinmux.c | 76 +++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 33 deletions(-) (limited to 'arch/arm/mach-tegra/board-pinmux.c') diff --git a/arch/arm/mach-tegra/board-pinmux.c b/arch/arm/mach-tegra/board-pinmux.c index 3015b5a38936..3b7ad07fcbcb 100644 --- a/arch/arm/mach-tegra/board-pinmux.c +++ b/arch/arm/mach-tegra/board-pinmux.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011,2012, NVIDIA CORPORATION. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -18,47 +18,57 @@ #include #include -#include - #include "board-pinmux.h" #include "devices.h" -struct tegra_board_pinmux_conf *confs[2]; +unsigned long tegra_pincfg_pullnone_driven[2] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_NONE), + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_DRIVEN), +}; -static void tegra_board_pinmux_setup_pinmux(void) -{ - int i; +unsigned long tegra_pincfg_pullnone_tristate[2] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_NONE), + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_TRISTATE), +}; - for (i = 0; i < ARRAY_SIZE(confs); i++) { - if (!confs[i]) - continue; +unsigned long tegra_pincfg_pullnone_na[1] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_NONE), +}; - tegra_pinmux_config_table(confs[i]->pgs, confs[i]->pg_count); +unsigned long tegra_pincfg_pullup_driven[2] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_UP), + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_DRIVEN), +}; - if (confs[i]->drives) - tegra_drive_pinmux_config_table(confs[i]->drives, - confs[i]->drive_count); - } -} +unsigned long tegra_pincfg_pullup_tristate[2] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_UP), + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_TRISTATE), +}; -static int tegra_board_pinmux_bus_notify(struct notifier_block *nb, - unsigned long event, void *vdev) -{ - struct device *dev = vdev; +unsigned long tegra_pincfg_pullup_na[1] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_UP), +}; - if (event != BUS_NOTIFY_BOUND_DRIVER) - return NOTIFY_DONE; +unsigned long tegra_pincfg_pulldown_driven[2] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_DOWN), + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_DRIVEN), +}; - if (strcmp(dev_name(dev), PINMUX_DEV)) - return NOTIFY_DONE; +unsigned long tegra_pincfg_pulldown_tristate[2] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_DOWN), + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_TRISTATE), +}; - tegra_board_pinmux_setup_pinmux(); +unsigned long tegra_pincfg_pulldown_na[1] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_DOWN), +}; - return NOTIFY_STOP_MASK; -} +unsigned long tegra_pincfg_pullna_driven[1] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_DRIVEN), +}; -static struct notifier_block nb = { - .notifier_call = tegra_board_pinmux_bus_notify, +unsigned long tegra_pincfg_pullna_tristate[1] = { + TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_TRISTATE), }; static struct platform_device *devices[] = { @@ -69,10 +79,10 @@ static struct platform_device *devices[] = { void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a, struct tegra_board_pinmux_conf *conf_b) { - confs[0] = conf_a; - confs[1] = conf_b; - - bus_register_notifier(&platform_bus_type, &nb); + if (conf_a) + pinctrl_register_mappings(conf_a->maps, conf_a->map_count); + if (conf_b) + pinctrl_register_mappings(conf_b->maps, conf_b->map_count); if (!of_machine_is_compatible("nvidia,tegra20")) platform_add_devices(devices, ARRAY_SIZE(devices)); -- cgit v1.2.1 From ecc295bbab6b9d1baf0c0a8c2d5a945b201df547 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 15 Mar 2012 16:27:36 -0600 Subject: ARM: dt: tegra20: add pinmux to device tree This adds a complete pinmux configuration to all Tegra20 device tree files. This allows removal of board-dt-tegra20.c's use of the pinmux board files, and the special device tree handling in board-pinmux.c. Signed-off-by: Stephen Warren Acked-by: Linus Walleij Acked-by: Olof Johansson --- arch/arm/mach-tegra/board-pinmux.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'arch/arm/mach-tegra/board-pinmux.c') diff --git a/arch/arm/mach-tegra/board-pinmux.c b/arch/arm/mach-tegra/board-pinmux.c index 3b7ad07fcbcb..a5574c71b931 100644 --- a/arch/arm/mach-tegra/board-pinmux.c +++ b/arch/arm/mach-tegra/board-pinmux.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "board-pinmux.h" @@ -84,6 +83,5 @@ void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a, if (conf_b) pinctrl_register_mappings(conf_b->maps, conf_b->map_count); - if (!of_machine_is_compatible("nvidia,tegra20")) - platform_add_devices(devices, ARRAY_SIZE(devices)); + platform_add_devices(devices, ARRAY_SIZE(devices)); } -- cgit v1.2.1