Skip to content

Commit cbe8e46

Browse files
maquefelarndb
authored andcommitted
gpio: ep93xx: split device in multiple
Prepare ep93xx SOC gpio to convert into device tree driver: - dropped banks and legacy defines - split AB IRQ and make it shared We are relying on IRQ number information A, B ports have single shared IRQ, while F port have dedicated IRQ for each line. Also we had to split single ep93xx platform_device into multiple, one for each port, without this we can't do a full working transition from legacy platform code into device tree capable. All GPIO_LOOKUP were change to match new chip namings. Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me> Tested-by: Alexander Sverdlin <alexander.sverdlin@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent a8c3944 commit cbe8e46

5 files changed

Lines changed: 235 additions & 227 deletions

File tree

arch/arm/mach-ep93xx/core.c

Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/reboot.h>
3636
#include <linux/usb/ohci_pdriver.h>
3737
#include <linux/random.h>
38+
#include <linux/ioport.h>
3839

3940
#include "hardware.h"
4041
#include <linux/platform_data/video-ep93xx.h>
@@ -139,9 +140,80 @@ EXPORT_SYMBOL_GPL(ep93xx_chip_revision);
139140
/*************************************************************************
140141
* EP93xx GPIO
141142
*************************************************************************/
142-
static struct resource ep93xx_gpio_resource[] = {
143-
DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE, 0xcc),
143+
/* port A */
144+
static struct resource ep93xx_a_gpio_resources[] = {
145+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE, 0x04, "data"),
146+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x10, 0x04, "dir"),
147+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x90, 0x1c, "intr"),
144148
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO_AB),
149+
};
150+
151+
static struct platform_device ep93xx_a_gpio = {
152+
.name = "gpio-ep93xx",
153+
.id = 0,
154+
.num_resources = ARRAY_SIZE(ep93xx_a_gpio_resources),
155+
.resource = ep93xx_a_gpio_resources,
156+
};
157+
158+
/* port B */
159+
static struct resource ep93xx_b_gpio_resources[] = {
160+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x04, 0x04, "data"),
161+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x14, 0x04, "dir"),
162+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0xac, 0x1c, "intr"),
163+
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO_AB),
164+
};
165+
166+
static struct platform_device ep93xx_b_gpio = {
167+
.name = "gpio-ep93xx",
168+
.id = 1,
169+
.num_resources = ARRAY_SIZE(ep93xx_b_gpio_resources),
170+
.resource = ep93xx_b_gpio_resources,
171+
};
172+
173+
/* port C */
174+
static struct resource ep93xx_c_gpio_resources[] = {
175+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x08, 0x04, "data"),
176+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x18, 0x04, "dir"),
177+
};
178+
179+
static struct platform_device ep93xx_c_gpio = {
180+
.name = "gpio-ep93xx",
181+
.id = 2,
182+
.num_resources = ARRAY_SIZE(ep93xx_c_gpio_resources),
183+
.resource = ep93xx_c_gpio_resources,
184+
};
185+
186+
/* port D */
187+
static struct resource ep93xx_d_gpio_resources[] = {
188+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x0c, 0x04, "data"),
189+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x1c, 0x04, "dir"),
190+
};
191+
192+
static struct platform_device ep93xx_d_gpio = {
193+
.name = "gpio-ep93xx",
194+
.id = 3,
195+
.num_resources = ARRAY_SIZE(ep93xx_d_gpio_resources),
196+
.resource = ep93xx_d_gpio_resources,
197+
};
198+
199+
/* port E */
200+
static struct resource ep93xx_e_gpio_resources[] = {
201+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x20, 0x04, "data"),
202+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x24, 0x04, "dir"),
203+
};
204+
205+
static struct platform_device ep93xx_e_gpio = {
206+
.name = "gpio-ep93xx",
207+
.id = 4,
208+
.num_resources = ARRAY_SIZE(ep93xx_e_gpio_resources),
209+
.resource = ep93xx_e_gpio_resources,
210+
};
211+
212+
/* port F */
213+
static struct resource ep93xx_f_gpio_resources[] = {
214+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x30, 0x04, "data"),
215+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x34, 0x04, "dir"),
216+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x4c, 0x1c, "intr"),
145217
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO0MUX),
146218
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO1MUX),
147219
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO2MUX),
@@ -152,11 +224,34 @@ static struct resource ep93xx_gpio_resource[] = {
152224
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO7MUX),
153225
};
154226

