Skip to content

Commit

Permalink
Disabled clock enablement on UART for Zephyr
Browse files Browse the repository at this point in the history
Disabled gpio and clock enablement on UART drivers for Zephyr.

Signed-off-by: Furkan Akkiz <hasanfurkan.akkiz@analog.com>
  • Loading branch information
hfakkiz committed Sep 24, 2024
1 parent 48391cd commit 44e2a78
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 3 deletions.
9 changes: 8 additions & 1 deletion Libraries/PeriphDrivers/Source/UART/uart_ai85.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int MXC_UART_AsyncStop(mxc_uart_regs_t *uart)
int MXC_UART_Init(mxc_uart_regs_t *uart, unsigned int baud, mxc_uart_clock_t clock)
{
int retval;

#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_UART_Shutdown(uart);
if (retval) {
return retval;
Expand Down Expand Up @@ -75,6 +75,7 @@ int MXC_UART_Init(mxc_uart_regs_t *uart, unsigned int baud, mxc_uart_clock_t clo
default:
return E_BAD_PARAM;
}
#endif // MSDK_NO_GPIO_CLK_INIT

retval = MXC_UART_SetClockSource(uart, clock);
if (retval != E_NO_ERROR) {
Expand Down Expand Up @@ -254,7 +255,9 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
break;

case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 2;
break;

Expand All @@ -267,12 +270,16 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
// UART3 (LPUART0) supports IBRO and ERTCO
switch (clock) {
case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 2;
break;

case MXC_UART_ERTCO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERTCO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 3;
break;

Expand Down
9 changes: 8 additions & 1 deletion Libraries/PeriphDrivers/Source/UART/uart_ai87.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void MXC_UART_UnlockClockSource(mxc_uart_regs_t *uart)
int MXC_UART_Init(mxc_uart_regs_t *uart, unsigned int baud, mxc_uart_clock_t clock)
{
int err;

#ifndef MSDK_NO_GPIO_CLK_INIT
err = MXC_UART_Shutdown(uart);

if (err) {
Expand Down Expand Up @@ -92,6 +92,7 @@ int MXC_UART_Init(mxc_uart_regs_t *uart, unsigned int baud, mxc_uart_clock_t clo
default:
return E_BAD_PARAM;
}
#endif // MSDK_NO_GPIO_CLK_INIT

err = MXC_UART_SetClockSource(uart, clock);
if (err)
Expand Down Expand Up @@ -282,7 +283,9 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
break;

case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
err = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 2;
break;

Expand All @@ -294,12 +297,16 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
// UART3 (LPUART0) supports IBRO and ERTCO
switch (clock) {
case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
err = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 0;
break;

case MXC_UART_ERTCO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
err = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERTCO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 1;
break;

Expand Down
6 changes: 6 additions & 0 deletions Libraries/PeriphDrivers/Source/UART/uart_me12.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,23 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
break;

case MXC_UART_EXT_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
error = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_EXTCLK);
#endif // MSDK_NO_GPIO_CLK_INIT
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 1);
break;

case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
error = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 2);
break;

case MXC_UART_ERFO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
error = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERFO);
#endif // MSDK_NO_GPIO_CLK_INIT
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 3);
break;

Expand Down
10 changes: 10 additions & 0 deletions Libraries/PeriphDrivers/Source/UART/uart_me15.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,21 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
clock_option = 0;
break;
case MXC_UART_EXT_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_GPIO_Config(&gpio_cfg_hfextclk);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 1;
break;
case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 2;
break;
case MXC_UART_ERFO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERFO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 3;
break;
default:
Expand All @@ -338,11 +344,15 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
clock_option = 0;
break;
case MXC_UART_EXT_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_GPIO_Config(&gpio_cfg_lpextclk);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 1;
break;
case MXC_UART_ERTCO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERTCO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 2;
break;
case MXC_UART_INRO_CLK:
Expand Down
6 changes: 6 additions & 0 deletions Libraries/PeriphDrivers/Source/UART/uart_me16.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,21 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 0);
break;
case MXC_UART_EXT_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_GPIO_Config(&gpio_cfg_extclk);
#endif // MSDK_NO_GPIO_CLK_INIT
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 1);
break;
case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 2);
break;
case MXC_UART_ERFO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERFO);
#endif // MSDK_NO_GPIO_CLK_INIT
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 3);
break;
default:
Expand Down
6 changes: 6 additions & 0 deletions Libraries/PeriphDrivers/Source/UART/uart_me17.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
break;

case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
error = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 2);
break;

Expand All @@ -283,12 +285,16 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
// UART3 (LPUART0) supports IBRO and ERTCO
switch (clock) {
case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
error = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 0);
break;

case MXC_UART_ERTCO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
error = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERTCO);
#endif // MSDK_NO_GPIO_CLK_INIT
MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 1);
break;

Expand Down
10 changes: 9 additions & 1 deletion Libraries/PeriphDrivers/Source/UART/uart_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int MXC_UART_Init(mxc_uart_regs_t *uart, unsigned int baud, mxc_uart_clock_t clo
default:
return E_BAD_PARAM;
}
#endif
#endif // MSDK_NO_GPIO_CLK_INIT

retval = MXC_UART_SetClockSource(uart, clock);
if (retval)
Expand Down Expand Up @@ -332,12 +332,16 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
break;

case MXC_UART_ERFO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERFO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 1;
break;

case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 2;
break;

Expand All @@ -349,12 +353,16 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
// UART3 (LPUART0) supports IBRO and ERTCO
switch (clock) {
case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 0;
break;

case MXC_UART_ERTCO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERTCO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 1;
break;

Expand Down
8 changes: 8 additions & 0 deletions Libraries/PeriphDrivers/Source/UART/uart_me21.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,16 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
break;

case MXC_UART_EXT_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_GPIO_Config(&gpio_cfg_hfextclk);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 1;
break;

case MXC_UART_IBRO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 2;
break;

Expand All @@ -359,7 +363,9 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
break;

case MXC_UART_EXT_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_GPIO_Config(&gpio_cfg_lpextclk);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 1;
break;

Expand All @@ -368,7 +374,9 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
break;

case MXC_UART_ERTCO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERTCO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 3;
break;

Expand Down

0 comments on commit 44e2a78

Please sign in to comment.