Varadarajan, Charulatha | c95d10b | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 1 | /* |
| 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 */ |
| 25 | static 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 Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame^] | 37 | static struct omap_gpio_reg_offs omap15xx_mpuio_regs = { |
| 38 | .direction = OMAP_MPUIO_IO_CNTL, |
| 39 | .datain = OMAP_MPUIO_INPUT_LATCH, |
| 40 | .dataout = OMAP_MPUIO_OUTPUT, |
| 41 | }; |
| 42 | |
Varadarajan, Charulatha | c95d10b | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 43 | static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { |
| 44 | .virtual_irq_start = IH_MPUIO_BASE, |
| 45 | .bank_type = METHOD_MPUIO, |
| 46 | .bank_width = 16, |
Tony Lindgren | 5de62b8 | 2010-12-07 16:26:58 -0800 | [diff] [blame] | 47 | .bank_stride = 1, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame^] | 48 | .regs = &omap15xx_mpuio_regs, |
Varadarajan, Charulatha | c95d10b | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | static struct __initdata platform_device omap15xx_mpu_gpio = { |
| 52 | .name = "omap_gpio", |
| 53 | .id = 0, |
| 54 | .dev = { |
| 55 | .platform_data = &omap15xx_mpu_gpio_config, |
| 56 | }, |
| 57 | .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources), |
| 58 | .resource = omap15xx_mpu_gpio_resources, |
| 59 | }; |
| 60 | |
| 61 | /* gpio2 */ |
| 62 | static struct __initdata resource omap15xx_gpio_resources[] = { |
| 63 | { |
| 64 | .start = OMAP1510_GPIO_BASE, |
| 65 | .end = OMAP1510_GPIO_BASE + SZ_2K - 1, |
| 66 | .flags = IORESOURCE_MEM, |
| 67 | }, |
| 68 | { |
| 69 | .start = INT_GPIO_BANK1, |
| 70 | .flags = IORESOURCE_IRQ, |
| 71 | }, |
| 72 | }; |
| 73 | |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame^] | 74 | static struct omap_gpio_reg_offs omap15xx_gpio_regs = { |
| 75 | .direction = OMAP1510_GPIO_DIR_CONTROL, |
| 76 | .datain = OMAP1510_GPIO_DATA_INPUT, |
| 77 | .dataout = OMAP1510_GPIO_DATA_OUTPUT, |
| 78 | }; |
| 79 | |
Varadarajan, Charulatha | c95d10b | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 80 | static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { |
| 81 | .virtual_irq_start = IH_GPIO_BASE, |
| 82 | .bank_type = METHOD_GPIO_1510, |
| 83 | .bank_width = 16, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame^] | 84 | .regs = &omap15xx_gpio_regs, |
Varadarajan, Charulatha | c95d10b | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | static struct __initdata platform_device omap15xx_gpio = { |
| 88 | .name = "omap_gpio", |
| 89 | .id = 1, |
| 90 | .dev = { |
| 91 | .platform_data = &omap15xx_gpio_config, |
| 92 | }, |
| 93 | .num_resources = ARRAY_SIZE(omap15xx_gpio_resources), |
| 94 | .resource = omap15xx_gpio_resources, |
| 95 | }; |
| 96 | |
| 97 | /* |
| 98 | * omap15xx_gpio_init needs to be done before |
| 99 | * machine_init functions access gpio APIs. |
| 100 | * Hence omap15xx_gpio_init is a postcore_initcall. |
| 101 | */ |
| 102 | static int __init omap15xx_gpio_init(void) |
| 103 | { |
| 104 | if (!cpu_is_omap15xx()) |
| 105 | return -EINVAL; |
| 106 | |
| 107 | platform_device_register(&omap15xx_mpu_gpio); |
| 108 | platform_device_register(&omap15xx_gpio); |
| 109 | |
| 110 | gpio_bank_count = 2; |
| 111 | return 0; |
| 112 | } |
| 113 | postcore_initcall(omap15xx_gpio_init); |