Skip to contentSkip to conversation

8xx: mpc885ads pcmcia support

PATCH In review Vitaly Bordug 3 participants 6 messages May 6, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 8xx: mpc885ads pcmcia support

Adds support for PowerQuicc on-chip PCMCIA. The driver is implemented as of_device, so only arch/powerpc stuff is capable to use it, which now implies only mpc885ads reference board.

To cope with the code that should be hooked inside driver, but is really board specific (like set_voltage), global structure mpc8xx_pcmcia_ops holds necessary function pointers that are filled in the BSP code.

---

 arch/powerpc/boot/dts/mpc885ads.dts          |   12 +
 arch/powerpc/platforms/8xx/m8xx_setup.c      |    5 
 arch/powerpc/platforms/8xx/mpc885ads.h       |    8 +
 arch/powerpc/platforms/8xx/mpc885ads_setup.c |   76 ++++++
 arch/powerpc/sysdev/fsl_soc.c                |   13 +
 arch/powerpc/sysdev/mpc8xx_pic.h             |    2 
 drivers/pcmcia/Kconfig                       |    1 
 drivers/pcmcia/m8xx_pcmcia.c                 |  352 ++++++++++++--------------
 include/asm-powerpc/mpc8xx.h                 |    4 
 include/linux/fsl_devices.h                  |    5 
 10 files changed, 292 insertions(+), 186 deletions(-)
arch/powerpc/boot/dts/mpc885ads.dts +12 -0
index 110bf61..0f3e8cf 100644
@@ -112,6 +112,18 @@
 			compatible = "CPM";
 		};
 
