linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* RFC: cpm2_devices.c
@ 2005-06-14 18:18 Allen Curtis
  2005-06-15  3:35 ` Kumar Gala
  0 siblings, 1 reply; 27+ messages in thread
From: Allen Curtis @ 2005-06-14 18:18 UTC (permalink / raw)
  To: linuxppc-embedded

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

Please review and comment on the following.

My comments regarding the implementation:
1. This implementation uses the cpm_map_t structure definition to derive
the IORESOURCE_MEM regions. This seems to be more adaptible to CPM
address differences but it assumes that there are unique structures for
each processor type.

2. ppc_sys_spec appears to identify the CPM elements which are
applicable to a particular processor. So this structure, not the
cpm_map_t structure identifies the CPM resources. This implementation
addresses the the CPU differences but assumes that a CPM resource is
always at the same IMMAP address. The FCC, DPRAM usage is an example of
an exception to this rule.

Note: The attachment was generated via cg-diff, please let me know if
there is a preferred format.

Thanks


[-- Attachment #2: cpm2_devices.patch --]
[-- Type: text/x-patch, Size: 12562 bytes --]

diff --git a/arch/ppc/syslib/cpm2_devices.c b/arch/ppc/syslib/cpm2_devices.c
new file mode 100644
--- /dev/null
+++ b/arch/ppc/syslib/cpm2_devices.c
@@ -0,0 +1,460 @@
+/*
+ * arch/ppc/platforms/cpm2_devices.c
+ *
+ * General CPM2 Device descriptions
+ *
+ * Maintainer: Allen Curtis <acurtis@onz.com>
+ * Derived from mpc83xx_devices.c by Kumar Gala
+ *
+ * Copyright 2005 Ones and Zeros 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/fsl_devices.h>
+#include <asm/cpm2.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 IMMRBAR is, will get fixed up by mach_mpc83xx_fixup
+ */
+
+#define CPM2_STARTOF(m)		(offsetof(cpm2_map_t,(m)))
+#define CCPM2_ENDOF(m)		(CPM_STARTOF(m)+sizeof(m)-1)
+
+/* Define the CPM2 platform devices
+ */
+struct platform_device ppc_sys_platform_devices[] = {
+	[CPM2_FCC1] = {
+		.name = "fsl-cpm-fcc",
+		.id	= 1,
+		.dev.platform_data = ,
+		.num_resources	 = 5,
+		.resource = (struct resource[]) {
+			{
+				.name	= "fcc_regs",
+				.start	= CPM2_STARTOF(im_fcc[0]),
+				.end	= CPM2_ENDOF(im_fcc[0]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "fcc_regs_c",
+				.start	= CPM2_STARTOF(im_fcc_c[0]),
+				.end	= CPM2_ENDOF(im_fcc_c[0]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "fcc_pram",
+				.start	= PROFF_FCC1,
+				.end	= PROFF_FCC1 + PROFF_FCC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			/* fcc_mem
+			 * This should be allocated from DPRAM, not part
+			 * of this structure definition.
+			 */
+			{
+				.name	= "fcc_mem",
+				.start	= PROFF_FCC1_MEM_BASE,
+				.end	= PROFF_FCC1_MEM_BASE + PROFF_FCC_MEM_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_FCC1,
+				.end	= SIU_INT_FCC1,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_FCC2] = {
+		.name = "fsl-cpm-fcc",
+		.id	= 2,
+		.dev.platform_data = ,
+		.num_resources	 = 5,
+		.resource = (struct resource[]) {
+			{
+				.name	= "fcc_regs",
+				.start	= CPM2_STARTOF(im_fcc[1]),
+				.end	= CPM2_ENDOF(im_fcc[1]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "fcc_regs_c",
+				.start	= CPM2_STARTOF(im_fcc_c[1]),
+				.end	= CPM2_ENDOF(im_fcc_c[1]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "fcc_pram",
+				.start	= PROFF_FCC2,
+				.end	= PROFF_FCC2 + PROFF_FCC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			/* fcc_mem
+			 * This should be allocated from DPRAM, not part
+			 * of this structure definition.
+			 */
+			{
+				.name	= "fcc_mem",
+				.start	= PROFF_FCC2_MEM_BASE,
+				.end	= PROFF_FCC2_MEM_BASE + PROFF_FCC_MEM_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_FCC2,
+				.end	= SIU_INT_FCC2,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_FCC3] = {
+		.name = "fsl-cpm-fcc",
+		.id	= 3,
+		.dev.platform_data = ,
+		.num_resources	 = 5,
+		.resource = (struct resource[]) {
+			{
+				.name	= "fcc_regs",
+				.start	= CPM2_STARTOF(im_fcc[2]),
+				.end	= CPM2_ENDOF(im_fcc[2]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "fcc_regs_c",
+				.start	= CPM2_STARTOF(im_fcc_c[2]),
+				.end	= CPM2_ENDOF(im_fcc_c[2]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "fcc_pram",
+				.start	= PROFF_FCC3,
+				.end	= PROFF_FCC3 + PROFF_FCC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			/* fcc_mem
+			 * This should be allocated from DPRAM, not part
+			 * of this structure definition.
+			 */
+			{
+				.name	= "fcc_mem",
+				.start	= PROFF_FCC3_MEM_BASE,
+				.end	= PROFF_FCC3_MEM_BASE + PROFF_FCC_MEM_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_FCC3,
+				.end	= SIU_INT_FCC3,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_SCC1] = {
+		.name = "fsl-cpm-scc",
+		.id	= 1,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "scc_regs",
+				.start	= CPM2_STARTOF(im_scc[0]),
+				.end	= CPM2_ENDOF(im_scc[0]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "scc_pram",
+				.start	= PROFF_SCC1,
+				.end	= PROFF_SCC1 + PROFF_SCC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_SCC1,
+				.end	= SIU_INT_SCC1,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_SCC2] = {
+		.name = "fsl-cpm-scc",
+		.id	= 2,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "scc_regs",
+				.start	= CPM2_STARTOF(im_scc[1]),
+				.end	= CPM2_ENDOF(im_scc[1]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "scc_pram",
+				.start	= PROFF_SCC2,
+				.end	= PROFF_SCC2 + PROFF_SCC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_SCC2,
+				.end	= SIU_INT_SCC2,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_SCC3] = {
+		.name = "fsl-cpm-scc",
+		.id	= 3,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "scc_regs",
+				.start	= CPM2_STARTOF(im_scc[2]),
+				.end	= CPM2_ENDOF(im_scc[2]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "scc_pram",
+				.start	= PROFF_SCC3,
+				.end	= PROFF_SCC3 + PROFF_SCC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_SCC3,
+				.end	= SIU_INT_SCC3,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_SCC4] = {
+		.name = "fsl-cpm-scc",
+		.id	= 4,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "scc_regs",
+				.start	= CPM2_STARTOF(im_scc[3]),
+				.end	= CPM2_ENDOF(im_scc[3]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "scc_pram",
+				.start	= PROFF_SCC4,
+				.end	= PROFF_SCC4 + PROFF_SCC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_SCC4,
+				.end	= SIU_INT_SCC4,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_SMC1] = {
+		.name = "fsl-cpm-smc",
+		.id	= 1,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "smc_regs",
+				.start	= CPM2_STARTOF(im_smc[0]),
+				.end	= CPM2_ENDOF(im_smc[0]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "smc_pram",
+				.start	= PROFF_SMC1_BASE,
+				.end	= PROFF_SMC1_BASE + PROFF_SMC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_SMC1,
+				.end	= SIU_INT_SMC1,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_SMC2] = {
+		.name = "fsl-cpm-smc",
+		.id	= 2,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "smc_regs",
+				.start	= CPM2_STARTOF(im_smc[1]),
+				.end	= CPM2_ENDOF(im_smc[1]),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "smc_pram",
+				.start	= PROFF_SMC2_BASE,
+				.end	= PROFF_SMC2_BASE + PROFF_SMC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_SMC2,
+				.end	= SIU_INT_SMC2,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_I2C] = {
+		.name = "fsl-cpm-i2c",
+		.id	= 1,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "i2c_regs",
+				.start	= CPM2_STARTOF(im_i2c),
+				.end	= CPM2_ENDOF(im_i2c),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "i2c_pram",
+				.start	= PROFF_I2C_BASE,
+				.end	= PROFF_I2C_BASE + PROFF_I2C_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_I2C,
+				.end	= SIU_INT_I2C,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_SPI] = {
+		.name = "fsl-cpm-spi",
+		.id	= 1,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "spi_regs",
+				.start	= CPM2_STARTOF(im_spi),
+				.end	= CPM2_ENDOF(im_spi),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "spi_pram",
+				.start	= PROFF_SPI_BASE,
+				.end	= PROFF_SPI_BASE + PROFF_SPI_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_SPI,
+				.end	= SIU_INT_SPI,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_CPM] = {
+		.name = "fsl-cpm-cpm",
+		.id	= 1,
+		.dev.platform_data = ,
+		.num_resources	 = 2,
+		.resource = (struct resource[]) {
+			{
+				.name	= "cpm_regs",
+				.start	= CPM2_STARTOF(im_cpm),
+				.end	= CPM2_ENDOF(im_cpm),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "cpm_mux",
+				.start	= CPM2_STARTOF(im_cpmux),
+				.end	= CPM2_ENDOF(im_cpmux),
+				.flags	= IORESOURCE_MEM,
+			},
+		},
+	},
+#if !defined(CONFIG_8272) && !defined(CONFIG_MPC8555)
+	[CPM2_MMC1] = {
+		.name = "fsl-cpm-mmc",
+		.id	= 1,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "mmc_regs",
+				.start	= CPM2_STARTOF(im_mmc1),
+				.end	= CPM2_ENDOF(im_mmc1),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "mmc_pram",
+				.start	= PROFF_MMC1,
+				.end	= PROFF_MMC1 + PROFF_MMC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_MMC1,
+				.end	= SIU_INT_MMC1,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+	[CPM2_MMC2] = {
+		.name = "fsl-cpm-mmc",
+		.id	= 2,
+		.dev.platform_data = ,
+		.num_resources	 = 3,
+		.resource = (struct resource[]) {
+			{
+				.name	= "mmc_regs",
+				.start	= CPM2_STARTOF(im_mmc2),
+				.end	= CPM2_ENDOF(im_mmc2),
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "mmc_pram",
+				.start	= PROFF_MMC2,
+				.end	= PROFF_MMC2 + PROFF_MMC_SIZE - 1,
+				.flags	= IORESOURCE_MEM,
+			},
+			{
+				.name	= "interrupt",
+				.start	= SIU_INT_MMC2,
+				.end	= SIU_INT_MMC2,
+				.flags	= IORESOURCE_IRQ,
+			},
+		},
+	},
+#endif
+
+	
+static int __init mach_cpm2_fixup(struct platform_device *pdev)
+{
+	ppc_sys_fixup_mem_resource(pdev, CPM_MAP_ADDR);
+	return 0;
+}
+
+static int __init mach_cpm2_init(void)
+{
+	if (ppc_md.progress)
+		ppc_md.progress("mach_cpm2_init:enter", 0);
+	ppc_sys_device_fixup = mach_cpm2_fixup;
+	return 0;
+}
+
+postcore_initcall(mach_cpm2_init);
+	
\ No newline at end of file
diff --git a/include/asm-ppc/cpm2.h b/include/asm-ppc/cpm2.h
--- a/include/asm-ppc/cpm2.h
+++ b/include/asm-ppc/cpm2.h
@@ -170,6 +170,20 @@ typedef struct cpm_buf_desc {
 #define PROFF_I2C_BASE		((uint)0x8afc)
 #define PROFF_IDMA4_BASE	((uint)0x8afe)
 
+#define PROFF_FCC_SIZE		((uint))256)
+#define PROFF_SCC_SIZE		((uint))256)
+#define PROFF_SMC_SIZE		((uint)2)
+#define PROFF_IDMA_SIZE		((uint)2)
+#define PROFF_SPI_SIZE		((uint)2)
+#define PROFF_I2C_SIZE		((uint)2)
+#define PROFF_MMC_SIZE		((uint)124)
+#define PROFF_USB_SIZE		((uint)256)
+
+#define PROFF_FCC_MEM_SIZE	((uint)128)
+#define PROFF_FCC1_MEM_BASE	(CPM_FCC_SPECIAL_BASE+(PROFF_FCC_MEM_SIZE*0))
+#define PROFF_FCC2_MEM_BASE	(CPM_FCC_SPECIAL_BASE+(PROFF_FCC_MEM_SIZE*1))
+#define PROFF_FCC3_MEM_BASE	(CPM_FCC_SPECIAL_BASE+(PROFF_FCC_MEM_SIZE*2))
+
 /* The SMCs are relocated to any of the first eight DPRAM pages.
  * We will fix these at the first locations of DPRAM, until we
  * get some microcode patches :-).
@@ -1084,6 +1098,40 @@ typedef struct im_idma {
 #define SCCR_PCIDF_MSK	0x00000078	/* PCI division factor	*/
 #define SCCR_PCIDF_SHIFT 3
 
+/*-----------------------------------------------------------------------
+ * Enumeration of PPC/CPM2 devices for platform initialization
+ */
+
+/* It says this should be an enumeration. If it was #defines then the
+ * cpm2_devices array definition could be conditionally compiled.
+ *
+ * Another approach would be to add all devices and have a flags field
+ * for the different CPM configuration options.
+ */
+enum ppc_sys_devices {
+	CPM2_FCC1,
+	CPM2_FCC2,
+	CPM2_FCC3,
+	CPM2_SCC1,
+	CPM2_SCC2,
+	CPM2_SCC3,
+	CPM2_SCC4,
+	CPM2_SMC1,
+	CPM2_SMC2,
+	CPM2_I2C,
+	CPM2_SPI,
+/*	CPM2_DMA,	think about this more, separate SDMA and IDMA? */
+	CPM2_CPM,
+/*	CPM2_SI2,	*/
+#if !defined(CONFIG_8272) && !defined(CONFIG_MPC8555)
+	CPM2_SI1,
+	CPM2_MMC1,
+	CPM2_MMC2,
+#else
+	CPM2_USB,
+#endf	
+};
+
 
 #endif /* __CPM2__ */
 #endif /* __KERNEL__ */

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

end of thread, other threads:[~2005-06-16 19:33 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-14 18:18 RFC: cpm2_devices.c Allen Curtis
2005-06-15  3:35 ` Kumar Gala
2005-06-15  3:57   ` Allen Curtis
2005-06-15  4:13     ` Kumar Gala
2005-06-15  4:41       ` Allen Curtis
2005-06-15 14:24         ` Jason McMullan
2005-06-15 15:06           ` Kumar Gala
2005-06-15 17:48             ` Allen Curtis
2005-06-15 18:05               ` Vitaly Bordug
2005-06-15 14:29         ` Kumar Gala
2005-06-15 14:30         ` Kumar Gala
2005-06-16 15:12       ` Dan Malek
2005-06-16 15:33         ` Kumar Gala
2005-06-16 15:42           ` Allen Curtis
2005-06-16 15:53             ` Kumar Gala
2005-06-16 16:39               ` Allen Curtis
2005-06-16 19:33           ` Dan Malek
2005-06-15  7:55   ` Vitaly Bordug
2005-06-15 14:25     ` Kumar Gala
2005-06-15 14:33       ` Jason McMullan
2005-06-15 15:01         ` Kumar Gala
2005-06-15 15:31       ` Vitaly Bordug
2005-06-15 15:41         ` Kumar Gala
2005-06-15 16:07           ` Vitaly Bordug
2005-06-16  6:42           ` Pantelis Antoniou
2005-06-16  9:33             ` Wolfgang Denk
2005-06-16 15:02             ` Kumar Gala

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).