Skip to contentSkip to conversation

add pinmux and gpio for CSR SiRFprimaII

RFC PATCH New Barry Song 8 participants 19 messages Jul 26, 2011 – Sep 19, 2011

Subsystems (4)
lore
Share & tools
lore

Barry Song

author
#0 lore raw

cover add pinmux and gpio for CSR SiRFprimaII

The following two patches add pinmux and gpio support for CSR SiRFprimaII.

Now the pinmux subsystem of Linus Walleij, so patch 1 isn't based on it yet. But it is easy to move that to use new framework once pinmux subsystem is merged.

Rongjun Ying (1):
ARM: CSR: Add pinmux support for SiRFprimaII

Yuping Luo (1):
GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller

 arch/arm/boot/dts/prima2-cb.dts               |    2 +-
 arch/arm/mach-prima2/Makefile                 |    1 +
 arch/arm/mach-prima2/include/mach/gpio.h      |   34 +
 arch/arm/mach-prima2/include/mach/irqs.h      |   11 +
 arch/arm/mach-prima2/include/mach/regs-gpio.h |   30 +
 arch/arm/mach-prima2/pinmux.c                 |  824 +++++++++++++++++++++++++
 drivers/gpio/Kconfig                          |    6 +
 drivers/gpio/Makefile                         |    1 +
 drivers/gpio/gpio-sirf.c                      |  529 ++++++++++++++++
 9 files changed, 1437 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-prima2/include/mach/gpio.h
 create mode 100644 arch/arm/mach-prima2/include/mach/regs-gpio.h
 create mode 100644 arch/arm/mach-prima2/pinmux.c
 create mode 100644 drivers/gpio/gpio-sirf.c

Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog

author
#1 lore raw

RFC PATCH 1/2 ARM: CSR: Add pinmux support for SiRFprimaII

From: Rongjun Ying <[email protected]>

---
 arch/arm/boot/dts/prima2-cb.dts               |    2 +-
 arch/arm/mach-prima2/Makefile                 |    1 +
 arch/arm/mach-prima2/include/mach/irqs.h      |   11 +
 arch/arm/mach-prima2/include/mach/regs-gpio.h |   30 +
 arch/arm/mach-prima2/pinmux.c                 |  824 +++++++++++++++++++++++++
 5 files changed, 867 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-prima2/include/mach/regs-gpio.h
 create mode 100644 arch/arm/mach-prima2/pinmux.c
arch/arm/boot/dts/prima2-cb.dts +1 -1
index 6fecc88..07249c2 100644
@@ -274,7 +274,7 @@
 			gpio: gpio-controller at b0120000 {
 				#gpio-cells = <2>;
 				#interrupt-cells = <2>;
-				compatible = "sirf,prima2-gpio";
+				compatible = "sirf,prima2-gpio", "sirf,prima2-pinmux";
 				reg = <0xb0120000 0x10000>;
 				gpio-controller;
 				interrupt-controller;
arch/arm/mach-prima2/Makefile +1 -0
index 7af7fc0..efb8489 100644
@@ -3,5 +3,6 @@ obj-y += irq.o
 obj-y += clock.o
 obj-y += rstc.o
 obj-y += prima2.o
+obj-y += pinmux.o
 obj-$(CONFIG_DEBUG_LL) += lluart.o
 obj-$(CONFIG_CACHE_L2X0) += l2x0.o
arch/arm/mach-prima2/include/mach/irqs.h +11 -0
index bb354f9..06fe4e0 100644
@@ -12,6 +12,17 @@
 #define SIRFSOC_INTENAL_IRQ_START  0
 #define SIRFSOC_INTENAL_IRQ_END    59
 
+#define SIRFSOC_GPIO_IO_CPLD_SIZE	(5 * 8)
+#define SIRFSOC_GPIO_HS_CPLD_SIZE	(16 * 8)
+
+#define SIRFSOC_GPIO_IRQ_START     (SIRFSOC_INTENAL_IRQ_END + 1)
+
+#define SIRFSOC_GPIO_NO_OF_BANKS        5
+#define SIRFSOC_GPIO_BANK_SIZE          32
+
+#define SIRFSOC_GPIO_IRQ_END       (SIRFSOC_GPIO_IRQ_START + \
+		SIRFSOC_GPIO_NO_OF_BANKS * SIRFSOC_GPIO_BANK_SIZE)
+
 #define NR_IRQS	220
 
 #endif