+		pcmcia@0080 {
+			linux,phandle = <0080>;
+			#interrupt-cells = <1>;
+			#size-cells = <2>;
+			compatible = "fsl,pq-pcmcia";
+			device_type = "pcmcia";
+			reg = <80 80>;
+			clock-frequency = <2faf080>;
+			interrupt-parent = <ff000000>;
+			interrupts = <d 1>;
+		};
+
 		cpm@ff000000 {
 			linux,phandle = <ff000000>;
 			#address-cells = <1>;
arch/powerpc/platforms/8xx/m8xx_setup.c +5 -0
index 0901dba..f169355 100644
@@ -32,6 +32,7 @@
 #include <linux/root_dev.h>
 #include <linux/time.h>
 #include <linux/rtc.h>
+#include <linux/fsl_devices.h>
 
 #include <asm/mmu.h>
 #include <asm/reg.h>
@@ -49,6 +50,10 @@
 
 #include "sysdev/mpc8xx_pic.h"
 
+#ifdef CONFIG_PCMCIA_M8XX
+struct mpc8xx_pcmcia_ops m8xx_pcmcia_ops;
+#endif
+
 void m8xx_calibrate_decr(void);
 extern void m8xx_wdt_handler_install(bd_t *bp);
 extern int cpm_pic_init(void);
arch/powerpc/platforms/8xx/mpc885ads.h +8 -0
index 7c31aec..932b59a 100644
@@ -91,5 +91,13 @@
 #define SICR_ENET_MASK	((uint)0x00ff0000)
 #define SICR_ENET_CLKRT	((uint)0x002c0000)
 
+/* 
+ * Some internal interrupt registers use an 8-bit mask for the interrupt
+ * level instead of a number.
+ */
+static inline uint mk_int_int_mask(uint mask) {
+	return (1 << (7 - (mask/2)));
+}
+
 #endif /* __ASM_MPC885ADS_H__ */
 #endif /* __KERNEL__ */
arch/powerpc/platforms/8xx/mpc885ads_setup.c +76 -0

100 lines not on this page · raw message

arch/powerpc/sysdev/fsl_soc.c +13 -0
index 8a123c7..880e45f 100644
@@ -1028,6 +1028,19 @@ err:
 
 arch_initcall(fs_enet_of_init);
 
+static int __init fsl_pcmcia_of_init(void)
+{
+	struct device_node *np = NULL;
+	/*
+	 * Register all the devices which type is "pcmcia"
+	 */
+	while ((np = of_find_compatible_node(np, 
+			"pcmcia", "fsl,pq-pcmcia")) != NULL)
+			    of_platform_device_create(np, "m8xx-pcmcia", NULL);
+	return 0;
+}
+
+arch_initcall(fsl_pcmcia_of_init);
 
 static const char *smc_regs = "regs";
 static const char *smc_pram = "pram";
arch/powerpc/sysdev/mpc8xx_pic.h +1 -1
index afa2ee6..07be061 100644
@@ -4,7 +4,7 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 
-extern struct hw_interrupt_type mpc8xx_pic;
+/*extern struct hw_interrupt_type mpc8xx_pic;*/
 
 int mpc8xx_pic_init(void);
 unsigned int mpc8xx_get_irq(void);
drivers/pcmcia/Kconfig +1 -0
index 35f8864..c3fd55d 100644
@@ -183,6 +183,7 @@ config PCMCIA_M8XX
         tristate "MPC8xx PCMCIA support"
         depends on PCMCIA && PPC && 8xx 
         select PCCARD_IODYN
+	select PCCARD_NONSTATIC
         help
         Say Y here to include support for PowerPC 8xx series PCMCIA
         controller.
drivers/pcmcia/m8xx_pcmcia.c +167 -185

605 lines not on this page · raw message

include/asm-powerpc/mpc8xx.h +4 -0
index 5803711..c1a6efc 100644
@@ -23,6 +23,10 @@
 #include <platforms/8xx/mpc885ads.h>
 #endif
 
+#ifdef CONFIG_PCMCIA_M8XX 
+extern struct mpc8xx_pcmcia_ops m8xx_pcmcia_ops;
+#endif 
+
 #endif /* CONFIG_8xx */
 #endif /* __CONFIG_8xx_DEFS */
 #endif /* __KERNEL__ */
include/linux/fsl_devices.h +5 -0
index 73710d6..12e631f 100644
@@ -120,5 +120,10 @@ struct fsl_spi_platform_data {
 	u32	sysclk;
 };
 
+struct mpc8xx_pcmcia_ops {
+	void(*hw_ctrl)(int slot, int enable);
+	int(*voltage_set)(int slot, int vcc, int vpp);
+};
+
 #endif /* _FSL_DEVICE_H_ */
 #endif /* __KERNEL__ */
#1 lore raw

arch/powerpc/boot/dts/mpc885ads.dts line 125

Quoted 7 lines
arch/powerpc/boot/dts/mpc885ads.dts +5 -0
+		pcmcia@0080 {
 
+			#interrupt-cells = <1>;
 
+			interrupt-parent = <ff000000>;
+			interrupts = <d 1>;
+		};

Since this node's children's interrupt representation is different from the node's parent's, you need an interrupt-map in here. You also forgot "#address-cells" and I think you need "ranges" too?

Segher

#2 lore raw
Quoted 4 lines · Segher Boessenkool
Quoted 3 lines
arch/powerpc/boot/dts/mpc885ads.dts +2 -0
+		pcmcia@0080 {
 
+			#interrupt-cells = <1>;
Quoted 8 lines

arch/powerpc/boot/dts/mpc885ads.dts line 125

Quoted 3 lines
arch/powerpc/boot/dts/mpc885ads.dts +3 -0
+			interrupt-parent = <ff000000>;
+			interrupts = <d 1>;
+		};

Since this node's children's interrupt representation is different from the node's parent's, you need an interrupt-map in here. You also forgot "#address-cells" and I think you need "ranges" too?

And we should use a reference, instead of an implicit phandle for the interrupt-parent.

Signature · 4 lines
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
#4 lore raw
In reply to Segher Boessenkool
Quoted 4 lines · On Sun, 6 May 2007 03:04:14 +0200 Segher Boessenkool wrote:
Quoted 3 lines
arch/powerpc/boot/dts/mpc885ads.dts +2 -0
+		pcmcia@0080 {
 
+			#interrupt-cells = <1>;
Quoted 9 lines

arch/powerpc/boot/dts/mpc885ads.dts line 125

Quoted 3 lines
arch/powerpc/boot/dts/mpc885ads.dts +3 -0
+			interrupt-parent = <ff000000>;
+			interrupts = <d 1>;
+		};

Since this node's children's interrupt representation is different from the node's parent's, you need an interrupt-map in here. You also forgot "#address-cells" and I think you need "ranges" too?

Well, in fact it does not introduce SoC device different from any others represented inside soc885 node. mk_int_int_mask() is just special way of enabling irq for PCMCIA stuff, in addition to normal pic stuff.

Emm. Why would I need #address-cells and ranges here? it uses parent bus address space...

Signature · 1 line
Sincerely, Vitaly
#3 lore raw
In reply to David Gibson
Quoted 14 lines · On Sun, 6 May 2007 12:04:27 +1000 David Gibson wrote:
Quoted 4 lines · Segher Boessenkool
Quoted 3 lines
arch/powerpc/boot/dts/mpc885ads.dts +2 -0
+		pcmcia@0080 {
 
+			#interrupt-cells = <1>;
Quoted 8 lines

arch/powerpc/boot/dts/mpc885ads.dts line 125

Quoted 3 lines
arch/powerpc/boot/dts/mpc885ads.dts +3 -0
+			interrupt-parent = <ff000000>;
+			interrupts = <d 1>;
+		};

Since this node's children's interrupt representation is different from the node's parent's, you need an interrupt-map in here. You also forgot "#address-cells" and I think you need "ranges" too?

Quoted 3 lines

And we should use a reference, instead of an implicit phandle for the interrupt-parent.

I have one more patch for this - I think it makes sense to append it to the series... Thinking it would be better to do the phandles->labels transition in one step for all the relevant stuff in dts as well.

Signature · 1 line
Sincerely, Vitaly
#5 lore raw
In reply to Vitaly Bordug
Quoted 8 lines
Quoted 5 lines

Since this node's children's interrupt representation is different from the node's parent's, you need an interrupt-map in here. You also forgot "#address-cells" and I think you need "ranges" too?

Well, in fact it does not introduce SoC device different from any others represented inside soc885 node. mk_int_int_mask() is just special way of enabling irq for PCMCIA stuff, in addition to normal pic stuff.

I have no idea what you mean here. Care to try again?

Quoted 1 line

Emm. Why would I need #address-cells and ranges here? it uses parent bus address space...

"#address-cells" is 3 for pcmcia, so not the default value (which is 2), so you need to put it in. The value of this property is not inherited from the parent node.

Absence of a "ranges" property means the child bus is *not* direct mapped into the parent bus space. If the mapping you need is 1-1, put in an empty "ranges" property; if not, you have to put the correct mapping in.

Segher