Re: [PATCH] drivers/pcmcia: Convert timers to use timer_setup()

2017-10-27 Thread Russell King - ARM Linux
On Tue, Oct 24, 2017 at 03:23:31AM -0700, Kees Cook wrote:
> In preparation for unconditionally passing the struct timer_list pointer to
> all timer callbacks, switch to using the new timer_setup() and from_timer()
> to pass the timer pointer explicitly.
> 
> Cc: Florian Fainelli 
> Cc: bcm-kernel-feedback-l...@broadcom.com
> Cc: David Howells 
> Cc: Arnd Bergmann 
> Cc: linux-pcmcia@lists.infradead.org
> Cc: linux-arm-ker...@lists.infradead.org
> Signed-off-by: Kees Cook 
> ---
>  drivers/pcmcia/bcm63xx_pcmcia.c | 6 +++---
>  drivers/pcmcia/bfin_cf_pcmcia.c | 6 +++---
>  drivers/pcmcia/i82365.c | 6 ++
>  drivers/pcmcia/omap_cf.c| 8 
>  drivers/pcmcia/pd6729.c | 7 +++
>  drivers/pcmcia/soc_common.c | 7 +++
>  drivers/pcmcia/tcic.c   | 8 +++-
>  drivers/pcmcia/yenta_socket.c   | 7 +++
>  8 files changed, 24 insertions(+), 31 deletions(-)

For soc_common.c:

Acked-by: Russell King 

Thanks.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 16/28] pcmcia: fix return value of soc_pcmcia_regulator_set

2016-10-18 Thread Russell King - ARM Linux
On Tue, Oct 18, 2016 at 12:13:37AM +0200, Arnd Bergmann wrote:
> The newly introduced soc_pcmcia_regulator_set() function sometimes returns
> without setting its return code, as shown by this warning:
> 
> drivers/pcmcia/soc_common.c: In function 'soc_pcmcia_regulator_set':
> drivers/pcmcia/soc_common.c:112:5: error: 'ret' may be used uninitialized in 
> this function [-Werror=maybe-uninitialized]
> 
> This changes it to propagate the regulator_disable() result instead.

I guess this is the problem with the stupid patch which silences this
warning - I don't see this warning here.

Having this warning disabled means that _real_ coding errors end up
making their way into the kernel (yes, this should be an error, this
is not a warning, because the value of 'ret' is completely undefined,
and therefore the behaviour of the following code is undefined.)

With the warning silenced, it means that such errors are undetectable.
I knew nothing about this until I received this patch, and I always
check that the code I send is warning-free on the GCC I'm using.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 10/33] pcmcia: soc_common: switch to using gpio_descs

2016-09-14 Thread Russell King - ARM Linux
On Wed, Sep 14, 2016 at 01:29:04PM +0200, Linus Walleij wrote:
> On Mon, Aug 29, 2016 at 12:24 PM, Russell King
>  wrote:
> 
> > Switch to using the gpiod_* consumer API rather than the legacy API.
> >
> > Signed-off-by: Russell King 
> (...)
> 
> > +int soc_pcmcia_request_gpiods(struct soc_pcmcia_socket *skt)
> > +{
> > +   int i;
> > +
> > +   for (i = 0; i < ARRAY_SIZE(skt->stat); i++) {
> > +   struct gpio_desc *desc;
> > +
> 
> Here I inserted:
> 
> /* Skip over unnamed GPIOs, assume unused */
> if (!skt->stat[i].name)
> continue;
> 
> to get it working again on h3600.

Thanks, I'll add that.

> > +   desc = gpiod_get(skt->socket.dev.parent,
> > +skt->stat[i].name, GPIOD_IN);
> > +   if (IS_ERR(desc)) {
> > +   dev_err(skt->socket.dev.parent,
> > +   "Failed to get GPIO for %s: %ld\n",
> > +   skt->stat[i].name, PTR_ERR(desc));
> > +   __soc_pcmcia_hw_shutdown(skt, i);
> > +   return PTR_ERR(desc);
> > +   }
> 
> 
> It bugs out for me on the legacy h3600, since it only defines
> two of these pins not all of the ARRAY_SIZE(skt->stat) pins
> will succeed and we get an error message like this:
> 
> sa11x0-pcmcia sa11x0-pcmcia: Failed to get GPIO for (null): -2
> sa11x0-pcmcia: probe of sa11x0-pcmcia failed with error -2
> 
> With the patch above it goes away and the log is silent.
> The debugfs gpio file looks like this:
> 
> cat gpio
> gpiochip0: GPIOs 0-27, gpio:
>  gpio-0   (|Power Button) in  hi
>  gpio-10  (|pcmcia1-detect  ) in  hi
>  gpio-11  (|pcmcia1-ready   ) in  hi
>  gpio-17  (|pcmcia0-detect  ) in  hi
>  gpio-18  (|Action button   ) in  hi
>  gpio-21  (|pcmcia0-ready   ) in  hi
>  gpio-23  (|dcd ) in  hi
>  gpio-25  (|cts ) in  lo
>  gpio-26  (|rts ) out lo
> 
> gpiochip1: GPIOs 28-43, parent: platform/htc-egpio, htc-egpio:
>  gpio-28  (|Flash Vpp   ) out lo
>  gpio-29  (|PCMCIA CARD RESET   ) out lo
>  gpio-30  (|OPT RESET   ) out lo
>  gpio-32  (|OPT NVRAM ON) out lo
>  gpio-33  (|OPT ON  ) out lo
>  gpio-34  (|LCD power   ) out lo
>  gpio-36  (|LCD control ) out lo
>  gpio-42  (|LCD 5v  ) out lo
>  gpio-43  (|LCD 9v/-6.5v) out lo
> 
> Which seems like before the patch series.

Yay.

> I still suspect the PCMCIA is not really working but I have
> limited experience of the bus so I don't really know how
> to test it deeply or have my PCMCIA ethernet or harddrive
> probe properly.

Yes, to me the H3600 code looks really really really weird - the way
H3XXX_EGPIO_CARD_RESET is "shared" (badly) between both sockets is
certainly racy.  I've no idea what the semantics there are supposed
to be - I suspect that H3600 PCMCIA hasn't worked for a very long
time, or if it has, it's probably not been reliable.

> There are no regressions however, so with something like
> the above patch applied:
> Tested-by: Linus Walleij 
> 
> For the whole patch series on H3600.

Thanks!

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 18/33] pcmcia: sa1100: provide generic CF support

2016-09-14 Thread Russell King - ARM Linux
On Wed, Sep 14, 2016 at 10:52:39AM +0200, Linus Walleij wrote:
> On Mon, Aug 29, 2016 at 12:25 PM, Russell King
>  wrote:
> 
> > Provide generic non-voltage sensing socket support for StrongARM
> > platforms using the gpiolib and regulator subsystems to obtain the
> > resources to control the socket.
> >
> > Signed-off-by: Russell King 
> (...)
> 
> > +static int sa11x0_drv_pcmcia_probe(struct platform_device *pdev)
> > +{
> > +   struct soc_pcmcia_socket *skt;
> > +   struct device *dev = >dev;
> > +
> > +   if (dev->id == -1)
> > +   return sa11x0_drv_pcmcia_legacy_probe(pdev);
> 
> There is a typo there, it should be pdev->id rather than dev->id.
> 
> After fixing this, my legacy h3600 PCMCIA started probing again.

Thanks, I've included a change there, should be part of the branch by
the time you get this email - sa1100 head should be 9ad0f8181616.  If
not, it's probably still being pushed out over my slow 'net link.

> (It revealed another bug in fetching GPIOs but it is an orthogobal
> problem altogether, looking into it.)

If you're referring to the generic sa1100 pcmcia code, there's a fix
for that already in my branch.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 8/8] ARM: pxa/lubbock: add pcmcia clock

2016-09-07 Thread Russell King - ARM Linux
On Tue, Sep 06, 2016 at 07:17:09PM +0200, Robert Jarzmik wrote:
> Russell King  writes:
> 
> > Add the required PCMCIA clock for the SA "1800" device.  This clock
> > is used to compute timing information for the PCMCIA interface in the
> > SoC device, rather than the SA.  Hence, the provision of this clock
> > is a convenience for the driver and does not reflect the hardware, so
> > this must not be copied into DT.
> >
> > Signed-off-by: Russell King 
> Acked-by: Robert Jarzmik 
> But more importantly:
> Tested-by: Robert Jarzmik 

Thanks Robert.  I guess no one else is be interested in these patches,
so I'm going to drop them into -next today, and send them on Friday or
over this weekend.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 0/3] SA11x0/PXA pcmcia fixes

2016-09-06 Thread Russell King - ARM Linux
On Mon, Aug 29, 2016 at 11:02:32AM +0100, Russell King - ARM Linux wrote:
> Further to the DS suspend/resume fix, here's a few more for SA11x0/PXA.
> 
>  drivers/pcmcia/sa11xx_base.c | 8 
>  drivers/pcmcia/soc_common.c  | 2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)

If no one objects, I'll queue these three fixes for -rc6 as well.

Thanks.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-09-05 Thread Russell King - ARM Linux
On Mon, Sep 05, 2016 at 11:06:28AM +0200, Linus Walleij wrote:
> I couldn't resist testing on the Compaq iPAQ h3600. It works the
> same as before so:
> Tested-by: Linus Walleij  [for Compaq iPAQ H3600]

Great news.  I've been thinking about digging out my h3600, but it's
very old, and hasn't been turned on for many years.  I'm not sure what
state it's in.

I've been hoping to try booting some kernels with qemu-system-arm, but
so far I've completely failed to get qemu-system-arm to do anything
useful - it just sits there doing apparently nothing, irrespective of
which platform I choose or which kernel I give it.

> The only news in the bootlog is this:
> sa11x0-pcmcia: probe of sa11x0-pcmcia failed with error -2

Not so great news - that's -ENOENT.  Did that happen before these
changes?  That could be that the gpiod lookup table isn't found.
However, if that were the case, I'd have expected an error message
along the lines of:

Failed to get GPIO for xxx: -nnn

from soc_pcmcia_request_gpiods().  The other possibility is that
we're not getting to sa11x0_drv_pcmcia_legacy_probe() but instead
trying to initialise it as a generic sa11x0 socket, and
sa11x0_pcmcia_hw_init() is failing as a result.

We should be using the legacy probe on H3600, so sa11x0_pcmcia_hw_init()
should never be reached.

> This device does have a PCMCIA "sleeve" where I slotted in an
> ethernet card at one time to see if I could network this thing.
> But I never got the PCMCIA working. Now it seems like I could
> actually start looking into that as the driver gives its first sign
> of life.
> 
> I don't think PCMCIA ever worked on this thing upstream,
> but I have a copy of the old linux-handheld kernel tree where
> it supposedly was working at one point.

Well, the H3600 PCMCIA driver raises lots of "that can't be right"
questions for me, so I decided to leave most of the GPIO stuff alone
there, and just convert only the bits which made sense to me - the
detect and ready(irq) bits.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-09-04 Thread Russell King - ARM Linux
On Sun, Sep 04, 2016 at 09:04:59PM +0200, Robert Jarzmik wrote:
> And retested with my 3 patches on top of it. Everything works fine :
>  - CF insertion is correctly detected now !
>  - AT/2 keyboard interrupts fire, keys are there, etc ...
>  - the AT/2 warning is now gone
> 
> The pxa_cplds_irqs patch will make it work as before, better than today for
> sure. I think edge type interrupts (such as sa), if they come close 
> enough,
> might be lost with the current implementation, but anyway, that's for another
> time.

Good news, but I suspect CF probably isn't working as it should do (see
my reply to the clock alias patch.)

> There is one patch in my serie that I left up to you, as I wasn't very sure
> about the accuracy of my commit message, nor been able to write down all the
> requirements implied on sa with this additional test.

That's basically what I have here at the moment, but since I made the
suggestion, I've been thinking about moving it into the IRQ
initialisation instead.

Also, I think it's a genirq problem that you can install a chained
handler on an interrupt without a registered chip - and then when an
irq chip comes along later, the IRQ isn't unmasked.  We should either
not allow a chained handler to be installed in that situation, /or/
we should unmask chained IRQs when the chip comes along later.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-09-03 Thread Russell King - ARM Linux
On Fri, Sep 02, 2016 at 11:21:12PM +0200, Robert Jarzmik wrote:
> It looks that I have an ordering problem :
>  - I want gpio-pxa.probe() to be called at device initcall time
>  - pxa_cplds_irqs.probe() cannot complete before gpio-pxa.probe() because it
>needs GPIO0 as its interrupt source
>=> it might need to honor -EPROBE_DEFER
>  - sa.sa_probe() cannot complete before pxa_cplds_irqs.probe() because
>it needs IRQ305 as its source
>=> it might need to honor -EPROBE_DEFER

I wonder if we can work around that by adding this to sa_probe():

if (!irq_get_chip(irq))
return -EPROBE_DEFER;

It's not particularly nice, but it should at least ensure that things
happen in the right order.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-09-03 Thread Russell King - ARM Linux
On Thu, Sep 01, 2016 at 09:19:13AM +0200, Robert Jarzmik wrote:
> >From 977c16201a752aac8a8fb2da1f4271795f0b2122 Mon Sep 17 00:00:00 2001
> From: Robert Jarzmik 
> Date: Thu, 1 Sep 2016 08:31:08 +0200
> Subject: [PATCH] pcmcia: lubbock: fix sockets configuration
> 
> On lubbock board, the probe of the driver crashes by dereferencing very
> early a platform_data structure which is not set, in
> pxa2xx_configure_sockets().

Patch applied, with some fixups for the error code propagation changes
and edited the patch description a little.

Thanks.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-09-02 Thread Russell King - ARM Linux
On Fri, Sep 02, 2016 at 07:50:35PM +0200, Robert Jarzmik wrote:
> Russell King - ARM Linux <li...@armlinux.org.uk> writes:
> >> Moreover, I have a bit of homework as I also see :
> >>  - no SA interrupts at all, especially nothing when I insert/remove my
> >>CompactFlash card
> >>This might be an effect of pxa_cplds_irqs.c I created, I must have a 
> >> look.
> >
> > Do you get other SA interrupts (eg, the PS/2 interrupts) delivered?
> I see no other interrupts at all.
> Actually I see no interrupt claimed in /proc/interrupts, where I would have
> expected interrupt 305.
>   cat /proc/interrupts
>  CPU0   
>24:   1419SC   8 Edge  gpio-0
>25:  0SC   9 Edge  gpio-1
>26:  0SC  10 Edge  gpio-mux
>38:118SC  22 Edge  UART1
>41:  0SC  25 Edge  DMA
>42:  40224SC  26 Edge  ost0
>   112:   1419  GPIO   0 Edge  pxa_cplds_irqs
>   307:   1419  pxa_cplds   3 Edge  eth0
>   387:  0  SA-h Edge  SA PCMCIA card detect
>   388:  0  SA-h Edge  SA CF card detect
>   389:  0  SA-h Edge  SA PCMCIA BVD1
>   390:  0  SA-h Edge  SA CF BVD1
>   Err:  0
> 
> Actually this leads me to think that this interrupt 305 is not "requested" nor
> activated. I see in sa.c:506 :
>   "irq_set_chained_handler_and_data(sachip->irq, sa_irq_handler, ..."
> This puts in the handler and data, but I don't this is "enables" the 
> interrupt,
> right ?

It should enable the interrupt - the end of that does:

if (handle != handle_bad_irq && is_chained) {
irq_settings_set_noprobe(desc);
irq_settings_set_norequest(desc);
irq_settings_set_nothread(desc);
desc->action = _action;
irq_startup(desc, true);
}

and indeed, I see that it gets enabled on Assabet.  That irq_startup()
should result in the irqchip's irq_startup, irq_enable, or irq_unmask
method being called.

So, that should result in the IRQ to which the sa is connected
being unmasked.

Chained interrupts don't appear in /proc/interrupts.

> I traced the code in the interrupt controller (pxa_cplds_irqs), the SA
> physical line is not set (even with an AT/2 keyboard connected, and I don't
> think anybody tried this AT/2 on a lubbock for a long time).

Hmm.  Looking at pxa_cplds_irqs, that's trying to support the CPLD
interrupts using a very very old and inefficient technique.  The
whole point of the chained interrupt system is to avoid several
overheads in the system...  I'm curious why PXA moved away from that.

One of the problems is that we end up nesting irq_entry()/irq_exit()
which contains a lot of code, eg trying to run softirqs.  All that
stuff is pure overhead because we'll never get to run anything like
that in this path.

I'm also very concerned that the conversion is wrong.  The old code
has this comment in the irq_unmask function:

-   /* the irq can be acknowledged only if deasserted, so it's done here */
-   LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq);

In other words, we "acknowledge" (really clear the latched status) of
the interrupt _after_ we've serviced the peripheral, not before.
The new code tries to clear down the interrupt when masking it - in
other words, before the peripheral handler has had a chance to clear
down its interrupt.

I suspect you're seeing about twice as many interrupt counts on your
ethernet interface because of this - you'll be entering the handler
once for the real interrupt, but because the clear-down was ineffective,
you end up re-entering it a second time when hopefully the peripheral
is no longer asserting the interrupt.

> The interrupt is for sure masked, and therefore the SA interrupts are not
> fired. Even if they would have been enabled, the "pending interrupts register"
> doesn't show any sa interrupt pending, so there is something else.

Masked where though - in the SA or FPGA?

> As I don't know if "enable_irq()" in sa.c would be an option as I have no
> sight on sa.c requirements, I would take any advice here.

It shouldn't be required, as I say above, irq_set_chained_handler_and_data()
deals with unmasking the IRQ already.

> > Hmm, on Neponset with a CF card inserted, I can cat that, and it reports
> > the CIS.  Any error messages in the kernel log?
> None.
> I have an ever more suprising thing.
> I tried again this morning, without changing a single line of code (excepting 
> in
> pxa_cplds_irqs.c) nor touchi

Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-09-02 Thread Russell King - ARM Linux
Linus,

There's a change I'd like to merge into patch 5 - overall it looks
like the below, and allows us to use gpio-reg with the PXA mainstone
MST_PCMCIA[01] registers.  Some of these GPIO signals have hardware
interrupts associated with them, but not all.

Do you approve?

Thanks.

8<
From: Russell King 
Subject: [PATCH] gpio: gpio-reg: add irq mapping for gpio-reg users

Add support for mapping gpio-reg gpios to interrupts.  This may be a
non-linear mapping - some gpios in the register may not even have
corresponding interrupts associated with them, so we need to pass an
array.

Signed-off-by: Russell King 
---
 arch/arm/mach-pxa/lubbock.c |  2 +-
 arch/arm/mach-sa1100/assabet.c  |  2 +-
 arch/arm/mach-sa1100/neponset.c |  2 +-
 drivers/gpio/gpio-reg.c | 25 +++--
 include/linux/gpio/gpio-reg.h   |  3 ++-
 5 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 1f7bfabfa4eb..cd401546cea8 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -477,7 +477,7 @@ static void __init lubbock_init(void)
 
lubbock_misc_wr_gc = gpio_reg_init(NULL, (void *)_MISC_WR,
   -1, 16, "lubbock", 0, LUB_MISC_WR,
-  NULL);
+  NULL, NULL, NULL);
if (IS_ERR(lubbock_misc_wr_gc)) {
pr_err("Lubbock: unable to register lubbock GPIOs: %ld\n",
   PTR_ERR(lubbock_misc_wr_gc));
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index 51950454afac..e086c609551c 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -120,7 +120,7 @@ static int __init assabet_init_gpio(void __iomem *reg, u32 
def_val)
writel_relaxed(def_val, reg);
 
gc = gpio_reg_init(NULL, reg, -1, 32, "assabet", 0xff00, def_val,
-  assabet_names);
+  assabet_names, NULL, NULL);
 
if (IS_ERR(gc))
return PTR_ERR(gc);
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
index 5abc04fb196d..b16de1f0d5d0 100644
--- a/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -240,7 +240,7 @@ static int neponset_init_gpio(struct gpio_chip **gcp,
struct gpio_chip *gc;
 
gc = gpio_reg_init(dev, reg, -1, num, label, in ? 0x : 0,
-  readl_relaxed(reg), names);
+  readl_relaxed(reg), names, NULL, NULL);
if (IS_ERR(gc))
return PTR_ERR(gc);
 
diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
index 561e28b4d3aa..39175d373871 100644
--- a/drivers/gpio/gpio-reg.c
+++ b/drivers/gpio/gpio-reg.c
@@ -19,6 +19,8 @@ struct gpio_reg {
u32 direction;
u32 out;
void __iomem *reg;
+   struct irq_domain *irqdomain;
+   const int *irqs;
 };
 
 #define to_gpio_reg(x) container_of(x, struct gpio_reg, gc)
@@ -96,6 +98,17 @@ static void gpio_reg_set_multiple(struct gpio_chip *gc, 
unsigned long *mask,
spin_unlock_irqrestore(>lock, flags);
 }
 
