linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] mpc5121 support
@ 2008-01-08 16:01 John Rigby
  2008-01-08 16:01 ` [PATCH 1/7] mpc5121: Add IPIC config option John Rigby
  0 siblings, 1 reply; 34+ messages in thread
From: John Rigby @ 2008-01-08 16:01 UTC (permalink / raw)
  To: linuxppc-dev

The following series adds basic support
for mpc5121.  I'm hoping that this can get reviewed
quickly so it can get into the for-2.6.25 tree.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH 1/7] mpc5121: Add IPIC config option
  2008-01-08 16:01 [PATCH 0/7] mpc5121 support John Rigby
@ 2008-01-08 16:01 ` John Rigby
  2008-01-08 16:01   ` [PATCH 2/7] Add mpc512x ipic support John Rigby
  0 siblings, 1 reply; 34+ messages in thread
From: John Rigby @ 2008-01-08 16:01 UTC (permalink / raw)
  To: linuxppc-dev

IPIC is not just for 83xx anymore so make it a separate
config option.

Signed-off-by: John Rigby <jrigby@freescale.com>
---
 arch/powerpc/platforms/Kconfig |    5 +++++
 arch/powerpc/sysdev/Makefile   |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index ea22cad..ad9b1c0 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -22,6 +22,7 @@ config PPC_83xx
 	depends on 6xx
 	select FSL_SOC
 	select 83xx
+	select FSL_IPIC
 	select WANT_DEVICE_TREE
 
 config PPC_86xx
@@ -80,6 +81,10 @@ config XICS
 	bool
 	default y
 
+config FSL_IPIC
+	bool
+	default n
+
 config MPIC
 	bool
 	default n
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 9a20ef4..66fe39c 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -24,7 +24,7 @@ obj-$(CONFIG_AXON_RAM)		+= axonram.o
 ifeq ($(CONFIG_PPC_MERGE),y)
 obj-$(CONFIG_PPC_INDIRECT_PCI)	+= indirect_pci.o
 obj-$(CONFIG_PPC_I8259)		+= i8259.o
-obj-$(CONFIG_PPC_83xx)		+= ipic.o
+obj-$(CONFIG_FSL_IPIC)		+= ipic.o
 obj-$(CONFIG_4xx)		+= uic.o
 obj-$(CONFIG_XILINX_VIRTEX)	+= xilinx_intc.o
 ifeq ($(CONFIG_PCI),y)
-- 
1.5.3.5.726.g41a7a

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 2/7] Add mpc512x ipic support
  2008-01-08 16:01 ` [PATCH 1/7] mpc5121: Add IPIC config option John Rigby
@ 2008-01-08 16:01   ` John Rigby
  2008-01-08 16:01     ` [PATCH 3/7] Basic Freescale MPC512x support John Rigby
  0 siblings, 1 reply; 34+ messages in thread
From: John Rigby @ 2008-01-08 16:01 UTC (permalink / raw)
  To: linuxppc-dev

Added ipic_info entries for vectors used by 512x that
were previously unused by 83xx.

Signed-off-by: John Rigby <jrigby@freescale.com>
---
 arch/powerpc/sysdev/ipic.c |   62 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 7274750..4c016da 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -48,6 +48,13 @@ static struct ipic_info ipic_info[] = {
 		.bit	= 17,
 		.prio_mask = 1,
 	},
