1 // SPDX-License-Identifier: GPL-2.0 2 #include "bcm47xx_private.h" 3 4 #include <linux/leds.h> 5 #include <bcm47xx_board.h> 6 7 /************************************************** 8 * Database 9 **************************************************/ 10 11 #define BCM47XX_GPIO_LED(_gpio, _color, _function, _active_low, \ 12 _default_state) \ 13 { \ 14 .name = "bcm47xx:" _color ":" _function, \ 15 .gpio = _gpio, \ 16 .active_low = _active_low, \ 17 .default_state = _default_state, \ 18 } 19 20 #define BCM47XX_GPIO_LED_TRIGGER(_gpio, _color, _function, _active_low, \ 21 _default_trigger) \ 22 { \ 23 .name = "bcm47xx:" _color ":" _function, \ 24 .gpio = _gpio, \ 25 .active_low = _active_low, \ 26 .default_state = LEDS_GPIO_DEFSTATE_OFF, \ 27 .default_trigger = _default_trigger, \ 28 } 29 30 /* Asus */ 31 32 static const struct gpio_led 33 bcm47xx_leds_asus_rtn12[] __initconst = { 34 BCM47XX_GPIO_LED(2, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 35 BCM47XX_GPIO_LED(7, "unk", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 36 }; 37 38 static const struct gpio_led 39 bcm47xx_leds_asus_rtn15u[] __initconst = { 40 /* TODO: Add "wlan" LED */ 41 BCM47XX_GPIO_LED(3, "blue", "wan", 1, LEDS_GPIO_DEFSTATE_OFF), 42 BCM47XX_GPIO_LED(4, "blue", "lan", 1, LEDS_GPIO_DEFSTATE_OFF), 43 BCM47XX_GPIO_LED(6, "blue", "power", 1, LEDS_GPIO_DEFSTATE_ON), 44 BCM47XX_GPIO_LED(9, "blue", "usb", 0, LEDS_GPIO_DEFSTATE_OFF), 45 }; 46 47 static const struct gpio_led 48 bcm47xx_leds_asus_rtn16[] __initconst = { 49 BCM47XX_GPIO_LED(1, "blue", "power", 1, LEDS_GPIO_DEFSTATE_ON), 50 BCM47XX_GPIO_LED(7, "blue", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 51 }; 52 53 static const struct gpio_led 54 bcm47xx_leds_asus_rtn66u[] __initconst = { 55 BCM47XX_GPIO_LED(12, "blue", "power", 1, LEDS_GPIO_DEFSTATE_ON), 56 BCM47XX_GPIO_LED(15, "blue", "usb", 1, LEDS_GPIO_DEFSTATE_OFF), 57 }; 58 59 static const struct gpio_led 60 bcm47xx_leds_asus_wl300g[] __initconst = { 61 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 62 }; 63 64 static const struct gpio_led 65 bcm47xx_leds_asus_wl320ge[] __initconst = { 66 BCM47XX_GPIO_LED(0, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 67 BCM47XX_GPIO_LED(2, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 68 BCM47XX_GPIO_LED(11, "unk", "link", 1, LEDS_GPIO_DEFSTATE_OFF), 69 }; 70 71 static const struct gpio_led 72 bcm47xx_leds_asus_wl330ge[] __initconst = { 73 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 74 }; 75 76 static const struct gpio_led 77 bcm47xx_leds_asus_wl500g[] __initconst = { 78 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 79 }; 80 81 static const struct gpio_led 82 bcm47xx_leds_asus_wl500gd[] __initconst = { 83 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 84 }; 85 86 static const struct gpio_led 87 bcm47xx_leds_asus_wl500gpv1[] __initconst = { 88 BCM47XX_GPIO_LED(1, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 89 }; 90 91 static const struct gpio_led 92 bcm47xx_leds_asus_wl500gpv2[] __initconst = { 93 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 94 BCM47XX_GPIO_LED(1, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 95 }; 96 97 static const struct gpio_led 98 bcm47xx_leds_asus_wl500w[] __initconst = { 99 BCM47XX_GPIO_LED(5, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 100 }; 101 102 static const struct gpio_led 103 bcm47xx_leds_asus_wl520gc[] __initconst = { 104 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 105 BCM47XX_GPIO_LED(1, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 106 }; 107 108 static const struct gpio_led 109 bcm47xx_leds_asus_wl520gu[] __initconst = { 110 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 111 BCM47XX_GPIO_LED(1, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 112 }; 113 114 static const struct gpio_led 115 bcm47xx_leds_asus_wl700ge[] __initconst = { 116 BCM47XX_GPIO_LED(1, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), /* Labeled "READY" (there is no "power" LED). Originally ON, flashing on USB activity. */ 117 }; 118 119 static const struct gpio_led 120 bcm47xx_leds_asus_wlhdd[] __initconst = { 121 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 122 BCM47XX_GPIO_LED(2, "unk", "usb", 1, LEDS_GPIO_DEFSTATE_OFF), 123 }; 124 125 /* Belkin */ 126 127 static const struct gpio_led 128 bcm47xx_leds_belkin_f7d4301[] __initconst = { 129 BCM47XX_GPIO_LED(10, "green", "power", 1, LEDS_GPIO_DEFSTATE_ON), 130 BCM47XX_GPIO_LED(11, "amber", "power", 1, LEDS_GPIO_DEFSTATE_OFF), 131 BCM47XX_GPIO_LED(12, "unk", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 132 BCM47XX_GPIO_LED(13, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 133 BCM47XX_GPIO_LED(14, "unk", "usb0", 1, LEDS_GPIO_DEFSTATE_OFF), 134 BCM47XX_GPIO_LED(15, "unk", "usb1", 1, LEDS_GPIO_DEFSTATE_OFF), 135 }; 136 137 /* Buffalo */ 138 139 static const struct gpio_led 140 bcm47xx_leds_buffalo_whr2_a54g54[] __initconst = { 141 BCM47XX_GPIO_LED(7, "unk", "diag", 1, LEDS_GPIO_DEFSTATE_OFF), 142 }; 143 144 static const struct gpio_led 145 bcm47xx_leds_buffalo_whr_g125[] __initconst = { 146 BCM47XX_GPIO_LED(1, "unk", "bridge", 1, LEDS_GPIO_DEFSTATE_OFF), 147 BCM47XX_GPIO_LED(2, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 148 BCM47XX_GPIO_LED(3, "unk", "internal", 1, LEDS_GPIO_DEFSTATE_OFF), 149 BCM47XX_GPIO_LED(6, "unk", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 150 BCM47XX_GPIO_LED(7, "unk", "diag", 1, LEDS_GPIO_DEFSTATE_OFF), 151 }; 152 153 static const struct gpio_led 154 bcm47xx_leds_buffalo_whr_g54s[] __initconst = { 155 BCM47XX_GPIO_LED(1, "unk", "bridge", 1, LEDS_GPIO_DEFSTATE_OFF), 156 BCM47XX_GPIO_LED(2, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 157 BCM47XX_GPIO_LED(3, "unk", "internal", 1, LEDS_GPIO_DEFSTATE_OFF), 158 BCM47XX_GPIO_LED(6, "unk", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 159 BCM47XX_GPIO_LED(7, "unk", "diag", 1, LEDS_GPIO_DEFSTATE_OFF), 160 }; 161 162 static const struct gpio_led 163 bcm47xx_leds_buffalo_whr_hp_g54[] __initconst = { 164 BCM47XX_GPIO_LED(1, "unk", "bridge", 1, LEDS_GPIO_DEFSTATE_OFF), 165 BCM47XX_GPIO_LED(2, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 166 BCM47XX_GPIO_LED(3, "unk", "internal", 1, LEDS_GPIO_DEFSTATE_OFF), 167 BCM47XX_GPIO_LED(6, "unk", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 168 BCM47XX_GPIO_LED(7, "unk", "diag", 1, LEDS_GPIO_DEFSTATE_OFF), 169 }; 170 171 static const struct gpio_led 172 bcm47xx_leds_buffalo_wzr_g300n[] __initconst = { 173 BCM47XX_GPIO_LED(1, "unk", "bridge", 1, LEDS_GPIO_DEFSTATE_OFF), 174 BCM47XX_GPIO_LED(6, "unk", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 175 BCM47XX_GPIO_LED(7, "unk", "diag", 1, LEDS_GPIO_DEFSTATE_OFF), 176 }; 177 178 static const struct gpio_led 179 bcm47xx_leds_buffalo_wzr_rs_g54[] __initconst = { 180 BCM47XX_GPIO_LED(6, "unk", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 181 BCM47XX_GPIO_LED(1, "unk", "vpn", 1, LEDS_GPIO_DEFSTATE_OFF), 182 BCM47XX_GPIO_LED(7, "unk", "diag", 1, LEDS_GPIO_DEFSTATE_OFF), 183 }; 184 185 static const struct gpio_led 186 bcm47xx_leds_buffalo_wzr_rs_g54hp[] __initconst = { 187 BCM47XX_GPIO_LED(6, "unk", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 188 BCM47XX_GPIO_LED(1, "unk", "vpn", 1, LEDS_GPIO_DEFSTATE_OFF), 189 BCM47XX_GPIO_LED(7, "unk", "diag", 1, LEDS_GPIO_DEFSTATE_OFF), 190 }; 191 192 /* Dell */ 193 194 static const struct gpio_led 195 bcm47xx_leds_dell_tm2300[] __initconst = { 196 BCM47XX_GPIO_LED(6, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 197 BCM47XX_GPIO_LED(7, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 198 }; 199 200 /* D-Link */ 201 202 static const struct gpio_led 203 bcm47xx_leds_dlink_dir130[] __initconst = { 204 BCM47XX_GPIO_LED_TRIGGER(0, "green", "status", 1, "timer"), /* Originally blinking when device is ready, separated from "power" LED */ 205 BCM47XX_GPIO_LED(6, "blue", "unk", 1, LEDS_GPIO_DEFSTATE_OFF), 206 }; 207 208 static const struct gpio_led 209 bcm47xx_leds_dlink_dir330[] __initconst = { 210 BCM47XX_GPIO_LED_TRIGGER(0, "green", "status", 1, "timer"), /* Originally blinking when device is ready, separated from "power" LED */ 211 BCM47XX_GPIO_LED(4, "unk", "usb", 1, LEDS_GPIO_DEFSTATE_OFF), 212 BCM47XX_GPIO_LED(6, "blue", "unk", 1, LEDS_GPIO_DEFSTATE_OFF), 213 }; 214 215 /* Huawei */ 216 217 static const struct gpio_led 218 bcm47xx_leds_huawei_e970[] __initconst = { 219 BCM47XX_GPIO_LED(0, "unk", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 220 }; 221 222 /* Linksys */ 223 224 static const struct gpio_led 225 bcm47xx_leds_linksys_e1000v1[] __initconst = { 226 BCM47XX_GPIO_LED(0, "blue", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 227 BCM47XX_GPIO_LED(1, "blue", "power", 0, LEDS_GPIO_DEFSTATE_ON), 228 BCM47XX_GPIO_LED(2, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 229 BCM47XX_GPIO_LED(4, "blue", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 230 }; 231 232 static const struct gpio_led 233 bcm47xx_leds_linksys_e1000v21[] __initconst = { 234 BCM47XX_GPIO_LED(5, "blue", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 235 BCM47XX_GPIO_LED(6, "blue", "power", 1, LEDS_GPIO_DEFSTATE_ON), 236 BCM47XX_GPIO_LED(7, "amber", "wps", 0, LEDS_GPIO_DEFSTATE_OFF), 237 BCM47XX_GPIO_LED(8, "blue", "wps", 0, LEDS_GPIO_DEFSTATE_OFF), 238 }; 239 240 static const struct gpio_led 241 bcm47xx_leds_linksys_e2000v1[] __initconst = { 242 BCM47XX_GPIO_LED(1, "blue", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 243 BCM47XX_GPIO_LED(2, "blue", "power", 0, LEDS_GPIO_DEFSTATE_ON), 244 BCM47XX_GPIO_LED(3, "blue", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 245 BCM47XX_GPIO_LED(4, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 246 }; 247 248 static const struct gpio_led 249 bcm47xx_leds_linksys_e3000v1[] __initconst = { 250 BCM47XX_GPIO_LED(0, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 251 BCM47XX_GPIO_LED(1, "unk", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 252 BCM47XX_GPIO_LED(3, "blue", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 253 BCM47XX_GPIO_LED(5, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 254 BCM47XX_GPIO_LED(7, "unk", "usb", 0, LEDS_GPIO_DEFSTATE_OFF), 255 }; 256 257 static const struct gpio_led 258 bcm47xx_leds_linksys_e3200v1[] __initconst = { 259 BCM47XX_GPIO_LED(3, "green", "power", 1, LEDS_GPIO_DEFSTATE_ON), 260 }; 261 262 static const struct gpio_led 263 bcm47xx_leds_linksys_e4200v1[] __initconst = { 264 BCM47XX_GPIO_LED(5, "white", "power", 1, LEDS_GPIO_DEFSTATE_ON), 265 }; 266 267 static const struct gpio_led 268 bcm47xx_leds_linksys_wrt150nv1[] __initconst = { 269 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 270 BCM47XX_GPIO_LED(3, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 271 BCM47XX_GPIO_LED(5, "green", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 272 }; 273 274 static const struct gpio_led 275 bcm47xx_leds_linksys_wrt150nv11[] __initconst = { 276 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 277 BCM47XX_GPIO_LED(3, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 278 BCM47XX_GPIO_LED(5, "green", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 279 }; 280 281 static const struct gpio_led 282 bcm47xx_leds_linksys_wrt160nv1[] __initconst = { 283 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 284 BCM47XX_GPIO_LED(3, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 285 BCM47XX_GPIO_LED(5, "blue", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 286 }; 287 288 static const struct gpio_led 289 bcm47xx_leds_linksys_wrt160nv3[] __initconst = { 290 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 291 BCM47XX_GPIO_LED(2, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 292 BCM47XX_GPIO_LED(4, "blue", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 293 }; 294 295 static const struct gpio_led 296 bcm47xx_leds_linksys_wrt300n_v1[] __initconst = { 297 BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 298 BCM47XX_GPIO_LED(3, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 299 BCM47XX_GPIO_LED(5, "green", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 300 }; 301 302 static const struct gpio_led 303 bcm47xx_leds_linksys_wrt300nv11[] __initconst = { 304 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 305 BCM47XX_GPIO_LED(3, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 306 BCM47XX_GPIO_LED(5, "green", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 307 }; 308 309 static const struct gpio_led 310 bcm47xx_leds_linksys_wrt310nv1[] __initconst = { 311 BCM47XX_GPIO_LED(1, "blue", "power", 0, LEDS_GPIO_DEFSTATE_ON), 312 BCM47XX_GPIO_LED(3, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 313 BCM47XX_GPIO_LED(9, "blue", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 314 }; 315 316 static const struct gpio_led 317 bcm47xx_leds_linksys_wrt54g_generic[] __initconst = { 318 BCM47XX_GPIO_LED(0, "unk", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 319 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 320 BCM47XX_GPIO_LED(5, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 321 BCM47XX_GPIO_LED(7, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 322 }; 323 324 static const struct gpio_led 325 bcm47xx_leds_linksys_wrt54g3gv2[] __initconst = { 326 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 327 BCM47XX_GPIO_LED(2, "green", "3g", 0, LEDS_GPIO_DEFSTATE_OFF), 328 BCM47XX_GPIO_LED(3, "blue", "3g", 0, LEDS_GPIO_DEFSTATE_OFF), 329 }; 330 331 /* Verified on: WRT54GS V1.0 */ 332 static const struct gpio_led 333 bcm47xx_leds_linksys_wrt54g_type_0101[] __initconst = { 334 BCM47XX_GPIO_LED(0, "green", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 335 BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 336 BCM47XX_GPIO_LED(7, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 337 }; 338 339 /* Verified on: WRT54GL V1.1 */ 340 static const struct gpio_led 341 bcm47xx_leds_linksys_wrt54g_type_0467[] __initconst = { 342 BCM47XX_GPIO_LED(0, "green", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 343 BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 344 BCM47XX_GPIO_LED(2, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 345 BCM47XX_GPIO_LED(3, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 346 BCM47XX_GPIO_LED(7, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 347 }; 348 349 static const struct gpio_led 350 bcm47xx_leds_linksys_wrt610nv1[] __initconst = { 351 BCM47XX_GPIO_LED(0, "unk", "usb", 1, LEDS_GPIO_DEFSTATE_OFF), 352 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_OFF), 353 BCM47XX_GPIO_LED(3, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 354 BCM47XX_GPIO_LED(9, "blue", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 355 }; 356 357 static const struct gpio_led 358 bcm47xx_leds_linksys_wrt610nv2[] __initconst = { 359 BCM47XX_GPIO_LED(0, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 360 BCM47XX_GPIO_LED(1, "unk", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 361 BCM47XX_GPIO_LED(3, "blue", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 362 BCM47XX_GPIO_LED(5, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 363 BCM47XX_GPIO_LED(7, "unk", "usb", 0, LEDS_GPIO_DEFSTATE_OFF), 364 }; 365 366 static const struct gpio_led 367 bcm47xx_leds_linksys_wrtsl54gs[] __initconst = { 368 BCM47XX_GPIO_LED(0, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 369 BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 370 BCM47XX_GPIO_LED(5, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 371 BCM47XX_GPIO_LED(7, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 372 }; 373 374 /* Luxul */ 375 376 static const struct gpio_led 377 bcm47xx_leds_luxul_abr_4400_v1[] __initconst = { 378 BCM47XX_GPIO_LED(12, "green", "usb", 0, LEDS_GPIO_DEFSTATE_OFF), 379 BCM47XX_GPIO_LED_TRIGGER(15, "green", "status", 0, "timer"), 380 }; 381 382 static const struct gpio_led 383 bcm47xx_leds_luxul_xap_310_v1[] __initconst = { 384 BCM47XX_GPIO_LED_TRIGGER(6, "green", "status", 1, "timer"), 385 }; 386 387 static const struct gpio_led 388 bcm47xx_leds_luxul_xap_1210_v1[] __initconst = { 389 BCM47XX_GPIO_LED_TRIGGER(6, "green", "status", 1, "timer"), 390 }; 391 392 static const struct gpio_led 393 bcm47xx_leds_luxul_xap_1230_v1[] __initconst = { 394 BCM47XX_GPIO_LED(3, "blue", "2ghz", 0, LEDS_GPIO_DEFSTATE_OFF), 395 BCM47XX_GPIO_LED(4, "green", "bridge", 0, LEDS_GPIO_DEFSTATE_OFF), 396 BCM47XX_GPIO_LED_TRIGGER(6, "green", "status", 1, "timer"), 397 }; 398 399 static const struct gpio_led 400 bcm47xx_leds_luxul_xap_1240_v1[] __initconst = { 401 BCM47XX_GPIO_LED(3, "blue", "2ghz", 0, LEDS_GPIO_DEFSTATE_OFF), 402 BCM47XX_GPIO_LED(4, "green", "bridge", 0, LEDS_GPIO_DEFSTATE_OFF), 403 BCM47XX_GPIO_LED_TRIGGER(6, "green", "status", 1, "timer"), 404 }; 405 406 static const struct gpio_led 407 bcm47xx_leds_luxul_xap_1500_v1[] __initconst = { 408 BCM47XX_GPIO_LED_TRIGGER(13, "green", "status", 1, "timer"), 409 }; 410 411 static const struct gpio_led 412 bcm47xx_leds_luxul_xap1500_v1_extra[] __initconst = { 413 BCM47XX_GPIO_LED(44, "green", "5ghz", 0, LEDS_GPIO_DEFSTATE_OFF), 414 BCM47XX_GPIO_LED(76, "green", "2ghz", 0, LEDS_GPIO_DEFSTATE_OFF), 415 }; 416 417 static const struct gpio_led 418 bcm47xx_leds_luxul_xbr_4400_v1[] __initconst = { 419 BCM47XX_GPIO_LED(12, "green", "usb", 0, LEDS_GPIO_DEFSTATE_OFF), 420 BCM47XX_GPIO_LED_TRIGGER(15, "green", "status", 0, "timer"), 421 }; 422 423 static const struct gpio_led 424 bcm47xx_leds_luxul_xvw_p30_v1[] __initconst = { 425 BCM47XX_GPIO_LED_TRIGGER(0, "blue", "status", 1, "timer"), 426 BCM47XX_GPIO_LED(1, "green", "link", 1, LEDS_GPIO_DEFSTATE_OFF), 427 }; 428 429 static const struct gpio_led 430 bcm47xx_leds_luxul_xwr_600_v1[] __initconst = { 431 BCM47XX_GPIO_LED(3, "green", "wps", 0, LEDS_GPIO_DEFSTATE_OFF), 432 BCM47XX_GPIO_LED_TRIGGER(6, "green", "status", 1, "timer"), 433 BCM47XX_GPIO_LED(9, "green", "usb", 0, LEDS_GPIO_DEFSTATE_OFF), 434 }; 435 436 static const struct gpio_led 437 bcm47xx_leds_luxul_xwr_1750_v1[] __initconst = { 438 BCM47XX_GPIO_LED(5, "green", "5ghz", 0, LEDS_GPIO_DEFSTATE_OFF), 439 BCM47XX_GPIO_LED(12, "green", "usb", 0, LEDS_GPIO_DEFSTATE_OFF), 440 BCM47XX_GPIO_LED_TRIGGER(13, "green", "status", 0, "timer"), 441 BCM47XX_GPIO_LED(15, "green", "wps", 0, LEDS_GPIO_DEFSTATE_OFF), 442 }; 443 444 static const struct gpio_led 445 bcm47xx_leds_luxul_xwr1750_v1_extra[] __initconst = { 446 BCM47XX_GPIO_LED(76, "green", "2ghz", 0, LEDS_GPIO_DEFSTATE_OFF), 447 }; 448 449 /* Microsoft */ 450 451 static const struct gpio_led 452 bcm47xx_leds_microsoft_nm700[] __initconst = { 453 BCM47XX_GPIO_LED(6, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 454 }; 455 456 /* Motorola */ 457 458 static const struct gpio_led 459 bcm47xx_leds_motorola_we800g[] __initconst = { 460 BCM47XX_GPIO_LED(1, "amber", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 461 BCM47XX_GPIO_LED(2, "unk", "unk", 1, LEDS_GPIO_DEFSTATE_OFF), /* There are only 3 LEDs: Power, Wireless and Device (ethernet) */ 462 BCM47XX_GPIO_LED(4, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 463 }; 464 465 static const struct gpio_led 466 bcm47xx_leds_motorola_wr850gp[] __initconst = { 467 BCM47XX_GPIO_LED(0, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 468 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 469 BCM47XX_GPIO_LED(6, "unk", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 470 BCM47XX_GPIO_LED(7, "unk", "diag", 1, LEDS_GPIO_DEFSTATE_OFF), 471 }; 472 473 static const struct gpio_led 474 bcm47xx_leds_motorola_wr850gv2v3[] __initconst = { 475 BCM47XX_GPIO_LED(0, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 476 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 477 BCM47XX_GPIO_LED(7, "unk", "diag", 1, LEDS_GPIO_DEFSTATE_OFF), 478 }; 479 480 /* Netgear */ 481 482 static const struct gpio_led 483 bcm47xx_leds_netgear_wndr3400v1[] __initconst = { 484 BCM47XX_GPIO_LED(2, "green", "usb", 1, LEDS_GPIO_DEFSTATE_OFF), 485 BCM47XX_GPIO_LED(3, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 486 BCM47XX_GPIO_LED(7, "amber", "power", 0, LEDS_GPIO_DEFSTATE_OFF), 487 }; 488 489 static const struct gpio_led 490 bcm47xx_leds_netgear_wndr4500v1[] __initconst = { 491 BCM47XX_GPIO_LED(1, "green", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 492 BCM47XX_GPIO_LED(2, "green", "power", 1, LEDS_GPIO_DEFSTATE_ON), 493 BCM47XX_GPIO_LED(3, "amber", "power", 1, LEDS_GPIO_DEFSTATE_OFF), 494 BCM47XX_GPIO_LED(8, "green", "usb1", 1, LEDS_GPIO_DEFSTATE_OFF), 495 BCM47XX_GPIO_LED(9, "green", "2ghz", 1, LEDS_GPIO_DEFSTATE_OFF), 496 BCM47XX_GPIO_LED(11, "blue", "5ghz", 1, LEDS_GPIO_DEFSTATE_OFF), 497 BCM47XX_GPIO_LED(14, "green", "usb2", 1, LEDS_GPIO_DEFSTATE_OFF), 498 }; 499 500 static const struct gpio_led 501 bcm47xx_leds_netgear_wnr3500lv1[] __initconst = { 502 BCM47XX_GPIO_LED(0, "blue", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 503 BCM47XX_GPIO_LED(1, "green", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 504 BCM47XX_GPIO_LED(2, "green", "wan", 1, LEDS_GPIO_DEFSTATE_OFF), 505 BCM47XX_GPIO_LED(3, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 506 BCM47XX_GPIO_LED(7, "amber", "power", 0, LEDS_GPIO_DEFSTATE_OFF), 507 }; 508 509 static const struct gpio_led 510 bcm47xx_leds_netgear_wnr834bv2[] __initconst = { 511 BCM47XX_GPIO_LED(2, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 512 BCM47XX_GPIO_LED(3, "amber", "power", 0, LEDS_GPIO_DEFSTATE_OFF), 513 BCM47XX_GPIO_LED(7, "unk", "connected", 0, LEDS_GPIO_DEFSTATE_OFF), 514 }; 515 516 /* Siemens */ 517 static const struct gpio_led 518 bcm47xx_leds_siemens_se505v2[] __initconst = { 519 BCM47XX_GPIO_LED(0, "unk", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 520 BCM47XX_GPIO_LED(3, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 521 BCM47XX_GPIO_LED(5, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 522 }; 523 524 /* SimpleTech */ 525 526 static const struct gpio_led 527 bcm47xx_leds_simpletech_simpleshare[] __initconst = { 528 BCM47XX_GPIO_LED(1, "unk", "status", 1, LEDS_GPIO_DEFSTATE_OFF), /* "Ready" LED */ 529 }; 530 531 /************************************************** 532 * Init 533 **************************************************/ 534 535 static struct gpio_led_platform_data bcm47xx_leds_pdata; 536 537 #define bcm47xx_set_pdata(dev_leds) do { \ 538 bcm47xx_leds_pdata.leds = dev_leds; \ 539 bcm47xx_leds_pdata.num_leds = ARRAY_SIZE(dev_leds); \ 540 } while (0) 541 542 static struct gpio_led_platform_data bcm47xx_leds_pdata_extra __initdata = {}; 543 #define bcm47xx_set_pdata_extra(dev_leds) do { \ 544 bcm47xx_leds_pdata_extra.leds = dev_leds; \ 545 bcm47xx_leds_pdata_extra.num_leds = ARRAY_SIZE(dev_leds); \ 546 } while (0) 547 548 void __init bcm47xx_leds_register(void) 549 { 550 enum bcm47xx_board board = bcm47xx_board_get(); 551 552 switch (board) { 553 case BCM47XX_BOARD_ASUS_RTN12: 554 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn12); 555 break; 556 case BCM47XX_BOARD_ASUS_RTN15U: 557 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn15u); 558 break; 559 case BCM47XX_BOARD_ASUS_RTN16: 560 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn16); 561 break; 562 case BCM47XX_BOARD_ASUS_RTN66U: 563 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn66u); 564 break; 565 case BCM47XX_BOARD_ASUS_WL300G: 566 bcm47xx_set_pdata(bcm47xx_leds_asus_wl300g); 567 break; 568 case BCM47XX_BOARD_ASUS_WL320GE: 569 bcm47xx_set_pdata(bcm47xx_leds_asus_wl320ge); 570 break; 571 case BCM47XX_BOARD_ASUS_WL330GE: 572 bcm47xx_set_pdata(bcm47xx_leds_asus_wl330ge); 573 break; 574 case BCM47XX_BOARD_ASUS_WL500G: 575 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500g); 576 break; 577 case BCM47XX_BOARD_ASUS_WL500GD: 578 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500gd); 579 break; 580 case BCM47XX_BOARD_ASUS_WL500GPV1: 581 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500gpv1); 582 break; 583 case BCM47XX_BOARD_ASUS_WL500GPV2: 584 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500gpv2); 585 break; 586 case BCM47XX_BOARD_ASUS_WL500W: 587 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500w); 588 break; 589 case BCM47XX_BOARD_ASUS_WL520GC: 590 bcm47xx_set_pdata(bcm47xx_leds_asus_wl520gc); 591 break; 592 case BCM47XX_BOARD_ASUS_WL520GU: 593 bcm47xx_set_pdata(bcm47xx_leds_asus_wl520gu); 594 break; 595 case BCM47XX_BOARD_ASUS_WL700GE: 596 bcm47xx_set_pdata(bcm47xx_leds_asus_wl700ge); 597 break; 598 case BCM47XX_BOARD_ASUS_WLHDD: 599 bcm47xx_set_pdata(bcm47xx_leds_asus_wlhdd); 600 break; 601 602 case BCM47XX_BOARD_BELKIN_F7D3301: 603 case BCM47XX_BOARD_BELKIN_F7D3302: 604 case BCM47XX_BOARD_BELKIN_F7D4301: 605 case BCM47XX_BOARD_BELKIN_F7D4302: 606 case BCM47XX_BOARD_BELKIN_F7D4401: 607 bcm47xx_set_pdata(bcm47xx_leds_belkin_f7d4301); 608 break; 609 610 case BCM47XX_BOARD_BUFFALO_WHR2_A54G54: 611 bcm47xx_set_pdata(bcm47xx_leds_buffalo_whr2_a54g54); 612 break; 613 case BCM47XX_BOARD_BUFFALO_WHR_G125: 614 bcm47xx_set_pdata(bcm47xx_leds_buffalo_whr_g125); 615 break; 616 case BCM47XX_BOARD_BUFFALO_WHR_G54S: 617 bcm47xx_set_pdata(bcm47xx_leds_buffalo_whr_g54s); 618 break; 619 case BCM47XX_BOARD_BUFFALO_WHR_HP_G54: 620 bcm47xx_set_pdata(bcm47xx_leds_buffalo_whr_hp_g54); 621 break; 622 case BCM47XX_BOARD_BUFFALO_WZR_G300N: 623 bcm47xx_set_pdata(bcm47xx_leds_buffalo_wzr_g300n); 624 break; 625 case BCM47XX_BOARD_BUFFALO_WZR_RS_G54: 626 bcm47xx_set_pdata(bcm47xx_leds_buffalo_wzr_rs_g54); 627 break; 628 case BCM47XX_BOARD_BUFFALO_WZR_RS_G54HP: 629 bcm47xx_set_pdata(bcm47xx_leds_buffalo_wzr_rs_g54hp); 630 break; 631 632 case BCM47XX_BOARD_DELL_TM2300: 633 bcm47xx_set_pdata(bcm47xx_leds_dell_tm2300); 634 break; 635 636 case BCM47XX_BOARD_DLINK_DIR130: 637 bcm47xx_set_pdata(bcm47xx_leds_dlink_dir130); 638 break; 639 case BCM47XX_BOARD_DLINK_DIR330: 640 bcm47xx_set_pdata(bcm47xx_leds_dlink_dir330); 641 break; 642 643 case BCM47XX_BOARD_HUAWEI_E970: 644 bcm47xx_set_pdata(bcm47xx_leds_huawei_e970); 645 break; 646 647 case BCM47XX_BOARD_LINKSYS_E1000V1: 648 bcm47xx_set_pdata(bcm47xx_leds_linksys_e1000v1); 649 break; 650 case BCM47XX_BOARD_LINKSYS_E1000V21: 651 bcm47xx_set_pdata(bcm47xx_leds_linksys_e1000v21); 652 break; 653 case BCM47XX_BOARD_LINKSYS_E2000V1: 654 bcm47xx_set_pdata(bcm47xx_leds_linksys_e2000v1); 655 break; 656 case BCM47XX_BOARD_LINKSYS_E3000V1: 657 bcm47xx_set_pdata(bcm47xx_leds_linksys_e3000v1); 658 break; 659 case BCM47XX_BOARD_LINKSYS_E3200V1: 660 bcm47xx_set_pdata(bcm47xx_leds_linksys_e3200v1); 661 break; 662 case BCM47XX_BOARD_LINKSYS_E4200V1: 663 bcm47xx_set_pdata(bcm47xx_leds_linksys_e4200v1); 664 break; 665 case BCM47XX_BOARD_LINKSYS_WRT150NV1: 666 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt150nv1); 667 break; 668 case BCM47XX_BOARD_LINKSYS_WRT150NV11: 669 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt150nv11); 670 break; 671 case BCM47XX_BOARD_LINKSYS_WRT160NV1: 672 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt160nv1); 673 break; 674 case BCM47XX_BOARD_LINKSYS_WRT160NV3: 675 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt160nv3); 676 break; 677 case BCM47XX_BOARD_LINKSYS_WRT300N_V1: 678 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt300n_v1); 679 break; 680 case BCM47XX_BOARD_LINKSYS_WRT300NV11: 681 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt300nv11); 682 break; 683 case BCM47XX_BOARD_LINKSYS_WRT310NV1: 684 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt310nv1); 685 break; 686 case BCM47XX_BOARD_LINKSYS_WRT54G3GV2: 687 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g3gv2); 688 break; 689 case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0101: 690 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g_type_0101); 691 break; 692 case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0467: 693 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g_type_0467); 694 break; 695 case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0708: 696 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g_generic); 697 break; 698 case BCM47XX_BOARD_LINKSYS_WRT610NV1: 699 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt610nv1); 700 break; 701 case BCM47XX_BOARD_LINKSYS_WRT610NV2: 702 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt610nv2); 703 break; 704 case BCM47XX_BOARD_LINKSYS_WRTSL54GS: 705 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrtsl54gs); 706 break; 707 708 case BCM47XX_BOARD_LUXUL_ABR_4400_V1: 709 bcm47xx_set_pdata(bcm47xx_leds_luxul_abr_4400_v1); 710 break; 711 case BCM47XX_BOARD_LUXUL_XAP_310_V1: 712 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_310_v1); 713 break; 714 case BCM47XX_BOARD_LUXUL_XAP_1210_V1: 715 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_1210_v1); 716 break; 717 case BCM47XX_BOARD_LUXUL_XAP_1230_V1: 718 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_1230_v1); 719 break; 720 case BCM47XX_BOARD_LUXUL_XAP_1240_V1: 721 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_1240_v1); 722 break; 723 case BCM47XX_BOARD_LUXUL_XAP_1500_V1: 724 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_1500_v1); 725 bcm47xx_set_pdata_extra(bcm47xx_leds_luxul_xap1500_v1_extra); 726 break; 727 case BCM47XX_BOARD_LUXUL_XBR_4400_V1: 728 bcm47xx_set_pdata(bcm47xx_leds_luxul_xbr_4400_v1); 729 break; 730 case BCM47XX_BOARD_LUXUL_XVW_P30_V1: 731 bcm47xx_set_pdata(bcm47xx_leds_luxul_xvw_p30_v1); 732 break; 733 case BCM47XX_BOARD_LUXUL_XWR_600_V1: 734 bcm47xx_set_pdata(bcm47xx_leds_luxul_xwr_600_v1); 735 break; 736 case BCM47XX_BOARD_LUXUL_XWR_1750_V1: 737 bcm47xx_set_pdata(bcm47xx_leds_luxul_xwr_1750_v1); 738 bcm47xx_set_pdata_extra(bcm47xx_leds_luxul_xwr1750_v1_extra); 739 break; 740 741 case BCM47XX_BOARD_MICROSOFT_MN700: 742 bcm47xx_set_pdata(bcm47xx_leds_microsoft_nm700); 743 break; 744 745 case BCM47XX_BOARD_MOTOROLA_WE800G: 746 bcm47xx_set_pdata(bcm47xx_leds_motorola_we800g); 747 break; 748 case BCM47XX_BOARD_MOTOROLA_WR850GP: 749 bcm47xx_set_pdata(bcm47xx_leds_motorola_wr850gp); 750 break; 751 case BCM47XX_BOARD_MOTOROLA_WR850GV2V3: 752 bcm47xx_set_pdata(bcm47xx_leds_motorola_wr850gv2v3); 753 break; 754 755 case BCM47XX_BOARD_NETGEAR_WNDR3400V1: 756 bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr3400v1); 757 break; 758 case BCM47XX_BOARD_NETGEAR_WNDR4500V1: 759 bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr4500v1); 760 break; 761 case BCM47XX_BOARD_NETGEAR_WNR3500L: 762 bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr3500lv1); 763 break; 764 case BCM47XX_BOARD_NETGEAR_WNR834BV2: 765 bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr834bv2); 766 break; 767 768 case BCM47XX_BOARD_SIEMENS_SE505V2: 769 bcm47xx_set_pdata(bcm47xx_leds_siemens_se505v2); 770 break; 771 772 case BCM47XX_BOARD_SIMPLETECH_SIMPLESHARE: 773 bcm47xx_set_pdata(bcm47xx_leds_simpletech_simpleshare); 774 break; 775 776 default: 777 pr_debug("No LEDs configuration found for this device\n"); 778 return; 779 } 780 781 gpio_led_register_device(-1, &bcm47xx_leds_pdata); 782 if (bcm47xx_leds_pdata_extra.num_leds) 783 gpio_led_register_device(0, &bcm47xx_leds_pdata_extra); 784 } 785