+static int gpio_reg_to_irq(struct gpio_chip *gc, unsigned offset)
+{
+   struct gpio_reg *r = to_gpio_reg(gc);
+   int irq = r->irqs[offset];
+
+   if (irq >= 0 && r->irqdomain)
+   irq = irq_find_mapping(r->irqdomain, irq);
+
+   return irq;
+}
+
 /**
  * gpio_reg_init - add a fixed in/out register as gpio
  * @dev: optional struct device associated with this register
@@ -104,7 +117,12 @@ static void gpio_reg_set_multiple(struct gpio_chip *gc, 
unsigned long *mask,
  * @label: GPIO chip label
  * @direction: bitmask of fixed direction, one per GPIO signal, 1 = in
  * @def_out: initial GPIO output value
- * @names: array of %num strings describing each GPIO signal
+ * @names: array of %num strings describing each GPIO signal or %NULL
+ * @irqdom: irq domain or %NULL
+ * @irqs: array of %num ints describing the interrupt mapping for each
+ *GPIO signal, or %NULL.  If @irqdom is %NULL, then this
+ *describes the Linux interrupt number, otherwise it describes
+ *the hardware interrupt number in the specified irq domain.
  *
  * Add a single-register GPIO device containing up to 32 GPIO signals,
  * where each GPIO has a fixed input or output configuration.  Only
@@ -114,7 +132,7 @@ static void gpio_reg_set_multiple(struct gpio_chip *gc, 
unsigned long *mask,
  */
 struct gpio_chip *gpio_reg_init(struct device *dev, void __iomem *reg,
int base, int num, const char *label, u32 direction, u32 def_out,
-   const char *const *names)
+   const char *const *names, struct irq_domain *irqdom, const int *irqs)
 {
struct gpio_reg *r;
int ret;
@@ -136,12 +154,15 @@ struct gpio_chip *gpio_reg_init(struct device 

Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-09-01 Thread Russell King - ARM Linux
On Thu, Sep 01, 2016 at 11:58:28PM +0200, Robert Jarzmik wrote:
> Russell King - ARM Linux <li...@armlinux.org.uk> writes:
> > On Thu, Sep 01, 2016 at 09:19:13AM +0200, Robert Jarzmik wrote:
> > It looks like:
> >
> > (a) pcmcia_probe() in drivers/pcmcia/sa_generic.c doesn't check the
> > return value from the platform specific init functions, meaning if
> > they fail, the driver still binds.  (note: they return -ENODEV to
> > indicate that they should skip to the next platform.)
> You're right, I submitted a patch for that, and I confirm it actually happens 
> on
> lubbock.

That'll work fine for lubbock, but not the others (we can have several
of the others enabled on sa11x0 platforms - eg, badge4 with neponset.)

> > (b) there is no clock provided for the sa pcmcia device (aka "1800").
> > This should be the same clock as pxa2xx-pcmcia.
> Again right in the spot.
> I added temporarily a clock until I have a more complete understanding in
> lubbock.c :
> + clk_add_alias(NULL, "1800", "SA_CLK", NULL);
> 
> With this, things look way better :
> [1.507480] pcmcia_socket pcmcia_socket1: pccard: PCMCIA card inserted 
> into slot 1

Yay!

> I'm still investigating the new message errors:
> [0.479157] genirq: Setting trigger mode 3 for irq 387 failed 
> (sa_type_highirq+0x0/0x6c)
> [0.488213] genirq: Setting trigger mode 3 for irq 389 failed 
> (sa_type_highirq+0x0/0x6c)
> [0.507449] genirq: Setting trigger mode 3 for irq 388 failed 
> (sa_type_highirq+0x0/0x6c)
> [0.516492] genirq: Setting trigger mode 3 for irq 390 failed 
> (sa_type_highirq+0x0/0x6c)

Ignore those for now - the old ARM IRQ stuff was silent on that, but genirq
is more noisy.  I should probably make the sa irqchip handle the both-
edge case itself.

> Moreover, I have a bit of homework as I also see :
>  - no SA interrupts at all, especially nothing when I insert/remove my
>CompactFlash card
>This might be an effect of pxa_cplds_irqs.c I created, I must have a look.

Do you get other SA interrupts (eg, the PS/2 interrupts) delivered?

>  - cat /sys/class/pcmcia_socket/pcmcia_socket1/cis 
>cat: read error: Input/output error
>That will cost me a review of the memory timings registers MCIO1/MECR/xxx,
>the power lines, etc ...

Hmm, on Neponset with a CF card inserted, I can cat that, and it reports
the CIS.  Any error messages in the kernel log?

>  - cat /sys/class/pcmcia_socket/pcmcia_socket1/status 
> slot : 1
> status   : SS_READY SS_DETECT SS_POWERON SS_3VCARD
> csc_mask : SS_DETECT
> cs_flags : SS_OUTPUT_ENA
> Vcc  : 33
> Vpp  : 33
> IRQ  : 0 (386)

That looks hopeful, but the IRQ hasn't been properly assigned (probably
because no driver has bound to the card.)

> >> As your gpios are contiguous (0 .. 31), why an array instead of a simple 
> >> offset
> >> so that your translation is only a linear irq = gpio + offset ?
> >
> > There isn't a linear translation here:
> ...zip...
> > MST_PCMCIA_nCD  => MAINSTONE_S0_CD_IRQ or MAINSTONE_S1_CD_IRQ
> > MST_PCMCIA_nSTSCHG_BVD1 => MAINSTONE_S0_STSCHG_IRQ or 
> > MAINSTONE_S1_STSCHG_IRQ
> > MST_PCMCIA_nIRQ => MAINSTONE_S0_IRQ or MAINSTONE_S1_IRQ
> >
> > So they aren't linear, and every "gpio" doesn't have a corresponding
> > interrupt.
> Ah yes, too bad, it would have been so much simpler.

Indeed, but a tabular approach isn't that painful, especially if we
also insist on knowing an irqdomain as well, which relieves us of
having to know absolute interrupt numbers, which may end up being
dynamically allocated eventually.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [RFC PATCH 00/33] SA11x0/PXA GPIO rework (Core + PCMCIA only)

2016-09-01 Thread Russell King - ARM Linux
On Tue, Aug 30, 2016 at 11:31:58PM +0200, Linus Walleij wrote:
> For all the GPIO patches:
> Acked-by: Linus Walleij 
> 
> With the smallish changes needed to patch 5/33 that one is acked too.
> 
> In fact I would ACK it anyway, because the net total cleanup is so
> nice on the kernel at large... SA11x0 has never been prettier than
> after this series.

Thanks, ack applied to all the gpio patches.

> I suspect you want to keep the series together and queue it in the ARM
> tree? Else tell me what to apply in the GPIO tree.

Yes, I need to keep the series together because of the dependencies -
trying to split it up will lead to conflicts and breakage from missing
include files, and when it's not from missing include files, it'll be
non-functional.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-08-31 Thread Russell King - ARM Linux
On Wed, Aug 31, 2016 at 09:49:38AM +0100, Russell King - ARM Linux wrote:
> On Tue, Aug 30, 2016 at 11:32:16PM +0200, Robert Jarzmik wrote:
> > Russell King - ARM Linux <li...@armlinux.org.uk> writes:
> > 
> > > If you can wait a day or two, I'll push a branch out for everything in
> > > all these multiple series.
> > Sure, just ping me when you have something.
> 
> git://git.armlinux.org.uk/~rmk/linux-arm.git sa1100
> 
> should get you something suitable to test.  It's based on 4.7-rc3 plus
> my fixes branch.
> 
> It would be great to have this tested on Lubbock, and get the PCMCIA
> issues fixed.  Maybe we can look at converting mainstone as well?

Yes, looking at mainstone's PCMCIA, it uses a MAX1602 device, which
is supported by the new max1600.c code.

#define MST_PCMCIA_PWR_VPP_00x0/* voltage VPP = 0V */
#define MST_PCMCIA_PWR_VPP_120  0x2/* voltage VPP = 12V*/
#define MST_PCMCIA_PWR_VPP_VCC  0x1/* voltage VPP = VCC */
#define MST_PCMCIA_PWR_VCC_00x0/* voltage VCC = 0V */
#define MST_PCMCIA_PWR_VCC_33   0x8/* voltage VCC = 3.3V */
#define MST_PCMCIA_PWR_VCC_50   0x4/* voltage VCC = 5.0V */

This follows the Cirrus code (also used by Lubbock.)  So, if we represent
the MST_PCMCIA[01] registers as GPIOs, we can switch pxa2xx_mainstone.c
to use the max1600.c code for power control.

With the other signals in MST_PCMCIA[01] represented as GPIOs (we'd
need to add the VS* to soc_common), we'd then have those read by
generic code, which means mst_pcmcia_socket_state() becomes just the
hack for STSCHG.

With gpio-reg, we can represent these registers easily as GPIOs, eg:

gc = gpio_reg_init(NULL, (void __iomem *)_PCMCIA0,
   -1, 11, "mst-pcmcia0", ~MST_PCMCIA_PWR_MASK, 0,
   mst_pcmcia_names);

There is a slight issue, which is that the interrupts can't be
translated to an interrupt by gpio-reg, which will currently cause
soc_common problems - but that's an easy fix, though leaves us with
more code than I'd desire in pxa2xx_mainstone.c.  Maybe a solution
there would be to have gpio-reg also take an array of interrupt
numbers... not sure yet.


For IrDA, it looks like it has the same transceiver as the assabet, so
I've (already) patches to split out the gpio-based transceiver control
from sa1100_ir - maybe we can re-use that in pxaficp_ir too.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-08-31 Thread Russell King - ARM Linux
On Tue, Aug 30, 2016 at 11:32:16PM +0200, Robert Jarzmik wrote:
> Russell King - ARM Linux <li...@armlinux.org.uk> writes:
> 
> > If you can wait a day or two, I'll push a branch out for everything in
> > all these multiple series.
> Sure, just ping me when you have something.

git://git.armlinux.org.uk/~rmk/linux-arm.git sa1100

should get you something suitable to test.  It's based on 4.7-rc3 plus
my fixes branch.

It would be great to have this tested on Lubbock, and get the PCMCIA
issues fixed.  Maybe we can look at converting mainstone as well?

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-08-30 Thread Russell King - ARM Linux
On Tue, Aug 30, 2016 at 11:25:19PM +0200, Linus Walleij wrote:
> On Mon, Aug 29, 2016 at 12:24 PM, Russell King
>  wrote:
> 
> > Add a simple, generic, single register fixed-direction GPIO driver.
> > This is able to support a single register where a fixed number of
> > bits are used for input and a fixed number of bits used for output.
> >
> > Signed-off-by: Russell King 
> 
> Clever, I like it!
> 
> >  include/linux/gpio-reg.h |  12 
> 
> Can we put this in include/linux/gpio/gpio-reg.h?
> 
> I try to do some scopeing to  there.

Sure, I'll just have to hunt through all the patches to find an occurance
of the include to fix them all up...

> > +#define to_gpio_reg(x) container_of(x, struct gpio_reg, gc)
> 
> You don't need that trickery anymore, just:
> 
> > +static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
> > +{
> > +   struct gpio_reg *r = to_gpio_reg(gc);
> 
> struct gpio_reg *r = gpiochip_get_data(gc);
> 
> (applied everywhere)

I prefer my method by a long shot - it's always going to work because
the gpiochip is embedded within the gpio_reg structure, and the compiler
is inteligent enough to keep a single pointer around.  With your
suggestion, the compiler has no idea that 'r' and 'gc' are actually
the same pointer, but a different type, and we end up having to carry
around identical pointers in two registers rather than just one.

It makes more sense to use gpiochip_get_data() if gpio_chip were a const
data structure that was never embedded, but the way *gpiochip_add*()
writes to the structure and the presence of members like "base" prevents
that.

> 
> > +   if (dev)
> > +   ret = devm_gpiochip_add_data(dev, >gc, r);
> > +   else
> > +   ret = gpiochip_add_data(>gc, r);
> 
> Aha both device and device-less, I see.

Yes, to avoid problems with the transition to it - the legacy APIs
(such as ASSABET_BCR_frob(), etc) can be called really early, so we
need the gpiochip available early as well so we can keep the legacy
APIs working until they can be killed off.  There's some corner
cases in the assabet code which make that difficult at the moment.

This whole patch set is still very much a work-in-progress - there's
more that needs doing, but I wanted to get _this_ out there so that
people can reviewing it, and hopefully get it queued for the next
merge window.

> Apart from that it looks nice, any other questionmarks were
> fixed in the other replies.
> 
> Yours,
> Linus Walleij

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-08-30 Thread Russell King - ARM Linux
On Tue, Aug 30, 2016 at 06:42:03PM +0200, Robert Jarzmik wrote:
> Russell King - ARM Linux <li...@armlinux.org.uk> writes:
> 
> > On Mon, Aug 29, 2016 at 09:39:54PM +0200, Robert Jarzmik wrote:
> >> Maybe this one would deserve a doxygen comment ?
> >
> > Does this solve it?
> Oh yes, that's very nice, especially the "1 = in" for which I have always a
> doubt.
> 
> Reviewed-by: Robert Jarzmik <robert.jarz...@free.fr>
> 
> I hope to have an "attempt" to test all your series on the lubbock board in 
> the
> next days. The "attempt" part is because last time I checked pcmcia support 
> was
> broken on lubbock (ie. CONFIG_PCMCIA_SA activated implies an Oops), and I
> don't remember having repaired it (and it's disabled on my test farm which is 
> a
> sign I was not very confident about this part).
> 
> If you happen to have somewhere a branch I can pull, with all your series (at
> least "[RFC PATCH 00/33] SA11x0/PXA GPIO rework (Core + PCMCIA only)" and
> "[PATCH 0/8] SA11x0/PXA remainder & cleanups"), that would spare me the 
> multiple
> git-am to make the test(s).

If you can wait a day or two, I'll push a branch out for everything in
all these multiple series.

Thanks.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-08-30 Thread Russell King - ARM Linux
On Tue, Aug 30, 2016 at 09:08:03AM +0300, Alexander Shiyan wrote:
> >Вторник, 30 августа 2016, 2:12 +03:00 от Russell King - ARM Linux 
> ><li...@armlinux.org.uk>:
> >
> >On Mon, Aug 29, 2016 at 09:39:54PM +0200, Robert Jarzmik wrote:
> >> Hi Russell,
> >> 
> >> Russell King < rmk+ker...@armlinux.org.uk > writes:
> >> 
> >> > Add a simple, generic, single register fixed-direction GPIO driver.
> >> > This is able to support a single register where a fixed number of
> >> > bits are used for input and a fixed number of bits used for output.
> >> >
> >> > Signed-off-by: Russell King < rmk+ker...@armlinux.org.uk >
> 
> There is a GPIO driver which already performs these tasks.
> Plaease take a look on the gpio-74xx-mmio driver.

I did, and no it doesn't, because:

1. It is either all-in or all-out, it doesn't support a mixture of
   fixed-directions for a single register.
2. It is DT-only, I need it for legacy platforms.
3. It uses the bgpio stuff, which is unsuitable for reasons already
   covered in a previous reply.

So, gpio-74xx-mmio is unsuitable.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 05/33] gpio: add generic single-register fixed-direction GPIO driver

2016-08-29 Thread Russell King - ARM Linux
On Mon, Aug 29, 2016 at 09:39:54PM +0200, Robert Jarzmik wrote:
> Hi Russell,
> 
> Russell King  writes:
> 
> > Add a simple, generic, single register fixed-direction GPIO driver.
> > This is able to support a single register where a fixed number of
> > bits are used for input and a fixed number of bits used for output.
> >
> > Signed-off-by: Russell King 
> > ---
> >  drivers/gpio/Kconfig |   6 ++
> >  drivers/gpio/Makefile|   1 +
> >  drivers/gpio/gpio-reg.c  | 139 
> > +++
> >  include/linux/gpio-reg.h |  12 
> >  4 files changed, 158 insertions(+)
> >  create mode 100644 drivers/gpio/gpio-reg.c
> >  create mode 100644 include/linux/gpio-reg.h
> >
> > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> > index 98dd47a30fc7..49bd8b89712e 100644
> > --- a/drivers/gpio/Kconfig
> > +++ b/drivers/gpio/Kconfig
> > @@ -365,6 +365,12 @@ config GPIO_RCAR
> > help
> >   Say yes here to support GPIO on Renesas R-Car SoCs.
> >  
> > +config GPIO_REG
> > +   bool
> So I suppose it is on purpose you forbid it to be a module. Is there a way to
> write either in the commit message or in the Kconfig this purpose, so that
> nobody on "purpose" changes this bool to tristate ?

The only forbidding is that it's used from code early at boot, so it has
to be available to the kernel for some of these platforms to function.
Even if it's changed to tristate, the select from these platforms would
force it to be built-in.

> > +   help
> > + A 32-bit single register GPIO fixed in/out implementation.  This
> > + can be used to represent any register as a set of GPIO signals.
> Another question I was asking myself was how it differenciated itself from
> gpio-mmio, ie. what brought the need for this driver that isn't available with
> gpio-mmio ?

gpio-mmio doesn't allow the fixed direction - it assumes that you always
have some form of direction register.  It also doesn't do the double-read
that's necessary for some platforms to get the "current" state of inputs.
It also doesn't do the "use 32-bit accessors even for smaller numbers of
GPIOs".  Lastly, it assumes that the current output state can be read
from the registers - this is not always the case (and is not the case for
Assabet.)

> I seem to understand that this is mainly for platform code, hence the
> "builtin only" necessity, and if I'm right a part of your cover letter
> could very well fit within this patch's commit message.

Apart from the missing MODULE_* tags and symbol exports, there's nothing
whic prohibits it becoming a module.

> > +static void gpio_reg_set_multiple(struct gpio_chip *gc, unsigned long 
> > *mask,
> > +   unsigned long *bits)
> > +{
> > +   struct gpio_reg *r = to_gpio_reg(gc);
> > +   unsigned long flags;
> > +
> > +   spin_lock_irqsave(>lock, flags);
> > +   r->out = (r->out & ~*mask) | *bits;
> Shouldn't this be :
>   r->out = (r->out & ~*mask) | (*bits & *mask);

Possibly, but the latter is redundant when used through gpiolib.

> > diff --git a/include/linux/gpio-reg.h b/include/linux/gpio-reg.h
> > new file mode 100644
> > index ..0352bec7319a
> > --- /dev/null
> > +++ b/include/linux/gpio-reg.h
> > @@ -0,0 +1,12 @@
> > +#ifndef GPIO_REG_H
> > +#define GPIO_REG_H
> > +
> > +struct device;
> > +
> > +struct gpio_chip *gpio_reg_init(struct device *dev, void __iomem *reg,
> > +   int base, int num, const char *label, u32 direction, u32 def_out,
> > +   const char *const *names);
> Maybe this one would deserve a doxygen comment ?

Maybe, but I've been told not to put such comments in header files.
I've already spent the last two weeks on this stuff (at the expense
of reading mail), I've not got around to thinking about any kind of
documentation.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 06/33] ARM: pxa/lubbock: add GPIO driver for LUB_MISC_WR register

2016-08-29 Thread Russell King - ARM Linux
On Mon, Aug 29, 2016 at 09:57:20PM +0200, Robert Jarzmik wrote:
> Russell King  writes:
> If gpio_reg_init() failed (and I know, the probability of a lack of memory at
> that stage of the kernel boot is ridiculous), this will end up as an NULL
> pointer dereference if either IRDA or PCMCIA is used.
> 
> If it's expected, then the the pr_err() below would deserve a pr_crit(). I 
> would
> as well take an option on a "panic()" if lubbock_misc_wr_gc allocation fails. 
> If
> not, maybe a not-NULL test on lubbock_misc_wr_gc is in order, even if that 
> would
> be "hidding under the carpet" and rather difficult to debug later.
> 
> Apart this detail point, it's good for me.

I'd prefer to kill the function entirely.  The PCMCIA user of it goes
later in the series, and all that's left are the three users in lubbock.c,
those being IrDA and ads7846.  I'd like to see pxaficp go the same way
as sa1100_ir - converting to using gpiolib gpiod* APIs to manage the
FIR mode select GPIO itself internally.

That leaves ads7846_cs(), and I'd be surprised if SPI didn't already of
wiring GPIOs up as chip selects.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[RFC PATCH 00/33] SA11x0/PXA GPIO rework (Core + PCMCIA only)

2016-08-29 Thread Russell King - ARM Linux
Following on from the PCMCIA fixes, this series reworks GPIO on SA11x0
and PXA platforms.  This is a subset of a larger series, which I'm
splitting up due to its size.  This part contains the base and PCMCIA
updates.  Further updates for IrDA drivers, DMA engine, serial, and
ethernet will follow in time.

Modern gpiolib provides us with a very flexible way to handle hardware
control and status signals without distributing board specifics in
drivers.  Legacy board files are able to describe the relationship
between physical GPIOs to drivers through gpio lookup tables, as well
as their polarity.

Drivers using the gpio descriptor APIs are able to lookup these GPIOs,
which may be optional, and binding to the appropriate GPIO provider.
What's even nicer is that this is forwards compatible with DT.

Several platforms provide "miscellaneous" control and status registers
which are very GPIO-like.  We add a fixed-direction GPIO driver to
gpiolib to support these, where the register address, number of GPIOs,
and their direction are all fixed at initialisation time.  This allows
(eg) the Assabet board control/status register, the Neponset control
and modem signal registers, and Lubbock miscellaneous write register
to be modelled as a set of GPIOs.

This permits us to implement reusable drivers for PCMCIA - we can
get rid of several board specific PCMCIA drivers in favour of a more
generic driver for the SoC.

Over the full series, we have a net increase in kernel LoC of less
than 200 lines, with the following significant changes:

 59 files changed, 1690 insertions(+), 1504 deletions(-)
 rename arch/arm/mach-sa1100/{include/mach => }/cerf.h (66%)
 delete mode 100644 arch/arm/mach-sa1100/include/mach/neponset.h
 rename arch/arm/mach-sa1100/{include/mach => }/nanoengine.h (69%)
 create mode 100644 drivers/gpio/gpio-reg.c
 create mode 100644 drivers/pcmcia/max1600.c
 create mode 100644 drivers/pcmcia/max1600.h
 delete mode 100644 drivers/pcmcia/sa1100_assabet.c
 delete mode 100644 drivers/pcmcia/sa1100_cerf.c
 delete mode 100644 drivers/pcmcia/sa1100_nanoengine.c
 create mode 100644 include/linux/gpio-reg.h
 delete mode 100644 include/linux/platform_data/irda-sa11x0.h
 delete mode 100644 include/linux/sa11x0-dma.h

However, deleting the unused SA-1101.h header file gives is a net
decrease in LoC.

For this series only:

 arch/arm/common/sa.c| 227 ++
 arch/arm/include/asm/hardware/sa.h  |   4 -
 arch/arm/mach-pxa/Kconfig   |   1 +
 arch/arm/mach-pxa/lubbock.c |  40 -
 arch/arm/mach-sa1100/Kconfig|   1 +
 arch/arm/mach-sa1100/assabet.c  | 130 +--
 arch/arm/mach-sa1100/cerf.c |  18 ++-
 arch/arm/mach-sa1100/clock.c|   2 +
 arch/arm/mach-sa1100/generic.c  |  14 +-
 arch/arm/mach-sa1100/generic.h  |   3 +
 arch/arm/mach-sa1100/h3xxx.c|  17 ++
 arch/arm/mach-sa1100/include/mach/assabet.h |   6 -
 arch/arm/mach-sa1100/jornada720.c   |  12 ++
 arch/arm/mach-sa1100/nanoengine.c   |  23 +++
 arch/arm/mach-sa1100/neponset.c | 172 +---
 arch/arm/mach-sa1100/shannon.c  |  13 ++
 arch/arm/mach-sa1100/simpad.c   |  12 ++
 drivers/gpio/Kconfig|   6 +
 drivers/gpio/Makefile   |   1 +
 drivers/gpio/gpio-reg.c | 139 
 drivers/gpio/gpio-sa1100.c  | 218 -
 drivers/pcmcia/Kconfig  |   5 +
 drivers/pcmcia/Makefile |   3 +-
 drivers/pcmcia/max1600.c| 119 ++
 drivers/pcmcia/max1600.h|  31 
 drivers/pcmcia/sa1100_assabet.c | 106 -
 drivers/pcmcia/sa1100_cerf.c|  92 ---
 drivers/pcmcia/sa1100_generic.c | 129 +--
 drivers/pcmcia/sa1100_generic.h |   3 -
 drivers/pcmcia/sa1100_h3600.c   |  16 +-
 drivers/pcmcia/sa1100_nanoengine.c  | 133 
 drivers/pcmcia/sa1100_shannon.c |  29 +---
 drivers/pcmcia/sa1100_simpad.c  |  16 +-
 drivers/pcmcia/sa_generic.h |   1 +
 drivers/pcmcia/sa_jornada720.c  |  81 ++
 drivers/pcmcia/sa_lubbock.c | 110 +++--
 drivers/pcmcia/sa_neponset.c|  79 +++--
 drivers/pcmcia/soc_common.c | 238 +++-
 drivers/pcmcia/soc_common.h |  24 ++-
 include/linux/gpio-reg.h|  12 ++
 40 files changed, 1400 insertions(+), 886 deletions(-)
 create mode 100644 drivers/gpio/gpio-reg.c
 create mode 100644 drivers/pcmcia/max1600.c
 create mode 100644 drivers/pcmcia/max1600.h
 delete mode 100644 drivers/pcmcia/sa1100_assabet.c
 delete mode 100644 

