root / hw / spitz.c @ f6ad2e32
History | View | Annotate | Download (31.1 kB)
1 | b00052e4 | balrog | /*
|
---|---|---|---|
2 | b00052e4 | balrog | * PXA270-based Clamshell PDA platforms.
|
3 | b00052e4 | balrog | *
|
4 | b00052e4 | balrog | * Copyright (c) 2006 Openedhand Ltd.
|
5 | b00052e4 | balrog | * Written by Andrzej Zaborowski <balrog@zabor.org>
|
6 | b00052e4 | balrog | *
|
7 | b00052e4 | balrog | * This code is licensed under the GNU GPL v2.
|
8 | b00052e4 | balrog | */
|
9 | b00052e4 | balrog | |
10 | 87ecb68b | pbrook | #include "hw.h" |
11 | 87ecb68b | pbrook | #include "pxa.h" |
12 | 87ecb68b | pbrook | #include "arm-misc.h" |
13 | 87ecb68b | pbrook | #include "sysemu.h" |
14 | 87ecb68b | pbrook | #include "pcmcia.h" |
15 | 87ecb68b | pbrook | #include "i2c.h" |
16 | a984a69e | Paul Brook | #include "ssi.h" |
17 | 87ecb68b | pbrook | #include "flash.h" |
18 | 87ecb68b | pbrook | #include "qemu-timer.h" |
19 | 87ecb68b | pbrook | #include "devices.h" |
20 | e33d8cdb | balrog | #include "sharpsl.h" |
21 | 87ecb68b | pbrook | #include "console.h" |
22 | 87ecb68b | pbrook | #include "block.h" |
23 | 87ecb68b | pbrook | #include "audio/audio.h" |
24 | 87ecb68b | pbrook | #include "boards.h" |
25 | 2446333c | Blue Swirl | #include "blockdev.h" |
26 | b00052e4 | balrog | |
27 | b00052e4 | balrog | #undef REG_FMT
|
28 | b00052e4 | balrog | #define REG_FMT "0x%02lx" |
29 | b00052e4 | balrog | |
30 | b00052e4 | balrog | /* Spitz Flash */
|
31 | b00052e4 | balrog | #define FLASH_BASE 0x0c000000 |
32 | b00052e4 | balrog | #define FLASH_ECCLPLB 0x00 /* Line parity 7 - 0 bit */ |
33 | b00052e4 | balrog | #define FLASH_ECCLPUB 0x04 /* Line parity 15 - 8 bit */ |
34 | b00052e4 | balrog | #define FLASH_ECCCP 0x08 /* Column parity 5 - 0 bit */ |
35 | b00052e4 | balrog | #define FLASH_ECCCNTR 0x0c /* ECC byte counter */ |
36 | b00052e4 | balrog | #define FLASH_ECCCLRR 0x10 /* Clear ECC */ |
37 | b00052e4 | balrog | #define FLASH_FLASHIO 0x14 /* Flash I/O */ |
38 | b00052e4 | balrog | #define FLASH_FLASHCTL 0x18 /* Flash Control */ |
39 | b00052e4 | balrog | |
40 | b00052e4 | balrog | #define FLASHCTL_CE0 (1 << 0) |
41 | b00052e4 | balrog | #define FLASHCTL_CLE (1 << 1) |
42 | b00052e4 | balrog | #define FLASHCTL_ALE (1 << 2) |
43 | b00052e4 | balrog | #define FLASHCTL_WP (1 << 3) |
44 | b00052e4 | balrog | #define FLASHCTL_CE1 (1 << 4) |
45 | b00052e4 | balrog | #define FLASHCTL_RYBY (1 << 5) |
46 | b00052e4 | balrog | #define FLASHCTL_NCE (FLASHCTL_CE0 | FLASHCTL_CE1)
|
47 | b00052e4 | balrog | |
48 | bc24a225 | Paul Brook | typedef struct { |
49 | bc24a225 | Paul Brook | NANDFlashState *nand; |
50 | b00052e4 | balrog | uint8_t ctl; |
51 | bc24a225 | Paul Brook | ECCState ecc; |
52 | bc24a225 | Paul Brook | } SLNANDState; |
53 | b00052e4 | balrog | |
54 | c227f099 | Anthony Liguori | static uint32_t sl_readb(void *opaque, target_phys_addr_t addr) |
55 | b00052e4 | balrog | { |
56 | bc24a225 | Paul Brook | SLNANDState *s = (SLNANDState *) opaque; |
57 | b00052e4 | balrog | int ryby;
|
58 | b00052e4 | balrog | |
59 | b00052e4 | balrog | switch (addr) {
|
60 | b00052e4 | balrog | #define BSHR(byte, from, to) ((s->ecc.lp[byte] >> (from - to)) & (1 << to)) |
61 | b00052e4 | balrog | case FLASH_ECCLPLB:
|
62 | b00052e4 | balrog | return BSHR(0, 4, 0) | BSHR(0, 5, 2) | BSHR(0, 6, 4) | BSHR(0, 7, 6) | |
63 | b00052e4 | balrog | BSHR(1, 4, 1) | BSHR(1, 5, 3) | BSHR(1, 6, 5) | BSHR(1, 7, 7); |
64 | b00052e4 | balrog | |
65 | b00052e4 | balrog | #define BSHL(byte, from, to) ((s->ecc.lp[byte] << (to - from)) & (1 << to)) |
66 | b00052e4 | balrog | case FLASH_ECCLPUB:
|
67 | b00052e4 | balrog | return BSHL(0, 0, 0) | BSHL(0, 1, 2) | BSHL(0, 2, 4) | BSHL(0, 3, 6) | |
68 | b00052e4 | balrog | BSHL(1, 0, 1) | BSHL(1, 1, 3) | BSHL(1, 2, 5) | BSHL(1, 3, 7); |
69 | b00052e4 | balrog | |
70 | b00052e4 | balrog | case FLASH_ECCCP:
|
71 | b00052e4 | balrog | return s->ecc.cp;
|
72 | b00052e4 | balrog | |
73 | b00052e4 | balrog | case FLASH_ECCCNTR:
|
74 | b00052e4 | balrog | return s->ecc.count & 0xff; |
75 | b00052e4 | balrog | |
76 | b00052e4 | balrog | case FLASH_FLASHCTL:
|
77 | b00052e4 | balrog | nand_getpins(s->nand, &ryby); |
78 | b00052e4 | balrog | if (ryby)
|
79 | b00052e4 | balrog | return s->ctl | FLASHCTL_RYBY;
|
80 | b00052e4 | balrog | else
|
81 | b00052e4 | balrog | return s->ctl;
|
82 | b00052e4 | balrog | |
83 | b00052e4 | balrog | case FLASH_FLASHIO:
|
84 | b00052e4 | balrog | return ecc_digest(&s->ecc, nand_getio(s->nand));
|
85 | b00052e4 | balrog | |
86 | b00052e4 | balrog | default:
|
87 | a8b7063b | Blue Swirl | zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr); |
88 | b00052e4 | balrog | } |
89 | b00052e4 | balrog | return 0; |
90 | b00052e4 | balrog | } |
91 | b00052e4 | balrog | |
92 | c227f099 | Anthony Liguori | static uint32_t sl_readl(void *opaque, target_phys_addr_t addr) |
93 | a5236105 | balrog | { |
94 | bc24a225 | Paul Brook | SLNANDState *s = (SLNANDState *) opaque; |
95 | a5236105 | balrog | |
96 | a5236105 | balrog | if (addr == FLASH_FLASHIO)
|
97 | a5236105 | balrog | return ecc_digest(&s->ecc, nand_getio(s->nand)) |
|
98 | a5236105 | balrog | (ecc_digest(&s->ecc, nand_getio(s->nand)) << 16);
|
99 | a5236105 | balrog | |
100 | a5236105 | balrog | return sl_readb(opaque, addr);
|
101 | a5236105 | balrog | } |
102 | a5236105 | balrog | |
103 | c227f099 | Anthony Liguori | static void sl_writeb(void *opaque, target_phys_addr_t addr, |
104 | b00052e4 | balrog | uint32_t value) |
105 | b00052e4 | balrog | { |
106 | bc24a225 | Paul Brook | SLNANDState *s = (SLNANDState *) opaque; |
107 | b00052e4 | balrog | |
108 | b00052e4 | balrog | switch (addr) {
|
109 | b00052e4 | balrog | case FLASH_ECCCLRR:
|
110 | b00052e4 | balrog | /* Value is ignored. */
|
111 | b00052e4 | balrog | ecc_reset(&s->ecc); |
112 | b00052e4 | balrog | break;
|
113 | b00052e4 | balrog | |
114 | b00052e4 | balrog | case FLASH_FLASHCTL:
|
115 | b00052e4 | balrog | s->ctl = value & 0xff & ~FLASHCTL_RYBY;
|
116 | b00052e4 | balrog | nand_setpins(s->nand, |
117 | b00052e4 | balrog | s->ctl & FLASHCTL_CLE, |
118 | b00052e4 | balrog | s->ctl & FLASHCTL_ALE, |
119 | b00052e4 | balrog | s->ctl & FLASHCTL_NCE, |
120 | b00052e4 | balrog | s->ctl & FLASHCTL_WP, |
121 | b00052e4 | balrog | 0);
|
122 | b00052e4 | balrog | break;
|
123 | b00052e4 | balrog | |
124 | b00052e4 | balrog | case FLASH_FLASHIO:
|
125 | b00052e4 | balrog | nand_setio(s->nand, ecc_digest(&s->ecc, value & 0xff));
|
126 | b00052e4 | balrog | break;
|
127 | b00052e4 | balrog | |
128 | b00052e4 | balrog | default:
|
129 | a8b7063b | Blue Swirl | zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr); |
130 | b00052e4 | balrog | } |
131 | b00052e4 | balrog | } |
132 | b00052e4 | balrog | |
133 | aa941b94 | balrog | static void sl_save(QEMUFile *f, void *opaque) |
134 | aa941b94 | balrog | { |
135 | bc24a225 | Paul Brook | SLNANDState *s = (SLNANDState *) opaque; |
136 | aa941b94 | balrog | |
137 | aa941b94 | balrog | qemu_put_8s(f, &s->ctl); |
138 | aa941b94 | balrog | ecc_put(f, &s->ecc); |
139 | aa941b94 | balrog | } |
140 | aa941b94 | balrog | |
141 | aa941b94 | balrog | static int sl_load(QEMUFile *f, void *opaque, int version_id) |
142 | aa941b94 | balrog | { |
143 | bc24a225 | Paul Brook | SLNANDState *s = (SLNANDState *) opaque; |
144 | aa941b94 | balrog | |
145 | aa941b94 | balrog | qemu_get_8s(f, &s->ctl); |
146 | aa941b94 | balrog | ecc_get(f, &s->ecc); |
147 | aa941b94 | balrog | |
148 | aa941b94 | balrog | return 0; |
149 | aa941b94 | balrog | } |
150 | aa941b94 | balrog | |
151 | b00052e4 | balrog | enum {
|
152 | b00052e4 | balrog | FLASH_128M, |
153 | b00052e4 | balrog | FLASH_1024M, |
154 | b00052e4 | balrog | }; |
155 | b00052e4 | balrog | |
156 | bc24a225 | Paul Brook | static void sl_flash_register(PXA2xxState *cpu, int size) |
157 | b00052e4 | balrog | { |
158 | b00052e4 | balrog | int iomemtype;
|
159 | bc24a225 | Paul Brook | SLNANDState *s; |
160 | d60efc6b | Blue Swirl | CPUReadMemoryFunc * const sl_readfn[] = {
|
161 | b00052e4 | balrog | sl_readb, |
162 | b00052e4 | balrog | sl_readb, |
163 | a5236105 | balrog | sl_readl, |
164 | b00052e4 | balrog | }; |
165 | d60efc6b | Blue Swirl | CPUWriteMemoryFunc * const sl_writefn[] = {
|
166 | b00052e4 | balrog | sl_writeb, |
167 | b00052e4 | balrog | sl_writeb, |
168 | b00052e4 | balrog | sl_writeb, |
169 | b00052e4 | balrog | }; |
170 | b00052e4 | balrog | |
171 | bc24a225 | Paul Brook | s = (SLNANDState *) qemu_mallocz(sizeof(SLNANDState));
|
172 | b00052e4 | balrog | s->ctl = 0;
|
173 | b00052e4 | balrog | if (size == FLASH_128M)
|
174 | b00052e4 | balrog | s->nand = nand_init(NAND_MFR_SAMSUNG, 0x73);
|
175 | b00052e4 | balrog | else if (size == FLASH_1024M) |
176 | b00052e4 | balrog | s->nand = nand_init(NAND_MFR_SAMSUNG, 0xf1);
|
177 | b00052e4 | balrog | |
178 | 1eed09cb | Avi Kivity | iomemtype = cpu_register_io_memory(sl_readfn, |
179 | 2507c12a | Alexander Graf | sl_writefn, s, DEVICE_NATIVE_ENDIAN); |
180 | 8da3ff18 | pbrook | cpu_register_physical_memory(FLASH_BASE, 0x40, iomemtype);
|
181 | aa941b94 | balrog | |
182 | 0be71e32 | Alex Williamson | register_savevm(NULL, "sl_flash", 0, 0, sl_save, sl_load, s); |
183 | b00052e4 | balrog | } |
184 | b00052e4 | balrog | |
185 | b00052e4 | balrog | /* Spitz Keyboard */
|
186 | b00052e4 | balrog | |
187 | b00052e4 | balrog | #define SPITZ_KEY_STROBE_NUM 11 |
188 | b00052e4 | balrog | #define SPITZ_KEY_SENSE_NUM 7 |
189 | b00052e4 | balrog | |
190 | b00052e4 | balrog | static const int spitz_gpio_key_sense[SPITZ_KEY_SENSE_NUM] = { |
191 | b00052e4 | balrog | 12, 17, 91, 34, 36, 38, 39 |
192 | b00052e4 | balrog | }; |
193 | b00052e4 | balrog | |
194 | b00052e4 | balrog | static const int spitz_gpio_key_strobe[SPITZ_KEY_STROBE_NUM] = { |
195 | b00052e4 | balrog | 88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114 |
196 | b00052e4 | balrog | }; |
197 | b00052e4 | balrog | |
198 | b00052e4 | balrog | /* Eighth additional row maps the special keys */
|
199 | b00052e4 | balrog | static int spitz_keymap[SPITZ_KEY_SENSE_NUM + 1][SPITZ_KEY_STROBE_NUM] = { |
200 | b00052e4 | balrog | { 0x1d, 0x02, 0x04, 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0e, 0x3f, 0x40 }, |
201 | b00052e4 | balrog | { -1 , 0x03, 0x05, 0x13, 0x15, 0x09, 0x17, 0x18, 0x19, 0x41, 0x42 }, |
202 | b00052e4 | balrog | { 0x0f, 0x10, 0x12, 0x14, 0x22, 0x16, 0x24, 0x25, -1 , -1 , -1 }, |
203 | b00052e4 | balrog | { 0x3c, 0x11, 0x1f, 0x21, 0x2f, 0x23, 0x32, 0x26, -1 , 0x36, -1 }, |
204 | b00052e4 | balrog | { 0x3b, 0x1e, 0x20, 0x2e, 0x30, 0x31, 0x34, -1 , 0x1c, 0x2a, -1 }, |
205 | 2b76bdc9 | balrog | { 0x44, 0x2c, 0x2d, 0x0c, 0x39, 0x33, -1 , 0x48, -1 , -1 , 0x38 }, |
206 | 2b76bdc9 | balrog | { 0x37, 0x3d, -1 , 0x45, 0x57, 0x58, 0x4b, 0x50, 0x4d, -1 , -1 }, |
207 | b00052e4 | balrog | { 0x52, 0x43, 0x01, 0x47, 0x49, -1 , -1 , -1 , -1 , -1 , -1 }, |
208 | b00052e4 | balrog | }; |
209 | b00052e4 | balrog | |
210 | b00052e4 | balrog | #define SPITZ_GPIO_AK_INT 13 /* Remote control */ |
211 | b00052e4 | balrog | #define SPITZ_GPIO_SYNC 16 /* Sync button */ |
212 | b00052e4 | balrog | #define SPITZ_GPIO_ON_KEY 95 /* Power button */ |
213 | b00052e4 | balrog | #define SPITZ_GPIO_SWA 97 /* Lid */ |
214 | b00052e4 | balrog | #define SPITZ_GPIO_SWB 96 /* Tablet mode */ |
215 | b00052e4 | balrog | |
216 | b00052e4 | balrog | /* The special buttons are mapped to unused keys */
|
217 | b00052e4 | balrog | static const int spitz_gpiomap[5] = { |
218 | b00052e4 | balrog | SPITZ_GPIO_AK_INT, SPITZ_GPIO_SYNC, SPITZ_GPIO_ON_KEY, |
219 | b00052e4 | balrog | SPITZ_GPIO_SWA, SPITZ_GPIO_SWB, |
220 | b00052e4 | balrog | }; |
221 | b00052e4 | balrog | static int spitz_gpio_invert[5] = { 0, 0, 0, 0, 0, }; |
222 | b00052e4 | balrog | |
223 | bc24a225 | Paul Brook | typedef struct { |
224 | 38641a52 | balrog | qemu_irq sense[SPITZ_KEY_SENSE_NUM]; |
225 | 38641a52 | balrog | qemu_irq *strobe; |
226 | 38641a52 | balrog | qemu_irq gpiomap[5];
|
227 | b00052e4 | balrog | int keymap[0x80]; |
228 | b00052e4 | balrog | uint16_t keyrow[SPITZ_KEY_SENSE_NUM]; |
229 | b00052e4 | balrog | uint16_t strobe_state; |
230 | b00052e4 | balrog | uint16_t sense_state; |
231 | b00052e4 | balrog | |
232 | b00052e4 | balrog | uint16_t pre_map[0x100];
|
233 | b00052e4 | balrog | uint16_t modifiers; |
234 | b00052e4 | balrog | uint16_t imodifiers; |
235 | b00052e4 | balrog | uint8_t fifo[16];
|
236 | b00052e4 | balrog | int fifopos, fifolen;
|
237 | b00052e4 | balrog | QEMUTimer *kbdtimer; |
238 | bc24a225 | Paul Brook | } SpitzKeyboardState; |
239 | b00052e4 | balrog | |
240 | bc24a225 | Paul Brook | static void spitz_keyboard_sense_update(SpitzKeyboardState *s) |
241 | b00052e4 | balrog | { |
242 | b00052e4 | balrog | int i;
|
243 | b00052e4 | balrog | uint16_t strobe, sense = 0;
|
244 | b00052e4 | balrog | for (i = 0; i < SPITZ_KEY_SENSE_NUM; i ++) { |
245 | b00052e4 | balrog | strobe = s->keyrow[i] & s->strobe_state; |
246 | b00052e4 | balrog | if (strobe) {
|
247 | b00052e4 | balrog | sense |= 1 << i;
|
248 | b00052e4 | balrog | if (!(s->sense_state & (1 << i))) |
249 | 38641a52 | balrog | qemu_irq_raise(s->sense[i]); |
250 | b00052e4 | balrog | } else if (s->sense_state & (1 << i)) |
251 | 38641a52 | balrog | qemu_irq_lower(s->sense[i]); |
252 | b00052e4 | balrog | } |
253 | b00052e4 | balrog | |
254 | b00052e4 | balrog | s->sense_state = sense; |
255 | b00052e4 | balrog | } |
256 | b00052e4 | balrog | |
257 | 38641a52 | balrog | static void spitz_keyboard_strobe(void *opaque, int line, int level) |
258 | b00052e4 | balrog | { |
259 | bc24a225 | Paul Brook | SpitzKeyboardState *s = (SpitzKeyboardState *) opaque; |
260 | 38641a52 | balrog | |
261 | 38641a52 | balrog | if (level)
|
262 | 38641a52 | balrog | s->strobe_state |= 1 << line;
|
263 | 38641a52 | balrog | else
|
264 | 38641a52 | balrog | s->strobe_state &= ~(1 << line);
|
265 | 38641a52 | balrog | spitz_keyboard_sense_update(s); |
266 | b00052e4 | balrog | } |
267 | b00052e4 | balrog | |
268 | bc24a225 | Paul Brook | static void spitz_keyboard_keydown(SpitzKeyboardState *s, int keycode) |
269 | b00052e4 | balrog | { |
270 | b00052e4 | balrog | int spitz_keycode = s->keymap[keycode & 0x7f]; |
271 | b00052e4 | balrog | if (spitz_keycode == -1) |
272 | b00052e4 | balrog | return;
|
273 | b00052e4 | balrog | |
274 | b00052e4 | balrog | /* Handle the additional keys */
|
275 | b00052e4 | balrog | if ((spitz_keycode >> 4) == SPITZ_KEY_SENSE_NUM) { |
276 | 38641a52 | balrog | qemu_set_irq(s->gpiomap[spitz_keycode & 0xf], (keycode < 0x80) ^ |
277 | b00052e4 | balrog | spitz_gpio_invert[spitz_keycode & 0xf]);
|
278 | b00052e4 | balrog | return;
|
279 | b00052e4 | balrog | } |
280 | b00052e4 | balrog | |
281 | b00052e4 | balrog | if (keycode & 0x80) |
282 | b00052e4 | balrog | s->keyrow[spitz_keycode >> 4] &= ~(1 << (spitz_keycode & 0xf)); |
283 | b00052e4 | balrog | else
|
284 | b00052e4 | balrog | s->keyrow[spitz_keycode >> 4] |= 1 << (spitz_keycode & 0xf); |
285 | b00052e4 | balrog | |
286 | b00052e4 | balrog | spitz_keyboard_sense_update(s); |
287 | b00052e4 | balrog | } |
288 | b00052e4 | balrog | |
289 | b00052e4 | balrog | #define SHIFT (1 << 7) |
290 | b00052e4 | balrog | #define CTRL (1 << 8) |
291 | b00052e4 | balrog | #define FN (1 << 9) |
292 | b00052e4 | balrog | |
293 | b00052e4 | balrog | #define QUEUE_KEY(c) s->fifo[(s->fifopos + s->fifolen ++) & 0xf] = c |
294 | b00052e4 | balrog | |
295 | bc24a225 | Paul Brook | static void spitz_keyboard_handler(SpitzKeyboardState *s, int keycode) |
296 | b00052e4 | balrog | { |
297 | b00052e4 | balrog | uint16_t code; |
298 | b00052e4 | balrog | int mapcode;
|
299 | b00052e4 | balrog | switch (keycode) {
|
300 | b00052e4 | balrog | case 0x2a: /* Left Shift */ |
301 | b00052e4 | balrog | s->modifiers |= 1;
|
302 | b00052e4 | balrog | break;
|
303 | b00052e4 | balrog | case 0xaa: |
304 | b00052e4 | balrog | s->modifiers &= ~1;
|
305 | b00052e4 | balrog | break;
|
306 | b00052e4 | balrog | case 0x36: /* Right Shift */ |
307 | b00052e4 | balrog | s->modifiers |= 2;
|
308 | b00052e4 | balrog | break;
|
309 | b00052e4 | balrog | case 0xb6: |
310 | b00052e4 | balrog | s->modifiers &= ~2;
|
311 | b00052e4 | balrog | break;
|
312 | b00052e4 | balrog | case 0x1d: /* Control */ |
313 | b00052e4 | balrog | s->modifiers |= 4;
|
314 | b00052e4 | balrog | break;
|
315 | b00052e4 | balrog | case 0x9d: |
316 | b00052e4 | balrog | s->modifiers &= ~4;
|
317 | b00052e4 | balrog | break;
|
318 | b00052e4 | balrog | case 0x38: /* Alt */ |
319 | b00052e4 | balrog | s->modifiers |= 8;
|
320 | b00052e4 | balrog | break;
|
321 | b00052e4 | balrog | case 0xb8: |
322 | b00052e4 | balrog | s->modifiers &= ~8;
|
323 | b00052e4 | balrog | break;
|
324 | b00052e4 | balrog | } |
325 | b00052e4 | balrog | |
326 | b00052e4 | balrog | code = s->pre_map[mapcode = ((s->modifiers & 3) ?
|
327 | b00052e4 | balrog | (keycode | SHIFT) : |
328 | b00052e4 | balrog | (keycode & ~SHIFT))]; |
329 | b00052e4 | balrog | |
330 | b00052e4 | balrog | if (code != mapcode) {
|
331 | b00052e4 | balrog | #if 0
|
332 | b00052e4 | balrog | if ((code & SHIFT) && !(s->modifiers & 1))
|
333 | b00052e4 | balrog | QUEUE_KEY(0x2a | (keycode & 0x80));
|
334 | b00052e4 | balrog | if ((code & CTRL ) && !(s->modifiers & 4))
|
335 | b00052e4 | balrog | QUEUE_KEY(0x1d | (keycode & 0x80));
|
336 | b00052e4 | balrog | if ((code & FN ) && !(s->modifiers & 8))
|
337 | b00052e4 | balrog | QUEUE_KEY(0x38 | (keycode & 0x80));
|
338 | b00052e4 | balrog | if ((code & FN ) && (s->modifiers & 1))
|
339 | b00052e4 | balrog | QUEUE_KEY(0x2a | (~keycode & 0x80));
|
340 | b00052e4 | balrog | if ((code & FN ) && (s->modifiers & 2))
|
341 | b00052e4 | balrog | QUEUE_KEY(0x36 | (~keycode & 0x80));
|
342 | b00052e4 | balrog | #else
|
343 | b00052e4 | balrog | if (keycode & 0x80) { |
344 | b00052e4 | balrog | if ((s->imodifiers & 1 ) && !(s->modifiers & 1)) |
345 | b00052e4 | balrog | QUEUE_KEY(0x2a | 0x80); |
346 | b00052e4 | balrog | if ((s->imodifiers & 4 ) && !(s->modifiers & 4)) |
347 | b00052e4 | balrog | QUEUE_KEY(0x1d | 0x80); |
348 | b00052e4 | balrog | if ((s->imodifiers & 8 ) && !(s->modifiers & 8)) |
349 | b00052e4 | balrog | QUEUE_KEY(0x38 | 0x80); |
350 | b00052e4 | balrog | if ((s->imodifiers & 0x10) && (s->modifiers & 1)) |
351 | b00052e4 | balrog | QUEUE_KEY(0x2a);
|
352 | b00052e4 | balrog | if ((s->imodifiers & 0x20) && (s->modifiers & 2)) |
353 | b00052e4 | balrog | QUEUE_KEY(0x36);
|
354 | b00052e4 | balrog | s->imodifiers = 0;
|
355 | b00052e4 | balrog | } else {
|
356 | b00052e4 | balrog | if ((code & SHIFT) && !((s->modifiers | s->imodifiers) & 1)) { |
357 | b00052e4 | balrog | QUEUE_KEY(0x2a);
|
358 | b00052e4 | balrog | s->imodifiers |= 1;
|
359 | b00052e4 | balrog | } |
360 | b00052e4 | balrog | if ((code & CTRL ) && !((s->modifiers | s->imodifiers) & 4)) { |
361 | b00052e4 | balrog | QUEUE_KEY(0x1d);
|
362 | b00052e4 | balrog | s->imodifiers |= 4;
|
363 | b00052e4 | balrog | } |
364 | b00052e4 | balrog | if ((code & FN ) && !((s->modifiers | s->imodifiers) & 8)) { |
365 | b00052e4 | balrog | QUEUE_KEY(0x38);
|
366 | b00052e4 | balrog | s->imodifiers |= 8;
|
367 | b00052e4 | balrog | } |
368 | b00052e4 | balrog | if ((code & FN ) && (s->modifiers & 1) && |
369 | b00052e4 | balrog | !(s->imodifiers & 0x10)) {
|
370 | b00052e4 | balrog | QUEUE_KEY(0x2a | 0x80); |
371 | b00052e4 | balrog | s->imodifiers |= 0x10;
|
372 | b00052e4 | balrog | } |
373 | b00052e4 | balrog | if ((code & FN ) && (s->modifiers & 2) && |
374 | b00052e4 | balrog | !(s->imodifiers & 0x20)) {
|
375 | b00052e4 | balrog | QUEUE_KEY(0x36 | 0x80); |
376 | b00052e4 | balrog | s->imodifiers |= 0x20;
|
377 | b00052e4 | balrog | } |
378 | b00052e4 | balrog | } |
379 | b00052e4 | balrog | #endif
|
380 | b00052e4 | balrog | } |
381 | b00052e4 | balrog | |
382 | b00052e4 | balrog | QUEUE_KEY((code & 0x7f) | (keycode & 0x80)); |
383 | b00052e4 | balrog | } |
384 | b00052e4 | balrog | |
385 | b00052e4 | balrog | static void spitz_keyboard_tick(void *opaque) |
386 | b00052e4 | balrog | { |
387 | bc24a225 | Paul Brook | SpitzKeyboardState *s = (SpitzKeyboardState *) opaque; |
388 | b00052e4 | balrog | |
389 | b00052e4 | balrog | if (s->fifolen) {
|
390 | b00052e4 | balrog | spitz_keyboard_keydown(s, s->fifo[s->fifopos ++]); |
391 | b00052e4 | balrog | s->fifolen --; |
392 | b00052e4 | balrog | if (s->fifopos >= 16) |
393 | b00052e4 | balrog | s->fifopos = 0;
|
394 | b00052e4 | balrog | } |
395 | b00052e4 | balrog | |
396 | 6ee093c9 | Juan Quintela | qemu_mod_timer(s->kbdtimer, qemu_get_clock(vm_clock) + |
397 | 6ee093c9 | Juan Quintela | get_ticks_per_sec() / 32);
|
398 | b00052e4 | balrog | } |
399 | b00052e4 | balrog | |
400 | bc24a225 | Paul Brook | static void spitz_keyboard_pre_map(SpitzKeyboardState *s) |
401 | b00052e4 | balrog | { |
402 | b00052e4 | balrog | int i;
|
403 | b00052e4 | balrog | for (i = 0; i < 0x100; i ++) |
404 | b00052e4 | balrog | s->pre_map[i] = i; |
405 | b00052e4 | balrog | s->pre_map[0x02 | SHIFT ] = 0x02 | SHIFT; /* exclam */ |
406 | b00052e4 | balrog | s->pre_map[0x28 | SHIFT ] = 0x03 | SHIFT; /* quotedbl */ |
407 | b00052e4 | balrog | s->pre_map[0x04 | SHIFT ] = 0x04 | SHIFT; /* numbersign */ |
408 | b00052e4 | balrog | s->pre_map[0x05 | SHIFT ] = 0x05 | SHIFT; /* dollar */ |
409 | b00052e4 | balrog | s->pre_map[0x06 | SHIFT ] = 0x06 | SHIFT; /* percent */ |
410 | b00052e4 | balrog | s->pre_map[0x08 | SHIFT ] = 0x07 | SHIFT; /* ampersand */ |
411 | b00052e4 | balrog | s->pre_map[0x28 ] = 0x08 | SHIFT; /* apostrophe */ |
412 | b00052e4 | balrog | s->pre_map[0x0a | SHIFT ] = 0x09 | SHIFT; /* parenleft */ |
413 | b00052e4 | balrog | s->pre_map[0x0b | SHIFT ] = 0x0a | SHIFT; /* parenright */ |
414 | b00052e4 | balrog | s->pre_map[0x29 | SHIFT ] = 0x0b | SHIFT; /* asciitilde */ |
415 | b00052e4 | balrog | s->pre_map[0x03 | SHIFT ] = 0x0c | SHIFT; /* at */ |
416 | b00052e4 | balrog | s->pre_map[0xd3 ] = 0x0e | FN; /* Delete */ |
417 | b00052e4 | balrog | s->pre_map[0x3a ] = 0x0f | FN; /* Caps_Lock */ |
418 | b00052e4 | balrog | s->pre_map[0x07 | SHIFT ] = 0x11 | FN; /* asciicircum */ |
419 | b00052e4 | balrog | s->pre_map[0x0d ] = 0x12 | FN; /* equal */ |
420 | b00052e4 | balrog | s->pre_map[0x0d | SHIFT ] = 0x13 | FN; /* plus */ |
421 | b00052e4 | balrog | s->pre_map[0x1a ] = 0x14 | FN; /* bracketleft */ |
422 | b00052e4 | balrog | s->pre_map[0x1b ] = 0x15 | FN; /* bracketright */ |
423 | 2b76bdc9 | balrog | s->pre_map[0x1a | SHIFT ] = 0x16 | FN; /* braceleft */ |
424 | 2b76bdc9 | balrog | s->pre_map[0x1b | SHIFT ] = 0x17 | FN; /* braceright */ |
425 | b00052e4 | balrog | s->pre_map[0x27 ] = 0x22 | FN; /* semicolon */ |
426 | b00052e4 | balrog | s->pre_map[0x27 | SHIFT ] = 0x23 | FN; /* colon */ |
427 | b00052e4 | balrog | s->pre_map[0x09 | SHIFT ] = 0x24 | FN; /* asterisk */ |
428 | b00052e4 | balrog | s->pre_map[0x2b ] = 0x25 | FN; /* backslash */ |
429 | b00052e4 | balrog | s->pre_map[0x2b | SHIFT ] = 0x26 | FN; /* bar */ |
430 | b00052e4 | balrog | s->pre_map[0x0c | SHIFT ] = 0x30 | FN; /* underscore */ |
431 | 2b76bdc9 | balrog | s->pre_map[0x33 | SHIFT ] = 0x33 | FN; /* less */ |
432 | b00052e4 | balrog | s->pre_map[0x35 ] = 0x33 | SHIFT; /* slash */ |
433 | 2b76bdc9 | balrog | s->pre_map[0x34 | SHIFT ] = 0x34 | FN; /* greater */ |
434 | b00052e4 | balrog | s->pre_map[0x35 | SHIFT ] = 0x34 | SHIFT; /* question */ |
435 | b00052e4 | balrog | s->pre_map[0x49 ] = 0x48 | FN; /* Page_Up */ |
436 | b00052e4 | balrog | s->pre_map[0x51 ] = 0x50 | FN; /* Page_Down */ |
437 | b00052e4 | balrog | |
438 | b00052e4 | balrog | s->modifiers = 0;
|
439 | b00052e4 | balrog | s->imodifiers = 0;
|
440 | b00052e4 | balrog | s->fifopos = 0;
|
441 | b00052e4 | balrog | s->fifolen = 0;
|
442 | b00052e4 | balrog | s->kbdtimer = qemu_new_timer(vm_clock, spitz_keyboard_tick, s); |
443 | b00052e4 | balrog | spitz_keyboard_tick(s); |
444 | b00052e4 | balrog | } |
445 | b00052e4 | balrog | |
446 | b00052e4 | balrog | #undef SHIFT
|
447 | b00052e4 | balrog | #undef CTRL
|
448 | b00052e4 | balrog | #undef FN
|
449 | b00052e4 | balrog | |
450 | aa941b94 | balrog | static void spitz_keyboard_save(QEMUFile *f, void *opaque) |
451 | aa941b94 | balrog | { |
452 | bc24a225 | Paul Brook | SpitzKeyboardState *s = (SpitzKeyboardState *) opaque; |
453 | aa941b94 | balrog | int i;
|
454 | aa941b94 | balrog | |
455 | aa941b94 | balrog | qemu_put_be16s(f, &s->sense_state); |
456 | aa941b94 | balrog | qemu_put_be16s(f, &s->strobe_state); |
457 | aa941b94 | balrog | for (i = 0; i < 5; i ++) |
458 | aa941b94 | balrog | qemu_put_byte(f, spitz_gpio_invert[i]); |
459 | aa941b94 | balrog | } |
460 | aa941b94 | balrog | |
461 | aa941b94 | balrog | static int spitz_keyboard_load(QEMUFile *f, void *opaque, int version_id) |
462 | aa941b94 | balrog | { |
463 | bc24a225 | Paul Brook | SpitzKeyboardState *s = (SpitzKeyboardState *) opaque; |
464 | aa941b94 | balrog | int i;
|
465 | aa941b94 | balrog | |
466 | aa941b94 | balrog | qemu_get_be16s(f, &s->sense_state); |
467 | aa941b94 | balrog | qemu_get_be16s(f, &s->strobe_state); |
468 | aa941b94 | balrog | for (i = 0; i < 5; i ++) |
469 | aa941b94 | balrog | spitz_gpio_invert[i] = qemu_get_byte(f); |
470 | aa941b94 | balrog | |
471 | aa941b94 | balrog | /* Release all pressed keys */
|
472 | aa941b94 | balrog | memset(s->keyrow, 0, sizeof(s->keyrow)); |
473 | aa941b94 | balrog | spitz_keyboard_sense_update(s); |
474 | aa941b94 | balrog | s->modifiers = 0;
|
475 | aa941b94 | balrog | s->imodifiers = 0;
|
476 | aa941b94 | balrog | s->fifopos = 0;
|
477 | aa941b94 | balrog | s->fifolen = 0;
|
478 | aa941b94 | balrog | |
479 | aa941b94 | balrog | return 0; |
480 | aa941b94 | balrog | } |
481 | aa941b94 | balrog | |
482 | bc24a225 | Paul Brook | static void spitz_keyboard_register(PXA2xxState *cpu) |
483 | b00052e4 | balrog | { |
484 | b00052e4 | balrog | int i, j;
|
485 | bc24a225 | Paul Brook | SpitzKeyboardState *s; |
486 | b00052e4 | balrog | |
487 | bc24a225 | Paul Brook | s = (SpitzKeyboardState *) |
488 | bc24a225 | Paul Brook | qemu_mallocz(sizeof(SpitzKeyboardState));
|
489 | bc24a225 | Paul Brook | memset(s, 0, sizeof(SpitzKeyboardState)); |
490 | b00052e4 | balrog | |
491 | b00052e4 | balrog | for (i = 0; i < 0x80; i ++) |
492 | b00052e4 | balrog | s->keymap[i] = -1;
|
493 | b00052e4 | balrog | for (i = 0; i < SPITZ_KEY_SENSE_NUM + 1; i ++) |
494 | b00052e4 | balrog | for (j = 0; j < SPITZ_KEY_STROBE_NUM; j ++) |
495 | b00052e4 | balrog | if (spitz_keymap[i][j] != -1) |
496 | b00052e4 | balrog | s->keymap[spitz_keymap[i][j]] = (i << 4) | j;
|
497 | b00052e4 | balrog | |
498 | 38641a52 | balrog | for (i = 0; i < SPITZ_KEY_SENSE_NUM; i ++) |
499 | 38641a52 | balrog | s->sense[i] = pxa2xx_gpio_in_get(cpu->gpio)[spitz_gpio_key_sense[i]]; |
500 | 38641a52 | balrog | |
501 | 38641a52 | balrog | for (i = 0; i < 5; i ++) |
502 | 38641a52 | balrog | s->gpiomap[i] = pxa2xx_gpio_in_get(cpu->gpio)[spitz_gpiomap[i]]; |
503 | 38641a52 | balrog | |
504 | 38641a52 | balrog | s->strobe = qemu_allocate_irqs(spitz_keyboard_strobe, s, |
505 | 38641a52 | balrog | SPITZ_KEY_STROBE_NUM); |
506 | b00052e4 | balrog | for (i = 0; i < SPITZ_KEY_STROBE_NUM; i ++) |
507 | 38641a52 | balrog | pxa2xx_gpio_out_set(cpu->gpio, spitz_gpio_key_strobe[i], s->strobe[i]); |
508 | b00052e4 | balrog | |
509 | b00052e4 | balrog | spitz_keyboard_pre_map(s); |
510 | b00052e4 | balrog | qemu_add_kbd_event_handler((QEMUPutKBDEvent *) spitz_keyboard_handler, s); |
511 | aa941b94 | balrog | |
512 | 0be71e32 | Alex Williamson | register_savevm(NULL, "spitz_keyboard", 0, 0, |
513 | aa941b94 | balrog | spitz_keyboard_save, spitz_keyboard_load, s); |
514 | b00052e4 | balrog | } |
515 | b00052e4 | balrog | |
516 | b00052e4 | balrog | /* LCD backlight controller */
|
517 | b00052e4 | balrog | |
518 | b00052e4 | balrog | #define LCDTG_RESCTL 0x00 |
519 | b00052e4 | balrog | #define LCDTG_PHACTRL 0x01 |
520 | b00052e4 | balrog | #define LCDTG_DUTYCTRL 0x02 |
521 | b00052e4 | balrog | #define LCDTG_POWERREG0 0x03 |
522 | b00052e4 | balrog | #define LCDTG_POWERREG1 0x04 |
523 | b00052e4 | balrog | #define LCDTG_GPOR3 0x05 |
524 | b00052e4 | balrog | #define LCDTG_PICTRL 0x06 |
525 | b00052e4 | balrog | #define LCDTG_POLCTRL 0x07 |
526 | b00052e4 | balrog | |
527 | a984a69e | Paul Brook | typedef struct { |
528 | a984a69e | Paul Brook | SSISlave ssidev; |
529 | a984a69e | Paul Brook | int bl_intensity;
|
530 | a984a69e | Paul Brook | int bl_power;
|
531 | a984a69e | Paul Brook | } SpitzLCDTG; |
532 | b00052e4 | balrog | |
533 | a984a69e | Paul Brook | static void spitz_bl_update(SpitzLCDTG *s) |
534 | b00052e4 | balrog | { |
535 | a984a69e | Paul Brook | if (s->bl_power && s->bl_intensity)
|
536 | a984a69e | Paul Brook | zaurus_printf("LCD Backlight now at %i/63\n", s->bl_intensity);
|
537 | b00052e4 | balrog | else
|
538 | 89cdb6af | balrog | zaurus_printf("LCD Backlight now off\n");
|
539 | b00052e4 | balrog | } |
540 | b00052e4 | balrog | |
541 | a984a69e | Paul Brook | /* FIXME: Implement GPIO properly and remove this hack. */
|
542 | a984a69e | Paul Brook | static SpitzLCDTG *spitz_lcdtg;
|
543 | a984a69e | Paul Brook | |
544 | 38641a52 | balrog | static inline void spitz_bl_bit5(void *opaque, int line, int level) |
545 | b00052e4 | balrog | { |
546 | a984a69e | Paul Brook | SpitzLCDTG *s = spitz_lcdtg; |
547 | a984a69e | Paul Brook | int prev = s->bl_intensity;
|
548 | b00052e4 | balrog | |
549 | b00052e4 | balrog | if (level)
|
550 | a984a69e | Paul Brook | s->bl_intensity &= ~0x20;
|
551 | b00052e4 | balrog | else
|
552 | a984a69e | Paul Brook | s->bl_intensity |= 0x20;
|
553 | b00052e4 | balrog | |
554 | a984a69e | Paul Brook | if (s->bl_power && prev != s->bl_intensity)
|
555 | a984a69e | Paul Brook | spitz_bl_update(s); |
556 | b00052e4 | balrog | } |
557 | b00052e4 | balrog | |
558 | 38641a52 | balrog | static inline void spitz_bl_power(void *opaque, int line, int level) |
559 | b00052e4 | balrog | { |
560 | a984a69e | Paul Brook | SpitzLCDTG *s = spitz_lcdtg; |
561 | a984a69e | Paul Brook | s->bl_power = !!level; |
562 | a984a69e | Paul Brook | spitz_bl_update(s); |
563 | b00052e4 | balrog | } |
564 | b00052e4 | balrog | |
565 | a984a69e | Paul Brook | static uint32_t spitz_lcdtg_transfer(SSISlave *dev, uint32_t value)
|
566 | b00052e4 | balrog | { |
567 | a984a69e | Paul Brook | SpitzLCDTG *s = FROM_SSI_SLAVE(SpitzLCDTG, dev); |
568 | a984a69e | Paul Brook | int addr;
|
569 | a984a69e | Paul Brook | addr = value >> 5;
|
570 | a984a69e | Paul Brook | value &= 0x1f;
|
571 | b00052e4 | balrog | |
572 | b00052e4 | balrog | switch (addr) {
|
573 | b00052e4 | balrog | case LCDTG_RESCTL:
|
574 | b00052e4 | balrog | if (value)
|
575 | 89cdb6af | balrog | zaurus_printf("LCD in QVGA mode\n");
|
576 | b00052e4 | balrog | else
|
577 | 89cdb6af | balrog | zaurus_printf("LCD in VGA mode\n");
|
578 | b00052e4 | balrog | break;
|
579 | b00052e4 | balrog | |
580 | b00052e4 | balrog | case LCDTG_DUTYCTRL:
|
581 | a984a69e | Paul Brook | s->bl_intensity &= ~0x1f;
|
582 | a984a69e | Paul Brook | s->bl_intensity |= value; |
583 | a984a69e | Paul Brook | if (s->bl_power)
|
584 | a984a69e | Paul Brook | spitz_bl_update(s); |
585 | b00052e4 | balrog | break;
|
586 | b00052e4 | balrog | |
587 | b00052e4 | balrog | case LCDTG_POWERREG0:
|
588 | b00052e4 | balrog | /* Set common voltage to M62332FP */
|
589 | b00052e4 | balrog | break;
|
590 | b00052e4 | balrog | } |
591 | a984a69e | Paul Brook | return 0; |
592 | a984a69e | Paul Brook | } |
593 | a984a69e | Paul Brook | |
594 | a984a69e | Paul Brook | static void spitz_lcdtg_save(QEMUFile *f, void *opaque) |
595 | a984a69e | Paul Brook | { |
596 | a984a69e | Paul Brook | SpitzLCDTG *s = (SpitzLCDTG *)opaque; |
597 | a984a69e | Paul Brook | qemu_put_be32(f, s->bl_intensity); |
598 | a984a69e | Paul Brook | qemu_put_be32(f, s->bl_power); |
599 | a984a69e | Paul Brook | } |
600 | a984a69e | Paul Brook | |
601 | a984a69e | Paul Brook | static int spitz_lcdtg_load(QEMUFile *f, void *opaque, int version_id) |
602 | a984a69e | Paul Brook | { |
603 | a984a69e | Paul Brook | SpitzLCDTG *s = (SpitzLCDTG *)opaque; |
604 | a984a69e | Paul Brook | s->bl_intensity = qemu_get_be32(f); |
605 | a984a69e | Paul Brook | s->bl_power = qemu_get_be32(f); |
606 | a984a69e | Paul Brook | return 0; |
607 | a984a69e | Paul Brook | } |
608 | a984a69e | Paul Brook | |
609 | 81a322d4 | Gerd Hoffmann | static int spitz_lcdtg_init(SSISlave *dev) |
610 | a984a69e | Paul Brook | { |
611 | a984a69e | Paul Brook | SpitzLCDTG *s = FROM_SSI_SLAVE(SpitzLCDTG, dev); |
612 | a984a69e | Paul Brook | |
613 | a984a69e | Paul Brook | spitz_lcdtg = s; |
614 | a984a69e | Paul Brook | s->bl_power = 0;
|
615 | a984a69e | Paul Brook | s->bl_intensity = 0x20;
|
616 | a984a69e | Paul Brook | |
617 | 0be71e32 | Alex Williamson | register_savevm(&dev->qdev, "spitz-lcdtg", -1, 1, |
618 | a984a69e | Paul Brook | spitz_lcdtg_save, spitz_lcdtg_load, s); |
619 | 81a322d4 | Gerd Hoffmann | return 0; |
620 | b00052e4 | balrog | } |
621 | b00052e4 | balrog | |
622 | b00052e4 | balrog | /* SSP devices */
|
623 | b00052e4 | balrog | |
624 | b00052e4 | balrog | #define CORGI_SSP_PORT 2 |
625 | b00052e4 | balrog | |
626 | b00052e4 | balrog | #define SPITZ_GPIO_LCDCON_CS 53 |
627 | b00052e4 | balrog | #define SPITZ_GPIO_ADS7846_CS 14 |
628 | b00052e4 | balrog | #define SPITZ_GPIO_MAX1111_CS 20 |
629 | b00052e4 | balrog | #define SPITZ_GPIO_TP_INT 11 |
630 | b00052e4 | balrog | |
631 | a984a69e | Paul Brook | static DeviceState *max1111;
|
632 | b00052e4 | balrog | |
633 | b00052e4 | balrog | /* "Demux" the signal based on current chipselect */
|
634 | a984a69e | Paul Brook | typedef struct { |
635 | a984a69e | Paul Brook | SSISlave ssidev; |
636 | a984a69e | Paul Brook | SSIBus *bus[3];
|
637 | a984a69e | Paul Brook | int enable[3]; |
638 | a984a69e | Paul Brook | } CorgiSSPState; |
639 | b00052e4 | balrog | |
640 | a984a69e | Paul Brook | static uint32_t corgi_ssp_transfer(SSISlave *dev, uint32_t value)
|
641 | b00052e4 | balrog | { |
642 | a984a69e | Paul Brook | CorgiSSPState *s = FROM_SSI_SLAVE(CorgiSSPState, dev); |
643 | a984a69e | Paul Brook | int i;
|
644 | a984a69e | Paul Brook | |
645 | a984a69e | Paul Brook | for (i = 0; i < 3; i++) { |
646 | a984a69e | Paul Brook | if (s->enable[i]) {
|
647 | a984a69e | Paul Brook | return ssi_transfer(s->bus[i], value);
|
648 | a984a69e | Paul Brook | } |
649 | a984a69e | Paul Brook | } |
650 | a984a69e | Paul Brook | return 0; |
651 | b00052e4 | balrog | } |
652 | b00052e4 | balrog | |
653 | 38641a52 | balrog | static void corgi_ssp_gpio_cs(void *opaque, int line, int level) |
654 | b00052e4 | balrog | { |
655 | a984a69e | Paul Brook | CorgiSSPState *s = (CorgiSSPState *)opaque; |
656 | a984a69e | Paul Brook | assert(line >= 0 && line < 3); |
657 | a984a69e | Paul Brook | s->enable[line] = !level; |
658 | b00052e4 | balrog | } |
659 | b00052e4 | balrog | |
660 | b00052e4 | balrog | #define MAX1111_BATT_VOLT 1 |
661 | b00052e4 | balrog | #define MAX1111_BATT_TEMP 2 |
662 | b00052e4 | balrog | #define MAX1111_ACIN_VOLT 3 |
663 | b00052e4 | balrog | |
664 | b00052e4 | balrog | #define SPITZ_BATTERY_TEMP 0xe0 /* About 2.9V */ |
665 | b00052e4 | balrog | #define SPITZ_BATTERY_VOLT 0xd0 /* About 4.0V */ |
666 | b00052e4 | balrog | #define SPITZ_CHARGEON_ACIN 0x80 /* About 5.0V */ |
667 | b00052e4 | balrog | |
668 | 38641a52 | balrog | static void spitz_adc_temp_on(void *opaque, int line, int level) |
669 | b00052e4 | balrog | { |
670 | b00052e4 | balrog | if (!max1111)
|
671 | b00052e4 | balrog | return;
|
672 | b00052e4 | balrog | |
673 | b00052e4 | balrog | if (level)
|
674 | b00052e4 | balrog | max111x_set_input(max1111, MAX1111_BATT_TEMP, SPITZ_BATTERY_TEMP); |
675 | b00052e4 | balrog | else
|
676 | b00052e4 | balrog | max111x_set_input(max1111, MAX1111_BATT_TEMP, 0);
|
677 | b00052e4 | balrog | } |
678 | b00052e4 | balrog | |
679 | aa941b94 | balrog | static void spitz_ssp_save(QEMUFile *f, void *opaque) |
680 | aa941b94 | balrog | { |
681 | a984a69e | Paul Brook | CorgiSSPState *s = (CorgiSSPState *)opaque; |
682 | a984a69e | Paul Brook | int i;
|
683 | a984a69e | Paul Brook | |
684 | a984a69e | Paul Brook | for (i = 0; i < 3; i++) { |
685 | a984a69e | Paul Brook | qemu_put_be32(f, s->enable[i]); |
686 | a984a69e | Paul Brook | } |
687 | aa941b94 | balrog | } |
688 | aa941b94 | balrog | |
689 | aa941b94 | balrog | static int spitz_ssp_load(QEMUFile *f, void *opaque, int version_id) |
690 | aa941b94 | balrog | { |
691 | a984a69e | Paul Brook | CorgiSSPState *s = (CorgiSSPState *)opaque; |
692 | a984a69e | Paul Brook | int i;
|
693 | aa941b94 | balrog | |
694 | a984a69e | Paul Brook | if (version_id != 1) { |
695 | a984a69e | Paul Brook | return -EINVAL;
|
696 | a984a69e | Paul Brook | } |
697 | a984a69e | Paul Brook | for (i = 0; i < 3; i++) { |
698 | a984a69e | Paul Brook | s->enable[i] = qemu_get_be32(f); |
699 | a984a69e | Paul Brook | } |
700 | aa941b94 | balrog | return 0; |
701 | aa941b94 | balrog | } |
702 | aa941b94 | balrog | |
703 | 81a322d4 | Gerd Hoffmann | static int corgi_ssp_init(SSISlave *dev) |
704 | a984a69e | Paul Brook | { |
705 | a984a69e | Paul Brook | CorgiSSPState *s = FROM_SSI_SLAVE(CorgiSSPState, dev); |
706 | a984a69e | Paul Brook | |
707 | a984a69e | Paul Brook | qdev_init_gpio_in(&dev->qdev, corgi_ssp_gpio_cs, 3);
|
708 | 02e2da45 | Paul Brook | s->bus[0] = ssi_create_bus(&dev->qdev, "ssi0"); |
709 | 02e2da45 | Paul Brook | s->bus[1] = ssi_create_bus(&dev->qdev, "ssi1"); |
710 | 02e2da45 | Paul Brook | s->bus[2] = ssi_create_bus(&dev->qdev, "ssi2"); |
711 | a984a69e | Paul Brook | |
712 | 0be71e32 | Alex Williamson | register_savevm(&dev->qdev, "spitz_ssp", -1, 1, |
713 | 0be71e32 | Alex Williamson | spitz_ssp_save, spitz_ssp_load, s); |
714 | 81a322d4 | Gerd Hoffmann | return 0; |
715 | a984a69e | Paul Brook | } |
716 | a984a69e | Paul Brook | |
717 | bc24a225 | Paul Brook | static void spitz_ssp_attach(PXA2xxState *cpu) |
718 | b00052e4 | balrog | { |
719 | a984a69e | Paul Brook | DeviceState *mux; |
720 | a984a69e | Paul Brook | DeviceState *dev; |
721 | a984a69e | Paul Brook | void *bus;
|
722 | a984a69e | Paul Brook | |
723 | a984a69e | Paul Brook | mux = ssi_create_slave(cpu->ssp[CORGI_SSP_PORT - 1], "corgi-ssp"); |
724 | 38641a52 | balrog | |
725 | a984a69e | Paul Brook | bus = qdev_get_child_bus(mux, "ssi0");
|
726 | 22ed1d34 | Blue Swirl | ssi_create_slave(bus, "spitz-lcdtg");
|
727 | b00052e4 | balrog | |
728 | a984a69e | Paul Brook | bus = qdev_get_child_bus(mux, "ssi1");
|
729 | a984a69e | Paul Brook | dev = ssi_create_slave(bus, "ads7846");
|
730 | a984a69e | Paul Brook | qdev_connect_gpio_out(dev, 0,
|
731 | a984a69e | Paul Brook | pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_TP_INT]); |
732 | b00052e4 | balrog | |
733 | a984a69e | Paul Brook | bus = qdev_get_child_bus(mux, "ssi2");
|
734 | a984a69e | Paul Brook | max1111 = ssi_create_slave(bus, "max1111");
|
735 | b00052e4 | balrog | max111x_set_input(max1111, MAX1111_BATT_VOLT, SPITZ_BATTERY_VOLT); |
736 | b00052e4 | balrog | max111x_set_input(max1111, MAX1111_BATT_TEMP, 0);
|
737 | b00052e4 | balrog | max111x_set_input(max1111, MAX1111_ACIN_VOLT, SPITZ_CHARGEON_ACIN); |
738 | b00052e4 | balrog | |
739 | a984a69e | Paul Brook | pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_LCDCON_CS, |
740 | a984a69e | Paul Brook | qdev_get_gpio_in(mux, 0));
|
741 | a984a69e | Paul Brook | pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_ADS7846_CS, |
742 | a984a69e | Paul Brook | qdev_get_gpio_in(mux, 1));
|
743 | a984a69e | Paul Brook | pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_MAX1111_CS, |
744 | a984a69e | Paul Brook | qdev_get_gpio_in(mux, 2));
|
745 | b00052e4 | balrog | } |
746 | b00052e4 | balrog | |
747 | b00052e4 | balrog | /* CF Microdrive */
|
748 | b00052e4 | balrog | |
749 | bc24a225 | Paul Brook | static void spitz_microdrive_attach(PXA2xxState *cpu, int slot) |
750 | b00052e4 | balrog | { |
751 | bc24a225 | Paul Brook | PCMCIACardState *md; |
752 | e4bcb14c | ths | BlockDriverState *bs; |
753 | 751c6a17 | Gerd Hoffmann | DriveInfo *dinfo; |
754 | b00052e4 | balrog | |
755 | 751c6a17 | Gerd Hoffmann | dinfo = drive_get(IF_IDE, 0, 0); |
756 | 751c6a17 | Gerd Hoffmann | if (!dinfo)
|
757 | e4bcb14c | ths | return;
|
758 | 751c6a17 | Gerd Hoffmann | bs = dinfo->bdrv; |
759 | e4bcb14c | ths | if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) {
|
760 | f455e98c | Gerd Hoffmann | md = dscm1xxxx_init(dinfo); |
761 | 15b18ec2 | balrog | pxa2xx_pcmcia_attach(cpu->pcmcia[slot], md); |
762 | b00052e4 | balrog | } |
763 | b00052e4 | balrog | } |
764 | b00052e4 | balrog | |
765 | adb86c37 | balrog | /* Wm8750 and Max7310 on I2C */
|
766 | adb86c37 | balrog | |
767 | adb86c37 | balrog | #define AKITA_MAX_ADDR 0x18 |
768 | 611d7189 | balrog | #define SPITZ_WM_ADDRL 0x1b |
769 | 611d7189 | balrog | #define SPITZ_WM_ADDRH 0x1a |
770 | adb86c37 | balrog | |
771 | adb86c37 | balrog | #define SPITZ_GPIO_WM 5 |
772 | adb86c37 | balrog | |
773 | 38641a52 | balrog | static void spitz_wm8750_addr(void *opaque, int line, int level) |
774 | adb86c37 | balrog | { |
775 | adb86c37 | balrog | i2c_slave *wm = (i2c_slave *) opaque; |
776 | adb86c37 | balrog | if (level)
|
777 | adb86c37 | balrog | i2c_set_slave_address(wm, SPITZ_WM_ADDRH); |
778 | adb86c37 | balrog | else
|
779 | adb86c37 | balrog | i2c_set_slave_address(wm, SPITZ_WM_ADDRL); |
780 | adb86c37 | balrog | } |
781 | adb86c37 | balrog | |
782 | bc24a225 | Paul Brook | static void spitz_i2c_setup(PXA2xxState *cpu) |
783 | adb86c37 | balrog | { |
784 | adb86c37 | balrog | /* Attach the CPU on one end of our I2C bus. */
|
785 | adb86c37 | balrog | i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
|
786 | adb86c37 | balrog | |
787 | cdbe40ca | Paul Brook | DeviceState *wm; |
788 | adb86c37 | balrog | |
789 | adb86c37 | balrog | /* Attach a WM8750 to the bus */
|
790 | cdbe40ca | Paul Brook | wm = i2c_create_slave(bus, "wm8750", 0); |
791 | adb86c37 | balrog | |
792 | 38641a52 | balrog | spitz_wm8750_addr(wm, 0, 0); |
793 | 38641a52 | balrog | pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_WM, |
794 | 38641a52 | balrog | qemu_allocate_irqs(spitz_wm8750_addr, wm, 1)[0]); |
795 | adb86c37 | balrog | /* .. and to the sound interface. */
|
796 | adb86c37 | balrog | cpu->i2s->opaque = wm; |
797 | adb86c37 | balrog | cpu->i2s->codec_out = wm8750_dac_dat; |
798 | adb86c37 | balrog | cpu->i2s->codec_in = wm8750_adc_dat; |
799 | adb86c37 | balrog | wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s); |
800 | adb86c37 | balrog | } |
801 | adb86c37 | balrog | |
802 | bc24a225 | Paul Brook | static void spitz_akita_i2c_setup(PXA2xxState *cpu) |
803 | adb86c37 | balrog | { |
804 | adb86c37 | balrog | /* Attach a Max7310 to Akita I2C bus. */
|
805 | 6c0bd6bd | Paul Brook | i2c_create_slave(pxa2xx_i2c_bus(cpu->i2c[0]), "max7310", |
806 | 6c0bd6bd | Paul Brook | AKITA_MAX_ADDR); |
807 | adb86c37 | balrog | } |
808 | adb86c37 | balrog | |
809 | b00052e4 | balrog | /* Other peripherals */
|
810 | b00052e4 | balrog | |
811 | 38641a52 | balrog | static void spitz_out_switch(void *opaque, int line, int level) |
812 | b00052e4 | balrog | { |
813 | 38641a52 | balrog | switch (line) {
|
814 | 38641a52 | balrog | case 0: |
815 | 89cdb6af | balrog | zaurus_printf("Charging %s.\n", level ? "off" : "on"); |
816 | 38641a52 | balrog | break;
|
817 | 38641a52 | balrog | case 1: |
818 | 89cdb6af | balrog | zaurus_printf("Discharging %s.\n", level ? "on" : "off"); |
819 | 38641a52 | balrog | break;
|
820 | 38641a52 | balrog | case 2: |
821 | 89cdb6af | balrog | zaurus_printf("Green LED %s.\n", level ? "on" : "off"); |
822 | 38641a52 | balrog | break;
|
823 | 38641a52 | balrog | case 3: |
824 | 89cdb6af | balrog | zaurus_printf("Orange LED %s.\n", level ? "on" : "off"); |
825 | 38641a52 | balrog | break;
|
826 | 38641a52 | balrog | case 4: |
827 | 38641a52 | balrog | spitz_bl_bit5(opaque, line, level); |
828 | 38641a52 | balrog | break;
|
829 | 38641a52 | balrog | case 5: |
830 | 38641a52 | balrog | spitz_bl_power(opaque, line, level); |
831 | 38641a52 | balrog | break;
|
832 | 38641a52 | balrog | case 6: |
833 | 38641a52 | balrog | spitz_adc_temp_on(opaque, line, level); |
834 | 38641a52 | balrog | break;
|
835 | 38641a52 | balrog | } |
836 | b00052e4 | balrog | } |
837 | b00052e4 | balrog | |
838 | b00052e4 | balrog | #define SPITZ_SCP_LED_GREEN 1 |
839 | b00052e4 | balrog | #define SPITZ_SCP_JK_B 2 |
840 | b00052e4 | balrog | #define SPITZ_SCP_CHRG_ON 3 |
841 | b00052e4 | balrog | #define SPITZ_SCP_MUTE_L 4 |
842 | b00052e4 | balrog | #define SPITZ_SCP_MUTE_R 5 |
843 | b00052e4 | balrog | #define SPITZ_SCP_CF_POWER 6 |
844 | b00052e4 | balrog | #define SPITZ_SCP_LED_ORANGE 7 |
845 | b00052e4 | balrog | #define SPITZ_SCP_JK_A 8 |
846 | b00052e4 | balrog | #define SPITZ_SCP_ADC_TEMP_ON 9 |
847 | b00052e4 | balrog | #define SPITZ_SCP2_IR_ON 1 |
848 | b00052e4 | balrog | #define SPITZ_SCP2_AKIN_PULLUP 2 |
849 | b00052e4 | balrog | #define SPITZ_SCP2_BACKLIGHT_CONT 7 |
850 | b00052e4 | balrog | #define SPITZ_SCP2_BACKLIGHT_ON 8 |
851 | b00052e4 | balrog | #define SPITZ_SCP2_MIC_BIAS 9 |
852 | b00052e4 | balrog | |
853 | bc24a225 | Paul Brook | static void spitz_scoop_gpio_setup(PXA2xxState *cpu, |
854 | bc24a225 | Paul Brook | ScoopInfo *scp0, ScoopInfo *scp1) |
855 | b00052e4 | balrog | { |
856 | 38641a52 | balrog | qemu_irq *outsignals = qemu_allocate_irqs(spitz_out_switch, cpu, 8);
|
857 | 38641a52 | balrog | |
858 | e33d8cdb | balrog | scoop_gpio_out_set(scp0, SPITZ_SCP_CHRG_ON, outsignals[0]);
|
859 | e33d8cdb | balrog | scoop_gpio_out_set(scp0, SPITZ_SCP_JK_B, outsignals[1]);
|
860 | e33d8cdb | balrog | scoop_gpio_out_set(scp0, SPITZ_SCP_LED_GREEN, outsignals[2]);
|
861 | e33d8cdb | balrog | scoop_gpio_out_set(scp0, SPITZ_SCP_LED_ORANGE, outsignals[3]);
|
862 | b00052e4 | balrog | |
863 | e33d8cdb | balrog | if (scp1) {
|
864 | e33d8cdb | balrog | scoop_gpio_out_set(scp1, SPITZ_SCP2_BACKLIGHT_CONT, outsignals[4]);
|
865 | e33d8cdb | balrog | scoop_gpio_out_set(scp1, SPITZ_SCP2_BACKLIGHT_ON, outsignals[5]);
|
866 | b00052e4 | balrog | } |
867 | b00052e4 | balrog | |
868 | e33d8cdb | balrog | scoop_gpio_out_set(scp0, SPITZ_SCP_ADC_TEMP_ON, outsignals[6]);
|
869 | b00052e4 | balrog | } |
870 | b00052e4 | balrog | |
871 | b00052e4 | balrog | #define SPITZ_GPIO_HSYNC 22 |
872 | b00052e4 | balrog | #define SPITZ_GPIO_SD_DETECT 9 |
873 | b00052e4 | balrog | #define SPITZ_GPIO_SD_WP 81 |
874 | b00052e4 | balrog | #define SPITZ_GPIO_ON_RESET 89 |
875 | b00052e4 | balrog | #define SPITZ_GPIO_BAT_COVER 90 |
876 | b00052e4 | balrog | #define SPITZ_GPIO_CF1_IRQ 105 |
877 | b00052e4 | balrog | #define SPITZ_GPIO_CF1_CD 94 |
878 | b00052e4 | balrog | #define SPITZ_GPIO_CF2_IRQ 106 |
879 | b00052e4 | balrog | #define SPITZ_GPIO_CF2_CD 93 |
880 | b00052e4 | balrog | |
881 | 38641a52 | balrog | static int spitz_hsync; |
882 | b00052e4 | balrog | |
883 | 38641a52 | balrog | static void spitz_lcd_hsync_handler(void *opaque, int line, int level) |
884 | b00052e4 | balrog | { |
885 | bc24a225 | Paul Brook | PXA2xxState *cpu = (PXA2xxState *) opaque; |
886 | 38641a52 | balrog | qemu_set_irq(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_HSYNC], spitz_hsync); |
887 | b00052e4 | balrog | spitz_hsync ^= 1;
|
888 | b00052e4 | balrog | } |
889 | b00052e4 | balrog | |
890 | bc24a225 | Paul Brook | static void spitz_gpio_setup(PXA2xxState *cpu, int slots) |
891 | b00052e4 | balrog | { |
892 | 38641a52 | balrog | qemu_irq lcd_hsync; |
893 | b00052e4 | balrog | /*
|
894 | b00052e4 | balrog | * Bad hack: We toggle the LCD hsync GPIO on every GPIO status
|
895 | b00052e4 | balrog | * read to satisfy broken guests that poll-wait for hsync.
|
896 | b00052e4 | balrog | * Simulating a real hsync event would be less practical and
|
897 | b00052e4 | balrog | * wouldn't guarantee that a guest ever exits the loop.
|
898 | b00052e4 | balrog | */
|
899 | b00052e4 | balrog | spitz_hsync = 0;
|
900 | 38641a52 | balrog | lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, cpu, 1)[0]; |
901 | 38641a52 | balrog | pxa2xx_gpio_read_notifier(cpu->gpio, lcd_hsync); |
902 | 38641a52 | balrog | pxa2xx_lcd_vsync_notifier(cpu->lcd, lcd_hsync); |
903 | b00052e4 | balrog | |
904 | b00052e4 | balrog | /* MMC/SD host */
|
905 | 02ce600c | balrog | pxa2xx_mmci_handlers(cpu->mmc, |
906 | 02ce600c | balrog | pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_SD_WP], |
907 | 02ce600c | balrog | pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_SD_DETECT]); |
908 | b00052e4 | balrog | |
909 | b00052e4 | balrog | /* Battery lock always closed */
|
910 | 38641a52 | balrog | qemu_irq_raise(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_BAT_COVER]); |
911 | b00052e4 | balrog | |
912 | b00052e4 | balrog | /* Handle reset */
|
913 | 38641a52 | balrog | pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_ON_RESET, cpu->reset); |
914 | b00052e4 | balrog | |
915 | b00052e4 | balrog | /* PCMCIA signals: card's IRQ and Card-Detect */
|
916 | b00052e4 | balrog | if (slots >= 1) |
917 | 38641a52 | balrog | pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
|
918 | 38641a52 | balrog | pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_CF1_IRQ], |
919 | 38641a52 | balrog | pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_CF1_CD]); |
920 | b00052e4 | balrog | if (slots >= 2) |
921 | 38641a52 | balrog | pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
|
922 | 38641a52 | balrog | pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_CF2_IRQ], |
923 | 38641a52 | balrog | pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_CF2_CD]); |
924 | b00052e4 | balrog | |
925 | b00052e4 | balrog | /* Initialise the screen rotation related signals */
|
926 | b00052e4 | balrog | spitz_gpio_invert[3] = 0; /* Always open */ |
927 | b00052e4 | balrog | if (graphic_rotate) { /* Tablet mode */ |
928 | b00052e4 | balrog | spitz_gpio_invert[4] = 0; |
929 | b00052e4 | balrog | } else { /* Portrait mode */ |
930 | b00052e4 | balrog | spitz_gpio_invert[4] = 1; |
931 | b00052e4 | balrog | } |
932 | 38641a52 | balrog | qemu_set_irq(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_SWA], |
933 | 38641a52 | balrog | spitz_gpio_invert[3]);
|
934 | 38641a52 | balrog | qemu_set_irq(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_SWB], |
935 | 38641a52 | balrog | spitz_gpio_invert[4]);
|
936 | b00052e4 | balrog | } |
937 | b00052e4 | balrog | |
938 | b00052e4 | balrog | /* Board init. */
|
939 | b00052e4 | balrog | enum spitz_model_e { spitz, akita, borzoi, terrier };
|
940 | b00052e4 | balrog | |
941 | 7fb4fdcf | balrog | #define SPITZ_RAM 0x04000000 |
942 | 7fb4fdcf | balrog | #define SPITZ_ROM 0x00800000 |
943 | 7fb4fdcf | balrog | |
944 | f93eb9ff | balrog | static struct arm_boot_info spitz_binfo = { |
945 | f93eb9ff | balrog | .loader_start = PXA2XX_SDRAM_BASE, |
946 | f93eb9ff | balrog | .ram_size = 0x04000000,
|
947 | f93eb9ff | balrog | }; |
948 | f93eb9ff | balrog | |
949 | c227f099 | Anthony Liguori | static void spitz_common_init(ram_addr_t ram_size, |
950 | 3023f332 | aliguori | const char *kernel_filename, |
951 | b00052e4 | balrog | const char *kernel_cmdline, const char *initrd_filename, |
952 | 4207117c | balrog | const char *cpu_model, enum spitz_model_e model, int arm_id) |
953 | b00052e4 | balrog | { |
954 | bc24a225 | Paul Brook | PXA2xxState *cpu; |
955 | bc24a225 | Paul Brook | ScoopInfo *scp0, *scp1 = NULL;
|
956 | b00052e4 | balrog | |
957 | 4207117c | balrog | if (!cpu_model)
|
958 | 4207117c | balrog | cpu_model = (model == terrier) ? "pxa270-c5" : "pxa270-c0"; |
959 | b00052e4 | balrog | |
960 | d95b2f8d | balrog | /* Setup CPU & memory */
|
961 | 3023f332 | aliguori | cpu = pxa270_init(spitz_binfo.ram_size, cpu_model); |
962 | b00052e4 | balrog | |
963 | b00052e4 | balrog | sl_flash_register(cpu, (model == spitz) ? FLASH_128M : FLASH_1024M); |
964 | b00052e4 | balrog | |
965 | 7fb4fdcf | balrog | cpu_register_physical_memory(0, SPITZ_ROM,
|
966 | 1724f049 | Alex Williamson | qemu_ram_alloc(NULL, "spitz.rom", SPITZ_ROM) | IO_MEM_ROM); |
967 | b00052e4 | balrog | |
968 | b00052e4 | balrog | /* Setup peripherals */
|
969 | b00052e4 | balrog | spitz_keyboard_register(cpu); |
970 | b00052e4 | balrog | |
971 | b00052e4 | balrog | spitz_ssp_attach(cpu); |
972 | b00052e4 | balrog | |
973 | e33d8cdb | balrog | scp0 = scoop_init(cpu, 0, 0x10800000); |
974 | e33d8cdb | balrog | if (model != akita) {
|
975 | e33d8cdb | balrog | scp1 = scoop_init(cpu, 1, 0x08800040); |
976 | e33d8cdb | balrog | } |
977 | b00052e4 | balrog | |
978 | e33d8cdb | balrog | spitz_scoop_gpio_setup(cpu, scp0, scp1); |
979 | b00052e4 | balrog | |
980 | b00052e4 | balrog | spitz_gpio_setup(cpu, (model == akita) ? 1 : 2); |
981 | b00052e4 | balrog | |
982 | adb86c37 | balrog | spitz_i2c_setup(cpu); |
983 | adb86c37 | balrog | |
984 | adb86c37 | balrog | if (model == akita)
|
985 | adb86c37 | balrog | spitz_akita_i2c_setup(cpu); |
986 | adb86c37 | balrog | |
987 | b00052e4 | balrog | if (model == terrier)
|
988 | bf5ee248 | balrog | /* A 6.0 GB microdrive is permanently sitting in CF slot 1. */
|
989 | 15b18ec2 | balrog | spitz_microdrive_attach(cpu, 1);
|
990 | b00052e4 | balrog | else if (model != akita) |
991 | 15b18ec2 | balrog | /* A 4.0 GB microdrive is permanently sitting in CF slot 0. */
|
992 | 15b18ec2 | balrog | spitz_microdrive_attach(cpu, 0);
|
993 | b00052e4 | balrog | |
994 | f93eb9ff | balrog | spitz_binfo.kernel_filename = kernel_filename; |
995 | f93eb9ff | balrog | spitz_binfo.kernel_cmdline = kernel_cmdline; |
996 | f93eb9ff | balrog | spitz_binfo.initrd_filename = initrd_filename; |
997 | f93eb9ff | balrog | spitz_binfo.board_id = arm_id; |
998 | f93eb9ff | balrog | arm_load_kernel(cpu->env, &spitz_binfo); |
999 | f78630ab | pbrook | sl_bootparam_write(SL_PXA_PARAM_BASE); |
1000 | b00052e4 | balrog | } |
1001 | b00052e4 | balrog | |
1002 | c227f099 | Anthony Liguori | static void spitz_init(ram_addr_t ram_size, |
1003 | 3023f332 | aliguori | const char *boot_device, |
1004 | b00052e4 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
1005 | b00052e4 | balrog | const char *initrd_filename, const char *cpu_model) |
1006 | b00052e4 | balrog | { |
1007 | fbe1b595 | Paul Brook | spitz_common_init(ram_size, kernel_filename, |
1008 | 4207117c | balrog | kernel_cmdline, initrd_filename, cpu_model, spitz, 0x2c9);
|
1009 | b00052e4 | balrog | } |
1010 | b00052e4 | balrog | |
1011 | c227f099 | Anthony Liguori | static void borzoi_init(ram_addr_t ram_size, |
1012 | 3023f332 | aliguori | const char *boot_device, |
1013 | b00052e4 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
1014 | b00052e4 | balrog | const char *initrd_filename, const char *cpu_model) |
1015 | b00052e4 | balrog | { |
1016 | fbe1b595 | Paul Brook | spitz_common_init(ram_size, kernel_filename, |
1017 | 4207117c | balrog | kernel_cmdline, initrd_filename, cpu_model, borzoi, 0x33f);
|
1018 | b00052e4 | balrog | } |
1019 | b00052e4 | balrog | |
1020 | c227f099 | Anthony Liguori | static void akita_init(ram_addr_t ram_size, |
1021 | 3023f332 | aliguori | const char *boot_device, |
1022 | b00052e4 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
1023 | b00052e4 | balrog | const char *initrd_filename, const char *cpu_model) |
1024 | b00052e4 | balrog | { |
1025 | fbe1b595 | Paul Brook | spitz_common_init(ram_size, kernel_filename, |
1026 | 4207117c | balrog | kernel_cmdline, initrd_filename, cpu_model, akita, 0x2e8);
|
1027 | b00052e4 | balrog | } |
1028 | b00052e4 | balrog | |
1029 | c227f099 | Anthony Liguori | static void terrier_init(ram_addr_t ram_size, |
1030 | 3023f332 | aliguori | const char *boot_device, |
1031 | b00052e4 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
1032 | b00052e4 | balrog | const char *initrd_filename, const char *cpu_model) |
1033 | b00052e4 | balrog | { |
1034 | fbe1b595 | Paul Brook | spitz_common_init(ram_size, kernel_filename, |
1035 | 4207117c | balrog | kernel_cmdline, initrd_filename, cpu_model, terrier, 0x33f);
|
1036 | b00052e4 | balrog | } |
1037 | b00052e4 | balrog | |
1038 | 11be4b3e | Stefan Weil | static QEMUMachine akitapda_machine = {
|
1039 | 4b32e168 | aliguori | .name = "akita",
|
1040 | 4b32e168 | aliguori | .desc = "Akita PDA (PXA270)",
|
1041 | 4b32e168 | aliguori | .init = akita_init, |
1042 | b00052e4 | balrog | }; |
1043 | b00052e4 | balrog | |
1044 | f80f9ec9 | Anthony Liguori | static QEMUMachine spitzpda_machine = {
|
1045 | 4b32e168 | aliguori | .name = "spitz",
|
1046 | 4b32e168 | aliguori | .desc = "Spitz PDA (PXA270)",
|
1047 | 4b32e168 | aliguori | .init = spitz_init, |
1048 | b00052e4 | balrog | }; |
1049 | b00052e4 | balrog | |
1050 | f80f9ec9 | Anthony Liguori | static QEMUMachine borzoipda_machine = {
|
1051 | 4b32e168 | aliguori | .name = "borzoi",
|
1052 | 4b32e168 | aliguori | .desc = "Borzoi PDA (PXA270)",
|
1053 | 4b32e168 | aliguori | .init = borzoi_init, |
1054 | b00052e4 | balrog | }; |
1055 | b00052e4 | balrog | |
1056 | f80f9ec9 | Anthony Liguori | static QEMUMachine terrierpda_machine = {
|
1057 | 4b32e168 | aliguori | .name = "terrier",
|
1058 | 4b32e168 | aliguori | .desc = "Terrier PDA (PXA270)",
|
1059 | 4b32e168 | aliguori | .init = terrier_init, |
1060 | b00052e4 | balrog | }; |
1061 | a984a69e | Paul Brook | |
1062 | f80f9ec9 | Anthony Liguori | static void spitz_machine_init(void) |
1063 | f80f9ec9 | Anthony Liguori | { |
1064 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&akitapda_machine); |
1065 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&spitzpda_machine); |
1066 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&borzoipda_machine); |
1067 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&terrierpda_machine); |
1068 | f80f9ec9 | Anthony Liguori | } |
1069 | f80f9ec9 | Anthony Liguori | |
1070 | f80f9ec9 | Anthony Liguori | machine_init(spitz_machine_init); |
1071 | f80f9ec9 | Anthony Liguori | |
1072 | a984a69e | Paul Brook | static SSISlaveInfo corgi_ssp_info = {
|
1073 | 074f2fff | Gerd Hoffmann | .qdev.name = "corgi-ssp",
|
1074 | 074f2fff | Gerd Hoffmann | .qdev.size = sizeof(CorgiSSPState),
|
1075 | a984a69e | Paul Brook | .init = corgi_ssp_init, |
1076 | a984a69e | Paul Brook | .transfer = corgi_ssp_transfer |
1077 | a984a69e | Paul Brook | }; |
1078 | a984a69e | Paul Brook | |
1079 | a984a69e | Paul Brook | static SSISlaveInfo spitz_lcdtg_info = {
|
1080 | 074f2fff | Gerd Hoffmann | .qdev.name = "spitz-lcdtg",
|
1081 | 074f2fff | Gerd Hoffmann | .qdev.size = sizeof(SpitzLCDTG),
|
1082 | a984a69e | Paul Brook | .init = spitz_lcdtg_init, |
1083 | a984a69e | Paul Brook | .transfer = spitz_lcdtg_transfer |
1084 | a984a69e | Paul Brook | }; |
1085 | a984a69e | Paul Brook | |
1086 | a984a69e | Paul Brook | static void spitz_register_devices(void) |
1087 | a984a69e | Paul Brook | { |
1088 | 074f2fff | Gerd Hoffmann | ssi_register_slave(&corgi_ssp_info); |
1089 | 074f2fff | Gerd Hoffmann | ssi_register_slave(&spitz_lcdtg_info); |
1090 | a984a69e | Paul Brook | } |
1091 | a984a69e | Paul Brook | |
1092 | a984a69e | Paul Brook | device_init(spitz_register_devices) |