import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / arm / mach-sa1100 / yopy.c
1 /*
2  * linux/arch/arm/mach-sa1100/yopy.c
3  */
4 #include <linux/module.h>
5 #include <linux/init.h>
6 #include <linux/kernel.h>
7 #include <linux/tty.h>
8
9 #include <asm/hardware.h>
10 #include <asm/setup.h>
11
12 #include <asm/mach/arch.h>
13 #include <asm/mach/map.h>
14 #include <asm/mach/serial_sa1100.h>
15
16 #include "generic.h"
17
18
19 static spinlock_t egpio_lock = SPIN_LOCK_UNLOCKED;
20
21 static unsigned long yopy_egpio =
22         GPIO_MASK(GPIO_CF_RESET) |
23         GPIO_MASK(GPIO_CLKDIV_CLR1) | GPIO_MASK(GPIO_CLKDIV_CLR2) |
24         GPIO_MASK(GPIO_SPEAKER_MUTE) | GPIO_MASK(GPIO_AUDIO_OPAMP_POWER);
25
26 int yopy_gpio_test(unsigned int gpio)
27 {
28         return ((yopy_egpio & (1 << gpio)) != 0);
29 }
30
31 void yopy_gpio_set(unsigned int gpio, int level)
32 {
33         unsigned long flags, mask;
34
35         mask = 1 << gpio;
36
37         spin_lock_irqsave(&egpio_lock, flags);
38
39         if (level)
40                 yopy_egpio |= mask;
41         else
42                 yopy_egpio &= ~mask;
43         YOPY_EGPIO = yopy_egpio;
44
45         spin_unlock_irqrestore(&egpio_lock, flags);
46 }
47
48 EXPORT_SYMBOL(yopy_gpio_test);
49 EXPORT_SYMBOL(yopy_gpio_set);
50
51 static int __init yopy_hw_init(void)
52 {
53         if (machine_is_yopy()) {
54                 YOPY_EGPIO = yopy_egpio;
55
56                 /* Enable Output */
57                 PPDR |= PPC_L_BIAS;
58                 PSDR &= ~PPC_L_BIAS;
59                 PPSR |= PPC_L_BIAS;
60
61                 YOPY_EGPIO = yopy_egpio;
62         }
63
64         return 0;
65 }
66
67 __initcall(yopy_hw_init);
68
69
70 static struct map_desc yopy_io_desc[] __initdata = {
71  /* virtual     physical    length      domain     r  w  c  b */
72   { 0xe8000000, 0x00000000, 0x04000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Flash 0 */
73   { 0xec000000, 0x08000000, 0x04000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Flash 1 */
74   { 0xf0000000, 0x48000000, 0x00300000, DOMAIN_IO, 0, 1, 0, 0 }, /* LCD */
75   { 0xf1000000, 0x10000000, 0x00100000, DOMAIN_IO, 0, 1, 0, 0 }, /* EGPIO */
76   LAST_DESC
77 };
78
79 static void __init yopy_map_io(void)
80 {
81         sa1100_map_io();
82         iotable_init(yopy_io_desc);
83
84         sa1100_register_uart(0, 3);
85
86         set_GPIO_IRQ_edge(GPIO_UCB1200_IRQ, GPIO_RISING_EDGE);
87 }
88
89
90 MACHINE_START(YOPY, "Yopy")
91         MAINTAINER("G.Mate, Inc.")
92         BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
93         BOOT_PARAMS(0xc0000100)
94         MAPIO(yopy_map_io)
95         INITIRQ(sa1100_init_irq)
96 MACHINE_END