[PATCH 0/3] SA11x0/PXA pcmcia fixes

2016-08-29 Thread Russell King - ARM Linux
Further to the DS suspend/resume fix, here's a few more for SA11x0/PXA.

 drivers/pcmcia/sa11xx_base.c | 8 
 drivers/pcmcia/soc_common.c  | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH] pcmcia: ds: fix suspend/resume

2016-08-27 Thread Russell King - ARM Linux
On Sat, Aug 27, 2016 at 02:05:22PM +0200, Dominik Brodowski wrote:
> Russell,
> 
> On Sun, Aug 21, 2016 at 12:05:30AM +0100, Russell King wrote:
> > PCMCIA suspend/resume no longer works since the commit mentioned below,
> > as the callbacks are no longer made.  Convert the driver to the new
> > dev_pm_ops, which restores the suspend/resume functionality.  Tested on
> > the arm arch Assabet platform with a pcnet_cs CF card.
> > 
> > Fixes: aa8e54b559479 ("PM / sleep: Go direct_complete if driver has no 
> > callbacks")
> > Signed-off-by: Russell King 
> 
> Looks goot to me. Can you push it upstream, please?

I can do - should I take that as an Acked-by?

Thanks.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 0/8] sa11x0 PCMCIA updates

2015-07-15 Thread Russell King - ARM Linux
A series of PCMCIA updates for SA11x0/PXA devices consisting mainly
of patches switching the code to use the devm_* APIs, thus cleaning the
code up.

The first patch fixes an omitted clk_put() in sa11xx_base.c by switching
the clk_get to devm_clk_get().

 drivers/pcmcia/pxa2xx_base.c| 17 +
 drivers/pcmcia/sa1100_generic.c |  2 --
 drivers/pcmcia/sa_generic.c | 14 +++---
 drivers/pcmcia/sa11xx_base.c| 17 ++---
 drivers/pcmcia/soc_common.h |  1 -
 5 files changed, 14 insertions(+), 37 deletions(-)

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH] Drivers: pcmcia: Fix memroy leak in sa11xx_drv_pcmcia_probe()

2015-04-22 Thread Russell King - ARM Linux
On Wed, Apr 22, 2015 at 04:25:48PM +0800, Firo Yang wrote:
 From: Firo Yang fir...@gmail.com
 
 Allocated clk was never freed if kzalloc() failed to alloc memory
 for skt_dev_info *sinfo. So just free clk when kzalloc() failed.

A similar patch was posted in March, and in March I posted a series
which addresses this in a better manner.

See the thread starting with message id
20150326112254.gz8...@n2100.arm.linux.org.uk

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 4/8] pcmcia: pxa2xx: convert memory allocation to devm_* API

2015-03-28 Thread Russell King - ARM Linux
On Sat, Mar 28, 2015 at 10:38:24PM +0100, Robert Jarzmik wrote:
 Russell King rmk+ker...@arm.linux.org.uk writes:
 
  Convert the pxa2xx socket driver memory allocation to use devm_kzalloc()
  to simplify the cleanup path.
 
  Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
  ---
   drivers/pcmcia/pxa2xx_base.c | 8 +++-
   1 file changed, 3 insertions(+), 5 deletions(-)
 
  diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
  index 197c77a64ce0..dfcf07828605 100644
  --- a/drivers/pcmcia/pxa2xx_base.c
  +++ b/drivers/pcmcia/pxa2xx_base.c
  @@ -302,7 +302,8 @@ static int pxa2xx_drv_pcmcia_probe(struct 
  platform_device *dev)
   
  pxa2xx_drv_pcmcia_ops(ops);
   
  -   sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops-nr), GFP_KERNEL);
  +   sinfo = devm_kzalloc(pdev-dev, SKT_DEV_INFO_SIZE(ops-nr),
 There is a typo here : pdev-dev should be dev-dev.
 
 Now given that fix, you can add my :
 Tested-by: Robert Jarzmik robert.jarz...@free.fr
 
 This test of mine is rather cheap :
  - it relies on 4.0-rc4
  - I don't have any PCMCIA card to insert in the lubbock, hence the cheap
  - I judge that pcmcia is working because :
- cat /proc/iomem gives:
  1000-10001fff : sa
1400-15ff : 0400
1800-19ff : 0800
1a00-1bff : 0a00
  1a00-1bff : sa-ps2
1c00-1dff : 0c00
  1c00-1dff : sa-ps2
10001600-100017ff : irq
10001800-100019ff : 1800
  10001800-100019ff : sa-pcmcia
 - I don't see any error message in kernel log
 
 As a side note mainly to myself, the pcmcia is broken on pxa2xx architectures
 and panics the kernel at boot time because :
  - in drivers/pcmcia/sa_lubbock.c I see :
pcmcia_lubbock_init()
  pxa2xx_configure_sockets(sadev-dev);
here it is expected that platform_data contains the pcmcia ops, but 
 it's
NULL, and the dereferencing in pxa2xx_configure_sockets() of ops-first
panics.

I guess it's broken as a result of 5b703683b6cc3cb97bbe6b1b14898b273eb59279
which added that call without really understanding the call path.  I
don't see any solution other than partially reverting that commit.
As can be seen from the commit message, this was done blindly with no
testing - so it's no surprise that it broke.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCHv2] pcmcia:Fix memory leak in the function, sa11xx_drv_pcmcia_probe

2015-03-26 Thread Russell King - ARM Linux
On Wed, Mar 25, 2015 at 11:15:52PM -0400, Nicholas Krause wrote:
 This fixes the memory found when running  coccinelle on the latest

How does this fix the memory ?  Is the memory faulty?

 kernel tree for if we are unable to successfully allocate memory
 for the structure pointer,sinfo of type skt_dev_info and need to
 clean up the memory already allocated to the clk structure pointer,
 clk by calling clk_get on it and freeing the no longer required
 mermory for this structure pointer.

This makes no sense.  clk_get() itself doesn't allocate any memory.  As
usual, you act as a mechanical automatom which doesn't understand what
you're doing or you just guess.  I don't care which it is, you are a
danger to the kernel by doing this.  As many other experienced kernel
developers have told you, please stop.

In any case, I'm NAKing your patch as there's better ways to solve this.
That's where experience and research come in.

Nevertheless, thanks for pointing out the oversight, and I notice that
there are a few more cases too.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 0/8] sa11x0 PCMCIA updates

2015-03-26 Thread Russell King - ARM Linux
Here's a collection of patches which cleans up and updates the SA11x0
and PXA2xx socket drivers, particularly converting them to the devm_*
APIs to ensure that resources are properly cleaned up.

I've stopped short of totally converting sa_generic as there are
some corner cases where we want to initialise only socket 1, but not
socket 0, which would require further testing to ensure that these
changes are correct.

I will be testing the sa11x0 changes later today, but as I gave most
of my PXA2xx platforms to Robert, I need Robert to test this on the
Lubbock.

 drivers/pcmcia/pxa2xx_base.c| 17 +
 drivers/pcmcia/sa1100_generic.c |  2 --
 drivers/pcmcia/sa_generic.c | 14 +++---
 drivers/pcmcia/sa11xx_base.c| 17 ++---
 drivers/pcmcia/soc_common.h |  1 -
 5 files changed, 14 insertions(+), 37 deletions(-)

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCHv2] pcmcia:Fix memory leak in the function, sa11xx_drv_pcmcia_probe

2015-03-26 Thread Russell King - ARM Linux
On Thu, Mar 26, 2015 at 07:14:38AM -0400, Nicholas Krause wrote:
 
 
 On March 26, 2015 5:52:25 AM EDT, Russell King - ARM Linux 
 li...@arm.linux.org.uk wrote:
 On Wed, Mar 25, 2015 at 11:15:52PM -0400, Nicholas Krause wrote:
  This fixes the memory found when running  coccinelle on the latest
 
 How does this fix the memory ?  Is the memory faulty?
 
  kernel tree for if we are unable to successfully allocate memory
  for the structure pointer,sinfo of type skt_dev_info and need to
  clean up the memory already allocated to the clk structure pointer,
  clk by calling clk_get on it and freeing the no longer required
  mermory for this structure pointer.
 
 This makes no sense.  clk_get() itself doesn't allocate any memory.  As
 usual, you act as a mechanical automatom which doesn't understand what
 you're doing or you just guess.  I don't care which it is, you are a
 danger to the kernel by doing this.  As many other experienced kernel
 developers have told you, please stop.
 
 In any case, I'm NAKing your patch as there's better ways to solve
 this.
 That's where experience and research come in.
 
 Nevertheless, thanks for pointing out the oversight, and I notice that
 there are a few more cases too.
 Very well then I  guess my patch commit message was wrong. 

Again, you fail to understand what you are being told.  Please re-read
the paragraph which starts In any case, I'm NAKing your patch.

Your patch is one way to solve it, but there are other solutions too.
I've just posted a small patch series which addresses the issue you
have raised.  You need to perform no further action on this.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 2/6] PCI/arm: Use list_for_each_entry() for bus traversal

2014-02-13 Thread Russell King - ARM Linux
On Thu, Feb 13, 2014 at 09:13:59PM +0800, Yijing Wang wrote:
 Replace list_for_each() + pci_bus_b() with the simpler
 list_for_each_entry().
 
 Signed-off-by: Yijing Wang wangyij...@huawei.com

Acked-by: Russell King rmk+ker...@arm.linux.org.uk

-- 
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up.  Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was up to 13.2Mbit.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 1/5] arm: sa1100: add cpu clock

2013-11-12 Thread Russell King - ARM Linux
On Tue, Nov 12, 2013 at 07:32:08AM +0400, Dmitry Eremin-Solenikov wrote:
 Both SA1100 framebuffer and PCMCIA drivers require knowledge of cpu
 frequency to correctly program timings.  Currently they receive timing
 information by calling cpufreq_get(0).  However if cpu frequency driver
 is not enabled (e.g. due to unsupported DRAM chip/board on sa1110)
 cpufreq_get(0) returns 0, causing incorrect timings to be programmed.

I added a select statement back in 1937f5b91833e2e8e53bcc821fc7a5fbe6ccb9b5
which avoids this problem.  Does this not work?

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH,FIXED] PCMCIA card inserted, five s2ram cycles, you're dead

2012-01-22 Thread Russell King - ARM Linux
Last night, I wrote:
 static int pcmcia_bus_early_resume(struct pcmcia_socket *skt)
 {
 if (!verify_cis_cache(skt)) {
 pcmcia_put_socket(skt);
 return 0;
 }
 
 I've not been able to check that theory tonight.  Maybe someone who
 knows the code can suggest - if not, I'll try deleting that
 pcmcia_put_socket() call at some point tomorrow.

Yes, this does appear to be the problem.  Tested patch below.  It looks
like the bug has been around since July 2010 - maybe no one suspends and
resumes with their PCMCIA (not Cardbus) card inserted.

Given its age, it seems to affect many stable kernels.

Note that this is a memory-corrupting bug: not only does it cause the
warning, but as a result of dropping the refcount to zero, it causes the
pcmcia_socket0 device structure to be freed while it still has references,
causing slab caches corruption.  A fatal oops quickly follows this warning
- often even just a 'dmesg' following the warning causes the kernel to
oops.

8
From: Russell King rmk+ker...@arm.linux.org.uk
Subject: [PATCH] Fix PCMCIA socket refcount decrementing on each resume

While testing suspend/resume on an ARM device with PCMCIA support, and
a CF card inserted, I found that after five suspend and resumes, the
kernel would complain, and shortly die after with slab corruption.

WARNING: at include/linux/kref.h:41 kobject_get+0x28/0x50()

As the message doesn't give a clue about which kobject, and the built-in
debugging in drivers/base/power/main.c happens too late, this was added
right before each get_device():

printk(%s: %p [%s] %u\n, __func__, dev, kobject_name(dev-kobj), 
atomic_read(dev-kobj.kref.refcount));

and on the 3rd s2ram cycle, the following behaviour observed:

On the 3rd suspend/resume cycle:

dpm_prepare: c1a0d998 [pcmcia_socket0] 3
dpm_suspend: c1a0d998 [pcmcia_socket0] 3
dpm_suspend_noirq: c1a0d998 [pcmcia_socket0] 3
dpm_resume_noirq: c1a0d998 [pcmcia_socket0] 3
dpm_resume: c1a0d998 [pcmcia_socket0] 3
dpm_complete: c1a0d998 [pcmcia_socket0] 2

4th:

dpm_prepare: c1a0d998 [pcmcia_socket0] 2
dpm_suspend: c1a0d998 [pcmcia_socket0] 2
dpm_suspend_noirq: c1a0d998 [pcmcia_socket0] 2
dpm_resume_noirq: c1a0d998 [pcmcia_socket0] 2
dpm_resume: c1a0d998 [pcmcia_socket0] 2
dpm_complete: c1a0d998 [pcmcia_socket0] 1

5th:

dpm_prepare: c1a0d998 [pcmcia_socket0] 1
dpm_suspend: c1a0d998 [pcmcia_socket0] 1
dpm_suspend_noirq: c1a0d998 [pcmcia_socket0] 1
dpm_resume_noirq: c1a0d998 [pcmcia_socket0] 1
dpm_resume: c1a0d998 [pcmcia_socket0] 1
dpm_complete: c1a0d998 [pcmcia_socket0] 0
[ cut here ]
WARNING: at include/linux/kref.h:41 kobject_get+0x28/0x50()
Modules linked in: ucb1x00_core
Backtrace:
[c0212090] (dump_backtrace+0x0/0x110) from [c04799dc] (dump_stack+0x18/0x1c)
[c04799c4] (dump_stack+0x0/0x1c) from [c021cba0] 
(warn_slowpath_common+0x50/0x68)
[c021cb50] (warn_slowpath_common+0x0/0x68) from [c021cbdc] 
(warn_slowpath_null+0x24/0x28)
[c021cbb8] (warn_slowpath_null+0x0/0x28) from [c0335374] 
(kobject_get+0x28/0x50)
[c033534c] (kobject_get+0x0/0x50) from [c03804f4] (get_device+0x1c/0x24)
[c0388c90] (dpm_complete+0x0/0x1a0) from [c0389cc0] 
(dpm_resume_end+0x1c/0x20)
...

Looking at commit 7b24e7988263 (pcmcia: split up central event handler),
the following change was made to cs.c:

@@ -546,8 +524,8 @@ static int socket_late_resume(struct pcmcia_socket *skt)
return 0;
}
 #endif
-
-   send_event(skt, CS_EVENT_PM_RESUME, CS_EVENT_PRI_LOW);
+   if (!(skt-state  SOCKET_CARDBUS)  (skt-callback))
+   skt-callback-early_resume(skt);
return 0;
 }


And the corresponding change in ds.c is from:

-static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
-{
-   struct pcmcia_socket *s = pcmcia_get_socket(skt);
...
-   switch (event) {
...
-   case CS_EVENT_PM_RESUME:
-   if (verify_cis_cache(skt) != 0) {
-   dev_dbg(skt-dev, cis mismatch - different card\n);
-   /* first, remove the card */
-   ds_event(skt, CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_HIGH);
-   mutex_lock(s-ops_mutex);
-   destroy_cis_cache(skt);
-   kfree(skt-fake_cis);
-   skt-fake_cis = NULL;
-   s-functions = 0;
-   mutex_unlock(s-ops_mutex);
-   /* now, add the new card */
-   ds_event(skt, CS_EVENT_CARD_INSERTION,
-CS_EVENT_PRI_LOW);
-   }
-   break;
...
-}

-pcmcia_put_socket(s);

-return 0;
-} /* ds_event */

to:

+static int pcmcia_bus_early_resume(struct pcmcia_socket *skt)
+{
+   if (!verify_cis_cache(skt)) {
+   pcmcia_put_socket(skt);
+   return 0;
+   }

+   dev_dbg(skt-dev, cis mismatch - different card\n);

+   /* first, remove the card */
+   

Re: [PATCH,FIXED] PCMCIA card inserted, five s2ram cycles, you're dead

2012-01-22 Thread Russell King - ARM Linux
Unfortunately, the description will need a couple of edits for it to
apply properly (I just applied it to a local private branch.)

On Sun, Jan 22, 2012 at 08:51:57AM +, Russell King - ARM Linux wrote:
 @@ -546,8 +524,8 @@ static int socket_late_resume(struct pcmcia_socket *skt)

This needs a space before it, otherwise git will try to take this as a
patch to be applied.

 Cc: sta...@vger.kernel.org
 Tested-by: Russell King rmk+ker...@arm.linux.org.uk
 Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
 -- 

And I keep messing this marker up in hand-crafted messages.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[BUG] PCMCIA card inserted, five s2ram cycles, you're dead

2012-01-21 Thread Russell King - ARM Linux
ARM platform, a pcnet_cs CF card inserted in pcmcia_socket0's slot
which works after each resume.

The messages below are produced by:
printk(%s: %p [%s] %u\n, __func__, dev, kobject_name(dev-kobj), 
atomic_read(dev-kobj.kref.refcount));

placed before get_device() in each of the stated functions in
drivers/base/power/main.c.  As you will notice, the kref count for
pcmcia_socket0 decrements each resume until it explodes.  I suspect
there's a bug somewhere in the PCMCIA code, possibly here:

static int pcmcia_bus_early_resume(struct pcmcia_socket *skt)
{
if (!verify_cis_cache(skt)) {
pcmcia_put_socket(skt);
return 0;
}

I've not been able to check that theory tonight.  Maybe someone who
knows the code can suggest - if not, I'll try deleting that
pcmcia_put_socket() call at some point tomorrow.

On the 3rd suspend/resume cycle:

dpm_prepare: c1a0d998 [pcmcia_socket0] 3
dpm_suspend: c1a0d998 [pcmcia_socket0] 3
dpm_suspend_noirq: c1a0d998 [pcmcia_socket0] 3
dpm_resume_noirq: c1a0d998 [pcmcia_socket0] 3
dpm_resume: c1a0d998 [pcmcia_socket0] 3
dpm_complete: c1a0d998 [pcmcia_socket0] 2

On the 4th suspend/resume cycle:

dpm_prepare: c1a0d998 [pcmcia_socket0] 2
dpm_suspend: c1a0d998 [pcmcia_socket0] 2
dpm_suspend_noirq: c1a0d998 [pcmcia_socket0] 2
dpm_resume_noirq: c1a0d998 [pcmcia_socket0] 2
dpm_resume: c1a0d998 [pcmcia_socket0] 2
dpm_complete: c1a0d998 [pcmcia_socket0] 1

On the 5th suspend/resume cycle:

dpm_prepare: c1a0d998 [pcmcia_socket0] 1
dpm_suspend: c1a0d998 [pcmcia_socket0] 1
dpm_suspend_noirq: c1a0d998 [pcmcia_socket0] 1
dpm_resume_noirq: c1a0d998 [pcmcia_socket0] 1
dpm_resume: c1a0d998 [pcmcia_socket0] 1
dpm_complete: c1a0d998 [pcmcia_socket0] 0
[ cut here ]
WARNING: at include/linux/kref.h:41 kobject_get+0x28/0x50()
Modules linked in: ucb1x00_core
Backtrace: [c0212090] (dump_backtrace+0x0/0x110) from [c04799dc] 
(dump_stack+0x18/0x1c)
 r7: r6:c0335374 r5:c0500312 r4:0029
[c04799c4] (dump_stack+0x0/0x1c) from [c021cba0] 
(warn_slowpath_common+0x50/0x68)
[c021cb50] (warn_slowpath_common+0x0/0x68) from [c021cbdc] 
(warn_slowpath_null+0x24/0x28)
 r8:c0adbe74 r7:c05811e0 r6:c1a19234 r5:c1a0d998 r4:c1a0d9a0
[c021cbb8] (warn_slowpath_null+0x0/0x28) from [c0335374] 
(kobject_get+0x28/0x50)
[c033534c] (kobject_get+0x0/0x50) from [c03804f4] (get_device+0x1c/0x24)
 r4:c1a0da18
[c03804d8] (get_device+0x0/0x24) from [c0388cec] (dpm_complete+0x5c/0x1a0)
[c0388c90] (dpm_complete+0x0/0x1a0) from [c0389cc0] 
(dpm_resume_end+0x1c/0x20)
 r8:c05a9864 r7:0003 r6:c059ada4 r5: r4:0010
[c0389ca4] (dpm_resume_end+0x0/0x20) from [c0245668] 
(suspend_devices_and_enter+0x1ac/0x1f8)
 r4:
[c02454bc] (suspend_devices_and_enter+0x0/0x1f8) from [c02457b0] 
(enter_state+0xfc/0x144)
 r8:c0aac000 r7:c04803c0 r6:0003 r5:0003 r4:
[c02456b4] (enter_state+0x0/0x144) from [c02446fc] (state_store+0x9c/0x11c)
 r5:0003 r4:c05009ad
[c0244660] (state_store+0x0/0x11c) from [c0334da0] 
(kobj_attr_store+0x28/0x2c)
[c0334d78] (kobj_attr_store+0x0/0x2c) from [c02d7848] 
(sysfs_write_file+0x10c/0x144)
[c02d773c] (sysfs_write_file+0x0/0x144) from [c0289d2c] 
(vfs_write+0xb8/0x144)
[c0289c74] (vfs_write+0x0/0x144) from [c0289e88] (sys_write+0x4c/0x7c)
 r8:c020f4a4 r7:0004 r6:c0ae0cc0 r5: r4:
[c0289e3c] (sys_write+0x0/0x7c) from [c020f300] (ret_fast_syscall+0x0/0x2c)
 r6:b6f09c64 r5:0004 r4:0209a408
---[ end trace 589b3a68dda1e5cd ]---


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 00/19] ARM SA11x0 / PXA / SoC-common PCMCIA cleanups

2012-01-20 Thread Russell King - ARM Linux
What follows is a series of 19 patches cleaning up the SA11xx and PXA
PCMCIA support, which uses the soc-common infrastructure.

Now that we have proper gpiolib support in the kernel for these platforms,
with properly implemented gpio_to_irq() functionality, we can move some
things that the individual platform socket drivers were doing into the
soc-common core.

This significantly reduces the code in the platform socket drivers -
a reduction of around 550 lines, for the net addition of about 50 lines
to soc-common.

The final set of five patches in this set contain some minor bug fixes
(which are really low priority) and cleanup the handling of the SA
build between PXA and SA11x0 platforms.

Please supply acks; I have other work which touches the header files
in arch/arm which would conflict, and it would help to keep it together
rather than have SFR carry those resolutions.

 arch/arm/mach-pxa/include/mach/balloon3.h  |1 -
 arch/arm/mach-sa1100/include/mach/assabet.h|   15 +-
 arch/arm/mach-sa1100/include/mach/cerf.h   |   15 +-
 arch/arm/mach-sa1100/include/mach/nanoengine.h |   12 +-
 arch/arm/mach-sa1100/include/mach/shannon.h|   12 +-
 arch/arm/mach-sa1100/include/mach/simpad.h |6 +-
 drivers/pcmcia/Kconfig |8 +-
 drivers/pcmcia/Makefile|   14 +-
 drivers/pcmcia/pxa2xx_balloon3.c   |   22 +--
 drivers/pcmcia/pxa2xx_base.c   |5 +-
 drivers/pcmcia/pxa2xx_cm_x255.c|   39 ++---
 drivers/pcmcia/pxa2xx_cm_x270.c|   23 +--
 drivers/pcmcia/pxa2xx_colibri.c|   21 +--
 drivers/pcmcia/pxa2xx_e740.c   |   71 ++--
 drivers/pcmcia/pxa2xx_mainstone.c  |   31 ++--
 drivers/pcmcia/pxa2xx_palmld.c |8 +-
 drivers/pcmcia/pxa2xx_palmtc.c |8 +-
 drivers/pcmcia/pxa2xx_palmtx.c |8 +-
 drivers/pcmcia/pxa2xx_sharpsl.c|   30 +---
 drivers/pcmcia/pxa2xx_stargate2.c  |   34 +---
 drivers/pcmcia/pxa2xx_trizeps4.c   |   63 +--
 drivers/pcmcia/pxa2xx_viper.c  |   39 +
 drivers/pcmcia/pxa2xx_vpac270.c|   54 +-
 drivers/pcmcia/sa1100_assabet.c|   65 ++-
 drivers/pcmcia/sa1100_cerf.c   |   52 ++
 drivers/pcmcia/sa1100_h3600.c  |   94 ++
 drivers/pcmcia/sa1100_nanoengine.c |  132 +++---
 drivers/pcmcia/sa1100_shannon.c|   52 ++
 drivers/pcmcia/sa1100_simpad.c |   27 +--
 .../pcmcia/{sa1100_badge4.c = sa_badge4.c}|3 +-
 drivers/pcmcia/sa_generic.c|   56 ++-
 drivers/pcmcia/sa_generic.h|1 -
 .../{sa1100_jornada720.c = sa_jornada720.c}   |8 +-
 .../pcmcia/{pxa2xx_lubbock.c = sa_lubbock.c}  |1 -
 .../{sa1100_neponset.c = sa_neponset.c}   |   11 +-
 drivers/pcmcia/sa11xx_base.c   |5 +-
 drivers/pcmcia/soc_common.c|  193 +---
 drivers/pcmcia/soc_common.h|   23 ++-
 38 files changed, 372 insertions(+), 890 deletions(-)
 rename drivers/pcmcia/{sa1100_badge4.c = sa_badge4.c} (98%)
 rename drivers/pcmcia/{sa1100_jornada720.c = sa_jornada720.c} (94%)
 rename drivers/pcmcia/{pxa2xx_lubbock.c = sa_lubbock.c} (99%)
 rename drivers/pcmcia/{sa1100_neponset.c = sa_neponset.c} (93%)


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 01/19] PCMCIA: soc_common: move common initialization into soc_common

