http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / arch / arm / mach-sa1100 / adsbitsy.c
1 /*
2  * linux/arch/arm/mach-sa1100/adsbitsy.c
3  *
4  * Author: Woojung Huh
5  *
6  * Pieces specific to the ADS Bitsy
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/kernel.h>
13 #include <linux/init.h>
14 #include <linux/ptrace.h>
15 #include <linux/ioport.h>
16 #include <linux/serial_core.h>
17
18 #include <asm/hardware.h>
19 #include <asm/mach-types.h>
20 #include <asm/setup.h>
21 #include <asm/irq.h>
22
23 #include <asm/mach/irq.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/map.h>
26 #include <asm/mach/serial_sa1100.h>
27
28 #include "generic.h"
29
30 static struct resource sa1111_resources[] = {
31         [0] = {
32                 .start          = 0x18000000,
33                 .end            = 0x18001fff,
34                 .flags          = IORESOURCE_MEM,
35         },
36         [1] = {
37                 .start          = IRQ_GPIO0,
38                 .end            = IRQ_GPIO0,
39                 .flags          = IORESOURCE_IRQ,
40         },
41 };
42
43 static u64 sa1111_dmamask = 0xffffffffUL;
44
45 static struct platform_device sa1111_device = {
46         .name           = "sa1111",
47         .id             = 0,
48         .dev            = {
49                 .dma_mask = &sa1111_dmamask,
50                 .coherent_dma_mask = 0xffffffff,
51         },
52         .num_resources  = ARRAY_SIZE(sa1111_resources),
53         .resource       = sa1111_resources,
54 };
55
56 static struct platform_device *devices[] __initdata = {
57         &sa1111_device,
58 };
59
60 static int __init adsbitsy_init(void)
61 {
62         int ret;
63
64         if (!machine_is_adsbitsy())
65                 return -ENODEV;
66
67         /*
68          * Ensure that the memory bus request/grant signals are setup,
69          * and the grant is held in its inactive state
70          */
71         sa1110_mb_disable();
72
73         /*
74          * Reset SA1111
75          */
76         GPCR |= GPIO_GPIO26;
77         udelay(1000);
78         GPSR |= GPIO_GPIO26;
79
80         /*
81          * Probe for SA1111.
82          */
83         ret = platform_add_devices(devices, ARRAY_SIZE(devices));
84         if (ret < 0)
85                 return ret;
86
87         /*
88          * Enable PWM control for LCD
89          */
90         sa1111_enable_device(SKPCR_PWMCLKEN);
91         SKPWM0 = 0x7F;                          // VEE
92         SKPEN0 = 1;
93         SKPWM1 = 0x01;                          // Backlight
94         SKPEN1 = 1;
95
96         return 0;
97 }
98
99 arch_initcall(adsbitsy_init);
100
101 static void __init adsbitsy_init_irq(void)
102 {
103         /* First the standard SA1100 IRQs */
104         sa1100_init_irq();
105 }
106
107 static struct map_desc adsbitsy_io_desc[] __initdata = {
108  /* virtual     physical    length      type */
109   { 0xf4000000, 0x18000000, 0x00800000, MT_DEVICE }  /* SA1111 */
110 };
111
112 static int adsbitsy_uart_open(struct uart_port *port, struct uart_info *info)
113 {
114         if (port->mapbase == _Ser1UTCR0) {
115                 Ser1SDCR0 |= SDCR0_UART;
116 #error Fixme    // Set RTS High (should be done in the set_mctrl fn)
117                 GPCR = GPIO_GPIO15;
118         } else if (port->mapbase == _Ser2UTCR0) {
119                 Ser2UTCR4 = Ser2HSCR0 = 0;
120 #error Fixme    // Set RTS High (should be done in the set_mctrl fn)
121                 GPCR = GPIO_GPIO17;
122         } else if (port->mapbase == _Ser2UTCR0) {
123 #error Fixme    // Set RTS High (should be done in the set_mctrl fn)
124                 GPCR = GPIO_GPIO19;
125         }
126         return 0;
127 }
128
129 static struct sa1100_port_fns adsbitsy_port_fns __initdata = {
130         .open   = adsbitsy_uart_open,
131 };
132
133 static void __init adsbitsy_map_io(void)
134 {
135         sa1100_map_io();
136         iotable_init(adsbitsy_io_desc, ARRAY_SIZE(adsbitsy_io_desc));
137
138         sa1100_register_uart_fns(&adsbitsy_port_fns);
139         sa1100_register_uart(0, 3);
140         sa1100_register_uart(1, 1);
141         sa1100_register_uart(2, 2);
142         GPDR |= GPIO_GPIO15 | GPIO_GPIO17 | GPIO_GPIO19;
143         GPDR &= ~(GPIO_GPIO14 | GPIO_GPIO16 | GPIO_GPIO18);
144 }
145
146 MACHINE_START(ADSBITSY, "ADS Bitsy")
147         BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
148         MAPIO(adsbitsy_map_io)
149         INITIRQ(adsbitsy_init_irq)
150         INITTIME(sa1100_init_time)
151 MACHINE_END