Skip to content

Commit bb2df88

Browse files
RichardSWheatleyAlessandroLuo
authored andcommitted
driver: pwm: create ambiq pwm driver
Restructured counter and timer. CTimer/Timer is now parent to pwm and counter. Created PWM driver and tied to pwm and pwm-led Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
1 parent cf0f00d commit bb2df88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1901
-100
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: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
sw1 = &button1;
3131
bootloader-led0 = &led0;
3232
mcuboot-led0 = &led0;
33+
pwm-led0 = &pwm_led0;
3334
};
3435

3536
leds {
@@ -74,6 +75,15 @@
7475
zephyr,code = <INPUT_KEY_2>;
7576
};
7677
};
78+
79+
pwmleds: pwmleds {
80+
compatible = "pwm-leds";
81+
status = "disabled";
82+
pwm_led0: pwm_led_0 {
83+
pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
84+
label = "PWM_LED";
85+
};
86+
};
7787
};
7888

7989
&flash0 {
@@ -159,8 +169,21 @@
159169
};
160170
};
161171

162-
&counter0 {
163-
status = "disabled";
172+
&timer0 {
173+
counter0: counter {
174+
status = "disabled";
175+
};
176+
};
177+
178+
&timer2 {
179+
pwm2: pwm {
180+
timer-segment = "SEGMENT_B";
181+
clock-select = "CLK_SELECT_HFRC_187_5KHZ";
182+
pwm-type = "PWM_REPEAT";
183+
pinctrl-0 = <&pwm2_default>;
184+
pinctrl-names = "default";
185+
status = "disabled";
186+
};
164187
};
165188

166189
&rtc0 {

boards/ambiq/apollo3p_evb/apollo3p_evb-pinctrl.dtsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,10 @@
179179
<BLEIF_IRQ_P41>;
180180
};
181181
};
182+
183+
pwm2_default: pwm2_default{
184+
group1 {
185+
pinmux = <GPIO_P30>;
186+
};
187+
};
182188
};

boards/ambiq/apollo3p_evb/apollo3p_evb.dts

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

3132
leds {
@@ -70,6 +71,15 @@
7071
zephyr,code = <INPUT_KEY_2>;
7172
};
7273
};
74+
75+
pwmleds: pwmleds {
76+
compatible = "pwm-leds";
77+
status = "disabled";
78+
pwm_led0: pwm_led_0 {
79+
pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
80+
label = "PWM_LED";
81+
};
82+
};
7383
};
7484

7585
&flash0 {
@@ -137,8 +147,21 @@
137147
};
138148
};
139149

140-
&counter0 {
141-
status = "disabled";
150+
&timer0 {
151+
counter0: counter {
152+
status = "disabled";
153+
};
154+
};
155+
156+
&timer2 {
157+
pwm2: pwm {
158+
timer-segment = "SEGMENT_B";
159+
clock-select = "CLK_SELECT_HFRC_187_5KHZ";
160+
pwm-type = "PWM_REPEAT";
161+
pinctrl-0 = <&pwm2_default>;
162+
pinctrl-names = "default";
163+
status = "disabled";
164+
};
142165
};
143166

144167
&rtc0 {

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
@@ -170,4 +170,11 @@
170170
drive-strength = "0.1";
171171
};
172172
};
173+
pwm2_default: pwm2_default{
174+
group1 {
175+
pinmux = <CT30_P30>;
176+
drive-open-drain;
177+
drive-strength = "0.5";
178+
};
179+
};
173180
};

boards/ambiq/apollo4p_blue_kxr_evb/apollo4p_blue_kxr_evb.dts

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

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

6575
&uart0 {
@@ -75,8 +85,19 @@
7585
status = "okay";
7686
};
7787

78-
&counter0 {
79-
status = "disabled";
88+
&timer0 {
89+
counter0: counter {
90+
status = "disabled";
91+
};
92+
};
93+
94+
&timer2 {
95+
pwm2: pwm {
96+
clock-select = "CLK_SELECT_HFRC_DIV64";
97+
pinctrl-0 = <&pwm2_default>;
98+
pinctrl-names = "default";
99+
status = "disabled";
100+
};
80101
};
81102

82103
&rtc0 {

boards/ambiq/apollo4p_evb/apollo4p_evb-pinctrl.dtsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,11 @@
192192
ambiq,pull-up-ohms = <12000>;
193193
};
194194
};
195+
pwm2_default: pwm2_default{
196+
group1 {
197+
pinmux = <CT30_P30>;
198+
drive-open-drain;
199+
drive-strength = "0.5";
200+
};
201+
};
195202
};

boards/ambiq/apollo4p_evb/apollo4p_evb.dts

Lines changed: 22 additions & 2 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 {
@@ -59,6 +60,14 @@
5960
status = "okay";
6061
};
6162
};
63+
pwmleds: pwmleds {
64+
compatible = "pwm-leds";
65+
status = "disabled";
66+
pwm_led0: pwm_led_0 {
67+
pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
68+
label = "PWM_LED";
69+
};
70+
};
6271
};
6372

6473
&uart0 {
@@ -80,8 +89,19 @@
8089
status = "disabled";
8190
};
8291

83-
&counter0 {
84-
status = "disabled";
92+
&timer0 {
93+
counter0: counter {
94+
status = "disabled";
95+
};
96+
};
97+
98+
&timer2 {
99+
pwm2: pwm {
100+
clock-select = "CLK_SELECT_HFRC_DIV64";
101+
pinctrl-0 = <&pwm2_default>;
102+
pinctrl-names = "default";
103+
status = "disabled";
104+
};
85105
};
86106

87107
&rtc0 {

0 commit comments

Comments
 (0)