arch/arm/mach-prima2/include/mach/regs-gpio.h new file +30 -0
new file mode 100644
index 0000000..e3489eb
@@ -0,0 +1,30 @@
+/*
+ * arch/arm/mach-prima2/include/mach/regs-gpio.h
+ *
+ * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
+ *
+ * Licensed under GPLv2 or later.
+ */
+
+#ifndef __REGS_GPIO_H_
+#define __REGS_GPIO_H_
+
+#define SIRFSOC_GPIO_CTRL(g, i)			((g)*0x100 + (i)*4)
+#define SIRFSOC_GPIO_DSP_EN0			(0x80)
+#define SIRFSOC_GPIO_PAD_EN(g)			((g)*0x100 + 0x84)
+#define SIRFSOC_GPIO_INT_STATUS(g) 		((g)*0x100 + 0x8C)
+
+#define SIRFSOC_GPIO_CTL_INTR_LOW_MASK		0x1
+#define SIRFSOC_GPIO_CTL_INTR_HIGH_MASK		0x2
+#define SIRFSOC_GPIO_CTL_INTR_TYPE_MASK		0x4
+#define SIRFSOC_GPIO_CTL_INTR_EN_MASK		0x8
+#define SIRFSOC_GPIO_CTL_INTR_STS_MASK		0x10
+#define SIRFSOC_GPIO_CTL_OUT_EN_MASK		0x20
+#define SIRFSOC_GPIO_CTL_DATAOUT_MASK		0x40
+#define SIRFSOC_GPIO_CTL_DATAIN_MASK		0x80
+#define SIRFSOC_GPIO_CTL_PULL_MASK		0x100
+#define SIRFSOC_GPIO_CTL_PULL_HIGH      	0x200
+#define SIRFSOC_GPIO_CTL_DSP_INT		0x400
+
+#define SIRFSOC_GPIO_NUM(bank, index)	(((bank)*(32)) + (index))
+#endif
arch/arm/mach-prima2/pinmux.c new file +824 -0

824 lines not on this page · raw message

Signature · 6 lines
1.7.1



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
author
#2 lore raw

RFC PATCH 2/2 GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller

In reply to Barry Song

From: Yuping Luo <[email protected]>

---
 arch/arm/mach-prima2/include/mach/gpio.h |   34 ++
 drivers/gpio/Kconfig                     |    6 +
 drivers/gpio/Makefile                    |    1 +
 drivers/gpio/gpio-sirf.c                 |  529 ++++++++++++++++++++++++++++++
 4 files changed, 570 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-prima2/include/mach/gpio.h
 create mode 100644 drivers/gpio/gpio-sirf.c
arch/arm/mach-prima2/include/mach/gpio.h new file +34 -0
new file mode 100644
index 0000000..25673b1
@@ -0,0 +1,34 @@
+/*
+ * arch/arm/mach-prima2/include/mach/gpio.h
+ *
+ * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
+ *
+ * Licensed under GPLv2 or later.
+ */
+
+#ifndef __MACH_GPIO_H
+#define __MACH_GPIO_H
+
+#include <mach/irqs.h>
+
+#ifndef CONFIG_GPIO_SIRFCPLD
+#define ARCH_NR_GPIOS	(SIRFSOC_GPIO_BANK_SIZE * SIRFSOC_GPIO_NO_OF_BANKS)
+#else
+#define ARCH_NR_GPIOS	(SIRFSOC_GPIO_BANK_SIZE * SIRFSOC_GPIO_NO_OF_BANKS + \
+	SIRFSOC_GPIO_CPLD_SIZE + SIRFSOC_GPIO_IO_CPLD_SIZE + \
+	SIRFSOC_GPIO_HS_CPLD_SIZE)
+#endif
+
+#include <linux/errno.h>
+#include <asm-generic/gpio.h>
+
+#define gpio_get_value	__gpio_get_value
+#define gpio_set_value	__gpio_set_value
+#define gpio_cansleep	__gpio_cansleep
+#define gpio_to_irq	__gpio_to_irq
+
+void gpio_set_pull(unsigned gpio, int enable);
+void gpio_pull_down(unsigned gpio);
+void gpio_pull_up(unsigned gpio);
+
+#endif
drivers/gpio/Kconfig +6 -0
index 3634986..c5da284 100644
@@ -162,6 +162,12 @@ config GPIO_SCH
 	  The Intel Tunnel Creek processor has 5 GPIOs powered by the
 	  core power rail and 9 from suspend power supply.
 
+config GPIO_SIRF
+	bool "CSR SiRFprimaII GPIO"
+	default y
+	help
+	  Say yes here to support GPIO interface on CSR SiRFprimaII.
+
 config GPIO_VX855
 	tristate "VIA VX855/VX875 GPIO"
 	depends on MFD_SUPPORT && PCI
drivers/gpio/Makefile +1 -0
index 7207112..f4ffd0e 100644
@@ -42,6 +42,7 @@ obj-$(CONFIG_GPIO_S5PC100)	+= gpio-s5pc100.o
 obj-$(CONFIG_GPIO_S5PV210)	+= gpio-s5pv210.o
 
 obj-$(CONFIG_GPIO_SCH)		+= gpio-sch.o
+obj-$(CONFIG_GPIO_SIRF)		+= gpio-sirf.o
 obj-$(CONFIG_GPIO_STMPE)	+= gpio-stmpe.o
 obj-$(CONFIG_GPIO_SX150X)	+= gpio-sx150x.o
 obj-$(CONFIG_GPIO_TC3589X)	+= gpio-tc3589x.o
drivers/gpio/gpio-sirf.c new file +529 -0

529 lines not on this page · raw message

Signature · 6 lines
1.7.1



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
#3 lore raw

RFC PATCH 2/2 GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller

Quoted 18 lines · Barry Song
arch/arm/mach-prima2/include/mach/gpio.h new file +12 -0
new file mode 100644
index 0000000..25673b1
@@ -0,0 +1,34 @@
+/*
+ * arch/arm/mach-prima2/include/mach/gpio.h
+ *
+ * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
+ *
+ * Licensed under GPLv2 or later.
+ */
+
+#ifndef __MACH_GPIO_H
+#define __MACH_GPIO_H
+
+#include <mach/irqs.h>

arch/arm/mach-prima2/include/mach/gpio.h line 22

Quoted 10 lines
arch/arm/mach-prima2/include/mach/gpio.h new file +10 -0
+
+#ifndef CONFIG_GPIO_SIRFCPLD
+#define ARCH_NR_GPIOS	(SIRFSOC_GPIO_BANK_SIZE * SIRFSOC_GPIO_NO_OF_BANKS)
+#else
+#define ARCH_NR_GPIOS	(SIRFSOC_GPIO_BANK_SIZE * SIRFSOC_GPIO_NO_OF_BANKS + \
+	SIRFSOC_GPIO_CPLD_SIZE + SIRFSOC_GPIO_IO_CPLD_SIZE + \
+	SIRFSOC_GPIO_HS_CPLD_SIZE)
+#endif
+
+#include <linux/errno.h>

Why do you need linux/errno.h? asm-generic/gpio.h already includes this.

arch/arm/mach-prima2/include/mach/gpio.h line 27

Quoted 5 lines
arch/arm/mach-prima2/include/mach/gpio.h new file +5 -0
+#include <asm-generic/gpio.h>
+
+#define gpio_get_value	__gpio_get_value
+#define gpio_set_value	__gpio_set_value
+#define gpio_cansleep	__gpio_cansleep

Hmm, yet another trivial gpio implementation. We have 24 others just like this. Well, mainline does... I have just one. Patches after the merge window closes.

#4 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

Quoted 3 lines · Russell King - ARM Linux

Hmm, yet another trivial gpio implementation. We have 24 others just like this. Well, mainline does... I have just one. Patches after the merge window closes.

As an additional note to this: we _really_ need to get on top of the includes of mach/gpio.h rather than linux/gpio.h - there are around 139 files in mainline (this morning) which include mach/gpio.h directly.

There's one which includes both asm/gpio.h and mach/gpio.h, which is silly when you look at what asm/gpio.h contains - maybe one attempt to include mach/gpio.h wasn't enough!

These includes get in the way of consolidating stuff out of mach/gpio.h into asm/gpio.h - moving stuff out of mach/gpio.h could take it out of view of these files, thereby causing build errors.

What is even less clear is whether changing these mach/gpio.h includes to linux/gpio.h is correct or not.

So, what I'd like all platform and all soc maintainers to do is to:

grep -rl '<mach/gpio.h>' arch/arm drivers

and investigate their files from that list which they're responsible for, and submit patches to _me_ to fix these includes up (preferably to use linux/gpio.h). I'd also like them to do a better job at spotting these while reviewing patches on the list to help reduce new occurances of this.

Thanks.

#5 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

Quoted 24 lines · Russell King - ARM Linux
Quoted 3 lines · Russell King - ARM Linux

Hmm, yet another trivial gpio implementation. ?We have 24 others just like this. ?Well, mainline does... I have just one. ?Patches after the merge window closes.

As an additional note to this: we _really_ need to get on top of the includes of mach/gpio.h rather than linux/gpio.h - there are around 139 files in mainline (this morning) which include mach/gpio.h directly.

There's one which includes both asm/gpio.h and mach/gpio.h, which is silly when you look at what asm/gpio.h contains - maybe one attempt to include mach/gpio.h wasn't enough!

These includes get in the way of consolidating stuff out of mach/gpio.h into asm/gpio.h - moving stuff out of mach/gpio.h could take it out of view of these files, thereby causing build errors.

What is even less clear is whether changing these mach/gpio.h includes to linux/gpio.h is correct or not.

So, what I'd like all platform and all soc maintainers to do is to:

? ? ? ?grep -rl '<mach/gpio.h>' arch/arm drivers

Quoted 7 lines

and investigate their files from that list which they're responsible for, and submit patches to _me_ to fix these includes up (preferably to use linux/gpio.h). ?I'd also like them to do a better job at spotting these while reviewing patches on the list to help reduce new occurances of this.

Thanks.

Tegra has four uses of mach/gpio.h:
arch/arm/mach-tegra/board-trimslice-pinmux.c
arch/arm/mach-tegra/board-paz00.c
arch/arm/mach-tegra/board-trimslice.c
drivers/mmc/host/sdhci-tegra.c

Each of these files calls tegra_gpio_enable/tegra_gpio_disable, which flip the pin in/out of gpio mode. Including linux/gpio.h and mach/gpio.h was deliberate, so that when linux/gpio.h stops causing mach/gpio.h to be included, the tegra gpio apis are still available. Should I move the tegra gpio apis to a separate include and drop mach/gpio.h?

#6 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

Quoted 40 lines · Colin Cross
Quoted 24 lines · Russell King - ARM Linux
Quoted 3 lines · Russell King - ARM Linux

