Skip to content

Commit f6e2cb9

Browse files
jvasanth1MaureenHelm
authored andcommitted
drivers: uart: microchip: add support for mec15xx
update uart mchp xec driver to support mec15xx and add pinctrl support for mec15xx uart Signed-off-by: Jay Vasanth <[email protected]>
1 parent a657aba commit f6e2cb9

File tree

4 files changed

+71
-17
lines changed

4 files changed

+71
-17
lines changed

boards/arm/mec1501modular_assy6885/mec1501modular_assy6885.dts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
&uart1 {
5353
status = "okay";
5454
current-speed = <115200>;
55+
pinctrl-0 = <&uart1_tx_gpio170 &uart1_rx_gpio171>;
56+
pinctrl-names = "default";
5557
};
5658

5759
&adc0 {

boards/arm/mec15xxevb_assy6853/mec15xxevb_assy6853.dts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
&uart2 {
8181
status = "okay";
8282
current-speed = <115200>;
83+
pinctrl-0 = <&uart2_tx_gpio146 &uart2_rx_gpio145>;
84+
pinctrl-names = "default";
8385
};
8486

8587
&adc0 {

drivers/serial/uart_mchp_xec.c

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@
2424
#include <zephyr/init.h>
2525
#include <zephyr/toolchain.h>
2626
#include <zephyr/linker/sections.h>
27+
#ifdef CONFIG_SOC_SERIES_MEC172X
2728
#include <zephyr/drivers/clock_control/mchp_xec_clock_control.h>
2829
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
30+
#endif
2931
#include <zephyr/drivers/pinctrl.h>
3032
#include <zephyr/drivers/uart.h>
3133
#include <zephyr/sys/sys_io.h>
3234
#include <zephyr/spinlock.h>
3335

34-
BUILD_ASSERT(IS_ENABLED(CONFIG_SOC_SERIES_MEC172X),
35-
"XEC UART driver only support MEC172x at this time");
36-
3736
/* Clock source is 1.8432 MHz derived from PLL 48 MHz */
3837
#define XEC_UART_CLK_SRC_1P8M 0
3938
/* Clock source is PLL 48 MHz output */
@@ -195,6 +194,56 @@ struct uart_xec_dev_data {
195194

196195
static const struct uart_driver_api uart_xec_driver_api;
197196

197+
#ifdef CONFIG_SOC_SERIES_MEC172X
198+
199+
static void uart_clr_slp_en(const struct device *dev)
200+
{
201+
struct uart_xec_device_config const *dev_cfg = dev->config;
202+
203+
z_mchp_xec_pcr_periph_sleep(dev_cfg->pcr_idx, dev_cfg->pcr_bitpos, 0);
204+
}
205+
206+
static inline void uart_xec_girq_clr(const struct device *dev)
207+
{
208+
struct uart_xec_device_config const *dev_cfg = dev->config;
209+
210+
mchp_soc_ecia_girq_src_clr(dev_cfg->girq_id, dev_cfg->girq_pos);
211+
}
212+
213+
static inline void uart_xec_girq_en(uint8_t girq_idx, uint8_t girq_posn)
214+
{
215+
mchp_xec_ecia_girq_src_en(girq_idx, girq_posn);
216+
}
217+
218+
#else
219+
220+
static void uart_clr_slp_en(const struct device *dev)
221+
{
222+
struct uart_xec_device_config const *dev_cfg = dev->config;
223+
224+
if (dev_cfg->pcr_bitpos == MCHP_PCR2_UART0_POS) {
225+
mchp_pcr_periph_slp_ctrl(PCR_UART0, 0);
226+
} else if (dev_cfg->pcr_bitpos == MCHP_PCR2_UART1_POS) {
227+
mchp_pcr_periph_slp_ctrl(PCR_UART1, 0);
228+
} else {
229+
mchp_pcr_periph_slp_ctrl(PCR_UART2, 0);
230+
}
231+
}
232+
233+
static inline void uart_xec_girq_clr(const struct device *dev)
234+
{
235+
struct uart_xec_device_config const *dev_cfg = dev->config;
236+
237+
MCHP_GIRQ_SRC(dev_cfg->girq_id) = BIT(dev_cfg->girq_pos);
238+
}
239+
240+
static inline void uart_xec_girq_en(uint8_t girq_idx, uint8_t girq_posn)
241+
{
242+
MCHP_GIRQ_ENSET(girq_idx) = BIT(girq_posn);
243+
}
244+
245+
#endif
246+
198247
static void set_baud_rate(const struct device *dev, uint32_t baud_rate)
199248
{
200249
const struct uart_xec_device_config * const dev_cfg = dev->config;
@@ -363,11 +412,7 @@ static int uart_xec_init(const struct device *dev)
363412
struct uart_xec_dev_data *dev_data = dev->data;
364413
int ret;
365414

366-
ret = z_mchp_xec_pcr_periph_sleep(dev_cfg->pcr_idx,
367-
dev_cfg->pcr_bitpos, 0);
368-
if (ret != 0) {
369-
return ret;
370-
}
415+
uart_clr_slp_en(dev);
371416

372417
ret = pinctrl_apply_state(dev_cfg->pcfg, PINCTRL_STATE_DEFAULT);
373418
if (ret != 0) {
@@ -750,15 +795,14 @@ static void uart_xec_irq_callback_set(const struct device *dev,
750795
*/
751796
static void uart_xec_isr(const struct device *dev)
752797
{
753-
const struct uart_xec_device_config * const dev_cfg = dev->config;
754798
struct uart_xec_dev_data * const dev_data = dev->data;
755799

756800
if (dev_data->cb) {
757801
dev_data->cb(dev, dev_data->cb_data);
758802
}
759803

760804
/* clear ECIA GIRQ R/W1C status bit after UART status cleared */
761-
mchp_xec_ecia_girq_src_clr(dev_cfg->girq_id, dev_cfg->girq_pos);
805+
uart_xec_girq_clr(dev);
762806
}
763807

764808
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
@@ -862,7 +906,7 @@ static const struct uart_driver_api uart_xec_driver_api = {
862906
uart_xec_isr, DEVICE_DT_INST_GET(n), \
863907
0); \
864908
irq_enable(DT_INST_IRQN(n)); \
865-
mchp_xec_ecia_girq_src_en(DT_INST_PROP_BY_IDX(n, girqs, 0), \
909+
uart_xec_girq_en(DT_INST_PROP_BY_IDX(n, girqs, 0), \
866910
DT_INST_PROP_BY_IDX(n, girqs, 1)); \
867911
}
868912
#else

dts/arm/microchip/mec1501hsz.dtsi

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,30 +162,36 @@
162162
pcrs = <1 9>;
163163
};
164164
uart0: uart@400f2400 {
165-
compatible = "ns16550";
165+
compatible = "microchip,xec-uart";
166166
reg = <0x400f2400 0x400>;
167167
interrupts = <40 0>;
168168
clock-frequency = <1843200>;
169169
current-speed = <38400>;
170-
reg-shift = <0>;
170+
girqs = <15 0>;
171+
pcrs = <2 1>;
172+
ldn = <9>;
171173
status = "disabled";
172174
};
173175
uart1: uart@400f2800 {
174-
compatible = "ns16550";
176+
compatible = "microchip,xec-uart";
175177
reg = <0x400f2800 0x400>;
176178
interrupts = <41 0>;
177179
clock-frequency = <1843200>;
178180
current-speed = <38400>;
179-
reg-shift = <0>;
181+
girqs = <15 1>;
182+
pcrs = <2 2>;
183+
ldn = <10>;
180184
status = "disabled";
181185
};
182186
uart2: uart@400f2c00 {
183-
compatible = "ns16550";
187+
compatible = "microchip,xec-uart";
184188
reg = <0x400f2c00 0x400>;
185189
interrupts = <44 0>;
186190
clock-frequency = <1843200>;
187191
current-speed = <38400>;
188-
reg-shift = <0>;
192+
girqs = <15 4>;
193+
pcrs = <2 28>;
194+
ldn = <11>;
189195
status = "disabled";
190196
};
191197

0 commit comments

Comments
 (0)