+	[3] = {
+		.mask	= IPIC_SIMSR_H,
+		.prio	= IPIC_SIPRR_C,
+		.force	= IPIC_SIFCR_H,
+		.bit	= 18,
+		.prio_mask = 2,
+	},
 	[4] = {
 		.mask	= IPIC_SIMSR_H,
 		.prio	= IPIC_SIPRR_C,
@@ -55,6 +62,34 @@ static struct ipic_info ipic_info[] = {
 		.bit	= 19,
 		.prio_mask = 3,
 	},
+	[5] = {
+		.mask	= IPIC_SIMSR_H,
+		.prio	= IPIC_SIPRR_C,
+		.force	= IPIC_SIFCR_H,
+		.bit	= 20,
+		.prio_mask = 4,
+	},
+	[6] = {
+		.mask	= IPIC_SIMSR_H,
+		.prio	= IPIC_SIPRR_C,
+		.force	= IPIC_SIFCR_H,
+		.bit	= 21,
+		.prio_mask = 5,
+	},
+	[7] = {
+		.mask	= IPIC_SIMSR_H,
+		.prio	= IPIC_SIPRR_C,
+		.force	= IPIC_SIFCR_H,
+		.bit	= 22,
+		.prio_mask = 6,
+	},
+	[8] = {
+		.mask	= IPIC_SIMSR_H,
+		.prio	= IPIC_SIPRR_C,
+		.force	= IPIC_SIFCR_H,
+		.bit	= 23,
+		.prio_mask = 7,
+	},
 	[9] = {
 		.mask	= IPIC_SIMSR_H,
 		.prio	= IPIC_SIPRR_D,
@@ -223,6 +258,20 @@ static struct ipic_info ipic_info[] = {
 		.bit	= 7,
 		.prio_mask = 7,
 	},
+	[40] = {
+		.mask	= IPIC_SIMSR_H,
+		.prio	= IPIC_SIPRR_B,
+		.force	= IPIC_SIFCR_H,
+		.bit	= 8,
+		.prio_mask = 0,
+	},
+	[41] = {
+		.mask	= IPIC_SIMSR_H,
+		.prio	= IPIC_SIPRR_B,
+		.force	= IPIC_SIFCR_H,
+		.bit	= 9,
+		.prio_mask = 1,
+	},
 	[42] = {
 		.mask	= IPIC_SIMSR_H,
 		.prio	= IPIC_SIPRR_B,
@@ -230,6 +279,13 @@ static struct ipic_info ipic_info[] = {
 		.bit	= 10,
 		.prio_mask = 2,
 	},
+	[43] = {
+		.mask	= IPIC_SIMSR_H,
+		.prio	= IPIC_SIPRR_B,
+		.force	= IPIC_SIFCR_H,
+		.bit	= 11,
+		.prio_mask = 3,
+	},
 	[44] = {
 		.mask	= IPIC_SIMSR_H,
 		.prio	= IPIC_SIPRR_B,
@@ -387,6 +443,12 @@ static struct ipic_info ipic_info[] = {
 		.force	= IPIC_SIFCR_L,
 		.bit	= 18,
 	},
+	[83] = {
+		.mask	= IPIC_SIMSR_L,
+		.prio	= 0,
+		.force	= IPIC_SIFCR_L,
+		.bit	= 19,
+	},
 	[84] = {
 		.mask	= IPIC_SIMSR_L,
 		.prio	= 0,
-- 
1.5.3.5.726.g41a7a

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 16:01   ` [PATCH 2/7] Add mpc512x ipic support John Rigby
@ 2008-01-08 16:01     ` John Rigby
  2008-01-08 16:01       ` [PATCH 4/7] Device tree for MPC5121 ADS John Rigby
                         ` (4 more replies)
  0 siblings, 5 replies; 34+ messages in thread
From: John Rigby @ 2008-01-08 16:01 UTC (permalink / raw)
  To: linuxppc-dev

512x is very similar to 83xx and most
of this is patterned after code from 83xx

New platform:
    changed:
	arch/powerpc/Kconfig
	arch/powerpc/platforms/Kconfig
	arch/powerpc/platforms/Kconfig.cputype
	arch/powerpc/platforms/Makefile
    new:
	arch/powerpc/platforms/512x/*

Signed-off-by: John Rigby <jrigby@freescale.com>
---
 arch/powerpc/Kconfig                      |    2 +-
 arch/powerpc/platforms/512x/Kconfig       |   20 ++++++
 arch/powerpc/platforms/512x/Makefile      |    4 +
 arch/powerpc/platforms/512x/mpc5121_ads.c |   90 +++++++++++++++++++++++++++++
 arch/powerpc/platforms/Kconfig            |    8 +++
 arch/powerpc/platforms/Kconfig.cputype    |    6 +-
 arch/powerpc/platforms/Makefile           |    1 +
 7 files changed, 127 insertions(+), 4 deletions(-)
 create mode 100644 arch/powerpc/platforms/512x/Kconfig
 create mode 100644 arch/powerpc/platforms/512x/Makefile
 create mode 100644 arch/powerpc/platforms/512x/mpc5121_ads.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 66a3d8c..81c3f05 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -470,7 +470,7 @@ config PCI
 	bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \
 		|| PPC_MPC52xx || (EMBEDDED && (PPC_PSERIES || PPC_ISERIES)) \
 		|| PPC_PS3
-	default y if !40x && !CPM2 && !8xx && !PPC_83xx \
+	default y if !40x && !CPM2 && !8xx && !PPC_512x && !PPC_83xx \
 		&& !PPC_85xx && !PPC_86xx
 	default PCI_PERMEDIA if !4xx && !CPM2 && !8xx
 	default PCI_QSPAN if !4xx && !CPM2 && 8xx
diff --git a/arch/powerpc/platforms/512x/Kconfig b/arch/powerpc/platforms/512x/Kconfig
new file mode 100644
index 0000000..399d279
--- /dev/null
+++ b/arch/powerpc/platforms/512x/Kconfig
@@ -0,0 +1,20 @@
+menu "Platform support"
+	depends on PPC_512x
+
+choice
+	prompt "Machine Type"
+	default MPC5121_ADS
+
+config MPC5121_ADS
+	bool "Freescale MPC5121E ADS"
+	select DEFAULT_UIMAGE
+	help
+	  This option enables support for the MPC5121E ADS board.
+
+endchoice
+
+config MPC5121
+	bool
+	default y if MPC5121_ADS
+
+endmenu
diff --git a/arch/powerpc/platforms/512x/Makefile b/arch/powerpc/platforms/512x/Makefile
new file mode 100644
index 0000000..232c89f
--- /dev/null
+++ b/arch/powerpc/platforms/512x/Makefile
@@ -0,0 +1,4 @@
+#
+# Makefile for the Freescale PowerPC 512x linux kernel.
+#
+obj-$(CONFIG_MPC5121_ADS)	+= mpc5121_ads.o
diff --git a/arch/powerpc/platforms/512x/mpc5121_ads.c b/arch/powerpc/platforms/512x/mpc5121_ads.c
new file mode 100644
index 0000000..a860bf0
--- /dev/null
+++ b/arch/powerpc/platforms/512x/mpc5121_ads.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author: John Rigby, <jrigby@freescale.com>, Thur Mar 29 2007
+ *
+ * Description:
+ * MPC5121 ADS board setup
+ *
+ * This 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/stddef.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/reboot.h>
+#include <linux/kdev_t.h>
+#include <linux/major.h>
+#include <linux/console.h>
+#include <linux/delay.h>
+#include <linux/seq_file.h>
+#include <linux/root_dev.h>
+#include <linux/time.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+
+#include <asm/system.h>
+#include <asm/atomic.h>
+#include <asm/machdep.h>
+#include <asm/ipic.h>
+#include <asm/prom.h>
+#include <asm/time.h>
+#include <asm/of_platform.h>
+
+static void __init mpc5121_ads_setup_arch(void)
+{
+	if (ppc_md.progress)
+		ppc_md.progress("mpc5121_ads_setup_arch()", 0);
+
+	printk(KERN_INFO "MPC5121 ADS board from Freescale Semiconductor\n");
+}
+
+static void __init mpc5121_ads_declare_of_platform_devices(void)
+{
+	/* Find every child of the SOC node and add it to of_platform */
+	if (of_platform_bus_probe(NULL, NULL, NULL))
+		printk(KERN_ERR __FILE__ ": "
+			"Error while probing of_platform bus\n");
+}
+
+static void __init mpc5121_ads_init_IRQ(void)
+{
+	struct device_node *np;
+
+	np = of_find_node_by_type(NULL, "ipic");
+	if (!np)
+		return;
+
+	ipic_init(np, 0);
+
+	/*
+	 * Initialize the default interrupt mapping priorities,
+	 * in case the boot rom changed something on us.
+	 */
+	ipic_set_default_priority();
+}
+
+/*
+ * Called very early, MMU is off, device-tree isn't unflattened
+ */
+static int __init mpc5121_ads_probe(void)
+{
+	unsigned long root = of_get_flat_dt_root();
+
+	return of_flat_dt_is_compatible(root, "MPC5121ADS");
+}
+
+define_machine(mpc5121_ads) {
+	.name			= "MPC5121 ADS",
+	.probe			= mpc5121_ads_probe,
+	.setup_arch		= mpc5121_ads_setup_arch,
+	.init			= mpc5121_ads_declare_of_platform_devices,
+	.init_IRQ		= mpc5121_ads_init_IRQ,
+	.get_irq		= ipic_get_irq,
+	.calibrate_decr		= generic_calibrate_decr,
+};
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index ad9b1c0..1daf47f 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -25,6 +25,13 @@ config PPC_83xx
 	select IPIC
 	select WANT_DEVICE_TREE
 
+config PPC_512x
+	bool "Freescale 512x"
+	depends on 6xx
+	select FSL_SOC
+	select IPIC
+	select WANT_DEVICE_TREE
+
 config PPC_86xx
 	bool "Freescale 86xx"
 	depends on 6xx
@@ -41,6 +48,7 @@ config CLASSIC32
 source "arch/powerpc/platforms/pseries/Kconfig"
 source "arch/powerpc/platforms/iseries/Kconfig"
 source "arch/powerpc/platforms/chrp/Kconfig"
+source "arch/powerpc/platforms/512x/Kconfig"
 source "arch/powerpc/platforms/52xx/Kconfig"
 source "arch/powerpc/platforms/powermac/Kconfig"
 source "arch/powerpc/platforms/prep/Kconfig"
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index c3ee0b5..e21ffa5 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -14,7 +14,7 @@ choice
 	  There are five families of 32 bit PowerPC chips supported.
 	  The most common ones are the desktop and server CPUs (601, 603,
 	  604, 740, 750, 74xx) CPUs from Freescale and IBM, with their
-	  embedded 52xx/82xx/83xx/86xx counterparts.
+	  embedded 512x/52xx/82xx/83xx/86xx counterparts.
 	  The other embeeded parts, namely 4xx, 8xx, e200 (55xx) and e500
 	  (85xx) each form a family of their own that is not compatible
 	  with the others.
@@ -22,7 +22,7 @@ choice
 	  If unsure, select 52xx/6xx/7xx/74xx/82xx/83xx/86xx.
 
 config 6xx
-	bool "52xx/6xx/7xx/74xx/82xx/83xx/86xx"
+	bool "512x/52xx/6xx/7xx/74xx/82xx/83xx/86xx"
 	select PPC_FPU
 
 config PPC_85xx
@@ -229,7 +229,7 @@ config NR_CPUS
 
 config NOT_COHERENT_CACHE
 	bool
-	depends on 4xx || 8xx || E200
+	depends on 4xx || 8xx || E200 || PPC_512x
 	default y
 
 config CHECK_CACHE_COHERENCY
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 6d9079d..633a599 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -11,6 +11,7 @@ endif
 obj-$(CONFIG_PPC_CHRP)		+= chrp/
 obj-$(CONFIG_40x)		+= 40x/
 obj-$(CONFIG_44x)		+= 44x/
+obj-$(CONFIG_PPC_512x)		+= 512x/
 obj-$(CONFIG_PPC_MPC52xx)	+= 52xx/
 obj-$(CONFIG_PPC_8xx)		+= 8xx/
 obj-$(CONFIG_PPC_82xx)		+= 82xx/
-- 
1.5.3.5.726.g41a7a

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 4/7] Device tree for MPC5121 ADS
  2008-01-08 16:01     ` [PATCH 3/7] Basic Freescale MPC512x support John Rigby
@ 2008-01-08 16:01       ` John Rigby
  2008-01-08 16:01         ` [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC John Rigby
                           ` (3 more replies)
  2008-01-08 17:19       ` [PATCH 3/7] Basic Freescale MPC512x support Grant Likely
                         ` (3 subsequent siblings)
  4 siblings, 4 replies; 34+ messages in thread
From: John Rigby @ 2008-01-08 16:01 UTC (permalink / raw)
  To: linuxppc-dev

Bare minimum tree containing only
what is currently supported.

Signed-off-by: John Rigby <jrigby@freescale.com>
---
 arch/powerpc/boot/dts/mpc5121ads.dts |  102 ++++++++++++++++++++++++++++++++++
 1 files changed, 102 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/mpc5121ads.dts

diff --git a/arch/powerpc/boot/dts/mpc5121ads.dts b/arch/powerpc/boot/dts/mpc5121ads.dts
new file mode 100644
index 0000000..26471ff
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121ads.dts
@@ -0,0 +1,102 @@
+/*
+ * MPC5121E MDS Device Tree Source
+ *
+ * Copyright 2007 Freescale Semiconductor Inc.
+ *
+ * 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.
+ */
+
+/ {
+	model = "MPC5121ADS";
+	compatible = "MPC5121ADS";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		PowerPC,5121@0 {
+			device_type = "cpu";
+			reg = <0>;
+			d-cache-line-size = <20>;	// 32 bytes
+			i-cache-line-size = <20>;	// 32 bytes
+			d-cache-size = <8000>;		// L1, 32K
+			i-cache-size = <8000>;		// L1, 32K
+			ref-frequency = <3ef1480>;	// 66MHz ref clock
+			timebase-frequency = <2f34f60>; // 49.5MHz (396MHz/8) makes time tick correctly
+			bus-frequency = <bcd3d80>;	// 198MHz csb bus
+			clock-frequency = <179a7b00>;	// 396MHz ppc core ??
+			32-bit;
+		};
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <00000000 10000000>;	// 256MB at 0
+	};
+
+	cpld@82000000 {
+		device_type = "board-control";
+		reg = <82000000 8000>;
+	};
+
+	soc5121@80000000 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		#interrupt-cells = <2>;
+		device_type = "soc";
+		ranges = <0 80000000 400000>;
+		reg = <80000000 400000>;
+		ref-frequency = <3ef1480>;	// 66MHz ref
+		bus-frequency = <5e69ec0>;	// 99MHz ips ref
+
+		// IPIC
+		// interrupts cell = <intr #, sense>
+		// sense values match linux IORESOURCE_IRQ_* defines:
+		// sense == 8: Level, low assertion
+		// sense == 2: Edge, high-to-low change
+		//
+		ipic: pic@c00 {
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <2>;
+			reg = <c00 100>;
+			built-in;
+			device_type = "ipic";
+		};
+
+		// 512x PSCs are not 52xx PSCs compatible
+		// PSC3 serial port A aka ttyPSC0
+		serial@11300 {
+			device_type = "serial";
+			compatible = "mpc512x-psc-uart";
+			port-number = <0>;  // Logical port assignment
+			cell-index = <3>;
+			reg = <11300 100>;
+			interrupts = <28 8>; // actually the fifo irq
+			interrupt-parent = < &ipic >;
+		};
+
+		// PSC4 serial port B aka ttyPSC1
+		serial@11400 {
+			device_type = "serial";
+			compatible = "mpc512x-psc-uart";
+			port-number = <1>;  // Logical port assignment
+			cell-index = <4>;
+			reg = <11400 100>;
+			interrupts = <28 8>; // actually the fifo irq
+			interrupt-parent = < &ipic >;
+		};
+
+		pscsfifo@11f00 {
+			compatible = "mpc512x-pscsfifo";
+			reg = <11f00 100>;
+			interrupts = <28 8>;
+			interrupt-parent = < &ipic >;
+		};
+	};
+};
-- 
1.5.3.5.726.g41a7a

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC
  2008-01-08 16:01       ` [PATCH 4/7] Device tree for MPC5121 ADS John Rigby
@ 2008-01-08 16:01         ` John Rigby
  2008-01-08 16:01           ` [PATCH 6/7] Add mpc512x_find_ips_freq John Rigby
  2008-01-08 17:26           ` [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC Grant Likely
  2008-01-08 17:25         ` [PATCH 4/7] Device tree for MPC5121 ADS Grant Likely
                           ` (2 subsequent siblings)
  3 siblings, 2 replies; 34+ messages in thread
From: John Rigby @ 2008-01-08 16:01 UTC (permalink / raw)
  To: linuxppc-dev

This is in preparation for the addition of MPC512x
PSC support.  The main difference in the 512x is
in the fifo registers.

Signed-off-by: John Rigby <jrigby@freescale.com>
---
 drivers/serial/mpc52xx_uart.c     |   10 ++++++----
 include/asm-powerpc/mpc52xx_psc.h |    3 +++
 include/asm-ppc/mpc52xx_psc.h     |    3 +++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index ec36ad7..25a91c9 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -111,6 +111,7 @@ static void mpc52xx_uart_of_enumerate(void);
 #endif
 
 #define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase))
+#define FIFO(port) ((struct mpc52xx_psc_fifo __iomem *)(PSC(port)+1))
 
 
 /* Forward declaration of the interruption handling routine */
@@ -222,6 +223,7 @@ static int
 mpc52xx_uart_startup(struct uart_port *port)
 {
 	struct mpc52xx_psc __iomem *psc = PSC(port);
+	struct mpc52xx_psc_fifo __iomem *fifo = FIFO(port);
 	int ret;
 
 	/* Request IRQ */
@@ -238,10 +240,10 @@ mpc52xx_uart_startup(struct uart_port *port)
 
 	out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */
 
-	out_8(&psc->rfcntl, 0x00);
-	out_be16(&psc->rfalarm, 0x1ff);
-	out_8(&psc->tfcntl, 0x07);
-	out_be16(&psc->tfalarm, 0x80);
+	out_8(&fifo->rfcntl, 0x00);
+	out_be16(&fifo->rfalarm, 0x1ff);
+	out_8(&fifo->tfcntl, 0x07);
+	out_be16(&fifo->tfalarm, 0x80);
 
 	port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY;
 	out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
diff --git a/include/asm-powerpc/mpc52xx_psc.h b/include/asm-powerpc/mpc52xx_psc.h
index 26690d2..bea42b9 100644
--- a/include/asm-powerpc/mpc52xx_psc.h
+++ b/include/asm-powerpc/mpc52xx_psc.h
@@ -153,6 +153,9 @@ struct mpc52xx_psc {
 	u8		reserved16[3];
 	u8		irfdr;		/* PSC + 0x54 */
 	u8		reserved17[3];
+};
+
+struct mpc52xx_psc_fifo {
 	u16		rfnum;		/* PSC + 0x58 */
 	u16		reserved18;
 	u16		tfnum;		/* PSC + 0x5c */
diff --git a/include/asm-ppc/mpc52xx_psc.h b/include/asm-ppc/mpc52xx_psc.h
index c82b8d4..39fcd02 100644
--- a/include/asm-ppc/mpc52xx_psc.h
+++ b/include/asm-ppc/mpc52xx_psc.h
@@ -159,6 +159,9 @@ struct mpc52xx_psc {
 	u8		reserved16[3];
 	u8		irfdr;		/* PSC + 0x54 */
 	u8		reserved17[3];
+};
+
+struct mpc52xx_psc_fifo {
 	u16		rfnum;		/* PSC + 0x58 */
 	u16		reserved18;
 	u16		tfnum;		/* PSC + 0x5c */
-- 
1.5.3.5.726.g41a7a

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 6/7] Add mpc512x_find_ips_freq
  2008-01-08 16:01         ` [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC John Rigby
@ 2008-01-08 16:01           ` John Rigby
  2008-01-08 16:01             ` [PATCH 7/7] Add MPC512x PSC serial driver John Rigby
                               ` (2 more replies)
  2008-01-08 17:26           ` [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC Grant Likely
  1 sibling, 3 replies; 34+ messages in thread
From: John Rigby @ 2008-01-08 16:01 UTC (permalink / raw)
  To: linuxppc-dev

Added mpc512x_find_ips_freq needed by the following
serial driver patch.  It is basically a renamed
mpc512x_find_ipd_freq from 52xx.

Signed-off-by: John Rigby <jrigby@freescale.com>
---
 arch/powerpc/platforms/512x/mpc5121_ads.c |   28 ++++++++++++++++++++++++++++
 include/asm-powerpc/mpc512x.h             |   22 ++++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-powerpc/mpc512x.h

diff --git a/arch/powerpc/platforms/512x/mpc5121_ads.c b/arch/powerpc/platforms/512x/mpc5121_ads.c
index a860bf0..2f4cfee 100644
--- a/arch/powerpc/platforms/512x/mpc5121_ads.c
+++ b/arch/powerpc/platforms/512x/mpc5121_ads.c
@@ -36,6 +36,34 @@
 #include <asm/time.h>
 #include <asm/of_platform.h>
 
+/**
+ * 	mpc512x_find_ips_freq - Find the IPB bus frequency for a device
+ * 	@node:	device node
+ *
+ * 	Returns IPS bus frequency, or 0 if the bus frequency cannot be found.
+ */
+unsigned long
+mpc512x_find_ips_freq(struct device_node *node)
+{
+	struct device_node *np;
+	const unsigned int *p_ips_freq = NULL;
+
+	of_node_get(node);
+	while (node) {
+		p_ips_freq = of_get_property(node, "bus-frequency", NULL);
+		if (p_ips_freq)
+			break;
+
+		np = of_get_parent(node);
+		of_node_put(node);
+		node = np;
+	}
+	if (node)
+		of_node_put(node);
+
+	return p_ips_freq ? *p_ips_freq : 0;
+}
+
 static void __init mpc5121_ads_setup_arch(void)
 {
 	if (ppc_md.progress)
diff --git a/include/asm-powerpc/mpc512x.h b/include/asm-powerpc/mpc512x.h
new file mode 100644
index 0000000..c48a165
--- /dev/null
+++ b/include/asm-powerpc/mpc512x.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author: John Rigby, <jrigby@freescale.com>, Friday Apr 13 2007
+ *
+ * Description:
+ * MPC5121 Prototypes and definitions
+ *
+ * This 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 __ASM_POWERPC_MPC512x_H__
+#define __ASM_POWERPC_MPC512x_H__
+
+extern unsigned long mpc512x_find_ips_freq(struct device_node *node);
+
+#endif /* __ASM_POWERPC_MPC512x_H__ */
+
-- 
1.5.3.5.726.g41a7a

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 7/7] Add MPC512x PSC serial driver
  2008-01-08 16:01           ` [PATCH 6/7] Add mpc512x_find_ips_freq John Rigby
@ 2008-01-08 16:01             ` John Rigby
  2008-01-08 17:32               ` Grant Likely
  2008-01-09  3:16               ` Stephen Rothwell
  2008-01-08 17:27             ` [PATCH 6/7] Add mpc512x_find_ips_freq Grant Likely
  2008-01-08 18:15             ` Arnd Bergmann
  2 siblings, 2 replies; 34+ messages in thread
From: John Rigby @ 2008-01-08 16:01 UTC (permalink / raw)
  To: linuxppc-dev

mpc512x_uart.c is based on mpc52xx_uart.c with
    names changed
    arch/ppc support removed
    512x psc fifo support added
    shares mpc52xx_psc.h with 52xx driver

Signed-off-by: John Rigby <jrigby@freescale.com>
---
 drivers/serial/Kconfig            |   18 +
 drivers/serial/Makefile           |    1 +
 drivers/serial/mpc512x_uart.c     |  969 +++++++++++++++++++++++++++++++++++++
 include/asm-powerpc/mpc52xx_psc.h |   47 ++
 4 files changed, 1035 insertions(+), 0 deletions(-)
 create mode 100644 drivers/serial/mpc512x_uart.c

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index d7e1996..643b84a 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -1113,6 +1113,24 @@ config SERIAL_SGI_L1_CONSOLE
 		controller serial port as your console (you want this!),
 		say Y.  Otherwise, say N.
 
+config SERIAL_MPC512x
+	tristate "Freescale MPC512x family PSC serial support"
+	depends on PPC_512x
+	select SERIAL_CORE
+	help
+	  This drivers support the MPC512x PSC serial ports. If you would
+	  like to use them, you must answer Y or M to this option. Not that
+	  for use as console, it must be included in kernel and not as a
+	  module.
+
+config SERIAL_MPC512x_CONSOLE
+	bool "Console on a Freescale MPC512x family PSC serial port"
+	depends on SERIAL_MPC512x=y
+	select SERIAL_CORE_CONSOLE
+	help
+	  Select this options if you'd like to use one of the PSC serial port
+	  of the Freescale MPC52xx family as a console.
+
 config SERIAL_MPC52xx
 	tristate "Freescale MPC52xx family PSC serial support"
 	depends on PPC_MPC52xx
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index af6377d..13e8176 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o
 obj-$(CONFIG_SERIAL_SGI_L1_CONSOLE) += sn_console.o
 obj-$(CONFIG_SERIAL_CPM) += cpm_uart/
 obj-$(CONFIG_SERIAL_IMX) += imx.o
+obj-$(CONFIG_SERIAL_MPC512x) += mpc512x_uart.o
 obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
 obj-$(CONFIG_SERIAL_ICOM) += icom.o
 obj-$(CONFIG_SERIAL_M32R_SIO) += m32r_sio.o
diff --git a/drivers/serial/mpc512x_uart.c b/drivers/serial/mpc512x_uart.c
new file mode 100644
index 0000000..e2ff0b8
--- /dev/null
+++ b/drivers/serial/mpc512x_uart.c
@@ -0,0 +1,969 @@
+/*
+ * Driver for the PSC of the Freescale MPC512x PSCs configured as UARTs.
+ *
+ * Copyright (C) 2007 Freescale Semiconductor Inc
+ * John Rigby <jrigby@freescale.com>
+ *
+ * Fork of mpc512x_uart.c:
+ *
+ *	Copyright (C) 2006 Secret Lab Technologies Ltd.
+ *	                   Grant Likely <grant.likely@secretlab.ca>
+ *	Copyright (C) 2004-2006 Sylvain Munaut <tnt@246tNt.com>
+ *	Copyright (C) 2003 MontaVista, Software, Inc.
+ *			      Dale Farnsworth <dfarnsworth@mvista.com>.
+ *
+ * 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.
+ */
+
+/*
+ * The 512x PSCs are almost identical to those on 52xx.  The most notable
+ * difference is that the FIFOs have been separated out.  This file
+ * still uses the mpc52xx_psc.h which has had the fifo differences added.
+ *
+ * TODO (maybe) abstract out the fifo differences and merge this back
+ * into mpc512x_serial.c
+ */
+
+/* OF Platform device Usage :
+ *
+ * This driver is only used for PSCs configured in uart mode.  The device
+ * tree will have a node for each PSC in uart mode w/ device_type = "serial"
+ * and "mpc52xx-psc-uart" in the compatible string
+ *
+ * By default, PSC devices are enumerated in the order they are found.  However
+ * a particular PSC number can be forced by adding 'device_no = <port#>'
+ * to the device node.
+ *
+ * The driver init all necessary registers to place the PSC in uart mode without
+ * DCD. However, the pin multiplexing aren't changed and should be set either
+ * by the bootloader or in the platform init code.
+ */
+
+#undef DEBUG
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/tty.h>
+#include <linux/serial.h>
+#include <linux/sysrq.h>
+#include <linux/console.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+
+#include <asm/of_platform.h>
+#include <asm/mpc52xx_psc.h>
+#include <asm/mpc512x.h>
+
+#if defined(CONFIG_SERIAL_MPC512x_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/serial_core.h>
+
+/* We've been assigned a range on the "Low-density serial ports" major */
+#define SERIAL_PSC_MAJOR	204
+#define SERIAL_PSC_MINOR	148
+
+#define ISR_PASS_LIMIT 256	/* Max number of iteration in the interrupt */
+
+static struct uart_port mpc512x_uart_ports[MPC52xx_PSC_MAXNUM];
+
+/* lookup table for matching device nodes to index numbers */
+static struct device_node *mpc512x_uart_nodes[MPC52xx_PSC_MAXNUM];
+
+static void mpc512x_uart_of_enumerate(void);
+
+static unsigned long getuartclk(void *p)
+{
+	return mpc512x_find_ips_freq(p);
+}
+
+#define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase))
+#define FIFO(port) ((struct mpc512x_psc_fifo __iomem *)(PSC(port)+1))
+
+/* Forward declaration of the interruption handling routine */
+static irqreturn_t mpc512x_uart_int(int irq, void *dev_id);
+
+/* Simple macro to test if a port is console or not. This one is taken
+ * for serial_core.c and maybe should be moved to serial_core.h ? */
+#ifdef CONFIG_SERIAL_CORE_CONSOLE
+#define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line)
+#else
+#define uart_console(port) (0)
+#endif
+
+static struct of_device_id mpc512x_uart_of_match[] = {
+	{.type = "serial", .compatible = "mpc512x-psc-uart",},
+	{},
+};
+
+/* ======================================================================== */
+/* UART operations                                                          */
+/* ======================================================================== */
+
+static unsigned int mpc512x_uart_tx_empty(struct uart_port *port)
+{
+	int status;
+
+	status = in_be32(&FIFO(port)->txsr);
+	return (status & MPC512x_PSC_FIFO_EMPTY) ? TIOCSER_TEMT : 0;
+}
+
+static void mpc512x_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+	/* Not implemented */
+}
+
+static unsigned int mpc512x_uart_get_mctrl(struct uart_port *port)
+{
+	/* Not implemented */
+	return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+}
+
+static void mpc512x_uart_stop_tx(struct uart_port *port)
+{
+	/* port->lock taken by caller */
+	unsigned long tx_fifo_imr;
+
+	tx_fifo_imr = in_be32(&FIFO(port)->tximr);
+	tx_fifo_imr &= ~MPC512x_PSC_FIFO_ALARM;
+	out_be32(&FIFO(port)->tximr, tx_fifo_imr);
+}
+
+static void mpc512x_uart_start_tx(struct uart_port *port)
+{
+	/* port->lock taken by caller */
+	unsigned long tx_fifo_imr;
+
+	tx_fifo_imr = in_be32(&FIFO(port)->tximr);
+	tx_fifo_imr |= MPC512x_PSC_FIFO_ALARM;
+	out_be32(&FIFO(port)->tximr, tx_fifo_imr);
+}
+
+static void mpc512x_uart_send_xchar(struct uart_port *port, char ch)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&port->lock, flags);
+
+	port->x_char = ch;
+	if (ch) {
+		/* Make sure tx interrupts are on */
+		/* Truly necessary ??? They should be anyway */
+		unsigned long tx_fifo_imr;
+
+		tx_fifo_imr = in_be32(&FIFO(port)->tximr);
+		tx_fifo_imr |= MPC512x_PSC_FIFO_ALARM;
+		out_be32(&FIFO(port)->tximr, tx_fifo_imr);
+	}
+
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void mpc512x_uart_stop_rx(struct uart_port *port)
+{
+	/* port->lock taken by caller */
+	unsigned long rx_fifo_imr;
+
+	rx_fifo_imr = in_be32(&FIFO(port)->rximr);
+	rx_fifo_imr &= ~MPC512x_PSC_FIFO_ALARM;
+	out_be32(&FIFO(port)->rximr, rx_fifo_imr);
+}
+
+static void mpc512x_uart_enable_ms(struct uart_port *port)
+{
+	/* Not implemented */
+}
+
+static void mpc512x_uart_break_ctl(struct uart_port *port, int ctl)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&port->lock, flags);
+
+	if (ctl == -1)
+		out_8(&PSC(port)->command, MPC52xx_PSC_START_BRK);
+	else
+		out_8(&PSC(port)->command, MPC52xx_PSC_STOP_BRK);
+
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void mpc512x_uart_fifo_init(struct mpc52xx_psc *psc)
+{
+	struct mpc512x_psc_fifo *fifo;
+
+	/* fifo is right after the psc */
+	fifo = (struct mpc512x_psc_fifo *)(psc + 1);
+
+	out_be32(&fifo->txcmd, MPC512x_PSC_FIFO_RESET_SLICE);
+	out_be32(&fifo->txcmd, MPC512x_PSC_FIFO_ENABLE_SLICE);
+	out_be32(&fifo->txalarm, 1);
+	out_be32(&fifo->tximr, 0);
+
+	out_be32(&fifo->rxcmd, MPC512x_PSC_FIFO_RESET_SLICE);
+	out_be32(&fifo->rxcmd, MPC512x_PSC_FIFO_ENABLE_SLICE);
+	out_be32(&fifo->rxalarm, 1);
+	out_be32(&fifo->rximr, 0);
+}
+
+static int mpc512x_uart_startup(struct uart_port *port)
+{
+	struct mpc52xx_psc __iomem *psc = PSC(port);
+	int ret;
+
+	/* Request IRQ */
+	ret = request_irq(port->irq, mpc512x_uart_int,
+			  IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
+			  "mpc512x_psc_uart", port);
+	if (ret)
+		return ret;
+
+	/* Reset/activate the port, clear and enable interrupts */
+	out_8(&psc->command, MPC52xx_PSC_RST_RX);
+	out_8(&psc->command, MPC52xx_PSC_RST_TX);
+
+	out_be32(&psc->sicr, 0);	/* UART mode DCD ignored */
+
+	mpc512x_uart_fifo_init(psc);
+
+	out_be32(&FIFO(port)->tximr, MPC512x_PSC_FIFO_ALARM);
+	out_be32(&FIFO(port)->rximr, MPC512x_PSC_FIFO_ALARM);
+
+	out_8(&psc->command, MPC52xx_PSC_TX_ENABLE);
+	out_8(&psc->command, MPC52xx_PSC_RX_ENABLE);
+
+	return 0;
+}
+
+static void mpc512x_uart_shutdown(struct uart_port *port)
+{
+	struct mpc52xx_psc __iomem *psc = PSC(port);
+
+	/* Shut down the port.  Leave TX active if on a console port */
+	out_8(&psc->command, MPC52xx_PSC_RST_RX);
+	if (!uart_console(port))
+		out_8(&psc->command, MPC52xx_PSC_RST_TX);
+
+	out_be32(&FIFO(port)->tximr, 0);
+	out_be32(&FIFO(port)->rximr, 0);
+
+	/* Release interrupt */
+	free_irq(port->irq, port);
+}
+
+static void
+mpc512x_uart_set_termios(struct uart_port *port, struct ktermios *new,
+			 struct ktermios *old)
+{
+	struct mpc52xx_psc __iomem *psc = PSC(port);
+	unsigned long flags;
+	unsigned char mr1, mr2;
+	unsigned short ctr;
+	unsigned int j, baud, quot;
+	struct mpc512x_psc_fifo *fifo = FIFO(port);
+
+	/* Prepare what we're gonna write */
+	mr1 = 0;
+
+	switch (new->c_cflag & CSIZE) {
+	case CS5:
+		mr1 |= MPC52xx_PSC_MODE_5_BITS;
+		break;
+	case CS6:
+		mr1 |= MPC52xx_PSC_MODE_6_BITS;
+		break;
+	case CS7:
+		mr1 |= MPC52xx_PSC_MODE_7_BITS;
+		break;
+	case CS8:
+	default:
+		mr1 |= MPC52xx_PSC_MODE_8_BITS;
+	}
+
+	if (new->c_cflag & PARENB) {
+		mr1 |= (new->c_cflag & PARODD) ?
+		    MPC52xx_PSC_MODE_PARODD : MPC52xx_PSC_MODE_PAREVEN;
+	} else
+		mr1 |= MPC52xx_PSC_MODE_PARNONE;
+
+	mr2 = 0;
+
+	if (new->c_cflag & CSTOPB)
+		mr2 |= MPC52xx_PSC_MODE_TWO_STOP;
+	else
+		mr2 |= ((new->c_cflag & CSIZE) == CS5) ?
+		    MPC52xx_PSC_MODE_ONE_STOP_5_BITS :
+		    MPC52xx_PSC_MODE_ONE_STOP;
+
+	baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16);
+	quot = uart_get_divisor(port, baud);
+	ctr = quot & 0xffff;
+
+	/* Get the lock */
+	spin_lock_irqsave(&port->lock, flags);
+
+	/* Update the per-port timeout */
+	uart_update_timeout(port, new->c_cflag, baud);
+
+	/* Do our best to flush TX & RX, so we don't loose anything */
+	/* But we don't wait indefinitly ! */
+	j = 5000000;		/* Maximum wait */
+	/* FIXME Can't receive chars since set_termios might be called at early
+	 * boot for the console, all stuff is not yet ready to receive at that
+	 * time and that just makes the kernel oops */
+	/* while (j-- && mpc512x_uart_int_rx_chars(port)); */
+	while (!(in_be32(&fifo->txsr) & MPC512x_PSC_FIFO_EMPTY) && --j)
+		udelay(1);
+
+	if (!j)
+		printk(KERN_ERR "mpc512x_uart.c: "
+		       "Unable to flush RX & TX fifos in-time in set_termios."
+		       "Some chars may have been lost.\n");
+
+	/* Reset the TX & RX */
+	out_8(&psc->command, MPC52xx_PSC_RST_RX);
+	out_8(&psc->command, MPC52xx_PSC_RST_TX);
+
+	/* Send new mode settings */
+	out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1);
+	out_8(&psc->mode, mr1);
+	out_8(&psc->mode, mr2);
+	out_8(&psc->ctur, ctr >> 8);
+	out_8(&psc->ctlr, ctr & 0xff);
+
+	/* Reenable TX & RX */
+	out_8(&psc->command, MPC52xx_PSC_TX_ENABLE);
+	out_8(&psc->command, MPC52xx_PSC_RX_ENABLE);
+
+	/* We're all set, release the lock */
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static const char *mpc512x_uart_type(struct uart_port *port)
+{
+	return port->type == PORT_MPC52xx ? "MPC52xx PSC" : NULL;
+}
+
+static void mpc512x_uart_release_port(struct uart_port *port)
+{
+	/* remapped by us ? */
+	if (port->flags & UPF_IOREMAP) {
+		iounmap(port->membase);
+		port->membase = NULL;
+	}
+
+	release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc));
+}
+
+static int mpc512x_uart_request_port(struct uart_port *port)
+{
+	int err;
+
+	if (port->flags & UPF_IOREMAP)	/* Need to remap ? */
+		port->membase = ioremap(port->mapbase,
+					sizeof(struct mpc52xx_psc));
+
+	if (!port->membase)
+		return -EINVAL;
+
+	err = request_mem_region(port->mapbase, sizeof(struct mpc52xx_psc),
+				 "mpc512x_psc_uart") != NULL ? 0 : -EBUSY;
+
+	if (err && (port->flags & UPF_IOREMAP)) {
+		iounmap(port->membase);
+		port->membase = NULL;
+	}
+
+	return err;
+}
+
+static void mpc512x_uart_config_port(struct uart_port *port, int flags)
+{
+	if ((flags & UART_CONFIG_TYPE) &&
+	    (mpc512x_uart_request_port(port) == 0))
+		port->type = PORT_MPC52xx;
+}
+
+static int
+mpc512x_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+	if (ser->type != PORT_UNKNOWN && ser->type != PORT_MPC52xx)
+		return -EINVAL;
+
+	if ((ser->irq != port->irq) ||
+	    (ser->io_type != SERIAL_IO_MEM) ||
+	    (ser->baud_base != port->uartclk) ||
+	    (ser->iomem_base != (void *)port->mapbase) || (ser->hub6 != 0))
+		return -EINVAL;
+
+	return 0;
+}
+
+static struct uart_ops mpc512x_uart_ops = {
+	.tx_empty = mpc512x_uart_tx_empty,
+	.set_mctrl = mpc512x_uart_set_mctrl,
+	.get_mctrl = mpc512x_uart_get_mctrl,
+	.stop_tx = mpc512x_uart_stop_tx,
+	.start_tx = mpc512x_uart_start_tx,
+	.send_xchar = mpc512x_uart_send_xchar,
+	.stop_rx = mpc512x_uart_stop_rx,
+	.enable_ms = mpc512x_uart_enable_ms,
+	.break_ctl = mpc512x_uart_break_ctl,
+	.startup = mpc512x_uart_startup,
+	.shutdown = mpc512x_uart_shutdown,
+	.set_termios = mpc512x_uart_set_termios,
+/*	.pm		= mpc512x_uart_pm,		Not supported yet */
+/*	.set_wake	= mpc512x_uart_set_wake,	Not supported yet */
+	.type = mpc512x_uart_type,
+	.release_port = mpc512x_uart_release_port,
+	.request_port = mpc512x_uart_request_port,
+	.config_port = mpc512x_uart_config_port,
+	.verify_port = mpc512x_uart_verify_port
+};
+
+/* ======================================================================== */
+/* Interrupt handling                                                       */
+/* ======================================================================== */
+
+static inline int mpc512x_uart_int_rx_chars(struct uart_port *port)
+{
+	struct tty_struct *tty = port->info->tty;
+	unsigned char ch, flag;
+	unsigned short status;
+	unsigned long fifostatus;
+	struct mpc52xx_psc __iomem *psc = PSC(port);
+	struct mpc512x_psc_fifo __iomem *fifo = FIFO(port);
+
+	/* While we can read, do so ! */
+	while (1) {
+		fifostatus = in_be32(&fifo->rxsr);
+
+		if (fifostatus & MPC512x_PSC_FIFO_EMPTY)
+			break;
+
+		status = in_be16(&psc->mpc52xx_psc_status);
+
+		/* Get the char */
+		ch = in_8(&fifo->rxdata_8);
+
+		/* Handle sysreq char */
+#ifdef SUPPORT_SYSRQ
+		if (uart_handle_sysrq_char(port, ch)) {
+			port->sysrq = 0;
+			continue;
+		}
+#endif
+
+		/* Store it */
+
+		flag = TTY_NORMAL;
+		port->icount.rx++;
+
+		if (status & (MPC52xx_PSC_SR_PE |
+			      MPC52xx_PSC_SR_FE | MPC52xx_PSC_SR_RB)) {
+
+			if (status & MPC52xx_PSC_SR_RB) {
+				flag = TTY_BREAK;
+				uart_handle_break(port);
+			} else if (status & MPC52xx_PSC_SR_PE)
+				flag = TTY_PARITY;
+			else if (status & MPC52xx_PSC_SR_FE)
+				flag = TTY_FRAME;
+
+			/* Clear error condition */
+			out_8(&PSC(port)->command, MPC52xx_PSC_RST_ERR_STAT);
+
+		}
+		tty_insert_flip_char(tty, ch, flag);
+		if (status & MPC52xx_PSC_SR_OE) {
+			/*
+			 * Overrun is special, since it's
+			 * reported immediately, and doesn't
+			 * affect the current character
+			 */
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
+		}
+	}
+
+	tty_flip_buffer_push(tty);
+
+	fifostatus = in_be32(&fifo->rxsr);
+	return !(fifostatus & MPC512x_PSC_FIFO_EMPTY);
+}
+
+static inline int mpc512x_uart_int_tx_chars(struct uart_port *port)
+{
+	struct circ_buf *xmit = &port->info->xmit;
+	struct mpc512x_psc_fifo *fifo = FIFO(port);
+
+	/* Process out of band chars */
+	if (port->x_char) {
+		out_8(&fifo->txdata_8, port->x_char);
+		port->icount.tx++;
+		port->x_char = 0;
+		return 1;
+	}
+
+	/* Nothing to do ? */
+	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
+		mpc512x_uart_stop_tx(port);
+		return 0;
+	}
+
+	/* Send chars */
+	while (!(in_be32(&fifo->txsr) & MPC512x_PSC_FIFO_FULL)) {
+		out_8(&fifo->txdata_8, xmit->buf[xmit->tail]);
+		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+		port->icount.tx++;
+		if (uart_circ_empty(xmit))
+			break;
+	}
+
+	/* Wake up */
+	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+		uart_write_wakeup(port);
+
+	/* Maybe we're done after all */
+	if (uart_circ_empty(xmit)) {
+		mpc512x_uart_stop_tx(port);
+		return 0;
+	}
+
+	return 1;
+}
+
+static irqreturn_t mpc512x_uart_int(int irq, void *dev_id)
+{
+	struct uart_port *port = dev_id;
+	unsigned long pass = ISR_PASS_LIMIT;
+	unsigned int keepgoing;
+	unsigned long rx_fifo_status;
+	unsigned long tx_fifo_status;
+
+	spin_lock(&port->lock);
+
+	/* While we have stuff to do, we continue */
+	do {
+		/* If we don't find anything to do, we stop */
+		keepgoing = 0;
+
+		/* clear any pending interrupts */
+		out_be32(&FIFO(port)->rxisr, in_be32(&FIFO(port)->rxisr));
+
+		rx_fifo_status = in_be32(&FIFO(port)->rxsr);
+		out_be32(&FIFO(port)->rxisr, rx_fifo_status);
+		rx_fifo_status &= in_be32(&FIFO(port)->rximr);
+
+		if (rx_fifo_status & MPC512x_PSC_FIFO_ALARM)
+			keepgoing |= mpc512x_uart_int_rx_chars(port);
+
+		/* clear any pending interrupts */
+		out_be32(&FIFO(port)->txisr, in_be32(&FIFO(port)->txisr));
+
+		tx_fifo_status = in_be32(&FIFO(port)->txsr);
+		out_be32(&FIFO(port)->txisr, tx_fifo_status);
+		tx_fifo_status &= in_be32(&FIFO(port)->tximr);
+
+		if (tx_fifo_status & MPC512x_PSC_FIFO_ALARM)
+			keepgoing |= mpc512x_uart_int_tx_chars(port);
+
+		/* Limit number of iteration */
+		if (!(--pass))
+			keepgoing = 0;
+
+	} while (keepgoing);
+
+	spin_unlock(&port->lock);
+
+	return IRQ_HANDLED;
+}
+
+/* ======================================================================== */
+/* Console ( if applicable )                                                */
+/* ======================================================================== */
+
+#ifdef CONFIG_SERIAL_MPC512x_CONSOLE
+
+static void __init
+mpc512x_console_get_options(struct uart_port *port,
+			    int *baud, int *parity, int *bits, int *flow)
+{
+	struct mpc52xx_psc __iomem *psc = PSC(port);
+	unsigned char mr1;
+
+	pr_debug("mpc512x_console_get_options(port=%p)\n", port);
+
+	/* Read the mode registers */
+	out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1);
+	mr1 = in_8(&psc->mode);
+
+	/* CT{U,L}R are write-only ! */
+	*baud = 115200;
+	/* Parse them */
+	switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) {
+	case MPC52xx_PSC_MODE_5_BITS:
+		*bits = 5;
+		break;
+	case MPC52xx_PSC_MODE_6_BITS:
+		*bits = 6;
+		break;
+	case MPC52xx_PSC_MODE_7_BITS:
+		*bits = 7;
+		break;
+	case MPC52xx_PSC_MODE_8_BITS:
+	default:
+		*bits = 8;
+	}
+
+	if (mr1 & MPC52xx_PSC_MODE_PARNONE)
+		*parity = 'n';
+	else
+		*parity = mr1 & MPC52xx_PSC_MODE_PARODD ? 'o' : 'e';
+}
+
+static void
+mpc512x_console_write(struct console *co, const char *s, unsigned int count)
+{
+	struct uart_port *port = &mpc512x_uart_ports[co->index];
+	unsigned int i, j;
+	unsigned long rx_fifo_imr, tx_fifo_imr;
+
+	/* Disable interrupts */
+	tx_fifo_imr = in_be32(&FIFO(port)->tximr);
+	out_be32(&FIFO(port)->tximr, 0);
+	rx_fifo_imr = in_be32(&FIFO(port)->rximr);
+	out_be32(&FIFO(port)->rximr, 0);
+
+	/* Wait the TX buffer to be empty */
+	j = 5000000;		/* Maximum wait */
+	while (!(in_be32(&FIFO(port)->txsr) & MPC512x_PSC_FIFO_EMPTY) && --j)
+		udelay(1);
+	/* Write all the chars */
+	for (i = 0; i < count; i++, s++) {
+		/* Line return handling */
+		if (*s == '\n')
+			out_8(&FIFO(port)->txdata_8, '\r');
+
+		/* Send the char */
+		out_8(&FIFO(port)->txdata_8, *s);
+
+		/* Wait the TX buffer to be empty */
+		j = 20000;	/* Maximum wait */
+		while (!(in_be32(&FIFO(port)->txsr) & MPC512x_PSC_FIFO_EMPTY)
+		       && --j)
+			udelay(1);
+	}
+
+	/* Restore interrupt state */
+	out_be32(&FIFO(port)->tximr, tx_fifo_imr);
+	out_be32(&FIFO(port)->rximr, rx_fifo_imr);
+}
+
+static int __init mpc512x_console_setup(struct console *co, char *options)
+{
+	struct uart_port *port = &mpc512x_uart_ports[co->index];
+	struct device_node *np = mpc512x_uart_nodes[co->index];
+	struct resource res;
+
+	int baud = 115200;
+	int bits = 8;
+	int parity = 'n';
+	int flow = 'n';
+
+	pr_debug("mpc512x_console_setup co=%p, co->index=%i, options=%s\n",
+		 co, co->index, options);
+
+	if ((co->index < 0) || (co->index > MPC52xx_PSC_MAXNUM)) {
+		pr_debug("PSC%x out of range\n", co->index);
+		return -EINVAL;
+	}
+
+	if (!np) {
+		pr_debug("PSC%x not found in device tree\n", co->index);
+		return -EINVAL;
+	}
+
+	pr_debug("Console on ttyPSC%x is %s\n",
+		 co->index, mpc512x_uart_nodes[co->index]->full_name);
+
+	/* Fetch register locations */
+	if (of_address_to_resource(np, 0, &res)) {
+		pr_debug("Could not get resources for PSC%x\n", co->index);
+		return -EINVAL;
+	}
+
+	/* Basic port init. Needed since we use some uart_??? func before
+	 * real init for early access */
+	spin_lock_init(&port->lock);
+	port->uartclk = getuartclk(np);
+	port->ops = &mpc512x_uart_ops;
+	port->mapbase = res.start;
+	port->membase = ioremap(res.start, sizeof(struct mpc52xx_psc));
+	port->irq = irq_of_parse_and_map(np, 0);
+
+	if (port->membase == NULL)
+		return -EINVAL;
+
+	pr_debug("mpc52xx-psc uart at %p, mapped to %p, irq=%x, freq=%i\n",
+		 (void *)port->mapbase, port->membase, port->irq,
+		 port->uartclk);
+
+	/* Setup the port parameters accoding to options */
+	if (options)
+		uart_parse_options(options, &baud, &parity, &bits, &flow);
+	else
+		mpc512x_console_get_options(port, &baud, &parity, &bits, &flow);
+
+	pr_debug("Setting console parameters: %i %i%c1 flow=%c\n",
+		 baud, bits, parity, flow);
+
+	return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct uart_driver mpc512x_uart_driver;
+
+static struct console mpc512x_console = {
+	.name = "ttyPSC",
+	.write = mpc512x_console_write,
+	.device = uart_console_device,
+	.setup = mpc512x_console_setup,
+	.flags = CON_PRINTBUFFER,
+	.index = -1,
+	.data = &mpc512x_uart_driver,
+};
+
+static int __init mpc512x_console_init(void)
+{
+	mpc512x_uart_of_enumerate();
+	register_console(&mpc512x_console);
+	return 0;
+}
+
+console_initcall(mpc512x_console_init);
+
+#define MPC52xx_PSC_CONSOLE &mpc512x_console
+#else
+#define MPC52xx_PSC_CONSOLE NULL
+#endif
+
+/* ======================================================================== */
+/* UART Driver                                                              */
+/* ======================================================================== */
+
+static struct uart_driver mpc512x_uart_driver = {
+	.owner = THIS_MODULE,
+	.driver_name = "mpc512x_psc_uart",
+	.dev_name = "ttyPSC",
+	.major = SERIAL_PSC_MAJOR,
+	.minor = SERIAL_PSC_MINOR,
+	.nr = MPC52xx_PSC_MAXNUM,
+	.cons = MPC52xx_PSC_CONSOLE,
+};
+
+/* ======================================================================== */
+/* OF Platform Driver                                                       */
+/* ======================================================================== */
+
+static int __devinit
+mpc512x_uart_of_probe(struct of_device *op, const struct of_device_id *match)
+{
+	int idx = -1;
+	struct uart_port *port = NULL;
+	struct resource res;
+	int ret;
+
+	dev_dbg(&op->dev, "mpc512x_uart_probe(op=%p, match=%p)\n", op, match);
+
+	/* Check validity & presence */
+	for (idx = 0; idx < MPC52xx_PSC_MAXNUM; idx++)
+		if (mpc512x_uart_nodes[idx] == op->node)
+			break;
+	if (idx >= MPC52xx_PSC_MAXNUM)
+		return -EINVAL;
+	pr_debug("Found %s assigned to ttyPSC%x\n",
+		 mpc512x_uart_nodes[idx]->full_name, idx);
+
+	/* Init the port structure */
+	port = &mpc512x_uart_ports[idx];
+
+	spin_lock_init(&port->lock);
+	port->uartclk = getuartclk(op->node);
+	port->fifosize = 512;
+	port->iotype = UPIO_MEM;
+	port->flags = UPF_BOOT_AUTOCONF |
+	    (uart_console(port) ? 0 : UPF_IOREMAP);
+	port->line = idx;
+	port->ops = &mpc512x_uart_ops;
+	port->dev = &op->dev;
+
+	/* Search for IRQ and mapbase */
+	if (of_address_to_resource(op->node, 0, &res))
+		return -EINVAL;
+
+	port->mapbase = res.start;
+	port->irq = irq_of_parse_and_map(op->node, 0);
+
+	dev_dbg(&op->dev, "mpc52xx-psc uart at %p, irq=%x, freq=%i\n",
+		(void *)port->mapbase, port->irq, port->uartclk);
+
+	if ((port->irq == NO_IRQ) || !port->mapbase) {
+		printk(KERN_ERR "Could not allocate resources for PSC\n");
+		return -EINVAL;
+	}
+
+	/* Add the port to the uart sub-system */
+	ret = uart_add_one_port(&mpc512x_uart_driver, port);
+	if (!ret)
+		dev_set_drvdata(&op->dev, (void *)port);
+
+	return ret;
+}
+
+static int mpc512x_uart_of_remove(struct of_device *op)
+{
+	struct uart_port *port = dev_get_drvdata(&op->dev);
+	dev_set_drvdata(&op->dev, NULL);
+
+	if (port) {
+		uart_remove_one_port(&mpc512x_uart_driver, port);
+		irq_dispose_mapping(port->irq);
+	}
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int mpc512x_uart_of_suspend(struct of_device *op, pm_message_t state)
+{
+	struct uart_port *port = (struct uart_port *)dev_get_drvdata(&op->dev);
+
+	if (port)
+		uart_suspend_port(&mpc512x_uart_driver, port);
+
+	return 0;
+}
+
+static int mpc512x_uart_of_resume(struct of_device *op)
+{
+	struct uart_port *port = (struct uart_port *)dev_get_drvdata(&op->dev);
+
+	if (port)
+		uart_resume_port(&mpc512x_uart_driver, port);
+
+	return 0;
+}
+#endif
+
+static void mpc512x_uart_of_assign(struct device_node *np, int idx)
+{
+	int free_idx = -1;
+	int i;
+
+	/* Find the first free node */
+	for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
+		if (mpc512x_uart_nodes[i] == NULL) {
+			free_idx = i;
+			break;
+		}
+	}
+
+	if ((idx < 0) || (idx >= MPC52xx_PSC_MAXNUM))
+		idx = free_idx;
+
+	if (idx < 0)
+		return;		/* No free slot; abort */
+
+	/* If the slot is already occupied, then swap slots */
+	if (mpc512x_uart_nodes[idx] && (free_idx != -1))
+		mpc512x_uart_nodes[free_idx] = mpc512x_uart_nodes[idx];
+	mpc512x_uart_nodes[idx] = np;
+}
+
+static void mpc512x_uart_of_enumerate(void)
+{
+	static int enum_done;
+	struct device_node *np;
+	const unsigned int *devno;
+	int i;
+
+	if (enum_done)
+		return;
+
+	for_each_node_by_type(np, "serial") {
+		if (!of_match_node(mpc512x_uart_of_match, np))
+			continue;
+
+		/* Is a particular device number requested? */
+		devno = of_get_property(np, "port-number", NULL);
+		mpc512x_uart_of_assign(of_node_get(np), devno ? *devno : -1);
+	}
+
+	enum_done = 1;
+
+	for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
+		if (mpc512x_uart_nodes[i])
+			pr_debug("%s assigned to ttyPSC%x\n",
+				 mpc512x_uart_nodes[i]->full_name, i);
+	}
+}
+
+MODULE_DEVICE_TABLE(of, mpc512x_uart_of_match);
+
+static struct of_platform_driver mpc512x_uart_of_driver = {
+	.owner = THIS_MODULE,
+	.name = "mpc52xx-psc-uart",
+	.match_table = mpc512x_uart_of_match,
+	.probe = mpc512x_uart_of_probe,
+	.remove = mpc512x_uart_of_remove,
+#ifdef CONFIG_PM
+	.suspend = mpc512x_uart_of_suspend,
+	.resume = mpc512x_uart_of_resume,
+#endif
+	.driver = {
+		   .name = "mpc52xx-psc-uart",
+		   },
+};
+
+/* ======================================================================== */
+/* Module                                                                   */
+/* ======================================================================== */
+
+static int __init mpc512x_uart_init(void)
+{
+	int ret;
+
+	printk(KERN_INFO "Serial: MPC512x PSC UART driver\n");
+
+	ret = uart_register_driver(&mpc512x_uart_driver);
+	if (ret) {
+		printk(KERN_ERR "%s: uart_register_driver failed (%i)\n",
+		       __FILE__, ret);
+		return ret;
+	}
+
+	mpc512x_uart_of_enumerate();
+
+	ret = of_register_platform_driver(&mpc512x_uart_of_driver);
+	if (ret) {
+		printk(KERN_ERR "%s: of_register_platform_driver failed (%i)\n",
+		       __FILE__, ret);
+		uart_unregister_driver(&mpc512x_uart_driver);
+		return ret;
+	}
+	return 0;
+}
+
+static void __exit mpc512x_uart_exit(void)
+{
+	of_unregister_platform_driver(&mpc512x_uart_of_driver);
+	uart_unregister_driver(&mpc512x_uart_driver);
+}
+
+module_init(mpc512x_uart_init);
+module_exit(mpc512x_uart_exit);
+
+MODULE_AUTHOR("John Rigby <jrigby@freescale.com>");
+MODULE_DESCRIPTION("Freescale MPC512x PSC UART");
+MODULE_LICENSE("GPL");
diff --git a/include/asm-powerpc/mpc52xx_psc.h b/include/asm-powerpc/mpc52xx_psc.h
index bea42b9..6841868 100644
--- a/include/asm-powerpc/mpc52xx_psc.h
+++ b/include/asm-powerpc/mpc52xx_psc.h
@@ -190,5 +190,52 @@ struct mpc52xx_psc_fifo {
 	u16		tflwfptr;	/* PSC + 0x9e */
 };
 
+#define MPC512x_PSC_FIFO_RESET_SLICE	0x80
+#define MPC512x_PSC_FIFO_ENABLE_SLICE	0x01
+
+#define MPC512x_PSC_FIFO_EMPTY		0x1
+#define MPC512x_PSC_FIFO_FULL		0x2
+#define MPC512x_PSC_FIFO_ALARM		0x4
+#define MPC512x_PSC_FIFO_URERR		0x8
+#define MPC512x_PSC_FIFO_ORERR		0x01
+#define MPC512x_PSC_FIFO_MEMERROR	0x02
+
+struct mpc512x_psc_fifo {
+	u32		reserved1[10];
+	u32		txcmd;		/* PSC + 0x80 */
+	u32		txalarm;	/* PSC + 0x84 */
+	u32		txsr;		/* PSC + 0x88 */
+	u32		txisr;		/* PSC + 0x8c */
+	u32		tximr;		/* PSC + 0x90 */
+	u32		txcnt;		/* PSC + 0x94 */
+	u32		txptr;		/* PSC + 0x98 */
+	u32		txsz;		/* PSC + 0x9c */
+	u32		reserved2[7];
+	union {
+		u8	txdata_8;
+		u16	txdata_16;
+		u32	txdata_32;
+	} txdata; 			/* PSC + 0xbc */
+#define txdata_8 txdata.txdata_8
+#define txdata_16 txdata.txdata_16
+#define txdata_32 txdata.txdata_32
+	u32		rxcmd;		/* PSC + 0xc0 */
+	u32		rxalarm;	/* PSC + 0xc4 */
+	u32		rxsr;		/* PSC + 0xc8 */
+	u32		rxisr;		/* PSC + 0xcc */
+	u32		rximr;		/* PSC + 0xd0 */
+	u32		rxcnt;		/* PSC + 0xd4 */
+	u32		rxptr;		/* PSC + 0xd8 */
+	u32		rxsz;		/* PSC + 0xdc */
+	u32		reserved3[7];
+	union {
+		u8	rxdata_8;
+		u16	rxdata_16;
+		u32	rxdata_32;
+	} rxdata; 			/* PSC + 0xfc */
+#define rxdata_8 rxdata.rxdata_8
+#define rxdata_16 rxdata.rxdata_16
+#define rxdata_32 rxdata.rxdata_32
+};
 
 #endif  /* __ASM_MPC52xx_PSC_H__ */
-- 
1.5.3.5.726.g41a7a

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 16:01     ` [PATCH 3/7] Basic Freescale MPC512x support John Rigby
  2008-01-08 16:01       ` [PATCH 4/7] Device tree for MPC5121 ADS John Rigby
@ 2008-01-08 17:19       ` Grant Likely
  2008-01-08 17:55         ` Scott Wood
  2008-01-08 17:40       ` [PATCH 3/7] Basic Freescale MPC512x support Olof Johansson
                         ` (2 subsequent siblings)
  4 siblings, 1 reply; 34+ messages in thread
From: Grant Likely @ 2008-01-08 17:19 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

Looks pretty good; major comment is that it should be multiplatform enabled.

Cheers,
g.

On 1/8/08, John Rigby <jrigby@freescale.com> wrote:
> 512x is very similar to 83xx and most
> of this is patterned after code from 83xx
>
> New platform:
>     changed:
>         arch/powerpc/Kconfig
>         arch/powerpc/platforms/Kconfig
>         arch/powerpc/platforms/Kconfig.cputype
>         arch/powerpc/platforms/Makefile
>     new:
>         arch/powerpc/platforms/512x/*
>
> Signed-off-by: John Rigby <jrigby@freescale.com>
> ---
>  arch/powerpc/Kconfig                      |    2 +-
>  arch/powerpc/platforms/512x/Kconfig       |   20 ++++++
>  arch/powerpc/platforms/512x/Makefile      |    4 +
>  arch/powerpc/platforms/512x/mpc5121_ads.c |   90 +++++++++++++++++++++++++++++
>  arch/powerpc/platforms/Kconfig            |    8 +++
>  arch/powerpc/platforms/Kconfig.cputype    |    6 +-
>  arch/powerpc/platforms/Makefile           |    1 +
>  7 files changed, 127 insertions(+), 4 deletions(-)
>  create mode 100644 arch/powerpc/platforms/512x/Kconfig
>  create mode 100644 arch/powerpc/platforms/512x/Makefile
>  create mode 100644 arch/powerpc/platforms/512x/mpc5121_ads.c
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 66a3d8c..81c3f05 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -470,7 +470,7 @@ config PCI
>         bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \
>                 || PPC_MPC52xx || (EMBEDDED && (PPC_PSERIES || PPC_ISERIES)) \
>                 || PPC_PS3
> -       default y if !40x && !CPM2 && !8xx && !PPC_83xx \
> +       default y if !40x && !CPM2 && !8xx && !PPC_512x && !PPC_83xx \
>                 && !PPC_85xx && !PPC_86xx
>         default PCI_PERMEDIA if !4xx && !CPM2 && !8xx
>         default PCI_QSPAN if !4xx && !CPM2 && 8xx
> diff --git a/arch/powerpc/platforms/512x/Kconfig b/arch/powerpc/platforms/512x/Kconfig
> new file mode 100644
> index 0000000..399d279
> --- /dev/null
> +++ b/arch/powerpc/platforms/512x/Kconfig
> @@ -0,0 +1,20 @@
> +menu "Platform support"
> +       depends on PPC_512x
> +
> +choice
> +       prompt "Machine Type"
> +       default MPC5121_ADS

You should drop this choice and make mpc512x support multiplatform instead.

You might also want to consider renaming platforms/52xx to
platforms/5xxx and putting the 512x boards there instead.

> +
> +config MPC5121_ADS
> +       bool "Freescale MPC5121E ADS"
> +       select DEFAULT_UIMAGE
> +       help
> +         This option enables support for the MPC5121E ADS board.

Make this depend on PPC_MULTIPLATFORM and PPC32

> +
> +endchoice
> +
> +config MPC5121
> +       bool
> +       default y if MPC5121_ADS

Drop the default and make the MPC5121_ADS select MPC5121.

Also I recommend change this to PPC_MPC5121 instead of MPC5121 (better
namespace)

> +
> +endmenu
> diff --git a/arch/powerpc/platforms/512x/Makefile b/arch/powerpc/platforms/512x/Makefile
> new file mode 100644
> index 0000000..232c89f
> --- /dev/null
> +++ b/arch/powerpc/platforms/512x/Makefile
> @@ -0,0 +1,4 @@
> +#
> +# Makefile for the Freescale PowerPC 512x linux kernel.
> +#
> +obj-$(CONFIG_MPC5121_ADS)      += mpc5121_ads.o
> diff --git a/arch/powerpc/platforms/512x/mpc5121_ads.c b/arch/powerpc/platforms/512x/mpc5121_ads.c
> new file mode 100644
> index 0000000..a860bf0
> --- /dev/null
> +++ b/arch/powerpc/platforms/512x/mpc5121_ads.c
> @@ -0,0 +1,90 @@
> +/*
> + * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
> + *
> + * Author: John Rigby, <jrigby@freescale.com>, Thur Mar 29 2007
> + *
> + * Description:
> + * MPC5121 ADS board setup
> + *
> + * This 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/stddef.h>
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/errno.h>
> +#include <linux/reboot.h>
> +#include <linux/kdev_t.h>
> +#include <linux/major.h>
> +#include <linux/console.h>
> +#include <linux/delay.h>
> +#include <linux/seq_file.h>
> +#include <linux/root_dev.h>
> +#include <linux/time.h>
> +#include <linux/io.h>
> +#include <linux/irq.h>
> +
> +#include <asm/system.h>
> +#include <asm/atomic.h>
> +#include <asm/machdep.h>
> +#include <asm/ipic.h>
> +#include <asm/prom.h>
> +#include <asm/time.h>
> +#include <asm/of_platform.h>
> +
> +static void __init mpc5121_ads_setup_arch(void)
> +{
> +       if (ppc_md.progress)
> +               ppc_md.progress("mpc5121_ads_setup_arch()", 0);
> +
> +       printk(KERN_INFO "MPC5121 ADS board from Freescale Semiconductor\n");
> +}

This function doesn't do anything; just drop it

> +
> +static void __init mpc5121_ads_declare_of_platform_devices(void)
> +{
> +       /* Find every child of the SOC node and add it to of_platform */
> +       if (of_platform_bus_probe(NULL, NULL, NULL))
> +               printk(KERN_ERR __FILE__ ": "
> +                       "Error while probing of_platform bus\n");
> +}
> +
> +static void __init mpc5121_ads_init_IRQ(void)
> +{
> +       struct device_node *np;
> +
> +       np = of_find_node_by_type(NULL, "ipic");
> +       if (!np)
> +               return;
> +
> +       ipic_init(np, 0);
> +
> +       /*
> +        * Initialize the default interrupt mapping priorities,
> +        * in case the boot rom changed something on us.
> +        */
> +       ipic_set_default_priority();
> +}
> +
> +/*
> + * Called very early, MMU is off, device-tree isn't unflattened
> + */
> +static int __init mpc5121_ads_probe(void)
> +{
> +       unsigned long root = of_get_flat_dt_root();
> +
> +       return of_flat_dt_is_compatible(root, "MPC5121ADS");

Use "fsl,mpc5121ads" instead.

> +}
> +
> +define_machine(mpc5121_ads) {
> +       .name                   = "MPC5121 ADS",
> +       .probe                  = mpc5121_ads_probe,
> +       .setup_arch             = mpc5121_ads_setup_arch,
> +       .init                   = mpc5121_ads_declare_of_platform_devices,
> +       .init_IRQ               = mpc5121_ads_init_IRQ,
> +       .get_irq                = ipic_get_irq,
> +       .calibrate_decr         = generic_calibrate_decr,
> +};
> diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
> index ad9b1c0..1daf47f 100644
> --- a/arch/powerpc/platforms/Kconfig
> +++ b/arch/powerpc/platforms/Kconfig
> @@ -25,6 +25,13 @@ config PPC_83xx
>         select IPIC
>         select WANT_DEVICE_TREE
>
> +config PPC_512x
> +       bool "Freescale 512x"
> +       depends on 6xx
> +       select FSL_SOC
> +       select IPIC
> +       select WANT_DEVICE_TREE
> +

Drop this entry so that 512x can be multiplatform instead.

>  config PPC_86xx
>         bool "Freescale 86xx"
>         depends on 6xx
> @@ -41,6 +48,7 @@ config CLASSIC32
>  source "arch/powerpc/platforms/pseries/Kconfig"
>  source "arch/powerpc/platforms/iseries/Kconfig"
>  source "arch/powerpc/platforms/chrp/Kconfig"
> +source "arch/powerpc/platforms/512x/Kconfig"
>  source "arch/powerpc/platforms/52xx/Kconfig"
>  source "arch/powerpc/platforms/powermac/Kconfig"
>  source "arch/powerpc/platforms/prep/Kconfig"
> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
> index c3ee0b5..e21ffa5 100644
> --- a/arch/powerpc/platforms/Kconfig.cputype
> +++ b/arch/powerpc/platforms/Kconfig.cputype
> @@ -14,7 +14,7 @@ choice
>           There are five families of 32 bit PowerPC chips supported.
>           The most common ones are the desktop and server CPUs (601, 603,
>           604, 740, 750, 74xx) CPUs from Freescale and IBM, with their
> -         embedded 52xx/82xx/83xx/86xx counterparts.
> +         embedded 512x/52xx/82xx/83xx/86xx counterparts.
>           The other embeeded parts, namely 4xx, 8xx, e200 (55xx) and e500
>           (85xx) each form a family of their own that is not compatible
>           with the others.
> @@ -22,7 +22,7 @@ choice
>           If unsure, select 52xx/6xx/7xx/74xx/82xx/83xx/86xx.
>
>  config 6xx
> -       bool "52xx/6xx/7xx/74xx/82xx/83xx/86xx"
> +       bool "512x/52xx/6xx/7xx/74xx/82xx/83xx/86xx"

5xxx maybe?

>         select PPC_FPU
>
>  config PPC_85xx
> @@ -229,7 +229,7 @@ config NR_CPUS
>
>  config NOT_COHERENT_CACHE
>         bool
> -       depends on 4xx || 8xx || E200
> +       depends on 4xx || 8xx || E200 || PPC_512x
>         default y
>
>  config CHECK_CACHE_COHERENCY
> diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
> index 6d9079d..633a599 100644
> --- a/arch/powerpc/platforms/Makefile
> +++ b/arch/powerpc/platforms/Makefile
> @@ -11,6 +11,7 @@ endif
>  obj-$(CONFIG_PPC_CHRP)         += chrp/
>  obj-$(CONFIG_40x)              += 40x/
>  obj-$(CONFIG_44x)              += 44x/
> +obj-$(CONFIG_PPC_512x)         += 512x/
>  obj-$(CONFIG_PPC_MPC52xx)      += 52xx/
>  obj-$(CONFIG_PPC_8xx)          += 8xx/
>  obj-$(CONFIG_PPC_82xx)         += 82xx/
> --
> 1.5.3.5.726.g41a7a
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 4/7] Device tree for MPC5121 ADS
  2008-01-08 16:01       ` [PATCH 4/7] Device tree for MPC5121 ADS John Rigby
  2008-01-08 16:01         ` [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC John Rigby
@ 2008-01-08 17:25         ` Grant Likely
  2008-01-08 19:22         ` Scott Wood
  2008-01-10  2:18         ` David Gibson
  3 siblings, 0 replies; 34+ messages in thread
From: Grant Likely @ 2008-01-08 17:25 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

Comments below.

On 1/8/08, John Rigby <jrigby@freescale.com> wrote:
> Bare minimum tree containing only
> what is currently supported.
>
> Signed-off-by: John Rigby <jrigby@freescale.com>
> ---
>  arch/powerpc/boot/dts/mpc5121ads.dts |  102 ++++++++++++++++++++++++++++++++++
>  1 files changed, 102 insertions(+), 0 deletions(-)
>  create mode 100644 arch/powerpc/boot/dts/mpc5121ads.dts
>
> diff --git a/arch/powerpc/boot/dts/mpc5121ads.dts b/arch/powerpc/boot/dts/mpc5121ads.dts
> new file mode 100644
> index 0000000..26471ff
> --- /dev/null
> +++ b/arch/powerpc/boot/dts/mpc5121ads.dts
> @@ -0,0 +1,102 @@
> +/*
> + * MPC5121E MDS Device Tree Source
> + *
> + * Copyright 2007 Freescale Semiconductor Inc.
> + *
> + * 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.
> + */
> +
> +/ {
> +       model = "MPC5121ADS";
> +       compatible = "MPC5121ADS";

"fsl, mpc5121ads" (drop the caps and use the fsl, prefix)

> +       #address-cells = <1>;
> +       #size-cells = <1>;
> +
> +       cpus {
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +
> +               PowerPC,5121@0 {
> +                       device_type = "cpu";
> +                       reg = <0>;
> +                       d-cache-line-size = <20>;       // 32 bytes
> +                       i-cache-line-size = <20>;       // 32 bytes
> +                       d-cache-size = <8000>;          // L1, 32K
> +                       i-cache-size = <8000>;          // L1, 32K
> +                       ref-frequency = <3ef1480>;      // 66MHz ref clock
> +                       timebase-frequency = <2f34f60>; // 49.5MHz (396MHz/8) makes time tick correctly
> +                       bus-frequency = <bcd3d80>;      // 198MHz csb bus
> +                       clock-frequency = <179a7b00>;   // 396MHz ppc core ??
> +                       32-bit;
> +               };
> +       };
> +
> +       memory {
> +               device_type = "memory";
> +               reg = <00000000 10000000>;      // 256MB at 0
> +       };
> +
> +       cpld@82000000 {
> +               device_type = "board-control";
> +               reg = <82000000 8000>;
> +       };
> +
> +       soc5121@80000000 {

soc@80000000

"soc<cpu>@<addr>" is no longer recommended.

> +               #address-cells = <1>;
> +               #size-cells = <1>;
> +               #interrupt-cells = <2>;
> +               device_type = "soc";

- Drop device_type property
- add: compatible = "fsl,mpc5121-immr";

> +               ranges = <0 80000000 400000>;
> +               reg = <80000000 400000>;
> +               ref-frequency = <3ef1480>;      // 66MHz ref
> +               bus-frequency = <5e69ec0>;      // 99MHz ips ref
> +
> +               // IPIC
> +               // interrupts cell = <intr #, sense>
> +               // sense values match linux IORESOURCE_IRQ_* defines:
> +               // sense == 8: Level, low assertion
> +               // sense == 2: Edge, high-to-low change
> +               //
> +               ipic: pic@c00 {
> +                       interrupt-controller;
> +                       #address-cells = <0>;
> +                       #interrupt-cells = <2>;
> +                       reg = <c00 100>;
> +                       built-in;
> +                       device_type = "ipic";
> +               };
> +
> +               // 512x PSCs are not 52xx PSCs compatible
> +               // PSC3 serial port A aka ttyPSC0
> +               serial@11300 {
> +                       device_type = "serial";
> +                       compatible = "mpc512x-psc-uart";

Specify the *exact* version in compatible first.  You can add generic
forms after that if you like, but the first entry should always be
exact (as per the generic names recommended practice).  It should be:
compatible = "fsl,mpc5121-psc-uart".

Also, make sure all compatible properties have the 'fsl,' prefix.

> +                       port-number = <0>;  // Logical port assignment
> +                       cell-index = <3>;
> +                       reg = <11300 100>;
> +                       interrupts = <28 8>; // actually the fifo irq
> +                       interrupt-parent = < &ipic >;
> +               };
> +
> +               // PSC4 serial port B aka ttyPSC1
> +               serial@11400 {
> +                       device_type = "serial";
> +                       compatible = "mpc512x-psc-uart";
> +                       port-number = <1>;  // Logical port assignment

Drop port-number.  Aliases will be used instead.

> +                       cell-index = <4>;
> +                       reg = <11400 100>;
> +                       interrupts = <28 8>; // actually the fifo irq
> +                       interrupt-parent = < &ipic >;
> +               };
> +
> +               pscsfifo@11f00 {
> +                       compatible = "mpc512x-pscsfifo";
> +                       reg = <11f00 100>;
> +                       interrupts = <28 8>;
> +                       interrupt-parent = < &ipic >;
> +               };
> +       };
> +};
> --
> 1.5.3.5.726.g41a7a
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC
  2008-01-08 16:01         ` [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC John Rigby
  2008-01-08 16:01           ` [PATCH 6/7] Add mpc512x_find_ips_freq John Rigby
@ 2008-01-08 17:26           ` Grant Likely
  1 sibling, 0 replies; 34+ messages in thread
From: Grant Likely @ 2008-01-08 17:26 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

On 1/8/08, John Rigby <jrigby@freescale.com> wrote:
> This is in preparation for the addition of MPC512x
> PSC support.  The main difference in the 512x is
> in the fifo registers.
>
> Signed-off-by: John Rigby <jrigby@freescale.com>

Looks good, I'll pick this one up.

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
>  drivers/serial/mpc52xx_uart.c     |   10 ++++++----
>  include/asm-powerpc/mpc52xx_psc.h |    3 +++
>  include/asm-ppc/mpc52xx_psc.h     |    3 +++
>  3 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
> index ec36ad7..25a91c9 100644
> --- a/drivers/serial/mpc52xx_uart.c
> +++ b/drivers/serial/mpc52xx_uart.c
> @@ -111,6 +111,7 @@ static void mpc52xx_uart_of_enumerate(void);
>  #endif
>
>  #define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase))
> +#define FIFO(port) ((struct mpc52xx_psc_fifo __iomem *)(PSC(port)+1))
>
>
>  /* Forward declaration of the interruption handling routine */
> @@ -222,6 +223,7 @@ static int
>  mpc52xx_uart_startup(struct uart_port *port)
>  {
>         struct mpc52xx_psc __iomem *psc = PSC(port);
> +       struct mpc52xx_psc_fifo __iomem *fifo = FIFO(port);
>         int ret;
>
>         /* Request IRQ */
> @@ -238,10 +240,10 @@ mpc52xx_uart_startup(struct uart_port *port)
>
>         out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */
>
> -       out_8(&psc->rfcntl, 0x00);
> -       out_be16(&psc->rfalarm, 0x1ff);
> -       out_8(&psc->tfcntl, 0x07);
> -       out_be16(&psc->tfalarm, 0x80);
> +       out_8(&fifo->rfcntl, 0x00);
> +       out_be16(&fifo->rfalarm, 0x1ff);
> +       out_8(&fifo->tfcntl, 0x07);
> +       out_be16(&fifo->tfalarm, 0x80);
>
>         port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY;
>         out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
> diff --git a/include/asm-powerpc/mpc52xx_psc.h b/include/asm-powerpc/mpc52xx_psc.h
> index 26690d2..bea42b9 100644
> --- a/include/asm-powerpc/mpc52xx_psc.h
> +++ b/include/asm-powerpc/mpc52xx_psc.h
> @@ -153,6 +153,9 @@ struct mpc52xx_psc {
>         u8              reserved16[3];
>         u8              irfdr;          /* PSC + 0x54 */
>         u8              reserved17[3];
> +};
> +
> +struct mpc52xx_psc_fifo {
>         u16             rfnum;          /* PSC + 0x58 */
>         u16             reserved18;
>         u16             tfnum;          /* PSC + 0x5c */
> diff --git a/include/asm-ppc/mpc52xx_psc.h b/include/asm-ppc/mpc52xx_psc.h
> index c82b8d4..39fcd02 100644
> --- a/include/asm-ppc/mpc52xx_psc.h
> +++ b/include/asm-ppc/mpc52xx_psc.h
> @@ -159,6 +159,9 @@ struct mpc52xx_psc {
>         u8              reserved16[3];
>         u8              irfdr;          /* PSC + 0x54 */
>         u8              reserved17[3];
> +};
> +
> +struct mpc52xx_psc_fifo {
>         u16             rfnum;          /* PSC + 0x58 */
>         u16             reserved18;
>         u16             tfnum;          /* PSC + 0x5c */
> --
> 1.5.3.5.726.g41a7a
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 6/7] Add mpc512x_find_ips_freq
  2008-01-08 16:01           ` [PATCH 6/7] Add mpc512x_find_ips_freq John Rigby
  2008-01-08 16:01             ` [PATCH 7/7] Add MPC512x PSC serial driver John Rigby
@ 2008-01-08 17:27             ` Grant Likely
  2008-01-08 18:15             ` Arnd Bergmann
  2 siblings, 0 replies; 34+ messages in thread
From: Grant Likely @ 2008-01-08 17:27 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

Looks good to me; but I'd just merge this one with the earlier patch
that adds 5121 board support.

Cheers,
g.

On 1/8/08, John Rigby <jrigby@freescale.com> wrote:
> Added mpc512x_find_ips_freq needed by the following
> serial driver patch.  It is basically a renamed
> mpc512x_find_ipd_freq from 52xx.
>
> Signed-off-by: John Rigby <jrigby@freescale.com>
> ---
>  arch/powerpc/platforms/512x/mpc5121_ads.c |   28 ++++++++++++++++++++++++++++
>  include/asm-powerpc/mpc512x.h             |   22 ++++++++++++++++++++++
>  2 files changed, 50 insertions(+), 0 deletions(-)
>  create mode 100644 include/asm-powerpc/mpc512x.h
>
> diff --git a/arch/powerpc/platforms/512x/mpc5121_ads.c b/arch/powerpc/platforms/512x/mpc5121_ads.c
> index a860bf0..2f4cfee 100644
> --- a/arch/powerpc/platforms/512x/mpc5121_ads.c
> +++ b/arch/powerpc/platforms/512x/mpc5121_ads.c
> @@ -36,6 +36,34 @@
>  #include <asm/time.h>
>  #include <asm/of_platform.h>
>
> +/**
> + *     mpc512x_find_ips_freq - Find the IPB bus frequency for a device
> + *     @node:  device node
> + *
> + *     Returns IPS bus frequency, or 0 if the bus frequency cannot be found.
> + */
> +unsigned long
> +mpc512x_find_ips_freq(struct device_node *node)
> +{
> +       struct device_node *np;
> +       const unsigned int *p_ips_freq = NULL;
> +
> +       of_node_get(node);
> +       while (node) {
> +               p_ips_freq = of_get_property(node, "bus-frequency", NULL);
> +               if (p_ips_freq)
> +                       break;
> +
> +               np = of_get_parent(node);
> +               of_node_put(node);
> +               node = np;
> +       }
> +       if (node)
> +               of_node_put(node);
> +
> +       return p_ips_freq ? *p_ips_freq : 0;
> +}
> +
>  static void __init mpc5121_ads_setup_arch(void)
>  {
>         if (ppc_md.progress)
> diff --git a/include/asm-powerpc/mpc512x.h b/include/asm-powerpc/mpc512x.h
> new file mode 100644
> index 0000000..c48a165
> --- /dev/null
> +++ b/include/asm-powerpc/mpc512x.h
> @@ -0,0 +1,22 @@
> +/*
> + * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
> + *
> + * Author: John Rigby, <jrigby@freescale.com>, Friday Apr 13 2007
> + *
> + * Description:
> + * MPC5121 Prototypes and definitions
> + *
> + * This 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 __ASM_POWERPC_MPC512x_H__
> +#define __ASM_POWERPC_MPC512x_H__
> +
> +extern unsigned long mpc512x_find_ips_freq(struct device_node *node);
> +
> +#endif /* __ASM_POWERPC_MPC512x_H__ */
> +
> --
> 1.5.3.5.726.g41a7a
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 7/7] Add MPC512x PSC serial driver
  2008-01-08 16:01             ` [PATCH 7/7] Add MPC512x PSC serial driver John Rigby
@ 2008-01-08 17:32               ` Grant Likely
  2008-01-08 17:47                 ` John Rigby
  2008-01-09  3:16               ` Stephen Rothwell
  1 sibling, 1 reply; 34+ messages in thread
From: Grant Likely @ 2008-01-08 17:32 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

Exactly *how* different is the 5121 PSC from the 5200 PSC?  If it is
really different, then it makes sense to clone.  In fact; I'd
duplicate the mpc52xx_psc.h file also to avoid any crossover.

However, if the differences are manegable, I'd rather see a single
driver that can drive either type of PSC.  In fact, can you post a
diff between this driver and the original PSC driver?

Cheers,
g.

On 1/8/08, John Rigby <jrigby@freescale.com> wrote:
> mpc512x_uart.c is based on mpc52xx_uart.c with
>     names changed
>     arch/ppc support removed
>     512x psc fifo support added
>     shares mpc52xx_psc.h with 52xx driver
>
> Signed-off-by: John Rigby <jrigby@freescale.com>
> ---
>  drivers/serial/Kconfig            |   18 +
>  drivers/serial/Makefile           |    1 +
>  drivers/serial/mpc512x_uart.c     |  969 +++++++++++++++++++++++++++++++++++++
>  include/asm-powerpc/mpc52xx_psc.h |   47 ++
>  4 files changed, 1035 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/serial/mpc512x_uart.c
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index d7e1996..643b84a 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -1113,6 +1113,24 @@ config SERIAL_SGI_L1_CONSOLE
>                 controller serial port as your console (you want this!),
>                 say Y.  Otherwise, say N.
>
> +config SERIAL_MPC512x
> +       tristate "Freescale MPC512x family PSC serial support"
> +       depends on PPC_512x
> +       select SERIAL_CORE
> +       help
> +         This drivers support the MPC512x PSC serial ports. If you would
> +         like to use them, you must answer Y or M to this option. Not that
> +         for use as console, it must be included in kernel and not as a
> +         module.
> +
> +config SERIAL_MPC512x_CONSOLE
> +       bool "Console on a Freescale MPC512x family PSC serial port"
> +       depends on SERIAL_MPC512x=y
> +       select SERIAL_CORE_CONSOLE
> +       help
> +         Select this options if you'd like to use one of the PSC serial port
> +         of the Freescale MPC52xx family as a console.
> +
>  config SERIAL_MPC52xx
>         tristate "Freescale MPC52xx family PSC serial support"
>         depends on PPC_MPC52xx
> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> index af6377d..13e8176 100644
> --- a/drivers/serial/Makefile
> +++ b/drivers/serial/Makefile
> @@ -48,6 +48,7 @@ obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o
>  obj-$(CONFIG_SERIAL_SGI_L1_CONSOLE) += sn_console.o
>  obj-$(CONFIG_SERIAL_CPM) += cpm_uart/
>  obj-$(CONFIG_SERIAL_IMX) += imx.o
> +obj-$(CONFIG_SERIAL_MPC512x) += mpc512x_uart.o
>  obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
>  obj-$(CONFIG_SERIAL_ICOM) += icom.o
>  obj-$(CONFIG_SERIAL_M32R_SIO) += m32r_sio.o
> diff --git a/drivers/serial/mpc512x_uart.c b/drivers/serial/mpc512x_uart.c
> new file mode 100644
> index 0000000..e2ff0b8
> --- /dev/null
> +++ b/drivers/serial/mpc512x_uart.c
> @@ -0,0 +1,969 @@
> +/*
> + * Driver for the PSC of the Freescale MPC512x PSCs configured as UARTs.
> + *
> + * Copyright (C) 2007 Freescale Semiconductor Inc
> + * John Rigby <jrigby@freescale.com>
> + *
> + * Fork of mpc512x_uart.c:
> + *
> + *     Copyright (C) 2006 Secret Lab Technologies Ltd.
> + *                        Grant Likely <grant.likely@secretlab.ca>
> + *     Copyright (C) 2004-2006 Sylvain Munaut <tnt@246tNt.com>
> + *     Copyright (C) 2003 MontaVista, Software, Inc.
> + *                           Dale Farnsworth <dfarnsworth@mvista.com>.
> + *
> + * 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.
> + */
> +
> +/*
> + * The 512x PSCs are almost identical to those on 52xx.  The most notable
> + * difference is that the FIFOs have been separated out.  This file
> + * still uses the mpc52xx_psc.h which has had the fifo differences added.
> + *
> + * TODO (maybe) abstract out the fifo differences and merge this back
> + * into mpc512x_serial.c
> + */
> +
> +/* OF Platform device Usage :
> + *
> + * This driver is only used for PSCs configured in uart mode.  The device
> + * tree will have a node for each PSC in uart mode w/ device_type = "serial"
> + * and "mpc52xx-psc-uart" in the compatible string
> + *
> + * By default, PSC devices are enumerated in the order they are found.  However
> + * a particular PSC number can be forced by adding 'device_no = <port#>'
> + * to the device node.
> + *
> + * The driver init all necessary registers to place the PSC in uart mode without
> + * DCD. However, the pin multiplexing aren't changed and should be set either
> + * by the bootloader or in the platform init code.
> + */
> +
> +#undef DEBUG
> +
> +#include <linux/device.h>
> +#include <linux/module.h>
> +#include <linux/tty.h>
> +#include <linux/serial.h>
> +#include <linux/sysrq.h>
> +#include <linux/console.h>
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +
> +#include <asm/of_platform.h>
> +#include <asm/mpc52xx_psc.h>
> +#include <asm/mpc512x.h>
> +
> +#if defined(CONFIG_SERIAL_MPC512x_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
> +#define SUPPORT_SYSRQ
> +#endif
> +
> +#include <linux/serial_core.h>
> +
> +/* We've been assigned a range on the "Low-density serial ports" major */
> +#define SERIAL_PSC_MAJOR       204
> +#define SERIAL_PSC_MINOR       148
> +
> +#define ISR_PASS_LIMIT 256     /* Max number of iteration in the interrupt */
> +
> +static struct uart_port mpc512x_uart_ports[MPC52xx_PSC_MAXNUM];
> +
> +/* lookup table for matching device nodes to index numbers */
> +static struct device_node *mpc512x_uart_nodes[MPC52xx_PSC_MAXNUM];
> +
> +static void mpc512x_uart_of_enumerate(void);
> +
> +static unsigned long getuartclk(void *p)
> +{
> +       return mpc512x_find_ips_freq(p);
> +}
> +
> +#define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase))
> +#define FIFO(port) ((struct mpc512x_psc_fifo __iomem *)(PSC(port)+1))
> +
> +/* Forward declaration of the interruption handling routine */
> +static irqreturn_t mpc512x_uart_int(int irq, void *dev_id);
> +
> +/* Simple macro to test if a port is console or not. This one is taken
> + * for serial_core.c and maybe should be moved to serial_core.h ? */
> +#ifdef CONFIG_SERIAL_CORE_CONSOLE
> +#define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line)
> +#else
> +#define uart_console(port) (0)
> +#endif
> +
> +static struct of_device_id mpc512x_uart_of_match[] = {
> +       {.type = "serial", .compatible = "mpc512x-psc-uart",},
> +       {},
> +};
> +
> +/* ======================================================================== */
> +/* UART operations                                                          */
> +/* ======================================================================== */
> +
> +static unsigned int mpc512x_uart_tx_empty(struct uart_port *port)
> +{
> +       int status;
> +
> +       status = in_be32(&FIFO(port)->txsr);
> +       return (status & MPC512x_PSC_FIFO_EMPTY) ? TIOCSER_TEMT : 0;
> +}
> +
> +static void mpc512x_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
> +{
> +       /* Not implemented */
> +}
> +
> +static unsigned int mpc512x_uart_get_mctrl(struct uart_port *port)
> +{
> +       /* Not implemented */
> +       return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
> +}
> +
> +static void mpc512x_uart_stop_tx(struct uart_port *port)
> +{
> +       /* port->lock taken by caller */
> +       unsigned long tx_fifo_imr;
> +
> +       tx_fifo_imr = in_be32(&FIFO(port)->tximr);
> +       tx_fifo_imr &= ~MPC512x_PSC_FIFO_ALARM;
> +       out_be32(&FIFO(port)->tximr, tx_fifo_imr);
> +}
> +
> +static void mpc512x_uart_start_tx(struct uart_port *port)
> +{
> +       /* port->lock taken by caller */
> +       unsigned long tx_fifo_imr;
> +
> +       tx_fifo_imr = in_be32(&FIFO(port)->tximr);
> +       tx_fifo_imr |= MPC512x_PSC_FIFO_ALARM;
> +       out_be32(&FIFO(port)->tximr, tx_fifo_imr);
> +}
> +
> +static void mpc512x_uart_send_xchar(struct uart_port *port, char ch)
> +{
> +       unsigned long flags;
> +       spin_lock_irqsave(&port->lock, flags);
> +
> +       port->x_char = ch;
> +       if (ch) {
> +               /* Make sure tx interrupts are on */
> +               /* Truly necessary ??? They should be anyway */
> +               unsigned long tx_fifo_imr;
> +
> +               tx_fifo_imr = in_be32(&FIFO(port)->tximr);
> +               tx_fifo_imr |= MPC512x_PSC_FIFO_ALARM;
> +               out_be32(&FIFO(port)->tximr, tx_fifo_imr);
> +       }
> +
> +       spin_unlock_irqrestore(&port->lock, flags);
> +}
> +
> +static void mpc512x_uart_stop_rx(struct uart_port *port)
> +{
> +       /* port->lock taken by caller */
> +       unsigned long rx_fifo_imr;
> +
> +       rx_fifo_imr = in_be32(&FIFO(port)->rximr);
> +       rx_fifo_imr &= ~MPC512x_PSC_FIFO_ALARM;
> +       out_be32(&FIFO(port)->rximr, rx_fifo_imr);
> +}
> +
> +static void mpc512x_uart_enable_ms(struct uart_port *port)
> +{
> +       /* Not implemented */
> +}
> +
> +static void mpc512x_uart_break_ctl(struct uart_port *port, int ctl)
> +{
> +       unsigned long flags;
> +       spin_lock_irqsave(&port->lock, flags);
> +
> +       if (ctl == -1)
> +               out_8(&PSC(port)->command, MPC52xx_PSC_START_BRK);
> +       else
> +               out_8(&PSC(port)->command, MPC52xx_PSC_STOP_BRK);
> +
> +       spin_unlock_irqrestore(&port->lock, flags);
> +}
> +
> +static void mpc512x_uart_fifo_init(struct mpc52xx_psc *psc)
> +{
> +       struct mpc512x_psc_fifo *fifo;
> +
> +       /* fifo is right after the psc */
> +       fifo = (struct mpc512x_psc_fifo *)(psc + 1);
> +
> +       out_be32(&fifo->txcmd, MPC512x_PSC_FIFO_RESET_SLICE);
> +       out_be32(&fifo->txcmd, MPC512x_PSC_FIFO_ENABLE_SLICE);
> +       out_be32(&fifo->txalarm, 1);
> +       out_be32(&fifo->tximr, 0);
> +
> +       out_be32(&fifo->rxcmd, MPC512x_PSC_FIFO_RESET_SLICE);
> +       out_be32(&fifo->rxcmd, MPC512x_PSC_FIFO_ENABLE_SLICE);
> +       out_be32(&fifo->rxalarm, 1);
> +       out_be32(&fifo->rximr, 0);
> +}
> +
> +static int mpc512x_uart_startup(struct uart_port *port)
> +{
> +       struct mpc52xx_psc __iomem *psc = PSC(port);
> +       int ret;
> +
> +       /* Request IRQ */
> +       ret = request_irq(port->irq, mpc512x_uart_int,
> +                         IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
> +                         "mpc512x_psc_uart", port);
> +       if (ret)
> +               return ret;
> +
> +       /* Reset/activate the port, clear and enable interrupts */
> +       out_8(&psc->command, MPC52xx_PSC_RST_RX);
> +       out_8(&psc->command, MPC52xx_PSC_RST_TX);
> +
> +       out_be32(&psc->sicr, 0);        /* UART mode DCD ignored */
> +
> +       mpc512x_uart_fifo_init(psc);
> +
> +       out_be32(&FIFO(port)->tximr, MPC512x_PSC_FIFO_ALARM);
> +       out_be32(&FIFO(port)->rximr, MPC512x_PSC_FIFO_ALARM);
> +
> +       out_8(&psc->command, MPC52xx_PSC_TX_ENABLE);
> +       out_8(&psc->command, MPC52xx_PSC_RX_ENABLE);
> +
> +       return 0;
> +}
> +
> +static void mpc512x_uart_shutdown(struct uart_port *port)
> +{
> +       struct mpc52xx_psc __iomem *psc = PSC(port);
> +
> +       /* Shut down the port.  Leave TX active if on a console port */
> +       out_8(&psc->command, MPC52xx_PSC_RST_RX);
> +       if (!uart_console(port))
> +               out_8(&psc->command, MPC52xx_PSC_RST_TX);
> +
> +       out_be32(&FIFO(port)->tximr, 0);
> +       out_be32(&FIFO(port)->rximr, 0);
> +
> +       /* Release interrupt */
> +       free_irq(port->irq, port);
> +}
> +
> +static void
> +mpc512x_uart_set_termios(struct uart_port *port, struct ktermios *new,
> +                        struct ktermios *old)
> +{
> +       struct mpc52xx_psc __iomem *psc = PSC(port);
> +       unsigned long flags;
> +       unsigned char mr1, mr2;
> +       unsigned short ctr;
> +       unsigned int j, baud, quot;
> +       struct mpc512x_psc_fifo *fifo = FIFO(port);
> +
> +       /* Prepare what we're gonna write */
> +       mr1 = 0;
> +
> +       switch (new->c_cflag & CSIZE) {
> +       case CS5:
> +               mr1 |= MPC52xx_PSC_MODE_5_BITS;
> +               break;
> +       case CS6:
> +               mr1 |= MPC52xx_PSC_MODE_6_BITS;
> +               break;
> +       case CS7:
> +               mr1 |= MPC52xx_PSC_MODE_7_BITS;
> +               break;
> +       case CS8:
> +       default:
> +               mr1 |= MPC52xx_PSC_MODE_8_BITS;
> +       }
> +
> +       if (new->c_cflag & PARENB) {
> +               mr1 |= (new->c_cflag & PARODD) ?
> +                   MPC52xx_PSC_MODE_PARODD : MPC52xx_PSC_MODE_PAREVEN;
> +       } else
> +               mr1 |= MPC52xx_PSC_MODE_PARNONE;
> +
> +       mr2 = 0;
> +
> +       if (new->c_cflag & CSTOPB)
> +               mr2 |= MPC52xx_PSC_MODE_TWO_STOP;
> +       else
> +               mr2 |= ((new->c_cflag & CSIZE) == CS5) ?
> +                   MPC52xx_PSC_MODE_ONE_STOP_5_BITS :
> +                   MPC52xx_PSC_MODE_ONE_STOP;
> +
> +       baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16);
> +       quot = uart_get_divisor(port, baud);
> +       ctr = quot & 0xffff;
> +
> +       /* Get the lock */
> +       spin_lock_irqsave(&port->lock, flags);
> +
> +       /* Update the per-port timeout */
> +       uart_update_timeout(port, new->c_cflag, baud);
> +
> +       /* Do our best to flush TX & RX, so we don't loose anything */
> +       /* But we don't wait indefinitly ! */
> +       j = 5000000;            /* Maximum wait */
> +       /* FIXME Can't receive chars since set_termios might be called at early
> +        * boot for the console, all stuff is not yet ready to receive at that
> +        * time and that just makes the kernel oops */
> +       /* while (j-- && mpc512x_uart_int_rx_chars(port)); */
> +       while (!(in_be32(&fifo->txsr) & MPC512x_PSC_FIFO_EMPTY) && --j)
> +               udelay(1);
> +
> +       if (!j)
> +               printk(KERN_ERR "mpc512x_uart.c: "
> +                      "Unable to flush RX & TX fifos in-time in set_termios."
> +                      "Some chars may have been lost.\n");
> +
> +       /* Reset the TX & RX */
> +       out_8(&psc->command, MPC52xx_PSC_RST_RX);
> +       out_8(&psc->command, MPC52xx_PSC_RST_TX);
> +
> +       /* Send new mode settings */
> +       out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1);
> +       out_8(&psc->mode, mr1);
> +       out_8(&psc->mode, mr2);
> +       out_8(&psc->ctur, ctr >> 8);
> +       out_8(&psc->ctlr, ctr & 0xff);
> +
> +       /* Reenable TX & RX */
> +       out_8(&psc->command, MPC52xx_PSC_TX_ENABLE);
> +       out_8(&psc->command, MPC52xx_PSC_RX_ENABLE);
> +
> +       /* We're all set, release the lock */
> +       spin_unlock_irqrestore(&port->lock, flags);
> +}
> +
> +static const char *mpc512x_uart_type(struct uart_port *port)
> +{
> +       return port->type == PORT_MPC52xx ? "MPC52xx PSC" : NULL;
> +}
> +
> +static void mpc512x_uart_release_port(struct uart_port *port)
> +{
> +       /* remapped by us ? */
> +       if (port->flags & UPF_IOREMAP) {
> +               iounmap(port->membase);
> +               port->membase = NULL;
> +       }
> +
> +       release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc));
> +}
> +
> +static int mpc512x_uart_request_port(struct uart_port *port)
> +{
> +       int err;
> +
> +       if (port->flags & UPF_IOREMAP)  /* Need to remap ? */
> +               port->membase = ioremap(port->mapbase,
> +                                       sizeof(struct mpc52xx_psc));
> +
> +       if (!port->membase)
> +               return -EINVAL;
> +
> +       err = request_mem_region(port->mapbase, sizeof(struct mpc52xx_psc),
> +                                "mpc512x_psc_uart") != NULL ? 0 : -EBUSY;
> +
> +       if (err && (port->flags & UPF_IOREMAP)) {
> +               iounmap(port->membase);
> +               port->membase = NULL;
> +       }
> +
> +       return err;
> +}
> +
> +static void mpc512x_uart_config_port(struct uart_port *port, int flags)
> +{
> +       if ((flags & UART_CONFIG_TYPE) &&
> +           (mpc512x_uart_request_port(port) == 0))
> +               port->type = PORT_MPC52xx;
> +}
> +
> +static int
> +mpc512x_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
> +{
> +       if (ser->type != PORT_UNKNOWN && ser->type != PORT_MPC52xx)
> +               return -EINVAL;
> +
> +       if ((ser->irq != port->irq) ||
> +           (ser->io_type != SERIAL_IO_MEM) ||
> +           (ser->baud_base != port->uartclk) ||
> +           (ser->iomem_base != (void *)port->mapbase) || (ser->hub6 != 0))
> +               return -EINVAL;
> +
> +       return 0;
> +}
> +
> +static struct uart_ops mpc512x_uart_ops = {
> +       .tx_empty = mpc512x_uart_tx_empty,
> +       .set_mctrl = mpc512x_uart_set_mctrl,
> +       .get_mctrl = mpc512x_uart_get_mctrl,
> +       .stop_tx = mpc512x_uart_stop_tx,
> +       .start_tx = mpc512x_uart_start_tx,
> +       .send_xchar = mpc512x_uart_send_xchar,
> +       .stop_rx = mpc512x_uart_stop_rx,
> +       .enable_ms = mpc512x_uart_enable_ms,
> +       .break_ctl = mpc512x_uart_break_ctl,
> +       .startup = mpc512x_uart_startup,
> +       .shutdown = mpc512x_uart_shutdown,
> +       .set_termios = mpc512x_uart_set_termios,
> +/*     .pm             = mpc512x_uart_pm,              Not supported yet */
> +/*     .set_wake       = mpc512x_uart_set_wake,        Not supported yet */
> +       .type = mpc512x_uart_type,
> +       .release_port = mpc512x_uart_release_port,
> +       .request_port = mpc512x_uart_request_port,
> +       .config_port = mpc512x_uart_config_port,
> +       .verify_port = mpc512x_uart_verify_port
> +};
> +
> +/* ======================================================================== */
> +/* Interrupt handling                                                       */
> +/* ======================================================================== */
> +
> +static inline int mpc512x_uart_int_rx_chars(struct uart_port *port)
> +{
> +       struct tty_struct *tty = port->info->tty;
> +       unsigned char ch, flag;
> +       unsigned short status;
> +       unsigned long fifostatus;
> +       struct mpc52xx_psc __iomem *psc = PSC(port);
> +       struct mpc512x_psc_fifo __iomem *fifo = FIFO(port);
> +
> +       /* While we can read, do so ! */
> +       while (1) {
> +               fifostatus = in_be32(&fifo->rxsr);
> +
> +               if (fifostatus & MPC512x_PSC_FIFO_EMPTY)
> +                       break;
> +
> +               status = in_be16(&psc->mpc52xx_psc_status);
> +
> +               /* Get the char */
> +               ch = in_8(&fifo->rxdata_8);
> +
> +               /* Handle sysreq char */
> +#ifdef SUPPORT_SYSRQ
> +               if (uart_handle_sysrq_char(port, ch)) {
> +                       port->sysrq = 0;
> +                       continue;
> +               }
> +#endif
> +
> +               /* Store it */
> +
> +               flag = TTY_NORMAL;
> +               port->icount.rx++;
> +
> +               if (status & (MPC52xx_PSC_SR_PE |
> +                             MPC52xx_PSC_SR_FE | MPC52xx_PSC_SR_RB)) {
> +
> +                       if (status & MPC52xx_PSC_SR_RB) {
> +                               flag = TTY_BREAK;
> +                               uart_handle_break(port);
> +                       } else if (status & MPC52xx_PSC_SR_PE)
> +                               flag = TTY_PARITY;
> +                       else if (status & MPC52xx_PSC_SR_FE)
> +                               flag = TTY_FRAME;
> +
> +                       /* Clear error condition */
> +                       out_8(&PSC(port)->command, MPC52xx_PSC_RST_ERR_STAT);
> +
> +               }
> +               tty_insert_flip_char(tty, ch, flag);
> +               if (status & MPC52xx_PSC_SR_OE) {
> +                       /*
> +                        * Overrun is special, since it's
> +                        * reported immediately, and doesn't
> +                        * affect the current character
> +                        */
> +                       tty_insert_flip_char(tty, 0, TTY_OVERRUN);
> +               }
> +       }
> +
> +       tty_flip_buffer_push(tty);
> +
> +       fifostatus = in_be32(&fifo->rxsr);
> +       return !(fifostatus & MPC512x_PSC_FIFO_EMPTY);
> +}
> +
> +static inline int mpc512x_uart_int_tx_chars(struct uart_port *port)
> +{
> +       struct circ_buf *xmit = &port->info->xmit;
> +       struct mpc512x_psc_fifo *fifo = FIFO(port);
> +
> +       /* Process out of band chars */
> +       if (port->x_char) {
> +               out_8(&fifo->txdata_8, port->x_char);
> +               port->icount.tx++;
> +               port->x_char = 0;
> +               return 1;
> +       }
> +
> +       /* Nothing to do ? */
> +       if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
> +               mpc512x_uart_stop_tx(port);
> +               return 0;
> +       }
> +
> +       /* Send chars */
> +       while (!(in_be32(&fifo->txsr) & MPC512x_PSC_FIFO_FULL)) {
> +               out_8(&fifo->txdata_8, xmit->buf[xmit->tail]);
> +               xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
> +               port->icount.tx++;
> +               if (uart_circ_empty(xmit))
> +                       break;
> +       }
> +
> +       /* Wake up */
> +       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
> +               uart_write_wakeup(port);
> +
> +       /* Maybe we're done after all */
> +       if (uart_circ_empty(xmit)) {
> +               mpc512x_uart_stop_tx(port);
> +               return 0;
> +       }
> +
> +       return 1;
> +}
> +
> +static irqreturn_t mpc512x_uart_int(int irq, void *dev_id)
> +{
> +       struct uart_port *port = dev_id;
> +       unsigned long pass = ISR_PASS_LIMIT;
> +       unsigned int keepgoing;
> +       unsigned long rx_fifo_status;
> +       unsigned long tx_fifo_status;
> +
> +       spin_lock(&port->lock);
> +
> +       /* While we have stuff to do, we continue */
> +       do {
> +               /* If we don't find anything to do, we stop */
> +               keepgoing = 0;
> +
> +               /* clear any pending interrupts */
> +               out_be32(&FIFO(port)->rxisr, in_be32(&FIFO(port)->rxisr));
> +
> +               rx_fifo_status = in_be32(&FIFO(port)->rxsr);
> +               out_be32(&FIFO(port)->rxisr, rx_fifo_status);
> +               rx_fifo_status &= in_be32(&FIFO(port)->rximr);
> +
> +               if (rx_fifo_status & MPC512x_PSC_FIFO_ALARM)
> +                       keepgoing |= mpc512x_uart_int_rx_chars(port);
> +
> +               /* clear any pending interrupts */
> +               out_be32(&FIFO(port)->txisr, in_be32(&FIFO(port)->txisr));
> +
> +               tx_fifo_status = in_be32(&FIFO(port)->txsr);
> +               out_be32(&FIFO(port)->txisr, tx_fifo_status);
> +               tx_fifo_status &= in_be32(&FIFO(port)->tximr);
> +
> +               if (tx_fifo_status & MPC512x_PSC_FIFO_ALARM)
> +                       keepgoing |= mpc512x_uart_int_tx_chars(port);
> +
> +               /* Limit number of iteration */
> +               if (!(--pass))
> +                       keepgoing = 0;
> +
> +       } while (keepgoing);
> +
> +       spin_unlock(&port->lock);
> +
> +       return IRQ_HANDLED;
> +}
> +
> +/* ======================================================================== */
> +/* Console ( if applicable )                                                */
> +/* ======================================================================== */
> +
> +#ifdef CONFIG_SERIAL_MPC512x_CONSOLE
> +
> +static void __init
> +mpc512x_console_get_options(struct uart_port *port,
> +                           int *baud, int *parity, int *bits, int *flow)
> +{
> +       struct mpc52xx_psc __iomem *psc = PSC(port);
> +       unsigned char mr1;
> +
> +       pr_debug("mpc512x_console_get_options(port=%p)\n", port);
> +
> +       /* Read the mode registers */
> +       out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1);
> +       mr1 = in_8(&psc->mode);
> +
> +       /* CT{U,L}R are write-only ! */
> +       *baud = 115200;
> +       /* Parse them */
> +       switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) {
> +       case MPC52xx_PSC_MODE_5_BITS:
> +               *bits = 5;
> +               break;
> +       case MPC52xx_PSC_MODE_6_BITS:
> +               *bits = 6;
> +               break;
> +       case MPC52xx_PSC_MODE_7_BITS:
> +               *bits = 7;
> +               break;
> +       case MPC52xx_PSC_MODE_8_BITS:
> +       default:
> +               *bits = 8;
> +       }
> +
> +       if (mr1 & MPC52xx_PSC_MODE_PARNONE)
> +               *parity = 'n';
> +       else
> +               *parity = mr1 & MPC52xx_PSC_MODE_PARODD ? 'o' : 'e';
> +}
> +
> +static void
> +mpc512x_console_write(struct console *co, const char *s, unsigned int count)
> +{
> +       struct uart_port *port = &mpc512x_uart_ports[co->index];
> +       unsigned int i, j;
> +       unsigned long rx_fifo_imr, tx_fifo_imr;
> +
> +       /* Disable interrupts */
> +       tx_fifo_imr = in_be32(&FIFO(port)->tximr);
> +       out_be32(&FIFO(port)->tximr, 0);
> +       rx_fifo_imr = in_be32(&FIFO(port)->rximr);
> +       out_be32(&FIFO(port)->rximr, 0);
> +
> +       /* Wait the TX buffer to be empty */
> +       j = 5000000;            /* Maximum wait */
> +       while (!(in_be32(&FIFO(port)->txsr) & MPC512x_PSC_FIFO_EMPTY) && --j)
> +               udelay(1);
> +       /* Write all the chars */
> +       for (i = 0; i < count; i++, s++) {
> +               /* Line return handling */
> +               if (*s == '\n')
> +                       out_8(&FIFO(port)->txdata_8, '\r');
> +
> +               /* Send the char */
> +               out_8(&FIFO(port)->txdata_8, *s);
> +
> +               /* Wait the TX buffer to be empty */
> +               j = 20000;      /* Maximum wait */
> +               while (!(in_be32(&FIFO(port)->txsr) & MPC512x_PSC_FIFO_EMPTY)
> +                      && --j)
> +                       udelay(1);
> +       }
> +
> +       /* Restore interrupt state */
> +       out_be32(&FIFO(port)->tximr, tx_fifo_imr);
> +       out_be32(&FIFO(port)->rximr, rx_fifo_imr);
> +}
> +
> +static int __init mpc512x_console_setup(struct console *co, char *options)
> +{
> +       struct uart_port *port = &mpc512x_uart_ports[co->index];
> +       struct device_node *np = mpc512x_uart_nodes[co->index];
> +       struct resource res;
> +
> +       int baud = 115200;
> +       int bits = 8;
> +       int parity = 'n';
> +       int flow = 'n';
> +
> +       pr_debug("mpc512x_console_setup co=%p, co->index=%i, options=%s\n",
> +                co, co->index, options);
> +
> +       if ((co->index < 0) || (co->index > MPC52xx_PSC_MAXNUM)) {
> +               pr_debug("PSC%x out of range\n", co->index);
> +               return -EINVAL;
> +       }
> +
> +       if (!np) {
> +               pr_debug("PSC%x not found in device tree\n", co->index);
> +               return -EINVAL;
> +       }
> +
> +       pr_debug("Console on ttyPSC%x is %s\n",
> +                co->index, mpc512x_uart_nodes[co->index]->full_name);
> +
> +       /* Fetch register locations */
> +       if (of_address_to_resource(np, 0, &res)) {
> +               pr_debug("Could not get resources for PSC%x\n", co->index);
> +               return -EINVAL;
> +       }
> +
> +       /* Basic port init. Needed since we use some uart_??? func before
> +        * real init for early access */
> +       spin_lock_init(&port->lock);
> +       port->uartclk = getuartclk(np);
> +       port->ops = &mpc512x_uart_ops;
> +       port->mapbase = res.start;
> +       port->membase = ioremap(res.start, sizeof(struct mpc52xx_psc));
> +       port->irq = irq_of_parse_and_map(np, 0);
> +
> +       if (port->membase == NULL)
> +               return -EINVAL;
> +
> +       pr_debug("mpc52xx-psc uart at %p, mapped to %p, irq=%x, freq=%i\n",
> +                (void *)port->mapbase, port->membase, port->irq,
> +                port->uartclk);
> +
> +       /* Setup the port parameters accoding to options */
> +       if (options)
> +               uart_parse_options(options, &baud, &parity, &bits, &flow);
> +       else
> +               mpc512x_console_get_options(port, &baud, &parity, &bits, &flow);
> +
> +       pr_debug("Setting console parameters: %i %i%c1 flow=%c\n",
> +                baud, bits, parity, flow);
> +
> +       return uart_set_options(port, co, baud, parity, bits, flow);
> +}
> +
> +static struct uart_driver mpc512x_uart_driver;
> +
> +static struct console mpc512x_console = {
> +       .name = "ttyPSC",
> +       .write = mpc512x_console_write,
> +       .device = uart_console_device,
> +       .setup = mpc512x_console_setup,
> +       .flags = CON_PRINTBUFFER,
> +       .index = -1,
> +       .data = &mpc512x_uart_driver,
> +};
> +
> +static int __init mpc512x_console_init(void)
> +{
> +       mpc512x_uart_of_enumerate();
> +       register_console(&mpc512x_console);
> +       return 0;
> +}
> +
> +console_initcall(mpc512x_console_init);
> +
> +#define MPC52xx_PSC_CONSOLE &mpc512x_console
> +#else
> +#define MPC52xx_PSC_CONSOLE NULL
> +#endif
> +
> +/* ======================================================================== */
> +/* UART Driver                                                              */
> +/* ======================================================================== */
> +
> +static struct uart_driver mpc512x_uart_driver = {
> +       .owner = THIS_MODULE,
> +       .driver_name = "mpc512x_psc_uart",
> +       .dev_name = "ttyPSC",
> +       .major = SERIAL_PSC_MAJOR,
> +       .minor = SERIAL_PSC_MINOR,
> +       .nr = MPC52xx_PSC_MAXNUM,
> +       .cons = MPC52xx_PSC_CONSOLE,
> +};
> +
> +/* ======================================================================== */
> +/* OF Platform Driver                                                       */
> +/* ======================================================================== */
> +
> +static int __devinit
> +mpc512x_uart_of_probe(struct of_device *op, const struct of_device_id *match)
> +{
> +       int idx = -1;
> +       struct uart_port *port = NULL;
> +       struct resource res;
> +       int ret;
> +
> +       dev_dbg(&op->dev, "mpc512x_uart_probe(op=%p, match=%p)\n", op, match);
> +
> +       /* Check validity & presence */
> +       for (idx = 0; idx < MPC52xx_PSC_MAXNUM; idx++)
> +               if (mpc512x_uart_nodes[idx] == op->node)
> +                       break;
> +       if (idx >= MPC52xx_PSC_MAXNUM)
> +               return -EINVAL;
> +       pr_debug("Found %s assigned to ttyPSC%x\n",
> +                mpc512x_uart_nodes[idx]->full_name, idx);
> +
> +       /* Init the port structure */
> +       port = &mpc512x_uart_ports[idx];
> +
> +       spin_lock_init(&port->lock);
> +       port->uartclk = getuartclk(op->node);
> +       port->fifosize = 512;
> +       port->iotype = UPIO_MEM;
> +       port->flags = UPF_BOOT_AUTOCONF |
> +           (uart_console(port) ? 0 : UPF_IOREMAP);
> +       port->line = idx;
> +       port->ops = &mpc512x_uart_ops;
> +       port->dev = &op->dev;
> +
> +       /* Search for IRQ and mapbase */
> +       if (of_address_to_resource(op->node, 0, &res))
> +               return -EINVAL;
> +
> +       port->mapbase = res.start;
> +       port->irq = irq_of_parse_and_map(op->node, 0);
> +
> +       dev_dbg(&op->dev, "mpc52xx-psc uart at %p, irq=%x, freq=%i\n",
> +               (void *)port->mapbase, port->irq, port->uartclk);
> +
> +       if ((port->irq == NO_IRQ) || !port->mapbase) {
> +               printk(KERN_ERR "Could not allocate resources for PSC\n");
> +               return -EINVAL;
> +       }
> +
> +       /* Add the port to the uart sub-system */
> +       ret = uart_add_one_port(&mpc512x_uart_driver, port);
> +       if (!ret)
> +               dev_set_drvdata(&op->dev, (void *)port);
> +
> +       return ret;
> +}
> +
> +static int mpc512x_uart_of_remove(struct of_device *op)
> +{
> +       struct uart_port *port = dev_get_drvdata(&op->dev);
> +       dev_set_drvdata(&op->dev, NULL);
> +
> +       if (port) {
> +               uart_remove_one_port(&mpc512x_uart_driver, port);
> +               irq_dispose_mapping(port->irq);
> +       }
> +
> +       return 0;
> +}
> +
> +#ifdef CONFIG_PM
> +static int mpc512x_uart_of_suspend(struct of_device *op, pm_message_t state)
> +{
> +       struct uart_port *port = (struct uart_port *)dev_get_drvdata(&op->dev);
> +
> +       if (port)
> +               uart_suspend_port(&mpc512x_uart_driver, port);
> +
> +       return 0;
> +}
> +
> +static int mpc512x_uart_of_resume(struct of_device *op)
> +{
> +       struct uart_port *port = (struct uart_port *)dev_get_drvdata(&op->dev);
> +
> +       if (port)
> +               uart_resume_port(&mpc512x_uart_driver, port);
> +
> +       return 0;
> +}
> +#endif
> +
> +static void mpc512x_uart_of_assign(struct device_node *np, int idx)
> +{
> +       int free_idx = -1;
> +       int i;
> +
> +       /* Find the first free node */
> +       for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
> +               if (mpc512x_uart_nodes[i] == NULL) {
> +                       free_idx = i;
> +                       break;
> +               }
> +       }
> +
> +       if ((idx < 0) || (idx >= MPC52xx_PSC_MAXNUM))
> +               idx = free_idx;
> +
> +       if (idx < 0)
> +               return;         /* No free slot; abort */
> +
> +       /* If the slot is already occupied, then swap slots */
> +       if (mpc512x_uart_nodes[idx] && (free_idx != -1))
> +               mpc512x_uart_nodes[free_idx] = mpc512x_uart_nodes[idx];
> +       mpc512x_uart_nodes[idx] = np;
> +}
> +
> +static void mpc512x_uart_of_enumerate(void)
> +{
> +       static int enum_done;
> +       struct device_node *np;
> +       const unsigned int *devno;
> +       int i;
> +
> +       if (enum_done)
> +               return;
> +
> +       for_each_node_by_type(np, "serial") {
> +               if (!of_match_node(mpc512x_uart_of_match, np))
> +                       continue;
> +
> +               /* Is a particular device number requested? */
> +               devno = of_get_property(np, "port-number", NULL);
> +               mpc512x_uart_of_assign(of_node_get(np), devno ? *devno : -1);
> +       }
> +
> +       enum_done = 1;
> +
> +       for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
> +               if (mpc512x_uart_nodes[i])
> +                       pr_debug("%s assigned to ttyPSC%x\n",
> +                                mpc512x_uart_nodes[i]->full_name, i);
> +       }
> +}
> +
> +MODULE_DEVICE_TABLE(of, mpc512x_uart_of_match);
> +
> +static struct of_platform_driver mpc512x_uart_of_driver = {
> +       .owner = THIS_MODULE,
> +       .name = "mpc52xx-psc-uart",
> +       .match_table = mpc512x_uart_of_match,
> +       .probe = mpc512x_uart_of_probe,
> +       .remove = mpc512x_uart_of_remove,
> +#ifdef CONFIG_PM
> +       .suspend = mpc512x_uart_of_suspend,
> +       .resume = mpc512x_uart_of_resume,
> +#endif
> +       .driver = {
> +                  .name = "mpc52xx-psc-uart",
> +                  },
> +};
> +
> +/* ======================================================================== */
> +/* Module                                                                   */
> +/* ======================================================================== */
> +
> +static int __init mpc512x_uart_init(void)
> +{
> +       int ret;
> +
> +       printk(KERN_INFO "Serial: MPC512x PSC UART driver\n");
> +
> +       ret = uart_register_driver(&mpc512x_uart_driver);
> +       if (ret) {
> +               printk(KERN_ERR "%s: uart_register_driver failed (%i)\n",
> +                      __FILE__, ret);
> +               return ret;
> +       }
> +
> +       mpc512x_uart_of_enumerate();
> +
> +       ret = of_register_platform_driver(&mpc512x_uart_of_driver);
> +       if (ret) {
> +               printk(KERN_ERR "%s: of_register_platform_driver failed (%i)\n",
> +                      __FILE__, ret);
> +               uart_unregister_driver(&mpc512x_uart_driver);
> +               return ret;
> +       }
> +       return 0;
> +}
> +
> +static void __exit mpc512x_uart_exit(void)
> +{
> +       of_unregister_platform_driver(&mpc512x_uart_of_driver);
> +       uart_unregister_driver(&mpc512x_uart_driver);
> +}
> +
> +module_init(mpc512x_uart_init);
> +module_exit(mpc512x_uart_exit);
> +
> +MODULE_AUTHOR("John Rigby <jrigby@freescale.com>");
> +MODULE_DESCRIPTION("Freescale MPC512x PSC UART");
> +MODULE_LICENSE("GPL");
> diff --git a/include/asm-powerpc/mpc52xx_psc.h b/include/asm-powerpc/mpc52xx_psc.h
> index bea42b9..6841868 100644
> --- a/include/asm-powerpc/mpc52xx_psc.h
> +++ b/include/asm-powerpc/mpc52xx_psc.h
> @@ -190,5 +190,52 @@ struct mpc52xx_psc_fifo {
>         u16             tflwfptr;       /* PSC + 0x9e */
>  };
>
> +#define MPC512x_PSC_FIFO_RESET_SLICE   0x80
> +#define MPC512x_PSC_FIFO_ENABLE_SLICE  0x01
> +
> +#define MPC512x_PSC_FIFO_EMPTY         0x1
> +#define MPC512x_PSC_FIFO_FULL          0x2
> +#define MPC512x_PSC_FIFO_ALARM         0x4
> +#define MPC512x_PSC_FIFO_URERR         0x8
> +#define MPC512x_PSC_FIFO_ORERR         0x01
> +#define MPC512x_PSC_FIFO_MEMERROR      0x02
> +
> +struct mpc512x_psc_fifo {
> +       u32             reserved1[10];
> +       u32             txcmd;          /* PSC + 0x80 */
> +       u32             txalarm;        /* PSC + 0x84 */
> +       u32             txsr;           /* PSC + 0x88 */
> +       u32             txisr;          /* PSC + 0x8c */
> +       u32             tximr;          /* PSC + 0x90 */
> +       u32             txcnt;          /* PSC + 0x94 */
> +       u32             txptr;          /* PSC + 0x98 */
> +       u32             txsz;           /* PSC + 0x9c */
> +       u32             reserved2[7];
> +       union {
> +               u8      txdata_8;
> +               u16     txdata_16;
> +               u32     txdata_32;
> +       } txdata;                       /* PSC + 0xbc */
> +#define txdata_8 txdata.txdata_8
> +#define txdata_16 txdata.txdata_16
> +#define txdata_32 txdata.txdata_32
> +       u32             rxcmd;          /* PSC + 0xc0 */
> +       u32             rxalarm;        /* PSC + 0xc4 */
> +       u32             rxsr;           /* PSC + 0xc8 */
> +       u32             rxisr;          /* PSC + 0xcc */
> +       u32             rximr;          /* PSC + 0xd0 */
> +       u32             rxcnt;          /* PSC + 0xd4 */
> +       u32             rxptr;          /* PSC + 0xd8 */
> +       u32             rxsz;           /* PSC + 0xdc */
> +       u32             reserved3[7];
> +       union {
> +               u8      rxdata_8;
> +               u16     rxdata_16;
> +               u32     rxdata_32;
> +       } rxdata;                       /* PSC + 0xfc */
> +#define rxdata_8 rxdata.rxdata_8
> +#define rxdata_16 rxdata.rxdata_16
> +#define rxdata_32 rxdata.rxdata_32
> +};
>
>  #endif  /* __ASM_MPC52xx_PSC_H__ */
> --
> 1.5.3.5.726.g41a7a
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 16:01     ` [PATCH 3/7] Basic Freescale MPC512x support John Rigby
  2008-01-08 16:01       ` [PATCH 4/7] Device tree for MPC5121 ADS John Rigby
  2008-01-08 17:19       ` [PATCH 3/7] Basic Freescale MPC512x support Grant Likely
@ 2008-01-08 17:40       ` Olof Johansson
  2008-01-08 17:44         ` Jon Loeliger
                           ` (3 more replies)
  2008-01-08 18:07       ` Arnd Bergmann
  2008-01-09  2:36       ` Stephen Rothwell
  4 siblings, 4 replies; 34+ messages in thread
From: Olof Johansson @ 2008-01-08 17:40 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

Hi,


> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 66a3d8c..81c3f05 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -470,7 +470,7 @@ config PCI
>  	bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \
>  		|| PPC_MPC52xx || (EMBEDDED && (PPC_PSERIES || PPC_ISERIES)) \
>  		|| PPC_PS3
> -	default y if !40x && !CPM2 && !8xx && !PPC_83xx \
> +	default y if !40x && !CPM2 && !8xx && !PPC_512x && !PPC_83xx \
>  		&& !PPC_85xx && !PPC_86xx

This is getting out of control. Not a comment to this specific patch,
but it's getting silly.

Btw, why no PCI by default on this platform when it seemingly is default
on 5200? I thought they were fairly similar.

> diff --git a/arch/powerpc/platforms/512x/Kconfig b/arch/powerpc/platforms/512x/Kconfig
> new file mode 100644
> index 0000000..399d279
> --- /dev/null
> +++ b/arch/powerpc/platforms/512x/Kconfig
> @@ -0,0 +1,20 @@
> +menu "Platform support"
> +	depends on PPC_512x
> +
> +choice
> +	prompt "Machine Type"
> +	default MPC5121_ADS
> +
> +config MPC5121_ADS
> +	bool "Freescale MPC5121E ADS"
> +	select DEFAULT_UIMAGE
> +	help
> +	  This option enables support for the MPC5121E ADS board.
> +
> +endchoice

For new platforms it makes more sense to make it possible to build
multiplatform kernels instead of using 'choice'.

I know some embedded board guys prefer to build a custom kernel for just
their board (since it means extra revenue for them to spin a kernel
for every customer), but it's still convenient to be able to build
multiplatform kernels. Especially since there's some companies out there
with intent to make end-user products with this cpu.

> @@ -0,0 +1,90 @@
> +#include <asm/system.h>
> +#include <asm/atomic.h>
> +#include <asm/machdep.h>
> +#include <asm/ipic.h>
> +#include <asm/prom.h>
> +#include <asm/time.h>
> +#include <asm/of_platform.h>

Stephen will tell you to include linux/of_platform.h instead. :-)

> @@ -229,7 +229,7 @@ config NR_CPUS
>  
>  config NOT_COHERENT_CACHE
>  	bool
> -	depends on 4xx || 8xx || E200
> +	depends on 4xx || 8xx || E200 || PPC_512x
>  	default y

Why do you need this, when 5200 doesn't?


-Olof

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 17:40       ` [PATCH 3/7] Basic Freescale MPC512x support Olof Johansson
@ 2008-01-08 17:44         ` Jon Loeliger
  2008-01-08 18:01         ` John Rigby
                           ` (2 subsequent siblings)
  3 siblings, 0 replies; 34+ messages in thread
From: Jon Loeliger @ 2008-01-08 17:44 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, John Rigby

So, like, the other day Olof Johansson mumbled:
> 
> > @@ -0,0 +1,90 @@
> > +#include <asm/system.h>
> > +#include <asm/atomic.h>
> > +#include <asm/machdep.h>
> > +#include <asm/ipic.h>
> > +#include <asm/prom.h>
> > +#include <asm/time.h>
> > +#include <asm/of_platform.h>
> 
> Stephen will tell you to include linux/of_platform.h instead. :-)

Yeah, watch me outright NAK it too. :-)

jdl

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 7/7] Add MPC512x PSC serial driver
  2008-01-08 17:32               ` Grant Likely
@ 2008-01-08 17:47                 ` John Rigby
  2008-01-08 20:16                   ` Grant Likely
  0 siblings, 1 reply; 34+ messages in thread
From: John Rigby @ 2008-01-08 17:47 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev

Thanks for the quick feedback Grant.

Grant Likely wrote:
> Exactly *how* different is the 5121 PSC from the 5200 PSC?  If it is
> really different, then it makes sense to clone. 
The fifo handling has completely changed that is the main difference.
>  In fact; I'd
> duplicate the mpc52xx_psc.h file also to avoid any crossover.
>   
I agree.

> However, if the differences are manegable, I'd rather see a single
> driver that can drive either type of PSC.  In fact, can you post a
> diff between this driver and the original PSC driver?
>   
I simple diff will mostly show the removal of arch/ppc support so
won't be much help.  How about I do take a pass at a new version
that supports 52xx and 512x but only for arch/powerpc?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 17:19       ` [PATCH 3/7] Basic Freescale MPC512x support Grant Likely
@ 2008-01-08 17:55         ` Scott Wood
  2008-01-08 17:56           ` Grant Likely
  0 siblings, 1 reply; 34+ messages in thread
From: Scott Wood @ 2008-01-08 17:55 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, John Rigby

On Tue, Jan 08, 2008 at 10:19:20AM -0700, Grant Likely wrote:
> > +config MPC5121_ADS
> > +       bool "Freescale MPC5121E ADS"
> > +       select DEFAULT_UIMAGE
> > +       help
> > +         This option enables support for the MPC5121E ADS board.
> 
> Make this depend on PPC_MULTIPLATFORM and PPC32

I don't think PPC_MULTIPLATFORM is appropriate here... it seems to be
OF-specific.

-Scott

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 17:55         ` Scott Wood
@ 2008-01-08 17:56           ` Grant Likely
  2008-01-08 19:25             ` Scott Wood
  0 siblings, 1 reply; 34+ messages in thread
From: Grant Likely @ 2008-01-08 17:56 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, John Rigby

On 1/8/08, Scott Wood <scottwood@freescale.com> wrote:
> On Tue, Jan 08, 2008 at 10:19:20AM -0700, Grant Likely wrote:
> > > +config MPC5121_ADS
> > > +       bool "Freescale MPC5121E ADS"
> > > +       select DEFAULT_UIMAGE
> > > +       help
> > > +         This option enables support for the MPC5121E ADS board.
> >
> > Make this depend on PPC_MULTIPLATFORM and PPC32
>
> I don't think PPC_MULTIPLATFORM is appropriate here... it seems to be
> OF-specific.

52xx is multiplatform.  It works well on both OF and non-OF boards.

Cheers,
g.


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 17:40       ` [PATCH 3/7] Basic Freescale MPC512x support Olof Johansson
  2008-01-08 17:44         ` Jon Loeliger
@ 2008-01-08 18:01         ` John Rigby
  2008-01-08 18:13         ` Arnd Bergmann
  2008-01-08 18:16         ` John Rigby
  3 siblings, 0 replies; 34+ messages in thread
From: John Rigby @ 2008-01-08 18:01 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev

Olof Johansson wrote:
> Hi,
>
>
>   
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 66a3d8c..81c3f05 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -470,7 +470,7 @@ config PCI
>>  	bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \
>>  		|| PPC_MPC52xx || (EMBEDDED && (PPC_PSERIES || PPC_ISERIES)) \
>>  		|| PPC_PS3
>> -	default y if !40x && !CPM2 && !8xx && !PPC_83xx \
>> +	default y if !40x && !CPM2 && !8xx && !PPC_512x && !PPC_83xx \
>>  		&& !PPC_85xx && !PPC_86xx
>>     
>
> This is getting out of control. Not a comment to this specific patch,
> but it's getting silly.
>
> Btw, why no PCI by default on this platform when it seemingly is default
> on 5200? I thought they were fairly similar.
>   

PCI has issues in first silicon so I left that out.

Also contrary to popular rumor, 5121 is more like a 83xx that 52xx.
The PCI and USB are very similar to 83xx.


>   
>> diff --git a/arch/powerpc/platforms/512x/Kconfig b/arch/powerpc/platforms/512x/Kconfig
>> new file mode 100644
>> index 0000000..399d279
>> --- /dev/null
>> +++ b/arch/powerpc/platforms/512x/Kconfig
>> @@ -0,0 +1,20 @@
>> +menu "Platform support"
>> +	depends on PPC_512x
>> +
>> +choice
>> +	prompt "Machine Type"
>> +	default MPC5121_ADS
>> +
>> +config MPC5121_ADS
>> +	bool "Freescale MPC5121E ADS"
>> +	select DEFAULT_UIMAGE
>> +	help
>> +	  This option enables support for the MPC5121E ADS board.
>> +
>> +endchoice
>>     
>
> For new platforms it makes more sense to make it possible to build
> multiplatform kernels instead of using 'choice'.
>
> I know some embedded board guys prefer to build a custom kernel for just
> their board (since it means extra revenue for them to spin a kernel
> for every customer), but it's still convenient to be able to build
> multiplatform kernels. Especially since there's some companies out there
> with intent to make end-user products with this cpu.
>   
Grant made the same comment about multiplatform support.
I'll change this.
>   
>> @@ -0,0 +1,90 @@
>> +#include <asm/system.h>
>> +#include <asm/atomic.h>
>> +#include <asm/machdep.h>
>> +#include <asm/ipic.h>
>> +#include <asm/prom.h>
>> +#include <asm/time.h>
>> +#include <asm/of_platform.h>
>>     
>
> Stephen will tell you to include linux/of_platform.h instead. :-)
>   
Oops, this patch was originally done before the open firmware
unification.  I guess checkpatch.pl needs an update too.
>   
>> @@ -229,7 +229,7 @@ config NR_CPUS
>>  
>>  config NOT_COHERENT_CACHE
>>  	bool
>> -	depends on 4xx || 8xx || E200
>> +	depends on 4xx || 8xx || E200 || PPC_512x
>>  	default y
>>     
>
> Why do you need this, when 5200 doesn't?
>
>
> -Olof
>
>   

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 16:01     ` [PATCH 3/7] Basic Freescale MPC512x support John Rigby
                         ` (2 preceding siblings ...)
  2008-01-08 17:40       ` [PATCH 3/7] Basic Freescale MPC512x support Olof Johansson
@ 2008-01-08 18:07       ` Arnd Bergmann
  2008-01-08 18:25         ` John Rigby
  2008-01-09  2:36       ` Stephen Rothwell
  4 siblings, 1 reply; 34+ messages in thread
From: Arnd Bergmann @ 2008-01-08 18:07 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: John Rigby

On Tuesday 08 January 2008, John Rigby wrote:
> =A0obj-$(CONFIG_PPC_CHRP)=A0=A0=A0=A0=A0=A0=A0=A0=A0+=3D chrp/
> =A0obj-$(CONFIG_40x)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0+=3D 40x/
> =A0obj-$(CONFIG_44x)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0+=3D 44x/
> +obj-$(CONFIG_PPC_512x)=A0=A0=A0=A0=A0=A0=A0=A0=A0+=3D 512x/
> =A0obj-$(CONFIG_PPC_MPC52xx)=A0=A0=A0=A0=A0=A0+=3D 52xx/
> =A0obj-$(CONFIG_PPC_8xx)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0+=3D 8xx/
> =A0obj-$(CONFIG_PPC_82xx)=A0=A0=A0=A0=A0=A0=A0=A0=A0+=3D 82xx/

Why do you name the directory 512x instead of 51xx, which would be
more consistent with the others? Do you expect other 51xx chips that
are mostly incompatible with 512x?

Moreover, is it really so different from 52xx that it needs a separate
directory? E.g. we often treat the 74xx and 7xx as 6xx variants.

	Arnd <><

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 17:40       ` [PATCH 3/7] Basic Freescale MPC512x support Olof Johansson
  2008-01-08 17:44         ` Jon Loeliger
  2008-01-08 18:01         ` John Rigby
@ 2008-01-08 18:13         ` Arnd Bergmann
  2008-01-08 18:16         ` John Rigby
  3 siblings, 0 replies; 34+ messages in thread
From: Arnd Bergmann @ 2008-01-08 18:13 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Olof Johansson, John Rigby

On Tuesday 08 January 2008, Olof Johansson wrote:
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index 66a3d8c..81c3f05 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -470,7 +470,7 @@ config PCI
> > =A0=A0=A0=A0=A0=A0bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_=
85xx || PPC_86xx \
> > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0|| PPC_MPC52xx || (EMBEDDED &=
& (PPC_PSERIES || PPC_ISERIES)) \
> > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0|| PPC_PS3
> > -=A0=A0=A0=A0=A0default y if !40x && !CPM2 && !8xx && !PPC_83xx \
> > +=A0=A0=A0=A0=A0default y if !40x && !CPM2 && !8xx && !PPC_512x && !PPC=
_83xx \
> > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0&& !PPC_85xx && !PPC_86xx
>=20
> This is getting out of control. Not a comment to this specific patch,
> but it's getting silly.
>=20
> Btw, why no PCI by default on this platform when it seemingly is default
> on 5200? I thought they were fairly similar.
>=20

Just an idea how to restructure this, you could have

config PCI_POSSIBLE
	bool
	help
	  select this from your platform if it can support PCI.

config PCI_DEFAULT
	bool
	select
	help
	  select this from your platform if you want PCI on by default

config PCI
	bool "PCI support"
	depends on PCI_POSSIBLE || PCI_DEFAULT
	default PCI_DEFAULT

config 40x
	# there could be PCI, but normally there isn't
	select PCI_POSSIBLE
=09
config PPC_83xx=20
	# PCI is normally wanted on 83xx, but you can disable it
	select PCI_DEFAULT

config CHRP
	# CHRP can only be built correctly when PCI is enabled
	select PCI

	Arnd <><

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 6/7] Add mpc512x_find_ips_freq
  2008-01-08 16:01           ` [PATCH 6/7] Add mpc512x_find_ips_freq John Rigby
  2008-01-08 16:01             ` [PATCH 7/7] Add MPC512x PSC serial driver John Rigby
  2008-01-08 17:27             ` [PATCH 6/7] Add mpc512x_find_ips_freq Grant Likely
@ 2008-01-08 18:15             ` Arnd Bergmann
  2 siblings, 0 replies; 34+ messages in thread
From: Arnd Bergmann @ 2008-01-08 18:15 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: John Rigby

On Tuesday 08 January 2008, John Rigby wrote:
> +unsigned long
> +mpc512x_find_ips_freq(struct device_node *node)
> +{

The driver that is using this is listed as 'tristate' in Kconfig, but
this function is not exported, so you get a link error if you want to
build it as a module.

	Arnd <><

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 17:40       ` [PATCH 3/7] Basic Freescale MPC512x support Olof Johansson
                           ` (2 preceding siblings ...)
  2008-01-08 18:13         ` Arnd Bergmann
@ 2008-01-08 18:16         ` John Rigby
  3 siblings, 0 replies; 34+ messages in thread
From: John Rigby @ 2008-01-08 18:16 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev


>
>   
>> @@ -229,7 +229,7 @@ config NR_CPUS
>>  
>>  config NOT_COHERENT_CACHE
>>  	bool
>> -	depends on 4xx || 8xx || E200
>> +	depends on 4xx || 8xx || E200 || PPC_512x
>>  	default y
>>     
>
> Why do you need this, when 5200 doesn't?
>
>   
Because the 5121 cache is not coherent.  The 5121 is not that similar
to 52xx.
> -Olof
>
>   

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 18:07       ` Arnd Bergmann
@ 2008-01-08 18:25         ` John Rigby
  0 siblings, 0 replies; 34+ messages in thread
From: John Rigby @ 2008-01-08 18:25 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev

Arnd Bergmann wrote:
> On Tuesday 08 January 2008, John Rigby wrote:
>   
>>  obj-$(CONFIG_PPC_CHRP)         += chrp/
>>  obj-$(CONFIG_40x)              += 40x/
>>  obj-$(CONFIG_44x)              += 44x/
>> +obj-$(CONFIG_PPC_512x)         += 512x/
>>  obj-$(CONFIG_PPC_MPC52xx)      += 52xx/
>>  obj-$(CONFIG_PPC_8xx)          += 8xx/
>>  obj-$(CONFIG_PPC_82xx)         += 82xx/
>>     
>
> Why do you name the directory 512x instead of 51xx, which would be
> more consistent with the others? Do you expect other 51xx chips that
> are mostly incompatible with 512x?
>   
51xx would be confusing because 5100 was a precursor to the 5200.

Adding it to 52xx would is wrong because 5121 is really not that
much like a 5200.  It is really a 83xx minus some networking hw
plus some 5200 peripherals (PSCs and MSCAN).

In the best of possible worlds it would have a 83xx part number
and go in 83xx but that would be confusing since it is targeted
at the automotive market.
> Moreover, is it really so different from 52xx that it needs a separate
> directory? E.g. we often treat the 74xx and 7xx as 6xx variants.
>
> 	Arnd <><
>
>   

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 4/7] Device tree for MPC5121 ADS
  2008-01-08 16:01       ` [PATCH 4/7] Device tree for MPC5121 ADS John Rigby
  2008-01-08 16:01         ` [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC John Rigby
  2008-01-08 17:25         ` [PATCH 4/7] Device tree for MPC5121 ADS Grant Likely
@ 2008-01-08 19:22         ` Scott Wood
  2008-01-10  2:18         ` David Gibson
  3 siblings, 0 replies; 34+ messages in thread
From: Scott Wood @ 2008-01-08 19:22 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

On Tue, Jan 08, 2008 at 09:01:30AM -0700, John Rigby wrote:
> +	cpld@82000000 {
> +		device_type = "board-control";
> +		reg = <82000000 8000>;
> +	};

Should be:

baord-control@82000000 {
	compatible = "fsl,mpc5121ads-cpld";
	reg = <82000000 8000>;
};

> +		ref-frequency = <3ef1480>;	// 66MHz ref
> +		bus-frequency = <5e69ec0>;	// 99MHz ips ref

Please specify these in decimal rather than hex (using the d# prefix, or
better yet /dts-v1/).

> +		// IPIC
> +		// interrupts cell = <intr #, sense>
> +		// sense values match linux IORESOURCE_IRQ_* defines:
> +		// sense == 8: Level, low assertion
> +		// sense == 2: Edge, high-to-low change
> +		//
> +		ipic: pic@c00 {
> +			interrupt-controller;
> +			#address-cells = <0>;
> +			#interrupt-cells = <2>;
> +			reg = <c00 100>;
> +			built-in;
> +			device_type = "ipic";
> +		};

Remove built-in.

-Scott

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 17:56           ` Grant Likely
@ 2008-01-08 19:25             ` Scott Wood
  2008-01-08 20:37               ` Generic desktop/server/laptop lable is confusing [Was Re: [PATCH 3/7] Basic Freescale MPC512x support] John Rigby
  0 siblings, 1 reply; 34+ messages in thread
From: Scott Wood @ 2008-01-08 19:25 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, John Rigby

On Tue, Jan 08, 2008 at 10:56:41AM -0700, Grant Likely wrote:
> On 1/8/08, Scott Wood <scottwood@freescale.com> wrote:
> > On Tue, Jan 08, 2008 at 10:19:20AM -0700, Grant Likely wrote:
> > > > +config MPC5121_ADS
> > > > +       bool "Freescale MPC5121E ADS"
> > > > +       select DEFAULT_UIMAGE
> > > > +       help
> > > > +         This option enables support for the MPC5121E ADS board.
> > >
> > > Make this depend on PPC_MULTIPLATFORM and PPC32
> >
> > I don't think PPC_MULTIPLATFORM is appropriate here... it seems to be
> > OF-specific.
> 
> 52xx is multiplatform.

"multiplatform" and "PPC_MULTIPLATFORM" are not the same.  The config option
is misnamed.

> It works well on both OF and non-OF boards.

It may work, but it pulls in code like prom_init.c that is not needed on
non-OF boards.  It's also quite confusing to have an embedded board's
checkbox only show up when you say yes to "Generic desktop/server/laptop".

-Scott

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 7/7] Add MPC512x PSC serial driver
  2008-01-08 17:47                 ` John Rigby
@ 2008-01-08 20:16                   ` Grant Likely
  0 siblings, 0 replies; 34+ messages in thread
From: Grant Likely @ 2008-01-08 20:16 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

On 1/8/08, John Rigby <jrigby@freescale.com> wrote:
> Thanks for the quick feedback Grant.
>
> Grant Likely wrote:
> > Exactly *how* different is the 5121 PSC from the 5200 PSC?  If it is
> > really different, then it makes sense to clone.
> The fifo handling has completely changed that is the main difference.
> >  In fact; I'd
> > duplicate the mpc52xx_psc.h file also to avoid any crossover.
> >
> I agree.
>
> > However, if the differences are manegable, I'd rather see a single
> > driver that can drive either type of PSC.  In fact, can you post a
> > diff between this driver and the original PSC driver?
> >
> I simple diff will mostly show the removal of arch/ppc support so
> won't be much help.  How about I do take a pass at a new version
> that supports 52xx and 512x but only for arch/powerpc?

I'm cool with that.  arch/powerpc support has *far* surpassed arch/ppc
for the 5200, so it may be time to just let the old stuff die, even if
it is a little ahead of schedule.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Generic desktop/server/laptop lable is confusing [Was Re: [PATCH 3/7] Basic Freescale MPC512x support]
  2008-01-08 19:25             ` Scott Wood
@ 2008-01-08 20:37               ` John Rigby
  2008-01-08 21:40                 ` Grant Likely
  0 siblings, 1 reply; 34+ messages in thread
From: John Rigby @ 2008-01-08 20:37 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Scott Wood


>
> It may work, but it pulls in code like prom_init.c that is not needed on
> non-OF boards.  It's also quite confusing to have an embedded board's
> checkbox only show up when you say yes to "Generic desktop/server/laptop".
>   
I have to agree with this, I have been confused by this myself.
Perhaps the prompt should be changed to something less
confusing?
> -Scott
>
>   

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: Generic desktop/server/laptop lable is confusing [Was Re: [PATCH 3/7] Basic Freescale MPC512x support]
  2008-01-08 20:37               ` Generic desktop/server/laptop lable is confusing [Was Re: [PATCH 3/7] Basic Freescale MPC512x support] John Rigby
@ 2008-01-08 21:40                 ` Grant Likely
  2008-01-08 21:46                   ` Scott Wood
  0 siblings, 1 reply; 34+ messages in thread
From: Grant Likely @ 2008-01-08 21:40 UTC (permalink / raw)
  To: John Rigby; +Cc: Scott Wood, linuxppc-dev

On 1/8/08, John Rigby <jrigby@freescale.com> wrote:
>
> >
> > It may work, but it pulls in code like prom_init.c that is not needed on
> > non-OF boards.  It's also quite confusing to have an embedded board's
> > checkbox only show up when you say yes to "Generic desktop/server/laptop".
> >
> I have to agree with this, I have been confused by this myself.
> Perhaps the prompt should be changed to something less
> confusing?

I'm agreeable to that.  Maybe simply "Multiplatform" with a better
description in the help text?

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: Generic desktop/server/laptop lable is confusing [Was Re: [PATCH 3/7] Basic Freescale MPC512x support]
  2008-01-08 21:40                 ` Grant Likely
@ 2008-01-08 21:46                   ` Scott Wood
  0 siblings, 0 replies; 34+ messages in thread
From: Scott Wood @ 2008-01-08 21:46 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, John Rigby

Grant Likely wrote:
> On 1/8/08, John Rigby <jrigby@freescale.com> wrote:
>>> It may work, but it pulls in code like prom_init.c that is not needed on
>>> non-OF boards.  It's also quite confusing to have an embedded board's
>>> checkbox only show up when you say yes to "Generic desktop/server/laptop".
>>>
>> I have to agree with this, I have been confused by this myself.
>> Perhaps the prompt should be changed to something less
>> confusing?
> 
> I'm agreeable to that.  Maybe simply "Multiplatform" with a better
> description in the help text?

Why do we need a config option for "multiplatform" at all?  It seems to 
be currently used to hang a few random, non-embeddy things off of such 
as real OF and SMT.  Let's clean up the mess rather than change the 
description.

-Scott

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/7] Basic Freescale MPC512x support
  2008-01-08 16:01     ` [PATCH 3/7] Basic Freescale MPC512x support John Rigby
                         ` (3 preceding siblings ...)
  2008-01-08 18:07       ` Arnd Bergmann
@ 2008-01-09  2:36       ` Stephen Rothwell
  4 siblings, 0 replies; 34+ messages in thread
From: Stephen Rothwell @ 2008-01-09  2:36 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 733 bytes --]

On Tue,  8 Jan 2008 09:01:29 -0700 John Rigby <jrigby@freescale.com> wrote:
>
> +++ b/arch/powerpc/platforms/512x/mpc5121_ads.c
> +#include <asm/of_platform.h>

I see I don't need to comment on this :-)

> +static void __init mpc5121_ads_init_IRQ(void)
> +{
> +	struct device_node *np;
> +
> +	np = of_find_node_by_type(NULL, "ipic");
> +	if (!np)
> +		return;
> +
> +	ipic_init(np, 0);
> +
> +	/*
> +	 * Initialize the default interrupt mapping priorities,
> +	 * in case the boot rom changed something on us.
> +	 */
> +	ipic_set_default_priority();
> +}

This needs an of_node_put(np) somewhere.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 7/7] Add MPC512x PSC serial driver
  2008-01-08 16:01             ` [PATCH 7/7] Add MPC512x PSC serial driver John Rigby
  2008-01-08 17:32               ` Grant Likely
