From: David Brown <davidb@codeaurora.org>
To: David Brown <davidb@codeaurora.org>,
Daniel Walker <dwalker@fifo99.com>,
Bryan Huntsman <bryanh@codeaurora.org>,
Russell King <linux@arm.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Grant Likely <grant.likely@secretlab.ca>
Subject: [PATCH v3 4/8] msm: gpio: Remove ifdefs on gpio chip registers
Date: Mon, 6 Jun 2011 14:51:11 -0700 [thread overview]
Message-ID: <1307397075-11733-5-git-send-email-davidb@codeaurora.org> (raw)
In-Reply-To: <1307397075-11733-1-git-send-email-davidb@codeaurora.org>
Select the GPIO register configuration at runtime rather than through
idefs.
Signed-off-by: David Brown <davidb@codeaurora.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
---
arch/arm/mach-msm/gpio.c | 33 ++++++++++++++++++++++++++-------
1 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-msm/gpio.c b/arch/arm/mach-msm/gpio.c
index 335afbd..e96199d 100644
--- a/arch/arm/mach-msm/gpio.c
+++ b/arch/arm/mach-msm/gpio.c
@@ -20,6 +20,7 @@
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/module.h>
+#include <mach/cpu.h>
#include "gpio_hw.h"
#include "gpiomux.h"
@@ -189,15 +190,19 @@ static void msm_gpio_free(struct gpio_chip *chip, unsigned offset)
#define msm_gpio_free NULL
#endif
-struct msm_gpio_chip msm_gpio_chips[] = {
-#if defined(CONFIG_ARCH_MSM7X00A)
+static struct msm_gpio_chip *msm_gpio_chips;
+static int msm_gpio_count;
+
+static struct msm_gpio_chip msm_gpio_chips_msm7x01[] = {
MSM_GPIO_BANK(MSM7X00, 0, 0, 15),
MSM_GPIO_BANK(MSM7X00, 1, 16, 42),
MSM_GPIO_BANK(MSM7X00, 2, 43, 67),
MSM_GPIO_BANK(MSM7X00, 3, 68, 94),
MSM_GPIO_BANK(MSM7X00, 4, 95, 106),
MSM_GPIO_BANK(MSM7X00, 5, 107, 121),
-#elif defined(CONFIG_ARCH_MSM7X30)
+};
+
+static struct msm_gpio_chip msm_gpio_chips_msm7x30[] = {
MSM_GPIO_BANK(MSM7X30, 0, 0, 15),
MSM_GPIO_BANK(MSM7X30, 1, 16, 43),
MSM_GPIO_BANK(MSM7X30, 2, 44, 67),
@@ -206,7 +211,9 @@ struct msm_gpio_chip msm_gpio_chips[] = {
MSM_GPIO_BANK(MSM7X30, 5, 107, 133),
MSM_GPIO_BANK(MSM7X30, 6, 134, 150),
MSM_GPIO_BANK(MSM7X30, 7, 151, 181),
-#elif defined(CONFIG_ARCH_QSD8X50)
+};
+
+static struct msm_gpio_chip msm_gpio_chips_qsd8x50[] = {
MSM_GPIO_BANK(QSD8X50, 0, 0, 15),
MSM_GPIO_BANK(QSD8X50, 1, 16, 42),
MSM_GPIO_BANK(QSD8X50, 2, 43, 67),
@@ -215,7 +222,6 @@ struct msm_gpio_chip msm_gpio_chips[] = {
MSM_GPIO_BANK(QSD8X50, 5, 104, 121),
MSM_GPIO_BANK(QSD8X50, 6, 122, 152),
MSM_GPIO_BANK(QSD8X50, 7, 153, 164),
-#endif
};
static void msm_gpio_irq_ack(struct irq_data *d)
@@ -311,7 +317,7 @@ static void msm_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
int i, j, mask;
unsigned val;
- for (i = 0; i < ARRAY_SIZE(msm_gpio_chips); i++) {
+ for (i = 0; i < msm_gpio_count; i++) {
struct msm_gpio_chip *msm_chip = &msm_gpio_chips[i];
val = readl(msm_chip->regs.int_status);
val &= msm_chip->int_enable[0];
@@ -342,6 +348,19 @@ static int __init msm_init_gpio(void)
{
int i, j = 0;
+ if (cpu_is_msm7x01()) {
+ msm_gpio_chips = msm_gpio_chips_msm7x01;
+ msm_gpio_count = ARRAY_SIZE(msm_gpio_chips_msm7x01);
+ } else if (cpu_is_msm7x30()) {
+ msm_gpio_chips = msm_gpio_chips_msm7x30;
+ msm_gpio_count = ARRAY_SIZE(msm_gpio_chips_msm7x30);
+ } else if (cpu_is_qsd8x50()) {
+ msm_gpio_chips = msm_gpio_chips_qsd8x50;
+ msm_gpio_count = ARRAY_SIZE(msm_gpio_chips_qsd8x50);
+ } else {
+ return 0;
+ }
+
for (i = FIRST_GPIO_IRQ; i < FIRST_GPIO_IRQ + NR_GPIO_IRQS; i++) {
if (i - FIRST_GPIO_IRQ >=
msm_gpio_chips[j].chip.base +
@@ -353,7 +372,7 @@ static int __init msm_init_gpio(void)
set_irq_flags(i, IRQF_VALID);
}
- for (i = 0; i < ARRAY_SIZE(msm_gpio_chips); i++) {
+ for (i = 0; i < msm_gpio_count; i++) {
spin_lock_init(&msm_gpio_chips[i].lock);
writel(0, msm_gpio_chips[i].regs.int_en);
gpiochip_add(&msm_gpio_chips[i].chip);
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
next prev parent reply other threads:[~2011-06-06 21:53 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 21:50 [PATCH 0/7] Move Qualcomm gpio drivers into drivers dir David Brown
2011-05-18 21:50 ` [PATCH 1/7] msm: gpio: Remove unsupported devices David Brown
2011-05-18 21:50 ` [PATCH 2/7] msm: Remove chip-ifdefs for GPIO io mappings David Brown
2011-05-18 21:50 ` [PATCH 3/7] msm: gpio: Remove chip-specific register definitions David Brown
2011-05-18 21:50 ` [PATCH 4/7] msm: gpio: Remove ifdefs on gpio chip registers David Brown
2011-05-18 21:50 ` [PATCH 5/7] msm: gpiomux: Move public API to public header David Brown
2011-05-18 22:44 ` H Hartley Sweeten
2011-05-18 23:06 ` David Brown
2011-05-18 21:50 ` [PATCH 6/7] gpio_msm: Move Qualcomm v6 MSM driver into drivers David Brown
2011-05-18 21:50 ` [PATCH 7/7] gpio_msm: Move Qualcomm MSM v2 gpio " David Brown
2011-05-18 22:35 ` Stephen Boyd
2011-05-18 22:43 ` David Brown
2011-05-18 22:25 ` [PATCH 0/7] Move Qualcomm gpio drivers into drivers dir Linus Walleij
2011-05-19 19:34 ` Nicolas Pitre
2011-05-27 3:13 ` Grant Likely
2011-05-27 16:29 ` David Brown
2011-05-27 16:35 ` David Brown
2011-05-27 19:31 ` Nicolas Pitre
2011-05-27 21:19 ` David Brown
2011-06-03 22:44 ` [PATCH v2 " David Brown
2011-06-03 22:44 ` [PATCH v2 1/7] msm: gpio: Remove unsupported devices David Brown
2011-06-03 22:44 ` [PATCH v2 2/7] msm: Remove chip-ifdefs for GPIO io mappings David Brown
2011-06-03 22:44 ` [PATCH v2 3/7] msm: gpio: Remove chip-specific register definitions David Brown
2011-06-03 22:44 ` [PATCH v2 4/7] msm: gpio: Remove ifdefs on gpio chip registers David Brown
2011-06-03 22:44 ` [PATCH v2 5/7] msm: gpiomux: Move public API to public header David Brown
2011-06-03 22:44 ` [PATCH v2 6/7] gpio_msm: Move Qualcomm v6 MSM driver into drivers David Brown
2011-06-04 6:44 ` Grant Likely
2011-06-03 22:44 ` [PATCH v2 7/7] gpio_msm: Move Qualcomm MSM v2 gpio " David Brown
2011-06-04 6:45 ` Grant Likely
2011-06-04 0:15 ` [PATCH v2 0/7] Move Qualcomm gpio drivers into drivers dir David Brown
2011-06-06 21:51 ` [PATCH v3 0/8] " David Brown
2011-06-06 21:51 ` [PATCH v3 1/8] msm: gpio: Remove unsupported devices David Brown
2011-06-06 21:51 ` [PATCH v3 2/8] msm: Remove chip-ifdefs for GPIO io mappings David Brown
2011-06-06 21:51 ` [PATCH v3 3/8] msm: gpio: Remove chip-specific register definitions David Brown
2011-06-06 21:51 ` David Brown [this message]
2011-06-06 21:51 ` [PATCH v3 5/8] msm: gpiomux: Move public API to public header David Brown
2011-06-06 21:51 ` [PATCH v3 6/8] msm: gpio: Fold register defs into C file David Brown
2011-06-06 21:51 ` [PATCH v3 7/8] gpio_msm: Move Qualcomm v6 MSM driver into drivers David Brown
2011-06-06 21:51 ` [PATCH v3 8/8] gpio_msm: Move Qualcomm MSM v2 gpio " David Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1307397075-11733-5-git-send-email-davidb@codeaurora.org \
--to=davidb@codeaurora.org \
--cc=bryanh@codeaurora.org \
--cc=dwalker@fifo99.com \
--cc=grant.likely@secretlab.ca \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).