pxa/hx4700: Add PCMCIA/CF support
Subsystems (3)
PATCH v4 1/2 pxa/hx4700: Add PCMCIA/CF support
Add PCMCIA/CF support for the HP iPAQ hx4700. Underlying support is provided by the pcmcia/pxa2xx_hx4700 platform_device implementation which hooks into the existing pxa2xx-pcmcia driver.
---
V4:
Converted to use the new irq/gpio management provided by soc_common. Rebased to linux-3.3-rc2 + soc_common patch series.
drivers/mfd/asic3.c +6 -0
@@ -992,6 +992,9 @@ static int __init asic3_probe(struct plaasic3_mfd_probe (pdev, pdata, mem); +asic3_set_register (asic,ASIC3_OFFSET (EXTCF ,SELECT ), + (ASIC3_EXTCF_CF0_BUF_EN |ASIC3_EXTCF_CF0_PWAIT_EN ),1 ); +dev_info (asic->dev,"ASIC3 Core driver\n" );return 0 ;
@@ -1013,6 +1016,9 @@ static int __devexit asic3_remove(structint ret;struct asic3 *asic =platform_get_drvdata (pdev); +asic3_set_register (asic,ASIC3_OFFSET (EXTCF ,SELECT ), + (ASIC3_EXTCF_CF0_BUF_EN |ASIC3_EXTCF_CF0_PWAIT_EN ),0 ); +asic3_mfd_remove (pdev); ret =asic3_gpio_remove (pdev);
drivers/pcmcia/Kconfig +1 -1
@@ -217,7 +217,7 @@ config PCMCIA_PXA2XX || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ || MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \ - || MACH_COLIBRI320) + || MACH_COLIBRI320 || MACH_H4700) select PCMCIA_SA1111 if ARCH_LUBBOCK && SA1111 select PCMCIA_SOC_COMMON help
drivers/pcmcia/Makefile +1 -0
@@ -69,6 +69,7 @@ pxa2xx-obj-$(CONFIG_MACH_VPAC270) += px pxa2xx-obj-$(CONFIG_MACH_BALLOON3) += pxa2xx_balloon3.o pxa2xx-obj-$(CONFIG_MACH_COLIBRI) += pxa2xx_colibri.o pxa2xx-obj-$(CONFIG_MACH_COLIBRI320) += pxa2xx_colibri.o +pxa2xx-obj-$(CONFIG_MACH_H4700) += pxa2xx_hx4700.o obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y)
drivers/pcmcia/pxa2xx_hx4700.c +130 -0
130 lines not on this page · raw message
PATCH v4 1/2 pxa/hx4700: Add PCMCIA/CF support
drivers/pcmcia/pxa2xx_hx4700.c line 32
Quoted 9 lines · Paul Parsons
drivers/pcmcia/pxa2xx_hx4700.c +9
-0+static int hw_init (struct soc_pcmcia_socket *skt) +{ +int ret; + + ret =gpio_request_array (gpios,ARRAY_SIZE (gpios)); +if (ret) + goto out; + +irq_set_irq_type (gpio_to_irq (GPIOD4_CF_nCD),IRQ_TYPE_EDGE_BOTH );
You shouldn't need to set the IRQ type for this.
Quoted 9 lines
drivers/pcmcia/pxa2xx_hx4700.c +9
-0+ + skt->stat[SOC_STAT_CD ].gpio = GPIOD4_CF_nCD; + skt->stat[SOC_STAT_CD ].name ="PCMCIA CD" ; + skt->stat[SOC_STAT_RDY ].gpio =GPIO60_HX4700_CF_RNB ; + skt->stat[SOC_STAT_RDY ].name ="PCMCIA Ready" ; + +out: +return ret; +}
...
drivers/pcmcia/pxa2xx_hx4700.c line 52
Quoted 5 lines
drivers/pcmcia/pxa2xx_hx4700.c +5
-0+static void socket_state (struct soc_pcmcia_socket *skt, +struct pcmcia_state *state) +{ + state->detect = (gpio_get_value (GPIOD4_CF_nCD) ==0 ); + state->ready = (gpio_get_value (GPIO60_HX4700_CF_RNB ) !=0 );
soc_common reads these for you before calling your socket_state function.
drivers/pcmcia/pxa2xx_hx4700.c line 54
Quoted 2 lines
drivers/pcmcia/pxa2xx_hx4700.c +2
-0+ state->bvd1 =1 ; + state->bvd2 =1 ;
If you don't have the BVD signals, soc_common now defaults these to '1'.
drivers/pcmcia/pxa2xx_hx4700.c line 55
Quoted 1 line
drivers/pcmcia/pxa2xx_hx4700.c +1
-0+ state->wrprot =0 ;
You don't need to set this - soc_common sets this to zero.
drivers/pcmcia/pxa2xx_hx4700.c line 57
Quoted 2 lines
drivers/pcmcia/pxa2xx_hx4700.c +2
-0+ state->vs_3v =1 ; + state->vs_Xv =0 ;
But you will need these two.
Quoted 1 line
+}
...
Quoted 10 lines
drivers/pcmcia/pxa2xx_hx4700.c +10
-0+static int __init hx4700_pcmcia_init (void ) +{ +struct platform_device *pdev; +int ret; + +if (!machine_is_h4700 ()) +return -ENODEV ; + + pdev =platform_device_alloc ("pxa2xx-pcmcia" ,-1 ); +if (!pdev)
drivers/pcmcia/pxa2xx_hx4700.c line 110
Quoted 10 lines
drivers/pcmcia/pxa2xx_hx4700.c +10
-0+return -ENOMEM ; + + ret =platform_device_add_data (pdev, + &hx4700_pcmcia_ops,sizeof (hx4700_pcmcia_ops)); +if (ret) + goto out; + + ret =platform_device_add (pdev); +if (ret) + goto out;
pdev = platform_device_register_data(NULL, "pxa2xx-pcmcia", -1, &hx4700_pcmcia_ops, sizeof(hx4700_pcmcia_ops)); if (IS_ERR(pdev)) return PTR_ERR(pdev);
Quoted 8 lines
drivers/pcmcia/pxa2xx_hx4700.c +8
-0+ + hx4700_pcmcia_device = pdev; +return 0 ; + +out: +platform_device_put (pdev); +return ret; +}
PATCH v4 1/2 pxa/hx4700: Add PCMCIA/CF support
Quoted 4 lines · Russell King - ARM Linux
irq_set_irq_type(gpio_to_irq(GPIOD4_CF_nCD),
IRQ_TYPE_EDGE_BOTH);You shouldn't need to set the IRQ type for this.
If I don't set the IRQ type then it doesn't get set before the interrupt is unmasked in request_irq(). On the hx4700 the default IRQ type is level triggered low level detect, which is exactly the signal present on the (active low) CF card detect GPIO at boot. Consequently the interrupt handler is called repeatedly, resulting in some breakage.
I can fix this by setting the IRQ type elsewhere in the hx4700 platform beforehand. But wouldn't it be better for soc_pcmcia_hw_init() (or whatever) to set the IRQ type before it calls request_irq() ?
Quoted 8 lines
Quoted 1 line
+???
state->detect=(
gpio_get_value(GPIOD4_CF_nCD)== 0);Quoted 1 line
+???
state->ready=(
gpio_get_value(GPIO60_HX4700_CF_RNB)!= 0);
soc_commonreads these for you before calling yoursocket_state
function.
OK.
Quoted 5 lines
Quoted 2 lines
+???
state->bvd1= 1;
+???state->bvd2= 1;If you don't have the BVD signals,
soc_commonnow defaults these to '1'.
OK.
Quoted 3 lines
Quoted 1 line
+???
state->wrprot= 0;You don't need to set this -
soc_commonsets this to zero.
OK.
Quoted 16 lines
Quoted 1 line
+??? pdev =
platform_device_alloc("pxa2xx-pcmcia", -1);Quoted 4 lines
+??? if (!pdev)
+??? ??? return-ENOMEM;
+
+??? ret =platform_device_add_data(pdev,
Quoted 1 line
+??? ???
&hx4700_pcmcia_ops,sizeof(hx4700_pcmcia_ops));Quoted 6 lines
+??? if (ret)
+??? ??? goto out;
+
+??? ret =platform_device_add(pdev);
+??? if (ret)
+??? ??? goto out;
Quoted 6 lines
??? pdev =
platform_device_register_data(NULL, "pxa2xx-pcmcia", -1, ??? ???&hx4700_pcmcia_ops,sizeof(hx4700_pcmcia_ops)); ??? if (IS_ERR(pdev))
??? ??? returnPTR_ERR(pdev);
Yes, that looks simpler.
PATCH v4 1/2 pxa/hx4700: Add PCMCIA/CF support
Quoted 11 lines · Paul Parsons
Quoted 4 lines · Russell King - ARM Linux
irq_set_irq_type(gpio_to_irq(GPIOD4_CF_nCD),
IRQ_TYPE_EDGE_BOTH);You shouldn't need to set the IRQ type for this.
If I don't set the IRQ type then it doesn't get set before the interrupt is unmasked in
request_irq(). On the hx4700 the default IRQ type is level triggered low level detect, which is exactly the signal present on the (active low) CF card detect GPIO at boot. Consequently the interrupt handler is called repeatedly, resulting in some breakage.
That's rather unfortunate.
Quoted 3 lines
I can fix this by setting the IRQ type elsewhere in the hx4700 platform beforehand. But wouldn't it be better for
soc_pcmcia_hw_init()(or whatever) to set the IRQ type before it callsrequest_irq()?
The big problem I have against this is: what if request_irq() returns -EBUSY because someone else is using the interrupt? Having the core call irq_set_irq_type() on these IRQs before it's claimed it would be asking for trouble. request_irq() is the resource allocation function for interrupts - as part of its operation, it ensures exclusivity to the interrupt.
It's unfortunate that genirq got rid of my 'request an interrupt but don't enable it' facility which we had in the ARM IRQ code...
I think we'll just have to live with it where you've placed it, but please ensure that you add a comment about _why_ it's needed. In years to come, the reason you've put it there will have been forgotten and it's the kind of thing which will get easily broken without such a comment.