Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: jamie@jamieiles.com (Jamie Iles)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv5 3/4] picoxcell: add common SoC devices
Date: Fri, 18 Feb 2011 10:00:30 +0000	[thread overview]
Message-ID: <1298023231-2747-4-git-send-email-jamie@jamieiles.com> (raw)
In-Reply-To: <1298023231-2747-1-git-send-email-jamie@jamieiles.com>

Add the devices common to all picoXcell variants (UART and PMU). Other
peripherals such as DMA, SPI, fuses and EMAC will be added later
with driver support.

v3:
    - move device registration to an arch_initcall
    - mark common_devices with __initdata

v2: - split the UARTs into two separate platform devices and use
      PLAT8250_* as the IDs

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 arch/arm/mach-picoxcell/Makefile  |    3 +-
 arch/arm/mach-picoxcell/devices.c |  122 +++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-picoxcell/devices.c

diff --git a/arch/arm/mach-picoxcell/Makefile b/arch/arm/mach-picoxcell/Makefile
index 493ec0e..3cace37 100644
--- a/arch/arm/mach-picoxcell/Makefile
+++ b/arch/arm/mach-picoxcell/Makefile
@@ -1,2 +1,3 @@
 obj-y				:= picoxcell_core.o io.o axi2cfg.o \
-				   time.o
+				   time.o \
+				   devices.o
diff --git a/arch/arm/mach-picoxcell/devices.c b/arch/arm/mach-picoxcell/devices.c
new file mode 100644
index 0000000..505de91
--- /dev/null
+++ b/arch/arm/mach-picoxcell/devices.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2010 Picochip Ltd., Jamie Iles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * All enquiries to support at picochip.com
+ */
+#include <linux/serial_8250.h>
+#include <linux/serial_reg.h>
+#include <linux/platform_device.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <mach/hardware.h>
+#include <mach/irqs.h>
+
+#include <asm/pmu.h>
+
+#include "picoxcell_core.h"
+#include "soc.h"
+
+#define UART_USR_REG_OFFSET			0x7C
+static struct plat_serial8250_port serial1_platform_data[] = {
+	{
+		.membase	= IO_ADDRESS(PICOXCELL_UART1_BASE),
+		.mapbase	= PICOXCELL_UART1_BASE,
+		.irq		= IRQ_UART1,
+		.flags		= UPF_BOOT_AUTOCONF,
+		.iotype		= UPIO_DWAPB32,
+		.regshift	= 2,
+		.uartclk	= PICOXCELL_BASE_BAUD,
+		.private_data	= (void *)(PHYS_TO_IO(PICOXCELL_UART1_BASE +
+						      UART_USR_REG_OFFSET)),
+	},
+	{},
+};
+
+static struct resource serial1_resources[] = {
+	{
+		.start		= PICOXCELL_UART1_BASE,
+		.end		= PICOXCELL_UART1_BASE + 0xFFFF,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= IRQ_UART1,
+		.end		= IRQ_UART2,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device serial1_device = {
+	.name			= "serial8250",
+	.id			= PLAT8250_DEV_PLATFORM1,
+	.dev.platform_data	= serial1_platform_data,
+	.resource		= serial1_resources,
+	.num_resources		= ARRAY_SIZE(serial1_resources),
+};
+
+static struct plat_serial8250_port serial2_platform_data[] = {
+	{
+		.membase	= IO_ADDRESS(PICOXCELL_UART2_BASE),
+		.mapbase	= PICOXCELL_UART2_BASE,
+		.irq		= IRQ_UART2,
+		.flags		= UPF_BOOT_AUTOCONF,
+		.iotype		= UPIO_DWAPB32,
+		.regshift	= 2,
+		.uartclk	= PICOXCELL_BASE_BAUD,
+		.private_data	= (void *)(PHYS_TO_IO(PICOXCELL_UART2_BASE +
+						      UART_USR_REG_OFFSET)),
+	},
+	{},
+};
+
+static struct resource serial2_resources[] = {
+	{
+		.start		= PICOXCELL_UART2_BASE,
+		.end		= PICOXCELL_UART2_BASE + 0xFFFF,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= IRQ_UART2,
+		.end		= IRQ_UART2,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device serial2_device = {
+	.name			= "serial8250",
+	.id			= PLAT8250_DEV_PLATFORM2,
+	.dev.platform_data	= serial2_platform_data,
+	.resource		= serial2_resources,
+	.num_resources		= ARRAY_SIZE(serial2_resources),
+};
+
+static struct resource pmu_resource = {
+	.start			= IRQ_NPMUIRQ,
+	.end			= IRQ_NPMUIRQ,
+	.flags			= IORESOURCE_IRQ,
+};
+
+static struct platform_device pmu_device = {
+	.name			= "arm-pmu",
+	.id			= ARM_PMU_DEVICE_CPU,
+	.num_resources		= 1,
+	.resource		= &pmu_resource,
+};
+
+static struct __initdata platform_device *common_devices[] __initdata = {
+	&serial1_device,
+	&serial2_device,
+	&pmu_device,
+};
+
+static int __init picoxcell_add_devices(void)
+{
+	platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
+
+	return 0;
+}
+arch_initcall(picoxcell_add_devices);
-- 
1.7.4

  parent reply	other threads:[~2011-02-18 10:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-18 10:00 [PATCHv5 0/4] ARM: add initial support for Picochip picoXcell SoC Jamie Iles
2011-02-18 10:00 ` [PATCHv5 1/4] picoxcell: add support for picoXcell Jamie Iles
2011-02-18 10:00 ` [PATCHv5 2/4] picoxcell: add support for the system timers Jamie Iles
2011-02-18 10:00 ` Jamie Iles [this message]
2011-02-18 10:00 ` [PATCHv5 4/4] picoxcell: add support for the PC7302 development board Jamie Iles

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=1298023231-2747-4-git-send-email-jamie@jamieiles.com \
    --to=jamie@jamieiles.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox