All of lore.kernel.org
 help / color / mirror / Atom feed
From: p.wilczek@samsung.com (Piotr Wilczek)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/8] serial: add Exynos specific serial driver
Date: Wed, 11 Dec 2013 14:07:38 +0100	[thread overview]
Message-ID: <1386767259-15693-8-git-send-email-p.wilczek@samsung.com> (raw)
In-Reply-To: <1386767259-15693-1-git-send-email-p.wilczek@samsung.com>

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Makefile        |    1 +
 serial-exynos.c |   84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)
 create mode 100644 serial-exynos.c

diff --git a/Makefile b/Makefile
index 6074106..78684b7 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,7 @@ include Makefile.config
 
 CFLAGS+=-DUART_BASE=$(UART_BASE)
 CFLAGS+=-DNR_BANKS=$(NR_BANKS)
+CFLAGS+=-DUART_PORT=$(UART_PORT)
 
 BOARD_OBJ = board-$(MFG).o
 UART_OBJ = serial-$(UART).o
diff --git a/serial-exynos.c b/serial-exynos.c
new file mode 100644
index 0000000..3ba4fc9
--- /dev/null
+++ b/serial-exynos.c
@@ -0,0 +1,84 @@
+#include "types.h"
+#include "register.h"
+#include "serial.h"
+
+#define EXYNOS_BASE_UART	0x13800000
+#define TX_FIFO_FULL_MASK	(1 << 24)
+
+#define UART_BAUDRATE_115200	115200
+
+union br_rest {
+	unsigned short	slot;		/* udivslot */
+	unsigned char	value;		/* ufracval */
+};
+
+struct s5p_uart {
+	unsigned int	ulcon;
+	unsigned int	ucon;
+	unsigned int	ufcon;
+	unsigned int	umcon;
+	unsigned int	utrstat;
+	unsigned int	uerstat;
+	unsigned int	ufstat;
+	unsigned int	umstat;
+	unsigned char	utxh;
+	unsigned char	res1[3];
+	unsigned char	urxh;
+	unsigned char	res2[3];
+	unsigned int	ubrdiv;
+	union br_rest	rest;
+	unsigned char	res3[0xffd0];
+};
+
+static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
+{
+	u32 offset = dev_index * sizeof(struct s5p_uart);
+	return (struct s5p_uart *)(EXYNOS_BASE_UART + offset);
+}
+
+static inline int s5p_uart_divslot(void)
+{
+	return 0;
+}
+
+static int serial_err_check(const int dev_index, int op)
+{
+	struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
+	unsigned int mask;
+
+	/*
+	 * UERSTAT
+	 * Break Detect	[3]
+	 * Frame Err	[2] : receive operation
+	 * Parity Err	[1] : receive operation
+	 * Overrun Err	[0] : receive operation
+	 */
+	if (op)
+		mask = 0x8;
+	else
+		mask = 0xf;
+
+	return readl((unsigned int)&uart->uerstat) & mask;
+}
+
+/*
+ * Output a single byte to the serial port.
+ */
+void __putch(char c)
+{
+	const int dev_index = UART_PORT;
+
+	struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
+
+	/* wait for room in the tx FIFO */
+	while ((readl((unsigned int)&uart->ufstat) & TX_FIFO_FULL_MASK)) {
+		if (serial_err_check(dev_index, 1))
+			return;
+	}
+
+	writeb(c, (unsigned int)&uart->utxh);
+
+	/* If \n, also do \r */
+	if (c == '\n')
+		__putch('\r');
+}
-- 
1.7.9.5

  parent reply	other threads:[~2013-12-11 13:07 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 13:07 [PATCH 0/8] Impedance matcher for Samsung boards Piotr Wilczek
2013-12-11 13:07 ` [PATCH 1/8] registers: add write u8 type Piotr Wilczek
2013-12-11 13:07 ` [PATCH 2/8] string: fix strncmp function Piotr Wilczek
2013-12-11 13:07 ` [PATCH 3/8] device tree blob must be 4-bytes alingned Piotr Wilczek
2013-12-11 13:07 ` [PATCH 4/8] Makefile: disable generating Thumb code Piotr Wilczek
2013-12-11 13:07 ` [PATCH 5/8] add memory operations Piotr Wilczek
2013-12-11 13:07 ` Piotr Wilczek [this message]
2013-12-11 13:07 ` [PATCH 8/8] board: add Samsung specific board support Piotr Wilczek
2013-12-11 13:16 ` [PATCH 0/8] Impedance matcher for Samsung boards Daniel Mack
2013-12-11 14:03   ` Piotr Wilczek
2013-12-11 14:10     ` Daniel Mack
2013-12-11 14:28       ` Tomasz Figa
2013-12-11 15:19         ` Daniel Mack
2013-12-11 15:48           ` Nicolas Pitre
2013-12-11 19:06           ` Jason Cooper
     [not found] ` <1386767259-15693-7-git-send-email-p.wilczek@samsung.com>
2013-12-11 19:00   ` [PATCH 6/8] add support to supplement atags to device tree Jason Cooper
2013-12-12 12:09     ` Piotr Wilczek
2013-12-12 12:36       ` Jason Cooper
2013-12-18 12:09 ` [PATCH V2 0/8] Impedance matcher for Samsung boards Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 1/8] registers: add write u8 type Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 2/8] string: fix strncmp function Piotr Wilczek
2013-12-18 12:15     ` Russell King - ARM Linux
2013-12-18 12:23       ` Daniel Mack
2013-12-18 12:52         ` Russell King - ARM Linux
2013-12-18 16:01           ` Jason Cooper
2013-12-18 18:50             ` Jason Cooper
2013-12-18 18:56             ` Jason Cooper
2013-12-18 16:03         ` Jason Cooper
2013-12-18 16:04           ` Daniel Mack
2013-12-18 12:50       ` Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 3/8] device tree blob must be 4-bytes alingned Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 4/8] Makefile: disable generating Thumb code Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 5/8] add memory operations Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 7/8] serial: add Exynos specific serial driver Piotr Wilczek
2013-12-18 12:09   ` [PATCH V2 8/8] board: add Samsung specific board support Piotr Wilczek

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=1386767259-15693-8-git-send-email-p.wilczek@samsung.com \
    --to=p.wilczek@samsung.com \
    --cc=linux-arm-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.