public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] s5pc1xx: support serial driver
Date: Fri, 4 Sep 2009 23:19:21 +0200	[thread overview]
Message-ID: <20090904211921.GS30118@game.jcrosoft.org> (raw)
In-Reply-To: <4AA0CE43.7000106@samsung.com>

> +
> +#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?
> +
> +#define barrier() asm volatile("" : : : "memory")
this is really generic maybe put it somewhere else
> +
> +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,
> +	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 API
get_pclk_rate() as at91 sh4 and other

> +	u32 baudrate = gd->baudrate;
> +	int i;
> +
> +	i = (pclk / baudrate) % 16;
> +
> +	uart->UBRDIV = pclk / baudrate / 16 - 1;
please use accesor writex/readx
> +
> +int restartpowersequence = 0;
> +int atmsecs;
do you use it somewhere else?
I guess no so please make them static
> +
> +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
> +

Best Regards,
J.

      reply	other threads:[~2009-09-04 21:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-04  8:22 [U-Boot] [PATCH 3/4] s5pc1xx: support serial driver Minkyu Kang
2009-09-04 21:19 ` Jean-Christophe PLAGNIOL-VILLARD [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090904211921.GS30118@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox