adm8668: drop 3.14
[openwrt.git] / target / linux / brcm47xx / patches-3.14 / 146-MIPS-BCM47XX-add-Microsoft-MN-700-and-Asus-WL500G.patch
1 From 250dc03727b9cce91bd86091f05bf2443e2be9ec Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Tue, 29 Jul 2014 00:12:09 +0200
4 Subject: [PATCH] MIPS: BCM47XX: add Microsoft MN-700 and Asus WL500G
5
6 This patch adds detection for the Microsoft MN-700 and the Asus WL500G
7 router. This is based on some old code from OpenWrt.
8
9 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
10 Cc: zajec5@gmail.com
11 Cc: linux-mips@linux-mips.org
12 Patchwork: https://patchwork.linux-mips.org/patch/7490/
13 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
14 ---
15  arch/mips/bcm47xx/board.c                          | 17 +++++++++++++++++
16  arch/mips/bcm47xx/buttons.c                        | 19 +++++++++++++++++++
17  arch/mips/bcm47xx/leds.c                           | 19 +++++++++++++++++++
18  arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h |  3 +++
19  4 files changed, 58 insertions(+)
20
21 --- a/arch/mips/bcm47xx/board.c
22 +++ b/arch/mips/bcm47xx/board.c
23 @@ -80,6 +80,14 @@ struct bcm47xx_board_type_list1 bcm47xx_
24         { {0}, NULL},
25  };
26  
27 +/* hardware_version, boardnum */
28 +static const
29 +struct bcm47xx_board_type_list2 bcm47xx_board_list_hw_version_num[] __initconst = {
30 +       {{BCM47XX_BOARD_MICROSOFT_MN700, "Microsoft MN-700"}, "WL500-", "mn700"},
31 +       {{BCM47XX_BOARD_ASUS_WL500G, "Asus WL500G"}, "WL500-", "asusX"},
32 +       { {0}, NULL},
33 +};
34 +
35  /* productid */
36  static const
37  struct bcm47xx_board_type_list1 bcm47xx_board_list_productid[] __initconst = {
38 @@ -237,6 +245,15 @@ static __init const struct bcm47xx_board
39                 }
40         }
41  
42 +       if (bcm47xx_nvram_getenv("hardware_version", buf1, sizeof(buf1)) >= 0 &&
43 +           bcm47xx_nvram_getenv("boardtype", buf2, sizeof(buf2)) >= 0) {
44 +               for (e2 = bcm47xx_board_list_boot_hw; e2->value1; e2++) {
45 +                       if (!strstarts(buf1, e2->value1) &&
46 +                           !strcmp(buf2, e2->value2))
47 +                               return &e2->board;
48 +               }
49 +       }
50 +
51         if (bcm47xx_nvram_getenv("productid", buf1, sizeof(buf1)) >= 0) {
52                 for (e1 = bcm47xx_board_list_productid; e1->value1; e1++) {
53                         if (!strcmp(buf1, e1->value1))
54 --- a/arch/mips/bcm47xx/buttons.c
55 +++ b/arch/mips/bcm47xx/buttons.c
56 @@ -56,6 +56,11 @@ bcm47xx_buttons_asus_wl330ge[] __initcon
57  };
58  
59  static const struct gpio_keys_button
60 +bcm47xx_buttons_asus_wl500g[] __initconst = {
61 +       BCM47XX_GPIO_KEY(6, KEY_RESTART),
62 +};
63 +
64 +static const struct gpio_keys_button
65  bcm47xx_buttons_asus_wl500gd[] __initconst = {
66         BCM47XX_GPIO_KEY(6, KEY_RESTART),
67  };
68 @@ -288,6 +293,13 @@ bcm47xx_buttons_linksys_wrtsl54gs[] __in
69         BCM47XX_GPIO_KEY(6, KEY_RESTART),
70  };
71  
72 +/* Microsoft */
73 +
74 +static const struct gpio_keys_button
75 +bcm47xx_buttons_microsoft_nm700[] __initconst = {
76 +       BCM47XX_GPIO_KEY(7, KEY_RESTART),
77 +};
78 +
79  /* Motorola */
80  
81  static const struct gpio_keys_button
82 @@ -395,6 +407,9 @@ int __init bcm47xx_buttons_register(void
83         case BCM47XX_BOARD_ASUS_WL330GE:
84                 err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl330ge);
85                 break;
86 +       case BCM47XX_BOARD_ASUS_WL500G:
87 +               err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500g);
88 +               break;
89         case BCM47XX_BOARD_ASUS_WL500GD:
90                 err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500gd);
91                 break;
92 @@ -517,6 +532,10 @@ int __init bcm47xx_buttons_register(void
93                 err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrtsl54gs);
94                 break;
95  
96 +       case BCM47XX_BOARD_MICROSOFT_MN700:
97 +               err = bcm47xx_copy_bdata(bcm47xx_buttons_microsoft_nm700);
98 +               break;
99 +
100         case BCM47XX_BOARD_MOTOROLA_WE800G:
101                 err = bcm47xx_copy_bdata(bcm47xx_buttons_motorola_we800g);
102                 break;
103 --- a/arch/mips/bcm47xx/leds.c
104 +++ b/arch/mips/bcm47xx/leds.c
105 @@ -64,6 +64,11 @@ bcm47xx_leds_asus_wl330ge[] __initconst 
106  };
107  
108  static const struct gpio_led
109 +bcm47xx_leds_asus_wl500g[] __initconst = {
110 +       BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON),
111 +};
112 +
113 +static const struct gpio_led
114  bcm47xx_leds_asus_wl500gd[] __initconst = {
115         BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON),
116  };
117 @@ -332,6 +337,13 @@ bcm47xx_leds_linksys_wrtsl54gs[] __initc
118         BCM47XX_GPIO_LED(7, "unk", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF),
119  };
120  
121 +/* Microsoft */
122 +
123 +static const struct gpio_led
124 +bcm47xx_leds_microsoft_nm700[] __initconst = {
125 +       BCM47XX_GPIO_LED(6, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON),
126 +};
127 +
128  /* Motorola */
129  
130  static const struct gpio_led
131 @@ -432,6 +444,9 @@ void __init bcm47xx_leds_register(void)
132         case BCM47XX_BOARD_ASUS_WL330GE:
133                 bcm47xx_set_pdata(bcm47xx_leds_asus_wl330ge);
134                 break;
135 +       case BCM47XX_BOARD_ASUS_WL500G:
136 +               bcm47xx_set_pdata(bcm47xx_leds_asus_wl500g);
137 +               break;
138         case BCM47XX_BOARD_ASUS_WL500GD:
139                 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500gd);
140                 break;
141 @@ -554,6 +569,10 @@ void __init bcm47xx_leds_register(void)
142                 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrtsl54gs);
143                 break;
144  
145 +       case BCM47XX_BOARD_MICROSOFT_MN700:
146 +               bcm47xx_set_pdata(bcm47xx_leds_microsoft_nm700);
147 +               break;
148 +
149         case BCM47XX_BOARD_MOTOROLA_WE800G:
150                 bcm47xx_set_pdata(bcm47xx_leds_motorola_we800g);
151                 break;
152 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
153 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
154 @@ -18,6 +18,7 @@ enum bcm47xx_board {
155         BCM47XX_BOARD_ASUS_WL300G,
156         BCM47XX_BOARD_ASUS_WL320GE,
157         BCM47XX_BOARD_ASUS_WL330GE,
158 +       BCM47XX_BOARD_ASUS_WL500G,
159         BCM47XX_BOARD_ASUS_WL500GD,
160         BCM47XX_BOARD_ASUS_WL500GPV1,
161         BCM47XX_BOARD_ASUS_WL500GPV2,
162 @@ -75,6 +76,8 @@ enum bcm47xx_board {
163         BCM47XX_BOARD_LINKSYS_WRT610NV2,
164         BCM47XX_BOARD_LINKSYS_WRTSL54GS,
165  
166 +       BCM47XX_BOARD_MICROSOFT_MN700,
167 +
168         BCM47XX_BOARD_MOTOROLA_WE800G,
169         BCM47XX_BOARD_MOTOROLA_WR850GP,
170         BCM47XX_BOARD_MOTOROLA_WR850GV2V3,