Hmm, yet another trivial gpio implementation. ?We have 24 others just like this. ?Well, mainline does... I have just one. ?Patches after the merge window closes.

As an additional note to this: we _really_ need to get on top of the includes of mach/gpio.h rather than linux/gpio.h - there are around 139 files in mainline (this morning) which include mach/gpio.h directly.

There's one which includes both asm/gpio.h and mach/gpio.h, which is silly when you look at what asm/gpio.h contains - maybe one attempt to include mach/gpio.h wasn't enough!

These includes get in the way of consolidating stuff out of mach/gpio.h into asm/gpio.h - moving stuff out of mach/gpio.h could take it out of view of these files, thereby causing build errors.

What is even less clear is whether changing these mach/gpio.h includes to linux/gpio.h is correct or not.

So, what I'd like all platform and all soc maintainers to do is to:

? ? ? ?grep -rl '<mach/gpio.h>' arch/arm drivers

Quoted 7 lines

and investigate their files from that list which they're responsible for, and submit patches to _me_ to fix these includes up (preferably to use linux/gpio.h). ?I'd also like them to do a better job at spotting these while reviewing patches on the list to help reduce new occurances of this.

Thanks.

Tegra has four uses of mach/gpio.h:
arch/arm/mach-tegra/board-trimslice-pinmux.c
arch/arm/mach-tegra/board-paz00.c
arch/arm/mach-tegra/board-trimslice.c
drivers/mmc/host/sdhci-tegra.c

Quoted 6 lines

Each of these files calls tegra_gpio_enable/tegra_gpio_disable, which flip the pin in/out of gpio mode. Including linux/gpio.h and mach/gpio.h was deliberate, so that when linux/gpio.h stops causing mach/gpio.h to be included, the tegra gpio apis are still available. Should I move the tegra gpio apis to a separate include and drop mach/gpio.h?

I don't think there's any plans to break the:

linux/gpio.h -> asm/gpio.h -> mach/gpio.h

include path at the moment, as platforms do define ARCH_NR_GPIO, which has to be done before asm-generic/gpiolib.h is included.

The problem which is there at the moment is that moving stuff out of mach/gpio.h is *dangerous* because soo much stuff includes mach/gpio.h, it's impossible to tell whether moving stuff like gpio_set_value, gpio_get_value, etc into asm/gpio.h is going to break anything - and there's no way I can get sufficient coverage to check that.

So, the only way I can think of sorting this out is to forcefully change all mach/gpio.h to be linux/gpio.h first, before starting to migrate stuff out of mach/gpio.h.

What we may do later is make the include of mach/gpio.h conditional, and those platforms with their own specific stuff would continue to include that. Those which don't need mach/gpio.h can then live on without it.

#7 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

Quoted 6 lines · Russell King - ARM Linux

I don't think there's any plans to break the:

linux/gpio.h -> asm/gpio.h -> mach/gpio.h

include path at the moment, as platforms do define ARCH_NR_GPIO, which has to be done before asm-generic/gpiolib.h is included.

Well, this GPIO business is the biggest hurdle towards a single kernel image that can support multiple SOCs at the moment, and the only one for which I have no solution yet. Anything that could help removing mach/gpio.h from asm/gpio.h would be welcome.

Nicolas

#8 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

2011/7/27 Nicolas Pitre <[email protected]>:

Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines

I don't think there's any plans to break the:

linux/gpio.h -> asm/gpio.h -> mach/gpio.h

Quoted 7 lines
Quoted 2 lines

include path at the moment, as platforms do define ARCH_NR_GPIO, which has to be done before asm-generic/gpiolib.h is included.

Well, this GPIO business is the biggest hurdle towards a single kernel image that can support multiple SOCs at the moment, and the only one for which I have no solution yet. ?Anything that could help removing mach/gpio.h from asm/gpio.h would be welcome.

After reading all the following patches,

1. use CONFIG_PHYS_OFFSET to prepare for removal of a bunch of <mach/memory.h> files

2. move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

3. convert boot_params to atag_offset

Have i lost anything for the work on 1 and 2? considering some platforms need CONSISTENT_DMA_SIZE more than the default 2MB in arch/arm/include/asm/memory.h, we can't remove all memory.h only by defining CONFIG_PHYS_OFFSET and moving ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size. So CONSISTENT_DMA_SIZE should also be a left issue except gpio.h.

Quoted 9 lines

Nicolas

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#9 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

Quoted 22 lines · Barry Song

2011/7/27 Nicolas Pitre <[email protected]>:

Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines

I don't think there's any plans to break the:

linux/gpio.h -> asm/gpio.h -> mach/gpio.h

Quoted 7 lines
Quoted 2 lines

include path at the moment, as platforms do define ARCH_NR_GPIO, which has to be done before asm-generic/gpiolib.h is included.

Well, this GPIO business is the biggest hurdle towards a single kernel image that can support multiple SOCs at the moment, and the only one for which I have no solution yet. ?Anything that could help removing mach/gpio.h from asm/gpio.h would be welcome.

After reading all the following patches,

