http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / 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/mach-types.h>
11 #include <asm/setup.h>
12
13 #include <asm/mach/arch.h>
14 #include <asm/mach/map.h>
15 #include <asm/mach/serial_sa1100.h>
16
17 #include "generic.h"
18
19
20 static spinlock_t egpio_lock = SPIN_LOCK_UNLOCKED;
21
22 static unsigned long yopy_egpio =
23         GPIO_MASK(GPIO_CF_RESET) |
24         GPIO_MASK(GPIO_CLKDIV_CLR1) | GPIO_MASK(GPIO_CLKDIV_CLR2) |
25         GPIO_MASK(GPIO_SPEAKER_MUTE) | GPIO_MASK(GPIO_AUDIO_OPAMP_POWER);
26
27 int yopy_gpio_test(unsigned int gpio)
28 {
29         return ((yopy_egpio & (1 << gpio)) != 0);
30 }
31
32 void yopy_gpio_set(unsigned int gpio, int level)
33 {
34         unsigned long flags, mask;
35
36         mask = 1 << gpio;
37
38         spin_lock_irqsave(&egpio_lock, flags);
39
40         if (level)
41                 yopy_egpio |= mask;
42         else
43                 yopy_egpio &= ~mask;
44         YOPY_EGPIO = yopy_egpio;
45
46         spin_unlock_irqrestore(&egpio_lock, flags);
47 }
48
49 EXPORT_SYMBOL(yopy_gpio_test);
50 EXPORT_SYMBOL(yopy_gpio_set);
51
52 static int __init yopy_hw_init(void)
53 {
54         if (machine_is_yopy()) {
55                 YOPY_EGPIO = yopy_egpio;
56
57                 /* Enable Output */
58                 PPDR |= PPC_L_BIAS;
59                 PSDR &= ~PPC_L_BIAS;
60                 PPSR |= PPC_L_BIAS;
61
62                 YOPY_EGPIO = yopy_egpio;
63         }
64
65         return 0;
66 }
67
68 arch_initcall(yopy_hw_init);
69
70
71 static struct map_desc yopy_io_desc[] __initdata = {
72  /* virtual     physical    length      type */
73   { 0xf0000000, 0x48000000, 0x00300000, MT_DEVICE }, /* LCD */
74   { 0xf1000000, 0x10000000, 0x00100000, MT_DEVICE }  /* EGPIO */
75 };
76
77 static void __init yopy_map_io(void)
78 {
79         sa1100_map_io();
80         iotable_init(yopy_io_desc, ARRAY_SIZE(yopy_io_desc));
81
82         sa1100_register_uart(0, 3);
83
84         set_GPIO_IRQ_edge(GPIO_UCB1200_IRQ, GPIO_RISING_EDGE);
85 }
86
87
88 MACHINE_START(YOPY, "Yopy")
89         MAINTAINER("G.Mate, Inc.")
90         BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
91         BOOT_PARAMS(0xc0000100)
92         MAPIO(yopy_map_io)
93         INITIRQ(sa1100_init_irq)
94         INITTIME(sa1100_init_time)
95 MACHINE_END