Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/arch/arm/mach-sa1100/simpad.c | |
3 | */ | |
4 | ||
5 | #include <linux/config.h> | |
6 | #include <linux/module.h> | |
7 | #include <linux/init.h> | |
8 | #include <linux/kernel.h> | |
9 | #include <linux/tty.h> | |
10 | #include <linux/proc_fs.h> | |
11 | #include <linux/string.h> | |
12 | #include <linux/pm.h> | |
13 | #include <linux/device.h> | |
14 | #include <linux/mtd/mtd.h> | |
15 | #include <linux/mtd/partitions.h> | |
16 | ||
17 | #include <asm/irq.h> | |
18 | #include <asm/hardware.h> | |
19 | #include <asm/setup.h> | |
20 | ||
21 | #include <asm/mach-types.h> | |
22 | #include <asm/mach/arch.h> | |
23 | #include <asm/mach/flash.h> | |
24 | #include <asm/mach/map.h> | |
25 | #include <asm/mach/serial_sa1100.h> | |
323cdfc1 | 26 | #include <asm/arch/mcp.h> |
1da177e4 LT |
27 | #include <asm/arch/simpad.h> |
28 | ||
29 | #include <linux/serial_core.h> | |
30 | #include <linux/ioport.h> | |
31 | #include <asm/io.h> | |
32 | ||
33 | #include "generic.h" | |
34 | ||
35 | long cs3_shadow; | |
36 | ||
37 | long get_cs3_shadow(void) | |
38 | { | |
39 | return cs3_shadow; | |
40 | } | |
41 | ||
42 | void set_cs3(long value) | |
43 | { | |
44 | *(CS3BUSTYPE *)(CS3_BASE) = cs3_shadow = value; | |
45 | } | |
46 | ||
47 | void set_cs3_bit(int value) | |
48 | { | |
49 | cs3_shadow |= value; | |
50 | *(CS3BUSTYPE *)(CS3_BASE) = cs3_shadow; | |
51 | } | |
52 | ||
53 | void clear_cs3_bit(int value) | |
54 | { | |
55 | cs3_shadow &= ~value; | |
56 | *(CS3BUSTYPE *)(CS3_BASE) = cs3_shadow; | |
57 | } | |
58 | ||
59 | EXPORT_SYMBOL(set_cs3_bit); | |
60 | EXPORT_SYMBOL(clear_cs3_bit); | |
61 | ||
62 | static struct map_desc simpad_io_desc[] __initdata = { | |
63 | /* virtual physical length type */ | |
64 | /* MQ200 */ | |
65 | { 0xf2800000, 0x4b800000, 0x00800000, MT_DEVICE }, | |
66 | /* Paules CS3, write only */ | |
67 | { 0xf1000000, 0x18000000, 0x00100000, MT_DEVICE }, | |
68 | }; | |
69 | ||
70 | ||
71 | static void simpad_uart_pm(struct uart_port *port, u_int state, u_int oldstate) | |
72 | { | |
73 | if (port->mapbase == (u_int)&Ser1UTCR0) { | |
74 | if (state) | |
75 | { | |
76 | clear_cs3_bit(RS232_ON); | |
77 | clear_cs3_bit(DECT_POWER_ON); | |
78 | }else | |
79 | { | |
80 | set_cs3_bit(RS232_ON); | |
81 | set_cs3_bit(DECT_POWER_ON); | |
82 | } | |
83 | } | |
84 | } | |
85 | ||
86 | static struct sa1100_port_fns simpad_port_fns __initdata = { | |
87 | .pm = simpad_uart_pm, | |
88 | }; | |
89 | ||
90 | ||
91 | static struct mtd_partition simpad_partitions[] = { | |
92 | { | |
93 | .name = "SIMpad boot firmware", | |
94 | .size = 0x00080000, | |
95 | .offset = 0, | |
96 | .mask_flags = MTD_WRITEABLE, | |
97 | }, { | |
98 | .name = "SIMpad kernel", | |
99 | .size = 0x0010000, | |
100 | .offset = MTDPART_OFS_APPEND, | |
101 | }, { | |
102 | .name = "SIMpad root jffs2", | |
103 | .size = MTDPART_SIZ_FULL, | |
104 | .offset = MTDPART_OFS_APPEND, | |
105 | } | |
106 | }; | |
107 | ||
108 | static struct flash_platform_data simpad_flash_data = { | |
109 | .map_name = "cfi_probe", | |
110 | .parts = simpad_partitions, | |
111 | .nr_parts = ARRAY_SIZE(simpad_partitions), | |
112 | }; | |
113 | ||
114 | ||
115 | static struct resource simpad_flash_resources [] = { | |
116 | { | |
117 | .start = SA1100_CS0_PHYS, | |
118 | .end = SA1100_CS0_PHYS + SZ_16M -1, | |
119 | .flags = IORESOURCE_MEM, | |
120 | }, { | |
121 | .start = SA1100_CS1_PHYS, | |
122 | .end = SA1100_CS1_PHYS + SZ_16M -1, | |
123 | .flags = IORESOURCE_MEM, | |
124 | } | |
125 | }; | |
126 | ||
323cdfc1 RK |
127 | static struct mcp_plat_data simpad_mcp_data = { |
128 | .mccr0 = MCCR0_ADM, | |
129 | .sclk_rate = 11981000, | |
130 | }; | |
131 | ||
1da177e4 LT |
132 | |
133 | ||
134 | static void __init simpad_map_io(void) | |
135 | { | |
136 | sa1100_map_io(); | |
137 | ||
138 | iotable_init(simpad_io_desc, ARRAY_SIZE(simpad_io_desc)); | |
139 | ||
140 | set_cs3_bit (EN1 | EN0 | LED2_ON | DISPLAY_ON | RS232_ON | | |
141 | ENABLE_5V | RESET_SIMCARD | DECT_POWER_ON); | |
142 | ||
143 | ||
144 | sa1100_register_uart_fns(&simpad_port_fns); | |
145 | sa1100_register_uart(0, 3); /* serial interface */ | |
146 | sa1100_register_uart(1, 1); /* DECT */ | |
147 | ||
148 | // Reassign UART 1 pins | |
149 | GAFR |= GPIO_UART_TXD | GPIO_UART_RXD; | |
150 | GPDR |= GPIO_UART_TXD | GPIO_LDD13 | GPIO_LDD15; | |
151 | GPDR &= ~GPIO_UART_RXD; | |
152 | PPAR |= PPAR_UPR; | |
153 | ||
154 | /* | |
155 | * Set up registers for sleep mode. | |
156 | */ | |
157 | ||
158 | ||
159 | PWER = PWER_GPIO0| PWER_RTC; | |
160 | PGSR = 0x818; | |
161 | PCFR = 0; | |
162 | PSDR = 0; | |
163 | ||
164 | sa11x0_set_flash_data(&simpad_flash_data, simpad_flash_resources, | |
165 | ARRAY_SIZE(simpad_flash_resources)); | |
323cdfc1 | 166 | sa11x0_set_mcp_data(&simpad_mcp_data); |
1da177e4 LT |
167 | } |
168 | ||
169 | static void simpad_power_off(void) | |
170 | { | |
171 | local_irq_disable(); // was cli | |
172 | set_cs3(0x800); /* only SD_MEDIAQ */ | |
173 | ||
174 | /* disable internal oscillator, float CS lines */ | |
175 | PCFR = (PCFR_OPDE | PCFR_FP | PCFR_FS); | |
176 | /* enable wake-up on GPIO0 (Assabet...) */ | |
177 | PWER = GFER = GRER = 1; | |
178 | /* | |
179 | * set scratchpad to zero, just in case it is used as a | |
180 | * restart address by the bootloader. | |
181 | */ | |
182 | PSPR = 0; | |
183 | PGSR = 0; | |
184 | /* enter sleep mode */ | |
185 | PMCR = PMCR_SF; | |
186 | while(1); | |
187 | ||
188 | local_irq_enable(); /* we won't ever call it */ | |
189 | ||
190 | ||
191 | } | |
192 | ||
193 | ||
194 | /* | |
195 | * MediaQ Video Device | |
196 | */ | |
197 | static struct platform_device simpad_mq200fb = { | |
198 | .name = "simpad-mq200", | |
199 | .id = 0, | |
200 | }; | |
201 | ||
202 | static struct platform_device *devices[] __initdata = { | |
203 | &simpad_mq200fb | |
204 | }; | |
205 | ||
206 | ||
207 | ||
208 | static int __init simpad_init(void) | |
209 | { | |
210 | int ret; | |
211 | ||
212 | pm_power_off = simpad_power_off; | |
213 | ||
214 | ret = platform_add_devices(devices, ARRAY_SIZE(devices)); | |
215 | if(ret) | |
216 | printk(KERN_WARNING "simpad: Unable to register mq200 framebuffer device"); | |
217 | ||
218 | return 0; | |
219 | } | |
220 | ||
221 | arch_initcall(simpad_init); | |
222 | ||
223 | ||
224 | MACHINE_START(SIMPAD, "Simpad") | |
e9dea0c6 RK |
225 | /* Maintainer: Holger Freyther */ |
226 | .phys_ram = 0xc0000000, | |
227 | .phys_io = 0x80000000, | |
228 | .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, | |
229 | .boot_params = 0xc0000100, | |
230 | .map_io = simpad_map_io, | |
231 | .init_irq = sa1100_init_irq, | |
1da177e4 LT |
232 | .timer = &sa1100_timer, |
233 | MACHINE_END |