2012-01-20 Thread Russell King - ARM Linux
Move common socket initialization into soc_common.c.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/pxa2xx_base.c|5 +
 drivers/pcmcia/sa_generic.c |4 +---
 drivers/pcmcia/sa11xx_base.c|5 +
 drivers/pcmcia/soc_common.c |   10 ++
 drivers/pcmcia/soc_common.h |3 ++-
 5 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index a87e272..18474f0 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -318,10 +318,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device 
*dev)
 
skt-nr = ops-first + i;
skt-clk = clk;
-   skt-ops = ops;
-   skt-socket.owner = ops-owner;
-   skt-socket.dev.parent = dev-dev;
-   skt-socket.pci_irq = NO_IRQ;
+   soc_pcmcia_init_one(skt, ops, dev-dev);
 
ret = pxa2xx_drv_pcmcia_add_one(skt);
if (ret)
diff --git a/drivers/pcmcia/sa_generic.c b/drivers/pcmcia/sa_generic.c
index 5986690..7d6d3d4 100644
--- a/drivers/pcmcia/sa_generic.c
+++ b/drivers/pcmcia/sa_generic.c
@@ -141,9 +141,7 @@ int sa_pcmcia_add(struct sa_dev *dev, struct 
pcmcia_low_level *ops,
return -ENOMEM;
 
s-soc.nr = ops-first + i;
-   s-soc.ops = ops;
-   s-soc.socket.owner = ops-owner;
-   s-soc.socket.dev.parent = dev-dev;
+   soc_pcmcia_init_one(s-soc, ops, dev-dev);
s-soc.socket.pci_irq = s-soc.nr ?
dev-irq[IDX_IRQ_S0_READY_NINT] :
dev-irq[IDX_IRQ_S1_READY_NINT];
diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c
index 0c62fe3..a3ee89a 100644
--- a/drivers/pcmcia/sa11xx_base.c
+++ b/drivers/pcmcia/sa11xx_base.c
@@ -236,10 +236,7 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct 
pcmcia_low_level *ops,
skt = sinfo-skt[i];
 
skt-nr = first + i;
-   skt-ops = ops;
-   skt-socket.owner = ops-owner;
-   skt-socket.dev.parent = dev;
-   skt-socket.pci_irq = NO_IRQ;
+   soc_pcmcia_init_one(skt, ops, dev);
 
ret = sa11xx_drv_pcmcia_add_one(skt);
if (ret)
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index a0a9c2a..84d90d5 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -635,6 +635,16 @@ module_exit(soc_pcmcia_cpufreq_unregister);
 
 #endif
 
+void soc_pcmcia_init_one(struct soc_pcmcia_socket *skt,
+   struct pcmcia_low_level *ops, struct device *dev)
+{
+   skt-ops = ops;
+   skt-socket.owner = ops-owner;
+   skt-socket.dev.parent = dev;
+   skt-socket.pci_irq = NO_IRQ;
+}
+EXPORT_SYMBOL(soc_pcmcia_init_one);
+
 void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt)
 {
mutex_lock(soc_pcmcia_sockets_lock);
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h
index 9daa736..3ff7ead 100644
--- a/drivers/pcmcia/soc_common.h
+++ b/drivers/pcmcia/soc_common.h
@@ -133,7 +133,8 @@ extern void soc_pcmcia_disable_irqs(struct 
soc_pcmcia_socket *skt, struct pcmcia
 extern void soc_pcmcia_enable_irqs(struct soc_pcmcia_socket *skt, struct 
pcmcia_irqs *irqs, int nr);
 extern void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *, struct 
soc_pcmcia_timing *);
 
-
+void soc_pcmcia_init_one(struct soc_pcmcia_socket *skt,
+   struct pcmcia_low_level *ops, struct device *dev);
 void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt);
 int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt);
 
-- 
1.7.4.4


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 03/19] PCMCIA: pxa: convert PXA socket drivers to use new irq/gpio management

2012-01-20 Thread Russell King - ARM Linux
Convert all the PXA platform socket drivers to use the new irq/gpio
management provided by soc_common.  This relieves these drivers from
having to do anything with these GPIOs other than provide the numbers
to soc_common.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 arch/arm/mach-pxa/include/mach/balloon3.h |1 -
 drivers/pcmcia/pxa2xx_balloon3.c  |   21 ++---
 drivers/pcmcia/pxa2xx_cm_x255.c   |   38 +---
 drivers/pcmcia/pxa2xx_cm_x270.c   |   22 ++---
 drivers/pcmcia/pxa2xx_colibri.c   |   20 +---
 drivers/pcmcia/pxa2xx_e740.c  |   70 +
 drivers/pcmcia/pxa2xx_mainstone.c |   30 ++---
 drivers/pcmcia/pxa2xx_palmld.c|7 +--
 drivers/pcmcia/pxa2xx_palmtc.c|7 +--
 drivers/pcmcia/pxa2xx_palmtx.c|7 +--
 drivers/pcmcia/pxa2xx_sharpsl.c   |   30 +---
 drivers/pcmcia/pxa2xx_stargate2.c |   33 ++---
 drivers/pcmcia/pxa2xx_trizeps4.c  |   61 +++--
 drivers/pcmcia/pxa2xx_viper.c |   38 +++-
 drivers/pcmcia/pxa2xx_vpac270.c   |   53 +++--
 15 files changed, 82 insertions(+), 356 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/balloon3.h 
