SUPERH platform development
 help / color / mirror / Atom feed
* [PATCH 2/5] ARM: mach-shmobile: bonito: make sure static function
From: Kuninori Morimoto @ 2011-10-20  3:01 UTC (permalink / raw)
  To: linux-sh

fpga_xxx() were static functions

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 arch/arm/mach-shmobile/board-bonito.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-bonito.c b/arch/arm/mach-shmobile/board-bonito.c
index a00de29..3a91e9c 100644
--- a/arch/arm/mach-shmobile/board-bonito.c
+++ b/arch/arm/mach-shmobile/board-bonito.c
@@ -83,12 +83,12 @@
 #define LCDCR		0x10B4
 #define A1MDSR		0x10E0
 #define BVERR		0x1100
-u16 fpga_read(u32 offset)
+static u16 fpga_read(u32 offset)
 {
 	return __raw_readw(0xf0003000 + offset);
 }
 
-void fpga_write(u32 offset, u16 val, u16 mask)
+static void fpga_write(u32 offset, u16 val, u16 mask)
 {
 	u16 tmp;
 
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH 3/5] ARM: mach-shmobile: bonito: fixup fpga_write()
From: Kuninori Morimoto @ 2011-10-20  3:02 UTC (permalink / raw)
  To: linux-sh

mask of fpga_write() was a puzzling parameter.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 arch/arm/mach-shmobile/board-bonito.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-bonito.c b/arch/arm/mach-shmobile/board-bonito.c
index 3a91e9c..64eea4b 100644
--- a/arch/arm/mach-shmobile/board-bonito.c
+++ b/arch/arm/mach-shmobile/board-bonito.c
@@ -88,13 +88,9 @@ static u16 fpga_read(u32 offset)
 	return __raw_readw(0xf0003000 + offset);
 }
 
-static void fpga_write(u32 offset, u16 val, u16 mask)
+static void fpga_write(u32 offset, u16 val)
 {
-	u16 tmp;
-
-	tmp = fpga_read(offset);
-	tmp = (tmp & ~mask) | (val & mask);
-	__raw_writew(tmp, 0xf0003000 + offset);
+	__raw_writew(val, 0xf0003000 + offset);
 }
 
 /*
@@ -372,7 +368,7 @@ static void __init bonito_init(void)
 			gpio_direction_output(GPIO_PORT61, 1);
 
 			/* backlight on */
-			fpga_write(LCDCR, 1, 1);
+			fpga_write(LCDCR, 1);
 
 			/*  drivability Max */
 			__raw_writew(0x00FF , VCCQ1LCDCR);
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH 4/5] ARM: mach-shmobile: add FPGA irq demux
From: Kuninori Morimoto @ 2011-10-20  3:02 UTC (permalink / raw)
  To: linux-sh

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 arch/arm/mach-shmobile/board-bonito.c |   81 ++++++++++++++++++++++++++++++++-
 1 files changed, 80 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-bonito.c b/arch/arm/mach-shmobile/board-bonito.c
index 64eea4b..08c3795 100644
--- a/arch/arm/mach-shmobile/board-bonito.c
+++ b/arch/arm/mach-shmobile/board-bonito.c
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/smsc911x.h>
 #include <mach/common.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -75,14 +76,26 @@
 /*
  * FPGA
  */
+
+#define IRQSR0		0x0020
+#define IRQSR1		0x0022
+#define IRQMR0		0x0030
+#define IRQMR1		0x0032
 #define BUSSWMR1	0x0070
 #define BUSSWMR2	0x0072
 #define BUSSWMR3	0x0074
 #define BUSSWMR4	0x0076
-
 #define LCDCR		0x10B4
+#define DEVRSTCR1	0x10D0
+#define DEVRSTCR2	0x10D2
 #define A1MDSR		0x10E0
 #define BVERR		0x1100
+
+/* FPGA IRQ */
+#define FPGA_IRQ_BASE		(512)
+#define FPGA_IRQ0		(FPGA_IRQ_BASE)
+#define FPGA_IRQ1		(FPGA_IRQ_BASE + 16)
+
 static u16 fpga_read(u32 offset)
 {
 	return __raw_readw(0xf0003000 + offset);
@@ -93,6 +106,71 @@ static void fpga_write(u32 offset, u16 val)
 	__raw_writew(val, 0xf0003000 + offset);
 }
 
