linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Jason McMullan <jason.mcmullan@timesys.com>
To: PPC_LINUX <linuxppc-embedded@ozlabs.org>
Subject: MPC8xx Platformization
Date: Wed, 27 Apr 2005 09:47:14 -0400	[thread overview]
Message-ID: <1114609634.30649.14.camel@ad.doubleclick.net> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 301 bytes --]


The following is a rough skeleton of platformization for the mpc8xx
series, in the same technique as Kumar's 85xx platformization.

This rough cut will be followed up later with specific
driver platformization fixes.


-- 
Jason McMullan <jason.mcmullan@timesys.com>
TimeSys Corporation


[-- Attachment #1.2: mpc8xx-platformize.patch --]
[-- Type: text/x-patch, Size: 11907 bytes --]

Date:        Wed, 20 Apr 2005 11:11:23 -0400
Signed-Off-By:  Jason McMullan <jason.mcmullan@timesys.com>
Description: MPC8xx platformization

Index of changes:

 arch/ppc/Makefile                             |    2 
 arch/ppc/syslib/Makefile                      |    3 
 arch/ppc/syslib/m8xx_setup.c                  |    3 
 include/asm-ppc/mpc8xx.h                      |   31 ++
 include/asm-ppc/ppc_sys.h                     |    2 
 linux/arch/ppc/platforms/8xx/mpc8xx_ads.c     |   22 ++
 linux/arch/ppc/platforms/8xx/mpc8xx_devices.c |  282 ++++++++++++++++++++++++++
 linux/arch/ppc/platforms/8xx/mpc8xx_sys.c     |   39 +++
 8 files changed, 383 insertions(+), 1 deletion(-)


--- linux-orig/arch/ppc/Makefile
+++ linux/arch/ppc/Makefile
@@ -38,6 +38,7 @@
 cpu-as-$(CONFIG_6xx)		+= -Wa,-maltivec
 cpu-as-$(CONFIG_POWER4)		+= -Wa,-maltivec
 cpu-as-$(CONFIG_E500)		+= -Wa,-me500
+cpu-as-$(CONFIG_8xx)		+= -mcpu=860
 
 AFLAGS += $(cpu-as-y)
 CFLAGS += $(cpu-as-y)
@@ -57,6 +58,7 @@
 core-y				+= arch/ppc/kernel/ arch/ppc/platforms/ \
 				   arch/ppc/mm/ arch/ppc/lib/ arch/ppc/syslib/
 core-$(CONFIG_4xx)		+= arch/ppc/platforms/4xx/
+core-$(CONFIG_8xx)		+= arch/ppc/platforms/8xx/
 core-$(CONFIG_85xx)		+= arch/ppc/platforms/85xx/
 core-$(CONFIG_MATH_EMULATION)	+= arch/ppc/math-emu/
 core-$(CONFIG_XMON)		+= arch/ppc/xmon/
--- /dev/null
+++ linux/arch/ppc/platforms/8xx/mpc8xx_ads.c
@@ -0,0 +1,22 @@
+#include <linux/config.h>
+#include <linux/fec_8xx_pd.h>
+#include <asm/ppcboot.h>
+#include <asm/mpc8xx.h>
+#include <asm/ppc_sys.h>
+
+extern unsigned char __res[];
+
+void board_init(void)
+{
+	struct fec_platform_info *fec;
+	bd_t *bi = (void *)&__res[0];
+
+	/* Set up the MAC addresses for the FECs
+	 */
+	fec = ppc_sys_platform_devices[MPC8xx_CPM_FEC1].dev.platform_data;
+	memcpy(fec->macaddr,bi->bi_enetaddr,6);
+
+	fec = ppc_sys_platform_devices[MPC8xx_CPM_FEC2].dev.platform_data;
+	memcpy(fec->macaddr,bi->bi_enetaddr,6);
+	fec->macaddr[5] ^= 1;
+}

--- /dev/null
+++ linux/arch/ppc/platforms/8xx/mpc8xx_devices.c
@@ -0,0 +1,282 @@
+/*
+ * arch/ppc/platforms/8xx/mpc8xx_devices.c
+ *
+ * MPC8xx Device descriptions
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * Copyright 2005 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.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/serial_8250.h>
+#include <linux/fsl_devices.h>
+#include <linux/fec_8xx_pd.h>
+#include <asm/mpc8xx.h>
+#include <asm/8xx_immap.h>
+#include <asm/irq.h>
+#include <asm/ppc_sys.h>
+
+/* We use offsets for IORESOURCE_MEM since we do not know at compile time
+ * what CCSRBAR is, will get fixed up by mach_mpc8xx_fixup
+ */
+
+static struct fsl_i2c_platform_data mpc8xx_fsl_i2c_pdata = {
+	.device_flags = FSL_I2C_DEV_SEPARATE_DFSRR,
+};
+
+static struct fec_mii_bus_info mii_bus_info = {
+	.method			= fecmii_fec,
+	.id			= 0,
+};
+
+static struct fec_platform_info mpc8xx_fec_pdata[] = {
+	{
+		.rx_ring = 128,
+		.tx_ring = 16,
+		.rx_copybreak = 240,
+
+		.use_napi = 1,
+		.napi_weight = 17,
+
+		.bus_info = &mii_bus_info,
+	},{
+		.rx_ring = 128,
+		.tx_ring = 16,
+		.rx_copybreak = 240,
+
+		.use_napi = 1,
+		.napi_weight = 17,
+
+		.bus_info = &mii_bus_info,
+	}
+};
+
+#define IMMAP_STRUCT(x)	((((immap_t *)0)->x))
+#define IMMAP_OFFSET(x)	((unsigned long)&IMMAP_STRUCT(x))
+#define IMMAP_END(x)	(IMMAP_OFFSET(x) + sizeof(IMMAP_STRUCT(x)) - 1)
+
+#define CPM_OFFSET(x)	IMMAP_OFFSET(im_cpm.x)
+#define CPM_END(x)	IMMAP_END(im_cpm.x)
+
+struct platform_device ppc_sys_platform_devices[] = {
+#if 0
+	[MPC8xx_I2C] = {
+		.name = "fsl-i2c",
+		.id	= 1,
+		.dev.platform_data = &mpc8xx_fsl_i2c_pdata,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= IMMAP_OFFSET(im_i2c),
+				.end	= IMMAP_END(im_i2c),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.start	= MPC8xx_IRQ_I2C,
+				.end	= MPC8xx_IRQ_I2C,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+#endif
+	[MPC8xx_CPM_FEC1] =	{
+		.name = "fsl-fec",
+		.id	= 0,
+		.dev.platform_data = &mpc8xx_fec_pdata[0],
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_fec1),
+				.end	= CPM_END(cp_fec1),
+				.flags	= IORESOURCE_MEM,
+
+			},
+			{
+				.start	= MPC8xx_INT_FEC1,
+				.end	= MPC8xx_INT_FEC1,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[MPC8xx_CPM_FEC2] =	{
+		.name = "fsl-fec",
+		.id	= 1,
+		.dev.platform_data = &mpc8xx_fec_pdata[1],
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_fec2),
+				.end	= CPM_END(cp_fec2),
+				.flags	= IORESOURCE_MEM,
+
+			},
+			{
+				.start	= MPC8xx_INT_FEC2,
+				.end	= MPC8xx_INT_FEC2,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[MPC8xx_CPM_SCC1] = {
+		.name = "fsl-cpm-scc",
+		.id	= 1,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_scc[0]),
+				.end	= CPM_END(cp_scc[0]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.start	= MPC8xx_INT_SCC1,
+				.end	= MPC8xx_INT_SCC1,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[MPC8xx_CPM_SCC2] = {
+		.name = "fsl-cpm-scc",
+		.id	= 2,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_scc[1]),
+				.end	= CPM_END(cp_scc[1]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.start	= MPC8xx_INT_SCC2,
+				.end	= MPC8xx_INT_SCC2,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[MPC8xx_CPM_SCC3] = {
+		.name = "fsl-cpm-scc",
+		.id	= 3,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_scc[2]),
+				.end	= CPM_END(cp_scc[2]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.start	= MPC8xx_INT_SCC3,
+				.end	= MPC8xx_INT_SCC3,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[MPC8xx_CPM_SCC4] = {
+		.name = "fsl-cpm-scc",
+		.id	= 4,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_scc[3]),
+				.end	= CPM_END(cp_scc[3]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.start	= MPC8xx_INT_SCC4,
+				.end	= MPC8xx_INT_SCC4,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+#if 0
+	[MPC8xx_CPM_SPI] = {
+		.name = "fsl-cpm-spi",
+		.id	= 1,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_spmode),
+				.end	= CPM_END(cp_spcom),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.start	= MPC8xx_INT_SPI,
+				.end	= MPC8xx_INT_SPI,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+#endif
+	[MPC8xx_CPM_SMC1] = {
+		.name = "fsl-cpm-smc",
+		.id	= 1,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_smc[0]),
+				.end	= CPM_END(cp_smc[0]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.start	= MPC8xx_INT_SMC1,
+				.end	= MPC8xx_INT_SMC1,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[MPC8xx_CPM_SMC2] = {
+		.name = "fsl-cpm-smc",
+		.id	= 2,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_smc[1]),
+				.end	= CPM_END(cp_smc[1]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.start	= MPC8xx_INT_SMC2,
+				.end	= MPC8xx_INT_SMC2,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+#if 0
+	[MPC8xx_CPM_USB] = {
+		.name = "fsl-cpm-usb",
+		.id	= 0,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.start	= CPM_OFFSET(cp_scc[0]),
+				.end	= CPM_END(cp_scc[0]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.start	= MPC8xx_INT_USB,
+				.end	= MPC8xx_INT_USB,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+#endif
+};
+
+static int __init mach_mpc8xx_fixup(struct platform_device *pdev)
+{
+	ppc_sys_fixup_mem_resource(pdev, IMAP_ADDR);
+	return 0;
+}
+
+static int __init mach_mpc8xx_init(void)
+{
+	ppc_sys_device_fixup = mach_mpc8xx_fixup;
+	return 0;
+}
+
+postcore_initcall(mach_mpc8xx_init);

--- /dev/null
+++ linux/arch/ppc/platforms/8xx/mpc8xx_sys.c
@@ -0,0 +1,39 @@
+/*
+ * arch/ppc/platforms/8xx/mpc8xx_sys.c
+ *
+ * MPC8xx System descriptions
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * Copyright 2005 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.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <asm/ppc_sys.h>
+
+struct ppc_sys_spec *cur_ppc_sys_spec;
+struct ppc_sys_spec ppc_sys_specs[] = {
+	{
+		.ppc_sys_name	= "MPC885",
+		.mask 		= 0xFFFF0000,
+		.value 		= 0x00500000,
+		.num_devices	= 2,
+		.device_list	= (enum ppc_sys_devices[])
+		{
+			MPC8xx_CPM_FEC1,
+			MPC8xx_CPM_SCC1,
+		},
+	},
+	{	/* default match */
+		.ppc_sys_name	= "",
+		.mask 		= 0x00000000,
+		.value 		= 0x00000000,
+	},
+};

--- linux-orig/arch/ppc/syslib/Makefile
+++ linux/arch/ppc/syslib/Makefile
@@ -33,7 +33,8 @@
 obj-$(CONFIG_PCI)		+= indirect_pci.o pci_auto.o ppc405_pci.o
 endif
 endif
-obj-$(CONFIG_8xx)		+= m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y)
+obj-$(CONFIG_8xx)		+= m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) \
+				   ppc_sys.o
 ifeq ($(CONFIG_8xx),y)
 obj-$(CONFIG_PCI)		+= qspan_pci.o i8259.o
 endif
--- linux-orig/arch/ppc/syslib/m8xx_setup.c
+++ linux/arch/ppc/syslib/m8xx_setup.c
@@ -45,6 +45,7 @@
 #include <asm/bootinfo.h>
 #include <asm/time.h>
 #include <asm/xmon.h>
+#include <asm/ppc_sys.h>
 
 #include "ppc8xx_pic.h"
 
@@ -408,6 +409,8 @@
 		strcpy(cmd_line, (char *)(r6+KERNELBASE));
 	}
 
+	identify_ppc_sys_by_id(mfspr(PVR));
+
 	ppc_md.setup_arch		= m8xx_setup_arch;
 	ppc_md.show_percpuinfo		= m8xx_show_percpuinfo;
 	ppc_md.irq_canonicalize	= NULL;
--- linux-orig/include/asm-ppc/mpc8xx.h
+++ linux/include/asm-ppc/mpc8xx.h
@@ -90,6 +90,10 @@
 #endif
 
 #ifndef __ASSEMBLY__
+#include <asm/irq.h>
+#include <asm/mmu.h>
+#include <asm/commproc.h>
+
 /* The "residual" data board information structure the boot loader
  * hands to us.
  */
@@ -97,7 +101,34 @@
 
 struct pt_regs;
 
+/* Let modules/drivers get at CCSRBAR */
+extern phys_addr_t get_ccsrbar(void);
+
+#define MPC8xx_INT_FEC1		SIU_LEVEL1
+#define MPC8xx_INT_FEC2		SIU_LEVEL3
+#define MPC8xx_INT_SCC1		(CPM_IRQ_OFFSET + CPMVEC_SCC1)
+#define MPC8xx_INT_SCC2		(CPM_IRQ_OFFSET + CPMVEC_SCC2)
+#define MPC8xx_INT_SCC3		(CPM_IRQ_OFFSET + CPMVEC_SCC3)
+#define MPC8xx_INT_SCC4		(CPM_IRQ_OFFSET + CPMVEC_SCC4)
+#define MPC8xx_INT_SMC1		(CPM_IRQ_OFFSET + CPMVEC_SMC1)
+#define MPC8xx_INT_SMC2		(CPM_IRQ_OFFSET + CPMVEC_SMC2)
+
+enum ppc_sys_devices {
+	MPC8xx_I2C,
+	MPC8xx_CPM_FEC1,
+	MPC8xx_CPM_FEC2,
+	MPC8xx_CPM_SPI,
+	MPC8xx_CPM_USB,
+	MPC8xx_CPM_SCC1,
+	MPC8xx_CPM_SCC2,
+	MPC8xx_CPM_SCC3,
+	MPC8xx_CPM_SCC4,
+	MPC8xx_CPM_SMC1,
+	MPC8xx_CPM_SMC2,
+};
 #endif /* !__ASSEMBLY__ */
+
+
 #endif /* CONFIG_8xx */
 #endif /* __CONFIG_8xx_DEFS */
 #endif /* __KERNEL__ */
--- linux-orig/include/asm-ppc/ppc_sys.h
+++ linux/include/asm-ppc/ppc_sys.h
@@ -23,6 +23,8 @@
 
 #if defined(CONFIG_85xx)
 #include <asm/mpc85xx.h>
+#elif defined(CONFIG_8xx)
+#include <asm/mpc8xx.h>
 #else
 #error "need definition of ppc_sys_devices"
 #endif

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2005-04-27 13:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-27 13:47 Jason McMullan [this message]
2005-04-27 14:42 ` MPC8xx Platformization Kumar Gala
2005-04-27 16:38   ` Jason McMullan
2005-05-20 17:37 ` Andrei Konovalov
2005-05-20 17:51   ` Dan Malek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1114609634.30649.14.camel@ad.doubleclick.net \
    --to=jason.mcmullan@timesys.com \
    --cc=linuxppc-embedded@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).