b/arch/arm/mach-pxa/include/mach/balloon3.h
index f02fa1e..954641e 100644
--- a/arch/arm/mach-pxa/include/mach/balloon3.h
+++ b/arch/arm/mach-pxa/include/mach/balloon3.h
@@ -174,7 +174,6 @@ enum balloon3_features {
 
 #define BALLOON3_AUX_NIRQ  PXA_GPIO_TO_IRQ(BALLOON3_GPIO_AUX_NIRQ)
 #define BALLOON3_CODEC_IRQ PXA_GPIO_TO_IRQ(BALLOON3_GPIO_CODEC_IRQ)
-#define BALLOON3_S0_CD_IRQ PXA_GPIO_TO_IRQ(BALLOON3_GPIO_S0_CD)
 
 #define BALLOON3_NR_IRQS   (IRQ_BOARD_START + 16)
 
diff --git a/drivers/pcmcia/pxa2xx_balloon3.c b/drivers/pcmcia/pxa2xx_balloon3.c
index 22a75e6..12e38b4 100644
--- a/drivers/pcmcia/pxa2xx_balloon3.c
+++ b/drivers/pcmcia/pxa2xx_balloon3.c
@@ -29,15 +29,6 @@
 
 #include soc_common.h
 
-/*
- * These are a list of interrupt sources that provokes a polled
- * check of status
- */
-static struct pcmcia_irqs irqs[] = {
-   { 0, BALLOON3_S0_CD_IRQ, PCMCIA0 CD },
-   { 0, BALLOON3_BP_NSTSCHG_IRQ, PCMCIA0 STSCHG },
-};
-
 static int balloon3_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 {
uint16_t ver;
@@ -49,12 +40,12 @@ static int balloon3_pcmcia_hw_init(struct soc_pcmcia_socket 
*skt)
ver);
 
skt-socket.pci_irq = BALLOON3_BP_CF_NRDY_IRQ;
-   return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
+   skt-stat[SOC_STAT_CD].gpio = BALLOON3_GPIO_S0_CD;
+   skt-stat[SOC_STAT_CD].name = PCMCIA0 CD;
+   skt-stat[SOC_STAT_BVD1].irq = BALLOON3_BP_NSTSCHG_IRQ;
+   skt-stat[SOC_STAT_BVD1].name = PCMCIA0 STSCHG;
 
-static void balloon3_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-   soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
+   return 0;
 }
 
 static unsigned long balloon3_pcmcia_status[2] = {
@@ -85,7 +76,6 @@ static void balloon3_pcmcia_socket_state(struct 
soc_pcmcia_socket *skt,
disable_irq(BALLOON3_BP_NSTSCHG_IRQ);
}
 
-   state-detect   = !gpio_get_value(BALLOON3_GPIO_S0_CD);
state-ready= !!(status  BALLOON3_CF_nIRQ);
state-bvd1 = !!(status  BALLOON3_CF_nSTSCHG_BVD1);
state-bvd2 = 0;/* not available */
@@ -106,7 +96,6 @@ static int balloon3_pcmcia_configure_socket(struct 
soc_pcmcia_socket *skt,
 static struct pcmcia_low_level balloon3_pcmcia_ops = {
.owner  = THIS_MODULE,
.hw_init= balloon3_pcmcia_hw_init,
-   .hw_shutdown= balloon3_pcmcia_hw_shutdown,
.socket_state   = balloon3_pcmcia_socket_state,
.configure_socket   = balloon3_pcmcia_configure_socket,
.first  = 0,
diff --git a/drivers/pcmcia/pxa2xx_cm_x255.c b/drivers/pcmcia/pxa2xx_cm_x255.c
index 31ab6ddf..f90e7b1 100644
--- a/drivers/pcmcia/pxa2xx_cm_x255.c
+++ b/drivers/pcmcia/pxa2xx_cm_x255.c
@@ -25,17 +25,6 @@
 #define GPIO_PCMCIA_S1_RDYINT  (8)
 #define GPIO_PCMCIA_RESET  (9)
 
-#define PCMCIA_S0_CD_VALID gpio_to_irq(GPIO_PCMCIA_S0_CD_VALID)
-#define PCMCIA_S1_CD_VALID gpio_to_irq(GPIO_PCMCIA_S1_CD_VALID)
-#define PCMCIA_S0_RDYINT   gpio_to_irq(GPIO_PCMCIA_S0_RDYINT)
-#define PCMCIA_S1_RDYINT   gpio_to_irq(GPIO_PCMCIA_S1_RDYINT)
-
-
-static struct pcmcia_irqs irqs[] = {
-   { .sock = 0, .str = PCMCIA0 CD },
-   { .sock = 1, .str = PCMCIA1 CD },
-};
-
 static int cmx255_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 {
int ret = gpio_request(GPIO_PCMCIA_RESET, PCCard reset);
@@ -43,19 +32,23 @@ static int cmx255_pcmcia_hw_init(struct soc_pcmcia_socket 
*skt)
return ret;
gpio_direction_output(GPIO_PCMCIA_RESET, 0);
 
-   skt-socket.pci_irq = skt-nr == 0 ? 

[PATCH 05/19] PCMCIA: sa11x0: assabet: convert to use new irq/gpio management

2012-01-20 Thread Russell King - ARM Linux
Convert Assabet socket driver to use the new irq/gpio management.
This is slightly more involved because we have to touch the private
platform header file to modify the GPIO bitmasks to be GPIO numbers.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 arch/arm/mach-sa1100/include/mach/assabet.h |   15 +++
 drivers/pcmcia/sa1100_assabet.c |   64 ++
 2 files changed, 21 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-sa1100/include/mach/assabet.h 
b/arch/arm/mach-sa1100/include/mach/assabet.h
index 28c2cf5..3073914 100644
--- a/arch/arm/mach-sa1100/include/mach/assabet.h
+++ b/arch/arm/mach-sa1100/include/mach/assabet.h
@@ -85,21 +85,18 @@ extern void ASSABET_BCR_frob(unsigned int mask, unsigned 
int set);
 #define ASSABET_BSR_RAD_RI (1  31)
 
 
-/* GPIOs for which the generic definition doesn't say much */
+/* GPIOs (bitmasks) for which the generic definition doesn't say much */
 #define ASSABET_GPIO_RADIO_IRQ GPIO_GPIO (14)  /* Radio interrupt 
request  */
 #define ASSABET_GPIO_PS_MODE_SYNC  GPIO_GPIO (16)  /* Power supply 
mode/sync   */
 #define ASSABET_GPIO_STEREO_64FS_CLK   GPIO_GPIO (19)  /* SSP UDA1341 clock 
input  */
-#define ASSABET_GPIO_CF_IRQGPIO_GPIO (21)  /* CF IRQ   */
-#define ASSABET_GPIO_CF_CD GPIO_GPIO (22)  /* CF CD */
-#define ASSABET_GPIO_CF_BVD2   GPIO_GPIO (24)  /* CF BVD */
 #define ASSABET_GPIO_GFX_IRQ   GPIO_GPIO (24)  /* Graphics IRQ */
-#define ASSABET_GPIO_CF_BVD1   GPIO_GPIO (25)  /* CF BVD */
 #define ASSABET_GPIO_BATT_LOW  GPIO_GPIO (26)  /* Low battery */
 #define ASSABET_GPIO_RCLK  GPIO_GPIO (26)  /* CCLK/2  */
 
-#define ASSABET_IRQ_GPIO_CF_IRQIRQ_GPIO21
-#define ASSABET_IRQ_GPIO_CF_CD IRQ_GPIO22
-#define ASSABET_IRQ_GPIO_CF_BVD2   IRQ_GPIO24
-#define ASSABET_IRQ_GPIO_CF_BVD1   IRQ_GPIO25
+/* These are gpiolib GPIO numbers, not bitmasks */
+#define ASSABET_GPIO_CF_IRQ21  /* CF IRQ */
+#define ASSABET_GPIO_CF_CD 22  /* CF CD  */
+#define ASSABET_GPIO_CF_BVD2   24  /* CF BVD / IOSPKR */
+#define ASSABET_GPIO_CF_BVD1   25  /* CF BVD / IOSTSCHG */
 
 #endif
diff --git a/drivers/pcmcia/sa1100_assabet.c b/drivers/pcmcia/sa1100_assabet.c
index f1e8822..618f546 100644
--- a/drivers/pcmcia/sa1100_assabet.c
+++ b/drivers/pcmcia/sa1100_assabet.c
@@ -10,45 +10,30 @@
 #include linux/interrupt.h
 #include linux/device.h
 #include linux/init.h
+#include linux/gpio.h
 
-#include mach/hardware.h
 #include asm/mach-types.h
-#include asm/irq.h
-#include asm/signal.h
 #include mach/assabet.h
 
 #include sa1100_generic.h
 
-static struct pcmcia_irqs irqs[] = {
-   { 1, ASSABET_IRQ_GPIO_CF_CD,   CF CD   },
-   { 1, ASSABET_IRQ_GPIO_CF_BVD2, CF BVD2 },
-   { 1, ASSABET_IRQ_GPIO_CF_BVD1, CF BVD1 },
-};
-
 static int assabet_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 {
-   skt-socket.pci_irq = ASSABET_IRQ_GPIO_CF_IRQ;
-
-   return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
+   skt-stat[SOC_STAT_CD].gpio = ASSABET_GPIO_CF_CD;
+   skt-stat[SOC_STAT_CD].name = CF CD;
+   skt-stat[SOC_STAT_BVD1].gpio = ASSABET_GPIO_CF_BVD1;
+   skt-stat[SOC_STAT_BVD1].name = CF BVD1;
+   skt-stat[SOC_STAT_BVD2].gpio = ASSABET_GPIO_CF_BVD2;
+   skt-stat[SOC_STAT_BVD2].name = CF BVD2;
+   skt-stat[SOC_STAT_RDY].gpio = ASSABET_GPIO_CF_IRQ;
+   skt-stat[SOC_STAT_RDY].name = CF RDY;
 
-/*
- * Release all resources.
- */
-static void assabet_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-   soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
+   return 0;
 }
 
 static void
 assabet_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state 
*state)
 {
-   unsigned long levels = GPLR;
-
-   state-detect = (levels  ASSABET_GPIO_CF_CD) ? 0 : 1;
-   state-ready  = (levels  ASSABET_GPIO_CF_IRQ) ? 1 : 0;
-   state-bvd1   = (levels  ASSABET_GPIO_CF_BVD1) ? 1 : 0;
-   state-bvd2   = (levels  ASSABET_GPIO_CF_BVD2) ? 1 : 0;
state-wrprot = 0; /* Not available on Assabet. */
state-vs_3v  = 1; /* Can only apply 3.3V on Assabet. */
state-vs_Xv  = 0;
@@ -78,38 +63,24 @@ assabet_pcmcia_configure_socket(struct soc_pcmcia_socket 
*skt, const socket_stat
return -1;
}
 
-   /* Silently ignore Vpp, output enable, speaker enable. */
+   /* Silently ignore Vpp, speaker enable. */
 
if (state-flags  SS_RESET)
mask |= ASSABET_BCR_CF_RST;
+   if (!(state-flags  SS_OUTPUT_ENA))
+   mask |= ASSABET_BCR_CF_BUS_OFF;
 
-   ASSABET_BCR_frob(ASSABET_BCR_CF_RST | ASSABET_BCR_CF_PWR, mask);
+   ASSABET_BCR_frob(ASSABET_BCR_CF_RST | ASSABET_BCR_CF_PWR |
+   ASSABET_BCR_CF_BUS_OFF, mask);
 
return 0;
 }
 
 /*
- * Enable card status IRQs on (re-)initialisation.  This can
- * be called 

[PATCH 06/19] PCMCIA: sa11x0: cerf: convert to use new irq/gpio management

2012-01-20 Thread Russell King - ARM Linux
Convert Cerf socket driver to use the new irq/gpio management.
This is slightly more involved because we have to touch the private
platform header file to modify the GPIO bitmasks to be GPIO numbers.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 arch/arm/mach-sa1100/include/mach/cerf.h |   13 +++--
 drivers/pcmcia/sa1100_cerf.c |   42 ++---
 2 files changed, 13 insertions(+), 42 deletions(-)

diff --git a/arch/arm/mach-sa1100/include/mach/cerf.h 
b/arch/arm/mach-sa1100/include/mach/cerf.h
index c3ac3d0..0e49545 100644
--- a/arch/arm/mach-sa1100/include/mach/cerf.h
+++ b/arch/arm/mach-sa1100/include/mach/cerf.h
@@ -14,15 +14,10 @@
 #define CERF_ETH_IO0xf000
 #define CERF_ETH_IRQ IRQ_GPIO26
 
-#define CERF_GPIO_CF_BVD2  GPIO_GPIO (19)
-#define CERF_GPIO_CF_BVD1  GPIO_GPIO (20)
+#define CERF_GPIO_CF_BVD2  19
+#define CERF_GPIO_CF_BVD1  20
 #define CERF_GPIO_CF_RESET GPIO_GPIO (21)
-#define CERF_GPIO_CF_IRQ   GPIO_GPIO (22)
-#define CERF_GPIO_CF_CDGPIO_GPIO (23)
-
-#define CERF_IRQ_GPIO_CF_BVD2  IRQ_GPIO19
-#define CERF_IRQ_GPIO_CF_BVD1  IRQ_GPIO20
-#define CERF_IRQ_GPIO_CF_IRQ   IRQ_GPIO22
-#define CERF_IRQ_GPIO_CF_CDIRQ_GPIO23
+#define CERF_GPIO_CF_IRQ   22
+#define CERF_GPIO_CF_CD23
 
 #endif // _INCLUDE_CERF_H_
diff --git a/drivers/pcmcia/sa1100_cerf.c b/drivers/pcmcia/sa1100_cerf.c
index 30560df..9d0424e 100644
--- a/drivers/pcmcia/sa1100_cerf.c
+++ b/drivers/pcmcia/sa1100_cerf.c
@@ -19,33 +19,23 @@
 
 #define CERF_SOCKET1
 
-static struct pcmcia_irqs irqs[] = {
-   { CERF_SOCKET, CERF_IRQ_GPIO_CF_CD,   CF_CD   },
-   { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD2, CF_BVD2 },
-   { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD1, CF_BVD1 }
-};
-
 static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 {
-   skt-socket.pci_irq = CERF_IRQ_GPIO_CF_IRQ;
-
-   return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
+   skt-stat[SOC_STAT_CD].gpio = CERF_GPIO_CF_CD;
+   skt-stat[SOC_STAT_CD].name = CF_CD;
+   skt-stat[SOC_STAT_BVD1].gpio = CERF_GPIO_CF_BVD1;
+   skt-stat[SOC_STAT_BVD1].name = CF_BVD1;
+   skt-stat[SOC_STAT_BVD2].gpio = CERF_GPIO_CF_BVD2;
+   skt-stat[SOC_STAT_BVD2].name = CF_BVD2;
+   skt-stat[SOC_STAT_RDY].gpio = CERF_GPIO_CF_IRQ;
+   skt-stat[SOC_STAT_RDY].name = CF_IRQ;
 
-static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-   soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
+   return 0;
 }
 
 static void
 cerf_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state 
*state)
 {
-   unsigned long levels = GPLR;
-
-   state-detect   = (levels  CERF_GPIO_CF_CD)  ?0:1;
-   state-ready= (levels  CERF_GPIO_CF_IRQ) ?1:0;
-   state-bvd1 = (levels  CERF_GPIO_CF_BVD1)?1:0;
-   state-bvd2 = (levels  CERF_GPIO_CF_BVD2)?1:0;
state-wrprot   = 0;
state-vs_3v= 1;
state-vs_Xv= 0;
@@ -76,25 +66,11 @@ cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
return 0;
 }
 
-static void cerf_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-   soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void cerf_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
-{
-   soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
 static struct pcmcia_low_level cerf_pcmcia_ops = { 
.owner  = THIS_MODULE,
.hw_init= cerf_pcmcia_hw_init,
-   .hw_shutdown= cerf_pcmcia_hw_shutdown,
.socket_state   = cerf_pcmcia_socket_state,
.configure_socket   = cerf_pcmcia_configure_socket,
-
-   .socket_init= cerf_pcmcia_socket_init,
-   .socket_suspend = cerf_pcmcia_socket_suspend,
 };
 
 int __devinit pcmcia_cerf_init(struct device *dev)
-- 
1.7.4.4


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 07/19] PCMCIA: sa11x0: cerf: convert reset handling to use GPIO subsystem

2012-01-20 Thread Russell King - ARM Linux
Rather than accessing GPSR and GPCR directly, use the GPIO subsystem
instead.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 arch/arm/mach-sa1100/include/mach/cerf.h |2 +-
 drivers/pcmcia/sa1100_cerf.c |   19 ++-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-sa1100/include/mach/cerf.h 
b/arch/arm/mach-sa1100/include/mach/cerf.h
index 0e49545..88fd9c0 100644
--- a/arch/arm/mach-sa1100/include/mach/cerf.h
+++ b/arch/arm/mach-sa1100/include/mach/cerf.h
@@ -16,7 +16,7 @@
 
 #define CERF_GPIO_CF_BVD2  19
 #define CERF_GPIO_CF_BVD1  20
-#define CERF_GPIO_CF_RESET GPIO_GPIO (21)
+#define CERF_GPIO_CF_RESET 21
 #define CERF_GPIO_CF_IRQ   22
 #define CERF_GPIO_CF_CD23
 
diff --git a/drivers/pcmcia/sa1100_cerf.c b/drivers/pcmcia/sa1100_cerf.c
index 9d0424e..50df0e6 100644
--- a/drivers/pcmcia/sa1100_cerf.c
+++ b/drivers/pcmcia/sa1100_cerf.c
@@ -10,6 +10,7 @@
 #include linux/device.h
 #include linux/init.h
 #include linux/delay.h
+#include linux/gpio.h
 
 #include mach/hardware.h
 #include asm/mach-types.h
@@ -21,6 +22,12 @@
 
 static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 {
+   int ret;
+
+   ret = gpio_request_one(CERF_GPIO_CF_RESET, GPIOF_OUT_INIT_LOW, 
CF_RESET);
+   if (ret)
+   return ret;
+
skt-stat[SOC_STAT_CD].gpio = CERF_GPIO_CF_CD;
skt-stat[SOC_STAT_CD].name = CF_CD;
skt-stat[SOC_STAT_BVD1].gpio = CERF_GPIO_CF_BVD1;
@@ -33,6 +40,11 @@ static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
return 0;
 }
 
+static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
+{
+   gpio_free(CERF_GPIO_CF_RESET);
+}
+
 static void
 cerf_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state 
*state)
 {
@@ -57,11 +69,7 @@ cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
return -1;
}
 
-   if (state-flags  SS_RESET) {
-   GPSR = CERF_GPIO_CF_RESET;
-   } else {
-   GPCR = CERF_GPIO_CF_RESET;
-   }
+   gpio_set_value(CERF_GPIO_CF_RESET, !!(state-flags  SS_RESET));
 
return 0;
 }
@@ -69,6 +77,7 @@ cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
 static struct pcmcia_low_level cerf_pcmcia_ops = { 
.owner  = THIS_MODULE,
.hw_init= cerf_pcmcia_hw_init,
+   .hw_shutdown= cerf_pcmcia_hw_shutdown,
.socket_state   = cerf_pcmcia_socket_state,
.configure_socket   = cerf_pcmcia_configure_socket,
 };
-- 
1.7.4.4


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 08/19] PCMCIA: sa11x0: nanoengine: convert to use new irq/gpio management

2012-01-20 Thread Russell King - ARM Linux
Convert Nanoengine socket driver to use the new irq/gpio management.
This is slightly more involved because we have to touch the private
platform header file to modify the GPIO bitmasks to be GPIO numbers.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 arch/arm/mach-sa1100/include/mach/nanoengine.h |8 +-
 drivers/pcmcia/sa1100_nanoengine.c |  101 +++-
 2 files changed, 15 insertions(+), 94 deletions(-)

diff --git a/arch/arm/mach-sa1100/include/mach/nanoengine.h 
b/arch/arm/mach-sa1100/include/mach/nanoengine.h
index 14f8382..ad24c6c 100644
--- a/arch/arm/mach-sa1100/include/mach/nanoengine.h
+++ b/arch/arm/mach-sa1100/include/mach/nanoengine.h
@@ -16,10 +16,10 @@
 
 #include mach/irqs.h
 
-#define GPIO_PC_READY0 GPIO_GPIO(11) /* ready for socket 0 (active high)*/
-#define GPIO_PC_READY1 GPIO_GPIO(12) /* ready for socket 1 (active high) */
-#define GPIO_PC_CD0GPIO_GPIO(13) /* detect for socket 0 (active low) */
-#define GPIO_PC_CD1GPIO_GPIO(14) /* detect for socket 1 (active low) */
+#define GPIO_PC_READY0 11 /* ready for socket 0 (active high)*/
+#define GPIO_PC_READY1 12 /* ready for socket 1 (active high) */
+#define GPIO_PC_CD013 /* detect for socket 0 (active low) */
+#define GPIO_PC_CD114 /* detect for socket 1 (active low) */
 #define GPIO_PC_RESET0 GPIO_GPIO(15) /* reset socket 0 */
 #define GPIO_PC_RESET1 GPIO_GPIO(16) /* reset socket 1 */
 
diff --git a/drivers/pcmcia/sa1100_nanoengine.c 
b/drivers/pcmcia/sa1100_nanoengine.c
index 93b9c9b..b19b816 100644
--- a/drivers/pcmcia/sa1100_nanoengine.c
+++ b/drivers/pcmcia/sa1100_nanoengine.c
@@ -34,43 +34,24 @@
 
 #include sa1100_generic.h
 
-static struct pcmcia_irqs irqs_skt0[] = {
-   /* socket, IRQ, name */
-   { 0, NANOENGINE_IRQ_GPIO_PC_CD0, PC CD0 },
-};
-
-static struct pcmcia_irqs irqs_skt1[] = {
-   /* socket, IRQ, name */
-   { 1, NANOENGINE_IRQ_GPIO_PC_CD1, PC CD1 },
-};
-
 struct nanoengine_pins {
-   unsigned input_pins;
unsigned output_pins;
unsigned clear_outputs;
-   unsigned transition_pins;
-   unsigned pci_irq;
-   struct pcmcia_irqs *pcmcia_irqs;
-   unsigned pcmcia_irqs_size;
+   int gpio_cd;
+   int gpio_rdy;
 };
 
 static struct nanoengine_pins nano_skts[] = {
{
-   .input_pins = GPIO_PC_READY0 | GPIO_PC_CD0,
.output_pins= GPIO_PC_RESET0,
.clear_outputs  = GPIO_PC_RESET0,
-   .transition_pins= NANOENGINE_IRQ_GPIO_PC_CD0,
-   .pci_irq= NANOENGINE_IRQ_GPIO_PC_READY0,
-   .pcmcia_irqs= irqs_skt0,
-   .pcmcia_irqs_size   = ARRAY_SIZE(irqs_skt0)
+   .gpio_cd= GPIO_PC_CD0,
+   .gpio_rdy   = GPIO_PC_READY0,
}, {
-   .input_pins = GPIO_PC_READY1 | GPIO_PC_CD1,
.output_pins= GPIO_PC_RESET1,
.clear_outputs  = GPIO_PC_RESET1,
-   .transition_pins= NANOENGINE_IRQ_GPIO_PC_CD1,
-   .pci_irq= NANOENGINE_IRQ_GPIO_PC_READY1,
-   .pcmcia_irqs= irqs_skt1,
-   .pcmcia_irqs_size   = ARRAY_SIZE(irqs_skt1)
+   .gpio_cd= GPIO_PC_CD1,
+   .gpio_rdy   = GPIO_PC_READY1,
}
 };
 
@@ -83,28 +64,15 @@ static int nanoengine_pcmcia_hw_init(struct 
soc_pcmcia_socket *skt)
if (i = num_nano_pcmcia_sockets)
return -ENXIO;
 
-   GPDR = ~nano_skts[i].input_pins;
GPDR |= nano_skts[i].output_pins;
GPCR = nano_skts[i].clear_outputs;
-   irq_set_irq_type(nano_skts[i].transition_pins, IRQ_TYPE_EDGE_BOTH);
-   skt-socket.pci_irq = nano_skts[i].pci_irq;
 
-   return soc_pcmcia_request_irqs(skt,
-   nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size);
-}
+   skt-stat[SOC_STAT_CD].gpio = nano_skts[i].gpio_cd;
+   skt-stat[SOC_STAT_CD].name = i ? PC CD1 : PC CD0;
+   skt-stat[SOC_STAT_RDY].gpio = nano_skts[i].gpio_rdy;
+   skt-stat[SOC_STAT_RDY].name = i ? PC RDY1 : PC RDY0;
 
-/*
- * Release all resources.
- */
-static void nanoengine_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-   unsigned i = skt-nr;
-
-   if (i = num_nano_pcmcia_sockets)
-   return;
-
-   soc_pcmcia_free_irqs(skt,
-   nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size);
+   return 0;
 }
 
 static int nanoengine_pcmcia_configure_socket(
@@ -138,25 +106,11 @@ static int nanoengine_pcmcia_configure_socket(
 static void nanoengine_pcmcia_socket_state(
struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
 {
-   unsigned long levels = GPLR;
unsigned i = skt-nr;
 
if (i = num_nano_pcmcia_sockets)
return;
 
-   memset(state, 0, sizeof(struct 

[PATCH 09/19] PCMCIA: sa11x0: nanoengine: convert reset handling to use GPIO subsystem

2012-01-20 Thread Russell King - ARM Linux
Rather than accessing GPSR and GPCR directly, use the GPIO subsystem
instead.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 arch/arm/mach-sa1100/include/mach/nanoengine.h |4 +-
 drivers/pcmcia/sa1100_nanoengine.c |   38 ++--
 2 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-sa1100/include/mach/nanoengine.h 
b/arch/arm/mach-sa1100/include/mach/nanoengine.h
index ad24c6c..5ebd469 100644
--- a/arch/arm/mach-sa1100/include/mach/nanoengine.h
+++ b/arch/arm/mach-sa1100/include/mach/nanoengine.h
@@ -20,8 +20,8 @@
 #define GPIO_PC_READY1 12 /* ready for socket 1 (active high) */
 #define GPIO_PC_CD013 /* detect for socket 0 (active low) */
 #define GPIO_PC_CD114 /* detect for socket 1 (active low) */
-#define GPIO_PC_RESET0 GPIO_GPIO(15) /* reset socket 0 */
-#define GPIO_PC_RESET1 GPIO_GPIO(16) /* reset socket 1 */
+#define GPIO_PC_RESET0 15 /* reset socket 0 */
+#define GPIO_PC_RESET1 16 /* reset socket 1 */
 
 #define NANOENGINE_IRQ_GPIO_PCIIRQ_GPIO0
 #define NANOENGINE_IRQ_GPIO_PC_READY0  IRQ_GPIO11
diff --git a/drivers/pcmcia/sa1100_nanoengine.c 
b/drivers/pcmcia/sa1100_nanoengine.c
index b19b816..cb43e39 100644
--- a/drivers/pcmcia/sa1100_nanoengine.c
+++ b/drivers/pcmcia/sa1100_nanoengine.c
@@ -19,6 +19,7 @@
  */
 #include linux/device.h
 #include linux/errno.h
+#include linux/gpio.h
 #include linux/interrupt.h
 #include linux/irq.h
 #include linux/init.h
@@ -37,19 +38,18 @@
 struct nanoengine_pins {
unsigned output_pins;
unsigned clear_outputs;
+   int gpio_rst;
int gpio_cd;
int gpio_rdy;
 };
 
 static struct nanoengine_pins nano_skts[] = {
{
-   .output_pins= GPIO_PC_RESET0,
-   .clear_outputs  = GPIO_PC_RESET0,
+   .gpio_rst   = GPIO_PC_RESET0,
.gpio_cd= GPIO_PC_CD0,
.gpio_rdy   = GPIO_PC_READY0,
}, {
-   .output_pins= GPIO_PC_RESET1,
-   .clear_outputs  = GPIO_PC_RESET1,
+   .gpio_rst   = GPIO_PC_RESET1,
.gpio_cd= GPIO_PC_CD1,
.gpio_rdy   = GPIO_PC_READY1,
}
@@ -60,12 +60,15 @@ unsigned num_nano_pcmcia_sockets = ARRAY_SIZE(nano_skts);
 static int nanoengine_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 {
unsigned i = skt-nr;
+   int ret;
 
if (i = num_nano_pcmcia_sockets)
return -ENXIO;
 
-   GPDR |= nano_skts[i].output_pins;
-   GPCR = nano_skts[i].clear_outputs;
+   ret = gpio_request_one(nano_skts[i].gpio_rst, GPIOF_OUT_INIT_LOW,
+   i ? PC RST1 : PC RST0);
+   if (ret)
+   return ret;
 
skt-stat[SOC_STAT_CD].gpio = nano_skts[i].gpio_cd;
skt-stat[SOC_STAT_CD].name = i ? PC CD1 : PC CD0;
@@ -75,30 +78,20 @@ static int nanoengine_pcmcia_hw_init(struct 
soc_pcmcia_socket *skt)
return 0;
 }
 
+static void nanoengine_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
+{
+   gpio_free(nano_skts[skt-nr].gpio_rst);
+}
+
 static int nanoengine_pcmcia_configure_socket(
struct soc_pcmcia_socket *skt, const socket_state_t *state)
 {
-   unsigned reset;
unsigned i = skt-nr;
 
if (i = num_nano_pcmcia_sockets)
return -ENXIO;
 
-   switch (i) {
-   case 0:
-   reset = GPIO_PC_RESET0;
-   break;
-   case 1:
-   reset = GPIO_PC_RESET1;
-   break;
-   default:
-   return -ENXIO;
-   }
-
-   if (state-flags  SS_RESET)
-   GPSR = reset;
-   else
-   GPCR = reset;
+   gpio_set_value(nano_skts[skt-nr].gpio_rst, !!(state-flags  
SS_RESET));
 
return 0;
 }
@@ -122,6 +115,7 @@ static struct pcmcia_low_level nanoengine_pcmcia_ops = {
.owner  = THIS_MODULE,
 
.hw_init= nanoengine_pcmcia_hw_init,
+   .hw_shutdown= nanoengine_pcmcia_hw_shutdown,
 
.configure_socket   = nanoengine_pcmcia_configure_socket,
.socket_state   = nanoengine_pcmcia_socket_state,
-- 
1.7.4.4


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 10/19] PCMCIA: sa11x0: shannon: convert to use new irq/gpio management

2012-01-20 Thread Russell King - ARM Linux
Convert Shannon socket driver to use the new irq/gpio management.
This is slightly more involved because we have to touch the private
platform header file to modify the GPIO bitmasks to be GPIO numbers.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 arch/arm/mach-sa1100/include/mach/shannon.h |   12 ++
 drivers/pcmcia/sa1100_shannon.c |   50 +-
 2 files changed, 21 insertions(+), 41 deletions(-)

diff --git a/arch/arm/mach-sa1100/include/mach/shannon.h 
b/arch/arm/mach-sa1100/include/mach/shannon.h
index ec27d6e..019f857 100644
--- a/arch/arm/mach-sa1100/include/mach/shannon.h
+++ b/arch/arm/mach-sa1100/include/mach/shannon.h
@@ -23,14 +23,10 @@
 #define SHANNON_GPIO_SENSE_12V GPIO_GPIO (21)  /* Input, 12v flash 
unprotect detected */
 #define SHANNON_GPIO_DISP_EN   GPIO_GPIO (22)  /* out */
 /* XXX GPIO 23 unaccounted for */
-#define SHANNON_GPIO_EJECT_0   GPIO_GPIO (24)  /* in */
-#define SHANNON_IRQ_GPIO_EJECT_0   IRQ_GPIO24
-#define SHANNON_GPIO_EJECT_1   GPIO_GPIO (25)  /* in */
-#define SHANNON_IRQ_GPIO_EJECT_1   IRQ_GPIO25
-#define SHANNON_GPIO_RDY_0 GPIO_GPIO (26)  /* in */
-#define SHANNON_IRQ_GPIO_RDY_0 IRQ_GPIO26
-#define SHANNON_GPIO_RDY_1 GPIO_GPIO (27)  /* in */
-#define SHANNON_IRQ_GPIO_RDY_1 IRQ_GPIO27
+#define SHANNON_GPIO_EJECT_0   24  /* in */
+#define SHANNON_GPIO_EJECT_1   25  /* in */
+#define SHANNON_GPIO_RDY_0 26  /* in */
+#define SHANNON_GPIO_RDY_1 27  /* in */
 
 /* MCP UCB codec GPIO pins... */
 
diff --git a/drivers/pcmcia/sa1100_shannon.c b/drivers/pcmcia/sa1100_shannon.c
index 7ff1b43..7337cbc 100644
--- a/drivers/pcmcia/sa1100_shannon.c
+++ b/drivers/pcmcia/sa1100_shannon.c
@@ -15,27 +15,27 @@
 #include asm/irq.h
 #include sa1100_generic.h
 
-static struct pcmcia_irqs irqs[] = {
-   { 0, SHANNON_IRQ_GPIO_EJECT_0, PCMCIA_CD_0 },
-   { 1, SHANNON_IRQ_GPIO_EJECT_1, PCMCIA_CD_1 },
-};
-
 static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 {
/* All those are inputs */
-   GPDR = ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 | 
- SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
-   GAFR = ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 | 
- SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
-
-   skt-socket.pci_irq = skt-nr ? SHANNON_IRQ_GPIO_RDY_1 : 
SHANNON_IRQ_GPIO_RDY_0;
-
-   return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
+   GAFR = ~(GPIO_GPIO(SHANNON_GPIO_EJECT_0) |
+ GPIO_GPIO(SHANNON_GPIO_EJECT_1) |
+ GPIO_GPIO(SHANNON_GPIO_RDY_0) |
+ GPIO_GPIO(SHANNON_GPIO_RDY_1));
+
+   if (skt-nr == 0) {
+   skt-stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_0;
+   skt-stat[SOC_STAT_CD].name = PCMCIA_CD_0;
+   skt-stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_0;
+   skt-stat[SOC_STAT_RDY].name = PCMCIA_RDY_0;
+   } else {
+   skt-stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_1;
+   skt-stat[SOC_STAT_CD].name = PCMCIA_CD_1;
+   skt-stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_1;
+   skt-stat[SOC_STAT_RDY].name = PCMCIA_RDY_1;
+   }
 
-static void shannon_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-   soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
+   return 0;
 }
 
 static void
@@ -46,7 +46,6 @@ shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
 
switch (skt-nr) {
case 0:
-   state-detect = (levels  SHANNON_GPIO_EJECT_0) ? 0 : 1;
state-ready  = (levels  SHANNON_GPIO_RDY_0) ? 1 : 0;
state-wrprot = 0; /* Not available on Shannon. */
state-bvd1   = 1; 
@@ -56,7 +55,6 @@ shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
break;
 
case 1:
-   state-detect = (levels  SHANNON_GPIO_EJECT_1) ? 0 : 1;
state-ready  = (levels  SHANNON_GPIO_RDY_1) ? 1 : 0;
state-wrprot = 0; /* Not available on Shannon. */
state-bvd1   = 1; 
@@ -92,25 +90,11 @@ shannon_pcmcia_configure_socket(struct soc_pcmcia_socket 
*skt,
return 0;
 }
 
-static void shannon_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-   soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void shannon_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
-{
-   soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
 static struct pcmcia_low_level shannon_pcmcia_ops = {
.owner  = THIS_MODULE,
.hw_init= shannon_pcmcia_hw_init,
-   .hw_shutdown= shannon_pcmcia_hw_shutdown,
.socket_state   = shannon_pcmcia_socket_state,
.configure_socket   = shannon_pcmcia_configure_socket,
-
-   

[PATCH 11/19] PCMCIA: sa11x0: simpad: convert to use new irq/gpio management

2012-01-20 Thread Russell King - ARM Linux
Convert Simpad socket driver to use the new irq/gpio management.
This is slightly more involved because we have to touch the private
platform header file to modify the GPIO bitmasks to be GPIO numbers.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 arch/arm/mach-sa1100/include/mach/simpad.h |6 ++
 drivers/pcmcia/sa1100_simpad.c |   26 --
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-sa1100/include/mach/simpad.h 
b/arch/arm/mach-sa1100/include/mach/simpad.h
index db28118..cdea671 100644
--- a/arch/arm/mach-sa1100/include/mach/simpad.h
+++ b/arch/arm/mach-sa1100/include/mach/simpad.h
@@ -39,10 +39,8 @@
 
 
 /*---  PCMCIA  ---*/
-#define GPIO_CF_CD  GPIO_GPIO24
-#define GPIO_CF_IRQ GPIO_GPIO1
-#define IRQ_GPIO_CF_IRQ IRQ_GPIO1
-#define IRQ_GPIO_CF_CD  IRQ_GPIO24
+#define GPIO_CF_CD  24
+#define GPIO_CF_IRQ 1
 
 /*--- SmartCard ---*/
 #define GPIO_SMART_CARDGPIO_GPIO10
diff --git a/drivers/pcmcia/sa1100_simpad.c b/drivers/pcmcia/sa1100_simpad.c
index 0fac965..39d2241 100644
--- a/drivers/pcmcia/sa1100_simpad.c
+++ b/drivers/pcmcia/sa1100_simpad.c
@@ -15,24 +15,21 @@
 #include mach/simpad.h
 #include sa1100_generic.h
  
-static struct pcmcia_irqs irqs[] = {
-   { 1, IRQ_GPIO_CF_CD, CF_CD },
-};
-
 static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 {
 
simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
 
-   skt-socket.pci_irq = IRQ_GPIO_CF_IRQ;
+   skt-stat[SOC_STAT_CD].gpio = GPIO_CF_CD;
+   skt-stat[SOC_STAT_CD].name = CF_CD;
+   skt-stat[SOC_STAT_RDY].gpio = GPIO_CF_IRQ;
+   skt-stat[SOC_STAT_RDY].name = CF_RDY;
 
-   return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
+   return 0;
 }
 
 static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
 {
-   soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
-
/* Disable CF bus: */
/*simpad_set_cs3_bit(PCMCIA_BUFF_DIS);*/
simpad_clear_cs3_bit(PCMCIA_RESET);
@@ -42,11 +39,11 @@ static void
 simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
   struct pcmcia_state *state)
 {
-   unsigned long levels = GPLR;
long cs3reg = simpad_get_cs3_ro();
 
-   state-detect=((levels  GPIO_CF_CD)==0)?1:0;
-   state-ready=(levels  GPIO_CF_IRQ)?1:0;
+   /* the detect signal is inverted - fix that up here */
+   state-detect = !state-detect;
+
state-bvd1 = 1; /* Might be cs3reg  PCMCIA_BVD1 */
state-bvd2 = 1; /* Might be cs3reg  PCMCIA_BVD2 */
state-wrprot=0; /* Not available on Simpad. */
@@ -99,14 +96,8 @@ simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
return 0;
 }
 
-static void simpad_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-   soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
 static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
 {
-   soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
simpad_set_cs3_bit(PCMCIA_RESET);
 }
 
@@ -116,7 +107,6 @@ static struct pcmcia_low_level simpad_pcmcia_ops = {
.hw_shutdown= simpad_pcmcia_hw_shutdown,
.socket_state   = simpad_pcmcia_socket_state,
.configure_socket   = simpad_pcmcia_configure_socket,
-   .socket_init= simpad_pcmcia_socket_init,
.socket_suspend = simpad_pcmcia_socket_suspend,
 };
 
-- 
1.7.4.4


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 12/19] PCMCIA: sa11x0: h3600: convert to use new irq/gpio management

2012-01-20 Thread Russell King - ARM Linux
Convert iPAQ socket driver to use the new irq/gpio management.  As
this already uses the GPIO subsystem, these changes are localized
to just the PCMCIA directory.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/sa1100_h3600.c |   95 ++--
 1 files changed, 15 insertions(+), 80 deletions(-)

diff --git a/drivers/pcmcia/sa1100_h3600.c b/drivers/pcmcia/sa1100_h3600.c
index edf8f00..410a636 100644
--- a/drivers/pcmcia/sa1100_h3600.c
+++ b/drivers/pcmcia/sa1100_h3600.c
@@ -19,36 +19,20 @@
 
 #include sa1100_generic.h
 
-static struct pcmcia_irqs irqs[] = {
-   { .sock = 0, .str = PCMCIA CD0 }, /* .irq will be filled later */
-   { .sock = 1, .str = PCMCIA CD1 }
-};
-
 static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 {
int err;
 
switch (skt-nr) {
case 0:
-   err = gpio_request(H3XXX_GPIO_PCMCIA_IRQ0, PCMCIA IRQ0);
-   if (err)
-   goto err00;
-   err = gpio_direction_input(H3XXX_GPIO_PCMCIA_IRQ0);
-   if (err)
-   goto err01;
-   skt-socket.pci_irq = gpio_to_irq(H3XXX_GPIO_PCMCIA_IRQ0);
-
-   err = gpio_request(H3XXX_GPIO_PCMCIA_CD0, PCMCIA CD0);
-   if (err)
-   goto err01;
-   err = gpio_direction_input(H3XXX_GPIO_PCMCIA_CD0);
-   if (err)
-   goto err02;
-   irqs[0].irq = gpio_to_irq(H3XXX_GPIO_PCMCIA_CD0);
+   skt-stat[SOC_STAT_CD].gpio = H3XXX_GPIO_PCMCIA_CD0;
+   skt-stat[SOC_STAT_CD].name = PCMCIA CD0;
+   skt-stat[SOC_STAT_RDY].gpio = H3XXX_GPIO_PCMCIA_IRQ0;
+   skt-stat[SOC_STAT_RDY].name = PCMCIA IRQ0;
 
err = gpio_request(H3XXX_EGPIO_OPT_NVRAM_ON, OPT NVRAM ON);
if (err)
-   goto err02;
+   goto err01;
err = gpio_direction_output(H3XXX_EGPIO_OPT_NVRAM_ON, 0);
if (err)
goto err03;
@@ -70,30 +54,12 @@ static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket 
*skt)
err = gpio_direction_output(H3XXX_EGPIO_CARD_RESET, 0);
if (err)
goto err06;
-   err = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-   if (err)
-   goto err06;
break;
case 1:
-   err = gpio_request(H3XXX_GPIO_PCMCIA_IRQ1, PCMCIA IRQ1);
-   if (err)
-   goto err10;
-   err = gpio_direction_input(H3XXX_GPIO_PCMCIA_IRQ1);
-   if (err)
-   goto err11;
-   skt-socket.pci_irq = gpio_to_irq(H3XXX_GPIO_PCMCIA_IRQ1);
-
-   err = gpio_request(H3XXX_GPIO_PCMCIA_CD1, PCMCIA CD1);
-   if (err)
-   goto err11;
-   err = gpio_direction_input(H3XXX_GPIO_PCMCIA_CD1);
-   if (err)
-   goto err12;
-   irqs[1].irq = gpio_to_irq(H3XXX_GPIO_PCMCIA_CD1);
-
-   err = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-   if (err)
-   goto err12;
+   skt-stat[SOC_STAT_CD].gpio = H3XXX_GPIO_PCMCIA_CD1;
+   skt-stat[SOC_STAT_CD].name = PCMCIA CD1;
+   skt-stat[SOC_STAT_RDY].gpio = H3XXX_GPIO_PCMCIA_IRQ1;
+   skt-stat[SOC_STAT_RDY].name = PCMCIA IRQ1;
break;
}
return 0;
@@ -102,19 +68,12 @@ err06: gpio_free(H3XXX_EGPIO_CARD_RESET);
 err05: gpio_free(H3XXX_EGPIO_OPT_RESET);
 err04: gpio_free(H3XXX_EGPIO_OPT_ON);
 err03: gpio_free(H3XXX_EGPIO_OPT_NVRAM_ON);
-err02: gpio_free(H3XXX_GPIO_PCMCIA_CD0);
 err01: gpio_free(H3XXX_GPIO_PCMCIA_IRQ0);
-err00: return err;
-
-err12: gpio_free(H3XXX_GPIO_PCMCIA_CD0);
-err11: gpio_free(H3XXX_GPIO_PCMCIA_IRQ0);
-err10: return err;
+   return err;
 }
 
 static void h3600_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
 {
-   soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
-  
switch (skt-nr) {
case 0:
/* Disable CF bus: */
@@ -126,12 +85,8 @@ static void h3600_pcmcia_hw_shutdown(struct 
soc_pcmcia_socket *skt)
gpio_free(H3XXX_EGPIO_OPT_RESET);
gpio_free(H3XXX_EGPIO_OPT_ON);
gpio_free(H3XXX_EGPIO_OPT_NVRAM_ON);
-   gpio_free(H3XXX_GPIO_PCMCIA_CD0);
-   gpio_free(H3XXX_GPIO_PCMCIA_IRQ0);
break;
case 1:
-   gpio_free(H3XXX_GPIO_PCMCIA_CD1);
-   gpio_free(H3XXX_GPIO_PCMCIA_IRQ1);
break;
}
 }
@@ -139,27 +94,11 @@ static void h3600_pcmcia_hw_shutdown(struct 
soc_pcmcia_socket *skt)
 static void
 h3600_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state 
*state)
 {
-   switch (skt-nr) {
-   case 0:

[PATCH 15/19] PCMCIA: sa1111: pass along sa1111_pcmcia_configure_socket() failure code

2012-01-20 Thread Russell King - ARM Linux
Pass along the sa_pcmcia_configure_socket() failure code to
higher levels, rather than just returning zero.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/sa1100_badge4.c   |2 +-
 drivers/pcmcia/sa1100_neponset.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pcmcia/sa1100_badge4.c b/drivers/pcmcia/sa1100_badge4.c
index ca97cb8..4d206f4 100644
--- a/drivers/pcmcia/sa1100_badge4.c
+++ b/drivers/pcmcia/sa1100_badge4.c
@@ -122,7 +122,7 @@ badge4_pcmcia_configure_socket(struct soc_pcmcia_socket 
*skt, const socket_state
local_irq_restore(flags);
}
 
-   return 0;
+   return ret;
 }
 
 static struct pcmcia_low_level badge4_pcmcia_ops = {
diff --git a/drivers/pcmcia/sa1100_neponset.c b/drivers/pcmcia/sa1100_neponset.c
index 1eac3fd..50f297d 100644
--- a/drivers/pcmcia/sa1100_neponset.c
+++ b/drivers/pcmcia/sa1100_neponset.c
@@ -103,7 +103,7 @@ neponset_pcmcia_configure_socket(struct soc_pcmcia_socket 
*skt, const socket_sta
sa_set_io(s-dev, pa_dwr_mask, pa_dwr_set);
}
 
-   return 0;
+   return ret;
 }
 
 static struct pcmcia_low_level neponset_pcmcia_ops = {
-- 
1.7.4.4


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 16/19] PCMCIA: sa1111: jornada720: no need to disable IRQs around sa1111_set_io

2012-01-20 Thread Russell King - ARM Linux
sa_set_io() already contains the necessary locking within itself
to safely change the state of a set of GPIOs.  There's no need for
callers to protect this by disabling IRQs themselves.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/sa1100_jornada720.c |7 +--
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/drivers/pcmcia/sa1100_jornada720.c 
b/drivers/pcmcia/sa1100_jornada720.c
index 61b443e..69428d1 100644
--- a/drivers/pcmcia/sa1100_jornada720.c
+++ b/drivers/pcmcia/sa1100_jornada720.c
@@ -78,13 +78,8 @@ jornada720_pcmcia_configure_socket(struct soc_pcmcia_socket 
*skt, const socket_s
}
 
ret = sa_pcmcia_configure_socket(skt, state);
-   if (ret == 0) {
-   unsigned long flags;
-
-   local_irq_save(flags);
+   if (ret == 0)
sa_set_io(s-dev, pa_dwr_mask, pa_dwr_set);
-   local_irq_restore(flags);
-   }
 
return ret;
 }
-- 
1.7.4.4


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 17/19] PCMCIA: Add Kconfig control for building sa11xx_base.c

2012-01-20 Thread Russell King - ARM Linux
sa11xx_base.c is currently built when either PCMCIA_SA1100 or
PCMCIA_SA are selected.  Let's move the logic into Kconfig.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/Kconfig  |5 +
 drivers/pcmcia/Makefile |5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index f9e3fb3..b7f3d29 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -183,10 +183,14 @@ config PCMCIA_BCM63XX
 config PCMCIA_SOC_COMMON
tristate
 
+config PCMCIA_SA11XX_BASE
+   tristate
+
 config PCMCIA_SA1100
tristate SA1100 support
depends on ARM  ARCH_SA1100  PCMCIA
select PCMCIA_SOC_COMMON
+   select PCMCIA_SA11XX_BASE
help
  Say Y here to include support for SA11x0-based PCMCIA or CF
  sockets, found on HP iPAQs, Yopy, and other StrongARM(R)/
@@ -198,6 +202,7 @@ config PCMCIA_SA
tristate SA support
depends on ARM  ARCH_SA1100  SA  PCMCIA
select PCMCIA_SOC_COMMON
+   select PCMCIA_SA11XX_BASE
help
  Say Y  here to include support for SA-based PCMCIA or CF
  sockets, found on the Jornada 720, Graphicsmaster and other
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index ec543a4..05136dd 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -25,8 +25,9 @@ obj-$(CONFIG_I82092)  += i82092.o
 obj-$(CONFIG_TCIC) += tcic.o
 obj-$(CONFIG_PCMCIA_M8XX)  += m8xx_pcmcia.o
 obj-$(CONFIG_PCMCIA_SOC_COMMON)+= soc_common.o
-obj-$(CONFIG_PCMCIA_SA1100)+= sa11xx_base.o sa1100_cs.o
-obj-$(CONFIG_PCMCIA_SA)+= sa11xx_base.o sa_cs.o
+obj-$(CONFIG_PCMCIA_SA11XX_BASE)   += sa11xx_base.o
+obj-$(CONFIG_PCMCIA_SA1100)+= sa1100_cs.o
+obj-$(CONFIG_PCMCIA_SA)+= sa_cs.o
 obj-$(CONFIG_M32R_PCC) += m32r_pcc.o
 obj-$(CONFIG_M32R_CFC) += m32r_cfc.o
 obj-$(CONFIG_PCMCIA_BCM63XX)   += bcm63xx_pcmcia.o
-- 
1.7.4.4


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 18/19] PCMCIA: make lubbock socket driver part of sa1111_cs

2012-01-20 Thread Russell King - ARM Linux
Lubbock is just another SA socket driver, so now that Kconfig has
better control of which files get built, we can sanitize the build
for this.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/Kconfig  |5 +++--
 drivers/pcmcia/Makefile |3 +--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index b7f3d29..bba3ab2 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -200,9 +200,9 @@ config PCMCIA_SA1100
 
 config PCMCIA_SA
tristate SA support
-   depends on ARM  ARCH_SA1100  SA  PCMCIA
+   depends on ARM  SA  PCMCIA
select PCMCIA_SOC_COMMON
-   select PCMCIA_SA11XX_BASE
+   select PCMCIA_SA11XX_BASE if ARCH_SA1100
help
  Say Y  here to include support for SA-based PCMCIA or CF
  sockets, found on the Jornada 720, Graphicsmaster and other
@@ -218,6 +218,7 @@ config PCMCIA_PXA2XX
|| ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \
|| MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \
|| MACH_COLIBRI320)
+   select PCMCIA_SA if ARCH_LUBBOCK  SA
select PCMCIA_SOC_COMMON
help
  Say Y here to include support for the PXA2xx PCMCIA controller
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 05136dd..49d79f7 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -43,6 +43,7 @@ sa_cs-y   += 
sa_generic.o
 sa_cs-$(CONFIG_ASSABET_NEPONSET)   += sa1100_neponset.o
 sa_cs-$(CONFIG_SA1100_BADGE4)  += sa1100_badge4.o
 sa_cs-$(CONFIG_SA1100_JORNADA720)  += sa1100_jornada720.o
+sa_cs-$(CONFIG_ARCH_LUBBOCK)   += pxa2xx_lubbock.o
 
 sa1100_cs-y+= sa1100_generic.o
 sa1100_cs-$(CONFIG_SA1100_ASSABET) += sa1100_assabet.o
@@ -53,9 +54,7 @@ sa1100_cs-$(CONFIG_SA1100_NANOENGINE) += 
sa1100_nanoengine.o
 sa1100_cs-$(CONFIG_SA1100_SHANNON) += sa1100_shannon.o
 sa1100_cs-$(CONFIG_SA1100_SIMPAD)  += sa1100_simpad.o
 
-pxa2xx_lubbock_cs-y+= pxa2xx_lubbock.o 
sa_generic.o
 pxa2xx_cm_x2xx_cs-y+= pxa2xx_cm_x2xx.o 
pxa2xx_cm_x255.o pxa2xx_cm_x270.o
-pxa2xx-obj-$(CONFIG_ARCH_LUBBOCK)  += pxa2xx_lubbock_cs.o
 pxa2xx-obj-$(CONFIG_MACH_MAINSTONE)+= pxa2xx_mainstone.o
 pxa2xx-obj-$(CONFIG_PXA_SHARPSL)   += pxa2xx_sharpsl.o
 pxa2xx-obj-$(CONFIG_MACH_ARMCORE)  += pxa2xx_cm_x2xx_cs.o
-- 
1.7.4.4


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 19/19] PCMCIA: sa1111: rename sa1111 socket drivers to have sa1111_ prefix.

2012-01-20 Thread Russell King - ARM Linux
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/Makefile|8 +-
 drivers/pcmcia/pxa2xx_lubbock.c|  236 
 drivers/pcmcia/sa1100_badge4.c |  166 -
 drivers/pcmcia/sa1100_jornada720.c |  114 -
 drivers/pcmcia/sa1100_neponset.c   |  134 
 drivers/pcmcia/sa_badge4.c |  166 +
 drivers/pcmcia/sa_jornada720.c |  114 +
 drivers/pcmcia/sa_lubbock.c|  236 
 drivers/pcmcia/sa_neponset.c   |  134 
 9 files changed, 654 insertions(+), 654 deletions(-)
 delete mode 100644 drivers/pcmcia/pxa2xx_lubbock.c
 delete mode 100644 drivers/pcmcia/sa1100_badge4.c
 delete mode 100644 drivers/pcmcia/sa1100_jornada720.c
 delete mode 100644 drivers/pcmcia/sa1100_neponset.c
 create mode 100644 drivers/pcmcia/sa_badge4.c
 create mode 100644 drivers/pcmcia/sa_jornada720.c
 create mode 100644 drivers/pcmcia/sa_lubbock.c
 create mode 100644 drivers/pcmcia/sa_neponset.c

diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 49d79f7..47525de 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -40,10 +40,10 @@ obj-$(CONFIG_ELECTRA_CF)+= electra_cf.o
 obj-$(CONFIG_PCMCIA_ALCHEMY_DEVBOARD)  += db1xxx_ss.o
 
 sa_cs-y+= sa_generic.o
-sa_cs-$(CONFIG_ASSABET_NEPONSET)   += sa1100_neponset.o
-sa_cs-$(CONFIG_SA1100_BADGE4)  += sa1100_badge4.o
-sa_cs-$(CONFIG_SA1100_JORNADA720)  += sa1100_jornada720.o
-sa_cs-$(CONFIG_ARCH_LUBBOCK)   += pxa2xx_lubbock.o
+sa_cs-$(CONFIG_ASSABET_NEPONSET)   += sa_neponset.o
+sa_cs-$(CONFIG_SA1100_BADGE4)  += sa_badge4.o
+sa_cs-$(CONFIG_SA1100_JORNADA720)  += sa_jornada720.o
+sa_cs-$(CONFIG_ARCH_LUBBOCK)   += sa_lubbock.o
 
 sa1100_cs-y+= sa1100_generic.o
 sa1100_cs-$(CONFIG_SA1100_ASSABET) += sa1100_assabet.o
diff --git a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c
deleted file mode 100644
index c5caf57..000
--- a/drivers/pcmcia/pxa2xx_lubbock.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * linux/drivers/pcmcia/pxa2xx_lubbock.c
- *
- * Author: George Davis
- * Created:Jan 10, 2002
- * Copyright:  MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Originally based upon linux/drivers/pcmcia/sa1100_neponset.c
- *
- * Lubbock PCMCIA specific routines.
- *
- */
-#include linux/module.h
-#include linux/kernel.h
-#include linux/device.h
-#include linux/errno.h
-#include linux/init.h
-#include linux/delay.h
-
-#include mach/hardware.h
-#include asm/hardware/sa.h
-#include asm/mach-types.h
-#include mach/lubbock.h
-
-#include sa_generic.h
-
-static int
-lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-   const socket_state_t *state)
-{
-   struct sa_pcmcia_socket *s = to_skt(skt);
-   unsigned int pa_dwr_mask, pa_dwr_set, misc_mask, misc_set;
-   int ret = 0;
-
-   pa_dwr_mask = pa_dwr_set = misc_mask = misc_set = 0;
-
-   /* Lubbock uses the Maxim MAX1602, with the following connections:
-*
-* Socket 0 (PCMCIA):
-*  MAX1602 Lubbock Register
-*  Pin Signal
-*  -   --- --
-*  A0VPP   S0_PWR0 SA- GPIO A0
-*  A1VPP   S0_PWR1 SA- GPIO A1
-*  A0VCC   S0_PWR2 SA- GPIO A2
-*  A1VCC   S0_PWR3 SA- GPIO A3
-*  VX  VCC
-*  VY  +3.3V
-*  12IN+12V
-*  CODE+3.3V   Cirrus  Code, CODE = High (VY)
-*
-* Socket 1 (CF):
-*  MAX1602 Lubbock Register
-*  Pin Signal
-*  -   --- --
-*  A0VPP   GND VPP is not connected
-*  A1VPP   GND VPP is not connected
-*  A0VCC   S1_PWR0 MISC_WR14
-*  A1VCC   S1_PWR1 MISC_WR15
-*  VX  VCC
-*  VY  +3.3V
-*  12INGND VPP is not connected
-*  CODE+3.3V   Cirrus  Code, CODE = High (VY)
-*
-*/
-
- again:
-   switch (skt-nr) {
-   case 0:
-   pa_dwr_mask = GPIO_A0 | GPIO_A1 | GPIO_A2 | GPIO_A3;
-
-   switch (state-Vcc) {
-   case 0: /* Hi-Z */
-   break;
-
-   case 33: /* VY 

Re: [PATCH 00/19] ARM SA11x0 / PXA / SoC-common PCMCIA cleanups

2012-01-20 Thread Russell King - ARM Linux
On Fri, Jan 20, 2012 at 10:17:09AM +, Russell King - ARM Linux wrote:
 What follows is a series of 19 patches cleaning up the SA11xx and PXA
 PCMCIA support, which uses the soc-common infrastructure.
 
 Now that we have proper gpiolib support in the kernel for these platforms,
 with properly implemented gpio_to_irq() functionality, we can move some
 things that the individual platform socket drivers were doing into the
 soc-common core.
 
 This significantly reduces the code in the platform socket drivers -
 a reduction of around 550 lines, for the net addition of about 50 lines
 to soc-common.
 
 The final set of five patches in this set contain some minor bug fixes
 (which are really low priority) and cleanup the handling of the SA
 build between PXA and SA11x0 platforms.
 
 Please supply acks; I have other work which touches the header files
 in arch/arm which would conflict, and it would help to keep it together
 rather than have SFR carry those resolutions.

I should add that these changes have been tested on the Assabet (SA1110)
and Assabet with Neponset daughter board (SA) platforms with a CF
network card and a PCMCIA wireless card.

There are a couple of bugs in genirq which stop both the original code,
and these updates from working correctly.  These changes in itself do
not cause a regression as a result of that.  This is in the hands of
the genirq people to resolve as it's a regression - this code worked
100% with the ARM IRQ layer, which was part of the basis for genirq.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH] spi: reorganize drivers

2011-06-06 Thread Russell King - ARM Linux
On Mon, Jun 06, 2011 at 11:00:38AM +0200, Arnd Bergmann wrote:
 This leaves out the two most common buses, USB and PCI, mostly because
 the directories contain a lot of stuff that is not really bus code
 but actual drivers. It does include i2c and spi, which stick out by
 being a lot larger than most others.
 
 Opinions? Move or don't move?

I don't see much point in adding an additional level of directories.
All that it'll do is add to the shell filename completion workload
and wear out our tab keys faster...

We'll still have these directories with not a lot under them.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 2/2] ARM: pcmcia: fix checkpatch.pl issues in soc_common.c

2010-03-28 Thread Russell King - ARM Linux
On Thu, Mar 25, 2010 at 06:04:40PM +0100, Dominik Brodowski wrote:
 do you prefer me pushing these patches upstream (possibly even for -rc3), or
 do you wish to take these patches?

I'll take them through the patch system, but as they're not bug fixes
I'd queue them for the next merge window.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 2/2] ARM: pcmcia: fix checkpatch.pl issues in soc_common.c

2010-03-26 Thread Russell King - ARM Linux
On Thu, Mar 25, 2010 at 01:19:29PM +0300, Sergei Shtylyov wrote:
 Hello.

 Russell King - ARM Linux wrote:

 -   debug(skt, 2, mask: %s%s%s%s%s%sflags: %s%s%s%s%s%sVcc %d Vpp %d irq 
 %d\n,
 -   (state-csc_mask==0)?NONE :,
 -   (state-csc_maskSS_DETECT)?DETECT :,
 -   (state-csc_maskSS_READY)?READY :,
 -   (state-csc_maskSS_BATDEAD)?BATDEAD :,
 -   (state-csc_maskSS_BATWARN)?BATWARN :,
 -   (state-csc_maskSS_STSCHG)?STSCHG :,
 -   (state-flags==0)?NONE :,
 -   (state-flagsSS_PWR_AUTO)?PWR_AUTO :,
 -   (state-flagsSS_IOCARD)?IOCARD :,
 -   (state-flagsSS_RESET)?RESET :,
 -   (state-flagsSS_SPKR_ENA)?SPKR_ENA :,
 -   (state-flagsSS_OUTPUT_ENA)?OUTPUT_ENA :,
 +   debug(skt, 2,   mask: %s%s%s%s%s%s 
 +   flags: %s%s%s%s%s%s Vcc %d Vpp %d irq %d\n,
 

 NAK.  Breaking kernel messages across multiple lines makes them impossible
 to grep for.  checkpatch.pl is wrong on this one.
   

   I'd disagree in this case. Anybody will hardly grep for mask:  
 %s%s%s%s%s%sflags: %s%s%s%s%s%s.

Well, I disagree on a matter of principle with you.  If you want to avoid
the line going over 80 columns, move the entire string onto the next line.
Then we can have the entire string intact _and_ we can have it fitting
within 80 columns.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 2/2] ARM: pcmcia: fix checkpatch.pl issues in soc_common.c

2010-03-26 Thread Russell King - ARM Linux
On Fri, Mar 26, 2010 at 06:57:07PM -0300, Marcelo Jimenez wrote:
 On Fri, Mar 26, 2010 at 15:18, Russell King - ARM Linux
 li...@arm.linux.org.uk wrote:
  On Thu, Mar 25, 2010 at 01:19:29PM +0300, Sergei Shtylyov wrote:
 
    I'd disagree in this case. Anybody will hardly grep for mask:
  %s%s%s%s%s%sflags: %s%s%s%s%s%s.
 
  Well, I disagree on a matter of principle with you.  If you want to avoid
  the line going over 80 columns, move the entire string onto the next line.
  Then we can have the entire string intact _and_ we can have it fitting
  within 80 columns.
 
 This is no big deal. Also, I have already submitted the new patch and
 Valdis had a good point for egrep.

Sorry, I'm having stability issues with my MTA which inexplicably died
about 12 hours ago, presumably due to the level of crap flying around
the 'net nowadays.  This appears to be becoming a regular occurance in
the last week. ;(

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 2/2] ARM: pcmcia: fix checkpatch.pl issues in soc_common.c

2010-03-24 Thread Russell King - ARM Linux
On Wed, Mar 24, 2010 at 08:04:58PM -0300, Marcelo Roberto Jimenez wrote:
 - debug(skt, 2, mask: %s%s%s%s%s%sflags: %s%s%s%s%s%sVcc %d Vpp %d irq 
 %d\n,
 - (state-csc_mask==0)?NONE :,
 - (state-csc_maskSS_DETECT)?DETECT :,
 - (state-csc_maskSS_READY)?READY :,
 - (state-csc_maskSS_BATDEAD)?BATDEAD :,
 - (state-csc_maskSS_BATWARN)?BATWARN :,
 - (state-csc_maskSS_STSCHG)?STSCHG :,
 - (state-flags==0)?NONE :,
 - (state-flagsSS_PWR_AUTO)?PWR_AUTO :,
 - (state-flagsSS_IOCARD)?IOCARD :,
 - (state-flagsSS_RESET)?RESET :,
 - (state-flagsSS_SPKR_ENA)?SPKR_ENA :,
 - (state-flagsSS_OUTPUT_ENA)?OUTPUT_ENA :,
 + debug(skt, 2,   mask: %s%s%s%s%s%s 
 + flags: %s%s%s%s%s%s Vcc %d Vpp %d irq %d\n,

NAK.  Breaking kernel messages across multiple lines makes them impossible
to grep for.  checkpatch.pl is wrong on this one.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 0/3] MXC PCMCIA Support

2010-02-20 Thread Russell King - ARM Linux
On Sat, Feb 20, 2010 at 04:32:01PM +0100, Martin Fuzzey wrote:
 This patch series adds support for the MXC PCMCIA / CF controller.
 
 It has been tested on MX21 (with CF card + ide-cs as well as a
 broadcom based wificard using b43 driver)
 
 It has been compile only tested for MX27, MX31 as I don't have
 this hardware but the code is based on Freescale's MX31.
 
 Changes since RFC:
* Split arch specifc changes from driver
* Update to 2.6.33-rc8 [soc-common is now a standalone module]

I do wonder whether, as you have windows, you should be using the soc
support - the soc support is based interfacing hardware which does not
have windows into the generic infrastructure which assumes the presence
of windows.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH] pcmcia/at91_cf: don't redefine SZ_2K

2009-12-22 Thread Russell King - ARM Linux
On Sun, Dec 20, 2009 at 10:10:34PM +0100, Uwe Kleine-König wrote:
 This fixes:
 
   drivers/pcmcia/at91_cf.c:55:1: warning: SZ_2K redefined
 
 Since
 
   c1191b0 ([ARM] Kirkwood: create a mapping for the Security Accelerator 
 SRAM)

Have you checked whether everything which uses at91_cf still builds after
this patch has been applied (eg, AVR32 stuff?)

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [RFC PATCH 01/10] PCMCIA: soc_common: convert to a stand alone module

2009-12-05 Thread Russell King - ARM Linux
On Sat, Dec 05, 2009 at 10:56:33AM +0100, Dominik Brodowski wrote:
 Russell,
 
 On Fri, Dec 04, 2009 at 05:24:17PM +, Russell King - ARM Linux wrote:
  For the time being, I'll merge your patch into my git tree, but unless
  Dominik hands my patches back to me for merging, it will be lost.
 
 your patches -- which you asked me to merge and push upstream -- are on
 their way to Linus. I'll merge this bugfix to your patch later and push it
 upstream, too, unless you prefer to do that independently.

Yes I did at the time, but things change.  Since you've been totally silent
on the merge conflicts between your PCMCIA tree and my tree which SFR
reported on December 1st:

| Hi Dominik,
| 
| Today's linux-next merge of the pcmcia tree got a conflict in
| drivers/pcmcia/sa1100_h3600.c between commit
| 6ce8f65e71f0d80ee23b543be09789dd865a99be (ARM: 5811/1: pcmcia: convert
| sa1100_h3600 driver to gpiolib) from the arm tree and commit
| 66024db57d5b9011e274b314affad68f370c0d6f (PCMCIA: stop duplicating
| pci_irq in soc_pcmcia_socket) from the pcmcia tree.
| 
| I fixed it up (see below) and can carry the fix as necessary.  Please
| check the fix below.
...

To which there was this reply:
| Fix looks good to me, and testing next-20091201 on real device (h3600)
| shows no problems with pcmcia.
| 
| Perhaps this merge conflict can be avoided by merging Russell's PCMCIA
| patches through arm tree. But, anyway, it's Russell and Dominik
| to decide.

And a reply from me agreeing that it would probably make more sense in
light of this for my patches to go through my tree.

This is no longer possible, so I'm going to kick out the conflicting code
for the time being.  The conflicting stuff can be merged at some later
date once this kind of issue is solved.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [RFC PATCH 01/10] PCMCIA: soc_common: convert to a stand alone module

2009-12-05 Thread Russell King - ARM Linux
On Sat, Dec 05, 2009 at 12:04:17PM +0100, Dominik Brodowski wrote:
 Russell,
 
 On Sat, Dec 05, 2009 at 10:28:16AM +, Russell King - ARM Linux wrote:
  On Sat, Dec 05, 2009 at 10:56:33AM +0100, Dominik Brodowski wrote:
   Russell,
   
   On Fri, Dec 04, 2009 at 05:24:17PM +, Russell King - ARM Linux wrote:
For the time being, I'll merge your patch into my git tree, but unless
Dominik hands my patches back to me for merging, it will be lost.
   
   your patches -- which you asked me to merge and push upstream -- are on
   their way to Linus. I'll merge this bugfix to your patch later and push it
   upstream, too, unless you prefer to do that independently.
  
  Yes I did at the time, but things change.  Since you've been totally silent
  on the merge conflicts between your PCMCIA tree and my tree which SFR
  reported on December 1st:
 
 Well, as this was an addition through your tree, I didn't consider it
 neccessary to comment on it.

Which, in spite of the discussion surrounding the conflict, and the
resulting fall-out from it, would seem to have been the wrong decision.

 
  | Hi Dominik,
  | 
  | Today's linux-next merge of the pcmcia tree got a conflict in
  | drivers/pcmcia/sa1100_h3600.c between commit
  | 6ce8f65e71f0d80ee23b543be09789dd865a99be (ARM: 5811/1: pcmcia: convert
  | sa1100_h3600 driver to gpiolib) from the arm tree and commit
  | 66024db57d5b9011e274b314affad68f370c0d6f (PCMCIA: stop duplicating
  | pci_irq in soc_pcmcia_socket) from the pcmcia tree.
  | 
  | I fixed it up (see below) and can carry the fix as necessary.  Please
  | check the fix below.
  ...
  
  To which there was this reply:
  | Fix looks good to me, and testing next-20091201 on real device (h3600)
  | shows no problems with pcmcia.
  | 
  | Perhaps this merge conflict can be avoided by merging Russell's PCMCIA
  | patches through arm tree. But, anyway, it's Russell and Dominik
  | to decide.
  
  And a reply from me agreeing that it would probably make more sense in
  light of this for my patches to go through my tree.
 
 Well, another option would have been to merge the other changes to
 drivers/pcmcia/ via PCMCIA -- something which has not even been suggested.

That would mean merging a bunch of other non-PCMCIA related changes
through your tree as well.

Do you want all the non-PCMCIA related changes in your tree as well?

 More and more I think some if not all PCMCIA socket drivers should reside in
 subdirectories to drivers/pcmcia/ .

That's a completely separate issue.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH] add pismo support

2009-11-29 Thread Russell King - ARM Linux
The following patch adds support for PISMO modules found on ARM Ltd
development platforms.  These are MTD modules, and can have a
selection of SRAM, flash or DOC devices as described by an on-board
I2C EEPROM.

We support SRAM and NOR flash devices only by registering appropriate
conventional MTD platform devices as children of the 'pismo' device.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
--
 drivers/mtd/maps/Kconfig  |   15 ++
 drivers/mtd/maps/Makefile |1 
 drivers/mtd/maps/pismo.c  |  325 ++
 include/linux/mtd/pismo.h |   17 ++
 4 files changed, 358 insertions(+)

diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 0b98654..631b060 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -553,4 +553,19 @@ config MTD_VMU
  To build this as a module select M here, the module will be called
  vmu-flash.
 
+config MTD_PISMO
+   tristate MTD discovery driver for PISMO modules
+   depends on I2C
+   depends on ARCH_VERSATILE
+   help
+ This driver allows for discovery of PISMO modules - see
+ http://www.pismoworld.org/.  These are small modules containing
+ up to five memory devices (eg, SRAM, flash, DOC) described by an
+ I2C EEPROM.
+
+ This driver does not create any MTD maps itself; instead it
+ creates MTD physmap and MTD SRAM platform devices.  If you
+ enable this option, you should consider enabling MTD_PHYSMAP
+ and/or MTD_PLATRAM according to the devices on your module.
+
 endmenu
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 8bae7f9..cffaaf1 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -61,3 +61,4 @@ obj-$(CONFIG_MTD_INTEL_VR_NOR)+= intel_vr_nor.o
 obj-$(CONFIG_MTD_BFIN_ASYNC)   += bfin-async-flash.o
 obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o
 obj-$(CONFIG_MTD_VMU)  += vmu-flash.o
+obj-$(CONFIG_MTD_PISMO)+= pismo.o
--- /dev/null   2009-08-03 10:19:25.737008066 +0100
+++ b/drivers/mtd/maps/pismo.c  2009-08-03 14:23:32.0 +0100
@@ -0,0 +1,325 @@
+/*
+ * PISMO memory driver - http://www.pismoworld.org/
+ *
+ * For ARM Realview and Versatile platforms
+ *
+ * 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.
+ */
+#include linux/init.h
+#include linux/module.h
+#include linux/i2c.h
+#include linux/platform_device.h
+#include linux/spinlock.h
+#include linux/mutex.h
+#include linux/mtd/physmap.h
+#include linux/mtd/plat-ram.h
+#include linux/mtd/pismo.h
+
+#define PISMO_NUM_CS   5
+
+struct pismo_cs_block {
+   u8  type;
+   u8  width;
+   __le16  access;
+   __le32  size;
+   u32 reserved[2];
+   chardevice[32];
+} __packed;
+
+struct pismo_eeprom {
+   struct pismo_cs_block cs[PISMO_NUM_CS];
+   charboard[15];
+   u8  sum;
+} __packed;
+
+struct pismo_mem {
+   phys_addr_t base;
+   u32 size;
+   u16 access;
+   u8  width;
+   u8  type;
+};
+
+struct pismo_data {
+   struct i2c_client   *client;
+   void(*vpp)(void *, int);
+   void*vpp_data;
+   struct platform_device  *dev[PISMO_NUM_CS];
+};
+
+/* FIXME: set_vpp could do with a better calling convention */
+static struct pismo_data *vpp_pismo;
+static DEFINE_MUTEX(pismo_mutex);
+
+static int pismo_setvpp_probe_fix(struct pismo_data *pismo)
+{
+   mutex_lock(pismo_mutex);
+   if (vpp_pismo) {
+   mutex_unlock(pismo_mutex);
+   kfree(pismo);
+   return -EBUSY;
+   }
+   vpp_pismo = pismo;
+   mutex_unlock(pismo_mutex);
+   return 0;
+}
+
+static void pismo_setvpp_remove_fix(struct pismo_data *pismo)
+{
+   mutex_lock(pismo_mutex);
+   if (vpp_pismo == pismo)
+   vpp_pismo = NULL;
+   mutex_unlock(pismo_mutex);
+}
+
+static void pismo_set_vpp(struct map_info *map, int on)
+{
+   struct pismo_data *pismo = vpp_pismo;
+
+   pismo-vpp(pismo-vpp_data, on);
+}
+/* end of hack */
+
+
+static unsigned int pismo_width_to_bytes(unsigned int width)
+{
+   width = 15;
+   if (width  2)
+   return 0;
+   return 1  width;
+}
+
+static int pismo_eeprom_read(struct i2c_client *client, void *buf, u8 addr,
+   size_t size)
+{
+   int ret;
+   struct i2c_msg msg[] = {
+   {
+   .addr = client-addr,
+   .len = sizeof(addr),
+   .buf = addr,
+   }, {
+   .addr = client-addr,
+   .flags = I2C_M_RD,
+   .len = size,
+   .buf = buf,
+   },
+   };
+
+   ret = 

Re: [PATCH 3/8] drivers/pcmcia: remove unnecessary kzalloc

2009-11-21 Thread Russell King - ARM Linux
On Sat, Nov 21, 2009 at 04:12:59PM +0100, Julia Lawall wrote:
 Both kzallocs were added at the same time, when the function was added in 
 commit 701a5dc05ad99a06958b3f97cb69d99b47cebee3.  I have added the author 
 to the CC list.

That commit id means nothing to me.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[RFC PATCH 01/10] PCMCIA: soc_common: convert to a stand alone module

2009-10-27 Thread Russell King - ARM Linux
Convert soc_common.c to be a stand alone module, rather than wrapping
it up into the individual SoC specific base modules.  In doing this,
we need to add init/exit functions for soc_common to register/remove
the cpufreq notifier.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/Kconfig  |6 ++
 drivers/pcmcia/Makefile |   10 --
 drivers/pcmcia/soc_common.c |   16 +++-
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 17f38a7..0b82493 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -196,9 +196,13 @@ config PCMCIA_BCM63XX
tristate bcm63xx pcmcia support
depends on BCM63XX  PCMCIA
 
+config PCMCIA_SOC_COMMON
+   bool
+
 config PCMCIA_SA1100
tristate SA1100 support
depends on ARM  ARCH_SA1100  PCMCIA
+   select PCMCIA_SOC_COMMON
help
  Say Y here to include support for SA11x0-based PCMCIA or CF
  sockets, found on HP iPAQs, Yopy, and other StrongARM(R)/
@@ -209,6 +213,7 @@ config PCMCIA_SA1100
 config PCMCIA_SA
tristate SA support
depends on ARM  ARCH_SA1100  SA  PCMCIA
+   select PCMCIA_SOC_COMMON
help
  Say Y  here to include support for SA-based PCMCIA or CF
  sockets, found on the Jornada 720, Graphicsmaster and other
@@ -222,6 +227,7 @@ config PCMCIA_PXA2XX
depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \
|| MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \
|| ARCH_VIPER || ARCH_PXA_ESERIES || MACH_STARGATE2)
+   select PCMCIA_SOC_COMMON
help
  Say Y here to include support for the PXA2xx PCMCIA controller
 
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index a03a38a..3829383 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -22,8 +22,9 @@ obj-$(CONFIG_I82365)  += i82365.o
 obj-$(CONFIG_I82092)   += i82092.o
 obj-$(CONFIG_TCIC) += tcic.o
 obj-$(CONFIG_PCMCIA_M8XX)  += m8xx_pcmcia.o
-obj-$(CONFIG_PCMCIA_SA1100)+= sa11xx_core.o sa1100_cs.o
-obj-$(CONFIG_PCMCIA_SA)+= sa11xx_core.o sa_cs.o
+obj-$(CONFIG_PCMCIA_SOC_COMMON)+= soc_common.o
+obj-$(CONFIG_PCMCIA_SA1100)+= sa11xx_base.o sa1100_cs.o
+obj-$(CONFIG_PCMCIA_SA)+= sa11xx_base.o sa_cs.o
 obj-$(CONFIG_M32R_PCC) += m32r_pcc.o
 obj-$(CONFIG_M32R_CFC) += m32r_cfc.o
 obj-$(CONFIG_PCMCIA_AU1X00)+= au1x00_ss.o
@@ -35,9 +36,6 @@ obj-$(CONFIG_BFIN_CFPCMCIA)   += 
bfin_cf_pcmcia.o
 obj-$(CONFIG_AT91_CF)  += at91_cf.o
 obj-$(CONFIG_ELECTRA_CF)   += electra_cf.o
 
-sa11xx_core-y  += soc_common.o sa11xx_base.o
-pxa2xx_core-y  += soc_common.o pxa2xx_base.o
-
 au1x00_ss-y+= au1000_generic.o
 au1x00_ss-$(CONFIG_MIPS_PB1000)+= au1000_pb1x00.o
 au1x00_ss-$(CONFIG_MIPS_PB1100)+= au1000_pb1x00.o
@@ -77,4 +75,4 @@ pxa2xx-obj-$(CONFIG_MACH_PALMLD)  += 
pxa2xx_palmld.o
 pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o
 pxa2xx-obj-$(CONFIG_MACH_STARGATE2)+= pxa2xx_stargate2.o
 
-obj-$(CONFIG_PCMCIA_PXA2XX)+= pxa2xx_core.o $(pxa2xx-obj-y)
+obj-$(CONFIG_PCMCIA_PXA2XX)+= pxa2xx_base.o $(pxa2xx-obj-y)
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 163cf98..38c5484 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -608,15 +608,14 @@ static int soc_pcmcia_cpufreq_register(void)
notifier for PCMCIA (%d)\n, ret);
return ret;
 }
+fs_initcall(soc_pcmcia_cpufreq_register);
 
 static void soc_pcmcia_cpufreq_unregister(void)
 {
cpufreq_unregister_notifier(soc_pcmcia_notifier_block, 
CPUFREQ_TRANSITION_NOTIFIER);
 }
+module_exit(soc_pcmcia_cpufreq_unregister);
 
-#else
-static int soc_pcmcia_cpufreq_register(void) { return 0; }
-static void soc_pcmcia_cpufreq_unregister(void) {}
 #endif
 
 int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level 
*ops,
@@ -667,9 +666,6 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct 
pcmcia_low_level *ops
goto out_err_5;
}
 
-   if (list_empty(soc_pcmcia_sockets))
-   soc_pcmcia_cpufreq_register();
-
list_add(skt-node, soc_pcmcia_sockets);
 
/*
@@ -742,6 +738,7 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct 
pcmcia_low_level *ops

[RFC PATCH 02/10] PCMCIA: soc_common: provide single socket add/remove functionality

2009-10-27 Thread Russell King - ARM Linux
Factor out the functionality for adding and removing a single
socket, thereby allowing SoCs to individually register each
socket.  The advantage of this approach is that SoCs can then
extend soc_pcmcia_socket as they wish.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/soc_common.c |  230 +++
 drivers/pcmcia/soc_common.h |3 +-
 2 files changed, 125 insertions(+), 108 deletions(-)

diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 38c5484..8938608 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -573,7 +573,7 @@ void soc_pcmcia_enable_irqs(struct soc_pcmcia_socket *skt,
 EXPORT_SYMBOL(soc_pcmcia_enable_irqs);
 
 
-LIST_HEAD(soc_pcmcia_sockets);
+static LIST_HEAD(soc_pcmcia_sockets);
 static DEFINE_MUTEX(soc_pcmcia_sockets_lock);
 
 #ifdef CONFIG_CPU_FREQ
@@ -618,158 +618,174 @@ module_exit(soc_pcmcia_cpufreq_unregister);
 
 #endif
 
-int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level 
*ops,
-   struct skt_dev_info *sinfo)
+void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt)
 {
-   struct soc_pcmcia_socket *skt;
-   int ret, i;
-
mutex_lock(soc_pcmcia_sockets_lock);
+   del_timer_sync(skt-poll_timer);
 
-   /*
-* Initialise the per-socket structure.
-*/
-   for (i = 0; i  sinfo-nskt; i++) {
-   skt = sinfo-skt[i];
+   pcmcia_unregister_socket(skt-socket);
 
-   skt-socket.ops = soc_common_pcmcia_operations;
-   skt-socket.owner = ops-owner;
-   skt-socket.dev.parent = dev;
+   flush_scheduled_work();
 
-   init_timer(skt-poll_timer);
-   skt-poll_timer.function = soc_common_pcmcia_poll_event;
-   skt-poll_timer.data = (unsigned long)skt;
-   skt-poll_timer.expires = jiffies + SOC_PCMCIA_POLL_PERIOD;
+   skt-ops-hw_shutdown(skt);
 
-   skt-dev= dev;
-   skt-ops= ops;
+   soc_common_pcmcia_config_skt(skt, dead_socket);
 
-   ret = request_resource(iomem_resource, skt-res_skt);
-   if (ret)
-   goto out_err_1;
+   list_del(skt-node);
+   mutex_unlock(soc_pcmcia_sockets_lock);
 
-   ret = request_resource(skt-res_skt, skt-res_io);
-   if (ret)
-   goto out_err_2;
+   iounmap(skt-virt_io);
+   skt-virt_io = NULL;
+   release_resource(skt-res_attr);
+   release_resource(skt-res_mem);
+   release_resource(skt-res_io);
+   release_resource(skt-res_skt);
+}
+EXPORT_SYMBOL(soc_pcmcia_remove_one);
 
-   ret = request_resource(skt-res_skt, skt-res_mem);
-   if (ret)
-   goto out_err_3;
+int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt)
+{
+   int ret;
 
-   ret = request_resource(skt-res_skt, skt-res_attr);
-   if (ret)
-   goto out_err_4;
+   init_timer(skt-poll_timer);
+   skt-poll_timer.function = soc_common_pcmcia_poll_event;
+   skt-poll_timer.data = (unsigned long)skt;
+   skt-poll_timer.expires = jiffies + SOC_PCMCIA_POLL_PERIOD;
 
-   skt-virt_io = ioremap(skt-res_io.start, 0x1);
-   if (skt-virt_io == NULL) {
-   ret = -ENOMEM;
-   goto out_err_5;
-   }
+   ret = request_resource(iomem_resource, skt-res_skt);
+   if (ret)
+   goto out_err_1;
 
-   list_add(skt-node, soc_pcmcia_sockets);
+   ret = request_resource(skt-res_skt, skt-res_io);
+   if (ret)
+   goto out_err_2;
 
-   /*
-* We initialize default socket timing here, because
-* we are not guaranteed to see a SetIOMap operation at
-* runtime.
-*/
-   ops-set_timing(skt);
+   ret = request_resource(skt-res_skt, skt-res_mem);
+   if (ret)
+   goto out_err_3;
 
-   ret = ops-hw_init(skt);
-   if (ret)
-   goto out_err_6;
+   ret = request_resource(skt-res_skt, skt-res_attr);
+   if (ret)
+   goto out_err_4;
 
-   skt-socket.features = SS_CAP_STATIC_MAP|SS_CAP_PCCARD;
-   skt-socket.resource_ops = pccard_static_ops;
-   skt-socket.irq_mask = 0;
-   skt-socket.map_size = PAGE_SIZE;
-   skt-socket.pci_irq = skt-irq;
-   skt-socket.io_offset = (unsigned long)skt-virt_io;
+   skt-virt_io = ioremap(skt-res_io.start, 0x1);
+   if (skt-virt_io == NULL) {
+   ret = -ENOMEM;
+   goto out_err_5;
+   }
 
-   skt-status = soc_common_pcmcia_skt_state(skt);
+   mutex_lock(soc_pcmcia_sockets_lock);
 
-   ret = 

[RFC PATCH 03/10] PCMCIA: soc_common: push socket removal down to SoC specific support

2009-10-27 Thread Russell King - ARM Linux
Mechanically transplant the removal code from soc_common into each
SoC specific base support file, thereby allowing
soc_common_drv_pcmcia_remove to be removed.  No other changes.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/pxa2xx_base.c|   11 ++-
 drivers/pcmcia/sa1100_generic.c |   11 ++-
 drivers/pcmcia/sa_generic.c |   10 +-
 drivers/pcmcia/soc_common.c |   16 
 drivers/pcmcia/soc_common.h |1 -
 5 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 0e35acb..8a91106 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -297,7 +297,16 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device 
*dev)
 
 static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
 {
-   return soc_common_drv_pcmcia_remove(dev-dev);
+   struct skt_dev_info *sinfo = platform_get_drvdata(dev);
+   int i;
+
+   platform_set_drvdata(dev, NULL);
+
+   for (i = 0; i  sinfo-nskt; i++)
+   soc_pcmcia_remove_one(sinfo-skt[i]);
+
+   kfree(sinfo);
+   return 0;
 }
 
 static int pxa2xx_drv_pcmcia_suspend(struct device *dev)
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
index 2d0e997..11cc3ba 100644
--- a/drivers/pcmcia/sa1100_generic.c
+++ b/drivers/pcmcia/sa1100_generic.c
@@ -83,7 +83,16 @@ static int sa11x0_drv_pcmcia_probe(struct platform_device 
*dev)
 
 static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
 {
-   return soc_common_drv_pcmcia_remove(dev-dev);
+   struct skt_dev_info *sinfo = platform_get_drvdata(dev);
+   int i;
+
+   platform_set_drvdata(dev, NULL);
+
+   for (i = 0; i  sinfo-nskt; i++)
+   soc_pcmcia_remove_one(sinfo-skt[i]);
+
+   kfree(sinfo);
+   return 0;
 }
 
 static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev,
diff --git a/drivers/pcmcia/sa_generic.c b/drivers/pcmcia/sa_generic.c
index 4be4e17..a6793e3 100644
--- a/drivers/pcmcia/sa_generic.c
+++ b/drivers/pcmcia/sa_generic.c
@@ -152,7 +152,15 @@ static int pcmcia_probe(struct sa_dev *dev)
 
 static int __devexit pcmcia_remove(struct sa_dev *dev)
 {
-   soc_common_drv_pcmcia_remove(dev-dev);
+   struct skt_dev_info *sinfo = dev_get_drvdata(dev-dev);
+   int i;
+
+   dev_set_drvdata(dev-dev, NULL);
+
+   for (i = 0; i  sinfo-nskt; i++)
+   soc_pcmcia_remove_one(sinfo-skt[i]);
+
+   kfree(sinfo);
release_mem_region(dev-res.start, 512);
return 0;
 }
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 8938608..c42b651 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -777,22 +777,6 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct 
pcmcia_low_level *ops
 }
 EXPORT_SYMBOL(soc_common_drv_pcmcia_probe);
 
-int soc_common_drv_pcmcia_remove(struct device *dev)
-{
-   struct skt_dev_info *sinfo = dev_get_drvdata(dev);
-   int i;
-
-   dev_set_drvdata(dev, NULL);
-
-   for (i = 0; i  sinfo-nskt; i++)
-   soc_pcmcia_remove_one(sinfo-skt[i]);
-
-   kfree(sinfo);
-
-   return 0;
-}
-EXPORT_SYMBOL(soc_common_drv_pcmcia_remove);
-
 MODULE_AUTHOR(John Dorsey jo...@cs.cmu.edu);
 MODULE_DESCRIPTION(Linux PCMCIA Card Services: Common SoC support);
 MODULE_LICENSE(Dual MPL/GPL);
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h
index 51c72ba..c33b8c3 100644
--- a/drivers/pcmcia/soc_common.h
+++ b/drivers/pcmcia/soc_common.h
@@ -139,7 +139,6 @@ void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt);
 int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt);
 
 extern int soc_common_drv_pcmcia_probe(struct device *dev, struct 
pcmcia_low_level *ops, struct skt_dev_info *sinfo);
-extern int soc_common_drv_pcmcia_remove(struct device *dev);
 
 
 #ifdef CONFIG_PCMCIA_DEBUG
