kernel: update linux 3.9 to 3.9.8
[openwrt/svn-archive/archive.git] / target / linux / lantiq / patches-3.9 / 0022-PINCTRL-add-gpio_irq-support.patch
1 From ea78e25b769740a801e259f4f6cb93fa92faa244 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sat, 29 Jun 2013 19:32:08 +0200
4 Subject: [PATCH 22/22] PINCTRL: add gpio_irq support
5
6 ---
7 drivers/pinctrl/pinctrl-xway.c | 28 ++++++++++++++++++++++++++--
8 1 file changed, 26 insertions(+), 2 deletions(-)
9
10 --- a/drivers/pinctrl/pinctrl-xway.c
11 +++ b/drivers/pinctrl/pinctrl-xway.c
12 @@ -564,10 +564,9 @@ static struct pinctrl_desc xway_pctrl_de
13 .confops = &xway_pinconf_ops,
14 };
15
16 -static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
17 +static int mux_apply(struct ltq_pinmux_info *info,
18 int pin, int mux)
19 {
20 - struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
21 int port = PORT(pin);
22 u32 alt1_reg = GPIO_ALT1(pin);
23
24 @@ -587,6 +586,14 @@ static inline int xway_mux_apply(struct
25 return 0;
26 }
27
28 +static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
29 + int pin, int mux)
30 +{
31 + struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
32 +
33 + return mux_apply(info, pin, mux);
34 +}
35 +
36 static const struct ltq_cfg_param xway_cfg_params[] = {
37 {"lantiq,pull", LTQ_PINCONF_PARAM_PULL},
38 {"lantiq,open-drain", LTQ_PINCONF_PARAM_OPEN_DRAIN},
39 @@ -631,6 +638,10 @@ static int xway_gpio_dir_out(struct gpio
40 {
41 struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
42
43 + if (PORT(pin) == PORT3)
44 + gpio_setbit(info->membase[0], GPIO3_OD, PORT_PIN(pin));
45 + else
46 + gpio_setbit(info->membase[0], GPIO_OD(pin), PORT_PIN(pin));
47 gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin));
48 xway_gpio_set(chip, pin, val);
49
50 @@ -651,6 +662,18 @@ static void xway_gpio_free(struct gpio_c
51 pinctrl_free_gpio(gpio);
52 }
53
54 +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
55 +{
56 + struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
57 + int i;
58 +
59 + for (i = 0; i < info->num_exin; i++)
60 + if (info->exin[i] == offset)
61 + return ltq_eiu_get_irq(i);
62 +
63 + return -1;
64 +}
65 +
66 static struct gpio_chip xway_chip = {
67 .label = "gpio-xway",
68 .direction_input = xway_gpio_dir_in,
69 @@ -659,6 +682,7 @@ static struct gpio_chip xway_chip = {
70 .set = xway_gpio_set,
71 .request = xway_gpio_req,
72 .free = xway_gpio_free,
73 + .to_irq = xway_gpio_to_irq,
74 .base = -1,
75 };
76