2 * OpenPOWER Palmetto BMC
4 * Andrew Jeffery <andrew@aj.id.au>
6 * Copyright 2016 IBM Corp.
8 * This code is licensed under the GPL version 2 or later. See
9 * the COPYING file in the top-level directory.
12 #include "qemu/osdep.h"
13 #include "qapi/error.h"
14 #include "qemu-common.h"
16 #include "exec/address-spaces.h"
17 #include "hw/arm/arm.h"
18 #include "hw/arm/ast2400.h"
19 #include "hw/boards.h"
21 #include "sysemu/block-backend.h"
22 #include "sysemu/blockdev.h"
24 static struct arm_boot_info palmetto_bmc_binfo
= {
25 .loader_start
= AST2400_SDRAM_BASE
,
30 typedef struct PalmettoBMCState
{
35 static void palmetto_bmc_init_flashes(AspeedSMCState
*s
, const char *flashtype
,
40 for (i
= 0; i
< s
->num_cs
; ++i
) {
41 AspeedSMCFlash
*fl
= &s
->flashes
[i
];
42 DriveInfo
*dinfo
= drive_get_next(IF_MTD
);
46 * FIXME: check that we are not using a flash module exceeding
47 * the controller segment size
49 fl
->flash
= ssi_create_slave_no_init(s
->spi
, flashtype
);
51 qdev_prop_set_drive(fl
->flash
, "drive", blk_by_legacy_dinfo(dinfo
),
54 qdev_init_nofail(fl
->flash
);
56 cs_line
= qdev_get_gpio_in_named(fl
->flash
, SSI_GPIO_CS
, 0);
57 sysbus_connect_irq(SYS_BUS_DEVICE(s
), i
+ 1, cs_line
);
61 static void palmetto_bmc_init(MachineState
*machine
)
63 PalmettoBMCState
*bmc
;
65 bmc
= g_new0(PalmettoBMCState
, 1);
66 object_initialize(&bmc
->soc
, (sizeof(bmc
->soc
)), TYPE_AST2400
);
67 object_property_add_child(OBJECT(machine
), "soc", OBJECT(&bmc
->soc
),
70 memory_region_allocate_system_memory(&bmc
->ram
, NULL
, "ram", ram_size
);
71 memory_region_add_subregion(get_system_memory(), AST2400_SDRAM_BASE
,
73 object_property_add_const_link(OBJECT(&bmc
->soc
), "ram", OBJECT(&bmc
->ram
),
75 object_property_set_int(OBJECT(&bmc
->soc
), 0x120CE416, "hw-strap1",
77 object_property_set_bool(OBJECT(&bmc
->soc
), true, "realized",
80 palmetto_bmc_init_flashes(&bmc
->soc
.smc
, "n25q256a", &error_abort
);
81 palmetto_bmc_init_flashes(&bmc
->soc
.spi
, "mx25l25635e", &error_abort
);
83 palmetto_bmc_binfo
.kernel_filename
= machine
->kernel_filename
;
84 palmetto_bmc_binfo
.initrd_filename
= machine
->initrd_filename
;
85 palmetto_bmc_binfo
.kernel_cmdline
= machine
->kernel_cmdline
;
86 palmetto_bmc_binfo
.ram_size
= ram_size
;
87 arm_load_kernel(ARM_CPU(first_cpu
), &palmetto_bmc_binfo
);
90 static void palmetto_bmc_machine_init(MachineClass
*mc
)
92 mc
->desc
= "OpenPOWER Palmetto BMC";
93 mc
->init
= palmetto_bmc_init
;
102 DEFINE_MACHINE("palmetto-bmc", palmetto_bmc_machine_init
);