-- 
1.6.2.5


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[RFC PATCH 04/10] PCMCIA: soc_common: push socket probe down into SoC specific support

2009-10-27 Thread Russell King - ARM Linux
Move the individual socket probing and initialization down into the
SoC specific support files, thereby allowing soc_common_drv_pcmcia_probe
to be eliminated.  soc_common.c now no longer deals with distinct groups
of sockets.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/pxa2xx_base.c |   77 +--
 drivers/pcmcia/sa11xx_base.c |   91 ++
 drivers/pcmcia/soc_common.c  |   37 -
 drivers/pcmcia/soc_common.h  |2 -
 4 files changed, 103 insertions(+), 104 deletions(-)

diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 8a91106..3cb4fd2 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -228,6 +228,31 @@ static const char *skt_names[] = {
 #define SKT_DEV_INFO_SIZE(n) \
(sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
 
+static int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt)
+{
+   skt-res_skt.start = _PCMCIA(skt-nr);
+   skt-res_skt.end = _PCMCIA(skt-nr) + PCMCIASp - 1;
+   skt-res_skt.name = skt_names[skt-nr];
+   skt-res_skt.flags = IORESOURCE_MEM;
+
+   skt-res_io.start = _PCMCIAIO(skt-nr);
+   skt-res_io.end = _PCMCIAIO(skt-nr) + PCMCIAIOSp - 1;
+   skt-res_io.name = io;
+   skt-res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+
+   skt-res_mem.start = _PCMCIAMem(skt-nr);
+   skt-res_mem.end = _PCMCIAMem(skt-nr) + PCMCIAMemSp - 1;
+   skt-res_mem.name = memory;
+   skt-res_mem.flags = IORESOURCE_MEM;
+
+   skt-res_attr.start = _PCMCIAAttr(skt-nr);
+   skt-res_attr.end = _PCMCIAAttr(skt-nr) + PCMCIAAttrSp - 1;
+   skt-res_attr.name = attribute;
+   skt-res_attr.flags = IORESOURCE_MEM;
+
+   return soc_pcmcia_add_one(skt);
+}
+
 int __pxa2xx_drv_pcmcia_probe(struct device *dev)
 {
int i, ret;
@@ -240,6 +265,12 @@ int __pxa2xx_drv_pcmcia_probe(struct device *dev)
 
ops = (struct pcmcia_low_level *)dev-platform_data;
 
+   /* Provide our PXA2xx specific timing routines. */
+   ops-set_timing  = pxa2xx_pcmcia_set_timing;
+#ifdef CONFIG_CPU_FREQ
+   ops-frequency_change = pxa2xx_pcmcia_frequency_change;
+#endif
+
sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops-nr), GFP_KERNEL);
if (!sinfo)
return -ENOMEM;
@@ -250,40 +281,26 @@ int __pxa2xx_drv_pcmcia_probe(struct device *dev)
for (i = 0; i  ops-nr; i++) {
skt = sinfo-skt[i];
 
-   skt-nr = ops-first + i;
-   skt-irq= NO_IRQ;
-
-   skt-res_skt.start  = _PCMCIA(skt-nr);
-   skt-res_skt.end= _PCMCIA(skt-nr) + PCMCIASp - 1;
-   skt-res_skt.name   = skt_names[skt-nr];
-   skt-res_skt.flags  = IORESOURCE_MEM;
+   skt-nr = ops-first + i;
+   skt-irq = NO_IRQ;
+   skt-dev = dev;
+   skt-ops = ops;
+   skt-socket.owner = ops-owner;
+   skt-socket.dev.parent = dev;
 
-   skt-res_io.start   = _PCMCIAIO(skt-nr);
-   skt-res_io.end = _PCMCIAIO(skt-nr) + PCMCIAIOSp - 1;
-   skt-res_io.name= io;
-   skt-res_io.flags   = IORESOURCE_MEM | IORESOURCE_BUSY;
-
-   skt-res_mem.start  = _PCMCIAMem(skt-nr);
-   skt-res_mem.end= _PCMCIAMem(skt-nr) + PCMCIAMemSp - 1;
-   skt-res_mem.name   = memory;
-   skt-res_mem.flags  = IORESOURCE_MEM;
-
-   skt-res_attr.start = _PCMCIAAttr(skt-nr);
-   skt-res_attr.end   = _PCMCIAAttr(skt-nr) + PCMCIAAttrSp - 
1;
-   skt-res_attr.name  = attribute;
-   skt-res_attr.flags = IORESOURCE_MEM;
+   ret = pxa2xx_drv_pcmcia_add_one(skt);
+   if (ret)
+   break;
}
 