1. use CONFIG_PHYS_OFFSET to prepare for removal of a bunch of <mach/memory.h> files

2. move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

Quoted 8 lines

3. convert boot_params to atag_offset

Have i lost anything for the work on 1 and 2? considering some platforms need CONSISTENT_DMA_SIZE more than the default 2MB in arch/arm/include/asm/memory.h, we can't remove all memory.h only by defining CONFIG_PHYS_OFFSET and moving ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size. So CONSISTENT_DMA_SIZE should also be a left issue except gpio.h.

CONSISTENT_DMA_SIZE can be solved the same way as ARM_DMA_ZONE_SIZE, plus a few changes in dma-mapping.c to dynamically allocate the consistent_pte array.

But that's far from the end of it. In a nutshell:

- We have to get rid of mach/vmalloc.h (trivial)

- We have to kill every SOC specific definition for CLOCK_TICK_RATE and remove mach/timex.h.

- All mach/io.h need a similar refactoring.

- asm/irq.h must stop including mach/irqs.h, and everyone should initialize mdesc->nr_irqs

- mach/entry-macro.S should be translated into something that hooks to mdesc->handle_irq.

- mach/system.h content needs to be moved to out-of-line indirect calls.

- A multy-SOC kernel binary might not support CONFIG_DEBUG_LL out of the box.

- And there are a few odd cases we probably might not find sufficient motivation to fix them and simply exclude them from a single image config.

But there is mach/gpio.h which is the real bummer at the moment.

Nicolas

#10 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

In reply to Nicolas Pitre

2011/7/26 Nicolas Pitre <[email protected]>:

Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines

I don't think there's any plans to break the:

linux/gpio.h -> asm/gpio.h -> mach/gpio.h

Quoted 7 lines
Quoted 2 lines

include path at the moment, as platforms do define ARCH_NR_GPIO, which has to be done before asm-generic/gpiolib.h is included.

Well, this GPIO business is the biggest hurdle towards a single kernel image that can support multiple SOCs at the moment, and the only one for which I have no solution yet. ?Anything that could help removing mach/gpio.h from asm/gpio.h would be welcome.

I've been trying to address it somewhat by converting existing users to use struct gpio_chip and struct irq_chip.

However I ran into a brick wall as soon as an advanced GPIO controller such as those in U8500 or the OMAPs needed anything custom apart from what is done in the API in <linux/gpio.h>, such as configuring pin bias and muxing pins.

Different alternatives have been floated to LKML, also a post of two different approaches for patches resolving the issue in two different ways (see subject [PATCH 0/2] RFC:
gpio: driver-local pin configuration)

Due to lack of interest i.e. no ACKing nor NACKing of the patches, nor any approach being chosen by the subsystem maintainer, I'm mainly resting my case, intially we (me & Grant) planned to have a solution for this early in the 3.1 cycle but that has failed.

A third solution is to complete the pincfg subsystem that I'm working on and which will naturally (hopefully) split off the controversial parts of GPIO drivers. Sadly this will involve a bit of upfront overhead work :-/

Thanks,
Linus Walleij

#17 lore raw

RFC PATCH 2/2 GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller

In reply to Russell King - ARM Linux

2011/7/26 Russell King - ARM Linux <[email protected]>:

Quoted 32 lines · Barry Song
Quoted 18 lines
arch/arm/mach-prima2/include/mach/gpio.h new file +12 -0
new file mode 100644
index 0000000..25673b1
@@ -0,0 +1,34 @@
+/*
+ * arch/arm/mach-prima2/include/mach/gpio.h
+ *
+ * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
+ *
+ * Licensed under GPLv2 or later.
+ */
+
+#ifndef __MACH_GPIO_H
+#define __MACH_GPIO_H
+
+#include <mach/irqs.h>

arch/arm/mach-prima2/include/mach/gpio.h line 22

Quoted 10 lines
arch/arm/mach-prima2/include/mach/gpio.h new file +10 -0
+
+#ifndef CONFIG_GPIO_SIRFCPLD
+#define ARCH_NR_GPIOS ? ? ? ?(SIRFSOC_GPIO_BANK_SIZE * SIRFSOC_GPIO_NO_OF_BANKS)
+#else
+#define ARCH_NR_GPIOS ? ? ? ?(SIRFSOC_GPIO_BANK_SIZE * SIRFSOC_GPIO_NO_OF_BANKS + \
+ ? ? SIRFSOC_GPIO_CPLD_SIZE + SIRFSOC_GPIO_IO_CPLD_SIZE + \
+ ? ? SIRFSOC_GPIO_HS_CPLD_SIZE)
+#endif
+
+#include <linux/errno.h>

Why do you need linux/errno.h? ?asm-generic/gpio.h already includes this.

Quoted 8 lines

arch/arm/mach-prima2/include/mach/gpio.h line 27

Quoted 5 lines
arch/arm/mach-prima2/include/mach/gpio.h new file +5 -0
+#include <asm-generic/gpio.h>
+
+#define gpio_get_value ? ? ? __gpio_get_value
+#define gpio_set_value ? ? ? __gpio_set_value
+#define gpio_cansleep ? ? ? ?__gpio_cansleep

