1*4882a593SmuzhiyunLEDs connected to Broadcom BCM6328 controller 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunThis controller is present on BCM6318, BCM6328, BCM6362 and BCM63268. 4*4882a593SmuzhiyunIn these SoCs it's possible to control LEDs both as GPIOs or by hardware. 5*4882a593SmuzhiyunHowever, on some devices there are Serial LEDs (LEDs connected to a 74x164 6*4882a593Smuzhiyuncontroller), which can either be controlled by software (exporting the 74x164 7*4882a593Smuzhiyunas spi-gpio. See Documentation/devicetree/bindings/gpio/gpio-74x164.txt), or 8*4882a593Smuzhiyunby hardware using this driver. 9*4882a593SmuzhiyunSome of these Serial LEDs are hardware controlled (e.g. ethernet LEDs) and 10*4882a593Smuzhiyunexporting the 74x164 as spi-gpio prevents those LEDs to be hardware 11*4882a593Smuzhiyuncontrolled, so the only chance to keep them working is by using this driver. 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunBCM6328 LED controller has a HWDIS register, which controls whether a LED 14*4882a593Smuzhiyunshould be controlled by a hardware signal instead of the MODE register value, 15*4882a593Smuzhiyunwith 0 meaning hardware control enabled and 1 hardware control disabled. This 16*4882a593Smuzhiyunis usually 1:1 for hardware to LED signals, but through the activity/link 17*4882a593Smuzhiyunregisters you have some limited control over rerouting the LEDs (as 18*4882a593Smuzhiyunexplained later in brcm,link-signal-sources). Even if a LED is hardware 19*4882a593Smuzhiyuncontrolled you are still able to make it blink or light it up if it isn't, 20*4882a593Smuzhiyunbut you can't turn it off if the hardware decides to light it up. For this 21*4882a593Smuzhiyunreason, hardware controlled LEDs aren't registered as LED class devices. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunRequired properties: 24*4882a593Smuzhiyun - compatible : should be "brcm,bcm6328-leds". 25*4882a593Smuzhiyun - #address-cells : must be 1. 26*4882a593Smuzhiyun - #size-cells : must be 0. 27*4882a593Smuzhiyun - reg : BCM6328 LED controller address and size. 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunOptional properties: 30*4882a593Smuzhiyun - brcm,serial-leds : Boolean, enables Serial LEDs. 31*4882a593Smuzhiyun Default : false 32*4882a593Smuzhiyun - brcm,serial-mux : Boolean, enables Serial LEDs multiplexing. 33*4882a593Smuzhiyun Default : false 34*4882a593Smuzhiyun - brcm,serial-clk-low : Boolean, makes clock signal active low. 35*4882a593Smuzhiyun Default : false 36*4882a593Smuzhiyun - brcm,serial-dat-low : Boolean, makes data signal active low. 37*4882a593Smuzhiyun Default : false 38*4882a593Smuzhiyun - brcm,serial-shift-inv : Boolean, inverts Serial LEDs shift direction. 39*4882a593Smuzhiyun Default : false 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunEach LED is represented as a sub-node of the brcm,bcm6328-leds device. 42*4882a593Smuzhiyun 43*4882a593SmuzhiyunLED sub-node required properties: 44*4882a593Smuzhiyun - reg : LED pin number (only LEDs 0 to 23 are valid). 45*4882a593Smuzhiyun 46*4882a593SmuzhiyunLED sub-node optional properties: 47*4882a593Smuzhiyun a) Optional properties for sub-nodes related to software controlled LEDs: 48*4882a593Smuzhiyun - label : see Documentation/devicetree/bindings/leds/common.txt 49*4882a593Smuzhiyun - active-low : Boolean, makes LED active low. 50*4882a593Smuzhiyun Default : false 51*4882a593Smuzhiyun - default-state : see 52*4882a593Smuzhiyun Documentation/devicetree/bindings/leds/common.txt 53*4882a593Smuzhiyun - linux,default-trigger : see 54*4882a593Smuzhiyun Documentation/devicetree/bindings/leds/common.txt 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun b) Optional properties for sub-nodes related to hardware controlled LEDs: 57*4882a593Smuzhiyun - brcm,hardware-controlled : Boolean, makes this LED hardware controlled. 58*4882a593Smuzhiyun Default : false 59*4882a593Smuzhiyun - brcm,link-signal-sources : An array of hardware link 60*4882a593Smuzhiyun signal sources. Up to four link hardware signals can get muxed into 61*4882a593Smuzhiyun these LEDs. Only valid for LEDs 0 to 7, where LED signals 0 to 3 may 62*4882a593Smuzhiyun be muxed to LEDs 0 to 3, and signals 4 to 7 may be muxed to LEDs 63*4882a593Smuzhiyun 4 to 7. A signal can be muxed to more than one LED, and one LED can 64*4882a593Smuzhiyun have more than one source signal. 65*4882a593Smuzhiyun - brcm,activity-signal-sources : An array of hardware activity 66*4882a593Smuzhiyun signal sources. Up to four activity hardware signals can get muxed into 67*4882a593Smuzhiyun these LEDs. Only valid for LEDs 0 to 7, where LED signals 0 to 3 may 68*4882a593Smuzhiyun be muxed to LEDs 0 to 3, and signals 4 to 7 may be muxed to LEDs 69*4882a593Smuzhiyun 4 to 7. A signal can be muxed to more than one LED, and one LED can 70*4882a593Smuzhiyun have more than one source signal. 71*4882a593Smuzhiyun 72*4882a593SmuzhiyunExamples: 73*4882a593SmuzhiyunScenario 1 : BCM6328 with 4 EPHY LEDs 74*4882a593Smuzhiyun leds0: led-controller@10000800 { 75*4882a593Smuzhiyun compatible = "brcm,bcm6328-leds"; 76*4882a593Smuzhiyun #address-cells = <1>; 77*4882a593Smuzhiyun #size-cells = <0>; 78*4882a593Smuzhiyun reg = <0x10000800 0x24>; 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun alarm_red@2 { 81*4882a593Smuzhiyun reg = <2>; 82*4882a593Smuzhiyun active-low; 83*4882a593Smuzhiyun label = "red:alarm"; 84*4882a593Smuzhiyun }; 85*4882a593Smuzhiyun inet_green@3 { 86*4882a593Smuzhiyun reg = <3>; 87*4882a593Smuzhiyun active-low; 88*4882a593Smuzhiyun label = "green:inet"; 89*4882a593Smuzhiyun }; 90*4882a593Smuzhiyun power_green@4 { 91*4882a593Smuzhiyun reg = <4>; 92*4882a593Smuzhiyun active-low; 93*4882a593Smuzhiyun label = "green:power"; 94*4882a593Smuzhiyun default-state = "on"; 95*4882a593Smuzhiyun }; 96*4882a593Smuzhiyun ephy0_spd@17 { 97*4882a593Smuzhiyun reg = <17>; 98*4882a593Smuzhiyun brcm,hardware-controlled; 99*4882a593Smuzhiyun }; 100*4882a593Smuzhiyun ephy1_spd@18 { 101*4882a593Smuzhiyun reg = <18>; 102*4882a593Smuzhiyun brcm,hardware-controlled; 103*4882a593Smuzhiyun }; 104*4882a593Smuzhiyun ephy2_spd@19 { 105*4882a593Smuzhiyun reg = <19>; 106*4882a593Smuzhiyun brcm,hardware-controlled; 107*4882a593Smuzhiyun }; 108*4882a593Smuzhiyun ephy3_spd@20 { 109*4882a593Smuzhiyun reg = <20>; 110*4882a593Smuzhiyun brcm,hardware-controlled; 111*4882a593Smuzhiyun }; 112*4882a593Smuzhiyun }; 113*4882a593Smuzhiyun 114*4882a593SmuzhiyunScenario 2 : BCM63268 with Serial/GPHY0 LEDs 115*4882a593Smuzhiyun leds0: led-controller@10001900 { 116*4882a593Smuzhiyun compatible = "brcm,bcm6328-leds"; 117*4882a593Smuzhiyun #address-cells = <1>; 118*4882a593Smuzhiyun #size-cells = <0>; 119*4882a593Smuzhiyun reg = <0x10001900 0x24>; 120*4882a593Smuzhiyun brcm,serial-leds; 121*4882a593Smuzhiyun brcm,serial-dat-low; 122*4882a593Smuzhiyun brcm,serial-shift-inv; 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun gphy0_spd0@0 { 125*4882a593Smuzhiyun reg = <0>; 126*4882a593Smuzhiyun brcm,hardware-controlled; 127*4882a593Smuzhiyun brcm,link-signal-sources = <0>; 128*4882a593Smuzhiyun }; 129*4882a593Smuzhiyun gphy0_spd1@1 { 130*4882a593Smuzhiyun reg = <1>; 131*4882a593Smuzhiyun brcm,hardware-controlled; 132*4882a593Smuzhiyun brcm,link-signal-sources = <1>; 133*4882a593Smuzhiyun }; 134*4882a593Smuzhiyun inet_red@2 { 135*4882a593Smuzhiyun reg = <2>; 136*4882a593Smuzhiyun active-low; 137*4882a593Smuzhiyun label = "red:inet"; 138*4882a593Smuzhiyun }; 139*4882a593Smuzhiyun dsl_green@3 { 140*4882a593Smuzhiyun reg = <3>; 141*4882a593Smuzhiyun active-low; 142*4882a593Smuzhiyun label = "green:dsl"; 143*4882a593Smuzhiyun }; 144*4882a593Smuzhiyun usb_green@4 { 145*4882a593Smuzhiyun reg = <4>; 146*4882a593Smuzhiyun active-low; 147*4882a593Smuzhiyun label = "green:usb"; 148*4882a593Smuzhiyun }; 149*4882a593Smuzhiyun wps_green@7 { 150*4882a593Smuzhiyun reg = <7>; 151*4882a593Smuzhiyun active-low; 152*4882a593Smuzhiyun label = "green:wps"; 153*4882a593Smuzhiyun }; 154*4882a593Smuzhiyun inet_green@8 { 155*4882a593Smuzhiyun reg = <8>; 156*4882a593Smuzhiyun active-low; 157*4882a593Smuzhiyun label = "green:inet"; 158*4882a593Smuzhiyun }; 159*4882a593Smuzhiyun ephy0_act@9 { 160*4882a593Smuzhiyun reg = <9>; 161*4882a593Smuzhiyun brcm,hardware-controlled; 162*4882a593Smuzhiyun }; 163*4882a593Smuzhiyun ephy1_act@10 { 164*4882a593Smuzhiyun reg = <10>; 165*4882a593Smuzhiyun brcm,hardware-controlled; 166*4882a593Smuzhiyun }; 167*4882a593Smuzhiyun ephy2_act@11 { 168*4882a593Smuzhiyun reg = <11>; 169*4882a593Smuzhiyun brcm,hardware-controlled; 170*4882a593Smuzhiyun }; 171*4882a593Smuzhiyun gphy0_act@12 { 172*4882a593Smuzhiyun reg = <12>; 173*4882a593Smuzhiyun brcm,hardware-controlled; 174*4882a593Smuzhiyun }; 175*4882a593Smuzhiyun ephy0_spd@13 { 176*4882a593Smuzhiyun reg = <13>; 177*4882a593Smuzhiyun brcm,hardware-controlled; 178*4882a593Smuzhiyun }; 179*4882a593Smuzhiyun ephy1_spd@14 { 180*4882a593Smuzhiyun reg = <14>; 181*4882a593Smuzhiyun brcm,hardware-controlled; 182*4882a593Smuzhiyun }; 183*4882a593Smuzhiyun ephy2_spd@15 { 184*4882a593Smuzhiyun reg = <15>; 185*4882a593Smuzhiyun brcm,hardware-controlled; 186*4882a593Smuzhiyun }; 187*4882a593Smuzhiyun power_green@20 { 188*4882a593Smuzhiyun reg = <20>; 189*4882a593Smuzhiyun active-low; 190*4882a593Smuzhiyun label = "green:power"; 191*4882a593Smuzhiyun default-state = "on"; 192*4882a593Smuzhiyun }; 193*4882a593Smuzhiyun }; 194*4882a593Smuzhiyun 195*4882a593SmuzhiyunScenario 3 : BCM6362 with 1 LED for each EPHY 196*4882a593Smuzhiyun leds0: led-controller@10001900 { 197*4882a593Smuzhiyun compatible = "brcm,bcm6328-leds"; 198*4882a593Smuzhiyun #address-cells = <1>; 199*4882a593Smuzhiyun #size-cells = <0>; 200*4882a593Smuzhiyun reg = <0x10001900 0x24>; 201*4882a593Smuzhiyun 202*4882a593Smuzhiyun usb@0 { 203*4882a593Smuzhiyun reg = <0>; 204*4882a593Smuzhiyun brcm,hardware-controlled; 205*4882a593Smuzhiyun brcm,link-signal-sources = <0>; 206*4882a593Smuzhiyun brcm,activity-signal-sources = <0>; 207*4882a593Smuzhiyun /* USB link/activity routed to USB LED */ 208*4882a593Smuzhiyun }; 209*4882a593Smuzhiyun inet@1 { 210*4882a593Smuzhiyun reg = <1>; 211*4882a593Smuzhiyun brcm,hardware-controlled; 212*4882a593Smuzhiyun brcm,activity-signal-sources = <1>; 213*4882a593Smuzhiyun /* INET activity routed to INET LED */ 214*4882a593Smuzhiyun }; 215*4882a593Smuzhiyun ephy0@4 { 216*4882a593Smuzhiyun reg = <4>; 217*4882a593Smuzhiyun brcm,hardware-controlled; 218*4882a593Smuzhiyun brcm,link-signal-sources = <4>; 219*4882a593Smuzhiyun /* EPHY0 link routed to EPHY0 LED */ 220*4882a593Smuzhiyun }; 221*4882a593Smuzhiyun ephy1@5 { 222*4882a593Smuzhiyun reg = <5>; 223*4882a593Smuzhiyun brcm,hardware-controlled; 224*4882a593Smuzhiyun brcm,link-signal-sources = <5>; 225*4882a593Smuzhiyun /* EPHY1 link routed to EPHY1 LED */ 226*4882a593Smuzhiyun }; 227*4882a593Smuzhiyun ephy2@6 { 228*4882a593Smuzhiyun reg = <6>; 229*4882a593Smuzhiyun brcm,hardware-controlled; 230*4882a593Smuzhiyun brcm,link-signal-sources = <6>; 231*4882a593Smuzhiyun /* EPHY2 link routed to EPHY2 LED */ 232*4882a593Smuzhiyun }; 233*4882a593Smuzhiyun ephy3@7 { 234*4882a593Smuzhiyun reg = <7>; 235*4882a593Smuzhiyun brcm,hardware-controlled; 236*4882a593Smuzhiyun brcm,link-signal-sources = <7>; 237*4882a593Smuzhiyun /* EPHY3 link routed to EPHY3 LED */ 238*4882a593Smuzhiyun }; 239*4882a593Smuzhiyun power_green@20 { 240*4882a593Smuzhiyun reg = <20>; 241*4882a593Smuzhiyun active-low; 242*4882a593Smuzhiyun label = "green:power"; 243*4882a593Smuzhiyun default-state = "on"; 244*4882a593Smuzhiyun }; 245*4882a593Smuzhiyun }; 246*4882a593Smuzhiyun 247*4882a593SmuzhiyunScenario 4 : BCM6362 with 1 LED for all EPHYs 248*4882a593Smuzhiyun leds0: led-controller@10001900 { 249*4882a593Smuzhiyun compatible = "brcm,bcm6328-leds"; 250*4882a593Smuzhiyun #address-cells = <1>; 251*4882a593Smuzhiyun #size-cells = <0>; 252*4882a593Smuzhiyun reg = <0x10001900 0x24>; 253*4882a593Smuzhiyun 254*4882a593Smuzhiyun usb@0 { 255*4882a593Smuzhiyun reg = <0>; 256*4882a593Smuzhiyun brcm,hardware-controlled; 257*4882a593Smuzhiyun brcm,link-signal-sources = <0 1>; 258*4882a593Smuzhiyun brcm,activity-signal-sources = <0 1>; 259*4882a593Smuzhiyun /* USB/INET link/activity routed to USB LED */ 260*4882a593Smuzhiyun }; 261*4882a593Smuzhiyun ephy@4 { 262*4882a593Smuzhiyun reg = <4>; 263*4882a593Smuzhiyun brcm,hardware-controlled; 264*4882a593Smuzhiyun brcm,link-signal-sources = <4 5 6 7>; 265*4882a593Smuzhiyun /* EPHY0/1/2/3 link routed to EPHY0 LED */ 266*4882a593Smuzhiyun }; 267*4882a593Smuzhiyun power_green@20 { 268*4882a593Smuzhiyun reg = <20>; 269*4882a593Smuzhiyun active-low; 270*4882a593Smuzhiyun label = "green:power"; 271*4882a593Smuzhiyun default-state = "on"; 272*4882a593Smuzhiyun }; 273*4882a593Smuzhiyun }; 274*4882a593Smuzhiyun 275*4882a593SmuzhiyunScenario 5 : BCM6362 with EPHY LEDs swapped 276*4882a593Smuzhiyun leds0: led-controller@10001900 { 277*4882a593Smuzhiyun compatible = "brcm,bcm6328-leds"; 278*4882a593Smuzhiyun #address-cells = <1>; 279*4882a593Smuzhiyun #size-cells = <0>; 280*4882a593Smuzhiyun reg = <0x10001900 0x24>; 281*4882a593Smuzhiyun 282*4882a593Smuzhiyun usb@0 { 283*4882a593Smuzhiyun reg = <0>; 284*4882a593Smuzhiyun brcm,hardware-controlled; 285*4882a593Smuzhiyun brcm,link-signal-sources = <0>; 286*4882a593Smuzhiyun brcm,activity-signal-sources = <0 1>; 287*4882a593Smuzhiyun /* USB link/act and INET act routed to USB LED */ 288*4882a593Smuzhiyun }; 289*4882a593Smuzhiyun ephy0@4 { 290*4882a593Smuzhiyun reg = <4>; 291*4882a593Smuzhiyun brcm,hardware-controlled; 292*4882a593Smuzhiyun brcm,link-signal-sources = <7>; 293*4882a593Smuzhiyun /* EPHY3 link routed to EPHY0 LED */ 294*4882a593Smuzhiyun }; 295*4882a593Smuzhiyun ephy1@5 { 296*4882a593Smuzhiyun reg = <5>; 297*4882a593Smuzhiyun brcm,hardware-controlled; 298*4882a593Smuzhiyun brcm,link-signal-sources = <6>; 299*4882a593Smuzhiyun /* EPHY2 link routed to EPHY1 LED */ 300*4882a593Smuzhiyun }; 301*4882a593Smuzhiyun ephy2@6 { 302*4882a593Smuzhiyun reg = <6>; 303*4882a593Smuzhiyun brcm,hardware-controlled; 304*4882a593Smuzhiyun brcm,link-signal-sources = <5>; 305*4882a593Smuzhiyun /* EPHY1 link routed to EPHY2 LED */ 306*4882a593Smuzhiyun }; 307*4882a593Smuzhiyun ephy3@7 { 308*4882a593Smuzhiyun reg = <7>; 309*4882a593Smuzhiyun brcm,hardware-controlled; 310*4882a593Smuzhiyun brcm,link-signal-sources = <4>; 311*4882a593Smuzhiyun /* EPHY0 link routed to EPHY3 LED */ 312*4882a593Smuzhiyun }; 313*4882a593Smuzhiyun power_green@20 { 314*4882a593Smuzhiyun reg = <20>; 315*4882a593Smuzhiyun active-low; 316*4882a593Smuzhiyun label = "green:power"; 317*4882a593Smuzhiyun default-state = "on"; 318*4882a593Smuzhiyun }; 319*4882a593Smuzhiyun }; 320