-   /* Provide our PXA2xx specific timing routines. */
-   ops-set_timing  = pxa2xx_pcmcia_set_timing;
-#ifdef CONFIG_CPU_FREQ
-   ops-frequency_change = pxa2xx_pcmcia_frequency_change;
-#endif
-
-   ret = soc_common_drv_pcmcia_probe(dev, ops, sinfo);
-
-   if (!ret)
+   if (ret) {
+   while (--i = 0)
+   soc_pcmcia_remove_one(sinfo-skt[i]);
+   kfree(sinfo);
+   } else {
pxa2xx_configure_sockets(dev);
+   dev_set_drvdata(dev, sinfo);
+   }
 
return ret;
 }
diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c
index e15d59f..92a4348 100644
--- a/drivers/pcmcia/sa11xx_base.c
+++ b/drivers/pcmcia/sa11xx_base.c
@@ -171,6 +171,31 @@ static const char *skt_names[] = {
 #define SKT_DEV_INFO_SIZE(n) \
(sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
 
+static int sa11xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt)
+{
+   skt-res_skt.start = _PCMCIA(skt-nr);

[RFC PATCH 05/10] PCMCIA: sa1111: wrap soc_pcmcia_socket to contain sa1111 specific data

2009-10-27 Thread Russell King - ARM Linux
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/pcmcia/pxa2xx_base.c   |   19 +++
 drivers/pcmcia/pxa2xx_base.h   |3 ++
 drivers/pcmcia/pxa2xx_lubbock.c|   10 --
 drivers/pcmcia/sa1100_badge4.c |7 -
 drivers/pcmcia/sa1100_jornada720.c |   20 
 drivers/pcmcia/sa1100_neponset.c   |9 -
 drivers/pcmcia/sa_generic.c|   58 
 drivers/pcmcia/sa_generic.h|   14 
 drivers/pcmcia/sa11xx_base.c   |   21 
 drivers/pcmcia/sa11xx_base.h   |2 +
 10 files changed, 123 insertions(+), 40 deletions(-)

diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 3cb4fd2..c9c104b 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -228,7 +228,7 @@ static const char *skt_names[] = {
 #define SKT_DEV_INFO_SIZE(n) \
(sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
 
-static int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt)
+int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt)
 {
skt-res_skt.start = _PCMCIA(skt-nr);
skt-res_skt.end = _PCMCIA(skt-nr) + PCMCIASp - 1;
@@ -253,9 +253,18 @@ static int pxa2xx_drv_pcmcia_add_one(struct 
soc_pcmcia_socket *skt)
return soc_pcmcia_add_one(skt);
 }
 
+void pxa2xx_drv_pcmcia_ops(struct pcmcia_low_level *ops)
+{
+   /* Provide our PXA2xx specific timing routines. */
+   ops-set_timing  = pxa2xx_pcmcia_set_timing;
+#ifdef CONFIG_CPU_FREQ
+   ops-frequency_change = pxa2xx_pcmcia_frequency_change;
+#endif
+}
+
 int __pxa2xx_drv_pcmcia_probe(struct device *dev)
 {
-   int i, ret;
+   int i, ret = 0;
struct pcmcia_low_level *ops;
struct skt_dev_info *sinfo;
struct soc_pcmcia_socket *skt;
@@ -265,11 +274,7 @@ int __pxa2xx_drv_pcmcia_probe(struct device *dev)
 
ops = (struct pcmcia_low_level *)dev-platform_data;
 
-   /* Provide our PXA2xx specific timing routines. */
-   ops-set_timing  = pxa2xx_pcmcia_set_timing;
-#ifdef CONFIG_CPU_FREQ
-   ops-frequency_change = pxa2xx_pcmcia_frequency_change;
-#endif
+   pxa2xx_drv_pcmcia_ops(ops);
 
sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops-nr), GFP_KERNEL);
if (!sinfo)
diff --git a/drivers/pcmcia/pxa2xx_base.h b/drivers/pcmcia/pxa2xx_base.h
index 235d681..cb5efae 100644
--- a/drivers/pcmcia/pxa2xx_base.h
+++ b/drivers/pcmcia/pxa2xx_base.h
@@ -1,3 +1,6 @@
 /* temporary measure */
 extern int __pxa2xx_drv_pcmcia_probe(struct device *);
 
+int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt);
+void pxa2xx_drv_pcmcia_ops(struct pcmcia_low_level *ops);
+
diff --git a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c
index 6cbb1b1..35d5280 100644
--- a/drivers/pcmcia/pxa2xx_lubbock.c
+++ b/drivers/pcmcia/pxa2xx_lubbock.c
@@ -32,6 +32,7 @@ static int
 lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
