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, "green", "bridge", 1, LEDS_GPIO_DEFSTATE_OFF), 156 BCM47XX_GPIO_LED(2, "green", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 157 BCM47XX_GPIO_LED(3, "green", "internal", 1, LEDS_GPIO_DEFSTATE_OFF), 158 BCM47XX_GPIO_LED(6, "amber", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 159 BCM47XX_GPIO_LED(7, "red", "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_wnr1000_v3[] __initconst = { 502 BCM47XX_GPIO_LED(0, "blue", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 503 BCM47XX_GPIO_LED(1, "green", "wps", 0, LEDS_GPIO_DEFSTATE_OFF), 504 }; 505 506 static const struct gpio_led 507 bcm47xx_leds_netgear_wnr3500lv1[] __initconst = { 508 BCM47XX_GPIO_LED(0, "blue", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 509 BCM47XX_GPIO_LED(1, "green", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 510 BCM47XX_GPIO_LED(2, "green", "wan", 1, LEDS_GPIO_DEFSTATE_OFF), 511 BCM47XX_GPIO_LED(3, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 512 BCM47XX_GPIO_LED(7, "amber", "power", 0, LEDS_GPIO_DEFSTATE_OFF), 513 }; 514 515 static const struct gpio_led 516 bcm47xx_leds_netgear_wnr834bv2[] __initconst = { 517 BCM47XX_GPIO_LED(2, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 518 BCM47XX_GPIO_LED(3, "amber", "power", 0, LEDS_GPIO_DEFSTATE_OFF), 519 BCM47XX_GPIO_LED(7, "unk", "connected", 0, LEDS_GPIO_DEFSTATE_OFF), 520 }; 521 522 /* Siemens */ 523 static const struct gpio_led 524 bcm47xx_leds_siemens_se505v2[] __initconst = { 525 BCM47XX_GPIO_LED(0, "unk", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 526 BCM47XX_GPIO_LED(3, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 527 BCM47XX_GPIO_LED(5, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 528 }; 529 530 /* SimpleTech */ 531 532 static const struct gpio_led 533 bcm47xx_leds_simpletech_simpleshare[] __initconst = { 534 BCM47XX_GPIO_LED(1, "unk", "status", 1, LEDS_GPIO_DEFSTATE_OFF), /* "Ready" LED */ 535 }; 536 537 /************************************************** 538 * Init 539 **************************************************/ 540 541 static struct gpio_led_platform_data bcm47xx_leds_pdata __initdata; 542 543 #define bcm47xx_set_pdata(dev_leds) do { \ 544 bcm47xx_leds_pdata.leds = dev_leds; \ 545 bcm47xx_leds_pdata.num_leds = ARRAY_SIZE(dev_leds); \ 546 } while (0) 547 548 static struct gpio_led_platform_data bcm47xx_leds_pdata_extra __initdata = {}; 549 #define bcm47xx_set_pdata_extra(dev_leds) do { \ 550 bcm47xx_leds_pdata_extra.leds = dev_leds; \ 551 bcm47xx_leds_pdata_extra.num_leds = ARRAY_SIZE(dev_leds); \ 552 } while (0) 553 554 void __init bcm47xx_leds_register(void) 555 { 556 enum bcm47xx_board board = bcm47xx_board_get(); 557 558 switch (board) { 559 case BCM47XX_BOARD_ASUS_RTN12: 560 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn12); 561 break; 562 case BCM47XX_BOARD_ASUS_RTN15U: 563 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn15u); 564 break; 565 case BCM47XX_BOARD_ASUS_RTN16: 566 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn16); 567 break; 568 case BCM47XX_BOARD_ASUS_RTN66U: 569 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn66u); 570 break; 571 case BCM47XX_BOARD_ASUS_WL300G: 572 bcm47xx_set_pdata(bcm47xx_leds_asus_wl300g); 573 break; 574 case BCM47XX_BOARD_ASUS_WL320GE: 575 bcm47xx_set_pdata(bcm47xx_leds_asus_wl320ge); 576 break; 577 case BCM47XX_BOARD_ASUS_WL330GE: 578 bcm47xx_set_pdata(bcm47xx_leds_asus_wl330ge); 579 break; 580 case BCM47XX_BOARD_ASUS_WL500G: 581 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500g); 582 break; 583 case BCM47XX_BOARD_ASUS_WL500GD: 584 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500gd); 585 break; 586 case BCM47XX_BOARD_ASUS_WL500GPV1: 587 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500gpv1); 588 break; 589 case BCM47XX_BOARD_ASUS_WL500GPV2: 590 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500gpv2); 591 break; 592 case BCM47XX_BOARD_ASUS_WL500W: 593 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500w); 594 break; 595 case BCM47XX_BOARD_ASUS_WL520GC: 596 bcm47xx_set_pdata(bcm47xx_leds_asus_wl520gc); 597 break; 598 case BCM47XX_BOARD_ASUS_WL520GU: 599 bcm47xx_set_pdata(bcm47xx_leds_asus_wl520gu); 600 break; 601 case BCM47XX_BOARD_ASUS_WL700GE: 602 bcm47xx_set_pdata(bcm47xx_leds_asus_wl700ge); 603 break; 604 case BCM47XX_BOARD_ASUS_WLHDD: 605 bcm47xx_set_pdata(bcm47xx_leds_asus_wlhdd); 606 break; 607 608 case BCM47XX_BOARD_BELKIN_F7D3301: 609 case BCM47XX_BOARD_BELKIN_F7D3302: 610 case BCM47XX_BOARD_BELKIN_F7D4301: 611 case BCM47XX_BOARD_BELKIN_F7D4302: 612 case BCM47XX_BOARD_BELKIN_F7D4401: 613 bcm47xx_set_pdata(bcm47xx_leds_belkin_f7d4301); 614 break; 615 616 case BCM47XX_BOARD_BUFFALO_WHR2_A54G54: 617 bcm47xx_set_pdata(bcm47xx_leds_buffalo_whr2_a54g54); 618 break; 619 case BCM47XX_BOARD_BUFFALO_WHR_G125: 620 bcm47xx_set_pdata(bcm47xx_leds_buffalo_whr_g125); 621 break; 622 case BCM47XX_BOARD_BUFFALO_WHR_G54S: 623 bcm47xx_set_pdata(bcm47xx_leds_buffalo_whr_g54s); 624 break; 625 case BCM47XX_BOARD_BUFFALO_WHR_HP_G54: 626 bcm47xx_set_pdata(bcm47xx_leds_buffalo_whr_hp_g54); 627 break; 628 case BCM47XX_BOARD_BUFFALO_WZR_G300N: 629 bcm47xx_set_pdata(bcm47xx_leds_buffalo_wzr_g300n); 630 break; 631 case BCM47XX_BOARD_BUFFALO_WZR_RS_G54: 632 bcm47xx_set_pdata(bcm47xx_leds_buffalo_wzr_rs_g54); 633 break; 634 case BCM47XX_BOARD_BUFFALO_WZR_RS_G54HP: 635 bcm47xx_set_pdata(bcm47xx_leds_buffalo_wzr_rs_g54hp); 636 break; 637 638 case BCM47XX_BOARD_DELL_TM2300: 639 bcm47xx_set_pdata(bcm47xx_leds_dell_tm2300); 640 break; 641 642 case BCM47XX_BOARD_DLINK_DIR130: 643 bcm47xx_set_pdata(bcm47xx_leds_dlink_dir130); 644 break; 645 case BCM47XX_BOARD_DLINK_DIR330: 646 bcm47xx_set_pdata(bcm47xx_leds_dlink_dir330); 647 break; 648 649 case BCM47XX_BOARD_HUAWEI_E970: 650 bcm47xx_set_pdata(bcm47xx_leds_huawei_e970); 651 break; 652 653 case BCM47XX_BOARD_LINKSYS_E1000V1: 654 bcm47xx_set_pdata(bcm47xx_leds_linksys_e1000v1); 655 break; 656 case BCM47XX_BOARD_LINKSYS_E1000V21: 657 bcm47xx_set_pdata(bcm47xx_leds_linksys_e1000v21); 658 break; 659 case BCM47XX_BOARD_LINKSYS_E2000V1: 660 bcm47xx_set_pdata(bcm47xx_leds_linksys_e2000v1); 661 break; 662 case BCM47XX_BOARD_LINKSYS_E3000V1: 663 bcm47xx_set_pdata(bcm47xx_leds_linksys_e3000v1); 664 break; 665 case BCM47XX_BOARD_LINKSYS_E3200V1: 666 bcm47xx_set_pdata(bcm47xx_leds_linksys_e3200v1); 667 break; 668 case BCM47XX_BOARD_LINKSYS_E4200V1: 669 bcm47xx_set_pdata(bcm47xx_leds_linksys_e4200v1); 670 break; 671 case BCM47XX_BOARD_LINKSYS_WRT150NV1: 672 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt150nv1); 673 break; 674 case BCM47XX_BOARD_LINKSYS_WRT150NV11: 675 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt150nv11); 676 break; 677 case BCM47XX_BOARD_LINKSYS_WRT160NV1: 678 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt160nv1); 679 break; 680 case BCM47XX_BOARD_LINKSYS_WRT160NV3: 681 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt160nv3); 682 break; 683 case BCM47XX_BOARD_LINKSYS_WRT300N_V1: 684 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt300n_v1); 685 break; 686 case BCM47XX_BOARD_LINKSYS_WRT300NV11: 687 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt300nv11); 688 break; 689 case BCM47XX_BOARD_LINKSYS_WRT310NV1: 690 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt310nv1); 691 break; 692 case BCM47XX_BOARD_LINKSYS_WRT54G3GV2: 693 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g3gv2); 694 break; 695 case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0101: 696 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g_type_0101); 697 break; 698 case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0467: 699 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g_type_0467); 700 break; 701 case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0708: 702 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g_generic); 703 break; 704 case BCM47XX_BOARD_LINKSYS_WRT610NV1: 705 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt610nv1); 706 break; 707 case BCM47XX_BOARD_LINKSYS_WRT610NV2: 708 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt610nv2); 709 break; 710 case BCM47XX_BOARD_LINKSYS_WRTSL54GS: 711 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrtsl54gs); 712 break; 713 714 case BCM47XX_BOARD_LUXUL_ABR_4400_V1: 715 bcm47xx_set_pdata(bcm47xx_leds_luxul_abr_4400_v1); 716 break; 717 case BCM47XX_BOARD_LUXUL_XAP_310_V1: 718 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_310_v1); 719 break; 720 case BCM47XX_BOARD_LUXUL_XAP_1210_V1: 721 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_1210_v1); 722 break; 723 case BCM47XX_BOARD_LUXUL_XAP_1230_V1: 724 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_1230_v1); 725 break; 726 case BCM47XX_BOARD_LUXUL_XAP_1240_V1: 727 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_1240_v1); 728 break; 729 case BCM47XX_BOARD_LUXUL_XAP_1500_V1: 730 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_1500_v1); 731 bcm47xx_set_pdata_extra(bcm47xx_leds_luxul_xap1500_v1_extra); 732 break; 733 case BCM47XX_BOARD_LUXUL_XBR_4400_V1: 734 bcm47xx_set_pdata(bcm47xx_leds_luxul_xbr_4400_v1); 735 break; 736 case BCM47XX_BOARD_LUXUL_XVW_P30_V1: 737 bcm47xx_set_pdata(bcm47xx_leds_luxul_xvw_p30_v1); 738 break; 739 case BCM47XX_BOARD_LUXUL_XWR_600_V1: 740 bcm47xx_set_pdata(bcm47xx_leds_luxul_xwr_600_v1); 741 break; 742 case BCM47XX_BOARD_LUXUL_XWR_1750_V1: 743 bcm47xx_set_pdata(bcm47xx_leds_luxul_xwr_1750_v1); 744 bcm47xx_set_pdata_extra(bcm47xx_leds_luxul_xwr1750_v1_extra); 745 break; 746 747 case BCM47XX_BOARD_MICROSOFT_MN700: 748 bcm47xx_set_pdata(bcm47xx_leds_microsoft_nm700); 749 break; 750 751 case BCM47XX_BOARD_MOTOROLA_WE800G: 752 bcm47xx_set_pdata(bcm47xx_leds_motorola_we800g); 753 break; 754 case BCM47XX_BOARD_MOTOROLA_WR850GP: 755 bcm47xx_set_pdata(bcm47xx_leds_motorola_wr850gp); 756 break; 757 case BCM47XX_BOARD_MOTOROLA_WR850GV2V3: 758 bcm47xx_set_pdata(bcm47xx_leds_motorola_wr850gv2v3); 759 break; 760 761 case BCM47XX_BOARD_NETGEAR_WNDR3400V1: 762 bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr3400v1); 763 break; 764 case BCM47XX_BOARD_NETGEAR_WNDR4500V1: 765 bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr4500v1); 766 break; 767 case BCM47XX_BOARD_NETGEAR_WNR1000_V3: 768 bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr1000_v3); 769 break; 770 case BCM47XX_BOARD_NETGEAR_WNR3500L: 771 bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr3500lv1); 772 break; 773 case BCM47XX_BOARD_NETGEAR_WNR834BV2: 774 bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr834bv2); 775 break; 776 777 case BCM47XX_BOARD_SIEMENS_SE505V2: 778 bcm47xx_set_pdata(bcm47xx_leds_siemens_se505v2); 779 break; 780 781 case BCM47XX_BOARD_SIMPLETECH_SIMPLESHARE: 782 bcm47xx_set_pdata(bcm47xx_leds_simpletech_simpleshare); 783 break; 784 785 default: 786 pr_debug("No LEDs configuration found for this device\n"); 787 return; 788 } 789 790 gpio_led_register_device(-1, &bcm47xx_leds_pdata); 791 if (bcm47xx_leds_pdata_extra.num_leds) 792 gpio_led_register_device(0, &bcm47xx_leds_pdata_extra); 793 } 794