From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Alexander Shiyan <shc_work@mail.ru>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 2/3] ARM: clps711x: Add serial driver
Date: Mon, 15 Oct 2012 19:58:52 +0200 [thread overview]
Message-ID: <20121015175852.GC5803@game.jcrosoft.org> (raw)
In-Reply-To: <1350318405-20081-2-git-send-email-shc_work@mail.ru>
On 20:26 Mon 15 Oct , Alexander Shiyan wrote:
>
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> ---
> drivers/serial/Kconfig | 5 ++
> drivers/serial/Makefile | 1 +
> drivers/serial/serial_clps711x.c | 118 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 124 insertions(+), 0 deletions(-)
> create mode 100644 drivers/serial/serial_clps711x.c
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index 7eb96ed..02bc8bf 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -43,6 +43,11 @@ config DRIVER_SERIAL_BLACKFIN
> default y
> bool "Blackfin serial driver"
>
> +config DRIVER_SERIAL_CLPS711X
> + depends on ARCH_CLPS711X
> + default y
> + bool "CLPS711X serial driver"
> +
> config DRIVER_SERIAL_ALTERA
> depends on NIOS2
> default y
> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> index e2d56b9..e6f1e22 100644
> --- a/drivers/serial/Makefile
> +++ b/drivers/serial/Makefile
> @@ -13,6 +13,7 @@ obj-$(CONFIG_DRIVER_SERIAL_NETX) += serial_netx.o
> obj-$(CONFIG_DRIVER_SERIAL_LINUX_CONSOLE) += linux_console.o
> obj-$(CONFIG_DRIVER_SERIAL_MPC5XXX) += serial_mpc5xxx.o
> obj-$(CONFIG_DRIVER_SERIAL_BLACKFIN) += serial_blackfin.o
> +obj-$(CONFIG_DRIVER_SERIAL_CLPS711X) += serial_clps711x.o
> obj-$(CONFIG_DRIVER_SERIAL_NS16550) += serial_ns16550.o
> obj-$(CONFIG_DRIVER_SERIAL_PL010) += serial_pl010.o
> obj-$(CONFIG_DRIVER_SERIAL_S3C) += serial_s3c.o
> diff --git a/drivers/serial/serial_clps711x.c b/drivers/serial/serial_clps711x.c
> new file mode 100644
> index 0000000..462ba9f
> --- /dev/null
> +++ b/drivers/serial/serial_clps711x.c
> @@ -0,0 +1,118 @@
> +/*
> + * Simple CLPS711X serial driver
> + *
> + * (C) Copyright 2012 Alexander Shiyan <shc_work@mail.ru>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + */
> +
> +#include <common.h>
> +#include <init.h>
> +#include <io.h>
> +#include <linux/clk.h>
> +
> +#include <mach/clps711x.h>
> +
> +#define UBRLCR(x) (UBRLCR1 + (x) * 0x1000)
> +#define SYSCON(x) (SYSCON1 + (x) * 0x1000)
> +#define SYSFLG(x) (SYSFLG1 + (x) * 0x1000)
> +#define UARTDR(x) (UARTDR1 + (x) * 0x1000)
provide this via resoure
here 4 resources
> +
> +static int clps711x_setbaudrate(struct console_device *cdev, int baudrate)
> +{
> + int divisor;
> + u32 tmp;
> +
> + divisor = (clk_get_rate(cdev->dev->priv) / 16) / baudrate;
> +
> + tmp = readl(UBRLCR(cdev->dev->id)) & ~UBRLCR_BAUD_MASK;
> + tmp |= divisor - 1;
> + writel(tmp, UBRLCR(cdev->dev->id));
> +
> + return 0;
> +}
> +
> +static void clps711x_init_port(struct console_device *cdev)
> +{
> + u32 tmp;
> +
> + /* Disable the UART */
> + writel(readl(SYSCON(cdev->dev->id)) & ~SYSCON_UARTEN,
> + SYSCON(cdev->dev->id));
> +
> + /* Setup Line Control Register */
> + tmp = readl(UBRLCR(cdev->dev->id)) & UBRLCR_BAUD_MASK;
> + tmp |= UBRLCR_FIFOEN | UBRLCR_WRDLEN8; /* FIFO on, 8N1 mode */
> + writel(tmp, UBRLCR(cdev->dev->id));
> +
> + /* Set default baudrate on initialization */
> + clps711x_setbaudrate(cdev, CONFIG_BAUDRATE);
> +
> + /* Enable the UART */
> + writel(readl(SYSCON(cdev->dev->id)) | SYSCON_UARTEN,
> + SYSCON(cdev->dev->id));
> +}
> +
> +static void clps711x_putc(struct console_device *cdev, char c)
> +{
> + /* Wait until there is space in the FIFO */
> + while (readl(SYSFLG(cdev->dev->id)) & SYSFLG_UTXFF) {
> + }
drop the {}
> +
> + /* Send the character */
> + writew(c, UARTDR(cdev->dev->id));
> +}
> +
> +static int clps711x_getc(struct console_device *cdev)
> +{
> + u16 data;
> +
> + /* Wait until there is data in the FIFO */
> + while (readl(SYSFLG(cdev->dev->id)) & SYSFLG_URXFE) {
> + }
> +
> + data = readw(UARTDR(cdev->dev->id));
> +
> + /* Check for an error flag */
> + if (data & (UARTDR_FRMERR | UARTDR_PARERR | UARTDR_OVERR))
> + return -1;
> +
> + return (int)data;
> +}
> +
> +static int clps711x_tstc(struct console_device *cdev)
> +{
> + return !(readl(SYSFLG(cdev->dev->id)) & SYSFLG_URXFE);
factorise those pull status as
status int xxx(data, mask) {}
Best Regards,
J.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-10-15 18:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-15 16:26 [PATCH v2 1/3] ARM: Add CLPS711X architecture Alexander Shiyan
2012-10-15 16:26 ` [PATCH v2 2/3] ARM: clps711x: Add serial driver Alexander Shiyan
2012-10-15 17:58 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-10-15 19:00 ` Alexander Shiyan
2012-10-15 21:58 ` Sascha Hauer
2012-10-16 8:08 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-16 21:39 ` Sascha Hauer
2012-10-20 13:50 ` Alexander Shiyan
2012-10-23 6:38 ` Sascha Hauer
2012-10-15 16:26 ` [PATCH v2 3/3] ARM: clps711x: Add generic board support (CLEP7212) Alexander Shiyan
2012-10-15 18:03 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-15 19:05 ` Alexander Shiyan
2012-10-15 17:54 ` [PATCH v2 1/3] ARM: Add CLPS711X architecture Jean-Christophe PLAGNIOL-VILLARD
2012-10-15 18:56 ` Alexander Shiyan
2012-10-16 8:09 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-16 21:42 ` Sascha Hauer
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=20121015175852.GC5803@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
--cc=shc_work@mail.ru \
/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