Merge branch 'depends/rmk/gpio' into next/devel
authorArnd Bergmann <arnd@arndb.de>
Mon, 31 Oct 2011 22:46:42 +0000 (23:46 +0100)
committerArnd Bergmann <arnd@arndb.de>
Mon, 31 Oct 2011 22:46:42 +0000 (23:46 +0100)
Conflicts:
arch/arm/mach-mxs/include/mach/gpio.h
arch/arm/plat-mxc/include/mach/gpio.h

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
16 files changed:
1  2 
arch/arm/Kconfig
arch/arm/mach-at91/at91cap9_devices.c
arch/arm/mach-at91/at91rm9200_devices.c
arch/arm/mach-at91/at91sam9260_devices.c
arch/arm/mach-at91/at91sam9261_devices.c
arch/arm/mach-at91/at91sam9263_devices.c
arch/arm/mach-at91/at91sam9g45_devices.c
arch/arm/mach-davinci/da850.c
arch/arm/mach-imx/mach-mx27ads.c
arch/arm/mach-mmp/gplugd.c
arch/arm/mach-mxs/include/mach/gpio.h
arch/arm/mach-orion5x/dns323-setup.c
arch/arm/mach-tegra/board-trimslice-pinmux.c
arch/arm/plat-mxc/include/mach/gpio.h
drivers/gpio/gpio-tegra.c
drivers/tty/serial/atmel_serial.c

diff --combined arch/arm/Kconfig
@@@ -195,7 -195,8 +195,7 @@@ config VECTORS_BAS
          The base address of exception vectors.
  
  config ARM_PATCH_PHYS_VIRT
 -      bool "Patch physical to virtual translations at runtime (EXPERIMENTAL)"
 -      depends on EXPERIMENTAL
 +      bool "Patch physical to virtual translations at runtime"
        depends on !XIP_KERNEL && MMU
        depends on !ARCH_REALVIEW || !SPARSEMEM
        help
@@@ -397,7 -398,6 +397,7 @@@ config ARCH_MX
        select CLKSRC_MMIO
        select GENERIC_IRQ_CHIP
        select HAVE_SCHED_CLOCK
 +      select MULTI_IRQ_HANDLER
        help
          Support for Freescale MXC/iMX-based family of processors
  
@@@ -836,6 -836,7 +836,7 @@@ config ARCH_U30
        select CLKDEV_LOOKUP
        select HAVE_MACH_CLKDEV
        select GENERIC_GPIO
+       select ARCH_REQUIRE_GPIOLIB
        help
          Support for ST-Ericsson U300 series mobile platforms.
  
@@@ -1272,32 -1273,6 +1273,32 @@@ config ARM_ERRATA_75432
          This workaround defines cpu_relax() as smp_mb(), preventing correctly
          written polling loops from denying visibility of updates to memory.
  
 +config ARM_ERRATA_364296
 +      bool "ARM errata: Possible cache data corruption with hit-under-miss enabled"
 +      depends on CPU_V6 && !SMP
 +      help
 +        This options enables the workaround for the 364296 ARM1136
 +        r0p2 erratum (possible cache data corruption with
 +        hit-under-miss enabled). It sets the undocumented bit 31 in
 +        the auxiliary control register and the FI bit in the control
 +        register, thus disabling hit-under-miss without putting the
 +        processor into full low interrupt latency mode. ARM11MPCore
 +        is not affected.
 +
 +config ARM_ERRATA_764369
 +      bool "ARM errata: Data cache line maintenance operation by MVA may not succeed"
 +      depends on CPU_V7 && SMP
 +      help
 +        This option enables the workaround for erratum 764369
 +        affecting Cortex-A9 MPCore with two or more processors (all
 +        current revisions). Under certain timing circumstances, a data
 +        cache line maintenance operation by MVA targeting an Inner
 +        Shareable memory region may fail to proceed up to either the
 +        Point of Coherency or to the Point of Unification of the
 +        system. This workaround adds a DSB instruction before the
 +        relevant cache maintenance functions and sets a specific bit
 +        in the diagnostic control register of the SCU.
 +
  endmenu
  
  source "arch/arm/common/Kconfig"
@@@ -16,6 -16,7 +16,7 @@@
  #include <asm/mach/irq.h>
  
  #include <linux/dma-mapping.h>
+ #include <linux/gpio.h>
  #include <linux/platform_device.h>
  #include <linux/i2c-gpio.h>
  
@@@ -23,7 -24,6 +24,6 @@@
  
  #include <mach/board.h>
  #include <mach/cpu.h>
- #include <mach/gpio.h>
  #include <mach/at91cap9.h>
  #include <mach/at91cap9_matrix.h>
  #include <mach/at91sam9_smc.h>
@@@ -80,12 -80,6 +80,12 @@@ void __init at91_add_device_usbh(struc
                        at91_set_gpio_output(data->vbus_pin[i], 0);
        }
  
 +      /* Enable overcurrent notification */
 +      for (i = 0; i < data->ports; i++) {
 +              if (data->overcurrent_pin[i])
 +                      at91_set_gpio_input(data->overcurrent_pin[i], 1);
 +      }
 +
        usbh_data = *data;
        platform_device_register(&at91_usbh_device);
  }
  #include <asm/mach/map.h>
  
  #include <linux/dma-mapping.h>
+ #include <linux/gpio.h>
  #include <linux/platform_device.h>
  #include <linux/i2c-gpio.h>
  
  #include <mach/board.h>
- #include <mach/gpio.h>
  #include <mach/at91rm9200.h>
  #include <mach/at91rm9200_mc.h>
  
@@@ -60,17 -60,9 +60,17 @@@ static struct platform_device at91rm920
  
  void __init at91_add_device_usbh(struct at91_usbh_data *data)
  {
 +      int i;
 +
        if (!data)
                return;
  
 +      /* Enable overcurrent notification */
 +      for (i = 0; i < data->ports; i++) {
 +              if (data->overcurrent_pin[i])
 +                      at91_set_gpio_input(data->overcurrent_pin[i], 1);
 +      }
 +
        usbh_data = *data;
        platform_device_register(&at91rm9200_usbh_device);
  }
  #include <asm/mach/map.h>
  
  #include <linux/dma-mapping.h>
+ #include <linux/gpio.h>
  #include <linux/platform_device.h>
  #include <linux/i2c-gpio.h>
  
  #include <mach/board.h>
- #include <mach/gpio.h>
  #include <mach/cpu.h>
  #include <mach/at91sam9260.h>
  #include <mach/at91sam9260_matrix.h>
@@@ -61,17 -61,9 +61,17 @@@ static struct platform_device at91_usbh
  
  void __init at91_add_device_usbh(struct at91_usbh_data *data)
  {
 +      int i;
 +
        if (!data)
                return;
  
 +      /* Enable overcurrent notification */
 +      for (i = 0; i < data->ports; i++) {
 +              if (data->overcurrent_pin[i])
 +                      at91_set_gpio_input(data->overcurrent_pin[i], 1);
 +      }
 +
        usbh_data = *data;
        platform_device_register(&at91_usbh_device);
  }
@@@ -14,6 -14,7 +14,7 @@@
  #include <asm/mach/map.h>
  
  #include <linux/dma-mapping.h>
+ #include <linux/gpio.h>
  #include <linux/platform_device.h>
  #include <linux/i2c-gpio.h>
  
@@@ -21,7 -22,6 +22,6 @@@
  #include <video/atmel_lcdc.h>
  
  #include <mach/board.h>
- #include <mach/gpio.h>
  #include <mach/at91sam9261.h>
  #include <mach/at91sam9261_matrix.h>
  #include <mach/at91sam9_smc.h>
@@@ -64,17 -64,9 +64,17 @@@ static struct platform_device at91sam92
  
  void __init at91_add_device_usbh(struct at91_usbh_data *data)
  {
 +      int i;
 +
        if (!data)
                return;
  
 +      /* Enable overcurrent notification */
 +      for (i = 0; i < data->ports; i++) {
 +              if (data->overcurrent_pin[i])
 +                      at91_set_gpio_input(data->overcurrent_pin[i], 1);
 +      }
 +
        usbh_data = *data;
        platform_device_register(&at91sam9261_usbh_device);
  }
@@@ -13,6 -13,7 +13,7 @@@
  #include <asm/mach/map.h>
  
  #include <linux/dma-mapping.h>
+ #include <linux/gpio.h>
  #include <linux/platform_device.h>
  #include <linux/i2c-gpio.h>
  
@@@ -20,7 -21,6 +21,6 @@@
  #include <video/atmel_lcdc.h>
  
  #include <mach/board.h>
- #include <mach/gpio.h>
  #include <mach/at91sam9263.h>
  #include <mach/at91sam9263_matrix.h>
  #include <mach/at91sam9_smc.h>
@@@ -74,12 -74,6 +74,12 @@@ void __init at91_add_device_usbh(struc
                        at91_set_gpio_output(data->vbus_pin[i], 0);
        }
  
 +      /* Enable overcurrent notification */
 +      for (i = 0; i < data->ports; i++) {
 +              if (data->overcurrent_pin[i])
 +                      at91_set_gpio_input(data->overcurrent_pin[i], 1);
 +      }
 +
        usbh_data = *data;
        platform_device_register(&at91_usbh_device);
  }
@@@ -13,6 -13,7 +13,7 @@@
  #include <asm/mach/map.h>
  
  #include <linux/dma-mapping.h>
+ #include <linux/gpio.h>
  #include <linux/platform_device.h>
  #include <linux/i2c-gpio.h>
  #include <linux/atmel-mci.h>
@@@ -21,7 -22,6 +22,6 @@@
  #include <video/atmel_lcdc.h>
  
  #include <mach/board.h>
- #include <mach/gpio.h>
  #include <mach/at91sam9g45.h>
  #include <mach/at91sam9g45_matrix.h>
  #include <mach/at91sam9_smc.h>
@@@ -124,12 -124,6 +124,12 @@@ void __init at91_add_device_usbh_ohci(s
                        at91_set_gpio_output(data->vbus_pin[i], 0);
        }
  
 +      /* Enable overcurrent notification */
 +      for (i = 0; i < data->ports; i++) {
 +              if (data->overcurrent_pin[i])
 +                      at91_set_gpio_input(data->overcurrent_pin[i], 1);
 +      }
 +
        usbh_ohci_data = *data;
        platform_device_register(&at91_usbh_ohci_device);
  }
@@@ -11,6 -11,7 +11,7 @@@
   * is licensed "as is" without any warranty of any kind, whether express
   * or implied.
   */
+ #include <linux/gpio.h>
  #include <linux/init.h>
  #include <linux/clk.h>
  #include <linux/platform_device.h>
@@@ -27,7 -28,7 +28,7 @@@
  #include <mach/da8xx.h>
  #include <mach/cpufreq.h>
  #include <mach/pm.h>
- #include <mach/gpio.h>
+ #include <mach/gpio-davinci.h>
  
  #include "clock.h"
  #include "mux.h"
@@@ -535,13 -536,6 +536,13 @@@ static const struct mux_config da850_pi
        MUX_CFG(DA850, MMCSD0_DAT_3,    10,     20,     15,     2,      false)
        MUX_CFG(DA850, MMCSD0_CLK,      10,     0,      15,     2,      false)
        MUX_CFG(DA850, MMCSD0_CMD,      10,     4,      15,     2,      false)
 +      /* MMC/SD1 function */
 +      MUX_CFG(DA850, MMCSD1_DAT_0,    18,     8,      15,     2,      false)
 +      MUX_CFG(DA850, MMCSD1_DAT_1,    19,     16,     15,     2,      false)
 +      MUX_CFG(DA850, MMCSD1_DAT_2,    19,     12,     15,     2,      false)
 +      MUX_CFG(DA850, MMCSD1_DAT_3,    19,     8,      15,     2,      false)
 +      MUX_CFG(DA850, MMCSD1_CLK,      18,     12,     15,     2,      false)
 +      MUX_CFG(DA850, MMCSD1_CMD,      18,     16,     15,     2,      false)
        /* EMIF2.5/EMIFA function */
        MUX_CFG(DA850, EMA_D_7,         9,      0,      15,     1,      false)
        MUX_CFG(DA850, EMA_D_6,         9,      4,      15,     1,      false)
        MUX_CFG(DA850, GPIO3_13,        7,      8,      15,     8,      false)
        MUX_CFG(DA850, GPIO4_0,         10,     28,     15,     8,      false)
        MUX_CFG(DA850, GPIO4_1,         10,     24,     15,     8,      false)
 +      MUX_CFG(DA850, GPIO6_9,         13,     24,     15,     8,      false)
 +      MUX_CFG(DA850, GPIO6_10,        13,     20,     15,     8,      false)
        MUX_CFG(DA850, GPIO6_13,        13,     8,      15,     8,      false)
        MUX_CFG(DA850, RTC_ALARM,       0,      28,     15,     2,      false)
  #endif
@@@ -13,7 -13,7 +13,7 @@@
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   */
+ #include <linux/gpio.h>
  #include <linux/platform_device.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/map.h>
@@@ -27,7 -27,6 +27,6 @@@
  #include <asm/mach/arch.h>
  #include <asm/mach/time.h>
  #include <asm/mach/map.h>
- #include <mach/gpio.h>
  #include <mach/iomux-mx27.h>
  
  #include "devices-imx27.h"
@@@ -349,7 -348,6 +348,7 @@@ MACHINE_START(MX27ADS, "Freescale i.MX2
        .map_io = mx27ads_map_io,
        .init_early = imx27_init_early,
        .init_irq = mx27_init_irq,
 +      .handle_irq = imx27_handle_irq,
        .timer = &mx27ads_timer,
        .init_machine = mx27ads_board_init,
  MACHINE_END
@@@ -9,25 -9,23 +9,25 @@@
   */
  
  #include <linux/init.h>
+ #include <linux/gpio.h>
  
  #include <asm/mach/arch.h>
  #include <asm/mach-types.h>
  
- #include <mach/gpio.h>
  #include <mach/pxa168.h>
  #include <mach/mfp-pxa168.h>
 -#include <mach/mfp-gplugd.h>
  
  #include "common.h"
  
  static unsigned long gplugd_pin_config[] __initdata = {
        /* UART3 */
 -      GPIO8_UART3_SOUT,
 -      GPIO9_UART3_SIN,
 -      GPI1O_UART3_CTS,
 -      GPI11_UART3_RTS,
 +      GPIO8_UART3_TXD,
 +      GPIO9_UART3_RXD,
 +      GPIO1O_UART3_CTS,
 +      GPIO11_UART3_RTS,
 +
 +      /* USB OTG PEN */
 +      GPIO18_GPIO,
  
        /* MMC2 */
        GPIO28_MMC2_CMD,
        GPIO105_CI2C_SDA,
        GPIO106_CI2C_SCL,
  
 +      /* SPI NOR Flash on SSP2 */
 +      GPIO107_SSP2_RXD,
 +      GPIO108_SSP2_TXD,
 +      GPIO110_GPIO,     /* SPI_CSn */
 +      GPIO111_SSP2_CLK,
 +
        /* Select JTAG */
        GPIO109_GPIO,
  
@@@ -162,7 -154,7 +162,7 @@@ static void __init select_disp_freq(voi
                                "frequency\n");
        } else {
                gpio_direction_output(35, 1);
 -              gpio_free(104);
 +              gpio_free(35);
        }
  
        if (unlikely(gpio_request(85, "DISP_FREQ_SEL_2"))) {
                                "frequency\n");
        } else {
                gpio_direction_output(85, 0);
 -              gpio_free(104);
 +              gpio_free(85);
        }
  }
  
@@@ -1,31 -1,27 +1,1 @@@
--/*
-- * Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved.
-- * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
-- *
-- * This program is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU General Public License
-- * as published by the Free Software Foundation; either version 2
-- * of the License, or (at your option) any later version.
-- * This program is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- * GNU General Public License for more details.
-- *
-- * You should have received a copy of the GNU General Public License
-- * along with this program; if not, write to the Free Software
-- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-- * MA  02110-1301, USA.
-- */
--
--#ifndef __MACH_MXS_GPIO_H__
--#define __MACH_MXS_GPIO_H__
--
- #include <asm-generic/gpio.h>
 -#define MXS_GPIO_NR(bank, nr) ((bank) * 32 + (nr))
--
- /* use gpiolib dispatchers */
- #define gpio_get_value                __gpio_get_value
- #define gpio_set_value                __gpio_set_value
- #define gpio_cansleep         __gpio_cansleep
- #define gpio_to_irq           __gpio_to_irq
 -#define irq_to_gpio(irq)      ((irq) - MXS_GPIO_IRQ_START)
--
--#endif /* __MACH_MXS_GPIO_H__ */
++/* empty */
@@@ -13,7 -13,7 +13,7 @@@
   * License, or (at your option) any later version.
   *
   */
+ #include <linux/gpio.h>
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <linux/delay.h>
@@@ -30,7 -30,6 +30,6 @@@
  #include <linux/phy.h>
  #include <linux/marvell_phy.h>
  #include <asm/mach-types.h>
- #include <asm/gpio.h>
  #include <asm/mach/arch.h>
  #include <asm/mach/pci.h>
  #include <mach/orion5x.h>
@@@ -77,7 -76,7 +76,7 @@@ static int __init dns323_pci_map_irq(co
        /*
         * Check for devices with hard-wired IRQs.
         */
 -      irq = orion5x_pci_map_irq(const dev, slot, pin);
 +      irq = orion5x_pci_map_irq(dev, slot, pin);
        if (irq != -1)
                return irq;
  
   * GNU General Public License for more details.
   *
   */
+ #include <linux/gpio.h>
  #include <linux/kernel.h>
  #include <linux/init.h>
  
  #include <mach/pinmux.h>
- #include <mach/gpio.h>
  
  #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},
        {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 */
  
  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));
  }
@@@ -1,32 -1,33 +1,1 @@@
--/*
-- * Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved.
-- * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
-- *
-- * This program is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU General Public License
-- * as published by the Free Software Foundation; either version 2
-- * of the License, or (at your option) any later version.
-- * This program is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- * GNU General Public License for more details.
-- *
-- * You should have received a copy of the GNU General Public License
-- * along with this program; if not, write to the Free Software
-- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-- */
--
--#ifndef __ASM_ARCH_MXC_GPIO_H__
--#define __ASM_ARCH_MXC_GPIO_H__
--
--#include <linux/spinlock.h>
--#include <mach/hardware.h>
- #include <asm-generic/gpio.h>
--
- /* use gpiolib dispatchers */
- #define gpio_get_value                __gpio_get_value
- #define gpio_set_value                __gpio_set_value
- #define gpio_cansleep         __gpio_cansleep
- #define gpio_to_irq           __gpio_to_irq
 -
 -/* There's a off-by-one betweem the gpio bank number and the gpiochip */
 -/* range e.g. GPIO_1_5 is gpio 5 under linux */
 -#define IMX_GPIO_NR(bank, nr)         (((bank) - 1) * 32 + (nr))
 -
 -#define gpio_to_irq(gpio)     (MXC_GPIO_IRQ_START + (gpio))
 -#define irq_to_gpio(irq)      ((irq) - MXC_GPIO_IRQ_START)
--
--#endif
++/* empty */
  #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>
  
+ #include <mach/gpio-tegra.h>
  #include <mach/iomap.h>
  #include <mach/suspend.h>
  
@@@ -35,7 -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)
@@@ -74,18 -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)
  {
@@@ -99,7 -98,7 +100,7 @@@ static void tegra_gpio_mask_write(u32 r
        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)
@@@ -119,7 -118,7 +120,7 @@@ static void tegra_gpio_set(struct gpio_
  
  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)
@@@ -136,7 -135,10 +137,10 @@@ static int tegra_gpio_direction_output(
        return 0;
  }
  
+ static int tegra_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
+ {
+       return TEGRA_GPIO_TO_IRQ(offset);
+ }
  
  static struct gpio_chip tegra_gpio_chip = {
        .label                  = "tegra-gpio",
        .get                    = tegra_gpio_get,
        .direction_output       = tegra_gpio_direction_output,
        .set                    = tegra_gpio_set,
+       .to_irq                 = tegra_gpio_to_irq,
        .base                   = 0,
        .ngpio                  = TEGRA_NR_GPIOS,
  };
@@@ -152,7 -155,7 +157,7 @@@ static void tegra_gpio_irq_ack(struct i
  {
        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)
@@@ -205,10 -208,10 +210,10 @@@ static int tegra_gpio_irq_set_type(stru
  
        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);
  
@@@ -234,12 -237,12 +239,12 @@@ static void tegra_gpio_irq_handler(unsi
  
        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
@@@ -273,11 -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));
                }
        }
  
@@@ -296,11 -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);
@@@ -330,65 -333,42 +335,69 @@@ static struct irq_chip tegra_gpio_irq_c
   */
  static struct lock_class_key gpio_lock_class;
  
 -static int __init tegra_gpio_init(void)
 +static int __devinit 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);
  
-       for (i = INT_GPIO_BASE; i < (INT_GPIO_BASE + TEGRA_NR_GPIOS); i++) {
-               bank = &tegra_gpio_banks[GPIO_BANK(irq_to_gpio(i))];
+       for (gpio = 0; gpio < TEGRA_NR_GPIOS; gpio++) {
+               int irq = TEGRA_GPIO_TO_IRQ(gpio);
+               /* No validity check; all Tegra GPIOs are valid IRQs */
+               bank = &tegra_gpio_banks[GPIO_BANK(gpio)];
  
-               irq_set_lockdep_class(i, &gpio_lock_class);
-               irq_set_chip_data(i, bank);
-               irq_set_chip_and_handler(i, &tegra_gpio_irq_chip,
+               irq_set_lockdep_class(irq, &gpio_lock_class);
+               irq_set_chip_data(irq, bank);
+               irq_set_chip_and_handler(irq, &tegra_gpio_irq_chip,
                                         handle_simple_irq);
-               set_irq_flags(i, IRQF_VALID);
+               set_irq_flags(irq, IRQF_VALID);
        }
  
        for (i = 0; i < ARRAY_SIZE(tegra_gpio_banks); i++) {
        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)
@@@ -454,13 -416,13 +463,13 @@@ static int dbg_gpio_show(struct seq_fil
                        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;
@@@ -46,7 -46,7 +46,7 @@@
  
  #ifdef CONFIG_ARM
  #include <mach/cpu.h>
- #include <mach/gpio.h>
+ #include <asm/gpio.h>
  #endif
  
  #define PDC_BUFFER_SIZE               512
@@@ -1609,11 -1609,9 +1609,11 @@@ static struct console atmel_console = 
  static int __init atmel_console_init(void)
  {
        if (atmel_default_console_device) {
 -              add_preferred_console(ATMEL_DEVICENAME,
 -                                    atmel_default_console_device->id, NULL);
 -              atmel_init_port(&atmel_ports[atmel_default_console_device->id],
 +              struct atmel_uart_data *pdata =
 +                      atmel_default_console_device->dev.platform_data;
 +
 +              add_preferred_console(ATMEL_DEVICENAME, pdata->num, NULL);
 +              atmel_init_port(&atmel_ports[pdata->num],
                                atmel_default_console_device);
                register_console(&atmel_console);
        }