Skip to content

Commit 558f75f

Browse files
Merge pull request zephyrproject-rtos#23 from AmbiqMicro/ambiq-add-pwm-restructure-counter
drivers: pwm: Add pwm driver and restructure counter
2 parents 0485c1a + 3d6045f commit 558f75f

36 files changed

+1863
-200
lines changed

boards/ambiq/apollo3_evb/apollo3_evb-pinctrl.dtsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,10 @@
140140
<BLEIF_IRQ_P41>;
141141
};
142142
};
143+
144+
pwm2_default: pwm2_default{
145+
group1 {
146+
pinmux = <GPIO_P30>;
147+
};
148+
};
143149
};

boards/ambiq/apollo3_evb/apollo3_evb.dts

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
led2 = &led2;
2626
sw0 = &button0;
2727
sw1 = &button1;
28+
pwm-led0 = &pwm_led0;
2829
};
2930

3031
leds {
@@ -66,6 +67,15 @@
6667
label = "BTN2";
6768
};
6869
};
70+
71+
pwmleds: pwmleds {
72+
compatible = "pwm-leds";
73+
status = "disabled";
74+
pwm_led0: pwm_led_0 {
75+
pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
76+
label = "PWM_LED";
77+
};
78+
};
6979
};
7080

7181
&flash0 {
@@ -131,36 +141,20 @@
131141
status = "okay";
132142
};
133143

134-
&counter0 {
135-
status = "okay";
136-
};
137-
138-
&counter1 {
139-
status = "okay";
140-
};
141-
142-
&counter2 {
143-
status = "okay";
144-
};
145-
146-
&counter3 {
147-
status = "okay";
148-
};
149-
150-
&counter4 {
151-
status = "okay";
152-
};
153-
154-
&counter5 {
155-
status = "okay";
156-
};
157-
158-
&counter6 {
159-
status = "okay";
144+
&timer0 {
145+
counter0: counter {
146+
status = "okay";
147+
};
160148
};
161149

162-
&counter7 {
163-
status = "okay";
150+
&timer2 {
151+
pwm2: pwm {
152+
timer-segment = "SEGMENT_B";
153+
pwm-type = "PWM_REPEAT";
154+
pinctrl-0 = <&pwm2_default>;
155+
pinctrl-names = "default";
156+
status = "disabled";
157+
};
164158
};
165159

166160
&adc0 {

boards/ambiq/apollo3p_evb/apollo3p_evb-pinctrl.dtsi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,12 @@
105105
pinmux = <M5SCK_P48>, <M5MISO_P49>, <M5MOSI_P47>;
106106
};
107107
};
108-
109108
adc0_default: adc0_default{
110109
group1 {
111110
pinmux = <ADCSE4_P32>, <ADCSE7_P35>;
112111
drive-strength = "0.1";
113112
};
114113
};
115-
116114
mspi0_default: mspi0_default{
117115
group1 {
118116
pinmux = <MSPI0_0_P22>,
@@ -168,7 +166,6 @@
168166
ambiq,iom-num = <2>;
169167
};
170168
};
171-
172169
bleif_default: bleif_default{
173170
group1 {
174171
pinmux = <BLEIF_SCK_P30>,
@@ -179,4 +176,9 @@
179176
<BLEIF_IRQ_P41>;
180177
};
181178
};
179+
pwm2_default: pwm2_default{
180+
group1 {
181+
pinmux = <GPIO_P30>;
182+
};
183+
};
182184
};

boards/ambiq/apollo3p_evb/apollo3p_evb.dts

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
led2 = &led2;
2626
sw0 = &button0;
2727
sw1 = &button1;
28+
pwm-led0 = &pwm_led0;
2829
};
2930

3031
leds {
@@ -66,6 +67,15 @@
6667
label = "BTN2";
6768
};
6869
};
70+
71+
pwmleds: pwmleds {
72+
compatible = "pwm-leds";
73+
status = "disabled";
74+
pwm_led0: pwm_led_0 {
75+
pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
76+
label = "PWM_LED";
77+
};
78+
};
6979
};
7080

7181
&flash0 {
@@ -131,36 +141,20 @@
131141
status = "okay";
132142
};
133143

