All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: linux-mips@linux-mips.org
Cc: Ralf Baechle <ralf@linux-mips.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Maarten ter Huurne <maarten@treewalker.org>,
	Antony Pavlov <antonynpavlov@gmail.com>
Subject: [RFC 10/13] MIPS: JZ4750D: Add platform UART devices
Date: Tue, 23 Oct 2012 21:43:58 +0400	[thread overview]
Message-ID: <1351014241-3207-11-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1351014241-3207-1-git-send-email-antonynpavlov@gmail.com>

Add platform devices for the JZ4750D platform UART drivers.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/mips/include/asm/mach-jz4750d/platform.h |   22 +++++++
 arch/mips/jz4750d/platform.c                  |   84 +++++++++++++++++++++++++
 2 files changed, 106 insertions(+)
 create mode 100644 arch/mips/include/asm/mach-jz4750d/platform.h
 create mode 100644 arch/mips/jz4750d/platform.c

diff --git a/arch/mips/include/asm/mach-jz4750d/platform.h b/arch/mips/include/asm/mach-jz4750d/platform.h
new file mode 100644
index 0000000..255a165
--- /dev/null
+++ b/arch/mips/include/asm/mach-jz4750d/platform.h
@@ -0,0 +1,22 @@
+/*
+ *  Copyright (C) 2012, Antony Pavlov <antonynpavlov@gmail.com>
+ *  JZ4750D platform device definitions
+ *
+ *  based on JZ4740 platform device definitions
+ *  Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
+ *
+ *  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.
+ *
+ */
+
+#ifndef __JZ4750D_PLATFORM_H__
+#define __JZ4750D_PLATFORM_H__
+
+#include <linux/platform_device.h>
+
+void jz4750d_serial_device_register(void);
+
+#endif /* __JZ4750D_PLATFORM_H__ */
diff --git a/arch/mips/jz4750d/platform.c b/arch/mips/jz4750d/platform.c
new file mode 100644
index 0000000..5ac083d
--- /dev/null
+++ b/arch/mips/jz4750d/platform.c
@@ -0,0 +1,84 @@
+/*
+ *  Copyright (C) 2012, Antony Pavlov <antonynpavlov@gmail.com>
+ *  JZ4750D platform devices
+ *
+ *  based on JZ4740 platform devices
+ *  Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
+ *
+ *  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 <linux/device.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/resource.h>
+
+#include <linux/dma-mapping.h>
+
+#include <asm/mach-jz4750d/platform.h>
+#include <asm/mach-jz4750d/base.h>
+#include <asm/mach-jz4750d/irq.h>
+
+#include <linux/serial_core.h>
+#include <linux/serial_8250.h>
+
+#include "serial.h"
+#include "clock.h"
+
+/* Serial */
+#define JZ4750D_UART_DATA(_id) \
+	{ \
+		.flags = UPF_SKIP_TEST | UPF_IOREMAP | UPF_FIXED_TYPE, \
+		.iotype = UPIO_MEM, \
+		.regshift = 2, \
+		.serial_out = jz4750d_serial_out, \
+		.type = PORT_16550, \
+		.mapbase = JZ4750D_UART ## _id ## _BASE_ADDR, \
+		.irq = JZ4750D_IRQ_UART ## _id, \
+	}
+
+static struct plat_serial8250_port jz4750d_uart_data[] = {
+	JZ4750D_UART_DATA(0),
+	JZ4750D_UART_DATA(1),
+	{},
+};
+
+static struct platform_device jz4750d_uart_device = {
+	.name = "serial8250",
+	.id = 0,
+	.dev = {
+		.platform_data = jz4750d_uart_data,
+	},
+};
+
+#define JZ_REG_CLOCK_CTRL	0x00
+#define JZ_CLOCK_CTRL_KO_ENABLE	BIT(30)
+
+void jz4750d_serial_device_register(void)
+{
+	void __iomem *cpm_base = ioremap(JZ4750D_CPM_BASE_ADDR, 0x100);
+	struct plat_serial8250_port *p;
+	int uart_rate;
+
+	uart_rate = jz4750d_clock_bdata.ext_rate;
+
+	/*
+	 * FIXME
+	 * ECS bit selects the clock source between EXCLK and EXCLK/2 output
+	 * This bit is only used to APB device such as UART I2S I2C SSI SADC UDC_PHY etc.
+	 */
+
+	if (readl(cpm_base + JZ_REG_CLOCK_CTRL) & JZ_CLOCK_CTRL_KO_ENABLE) {
+		uart_rate >>= 1;
+	}
+
+	for (p = jz4750d_uart_data; p->flags != 0; ++p)
+		p->uartclk = uart_rate;
+
+	platform_device_register(&jz4750d_uart_device);
+}
-- 
1.7.10.4

  parent reply	other threads:[~2012-10-23 17:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 17:43 [RFC 00/13] MIPS: JZ4750D: Add base support for Ingenic JZ4750D SOC Antony Pavlov
2012-10-23 17:43 ` [RFC 01/13] MIPS: JZ4750D: Add base support for Ingenic JZ4750D System-on-a-Chip Antony Pavlov
2012-10-23 17:43 ` [RFC 02/13] MIPS: JZ4750D: Add clock API support Antony Pavlov
2012-10-23 17:43 ` [RFC 03/13] MIPS: JZ4750D: Add IRQ handler code Antony Pavlov
2012-10-23 17:43 ` [RFC 04/13] MIPS: JZ4750D: Add timer support Antony Pavlov
2012-10-23 17:43 ` [RFC 05/13] MIPS: JZ4750D: Add clocksource/clockevent support Antony Pavlov
2012-10-23 17:43 ` [RFC 06/13] MIPS: JZ4750D: Add system reset support Antony Pavlov
2012-10-23 17:43 ` [RFC 07/13] MIPS: JZ4750D: Add setup code Antony Pavlov
2012-10-23 17:43 ` [RFC 08/13] MIPS: JZ4750D: Add serial support Antony Pavlov
2012-10-23 17:43 ` [RFC 09/13] MIPS: JZ4750D: Add prom support Antony Pavlov
2012-10-23 17:43 ` Antony Pavlov [this message]
2012-10-23 17:43 ` [RFC 11/13] MIPS: JZ4750D: Add Kbuild files Antony Pavlov
2012-10-24 16:16   ` Maarten ter Huurne
2012-10-24 16:56     ` Ralf Baechle
2012-10-24 17:18     ` Antony Pavlov
2012-10-24 17:43     ` Florian Fainelli
2012-10-24 18:15       ` Maarten ter Huurne
2012-10-23 17:44 ` [RFC 12/13] MIPS: JZ4750D: Add rzx50 board support Antony Pavlov
2012-10-23 17:44 ` [RFC 13/13] MIPS: rzx50: Add defconfig file Antony Pavlov
2012-10-23 18:15 ` [RFC 00/13] MIPS: JZ4750D: Add base support for Ingenic JZ4750D SOC Lars-Peter Clausen
2012-10-23 19:57   ` Steven J. Hill
2012-10-24  8:25     ` Lars-Peter Clausen

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=1351014241-3207-11-git-send-email-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-mips@linux-mips.org \
    --cc=maarten@treewalker.org \
    --cc=ralf@linux-mips.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.