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