blob: 399da4ce017bfb39d9134e869002710da6f28e20 [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>
20
21#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
22#define OMAP1510_GPIO_BASE 0xFFFCE000
23
24/* gpio1 */
25static struct __initdata resource omap15xx_mpu_gpio_resources[] = {
26 {
27 .start = OMAP1_MPUIO_VBASE,
28 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
29 .flags = IORESOURCE_MEM,
30 },
31 {
32 .start = INT_MPUIO,
33 .flags = IORESOURCE_IRQ,
34 },
35};
36
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070037static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070038 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070039 .direction = OMAP_MPUIO_IO_CNTL,
40 .datain = OMAP_MPUIO_INPUT_LATCH,
41 .dataout = OMAP_MPUIO_OUTPUT,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070042 .irqstatus = OMAP_MPUIO_GPIO_INT,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070043 .irqenable = OMAP_MPUIO_GPIO_MASKIT,
44 .irqenable_inv = true,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070045};
46
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080047static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
48 .virtual_irq_start = IH_MPUIO_BASE,
49 .bank_type = METHOD_MPUIO,
50 .bank_width = 16,
Tony Lindgren5de62b82010-12-07 16:26:58 -080051 .bank_stride = 1,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070052 .regs = &omap15xx_mpuio_regs,
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080053};
54
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -070055static struct platform_device omap15xx_mpu_gpio = {
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080056 .name = "omap_gpio",
57 .id = 0,
58 .dev = {
59 .platform_data = &omap15xx_mpu_gpio_config,
60 },
61 .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources),
62 .resource = omap15xx_mpu_gpio_resources,
63};
64
65/* gpio2 */
66static struct __initdata resource omap15xx_gpio_resources[] = {
67 {
68 .start = OMAP1510_GPIO_BASE,
69 .end = OMAP1510_GPIO_BASE + SZ_2K - 1,
70 .flags = IORESOURCE_MEM,
71 },
72 {
73 .start = INT_GPIO_BANK1,
74 .flags = IORESOURCE_IRQ,
75 },
76};
77
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070078static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070079 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070080 .direction = OMAP1510_GPIO_DIR_CONTROL,
81 .datain = OMAP1510_GPIO_DATA_INPUT,
82 .dataout = OMAP1510_GPIO_DATA_OUTPUT,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070083 .irqstatus = OMAP1510_GPIO_INT_STATUS,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070084 .irqenable = OMAP1510_GPIO_INT_MASK,
85 .irqenable_inv = true,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070086};
87
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080088static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
89 .virtual_irq_start = IH_GPIO_BASE,
90 .bank_type = METHOD_GPIO_1510,
91 .bank_width = 16,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070092 .regs = &omap15xx_gpio_regs,
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080093};
94
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -070095static struct platform_device omap15xx_gpio = {
Varadarajan, Charulathac95d10b2010-12-07 16:26:56 -080096 .name = "omap_gpio",
97 .id = 1,
98 .dev = {
99 .platform_data = &omap15xx_gpio_config,
100 },
101 .num_resources = ARRAY_SIZE(omap15xx_gpio_resources),
102 .resource = omap15xx_gpio_resources,
103};
104
105/*
106 * omap15xx_gpio_init needs to be done before
107 * machine_init functions access gpio APIs.
108 * Hence omap15xx_gpio_init is a postcore_initcall.
109 */
110static int __init omap15xx_gpio_init(void)
111{
112 if (!cpu_is_omap15xx())
113 return -EINVAL;
114
115 platform_device_register(&omap15xx_mpu_gpio);
116 platform_device_register(&omap15xx_gpio);
117
118 gpio_bank_count = 2;
119 return 0;
120}
121postcore_initcall(omap15xx_gpio_init);