15
15
* GNU General Public License for more details.
17
17
* You should have received a copy of the GNU General Public License along
18
* with this program; if not, write to the Free Software Foundation, Inc.,
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
* with this program; if not, see <http://www.gnu.org/licenses/>.
22
21
#include "qemu-common.h"
180
179
static void n8x0_i2c_setup(struct n800_s *s)
182
182
qemu_irq tmp_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_TMP105_GPIO)[0];
184
184
/* Attach the CPU on one end of our I2C bus. */
185
185
s->i2c = omap_i2c_bus(s->cpu->i2c[0]);
187
187
/* Attach a menelaus PM chip */
188
i2c_set_slave_address(
189
twl92230_init(s->i2c,
190
s->cpu->irq[0][OMAP_INT_24XX_SYS_NIRQ]),
188
dev = i2c_create_slave(s->i2c, "twl92230", N8X0_MENELAUS_ADDR);
189
qdev_connect_gpio_out(dev, 3, s->cpu->irq[0][OMAP_INT_24XX_SYS_NIRQ]);
193
191
/* Attach a TMP105 PM chip (A0 wired to ground) */
194
i2c_set_slave_address(tmp105_init(s->i2c, tmp_irq), N8X0_TMP105_ADDR);
192
dev = i2c_create_slave(s->i2c, "tmp105", N8X0_TMP105_ADDR);
193
qdev_connect_gpio_out(dev, 0, tmp_irq);
197
196
/* Touchscreen and keypad controller */
198
static struct mouse_transform_info_s n800_pointercal = {
197
static MouseTransformInfo n800_pointercal = {
201
200
.a = { 14560, -68, -3455208, -39, -9621, 35152972, 65536 },
204
static struct mouse_transform_info_s n810_pointercal = {
203
static MouseTransformInfo n810_pointercal = {
207
206
.a = { 15041, 148, -4731056, 171, -10238, 35933380, 65536 },
252
251
qemu_irq kbirq = omap2_gpio_in_get(s->cpu->gpif, N800_TSC_KP_IRQ_GPIO)[0];
253
252
qemu_irq dav = omap2_gpio_in_get(s->cpu->gpif, N800_TSC_TS_GPIO)[0];
255
s->ts.chip = tsc2301_init(penirq, kbirq, dav, 0);
254
s->ts.chip = tsc2301_init(penirq, kbirq, dav);
256
255
s->ts.opaque = s->ts.chip->opaque;
257
256
s->ts.txrx = tsc210x_txrx;
375
375
/* Attach the LM8322 keyboard to the I2C bus,
376
376
* should happen in n8x0_i2c_setup and s->kbd be initialised here. */
377
s->kbd = lm8323_init(s->i2c, kbd_irq);
378
i2c_set_slave_address(s->kbd, N810_LM8323_ADDR);
377
dev = i2c_create_slave(s->i2c, "lm8323", N810_LM8323_ADDR);
378
qdev_connect_gpio_out(dev, 0, kbd_irq);
381
381
/* LCD MIPI DBI-C controller (URAL) */
431
cpu_abort(cpu_single_env, "%s: FIXME: bad SPI word width %i\n",
431
hw_error("%s: FIXME: bad SPI word width %i\n", __FUNCTION__, len);
434
433
if (s->p >= ARRAY_SIZE(s->resp))
730
729
qemu_irq retu_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_RETU_GPIO)[0];
731
730
qemu_irq tahvo_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_TAHVO_GPIO)[0];
733
struct cbus_s *cbus = cbus_init(dat_out);
732
CBus *cbus = cbus_init(dat_out);
735
734
omap2_gpio_out_set(s->cpu->gpif, N8X0_CBUS_CLK_GPIO, cbus->clk);
736
735
omap2_gpio_out_set(s->cpu->gpif, N8X0_CBUS_DAT_GPIO, cbus->dat);
766
765
qemu_irq tusb_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_TUSB_INT_GPIO)[0];
767
766
qemu_irq tusb_pwr = qemu_allocate_irqs(n8x0_usb_power_cb, s, 1)[0];
768
struct tusb_s *tusb = tusb6010_init(tusb_irq);
767
TUSBState *tusb = tusb6010_init(tusb_irq);
770
769
/* Using the NOR interface */
771
770
omap_gpmc_attach(s->cpu->gpmc, N8X0_USB_ASYNC_CS,
1273
1272
struct n800_s *s = (struct n800_s *) qemu_mallocz(sizeof(*s));
1274
1273
int sdram_size = binfo->ram_size;
1275
int onenandram_size = 0x00010000;
1276
1274
DisplayState *ds;
1278
if (ram_size < sdram_size + onenandram_size + OMAP242X_SRAM_SIZE) {
1279
fprintf(stderr, "This architecture uses %i bytes of memory\n",
1280
sdram_size + onenandram_size + OMAP242X_SRAM_SIZE);
1284
1276
s->cpu = omap2420_mpu_init(sdram_size, cpu_model);
1286
1278
/* Setup peripherals
1343
1335
if (option_rom[0] && (boot_device[0] == 'n' || !kernel_filename)) {
1337
uint8_t nolo_tags[0x10000];
1344
1338
/* No, wait, better start at the ROM. */
1345
1339
s->cpu->env->regs[15] = OMAP2_Q2_BASE + 0x400000;
1354
1348
* The code above is for loading the `zImage' file from Nokia
1356
printf("%i bytes of image loaded\n", load_image(option_rom[0],
1357
phys_ram_base + 0x400000));
1350
rom_size = load_image_targphys(option_rom[0],
1351
OMAP2_Q2_BASE + 0x400000,
1352
sdram_size - 0x400000);
1353
printf("%i bytes of image loaded\n", rom_size);
1359
n800_setup_nolo_tags(phys_ram_base + sdram_size);
1355
n800_setup_nolo_tags(nolo_tags);
1356
cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000);
1361
1358
/* FIXME: We shouldn't really be doing this here. The LCD controller
1362
1359
will set the size once configured, so this just sets an initial
1363
1360
size until the guest activates the display. */
1364
1361
ds = get_displaystate();
1365
ds->surface = qemu_resize_displaysurface(ds->surface, 800, 480, 32, 4 * 800);
1362
ds->surface = qemu_resize_displaysurface(ds, 800, 480);
1366
1363
dpy_resize(ds);
1385
1382
.atag_board = n810_atag_setup,
1388
static void n800_init(ram_addr_t ram_size, int vga_ram_size,
1385
static void n800_init(ram_addr_t ram_size,
1389
1386
const char *boot_device,
1390
1387
const char *kernel_filename, const char *kernel_cmdline,
1391
1388
const char *initrd_filename, const char *cpu_model)
1395
1392
cpu_model, &n800_binfo, 800);
1398
static void n810_init(ram_addr_t ram_size, int vga_ram_size,
1395
static void n810_init(ram_addr_t ram_size,
1399
1396
const char *boot_device,
1400
1397
const char *kernel_filename, const char *kernel_cmdline,
1401
1398
const char *initrd_filename, const char *cpu_model)
1405
1402
cpu_model, &n810_binfo, 810);
1408
QEMUMachine n800_machine = {
1405
static QEMUMachine n800_machine = {
1409
1406
.name = "n800",
1410
1407
.desc = "Nokia N800 tablet aka. RX-34 (OMAP2420)",
1411
1408
.init = n800_init,
1412
.ram_require = (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) |
1416
QEMUMachine n810_machine = {
1411
static QEMUMachine n810_machine = {
1417
1412
.name = "n810",
1418
1413
.desc = "Nokia N810 tablet aka. RX-44 (OMAP2420)",
1419
1414
.init = n810_init,
1420
.ram_require = (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) |
1417
static void nseries_machine_init(void)
1419
qemu_register_machine(&n800_machine);
1420
qemu_register_machine(&n810_machine);
1423
machine_init(nseries_machine_init);