@ 2008-01-09  3:16               ` Stephen Rothwell
  2008-01-09  6:06                 ` Stephen Rothwell
  1 sibling, 1 reply; 34+ messages in thread
From: Stephen Rothwell @ 2008-01-09  3:16 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1410 bytes --]

On Tue,  8 Jan 2008 09:01:33 -0700 John Rigby <jrigby@freescale.com> wrote:
>
> +++ b/drivers/serial/mpc512x_uart.c
>
> +#include <asm/of_platform.h>

Purely to avoid suggestions of favouritism, I will not the above. :-)

> +static struct of_device_id mpc512x_uart_of_match[] = {

Please make this const.

> +static void mpc512x_uart_of_enumerate(void)
> +{

> +	for_each_node_by_type(np, "serial") {
> +		if (!of_match_node(mpc512x_uart_of_match, np))
> +			continue;
> +
> +		/* Is a particular device number requested? */
> +		devno = of_get_property(np, "port-number", NULL);
> +		mpc512x_uart_of_assign(of_node_get(np), devno ? *devno : -1);

This of_node_get() should be in mpc512x_uart_of_assign() where the
reference is kept.

> +static struct of_platform_driver mpc512x_uart_of_driver = {
> +	.owner = THIS_MODULE,
> +	.name = "mpc52xx-psc-uart",

You don't need these two (we are removing them) but move the .owner
assignment to the .driver part below.

> +	.match_table = mpc512x_uart_of_match,
> +	.probe = mpc512x_uart_of_probe,
> +	.remove = mpc512x_uart_of_remove,
> +#ifdef CONFIG_PM
> +	.suspend = mpc512x_uart_of_suspend,
> +	.resume = mpc512x_uart_of_resume,
> +#endif
> +	.driver = {
> +		   .name = "mpc52xx-psc-uart",
> +		   },
> +};

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 7/7] Add MPC512x PSC serial driver
  2008-01-09  3:16               ` Stephen Rothwell
@ 2008-01-09  6:06                 ` Stephen Rothwell
  0 siblings, 0 replies; 34+ messages in thread
From: Stephen Rothwell @ 2008-01-09  6:06 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 517 bytes --]

On Wed, 9 Jan 2008 14:16:49 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> On Tue,  8 Jan 2008 09:01:33 -0700 John Rigby <jrigby@freescale.com> wrote:
> >
> > +++ b/drivers/serial/mpc512x_uart.c
> >
> > +#include <asm/of_platform.h>
> 
> Purely to avoid suggestions of favouritism, I will not the above. :-)
                                                     ^^^
