18 #include <linux/module.h>
20 #include <linux/kernel.h>
22 #include <linux/errno.h>
25 #include <linux/slab.h>
29 #include <mach/hardware.h>
36 #define IRQ_LOCOMO_KEY (0)
37 #define IRQ_LOCOMO_GPIO (1)
38 #define IRQ_LOCOMO_LT (2)
39 #define IRQ_LOCOMO_SPI (3)
42 #define M62332_EVR_CH 1
45 #define M62332_SLAVE_ADDR 0x4e
46 #define M62332_W_BIT 0x00
47 #define M62332_SUB_ADDR 0x00
48 #define M62332_A_BIT 0x00
51 #define DAC_BUS_FREE_TIME 5
52 #define DAC_START_SETUP_TIME 5
53 #define DAC_STOP_SETUP_TIME 4
54 #define DAC_START_HOLD_TIME 5
55 #define DAC_SCL_LOW_HOLD_TIME 5
56 #define DAC_SCL_HIGH_HOLD_TIME 4
57 #define DAC_DATA_SETUP_TIME 1
58 #define DAC_DATA_HOLD_TIME 1
59 #define DAC_LOW_SETUP_TIME 1
60 #define DAC_HIGH_SETUP_TIME 1
92 .name =
"locomo-keyboard",
99 .name =
"locomo-frontlight",
107 .name =
"locomo-backlight",
114 .name =
"locomo-audio",
121 .name =
"locomo-led",
128 .name =
"locomo-uart",
135 .name =
"locomo-spi",
143 struct locomo *lchip = irq_get_chip_data(irq);
155 for (i = 0; i <= 3; i++, irq++) {
156 if (req & (0x0100 << i)) {
164 static void locomo_ack_irq(
struct irq_data *
d)
168 static void locomo_mask_irq(
struct irq_data *
d)
170 struct locomo *lchip = irq_data_get_irq_chip_data(d);
177 static void locomo_unmask_irq(
struct irq_data *
d)
179 struct locomo *lchip = irq_data_get_irq_chip_data(d);
186 static struct irq_chip locomo_chip = {
188 .irq_ack = locomo_ack_irq,
189 .irq_mask = locomo_mask_irq,
190 .irq_unmask = locomo_unmask_irq,
193 static void locomo_setup_irq(
struct locomo *lchip)
202 irq_set_chained_handler(lchip->
irq, locomo_handler);
205 for ( ; irq <= lchip->
irq_base + 3; irq++) {
213 static void locomo_dev_release(
struct device *_dev)
236 if (lchip->
dev->dma_mask) {
243 dev->
dev.parent = lchip->
dev;
245 dev->
dev.release = locomo_dev_release;
246 dev->
dev.coherent_dma_mask = lchip->
dev->coherent_dma_mask;
267 struct locomo_save_data {
277 struct locomo *lchip = platform_get_drvdata(dev);
278 struct locomo_save_data *save;
285 lchip->saved_state = save;
314 spin_unlock_irqrestore(&lchip->
lock, flags);
321 struct locomo *lchip = platform_get_drvdata(dev);
322 struct locomo_save_data *save;
326 save = lchip->saved_state;
347 spin_unlock_irqrestore(&lchip->
lock, flags);
349 lchip->saved_state =
NULL;
456 locomo_setup_irq(lchip);
458 for (i = 0; i <
ARRAY_SIZE(locomo_devices); i++)
459 locomo_init_one_child(lchip, &locomo_devices[i]);
467 static int locomo_remove_child(
struct device *dev,
void *
data)
473 static void __locomo_remove(
struct locomo *lchip)
478 irq_set_chained_handler(lchip->
irq,
NULL);
498 return __locomo_probe(&dev->
dev, mem, irq);
503 struct locomo *lchip = platform_get_drvdata(dev);
506 __locomo_remove(lchip);
507 platform_set_drvdata(dev,
NULL);
520 .probe = locomo_probe,
521 .remove = locomo_remove,
523 .suspend = locomo_suspend,
524 .resume = locomo_resume,
565 spin_unlock_irqrestore(&lchip->
lock, flags);
580 spin_unlock_irqrestore(&lchip->
lock, flags);
598 spin_unlock_irqrestore(&lchip->
lock, flags);
623 spin_unlock_irqrestore(&lchip->
lock, flags);
627 static void locomo_m62332_sendbit(
void *mapbase,
int bit)
664 struct locomo *lchip = locomo_chip_driver(ldev);
668 void *mapbase = lchip->
base;
688 for (i = 1; i <= 8; i++) {
689 locomo_m62332_sendbit(mapbase, data >> (8 - i));
716 for (i = 1; i <= 8; i++) {
717 locomo_m62332_sendbit(mapbase, data >> (8 - i));
741 for (i = 1; i <= 8; i++) {
742 locomo_m62332_sendbit(mapbase, dac_data >> (8 - i));
788 spin_unlock_irqrestore(&lchip->
lock, flags);
799 struct locomo *lchip = locomo_chip_driver(dev);
811 spin_unlock_irqrestore(&lchip->
lock, flags);
836 ret = drv->
suspend(ldev, state);
840 static int locomo_bus_resume(
struct device *dev)
851 static int locomo_bus_probe(
struct device *dev)
858 ret = drv->
probe(ldev);
862 static int locomo_bus_remove(
struct device *dev)
874 .name =
"locomo-bus",
875 .match = locomo_match,
876 .probe = locomo_bus_probe,
877 .remove = locomo_bus_remove,
878 .suspend = locomo_bus_suspend,
879 .resume = locomo_bus_resume,
895 static int __init locomo_init(
void)
903 static void __exit locomo_exit(
void)