1 #include <linux/init.h>
2 #include <linux/module.h>
3 #include <linux/types.h>
4 #include <linux/platform_device.h>
5 #include <linux/mutex.h>
6 #include <linux/gpio.h>
9 #include <ifxmips_ebu.h>
11 #define IFXMIPS_EBU_BUSCON 0x1e7ff
12 #define IFXMIPS_EBU_WP 0x80000000
14 static int shadow
= 0;
15 static void __iomem
*virt
;
18 ifxmips_ebu_direction_output(struct gpio_chip
*chip
, unsigned offset
, int value
)
24 ifxmips_ebu_set(struct gpio_chip
*chip
, unsigned offset
, int value
)
28 shadow
|= (1 << offset
);
30 shadow
&= ~(1 << offset
);
31 spin_lock_irqsave(&ebu_lock
, flags
);
32 ifxmips_w32(IFXMIPS_EBU_BUSCON
, IFXMIPS_EBU_BUSCON1
);
33 *((__u16
*)virt
) = shadow
;
34 ifxmips_w32(IFXMIPS_EBU_BUSCON
| IFXMIPS_EBU_WP
, IFXMIPS_EBU_BUSCON1
);
35 spin_unlock_irqrestore(&ebu_lock
, flags
);
38 static struct gpio_chip
41 .label
= "ifxmips_ebu",
42 .direction_output
= ifxmips_ebu_direction_output
,
43 .set
= ifxmips_ebu_set
,
51 ifxmips_ebu_probe(struct platform_device
*pdev
)
53 ifxmips_w32(pdev
->resource
->start
| 0x1, IFXMIPS_EBU_ADDRSEL1
);
54 ifxmips_w32(IFXMIPS_EBU_BUSCON
| IFXMIPS_EBU_WP
, IFXMIPS_EBU_BUSCON1
);
55 virt
= ioremap_nocache(pdev
->resource
->start
, pdev
->resource
->end
);
56 if(gpiochip_add(&ifxmips_ebu_chip
))
58 shadow
= (int) pdev
->dev
.platform_data
;
59 printk("IFXMIPS: ebu-gpio loaded\n");
64 ifxmips_ebu_remove(struct platform_device
*dev
)
66 return gpiochip_remove(&ifxmips_ebu_chip
);
69 static struct platform_driver
70 ifxmips_ebu_driver
= {
71 .probe
= ifxmips_ebu_probe
,
72 .remove
= ifxmips_ebu_remove
,
74 .name
= "ifxmips_ebu",
80 ifxmips_ebu_init(void)
82 return platform_driver_register(&ifxmips_ebu_driver
);
86 ifxmips_ebu_exit(void)
88 platform_driver_unregister(&ifxmips_ebu_driver
);
91 module_init(ifxmips_ebu_init
);
92 module_exit(ifxmips_ebu_exit
);
94 MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
95 MODULE_LICENSE("GPL v2");
96 MODULE_DESCRIPTION("ifxmips - EBU Latch GPIO-Expander");