Dove: add support for MPP configuration
cover Dove: add support for MPP configuration
These patches add support for multi-purpose pins configuration on Marvell Dove and enable use of GPIOs 64-71
Mike Rapoport (2):
[ARM] Dove: add support for GPIOs 64-71
[ARM] Dove: add support for multi-purpose pins configuration
arch/arm/mach-dove/Makefile | 2 +- arch/arm/mach-dove/include/mach/dove.h | 9 ++- arch/arm/mach-dove/include/mach/gpio.h | 6 +- arch/arm/mach-dove/mpp.c | 215 ++++++++++++++++++++++++++++++++ arch/arm/mach-dove/mpp.h | 214 +++++++++++++++++++++++++++++++ 5 files changed, 442 insertions(+), 4 deletions(-) create mode 100644 arch/arm/mach-dove/mpp.c create mode 100644 arch/arm/mach-dove/mpp.h
Signature · 1 line
1.7.3.1
PATCH 1/2 Dove: add support for GPIOs 64-71
--- arch/arm/mach-dove/include/mach/dove.h | 1 + arch/arm/mach-dove/include/mach/gpio.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-dove/include/mach/dove.h +1 -0
@@ -131,6 +131,7 @@#define DOVE_RESET_SAMPLE_LO (DOVE_MPP_VIRT_BASE | 0x014)#define DOVE_RESET_SAMPLE_HI (DOVE_MPP_VIRT_BASE | 0x018)#define DOVE_GPIO_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE | 0xd0400) +#define DOVE_GPIO2_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE | 0xe8400)#define DOVE_MPP_GENERAL_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE | 0xe803c)#define DOVE_AU1_SPDIFO_GPIO_EN (1 << 1)#define DOVE_NAND_GPIO_EN (1 << 0)
arch/arm/mach-dove/include/mach/gpio.h +4 -2
@@ -14,12 +14,14 @@#include <plat/gpio.h> #include <asm-generic/gpio.h> /* cansleep wrappers */ -#define GPIO_MAX 64 +#define GPIO_MAX 72#define GPIO_BASE_LO (DOVE_GPIO_VIRT_BASE + 0x00)#define GPIO_BASE_HI (DOVE_GPIO_VIRT_BASE + 0x20) -#define GPIO_BASE (pin) ((pin < 32) ? GPIO_BASE_LO : GPIO_BASE_HI) +#define GPIO_BASE (pin) ((pin < 32) ? GPIO_BASE_LO : \ + ((pin < 64) ? GPIO_BASE_HI : \ + DOVE_GPIO2_VIRT_BASE))#define GPIO_OUT (pin) (GPIO_BASE(pin) + 0x00)#define GPIO_IO_CONF (pin) (GPIO_BASE(pin) + 0x04)
Signature · 1 line
1.7.3.1
PATCH 2/2 Dove: add support for multi-purpose pins configuration
In reply to Mike Rapoport--- arch/arm/mach-dove/Makefile | 2 +- arch/arm/mach-dove/include/mach/dove.h | 8 +- arch/arm/mach-dove/mpp.c | 215 ++++++++++++++++++++++++++++++++ arch/arm/mach-dove/mpp.h | 214 +++++++++++++++++++++++++++++++ 4 files changed, 437 insertions(+), 2 deletions(-) create mode 100644 arch/arm/mach-dove/mpp.c create mode 100644 arch/arm/mach-dove/mpp.h
arch/arm/mach-dove/Makefile +1 -1
@@ -1,3 +1,3 @@ -obj-y += common.o addr-map.o irq.o pcie.o +obj-y += common.o addr-map.o irq.o pcie.o mpp.o obj-$(CONFIG_MACH_DOVE_DB) += dove-db-setup.o
arch/arm/mach-dove/include/mach/dove.h +7 -1
@@ -136,10 +136,16 @@#define DOVE_AU1_SPDIFO_GPIO_EN (1 << 1)#define DOVE_NAND_GPIO_EN (1 << 0)#define DOVE_MPP_CTRL4_VIRT_BASE (DOVE_GPIO_VIRT_BASE + 0x40) - +#define DOVE_SPI_GPIO_SEL (1 << 5) +#define DOVE_UART1_GPIO_SEL (1 << 4) +#define DOVE_AU1_GPIO_SEL (1 << 3) +#define DOVE_CAM_GPIO_SEL (1 << 2) +#define DOVE_SD1_GPIO_SEL (1 << 1) +#define DOVE_SD0_GPIO_SEL (1 << 0)/* Power Management */ #define DOVE_PMU_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE | 0xd0000) +#define DOVE_PMU_SIG_CTRL (DOVE_PMU_VIRT_BASE + 0x802c)/* Real Time Clock */ #define DOVE_RTC_PHYS_BASE (DOVE_SB_REGS_PHYS_BASE | 0xd8500)
arch/arm/mach-dove/mpp.c new file +215 -0
215 lines not on this page · raw message
arch/arm/mach-dove/mpp.h new file +214 -0
214 lines not on this page · raw message
Signature · 1 line
1.7.3.1
PATCH 2/2 Dove: add support for multi-purpose pins configuration
+static void dove_mpp_conf_grp(int num, int sel, u32 *mpp_ctrl) +{
+ int start = dove_mpp_grp[num].start;
+ int end = dove_mpp_grp[num].start;
Shouldn't that be dove_mpp_grp[num].end ?
saeed
PATCH 2/2 Dove: add support for multi-purpose pins configuration
Quoted 5 lines · Saeed Bishara
arch/arm/mach-dove/mpp.c new file +4
-0+static void dove_mpp_conf_grp (int num,int sel,u32 *mpp_ctrl) +{ +int start = dove_mpp_grp[num].start; +int end = dove_mpp_grp[num].start;Shouldn't that be dove_mpp_grp[num].end ?
oops.. thanks, will fix and resend
Quoted 1 line
saeed
Signature · 2 lines
Sincerely yours, Mike.
PATCH 2/2 Dove: add support for multi-purpose pins configuration
In reply to Mike RapoportQuoted 6 lines
+
+ ? ? ? ? ? ? ? shift = (num & 7) << 2;
+ ? ? ? ? ? ? ? if (*mpp_list&MPP_PMU_MASK) {
+ ? ? ? ? ? ? ? ? ? ? ?pmu_mpp_ctrl|= (0x1<< num);
+ ? ? ? ? ? ? ? ? ? ? ? pmu_sig_ctrl[num / 8] &= ~(0xf << shift);
+ ? ? ? ? ? ? ? ? ? ? ? pmu_sig_ctrl[num / 8] |= ~(0xf << shift);
the ~ in line hints something wrong
Quoted 6 lines
arch/arm/mach-dove/mpp.h new file +0
-0
arch/arm/mach-dove/mpp.h line 10
Quoted 10 lines
arch/arm/mach-dove/mpp.h new file +10
-0@@ -0,0 +1,214 @@ +#ifndef __ARCH_DOVE_MPP_CODED_H +#define __ARCH_DOVE_MPP_CODED_H + +#define MPP(_num, _mode, _pmu, _grp, _au1, _nfc) ( ? ? \ +/* MPP/group number */ ? ? ? ? ((_num) & 0xff) | ? ? ? ? ? ? ? \ +/* MPP select value */ ? ? ? ? (((_mode) & 0xf) << 8) | ? ? ? ?\ +/* MPP PMU */ ? ? ? ? ? ? ? ? ?((!!(_pmu)) << 12) | ? ? ? ? ? ?\ +/* group flag */ ? ? ? ? ? ? ? ((!!(_grp)) << 13) | ? ? ? ? ? ?\ +/* AU1 flag */ ? ? ? ? ? ? ? ? ((!!(_au1)) << 14) | ? ? ? ? ? ?\ +/* NFCE flag */ ? ? ? ? ? ? ? ? ? ? ? ?((!!(_nfc)) << 15))
in order to make these defines readable, I suggest to add defines for the flags, for example:
#define GROUP (1 << 13)
then MPP defines look like:
#define MPPX_GPIO MPP(MPP_X, 0x1, GROUP|AU1)
arch/arm/mach-dove/mpp.h line 14
Quoted 4 lines
arch/arm/mach-dove/mpp.h new file +4
-0+ +#define MPP20_GPIO20 ? ? ? ? ? MPP(20, 0x0, 0, 0, 0, 0) +#define MPP20_AC97_SYSCLK_OUT ?MPP(20, 0x1, 0, 0, 0, 0) +#define MPP20_SPI_2_MISO ? ? ? MPP(20, 0x2, 0, 0, 0, 0)
I'ld rather call this LCD_SPI instead of SPI_2 to make it clear that this SPI is different
PATCH 2/2 Dove: add support for multi-purpose pins configuration
Quoted 7 lines · saeed bishara
arch/arm/mach-dove/mpp.c line 192
Quoted 6 lines
arch/arm/mach-dove/mpp.c new file +6
-0+ + shift = (num &7 ) <<2 ; +if (*mpp_list &MPP_PMU_MASK ) { + pmu_mpp_ctrl |= (0x1 << num); + pmu_sig_ctrl[num /8 ] &= ~(0xf << shift); + pmu_sig_ctrl[num /8 ] |= ~(0xf << shift);the ~ in line hints something wrong
indeed :)
Quoted 21 lines
Quoted 6 lines
arch/arm/mach-dove/mpp.h new file +0
-0arch/arm/mach-dove/mpp.h line 10
Quoted 10 lines
arch/arm/mach-dove/mpp.h new file +10
-0@@ -0,0 +1,214 @@ +#ifndef __ARCH_DOVE_MPP_CODED_H +#define __ARCH_DOVE_MPP_CODED_H + +#define MPP (_num, _mode, _pmu, _grp, _au1, _nfc) ( \ +/* MPP/group number */ ((_num) &0xff ) | \ +/* MPP select value */ (((_mode) &0xf ) <<8 ) | \ +/* MPP PMU */ ((!!(_pmu)) <<12 ) | \ +/* group flag */ ((!!(_grp)) <<13 ) | \ +/* AU1 flag */ ((!!(_au1)) <<14 ) | \ +/* NFCE flag */ ((!!(_nfc)) << 15))in order to make these defines readable, I suggest to add defines for the flags, for example:
#define GROUP (1 << 13)
then MPP defines look like:
Quoted 1 line
#define
MPPX_GPIOMPP(MPP_X, 0x1, GROUP|AU1)
I think we can make it even more readable with
#define MPP_PIN(_num, _sel) MPP(_num, _sel, 0, 0, 0, 0)
#define MPP_GRP(_grp, _sel) MPP(_grp, _sel, 0, 1, 0, 0)
#define MPP_GRP_AU1(_sel) MPP(0, _sel, 0, 0, 1, 0)
#define MPP_GRP_NFC(_sel) MPP(0, _sel, 0, 0, 0, 1)
What do you think?
Quoted 7 lines
arch/arm/mach-dove/mpp.h line 143
Quoted 5 lines
arch/arm/mach-dove/mpp.h new file +4
-0+ +#define MPP20_GPIO20 MPP(20, 0x0, 0, 0, 0, 0) +#define MPP20_AC97_SYSCLK_OUT MPP(20, 0x1, 0, 0, 0, 0) +#define MPP20_SPI_2_MISO MPP(20, 0x2, 0, 0, 0, 0)I'ld rather call this
LCD_SPIinstead ofSPI_2to make it clear that this SPI is different
Signature · 2 lines
Sincerely yours, Mike.
PATCH 2/2 Dove: add support for multi-purpose pins configuration
Quoted 34 lines · Mike Rapoport
Quoted 7 lines · saeed bishara
Quoted 6 lines
+
+ ? ? ? ? ? ? ? shift = (num & 7) << 2;
+ ? ? ? ? ? ? ? if (*mpp_list&MPP_PMU_MASK) {
+ ? ? ? ? ? ? ? ? ? ? ?pmu_mpp_ctrl|= (0x1<< num);
+ ? ? ? ? ? ? ? ? ? ? ? pmu_sig_ctrl[num / 8] &= ~(0xf << shift);
+ ? ? ? ? ? ? ? ? ? ? ? pmu_sig_ctrl[num / 8] |= ~(0xf << shift);the ?~ in line hints something wrong
indeed :)
Quoted 21 lines
Quoted 6 lines
arch/arm/mach-dove/mpp.h new file +0
-0arch/arm/mach-dove/mpp.h line 10
Quoted 10 lines
arch/arm/mach-dove/mpp.h new file +10
-0@@ -0,0 +1,214 @@ +#ifndef __ARCH_DOVE_MPP_CODED_H +#define __ARCH_DOVE_MPP_CODED_H + +#define MPP(_num, _mode, _pmu, _grp, _au1, _nfc) ( ? ? \ +/* MPP/group number */ ? ? ? ? ((_num) & 0xff) | ? ? ? ? ? ? ? \ +/* MPP select value */ ? ? ? ? (((_mode) & 0xf) << 8) | ? ? ? ?\ +/* MPP PMU */ ? ? ? ? ? ? ? ? ?((!!(_pmu)) << 12) | ? ? ? ? ? ?\ +/* group flag */ ? ? ? ? ? ? ? ((!!(_grp)) << 13) | ? ? ? ? ? ?\ +/* AU1 flag */ ? ? ? ? ? ? ? ? ((!!(_au1)) << 14) | ? ? ? ? ? ?\ +/* NFCE flag */ ? ? ? ? ? ? ? ? ? ? ? ?((!!(_nfc)) << 15))in order to make these defines readable, I suggest to add defines for the flags, for example:
#define GROUP ? (1 << 13)
then MPP defines look like:Quoted 1 line
#define
MPPX_GPIO? ? ? ? ?MPP(MPP_X,0x1, GROUP|AU1)
Quoted 8 lines
I think we can make it even more readable with
#define
MPP_PIN(_num, _sel)? ?MPP(_num, _sel, 0, 0, 0, 0)#defineMPP_GRP(_grp, _sel)? ?MPP(_grp, _sel, 0, 1, 0, 0)#defineMPP_GRP_AU1(_sel)? ? ?MPP(0, _sel, 0, 0, 1, 0)#defineMPP_GRP_NFC(_sel)? ? ?MPP(0, _sel, 0, 0, 0, 1)What do you think?
when you have multiple flags in the MPP macro, people would think that those flags are not exlusive, in other words, mpp can have multiple flags. so I suggest you to use a type (gpr, au1, nfc or pmu).
Quoted 14 lines
Quoted 8 lines
arch/arm/mach-dove/mpp.h line 14
Quoted 6 lines
arch/arm/mach-dove/mpp.h new file +4
-0+ +#define MPP20_GPIO20 ? ? ? ? ? MPP(20, 0x0, 0, 0, 0, 0) +#define MPP20_AC97_SYSCLK_OUT ?MPP(20, 0x1, 0, 0, 0, 0) +#define MPP20_SPI_2_MISO ? ? ? MPP(20, 0x2, 0, 0, 0, 0)I'ld rather call this
LCD_SPIinstead ofSPI_2to make it clear that this SPI is different--
Sincerely yours,
Mike.
PATCH 2/2 Dove: add support for multi-purpose pins configuration
Quoted 42 lines · saeed bishara
Quoted 41 lines · Mike Rapoport
Quoted 7 lines · saeed bishara
Quoted 6 lines
+
+ ? ? ? ? ? ? ? shift = (num & 7) << 2;
+ ? ? ? ? ? ? ? if (*mpp_list&MPP_PMU_MASK) {
+ ? ? ? ? ? ? ? ? ? ? ?pmu_mpp_ctrl|= (0x1<< num);
+ ? ? ? ? ? ? ? ? ? ? ? pmu_sig_ctrl[num / 8] &= ~(0xf << shift);
+ ? ? ? ? ? ? ? ? ? ? ? pmu_sig_ctrl[num / 8] |= ~(0xf << shift);the ?~ in line hints something wrong
indeed :)
Quoted 21 lines
Quoted 6 lines
arch/arm/mach-dove/mpp.h new file +0
-0arch/arm/mach-dove/mpp.h line 10
Quoted 10 lines
arch/arm/mach-dove/mpp.h new file +10
-0@@ -0,0 +1,214 @@ +#ifndef __ARCH_DOVE_MPP_CODED_H +#define __ARCH_DOVE_MPP_CODED_H + +#define MPP(_num, _mode, _pmu, _grp, _au1, _nfc) ( ? ? \ +/* MPP/group number */ ? ? ? ? ((_num) & 0xff) | ? ? ? ? ? ? ? \ +/* MPP select value */ ? ? ? ? (((_mode) & 0xf) << 8) | ? ? ? ?\ +/* MPP PMU */ ? ? ? ? ? ? ? ? ?((!!(_pmu)) << 12) | ? ? ? ? ? ?\ +/* group flag */ ? ? ? ? ? ? ? ((!!(_grp)) << 13) | ? ? ? ? ? ?\ +/* AU1 flag */ ? ? ? ? ? ? ? ? ((!!(_au1)) << 14) | ? ? ? ? ? ?\ +/* NFCE flag */ ? ? ? ? ? ? ? ? ? ? ? ?((!!(_nfc)) << 15))in order to make these defines readable, I suggest to add defines for the flags, for example:
#define GROUP ? (1 << 13)
then MPP defines look like:Quoted 1 line
#define
MPPX_GPIO? ? ? ? ?MPP(MPP_X,0x1, GROUP|AU1)I think we can make it even more readable with
#define
MPP_PIN(_num, _sel)? ?MPP(_num, _sel, 0, 0, 0, 0)#defineMPP_GRP(_grp, _sel)? ?MPP(_grp, _sel, 0, 1, 0, 0)#defineMPP_GRP_AU1(_sel)? ? ?MPP(0, _sel, 0, 0, 1, 0)#defineMPP_GRP_NFC(_sel)? ? ?MPP(0, _sel, 0, 0, 0, 1)
Quoted 5 lines
Quoted 1 line
What do you think?
when you have multiple flags in the MPP macro, people would think that those flags are not exlusive, in other words, mpp can have multiple flags. so I suggest you to use a type (gpr, au1, nfc or pmu).
Hi Saeed,
I think it's a good idea to simplify the macros as Mike suggested, we are doing the same thing for PXA. There is actually another benefit of defining like that in addition to the readability, - it's less error-prone.
In practice, there is always a fixed combination of flags for a macro like MPPx_GPIO,
even if the flags are combinational.
I'm not that enthusiastic but it's something to think about.
PATCH 2/2 Dove: add support for multi-purpose pins configuration
Quoted 71 lines
-----Original Message-----
From: Eric Miao [mailto:eric.y.miao at gmail.com]
Sent: Wednesday, October 27, 2010 5:38 PM
To: saeed bishara
Cc: Mike Rapoport; Saeed Bishara; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH 2/2] [ARM] Dove: add support for multi-purpose pins configurationQuoted 1 line · saeed bishara
On Wed, Oct 27, 2010 at 4:30 PM, Mike Rapoport
Quoted 20 lines · <[email protected]> wrote:
Quoted 20 lines · saeed bishara
Quoted 7 lines
Quoted 6 lines
+
+ ? ? ? ? ? ? ? shift = (num & 7) << 2;
+ ? ? ? ? ? ? ? if (*mpp_list&MPP_PMU_MASK) {
+ ? ? ? ? ? ? ? ? ? ? ?pmu_mpp_ctrl|= (0x1<< num);
+ ? ? ? ? ? ? ? ? ? ? ? pmu_sig_ctrl[num / 8] &= ~(0xf << shift);
+ ? ? ? ? ? ? ? ? ? ? ? pmu_sig_ctrl[num / 8] |= ~(0xf << shift);the ?~ in line hints something wrong
indeed :)
Quoted 9 lines
Quoted 9 lines
arch/arm/mach-dove/mpp.h new file +3
-0@@ -0,0 +1,214 @@ +#ifndef __ARCH_DOVE_MPP_CODED_H +#define __ARCH_DOVE_MPP_CODED_H +Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-dove/mpp.h line 10
Quoted 7 lines
arch/arm/mach-dove/mpp.h new file +7
-0+#define MPP(_num, _mode, _pmu, _grp, _au1, _nfc) ( ? ? \ +/* MPP/group number */ ? ? ? ? ((_num) & 0xff) | ? ? ? ? ? ? ? \ +/* MPP select value */ ? ? ? ? (((_mode) & 0xf) << 8) | ? ? ? ?\ +/* MPP PMU */ ? ? ? ? ? ? ? ? ?((!!(_pmu)) << 12) | ? ? ? ? ? ?\ +/* group flag */ ? ? ? ? ? ? ? ((!!(_grp)) << 13) | ? ? ? ? ? ?\ +/* AU1 flag */ ? ? ? ? ? ? ? ? ((!!(_au1)) << 14) | ? ? ? ? ? ?\ +/* NFCE flag */ ? ? ? ? ? ? ? ? ? ? ? ?((!!(_nfc)) << 15))in order to make these defines readable, I suggest to add
defines for
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
the flags, for example:
#define GROUP ? (1 << 13)
then MPP defines look like:#define
MPPX_GPIO? ? ? ? ?MPP(MPP_X,0x1, GROUP|AU1)I think we can make it even more readable with
Quoted 7 lines
Quoted 6 lines
#define
MPP_PIN(_num, _sel)? ?MPP(_num, _sel, 0, 0, 0, 0)#defineMPP_GRP(_grp, _sel)? ?MPP(_grp, _sel, 0, 1, 0, 0)#defineMPP_GRP_AU1(_sel)? ? ?MPP(0, _sel, 0, 0, 1, 0)#defineMPP_GRP_NFC(_sel)? ? ?MPP(0, _sel, 0, 0, 0, 1)What do you think?
when you have multiple flags in the MPP macro, people would
think that
Quoted 3 lines
those flags are not exlusive, in other words, mpp can have multiple flags. so I suggest you to use a type (gpr, au1, nfc or pmu).
Hi Saeed,
I think it's a good idea to simplify the macros as Mike suggested, we are doing
the same thing for PXA. There is actually another benefit of defining like that
in addition to the readability, - it's less error-prone.
Quoted 5 lines
In practice, there is always a fixed combination of flags for a macro like
MPPx_GPIO,
even if the flags are combinational.I'm not that enthusiastic but it's something to think about.
Ok, Mike, go ahead with your latest suggestion.