public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: "Dale Farnsworth" <dale@farnsworth•org>
To: linuxppc-dev <Linuxppc-dev@ozlabs•org>
Cc: Stephen Rothwell <sfr@canb•auug.org.au>,
	Paul Mackerras <paulus@samba•org>, Arnd Bergmann <arnd@arndb•de>
Subject: [PATCH 7/13] powerpc: Create Marvell mv64x60 MPSC (serial) platform_data
Date: Fri, 4 May 2007 14:03:15 -0700	[thread overview]
Message-ID: <20070504210315.GA3166@xyzzy.farnsworth.org> (raw)
In-Reply-To: <20070502214104.GB27253@xyzzy.farnsworth.org>

This patch creates platform_device entries for the Marvell mv64x60
MPSC (multi-protocol serial controller) ports, based on information
contained in the device tree.

Signed-off-by: Dale Farnsworth <dale@farnsworth•org>
---
Latest rev.  I believe I have address all the issues raised by
Stephen Rothwell and Arnd Bergmann.

 arch/powerpc/platforms/embedded6xx/Kconfig |    3 
 arch/powerpc/sysdev/Makefile               |    2 
 arch/powerpc/sysdev/mv64x60_dev.c          |  221 +++++++++++++++++++
 3 files changed, 225 insertions(+), 1 deletion(-)

