[U-Boot] [PATCH 1/2] serial: sh: Add support DL and CKS register for R8A7794

R8A7794 has DL and CKS register, and these registers are used in external clock mode. This adds support these for R8A7794.
Signed-off-by: Nobuhiro Iwamatsu nobuhiro.iwamatsu.yj@renesas.com --- drivers/serial/serial_sh.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/serial_sh.h b/drivers/serial/serial_sh.h index 341997c..4f3e225 100644 --- a/drivers/serial/serial_sh.h +++ b/drivers/serial/serial_sh.h @@ -588,7 +588,8 @@ SCIF_FNS(SCSPTR, 0, 0, 0, 0) #else SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) #endif -#if defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) +#if defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) || \ + defined(CONFIG_R8A7794) SCIF_FNS(DL, 0, 0, 0x30, 16) SCIF_FNS(CKS, 0, 0, 0x34, 16) #endif

R8A7780 and R7A7791 of rmobile supports External Clock mode, and these uses different from Internal Clock mode registers and calculations to the baud rate setting. This adds function for External Clock mode.
Signed-off-by: Nobuhiro Iwamatsu nobuhiro.iwamatsu.yj@renesas.com --- drivers/serial/serial_sh.c | 8 +++++++- drivers/serial/serial_sh.h | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c index 0826d59..144a925 100644 --- a/drivers/serial/serial_sh.c +++ b/drivers/serial/serial_sh.c @@ -49,9 +49,15 @@ static struct uart_port sh_sci = { static void sh_serial_setbrg(void) { DECLARE_GLOBAL_DATA_PTR; - +#ifdef CONFIG_SCIF_USE_EXT_CLK + unsigned short dl = DL_VALUE(gd->baudrate, CONFIG_SH_SCIF_CLK_FREQ); + sci_out(&sh_sci, DL, dl); + /* Need wait: Clock * 1/dl × 1/16 */ + udelay((1000000 * dl * 16 / CONFIG_SYS_CLK_FREQ) * 1000 + 1); +#else sci_out(&sh_sci, SCBRR, SCBRR_VALUE(gd->baudrate, CONFIG_SH_SCIF_CLK_FREQ)); +#endif }
static int sh_serial_init(void) diff --git a/drivers/serial/serial_sh.h b/drivers/serial/serial_sh.h index 4f3e225..fe8cde4 100644 --- a/drivers/serial/serial_sh.h +++ b/drivers/serial/serial_sh.h @@ -735,8 +735,8 @@ static inline int scbrr_calc(struct uart_port port, int bps, int clk) #elif defined(__H8300H__) || defined(__H8300S__) #define SCBRR_VALUE(bps, clk) (((clk*1000/32)/bps)-1) #elif defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) -#define SCBRR DL -#define SCBRR_VALUE(bps, clk) (clk / bps / 16) +#define DL_VALUE(bps, clk) (clk / bps / 16) /* External Clock */ +#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) /* Internal Clock */ #else /* Generic SH */ #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) #endif
participants (1)
-
Nobuhiro Iwamatsu