2013-12-17 20:42:38 +01:00
|
|
|
/*
|
|
|
|
* cubieboard emulation
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Li Guang
|
|
|
|
* Written by Li Guang <lig.fnst@cn.fujitsu.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2015-12-07 17:23:45 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-12-17 20:42:38 +01:00
|
|
|
#include "hw/sysbus.h"
|
|
|
|
#include "hw/devices.h"
|
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "hw/arm/allwinner-a10.h"
|
|
|
|
|
|
|
|
static struct arm_boot_info cubieboard_binfo = {
|
|
|
|
.loader_start = AW_A10_SDRAM_BASE,
|
|
|
|
.board_id = 0x1008,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct CubieBoardState {
|
|
|
|
AwA10State *a10;
|
|
|
|
MemoryRegion sdram;
|
|
|
|
} CubieBoardState;
|
|
|
|
|
2014-05-07 16:42:57 +02:00
|
|
|
static void cubieboard_init(MachineState *machine)
|
2013-12-17 20:42:38 +01:00
|
|
|
{
|
|
|
|
CubieBoardState *s = g_new(CubieBoardState, 1);
|
|
|
|
Error *err = NULL;
|
|
|
|
|
|
|
|
s->a10 = AW_A10(object_new(TYPE_AW_A10));
|
2014-01-30 23:02:07 +01:00
|
|
|
|
|
|
|
object_property_set_int(OBJECT(&s->a10->emac), 1, "phy-addr", &err);
|
|
|
|
if (err != NULL) {
|
2015-12-18 16:35:14 +01:00
|
|
|
error_reportf_err(err, "Couldn't set phy address: ");
|
2014-01-30 23:02:07 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2014-03-25 19:22:08 +01:00
|
|
|
object_property_set_int(OBJECT(&s->a10->timer), 32768, "clk0-freq", &err);
|
|
|
|
if (err != NULL) {
|
2015-12-18 16:35:14 +01:00
|
|
|
error_reportf_err(err, "Couldn't set clk0 frequency: ");
|
2014-03-25 19:22:08 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
object_property_set_int(OBJECT(&s->a10->timer), 24000000, "clk1-freq",
|
|
|
|
&err);
|
|
|
|
if (err != NULL) {
|
2015-12-18 16:35:14 +01:00
|
|
|
error_reportf_err(err, "Couldn't set clk1 frequency: ");
|
2014-03-25 19:22:08 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2013-12-17 20:42:38 +01:00
|
|
|
object_property_set_bool(OBJECT(s->a10), true, "realized", &err);
|
|
|
|
if (err != NULL) {
|
2015-12-18 16:35:14 +01:00
|
|
|
error_reportf_err(err, "Couldn't realize Allwinner A10: ");
|
2013-12-17 20:42:38 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2015-04-04 14:24:38 +02:00
|
|
|
memory_region_allocate_system_memory(&s->sdram, NULL, "cubieboard.ram",
|
|
|
|
machine->ram_size);
|
2013-12-17 20:42:38 +01:00
|
|
|
memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE,
|
|
|
|
&s->sdram);
|
|
|
|
|
2014-05-07 16:42:57 +02:00
|
|
|
cubieboard_binfo.ram_size = machine->ram_size;
|
|
|
|
cubieboard_binfo.kernel_filename = machine->kernel_filename;
|
|
|
|
cubieboard_binfo.kernel_cmdline = machine->kernel_cmdline;
|
2013-12-17 20:42:38 +01:00
|
|
|
arm_load_kernel(&s->a10->cpu, &cubieboard_binfo);
|
|
|
|
}
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
static void cubieboard_machine_init(MachineClass *mc)
|
2013-12-17 20:42:38 +01:00
|
|
|
{
|
2015-09-04 20:37:08 +02:00
|
|
|
mc->desc = "cubietech cubieboard";
|
|
|
|
mc->init = cubieboard_init;
|
2013-12-17 20:42:38 +01:00
|
|
|
}
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
DEFINE_MACHINE("cubieboard", cubieboard_machine_init)
|