Index: linux-2.6-powerpc-df/arch/powerpc/sysdev/mv64x60_dev.c
===================================================================
--- /dev/null
+++ linux-2.6-powerpc-df/arch/powerpc/sysdev/mv64x60_dev.c
@@ -0,0 +1,221 @@
+/*
+ * Platform device setup for Marvell mv64360/mv64460 host bridges (Discovery)
+ *
+ * Author: Dale Farnsworth <dale@farnsworth•org>
+ *
+ * 2007 (c) MontaVista, Software, Inc.  This file is licensed under
+ * the terms of the GNU General Public License version 2.  This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/mv643xx.h>
+#include <linux/platform_device.h>
+
+#include <asm/prom.h>
+
+/*
+ * These functions provide the necessary setup for the mv64x60 drivers.
+ * These drivers are unusual in that they work on both the MIPS and PowerPC
+ * architectures.  Because of that, the drivers do not support the normal
+ * PowerPC of_platform_bus_type.  They support platform_bus_type instead.
+ */
+
+/*
+ * Create MPSC platform device
+ */
+static int __init mv64x60_mpsc_register_shared_pdev(struct device_node *np)
+{
+	struct platform_device *pdev;
+	struct resource r[2];
+	struct mpsc_shared_pdata pdata;
+	const phandle *ph;
+	struct device_node *mpscrouting, *mpscintr;
+	int err;
+
+	ph = of_get_property(np, "mpscrouting", NULL);
+	mpscrouting = of_find_node_by_phandle(*ph);
+	if (!mpscrouting)
+		return -ENODEV;
+
+	err = of_address_to_resource(mpscrouting, 0, &r[0]);
+	of_node_put(mpscrouting);
+	if (err)
+		return err;
+
+	ph = of_get_property(np, "mpscintr", NULL);
+	mpscintr = of_find_node_by_phandle(*ph);
+	if (!mpscintr)
+		return -ENODEV;
+
+	err = of_address_to_resource(mpscintr, 0, &r[1]);
+	of_node_put(mpscintr);
+	if (err)
+		return err;
+
+	memset(&pdata, 0, sizeof(pdata));
+
+	pdev = platform_device_alloc(MPSC_SHARED_NAME, 0);
+	if (!pdev)
+		return -ENOMEM;
+
+	err = platform_device_add_resources(pdev, r, 2);
+	if (err)
+		goto error;
+
+	err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+	if (err)
+		goto error;
+
+	err = platform_device_add(pdev);
+	if (err)
+		goto error;
+
+	return 0;
+
+error:
+	platform_device_put(pdev);
+	return err;
+}
+
+
+static int __init mv64x60_mpsc_device_setup(struct device_node *np, int id)
+{
+	struct resource r[5];
+	struct mpsc_pdata pdata;
+	struct platform_device *pdev;
+	const unsigned int *prop;
+	const phandle *ph;
+	struct device_node *sdma, *brg;
+	int err;
+	int port_number;
+
+	/* only register the shared platform device the first time through */
+	if (id == 0 && (err = mv64x60_mpsc_register_shared_pdev(np)))
+		return err;
+
+	memset(&r, 0, sizeof(r));
+
+	err = of_address_to_resource(np, 0, &r[0]);
+	if (err)
+		return err;
+
+	of_irq_to_resource(np, 0, &r[4]);
+
+	ph = of_get_property(np, "sdma", NULL);
+	sdma = of_find_node_by_phandle(*ph);
+	if (!sdma)
+		return -ENODEV;
+
+	of_irq_to_resource(sdma, 0, &r[3]);
+	err = of_address_to_resource(sdma, 0, &r[1]);
+	of_node_put(sdma);
+	if (err)
+		return err;
+
+	ph = of_get_property(np, "brg", NULL);
+	brg = of_find_node_by_phandle(*ph);
+	if (!brg)
+		return -ENODEV;
+
+	err = of_address_to_resource(brg, 0, &r[2]);
+	of_node_put(brg);
+	if (err)
+		return err;
+
+	prop = of_get_property(np, "block-index", NULL);
+	if (!prop)
+		return -ENODEV;
+	port_number = *(int *)prop;
+
+	memset(&pdata, 0, sizeof(pdata));
+
+	pdata.cache_mgmt = 1; /* All current revs need this set */
+
+	prop = of_get_property(np, "max_idle", NULL);
+	if (prop)
+		pdata.max_idle = *prop;
+
+	prop = of_get_property(brg, "current-speed", NULL);
+	if (prop)
+		pdata.default_baud = *prop;
+
+	/* Default is 8 bits, no parity, no flow control */
+	pdata.default_bits = 8;
+	pdata.default_parity = 'n';
+	pdata.default_flow = 'n';
+
+	prop = of_get_property(np, "chr_1", NULL);
+	if (prop)
+		pdata.chr_1_val = *prop;
+
+	prop = of_get_property(np, "chr_2", NULL);
+	if (prop)
+		pdata.chr_2_val = *prop;
+
+	prop = of_get_property(np, "chr_10", NULL);
+	if (prop)
+		pdata.chr_10_val = *prop;
+
+	prop = of_get_property(np, "mpcr", NULL);
+	if (prop)
+		pdata.mpcr_val = *prop;
+
+	prop = of_get_property(brg, "bcr", NULL);
+	if (prop)
+		pdata.bcr_val = *prop;
+
+	pdata.brg_can_tune = 1; /* All current revs need this set */
+
+	prop = of_get_property(brg, "clock-src", NULL);
+	if (prop)
+		pdata.brg_clk_src = *prop;
+
+	prop = of_get_property(brg, "clock-frequency", NULL);
+	if (prop)
+		pdata.brg_clk_freq = *prop;
+
+	pdev = platform_device_alloc(MPSC_CTLR_NAME, port_number);
+	if (!pdev)
+		return -ENOMEM;
+
+	err = platform_device_add_resources(pdev, r, 5);
+	if (err)
+		goto error;
+
+	err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+	if (err)
+		goto error;
+
+	err = platform_device_add(pdev);
+	if (err)
+		goto error;
+
+	return 0;
+
+error:
+	platform_device_put(pdev);
+	return err;
+}
+
+static int __init mv64x60_device_setup(void)
+{
+	struct device_node *np = NULL;
+	int id;
+	int err;
+
+	for (id = 0;
+	     (np = of_find_compatible_node(np, "serial", "mpsc")); id++)
+		if ((err = mv64x60_mpsc_device_setup(np, id)))
+			goto error;
+
+	return 0;
+
+error:
+	of_node_put(np);
+	return err;
+}
+arch_initcall(mv64x60_device_setup);
Index: linux-2.6-powerpc-df/arch/powerpc/sysdev/Makefile
===================================================================
--- linux-2.6-powerpc-df.orig/arch/powerpc/sysdev/Makefile
+++ linux-2.6-powerpc-df/arch/powerpc/sysdev/Makefile
@@ -14,7 +14,7 @@ obj-$(CONFIG_FSL_SOC)		+= fsl_soc.o
 obj-$(CONFIG_FSL_PCIE)		+= fsl_pcie.o
 obj-$(CONFIG_TSI108_BRIDGE)	+= tsi108_pci.o tsi108_dev.o
 obj-$(CONFIG_QUICC_ENGINE)	+= qe_lib/
