aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-u300.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2012-11-20 08:28:07 -0500
committerLinus Walleij <linus.walleij@linaro.org>2012-11-21 02:55:17 -0500
commit387923c585ac68ff51e6bf673807438b5e5fdaf3 (patch)
tree1e6faaf633d5d647135ae8f86d45bd103d242fee /drivers/pinctrl/pinctrl-u300.c
parent9afbefb227792a3c195085d662050dcca748f521 (diff)
pinctrl/u300/coh901: let the gpio_chip register the range
Instead of having the pinctrl driver register the GPIO range for the gpio_chip, making it necessary to instantiate the pin controller from the GPIO driver and pass the GPIO chip as platform data, now let the GPIO chip driver register it's own ranges and have the pinctrl driver look up the GPIO chip from the pinctrl core as necessary. Reviewed-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-u300.c')
-rw-r--r--drivers/pinctrl/pinctrl-u300.c55
1 files changed, 4 insertions, 51 deletions
diff --git a/drivers/pinctrl/pinctrl-u300.c b/drivers/pinctrl/pinctrl-u300.c
index d756cce588fd..b84de03ed54d 100644
--- a/drivers/pinctrl/pinctrl-u300.c
+++ b/drivers/pinctrl/pinctrl-u300.c
@@ -1011,51 +1011,11 @@ static struct pinmux_ops u300_pmx_ops = {
1011 .disable = u300_pmx_disable, 1011 .disable = u300_pmx_disable,
1012}; 1012};
1013 1013
1014/*
1015 * GPIO ranges handled by the application-side COH901XXX GPIO controller
1016 * Very many pins can be converted into GPIO pins, but we only list those
1017 * that are useful in practice to cut down on tables.
1018 */
1019#define U300_GPIO_RANGE(a, b, c) { .name = "COH901XXX", .id = a, .base= a, \
1020 .pin_base = b, .npins = c }
1021
1022static struct pinctrl_gpio_range u300_gpio_ranges[] = {
1023 U300_GPIO_RANGE(10, 426, 1),
1024 U300_GPIO_RANGE(11, 180, 1),
1025 U300_GPIO_RANGE(12, 165, 1), /* MS/MMC card insertion */
1026 U300_GPIO_RANGE(13, 179, 1),
1027 U300_GPIO_RANGE(14, 178, 1),
1028 U300_GPIO_RANGE(16, 194, 1),
1029 U300_GPIO_RANGE(17, 193, 1),
1030 U300_GPIO_RANGE(18, 192, 1),
1031 U300_GPIO_RANGE(19, 191, 1),
1032 U300_GPIO_RANGE(20, 186, 1),
1033 U300_GPIO_RANGE(21, 185, 1),
1034 U300_GPIO_RANGE(22, 184, 1),
1035 U300_GPIO_RANGE(23, 183, 1),
1036 U300_GPIO_RANGE(24, 182, 1),
1037 U300_GPIO_RANGE(25, 181, 1),
1038};
1039
1040static struct pinctrl_gpio_range *u300_match_gpio_range(unsigned pin)
1041{
1042 int i;
1043
1044 for (i = 0; i < ARRAY_SIZE(u300_gpio_ranges); i++) {
1045 struct pinctrl_gpio_range *range;
1046
1047 range = &u300_gpio_ranges[i];
1048 if (pin >= range->pin_base &&
1049 pin <= (range->pin_base + range->npins - 1))
1050 return range;
1051 }
1052 return NULL;
1053}
1054
1055static int u300_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin, 1014static int u300_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin,
1056 unsigned long *config) 1015 unsigned long *config)
1057{ 1016{
1058 struct pinctrl_gpio_range *range = u300_match_gpio_range(pin); 1017 struct pinctrl_gpio_range *range =
1018 pinctrl_find_gpio_range_from_pin(pctldev, pin);
1059 1019
1060 /* We get config for those pins we CAN get it for and that's it */ 1020 /* We get config for those pins we CAN get it for and that's it */
1061 if (!range) 1021 if (!range)
@@ -1069,7 +1029,8 @@ static int u300_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin,
1069static int u300_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin, 1029static int u300_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
1070 unsigned long config) 1030 unsigned long config)
1071{ 1031{
1072 struct pinctrl_gpio_range *range = u300_match_gpio_range(pin); 1032 struct pinctrl_gpio_range *range =
1033 pinctrl_find_gpio_range_from_pin(pctldev, pin);
1073 int ret; 1034 int ret;
1074 1035
1075 if (!range) 1036 if (!range)
@@ -1105,8 +1066,6 @@ static int __devinit u300_pmx_probe(struct platform_device *pdev)
1105{ 1066{
1106 struct u300_pmx *upmx; 1067 struct u300_pmx *upmx;
1107 struct resource *res; 1068 struct resource *res;
1108 struct gpio_chip *gpio_chip = dev_get_platdata(&pdev->dev);
1109 int i;
1110 1069
1111 /* Create state holders etc for this driver */ 1070 /* Create state holders etc for this driver */
1112 upmx = devm_kzalloc(&pdev->dev, sizeof(*upmx), GFP_KERNEL); 1071 upmx = devm_kzalloc(&pdev->dev, sizeof(*upmx), GFP_KERNEL);
@@ -1129,12 +1088,6 @@ static int __devinit u300_pmx_probe(struct platform_device *pdev)
1129 return -EINVAL; 1088 return -EINVAL;
1130 } 1089 }
1131 1090
1132 /* We will handle a range of GPIO pins */
1133 for (i = 0; i < ARRAY_SIZE(u300_gpio_ranges); i++) {
1134 u300_gpio_ranges[i].gc = gpio_chip;
1135 pinctrl_add_gpio_range(upmx->pctl, &u300_gpio_ranges[i]);
1136 }
1137
1138 platform_set_drvdata(pdev, upmx); 1091 platform_set_drvdata(pdev, upmx);
1139 1092
1140 dev_info(&pdev->dev, "initialized U300 pin control driver\n"); 1093 dev_info(&pdev->dev, "initialized U300 pin control driver\n");