155-
static struct platform_device ep93xx_gpio_device = {
156-
.name = "gpio-ep93xx",
157-
.id = -1,
158-
.num_resources = ARRAY_SIZE(ep93xx_gpio_resource),
159-
.resource = ep93xx_gpio_resource,
227+
static struct platform_device ep93xx_f_gpio = {
228+
.name = "gpio-ep93xx",
229+
.id = 5,
230+
.num_resources = ARRAY_SIZE(ep93xx_f_gpio_resources),
231+
.resource = ep93xx_f_gpio_resources,
232+
};
233+
234+
/* port G */
235+
static struct resource ep93xx_g_gpio_resources[] = {
236+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x38, 0x04, "data"),
237+
DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x3c, 0x04, "dir"),
238+
};
239+
240+
static struct platform_device ep93xx_g_gpio = {
241+
.name = "gpio-ep93xx",
242+
.id = 6,
243+
.num_resources = ARRAY_SIZE(ep93xx_g_gpio_resources),
244+
.resource = ep93xx_g_gpio_resources,
245+
};
246+
247+
static struct platform_device *ep93xx_gpio_device[] __initdata = {
248+
&ep93xx_a_gpio,
249+
&ep93xx_b_gpio,
250+
&ep93xx_c_gpio,
251+
&ep93xx_d_gpio,
252+
&ep93xx_e_gpio,
253+
&ep93xx_f_gpio,
254+
&ep93xx_g_gpio,
160255
};
161256

