From patchwork Wed May 17 21:05:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev\" via" X-Patchwork-Id: 9731899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04C5760230 for ; Wed, 17 May 2017 21:10:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC433287D0 for ; Wed, 17 May 2017 21:09:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0CE1287FA; Wed, 17 May 2017 21:09:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, FORGED_MUA_MOZILLA, FREEMAIL_REPLYTO_END_DIGIT, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 197DE287D0 for ; Wed, 17 May 2017 21:09:58 +0000 (UTC) Received: from localhost ([::1]:50765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB6Cj-0006jJ-NR for patchwork-qemu-devel@patchwork.kernel.org; Wed, 17 May 2017 17:09:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB6CA-0006jD-42 for qemu-devel@nongnu.org; Wed, 17 May 2017 17:09:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB6C6-0001JF-3I for qemu-devel@nongnu.org; Wed, 17 May 2017 17:09:22 -0400 Received: from sonic315-26.consmr.mail.ir2.yahoo.com ([77.238.176.55]:38525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB6C5-0001J7-Po for qemu-devel@nongnu.org; Wed, 17 May 2017 17:09:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1495055353; bh=ArXcM1ZCHoHR2EQIgOnsEQVuHPuS+GPJwANZVTy5KDg=; h=Date:From:Reply-To:To:Cc:Subject:References:From:Subject; b=kjGWHaVkYLzAqV4STgD84oSDR+cTNBAeyyZwg5Zp2BZVbNaMMuKt7wTl9vrIW/7gc7PET7mH0DfJVePgRyunLd5oaMO60VUGN+UQKut42+cvjWfYLDHPG03KjaghQnYmB5+zujAO7jMLiZpnUQGsXw0ocHMldN+QG+L9sgebPMt7c24NDVcXEP51KFZyiRM1yYu1SOgBqIy1Ob44tJNVccpQb5XEXAyewTNP7l2GGQ39jB97T6BLhzoFPwg5uO9afGTm5ZaDX+5CILms4JjiEp0DcDyjwHDGch6Pv+hcPN35HIxN83sE7oPEeIsvEwsR/P4QhQlijr66ITapHcUT0g== X-YMail-OSG: AvuMIeYVM1mtwTUGS3kovGYGyJ.0g5LjaCsB8MPfPOKTh_kYJqo3HolQCHd.PAd eboLc8X4QtGBL4985xgZBmS4mfLq8iRaqFZX_Y_IYgwqG0aknYh19Sqd53Gxz1tAdpshusT5_9Pm 5RUXbJaW.PsuOLtOmIuxMa1dbcRswmYNpiIGm4jHOlhwcuXOvlQEu5.Ip6DJwJaE2RdMyFRltUIg CDWq5PEpTL5.4uRd0TGQsO.5nXA2yUKE99EvS81YFCwAryc7O6bPyEsWmtLRLraq2M5El3m4N1ou xDzEg2vE2Ohd4Nk0p1OO8ZllhMY09gmT8l6gZjmfLdF_Ty6CVZ2A41tKE0PO1NzN4vEpB1xQOOgh bEgEK1UOQkh1X3Za0foFXVr806AHNb8n6fWAPQN88qn1cVaE82lkGEdb6HsZ.Y65wH6RWq7HfGcC ooYRN6mBac87n.DtYukfNhKxsjHBDjQ3T0XdPN0IeYBttSLqbCtZOulPN2KCQOT1EgkC0bjXWR9Y yF5bfGCndsmcUh_Y3nncYyD9eoQqSHZXiEIzk5I776L1B5jzGjZej.buSPLq99rg- Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.ir2.yahoo.com with HTTP; Wed, 17 May 2017 21:09:13 +0000 Date: Wed, 17 May 2017 21:05:11 +0000 (UTC) To: "qemu-devel@nongnu.org" Message-ID: <218478942.134698.1495055111655@mail.yahoo.com> MIME-Version: 1.0 References: <218478942.134698.1495055111655.ref@mail.yahoo.com> X-Mailer: WebService/1.1.9679 YahooMailNeo Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 77.238.176.55 Subject: [Qemu-devel] [PATCH] Add BCM2835 devices to Arm hardware. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: John Bradley via Qemu-devel From: "Denis V. Lunev\" via" Reply-To: John Bradley Cc: John Bradley , Laurent Vivier , Peter Maydell , Geert Martin Ijewski , =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= , "qemu-website@weilnetz.de" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From 0b39a04030d5a2cea4fcd2159d365580ca155b78 Mon Sep 17 00:00:00 2001 From: John Bradley Date: Wed, 17 May 2017 18:57:21 +0100 Subject: [PATCH] Add BCM2835 devices to Arm hardware. Signed-off-by: John Bradley --- hw/arm/bcm2835.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) John Bradley Tel: 07896 839635 Skype: flypie125 125B Grove Street Edge Hill Liverpool L7 7AF diff --git a/hw/arm/bcm2835.c b/hw/arm/bcm2835.c new file mode 100644 index 0000000000..e5744c1620 --- /dev/null +++ b/hw/arm/bcm2835.c @@ -0,0 +1,114 @@ +/* + * Raspberry Pi emulation (c) 2012 Gregory Estrade + * Upstreaming code cleanup [including bcm2835_*] (c) 2013 Jan Petrous + * + * Rasperry Pi 2 emulation and refactoring Copyright (c) 2015, Microsoft + * Written by Andrew Baumann + * + * This code is licensed under the GNU GPLv2 and later. + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "hw/arm/bcm2835.h" +#include "hw/arm/raspi_platform.h" +#include "hw/sysbus.h" +#include "exec/address-spaces.h" + + +/* Peripheral base address seen by the CPU */ +#define BCM2835_PERI_BASE 0x20000000 + +static void bcm2835_init(Object *obj) +{ + BCM2835State *s = BCM2835(obj); + + object_initialize(&s->cpus[0], sizeof(s->cpus[0]), "arm1176-" TYPE_ARM_CPU); + object_property_add_child(obj, "cpu", OBJECT(&s->cpus[0]), &error_abort); + + object_initialize(&s->peripherals, sizeof(s->peripherals), + TYPE_BCM2835_PERIPHERALS); + object_property_add_child(obj, "peripherals", OBJECT(&s->peripherals), + &error_abort); + object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals), + "board-rev", &error_abort); + object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), + "vcram-size", &error_abort); + qdev_set_parent_bus(DEVICE(&s->peripherals), sysbus_get_default()); +} + +static void bcm2835_realize(DeviceState *dev, Error **errp) +{ + BCM2835State *s = BCM2835(dev); + Object *obj; + Error *err = NULL; + + /* common peripherals from bcm2835 */ + obj = object_property_get_link(OBJECT(dev), "ram", &err); + if (obj == NULL) { + error_setg(errp, "%s: required ram link not found: %s", + __func__, error_get_pretty(err)); + return; + } + + object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj, &err); + if (err) { + error_propagate(errp, err); + return; + } + + object_property_set_bool(OBJECT(&s->peripherals), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->peripherals), + "sd-bus", &err); + if (err) { + error_propagate(errp, err); + return; + } + + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0, + BCM2835_PERI_BASE, 1); + + object_property_set_bool(OBJECT(&s->cpus[0]), true, "realized", &err); + if (err) { + error_report_err(err); + exit(1); + } + + sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0, + qdev_get_gpio_in(DEVICE(&s->cpus[0]), ARM_CPU_IRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, + qdev_get_gpio_in(DEVICE(&s->cpus[0]), ARM_CPU_FIQ)); +} + +static Property bcm2835_props[] = { + DEFINE_PROP_UINT32("enabled-cpus", BCM2835State, enabled_cpus, BCM2835_NCPUS), + DEFINE_PROP_END_OF_LIST() +}; + +static void bcm2835_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + dc->props = bcm2835_props; + dc->realize = bcm2835_realize; +} + +static const TypeInfo bcm2835_type_info = { + .name = TYPE_BCM2835, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(BCM2835State), + .instance_init = bcm2835_init, + .class_init = bcm2835_class_init, +}; + +static void bcm2835_register_types(void) +{ + type_register_static(&bcm2835_type_info); +} + +type_init(bcm2835_register_types)