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)
9751070struct 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 );
0 commit comments