Skip to content

Commit 8a7a1fe

Browse files
committed
drivers: pwm: Add support for Apollo510 pwm
This commit adds support for Apollo510 pwm driver Signed-off-by: Hao Luo <hluo@ambiq.com>
1 parent e7adb5a commit 8a7a1fe

File tree

10 files changed

+287
-93
lines changed

10 files changed

+287
-93
lines changed

boards/ambiq/apollo510_evb/apollo510_evb-pinctrl.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,12 @@
380380
drive-strength = "0.5";
381381
};
382382
};
383+
384+
pwm2_default: pwm2_default{
385+
group1 {
386+
pinmux = <CT165_P165>;
387+
drive-open-drain;
388+
drive-strength = "0.5";
389+
};
390+
};
383391
};

boards/ambiq/apollo510_evb/apollo510_evb.dts

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

3233
sram0: memory@SSRAM_BASE_NAME {
@@ -78,6 +79,15 @@
7879
status = "okay";
7980
};
8081
};
82+
83+
pwmleds: pwmleds {
84+
compatible = "pwm-leds";
85+
status = "disabled";
86+
pwm_led0: pwm_led_0 {
87+
pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
88+
label = "PWM_LED";
89+
};
90+
};
8191
};
8292

8393
&xo32m_xtal {
@@ -95,8 +105,18 @@
95105
status = "disabled";
96106
};
97107

98-
&counter0 {
99-
status = "disabled";
108+
&timer0 {
109+
counter0: counter {
110+
status = "disabled";
111+
};
112+
};
113+
114+
&timer2 {
115+
pwm2: pwm {
116+
pinctrl-0 = <&pwm2_default>;
117+
pinctrl-names = "default";
118+
status = "disabled";
119+
};
100120
};
101121

102122
&rtc0 {

drivers/counter/counter_ambiq_timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LOG_MODULE_REGISTER(ambiq_counter, CONFIG_COUNTER_LOG_LEVEL);
1818

1919
#if defined(CONFIG_SOC_SERIES_APOLLO3X)
2020
#define SOC_TIMER_BASE CTIMER_BASE
21-
#elif defined(CONFIG_SOC_SERIES_APOLLO4X)
21+
#elif defined(CONFIG_SOC_SERIES_APOLLO4X) || defined(CONFIG_SOC_SERIES_APOLLO5X)
2222
#define SOC_TIMER_BASE TIMER_BASE
2323
#endif
2424
static void counter_ambiq_isr(void *arg);
@@ -120,7 +120,7 @@ static uint32_t get_clock_cycles(uint32_t clock_sel)
120120
case 18:
121121
ret = 1024;
122122
break;
123-
#elif defined(CONFIG_SOC_SERIES_APOLLO4X)
123+
#elif defined(CONFIG_SOC_SERIES_APOLLO4X) || defined(CONFIG_SOC_SERIES_APOLLO5X)
124124
case 0:
125125
ret = 24000000;
126126
break;

drivers/pwm/pwm_ambiq_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
LOG_MODULE_REGISTER(ambiq_timer_pwm, CONFIG_PWM_LOG_LEVEL);
1818

19-
#if defined(CONFIG_SOC_SERIES_APOLLO4X)
19+
#if defined(CONFIG_SOC_SERIES_APOLLO4X) || defined(CONFIG_SOC_SERIES_APOLLO5X)
2020
typedef am_hal_timer_config_t pwm_timer_config_t;
2121
#endif
2222

0 commit comments

Comments
 (0)