162257
/*************************************************************************
@@ -335,9 +430,9 @@ static struct gpiod_lookup_table ep93xx_i2c_gpiod_table = {
335430
.dev_id = "i2c-gpio.0",
336431
.table = {
337432
/* Use local offsets on gpiochip/port "G" */
338-
GPIO_LOOKUP_IDX("G", 1, NULL, 0,
433+
GPIO_LOOKUP_IDX("gpio-ep93xx.6", 1, NULL, 0,
339434
GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
340-
GPIO_LOOKUP_IDX("G", 0, NULL, 1,
435+
GPIO_LOOKUP_IDX("gpio-ep93xx.6", 0, NULL, 1,
341436
GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
342437
{ }
343438
},
@@ -441,8 +536,8 @@ static struct gpiod_lookup_table ep93xx_leds_gpio_table = {
441536
.dev_id = "leds-gpio",
442537
.table = {
443538
/* Use local offsets on gpiochip/port "E" */
444-
GPIO_LOOKUP_IDX("E", 0, NULL, 0, GPIO_ACTIVE_HIGH),
445-
GPIO_LOOKUP_IDX("E", 1, NULL, 1, GPIO_ACTIVE_HIGH),
539+
GPIO_LOOKUP_IDX("gpio-ep93xx.4", 0, NULL, 0, GPIO_ACTIVE_HIGH),
540+
GPIO_LOOKUP_IDX("gpio-ep93xx.4", 1, NULL, 1, GPIO_ACTIVE_HIGH),
446541
{ }
447542
},
448543
};
@@ -975,6 +1070,7 @@ static struct device __init *ep93xx_init_soc(void)
9751070
struct device __init *ep93xx_init_devices(void)
9761071
{
9771072
struct device *parent;
1073+
unsigned int i;
9781074

9791075
/* Disallow access to MaverickCrunch initially */
9801076
ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA);
@@ -989,7 +1085,8 @@ struct device __init *ep93xx_init_devices(void)
9891085
parent = ep93xx_init_soc();
9901086

9911087
/* Get the GPIO working early, other devices need it */
992-
platform_device_register(&ep93xx_gpio_device);
1088+
for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_device); i++)
1089+
platform_device_register(ep93xx_gpio_device[i]);
9931090

9941091
amba_device_register(&uart1_device, &iomem_resource);
9951092
amba_device_register(&uart2_device, &iomem_resource);

arch/arm/mach-ep93xx/edb93xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
105105
static struct gpiod_lookup_table edb93xx_spi_cs_gpio_table = {
106106
.dev_id = "spi0",
107107
.table = {
108-
GPIO_LOOKUP("A", 6, "cs", GPIO_ACTIVE_LOW),
108+
GPIO_LOOKUP("gpio-ep93xx.0", 6, "cs", GPIO_ACTIVE_LOW),
109109
{ },
110110
},
111111
};

arch/arm/mach-ep93xx/ts72xx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static struct spi_board_info bk3_spi_board_info[] __initdata = {
268268
static struct gpiod_lookup_table bk3_spi_cs_gpio_table = {
269269
.dev_id = "spi0",
270270
.table = {
271-
GPIO_LOOKUP("F", 3, "cs", GPIO_ACTIVE_LOW),
271+
GPIO_LOOKUP("gpio-ep93xx.5", 3, "cs", GPIO_ACTIVE_LOW),
272272
{ },
273273
},
274274
};
@@ -318,7 +318,7 @@ static struct gpiod_lookup_table ts72xx_spi_cs_gpio_table = {
318318
.dev_id = "spi0",
319319
.table = {
320320
/* DIO_17 */
321-
GPIO_LOOKUP("F", 2, "cs", GPIO_ACTIVE_LOW),
321+
GPIO_LOOKUP("gpio-ep93xx.5", 2, "cs", GPIO_ACTIVE_LOW),
322322
{ },
323323
},
324324
};

arch/arm/mach-ep93xx/vision_ep9307.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ static struct gpiod_lookup_table vision_spi_mmc_gpio_table = {
206206
.dev_id = "mmc_spi.2", /* "mmc_spi @ CS2 */
207207
.table = {
208208
/* Card detect */
209-
GPIO_LOOKUP_IDX("B", 7, NULL, 0, GPIO_ACTIVE_LOW),
209+
GPIO_LOOKUP_IDX("gpio-ep93xx.1", 7, NULL, 0, GPIO_ACTIVE_LOW),
210210
/* Write protect */
211-
GPIO_LOOKUP_IDX("F", 0, NULL, 1, GPIO_ACTIVE_HIGH),
211+
GPIO_LOOKUP_IDX("gpio-ep93xx.5", 0, NULL, 1, GPIO_ACTIVE_HIGH),
212212
{ },
213213
},
214214
};
@@ -253,9 +253,9 @@ static struct gpiod_lookup_table vision_spi_cs4271_gpio_table = {
253253
static struct gpiod_lookup_table vision_spi_cs_gpio_table = {
254254
.dev_id = "spi0",
255255
.table = {
256-
GPIO_LOOKUP_IDX("A", 6, "cs", 0, GPIO_ACTIVE_LOW),
257-
GPIO_LOOKUP_IDX("A", 7, "cs", 1, GPIO_ACTIVE_LOW),
258-
GPIO_LOOKUP_IDX("G", 2, "cs", 2, GPIO_ACTIVE_LOW),
256+
GPIO_LOOKUP_IDX("gpio-ep93xx.0", 6, "cs", 0, GPIO_ACTIVE_LOW),
257+
GPIO_LOOKUP_IDX("gpio-ep93xx.0", 7, "cs", 1, GPIO_ACTIVE_LOW),
258+
GPIO_LOOKUP_IDX("gpio-ep93xx.6", 2, "cs", 2, GPIO_ACTIVE_LOW),
259259
{ },
260260
},
261261
};

0 commit comments

Comments
 (0)