@ -53,7 +53,7 @@ struct uart_npcx_data {
@@ -53,7 +53,7 @@ struct uart_npcx_data {
# ifdef CONFIG_UART_INTERRUPT_DRIVEN
static int uart_npcx_tx_fifo_ready ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
/* True if the Tx FIFO is not completely full */
return ! ( GET_FIELD ( inst - > UFTSTS , NPCX_UFTSTS_TEMPTY_LVL ) = = 0 ) ;
@ -61,7 +61,7 @@ static int uart_npcx_tx_fifo_ready(const struct device *dev)
@@ -61,7 +61,7 @@ static int uart_npcx_tx_fifo_ready(const struct device *dev)
static int uart_npcx_rx_fifo_available ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
/* True if at least one byte is in the Rx FIFO */
return IS_BIT_SET ( inst - > UFRSTS , NPCX_UFRSTS_RFIFO_NEMPTY_STS ) ;
@ -69,7 +69,7 @@ static int uart_npcx_rx_fifo_available(const struct device *dev)
@@ -69,7 +69,7 @@ static int uart_npcx_rx_fifo_available(const struct device *dev)
static void uart_npcx_dis_all_tx_interrupts ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
/* Disable all Tx interrupts */
inst - > UFTCTL & = ~ ( BIT ( NPCX_UFTCTL_TEMPTY_LVL_EN ) |
@ -79,7 +79,7 @@ static void uart_npcx_dis_all_tx_interrupts(const struct device *dev)
@@ -79,7 +79,7 @@ static void uart_npcx_dis_all_tx_interrupts(const struct device *dev)
static void uart_npcx_clear_rx_fifo ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
uint8_t scratch ;
/* Read all dummy bytes out from Rx FIFO */
@ -91,7 +91,7 @@ static void uart_npcx_clear_rx_fifo(const struct device *dev)
@@ -91,7 +91,7 @@ static void uart_npcx_clear_rx_fifo(const struct device *dev)
/* UART api functions */
static int uart_npcx_poll_in ( const struct device * dev , unsigned char * c )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
/* Rx single byte buffer is not full */
if ( ! IS_BIT_SET ( inst - > UICTRL , NPCX_UICTRL_RBF ) )
@ -103,7 +103,7 @@ static int uart_npcx_poll_in(const struct device *dev, unsigned char *c)
@@ -103,7 +103,7 @@ static int uart_npcx_poll_in(const struct device *dev, unsigned char *c)
static void uart_npcx_poll_out ( const struct device * dev , unsigned char c )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
/* Wait while Tx single byte buffer is ready to send */
while ( ! IS_BIT_SET ( inst - > UICTRL , NPCX_UICTRL_TBE ) )
@ -114,7 +114,7 @@ static void uart_npcx_poll_out(const struct device *dev, unsigned char c)
@@ -114,7 +114,7 @@ static void uart_npcx_poll_out(const struct device *dev, unsigned char c)
static int uart_npcx_err_check ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
uint32_t err = 0U ;
uint8_t stat = inst - > USTAT ;
@ -135,7 +135,7 @@ static int uart_npcx_fifo_fill(const struct device *dev,
@@ -135,7 +135,7 @@ static int uart_npcx_fifo_fill(const struct device *dev,
const uint8_t * tx_data ,
int size )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
uint8_t tx_bytes = 0U ;
/* If Tx FIFO is still ready to send */
@ -150,7 +150,7 @@ static int uart_npcx_fifo_fill(const struct device *dev,
@@ -150,7 +150,7 @@ static int uart_npcx_fifo_fill(const struct device *dev,
static int uart_npcx_fifo_read ( const struct device * dev , uint8_t * rx_data ,
const int size )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
unsigned int rx_bytes = 0U ;
/* If least one byte is in the Rx FIFO */
@ -164,21 +164,21 @@ static int uart_npcx_fifo_read(const struct device *dev, uint8_t *rx_data,
@@ -164,21 +164,21 @@ static int uart_npcx_fifo_read(const struct device *dev, uint8_t *rx_data,
static void uart_npcx_irq_tx_enable ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
inst - > UFTCTL | = BIT ( NPCX_UFTCTL_TEMPTY_EN ) ;
}
static void uart_npcx_irq_tx_disable ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
inst - > UFTCTL & = ~ ( BIT ( NPCX_UFTCTL_TEMPTY_EN ) ) ;
}
static int uart_npcx_irq_tx_ready ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
/* Tx interrupt is enable and its FIFO is ready to send (not full) */
return ( IS_BIT_SET ( inst - > UFTCTL , NPCX_UFTCTL_TEMPTY_EN ) & &
@ -187,7 +187,7 @@ static int uart_npcx_irq_tx_ready(const struct device *dev)
@@ -187,7 +187,7 @@ static int uart_npcx_irq_tx_ready(const struct device *dev)
static int uart_npcx_irq_tx_complete ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
/* Tx FIFO is empty or last byte is sending */
return IS_BIT_SET ( inst - > UFTSTS , NPCX_UFTSTS_NXMIP ) ;
@ -195,21 +195,21 @@ static int uart_npcx_irq_tx_complete(const struct device *dev)
@@ -195,21 +195,21 @@ static int uart_npcx_irq_tx_complete(const struct device *dev)
static void uart_npcx_irq_rx_enable ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
inst - > UFRCTL | = BIT ( NPCX_UFRCTL_RNEMPTY_EN ) ;
}
static void uart_npcx_irq_rx_disable ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
inst - > UFRCTL & = ~ ( BIT ( NPCX_UFRCTL_RNEMPTY_EN ) ) ;
}
static int uart_npcx_irq_rx_ready ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
/* Rx interrupt is enable and at least one byte is in its FIFO */
return ( IS_BIT_SET ( inst - > UFRCTL , NPCX_UFRCTL_RNEMPTY_EN ) & &
@ -218,14 +218,14 @@ static int uart_npcx_irq_rx_ready(const struct device *dev)
@@ -218,14 +218,14 @@ static int uart_npcx_irq_rx_ready(const struct device *dev)
static void uart_npcx_irq_err_enable ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
inst - > UICTRL | = BIT ( NPCX_UICTRL_EEI ) ;
}
static void uart_npcx_irq_err_disable ( const struct device * dev )
{
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
inst - > UICTRL & = ~ ( BIT ( NPCX_UICTRL_EEI ) ) ;
}
@ -288,10 +288,11 @@ static const struct uart_driver_api uart_npcx_driver_api = {
@@ -288,10 +288,11 @@ static const struct uart_driver_api uart_npcx_driver_api = {
static int uart_npcx_init ( const struct device * dev )
{
const struct uart_npcx_config * config = DRV_CONFIG ( dev ) ;
const struct uart_npcx_data * data = DRV_DATA ( dev ) ;
struct uart_reg * inst = HAL_INSTANCE ( dev ) ;
const struct device * clk_dev = device_get_binding ( NPCX_CLK_CTRL_NAME ) ;
const struct uart_npcx_config * const config = DRV_CONFIG ( dev ) ;
const struct uart_npcx_data * const data = DRV_DATA ( dev ) ;
struct uart_reg * const inst = HAL_INSTANCE ( dev ) ;
const struct device * const clk_dev =
device_get_binding ( NPCX_CLK_CTRL_NAME ) ;
uint32_t uart_rate ;
/* Turn on device clock first */