"note", of course :-(

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 4/7] Device tree for MPC5121 ADS
  2008-01-08 16:01       ` [PATCH 4/7] Device tree for MPC5121 ADS John Rigby
                           ` (2 preceding siblings ...)
  2008-01-08 19:22         ` Scott Wood
@ 2008-01-10  2:18         ` David Gibson
  3 siblings, 0 replies; 34+ messages in thread
From: David Gibson @ 2008-01-10  2:18 UTC (permalink / raw)
  To: John Rigby; +Cc: linuxppc-dev

On Tue, Jan 08, 2008 at 09:01:30AM -0700, John Rigby wrote:
> Bare minimum tree containing only
> what is currently supported.

[snip]
> +	cpus {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		PowerPC,5121@0 {
> +			device_type = "cpu";
> +			reg = <0>;
> +			d-cache-line-size = <20>;	// 32 bytes
> +			i-cache-line-size = <20>;	// 32 bytes
> +			d-cache-size = <8000>;		// L1, 32K
> +			i-cache-size = <8000>;		// L1, 32K
> +			ref-frequency = <3ef1480>;	// 66MHz ref clock
> +			timebase-frequency = <2f34f60>; // 49.5MHz (396MHz/8) makes time tick correctly
> +			bus-frequency = <bcd3d80>;	// 198MHz csb bus
> +			clock-frequency = <179a7b00>;	// 396MHz ppc core ??
> +			32-bit;

The "32-bit" property was only ever added by mistake.  Drop it.

[snip]
> +	cpld@82000000 {
> +		device_type = "board-control";

No device_type here.  But you should have a "compatible" property.

[snip]
> +	soc5121@80000000 {
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		#interrupt-cells = <2>;
> +		device_type = "soc";
> +		ranges = <0 80000000 400000>;
> +		reg = <80000000 400000>;
> +		ref-frequency = <3ef1480>;	// 66MHz ref

What the hell is ref-frequency?  Unfortunately, you have to work with
existing broken practice for SoC nodes here, but the principle clock
frequency for any device should always be encoded in a property called
"clock-frequency".

[snip]
> +		ipic: pic@c00 {

Should be "interrupt-controller@c00"

> +			interrupt-controller;
> +			#address-cells = <0>;
> +			#interrupt-cells = <2>;
> +			reg = <c00 100>;
> +			built-in;
> +			device_type = "ipic";

Drop this device_type.  Should have a compatible value instead.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2008-01-10  2:18 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-08 16:01 [PATCH 0/7] mpc5121 support John Rigby
2008-01-08 16:01 ` [PATCH 1/7] mpc5121: Add IPIC config option John Rigby
2008-01-08 16:01   ` [PATCH 2/7] Add mpc512x ipic support John Rigby
2008-01-08 16:01     ` [PATCH 3/7] Basic Freescale MPC512x support John Rigby
2008-01-08 16:01       ` [PATCH 4/7] Device tree for MPC5121 ADS John Rigby
2008-01-08 16:01         ` [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC John Rigby
2008-01-08 16:01           ` [PATCH 6/7] Add mpc512x_find_ips_freq John Rigby
2008-01-08 16:01             ` [PATCH 7/7] Add MPC512x PSC serial driver John Rigby
2008-01-08 17:32               ` Grant Likely
2008-01-08 17:47                 ` John Rigby
2008-01-08 20:16                   ` Grant Likely
2008-01-09  3:16               ` Stephen Rothwell
2008-01-09  6:06                 ` Stephen Rothwell
2008-01-08 17:27             ` [PATCH 6/7] Add mpc512x_find_ips_freq Grant Likely
2008-01-08 18:15             ` Arnd Bergmann
2008-01-08 17:26           ` [PATCH 5/7] Separate MPC52xx PSC FIFO registers from rest of PSC Grant Likely
2008-01-08 17:25         ` [PATCH 4/7] Device tree for MPC5121 ADS Grant Likely
2008-01-08 19:22         ` Scott Wood
2008-01-10  2:18         ` David Gibson
2008-01-08 17:19       ` [PATCH 3/7] Basic Freescale MPC512x support Grant Likely
2008-01-08 17:55         ` Scott Wood
2008-01-08 17:56           ` Grant Likely
2008-01-08 19:25             ` Scott Wood
2008-01-08 20:37               ` Generic desktop/server/laptop lable is confusing [Was Re: [PATCH 3/7] Basic Freescale MPC512x support] John Rigby
2008-01-08 21:40                 ` Grant Likely
2008-01-08 21:46                   ` Scott Wood
2008-01-08 17:40       ` [PATCH 3/7] Basic Freescale MPC512x support Olof Johansson
2008-01-08 17:44         ` Jon Loeliger
2008-01-08 18:01         ` John Rigby
2008-01-08 18:13         ` Arnd Bergmann
2008-01-08 18:16         ` John Rigby
2008-01-08 18:07       ` Arnd Bergmann
2008-01-08 18:25         ` John Rigby
2008-01-09  2:36       ` Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).