root / hw / nseries.c @ 1ffc346f
History | View | Annotate | Download (31.5 kB)
1 | 7e7c5e4c | balrog | /*
|
---|---|---|---|
2 | 7e7c5e4c | balrog | * Nokia N-series internet tablets.
|
3 | 7e7c5e4c | balrog | *
|
4 | 7e7c5e4c | balrog | * Copyright (C) 2007 Nokia Corporation
|
5 | 7e7c5e4c | balrog | * Written by Andrzej Zaborowski <andrew@openedhand.com>
|
6 | 7e7c5e4c | balrog | *
|
7 | 7e7c5e4c | balrog | * This program is free software; you can redistribute it and/or
|
8 | 7e7c5e4c | balrog | * modify it under the terms of the GNU General Public License as
|
9 | 7e7c5e4c | balrog | * published by the Free Software Foundation; either version 2 or
|
10 | 7e7c5e4c | balrog | * (at your option) version 3 of the License.
|
11 | 7e7c5e4c | balrog | *
|
12 | 7e7c5e4c | balrog | * This program is distributed in the hope that it will be useful,
|
13 | 7e7c5e4c | balrog | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | 7e7c5e4c | balrog | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 | 7e7c5e4c | balrog | * GNU General Public License for more details.
|
16 | 7e7c5e4c | balrog | *
|
17 | 7e7c5e4c | balrog | * You should have received a copy of the GNU General Public License
|
18 | 7e7c5e4c | balrog | * along with this program; if not, write to the Free Software
|
19 | 7e7c5e4c | balrog | * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
20 | 7e7c5e4c | balrog | * MA 02111-1307 USA
|
21 | 7e7c5e4c | balrog | */
|
22 | 7e7c5e4c | balrog | |
23 | 7e7c5e4c | balrog | #include "qemu-common.h" |
24 | 7e7c5e4c | balrog | #include "sysemu.h" |
25 | 7e7c5e4c | balrog | #include "omap.h" |
26 | 7e7c5e4c | balrog | #include "arm-misc.h" |
27 | 7e7c5e4c | balrog | #include "irq.h" |
28 | 7e7c5e4c | balrog | #include "console.h" |
29 | 7e7c5e4c | balrog | #include "boards.h" |
30 | 7e7c5e4c | balrog | #include "i2c.h" |
31 | 7e7c5e4c | balrog | #include "devices.h" |
32 | 7e7c5e4c | balrog | #include "flash.h" |
33 | 7e7c5e4c | balrog | #include "hw.h" |
34 | 7e7c5e4c | balrog | |
35 | 7e7c5e4c | balrog | /* Nokia N8x0 support */
|
36 | 7e7c5e4c | balrog | struct n800_s {
|
37 | 7e7c5e4c | balrog | struct omap_mpu_state_s *cpu;
|
38 | 7e7c5e4c | balrog | |
39 | 7e7c5e4c | balrog | struct rfbi_chip_s blizzard;
|
40 | e927bb00 | balrog | struct {
|
41 | e927bb00 | balrog | void *opaque;
|
42 | e927bb00 | balrog | uint32_t (*txrx)(void *opaque, uint32_t value, int len); |
43 | e927bb00 | balrog | struct uwire_slave_s *chip;
|
44 | e927bb00 | balrog | } ts; |
45 | 7e7c5e4c | balrog | i2c_bus *i2c; |
46 | 7e7c5e4c | balrog | |
47 | 7e7c5e4c | balrog | int keymap[0x80]; |
48 | 7e7c5e4c | balrog | |
49 | 942ac052 | balrog | struct tusb_s *usb;
|
50 | 7e7c5e4c | balrog | void *retu;
|
51 | 7e7c5e4c | balrog | void *tahvo;
|
52 | 7e7c5e4c | balrog | }; |
53 | 7e7c5e4c | balrog | |
54 | 7e7c5e4c | balrog | /* GPIO pins */
|
55 | e927bb00 | balrog | #define N8X0_TUSB_ENABLE_GPIO 0 |
56 | 7e7c5e4c | balrog | #define N800_MMC2_WP_GPIO 8 |
57 | 7e7c5e4c | balrog | #define N800_UNKNOWN_GPIO0 9 /* out */ |
58 | 7e7c5e4c | balrog | #define N800_UNKNOWN_GPIO1 10 /* out */ |
59 | 7e7c5e4c | balrog | #define N800_CAM_TURN_GPIO 12 |
60 | e927bb00 | balrog | #define N810_GPS_RESET_GPIO 12 |
61 | 7e7c5e4c | balrog | #define N800_BLIZZARD_POWERDOWN_GPIO 15 |
62 | 7e7c5e4c | balrog | #define N800_MMC1_WP_GPIO 23 |
63 | 7e7c5e4c | balrog | #define N8X0_ONENAND_GPIO 26 |
64 | e927bb00 | balrog | #define N810_BLIZZARD_RESET_GPIO 30 |
65 | 7e7c5e4c | balrog | #define N800_UNKNOWN_GPIO2 53 /* out */ |
66 | 7e7c5e4c | balrog | #define N8X0_TUSB_INT_GPIO 58 |
67 | e927bb00 | balrog | #define N8X0_BT_WKUP_GPIO 61 |
68 | e927bb00 | balrog | #define N8X0_STI_GPIO 62 |
69 | 7e7c5e4c | balrog | #define N8X0_CBUS_SEL_GPIO 64 |
70 | e927bb00 | balrog | #define N8X0_CBUS_DAT_GPIO 65 |
71 | e927bb00 | balrog | #define N8X0_CBUS_CLK_GPIO 66 |
72 | e927bb00 | balrog | #define N8X0_WLAN_IRQ_GPIO 87 |
73 | e927bb00 | balrog | #define N8X0_BT_RESET_GPIO 92 |
74 | e927bb00 | balrog | #define N8X0_TEA5761_CS_GPIO 93 |
75 | 7e7c5e4c | balrog | #define N800_UNKNOWN_GPIO 94 |
76 | e927bb00 | balrog | #define N810_TSC_RESET_GPIO 94 |
77 | 7e7c5e4c | balrog | #define N800_CAM_ACT_GPIO 95 |
78 | e927bb00 | balrog | #define N810_GPS_WAKEUP_GPIO 95 |
79 | e927bb00 | balrog | #define N8X0_MMC_CS_GPIO 96 |
80 | e927bb00 | balrog | #define N8X0_WLAN_PWR_GPIO 97 |
81 | 7e7c5e4c | balrog | #define N8X0_BT_HOST_WKUP_GPIO 98 |
82 | 7e7c5e4c | balrog | #define N800_UNKNOWN_GPIO3 101 /* out */ |
83 | 7e7c5e4c | balrog | #define N810_KB_LOCK_GPIO 102 |
84 | 7e7c5e4c | balrog | #define N800_TSC_TS_GPIO 103 |
85 | e927bb00 | balrog | #define N810_TSC_TS_GPIO 106 |
86 | e927bb00 | balrog | #define N8X0_HEADPHONE_GPIO 107 |
87 | 7e7c5e4c | balrog | #define N8X0_RETU_GPIO 108 |
88 | 7e7c5e4c | balrog | #define N800_TSC_KP_IRQ_GPIO 109 |
89 | 7e7c5e4c | balrog | #define N810_KEYBOARD_GPIO 109 |
90 | 7e7c5e4c | balrog | #define N800_BAT_COVER_GPIO 110 |
91 | 7e7c5e4c | balrog | #define N810_SLIDE_GPIO 110 |
92 | 7e7c5e4c | balrog | #define N8X0_TAHVO_GPIO 111 |
93 | 7e7c5e4c | balrog | #define N800_UNKNOWN_GPIO4 112 /* out */ |
94 | e927bb00 | balrog | #define N810_SLEEPX_LED_GPIO 112 |
95 | e927bb00 | balrog | #define N810_TSC_UNKNOWN_GPIO 118 /* out */ |
96 | 7e7c5e4c | balrog | #define N800_TSC_RESET_GPIO 119 /* ? */ |
97 | 7e7c5e4c | balrog | #define N8X0_TMP105_GPIO 125 |
98 | 7e7c5e4c | balrog | |
99 | 7e7c5e4c | balrog | /* Config */
|
100 | 7e7c5e4c | balrog | #define XLDR_LL_UART 1 |
101 | 7e7c5e4c | balrog | |
102 | 7e7c5e4c | balrog | /* Addresses on the I2C bus */
|
103 | 7e7c5e4c | balrog | #define N8X0_TMP105_ADDR 0x48 |
104 | 7e7c5e4c | balrog | #define N8X0_MENELAUS_ADDR 0x72 |
105 | 7e7c5e4c | balrog | |
106 | 7e7c5e4c | balrog | /* Chipselects on GPMC NOR interface */
|
107 | 7e7c5e4c | balrog | #define N8X0_ONENAND_CS 0 |
108 | 7e7c5e4c | balrog | #define N8X0_USB_ASYNC_CS 1 |
109 | 7e7c5e4c | balrog | #define N8X0_USB_SYNC_CS 4 |
110 | 7e7c5e4c | balrog | |
111 | 7e7c5e4c | balrog | static void n800_mmc_cs_cb(void *opaque, int line, int level) |
112 | 7e7c5e4c | balrog | { |
113 | 7e7c5e4c | balrog | /* TODO: this seems to actually be connected to the menelaus, to
|
114 | 7e7c5e4c | balrog | * which also both MMC slots connect. */
|
115 | 7e7c5e4c | balrog | omap_mmc_enable((struct omap_mmc_s *) opaque, !level);
|
116 | 7e7c5e4c | balrog | |
117 | 7e7c5e4c | balrog | printf("%s: MMC slot %i active\n", __FUNCTION__, level + 1); |
118 | 7e7c5e4c | balrog | } |
119 | 7e7c5e4c | balrog | |
120 | e927bb00 | balrog | static void n8x0_gpio_setup(struct n800_s *s) |
121 | 7e7c5e4c | balrog | { |
122 | 7e7c5e4c | balrog | qemu_irq *mmc_cs = qemu_allocate_irqs(n800_mmc_cs_cb, s->cpu->mmc, 1);
|
123 | e927bb00 | balrog | omap2_gpio_out_set(s->cpu->gpif, N8X0_MMC_CS_GPIO, mmc_cs[0]);
|
124 | 7e7c5e4c | balrog | |
125 | 7e7c5e4c | balrog | qemu_irq_lower(omap2_gpio_in_get(s->cpu->gpif, N800_BAT_COVER_GPIO)[0]);
|
126 | 7e7c5e4c | balrog | } |
127 | 7e7c5e4c | balrog | |
128 | 7e7c5e4c | balrog | static void n8x0_nand_setup(struct n800_s *s) |
129 | 7e7c5e4c | balrog | { |
130 | 7e7c5e4c | balrog | /* Either ec40xx or ec48xx are OK for the ID */
|
131 | 7e7c5e4c | balrog | omap_gpmc_attach(s->cpu->gpmc, N8X0_ONENAND_CS, 0, onenand_base_update,
|
132 | 7e7c5e4c | balrog | onenand_base_unmap, |
133 | 7e7c5e4c | balrog | onenand_init(0xec4800, 1, |
134 | 7e7c5e4c | balrog | omap2_gpio_in_get(s->cpu->gpif, |
135 | 7e7c5e4c | balrog | N8X0_ONENAND_GPIO)[0]));
|
136 | 7e7c5e4c | balrog | } |
137 | 7e7c5e4c | balrog | |
138 | e927bb00 | balrog | static void n8x0_i2c_setup(struct n800_s *s) |
139 | 7e7c5e4c | balrog | { |
140 | 7e7c5e4c | balrog | qemu_irq tmp_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_TMP105_GPIO)[0];
|
141 | 7e7c5e4c | balrog | |
142 | 7e7c5e4c | balrog | /* Attach the CPU on one end of our I2C bus. */
|
143 | 7e7c5e4c | balrog | s->i2c = omap_i2c_bus(s->cpu->i2c[0]);
|
144 | 7e7c5e4c | balrog | |
145 | 7e7c5e4c | balrog | /* Attach a menelaus PM chip */
|
146 | 7e7c5e4c | balrog | i2c_set_slave_address( |
147 | 7e7c5e4c | balrog | twl92230_init(s->i2c, |
148 | 7e7c5e4c | balrog | s->cpu->irq[0][OMAP_INT_24XX_SYS_NIRQ]),
|
149 | 7e7c5e4c | balrog | N8X0_MENELAUS_ADDR); |
150 | 7e7c5e4c | balrog | |
151 | 7e7c5e4c | balrog | /* Attach a TMP105 PM chip (A0 wired to ground) */
|
152 | 7e7c5e4c | balrog | i2c_set_slave_address(tmp105_init(s->i2c, tmp_irq), N8X0_TMP105_ADDR); |
153 | 7e7c5e4c | balrog | } |
154 | 7e7c5e4c | balrog | |
155 | 7e7c5e4c | balrog | /* Touchscreen and keypad controller */
|
156 | e927bb00 | balrog | static struct mouse_transform_info_s n800_pointercal = { |
157 | e927bb00 | balrog | .x = 800,
|
158 | e927bb00 | balrog | .y = 480,
|
159 | e927bb00 | balrog | .a = { 14560, -68, -3455208, -39, -9621, 35152972, 65536 }, |
160 | e927bb00 | balrog | }; |
161 | e927bb00 | balrog | |
162 | e927bb00 | balrog | static struct mouse_transform_info_s n810_pointercal = { |
163 | e927bb00 | balrog | .x = 800,
|
164 | e927bb00 | balrog | .y = 480,
|
165 | e927bb00 | balrog | .a = { 15041, 148, -4731056, 171, -10238, 35933380, 65536 }, |
166 | e927bb00 | balrog | }; |
167 | e927bb00 | balrog | |
168 | 7e7c5e4c | balrog | #define RETU_KEYCODE 61 /* F3 */ |
169 | 7e7c5e4c | balrog | |
170 | 7e7c5e4c | balrog | static void n800_key_event(void *opaque, int keycode) |
171 | 7e7c5e4c | balrog | { |
172 | 7e7c5e4c | balrog | struct n800_s *s = (struct n800_s *) opaque; |
173 | 7e7c5e4c | balrog | int code = s->keymap[keycode & 0x7f]; |
174 | 7e7c5e4c | balrog | |
175 | 7e7c5e4c | balrog | if (code == -1) { |
176 | 7e7c5e4c | balrog | if ((keycode & 0x7f) == RETU_KEYCODE) |
177 | 7e7c5e4c | balrog | retu_key_event(s->retu, !(keycode & 0x80));
|
178 | 7e7c5e4c | balrog | return;
|
179 | 7e7c5e4c | balrog | } |
180 | 7e7c5e4c | balrog | |
181 | e927bb00 | balrog | tsc210x_key_event(s->ts.chip, code, !(keycode & 0x80));
|
182 | 7e7c5e4c | balrog | } |
183 | 7e7c5e4c | balrog | |
184 | 7e7c5e4c | balrog | static const int n800_keys[16] = { |
185 | 7e7c5e4c | balrog | -1,
|
186 | 7e7c5e4c | balrog | 72, /* Up */ |
187 | 7e7c5e4c | balrog | 63, /* Home (F5) */ |
188 | 7e7c5e4c | balrog | -1,
|
189 | 7e7c5e4c | balrog | 75, /* Left */ |
190 | 7e7c5e4c | balrog | 28, /* Enter */ |
191 | 7e7c5e4c | balrog | 77, /* Right */ |
192 | 7e7c5e4c | balrog | -1,
|
193 | 7e7c5e4c | balrog | 1, /* Cycle (ESC) */ |
194 | 7e7c5e4c | balrog | 80, /* Down */ |
195 | 7e7c5e4c | balrog | 62, /* Menu (F4) */ |
196 | 7e7c5e4c | balrog | -1,
|
197 | 7e7c5e4c | balrog | 66, /* Zoom- (F8) */ |
198 | 7e7c5e4c | balrog | 64, /* FS (F6) */ |
199 | 7e7c5e4c | balrog | 65, /* Zoom+ (F7) */ |
200 | 7e7c5e4c | balrog | -1,
|
201 | 7e7c5e4c | balrog | }; |
202 | 7e7c5e4c | balrog | |
203 | e927bb00 | balrog | static void n800_tsc_kbd_setup(struct n800_s *s) |
204 | 7e7c5e4c | balrog | { |
205 | 7e7c5e4c | balrog | int i;
|
206 | 7e7c5e4c | balrog | |
207 | 7e7c5e4c | balrog | /* XXX: are the three pins inverted inside the chip between the
|
208 | 7e7c5e4c | balrog | * tsc and the cpu (N4111)? */
|
209 | 7e7c5e4c | balrog | qemu_irq penirq = 0; /* NC */ |
210 | 7e7c5e4c | balrog | qemu_irq kbirq = omap2_gpio_in_get(s->cpu->gpif, N800_TSC_KP_IRQ_GPIO)[0];
|
211 | 7e7c5e4c | balrog | qemu_irq dav = omap2_gpio_in_get(s->cpu->gpif, N800_TSC_TS_GPIO)[0];
|
212 | 7e7c5e4c | balrog | |
213 | e927bb00 | balrog | s->ts.chip = tsc2301_init(penirq, kbirq, dav, 0);
|
214 | e927bb00 | balrog | s->ts.opaque = s->ts.chip->opaque; |
215 | e927bb00 | balrog | s->ts.txrx = tsc210x_txrx; |
216 | 7e7c5e4c | balrog | |
217 | 7e7c5e4c | balrog | for (i = 0; i < 0x80; i ++) |
218 | 7e7c5e4c | balrog | s->keymap[i] = -1;
|
219 | 7e7c5e4c | balrog | for (i = 0; i < 0x10; i ++) |
220 | 7e7c5e4c | balrog | if (n800_keys[i] >= 0) |
221 | 7e7c5e4c | balrog | s->keymap[n800_keys[i]] = i; |
222 | 7e7c5e4c | balrog | |
223 | 7e7c5e4c | balrog | qemu_add_kbd_event_handler(n800_key_event, s); |
224 | 7e7c5e4c | balrog | |
225 | e927bb00 | balrog | tsc210x_set_transform(s->ts.chip, &n800_pointercal); |
226 | e927bb00 | balrog | } |
227 | e927bb00 | balrog | |
228 | e927bb00 | balrog | static void n810_tsc_setup(struct n800_s *s) |
229 | e927bb00 | balrog | { |
230 | e927bb00 | balrog | qemu_irq pintdav = omap2_gpio_in_get(s->cpu->gpif, N810_TSC_TS_GPIO)[0];
|
231 | e927bb00 | balrog | |
232 | e927bb00 | balrog | s->ts.opaque = tsc2005_init(pintdav); |
233 | e927bb00 | balrog | s->ts.txrx = tsc2005_txrx; |
234 | e927bb00 | balrog | |
235 | e927bb00 | balrog | tsc2005_set_transform(s->ts.opaque, &n810_pointercal); |
236 | 7e7c5e4c | balrog | } |
237 | 7e7c5e4c | balrog | |
238 | 7e7c5e4c | balrog | /* LCD MIPI DBI-C controller (URAL) */
|
239 | 7e7c5e4c | balrog | struct mipid_s {
|
240 | 7e7c5e4c | balrog | int resp[4]; |
241 | 7e7c5e4c | balrog | int param[4]; |
242 | 7e7c5e4c | balrog | int p;
|
243 | 7e7c5e4c | balrog | int pm;
|
244 | 7e7c5e4c | balrog | int cmd;
|
245 | 7e7c5e4c | balrog | |
246 | 7e7c5e4c | balrog | int sleep;
|
247 | 7e7c5e4c | balrog | int booster;
|
248 | 7e7c5e4c | balrog | int te;
|
249 | 7e7c5e4c | balrog | int selfcheck;
|
250 | 7e7c5e4c | balrog | int partial;
|
251 | 7e7c5e4c | balrog | int normal;
|
252 | 7e7c5e4c | balrog | int vscr;
|
253 | 7e7c5e4c | balrog | int invert;
|
254 | 7e7c5e4c | balrog | int onoff;
|
255 | 7e7c5e4c | balrog | int gamma;
|
256 | 7e7c5e4c | balrog | uint32_t id; |
257 | 7e7c5e4c | balrog | }; |
258 | 7e7c5e4c | balrog | |
259 | 7e7c5e4c | balrog | static void mipid_reset(struct mipid_s *s) |
260 | 7e7c5e4c | balrog | { |
261 | 7e7c5e4c | balrog | if (!s->sleep)
|
262 | 7e7c5e4c | balrog | fprintf(stderr, "%s: Display off\n", __FUNCTION__);
|
263 | 7e7c5e4c | balrog | |
264 | 7e7c5e4c | balrog | s->pm = 0;
|
265 | 7e7c5e4c | balrog | s->cmd = 0;
|
266 | 7e7c5e4c | balrog | |
267 | 7e7c5e4c | balrog | s->sleep = 1;
|
268 | 7e7c5e4c | balrog | s->booster = 0;
|
269 | 7e7c5e4c | balrog | s->selfcheck = |
270 | 7e7c5e4c | balrog | (1 << 7) | /* Register loading OK. */ |
271 | 7e7c5e4c | balrog | (1 << 5) | /* The chip is attached. */ |
272 | 7e7c5e4c | balrog | (1 << 4); /* Display glass still in one piece. */ |
273 | 7e7c5e4c | balrog | s->te = 0;
|
274 | 7e7c5e4c | balrog | s->partial = 0;
|
275 | 7e7c5e4c | balrog | s->normal = 1;
|
276 | 7e7c5e4c | balrog | s->vscr = 0;
|
277 | 7e7c5e4c | balrog | s->invert = 0;
|
278 | 7e7c5e4c | balrog | s->onoff = 1;
|
279 | 7e7c5e4c | balrog | s->gamma = 0;
|
280 | 7e7c5e4c | balrog | } |
281 | 7e7c5e4c | balrog | |
282 | e927bb00 | balrog | static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len) |
283 | 7e7c5e4c | balrog | { |
284 | 7e7c5e4c | balrog | struct mipid_s *s = (struct mipid_s *) opaque; |
285 | 7e7c5e4c | balrog | uint8_t ret; |
286 | 7e7c5e4c | balrog | |
287 | e927bb00 | balrog | if (len > 9) |
288 | e927bb00 | balrog | cpu_abort(cpu_single_env, "%s: FIXME: bad SPI word width %i\n",
|
289 | e927bb00 | balrog | __FUNCTION__, len); |
290 | e927bb00 | balrog | |
291 | 7e7c5e4c | balrog | if (s->p >= sizeof(s->resp) / sizeof(*s->resp)) |
292 | 7e7c5e4c | balrog | ret = 0;
|
293 | 7e7c5e4c | balrog | else
|
294 | 7e7c5e4c | balrog | ret = s->resp[s->p ++]; |
295 | 7e7c5e4c | balrog | if (s->pm --> 0) |
296 | 7e7c5e4c | balrog | s->param[s->pm] = cmd; |
297 | 7e7c5e4c | balrog | else
|
298 | 7e7c5e4c | balrog | s->cmd = cmd; |
299 | 7e7c5e4c | balrog | |
300 | 7e7c5e4c | balrog | switch (s->cmd) {
|
301 | 7e7c5e4c | balrog | case 0x00: /* NOP */ |
302 | 7e7c5e4c | balrog | break;
|
303 | 7e7c5e4c | balrog | |
304 | 7e7c5e4c | balrog | case 0x01: /* SWRESET */ |
305 | 7e7c5e4c | balrog | mipid_reset(s); |
306 | 7e7c5e4c | balrog | break;
|
307 | 7e7c5e4c | balrog | |
308 | 7e7c5e4c | balrog | case 0x02: /* BSTROFF */ |
309 | 7e7c5e4c | balrog | s->booster = 0;
|
310 | 7e7c5e4c | balrog | break;
|
311 | 7e7c5e4c | balrog | case 0x03: /* BSTRON */ |
312 | 7e7c5e4c | balrog | s->booster = 1;
|
313 | 7e7c5e4c | balrog | break;
|
314 | 7e7c5e4c | balrog | |
315 | 7e7c5e4c | balrog | case 0x04: /* RDDID */ |
316 | 7e7c5e4c | balrog | s->p = 0;
|
317 | 7e7c5e4c | balrog | s->resp[0] = (s->id >> 16) & 0xff; |
318 | 7e7c5e4c | balrog | s->resp[1] = (s->id >> 8) & 0xff; |
319 | 7e7c5e4c | balrog | s->resp[2] = (s->id >> 0) & 0xff; |
320 | 7e7c5e4c | balrog | break;
|
321 | 7e7c5e4c | balrog | |
322 | 7e7c5e4c | balrog | case 0x06: /* RD_RED */ |
323 | 7e7c5e4c | balrog | case 0x07: /* RD_GREEN */ |
324 | 7e7c5e4c | balrog | /* XXX the bootloader sometimes issues RD_BLUE meaning RDDID so
|
325 | 7e7c5e4c | balrog | * for the bootloader one needs to change this. */
|
326 | 7e7c5e4c | balrog | case 0x08: /* RD_BLUE */ |
327 | 7e7c5e4c | balrog | s->p = 0;
|
328 | 7e7c5e4c | balrog | /* TODO: return first pixel components */
|
329 | 7e7c5e4c | balrog | s->resp[0] = 0x01; |
330 | 7e7c5e4c | balrog | break;
|
331 | 7e7c5e4c | balrog | |
332 | 7e7c5e4c | balrog | case 0x09: /* RDDST */ |
333 | 7e7c5e4c | balrog | s->p = 0;
|
334 | 7e7c5e4c | balrog | s->resp[0] = s->booster << 7; |
335 | 7e7c5e4c | balrog | s->resp[1] = (5 << 4) | (s->partial << 2) | |
336 | 7e7c5e4c | balrog | (s->sleep << 1) | s->normal;
|
337 | 7e7c5e4c | balrog | s->resp[2] = (s->vscr << 7) | (s->invert << 5) | |
338 | 7e7c5e4c | balrog | (s->onoff << 2) | (s->te << 1) | (s->gamma >> 2); |
339 | 7e7c5e4c | balrog | s->resp[3] = s->gamma << 6; |
340 | 7e7c5e4c | balrog | break;
|
341 | 7e7c5e4c | balrog | |
342 | 7e7c5e4c | balrog | case 0x0a: /* RDDPM */ |
343 | 7e7c5e4c | balrog | s->p = 0;
|
344 | 7e7c5e4c | balrog | s->resp[0] = (s->onoff << 2) | (s->normal << 3) | (s->sleep << 4) | |
345 | 7e7c5e4c | balrog | (s->partial << 5) | (s->sleep << 6) | (s->booster << 7); |
346 | 7e7c5e4c | balrog | break;
|
347 | 7e7c5e4c | balrog | case 0x0b: /* RDDMADCTR */ |
348 | 7e7c5e4c | balrog | s->p = 0;
|
349 | 7e7c5e4c | balrog | s->resp[0] = 0; |
350 | 7e7c5e4c | balrog | break;
|
351 | 7e7c5e4c | balrog | case 0x0c: /* RDDCOLMOD */ |
352 | 7e7c5e4c | balrog | s->p = 0;
|
353 | 7e7c5e4c | balrog | s->resp[0] = 5; /* 65K colours */ |
354 | 7e7c5e4c | balrog | break;
|
355 | 7e7c5e4c | balrog | case 0x0d: /* RDDIM */ |
356 | 7e7c5e4c | balrog | s->p = 0;
|
357 | 7e7c5e4c | balrog | s->resp[0] = (s->invert << 5) | (s->vscr << 7) | s->gamma; |
358 | 7e7c5e4c | balrog | break;
|
359 | 7e7c5e4c | balrog | case 0x0e: /* RDDSM */ |
360 | 7e7c5e4c | balrog | s->p = 0;
|
361 | 7e7c5e4c | balrog | s->resp[0] = s->te << 7; |
362 | 7e7c5e4c | balrog | break;
|
363 | 7e7c5e4c | balrog | case 0x0f: /* RDDSDR */ |
364 | 7e7c5e4c | balrog | s->p = 0;
|
365 | 7e7c5e4c | balrog | s->resp[0] = s->selfcheck;
|
366 | 7e7c5e4c | balrog | break;
|
367 | 7e7c5e4c | balrog | |
368 | 7e7c5e4c | balrog | case 0x10: /* SLPIN */ |
369 | 7e7c5e4c | balrog | s->sleep = 1;
|
370 | 7e7c5e4c | balrog | break;
|
371 | 7e7c5e4c | balrog | case 0x11: /* SLPOUT */ |
372 | 7e7c5e4c | balrog | s->sleep = 0;
|
373 | 7e7c5e4c | balrog | s->selfcheck ^= 1 << 6; /* POFF self-diagnosis Ok */ |
374 | 7e7c5e4c | balrog | break;
|
375 | 7e7c5e4c | balrog | |
376 | 7e7c5e4c | balrog | case 0x12: /* PTLON */ |
377 | 7e7c5e4c | balrog | s->partial = 1;
|
378 | 7e7c5e4c | balrog | s->normal = 0;
|
379 | 7e7c5e4c | balrog | s->vscr = 0;
|
380 | 7e7c5e4c | balrog | break;
|
381 | 7e7c5e4c | balrog | case 0x13: /* NORON */ |
382 | 7e7c5e4c | balrog | s->partial = 0;
|
383 | 7e7c5e4c | balrog | s->normal = 1;
|
384 | 7e7c5e4c | balrog | s->vscr = 0;
|
385 | 7e7c5e4c | balrog | break;
|
386 | 7e7c5e4c | balrog | |
387 | 7e7c5e4c | balrog | case 0x20: /* INVOFF */ |
388 | 7e7c5e4c | balrog | s->invert = 0;
|
389 | 7e7c5e4c | balrog | break;
|
390 | 7e7c5e4c | balrog | case 0x21: /* INVON */ |
391 | 7e7c5e4c | balrog | s->invert = 1;
|
392 | 7e7c5e4c | balrog | break;
|
393 | 7e7c5e4c | balrog | |
394 | 7e7c5e4c | balrog | case 0x22: /* APOFF */ |
395 | 7e7c5e4c | balrog | case 0x23: /* APON */ |
396 | 7e7c5e4c | balrog | goto bad_cmd;
|
397 | 7e7c5e4c | balrog | |
398 | 7e7c5e4c | balrog | case 0x25: /* WRCNTR */ |
399 | 7e7c5e4c | balrog | if (s->pm < 0) |
400 | 7e7c5e4c | balrog | s->pm = 1;
|
401 | 7e7c5e4c | balrog | goto bad_cmd;
|
402 | 7e7c5e4c | balrog | |
403 | 7e7c5e4c | balrog | case 0x26: /* GAMSET */ |
404 | 7e7c5e4c | balrog | if (!s->pm)
|
405 | 7e7c5e4c | balrog | s->gamma = ffs(s->param[0] & 0xf) - 1; |
406 | 7e7c5e4c | balrog | else if (s->pm < 0) |
407 | 7e7c5e4c | balrog | s->pm = 1;
|
408 | 7e7c5e4c | balrog | break;
|
409 | 7e7c5e4c | balrog | |
410 | 7e7c5e4c | balrog | case 0x28: /* DISPOFF */ |
411 | 7e7c5e4c | balrog | s->onoff = 0;
|
412 | 7e7c5e4c | balrog | fprintf(stderr, "%s: Display off\n", __FUNCTION__);
|
413 | 7e7c5e4c | balrog | break;
|
414 | 7e7c5e4c | balrog | case 0x29: /* DISPON */ |
415 | 7e7c5e4c | balrog | s->onoff = 1;
|
416 | 7e7c5e4c | balrog | fprintf(stderr, "%s: Display on\n", __FUNCTION__);
|
417 | 7e7c5e4c | balrog | break;
|
418 | 7e7c5e4c | balrog | |
419 | 7e7c5e4c | balrog | case 0x2a: /* CASET */ |
420 | 7e7c5e4c | balrog | case 0x2b: /* RASET */ |
421 | 7e7c5e4c | balrog | case 0x2c: /* RAMWR */ |
422 | 7e7c5e4c | balrog | case 0x2d: /* RGBSET */ |
423 | 7e7c5e4c | balrog | case 0x2e: /* RAMRD */ |
424 | 7e7c5e4c | balrog | case 0x30: /* PTLAR */ |
425 | 7e7c5e4c | balrog | case 0x33: /* SCRLAR */ |
426 | 7e7c5e4c | balrog | goto bad_cmd;
|
427 | 7e7c5e4c | balrog | |
428 | 7e7c5e4c | balrog | case 0x34: /* TEOFF */ |
429 | 7e7c5e4c | balrog | s->te = 0;
|
430 | 7e7c5e4c | balrog | break;
|
431 | 7e7c5e4c | balrog | case 0x35: /* TEON */ |
432 | 7e7c5e4c | balrog | if (!s->pm)
|
433 | 7e7c5e4c | balrog | s->te = 1;
|
434 | 7e7c5e4c | balrog | else if (s->pm < 0) |
435 | 7e7c5e4c | balrog | s->pm = 1;
|
436 | 7e7c5e4c | balrog | break;
|
437 | 7e7c5e4c | balrog | |
438 | 7e7c5e4c | balrog | case 0x36: /* MADCTR */ |
439 | 7e7c5e4c | balrog | goto bad_cmd;
|
440 | 7e7c5e4c | balrog | |
441 | 7e7c5e4c | balrog | case 0x37: /* VSCSAD */ |
442 | 7e7c5e4c | balrog | s->partial = 0;
|
443 | 7e7c5e4c | balrog | s->normal = 0;
|
444 | 7e7c5e4c | balrog | s->vscr = 1;
|
445 | 7e7c5e4c | balrog | break;
|
446 | 7e7c5e4c | balrog | |
447 | 7e7c5e4c | balrog | case 0x38: /* IDMOFF */ |
448 | 7e7c5e4c | balrog | case 0x39: /* IDMON */ |
449 | 7e7c5e4c | balrog | case 0x3a: /* COLMOD */ |
450 | 7e7c5e4c | balrog | goto bad_cmd;
|
451 | 7e7c5e4c | balrog | |
452 | 7e7c5e4c | balrog | case 0xb0: /* CLKINT / DISCTL */ |
453 | 7e7c5e4c | balrog | case 0xb1: /* CLKEXT */ |
454 | 7e7c5e4c | balrog | if (s->pm < 0) |
455 | 7e7c5e4c | balrog | s->pm = 2;
|
456 | 7e7c5e4c | balrog | break;
|
457 | 7e7c5e4c | balrog | |
458 | 7e7c5e4c | balrog | case 0xb4: /* FRMSEL */ |
459 | 7e7c5e4c | balrog | break;
|
460 | 7e7c5e4c | balrog | |
461 | 7e7c5e4c | balrog | case 0xb5: /* FRM8SEL */ |
462 | 7e7c5e4c | balrog | case 0xb6: /* TMPRNG / INIESC */ |
463 | 7e7c5e4c | balrog | case 0xb7: /* TMPHIS / NOP2 */ |
464 | 7e7c5e4c | balrog | case 0xb8: /* TMPREAD / MADCTL */ |
465 | 7e7c5e4c | balrog | case 0xba: /* DISTCTR */ |
466 | 7e7c5e4c | balrog | case 0xbb: /* EPVOL */ |
467 | 7e7c5e4c | balrog | goto bad_cmd;
|
468 | 7e7c5e4c | balrog | |
469 | 7e7c5e4c | balrog | case 0xbd: /* Unknown */ |
470 | 7e7c5e4c | balrog | s->p = 0;
|
471 | 7e7c5e4c | balrog | s->resp[0] = 0; |
472 | 7e7c5e4c | balrog | s->resp[1] = 1; |
473 | 7e7c5e4c | balrog | break;
|
474 | 7e7c5e4c | balrog | |
475 | 7e7c5e4c | balrog | case 0xc2: /* IFMOD */ |
476 | 7e7c5e4c | balrog | if (s->pm < 0) |
477 | 7e7c5e4c | balrog | s->pm = 2;
|
478 | 7e7c5e4c | balrog | break;
|
479 | 7e7c5e4c | balrog | |
480 | 7e7c5e4c | balrog | case 0xc6: /* PWRCTL */ |
481 | 7e7c5e4c | balrog | case 0xc7: /* PPWRCTL */ |
482 | 7e7c5e4c | balrog | case 0xd0: /* EPWROUT */ |
483 | 7e7c5e4c | balrog | case 0xd1: /* EPWRIN */ |
484 | 7e7c5e4c | balrog | case 0xd4: /* RDEV */ |
485 | 7e7c5e4c | balrog | case 0xd5: /* RDRR */ |
486 | 7e7c5e4c | balrog | goto bad_cmd;
|
487 | 7e7c5e4c | balrog | |
488 | 7e7c5e4c | balrog | case 0xda: /* RDID1 */ |
489 | 7e7c5e4c | balrog | s->p = 0;
|
490 | 7e7c5e4c | balrog | s->resp[0] = (s->id >> 16) & 0xff; |
491 | 7e7c5e4c | balrog | break;
|
492 | 7e7c5e4c | balrog | case 0xdb: /* RDID2 */ |
493 | 7e7c5e4c | balrog | s->p = 0;
|
494 | 7e7c5e4c | balrog | s->resp[0] = (s->id >> 8) & 0xff; |
495 | 7e7c5e4c | balrog | break;
|
496 | 7e7c5e4c | balrog | case 0xdc: /* RDID3 */ |
497 | 7e7c5e4c | balrog | s->p = 0;
|
498 | 7e7c5e4c | balrog | s->resp[0] = (s->id >> 0) & 0xff; |
499 | 7e7c5e4c | balrog | break;
|
500 | 7e7c5e4c | balrog | |
501 | 7e7c5e4c | balrog | default:
|
502 | 7e7c5e4c | balrog | bad_cmd:
|
503 | 7e7c5e4c | balrog | fprintf(stderr, "%s: unknown command %02x\n", __FUNCTION__, s->cmd);
|
504 | 7e7c5e4c | balrog | break;
|
505 | 7e7c5e4c | balrog | } |
506 | 7e7c5e4c | balrog | |
507 | 7e7c5e4c | balrog | return ret;
|
508 | 7e7c5e4c | balrog | } |
509 | 7e7c5e4c | balrog | |
510 | 7e7c5e4c | balrog | static void *mipid_init(void) |
511 | 7e7c5e4c | balrog | { |
512 | 7e7c5e4c | balrog | struct mipid_s *s = (struct mipid_s *) qemu_mallocz(sizeof(*s)); |
513 | 7e7c5e4c | balrog | |
514 | 7e7c5e4c | balrog | s->id = 0x838f03;
|
515 | 7e7c5e4c | balrog | mipid_reset(s); |
516 | 7e7c5e4c | balrog | |
517 | 7e7c5e4c | balrog | return s;
|
518 | 7e7c5e4c | balrog | } |
519 | 7e7c5e4c | balrog | |
520 | e927bb00 | balrog | static void n8x0_spi_setup(struct n800_s *s) |
521 | 7e7c5e4c | balrog | { |
522 | e927bb00 | balrog | void *tsc = s->ts.opaque;
|
523 | 7e7c5e4c | balrog | void *mipid = mipid_init();
|
524 | 7e7c5e4c | balrog | |
525 | e927bb00 | balrog | omap_mcspi_attach(s->cpu->mcspi[0], s->ts.txrx, tsc, 0); |
526 | 7e7c5e4c | balrog | omap_mcspi_attach(s->cpu->mcspi[0], mipid_txrx, mipid, 1); |
527 | 7e7c5e4c | balrog | } |
528 | 7e7c5e4c | balrog | |
529 | 7e7c5e4c | balrog | /* This task is normally performed by the bootloader. If we're loading
|
530 | 7e7c5e4c | balrog | * a kernel directly, we need to enable the Blizzard ourselves. */
|
531 | 7e7c5e4c | balrog | static void n800_dss_init(struct rfbi_chip_s *chip) |
532 | 7e7c5e4c | balrog | { |
533 | 7e7c5e4c | balrog | uint8_t *fb_blank; |
534 | 7e7c5e4c | balrog | |
535 | 7e7c5e4c | balrog | chip->write(chip->opaque, 0, 0x2a); /* LCD Width register */ |
536 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x64); |
537 | 7e7c5e4c | balrog | chip->write(chip->opaque, 0, 0x2c); /* LCD HNDP register */ |
538 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x1e); |
539 | 7e7c5e4c | balrog | chip->write(chip->opaque, 0, 0x2e); /* LCD Height 0 register */ |
540 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0xe0); |
541 | 7e7c5e4c | balrog | chip->write(chip->opaque, 0, 0x30); /* LCD Height 1 register */ |
542 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x01); |
543 | 7e7c5e4c | balrog | chip->write(chip->opaque, 0, 0x32); /* LCD VNDP register */ |
544 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x06); |
545 | 7e7c5e4c | balrog | chip->write(chip->opaque, 0, 0x68); /* Display Mode register */ |
546 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 1); /* Enable bit */ |
547 | 7e7c5e4c | balrog | |
548 | 7e7c5e4c | balrog | chip->write(chip->opaque, 0, 0x6c); |
549 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x00); /* Input X Start Position */ |
550 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x00); /* Input X Start Position */ |
551 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x00); /* Input Y Start Position */ |
552 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x00); /* Input Y Start Position */ |
553 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x1f); /* Input X End Position */ |
554 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x03); /* Input X End Position */ |
555 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0xdf); /* Input Y End Position */ |
556 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x01); /* Input Y End Position */ |
557 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x00); /* Output X Start Position */ |
558 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x00); /* Output X Start Position */ |
559 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x00); /* Output Y Start Position */ |
560 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x00); /* Output Y Start Position */ |
561 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x1f); /* Output X End Position */ |
562 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x03); /* Output X End Position */ |
563 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0xdf); /* Output Y End Position */ |
564 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x01); /* Output Y End Position */ |
565 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x01); /* Input Data Format */ |
566 | 7e7c5e4c | balrog | chip->write(chip->opaque, 1, 0x01); /* Data Source Select */ |
567 | 7e7c5e4c | balrog | |
568 | 7e7c5e4c | balrog | fb_blank = memset(qemu_malloc(800 * 480 * 2), 0xff, 800 * 480 * 2); |
569 | 7e7c5e4c | balrog | /* Display Memory Data Port */
|
570 | 7e7c5e4c | balrog | chip->block(chip->opaque, 1, fb_blank, 800 * 480 * 2, 800); |
571 | 7e7c5e4c | balrog | free(fb_blank); |
572 | 7e7c5e4c | balrog | } |
573 | 7e7c5e4c | balrog | |
574 | e927bb00 | balrog | static void n8x0_dss_setup(struct n800_s *s, DisplayState *ds) |
575 | 7e7c5e4c | balrog | { |
576 | 7e7c5e4c | balrog | s->blizzard.opaque = s1d13745_init(0, ds);
|
577 | 7e7c5e4c | balrog | s->blizzard.block = s1d13745_write_block; |
578 | 7e7c5e4c | balrog | s->blizzard.write = s1d13745_write; |
579 | 7e7c5e4c | balrog | s->blizzard.read = s1d13745_read; |
580 | 7e7c5e4c | balrog | |
581 | 7e7c5e4c | balrog | omap_rfbi_attach(s->cpu->dss, 0, &s->blizzard);
|
582 | 7e7c5e4c | balrog | } |
583 | 7e7c5e4c | balrog | |
584 | e927bb00 | balrog | static void n8x0_cbus_setup(struct n800_s *s) |
585 | 7e7c5e4c | balrog | { |
586 | 7e7c5e4c | balrog | qemu_irq dat_out = omap2_gpio_in_get(s->cpu->gpif, N8X0_CBUS_DAT_GPIO)[0];
|
587 | 7e7c5e4c | balrog | qemu_irq retu_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_RETU_GPIO)[0];
|
588 | 7e7c5e4c | balrog | qemu_irq tahvo_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_TAHVO_GPIO)[0];
|
589 | 7e7c5e4c | balrog | |
590 | 7e7c5e4c | balrog | struct cbus_s *cbus = cbus_init(dat_out);
|
591 | 7e7c5e4c | balrog | |
592 | 7e7c5e4c | balrog | omap2_gpio_out_set(s->cpu->gpif, N8X0_CBUS_CLK_GPIO, cbus->clk); |
593 | 7e7c5e4c | balrog | omap2_gpio_out_set(s->cpu->gpif, N8X0_CBUS_DAT_GPIO, cbus->dat); |
594 | 7e7c5e4c | balrog | omap2_gpio_out_set(s->cpu->gpif, N8X0_CBUS_SEL_GPIO, cbus->sel); |
595 | 7e7c5e4c | balrog | |
596 | 7e7c5e4c | balrog | cbus_attach(cbus, s->retu = retu_init(retu_irq, 1));
|
597 | 7e7c5e4c | balrog | cbus_attach(cbus, s->tahvo = tahvo_init(tahvo_irq, 1));
|
598 | 7e7c5e4c | balrog | } |
599 | 7e7c5e4c | balrog | |
600 | e927bb00 | balrog | static void n8x0_usb_power_cb(void *opaque, int line, int level) |
601 | 942ac052 | balrog | { |
602 | 942ac052 | balrog | struct n800_s *s = opaque;
|
603 | 942ac052 | balrog | |
604 | 942ac052 | balrog | tusb6010_power(s->usb, level); |
605 | 942ac052 | balrog | } |
606 | 942ac052 | balrog | |
607 | e927bb00 | balrog | static void n8x0_usb_setup(struct n800_s *s) |
608 | 942ac052 | balrog | { |
609 | 942ac052 | balrog | qemu_irq tusb_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_TUSB_INT_GPIO)[0];
|
610 | e927bb00 | balrog | qemu_irq tusb_pwr = qemu_allocate_irqs(n8x0_usb_power_cb, s, 1)[0]; |
611 | 942ac052 | balrog | struct tusb_s *tusb = tusb6010_init(tusb_irq);
|
612 | 942ac052 | balrog | |
613 | 942ac052 | balrog | /* Using the NOR interface */
|
614 | 942ac052 | balrog | omap_gpmc_attach(s->cpu->gpmc, N8X0_USB_ASYNC_CS, |
615 | 942ac052 | balrog | tusb6010_async_io(tusb), 0, 0, tusb); |
616 | 942ac052 | balrog | omap_gpmc_attach(s->cpu->gpmc, N8X0_USB_SYNC_CS, |
617 | 942ac052 | balrog | tusb6010_sync_io(tusb), 0, 0, tusb); |
618 | 942ac052 | balrog | |
619 | 942ac052 | balrog | s->usb = tusb; |
620 | e927bb00 | balrog | omap2_gpio_out_set(s->cpu->gpif, N8X0_TUSB_ENABLE_GPIO, tusb_pwr); |
621 | 942ac052 | balrog | } |
622 | 942ac052 | balrog | |
623 | 7e7c5e4c | balrog | /* This task is normally performed by the bootloader. If we're loading
|
624 | 7e7c5e4c | balrog | * a kernel directly, we need to set up GPMC mappings ourselves. */
|
625 | 7e7c5e4c | balrog | static void n800_gpmc_init(struct n800_s *s) |
626 | 7e7c5e4c | balrog | { |
627 | 7e7c5e4c | balrog | uint32_t config7 = |
628 | 7e7c5e4c | balrog | (0xf << 8) | /* MASKADDRESS */ |
629 | 7e7c5e4c | balrog | (1 << 6) | /* CSVALID */ |
630 | 7e7c5e4c | balrog | (4 << 0); /* BASEADDRESS */ |
631 | 7e7c5e4c | balrog | |
632 | 7e7c5e4c | balrog | cpu_physical_memory_write(0x6800a078, /* GPMC_CONFIG7_0 */ |
633 | 7e7c5e4c | balrog | (void *) &config7, sizeof(config7)); |
634 | 7e7c5e4c | balrog | } |
635 | 7e7c5e4c | balrog | |
636 | 7e7c5e4c | balrog | /* Setup sequence done by the bootloader */
|
637 | e927bb00 | balrog | static void n8x0_boot_init(void *opaque) |
638 | 7e7c5e4c | balrog | { |
639 | 7e7c5e4c | balrog | struct n800_s *s = (struct n800_s *) opaque; |
640 | 7e7c5e4c | balrog | uint32_t buf; |
641 | 7e7c5e4c | balrog | |
642 | 7e7c5e4c | balrog | /* PRCM setup */
|
643 | 7e7c5e4c | balrog | #define omap_writel(addr, val) \
|
644 | 7e7c5e4c | balrog | buf = (val); \ |
645 | 7e7c5e4c | balrog | cpu_physical_memory_write(addr, (void *) &buf, sizeof(buf)) |
646 | 7e7c5e4c | balrog | |
647 | 7e7c5e4c | balrog | omap_writel(0x48008060, 0x41); /* PRCM_CLKSRC_CTRL */ |
648 | 7e7c5e4c | balrog | omap_writel(0x48008070, 1); /* PRCM_CLKOUT_CTRL */ |
649 | 7e7c5e4c | balrog | omap_writel(0x48008078, 0); /* PRCM_CLKEMUL_CTRL */ |
650 | 7e7c5e4c | balrog | omap_writel(0x48008090, 0); /* PRCM_VOLTSETUP */ |
651 | 7e7c5e4c | balrog | omap_writel(0x48008094, 0); /* PRCM_CLKSSETUP */ |
652 | 7e7c5e4c | balrog | omap_writel(0x48008098, 0); /* PRCM_POLCTRL */ |
653 | 7e7c5e4c | balrog | omap_writel(0x48008140, 2); /* CM_CLKSEL_MPU */ |
654 | 7e7c5e4c | balrog | omap_writel(0x48008148, 0); /* CM_CLKSTCTRL_MPU */ |
655 | 7e7c5e4c | balrog | omap_writel(0x48008158, 1); /* RM_RSTST_MPU */ |
656 | 7e7c5e4c | balrog | omap_writel(0x480081c8, 0x15); /* PM_WKDEP_MPU */ |
657 | 7e7c5e4c | balrog | omap_writel(0x480081d4, 0x1d4); /* PM_EVGENCTRL_MPU */ |
658 | 7e7c5e4c | balrog | omap_writel(0x480081d8, 0); /* PM_EVEGENONTIM_MPU */ |
659 | 7e7c5e4c | balrog | omap_writel(0x480081dc, 0); /* PM_EVEGENOFFTIM_MPU */ |
660 | 7e7c5e4c | balrog | omap_writel(0x480081e0, 0xc); /* PM_PWSTCTRL_MPU */ |
661 | 7e7c5e4c | balrog | omap_writel(0x48008200, 0x047e7ff7); /* CM_FCLKEN1_CORE */ |
662 | 7e7c5e4c | balrog | omap_writel(0x48008204, 0x00000004); /* CM_FCLKEN2_CORE */ |
663 | 7e7c5e4c | balrog | omap_writel(0x48008210, 0x047e7ff1); /* CM_ICLKEN1_CORE */ |
664 | 7e7c5e4c | balrog | omap_writel(0x48008214, 0x00000004); /* CM_ICLKEN2_CORE */ |
665 | 7e7c5e4c | balrog | omap_writel(0x4800821c, 0x00000000); /* CM_ICLKEN4_CORE */ |
666 | 7e7c5e4c | balrog | omap_writel(0x48008230, 0); /* CM_AUTOIDLE1_CORE */ |
667 | 7e7c5e4c | balrog | omap_writel(0x48008234, 0); /* CM_AUTOIDLE2_CORE */ |
668 | 7e7c5e4c | balrog | omap_writel(0x48008238, 7); /* CM_AUTOIDLE3_CORE */ |
669 | 7e7c5e4c | balrog | omap_writel(0x4800823c, 0); /* CM_AUTOIDLE4_CORE */ |
670 | 7e7c5e4c | balrog | omap_writel(0x48008240, 0x04360626); /* CM_CLKSEL1_CORE */ |
671 | 7e7c5e4c | balrog | omap_writel(0x48008244, 0x00000014); /* CM_CLKSEL2_CORE */ |
672 | 7e7c5e4c | balrog | omap_writel(0x48008248, 0); /* CM_CLKSTCTRL_CORE */ |
673 | 7e7c5e4c | balrog | omap_writel(0x48008300, 0x00000000); /* CM_FCLKEN_GFX */ |
674 | 7e7c5e4c | balrog | omap_writel(0x48008310, 0x00000000); /* CM_ICLKEN_GFX */ |
675 | 7e7c5e4c | balrog | omap_writel(0x48008340, 0x00000001); /* CM_CLKSEL_GFX */ |
676 | 7e7c5e4c | balrog | omap_writel(0x48008400, 0x00000004); /* CM_FCLKEN_WKUP */ |
677 | 7e7c5e4c | balrog | omap_writel(0x48008410, 0x00000004); /* CM_ICLKEN_WKUP */ |
678 | 7e7c5e4c | balrog | omap_writel(0x48008440, 0x00000000); /* CM_CLKSEL_WKUP */ |
679 | 7e7c5e4c | balrog | omap_writel(0x48008500, 0x000000cf); /* CM_CLKEN_PLL */ |
680 | 7e7c5e4c | balrog | omap_writel(0x48008530, 0x0000000c); /* CM_AUTOIDLE_PLL */ |
681 | 7e7c5e4c | balrog | omap_writel(0x48008540, /* CM_CLKSEL1_PLL */ |
682 | 7e7c5e4c | balrog | (0x78 << 12) | (6 << 8)); |
683 | 7e7c5e4c | balrog | omap_writel(0x48008544, 2); /* CM_CLKSEL2_PLL */ |
684 | 7e7c5e4c | balrog | |
685 | 7e7c5e4c | balrog | /* GPMC setup */
|
686 | 7e7c5e4c | balrog | n800_gpmc_init(s); |
687 | 7e7c5e4c | balrog | |
688 | 7e7c5e4c | balrog | /* Video setup */
|
689 | 7e7c5e4c | balrog | n800_dss_init(&s->blizzard); |
690 | 7e7c5e4c | balrog | |
691 | 7e7c5e4c | balrog | /* CPU setup */
|
692 | 7e7c5e4c | balrog | s->cpu->env->regs[15] = s->cpu->env->boot_info->loader_start;
|
693 | 7e7c5e4c | balrog | s->cpu->env->GE = 0x5;
|
694 | 7e7c5e4c | balrog | } |
695 | 7e7c5e4c | balrog | |
696 | 7e7c5e4c | balrog | #define OMAP_TAG_NOKIA_BT 0x4e01 |
697 | 7e7c5e4c | balrog | #define OMAP_TAG_WLAN_CX3110X 0x4e02 |
698 | 7e7c5e4c | balrog | #define OMAP_TAG_CBUS 0x4e03 |
699 | 7e7c5e4c | balrog | #define OMAP_TAG_EM_ASIC_BB5 0x4e04 |
700 | 7e7c5e4c | balrog | |
701 | e927bb00 | balrog | static struct omap_gpiosw_info_s { |
702 | e927bb00 | balrog | const char *name; |
703 | e927bb00 | balrog | int line;
|
704 | e927bb00 | balrog | int type;
|
705 | e927bb00 | balrog | } n800_gpiosw_info[] = { |
706 | e927bb00 | balrog | { |
707 | e927bb00 | balrog | "bat_cover", N800_BAT_COVER_GPIO,
|
708 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_COVER | OMAP_GPIOSW_INVERTED, |
709 | e927bb00 | balrog | }, { |
710 | e927bb00 | balrog | "cam_act", N800_CAM_ACT_GPIO,
|
711 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_ACTIVITY, |
712 | e927bb00 | balrog | }, { |
713 | e927bb00 | balrog | "cam_turn", N800_CAM_TURN_GPIO,
|
714 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_ACTIVITY | OMAP_GPIOSW_INVERTED, |
715 | e927bb00 | balrog | }, { |
716 | e927bb00 | balrog | "headphone", N8X0_HEADPHONE_GPIO,
|
717 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_CONNECTION | OMAP_GPIOSW_INVERTED, |
718 | e927bb00 | balrog | }, |
719 | e927bb00 | balrog | { 0 }
|
720 | e927bb00 | balrog | }, n810_gpiosw_info[] = { |
721 | e927bb00 | balrog | { |
722 | e927bb00 | balrog | "gps_reset", N810_GPS_RESET_GPIO,
|
723 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_ACTIVITY | OMAP_GPIOSW_OUTPUT, |
724 | e927bb00 | balrog | }, { |
725 | e927bb00 | balrog | "gps_wakeup", N810_GPS_WAKEUP_GPIO,
|
726 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_ACTIVITY | OMAP_GPIOSW_OUTPUT, |
727 | e927bb00 | balrog | }, { |
728 | e927bb00 | balrog | "headphone", N8X0_HEADPHONE_GPIO,
|
729 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_CONNECTION | OMAP_GPIOSW_INVERTED, |
730 | e927bb00 | balrog | }, { |
731 | e927bb00 | balrog | "kb_lock", N810_KB_LOCK_GPIO,
|
732 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_COVER | OMAP_GPIOSW_INVERTED, |
733 | e927bb00 | balrog | }, { |
734 | e927bb00 | balrog | "sleepx_led", N810_SLEEPX_LED_GPIO,
|
735 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_ACTIVITY | OMAP_GPIOSW_INVERTED | OMAP_GPIOSW_OUTPUT, |
736 | e927bb00 | balrog | }, { |
737 | e927bb00 | balrog | "slide", N810_SLIDE_GPIO,
|
738 | e927bb00 | balrog | OMAP_GPIOSW_TYPE_COVER | OMAP_GPIOSW_INVERTED, |
739 | e927bb00 | balrog | }, |
740 | e927bb00 | balrog | { 0 }
|
741 | e927bb00 | balrog | }; |
742 | e927bb00 | balrog | |
743 | e927bb00 | balrog | static struct omap_partition_info_s { |
744 | e927bb00 | balrog | uint32_t offset; |
745 | e927bb00 | balrog | uint32_t size; |
746 | e927bb00 | balrog | int mask;
|
747 | e927bb00 | balrog | const char *name; |
748 | e927bb00 | balrog | } n800_part_info[] = { |
749 | e927bb00 | balrog | { 0x00000000, 0x00020000, 0x3, "bootloader" }, |
750 | e927bb00 | balrog | { 0x00020000, 0x00060000, 0x0, "config" }, |
751 | e927bb00 | balrog | { 0x00080000, 0x00200000, 0x0, "kernel" }, |
752 | e927bb00 | balrog | { 0x00280000, 0x00200000, 0x3, "initfs" }, |
753 | e927bb00 | balrog | { 0x00480000, 0x0fb80000, 0x3, "rootfs" }, |
754 | e927bb00 | balrog | |
755 | e927bb00 | balrog | { 0, 0, 0, 0 } |
756 | e927bb00 | balrog | }, n810_part_info[] = { |
757 | e927bb00 | balrog | { 0x00000000, 0x00020000, 0x3, "bootloader" }, |
758 | e927bb00 | balrog | { 0x00020000, 0x00060000, 0x0, "config" }, |
759 | e927bb00 | balrog | { 0x00080000, 0x00220000, 0x0, "kernel" }, |
760 | e927bb00 | balrog | { 0x002a0000, 0x00400000, 0x0, "initfs" }, |
761 | e927bb00 | balrog | { 0x006a0000, 0x0f960000, 0x0, "rootfs" }, |
762 | e927bb00 | balrog | |
763 | e927bb00 | balrog | { 0, 0, 0, 0 } |
764 | e927bb00 | balrog | }; |
765 | e927bb00 | balrog | |
766 | e927bb00 | balrog | static int n8x0_atag_setup(void *p, int model) |
767 | 7e7c5e4c | balrog | { |
768 | 7e7c5e4c | balrog | uint8_t *b; |
769 | 7e7c5e4c | balrog | uint16_t *w; |
770 | 7e7c5e4c | balrog | uint32_t *l; |
771 | e927bb00 | balrog | struct omap_gpiosw_info_s *gpiosw;
|
772 | e927bb00 | balrog | struct omap_partition_info_s *partition;
|
773 | e927bb00 | balrog | const char *tag; |
774 | 7e7c5e4c | balrog | |
775 | 7e7c5e4c | balrog | w = p; |
776 | 7e7c5e4c | balrog | |
777 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_UART); /* u16 tag */
|
778 | 7e7c5e4c | balrog | stw_raw(w ++, 4); /* u16 len */ |
779 | 7e7c5e4c | balrog | stw_raw(w ++, (1 << 2) | (1 << 1) | (1 << 0)); /* uint enabled_uarts */ |
780 | 7e7c5e4c | balrog | w ++; |
781 | 7e7c5e4c | balrog | |
782 | e927bb00 | balrog | #if 0
|
783 | e927bb00 | balrog | stw_raw(w ++, OMAP_TAG_SERIAL_CONSOLE); /* u16 tag */
|
784 | 7e7c5e4c | balrog | stw_raw(w ++, 4); /* u16 len */
|
785 | e927bb00 | balrog | stw_raw(w ++, XLDR_LL_UART); /* u8 console_uart */
|
786 | e927bb00 | balrog | stw_raw(w ++, 115200); /* u32 console_speed */
|
787 | e927bb00 | balrog | #endif
|
788 | e927bb00 | balrog | |
789 | e927bb00 | balrog | stw_raw(w ++, OMAP_TAG_LCD); /* u16 tag */
|
790 | e927bb00 | balrog | stw_raw(w ++, 36); /* u16 len */ |
791 | e927bb00 | balrog | strcpy((void *) w, "QEMU LCD panel"); /* char panel_name[16] */ |
792 | e927bb00 | balrog | w += 8;
|
793 | e927bb00 | balrog | strcpy((void *) w, "blizzard"); /* char ctrl_name[16] */ |
794 | e927bb00 | balrog | w += 8;
|
795 | e927bb00 | balrog | stw_raw(w ++, N810_BLIZZARD_RESET_GPIO); /* TODO: n800 s16 nreset_gpio */
|
796 | e927bb00 | balrog | stw_raw(w ++, 24); /* u8 data_lines */ |
797 | 7e7c5e4c | balrog | |
798 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_CBUS); /* u16 tag */
|
799 | 7e7c5e4c | balrog | stw_raw(w ++, 8); /* u16 len */ |
800 | 7e7c5e4c | balrog | stw_raw(w ++, N8X0_CBUS_CLK_GPIO); /* s16 clk_gpio */
|
801 | 7e7c5e4c | balrog | stw_raw(w ++, N8X0_CBUS_DAT_GPIO); /* s16 dat_gpio */
|
802 | 7e7c5e4c | balrog | stw_raw(w ++, N8X0_CBUS_SEL_GPIO); /* s16 sel_gpio */
|
803 | 7e7c5e4c | balrog | w ++; |
804 | 7e7c5e4c | balrog | |
805 | e927bb00 | balrog | stw_raw(w ++, OMAP_TAG_EM_ASIC_BB5); /* u16 tag */
|
806 | e927bb00 | balrog | stw_raw(w ++, 4); /* u16 len */ |
807 | e927bb00 | balrog | stw_raw(w ++, N8X0_RETU_GPIO); /* s16 retu_irq_gpio */
|
808 | e927bb00 | balrog | stw_raw(w ++, N8X0_TAHVO_GPIO); /* s16 tahvo_irq_gpio */
|
809 | e927bb00 | balrog | |
810 | e927bb00 | balrog | gpiosw = (model == 810) ? n810_gpiosw_info : n800_gpiosw_info;
|
811 | e927bb00 | balrog | for (; gpiosw->name; gpiosw ++) {
|
812 | e927bb00 | balrog | stw_raw(w ++, OMAP_TAG_GPIO_SWITCH); /* u16 tag */
|
813 | e927bb00 | balrog | stw_raw(w ++, 20); /* u16 len */ |
814 | e927bb00 | balrog | strcpy((void *) w, gpiosw->name); /* char name[12] */ |
815 | e927bb00 | balrog | w += 6;
|
816 | e927bb00 | balrog | stw_raw(w ++, gpiosw->line); /* u16 gpio */
|
817 | e927bb00 | balrog | stw_raw(w ++, gpiosw->type); |
818 | e927bb00 | balrog | stw_raw(w ++, 0);
|
819 | e927bb00 | balrog | stw_raw(w ++, 0);
|
820 | e927bb00 | balrog | } |
821 | 7e7c5e4c | balrog | |
822 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_NOKIA_BT); /* u16 tag */
|
823 | 7e7c5e4c | balrog | stw_raw(w ++, 12); /* u16 len */ |
824 | 7e7c5e4c | balrog | b = (void *) w;
|
825 | 7e7c5e4c | balrog | stb_raw(b ++, 0x01); /* u8 chip_type (CSR) */ |
826 | e927bb00 | balrog | stb_raw(b ++, N8X0_BT_WKUP_GPIO); /* u8 bt_wakeup_gpio */
|
827 | 7e7c5e4c | balrog | stb_raw(b ++, N8X0_BT_HOST_WKUP_GPIO); /* u8 host_wakeup_gpio */
|
828 | e927bb00 | balrog | stb_raw(b ++, N8X0_BT_RESET_GPIO); /* u8 reset_gpio */
|
829 | 7e7c5e4c | balrog | stb_raw(b ++, 1); /* u8 bt_uart */ |
830 | 7e7c5e4c | balrog | memset(b, 0, 6); /* u8 bd_addr[6] */ |
831 | 7e7c5e4c | balrog | b += 6;
|
832 | 7e7c5e4c | balrog | stb_raw(b ++, 0x02); /* u8 bt_sysclk (38.4) */ |
833 | 7e7c5e4c | balrog | w = (void *) b;
|
834 | 7e7c5e4c | balrog | |
835 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_WLAN_CX3110X); /* u16 tag */
|
836 | 7e7c5e4c | balrog | stw_raw(w ++, 8); /* u16 len */ |
837 | 7e7c5e4c | balrog | stw_raw(w ++, 0x25); /* u8 chip_type */ |
838 | e927bb00 | balrog | stw_raw(w ++, N8X0_WLAN_PWR_GPIO); /* s16 power_gpio */
|
839 | e927bb00 | balrog | stw_raw(w ++, N8X0_WLAN_IRQ_GPIO); /* s16 irq_gpio */
|
840 | 7e7c5e4c | balrog | stw_raw(w ++, -1); /* s16 spi_cs_gpio */ |
841 | 7e7c5e4c | balrog | |
842 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_MMC); /* u16 tag */
|
843 | 7e7c5e4c | balrog | stw_raw(w ++, 16); /* u16 len */ |
844 | e927bb00 | balrog | if (model == 810) { |
845 | e927bb00 | balrog | stw_raw(w ++, 0x23f); /* unsigned flags */ |
846 | e927bb00 | balrog | stw_raw(w ++, -1); /* s16 power_pin */ |
847 | e927bb00 | balrog | stw_raw(w ++, -1); /* s16 switch_pin */ |
848 | e927bb00 | balrog | stw_raw(w ++, -1); /* s16 wp_pin */ |
849 | e927bb00 | balrog | stw_raw(w ++, 0x240); /* unsigned flags */ |
850 | e927bb00 | balrog | stw_raw(w ++, 0xc000); /* s16 power_pin */ |
851 | e927bb00 | balrog | stw_raw(w ++, 0x0248); /* s16 switch_pin */ |
852 | e927bb00 | balrog | stw_raw(w ++, 0xc000); /* s16 wp_pin */ |
853 | e927bb00 | balrog | } else {
|
854 | e927bb00 | balrog | stw_raw(w ++, 0xf); /* unsigned flags */ |
855 | e927bb00 | balrog | stw_raw(w ++, -1); /* s16 power_pin */ |
856 | e927bb00 | balrog | stw_raw(w ++, -1); /* s16 switch_pin */ |
857 | e927bb00 | balrog | stw_raw(w ++, -1); /* s16 wp_pin */ |
858 | e927bb00 | balrog | stw_raw(w ++, 0); /* unsigned flags */ |
859 | e927bb00 | balrog | stw_raw(w ++, 0); /* s16 power_pin */ |
860 | e927bb00 | balrog | stw_raw(w ++, 0); /* s16 switch_pin */ |
861 | e927bb00 | balrog | stw_raw(w ++, 0); /* s16 wp_pin */ |
862 | e927bb00 | balrog | } |
863 | 7e7c5e4c | balrog | |
864 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_TEA5761); /* u16 tag */
|
865 | 7e7c5e4c | balrog | stw_raw(w ++, 4); /* u16 len */ |
866 | e927bb00 | balrog | stw_raw(w ++, N8X0_TEA5761_CS_GPIO); /* u16 enable_gpio */
|
867 | 7e7c5e4c | balrog | w ++; |
868 | 7e7c5e4c | balrog | |
869 | e927bb00 | balrog | partition = (model == 810) ? n810_part_info : n800_part_info;
|
870 | e927bb00 | balrog | for (; partition->name; partition ++) {
|
871 | e927bb00 | balrog | stw_raw(w ++, OMAP_TAG_PARTITION); /* u16 tag */
|
872 | e927bb00 | balrog | stw_raw(w ++, 28); /* u16 len */ |
873 | e927bb00 | balrog | strcpy((void *) w, partition->name); /* char name[16] */ |
874 | e927bb00 | balrog | l = (void *) (w + 8); |
875 | e927bb00 | balrog | stl_raw(l ++, partition->size); /* unsigned int size */
|
876 | e927bb00 | balrog | stl_raw(l ++, partition->offset); /* unsigned int offset */
|
877 | e927bb00 | balrog | stl_raw(l ++, partition->mask); /* unsigned int mask_flags */
|
878 | e927bb00 | balrog | w = (void *) l;
|
879 | e927bb00 | balrog | } |
880 | 7e7c5e4c | balrog | |
881 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_BOOT_REASON); /* u16 tag */
|
882 | 7e7c5e4c | balrog | stw_raw(w ++, 12); /* u16 len */ |
883 | 7e7c5e4c | balrog | #if 0
|
884 | 7e7c5e4c | balrog | strcpy((void *) w, "por"); /* char reason_str[12] */
|
885 | 7e7c5e4c | balrog | strcpy((void *) w, "charger"); /* char reason_str[12] */
|
886 | 7e7c5e4c | balrog | strcpy((void *) w, "32wd_to"); /* char reason_str[12] */
|
887 | 7e7c5e4c | balrog | strcpy((void *) w, "sw_rst"); /* char reason_str[12] */
|
888 | 7e7c5e4c | balrog | strcpy((void *) w, "mbus"); /* char reason_str[12] */
|
889 | 7e7c5e4c | balrog | strcpy((void *) w, "unknown"); /* char reason_str[12] */
|
890 | 7e7c5e4c | balrog | strcpy((void *) w, "swdg_to"); /* char reason_str[12] */
|
891 | 7e7c5e4c | balrog | strcpy((void *) w, "sec_vio"); /* char reason_str[12] */
|
892 | 7e7c5e4c | balrog | strcpy((void *) w, "pwr_key"); /* char reason_str[12] */
|
893 | 7e7c5e4c | balrog | strcpy((void *) w, "rtc_alarm"); /* char reason_str[12] */
|
894 | 7e7c5e4c | balrog | #else
|
895 | 7e7c5e4c | balrog | strcpy((void *) w, "pwr_key"); /* char reason_str[12] */ |
896 | 7e7c5e4c | balrog | #endif
|
897 | 7e7c5e4c | balrog | w += 6;
|
898 | 7e7c5e4c | balrog | |
899 | e927bb00 | balrog | tag = (model == 810) ? "RX-44" : "RX-34"; |
900 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_VERSION_STR); /* u16 tag */
|
901 | 7e7c5e4c | balrog | stw_raw(w ++, 24); /* u16 len */ |
902 | 7e7c5e4c | balrog | strcpy((void *) w, "product"); /* char component[12] */ |
903 | 7e7c5e4c | balrog | w += 6;
|
904 | e927bb00 | balrog | strcpy((void *) w, tag); /* char version[12] */ |
905 | 7e7c5e4c | balrog | w += 6;
|
906 | 7e7c5e4c | balrog | |
907 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_VERSION_STR); /* u16 tag */
|
908 | 7e7c5e4c | balrog | stw_raw(w ++, 24); /* u16 len */ |
909 | 7e7c5e4c | balrog | strcpy((void *) w, "hw-build"); /* char component[12] */ |
910 | 7e7c5e4c | balrog | w += 6;
|
911 | e927bb00 | balrog | strcpy((void *) w, "QEMU " QEMU_VERSION); /* char version[12] */ |
912 | 7e7c5e4c | balrog | w += 6;
|
913 | 7e7c5e4c | balrog | |
914 | e927bb00 | balrog | tag = (model == 810) ? "1.1.10-qemu" : "1.1.6-qemu"; |
915 | 7e7c5e4c | balrog | stw_raw(w ++, OMAP_TAG_VERSION_STR); /* u16 tag */
|
916 | 7e7c5e4c | balrog | stw_raw(w ++, 24); /* u16 len */ |
917 | 7e7c5e4c | balrog | strcpy((void *) w, "nolo"); /* char component[12] */ |
918 | 7e7c5e4c | balrog | w += 6;
|
919 | e927bb00 | balrog | strcpy((void *) w, tag); /* char version[12] */ |
920 | 7e7c5e4c | balrog | w += 6;
|
921 | 7e7c5e4c | balrog | |
922 | 7e7c5e4c | balrog | return (void *) w - p; |
923 | 7e7c5e4c | balrog | } |
924 | 7e7c5e4c | balrog | |
925 | e927bb00 | balrog | static int n800_atag_setup(struct arm_boot_info *info, void *p) |
926 | e927bb00 | balrog | { |
927 | e927bb00 | balrog | return n8x0_atag_setup(p, 800); |
928 | e927bb00 | balrog | } |
929 | 7e7c5e4c | balrog | |
930 | e927bb00 | balrog | static int n810_atag_setup(struct arm_boot_info *info, void *p) |
931 | e927bb00 | balrog | { |
932 | e927bb00 | balrog | return n8x0_atag_setup(p, 810); |
933 | e927bb00 | balrog | } |
934 | e927bb00 | balrog | |
935 | e927bb00 | balrog | static void n8x0_init(ram_addr_t ram_size, const char *boot_device, |
936 | e927bb00 | balrog | DisplayState *ds, const char *kernel_filename, |
937 | e927bb00 | balrog | const char *kernel_cmdline, const char *initrd_filename, |
938 | e927bb00 | balrog | const char *cpu_model, struct arm_boot_info *binfo, int model) |
939 | 7e7c5e4c | balrog | { |
940 | 7e7c5e4c | balrog | struct n800_s *s = (struct n800_s *) qemu_mallocz(sizeof(*s)); |
941 | e927bb00 | balrog | int sdram_size = binfo->ram_size;
|
942 | 7e7c5e4c | balrog | int onenandram_size = 0x00010000; |
943 | 7e7c5e4c | balrog | |
944 | 7e7c5e4c | balrog | if (ram_size < sdram_size + onenandram_size + OMAP242X_SRAM_SIZE) {
|
945 | 7e7c5e4c | balrog | fprintf(stderr, "This architecture uses %i bytes of memory\n",
|
946 | 7e7c5e4c | balrog | sdram_size + onenandram_size + OMAP242X_SRAM_SIZE); |
947 | 7e7c5e4c | balrog | exit(1);
|
948 | 7e7c5e4c | balrog | } |
949 | 7e7c5e4c | balrog | |
950 | 7e7c5e4c | balrog | s->cpu = omap2420_mpu_init(sdram_size, NULL, cpu_model);
|
951 | 7e7c5e4c | balrog | |
952 | e927bb00 | balrog | n8x0_gpio_setup(s); |
953 | 7e7c5e4c | balrog | n8x0_nand_setup(s); |
954 | e927bb00 | balrog | n8x0_i2c_setup(s); |
955 | e927bb00 | balrog | if (model == 800) |
956 | e927bb00 | balrog | n800_tsc_kbd_setup(s); |
957 | e927bb00 | balrog | else if (model == 810) |
958 | e927bb00 | balrog | n810_tsc_setup(s); |
959 | e927bb00 | balrog | n8x0_spi_setup(s); |
960 | e927bb00 | balrog | n8x0_dss_setup(s, ds); |
961 | e927bb00 | balrog | n8x0_cbus_setup(s); |
962 | 942ac052 | balrog | if (usb_enabled)
|
963 | e927bb00 | balrog | n8x0_usb_setup(s); |
964 | 7e7c5e4c | balrog | |
965 | 7e7c5e4c | balrog | /* Setup initial (reset) machine state */
|
966 | 7e7c5e4c | balrog | |
967 | 7e7c5e4c | balrog | /* Start at the OneNAND bootloader. */
|
968 | 7e7c5e4c | balrog | s->cpu->env->regs[15] = 0; |
969 | 7e7c5e4c | balrog | |
970 | 7e7c5e4c | balrog | if (kernel_filename) {
|
971 | 7e7c5e4c | balrog | /* Or at the linux loader. */
|
972 | e927bb00 | balrog | binfo->kernel_filename = kernel_filename; |
973 | e927bb00 | balrog | binfo->kernel_cmdline = kernel_cmdline; |
974 | e927bb00 | balrog | binfo->initrd_filename = initrd_filename; |
975 | e927bb00 | balrog | arm_load_kernel(s->cpu->env, binfo); |
976 | 7e7c5e4c | balrog | |
977 | e927bb00 | balrog | qemu_register_reset(n8x0_boot_init, s); |
978 | e927bb00 | balrog | n8x0_boot_init(s); |
979 | 7e7c5e4c | balrog | } |
980 | 7e7c5e4c | balrog | |
981 | 7e7c5e4c | balrog | dpy_resize(ds, 800, 480); |
982 | 7e7c5e4c | balrog | } |
983 | 7e7c5e4c | balrog | |
984 | e927bb00 | balrog | static struct arm_boot_info n800_binfo = { |
985 | e927bb00 | balrog | .loader_start = OMAP2_Q2_BASE, |
986 | e927bb00 | balrog | /* Actually two chips of 0x4000000 bytes each */
|
987 | e927bb00 | balrog | .ram_size = 0x08000000,
|
988 | e927bb00 | balrog | .board_id = 0x4f7,
|
989 | e927bb00 | balrog | .atag_board = n800_atag_setup, |
990 | e927bb00 | balrog | }; |
991 | e927bb00 | balrog | |
992 | e927bb00 | balrog | static struct arm_boot_info n810_binfo = { |
993 | e927bb00 | balrog | .loader_start = OMAP2_Q2_BASE, |
994 | e927bb00 | balrog | /* Actually two chips of 0x4000000 bytes each */
|
995 | e927bb00 | balrog | .ram_size = 0x08000000,
|
996 | e927bb00 | balrog | /* 0x60c and 0x6bf (WiMAX Edition) have been assigned but are not
|
997 | e927bb00 | balrog | * used by some older versions of the bootloader and 5555 is used
|
998 | e927bb00 | balrog | * instead (including versions that shipped with many devices). */
|
999 | e927bb00 | balrog | .board_id = 0x60c,
|
1000 | e927bb00 | balrog | .atag_board = n810_atag_setup, |
1001 | e927bb00 | balrog | }; |
1002 | e927bb00 | balrog | |
1003 | e927bb00 | balrog | static void n800_init(ram_addr_t ram_size, int vga_ram_size, |
1004 | e927bb00 | balrog | const char *boot_device, DisplayState *ds, |
1005 | e927bb00 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
1006 | e927bb00 | balrog | const char *initrd_filename, const char *cpu_model) |
1007 | e927bb00 | balrog | { |
1008 | e927bb00 | balrog | return n8x0_init(ram_size, boot_device, ds,
|
1009 | e927bb00 | balrog | kernel_filename, kernel_cmdline, initrd_filename, |
1010 | e927bb00 | balrog | cpu_model, &n800_binfo, 800);
|
1011 | e927bb00 | balrog | } |
1012 | e927bb00 | balrog | |
1013 | e927bb00 | balrog | static void n810_init(ram_addr_t ram_size, int vga_ram_size, |
1014 | e927bb00 | balrog | const char *boot_device, DisplayState *ds, |
1015 | e927bb00 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
1016 | e927bb00 | balrog | const char *initrd_filename, const char *cpu_model) |
1017 | e927bb00 | balrog | { |
1018 | e927bb00 | balrog | return n8x0_init(ram_size, boot_device, ds,
|
1019 | e927bb00 | balrog | kernel_filename, kernel_cmdline, initrd_filename, |
1020 | e927bb00 | balrog | cpu_model, &n810_binfo, 810);
|
1021 | e927bb00 | balrog | } |
1022 | e927bb00 | balrog | |
1023 | 7e7c5e4c | balrog | QEMUMachine n800_machine = { |
1024 | 7e7c5e4c | balrog | "n800",
|
1025 | e927bb00 | balrog | "Nokia N800 tablet aka. RX-34 (OMAP2420)",
|
1026 | 7e7c5e4c | balrog | n800_init, |
1027 | 7fb4fdcf | balrog | (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED, |
1028 | 7e7c5e4c | balrog | }; |
1029 | e927bb00 | balrog | |
1030 | e927bb00 | balrog | QEMUMachine n810_machine = { |
1031 | e927bb00 | balrog | "n810",
|
1032 | e927bb00 | balrog | "Nokia N810 tablet aka. RX-44 (OMAP2420)",
|
1033 | e927bb00 | balrog | n810_init, |
1034 | 069de562 | balrog | (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED, |
1035 | e927bb00 | balrog | }; |