Hmm, yet another trivial gpio implementation. ?We have 24 others just like this. ?Well, mainline does... I have just one.

Ok.
this gpio driver includes two parts: gpio chip and irq chip. For gpio chip, we could import gpio-generic and delete sirfsoc_gpio_direction_input, sirfsoc_gpio_get_value, sirfsoc_gpio_direction_output and so on.
For the part of irq chip, i don't see much benefit from generic-irq. all of sirfsoc_gpio_irq_ack, sirfsoc_gpio_irq_mask and sirfsoc_gpio_irq_unmask are CSR-specific. irq_gc_ack_set_bit, irq_gc_mask_clr_bit and irq_gc_mask_set_bit are not practicable to this chip.

-barry

#18 lore raw

RFC PATCH 2/2 GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller

In reply to Russell King - ARM Linux

2011/7/26 Russell King - ARM Linux <[email protected]>:

Quoted 10 lines

[Barry]

Review

Quoted 5 lines
(quoted diff) +5 -0
+#include <asm-generic/gpio.h>
+
+#define gpio_get_value ? ? ? __gpio_get_value
+#define gpio_set_value ? ? ? __gpio_set_value
+#define gpio_cansleep ? ? ? ?__gpio_cansleep

Hmm, yet another trivial gpio implementation. ?We have 24 others just like this. ?Well, mainline does... I have just one. ?Patches after the merge window closes.

Hm, that sounds very good, now the merge window is closed, can you post them? Me and Ben have some stash of GPIO patches as well so we may just as well base them atop of your cleanup.

Thanks,
Linus Walleij

#11 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

In reply to Linus Walleij

2011/7/29 Linus Walleij <[email protected]>:

Quoted 15 lines

2011/7/26 Nicolas Pitre <[email protected]>:

Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines

I don't think there's any plans to break the:

linux/gpio.h -> asm/gpio.h -> mach/gpio.h

Quoted 7 lines
Quoted 2 lines

include path at the moment, as platforms do define ARCH_NR_GPIO, which has to be done before asm-generic/gpiolib.h is included.

Well, this GPIO business is the biggest hurdle towards a single kernel image that can support multiple SOCs at the moment, and the only one for which I have no solution yet. ?Anything that could help removing mach/gpio.h from asm/gpio.h would be welcome.

Quoted 7 lines

I've been trying to address it somewhat by converting existing users to use struct gpio_chip and struct irq_chip.

However I ran into a brick wall as soon as an advanced GPIO controller such as those in U8500 or the OMAPs needed anything custom apart from what is done in the API in <linux/gpio.h>, such as configuring pin bias and muxing pins.

The patch wants to eliminate the requirement of self-defined SoC-specific gpio APIs. The intent is that you want to delete files arch/arm/mach-xxx/include/mach/gpio.h.

I guess same issues exist for other hardwares except GPIO. For example, almost every different SoC has different DMA API, for example:
mach-bcmring/dma.c:EXPORT_SYMBOL(dma_alloc_descriptor_ring); mach-davinci/dma.c:EXPORT_SYMBOL(edma_alloc_channel); mach-davinci/dma.c:EXPORT_SYMBOL(edma_clear_event); mach-imx/dma-v1.c:EXPORT_SYMBOL(imx_dma_setup_single); mach-s3c64xx/dma.c:EXPORT_SYMBOL(s3c2410_dma_enqueue);

Do we also want to delete all arch/arm/mach-xxx/include/mach/dma.h?

Or do we want to delete the whole arch/arm/mach-xxx/include/mach directory?

If not, it is probably that SoC can still hold some chip-specific APIs in arch/arm/mach-xxx/include/mach/yyy.h.

Quoted 18 lines

Different alternatives have been floated to LKML, also a post of two different approaches for patches resolving the issue in two different ways (see subject [PATCH 0/2] RFC:
gpio: driver-local pin configuration)

Due to lack of interest i.e. no ACKing nor NACKing of the patches, nor any approach being chosen by the subsystem maintainer, I'm mainly resting my case, intially we (me & Grant) planned to have a solution for this early in the 3.1 cycle but that has failed.

A third solution is to complete the pincfg subsystem that I'm working on and which will naturally (hopefully) split off the controversial parts of GPIO drivers. Sadly this will involve a bit of upfront overhead work :-/

Thanks,
Linus Walleij

#12 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

Quoted 10 lines · Barry Song

I guess same issues exist for other hardwares except GPIO. For example, almost every different SoC has different DMA API, for example:
mach-bcmring/dma.c:EXPORT_SYMBOL(dma_alloc_descriptor_ring); mach-davinci/dma.c:EXPORT_SYMBOL(edma_alloc_channel); mach-davinci/dma.c:EXPORT_SYMBOL(edma_clear_event); mach-imx/dma-v1.c:EXPORT_SYMBOL(imx_dma_setup_single); mach-s3c64xx/dma.c:EXPORT_SYMBOL(s3c2410_dma_enqueue);

Do we also want to delete all arch/arm/mach-xxx/include/mach/dma.h?

