Skip to contentSkip to conversation

8xx: mpc885ads pcmcia support

PATCH In review Vitaly Bordug 3 participants 5 messages May 3, 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/mpc885ads.h       |    5 
 arch/powerpc/platforms/8xx/mpc885ads_setup.c |   75 +++++
 arch/powerpc/sysdev/fsl_soc.c                |   12 +
 drivers/pcmcia/Kconfig                       |    1 
 drivers/pcmcia/m8xx_pcmcia.c                 |  356 ++++++++++++--------------
 6 files changed, 271 insertions(+), 190 deletions(-)
arch/powerpc/boot/dts/mpc885ads.dts +12 -0
index 110bf61..89d585f 100644
@@ -112,6 +112,18 @@
 			compatible = "CPM";
 		};
 
+               pcmcia@0080 {
+                       linux,phandle = <0080>;
+                       #interrupt-cells = <1>;
+                       #size-cells = <2>;
+                       compatible = "8xx";
+                       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/mpc885ads.h +5 -0
index 7c31aec..4439346 100644
@@ -91,5 +91,10 @@
 #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.
+ */
+#define mk_int_int_mask(IL) (1 << (7 - (IL/2)))
+
 #endif /* __ASM_MPC885ADS_H__ */
 #endif /* __KERNEL__ */
arch/powerpc/platforms/8xx/mpc885ads_setup.c +75 -0

93 lines not on this page · raw message

arch/powerpc/sysdev/fsl_soc.c +12 -0
index 8a123c7..e7eff6b 100644
@@ -1028,6 +1028,18 @@ 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_node_by_type(np, "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";
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 +166 -190

597 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · Vitaly Bordug

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.

Very nice, looks much better now than the previous version.

Quoted 13 lines
arch/powerpc/boot/dts/mpc885ads.dts +5 -0
index 110bf61..89d585f 100644
@@ -112,6 +112,18 @@
 			compatible = "CPM";
 		};
 
+               pcmcia@0080 {
+                       linux,phandle = <0080>;
+                       #interrupt-cells = <1>;
+                       #size-cells = <2>;
+                       compatible = "8xx";

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

Quoted 10 lines
arch/powerpc/boot/dts/mpc885ads.dts +7 -0
+                       device_type = "pcmcia";
+                       reg = <80 80>;
+                       clock-frequency = <2faf080>;
+                       interrupt-parent = <ff000000>;
+                       interrupts = <d 1>;
+		};
+
 		cpm@ff000000 {
 			linux,phandle = <ff000000>;
 			#address-cells = <1>;

The compatible property should be a little more specific, imho. Since there are differences in how things are done depending on the board, it would be good to tell the exact method from the pcmcia node itself.

For example, you could make this

	compatible = "8xx\0mpc885ads";

Your code doesn't currently use this, I like to have the option.

arch/powerpc/boot/dts/mpc885ads.dts

Quoted 13 lines
arch/powerpc/boot/dts/mpc885ads.dts +10 -0
+#ifdef CONFIG_PCMCIA_M8XX
+static void pcmcia_hw_setup(int slot, int enable);
+static int pcmcia_set_voltage(int slot, int vcc, int vpp);
+
+struct mpc8xx_pcmcia_ops m8xx_pcmcia_ops = {
+	.hw_ctrl = pcmcia_hw_setup,
+	.voltage_set = pcmcia_set_voltage,
+};
+#endif
+
 void __init mpc885ads_board_setup(void)
 {
 	cpm8xx_t *cp;

If you define the global variable in the board code, you can not have multiple board implementations in a multiplatform kernel.
In order to make that work, you'd need to have the definition of m8xx_pcmcia_ops in 8xx common code, and then assign the two function pointers dynamically in the board initialization.

arch/powerpc/boot/dts/mpc885ads.dts

Quoted 6 lines
arch/powerpc/boot/dts/mpc885ads.dts +6 -0
+	if (of_address_to_resource(np, 0, &r))
+		return -EINVAL;
+
+	pcmcia = ioremap(r.start, r.end - r.start + 1);
+	if(pcmcia == NULL)
+		return -EINVAL;

A new of_iomap() function was recently added that allows you to do these two steps in one.

arch/powerpc/boot/dts/mpc885ads.dts

Quoted 3 lines
arch/powerpc/boot/dts/mpc885ads.dts +2 -1
-/* connect interrupt and disable CxOE */
+	out_be32(M8XX_PGCRX(0), M8XX_PGCRX_CXOE | (mk_int_int_mask(hwirq) << 16));
+	out_be32(M8XX_PGCRX(1), M8XX_PGCRX_CXOE | (mk_int_int_mask(hwirq) << 16));

I'm not sure why you need to use the hwirq here, it should not be visible to device drivers normally.

Is this the same as enable_irq(pcmcia_schlvl) ?

	Arnd <><
#2 lore raw
Quoted 7 lines

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

Quoted 3 lines
arch/powerpc/boot/dts/mpc885ads.dts +2 -0
+               pcmcia@0080 {
 
+                       compatible = "8xx";

The compatible property should be a little more specific, imho. Since there are differences in how things are done depending on the board, it would be good to tell the exact method from the pcmcia node itself.

Just "8xx" isn't good enough -- at a very minimum it needs to say this is a PCMCIA controller!

Quoted 3 lines

For example, you could make this

	compatible = "8xx\0mpc885ads";

"mpc885ads-pcmcia\0mpc8xx-pcmcia" or something like that.

Segher

#3 lore raw
Quoted 5 lines · Segher Boessenkool
Quoted 3 lines

For example, you could make this

=A0=A0=A0=A0=A0=A0compatible =3D "8xx\0mpc885ads";

=20
"mpc885ads-pcmcia\0mpc8xx-pcmcia" or something like that.

Right. I can never remember what goes first...

	Arnd <><
#4 lore raw
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

For example, you could make this

=A0=A0=A0=A0=A0=A0compatible =3D "8xx\0mpc885ads";

"mpc885ads-pcmcia\0mpc8xx-pcmcia" or something like that.

Right. I can never remember what goes first...

It doesn't really matter all that much; "correct" drivers probe for the most specific thing first, then the next most specific thing they support, etc. It is mostly a convention.

The important thing is that you can't just call yourself "8xx", that is way to generic a name.

Segher