+static void fpga_irq_disable(struct irq_data *data)
+{
+	unsigned int irq = data->irq;
+	u32 addr = (irq < 1016) ? IRQMR0 : IRQMR1;
+	int shift = irq % 16;
+
+	fpga_write(addr, fpga_read(addr) | (1 << shift));
+}
+
+static void fpga_irq_enable(struct irq_data *data)
+{
+	unsigned int irq = data->irq;
+	u32 addr = (irq < 1016) ? IRQMR0 : IRQMR1;
+	int shift = irq % 16;
+
+	fpga_write(addr, fpga_read(addr) & ~(1 << shift));
+}
+
+static struct irq_chip fpga_irq_chip __read_mostly = {
+	.name		= "bonito FPGA",
+	.irq_mask	= fpga_irq_disable,
+	.irq_unmask	= fpga_irq_enable,
+};
+
+static void fpga_irq_demux(unsigned int irq, struct irq_desc *desc)
+{
+	u32 val =  fpga_read(IRQSR1) << 16 |
+		   fpga_read(IRQSR0);
+	u32 mask = fpga_read(IRQMR1) << 16 |
+		   fpga_read(IRQMR0);
+
+	int i;
+
+	val &= ~mask;
+
+	for (i = 0; i < 32; i++) {
+		if (!(val & (1 << i)))
+			continue;
+
+		generic_handle_irq(FPGA_IRQ_BASE + i);
+	}
+}
+
+static void fpga_init(void)
+{
+	int i;
+
+	fpga_write(IRQMR0, 0xffff); /* mask all */
+	fpga_write(IRQMR1, 0xffff); /* mask all */
+
+	/* Device reset */
+	fpga_write(DEVRSTCR1,
+		   (1 << 2));	/* Eth */
+
+	/* FPGA irq require special handling */
+	for (i = FPGA_IRQ_BASE; i < FPGA_IRQ_BASE + 32; i++) {
+		irq_set_chip_and_handler_name(i, &fpga_irq_chip,
+					      handle_level_irq, "level");
+		set_irq_flags(i, IRQF_VALID); /* yuck */
+	}
+
+	irq_set_chained_handler(evt2irq(0x0340), fpga_irq_demux);
+	irq_set_irq_type(evt2irq(0x0340), IRQ_TYPE_LEVEL_LOW);
+}
+
 /*
 * PMIC settings
 *
@@ -274,6 +352,7 @@ static void __init bonito_init(void)
 	u16 val;
 
 	r8a7740_pinmux_init();
+	fpga_init();
 
 	pmic_settings = pmic_do_2A;
 
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH 5/5] ARM: mach-shmobile: add SMSC9221 support
From: Kuninori Morimoto @ 2011-10-20  3:02 UTC (permalink / raw)
  To: linux-sh

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 arch/arm/mach-shmobile/board-bonito.c |   34 +++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-bonito.c b/arch/arm/mach-shmobile/board-bonito.c
index 08c3795..e93c61d 100644
--- a/arch/arm/mach-shmobile/board-bonito.c
+++ b/arch/arm/mach-shmobile/board-bonito.c
@@ -96,6 +96,8 @@
 #define FPGA_IRQ0		(FPGA_IRQ_BASE)
 #define FPGA_IRQ1		(FPGA_IRQ_BASE + 16)
 
+#define FPGA_ETH_IRQ		(FPGA_IRQ0 + 15)
+
 static u16 fpga_read(u32 offset)
 {
 	return __raw_readw(0xf0003000 + offset);
@@ -279,6 +281,37 @@ static struct platform_device lcdc0_device = {
 };
 
 /*
+ * SMSC 9221
+ */
+static struct resource smsc_resources[] = {
+	[0] = {
+		.start		= 0x18010000,
+		.end		= 0x18011000 - 1,
+		.flags		= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start		= FPGA_ETH_IRQ,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+
+static struct smsc911x_platform_config smsc_platdata = {
+	.flags		= SMSC911X_USE_16BIT,
+	.phy_interface	= PHY_INTERFACE_MODE_MII,
+	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
+	.irq_type	= SMSC911X_IRQ_TYPE_PUSH_PULL,
+};
+
+static struct platform_device smsc_device = {
+	.name		= "smsc911x",
+	.dev  = {
+		.platform_data = &smsc_platdata,
+	},
+	.resource	= smsc_resources,
+	.num_resources	= ARRAY_SIZE(smsc_resources),
+};
+
+/*
  * core board devices
  */
 static struct platform_device *bonito_core_devices[] __initdata = {
@@ -289,6 +322,7 @@ static struct platform_device *bonito_core_devices[] __initdata = {
  */
 static struct platform_device *bonito_base_devices[] __initdata = {
 	&lcdc0_device,
+	&smsc_device,
 };
 
 /*
-- 
1.7.4.1


^ permalink raw reply related

* Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Simon Horman @ 2011-10-20  4:24 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Will, Hi All,

it appears that "ARM: proc: add definition of cpu_reset for
 ARMv6 and ARMv7 cores" (f4daf06fc23b99df5ca5b3e892428b91e148cc52),
which was introduced for 3.1-rc1, causes a regression and that
kexec no longer works on ARM. The board that I am testing
on is a Renesas Mackerel which has an SH7372 (ARMv7) processor.

I have included the patch below for reference.


commit f4daf06fc23b99df5ca5b3e892428b91e148cc52
Author: Will Deacon <will.deacon@arm.com>
Date:   Mon Jun 6 12:27:34 2011 +0100

    ARM: proc: add definition of cpu_reset for ARMv6 and ARMv7 cores
    
    This patch adds simple definitions of cpu_reset for ARMv6 and ARMv7
    cores, which disable the MMU via the SCTLR.
    
    Signed-off-by: Will Deacon <will.deacon@arm.com>

diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 5ec1543..aedf3c5 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -56,6 +56,11 @@ ENTRY(cpu_v6_proc_fin)
  */
 	.align	5
 ENTRY(cpu_v6_reset)
+	mrc	p15, 0, r1, c1, c0, 0		@ ctrl register
+	bic	r1, r1, #0x1			@ ...............m
+	mcr	p15, 0, r1, c1, c0, 0		@ disable MMU
+	mov	r1, #0
+	mcr	p15, 0, r1, c7, c5, 4		@ ISB
 	mov	pc, r0
 
 /*
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 5932854..54d1a63 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -58,9 +58,16 @@ ENDPROC(cpu_v7_proc_fin)
  *	to what would be the reset vector.
  *
  *	- loc   - location to jump to for soft reset
+ *
+ *	This code must be executed using a flat identity mapping with
+ *      caches disabled.
  */
 	.align	5
 ENTRY(cpu_v7_reset)
+	mrc	p15, 0, r1, c1, c0, 0		@ ctrl register
+	bic	r1, r1, #0x1			@ ...............m
+	mcr	p15, 0, r1, c1, c0, 0		@ disable MMU
+	isb
 	mov	pc, r0
 ENDPROC(cpu_v7_reset)
 

^ permalink raw reply related

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Will Deacon @ 2011-10-20  7:01 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111020042444.GA20260@verge.net.au>

On Thu, Oct 20, 2011 at 05:24:45AM +0100, Simon Horman wrote:
> Hi Will, Hi All,

Hi Simon,

> it appears that "ARM: proc: add definition of cpu_reset for
>  ARMv6 and ARMv7 cores" (f4daf06fc23b99df5ca5b3e892428b91e148cc52),
> which was introduced for 3.1-rc1, causes a regression and that
> kexec no longer works on ARM. The board that I am testing
> on is a Renesas Mackerel which has an SH7372 (ARMv7) processor.

Wow, I'm surprised the old code worked at all on an ARMv7 CPU! It's certainly
highly unlikely to work by the letter of the architecture, so I guess the
planets aligned in just the right way for your particular implementation.

Please can you try my kexec/mmu-off patches? They should add the bits and
pieces you need for kexec to work reliably on a UP system. I plan to finish
these off next week in Prague so hopefully they'll hit mainline in the near
future.

https://github.com/wdeacon/linux-wd/commits/kexec/mmu-off

Will

^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Simon Horman @ 2011-10-20  8:08 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111020070105.GA28548@mudshark.cambridge.arm.com>

On Thu, Oct 20, 2011 at 08:01:06AM +0100, Will Deacon wrote:
> On Thu, Oct 20, 2011 at 05:24:45AM +0100, Simon Horman wrote:
> > Hi Will, Hi All,
> 
> Hi Simon,

Hi Will,

> > it appears that "ARM: proc: add definition of cpu_reset for
> >  ARMv6 and ARMv7 cores" (f4daf06fc23b99df5ca5b3e892428b91e148cc52),
> > which was introduced for 3.1-rc1, causes a regression and that
> > kexec no longer works on ARM. The board that I am testing
> > on is a Renesas Mackerel which has an SH7372 (ARMv7) processor.
> 
> Wow, I'm surprised the old code worked at all on an ARMv7 CPU! It's certainly
> highly unlikely to work by the letter of the architecture, so I guess the
> planets aligned in just the right way for your particular implementation.
> 
> Please can you try my kexec/mmu-off patches? They should add the bits and
> pieces you need for kexec to work reliably on a UP system. I plan to finish
> these off next week in Prague so hopefully they'll hit mainline in the near
> future.
> 
> https://github.com/wdeacon/linux-wd/commits/kexec/mmu-off

Thanks, I will try your patches and let you know how I go.

You mention UP in particular, which I will test.
Do you have any thoughts on SMP?


^ permalink raw reply

* Re: Ecovec in current sh-latest
From: Kuninori Morimoto @ 2011-10-21  1:53 UTC (permalink / raw)
  To: linux-sh
In-Reply-To: <Pine.LNX.4.64.1109020025350.15166@axis700.grange>


Hi Magnus, Paul

> > > To get ecovec to run with today's sh-latest (pretty much the same with 
> > > Linux' tree) the following patches have to be reverted:
> > > 
> > > commit 794d78fea51504bad3880d14f354a9847f318f25
> > > Author: Magnus Damm <damm@opensource.se>
> > > Date:   Tue Jun 21 07:55:12 2011 +0000
> > > 
> > >     drivers: sh: late disabling of clocks V2
> > > 
> > Do we know which driver that's the problem for the ecovec case?
> 
> I see at least two drivers misbehaving: ethernet is failing to perform 
> dhcp for nfs root-mount, and LCD gets an image at boot and then slowly 
> fade out.

My renesas_usbhs driver breaks too in SH7724 ecovec board.
So I debuged it.

when my driver call pm_runtime_get_sync(),
then, arch/sh/kernel/cpu/hwblk.c :: hwblk_enable() are called,
and it enabled my driver's MSTP bit.

But clk_late_init() disabled it.

Does hwblk/pm_runtime (?) didn't care clk->usecount ?

Best regards
---
Kuninori Morimoto

^ permalink raw reply

* Re: Ecovec in current sh-latest
From: Kuninori Morimoto @ 2011-10-21  1:57 UTC (permalink / raw)
  To: linux-sh
In-Reply-To: <Pine.LNX.4.64.1109020025350.15166@axis700.grange>


Hi Magnus, Paul

> > > To get ecovec to run with today's sh-latest (pretty much the same with 
> > > Linux' tree) the following patches have to be reverted:
> > > 
> > > commit 794d78fea51504bad3880d14f354a9847f318f25
> > > Author: Magnus Damm <damm@opensource.se>
> > > Date:   Tue Jun 21 07:55:12 2011 +0000
> > > 
> > >     drivers: sh: late disabling of clocks V2
> > > 
> > Do we know which driver that's the problem for the ecovec case?
> 
> I see at least two drivers misbehaving: ethernet is failing to perform 
> dhcp for nfs root-mount, and LCD gets an image at boot and then slowly 
> fade out.

My renesas_usbhs driver breaks too in SH7724 ecovec board.
So I debuged it.

when my driver call pm_runtime_get_sync(),
then, arch/sh/kernel/cpu/hwblk.c :: hwblk_enable() are called,
and it enabled my driver's MSTP bit.

But clk_late_init() disabled it.

Does hwblk/pm_runtime (?) didn't care clk->usecount ?

Best regards
---
Kuninori Morimoto

^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Simon Horman @ 2011-10-21  8:34 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111020080823.GA2716@verge.net.au>

On Thu, Oct 20, 2011 at 05:08:24PM +0900, Simon Horman wrote:
> On Thu, Oct 20, 2011 at 08:01:06AM +0100, Will Deacon wrote:
> > On Thu, Oct 20, 2011 at 05:24:45AM +0100, Simon Horman wrote:
> > > Hi Will, Hi All,
> > 
> > Hi Simon,
> 
> Hi Will,
> 
> > > it appears that "ARM: proc: add definition of cpu_reset for
> > >  ARMv6 and ARMv7 cores" (f4daf06fc23b99df5ca5b3e892428b91e148cc52),
> > > which was introduced for 3.1-rc1, causes a regression and that
> > > kexec no longer works on ARM. The board that I am testing
> > > on is a Renesas Mackerel which has an SH7372 (ARMv7) processor.
> > 
> > Wow, I'm surprised the old code worked at all on an ARMv7 CPU! It's certainly
> > highly unlikely to work by the letter of the architecture, so I guess the
> > planets aligned in just the right way for your particular implementation.
> > 
> > Please can you try my kexec/mmu-off patches? They should add the bits and
> > pieces you need for kexec to work reliably on a UP system. I plan to finish
> > these off next week in Prague so hopefully they'll hit mainline in the near
> > future.
> > 
> > https://github.com/wdeacon/linux-wd/commits/kexec/mmu-off
> 
> Thanks, I will try your patches and let you know how I go.

I have tested the kexec/mmu-off branch of your tree on the UP board
I mentioned above and kexec works :)

> You mention UP in particular, which I will test.
> Do you have any thoughts on SMP?

^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Will Deacon @ 2011-10-21  8:46 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111021083426.GA16088@verge.net.au>

On Fri, Oct 21, 2011 at 09:34:26AM +0100, Simon Horman wrote:
> I have tested the kexec/mmu-off branch of your tree on the UP board
> I mentioned above and kexec works :)

Hurrah! Thanks for giving it a spin.

> > You mention UP in particular, which I will test.
> > Do you have any thoughts on SMP?

Yes. Currently [i.e. on my branch above] you can do SMP kexec using the CPU
hotplug platform_cpu_kill callback to take down the CPUs in some
platform-specific manner.

The more difficult case is when you want to offline the secondary CPUs into
a pen and then boot them in the new kernel. I did get some of this working,
but there are outstanding issues with whether the pen should be at a fixed
location or not. If not, then we need a way to tell the new kernel where it
is, which may involve updating the DT blob...

Will

^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Simon Horman @ 2011-10-21  8:59 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111021084641.GA30168@mudshark.cambridge.arm.com>

On Fri, Oct 21, 2011 at 09:46:41AM +0100, Will Deacon wrote:
> On Fri, Oct 21, 2011 at 09:34:26AM +0100, Simon Horman wrote:
> > I have tested the kexec/mmu-off branch of your tree on the UP board
> > I mentioned above and kexec works :)
> 
> Hurrah! Thanks for giving it a spin.
> 
> > > You mention UP in particular, which I will test.
> > > Do you have any thoughts on SMP?
> 
> Yes. Currently [i.e. on my branch above] you can do SMP kexec using the CPU
> hotplug platform_cpu_kill callback to take down the CPUs in some
> platform-specific manner.

Thanks, I will take a look into it.

> The more difficult case is when you want to offline the secondary CPUs into
> a pen and then boot them in the new kernel. I did get some of this working,
> but there are outstanding issues with whether the pen should be at a fixed
> location or not. If not, then we need a way to tell the new kernel where it
> is, which may involve updating the DT blob...

Is the implication that the (working) callback method does not
give the second kernel any secondary CPUs?

^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Will Deacon @ 2011-10-21  9:15 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111021085958.GC21850@verge.net.au>

On Fri, Oct 21, 2011 at 09:59:58AM +0100, Simon Horman wrote:
> On Fri, Oct 21, 2011 at 09:46:41AM +0100, Will Deacon wrote:
> > The more difficult case is when you want to offline the secondary CPUs into
> > a pen and then boot them in the new kernel. I did get some of this working,
> > but there are outstanding issues with whether the pen should be at a fixed
> > location or not. If not, then we need a way to tell the new kernel where it
> > is, which may involve updating the DT blob...
> 
> Is the implication that the (working) callback method does not
> give the second kernel any secondary CPUs?

What the callback does it up to you. You just need to make sure that you can
cope with the kernel disappearing later on, so you'll probably need some
hardware mechanism for offlining a CPU (for example, placing it in SRAM
or cutting the power).

Will

^ permalink raw reply

* [RFC][PATCH 0/2] PM: Generic PM domains and device PM QoS (v2)
From: Rafael J. Wysocki @ 2011-10-21 23:09 UTC (permalink / raw)
  To: Linux PM list; +Cc: LKML, Linux-sh list, Jean Pihet, Magnus Damm

Hi,

This patchset is a refresh of patches introducing simple PM QoS governor
functions for PM domains.  The patches still haven't been tested properly,
although they should build.  The purpose of them is mainly to illustrate
how PM QoS may be used with PM domains to control device runtime PM.

Thanks,
Rafael


^ permalink raw reply

* [RFC][PATCH 1/2] PM / Domains: Add device stop governor function (v2)
From: Rafael J. Wysocki @ 2011-10-21 23:10 UTC (permalink / raw)
  To: Linux PM list; +Cc: LKML, Linux-sh list, Jean Pihet, Magnus Damm
In-Reply-To: <201110220109.52991.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

Add a function deciding whether or not devices should be
stopped in pm_genpd_runtime_suspend() depending on their
PM QoS values.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 arch/arm/mach-shmobile/pm-sh7372.c   |    4 ++-
 drivers/base/power/Makefile          |    2 -
 drivers/base/power/domain.c          |   29 ++++++++++++++++++----
 drivers/base/power/domain_governor.c |   40 +++++++++++++++++++++++++++++++
 include/linux/pm_domain.h            |   45 +++++++++++++++++++++++++++++++----
 5 files changed, 109 insertions(+), 11 deletions(-)

Index: linux/include/linux/pm_domain.h
=================================--- linux.orig/include/linux/pm_domain.h
+++ linux/include/linux/pm_domain.h
@@ -21,6 +21,7 @@ enum gpd_status {
 
 struct dev_power_governor {
 	bool (*power_down_ok)(struct dev_pm_domain *domain);
+	bool (*stop_ok)(struct device *dev);
 };
 
 struct generic_pm_domain {
@@ -62,8 +63,13 @@ struct gpd_link {
 	struct list_head slave_node;
 };
 
+struct gpd_gov_dev_data {
+	s64 break_even_ns;
+};
+
 struct generic_pm_domain_data {
 	struct pm_domain_data base;
+	struct gpd_gov_dev_data *gov_data;
 	bool need_restore;
 };
 
@@ -73,8 +79,19 @@ static inline struct generic_pm_domain_d
 }
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS
-extern int pm_genpd_add_device(struct generic_pm_domain *genpd,
-			       struct device *dev);
+extern struct dev_power_governor simple_qos_governor;
+
+extern struct generic_pm_domain *dev_to_genpd(struct device *dev);
+extern int __pm_genpd_add_device(struct generic_pm_domain *genpd,
+				 struct device *dev,
+				 struct gpd_gov_dev_data *gov_data);
+
+static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
+				      struct device *dev)
+{
+	return __pm_genpd_add_device(genpd, dev, NULL);
+}
+
 extern int pm_genpd_remove_device(struct generic_pm_domain *genpd,
 				  struct device *dev);
 extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
@@ -83,8 +100,23 @@ extern int pm_genpd_remove_subdomain(str
 				     struct generic_pm_domain *target);
 extern void pm_genpd_init(struct generic_pm_domain *genpd,
 			  struct dev_power_governor *gov, bool is_off);
+
 extern int pm_genpd_poweron(struct generic_pm_domain *genpd);
+
+extern bool default_stop_ok(struct device *dev);
+
 #else
+
+static inline struct generic_pm_domain *dev_to_genpd(struct device *dev)
+{
+	return ERR_PTR(-ENOSYS);
+}
+static inline int __pm_genpd_add_device(struct generic_pm_domain *genpd,
+					struct device *dev,
+					struct gpd_gov_dev_data *gov_data)
+{
+	return -ENOSYS;
+}
 static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
 				      struct device *dev)
 {
@@ -105,12 +137,17 @@ static inline int pm_genpd_remove_subdom
 {
 	return -ENOSYS;
 }
-static inline void pm_genpd_init(struct generic_pm_domain *genpd,
-				 struct dev_power_governor *gov, bool is_off) {}
+static inline void pm_genpd_init(struct generic_pm_domain *genpd, bool is_off)
+{
+}
 static inline int pm_genpd_poweron(struct generic_pm_domain *genpd)
 {
 	return -ENOSYS;
 }
+static inline bool default_stop_ok(struct device *dev)
+{
+	return false;
+}
 #endif
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS_RUNTIME
Index: linux/drivers/base/power/domain.c
=================================--- linux.orig/drivers/base/power/domain.c
+++ linux/drivers/base/power/domain.c
@@ -21,7 +21,7 @@ static DEFINE_MUTEX(gpd_list_lock);
 
 #ifdef CONFIG_PM
 
-static struct generic_pm_domain *dev_to_genpd(struct device *dev)
+struct generic_pm_domain *dev_to_genpd(struct device *dev)
 {
 	if (IS_ERR_OR_NULL(dev->pm_domain))
 		return ERR_PTR(-EINVAL);
@@ -403,6 +403,22 @@ static void genpd_power_off_work_fn(stru
 }
 
 /**
+ * genpd_stop_dev - Stop a given device if that's beneficial.
+ * @genpd: PM domain the device belongs to.
+ * @dev: Device to stop.
+ */
+static int genpd_stop_dev(struct generic_pm_domain *genpd, struct device *dev)
+{
+	bool (*stop_ok)(struct device *dev);
+
+	stop_ok = genpd->gov ? genpd->gov->stop_ok : NULL;
+	if (stop_ok && !stop_ok(dev))
+		return -EBUSY;
+
+	return genpd->stop_device(dev);
+}
+
+/**
  * pm_genpd_runtime_suspend - Suspend a device belonging to I/O PM domain.
  * @dev: Device to suspend.
  *
@@ -423,7 +439,7 @@ static int pm_genpd_runtime_suspend(stru
 	might_sleep_if(!genpd->dev_irq_safe);
 
 	if (genpd->stop_device) {
-		int ret = genpd->stop_device(dev);
+		int ret = genpd_stop_dev(genpd, dev);
 		if (ret)
 			return ret;
 	}
@@ -495,7 +511,7 @@ static int pm_genpd_runtime_resume(struc
 		mutex_lock(&genpd->lock);
 	}
 	finish_wait(&genpd->status_wait_queue, &wait);
-	__pm_genpd_restore_device(dev->power.subsys_data->domain_data, genpd);
+	__pm_genpd_restore_device(dev_to_psd(dev)->domain_data, genpd);
 	genpd->resume_count--;
 	genpd_set_active(genpd);
 	wake_up_all(&genpd->status_wait_queue);
@@ -1076,11 +1092,13 @@ static void pm_genpd_complete(struct dev
 #endif /* CONFIG_PM_SLEEP */
 
 /**
- * pm_genpd_add_device - Add a device to an I/O PM domain.
+ * __pm_genpd_add_device - Add a device to an I/O PM domain.
  * @genpd: PM domain to add the device to.
  * @dev: Device to be added.
+ * @gov_data: Set of PM QoS parameters to attach to the device.
  */
-int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
+int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
+			  struct gpd_gov_dev_data *gov_data)
 {
 	struct generic_pm_domain_data *gpd_data;
 	struct pm_domain_data *pdd;
@@ -1123,6 +1141,7 @@ int pm_genpd_add_device(struct generic_p
 	gpd_data->base.dev = dev;
 	gpd_data->need_restore = false;
 	list_add_tail(&gpd_data->base.list_node, &genpd->dev_list);
+	gpd_data->gov_data = gov_data;
 
  out:
 	genpd_release_lock(genpd);
Index: linux/drivers/base/power/Makefile
=================================--- linux.orig/drivers/base/power/Makefile
+++ linux/drivers/base/power/Makefile
@@ -3,7 +3,7 @@ obj-$(CONFIG_PM_SLEEP)	+= main.o wakeup.
 obj-$(CONFIG_PM_RUNTIME)	+= runtime.o
 obj-$(CONFIG_PM_TRACE_RTC)	+= trace.o
 obj-$(CONFIG_PM_OPP)	+= opp.o
-obj-$(CONFIG_PM_GENERIC_DOMAINS)	+=  domain.o
+obj-$(CONFIG_PM_GENERIC_DOMAINS)	+=  domain.o domain_governor.o
 obj-$(CONFIG_HAVE_CLK)	+= clock_ops.o
 
 ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG
Index: linux/drivers/base/power/domain_governor.c
=================================--- /dev/null
+++ linux/drivers/base/power/domain_governor.c
@@ -0,0 +1,40 @@
+/*
+ * drivers/base/power/domain_governor.c - Governors for device PM domains.
+ *
+ * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp.
+ *
+ * This file is released under the GPLv2.
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/pm_domain.h>
+#include <linux/pm_qos.h>
+
+bool default_stop_ok(struct device *dev)
+{
+	struct gpd_gov_dev_data *gov_data;
+	s64 constraint_ns;
+	s32 constraint;
+
+	dev_dbg(dev, "%s()\n", __func__);
+
+	gov_data = to_gpd_data(dev_to_psd(dev)->domain_data)->gov_data;
+	if (!gov_data)
+		return true;
+
+	constraint = dev_pm_qos_read_value(dev);
+	if (constraint < 0)
+		return false;
+	else if (constraint = 0) /* 0 means "don't care" */
+		return true;
+
+	constraint_ns = constraint;
+	constraint_ns *= NSEC_PER_USEC;
+
+	return constraint_ns > gov_data->break_even_ns;
+}
+
+struct dev_power_governor simple_qos_governor = {
+	.stop_ok = default_stop_ok,
+};
Index: linux/arch/arm/mach-shmobile/pm-sh7372.c
=================================--- linux.orig/arch/arm/mach-shmobile/pm-sh7372.c
+++ linux/arch/arm/mach-shmobile/pm-sh7372.c
@@ -161,13 +161,15 @@ static bool sh7372_power_down_forbidden(
 
 struct dev_power_governor sh7372_always_on_gov = {
 	.power_down_ok = sh7372_power_down_forbidden,
+	.stop_ok = default_stop_ok,
 };
 
 void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd)
 {
 	struct generic_pm_domain *genpd = &sh7372_pd->genpd;
+	struct dev_power_governor *gov = sh7372_pd->gov;
 
-	pm_genpd_init(genpd, sh7372_pd->gov, false);
+	pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
 	genpd->stop_device = pm_clk_suspend;
 	genpd->start_device = pm_clk_resume;
 	genpd->dev_irq_safe = true;


^ permalink raw reply

* [RFC][PATCH 2/2] PM / Domains: Add default power off governor function (v2)
From: Rafael J. Wysocki @ 2011-10-21 23:11 UTC (permalink / raw)
  To: Linux PM list; +Cc: LKML, Linux-sh list, Jean Pihet, Magnus Damm
In-Reply-To: <201110220109.52991.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

Add a function deciding whether or not a given PM domain should
be powered off on the basis of that domain's devices' PM QoS
constraints.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/power/domain_governor.c |   96 +++++++++++++++++++++++++++++++++++
 include/linux/pm_domain.h            |    7 ++
 2 files changed, 103 insertions(+)

Index: linux/include/linux/pm_domain.h
=================================--- linux.orig/include/linux/pm_domain.h
+++ linux/include/linux/pm_domain.h
@@ -49,6 +49,10 @@ struct generic_pm_domain {
 	int (*start_device)(struct device *dev);
 	int (*stop_device)(struct device *dev);
 	bool (*active_wakeup)(struct device *dev);
+	ktime_t power_off_latency;
+	ktime_t power_on_latency;
+	s64 break_even_ns;
+	s64 min_delta_ns;
 };
 
 static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
@@ -64,6 +68,9 @@ struct gpd_link {
 };
 
 struct gpd_gov_dev_data {
+	ktime_t start_latency;
+	ktime_t suspend_latency;
+	ktime_t resume_latency;
 	s64 break_even_ns;
 };
 
Index: linux/drivers/base/power/domain_governor.c
=================================--- linux.orig/drivers/base/power/domain_governor.c
+++ linux/drivers/base/power/domain_governor.c
@@ -35,6 +35,102 @@ bool default_stop_ok(struct device *dev)
 	return constraint_ns > gov_data->break_even_ns;
 }
 
+/* This routine must be executed under the PM domain's lock. */
+static bool default_power_down_ok(struct dev_pm_domain *pd)
+{
+	struct generic_pm_domain *genpd = pd_to_genpd(pd);
+	struct gpd_link *link;
+	struct pm_domain_data *pdd;
+	ktime_t off_time, on_time;
+	s64 delta_ns, min_delta_ns;
+
+	on_time = genpd->power_on_latency;
+	/* Check if slave domains can be off for enough time. */
+	delta_ns = ktime_to_ns(ktime_add(genpd->power_off_latency, on_time));
+	min_delta_ns = 0;
+	/* All slave domains have been powered off at this point. */
+	list_for_each_entry(link, &genpd->master_links, master_node) {
+		if (delta_ns > link->slave->min_delta_ns)
+			return false;
+
+		delta_ns = link->slave->min_delta_ns - delta_ns;
+		if (delta_ns < min_delta_ns)
+			min_delta_ns = delta_ns;
+	}
+
+	genpd->min_delta_ns = min_delta_ns;
+
+	/* Compute the total time needed to power off the domain. */
+	off_time = ktime_set(0, 0);
+	/* All devices have been stopped at this point. */
+	list_for_each_entry(pdd, &genpd->dev_list, list_node) {
+		struct gpd_gov_dev_data *gov_data;
+
+		if (!pdd->dev->driver)
+			continue;
+
+		gov_data = to_gpd_data(pdd)->gov_data;
+		if (!gov_data)
+			continue;
+
+		off_time = ktime_add(off_time, gov_data->suspend_latency);
+	}
+	off_time = ktime_add(off_time, genpd->power_off_latency);
+
+	/*
+	 * For each device in the domain compute the difference between the
+	 * QoS value and the total time required to bring the device back
+	 * assuming that the domain will be powered off and compute the minimum
+	 * of those.
+	 */
+	min_delta_ns = 0;
+	on_time = ktime_add(on_time, off_time);
+	list_for_each_entry(pdd, &genpd->dev_list, list_node) {
+		struct gpd_gov_dev_data *gov_data;
+		struct device *dev = pdd->dev;
+		ktime_t dev_up_time;
+		s32 constraint;
+		s64 constraint_ns;
+
+		if (!dev->driver)
+			continue;
+
+		gov_data = to_gpd_data(pdd)->gov_data;
+		if (gov_data) {
+			dev_up_time = ktime_add(on_time,
+						gov_data->resume_latency);
+			dev_up_time = ktime_add(dev_up_time,
+						gov_data->start_latency);
+		} else {
+			dev_up_time = on_time;
+		}
+
+		constraint = dev_pm_qos_read_value(dev);
+		if (constraint < 0)
+			return false;
+		else if (constraint = 0) /* 0 means "don't care" */
+			continue;
+
+		constraint_ns = constraint;
+		constraint_ns *= NSEC_PER_USEC;
+		delta_ns = constraint_ns - ktime_to_ns(dev_up_time);
+		if (min_delta_ns > delta_ns)
+			min_delta_ns = delta_ns;
+	}
+
+	/* Compare the computed delta with the break even value. */
+	if (min_delta_ns < genpd->break_even_ns)
+		return false;
+
+	/* Store the computed value for the masters to use. */
+	if (genpd->min_delta_ns > min_delta_ns)
+		genpd->min_delta_ns = min_delta_ns;
+
+	/* The domain can be powered off. */
+	return true;
+}
+
 struct dev_power_governor simple_qos_governor = {
 	.stop_ok = default_stop_ok,
+	.power_down_ok = default_power_down_ok,
 };


^ permalink raw reply

* Re: Possible regression in kexec on ARM ARMv6 and ARMv7 cores
From: Simon Horman @ 2011-10-22  2:20 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111021091524.GB30168@mudshark.cambridge.arm.com>

On Fri, Oct 21, 2011 at 10:15:24AM +0100, Will Deacon wrote:
> On Fri, Oct 21, 2011 at 09:59:58AM +0100, Simon Horman wrote:
> > On Fri, Oct 21, 2011 at 09:46:41AM +0100, Will Deacon wrote:
> > > The more difficult case is when you want to offline the secondary CPUs into
> > > a pen and then boot them in the new kernel. I did get some of this working,
> > > but there are outstanding issues with whether the pen should be at a fixed
> > > location or not. If not, then we need a way to tell the new kernel where it
> > > is, which may involve updating the DT blob...
> > 
> > Is the implication that the (working) callback method does not
> > give the second kernel any secondary CPUs?
> 
> What the callback does it up to you. You just need to make sure that you can
> cope with the kernel disappearing later on, so you'll probably need some
> hardware mechanism for offlining a CPU (for example, placing it in SRAM
> or cutting the power).

Thanks, it seems that I now have a bit of work to do implementing
a callback.

^ permalink raw reply

* [PATCH 16/49] SH: irq: Remove IRQF_DISABLED
From: Yong Zhang @ 2011-10-22  9:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, Paul Mundt, linux-sh
In-Reply-To: <1319277421-9203-1-git-send-email-yong.zhang0@gmail.com>

Since commit [e58aa3d2: genirq: Run irq handlers with interrupts disabled],
We run all interrupt handlers with interrupts disabled
and we even check and yell when an interrupt handler
returns with interrupts enabled (see commit [b738a50a:
genirq: Warn when handler enables interrupts]).

So now this flag is a NOOP and can be removed.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
---
 arch/sh/boards/board-secureedge5410.c |    3 +--
 arch/sh/boards/mach-cayman/irq.c      |    2 --
 arch/sh/boards/mach-hp6xx/hp6xx_apm.c |    2 +-
 arch/sh/drivers/dma/dma-g2.c          |    2 +-
 arch/sh/drivers/dma/dma-pvr2.c        |    1 -
 arch/sh/drivers/dma/dma-sh.c          |    4 ++--
 arch/sh/drivers/dma/dmabrg.c          |    6 +++---
 arch/sh/drivers/pci/pci-sh5.c         |    4 ++--
 arch/sh/drivers/pci/pci-sh7780.c      |    2 +-
 arch/sh/drivers/push-switch.c         |    2 +-
 arch/sh/kernel/cpu/sh4a/smp-shx3.c    |    2 +-
 11 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/arch/sh/boards/board-secureedge5410.c b/arch/sh/boards/board-secureedge5410.c
index f968f17..03820c3 100644
--- a/arch/sh/boards/board-secureedge5410.c
+++ b/arch/sh/boards/board-secureedge5410.c
@@ -41,8 +41,7 @@ static int __init eraseconfig_init(void)
 	printk("SnapGear: EraseConfig init\n");
 
 	/* Setup "EraseConfig" switch on external IRQ 0 */
-	if (request_irq(irq, eraseconfig_interrupt, IRQF_DISABLED,
-				"Erase Config", NULL))
+	if (request_irq(irq, eraseconfig_interrupt, 0, "Erase Config", NULL))
 		printk("SnapGear: failed to register IRQ%d for Reset witch\n",
 				irq);
 	else
diff --git a/arch/sh/boards/mach-cayman/irq.c b/arch/sh/boards/mach-cayman/irq.c
index 311bceb..724e8b7 100644
--- a/arch/sh/boards/mach-cayman/irq.c
+++ b/arch/sh/boards/mach-cayman/irq.c
@@ -46,13 +46,11 @@ static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id)
 static struct irqaction cayman_action_smsc = {
 	.name		= "Cayman SMSC Mux",
 	.handler	= cayman_interrupt_smsc,
-	.flags		= IRQF_DISABLED,
 };
 
 static struct irqaction cayman_action_pci2 = {
 	.name		= "Cayman PCI2 Mux",
 	.handler	= cayman_interrupt_pci2,
-	.flags		= IRQF_DISABLED,
 };
 
 static void enable_cayman_irq(struct irq_data *data)
diff --git a/arch/sh/boards/mach-hp6xx/hp6xx_apm.c b/arch/sh/boards/mach-hp6xx/hp6xx_apm.c
index b49535c..865d8d6 100644
--- a/arch/sh/boards/mach-hp6xx/hp6xx_apm.c
+++ b/arch/sh/boards/mach-hp6xx/hp6xx_apm.c
@@ -86,7 +86,7 @@ static int __init hp6x0_apm_init(void)
 	int ret;
 
 	ret = request_irq(HP680_BTN_IRQ, hp6x0_apm_interrupt,
-			  IRQF_DISABLED, MODNAME, NULL);
+			  0, MODNAME, NULL);
 	if (unlikely(ret < 0)) {
 		printk(KERN_ERR MODNAME ": IRQ %d request failed\n",
 		       HP680_BTN_IRQ);
diff --git a/arch/sh/drivers/dma/dma-g2.c b/arch/sh/drivers/dma/dma-g2.c
index af7bb58..be9ca7c 100644
--- a/arch/sh/drivers/dma/dma-g2.c
+++ b/arch/sh/drivers/dma/dma-g2.c
@@ -170,7 +170,7 @@ static int __init g2_dma_init(void)
 {
 	int ret;
 
-	ret = request_irq(HW_EVENT_G2_DMA, g2_dma_interrupt, IRQF_DISABLED,
+	ret = request_irq(HW_EVENT_G2_DMA, g2_dma_interrupt, 0,
 			  "g2 DMA handler", &g2_dma_info);
 	if (unlikely(ret))
 		return -EINVAL;
diff --git a/arch/sh/drivers/dma/dma-pvr2.c b/arch/sh/drivers/dma/dma-pvr2.c
index 3cee58e..706a343 100644
--- a/arch/sh/drivers/dma/dma-pvr2.c
+++ b/arch/sh/drivers/dma/dma-pvr2.c
@@ -70,7 +70,6 @@ static int pvr2_xfer_dma(struct dma_channel *chan)
 static struct irqaction pvr2_dma_irq = {
 	.name		= "pvr2 DMA handler",
 	.handler	= pvr2_dma_interrupt,
-	.flags		= IRQF_DISABLED,
 };
 
 static struct dma_ops pvr2_dma_ops = {
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 8272087..a60da6d 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -95,7 +95,7 @@ static int sh_dmac_request_dma(struct dma_channel *chan)
 #if defined(CONFIG_SH_DMA_IRQ_MULTI)
 				IRQF_SHARED,
 #else
-				IRQF_DISABLED,
+				0,
 #endif
 				chan->dev_id, chan);
 }
@@ -305,7 +305,7 @@ static int __init sh_dmac_init(void)
 #if defined(CONFIG_SH_DMA_IRQ_MULTI)
 				IRQF_SHARED,
 #else
-				IRQF_DISABLED,
+				0,
 #endif
 				dmae_name[n], (void *)dmae_name[n]);
 		if (unlikely(i < 0)) {
diff --git a/arch/sh/drivers/dma/dmabrg.c b/arch/sh/drivers/dma/dmabrg.c
index 6ab9c4a..3d66a32 100644
--- a/arch/sh/drivers/dma/dmabrg.c
+++ b/arch/sh/drivers/dma/dmabrg.c
@@ -174,17 +174,17 @@ static int __init dmabrg_init(void)
 	or = __raw_readl(DMAOR);
 	__raw_writel(or | DMAOR_BRG | DMAOR_DMEN, DMAOR);
 
-	ret = request_irq(DMABRGI0, dmabrg_irq, IRQF_DISABLED,
+	ret = request_irq(DMABRGI0, dmabrg_irq, 0,
 			"DMABRG USB address error", NULL);
 	if (ret)
 		goto out0;
 
-	ret = request_irq(DMABRGI1, dmabrg_irq, IRQF_DISABLED,
+	ret = request_irq(DMABRGI1, dmabrg_irq, 0,
 			"DMABRG Transfer End", NULL);
 	if (ret)
 		goto out1;
 
-	ret = request_irq(DMABRGI2, dmabrg_irq, IRQF_DISABLED,
+	ret = request_irq(DMABRGI2, dmabrg_irq, 0,
 			"DMABRG Transfer Half", NULL);
 	if (ret = 0)
 		return ret;
diff --git a/arch/sh/drivers/pci/pci-sh5.c b/arch/sh/drivers/pci/pci-sh5.c
index 0bf296c..16c1e72 100644
--- a/arch/sh/drivers/pci/pci-sh5.c
+++ b/arch/sh/drivers/pci/pci-sh5.c
@@ -107,13 +107,13 @@ static int __init sh5pci_init(void)
 	u32 uval;
 
         if (request_irq(IRQ_ERR, pcish5_err_irq,
-                        IRQF_DISABLED, "PCI Error",NULL) < 0) {
+                        0, "PCI Error",NULL) < 0) {
                 printk(KERN_ERR "PCISH5: Cannot hook PCI_PERR interrupt\n");
                 return -EINVAL;
         }
 
         if (request_irq(IRQ_SERR, pcish5_serr_irq,
-                        IRQF_DISABLED, "PCI SERR interrupt", NULL) < 0) {
+                        0, "PCI SERR interrupt", NULL) < 0) {
                 printk(KERN_ERR "PCISH5: Cannot hook PCI_SERR interrupt\n");
                 return -EINVAL;
         }
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
index edb7cca..fa7b978 100644
--- a/arch/sh/drivers/pci/pci-sh7780.c
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -172,7 +172,7 @@ static int __init sh7780_pci_setup_irqs(struct pci_channel *hose)
 		     PCI_STATUS_SIG_TARGET_ABORT | \
 		     PCI_STATUS_PARITY, hose->reg_base + PCI_STATUS);
 
-	ret = request_irq(hose->serr_irq, sh7780_pci_serr_irq, IRQF_DISABLED,
+	ret = request_irq(hose->serr_irq, sh7780_pci_serr_irq, 0,
 			  "PCI SERR interrupt", hose);
 	if (unlikely(ret)) {
 		printk(KERN_ERR "PCI: Failed hooking SERR IRQ\n");
diff --git a/arch/sh/drivers/push-switch.c b/arch/sh/drivers/push-switch.c
index afc2455..637b79b 100644
--- a/arch/sh/drivers/push-switch.c
+++ b/arch/sh/drivers/push-switch.c
@@ -63,7 +63,7 @@ static int switch_drv_probe(struct platform_device *pdev)
 	BUG_ON(!psw_info);
 
 	ret = request_irq(irq, psw_info->irq_handler,
-			  IRQF_DISABLED | psw_info->irq_flags,
+			  psw_info->irq_flags,
 			  psw_info->name ? psw_info->name : DRV_NAME, pdev);
 	if (unlikely(ret < 0))
 		goto err;
diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
index de865ca..03f2b55 100644
--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
@@ -79,7 +79,7 @@ static void shx3_prepare_cpus(unsigned int max_cpus)
 
 	for (i = 0; i < SMP_MSG_NR; i++)
 		request_irq(104 + i, ipi_interrupt_handler,
-			    IRQF_DISABLED | IRQF_PERCPU, "IPI", (void *)(long)i);
+			    IRQF_PERCPU, "IPI", (void *)(long)i);
 
 	for (i = 0; i < max_cpus; i++)
 		set_cpu_present(i, true);
-- 
1.7.1


^ permalink raw reply related

* Question about clk->usecount
From: kuninori.morimoto.gx @ 2011-10-25  0:44 UTC (permalink / raw)
  To: linux-sh


Hi SH ML

renesas_usbhs and sh_eth seems break in SH7724 ecovec board
from 794d78fea51504bad3880d14f354a9847f318f25 (drivers: sh: late disabling of clocks V2)
So I debuged it.

when these driver call pm_runtime_get_sync(),
then, arch/sh/kernel/cpu/hwblk.c :: hwblk_enable() are called,
and it enabled MSTP bit.
This is OK.

But clk_late_init() disabled it.

Does hwblk/pm_runtime (?) not care clk->usecount ?

^ permalink raw reply

* [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Mark Brown @ 2011-10-25  7:33 UTC (permalink / raw)
  To: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Mike Frysinger, Geert
  Cc: linux-arm-kernel, linux-kernel, uclinux-dist-devel, linux-m68k,
	linux-mips, linux-sh, linux-arch, Mark Brown

Rather than requiring architectures that use gpiolib but don't have any
need to define anything custom to copy an asm/gpio.h provide a Kconfig
symbol which architectures must select in order to include gpio.h and
for other architectures just provide the trivial implementation directly.

This makes it much easier to do gpiolib updates and is also a step towards
making gpiolib APIs available on every architecture.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 arch/alpha/include/asm/gpio.h      |   55 ------------------------------
 arch/arm/Kconfig                   |    1 +
 arch/avr32/Kconfig                 |    1 +
 arch/blackfin/Kconfig              |    1 +
 arch/ia64/include/asm/gpio.h       |   55 ------------------------------
 arch/m68k/Kconfig.cpu              |    1 +
 arch/microblaze/include/asm/gpio.h |   53 -----------------------------
 arch/mips/Kconfig                  |    1 +
 arch/openrisc/include/asm/gpio.h   |   65 ------------------------------------
 arch/powerpc/include/asm/gpio.h    |   53 -----------------------------
 arch/sh/Kconfig                    |    1 +
 arch/sparc/include/asm/gpio.h      |   36 --------------------
 arch/unicore32/Kconfig             |    1 +
 arch/x86/include/asm/gpio.h        |   53 -----------------------------
 arch/xtensa/include/asm/gpio.h     |   56 -------------------------------
 drivers/gpio/Kconfig               |    8 ++++
 include/linux/gpio.h               |   34 +++++++++++++++++++
 17 files changed, 49 insertions(+), 426 deletions(-)
 delete mode 100644 arch/alpha/include/asm/gpio.h
 delete mode 100644 arch/ia64/include/asm/gpio.h
 delete mode 100644 arch/microblaze/include/asm/gpio.h
 delete mode 100644 arch/openrisc/include/asm/gpio.h
 delete mode 100644 arch/powerpc/include/asm/gpio.h
 delete mode 100644 arch/sparc/include/asm/gpio.h
 delete mode 100644 arch/x86/include/asm/gpio.h
 delete mode 100644 arch/xtensa/include/asm/gpio.h

diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h
deleted file mode 100644
index 7dc6a63..0000000
--- a/arch/alpha/include/asm/gpio.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Generic GPIO API implementation for Alpha.
- *
- * A stright copy of that for PowerPC which was:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_ALPHA_GPIO_H
-#define _ASM_ALPHA_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_ALPHA_GPIO_H */
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7e8ffe7..5e0446c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1,6 +1,7 @@
 config ARM
 	bool
 	default y
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select HAVE_AOUT
 	select HAVE_DMA_API_DEBUG
 	select HAVE_IDE if PCI || ISA || PCMCIA
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index 197e96f..b2e3e58 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -10,6 +10,7 @@ config AVR32
 	select GENERIC_IRQ_PROBE
 	select HARDIRQS_SW_RESEND
 	select GENERIC_IRQ_SHOW
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	help
 	  AVR32 is a high-performance 32-bit RISC microprocessor core,
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index c747629..2c13eef 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -31,6 +31,7 @@ config BLACKFIN
 	select HAVE_KERNEL_LZO if RAMKERNEL
 	select HAVE_OPROFILE
 	select HAVE_PERF_EVENTS
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select HAVE_GENERIC_HARDIRQS
 	select GENERIC_ATOMIC64
diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h
deleted file mode 100644
index 590a20d..0000000
--- a/arch/ia64/include/asm/gpio.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Generic GPIO API implementation for IA-64.
- *
- * A stright copy of that for PowerPC which was:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_IA64_GPIO_H
-#define _ASM_IA64_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_IA64_GPIO_H */
diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index e632b2d..d4a818b 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -21,6 +21,7 @@ config MCPU32
 config COLDFIRE
 	bool
 	select GENERIC_GPIO
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_REQUIRE_GPIOLIB
 	select CPU_HAS_NO_BITFIELDS
 	help
diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h
deleted file mode 100644
index 2b2c18b..0000000
--- a/arch/microblaze/include/asm/gpio.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Generic GPIO API implementation for PowerPC.
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_MICROBLAZE_GPIO_H
-#define _ASM_MICROBLAZE_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_MICROBLAZE_GPIO_H */
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 62b9677..567290c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -8,6 +8,7 @@ config MIPS
 	select HAVE_PERF_EVENTS
 	select PERF_USE_VMALLOC
 	select HAVE_ARCH_KGDB
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_DYNAMIC_FTRACE
diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h
deleted file mode 100644
index 0b0d174..0000000
--- a/arch/openrisc/include/asm/gpio.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * OpenRISC Linux
- *
- * Linux architectural port borrowing liberally from similar works of
- * others.  All original copyrights apply as per the original source
- * declaration.
- *
- * OpenRISC implementation:
- * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
- * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
- * et al.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef __ASM_OPENRISC_GPIO_H
-#define __ASM_OPENRISC_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * OpenRISC (or1k) does not have on-chip GPIO's so there is not really
- * any standardized implementation that makes sense here.  If passing
- * through gpiolib becomes a bottleneck then it may make sense, on a
- * case-by-case basis, to implement these inlined/rapid versions.
- *
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-/*
- * Not implemented, yet.
- */
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return -ENOSYS;
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_OPENRISC_GPIO_H */
diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h
deleted file mode 100644
index 38762ed..0000000
--- a/arch/powerpc/include/asm/gpio.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Generic GPIO API implementation for PowerPC.
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef __ASM_POWERPC_GPIO_H
-#define __ASM_POWERPC_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * We don't (yet) implement inlined/rapid versions for on-chip gpios.
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_POWERPC_GPIO_H */
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index ff9177c..d00e11a 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -11,6 +11,7 @@ config SUPERH
 	select HAVE_DMA_ATTRS
 	select HAVE_IRQ_WORK
 	select HAVE_PERF_EVENTS
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
 	select PERF_USE_VMALLOC
 	select HAVE_KERNEL_GZIP
diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h
deleted file mode 100644
index a0e3ac0..0000000
--- a/arch/sparc/include/asm/gpio.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef __ASM_SPARC_GPIO_H
-#define __ASM_SPARC_GPIO_H
-
-#include <linux/errno.h>
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return -ENOSYS;
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_SPARC_GPIO_H */
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index e57dcce..7bdc7c6 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -8,6 +8,7 @@ config UNICORE32
 	select HAVE_KERNEL_BZIP2
 	select HAVE_KERNEL_LZO
 	select HAVE_KERNEL_LZMA
+	select ARCH_HAVE_CUSTOM_GPIO_H
 	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h
deleted file mode 100644
index 91d915a..0000000
--- a/arch/x86/include/asm/gpio.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Generic GPIO API implementation for x86.
- *
- * Derived from the generic GPIO API for powerpc:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_X86_GPIO_H
-#define _ASM_X86_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_X86_GPIO_H */
diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h
deleted file mode 100644
index a8c9fc4..0000000
--- a/arch/xtensa/include/asm/gpio.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Generic GPIO API implementation for xtensa.
- *
- * Stolen from x86, which is derived from the generic GPIO API for powerpc:
- *
- * Copyright (c) 2007-2008  MontaVista Software, Inc.
- *
- * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _ASM_XTENSA_GPIO_H
-#define _ASM_XTENSA_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-/*
- * Just call gpiolib.
- */
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-/*
- * Not implemented, yet.
- */
-static inline int irq_to_gpio(unsigned int irq)
-{
-	return -EINVAL;
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* _ASM_XTENSA_GPIO_H */
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index a107d44..ef920a2 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -2,6 +2,14 @@
 # GPIO infrastructure and drivers
 #
 
+config ARCH_HAVE_CUSTOM_GPIO_H
+	bool
+	help
+	  Selecting this config option from the architecture Kconfig allows
+	  the architecture to provide a custom asm/gpio.h implementation
+	  overriding the default implementations.  New uses of this are
+	  strongly discouraged.
+
 config ARCH_WANT_OPTIONAL_GPIOLIB
 	bool
 	help
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 38ac48b..3149f68 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -1,6 +1,8 @@
 #ifndef __LINUX_GPIO_H
 #define __LINUX_GPIO_H
 
+#include <linux/errno.h>
+
 /* see Documentation/gpio.txt */
 
 /* make these flag values available regardless of GPIO kconfig options */
@@ -27,7 +29,39 @@ struct gpio {
 };
 
 #ifdef CONFIG_GENERIC_GPIO
+
+#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
 #include <asm/gpio.h>
+#else
+
+#include <asm-generic/gpio.h>
+
+static inline int gpio_get_value(unsigned int gpio)
+{
+	return __gpio_get_value(gpio);
+}
+
+static inline void gpio_set_value(unsigned int gpio, int value)
+{
+	__gpio_set_value(gpio, value);
+}
+
+static inline int gpio_cansleep(unsigned int gpio)
+{
+	return __gpio_cansleep(gpio);
+}
+
+static inline int gpio_to_irq(unsigned int gpio)
+{
+	return __gpio_to_irq(gpio);
+}
+
+static inline int irq_to_gpio(unsigned int irq)
+{
+	return -EINVAL;
+}
+
+#endif
 
 #else
 
-- 
1.7.6.3


^ permalink raw reply related

* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Grant Likely @ 2011-10-25  8:33 UTC (permalink / raw)
  To: Mark Brown
  Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Mike Frysinger, Geert Uytterhoeven, Ralf Baechle, Paul Mundt,
	Guan Xuetao, linux-arm-kernel, linux-kernel, uclinux-dist-devel,
	linux-m68k, linux-mips, linux-sh, linux-arch
In-Reply-To: <1319528012-19006-1-git-send-email-broonie@opensource.wolfsonmicro.com>

On Tue, Oct 25, 2011 at 09:33:32AM +0200, Mark Brown wrote:
> Rather than requiring architectures that use gpiolib but don't have any
> need to define anything custom to copy an asm/gpio.h provide a Kconfig
> symbol which architectures must select in order to include gpio.h and
> for other architectures just provide the trivial implementation directly.
> 
> This makes it much easier to do gpiolib updates and is also a step towards
> making gpiolib APIs available on every architecture.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

(not that I've actually tested this much yet; it should probably go
into a separate branch to marinate in linux-next for a bit without
impacting the other GPIO patches I've got queued.

g.

> ---
>  arch/alpha/include/asm/gpio.h      |   55 ------------------------------
>  arch/arm/Kconfig                   |    1 +
>  arch/avr32/Kconfig                 |    1 +
>  arch/blackfin/Kconfig              |    1 +
>  arch/ia64/include/asm/gpio.h       |   55 ------------------------------
>  arch/m68k/Kconfig.cpu              |    1 +
>  arch/microblaze/include/asm/gpio.h |   53 -----------------------------
>  arch/mips/Kconfig                  |    1 +
>  arch/openrisc/include/asm/gpio.h   |   65 ------------------------------------
>  arch/powerpc/include/asm/gpio.h    |   53 -----------------------------
>  arch/sh/Kconfig                    |    1 +
>  arch/sparc/include/asm/gpio.h      |   36 --------------------
>  arch/unicore32/Kconfig             |    1 +
>  arch/x86/include/asm/gpio.h        |   53 -----------------------------
>  arch/xtensa/include/asm/gpio.h     |   56 -------------------------------
>  drivers/gpio/Kconfig               |    8 ++++
>  include/linux/gpio.h               |   34 +++++++++++++++++++
>  17 files changed, 49 insertions(+), 426 deletions(-)
>  delete mode 100644 arch/alpha/include/asm/gpio.h
>  delete mode 100644 arch/ia64/include/asm/gpio.h
>  delete mode 100644 arch/microblaze/include/asm/gpio.h
>  delete mode 100644 arch/openrisc/include/asm/gpio.h
>  delete mode 100644 arch/powerpc/include/asm/gpio.h
>  delete mode 100644 arch/sparc/include/asm/gpio.h
>  delete mode 100644 arch/x86/include/asm/gpio.h
>  delete mode 100644 arch/xtensa/include/asm/gpio.h
> 
> diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h
> deleted file mode 100644
> index 7dc6a63..0000000
> --- a/arch/alpha/include/asm/gpio.h
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -/*
> - * Generic GPIO API implementation for Alpha.
> - *
> - * A stright copy of that for PowerPC which was:
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_ALPHA_GPIO_H
> -#define _ASM_ALPHA_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * We don't (yet) implement inlined/rapid versions for on-chip gpios.
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_ALPHA_GPIO_H */
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 7e8ffe7..5e0446c 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1,6 +1,7 @@
>  config ARM
>  	bool
>  	default y
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select HAVE_AOUT
>  	select HAVE_DMA_API_DEBUG
>  	select HAVE_IDE if PCI || ISA || PCMCIA
> diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
> index 197e96f..b2e3e58 100644
> --- a/arch/avr32/Kconfig
> +++ b/arch/avr32/Kconfig
> @@ -10,6 +10,7 @@ config AVR32
>  	select GENERIC_IRQ_PROBE
>  	select HARDIRQS_SW_RESEND
>  	select GENERIC_IRQ_SHOW
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select ARCH_HAVE_NMI_SAFE_CMPXCHG
>  	help
>  	  AVR32 is a high-performance 32-bit RISC microprocessor core,
> diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
> index c747629..2c13eef 100644
> --- a/arch/blackfin/Kconfig
> +++ b/arch/blackfin/Kconfig
> @@ -31,6 +31,7 @@ config BLACKFIN
>  	select HAVE_KERNEL_LZO if RAMKERNEL
>  	select HAVE_OPROFILE
>  	select HAVE_PERF_EVENTS
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select ARCH_WANT_OPTIONAL_GPIOLIB
>  	select HAVE_GENERIC_HARDIRQS
>  	select GENERIC_ATOMIC64
> diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h
> deleted file mode 100644
> index 590a20d..0000000
> --- a/arch/ia64/include/asm/gpio.h
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -/*
> - * Generic GPIO API implementation for IA-64.
> - *
> - * A stright copy of that for PowerPC which was:
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_IA64_GPIO_H
> -#define _ASM_IA64_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * We don't (yet) implement inlined/rapid versions for on-chip gpios.
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_IA64_GPIO_H */
> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
> index e632b2d..d4a818b 100644
> --- a/arch/m68k/Kconfig.cpu
> +++ b/arch/m68k/Kconfig.cpu
> @@ -21,6 +21,7 @@ config MCPU32
>  config COLDFIRE
>  	bool
>  	select GENERIC_GPIO
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select ARCH_REQUIRE_GPIOLIB
>  	select CPU_HAS_NO_BITFIELDS
>  	help
> diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h
> deleted file mode 100644
> index 2b2c18b..0000000
> --- a/arch/microblaze/include/asm/gpio.h
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -/*
> - * Generic GPIO API implementation for PowerPC.
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_MICROBLAZE_GPIO_H
> -#define _ASM_MICROBLAZE_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * We don't (yet) implement inlined/rapid versions for on-chip gpios.
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_MICROBLAZE_GPIO_H */
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 62b9677..567290c 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -8,6 +8,7 @@ config MIPS
>  	select HAVE_PERF_EVENTS
>  	select PERF_USE_VMALLOC
>  	select HAVE_ARCH_KGDB
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select HAVE_FUNCTION_TRACER
>  	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
>  	select HAVE_DYNAMIC_FTRACE
> diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h
> deleted file mode 100644
> index 0b0d174..0000000
> --- a/arch/openrisc/include/asm/gpio.h
> +++ /dev/null
> @@ -1,65 +0,0 @@
> -/*
> - * OpenRISC Linux
> - *
> - * Linux architectural port borrowing liberally from similar works of
> - * others.  All original copyrights apply as per the original source
> - * declaration.
> - *
> - * OpenRISC implementation:
> - * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
> - * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
> - * et al.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef __ASM_OPENRISC_GPIO_H
> -#define __ASM_OPENRISC_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * OpenRISC (or1k) does not have on-chip GPIO's so there is not really
> - * any standardized implementation that makes sense here.  If passing
> - * through gpiolib becomes a bottleneck then it may make sense, on a
> - * case-by-case basis, to implement these inlined/rapid versions.
> - *
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -/*
> - * Not implemented, yet.
> - */
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return -ENOSYS;
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* __ASM_OPENRISC_GPIO_H */
> diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h
> deleted file mode 100644
> index 38762ed..0000000
> --- a/arch/powerpc/include/asm/gpio.h
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -/*
> - * Generic GPIO API implementation for PowerPC.
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef __ASM_POWERPC_GPIO_H
> -#define __ASM_POWERPC_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * We don't (yet) implement inlined/rapid versions for on-chip gpios.
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* __ASM_POWERPC_GPIO_H */
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index ff9177c..d00e11a 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -11,6 +11,7 @@ config SUPERH
>  	select HAVE_DMA_ATTRS
>  	select HAVE_IRQ_WORK
>  	select HAVE_PERF_EVENTS
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
>  	select PERF_USE_VMALLOC
>  	select HAVE_KERNEL_GZIP
> diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h
> deleted file mode 100644
> index a0e3ac0..0000000
> --- a/arch/sparc/include/asm/gpio.h
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -#ifndef __ASM_SPARC_GPIO_H
> -#define __ASM_SPARC_GPIO_H
> -
> -#include <linux/errno.h>
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return -ENOSYS;
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* __ASM_SPARC_GPIO_H */
> diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
> index e57dcce..7bdc7c6 100644
> --- a/arch/unicore32/Kconfig
> +++ b/arch/unicore32/Kconfig
> @@ -8,6 +8,7 @@ config UNICORE32
>  	select HAVE_KERNEL_BZIP2
>  	select HAVE_KERNEL_LZO
>  	select HAVE_KERNEL_LZMA
> +	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select GENERIC_FIND_FIRST_BIT
>  	select GENERIC_IRQ_PROBE
>  	select GENERIC_IRQ_SHOW
> diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h
> deleted file mode 100644
> index 91d915a..0000000
> --- a/arch/x86/include/asm/gpio.h
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -/*
> - * Generic GPIO API implementation for x86.
> - *
> - * Derived from the generic GPIO API for powerpc:
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_X86_GPIO_H
> -#define _ASM_X86_GPIO_H
> -
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_X86_GPIO_H */
> diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h
> deleted file mode 100644
> index a8c9fc4..0000000
> --- a/arch/xtensa/include/asm/gpio.h
> +++ /dev/null
> @@ -1,56 +0,0 @@
> -/*
> - * Generic GPIO API implementation for xtensa.
> - *
> - * Stolen from x86, which is derived from the generic GPIO API for powerpc:
> - *
> - * Copyright (c) 2007-2008  MontaVista Software, Inc.
> - *
> - * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef _ASM_XTENSA_GPIO_H
> -#define _ASM_XTENSA_GPIO_H
> -
> -#include <asm-generic/gpio.h>
> -
> -#ifdef CONFIG_GPIOLIB
> -
> -/*
> - * Just call gpiolib.
> - */
> -static inline int gpio_get_value(unsigned int gpio)
> -{
> -	return __gpio_get_value(gpio);
> -}
> -
> -static inline void gpio_set_value(unsigned int gpio, int value)
> -{
> -	__gpio_set_value(gpio, value);
> -}
> -
> -static inline int gpio_cansleep(unsigned int gpio)
> -{
> -	return __gpio_cansleep(gpio);
> -}
> -
> -static inline int gpio_to_irq(unsigned int gpio)
> -{
> -	return __gpio_to_irq(gpio);
> -}
> -
> -/*
> - * Not implemented, yet.
> - */
> -static inline int irq_to_gpio(unsigned int irq)
> -{
> -	return -EINVAL;
> -}
> -
> -#endif /* CONFIG_GPIOLIB */
> -
> -#endif /* _ASM_XTENSA_GPIO_H */
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index a107d44..ef920a2 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -2,6 +2,14 @@
>  # GPIO infrastructure and drivers
>  #
>  
> +config ARCH_HAVE_CUSTOM_GPIO_H
> +	bool
> +	help
> +	  Selecting this config option from the architecture Kconfig allows
> +	  the architecture to provide a custom asm/gpio.h implementation
> +	  overriding the default implementations.  New uses of this are
> +	  strongly discouraged.
> +
>  config ARCH_WANT_OPTIONAL_GPIOLIB
>  	bool
>  	help
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index 38ac48b..3149f68 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -1,6 +1,8 @@
>  #ifndef __LINUX_GPIO_H
>  #define __LINUX_GPIO_H
>  
> +#include <linux/errno.h>
> +
>  /* see Documentation/gpio.txt */
>  
>  /* make these flag values available regardless of GPIO kconfig options */
> @@ -27,7 +29,39 @@ struct gpio {
>  };
>  
>  #ifdef CONFIG_GENERIC_GPIO
> +
> +#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
>  #include <asm/gpio.h>
> +#else
> +
> +#include <asm-generic/gpio.h>
> +
> +static inline int gpio_get_value(unsigned int gpio)
> +{
> +	return __gpio_get_value(gpio);
> +}
> +
> +static inline void gpio_set_value(unsigned int gpio, int value)
> +{
> +	__gpio_set_value(gpio, value);
> +}
> +
> +static inline int gpio_cansleep(unsigned int gpio)
> +{
> +	return __gpio_cansleep(gpio);
> +}
> +
> +static inline int gpio_to_irq(unsigned int gpio)
> +{
> +	return __gpio_to_irq(gpio);
> +}
> +
> +static inline int irq_to_gpio(unsigned int irq)
> +{
> +	return -EINVAL;
> +}
> +
> +#endif
>  
>  #else
>  
> -- 
> 1.7.6.3
> 

^ permalink raw reply

* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Mark Brown @ 2011-10-25  8:39 UTC (permalink / raw)
  To: Grant Likely
  Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Mike Frysinger, Geert Uytterhoeven, Ralf Baechle, Paul Mundt,
	Guan Xuetao, linux-arm-kernel, linux-kernel, uclinux-dist-devel,
	linux-m68k, linux-mips, linux-sh, linux-arch
In-Reply-To: <20111025083301.GD4605@ponder.secretlab.ca>

On Tue, Oct 25, 2011 at 10:33:01AM +0200, Grant Likely wrote:

> (not that I've actually tested this much yet; it should probably go
> into a separate branch to marinate in linux-next for a bit without
> impacting the other GPIO patches I've got queued.

Yes, it should.  I've test built a few configurations covering both
asm/gpio.h and default implementations and it seems to be doing the
right thing but I might well have missed something.  I'm hoping to also
have a further patch to go on top of this which makes _OPTIONAL_GPOILIB
on by default.

^ permalink raw reply

* [GIT PULL] Power management updates for 3.2
From: Rafael J. Wysocki @ 2011-10-25 13:19 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: LKML, Linux PM list, Linux-sh list, Turquette, Mike,
	Len Brown (Intel)

Hi Linus,

Please pull power management updates for 3.2 (on top of commit
3ee72ca99288f1de95ec9c570e43f531c8799f06) from:

git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git pm-for-linus

with top-most commit 0ab1e79b825a5cd8aeb3b34d89c9a89dea900056
"PM / Clocks: Remove redundant NULL checks before kfree()".

They include:

* Runtime PM tracepoints (replacing not very useful debug printks) and fixes
  from Ming Lei.

* Introduction of devfreq by MyungJoo Ham (special thanks to Mike Turquette
  for reviewing all of the versions of this patchset).

* Introduction of device PM QoS from Jean Pihet.

* Generic PM domains core code refinements and extensions.

* SH7372 power management changes from Magnus Damm.

* Threaded hibernate image saving from Bojan Smojver.

* New entries for the ACPI suspend blacklist.

* Assorted fixes.

Thanks!


 Documentation/ABI/testing/sysfs-class-devfreq  |   52 ++
 Documentation/kernel-parameters.txt            |    7 +
 Documentation/power/00-INDEX                   |    2 +
 Documentation/power/basic-pm-debugging.txt     |   24 +
 Documentation/power/devices.txt                |    8 +-
 Documentation/power/pm_qos_interface.txt       |   92 +++-
 Documentation/power/runtime_pm.txt             |   21 +-
 Documentation/power/suspend-and-cpuhotplug.txt |  275 ++++++++
 Documentation/usb/power-management.txt         |    8 +-
 MAINTAINERS                                    |   12 +-
 arch/arm/mach-msm/clock.c                      |    2 +-
 arch/arm/mach-omap1/pm_bus.c                   |    1 +
 arch/arm/mach-shmobile/board-ap4evb.c          |    6 +
 arch/arm/mach-shmobile/board-mackerel.c        |   11 +-
 arch/arm/mach-shmobile/include/mach/common.h   |    4 +-
 arch/arm/mach-shmobile/include/mach/sh7372.h   |   13 +
 arch/arm/mach-shmobile/intc-sh7372.c           |   52 ++-
 arch/arm/mach-shmobile/pm-sh7372.c             |  342 ++++++++--
 arch/arm/mach-shmobile/pm_runtime.c            |    1 +
 arch/arm/mach-shmobile/setup-sh7372.c          |   25 +
 arch/arm/mach-shmobile/sleep-sh7372.S          |  221 +------
 arch/s390/Kconfig                              |    1 +
 arch/s390/kernel/suspend.c                     |  118 ++++
 arch/s390/kernel/swsusp_asm64.S                |    3 +
 drivers/Kconfig                                |    2 +
 drivers/Makefile                               |    2 +
 drivers/acpi/processor_idle.c                  |    2 +-
 drivers/acpi/sleep.c                           |   24 +
 drivers/base/power/Makefile                    |    4 +-
 drivers/base/power/clock_ops.c                 |  127 ++--
 drivers/base/power/common.c                    |   86 +++
 drivers/base/power/domain.c                    |  352 ++++++-----
 drivers/base/power/main.c                      |   42 +-
 drivers/base/power/opp.c                       |   30 +
 drivers/base/power/power.h                     |   10 +-
 drivers/base/power/qos.c                       |  419 ++++++++++++
 drivers/base/power/runtime.c                   |  127 +++--
 drivers/base/power/wakeup.c                    |    4 +-
 drivers/bluetooth/btusb.c                      |    2 +-
 drivers/cpuidle/cpuidle.c                      |    2 +-
 drivers/cpuidle/governors/ladder.c             |    2 +-
 drivers/cpuidle/governors/menu.c               |    2 +-
 drivers/devfreq/Kconfig                        |   75 +++
 drivers/devfreq/Makefile                       |    5 +
 drivers/devfreq/devfreq.c                      |  601 +++++++++++++++++
 drivers/devfreq/governor.h                     |   24 +
 drivers/devfreq/governor_performance.c         |   29 +
 drivers/devfreq/governor_powersave.c           |   29 +
 drivers/devfreq/governor_simpleondemand.c      |   88 +++
 drivers/devfreq/governor_userspace.c           |  116 ++++
 drivers/hid/hid-picolcd.c                      |    2 +-
 drivers/hid/usbhid/hid-core.c                  |    7 +-
 drivers/media/video/via-camera.c               |    4 +-
 drivers/net/e1000e/netdev.c                    |    2 +-
 drivers/net/usb/usbnet.c                       |    2 +-
 drivers/net/wimax/i2400m/usb.c                 |    4 +-
 drivers/net/wireless/ipw2x00/ipw2100.c         |    4 +-
 drivers/tty/Kconfig                            |    4 +
 drivers/usb/class/cdc-acm.c                    |    2 +-
 drivers/usb/class/cdc-wdm.c                    |    6 +-
 drivers/usb/core/driver.c                      |    9 +-
 drivers/usb/core/hcd.c                         |    9 +-
 drivers/usb/core/hub.c                         |   15 +-
 drivers/usb/serial/sierra.c                    |    2 +-
 drivers/usb/serial/usb_wwan.c                  |    2 +-
 include/linux/devfreq.h                        |  238 +++++++
 include/linux/device.h                         |    5 +
 include/linux/freezer.h                        |    4 +-
 include/linux/netdevice.h                      |    4 +-
 include/linux/opp.h                            |   12 +
 include/linux/pm.h                             |   26 +-
 include/linux/pm_clock.h                       |   71 ++
 include/linux/pm_domain.h                      |   26 +-
 include/linux/pm_qos.h                         |  155 +++++
 include/linux/pm_qos_params.h                  |   38 --
 include/linux/pm_runtime.h                     |   42 --
 include/linux/suspend.h                        |   95 +++-
 include/sound/pcm.h                            |    4 +-
 include/trace/events/rpm.h                     |   99 +++
 kernel/Makefile                                |    2 +-
 kernel/freezer.c                               |    2 +-
 kernel/power/Kconfig                           |    4 +
 kernel/power/Makefile                          |    4 +-
 kernel/power/console.c                         |    4 +-
 kernel/power/hibernate.c                       |   53 ++-
 kernel/power/main.c                            |  102 +++
 kernel/power/power.h                           |    4 +-
 kernel/power/process.c                         |   30 +-
 kernel/{pm_qos_params.c => power/qos.c}        |  273 ++++----
 kernel/power/snapshot.c                        |   18 +
 kernel/power/suspend.c                         |   17 +-
 kernel/power/swap.c                            |  818 ++++++++++++++++++-----
 kernel/trace/Makefile                          |    3 +
 kernel/trace/rpm-traces.c                      |   20 +
 net/mac80211/main.c                            |    2 +-
 net/mac80211/mlme.c                            |    2 +-
 net/mac80211/scan.c                            |    2 +-
 sound/core/pcm_native.c                        |    2 +-
 sound/usb/card.c                               |    2 +-
 99 files changed, 4720 insertions(+), 1044 deletions(-)

---------------

Alan Stern (3):
      PM / Runtime: Add macro to test for runtime PM events
      USB: Add wakeup info to debugging messages
      PM: Update the policy on default wakeup settings

Barry Song (4):
      PM / Hibernate: Fix typo in a kerneldoc comment
      PM / Hibernate: Add resumewait param to support MMC-like devices as resume file
      PM / Hibernate: Add resumedelay kernel param in addition to resumewait
      PM / Hibernate: Do not initialize static and extern variables to 0

Bogdan Radulescu (1):
      PM / ACPI: Blacklist Vaio VGN-FW520F machine known to require acpi_sleep=nonvs

Bojan Smojver (1):
      PM / Hibernate: Improve performance of LZO/plain hibernation, checksum image

Colin Cross (1):
      PM / Runtime: Add might_sleep() to runtime PM functions

Dan Carpenter (1):
      PM / Suspend: Off by one in pm_suspend()

Dave Jones (1):
      ACPI / PM: Add Sony VGN-FW21E to nonvs blacklist.

H Hartley Sweeten (1):
      PM / VT: Cleanup #if defined uglyness and fix compile error

Jean Pihet (8):
      PM QoS: Move and rename the implementation files
      PM QoS: Minor clean-ups
      PM QoS: Code reorganization
      PM QoS: Reorganize data structs
      PM QoS: Generalize and export constraints management code
      PM QoS: Implement per-device PM QoS constraints
      PM QoS: Add global notification mechanism for device constraints
      PM / QoS: Update Documentation for the pm_qos and dev_pm_qos frameworks

Jeff Layton (1):
      PM / Freezer: Make fake_signal_wake_up() wake TASK_KILLABLE tasks too

Jonghwan Choi (1):
      PM / Clocks: Remove redundant NULL checks before kfree()

Magnus Damm (5):
      ARM: mach-shmobile: sh7372 generic suspend/resume support
      ARM: mach-shmobile: sh7372 A3SM support
      ARM: mach-shmobile: sh7372 sleep warning fixes
      ARM: mach-shmobile: sh7372 A3SP support (v4)
      ARM: mach-shmobile: sh7372 A4R support (v4)

Martin Schwidefsky (1):
      PM / Hibernate: Include storage keys in hibernation image on s390

Ming Lei (7):
      PM / Runtime: pm_runtime_idle() can be called in atomic context
      PM / Runtime: Introduce trace points for tracing rpm_* functions
      PM / Runtime: Replace dev_dbg() with trace_rpm_*()
      PM / Tracing: build rpm-traces.c only if CONFIG_PM_RUNTIME is set
      PM / Runtime: Update document about callbacks
      PM / Runtime: Fix kerneldoc comment for rpm_suspend()
      PM / Runtime: Handle .runtime_suspend() failure correctly

MyungJoo Ham (4):
      PM / OPP: Add OPP availability change notifier.
      PM: Introduce devfreq: generic DVFS framework with device-specific OPPs
      PM / devfreq: Add common sysfs interfaces
      PM / devfreq: Add basic governors

Rafael J. Wysocki (20):
      PM / Domains: Implement subdomain counters as atomic fields
      PM / Domains: Do not take parent locks to modify subdomain counters
      PM / Domains: Make pm_genpd_poweron() always survive parent removal
      PM / Domains: Add "wait for parent" status for generic PM domains
      PM / Domains: Allow generic PM domains to have multiple masters
      PM / Domains: Rename GPD_STATE_WAIT_PARENT to GPD_STATE_WAIT_MASTER
      PM / Domains: Rename argument of pm_genpd_add_subdomain()
      ARM / shmobile: Make A3RV be a subdomain of A4LC on SH7372
      PM: Introduce struct pm_subsys_data
      PM: Reference counting of power.subsys_data
      PM / Domains: Use power.sybsys_data to reduce overhead
      PM: Move clock-related definitions and headers to separate file
      PM / Domains: Preliminary support for devices with power.irq_safe set
      PM / Domains: Split device PM domain data into base and need_restore
      PM / Runtime: Don't run callbacks under lock for power.irq_safe set
      PM / QoS: Add function dev_pm_qos_read_value() (v3)
      PM: Fix build issue in main.c for CONFIG_PM_SLEEP unset
      PM / Hibernate: Freeze kernel threads after preallocating memory
      PM / ACPI: Blacklist Sony Vaio known to require acpi_sleep=nonvs
      PM / Sleep: Mark devices involved in wakeup signaling during suspend

ShuoX Liu (1):
      PM / Suspend: Add statistics debugfs file for suspend to RAM

Srivatsa S. Bhat (1):
      PM / Documentation: Update docs about suspend and CPU hotplug

WANG Cong (1):
      MAINTAINERS: Update linux-pm list address


^ permalink raw reply

* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Mike Frysinger @ 2011-10-25 23:44 UTC (permalink / raw)
  To: Mark Brown
  Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Geert Uytterhoeven, Ralf Baechle, Paul Mundt, Guan Xuetao,
	Grant Likely, linux-arm-kernel, linux-kernel, uclinux-dist-devel,
	linux-m68k, linux-mips, linux-sh, linux-arch
In-Reply-To: <1319528012-19006-1-git-send-email-broonie@opensource.wolfsonmicro.com>

On Tue, Oct 25, 2011 at 03:33, Mark Brown wrote:
> Rather than requiring architectures that use gpiolib but don't have any
> need to define anything custom to copy an asm/gpio.h provide a Kconfig
> symbol which architectures must select in order to include gpio.h and
> for other architectures just provide the trivial implementation directly.

i don't think this is generally how asm-generic is handled.  instead, how about:
 - move the duplicate code to asm-generic/gpio.h
 - have the arches which merely need asm-generic/gpio.h add "generic-y
+= gpio.h" to their include/asm/Kbuild
 - for arches which need to override these common funcs in some way,
add #ifdef protection to the asm-generic/gpio.h

and it seems like with slightly more work, this path allow you to
merge most of arch/sh/include/asm/gpio.h.  and it has the advantage of
not needing new Kconfig symbols.

for example, with asm-generic/atomic.h, it does:
#ifndef atomic_sub_return
static inline int atomic_sub_return(int i, atomic_t *v)
{ ... common implementation ... }
#endif

and then any arch that wants to override it does:
#define atomic_sub_return atomic_sub_return
static inline int atomic_sub_return(int i, atomic_t *v) { weirdness }
#include <asm-generic/atomic.h>
-mike

^ permalink raw reply

* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h
From: Mark Brown @ 2011-10-26  7:33 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt,
	Geert Uytterhoeven, Ralf Baechle, Paul Mundt, Guan Xuetao,
	Grant Likely, linux-arm-kernel, linux-kernel, uclinux-dist-devel,
	linux-m68k, linux-mips, linux-sh, linux-arch
In-Reply-To: <CAJaTeTp2w85UHnmH-PPMZsQGQMNa-93kw-tjmDxA_wjJXkYQcQ@mail.gmail.com>

On Tue, Oct 25, 2011 at 07:44:14PM -0400, Mike Frysinger wrote:

> i don't think this is generally how asm-generic is handled.  instead, how about:
>  - move the duplicate code to asm-generic/gpio.h
>  - have the arches which merely need asm-generic/gpio.h add "generic-y
> += gpio.h" to their include/asm/Kbuild
>  - for arches which need to override these common funcs in some way,
> add #ifdef protection to the asm-generic/gpio.h

> and it seems like with slightly more work, this path allow you to
> merge most of arch/sh/include/asm/gpio.h.  and it has the advantage of
> not needing new Kconfig symbols.

That's really not how gpiolib is currently handled, unfortunately -
trying to transition over to that model in one patch would be way too
much.  

The goal here from that point of view is to make transitioning to
something more sensible easier by getting rid of the boilerplate code,
it makes doing the more invasive changes like you're suggesting much
easier as we're only dealing with the architectures that are actually
doing something.  It also means that we're able to immediately work on
turning on gpiolib on random architectures which is a definite win.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox