blob: 98e6f39224a4ee42449b847f997889b0842cb4c6 [file] [log] [blame]
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -08001/*
2 * OMAP15xx specific gpio init
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * Author:
7 * Charulatha V <charu@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation version 2.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/gpio.h>
Tony Lindgren4b254082012-08-30 15:37:24 -070020#include <linux/platform_data/gpio-omap.h>
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080021
22#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
23#define OMAP1510_GPIO_BASE 0xFFFCE000
24
25/* gpio1 */
26static struct __initdata resource omap15xx_mpu_gpio_resources[] = {
27 {
28 .start = OMAP1_MPUIO_VBASE,
29 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
30 .flags = IORESOURCE_MEM,
31 },
32 {
33 .start = INT_MPUIO,
34 .flags = IORESOURCE_IRQ,
35 },
36};
37
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070038static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070039 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070040 .direction = OMAP_MPUIO_IO_CNTL,
41 .datain = OMAP_MPUIO_INPUT_LATCH,
42 .dataout = OMAP_MPUIO_OUTPUT,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070043 .irqstatus = OMAP_MPUIO_GPIO_INT,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070044 .irqenable = OMAP_MPUIO_GPIO_MASKIT,
45 .irqenable_inv = true,
Tarun Kanti DebBarma5e571f32011-09-13 15:02:14 +053046 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070047};
48
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080049static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
Charulatha Vd0d665a2011-08-31 00:02:21 +053050 .is_mpuio = true,
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080051 .bank_width = 16,
Tony Lindgren5de62b82010-12-07 16:26:58 -080052 .bank_stride = 1,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070053 .regs = &omap15xx_mpuio_regs,
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080054};
55
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -070056static struct platform_device omap15xx_mpu_gpio = {
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080057 .name = "omap_gpio",
58 .id = 0,
59 .dev = {
60 .platform_data = &omap15xx_mpu_gpio_config,
61 },
62 .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources),
63 .resource = omap15xx_mpu_gpio_resources,
64};
65
66/* gpio2 */
67static struct __initdata resource omap15xx_gpio_resources[] = {
68 {
69 .start = OMAP1510_GPIO_BASE,
70 .end = OMAP1510_GPIO_BASE + SZ_2K - 1,
71 .flags = IORESOURCE_MEM,
72 },
73 {
74 .start = INT_GPIO_BANK1,
75 .flags = IORESOURCE_IRQ,
76 },
77};
78
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070079static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070080 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070081 .direction = OMAP1510_GPIO_DIR_CONTROL,
82 .datain = OMAP1510_GPIO_DATA_INPUT,
83 .dataout = OMAP1510_GPIO_DATA_OUTPUT,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070084 .irqstatus = OMAP1510_GPIO_INT_STATUS,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070085 .irqenable = OMAP1510_GPIO_INT_MASK,
86 .irqenable_inv = true,
Tarun Kanti DebBarma5e571f32011-09-13 15:02:14 +053087 .irqctrl = OMAP1510_GPIO_INT_CONTROL,
Charulatha Vfad96ea2011-05-25 11:23:50 +053088 .pinctrl = OMAP1510_GPIO_PIN_CONTROL,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070089};
90
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080091static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080092 .bank_width = 16,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070093 .regs = &omap15xx_gpio_regs,
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080094};
95
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -070096static struct platform_device omap15xx_gpio = {
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080097 .name = "omap_gpio",
98 .id = 1,
99 .dev = {
100 .platform_data = &omap15xx_gpio_config,
101 },
102 .num_resources = ARRAY_SIZE(omap15xx_gpio_resources),
103 .resource = omap15xx_gpio_resources,
104};
105
106/*
107 * omap15xx_gpio_init needs to be done before
108 * machine_init functions access gpio APIs.
109 * Hence omap15xx_gpio_init is a postcore_initcall.
110 */
111static int __init omap15xx_gpio_init(void)
112{
113 if (!cpu_is_omap15xx())
114 return -EINVAL;
115
116 platform_device_register(&omap15xx_mpu_gpio);
117 platform_device_register(&omap15xx_gpio);
118
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -0800119 return 0;
120}
121postcore_initcall(omap15xx_gpio_init);