sunxi: initial 3.14 patchset
[15.05/openwrt.git] / target / linux / sunxi / patches-3.14 / 137-1-pinctrl-create-irq-pin-mapping.patch
1 From 4c228d02d1339a286e259893062ea445be82b573 Mon Sep 17 00:00:00 2001
2 From: Chen-Yu Tsai <wens@csie.org>
3 Date: Tue, 7 Jan 2014 18:56:29 +0800
4 Subject: [PATCH] pinctrl: sunxi: create irq/pin mapping during init
5
6 The irq/pin mapping is used to lookup the pin to mux to the irq
7 function when the irq is enabled. It is created when gpio_to_irq
8 is called. Creating the mapping during init allows us to map the
9 interrupts directly from the device tree.
10
11 Signed-off-by: Chen-Yu Tsai <wens@csie.org>
12 ---
13  drivers/pinctrl/pinctrl-sunxi.c | 5 +++--
14  1 file changed, 3 insertions(+), 2 deletions(-)
15
16 diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
17 index d16da53..067e7e10 100644
18 --- a/drivers/pinctrl/pinctrl-sunxi.c
19 +++ b/drivers/pinctrl/pinctrl-sunxi.c
20 @@ -531,8 +531,6 @@ static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
21         if (!desc)
22                 return -EINVAL;
23  
24 -       pctl->irq_array[desc->irqnum] = offset;
25 -
26         dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n",
27                 chip->label, offset + chip->base, desc->irqnum);
28  
29 @@ -759,6 +757,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
30                 struct sunxi_desc_function *func = pin->functions;
31  
32                 while (func->name) {
33 +                       /* Create interrupt mapping while we're at it */
34 +                       if (!strcmp(func->name, "irq"))
35 +                               pctl->irq_array[func->irqnum] = pin->pin.number;
36                         sunxi_pinctrl_add_function(pctl, func->name);
37                         func++;
38                 }
39 -- 
40 2.0.3
41