s390x/css: provide a dev_path for css devices
[qemu.git] / hw / arm / palmetto-bmc.c
blob54e29a865d883c43b9e8c6e4d5c911e0c332fe83
1 /*
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"
15 #include "cpu.h"
16 #include "exec/address-spaces.h"
17 #include "hw/arm/arm.h"
18 #include "hw/arm/ast2400.h"
19 #include "hw/boards.h"
20 #include "qemu/log.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,
26 .board_id = 0,
27 .nb_cpus = 1,
30 typedef struct PalmettoBMCState {
31 AST2400State soc;
32 MemoryRegion ram;
33 } PalmettoBMCState;
35 static void palmetto_bmc_init_flashes(AspeedSMCState *s, const char *flashtype,
36 Error **errp)
38 int i ;
40 for (i = 0; i < s->num_cs; ++i) {
41 AspeedSMCFlash *fl = &s->flashes[i];
42 DriveInfo *dinfo = drive_get_next(IF_MTD);
43 qemu_irq cs_line;
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);
50 if (dinfo) {
51 qdev_prop_set_drive(fl->flash, "drive", blk_by_legacy_dinfo(dinfo),
52 errp);
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),
68 &error_abort);
70 memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
71 memory_region_add_subregion(get_system_memory(), AST2400_SDRAM_BASE,
72 &bmc->ram);
73 object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram),
74 &error_abort);
75 object_property_set_int(OBJECT(&bmc->soc), 0x120CE416, "hw-strap1",
76 &error_abort);
77 object_property_set_bool(OBJECT(&bmc->soc), true, "realized",
78 &error_abort);
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;
94 mc->max_cpus = 1;
95 mc->no_sdcard = 1;
96 mc->no_floppy = 1;
97 mc->no_cdrom = 1;
98 mc->no_sdcard = 1;
99 mc->no_parallel = 1;
102 DEFINE_MACHINE("palmetto-bmc", palmetto_bmc_machine_init);