const socket_state_t *state)
 {
+   struct sa_pcmcia_socket *s = to_skt(skt);
unsigned int pa_dwr_mask, pa_dwr_set, misc_mask, misc_set;
int ret = 0;
 
@@ -149,7 +150,7 @@ lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket 
*skt,
 
if (ret == 0) {
lubbock_set_misc_wr(misc_mask, misc_set);
-   sa_set_io(SA_DEV(skt-dev), pa_dwr_mask, pa_dwr_set);
+   sa_set_io(s-dev, pa_dwr_mask, pa_dwr_set);
}
 
 #if 1
@@ -175,7 +176,7 @@ lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket 
*skt,
 * Switch to 5V,  Configure socket with 5V voltage
 */
lubbock_set_misc_wr(misc_mask, 0);
-   sa_set_io(SA_DEV(skt-dev), pa_dwr_mask, 0);
+   sa_set_io(s-dev, pa_dwr_mask, 0);
 
/*
 * It takes about 100ms to turn off Vcc.
@@ -228,8 +229,9 @@ int pcmcia_lubbock_init(struct sa_dev *sadev)
/* Set CF Socket 1 power to standby mode. */
lubbock_set_misc_wr((1  15) | (1  14), 0);
 
-   sadev-dev.platform_data = lubbock_pcmcia_ops;
-   ret = __pxa2xx_drv_pcmcia_probe(sadev-dev);
+   pxa2xx_drv_pcmcia_ops(lubbock_pcmcia_ops);
+   ret = sa_pcmcia_add(sadev, lubbock_pcmcia_ops,
+   pxa2xx_drv_pcmcia_add_one);
}
 
return ret;
diff --git a/drivers/pcmcia/sa1100_badge4.c b/drivers/pcmcia/sa1100_badge4.c
index 1ca9737..6399314 100644
--- a/drivers/pcmcia/sa1100_badge4.c
+++ b/drivers/pcmcia/sa1100_badge4.c
@@ -134,6 +134,9 @@ static struct pcmcia_low_level badge4_pcmcia_ops = {
 
.socket_init= sa_pcmcia_socket_init,
.socket_suspend = sa_pcmcia_socket_suspend,
+
+   .first  = 0,
+   .nr = 2,
 };
 
 int 

Re: [RFC PATCH 00/10] PCMCIA soc_common re-factorization

2009-10-27 Thread Russell King - ARM Linux
This is a re-post of the previous patch series, but rebased forward
earlier on this month.  Review comments would be nice to have, or
alternatively acks.

Lastly, is there an active PCMCIA maintainer who should take these?

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [RFC PATCH 00/10] PCMCIA soc_common re-factorization

2009-10-27 Thread Russell King - ARM Linux
On Tue, Oct 27, 2009 at 11:18:49PM +, Russell King - ARM Linux wrote:
 This is a re-post of the previous patch series, but rebased forward
 earlier on this month.  Review comments would be nice to have, or
 alternatively acks.
 
 Lastly, is there an active PCMCIA maintainer who should take these?

Oh, and sorry for the stupid dates; next time I'll remember to delete
the Date: header from the git format-patch output.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [RFC PATCH 05/10] PCMCIA: sa1111: wrap soc_pcmcia_socket to contain sa1111 specific data

2009-10-06 Thread Russell King - ARM Linux
On Mon, Oct 05, 2009 at 11:21:13AM +0200, Kristoffer Ericson wrote:
 My bad, it sent an updated version to linux-pcmcia while
 forgetting to CC arm. Also totally forgot that I still had it
 pending inside linux-arm patch tracker.

This series has been rebased in my git tree - branch pcmcia.  I'll
avoid re-posting the patches since it appears to cause dwmw2's mail
server quite a bit of grief (it took well over an hour to deal with
the 10 patches last time I posted.)

Ignore the top commit of:

http://ftp.arm.linux.org.uk/git/gitweb.cgi?p=linux-2.6-arm.git;a=shortlog;h=refs/heads/pcmcia

As usual, it's also available in overall patch and mbox forms:

http://ftp.arm.linux.org.uk/pub/linux/arm/kernel/git-cur/

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH] pcmcia: pxa2xx-sharpsl: check if we do have Scoop config

2009-04-20 Thread Russell King - ARM Linux
On Mon, Apr 20, 2009 at 08:01:19PM +0400, Dmitry Eremin-Solenikov wrote:
 Check if we really have Scoop config, otherwice we can get a nice Oops
 during probe.

Looks to me like -rc material.  Please submit to the patch tracker with
your (missing) sign-off.  Thanks.

 ---
  drivers/pcmcia/pxa2xx_sharpsl.c |3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
 index 1cd02f5..bc43f78 100644
 --- a/drivers/pcmcia/pxa2xx_sharpsl.c
 +++ b/drivers/pcmcia/pxa2xx_sharpsl.c
 @@ -255,6 +255,9 @@ static int __init sharpsl_pcmcia_init(void)
  {
   int ret;
  
 + if (!platform_scoop_config)
 + return -ENODEV;
 +
   sharpsl_pcmcia_ops.nr = platform_scoop_config-num_devs;
   sharpsl_pcmcia_device = platform_device_alloc(pxa2xx-pcmcia, -1);
  
 -- 
 1.6.2.1
 
 
 ---
 List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
 FAQ:http://www.arm.linux.org.uk/mailinglists/faq.php
 Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 0/5] PXA LX platform support

2009-04-18 Thread Russell King - ARM Linux
The following series adds basic support for the LX platform.  This
platform is a portable small netbook style machine, with support
for touch screen LCD, sound, MMC/SD, one serial port, CF, PCMCIA
and MMC.

The entire series is posted to the linux-arm-kernel list; individual
patches are only copied to relevent people/lists.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia