[lantiq] update 3.2 patches
[openwrt.git] / target / linux / lantiq / patches-3.2 / 0071-MIPS-lantiq-stp-fix-for-ase-add-get-clock-disabled.patch
1 From d8e3038c520ea6c7619d3f5339c47ca0c2aa7fe3 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 11 Apr 2012 18:47:53 +0200
4 Subject: [PATCH 71/73] MIPS: lantiq: stp, fix for ase, add get, clock
5  disabled
6
7 Lantiq serial-to-parallel hardware gpio module
8 Added gpio pins as used for amazon se (ase)
9 Added get to enable reporting of gpio status
10 Changed to use software update, as hw clock was not running on ase. Clock
11 really only needed if hw flashing was implemented.
12
13 Signed-off-by: Conor O'Gorman <i@conorogorman.net>
14 ---
15  arch/mips/lantiq/xway/gpio_stp.c |   22 +++++++++++++---------
16  1 files changed, 13 insertions(+), 9 deletions(-)
17
18 diff --git a/arch/mips/lantiq/xway/gpio_stp.c b/arch/mips/lantiq/xway/gpio_stp.c
19 index 9610c10..791beeb 100644
20 --- a/arch/mips/lantiq/xway/gpio_stp.c
21 +++ b/arch/mips/lantiq/xway/gpio_stp.c
22 @@ -27,6 +27,7 @@
23  #define LTQ_STP_AR             0x10
24  
25  #define LTQ_STP_CON_SWU                (1 << 31)
26 +#define LTQ_STP_SWU_MASK       (1 << 31)
27  #define LTQ_STP_2HZ            0
28  #define LTQ_STP_4HZ            (1 << 23)
29  #define LTQ_STP_8HZ            (2 << 23)
30 @@ -60,6 +61,12 @@ static void ltq_stp_set(struct gpio_chip *chip, unsigned offset, int value)
31         else
32                 ltq_stp_shadow &= ~(1 << offset);
33         ltq_stp_w32(ltq_stp_shadow, LTQ_STP_CPU0);
34 +       ltq_stp_w32_mask(LTQ_STP_SWU_MASK, LTQ_STP_CON_SWU, LTQ_STP_CON0);
35 +}
36 +
37 +static int ltq_stp_get(struct gpio_chip *chip, unsigned offset)
38 +{
39 +       return !!(ltq_stp_r32(LTQ_STP_CPU0) & (1<<offset));
40  }
41  
42  static int ltq_stp_direction_output(struct gpio_chip *chip, unsigned offset,
43 @@ -74,6 +81,7 @@ static struct gpio_chip ltq_stp_chip = {
44         .label = "ltq_stp",
45         .direction_output = ltq_stp_direction_output,
46         .set = ltq_stp_set,
47 +       .get = ltq_stp_get,
48         .base = 200,
49         .ngpio = 24,
50         .owner = THIS_MODULE,
51 @@ -97,12 +105,6 @@ static int ltq_stp_hw_init(struct device *dev)
52         ltq_stp_w32_mask(0, LTQ_STP_GROUP0 | LTQ_STP_GROUP1 | LTQ_STP_GROUP2,
53                 LTQ_STP_CON1);
54  
55 -       /* stp are update periodically by the FPI bus */
56 -       ltq_stp_w32_mask(LTQ_STP_UPD_MASK, LTQ_STP_UPD_FPI, LTQ_STP_CON1);
57 -
58 -       /* set stp update speed */
59 -       ltq_stp_w32_mask(LTQ_STP_SPEED_MASK, LTQ_STP_8HZ, LTQ_STP_CON1);
60 -
61         /* tell the hardware that pin (led) 0 and 1 are controlled
62          *  by the dsl arc
63          */
64 @@ -118,6 +120,7 @@ static int __devinit ltq_stp_probe(struct platform_device *pdev)
65  {
66         struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
67         int ret = 0;
68 +       int pin;
69  
70         if (!res)
71                 return -ENOENT;
72 @@ -135,9 +138,10 @@ static int __devinit ltq_stp_probe(struct platform_device *pdev)
73         }
74  
75         /* the 3 pins used to control the external stp */
76 -       if (ltq_gpio_request(&pdev->dev, 4, 2, 1, "stp-st") ||
77 -                       ltq_gpio_request(&pdev->dev, 5, 2, 1, "stp-d") ||
78 -                       ltq_gpio_request(&pdev->dev, 6, 2, 1, "stp-sh")) {
79 +       pin = ltq_is_ase() ? 1 : 4;
80 +       if (ltq_gpio_request(&pdev->dev, pin, 2, 1, "stp-st") ||
81 +                       ltq_gpio_request(&pdev->dev, pin+1, 2, 1, "stp-d") ||
82 +                       ltq_gpio_request(&pdev->dev, pin+2, 2, 1, "stp-sh")) {
83                 dev_err(&pdev->dev, "failed to request needed gpios\n");
84                 return -EBUSY;
85         }
86 -- 
87 1.7.9.1
88