s5pc1xx: support serial driver
PATCH 3/4 s5pc1xx: support serial driver
This patch includes the serial driver for s5pc1xx
Signed-off-by Minkyu Kang <[email protected]>
--- drivers/serial/Makefile | 1 + drivers/serial/serial_s5pc1xx.c | 250 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 251 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/serial_s5pc1xx.c
drivers/serial/Makefile +1 -0
@@ -33,6 +33,7 @@ COBJS-$(CONFIG_NS9750_UART) += ns9750_serial.o COBJS-$(CONFIG_SYS_NS16550) += ns16550.o COBJS-$(CONFIG_DRIVER_S3C4510_UART) += s3c4510b_uart.o COBJS-$(CONFIG_S3C64XX) += s3c64xx.o +COBJS-$(CONFIG_S5PC1XX) += serial_s5pc1xx.o COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial.o COBJS-$(CONFIG_CLPS7111_SERIAL) += serial_clps7111.o COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
drivers/serial/serial_s5pc1xx.c new file +250 -0
250 lines not on this page · raw message
Signature · 1 line
1.5.4.3
PATCH 3/4 s5pc1xx: support serial driver
drivers/serial/serial_s5pc1xx.c line 39
Quoted 12 lines
drivers/serial/serial_s5pc1xx.c new file +12
-0+ +#ifdef CONFIG_SERIAL0 +#define UART_NR S5PC1XX_UART0 +#elif defined(CONFIG_SERIAL1 ) +#define UART_NR S5PC1XX_UART1 +#elif defined(CONFIG_SERIAL2 ) +#define UART_NR S5PC1XX_UART2 +#elif defined(CONFIG_SERIAL3 ) +#define UART_NR S5PC1XX_UART3 +#else +#error "Bad: you didn't configure serial ..." +#endif
why not use serial multi API?
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#define barrier() asm volatile("" : : : "memory")
this is really generic maybe put it somewhere else
Quoted 30 lines
drivers/serial/serial_s5pc1xx.c new file +30
-0+ +static inline s5pc1xx_uart_t *s5pc1xx_get_base_uart (enum s5pc1xx_uarts_nr nr) +{ +if (cpu_is_s5pc100 ()) +return (s5pc1xx_uart_t *)(S5PC100_PA_UART + (nr *0x400 )); +else +return (s5pc1xx_uart_t *)(S5PC110_PA_UART + (nr *0x400 )); +} + +/* +* The coefficient, used to calculate the baudrate on S5PC1XX UARTs is +* calculated as +* C = UBRDIV * 16 + number_of_set_bits_in_UDIVSLOT +* however, section 31.6.11 of the datasheet doesn't recomment using 1 for 1, +* 3 for 2, ... (2^n - 1) for n, instead, they suggest using these constants: +*/ +static const int udivslot[] = { +0 , +0x0080 , +0x0808 , +0x0888 , +0x2222 , +0x4924 , +0x4a52 , +0x54aa , +0x5555 , +0xd555 , +0xd5d5 , +0xddd5 , +0xdddd ,
drivers/serial/serial_s5pc1xx.c line 81
Quoted 10 lines
drivers/serial/serial_s5pc1xx.c new file +10
-0+0xdfdd , +0xdfdf , + 0xffdf, +}; + +void serial_setbrg (void ) +{ +DECLARE_GLOBAL_DATA_PTR ; +s5pc1xx_uart_t *const uart =s5pc1xx_get_base_uart (UART_NR ); +u32 pclk =get_pclk ();
please use this APIget_pclk_rate() as at91 sh4 and other
drivers/serial/serial_s5pc1xx.c line 87
Quoted 6 lines
drivers/serial/serial_s5pc1xx.c new file +6
-0+u32 baudrate = gd->baudrate; +int i; + + i = (pclk / baudrate) %16 ; + + uart->UBRDIV = pclk / baudrate /16 -1 ;
please use accesor writex/readx
drivers/serial/serial_s5pc1xx.c line 182
Quoted 3 lines
drivers/serial/serial_s5pc1xx.c new file +3
-0+ +int restartpowersequence =0 ; +int atmsecs;
do you use it somewhere else?
I guess no so please make them static
drivers/serial/serial_s5pc1xx.c line 194
Quoted 12 lines
drivers/serial/serial_s5pc1xx.c new file +12
-0+ +void uart_serial_setbrg (unsigned int baudrate,int port) +{ +s5pc1xx_uart_t *const uart =s5pc1xx_get_base_uart (port); +u32 pclk =get_pclk (); +int i; + + i = (pclk / baudrate) %16 ; + + uart->UBRDIV = pclk / baudrate /16 -1 ; + uart->UDIVSLOT = udivslot[i]; +}
please do not duplidate code
Quoted 1 line
+
Best Regards,
J.