* [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs
@ 2011-10-11 22:16 Stephen Warren
2011-10-11 22:16 ` [PATCH v4 2/4] arm/dt: Tegra: Add pinmux node to tegra20.dtsi Stephen Warren
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Stephen Warren @ 2011-10-11 22:16 UTC (permalink / raw)
To: linux-arm-kernel
The Tegra GPIO driver will be converted from static registration via
postcore_initcall() to be a platform device later in this patch series.
A new Tegra pinmux platform device will also be added.
Prepare for this by modifying all boards to register the appropriate
platform devices before-hand, so that when the drivers are converted,
those devices will be probed, and git bisectability will be maintained.
v2: Add resource definitions for GPIO and pinmux
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
arch/arm/mach-tegra/board-harmony-pinmux.c | 8 +++
arch/arm/mach-tegra/board-paz00-pinmux.c | 8 +++
arch/arm/mach-tegra/board-seaboard-pinmux.c | 9 ++-
arch/arm/mach-tegra/board-trimslice-pinmux.c | 7 ++
arch/arm/mach-tegra/devices.c | 84 ++++++++++++++++++++++++++
arch/arm/mach-tegra/devices.h | 2 +
6 files changed, 116 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-tegra/board-harmony-pinmux.c b/arch/arm/mach-tegra/board-harmony-pinmux.c
index 4d63e2e..e99b456 100644
--- a/arch/arm/mach-tegra/board-harmony-pinmux.c
+++ b/arch/arm/mach-tegra/board-harmony-pinmux.c
@@ -20,6 +20,7 @@
#include "gpio-names.h"
#include "board-harmony.h"
+#include "devices.h"
static struct tegra_pingroup_config harmony_pinmux[] = {
{TEGRA_PINGROUP_ATA, TEGRA_MUX_IDE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
@@ -140,6 +141,11 @@ static struct tegra_pingroup_config harmony_pinmux[] = {
{TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
};
+static struct platform_device *pinmux_devices[] = {
+ &tegra_gpio_device,
+ &tegra_pinmux_device,
+};
+
static struct tegra_gpio_table gpio_table[] = {
{ .gpio = TEGRA_GPIO_SD2_CD, .enable = true },
{ .gpio = TEGRA_GPIO_SD2_WP, .enable = true },
@@ -155,6 +161,8 @@ static struct tegra_gpio_table gpio_table[] = {
void harmony_pinmux_init(void)
{
+ platform_add_devices(pinmux_devices, ARRAY_SIZE(pinmux_devices));
+
tegra_pinmux_config_table(harmony_pinmux, ARRAY_SIZE(harmony_pinmux));
tegra_gpio_config(gpio_table, ARRAY_SIZE(gpio_table));
diff --git a/arch/arm/mach-tegra/board-paz00-pinmux.c b/arch/arm/mach-tegra/board-paz00-pinmux.c
index 2225769..fb20894 100644
--- a/arch/arm/mach-tegra/board-paz00-pinmux.c
+++ b/arch/arm/mach-tegra/board-paz00-pinmux.c
@@ -20,6 +20,7 @@
#include "gpio-names.h"
#include "board-paz00.h"
+#include "devices.h"
static struct tegra_pingroup_config paz00_pinmux[] = {
{TEGRA_PINGROUP_ATA, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
@@ -140,6 +141,11 @@ static struct tegra_pingroup_config paz00_pinmux[] = {
{TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
};
+static struct platform_device *pinmux_devices[] = {
+ &tegra_gpio_device,
+ &tegra_pinmux_device,
+};
+
static struct tegra_gpio_table gpio_table[] = {
{ .gpio = TEGRA_GPIO_SD1_CD, .enable = true },
{ .gpio = TEGRA_GPIO_SD1_WP, .enable = true },
@@ -152,6 +158,8 @@ static struct tegra_gpio_table gpio_table[] = {
void paz00_pinmux_init(void)
{
+ platform_add_devices(pinmux_devices, ARRAY_SIZE(pinmux_devices));
+
tegra_pinmux_config_table(paz00_pinmux, ARRAY_SIZE(paz00_pinmux));
tegra_gpio_config(gpio_table, ARRAY_SIZE(gpio_table));
diff --git a/arch/arm/mach-tegra/board-seaboard-pinmux.c b/arch/arm/mach-tegra/board-seaboard-pinmux.c
index 74f78b7..f092298 100644
--- a/arch/arm/mach-tegra/board-seaboard-pinmux.c
+++ b/arch/arm/mach-tegra/board-seaboard-pinmux.c
@@ -21,6 +21,7 @@
#include "gpio-names.h"
#include "board-seaboard.h"
+#include "devices.h"
#define DEFAULT_DRIVE(_name) \
{ \
@@ -157,8 +158,10 @@ static __initdata struct tegra_pingroup_config seaboard_pinmux[] = {
{TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
};
-
-
+static struct platform_device *pinmux_devices[] = {
+ &tegra_gpio_device,
+ &tegra_pinmux_device,
+};
static struct tegra_gpio_table gpio_table[] = {
{ .gpio = TEGRA_GPIO_SD2_CD, .enable = true },
@@ -173,6 +176,8 @@ static struct tegra_gpio_table gpio_table[] = {
void __init seaboard_pinmux_init(void)
{
+ platform_add_devices(pinmux_devices, ARRAY_SIZE(pinmux_devices));
+
tegra_pinmux_config_table(seaboard_pinmux, ARRAY_SIZE(seaboard_pinmux));
tegra_drive_pinmux_config_table(seaboard_drive_pinmux,
diff --git a/arch/arm/mach-tegra/board-trimslice-pinmux.c b/arch/arm/mach-tegra/board-trimslice-pinmux.c
index bcb1916..4969dd2 100644
--- a/arch/arm/mach-tegra/board-trimslice-pinmux.c
+++ b/arch/arm/mach-tegra/board-trimslice-pinmux.c
@@ -21,6 +21,7 @@
#include "gpio-names.h"
#include "board-trimslice.h"
+#include "devices.h"
static __initdata struct tegra_pingroup_config trimslice_pinmux[] = {
{TEGRA_PINGROUP_ATA, TEGRA_MUX_IDE, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE},
@@ -141,6 +142,11 @@ static __initdata struct tegra_pingroup_config trimslice_pinmux[] = {
{TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
};
+static struct platform_device *pinmux_devices[] = {
+ &tegra_gpio_device,
+ &tegra_pinmux_device,
+};
+
static struct tegra_gpio_table gpio_table[] = {
{ .gpio = TRIMSLICE_GPIO_SD4_CD, .enable = true }, /* mmc4 cd */
{ .gpio = TRIMSLICE_GPIO_SD4_WP, .enable = true }, /* mmc4 wp */
@@ -151,6 +157,7 @@ static struct tegra_gpio_table gpio_table[] = {
void __init trimslice_pinmux_init(void)
{
+ platform_add_devices(pinmux_devices, ARRAY_SIZE(pinmux_devices));
tegra_pinmux_config_table(trimslice_pinmux, ARRAY_SIZE(trimslice_pinmux));
tegra_gpio_config(gpio_table, ARRAY_SIZE(gpio_table));
}
diff --git a/arch/arm/mach-tegra/devices.c b/arch/arm/mach-tegra/devices.c
index 57e35d2..240d5dc 100644
--- a/arch/arm/mach-tegra/devices.c
+++ b/arch/arm/mach-tegra/devices.c
@@ -31,6 +31,90 @@
#include <mach/usb_phy.h>
#include "gpio-names.h"
+static struct resource gpio_resource[] = {
+ [0] = {
+ .start = TEGRA_GPIO_BASE,
+ .end = TEGRA_GPIO_BASE + TEGRA_GPIO_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = INT_GPIO1,
+ .end = INT_GPIO1,
+ .flags = IORESOURCE_IRQ,
+ },
+ [2] = {
+ .start = INT_GPIO2,
+ .end = INT_GPIO2,
+ .flags = IORESOURCE_IRQ,
+ },
+ [3] = {
+ .start = INT_GPIO3,
+ .end = INT_GPIO3,
+ .flags = IORESOURCE_IRQ,
+ },
+ [4] = {
+ .start = INT_GPIO4,
+ .end = INT_GPIO4,
+ .flags = IORESOURCE_IRQ,
+ },
+ [5] = {
+ .start = INT_GPIO5,
+ .end = INT_GPIO5,
+ .flags = IORESOURCE_IRQ,
+ },
+ [6] = {
+ .start = INT_GPIO6,
+ .end = INT_GPIO6,
+ .flags = IORESOURCE_IRQ,
+ },
+ [7] = {
+ .start = INT_GPIO7,
+ .end = INT_GPIO7,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+struct platform_device tegra_gpio_device = {
+ .name = "tegra-gpio",
+ .id = -1,
+ .resource = gpio_resource,
+ .num_resources = ARRAY_SIZE(gpio_resource),
+};
+
+static struct resource pinmux_resource[] = {
+ [0] = {
+ /* Tri-state registers */
+ .start = TEGRA_APB_MISC_BASE + 0x14,
+ .end = TEGRA_APB_MISC_BASE + 0x20 + 3,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ /* Mux registers */
+ .start = TEGRA_APB_MISC_BASE + 0x80,
+ .end = TEGRA_APB_MISC_BASE + 0x9c + 3,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = {
+ /* Pull-up/down registers */
+ .start = TEGRA_APB_MISC_BASE + 0xa0,
+ .end = TEGRA_APB_MISC_BASE + 0xb0 + 3,
+ .flags = IORESOURCE_MEM,
+ },
+ [3] = {
+ /* Pad control registers */
+ .start = TEGRA_APB_MISC_BASE + 0x868,
+ .end = TEGRA_APB_MISC_BASE + 0x90c + 3,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+struct platform_device tegra_pinmux_device = {
+ .name = "tegra-pinmux",
+ .id = -1,
+ .resource = pinmux_resource,
+ .num_resources = ARRAY_SIZE(pinmux_resource),
+};
+
static struct resource i2c_resource1[] = {
[0] = {
.start = INT_I2C,
diff --git a/arch/arm/mach-tegra/devices.h b/arch/arm/mach-tegra/devices.h
index 4a7dc0a..873ecb2 100644
--- a/arch/arm/mach-tegra/devices.h
+++ b/arch/arm/mach-tegra/devices.h
@@ -21,6 +21,8 @@
#include <linux/platform_device.h>
+extern struct platform_device tegra_gpio_device;
+extern struct platform_device tegra_pinmux_device;
extern struct platform_device tegra_sdhci_device1;
extern struct platform_device tegra_sdhci_device2;
extern struct platform_device tegra_sdhci_device3;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 2/4] arm/dt: Tegra: Add pinmux node to tegra20.dtsi
2011-10-11 22:16 [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs Stephen Warren
@ 2011-10-11 22:16 ` Stephen Warren
2011-10-12 22:38 ` Olof Johansson
2011-10-11 22:16 ` [PATCH v4 3/4] gpio/tegra: Convert to a platform device Stephen Warren
` (2 subsequent siblings)
3 siblings, 1 reply; 14+ messages in thread
From: Stephen Warren @ 2011-10-11 22:16 UTC (permalink / raw)
To: linux-arm-kernel
Add a pinmux node to tegra20.dtsi in order to instantiate the future
pinmux device.
v2: Specify reg property precisely; don't just point at the whole APB_MISC
register range.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
.../devicetree/bindings/pinmux/pinmux_nvidia.txt | 5 +++++
arch/arm/boot/dts/tegra20.dtsi | 8 ++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
create mode 100644 Documentation/devicetree/bindings/pinmux/pinmux_nvidia.txt
diff --git a/Documentation/devicetree/bindings/pinmux/pinmux_nvidia.txt b/Documentation/devicetree/bindings/pinmux/pinmux_nvidia.txt
new file mode 100644
index 0000000..36f82db
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinmux/pinmux_nvidia.txt
@@ -0,0 +1,5 @@
+NVIDIA Tegra 2 pinmux controller
+
+Required properties:
+- compatible : "nvidia,tegra20-pinmux"
+
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index 5727595..65d7e6a 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -77,6 +77,14 @@
gpio-controller;
};
+ pinmux: pinmux at 70000000 {
+ compatible = "nvidia,tegra20-pinmux";
+ reg = < 0x70000014 0x10 /* Tri-state registers */
+ 0x70000080 0x20 /* Mux registers */
+ 0x700000a0 0x14 /* Pull-up/down registers */
+ 0x70000868 0xa8 >; /* Pad control registers */
+ };
+
serial at 70006000 {
compatible = "nvidia,tegra20-uart";
reg = <0x70006000 0x40>;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 3/4] gpio/tegra: Convert to a platform device
2011-10-11 22:16 [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs Stephen Warren
2011-10-11 22:16 ` [PATCH v4 2/4] arm/dt: Tegra: Add pinmux node to tegra20.dtsi Stephen Warren
@ 2011-10-11 22:16 ` Stephen Warren
2011-10-12 22:41 ` Olof Johansson
2011-10-12 23:08 ` Grant Likely
2011-10-11 22:16 ` [PATCH v4 4/4] arm/tegra: Convert pinmux driver " Stephen Warren
2011-10-12 22:37 ` [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs Olof Johansson
3 siblings, 2 replies; 14+ messages in thread
From: Stephen Warren @ 2011-10-11 22:16 UTC (permalink / raw)
To: linux-arm-kernel
v3: Make regs variable static. Remove empty init of tegra_gpio_banks.
v2: Retrieve IRQ and memory addresses from resources instead of hard-
coding them. Add back initialization of tegra_gpio_chip.of_node.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
gpio fixup
---
drivers/gpio/gpio-tegra.c | 143 ++++++++++++++++++++++++++++++---------------
1 files changed, 95 insertions(+), 48 deletions(-)
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 6b65207..4cb59ed 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -20,10 +20,11 @@
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
-
#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
#include <asm/mach/irq.h>
@@ -35,9 +36,7 @@
#define GPIO_PORT(x) (((x) >> 3) & 0x3)
#define GPIO_BIT(x) ((x) & 0x7)
-#define GPIO_REG(x) (IO_TO_VIRT(TEGRA_GPIO_BASE) + \
- GPIO_BANK(x) * 0x80 + \
- GPIO_PORT(x) * 4)
+#define GPIO_REG(x) (GPIO_BANK(x) * 0x80 + GPIO_PORT(x) * 4)
#define GPIO_CNF(x) (GPIO_REG(x) + 0x00)
#define GPIO_OE(x) (GPIO_REG(x) + 0x10)
@@ -76,15 +75,18 @@ struct tegra_gpio_bank {
};
-static struct tegra_gpio_bank tegra_gpio_banks[] = {
- {.bank = 0, .irq = INT_GPIO1},
- {.bank = 1, .irq = INT_GPIO2},
- {.bank = 2, .irq = INT_GPIO3},
- {.bank = 3, .irq = INT_GPIO4},
- {.bank = 4, .irq = INT_GPIO5},
- {.bank = 5, .irq = INT_GPIO6},
- {.bank = 6, .irq = INT_GPIO7},
-};
+static void __iomem *regs;
+static struct tegra_gpio_bank tegra_gpio_banks[7];
+
+static inline void tegra_gpio_writel(u32 val, u32 reg)
+{
+ __raw_writel(val, regs + reg);
+}
+
+static inline u32 tegra_gpio_readl(u32 reg)
+{
+ return __raw_readl(regs + reg);
+}
static int tegra_gpio_compose(int bank, int port, int bit)
{
@@ -98,7 +100,7 @@ static void tegra_gpio_mask_write(u32 reg, int gpio, int value)
val = 0x100 << GPIO_BIT(gpio);
if (value)
val |= 1 << GPIO_BIT(gpio);
- __raw_writel(val, reg);
+ tegra_gpio_writel(val, reg);
}
void tegra_gpio_enable(int gpio)
@@ -118,7 +120,7 @@ static void tegra_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
static int tegra_gpio_get(struct gpio_chip *chip, unsigned offset)
{
- return (__raw_readl(GPIO_IN(offset)) >> GPIO_BIT(offset)) & 0x1;
+ return (tegra_gpio_readl(GPIO_IN(offset)) >> GPIO_BIT(offset)) & 0x1;
}
static int tegra_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
@@ -155,7 +157,7 @@ static void tegra_gpio_irq_ack(struct irq_data *d)
{
int gpio = d->irq - INT_GPIO_BASE;
- __raw_writel(1 << GPIO_BIT(gpio), GPIO_INT_CLR(gpio));
+ tegra_gpio_writel(1 << GPIO_BIT(gpio), GPIO_INT_CLR(gpio));
}
static void tegra_gpio_irq_mask(struct irq_data *d)
@@ -208,10 +210,10 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type)
spin_lock_irqsave(&bank->lvl_lock[port], flags);
- val = __raw_readl(GPIO_INT_LVL(gpio));
+ val = tegra_gpio_readl(GPIO_INT_LVL(gpio));
val &= ~(GPIO_INT_LVL_MASK << GPIO_BIT(gpio));
val |= lvl_type << GPIO_BIT(gpio);
- __raw_writel(val, GPIO_INT_LVL(gpio));
+ tegra_gpio_writel(val, GPIO_INT_LVL(gpio));
spin_unlock_irqrestore(&bank->lvl_lock[port], flags);
@@ -237,12 +239,12 @@ static void tegra_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
for (port = 0; port < 4; port++) {
int gpio = tegra_gpio_compose(bank->bank, port, 0);
- unsigned long sta = __raw_readl(GPIO_INT_STA(gpio)) &
- __raw_readl(GPIO_INT_ENB(gpio));
- u32 lvl = __raw_readl(GPIO_INT_LVL(gpio));
+ unsigned long sta = tegra_gpio_readl(GPIO_INT_STA(gpio)) &
+ tegra_gpio_readl(GPIO_INT_ENB(gpio));
+ u32 lvl = tegra_gpio_readl(GPIO_INT_LVL(gpio));
for_each_set_bit(pin, &sta, 8) {
- __raw_writel(1 << pin, GPIO_INT_CLR(gpio));
+ tegra_gpio_writel(1 << pin, GPIO_INT_CLR(gpio));
/* if gpio is edge triggered, clear condition
* before executing the hander so that we don't
@@ -276,11 +278,11 @@ void tegra_gpio_resume(void)
for (p = 0; p < ARRAY_SIZE(bank->oe); p++) {
unsigned int gpio = (b<<5) | (p<<3);
- __raw_writel(bank->cnf[p], GPIO_CNF(gpio));
- __raw_writel(bank->out[p], GPIO_OUT(gpio));
- __raw_writel(bank->oe[p], GPIO_OE(gpio));
- __raw_writel(bank->int_lvl[p], GPIO_INT_LVL(gpio));
- __raw_writel(bank->int_enb[p], GPIO_INT_ENB(gpio));
+ tegra_gpio_writel(bank->cnf[p], GPIO_CNF(gpio));
+ tegra_gpio_writel(bank->out[p], GPIO_OUT(gpio));
+ tegra_gpio_writel(bank->oe[p], GPIO_OE(gpio));
+ tegra_gpio_writel(bank->int_lvl[p], GPIO_INT_LVL(gpio));
+ tegra_gpio_writel(bank->int_enb[p], GPIO_INT_ENB(gpio));
}
}
@@ -299,11 +301,11 @@ void tegra_gpio_suspend(void)
for (p = 0; p < ARRAY_SIZE(bank->oe); p++) {
unsigned int gpio = (b<<5) | (p<<3);
- bank->cnf[p] = __raw_readl(GPIO_CNF(gpio));
- bank->out[p] = __raw_readl(GPIO_OUT(gpio));
- bank->oe[p] = __raw_readl(GPIO_OE(gpio));
- bank->int_enb[p] = __raw_readl(GPIO_INT_ENB(gpio));
- bank->int_lvl[p] = __raw_readl(GPIO_INT_LVL(gpio));
+ bank->cnf[p] = tegra_gpio_readl(GPIO_CNF(gpio));
+ bank->out[p] = tegra_gpio_readl(GPIO_OUT(gpio));
+ bank->oe[p] = tegra_gpio_readl(GPIO_OE(gpio));
+ bank->int_enb[p] = tegra_gpio_readl(GPIO_INT_ENB(gpio));
+ bank->int_lvl[p] = tegra_gpio_readl(GPIO_INT_LVL(gpio));
}
}
local_irq_restore(flags);
@@ -333,28 +335,55 @@ static struct irq_chip tegra_gpio_irq_chip = {
*/
static struct lock_class_key gpio_lock_class;
-static int __init tegra_gpio_init(void)
+static int __init tegra_gpio_probe(struct platform_device *pdev)
{
+ struct resource *res;
struct tegra_gpio_bank *bank;
int gpio;
int i;
int j;
+ for (i = 0; i < ARRAY_SIZE(tegra_gpio_banks); i++) {
+ res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
+ if (!res) {
+ dev_err(&pdev->dev, "Missing IRQ resource\n");
+ return -ENODEV;
+ }
+
+ bank = &tegra_gpio_banks[i];
+ bank->bank = i;
+ bank->irq = res->start;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "Missing MEM resource\n");
+ return -ENODEV;
+ }
+
+ if (!devm_request_mem_region(&pdev->dev, res->start,
+ resource_size(res),
+ dev_name(&pdev->dev))) {
+ dev_err(&pdev->dev, "Couldn't request MEM resource\n");
+ return -ENODEV;
+ }
+
+ regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+ if (!regs) {
+ dev_err(&pdev->dev, "Couldn't ioremap regs\n");
+ return -ENODEV;
+ }
+
for (i = 0; i < 7; i++) {
for (j = 0; j < 4; j++) {
int gpio = tegra_gpio_compose(i, j, 0);
- __raw_writel(0x00, GPIO_INT_ENB(gpio));
+ tegra_gpio_writel(0x00, GPIO_INT_ENB(gpio));
}
}
#ifdef CONFIG_OF_GPIO
- /*
- * This isn't ideal, but it gets things hooked up until this
- * driver is converted into a platform_device
- */
- tegra_gpio_chip.of_node = of_find_compatible_node(NULL, NULL,
- "nvidia,tegra20-gpio");
-#endif /* CONFIG_OF_GPIO */
+ tegra_gpio_chip.of_node = pdev->dev.of_node;
+#endif
gpiochip_add(&tegra_gpio_chip);
@@ -384,6 +413,24 @@ static int __init tegra_gpio_init(void)
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",
+ .owner = THIS_MODULE,
+ .of_match_table = tegra_gpio_of_match,
+ },
+ .probe = tegra_gpio_probe,
+};
+
+static int __init tegra_gpio_init(void)
+{
+ return platform_driver_register(&tegra_gpio_driver);
+}
postcore_initcall(tegra_gpio_init);
void __init tegra_gpio_config(struct tegra_gpio_table *table, int num)
@@ -416,13 +463,13 @@ static int dbg_gpio_show(struct seq_file *s, void *unused)
seq_printf(s,
"%d:%d %02x %02x %02x %02x %02x %02x %06x\n",
i, j,
- __raw_readl(GPIO_CNF(gpio)),
- __raw_readl(GPIO_OE(gpio)),
- __raw_readl(GPIO_OUT(gpio)),
- __raw_readl(GPIO_IN(gpio)),
- __raw_readl(GPIO_INT_STA(gpio)),
- __raw_readl(GPIO_INT_ENB(gpio)),
- __raw_readl(GPIO_INT_LVL(gpio)));
+ tegra_gpio_readl(GPIO_CNF(gpio)),
+ tegra_gpio_readl(GPIO_OE(gpio)),
+ tegra_gpio_readl(GPIO_OUT(gpio)),
+ tegra_gpio_readl(GPIO_IN(gpio)),
+ tegra_gpio_readl(GPIO_INT_STA(gpio)),
+ tegra_gpio_readl(GPIO_INT_ENB(gpio)),
+ tegra_gpio_readl(GPIO_INT_LVL(gpio)));
}
}
return 0;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 4/4] arm/tegra: Convert pinmux driver to a platform device
2011-10-11 22:16 [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs Stephen Warren
2011-10-11 22:16 ` [PATCH v4 2/4] arm/dt: Tegra: Add pinmux node to tegra20.dtsi Stephen Warren
2011-10-11 22:16 ` [PATCH v4 3/4] gpio/tegra: Convert to a platform device Stephen Warren
@ 2011-10-11 22:16 ` Stephen Warren
2011-10-12 22:38 ` Olof Johansson
2011-10-12 22:37 ` [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs Olof Johansson
3 siblings, 1 reply; 14+ messages in thread
From: Stephen Warren @ 2011-10-11 22:16 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
arch/arm/mach-tegra/pinmux.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-tegra/pinmux.c b/arch/arm/mach-tegra/pinmux.c
index f80d507..46b9d87 100644
--- a/arch/arm/mach-tegra/pinmux.c
+++ b/arch/arm/mach-tegra/pinmux.c
@@ -20,6 +20,7 @@
#include <linux/errno.h>
#include <linux/spinlock.h>
#include <linux/io.h>
+#include <linux/platform_device.h>
#include <mach/iomap.h>
#include <mach/pinmux.h>
@@ -665,6 +666,31 @@ void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co
}
}
+static int __init tegra_pinmux_probe(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static struct of_device_id tegra_pinmux_of_match[] __devinitdata = {
+ { .compatible = "nvidia,tegra20-pinmux", },
+ { },
+};
+
+static struct platform_driver tegra_pinmux_driver = {
+ .driver = {
+ .name = "tegra-pinmux",
+ .owner = THIS_MODULE,
+ .of_match_table = tegra_pinmux_of_match,
+ },
+ .probe = tegra_pinmux_probe,
+};
+
+static int __init tegra_pinmux_init(void)
+{
+ return platform_driver_register(&tegra_pinmux_driver);
+}
+postcore_initcall(tegra_pinmux_init);
+
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
--
1.7.0.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs
2011-10-11 22:16 [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs Stephen Warren
` (2 preceding siblings ...)
2011-10-11 22:16 ` [PATCH v4 4/4] arm/tegra: Convert pinmux driver " Stephen Warren
@ 2011-10-12 22:37 ` Olof Johansson
3 siblings, 0 replies; 14+ messages in thread
From: Olof Johansson @ 2011-10-12 22:37 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Oct 11, 2011 at 04:16:12PM -0600, Stephen Warren wrote:
> The Tegra GPIO driver will be converted from static registration via
> postcore_initcall() to be a platform device later in this patch series.
> A new Tegra pinmux platform device will also be added.
>
> Prepare for this by modifying all boards to register the appropriate
> platform devices before-hand, so that when the drivers are converted,
> those devices will be probed, and git bisectability will be maintained.
>
> v2: Add resource definitions for GPIO and pinmux
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
Thanks, applied to for-3.2/features.
-Olof
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 2/4] arm/dt: Tegra: Add pinmux node to tegra20.dtsi
2011-10-11 22:16 ` [PATCH v4 2/4] arm/dt: Tegra: Add pinmux node to tegra20.dtsi Stephen Warren
@ 2011-10-12 22:38 ` Olof Johansson
0 siblings, 0 replies; 14+ messages in thread
From: Olof Johansson @ 2011-10-12 22:38 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Oct 11, 2011 at 04:16:13PM -0600, Stephen Warren wrote:
> Add a pinmux node to tegra20.dtsi in order to instantiate the future
> pinmux device.
>
> v2: Specify reg property precisely; don't just point at the whole APB_MISC
> register range.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
Thanks, applied to for-3.2/features.
-Olof
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 4/4] arm/tegra: Convert pinmux driver to a platform device
2011-10-11 22:16 ` [PATCH v4 4/4] arm/tegra: Convert pinmux driver " Stephen Warren
@ 2011-10-12 22:38 ` Olof Johansson
0 siblings, 0 replies; 14+ messages in thread
From: Olof Johansson @ 2011-10-12 22:38 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Oct 11, 2011 at 04:16:15PM -0600, Stephen Warren wrote:
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
Thanks, applied to for-3.2/features.
(In the future, please give at least a one-sentence patch description in the
body).
-Olof
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 3/4] gpio/tegra: Convert to a platform device
2011-10-11 22:16 ` [PATCH v4 3/4] gpio/tegra: Convert to a platform device Stephen Warren
@ 2011-10-12 22:41 ` Olof Johansson
2011-10-12 22:49 ` Stephen Warren
2011-10-12 23:03 ` Grant Likely
2011-10-12 23:08 ` Grant Likely
1 sibling, 2 replies; 14+ messages in thread
From: Olof Johansson @ 2011-10-12 22:41 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Oct 11, 2011 at 04:16:14PM -0600, Stephen Warren wrote:
> v3: Make regs variable static. Remove empty init of tegra_gpio_banks.
>
> v2: Retrieve IRQ and memory addresses from resources instead of hard-
> coding them. Add back initialization of tegra_gpio_chip.of_node.
In the future, please move the revision log to below the ---, and just have
the main patch description above, since that is what goes into the git repo.
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
Otherwise, patch looks good. Due to dependencies between this, the rest
of this patch series and the pinmux changes, I'll hold off on it until
the dependencies land (i.e. target it for 3.3). We're cutting it very close
to the merge window as it is, I'll start for-3.3 branches shortly.
-Olof
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 3/4] gpio/tegra: Convert to a platform device
2011-10-12 22:41 ` Olof Johansson
@ 2011-10-12 22:49 ` Stephen Warren
2011-10-12 23:03 ` Grant Likely
1 sibling, 0 replies; 14+ messages in thread
From: Stephen Warren @ 2011-10-12 22:49 UTC (permalink / raw)
To: linux-arm-kernel
Olof Johansson wrote at Wednesday, October 12, 2011 4:42 PM:
> On Tue, Oct 11, 2011 at 04:16:14PM -0600, Stephen Warren wrote:
> > v3: Make regs variable static. Remove empty init of tegra_gpio_banks.
> >
> > v2: Retrieve IRQ and memory addresses from resources instead of hard-
> > coding them. Add back initialization of tegra_gpio_chip.of_node.
>
> In the future, please move the revision log to below the ---, and just have
> the main patch description above, since that is what goes into the git repo.
I don't quite recall when or exactly which Linux-related mailing list I
saw it on, but I saw a discussion on this topic, and people pointed out
that having the revision log in the git commit message actually has some
advantages; it documents some of the things that were though about during
the review, and ends up documenting which version of the patch actually
ended up in git.
Besides, it's a lot easier to maintain the changelog in the git commit
description than in some out-of-band location:-) Although I guess I
could edit the files after git format-patch.
So, I wonder if it might be a good idea to check the changelog in?
--
nvpublic
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 3/4] gpio/tegra: Convert to a platform device
2011-10-12 22:41 ` Olof Johansson
2011-10-12 22:49 ` Stephen Warren
@ 2011-10-12 23:03 ` Grant Likely
2011-10-12 23:19 ` Olof Johansson
1 sibling, 1 reply; 14+ messages in thread
From: Grant Likely @ 2011-10-12 23:03 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Oct 12, 2011 at 4:41 PM, Olof Johansson <olof@lixom.net> wrote:
> On Tue, Oct 11, 2011 at 04:16:14PM -0600, Stephen Warren wrote:
>> v3: Make regs variable static. Remove empty init of tegra_gpio_banks.
>>
>> v2: Retrieve IRQ and memory addresses from resources instead of hard-
>> coding them. Add back initialization of tegra_gpio_chip.of_node.
>
> In the future, please move the revision log to below the ---, and just have
> the main patch description above, since that is what goes into the git repo.
No! Keep it above the line so it shows up in the Linux commit log.
It makes it easier to know which version of a patch actually got
committed. :-)
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>
> Otherwise, patch looks good. Due to dependencies between this, the rest
> of this patch series and the pinmux changes, I'll hold off on it until
> the dependencies land (i.e. target it for 3.3). We're cutting it very close
> to the merge window as it is, I'll start for-3.3 branches shortly.
Actually, see if you can get it in via the same tree as the pinmux
changes. Dependencies is not a reason to hold off from getting it
into linux-next.
g.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 3/4] gpio/tegra: Convert to a platform device
2011-10-11 22:16 ` [PATCH v4 3/4] gpio/tegra: Convert to a platform device Stephen Warren
2011-10-12 22:41 ` Olof Johansson
@ 2011-10-12 23:08 ` Grant Likely
1 sibling, 0 replies; 14+ messages in thread
From: Grant Likely @ 2011-10-12 23:08 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Oct 11, 2011 at 4:16 PM, Stephen Warren <swarren@nvidia.com> wrote:
> v3: Make regs variable static. Remove empty init of tegra_gpio_banks.
>
> v2: Retrieve IRQ and memory addresses from resources instead of hard-
> coding them. Add back initialization of tegra_gpio_chip.of_node.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
One comment below however.
> @@ -333,28 +335,55 @@ static struct irq_chip tegra_gpio_irq_chip = {
> ?*/
> ?static struct lock_class_key gpio_lock_class;
>
> -static int __init tegra_gpio_init(void)
> +static int __init tegra_gpio_probe(struct platform_device *pdev)
__devinit because this is put in the .probe hook of the driver.
g.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 3/4] gpio/tegra: Convert to a platform device
2011-10-12 23:03 ` Grant Likely
@ 2011-10-12 23:19 ` Olof Johansson
2011-10-13 16:36 ` Stephen Warren
0 siblings, 1 reply; 14+ messages in thread
From: Olof Johansson @ 2011-10-12 23:19 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Oct 12, 2011 at 05:03:24PM -0600, Grant Likely wrote:
> On Wed, Oct 12, 2011 at 4:41 PM, Olof Johansson <olof@lixom.net> wrote:
> > On Tue, Oct 11, 2011 at 04:16:14PM -0600, Stephen Warren wrote:
> >> v3: Make regs variable static. Remove empty init of tegra_gpio_banks.
> >>
> >> v2: Retrieve IRQ and memory addresses from resources instead of hard-
> >> coding them. Add back initialization of tegra_gpio_chip.of_node.
> >
> > In the future, please move the revision log to below the ---, and just have
> > the main patch description above, since that is what goes into the git repo.
>
> No! Keep it above the line so it shows up in the Linux commit log.
> It makes it easier to know which version of a patch actually got
> committed. :-)
Alright, I'm convinced.
Maybe it was the fact that the patch description was 100% revision log that
made me notice it this time. :)
> >> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> >
> > Otherwise, patch looks good. Due to dependencies between this, the rest
> > of this patch series and the pinmux changes, I'll hold off on it until
> > the dependencies land (i.e. target it for 3.3). We're cutting it very close
> > to the merge window as it is, I'll start for-3.3 branches shortly.
>
> Actually, see if you can get it in via the same tree as the pinmux
> changes. Dependencies is not a reason to hold off from getting it
> into linux-next.
Ok, the fixup is minimal, should be trivial to spot at git merge time.
Stephen, do you want to respin yourself or should I do the __devinit
change when I apply?
-Olof
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 3/4] gpio/tegra: Convert to a platform device
2011-10-12 23:19 ` Olof Johansson
@ 2011-10-13 16:36 ` Stephen Warren
2011-10-13 23:42 ` Olof Johansson
0 siblings, 1 reply; 14+ messages in thread
From: Stephen Warren @ 2011-10-13 16:36 UTC (permalink / raw)
To: linux-arm-kernel
Olof Johansson wrote at Wednesday, October 12, 2011 5:19 PM:
> On Wed, Oct 12, 2011 at 05:03:24PM -0600, Grant Likely wrote:
> > On Wed, Oct 12, 2011 at 4:41 PM, Olof Johansson <olof@lixom.net> wrote:
> > > On Tue, Oct 11, 2011 at 04:16:14PM -0600, Stephen Warren wrote:
...
> > > Otherwise, patch looks good. Due to dependencies between this, the rest
> > > of this patch series and the pinmux changes, I'll hold off on it until
> > > the dependencies land (i.e. target it for 3.3). We're cutting it very close
> > > to the merge window as it is, I'll start for-3.3 branches shortly.
> >
> > Actually, see if you can get it in via the same tree as the pinmux
> > changes. Dependencies is not a reason to hold off from getting it
> > into linux-next.
>
> Ok, the fixup is minimal, should be trivial to spot at git merge time.
>
> Stephen, do you want to respin yourself or should I do the __devinit
> change when I apply?
I'm happy for you to fix that up when you apply if you're happy doing that.
The same fixup applies to the pinmux patches too.
--
nvpublic
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 3/4] gpio/tegra: Convert to a platform device
2011-10-13 16:36 ` Stephen Warren
@ 2011-10-13 23:42 ` Olof Johansson
0 siblings, 0 replies; 14+ messages in thread
From: Olof Johansson @ 2011-10-13 23:42 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Oct 13, 2011 at 9:36 AM, Stephen Warren <swarren@nvidia.com> wrote:
> Olof Johansson wrote at Wednesday, October 12, 2011 5:19 PM:
>> On Wed, Oct 12, 2011 at 05:03:24PM -0600, Grant Likely wrote:
>> > On Wed, Oct 12, 2011 at 4:41 PM, Olof Johansson <olof@lixom.net> wrote:
>> > > On Tue, Oct 11, 2011 at 04:16:14PM -0600, Stephen Warren wrote:
> ...
>> > > Otherwise, patch looks good. Due to dependencies between this, the rest
>> > > of this patch series and the pinmux changes, I'll hold off on it until
>> > > the dependencies land (i.e. target it for 3.3). We're cutting it very close
>> > > to the merge window as it is, I'll start for-3.3 branches shortly.
>> >
>> > Actually, see if you can get it in via the same tree as the pinmux
>> > changes. ?Dependencies is not a reason to hold off from getting it
>> > into linux-next.
>>
>> Ok, the fixup is minimal, should be trivial to spot at git merge time.
>>
>> Stephen, do you want to respin yourself or should I do the __devinit
>> change when I apply?
>
> I'm happy for you to fix that up when you apply if you're happy doing that.
>
> The same fixup applies to the pinmux patches too.
Thanks, applied (and pinmux patch fixed up). for-3.2/features was
rebased to roll in the pinmux change.
-Olof
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-10-13 23:42 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-11 22:16 [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs Stephen Warren
2011-10-11 22:16 ` [PATCH v4 2/4] arm/dt: Tegra: Add pinmux node to tegra20.dtsi Stephen Warren
2011-10-12 22:38 ` Olof Johansson
2011-10-11 22:16 ` [PATCH v4 3/4] gpio/tegra: Convert to a platform device Stephen Warren
2011-10-12 22:41 ` Olof Johansson
2011-10-12 22:49 ` Stephen Warren
2011-10-12 23:03 ` Grant Likely
2011-10-12 23:19 ` Olof Johansson
2011-10-13 16:36 ` Stephen Warren
2011-10-13 23:42 ` Olof Johansson
2011-10-12 23:08 ` Grant Likely
2011-10-11 22:16 ` [PATCH v4 4/4] arm/tegra: Convert pinmux driver " Stephen Warren
2011-10-12 22:38 ` Olof Johansson
2011-10-12 22:37 ` [PATCH v4 1/4] arm/tegra: Prep boards for gpio/pinmux conversion to pdevs Olof Johansson
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).