From: swarren@wwwdotorg.org (Stephen Warren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/11] gpio: tegra: fix register address calculations for Tegra30
Date: Fri, 30 Mar 2012 16:59:56 -0600 [thread overview]
Message-ID: <1333148404-17691-4-git-send-email-swarren@wwwdotorg.org> (raw)
In-Reply-To: <1333148404-17691-1-git-send-email-swarren@wwwdotorg.org>
From: Stephen Warren <swarren@nvidia.com>
Tegra20 and Tegra30 share the same register layout within registers, but
the addresses of the registers is a little different. Fix the driver to
cope with this.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
drivers/gpio/gpio-tegra.c | 55 ++++++++++++++++++++++++++++++++++----------
1 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 32de670..7d05a34 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -22,7 +22,7 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/gpio.h>
-#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/irqdomain.h>
@@ -37,7 +37,8 @@
#define GPIO_PORT(x) (((x) >> 3) & 0x3)
#define GPIO_BIT(x) ((x) & 0x7)
-#define GPIO_REG(x) (GPIO_BANK(x) * 0x80 + GPIO_PORT(x) * 4)
+#define GPIO_REG(x) (GPIO_BANK(x) * tegra_gpio_bank_stride + \
+ GPIO_PORT(x) * 4)
#define GPIO_CNF(x) (GPIO_REG(x) + 0x00)
#define GPIO_OE(x) (GPIO_REG(x) + 0x10)
@@ -48,12 +49,12 @@
#define GPIO_INT_LVL(x) (GPIO_REG(x) + 0x60)
#define GPIO_INT_CLR(x) (GPIO_REG(x) + 0x70)
-#define GPIO_MSK_CNF(x) (GPIO_REG(x) + 0x800)
-#define GPIO_MSK_OE(x) (GPIO_REG(x) + 0x810)
-#define GPIO_MSK_OUT(x) (GPIO_REG(x) + 0X820)
-#define GPIO_MSK_INT_STA(x) (GPIO_REG(x) + 0x840)
-#define GPIO_MSK_INT_ENB(x) (GPIO_REG(x) + 0x850)
-#define GPIO_MSK_INT_LVL(x) (GPIO_REG(x) + 0x860)
+#define GPIO_MSK_CNF(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x00)
+#define GPIO_MSK_OE(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x10)
+#define GPIO_MSK_OUT(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0X20)
+#define GPIO_MSK_INT_STA(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x40)
+#define GPIO_MSK_INT_ENB(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x50)
+#define GPIO_MSK_INT_LVL(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x60)
#define GPIO_INT_LVL_MASK 0x010101
#define GPIO_INT_LVL_EDGE_RISING 0x000101
@@ -78,6 +79,8 @@ struct tegra_gpio_bank {
static struct irq_domain *irq_domain;
static void __iomem *regs;
static u32 tegra_gpio_bank_count;
+static u32 tegra_gpio_bank_stride;
+static u32 tegra_gpio_upper_offset;
static struct tegra_gpio_bank *tegra_gpio_banks;
static inline void tegra_gpio_writel(u32 val, u32 reg)
@@ -333,6 +336,26 @@ static struct irq_chip tegra_gpio_irq_chip = {
#endif
};
+struct tegra_gpio_soc_config {
+ u32 bank_stride;
+ u32 upper_offset;
+};
+
+static struct tegra_gpio_soc_config tegra20_gpio_config = {
+ .bank_stride = 0x80,
+ .upper_offset = 0x800,
+};
+
+static struct tegra_gpio_soc_config tegra30_gpio_config = {
+ .bank_stride = 0x100,
+ .upper_offset = 0x80,
+};
+
+static struct of_device_id tegra_gpio_of_match[] __devinitdata = {
+ { .compatible = "nvidia,tegra30-gpio", .data = &tegra30_gpio_config },
+ { .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config },
+ { },
+};
/* This lock class tells lockdep that GPIO irqs are in a different
* category than their parents, so it won't report false recursion.
@@ -341,6 +364,8 @@ static struct lock_class_key gpio_lock_class;
static int __devinit tegra_gpio_probe(struct platform_device *pdev)
{
+ const struct of_device_id *match;
+ struct tegra_gpio_soc_config *config;
int irq_base;
struct resource *res;
struct tegra_gpio_bank *bank;
@@ -348,6 +373,15 @@ static int __devinit tegra_gpio_probe(struct platform_device *pdev)
int i;
int j;
+ match = of_match_device(tegra_gpio_of_match, &pdev->dev);
+ if (match)
+ config = (struct tegra_gpio_soc_config *)match->data;
+ else
+ config = &tegra20_gpio_config;
+
+ tegra_gpio_bank_stride = config->bank_stride;
+ tegra_gpio_upper_offset = config->upper_offset;
+
for (;;) {
res = platform_get_resource(pdev, IORESOURCE_IRQ, tegra_gpio_bank_count);
if (!res)
@@ -441,11 +475,6 @@ static int __devinit tegra_gpio_probe(struct platform_device *pdev)
return 0;
}
-static struct of_device_id tegra_gpio_of_match[] __devinitdata = {
- { .compatible = "nvidia,tegra20-gpio", },
- { },
-};
-
static struct platform_driver tegra_gpio_driver = {
.driver = {
.name = "tegra-gpio",
--
1.7.0.4
next prev parent reply other threads:[~2012-03-30 22:59 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-30 22:59 [PATCH 00/11] ARM: tegra: GPIO and pinmux-related changes Stephen Warren
2012-03-30 22:59 ` [PATCH 01/11] usb: ehci-tegra: Add vbus_gpio to platform data Stephen Warren
2012-04-04 17:51 ` Olof Johansson
2012-03-30 22:59 ` [PATCH 02/11] ARM: tegra: Remove VBUS_GPIO handling from board files Stephen Warren
2012-04-04 17:52 ` Olof Johansson
2012-03-30 22:59 ` Stephen Warren [this message]
2012-04-04 17:57 ` [PATCH 03/11] gpio: tegra: fix register address calculations for Tegra30 Olof Johansson
2012-04-04 18:53 ` Stephen Warren
2012-04-04 18:57 ` Olof Johansson
2012-03-30 22:59 ` [PATCH 04/11] gpio: tegra: Iterate over the correct number of banks Stephen Warren
2012-04-04 17:58 ` Olof Johansson
2012-04-04 18:41 ` Stephen Warren
2012-04-04 18:59 ` Olof Johansson
2012-03-30 22:59 ` [PATCH 05/11] gpio: tegra: configure pins during irq_set_type Stephen Warren
2012-04-04 17:58 ` Olof Johansson
2012-03-30 22:59 ` [PATCH 06/11] ARM: tegra: seaboard: Don't gpio_request() ISL29018_IRQ Stephen Warren
2012-04-04 17:59 ` Olof Johansson
2012-03-30 23:00 ` [PATCH 07/11] gpio: tegra: Hide tegra_gpio_enable/disable() Stephen Warren
2012-04-01 4:32 ` Chris Ball
2012-04-01 9:54 ` Linus Walleij
2012-04-04 18:01 ` Olof Johansson
2012-04-09 1:09 ` Chris Ball
2012-03-30 23:00 ` [PATCH 08/11] ARM: tegra: Switch to new pinctrl driver Stephen Warren
2012-04-03 20:49 ` Linus Walleij
2012-04-04 18:49 ` Olof Johansson
2012-03-30 23:00 ` [PATCH 09/11] ARM: tegra: Remove pre-pinctrl pinmux driver Stephen Warren
2012-03-30 23:00 ` [PATCH 10/11] ARM: dt: tegra cardhu: add pinmux to device tree Stephen Warren
2012-04-04 18:52 ` Olof Johansson
2012-03-30 23:00 ` [PATCH 11/11] ARM: dt: tegra20: " Stephen Warren
2012-04-03 20:51 ` Linus Walleij
2012-04-04 19:14 ` Olof Johansson
2012-04-04 19:16 ` [PATCH 00/11] ARM: tegra: GPIO and pinmux-related changes Olof Johansson
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=1333148404-17691-4-git-send-email-swarren@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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).