134-
&counter0 {
135-
status = "okay";
136-
};
137-
138-
&counter1 {
139-
status = "okay";
140-
};
141-
142-
&counter2 {
143-
status = "okay";
144-
};
145-
146-
&counter3 {
147-
status = "okay";
148-
};
149-
150-
&counter4 {
151-
status = "okay";
152-
};
153-
154-
&counter5 {
155-
status = "okay";
156-
};
157-
158-
&counter6 {
159-
status = "okay";
144+
&timer0 {
145+
counter0: counter {
146+
status = "okay";
147+
};
160148
};
161149

162-
&counter7 {
163-
status = "okay";
150+
&timer2 {
151+
pwm2: pwm {
152+
timer-segment = "SEGMENT_B";
153+
pwm-type = "PWM_REPEAT";
154+
pinctrl-0 = <&pwm2_default>;
155+
pinctrl-names = "default";
156+
status = "disabled";
157+
};
164158
};
165159

166160
&adc0 {

boards/ambiq/apollo4p_blue_kxr_evb/apollo4p_blue_kxr_evb-pinctrl.dtsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,11 @@
176176
drive-strength = "0.1";
177177
};
178178
};
179+
pwm2_default: pwm2_default{
180+
group1 {
181+
pinmux = <CT30_P30>;
182+
drive-open-drain;
183+
drive-strength = "0.5";
184+
};
185+
};
179186
};

boards/ambiq/apollo4p_blue_kxr_evb/apollo4p_blue_kxr_evb.dts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
sw0 = &button0;
2828
sw1 = &button1;
2929
rtc = &rtc0;
30+
pwm-led0 = &pwm_led0;
3031
};
3132

3233
leds {
@@ -61,6 +62,15 @@
6162
status = "okay";
6263
};
6364
};
65+
66+
pwmleds: pwmleds {
67+
compatible = "pwm-leds";
68+
status = "disabled";
69+
pwm_led0: pwm_led_0 {
70+
pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
71+
label = "PWM_LED";
72+
};
73+
};
6474
};
6575

6676
&uart0 {
@@ -76,8 +86,18 @@
7686
status = "okay";
7787
};
7888

79-
&counter0 {
80-
status = "okay";
89+
&timer0 {
90+
counter0: counter {
91+
status = "okay";
92+
};
93+
};
94+
95+
&timer2 {
96+
pwm2: pwm {
97+
pinctrl-0 = <&pwm2_default>;
98+
pinctrl-names = "default";
99+
status = "disabled";
100+
};
81101
};
82102

83103
&rtc0 {

boards/ambiq/apollo4p_evb/apollo4p_evb-pinctrl.dtsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,11 @@
194194
ambiq,iom-nce-module = <36>;
195195
};
196196
};
197+
pwm2_default: pwm2_default{
198+
group1 {
199+
pinmux = <CT30_P30>;
200+
drive-open-drain;
201+
drive-strength = "0.5";
202+
};
203+
};
197204
};

boards/ambiq/apollo4p_evb/apollo4p_evb.dts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
sw0 = &button0;
2727
sw1 = &button1;
2828
rtc = &rtc0;
29+
pwm-led0 = &pwm_led0;
2930
};
3031

3132
leds {
@@ -60,6 +61,14 @@
6061
status = "okay";
6162
};
6263
};
64+
pwmleds: pwmleds {
65+
compatible = "pwm-leds";
66+
status = "disabled";
67+
pwm_led0: pwm_led_0 {
68+
pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
69+
label = "PWM_LED";
70+
};
71+
};
6372
};
6473

6574
&uart0 {
@@ -82,8 +91,18 @@
8291
status = "okay";
8392
};
8493

85-
&counter0 {
86-
status = "okay";
94+
&timer0 {
95+
counter0: counter {
96+
status = "okay";
97+
};
98+
};
99+
100+
&timer2 {
101+
pwm2: pwm {
102+
pinctrl-0 = <&pwm2_default>;
103+
pinctrl-names = "default";
104+
status = "disabled";
105+
};
87106
};
88107

89108
&rtc0 {

0 commit comments

Comments
 (0)