1 // SPDX-License-Identifier: GPL-2.0-only
3 * OMAP15xx specific gpio init
5 * Copyright (C) 2010 Texas Instruments Incorporated - https://www.ti.com/
8 * Charulatha V <charu@ti.com>
11 #include <linux/gpio.h>
12 #include <linux/platform_data/gpio-omap.h>
13 #include <linux/soc/ti/omap1-soc.h>
18 #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
19 #define OMAP1510_GPIO_BASE 0xFFFCE000
22 static struct resource omap15xx_mpu_gpio_resources[] = {
24 .start = OMAP1_MPUIO_VBASE,
25 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
26 .flags = IORESOURCE_MEM,
30 .flags = IORESOURCE_IRQ,
34 static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
35 .revision = USHRT_MAX,
36 .direction = OMAP_MPUIO_IO_CNTL,
37 .datain = OMAP_MPUIO_INPUT_LATCH,
38 .dataout = OMAP_MPUIO_OUTPUT,
39 .irqstatus = OMAP_MPUIO_GPIO_INT,
40 .irqenable = OMAP_MPUIO_GPIO_MASKIT,
41 .irqenable_inv = true,
42 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
45 static struct omap_gpio_platform_data omap15xx_mpu_gpio_config = {
49 .regs = &omap15xx_mpuio_regs,
52 static struct platform_device omap15xx_mpu_gpio = {
56 .platform_data = &omap15xx_mpu_gpio_config,
58 .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources),
59 .resource = omap15xx_mpu_gpio_resources,
63 static struct resource omap15xx_gpio_resources[] = {
65 .start = OMAP1510_GPIO_BASE,
66 .end = OMAP1510_GPIO_BASE + SZ_2K - 1,
67 .flags = IORESOURCE_MEM,
70 .start = INT_GPIO_BANK1,
71 .flags = IORESOURCE_IRQ,
75 static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
76 .revision = USHRT_MAX,
77 .direction = OMAP1510_GPIO_DIR_CONTROL,
78 .datain = OMAP1510_GPIO_DATA_INPUT,
79 .dataout = OMAP1510_GPIO_DATA_OUTPUT,
80 .irqstatus = OMAP1510_GPIO_INT_STATUS,
81 .irqenable = OMAP1510_GPIO_INT_MASK,
82 .irqenable_inv = true,
83 .irqctrl = OMAP1510_GPIO_INT_CONTROL,
84 .pinctrl = OMAP1510_GPIO_PIN_CONTROL,
87 static struct omap_gpio_platform_data omap15xx_gpio_config = {
89 .regs = &omap15xx_gpio_regs,
92 static struct platform_device omap15xx_gpio = {
96 .platform_data = &omap15xx_gpio_config,
98 .num_resources = ARRAY_SIZE(omap15xx_gpio_resources),
99 .resource = omap15xx_gpio_resources,
103 * omap15xx_gpio_init needs to be done before
104 * machine_init functions access gpio APIs.
105 * Hence omap15xx_gpio_init is a postcore_initcall.
107 static int __init omap15xx_gpio_init(void)
109 if (!cpu_is_omap15xx())
112 platform_device_register(&omap15xx_mpu_gpio);
113 platform_device_register(&omap15xx_gpio);
117 postcore_initcall(omap15xx_gpio_init);