We need to eliminate all header files that have conflicting names and that are used by drivers or other header files outside of mach-*. How we get there is very different for each of these headers.

Quoted 1 line

Or do we want to delete the whole arch/arm/mach-xxx/include/mach directory?

Ideally, yes. However, that will take a lot of time. Meanwhile, we should rename the individual header files to have unique names for each API, and ensure that the symbols don't clash.

Quoted 2 lines

If not, it is probably that SoC can still hold some chip-specific APIs in arch/arm/mach-xxx/include/mach/yyy.h.

Can you name an example? Most of the ones I can think of will not work in a multiplatform kernel.

Arnd

#13 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

2011/8/9 Arnd Bergmann <[email protected]>:

Quoted 10 lines · Barry Song
Quoted 9 lines

I guess same issues exist for other hardwares except GPIO. For example, almost every different SoC has different DMA API, for example:
mach-bcmring/dma.c:EXPORT_SYMBOL(dma_alloc_descriptor_ring); mach-davinci/dma.c:EXPORT_SYMBOL(edma_alloc_channel); mach-davinci/dma.c:EXPORT_SYMBOL(edma_clear_event); mach-imx/dma-v1.c:EXPORT_SYMBOL(imx_dma_setup_single); mach-s3c64xx/dma.c:EXPORT_SYMBOL(s3c2410_dma_enqueue);

Quoted 5 lines
Quoted 1 line

Do we also want to delete all arch/arm/mach-xxx/include/mach/dma.h?

We need to eliminate all header files that have conflicting names and that are used by drivers or other header files outside of mach-*. How we get there is very different for each of these headers.

now every SoCs have different DMA APIs due to different DMA controller:

1. Tegra(dma has a queue with enqueue and dequeue API):
int tegra_dma_enqueue_req(struct tegra_dma_channel *ch,

        struct tegra_dma_req *req);
int tegra_dma_dequeue_req(struct tegra_dma_channel *ch,
        struct tegra_dma_req *req);

void tegra_dma_dequeue(struct tegra_dma_channel *ch); void tegra_dma_flush(struct tegra_dma_channel *ch);

bool tegra_dma_is_req_inflight(struct tegra_dma_channel *ch,

        struct tegra_dma_req *req);

bool tegra_dma_is_empty(struct tegra_dma_channel *ch);

struct tegra_dma_channel *tegra_dma_allocate_channel(int mode); void tegra_dma_free_channel(struct tegra_dma_channel *ch);

2. samsung(with queue and request/free, ctrl):
/* s3c2410_dma_request
*
* request a dma channel exclusivley
*/

extern int s3c2410_dma_request(enum dma_ch channel,

                               struct s3c2410_dma_client *, void *dev);

/* s3c2410_dma_ctrl
*
* change the state of the dma channel
*/

extern int s3c2410_dma_ctrl(enum dma_ch channel, enum s3c2410_chan_op op);

/* s3c2410_dma_setflags
*
* set the channel's flags to a given state
*/

extern int s3c2410_dma_setflags(enum dma_ch channel,

                                unsigned int flags);

/* s3c2410_dma_free
*
* free the dma channel (will also abort any outstanding operations)
*/

extern int s3c2410_dma_free(enum dma_ch channel, struct s3c2410_dma_client *);

/* s3c2410_dma_enqueue
*
* place the given buffer onto the queue of operations for the channel.
* The buffer must be allocated from dma coherent memory, or the Dcache/WB
* drained before the buffer is given to the DMA system.

*/

extern int s3c2410_dma_enqueue(enum dma_ch channel, void *id,

                               dma_addr_t data, int size);

/* s3c2410_dma_config
*
* configure the dma channel
*/

extern int s3c2410_dma_config(enum dma_ch channel, int xferunit);

3. PXA(pretty simple)
int __init pxa_init_dma(int irq, int num_ch);

int pxa_request_dma (char *name,

                         pxa_dma_prio prio,
                         void (*irq_handler)(int, void *),
                         void *data);

void pxa_free_dma (int dma_ch);

4. qualcomm msm(with queue cmd and exec cmd):
void msm_dmov_enqueue_cmd(unsigned id, struct msm_dmov_cmd *cmd); void msm_dmov_stop_cmd(unsigned id, struct msm_dmov_cmd *cmd, int graceful); int msm_dmov_exec_cmd(unsigned id, unsigned int cmdptr);

5. TI omap(with request/free/enable/param config/mode set....) extern void omap_set_dma_priority(int lch, int dst_port, int priority); extern int omap_request_dma(int dev_id, const char *dev_name,
void (*callback)(int lch, u16 ch_status, void *data), void *data, int *dma_ch);
extern void omap_enable_dma_irq(int ch, u16 irq_bits);
extern void omap_disable_dma_irq(int ch, u16 irq_bits);
extern void omap_free_dma(int ch);
extern void omap_start_dma(int lch);
extern void omap_stop_dma(int lch);
extern void omap_set_dma_transfer_params(int lch, int data_type,
int elem_count, int frame_count, int sync_mode,
int dma_trigger, int src_or_dst_synch);
extern void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode,

                                    u32 color);

