18c2ecf20Sopenharmony_ciLEDs connected to Broadcom BCM6328 controller
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciThis controller is present on BCM6318, BCM6328, BCM6362 and BCM63268.
48c2ecf20Sopenharmony_ciIn these SoCs it's possible to control LEDs both as GPIOs or by hardware.
58c2ecf20Sopenharmony_ciHowever, on some devices there are Serial LEDs (LEDs connected to a 74x164
68c2ecf20Sopenharmony_cicontroller), which can either be controlled by software (exporting the 74x164
78c2ecf20Sopenharmony_cias spi-gpio. See Documentation/devicetree/bindings/gpio/gpio-74x164.txt), or
88c2ecf20Sopenharmony_ciby hardware using this driver.
98c2ecf20Sopenharmony_ciSome of these Serial LEDs are hardware controlled (e.g. ethernet LEDs) and
108c2ecf20Sopenharmony_ciexporting the 74x164 as spi-gpio prevents those LEDs to be hardware
118c2ecf20Sopenharmony_cicontrolled, so the only chance to keep them working is by using this driver.
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciBCM6328 LED controller has a HWDIS register, which controls whether a LED
148c2ecf20Sopenharmony_cishould be controlled by a hardware signal instead of the MODE register value,
158c2ecf20Sopenharmony_ciwith 0 meaning hardware control enabled and 1 hardware control disabled. This
168c2ecf20Sopenharmony_ciis usually 1:1 for hardware to LED signals, but through the activity/link
178c2ecf20Sopenharmony_ciregisters you have some limited control over rerouting the LEDs (as
188c2ecf20Sopenharmony_ciexplained later in brcm,link-signal-sources). Even if a LED is hardware
198c2ecf20Sopenharmony_cicontrolled you are still able to make it blink or light it up if it isn't,
208c2ecf20Sopenharmony_cibut you can't turn it off if the hardware decides to light it up. For this
218c2ecf20Sopenharmony_cireason, hardware controlled LEDs aren't registered as LED class devices.
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ciRequired properties:
248c2ecf20Sopenharmony_ci  - compatible : should be "brcm,bcm6328-leds".
258c2ecf20Sopenharmony_ci  - #address-cells : must be 1.
268c2ecf20Sopenharmony_ci  - #size-cells : must be 0.
278c2ecf20Sopenharmony_ci  - reg : BCM6328 LED controller address and size.
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ciOptional properties:
308c2ecf20Sopenharmony_ci  - brcm,serial-leds : Boolean, enables Serial LEDs.
318c2ecf20Sopenharmony_ci    Default : false
328c2ecf20Sopenharmony_ci  - brcm,serial-mux : Boolean, enables Serial LEDs multiplexing.
338c2ecf20Sopenharmony_ci    Default : false
348c2ecf20Sopenharmony_ci  - brcm,serial-clk-low : Boolean, makes clock signal active low.
358c2ecf20Sopenharmony_ci    Default : false
368c2ecf20Sopenharmony_ci  - brcm,serial-dat-low : Boolean, makes data signal active low.
378c2ecf20Sopenharmony_ci    Default : false
388c2ecf20Sopenharmony_ci  - brcm,serial-shift-inv : Boolean, inverts Serial LEDs shift direction.
398c2ecf20Sopenharmony_ci    Default : false
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciEach LED is represented as a sub-node of the brcm,bcm6328-leds device.
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciLED sub-node required properties:
448c2ecf20Sopenharmony_ci  - reg : LED pin number (only LEDs 0 to 23 are valid).
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciLED sub-node optional properties:
478c2ecf20Sopenharmony_ci  a) Optional properties for sub-nodes related to software controlled LEDs:
488c2ecf20Sopenharmony_ci    - label : see Documentation/devicetree/bindings/leds/common.txt
498c2ecf20Sopenharmony_ci    - active-low : Boolean, makes LED active low.
508c2ecf20Sopenharmony_ci      Default : false
518c2ecf20Sopenharmony_ci    - default-state : see
528c2ecf20Sopenharmony_ci      Documentation/devicetree/bindings/leds/common.txt
538c2ecf20Sopenharmony_ci    - linux,default-trigger : see
548c2ecf20Sopenharmony_ci      Documentation/devicetree/bindings/leds/common.txt
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci  b) Optional properties for sub-nodes related to hardware controlled LEDs:
578c2ecf20Sopenharmony_ci    - brcm,hardware-controlled : Boolean, makes this LED hardware controlled.
588c2ecf20Sopenharmony_ci      Default : false
598c2ecf20Sopenharmony_ci    - brcm,link-signal-sources : An array of hardware link
608c2ecf20Sopenharmony_ci      signal sources. Up to four link hardware signals can get muxed into
618c2ecf20Sopenharmony_ci      these LEDs. Only valid for LEDs 0 to 7, where LED signals 0 to 3 may
628c2ecf20Sopenharmony_ci      be muxed to LEDs 0 to 3, and signals 4 to 7 may be muxed to LEDs
638c2ecf20Sopenharmony_ci      4 to 7. A signal can be muxed to more than one LED, and one LED can
648c2ecf20Sopenharmony_ci      have more than one source signal.
658c2ecf20Sopenharmony_ci    - brcm,activity-signal-sources : An array of hardware activity
668c2ecf20Sopenharmony_ci      signal sources. Up to four activity hardware signals can get muxed into
678c2ecf20Sopenharmony_ci      these LEDs. Only valid for LEDs 0 to 7, where LED signals 0 to 3 may
688c2ecf20Sopenharmony_ci      be muxed to LEDs 0 to 3, and signals 4 to 7 may be muxed to LEDs
698c2ecf20Sopenharmony_ci      4 to 7. A signal can be muxed to more than one LED, and one LED can
708c2ecf20Sopenharmony_ci      have more than one source signal.
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ciExamples:
738c2ecf20Sopenharmony_ciScenario 1 : BCM6328 with 4 EPHY LEDs
748c2ecf20Sopenharmony_ci	leds0: led-controller@10000800 {
758c2ecf20Sopenharmony_ci		compatible = "brcm,bcm6328-leds";
768c2ecf20Sopenharmony_ci		#address-cells = <1>;
778c2ecf20Sopenharmony_ci		#size-cells = <0>;
788c2ecf20Sopenharmony_ci		reg = <0x10000800 0x24>;
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci		alarm_red@2 {
818c2ecf20Sopenharmony_ci			reg = <2>;
828c2ecf20Sopenharmony_ci			active-low;
838c2ecf20Sopenharmony_ci			label = "red:alarm";
848c2ecf20Sopenharmony_ci		};
858c2ecf20Sopenharmony_ci		inet_green@3 {
868c2ecf20Sopenharmony_ci			reg = <3>;
878c2ecf20Sopenharmony_ci			active-low;
888c2ecf20Sopenharmony_ci			label = "green:inet";
898c2ecf20Sopenharmony_ci		};
908c2ecf20Sopenharmony_ci		power_green@4 {
918c2ecf20Sopenharmony_ci			reg = <4>;
928c2ecf20Sopenharmony_ci			active-low;
938c2ecf20Sopenharmony_ci			label = "green:power";
948c2ecf20Sopenharmony_ci			default-state = "on";
958c2ecf20Sopenharmony_ci		};
968c2ecf20Sopenharmony_ci		ephy0_spd@17 {
978c2ecf20Sopenharmony_ci			reg = <17>;
988c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
998c2ecf20Sopenharmony_ci		};
1008c2ecf20Sopenharmony_ci		ephy1_spd@18 {
1018c2ecf20Sopenharmony_ci			reg = <18>;
1028c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1038c2ecf20Sopenharmony_ci		};
1048c2ecf20Sopenharmony_ci		ephy2_spd@19 {
1058c2ecf20Sopenharmony_ci			reg = <19>;
1068c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1078c2ecf20Sopenharmony_ci		};
1088c2ecf20Sopenharmony_ci		ephy3_spd@20 {
1098c2ecf20Sopenharmony_ci			reg = <20>;
1108c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1118c2ecf20Sopenharmony_ci		};
1128c2ecf20Sopenharmony_ci	};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ciScenario 2 : BCM63268 with Serial/GPHY0 LEDs
1158c2ecf20Sopenharmony_ci	leds0: led-controller@10001900 {
1168c2ecf20Sopenharmony_ci		compatible = "brcm,bcm6328-leds";
1178c2ecf20Sopenharmony_ci		#address-cells = <1>;
1188c2ecf20Sopenharmony_ci		#size-cells = <0>;
1198c2ecf20Sopenharmony_ci		reg = <0x10001900 0x24>;
1208c2ecf20Sopenharmony_ci		brcm,serial-leds;
1218c2ecf20Sopenharmony_ci		brcm,serial-dat-low;
1228c2ecf20Sopenharmony_ci		brcm,serial-shift-inv;
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci		gphy0_spd0@0 {
1258c2ecf20Sopenharmony_ci			reg = <0>;
1268c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1278c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <0>;
1288c2ecf20Sopenharmony_ci		};
1298c2ecf20Sopenharmony_ci		gphy0_spd1@1 {
1308c2ecf20Sopenharmony_ci			reg = <1>;
1318c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1328c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <1>;
1338c2ecf20Sopenharmony_ci		};
1348c2ecf20Sopenharmony_ci		inet_red@2 {
1358c2ecf20Sopenharmony_ci			reg = <2>;
1368c2ecf20Sopenharmony_ci			active-low;
1378c2ecf20Sopenharmony_ci			label = "red:inet";
1388c2ecf20Sopenharmony_ci		};
1398c2ecf20Sopenharmony_ci		dsl_green@3 {
1408c2ecf20Sopenharmony_ci			reg = <3>;
1418c2ecf20Sopenharmony_ci			active-low;
1428c2ecf20Sopenharmony_ci			label = "green:dsl";
1438c2ecf20Sopenharmony_ci		};
1448c2ecf20Sopenharmony_ci		usb_green@4 {
1458c2ecf20Sopenharmony_ci			reg = <4>;
1468c2ecf20Sopenharmony_ci			active-low;
1478c2ecf20Sopenharmony_ci			label = "green:usb";
1488c2ecf20Sopenharmony_ci		};
1498c2ecf20Sopenharmony_ci		wps_green@7 {
1508c2ecf20Sopenharmony_ci			reg = <7>;
1518c2ecf20Sopenharmony_ci			active-low;
1528c2ecf20Sopenharmony_ci			label = "green:wps";
1538c2ecf20Sopenharmony_ci		};
1548c2ecf20Sopenharmony_ci		inet_green@8 {
1558c2ecf20Sopenharmony_ci			reg = <8>;
1568c2ecf20Sopenharmony_ci			active-low;
1578c2ecf20Sopenharmony_ci			label = "green:inet";
1588c2ecf20Sopenharmony_ci		};
1598c2ecf20Sopenharmony_ci		ephy0_act@9 {
1608c2ecf20Sopenharmony_ci			reg = <9>;
1618c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1628c2ecf20Sopenharmony_ci		};
1638c2ecf20Sopenharmony_ci		ephy1_act@10 {
1648c2ecf20Sopenharmony_ci			reg = <10>;
1658c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1668c2ecf20Sopenharmony_ci		};
1678c2ecf20Sopenharmony_ci		ephy2_act@11 {
1688c2ecf20Sopenharmony_ci			reg = <11>;
1698c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1708c2ecf20Sopenharmony_ci		};
1718c2ecf20Sopenharmony_ci		gphy0_act@12 {
1728c2ecf20Sopenharmony_ci			reg = <12>;
1738c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1748c2ecf20Sopenharmony_ci		};
1758c2ecf20Sopenharmony_ci		ephy0_spd@13 {
1768c2ecf20Sopenharmony_ci			reg = <13>;
1778c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1788c2ecf20Sopenharmony_ci		};
1798c2ecf20Sopenharmony_ci		ephy1_spd@14 {
1808c2ecf20Sopenharmony_ci			reg = <14>;
1818c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1828c2ecf20Sopenharmony_ci		};
1838c2ecf20Sopenharmony_ci		ephy2_spd@15 {
1848c2ecf20Sopenharmony_ci			reg = <15>;
1858c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
1868c2ecf20Sopenharmony_ci		};
1878c2ecf20Sopenharmony_ci		power_green@20 {
1888c2ecf20Sopenharmony_ci			reg = <20>;
1898c2ecf20Sopenharmony_ci			active-low;
1908c2ecf20Sopenharmony_ci			label = "green:power";
1918c2ecf20Sopenharmony_ci			default-state = "on";
1928c2ecf20Sopenharmony_ci		};
1938c2ecf20Sopenharmony_ci	};
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ciScenario 3 : BCM6362 with 1 LED for each EPHY
1968c2ecf20Sopenharmony_ci	leds0: led-controller@10001900 {
1978c2ecf20Sopenharmony_ci		compatible = "brcm,bcm6328-leds";
1988c2ecf20Sopenharmony_ci		#address-cells = <1>;
1998c2ecf20Sopenharmony_ci		#size-cells = <0>;
2008c2ecf20Sopenharmony_ci		reg = <0x10001900 0x24>;
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci		usb@0 {
2038c2ecf20Sopenharmony_ci			reg = <0>;
2048c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2058c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <0>;
2068c2ecf20Sopenharmony_ci			brcm,activity-signal-sources = <0>;
2078c2ecf20Sopenharmony_ci			/* USB link/activity routed to USB LED */
2088c2ecf20Sopenharmony_ci		};
2098c2ecf20Sopenharmony_ci		inet@1 {
2108c2ecf20Sopenharmony_ci			reg = <1>;
2118c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2128c2ecf20Sopenharmony_ci			brcm,activity-signal-sources = <1>;
2138c2ecf20Sopenharmony_ci			/* INET activity routed to INET LED */
2148c2ecf20Sopenharmony_ci		};
2158c2ecf20Sopenharmony_ci		ephy0@4 {
2168c2ecf20Sopenharmony_ci			reg = <4>;
2178c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2188c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <4>;
2198c2ecf20Sopenharmony_ci			/* EPHY0 link routed to EPHY0 LED */
2208c2ecf20Sopenharmony_ci		};
2218c2ecf20Sopenharmony_ci		ephy1@5 {
2228c2ecf20Sopenharmony_ci			reg = <5>;
2238c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2248c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <5>;
2258c2ecf20Sopenharmony_ci			/* EPHY1 link routed to EPHY1 LED */
2268c2ecf20Sopenharmony_ci		};
2278c2ecf20Sopenharmony_ci		ephy2@6 {
2288c2ecf20Sopenharmony_ci			reg = <6>;
2298c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2308c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <6>;
2318c2ecf20Sopenharmony_ci			/* EPHY2 link routed to EPHY2 LED */
2328c2ecf20Sopenharmony_ci		};
2338c2ecf20Sopenharmony_ci		ephy3@7 {
2348c2ecf20Sopenharmony_ci			reg = <7>;
2358c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2368c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <7>;
2378c2ecf20Sopenharmony_ci			/* EPHY3 link routed to EPHY3 LED */
2388c2ecf20Sopenharmony_ci		};
2398c2ecf20Sopenharmony_ci		power_green@20 {
2408c2ecf20Sopenharmony_ci			reg = <20>;
2418c2ecf20Sopenharmony_ci			active-low;
2428c2ecf20Sopenharmony_ci			label = "green:power";
2438c2ecf20Sopenharmony_ci			default-state = "on";
2448c2ecf20Sopenharmony_ci		};
2458c2ecf20Sopenharmony_ci	};
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ciScenario 4 : BCM6362 with 1 LED for all EPHYs
2488c2ecf20Sopenharmony_ci	leds0: led-controller@10001900 {
2498c2ecf20Sopenharmony_ci		compatible = "brcm,bcm6328-leds";
2508c2ecf20Sopenharmony_ci		#address-cells = <1>;
2518c2ecf20Sopenharmony_ci		#size-cells = <0>;
2528c2ecf20Sopenharmony_ci		reg = <0x10001900 0x24>;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci		usb@0 {
2558c2ecf20Sopenharmony_ci			reg = <0>;
2568c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2578c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <0 1>;
2588c2ecf20Sopenharmony_ci			brcm,activity-signal-sources = <0 1>;
2598c2ecf20Sopenharmony_ci			/* USB/INET link/activity routed to USB LED */
2608c2ecf20Sopenharmony_ci		};
2618c2ecf20Sopenharmony_ci		ephy@4 {
2628c2ecf20Sopenharmony_ci			reg = <4>;
2638c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2648c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <4 5 6 7>;
2658c2ecf20Sopenharmony_ci			/* EPHY0/1/2/3 link routed to EPHY0 LED */
2668c2ecf20Sopenharmony_ci		};
2678c2ecf20Sopenharmony_ci		power_green@20 {
2688c2ecf20Sopenharmony_ci			reg = <20>;
2698c2ecf20Sopenharmony_ci			active-low;
2708c2ecf20Sopenharmony_ci			label = "green:power";
2718c2ecf20Sopenharmony_ci			default-state = "on";
2728c2ecf20Sopenharmony_ci		};
2738c2ecf20Sopenharmony_ci	};
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ciScenario 5 : BCM6362 with EPHY LEDs swapped
2768c2ecf20Sopenharmony_ci	leds0: led-controller@10001900 {
2778c2ecf20Sopenharmony_ci		compatible = "brcm,bcm6328-leds";
2788c2ecf20Sopenharmony_ci		#address-cells = <1>;
2798c2ecf20Sopenharmony_ci		#size-cells = <0>;
2808c2ecf20Sopenharmony_ci		reg = <0x10001900 0x24>;
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci		usb@0 {
2838c2ecf20Sopenharmony_ci			reg = <0>;
2848c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2858c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <0>;
2868c2ecf20Sopenharmony_ci			brcm,activity-signal-sources = <0 1>;
2878c2ecf20Sopenharmony_ci			/* USB link/act and INET act routed to USB LED */
2888c2ecf20Sopenharmony_ci		};
2898c2ecf20Sopenharmony_ci		ephy0@4 {
2908c2ecf20Sopenharmony_ci			reg = <4>;
2918c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2928c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <7>;
2938c2ecf20Sopenharmony_ci			/* EPHY3 link routed to EPHY0 LED */
2948c2ecf20Sopenharmony_ci		};
2958c2ecf20Sopenharmony_ci		ephy1@5 {
2968c2ecf20Sopenharmony_ci			reg = <5>;
2978c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
2988c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <6>;
2998c2ecf20Sopenharmony_ci			/* EPHY2 link routed to EPHY1 LED */
3008c2ecf20Sopenharmony_ci		};
3018c2ecf20Sopenharmony_ci		ephy2@6 {
3028c2ecf20Sopenharmony_ci			reg = <6>;
3038c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
3048c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <5>;
3058c2ecf20Sopenharmony_ci			/* EPHY1 link routed to EPHY2 LED */
3068c2ecf20Sopenharmony_ci		};
3078c2ecf20Sopenharmony_ci		ephy3@7 {
3088c2ecf20Sopenharmony_ci			reg = <7>;
3098c2ecf20Sopenharmony_ci			brcm,hardware-controlled;
3108c2ecf20Sopenharmony_ci			brcm,link-signal-sources = <4>;
3118c2ecf20Sopenharmony_ci			/* EPHY0 link routed to EPHY3 LED */
3128c2ecf20Sopenharmony_ci		};
3138c2ecf20Sopenharmony_ci		power_green@20 {
3148c2ecf20Sopenharmony_ci			reg = <20>;
3158c2ecf20Sopenharmony_ci			active-low;
3168c2ecf20Sopenharmony_ci			label = "green:power";
3178c2ecf20Sopenharmony_ci			default-state = "on";
3188c2ecf20Sopenharmony_ci		};
3198c2ecf20Sopenharmony_ci	};
320