1/*
2 * Copyright (c) 2023 Microchip Technology Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/dt-bindings/pwm/pwm.h>
8
9/* MEC172x EVB
10 * BBLED controller 0 uses GPIO156/LED1 connected to JP71-11
11 * BBLED controller 1 uses GPIO157/LED2 connected to JP71-13
12 * BBLED controller 2 uses GPIO153/LED3 connected to JP71-5
13 * BBLED controller 3 uses GPIO035/PWM8 connected to JP67-19
14 * NOTE: Data sheet indicates BBLED3 uses GPIO035.
15 * Schematic Rev A1p0 shows LED3 on GPIO226 (incorrect).
16 * BBLED hardware divides input clock (32KHz or 48MHz) by (256 * (prescalar+1)
17 * and implements duty cycle for blink mode as an 8-bit value where 0 is off and
18 * 255 full on. BBLED PWM is 8-bit.
19 * BBLED-PWM driver get cycles API reports 32KHz/256 or 48M/256.
20 * Due to all the above we use 50 ms for DT PWM period.
21 */
22
23/* PWM_SEC(1) PWM_USEC(7812) */
24/ {
25	pwmleds {
26		compatible = "pwm-leds";
27		/* struct pwm_dt_spec: phandle channel period(ns) flags */
28		bbled_pwm0: bbled_pwm0 {
29			pwms = <&bbled0 0 PWM_MSEC(50) PWM_POLARITY_NORMAL>;
30		};
31		bbled_pwm1: bbled_pwm1 {
32			pwms = <&bbled1 0 PWM_MSEC(50) PWM_POLARITY_NORMAL>;
33		};
34		bbled_pwm2: bbled_pwm2 {
35			pwms = <&bbled2 0 PWM_MSEC(50) PWM_POLARITY_NORMAL>;
36		};
37		bbled_pwm3: bbled_pwm3 {
38			pwms = <&bbled3 0 PWM_MSEC(50) PWM_POLARITY_NORMAL>;
39		};
40	};
41};
42
43&pinctrl {
44	led0_gpio156_invert: led0_gpio156_invert {
45		pinmux = <MCHP_XEC_PINMUX(0156, MCHP_AF1)>;
46		microchip,output-func-invert;
47	};
48	led1_gpio157_invert: led1_gpio157_invert {
49		pinmux = <MCHP_XEC_PINMUX(0157, MCHP_AF1)>;
50		microchip,output-func-invert;
51	};
52	led2_gpio153_invert: led2_gpio153_invert {
53		pinmux = <MCHP_XEC_PINMUX(0153, MCHP_AF1)>;
54		microchip,output-func-invert;
55	};
56	led3_gpio035_invert: led3_gpio035_invert {
57		pinmux = <MCHP_XEC_PINMUX(035, MCHP_AF4)>;
58		microchip,output-func-invert;
59	};
60};
61
62&bbled0 {
63	compatible = "microchip,xec-pwmbbled";
64	clock-select = "PWM_BBLED_CLK_32K";
65	pinctrl-0 = <&led0_gpio156>;
66	pinctrl-1 = <&led0_gpio156_sleep>;
67	pinctrl-names = "default", "sleep";
68	status = "okay";
69	#pwm-cells = <3>;
70};
71
72&bbled1 {
73	compatible = "microchip,xec-pwmbbled";
74	clock-select = "PWM_BBLED_CLK_32K";
75	pinctrl-0 = <&led1_gpio157>;
76	pinctrl-1 = <&led1_gpio157_sleep>;
77	pinctrl-names = "default", "sleep";
78	status = "okay";
79	#pwm-cells = <3>;
80};
81
82&bbled2 {
83	compatible = "microchip,xec-pwmbbled";
84	clock-select = "PWM_BBLED_CLK_32K";
85	pinctrl-0 = <&led2_gpio153>;
86	pinctrl-1 = <&led2_gpio153_sleep>;
87	pinctrl-names = "default", "sleep";
88	status = "okay";
89	#pwm-cells = <3>;
90};
91
92&bbled3 {
93	compatible = "microchip,xec-pwmbbled";
94	clock-select = "PWM_BBLED_CLK_32K";
95	pinctrl-0 = <&led3_gpio035>;
96	pinctrl-1 = <&led3_gpio035_sleep>;
97	pinctrl-names = "default", "sleep";
98	status = "okay";
99	#pwm-cells = <3>;
100};
101