extern void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode); extern void omap_set_dma_channel_mode(int lch, enum omap_dma_channel_mode mode);

extern void omap_set_dma_src_params(int lch, int src_port, int src_amode,
unsigned long src_start, int src_ei, int src_fi);
extern void omap_set_dma_src_index(int lch, int eidx, int fidx); extern void omap_set_dma_src_data_pack(int lch, int enable); extern void omap_set_dma_src_burst_mode(int lch,

                                        enum omap_dma_burst_mode burst_mode);

extern void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,
unsigned long dest_start, int dst_ei, int dst_fi);
extern void omap_set_dma_dest_index(int lch, int eidx, int fidx); extern void omap_set_dma_dest_data_pack(int lch, int enable); extern void omap_set_dma_dest_burst_mode(int lch,

we might figure out some common DMA API framework so that all SoCs can use. i think:

group1 : request/free/enable/disable/set_mode/set_priority are common to all, but set_mode/set_priority can be empty.

group2:  enqueue/dequeue  are common to DMAC with queues
group3:  many param configurations.
group4:  other DMA controller with special work mode which can't be

covered by group1-3.
for example, prima2 has a 2D dma controller, In 2-D DMA, the system memory space is interpreted as a 2-D layout instead of a linear 1-D layout. More specifically, the system memory can be considered as multiple data lines. The length of the data line is determined by the user-selected DMA_WIDTH register. The user can specify a data window that the user wants to access using four parameters:
? Start address
? X length
? Y length
? Width

we might also want a dma_chip with many callbacks like gpio and irq, then move all dma drivers to drivers/dma just like Linus W is moving all gpio drivers to drivers/gpio. How do you think?

Quoted 7 lines
Quoted 2 lines

Or do we want to delete the whole arch/arm/mach-xxx/include/mach directory?

Ideally, yes. However, that will take a lot of time. Meanwhile, we should rename the individual header files to have unique names for each API, and ensure that the symbols don't clash.

Quoted 5 lines
Quoted 2 lines

If not, it is probably that SoC can still hold some chip-specific APIs in arch/arm/mach-xxx/include/mach/yyy.h.

Can you name an example? Most of the ones I can think of will not work in a multiplatform kernel.

as i have posted the sirfsoc rtciobrg, we can't read rtc and pm controller directly since they are not in memory space and any one of i2c/spi/usb/pci busses, and we are reading them by the following strange APIs indirectly:
extern void sirfsoc_rtc_iobrg_besyncing(void);
extern u32 sirfsoc_rtc_iobrg_readl(u32 addr);
extern void sirfsoc_rtc_iobrg_writel(u32 val, u32 addr); now i have placed these APIs in a head file include/linux/rtc/sirfsoc_rtciobrg.h not in arch/arm/mach-prima2/include/mach considering we are tending to delete the dir.

Quoted 3 lines

? ? ? ?Arnd

-barry

#14 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

Quoted 1 line · Barry Song

now every SoCs have different DMA APIs due to different DMA controller:

We already have a solution to this. It's called dmaengine. See drivers/dma, include/linux/dmaengine.h and Documentation/dmaengine.txt There is work going on at present to convert the OMAP and Samsung SoC specific DMA support to dmaengine.

#15 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

In reply to Arnd Bergmann
Quoted 4 lines · Barry Song

Or do we want to delete the whole arch/arm/mach-xxx/include/mach directory?

If not, it is probably that SoC can still hold some chip-specific APIs in arch/arm/mach-xxx/include/mach/yyy.h.

I was actually proposing patches that moved GPIO headers from <mach/foo-gpio> to <linux/gpio/foo.h> but they were NAK:ed or frowned upon, so I guess we're keeping the <mach/*> include union namespace for machine/SoC-specific headers.

Now we just try to make files in this namespace have unqiue names.

Yours,
Linus Walleij

#16 lore raw

PLEA: Please fix mach/gpio.h includes (was: Re: [RFC PATCH 2/2] GPIO: add gpiolib and irqchip for CSR SiRFprimaII GPIO controller)

Quoted 7 lines · Linus Walleij
Quoted 4 lines · Barry Song

Or do we want to delete the whole arch/arm/mach-xxx/include/mach directory?

If not, it is probably that SoC can still hold some chip-specific APIs in arch/arm/mach-xxx/include/mach/yyy.h.

Quoted 7 lines

I was actually proposing patches that moved GPIO headers from <mach/foo-gpio> to <linux/gpio/foo.h> but they were NAK:ed or frowned upon, so I guess we're keeping the <mach/*> include union namespace for machine/SoC-specific headers.

Now we just try to make files in this namespace have unqiue names.

That doesn't really sound like a long-term solution. I think the idea for the single-zimage work is to eventually make the mach/ headers local to the mach-* directory so they cannot be included from any device drivers at all.

For any constants in those headers, they should be communicated to the drivers using the platform data or (better) device tree information.

The platform specific APIs that you mentioned are a bigger problem, and I think the focus for those should be on avoiding them with proper generic infrastructure and having only selected interfaces exported through asm/*.h or linux/*.h where that is not an option.

Arnd