11/*
22 * Copyright (c) 2017 Piotr Mienkowski
33 * Copyright (c) 2018 Justin Watson
4+ * Copyright (c) 2023 Gerson Fernando Budke
45 * SPDX-License-Identifier: Apache-2.0
56 */
67
78#define DT_DRV_COMPAT atmel_sam_uart
89
910/** @file
1011 * @brief UART driver for Atmel SAM MCU family.
11- *
12- * Note:
13- * - Error handling is not implemented.
14- * - The driver works only in polling mode, interrupt mode is not implemented.
1512 */
1613
1714#include <errno.h>
2118#include <soc.h>
2219#include <zephyr/drivers/uart.h>
2320#include <zephyr/drivers/pinctrl.h>
21+ #include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
2422#include <zephyr/irq.h>
2523
2624/* Device constant configuration parameters */
2725struct uart_sam_dev_cfg {
2826 Uart * regs ;
29- uint32_t periph_id ;
27+ const struct atmel_sam_pmc_config clock_cfg ;
3028 const struct pinctrl_dev_config * pcfg ;
3129
3230#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@@ -40,7 +38,7 @@ struct uart_sam_dev_data {
4038
4139#ifdef CONFIG_UART_INTERRUPT_DRIVEN
4240 uart_irq_callback_user_data_t irq_cb ; /* Interrupt Callback */
43- void * irq_cb_data ; /* Interrupt Callback Arg */
41+ void * irq_cb_data ; /* Interrupt Callback Arg */
4442#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
4543};
4644
@@ -391,7 +389,8 @@ static int uart_sam_init(const struct device *dev)
391389 Uart * const uart = cfg -> regs ;
392390
393391 /* Enable UART clock in PMC */
394- soc_pmc_peripheral_enable (cfg -> periph_id );
392+ (void )clock_control_on (SAM_DT_PMC_CONTROLLER ,
393+ (clock_control_subsys_t * )& cfg -> clock_cfg );
395394
396395 /* Connect pins to the peripheral */
397396 retval = pinctrl_apply_state (cfg -> pcfg , PINCTRL_STATE_DEFAULT );
@@ -445,7 +444,7 @@ static const struct uart_driver_api uart_sam_driver_api = {
445444#define UART_SAM_DECLARE_CFG (n , IRQ_FUNC_INIT ) \
446445 static const struct uart_sam_dev_cfg uart##n##_sam_config = { \
447446 .regs = (Uart *)DT_INST_REG_ADDR(n), \
448- .periph_id = DT_INST_PROP(n, peripheral_id ), \
447+ .clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(n ), \
449448 \
450449 .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
451450 \
0 commit comments