mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Juergen Beisert <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 06/18] Samsung/serial: make the code more readable
Date: Fri, 13 Jul 2012 21:00:58 +0200	[thread overview]
Message-ID: <1342206070-29698-7-git-send-email-jbe@pengutronix.de> (raw)
In-Reply-To: <1342206070-29698-1-git-send-email-jbe@pengutronix.de>

This bit magic is just setting and reading the UART's selected clock source.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/serial/serial_s3c.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index 5c05ba8..a4c1f68 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -31,6 +31,8 @@
 /* Note: Offsets are for little endian access */
 #define ULCON 0x00		/* line control */
 #define UCON 0x04		/* UART control */
+# define UCON_SET_CLK_SRC(x) (((x) & 0x03) << 10)
+# define UCON_GET_CLK_SRC(x) (((x) >> 10) & 0x03)
 #define UFCON 0x08		/* FIFO control */
 #define UMCON 0x0c		/* modem control */
 #define UTRSTAT 0x10		/* Rx/Tx status */
@@ -57,8 +59,7 @@ struct s3c_uart {
 static unsigned s3c_get_arch_uart_input_clock(void __iomem *base)
 {
 	unsigned reg = readw(base + UCON);
-	reg = (reg >> 10) & 0x3;
-	return s3c_get_uart_clk(reg);
+	return s3c_get_uart_clk(UCON_GET_CLK_SRC(reg));
 }
 
 #ifdef S3C_UART_HAS_UBRDIVSLOT
@@ -103,7 +104,8 @@ static int s3c_serial_init_port(struct console_device *cdev)
 
 	/* tx=level,rx=edge,disable timeout int.,enable rx error int.,
 	 * normal, interrupt or polling, no pre-divider */
-	writew(0x0245 | ((CONFIG_DRIVER_SERIAL_S3C_CLK) << 10), base + UCON);
+	writew(0x0245 | UCON_SET_CLK_SRC(CONFIG_DRIVER_SERIAL_S3C_CLK),
+						base + UCON);
 
 #ifdef S3C_UART_HAS_UINTM
 	/* 'interrupt or polling mode' for both directions */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-07-13 19:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13 19:00 [RFC] Inclusion of the Samsung S3C6410 SoC Juergen Beisert
2012-07-13 19:00 ` [PATCH 01/18] ARM/Samsung: be able to include the nand header multiple times Juergen Beisert
2012-07-13 19:00 ` [PATCH 02/18] ARM/Samsung: unify device registration for the S3C24XX SoCs Juergen Beisert
2012-07-16  7:21   ` Sascha Hauer
2012-07-16  7:37     ` Juergen Beisert
2012-07-13 19:00 ` [PATCH 03/18] ARM/Samsung: follow the name style of the other source files in this directory Juergen Beisert
2012-07-13 19:00 ` [PATCH 04/18] Samsung/serial: remove more ugly ifdef lines Juergen Beisert
2012-07-13 19:00 ` [PATCH 05/18] Samsung/serial: make the clock source configureable Juergen Beisert
2012-07-16  7:20   ` Sascha Hauer
2012-07-13 19:00 ` Juergen Beisert [this message]
2012-07-13 19:00 ` [PATCH 07/18] Samsung/serial: there is no need to ifdef these register defines Juergen Beisert
2012-07-13 19:01 ` [PATCH 08/18] Samsung/serial: there is no need to ifdef the slot table Juergen Beisert
2012-07-13 19:01 ` [PATCH 09/18] Samsung/serial: move the decision about an improved UART into Kconfig Juergen Beisert
2012-07-13 19:01 ` [PATCH 10/18] Samsung/serial: unify UCON register settings Juergen Beisert
2012-07-13 19:01 ` [PATCH 11/18] ARM/Samsung: add generic lowlevel init Juergen Beisert
2012-07-16  7:22   ` Sascha Hauer
2012-07-13 19:01 ` [PATCH 12/18] ARM/Samsung: add S3C6410 SoC iomap Juergen Beisert
2012-07-13 19:01 ` [PATCH 13/18] ARM/Samsung: adapt the generic timer driver to support the S3C6410 SoC Juergen Beisert
2012-07-13 19:01 ` [PATCH 14/18] ARM/Samsung: add the clock tree support for " Juergen Beisert
2012-07-13 19:01 ` [PATCH 15/18] ARM/Samsung: add GPIO handling " Juergen Beisert
2012-07-13 19:01 ` [PATCH 16/18] ARM/Samsung: add generic S3C6410 SoC specific functions Juergen Beisert
2012-07-13 19:01 ` [PATCH 17/18] ARM/Samsung: add the S3C6410 SoC Juergen Beisert
2012-07-13 19:01 ` [PATCH 18/18] ARM/Samsung: add the Mini6410 platform as the first user of " Juergen Beisert

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=1342206070-29698-7-git-send-email-jbe@pengutronix.de \
    --to=jbe@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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