arm/tegra: Convert GPIO and pinmux to platform devs
Subsystems (5)
v2 cover arm/tegra: Convert GPIO and pinmux to platform devs
v2: Convert GPIO driver to ioremap its registers instead of using static mappings. The pinmux driver doesn't do this yet, but will soon. However, the pinmux register resources/DT-properties are set up correctly for when the driver is converted. Also, add back initialization of tegra_gpio_chip.of_node.
Stephen Warren (4):
arm/tegra: Prep boards for gpio/pinmux conversion to pdevs arm/dt: Tegra: Add pinmux node to tegra20.dtsi gpio/tegra: Convert to a platform device arm/tegra: Convert pinmux driver to a platform device
.../devicetree/bindings/pinmux/pinmux_nvidia.txt | 5 + arch/arm/boot/dts/tegra20.dtsi | 8 + 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 + arch/arm/mach-tegra/pinmux.c | 26 ++++ drivers/gpio/gpio-tegra.c | 142 +++++++++++++------- 10 files changed, 250 insertions(+), 49 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinmux/pinmux_nvidia.txt
PATCH v2 1/4 arm/tegra: Prep boards for gpio/pinmux conversion to pdevs
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
--- 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(-)
arch/arm/mach-tegra/board-harmony-pinmux.c +8 -0
@@ -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));
arch/arm/mach-tegra/board-paz00-pinmux.c +8 -0
@@ -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));
arch/arm/mach-tegra/board-seaboard-pinmux.c +7 -2
@@ -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,
arch/arm/mach-tegra/board-trimslice-pinmux.c +7 -0
@@ -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)); }
arch/arm/mach-tegra/devices.c +84 -0
90 lines not on this page · raw message
arch/arm/mach-tegra/devices.h +2 -0
@@ -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;
Signature · 1 line
1.7.0.4
PATCH v2 2/4 arm/dt: Tegra: Add pinmux node to tegra20.dtsi
In reply to Stephen WarrenAdd 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.
--- .../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
Documentation/devicetree/bindings/pinmux/pinmux_nvidia.txt new file +5 -0
@@ -0,0 +1,5 @@ +NVIDIA Tegra 2 pinmux controller + +Required properties: +- compatible : "nvidia,tegra20-pinmux" +
arch/arm/boot/dts/tegra20.dtsi +8 -0
@@ -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>;
Signature · 1 line
1.7.0.4
PATCH v2 3/4 gpio/tegra: Convert to a platform device
In reply to Stephen Warrenv2: Retrieve IRQ and memory addresses from resources instead of hard- coding them. Add back initialization of tegra_gpio_chip.of_node.
--- drivers/gpio/gpio-tegra.c | 142 ++++++++++++++++++++++++++++++--------------- 1 files changed, 95 insertions(+), 47 deletions(-)
drivers/gpio/gpio-tegra.c +95 -47
@@ -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,16 +75,20 @@ 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 }, +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) {return (bank <<5 ) | ((port &0x3 ) <<3 ) | (bit &0x7 );
@@ -98,7 +101,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 +121,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 +158,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 +211,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 +240,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 +279,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 +302,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 +336,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 +414,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 +464,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 ;
Signature · 1 line
1.7.0.4
PATCH v2 3/4 gpio/tegra: Convert to a platform device
Hi,
Some nits below. Overall looks good.
drivers/gpio/gpio-tegra.c struct tegra_gpio_bank { · line 78
Quoted 13 lines · Stephen Warren
drivers/gpio/gpio-tegra.c +1
-8@@ -76,16 +75,20 @@ 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 }, +void __iomem *regs;
Should be static.
drivers/gpio/gpio-tegra.c struct tegra_gpio_bank { · line 80
Quoted 2 lines
drivers/gpio/gpio-tegra.c +1
-0+static struct tegra_gpio_bank tegra_gpio_banks[7 ] = { };
Can be on the same line as the rest, i.e. ... = { };
Quoted 13 lines
drivers/gpio/gpio-tegra.c +10
-0+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) {return (bank <<5 ) | ((port &0x3 ) <<3 ) | (bit &0x7 );
[...]
Quoted 32 lines
drivers/gpio/gpio-tegra.c +21
-1@@ -333,28 +336,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,
drivers/gpio/gpio-tegra.c static struct irq_chip tegra_gpio_irq_chip = { · line 375
Quoted 10 lines
drivers/gpio/gpio-tegra.c +10
-0+ 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 ;
Should you release the mem region requested above here?
-Olof
PATCH v2 3/4 gpio/tegra: Convert to a platform device
Quoted 36 lines · Olof Johansson
Quoted 36 lines
(quoted diff) +0
-0@@ -333,28 +336,55 @@ static struct irq_chip tegra_gpio_irq_chip = {? */
?static structlock_class_keygpio_lock_class;drivers/gpio/gpio-tegra.c +1
-1-static int __init tegra_gpio_init (void ) +static int __init tegra_gpio_probe (struct platform_device *pdev)?{
+ ? ? struct resource *res;
? ? ? structtegra_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;
+ ? ? ? ? ? ? }(quoted diff) +17
-0+ + ? ? ? ? ? ? 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;
Quoted 8 lines
Quoted 6 lines
+ ? ? }
+
+ ? ? regs =devm_ioremap(&pdev->dev, res->start, resource_size(res));
+ ? ? if (!regs) {
+ ? ? ? ? ? ?dev_err(&pdev->dev, "Couldn't ioremap regs\n");
+ ? ? ? ? ? ? return-ENODEV;Should you release the mem region requested above here?
As discussed on irc, this is handled by the driver core in case of failed probe, so nevermind.
-Olof
PATCH v2 4/4 arm/tegra: Convert pinmux driver to a platform device
In reply to Stephen Warren--- arch/arm/mach-tegra/pinmux.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/pinmux.c +26 -0
@@ -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>
Signature · 1 line
1.7.0.4