-obj-$(CONFIG_MV64X60)		+= mv64x60_pic.o
+obj-$(CONFIG_MV64X60)		+= mv64x60_pic.o mv64x60_dev.o
 
 # contains only the suspend handler for time
 obj-$(CONFIG_PM)		+= timer.o
Index: linux-2.6-powerpc-df/arch/powerpc/platforms/embedded6xx/Kconfig
===================================================================
--- linux-2.6-powerpc-df.orig/arch/powerpc/platforms/embedded6xx/Kconfig
+++ linux-2.6-powerpc-df/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -38,6 +38,9 @@ config MPC10X_BRIDGE
 	select PPC_INDIRECT_PCI
 	default y
 
+config MV64X60
+	bool
+
 config MPC10X_OPENPIC
 	bool
 	depends on LINKSTATION

  parent reply	other threads:[~2007-05-04 21:03 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-25 23:46 [PATCH 0/13] powerpc: Add support for Marvell/mv64x60 and prpmc2800 Mark A. Greer
2007-04-25 23:55 ` [PATCH 1/13] powerpc: Add Makefile rule to wrap dts file in zImage Mark A. Greer
2007-04-30  6:06   ` David Gibson
2007-04-25 23:55 ` [PATCH 2/13] powerpc: Add dt_xlate_addr() to bootwrapper Mark A. Greer
2007-04-26 16:44   ` Scott Wood
2007-04-27  5:55   ` Paul Mackerras
2007-04-27 20:48     ` Mark A. Greer
2007-04-25 23:56 ` [PATCH 3/13] powerpc: Add bootwrapper support for Marvell/mv64x60 hostbridge Mark A. Greer
2007-04-27  6:01   ` Paul Mackerras
2007-04-27 22:02     ` Mark A. Greer
2007-05-03  5:25       ` Paul Mackerras
2007-05-03 18:44         ` Mark A. Greer
2007-05-03 19:00           ` Mark A. Greer
2007-05-05 23:27           ` Paul Mackerras
2007-05-07 18:15             ` Mark A. Greer
2007-04-25 23:57 ` [PATCH 4/13] powerpc: Add bootwrapper support for Marvell MPSC Mark A. Greer
2007-04-25 23:57 ` [PATCH 5/13] powerpc: Add bootwrapper support for Marvell/mv64x60 I2C Mark A. Greer
2007-04-25 23:58 ` [PATCH 6/13] powerpc: Add arch/powerpc support for Marvell/mv64x60 hostbridge Mark A. Greer
2007-04-26  0:42   ` Arnd Bergmann
2007-04-26  5:49     ` Dale Farnsworth
2007-05-02 21:38   ` [PATCH 6/13] powerpc: Add arch/powerpc interrupt handler for mv64x60 Dale Farnsworth
2007-05-03  1:47     ` Stephen Rothwell
2007-05-03  2:55       ` Dale Farnsworth
2007-04-25 23:59 ` [PATCH 7/13] powerpc: Add arch/powerpc mv64x60 MPSC platform data setup Mark A. Greer
2007-04-26  0:14   ` Arnd Bergmann
2007-04-26  5:57     ` Dale Farnsworth
2007-04-26 11:24       ` Arnd Bergmann
2007-04-26 14:30         ` Dale Farnsworth
2007-04-26 15:14           ` Arnd Bergmann
2007-05-02 21:41   ` Dale Farnsworth
2007-05-03  6:40     ` Arnd Bergmann
2007-05-04 21:03     ` Dale Farnsworth [this message]
2007-05-05 12:26       ` [PATCH 7/13] powerpc: Create Marvell mv64x60 MPSC (serial) platform_data Arnd Bergmann
2007-04-26  0:00 ` [PATCH 8/13] powerpc: Add arch/powerpc mv64x60_eth platform data setup Mark A. Greer
2007-04-26  0:18   ` Arnd Bergmann
2007-04-26  6:00     ` Dale Farnsworth
2007-05-02 21:43   ` Dale Farnsworth
2007-05-03  2:03     ` Stephen Rothwell
2007-05-03  6:43     ` Arnd Bergmann
2007-05-04 21:06     ` [PATCH 8/13] powerpc: Create Marvell mv64x60 ethernet platform_data Dale Farnsworth
2007-05-05 12:28       ` Arnd Bergmann
2007-04-26  0:00 ` [PATCH 9/13] powerpc: Add arch/powerpc mv64x60 I2C platform data setup Mark A. Greer
2007-04-26  0:21   ` Arnd Bergmann
2007-04-26  0:43     ` Mark A. Greer
2007-04-26  0:55       ` Arnd Bergmann
2007-04-26  1:13         ` Mark A. Greer
2007-04-26  2:02           ` Arnd Bergmann
2007-04-26  6:08             ` Dale Farnsworth
2007-04-26  9:00               ` Arnd Bergmann
2007-04-26 14:19                 ` Dale Farnsworth
2007-04-26 15:04                   ` Arnd Bergmann
2007-04-27 23:50                     ` Dale Farnsworth
2007-04-28  1:05                       ` Arnd Bergmann
2007-04-28  2:40                         ` Dale Farnsworth
2007-05-01  4:58                         ` Paul Mackerras
2007-05-01  4:45                     ` Paul Mackerras
2007-04-26  6:48             ` Mark A. Greer
2007-05-02 21:44   ` Dale Farnsworth
2007-05-03  6:53     ` Arnd Bergmann
2007-05-03 13:06       ` 
2007-05-04 21:08     ` [PATCH 9/13] powerpc: Create Marvell mv64x60 I2C platform_data Dale Farnsworth
2007-05-05 12:29       ` Arnd Bergmann
2007-04-26  0:01 ` [PATCH 10/13] powerpc: Add arch/powerpc mv64x60 PCI setup Mark A. Greer
2007-04-26  0:25   ` Arnd Bergmann
2007-04-26  6:33     ` Dale Farnsworth
2007-04-26 11:39       ` Arnd Bergmann
2007-04-26 14:42         ` Dale Farnsworth
2007-05-02 21:46   ` Dale Farnsworth
2007-05-03  2:13     ` Stephen Rothwell
2007-05-03  2:57       ` Dale Farnsworth
2007-05-03  7:17     ` Arnd Bergmann
2007-05-03 13:45       ` Dale Farnsworth
2007-05-04 21:10     ` [PATCH 10/13] powerpc: Add Marvell mv64x60 PCI bridge support Dale Farnsworth
2007-05-05 12:30       ` Arnd Bergmann
2007-04-26  0:01 ` [PATCH 11/13] powerpc: Add DTS file for the Motorola PrPMC2800 platform Mark A. Greer
2007-04-26 16:42   ` Scott Wood
2007-04-26 23:34     ` Mark A. Greer
2007-04-26 23:37     ` David Gibson
2007-04-27 20:41   ` Mark A. Greer
2007-04-30 16:45     ` Jon Loeliger
2007-04-30 18:08       ` Mark A. Greer
2007-04-30 22:29       ` Mark A. Greer
2007-04-26  0:02 ` [PATCH 12/13] powerpc: Add bootwrapper support for " Mark A. Greer
2007-04-26  0:02 ` [PATCH 13/13] powerpc: Add arch/powerpc support for the " Mark A. Greer
2007-04-26  0:45 ` [PATCH 0/13] powerpc: Add support for Marvell/mv64x60 and prpmc2800 David Gibson
2007-04-26  0:58   ` Mark A. Greer
2007-04-26  1:15     ` Mark A. Greer

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=20070504210315.GA3166@xyzzy.farnsworth.org \
    --to=dale@farnsworth$(echo .)org \
    --cc=Linuxppc-dev@ozlabs$(echo .)org \
    --cc=arnd@arndb$(echo .)de \
    --cc=paulus@samba$(echo .)org \
    --cc=sfr@canb$(echo .)auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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