|
24 | 24 | #include <zephyr/init.h>
|
25 | 25 | #include <zephyr/toolchain.h>
|
26 | 26 | #include <zephyr/linker/sections.h>
|
| 27 | +#ifdef CONFIG_SOC_SERIES_MEC172X |
27 | 28 | #include <zephyr/drivers/clock_control/mchp_xec_clock_control.h>
|
28 | 29 | #include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
| 30 | +#endif |
29 | 31 | #include <zephyr/drivers/pinctrl.h>
|
30 | 32 | #include <zephyr/drivers/uart.h>
|
31 | 33 | #include <zephyr/sys/sys_io.h>
|
32 | 34 | #include <zephyr/spinlock.h>
|
33 | 35 |
|
34 |
| -BUILD_ASSERT(IS_ENABLED(CONFIG_SOC_SERIES_MEC172X), |
35 |
| - "XEC UART driver only support MEC172x at this time"); |
36 |
| - |
37 | 36 | /* Clock source is 1.8432 MHz derived from PLL 48 MHz */
|
38 | 37 | #define XEC_UART_CLK_SRC_1P8M 0
|
39 | 38 | /* Clock source is PLL 48 MHz output */
|
@@ -195,6 +194,56 @@ struct uart_xec_dev_data {
|
195 | 194 |
|
196 | 195 | static const struct uart_driver_api uart_xec_driver_api;
|
197 | 196 |
|
| 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 | + |
198 | 247 | static void set_baud_rate(const struct device *dev, uint32_t baud_rate)
|
199 | 248 | {
|
200 | 249 | const struct uart_xec_device_config * const dev_cfg = dev->config;
|
@@ -363,11 +412,7 @@ static int uart_xec_init(const struct device *dev)
|
363 | 412 | struct uart_xec_dev_data *dev_data = dev->data;
|
364 | 413 | int ret;
|
365 | 414 |
|
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); |
371 | 416 |
|
372 | 417 | ret = pinctrl_apply_state(dev_cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
373 | 418 | if (ret != 0) {
|
@@ -750,15 +795,14 @@ static void uart_xec_irq_callback_set(const struct device *dev,
|
750 | 795 | */
|
751 | 796 | static void uart_xec_isr(const struct device *dev)
|
752 | 797 | {
|
753 |
| - const struct uart_xec_device_config * const dev_cfg = dev->config; |
754 | 798 | struct uart_xec_dev_data * const dev_data = dev->data;
|
755 | 799 |
|
756 | 800 | if (dev_data->cb) {
|
757 | 801 | dev_data->cb(dev, dev_data->cb_data);
|
758 | 802 | }
|
759 | 803 |
|
760 | 804 | /* 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); |
762 | 806 | }
|
763 | 807 |
|
764 | 808 | #endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
@@ -862,7 +906,7 @@ static const struct uart_driver_api uart_xec_driver_api = {
|
862 | 906 | uart_xec_isr, DEVICE_DT_INST_GET(n), \
|
863 | 907 | 0); \
|
864 | 908 | 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), \ |
866 | 910 | DT_INST_PROP_BY_IDX(n, girqs, 1)); \
|
867 | 911 | }
|
868 | 912 | #else
|
|
0 commit comments