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