diff options
Diffstat (limited to 'arch/arm/common')
-rw-r--r-- | arch/arm/common/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/common/dmabounce.c | 3 | ||||
-rw-r--r-- | arch/arm/common/it8152.c | 5 | ||||
-rw-r--r-- | arch/arm/common/locomo.c | 66 | ||||
-rw-r--r-- | arch/arm/common/rtctime.c | 435 | ||||
-rw-r--r-- | arch/arm/common/scoop.c | 183 |
6 files changed, 200 insertions, 493 deletions
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile index 3d0b9fa42f84..325e4b6a6afb 100644 --- a/arch/arm/common/Makefile +++ b/arch/arm/common/Makefile | |||
@@ -2,7 +2,6 @@ | |||
2 | # Makefile for the linux kernel. | 2 | # Makefile for the linux kernel. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += rtctime.o | ||
6 | obj-$(CONFIG_ARM_GIC) += gic.o | 5 | obj-$(CONFIG_ARM_GIC) += gic.o |
7 | obj-$(CONFIG_ARM_VIC) += vic.o | 6 | obj-$(CONFIG_ARM_VIC) += vic.o |
8 | obj-$(CONFIG_ICST525) += icst525.o | 7 | obj-$(CONFIG_ICST525) += icst525.o |
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 52fc6a883281..2744673314b4 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c | |||
@@ -650,7 +650,8 @@ EXPORT_SYMBOL(dma_map_sg); | |||
650 | EXPORT_SYMBOL(dma_unmap_sg); | 650 | EXPORT_SYMBOL(dma_unmap_sg); |
651 | EXPORT_SYMBOL(dma_sync_single_for_cpu); | 651 | EXPORT_SYMBOL(dma_sync_single_for_cpu); |
652 | EXPORT_SYMBOL(dma_sync_single_for_device); | 652 | EXPORT_SYMBOL(dma_sync_single_for_device); |
653 | EXPORT_SYMBOL(dma_sync_sg); | 653 | EXPORT_SYMBOL(dma_sync_sg_for_cpu); |
654 | EXPORT_SYMBOL(dma_sync_sg_for_device); | ||
654 | EXPORT_SYMBOL(dmabounce_register_dev); | 655 | EXPORT_SYMBOL(dmabounce_register_dev); |
655 | EXPORT_SYMBOL(dmabounce_unregister_dev); | 656 | EXPORT_SYMBOL(dmabounce_unregister_dev); |
656 | 657 | ||
diff --git a/arch/arm/common/it8152.c b/arch/arm/common/it8152.c index 538262241483..5fe9588db077 100644 --- a/arch/arm/common/it8152.c +++ b/arch/arm/common/it8152.c | |||
@@ -120,6 +120,7 @@ void it8152_irq_demux(unsigned int irq, struct irq_desc *desc) | |||
120 | time, when they all three were 0. */ | 120 | time, when they all three were 0. */ |
121 | bits_pd = __raw_readl(IT8152_INTC_PDCNIRR); | 121 | bits_pd = __raw_readl(IT8152_INTC_PDCNIRR); |
122 | bits_lp = __raw_readl(IT8152_INTC_LPCNIRR); | 122 | bits_lp = __raw_readl(IT8152_INTC_LPCNIRR); |
123 | bits_ld = __raw_readl(IT8152_INTC_LDCNIRR); | ||
123 | if (!(bits_ld | bits_lp | bits_pd)) | 124 | if (!(bits_ld | bits_lp | bits_pd)) |
124 | return; | 125 | return; |
125 | } | 126 | } |
@@ -133,14 +134,14 @@ void it8152_irq_demux(unsigned int irq, struct irq_desc *desc) | |||
133 | 134 | ||
134 | bits_lp &= ((1 << IT8152_LP_IRQ_COUNT) - 1); | 135 | bits_lp &= ((1 << IT8152_LP_IRQ_COUNT) - 1); |
135 | while (bits_lp) { | 136 | while (bits_lp) { |
136 | i = __ffs(bits_pd); | 137 | i = __ffs(bits_lp); |
137 | it8152_irq(IT8152_LP_IRQ(i)); | 138 | it8152_irq(IT8152_LP_IRQ(i)); |
138 | bits_lp &= ~(1 << i); | 139 | bits_lp &= ~(1 << i); |
139 | } | 140 | } |
140 | 141 | ||
141 | bits_ld &= ((1 << IT8152_LD_IRQ_COUNT) - 1); | 142 | bits_ld &= ((1 << IT8152_LD_IRQ_COUNT) - 1); |
142 | while (bits_ld) { | 143 | while (bits_ld) { |
143 | i = __ffs(bits_pd); | 144 | i = __ffs(bits_ld); |
144 | it8152_irq(IT8152_LD_IRQ(i)); | 145 | it8152_irq(IT8152_LD_IRQ(i)); |
145 | bits_ld &= ~(1 << i); | 146 | bits_ld &= ~(1 << i); |
146 | } | 147 | } |
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c index ae21755872ed..d973c986f721 100644 --- a/arch/arm/common/locomo.c +++ b/arch/arm/common/locomo.c | |||
@@ -321,11 +321,42 @@ static void locomo_gpio_unmask_irq(unsigned int irq) | |||
321 | locomo_writel(r, mapbase + LOCOMO_GIE); | 321 | locomo_writel(r, mapbase + LOCOMO_GIE); |
322 | } | 322 | } |
323 | 323 | ||
324 | static int GPIO_IRQ_rising_edge; | ||
325 | static int GPIO_IRQ_falling_edge; | ||
326 | |||
327 | static int locomo_gpio_type(unsigned int irq, unsigned int type) | ||
328 | { | ||
329 | unsigned int mask; | ||
330 | void __iomem *mapbase = get_irq_chip_data(irq); | ||
331 | |||
332 | mask = 1 << (irq - LOCOMO_IRQ_GPIO_START); | ||
333 | |||
334 | if (type == IRQT_PROBE) { | ||
335 | if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask) | ||
336 | return 0; | ||
337 | type = __IRQT_RISEDGE | __IRQT_FALEDGE; | ||
338 | } | ||
339 | |||
340 | if (type & __IRQT_RISEDGE) | ||
341 | GPIO_IRQ_rising_edge |= mask; | ||
342 | else | ||
343 | GPIO_IRQ_rising_edge &= ~mask; | ||
344 | if (type & __IRQT_FALEDGE) | ||
345 | GPIO_IRQ_falling_edge |= mask; | ||
346 | else | ||
347 | GPIO_IRQ_falling_edge &= ~mask; | ||
348 | locomo_writel(GPIO_IRQ_rising_edge, mapbase + LOCOMO_GRIE); | ||
349 | locomo_writel(GPIO_IRQ_falling_edge, mapbase + LOCOMO_GFIE); | ||
350 | |||
351 | return 0; | ||
352 | } | ||
353 | |||
324 | static struct irq_chip locomo_gpio_chip = { | 354 | static struct irq_chip locomo_gpio_chip = { |
325 | .name = "LOCOMO-gpio", | 355 | .name = "LOCOMO-gpio", |
326 | .ack = locomo_gpio_ack_irq, | 356 | .ack = locomo_gpio_ack_irq, |
327 | .mask = locomo_gpio_mask_irq, | 357 | .mask = locomo_gpio_mask_irq, |
328 | .unmask = locomo_gpio_unmask_irq, | 358 | .unmask = locomo_gpio_unmask_irq, |
359 | .set_type = locomo_gpio_type, | ||
329 | }; | 360 | }; |
330 | 361 | ||
331 | static void locomo_lt_handler(unsigned int irq, struct irq_desc *desc) | 362 | static void locomo_lt_handler(unsigned int irq, struct irq_desc *desc) |
@@ -450,22 +481,18 @@ static void locomo_setup_irq(struct locomo *lchip) | |||
450 | set_irq_chip(IRQ_LOCOMO_KEY_BASE, &locomo_chip); | 481 | set_irq_chip(IRQ_LOCOMO_KEY_BASE, &locomo_chip); |
451 | set_irq_chip_data(IRQ_LOCOMO_KEY_BASE, irqbase); | 482 | set_irq_chip_data(IRQ_LOCOMO_KEY_BASE, irqbase); |
452 | set_irq_chained_handler(IRQ_LOCOMO_KEY_BASE, locomo_key_handler); | 483 | set_irq_chained_handler(IRQ_LOCOMO_KEY_BASE, locomo_key_handler); |
453 | set_irq_flags(IRQ_LOCOMO_KEY_BASE, IRQF_VALID | IRQF_PROBE); | ||
454 | 484 | ||
455 | set_irq_chip(IRQ_LOCOMO_GPIO_BASE, &locomo_chip); | 485 | set_irq_chip(IRQ_LOCOMO_GPIO_BASE, &locomo_chip); |
456 | set_irq_chip_data(IRQ_LOCOMO_GPIO_BASE, irqbase); | 486 | set_irq_chip_data(IRQ_LOCOMO_GPIO_BASE, irqbase); |
457 | set_irq_chained_handler(IRQ_LOCOMO_GPIO_BASE, locomo_gpio_handler); | 487 | set_irq_chained_handler(IRQ_LOCOMO_GPIO_BASE, locomo_gpio_handler); |
458 | set_irq_flags(IRQ_LOCOMO_GPIO_BASE, IRQF_VALID | IRQF_PROBE); | ||
459 | 488 | ||
460 | set_irq_chip(IRQ_LOCOMO_LT_BASE, &locomo_chip); | 489 | set_irq_chip(IRQ_LOCOMO_LT_BASE, &locomo_chip); |
461 | set_irq_chip_data(IRQ_LOCOMO_LT_BASE, irqbase); | 490 | set_irq_chip_data(IRQ_LOCOMO_LT_BASE, irqbase); |
462 | set_irq_chained_handler(IRQ_LOCOMO_LT_BASE, locomo_lt_handler); | 491 | set_irq_chained_handler(IRQ_LOCOMO_LT_BASE, locomo_lt_handler); |
463 | set_irq_flags(IRQ_LOCOMO_LT_BASE, IRQF_VALID | IRQF_PROBE); | ||
464 | 492 | ||
465 | set_irq_chip(IRQ_LOCOMO_SPI_BASE, &locomo_chip); | 493 | set_irq_chip(IRQ_LOCOMO_SPI_BASE, &locomo_chip); |
466 | set_irq_chip_data(IRQ_LOCOMO_SPI_BASE, irqbase); | 494 | set_irq_chip_data(IRQ_LOCOMO_SPI_BASE, irqbase); |
467 | set_irq_chained_handler(IRQ_LOCOMO_SPI_BASE, locomo_spi_handler); | 495 | set_irq_chained_handler(IRQ_LOCOMO_SPI_BASE, locomo_spi_handler); |
468 | set_irq_flags(IRQ_LOCOMO_SPI_BASE, IRQF_VALID | IRQF_PROBE); | ||
469 | 496 | ||
470 | /* install handlers for IRQ_LOCOMO_KEY_BASE generated interrupts */ | 497 | /* install handlers for IRQ_LOCOMO_KEY_BASE generated interrupts */ |
471 | set_irq_chip(LOCOMO_IRQ_KEY_START, &locomo_key_chip); | 498 | set_irq_chip(LOCOMO_IRQ_KEY_START, &locomo_key_chip); |
@@ -488,7 +515,7 @@ static void locomo_setup_irq(struct locomo *lchip) | |||
488 | set_irq_flags(LOCOMO_IRQ_LT_START, IRQF_VALID | IRQF_PROBE); | 515 | set_irq_flags(LOCOMO_IRQ_LT_START, IRQF_VALID | IRQF_PROBE); |
489 | 516 | ||
490 | /* install handlers for IRQ_LOCOMO_SPI_BASE generated interrupts */ | 517 | /* install handlers for IRQ_LOCOMO_SPI_BASE generated interrupts */ |
491 | for (irq = LOCOMO_IRQ_SPI_START; irq < LOCOMO_IRQ_SPI_START + 3; irq++) { | 518 | for (irq = LOCOMO_IRQ_SPI_START; irq < LOCOMO_IRQ_SPI_START + 4; irq++) { |
492 | set_irq_chip(irq, &locomo_spi_chip); | 519 | set_irq_chip(irq, &locomo_spi_chip); |
493 | set_irq_chip_data(irq, irqbase); | 520 | set_irq_chip_data(irq, irqbase); |
494 | set_irq_handler(irq, handle_edge_irq); | 521 | set_irq_handler(irq, handle_edge_irq); |
@@ -574,20 +601,20 @@ static int locomo_suspend(struct platform_device *dev, pm_message_t state) | |||
574 | 601 | ||
575 | save->LCM_GPO = locomo_readl(lchip->base + LOCOMO_GPO); /* GPIO */ | 602 | save->LCM_GPO = locomo_readl(lchip->base + LOCOMO_GPO); /* GPIO */ |
576 | locomo_writel(0x00, lchip->base + LOCOMO_GPO); | 603 | locomo_writel(0x00, lchip->base + LOCOMO_GPO); |
577 | save->LCM_SPICT = locomo_readl(lchip->base + LOCOMO_SPICT); /* SPI */ | 604 | save->LCM_SPICT = locomo_readl(lchip->base + LOCOMO_SPI + LOCOMO_SPICT); /* SPI */ |
578 | locomo_writel(0x40, lchip->base + LOCOMO_SPICT); | 605 | locomo_writel(0x40, lchip->base + LOCOMO_SPICT); |
579 | save->LCM_GPE = locomo_readl(lchip->base + LOCOMO_GPE); /* GPIO */ | 606 | save->LCM_GPE = locomo_readl(lchip->base + LOCOMO_GPE); /* GPIO */ |
580 | locomo_writel(0x00, lchip->base + LOCOMO_GPE); | 607 | locomo_writel(0x00, lchip->base + LOCOMO_GPE); |
581 | save->LCM_ASD = locomo_readl(lchip->base + LOCOMO_ASD); /* ADSTART */ | 608 | save->LCM_ASD = locomo_readl(lchip->base + LOCOMO_ASD); /* ADSTART */ |
582 | locomo_writel(0x00, lchip->base + LOCOMO_ASD); | 609 | locomo_writel(0x00, lchip->base + LOCOMO_ASD); |
583 | save->LCM_SPIMD = locomo_readl(lchip->base + LOCOMO_SPIMD); /* SPI */ | 610 | save->LCM_SPIMD = locomo_readl(lchip->base + LOCOMO_SPI + LOCOMO_SPIMD); /* SPI */ |
584 | locomo_writel(0x3C14, lchip->base + LOCOMO_SPIMD); | 611 | locomo_writel(0x3C14, lchip->base + LOCOMO_SPI + LOCOMO_SPIMD); |
585 | 612 | ||
586 | locomo_writel(0x00, lchip->base + LOCOMO_PAIF); | 613 | locomo_writel(0x00, lchip->base + LOCOMO_PAIF); |
587 | locomo_writel(0x00, lchip->base + LOCOMO_DAC); | 614 | locomo_writel(0x00, lchip->base + LOCOMO_DAC); |
588 | locomo_writel(0x00, lchip->base + LOCOMO_BACKLIGHT + LOCOMO_TC); | 615 | locomo_writel(0x00, lchip->base + LOCOMO_BACKLIGHT + LOCOMO_TC); |
589 | 616 | ||
590 | if ( (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT0) & 0x88) && (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT1) & 0x88) ) | 617 | if ((locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT0) & 0x88) && (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT1) & 0x88)) |
591 | locomo_writel(0x00, lchip->base + LOCOMO_C32K); /* CLK32 off */ | 618 | locomo_writel(0x00, lchip->base + LOCOMO_C32K); /* CLK32 off */ |
592 | else | 619 | else |
593 | /* 18MHz already enabled, so no wait */ | 620 | /* 18MHz already enabled, so no wait */ |
@@ -616,10 +643,10 @@ static int locomo_resume(struct platform_device *dev) | |||
616 | spin_lock_irqsave(&lchip->lock, flags); | 643 | spin_lock_irqsave(&lchip->lock, flags); |
617 | 644 | ||
618 | locomo_writel(save->LCM_GPO, lchip->base + LOCOMO_GPO); | 645 | locomo_writel(save->LCM_GPO, lchip->base + LOCOMO_GPO); |
619 | locomo_writel(save->LCM_SPICT, lchip->base + LOCOMO_SPICT); | 646 | locomo_writel(save->LCM_SPICT, lchip->base + LOCOMO_SPI + LOCOMO_SPICT); |
620 | locomo_writel(save->LCM_GPE, lchip->base + LOCOMO_GPE); | 647 | locomo_writel(save->LCM_GPE, lchip->base + LOCOMO_GPE); |
621 | locomo_writel(save->LCM_ASD, lchip->base + LOCOMO_ASD); | 648 | locomo_writel(save->LCM_ASD, lchip->base + LOCOMO_ASD); |
622 | locomo_writel(save->LCM_SPIMD, lchip->base + LOCOMO_SPIMD); | 649 | locomo_writel(save->LCM_SPIMD, lchip->base + LOCOMO_SPI + LOCOMO_SPIMD); |
623 | 650 | ||
624 | locomo_writel(0x00, lchip->base + LOCOMO_C32K); | 651 | locomo_writel(0x00, lchip->base + LOCOMO_C32K); |
625 | locomo_writel(0x90, lchip->base + LOCOMO_TADC); | 652 | locomo_writel(0x90, lchip->base + LOCOMO_TADC); |
@@ -688,9 +715,9 @@ __locomo_probe(struct device *me, struct resource *mem, int irq) | |||
688 | 715 | ||
689 | /* GPIO */ | 716 | /* GPIO */ |
690 | locomo_writel(0, lchip->base + LOCOMO_GPO); | 717 | locomo_writel(0, lchip->base + LOCOMO_GPO); |
691 | locomo_writel( (LOCOMO_GPIO(2) | LOCOMO_GPIO(3) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14)) | 718 | locomo_writel((LOCOMO_GPIO(1) | LOCOMO_GPIO(2) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14)) |
692 | , lchip->base + LOCOMO_GPE); | 719 | , lchip->base + LOCOMO_GPE); |
693 | locomo_writel( (LOCOMO_GPIO(2) | LOCOMO_GPIO(3) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14)) | 720 | locomo_writel((LOCOMO_GPIO(1) | LOCOMO_GPIO(2) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14)) |
694 | , lchip->base + LOCOMO_GPD); | 721 | , lchip->base + LOCOMO_GPD); |
695 | locomo_writel(0, lchip->base + LOCOMO_GIE); | 722 | locomo_writel(0, lchip->base + LOCOMO_GIE); |
696 | 723 | ||
@@ -833,7 +860,10 @@ void locomo_gpio_set_dir(struct device *dev, unsigned int bits, unsigned int dir | |||
833 | spin_lock_irqsave(&lchip->lock, flags); | 860 | spin_lock_irqsave(&lchip->lock, flags); |
834 | 861 | ||
835 | r = locomo_readl(lchip->base + LOCOMO_GPD); | 862 | r = locomo_readl(lchip->base + LOCOMO_GPD); |
836 | r &= ~bits; | 863 | if (dir) |
864 | r |= bits; | ||
865 | else | ||
866 | r &= ~bits; | ||
837 | locomo_writel(r, lchip->base + LOCOMO_GPD); | 867 | locomo_writel(r, lchip->base + LOCOMO_GPD); |
838 | 868 | ||
839 | r = locomo_readl(lchip->base + LOCOMO_GPE); | 869 | r = locomo_readl(lchip->base + LOCOMO_GPE); |
diff --git a/arch/arm/common/rtctime.c b/arch/arm/common/rtctime.c deleted file mode 100644 index f53bca46e23c..000000000000 --- a/arch/arm/common/rtctime.c +++ /dev/null | |||
@@ -1,435 +0,0 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/common/rtctime.c | ||
3 | * | ||
4 | * Copyright (C) 2003 Deep Blue Solutions Ltd. | ||
5 | * Based on sa1100-rtc.c, Nils Faerber, CIH, Nicolas Pitre. | ||
6 | * Based on rtc.c by Paul Gortmaker | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/time.h> | ||
15 | #include <linux/rtc.h> | ||
16 | #include <linux/poll.h> | ||
17 | #include <linux/proc_fs.h> | ||
18 | #include <linux/miscdevice.h> | ||
19 | #include <linux/spinlock.h> | ||
20 | #include <linux/capability.h> | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/mutex.h> | ||
23 | |||
24 | #include <asm/rtc.h> | ||
25 | #include <asm/semaphore.h> | ||
26 | |||
27 | static DECLARE_WAIT_QUEUE_HEAD(rtc_wait); | ||
28 | static struct fasync_struct *rtc_async_queue; | ||
29 | |||
30 | /* | ||
31 | * rtc_lock protects rtc_irq_data | ||
32 | */ | ||
33 | static DEFINE_SPINLOCK(rtc_lock); | ||
34 | static unsigned long rtc_irq_data; | ||
35 | |||
36 | /* | ||
37 | * rtc_sem protects rtc_inuse and rtc_ops | ||
38 | */ | ||
39 | static DEFINE_MUTEX(rtc_mutex); | ||
40 | static unsigned long rtc_inuse; | ||
41 | static struct rtc_ops *rtc_ops; | ||
42 | |||
43 | #define rtc_epoch 1900UL | ||
44 | |||
45 | /* | ||
46 | * Calculate the next alarm time given the requested alarm time mask | ||
47 | * and the current time. | ||
48 | */ | ||
49 | void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc_time *alrm) | ||
50 | { | ||
51 | unsigned long next_time; | ||
52 | unsigned long now_time; | ||
53 | |||
54 | next->tm_year = now->tm_year; | ||
55 | next->tm_mon = now->tm_mon; | ||
56 | next->tm_mday = now->tm_mday; | ||
57 | next->tm_hour = alrm->tm_hour; | ||
58 | next->tm_min = alrm->tm_min; | ||
59 | next->tm_sec = alrm->tm_sec; | ||
60 | |||
61 | rtc_tm_to_time(now, &now_time); | ||
62 | rtc_tm_to_time(next, &next_time); | ||
63 | |||
64 | if (next_time < now_time) { | ||
65 | /* Advance one day */ | ||
66 | next_time += 60 * 60 * 24; | ||
67 | rtc_time_to_tm(next_time, next); | ||
68 | } | ||
69 | } | ||
70 | EXPORT_SYMBOL(rtc_next_alarm_time); | ||
71 | |||
72 | static inline int rtc_arm_read_time(struct rtc_ops *ops, struct rtc_time *tm) | ||
73 | { | ||
74 | memset(tm, 0, sizeof(struct rtc_time)); | ||
75 | return ops->read_time(tm); | ||
76 | } | ||
77 | |||
78 | static inline int rtc_arm_set_time(struct rtc_ops *ops, struct rtc_time *tm) | ||
79 | { | ||
80 | int ret; | ||
81 | |||
82 | ret = rtc_valid_tm(tm); | ||
83 | if (ret == 0) | ||
84 | ret = ops->set_time(tm); | ||
85 | |||
86 | return ret; | ||
87 | } | ||
88 | |||
89 | static inline int rtc_arm_read_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm) | ||
90 | { | ||
91 | int ret = -EINVAL; | ||
92 | if (ops->read_alarm) { | ||
93 | memset(alrm, 0, sizeof(struct rtc_wkalrm)); | ||
94 | ret = ops->read_alarm(alrm); | ||
95 | } | ||
96 | return ret; | ||
97 | } | ||
98 | |||
99 | static inline int rtc_arm_set_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm) | ||
100 | { | ||
101 | int ret = -EINVAL; | ||
102 | if (ops->set_alarm) | ||
103 | ret = ops->set_alarm(alrm); | ||
104 | return ret; | ||
105 | } | ||
106 | |||
107 | void rtc_update(unsigned long num, unsigned long events) | ||
108 | { | ||
109 | spin_lock(&rtc_lock); | ||
110 | rtc_irq_data = (rtc_irq_data + (num << 8)) | events; | ||
111 | spin_unlock(&rtc_lock); | ||
112 | |||
113 | wake_up_interruptible(&rtc_wait); | ||
114 | kill_fasync(&rtc_async_queue, SIGIO, POLL_IN); | ||
115 | } | ||
116 | EXPORT_SYMBOL(rtc_update); | ||
117 | |||
118 | |||
119 | static ssize_t | ||
120 | rtc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | ||
121 | { | ||
122 | DECLARE_WAITQUEUE(wait, current); | ||
123 | unsigned long data; | ||
124 | ssize_t ret; | ||
125 | |||
126 | if (count < sizeof(unsigned long)) | ||
127 | return -EINVAL; | ||
128 | |||
129 | add_wait_queue(&rtc_wait, &wait); | ||
130 | do { | ||
131 | __set_current_state(TASK_INTERRUPTIBLE); | ||
132 | |||
133 | spin_lock_irq(&rtc_lock); | ||
134 | data = rtc_irq_data; | ||
135 | rtc_irq_data = 0; | ||
136 | spin_unlock_irq(&rtc_lock); | ||
137 | |||
138 | if (data != 0) { | ||
139 | ret = 0; | ||
140 | break; | ||
141 | } | ||
142 | if (file->f_flags & O_NONBLOCK) { | ||
143 | ret = -EAGAIN; | ||
144 | break; | ||
145 | } | ||
146 | if (signal_pending(current)) { | ||
147 | ret = -ERESTARTSYS; | ||
148 | break; | ||
149 | } | ||
150 | schedule(); | ||
151 | } while (1); | ||
152 | set_current_state(TASK_RUNNING); | ||
153 | remove_wait_queue(&rtc_wait, &wait); | ||
154 | |||
155 | if (ret == 0) { | ||
156 | ret = put_user(data, (unsigned long __user *)buf); | ||
157 | if (ret == 0) | ||
158 | ret = sizeof(unsigned long); | ||
159 | } | ||
160 | return ret; | ||
161 | } | ||
162 | |||
163 | static unsigned int rtc_poll(struct file *file, poll_table *wait) | ||
164 | { | ||
165 | unsigned long data; | ||
166 | |||
167 | poll_wait(file, &rtc_wait, wait); | ||
168 | |||
169 | spin_lock_irq(&rtc_lock); | ||
170 | data = rtc_irq_data; | ||
171 | spin_unlock_irq(&rtc_lock); | ||
172 | |||
173 | return data != 0 ? POLLIN | POLLRDNORM : 0; | ||
174 | } | ||
175 | |||
176 | static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | ||
177 | unsigned long arg) | ||
178 | { | ||
179 | struct rtc_ops *ops = file->private_data; | ||
180 | struct rtc_time tm; | ||
181 | struct rtc_wkalrm alrm; | ||
182 | void __user *uarg = (void __user *)arg; | ||
183 | int ret = -EINVAL; | ||
184 | |||
185 | switch (cmd) { | ||
186 | case RTC_ALM_READ: | ||
187 | ret = rtc_arm_read_alarm(ops, &alrm); | ||
188 | if (ret) | ||
189 | break; | ||
190 | ret = copy_to_user(uarg, &alrm.time, sizeof(tm)); | ||
191 | if (ret) | ||
192 | ret = -EFAULT; | ||
193 | break; | ||
194 | |||
195 | case RTC_ALM_SET: | ||
196 | ret = copy_from_user(&alrm.time, uarg, sizeof(tm)); | ||
197 | if (ret) { | ||
198 | ret = -EFAULT; | ||
199 | break; | ||
200 | } | ||
201 | alrm.enabled = 0; | ||
202 | alrm.pending = 0; | ||
203 | alrm.time.tm_mday = -1; | ||
204 | alrm.time.tm_mon = -1; | ||
205 | alrm.time.tm_year = -1; | ||
206 | alrm.time.tm_wday = -1; | ||
207 | alrm.time.tm_yday = -1; | ||
208 | alrm.time.tm_isdst = -1; | ||
209 | ret = rtc_arm_set_alarm(ops, &alrm); | ||
210 | break; | ||
211 | |||
212 | case RTC_RD_TIME: | ||
213 | ret = rtc_arm_read_time(ops, &tm); | ||
214 | if (ret) | ||
215 | break; | ||
216 | ret = copy_to_user(uarg, &tm, sizeof(tm)); | ||
217 | if (ret) | ||
218 | ret = -EFAULT; | ||
219 | break; | ||
220 | |||
221 | case RTC_SET_TIME: | ||
222 | if (!capable(CAP_SYS_TIME)) { | ||
223 | ret = -EACCES; | ||
224 | break; | ||
225 | } | ||
226 | ret = copy_from_user(&tm, uarg, sizeof(tm)); | ||
227 | if (ret) { | ||
228 | ret = -EFAULT; | ||
229 | break; | ||
230 | } | ||
231 | ret = rtc_arm_set_time(ops, &tm); | ||
232 | break; | ||
233 | |||
234 | case RTC_EPOCH_SET: | ||
235 | #ifndef rtc_epoch | ||
236 | /* | ||
237 | * There were no RTC clocks before 1900. | ||
238 | */ | ||
239 | if (arg < 1900) { | ||
240 | ret = -EINVAL; | ||
241 | break; | ||
242 | } | ||
243 | if (!capable(CAP_SYS_TIME)) { | ||
244 | ret = -EACCES; | ||
245 | break; | ||
246 | } | ||
247 | rtc_epoch = arg; | ||
248 | ret = 0; | ||
249 | #endif | ||
250 | break; | ||
251 | |||
252 | case RTC_EPOCH_READ: | ||
253 | ret = put_user(rtc_epoch, (unsigned long __user *)uarg); | ||
254 | break; | ||
255 | |||
256 | case RTC_WKALM_SET: | ||
257 | ret = copy_from_user(&alrm, uarg, sizeof(alrm)); | ||
258 | if (ret) { | ||
259 | ret = -EFAULT; | ||
260 | break; | ||
261 | } | ||
262 | ret = rtc_arm_set_alarm(ops, &alrm); | ||
263 | break; | ||
264 | |||
265 | case RTC_WKALM_RD: | ||
266 | ret = rtc_arm_read_alarm(ops, &alrm); | ||
267 | if (ret) | ||
268 | break; | ||
269 | ret = copy_to_user(uarg, &alrm, sizeof(alrm)); | ||
270 | if (ret) | ||
271 | ret = -EFAULT; | ||
272 | break; | ||
273 | |||
274 | default: | ||
275 | if (ops->ioctl) | ||
276 | ret = ops->ioctl(cmd, arg); | ||
277 | break; | ||
278 | } | ||
279 | return ret; | ||
280 | } | ||
281 | |||
282 | static int rtc_open(struct inode *inode, struct file *file) | ||
283 | { | ||
284 | int ret; | ||
285 | |||
286 | mutex_lock(&rtc_mutex); | ||
287 | |||
288 | if (rtc_inuse) { | ||
289 | ret = -EBUSY; | ||
290 | } else if (!rtc_ops || !try_module_get(rtc_ops->owner)) { | ||
291 | ret = -ENODEV; | ||
292 | } else { | ||
293 | file->private_data = rtc_ops; | ||
294 | |||
295 | ret = rtc_ops->open ? rtc_ops->open() : 0; | ||
296 | if (ret == 0) { | ||
297 | spin_lock_irq(&rtc_lock); | ||
298 | rtc_irq_data = 0; | ||
299 | spin_unlock_irq(&rtc_lock); | ||
300 | |||
301 | rtc_inuse = 1; | ||
302 | } | ||
303 | } | ||
304 | mutex_unlock(&rtc_mutex); | ||
305 | |||
306 | return ret; | ||
307 | } | ||
308 | |||
309 | static int rtc_release(struct inode *inode, struct file *file) | ||
310 | { | ||
311 | struct rtc_ops *ops = file->private_data; | ||
312 | |||
313 | if (ops->release) | ||
314 | ops->release(); | ||
315 | |||
316 | spin_lock_irq(&rtc_lock); | ||
317 | rtc_irq_data = 0; | ||
318 | spin_unlock_irq(&rtc_lock); | ||
319 | |||
320 | module_put(rtc_ops->owner); | ||
321 | rtc_inuse = 0; | ||
322 | |||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | static int rtc_fasync(int fd, struct file *file, int on) | ||
327 | { | ||
328 | return fasync_helper(fd, file, on, &rtc_async_queue); | ||
329 | } | ||
330 | |||
331 | static const struct file_operations rtc_fops = { | ||
332 | .owner = THIS_MODULE, | ||
333 | .llseek = no_llseek, | ||
334 | .read = rtc_read, | ||
335 | .poll = rtc_poll, | ||
336 | .ioctl = rtc_ioctl, | ||
337 | .open = rtc_open, | ||
338 | .release = rtc_release, | ||
339 | .fasync = rtc_fasync, | ||
340 | }; | ||
341 | |||
342 | static struct miscdevice rtc_miscdev = { | ||
343 | .minor = RTC_MINOR, | ||
344 | .name = "rtc", | ||
345 | .fops = &rtc_fops, | ||
346 | }; | ||
347 | |||
348 | |||
349 | static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) | ||
350 | { | ||
351 | struct rtc_ops *ops = data; | ||
352 | struct rtc_wkalrm alrm; | ||
353 | struct rtc_time tm; | ||
354 | char *p = page; | ||
355 | |||
356 | if (rtc_arm_read_time(ops, &tm) == 0) { | ||
357 | p += sprintf(p, | ||
358 | "rtc_time\t: %02d:%02d:%02d\n" | ||
359 | "rtc_date\t: %04d-%02d-%02d\n" | ||
360 | "rtc_epoch\t: %04lu\n", | ||
361 | tm.tm_hour, tm.tm_min, tm.tm_sec, | ||
362 | tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, | ||
363 | rtc_epoch); | ||
364 | } | ||
365 | |||
366 | if (rtc_arm_read_alarm(ops, &alrm) == 0) { | ||
367 | p += sprintf(p, "alrm_time\t: "); | ||
368 | if ((unsigned int)alrm.time.tm_hour <= 24) | ||
369 | p += sprintf(p, "%02d:", alrm.time.tm_hour); | ||
370 | else | ||
371 | p += sprintf(p, "**:"); | ||
372 | if ((unsigned int)alrm.time.tm_min <= 59) | ||
373 | p += sprintf(p, "%02d:", alrm.time.tm_min); | ||
374 | else | ||
375 | p += sprintf(p, "**:"); | ||
376 | if ((unsigned int)alrm.time.tm_sec <= 59) | ||
377 | p += sprintf(p, "%02d\n", alrm.time.tm_sec); | ||
378 | else | ||
379 | p += sprintf(p, "**\n"); | ||
380 | |||
381 | p += sprintf(p, "alrm_date\t: "); | ||
382 | if ((unsigned int)alrm.time.tm_year <= 200) | ||
383 | p += sprintf(p, "%04d-", alrm.time.tm_year + 1900); | ||
384 | else | ||
385 | p += sprintf(p, "****-"); | ||
386 | if ((unsigned int)alrm.time.tm_mon <= 11) | ||
387 | p += sprintf(p, "%02d-", alrm.time.tm_mon + 1); | ||
388 | else | ||
389 | p += sprintf(p, "**-"); | ||
390 | if ((unsigned int)alrm.time.tm_mday <= 31) | ||
391 | p += sprintf(p, "%02d\n", alrm.time.tm_mday); | ||
392 | else | ||
393 | p += sprintf(p, "**\n"); | ||
394 | p += sprintf(p, "alrm_wakeup\t: %s\n", | ||
395 | alrm.enabled ? "yes" : "no"); | ||
396 | p += sprintf(p, "alrm_pending\t: %s\n", | ||
397 | alrm.pending ? "yes" : "no"); | ||
398 | } | ||
399 | |||
400 | if (ops->proc) | ||
401 | p += ops->proc(p); | ||
402 | |||
403 | return p - page; | ||
404 | } | ||
405 | |||
406 | int register_rtc(struct rtc_ops *ops) | ||
407 | { | ||
408 | int ret = -EBUSY; | ||
409 | |||
410 | mutex_lock(&rtc_mutex); | ||
411 | if (rtc_ops == NULL) { | ||
412 | rtc_ops = ops; | ||
413 | |||
414 | ret = misc_register(&rtc_miscdev); | ||
415 | if (ret == 0) | ||
416 | create_proc_read_entry("driver/rtc", 0, NULL, | ||
417 | rtc_read_proc, ops); | ||
418 | } | ||
419 | mutex_unlock(&rtc_mutex); | ||
420 | |||
421 | return ret; | ||
422 | } | ||
423 | EXPORT_SYMBOL(register_rtc); | ||
424 | |||
425 | void unregister_rtc(struct rtc_ops *rtc) | ||
426 | { | ||
427 | mutex_lock(&rtc_mutex); | ||
428 | if (rtc == rtc_ops) { | ||
429 | remove_proc_entry("driver/rtc", NULL); | ||
430 | misc_deregister(&rtc_miscdev); | ||
431 | rtc_ops = NULL; | ||
432 | } | ||
433 | mutex_unlock(&rtc_mutex); | ||
434 | } | ||
435 | EXPORT_SYMBOL(unregister_rtc); | ||
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c index 314ebd3a1d71..bc299b07a6fa 100644 --- a/arch/arm/common/scoop.c +++ b/arch/arm/common/scoop.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <asm/io.h> | 18 | #include <asm/io.h> |
19 | #include <asm/gpio.h> | ||
19 | #include <asm/hardware/scoop.h> | 20 | #include <asm/hardware/scoop.h> |
20 | 21 | ||
21 | /* PCMCIA to Scoop linkage | 22 | /* PCMCIA to Scoop linkage |
@@ -30,10 +31,9 @@ | |||
30 | struct scoop_pcmcia_config *platform_scoop_config; | 31 | struct scoop_pcmcia_config *platform_scoop_config; |
31 | EXPORT_SYMBOL(platform_scoop_config); | 32 | EXPORT_SYMBOL(platform_scoop_config); |
32 | 33 | ||
33 | #define SCOOP_REG(d,adr) (*(volatile unsigned short*)(d +(adr))) | ||
34 | |||
35 | struct scoop_dev { | 34 | struct scoop_dev { |
36 | void *base; | 35 | void __iomem *base; |
36 | struct gpio_chip gpio; | ||
37 | spinlock_t scoop_lock; | 37 | spinlock_t scoop_lock; |
38 | unsigned short suspend_clr; | 38 | unsigned short suspend_clr; |
39 | unsigned short suspend_set; | 39 | unsigned short suspend_set; |
@@ -44,13 +44,84 @@ void reset_scoop(struct device *dev) | |||
44 | { | 44 | { |
45 | struct scoop_dev *sdev = dev_get_drvdata(dev); | 45 | struct scoop_dev *sdev = dev_get_drvdata(dev); |
46 | 46 | ||
47 | SCOOP_REG(sdev->base,SCOOP_MCR) = 0x0100; // 00 | 47 | iowrite16(0x0100, sdev->base + SCOOP_MCR); // 00 |
48 | SCOOP_REG(sdev->base,SCOOP_CDR) = 0x0000; // 04 | 48 | iowrite16(0x0000, sdev->base + SCOOP_CDR); // 04 |
49 | SCOOP_REG(sdev->base,SCOOP_CCR) = 0x0000; // 10 | 49 | iowrite16(0x0000, sdev->base + SCOOP_CCR); // 10 |
50 | SCOOP_REG(sdev->base,SCOOP_IMR) = 0x0000; // 18 | 50 | iowrite16(0x0000, sdev->base + SCOOP_IMR); // 18 |
51 | SCOOP_REG(sdev->base,SCOOP_IRM) = 0x00FF; // 14 | 51 | iowrite16(0x00FF, sdev->base + SCOOP_IRM); // 14 |
52 | SCOOP_REG(sdev->base,SCOOP_ISR) = 0x0000; // 1C | 52 | iowrite16(0x0000, sdev->base + SCOOP_ISR); // 1C |
53 | SCOOP_REG(sdev->base,SCOOP_IRM) = 0x0000; | 53 | iowrite16(0x0000, sdev->base + SCOOP_IRM); |
54 | } | ||
55 | |||
56 | static void __scoop_gpio_set(struct scoop_dev *sdev, | ||
57 | unsigned offset, int value) | ||
58 | { | ||
59 | unsigned short gpwr; | ||
60 | |||
61 | gpwr = ioread16(sdev->base + SCOOP_GPWR); | ||
62 | if (value) | ||
63 | gpwr |= 1 << (offset + 1); | ||
64 | else | ||
65 | gpwr &= ~(1 << (offset + 1)); | ||
66 | iowrite16(gpwr, sdev->base + SCOOP_GPWR); | ||
67 | } | ||
68 | |||
69 | static void scoop_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | ||
70 | { | ||
71 | struct scoop_dev *sdev = container_of(chip, struct scoop_dev, gpio); | ||
72 | unsigned long flags; | ||
73 | |||
74 | spin_lock_irqsave(&sdev->scoop_lock, flags); | ||
75 | |||
76 | __scoop_gpio_set(sdev, offset, value); | ||
77 | |||
78 | spin_unlock_irqrestore(&sdev->scoop_lock, flags); | ||
79 | } | ||
80 | |||
81 | static int scoop_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
82 | { | ||
83 | struct scoop_dev *sdev = container_of(chip, struct scoop_dev, gpio); | ||
84 | |||
85 | /* XXX: I'm usure, but it seems so */ | ||
86 | return ioread16(sdev->base + SCOOP_GPRR) & (1 << (offset + 1)); | ||
87 | } | ||
88 | |||
89 | static int scoop_gpio_direction_input(struct gpio_chip *chip, | ||
90 | unsigned offset) | ||
91 | { | ||
92 | struct scoop_dev *sdev = container_of(chip, struct scoop_dev, gpio); | ||
93 | unsigned long flags; | ||
94 | unsigned short gpcr; | ||
95 | |||
96 | spin_lock_irqsave(&sdev->scoop_lock, flags); | ||
97 | |||
98 | gpcr = ioread16(sdev->base + SCOOP_GPCR); | ||
99 | gpcr &= ~(1 << (offset + 1)); | ||
100 | iowrite16(gpcr, sdev->base + SCOOP_GPCR); | ||
101 | |||
102 | spin_unlock_irqrestore(&sdev->scoop_lock, flags); | ||
103 | |||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | static int scoop_gpio_direction_output(struct gpio_chip *chip, | ||
108 | unsigned offset, int value) | ||
109 | { | ||
110 | struct scoop_dev *sdev = container_of(chip, struct scoop_dev, gpio); | ||
111 | unsigned long flags; | ||
112 | unsigned short gpcr; | ||
113 | |||
114 | spin_lock_irqsave(&sdev->scoop_lock, flags); | ||
115 | |||
116 | __scoop_gpio_set(sdev, offset, value); | ||
117 | |||
118 | gpcr = ioread16(sdev->base + SCOOP_GPCR); | ||
119 | gpcr |= 1 << (offset + 1); | ||
120 | iowrite16(gpcr, sdev->base + SCOOP_GPCR); | ||
121 | |||
122 | spin_unlock_irqrestore(&sdev->scoop_lock, flags); | ||
123 | |||
124 | return 0; | ||
54 | } | 125 | } |
55 | 126 | ||
56 | unsigned short set_scoop_gpio(struct device *dev, unsigned short bit) | 127 | unsigned short set_scoop_gpio(struct device *dev, unsigned short bit) |
@@ -60,8 +131,8 @@ unsigned short set_scoop_gpio(struct device *dev, unsigned short bit) | |||
60 | struct scoop_dev *sdev = dev_get_drvdata(dev); | 131 | struct scoop_dev *sdev = dev_get_drvdata(dev); |
61 | 132 | ||
62 | spin_lock_irqsave(&sdev->scoop_lock, flag); | 133 | spin_lock_irqsave(&sdev->scoop_lock, flag); |
63 | gpio_bit = SCOOP_REG(sdev->base, SCOOP_GPWR) | bit; | 134 | gpio_bit = ioread16(sdev->base + SCOOP_GPWR) | bit; |
64 | SCOOP_REG(sdev->base, SCOOP_GPWR) = gpio_bit; | 135 | iowrite16(gpio_bit, sdev->base + SCOOP_GPWR); |
65 | spin_unlock_irqrestore(&sdev->scoop_lock, flag); | 136 | spin_unlock_irqrestore(&sdev->scoop_lock, flag); |
66 | 137 | ||
67 | return gpio_bit; | 138 | return gpio_bit; |
@@ -74,8 +145,8 @@ unsigned short reset_scoop_gpio(struct device *dev, unsigned short bit) | |||
74 | struct scoop_dev *sdev = dev_get_drvdata(dev); | 145 | struct scoop_dev *sdev = dev_get_drvdata(dev); |
75 | 146 | ||
76 | spin_lock_irqsave(&sdev->scoop_lock, flag); | 147 | spin_lock_irqsave(&sdev->scoop_lock, flag); |
77 | gpio_bit = SCOOP_REG(sdev->base, SCOOP_GPWR) & ~bit; | 148 | gpio_bit = ioread16(sdev->base + SCOOP_GPWR) & ~bit; |
78 | SCOOP_REG(sdev->base,SCOOP_GPWR) = gpio_bit; | 149 | iowrite16(gpio_bit, sdev->base + SCOOP_GPWR); |
79 | spin_unlock_irqrestore(&sdev->scoop_lock, flag); | 150 | spin_unlock_irqrestore(&sdev->scoop_lock, flag); |
80 | 151 | ||
81 | return gpio_bit; | 152 | return gpio_bit; |
@@ -87,13 +158,13 @@ EXPORT_SYMBOL(reset_scoop_gpio); | |||
87 | unsigned short read_scoop_reg(struct device *dev, unsigned short reg) | 158 | unsigned short read_scoop_reg(struct device *dev, unsigned short reg) |
88 | { | 159 | { |
89 | struct scoop_dev *sdev = dev_get_drvdata(dev); | 160 | struct scoop_dev *sdev = dev_get_drvdata(dev); |
90 | return SCOOP_REG(sdev->base,reg); | 161 | return ioread16(sdev->base + reg); |
91 | } | 162 | } |
92 | 163 | ||
93 | void write_scoop_reg(struct device *dev, unsigned short reg, unsigned short data) | 164 | void write_scoop_reg(struct device *dev, unsigned short reg, unsigned short data) |
94 | { | 165 | { |
95 | struct scoop_dev *sdev = dev_get_drvdata(dev); | 166 | struct scoop_dev *sdev = dev_get_drvdata(dev); |
96 | SCOOP_REG(sdev->base,reg)=data; | 167 | iowrite16(data, sdev->base + reg); |
97 | } | 168 | } |
98 | 169 | ||
99 | EXPORT_SYMBOL(reset_scoop); | 170 | EXPORT_SYMBOL(reset_scoop); |
@@ -104,9 +175,9 @@ static void check_scoop_reg(struct scoop_dev *sdev) | |||
104 | { | 175 | { |
105 | unsigned short mcr; | 176 | unsigned short mcr; |
106 | 177 | ||
107 | mcr = SCOOP_REG(sdev->base, SCOOP_MCR); | 178 | mcr = ioread16(sdev->base + SCOOP_MCR); |
108 | if ((mcr & 0x100) == 0) | 179 | if ((mcr & 0x100) == 0) |
109 | SCOOP_REG(sdev->base, SCOOP_MCR) = 0x0101; | 180 | iowrite16(0x0101, sdev->base + SCOOP_MCR); |
110 | } | 181 | } |
111 | 182 | ||
112 | #ifdef CONFIG_PM | 183 | #ifdef CONFIG_PM |
@@ -115,8 +186,8 @@ static int scoop_suspend(struct platform_device *dev, pm_message_t state) | |||
115 | struct scoop_dev *sdev = platform_get_drvdata(dev); | 186 | struct scoop_dev *sdev = platform_get_drvdata(dev); |
116 | 187 | ||
117 | check_scoop_reg(sdev); | 188 | check_scoop_reg(sdev); |
118 | sdev->scoop_gpwr = SCOOP_REG(sdev->base, SCOOP_GPWR); | 189 | sdev->scoop_gpwr = ioread16(sdev->base + SCOOP_GPWR); |
119 | SCOOP_REG(sdev->base, SCOOP_GPWR) = (sdev->scoop_gpwr & ~sdev->suspend_clr) | sdev->suspend_set; | 190 | iowrite16((sdev->scoop_gpwr & ~sdev->suspend_clr) | sdev->suspend_set, sdev->base + SCOOP_GPWR); |
120 | 191 | ||
121 | return 0; | 192 | return 0; |
122 | } | 193 | } |
@@ -126,7 +197,7 @@ static int scoop_resume(struct platform_device *dev) | |||
126 | struct scoop_dev *sdev = platform_get_drvdata(dev); | 197 | struct scoop_dev *sdev = platform_get_drvdata(dev); |
127 | 198 | ||
128 | check_scoop_reg(sdev); | 199 | check_scoop_reg(sdev); |
129 | SCOOP_REG(sdev->base,SCOOP_GPWR) = sdev->scoop_gpwr; | 200 | iowrite16(sdev->scoop_gpwr, sdev->base + SCOOP_GPWR); |
130 | 201 | ||
131 | return 0; | 202 | return 0; |
132 | } | 203 | } |
@@ -135,11 +206,13 @@ static int scoop_resume(struct platform_device *dev) | |||
135 | #define scoop_resume NULL | 206 | #define scoop_resume NULL |
136 | #endif | 207 | #endif |
137 | 208 | ||
138 | int __init scoop_probe(struct platform_device *pdev) | 209 | static int __devinit scoop_probe(struct platform_device *pdev) |
139 | { | 210 | { |
140 | struct scoop_dev *devptr; | 211 | struct scoop_dev *devptr; |
141 | struct scoop_config *inf; | 212 | struct scoop_config *inf; |
142 | struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 213 | struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
214 | int ret; | ||
215 | int temp; | ||
143 | 216 | ||
144 | if (!mem) | 217 | if (!mem) |
145 | return -EINVAL; | 218 | return -EINVAL; |
@@ -154,40 +227,78 @@ int __init scoop_probe(struct platform_device *pdev) | |||
154 | devptr->base = ioremap(mem->start, mem->end - mem->start + 1); | 227 | devptr->base = ioremap(mem->start, mem->end - mem->start + 1); |
155 | 228 | ||
156 | if (!devptr->base) { | 229 | if (!devptr->base) { |
157 | kfree(devptr); | 230 | ret = -ENOMEM; |
158 | return -ENOMEM; | 231 | goto err_ioremap; |
159 | } | 232 | } |
160 | 233 | ||
161 | platform_set_drvdata(pdev, devptr); | 234 | platform_set_drvdata(pdev, devptr); |
162 | 235 | ||
163 | printk("Sharp Scoop Device found at 0x%08x -> 0x%08x\n",(unsigned int)mem->start,(unsigned int)devptr->base); | 236 | printk("Sharp Scoop Device found at 0x%08x -> 0x%8p\n",(unsigned int)mem->start, devptr->base); |
164 | 237 | ||
165 | SCOOP_REG(devptr->base, SCOOP_MCR) = 0x0140; | 238 | iowrite16(0x0140, devptr->base + SCOOP_MCR); |
166 | reset_scoop(&pdev->dev); | 239 | reset_scoop(&pdev->dev); |
167 | SCOOP_REG(devptr->base, SCOOP_CPR) = 0x0000; | 240 | iowrite16(0x0000, devptr->base + SCOOP_CPR); |
168 | SCOOP_REG(devptr->base, SCOOP_GPCR) = inf->io_dir & 0xffff; | 241 | iowrite16(inf->io_dir & 0xffff, devptr->base + SCOOP_GPCR); |
169 | SCOOP_REG(devptr->base, SCOOP_GPWR) = inf->io_out & 0xffff; | 242 | iowrite16(inf->io_out & 0xffff, devptr->base + SCOOP_GPWR); |
170 | 243 | ||
171 | devptr->suspend_clr = inf->suspend_clr; | 244 | devptr->suspend_clr = inf->suspend_clr; |
172 | devptr->suspend_set = inf->suspend_set; | 245 | devptr->suspend_set = inf->suspend_set; |
173 | 246 | ||
247 | devptr->gpio.base = -1; | ||
248 | |||
249 | if (inf->gpio_base != 0) { | ||
250 | devptr->gpio.label = pdev->dev.bus_id; | ||
251 | devptr->gpio.base = inf->gpio_base; | ||
252 | devptr->gpio.ngpio = 12; /* PA11 = 0, PA12 = 1, etc. up to PA22 = 11 */ | ||
253 | devptr->gpio.set = scoop_gpio_set; | ||
254 | devptr->gpio.get = scoop_gpio_get; | ||
255 | devptr->gpio.direction_input = scoop_gpio_direction_input; | ||
256 | devptr->gpio.direction_output = scoop_gpio_direction_output; | ||
257 | |||
258 | ret = gpiochip_add(&devptr->gpio); | ||
259 | if (ret) | ||
260 | goto err_gpio; | ||
261 | } | ||
262 | |||
174 | return 0; | 263 | return 0; |
264 | |||
265 | if (devptr->gpio.base != -1) | ||
266 | temp = gpiochip_remove(&devptr->gpio); | ||
267 | err_gpio: | ||
268 | platform_set_drvdata(pdev, NULL); | ||
269 | err_ioremap: | ||
270 | iounmap(devptr->base); | ||
271 | kfree(devptr); | ||
272 | |||
273 | return ret; | ||
175 | } | 274 | } |
176 | 275 | ||
177 | static int scoop_remove(struct platform_device *pdev) | 276 | static int __devexit scoop_remove(struct platform_device *pdev) |
178 | { | 277 | { |
179 | struct scoop_dev *sdev = platform_get_drvdata(pdev); | 278 | struct scoop_dev *sdev = platform_get_drvdata(pdev); |
180 | if (sdev) { | 279 | int ret; |
181 | iounmap(sdev->base); | 280 | |
182 | kfree(sdev); | 281 | if (!sdev) |
183 | platform_set_drvdata(pdev, NULL); | 282 | return -EINVAL; |
283 | |||
284 | if (sdev->gpio.base != -1) { | ||
285 | ret = gpiochip_remove(&sdev->gpio); | ||
286 | if (ret) { | ||
287 | dev_err(&pdev->dev, "Can't remove gpio chip: %d\n", ret); | ||
288 | return ret; | ||
289 | } | ||
184 | } | 290 | } |
291 | |||
292 | platform_set_drvdata(pdev, NULL); | ||
293 | iounmap(sdev->base); | ||
294 | kfree(sdev); | ||
295 | |||
185 | return 0; | 296 | return 0; |
186 | } | 297 | } |
187 | 298 | ||
188 | static struct platform_driver scoop_driver = { | 299 | static struct platform_driver scoop_driver = { |
189 | .probe = scoop_probe, | 300 | .probe = scoop_probe, |
190 | .remove = scoop_remove, | 301 | .remove = __devexit_p(scoop_remove), |
191 | .suspend = scoop_suspend, | 302 | .suspend = scoop_suspend, |
192 | .resume = scoop_resume, | 303 | .resume = scoop_resume, |
193 | .driver = { | 304 | .driver = { |
@@ -195,7 +306,7 @@ static struct platform_driver scoop_driver = { | |||
195 | }, | 306 | }, |
196 | }; | 307 | }; |
197 | 308 | ||
198 | int __init scoop_init(void) | 309 | static int __init scoop_init(void) |
199 | { | 310 | { |
200 | return platform_driver_register(&scoop_driver); | 311 | return platform_driver_register(&scoop_driver); |
201 | } | 312 | } |