From patchwork Wed Aug 14 07:14:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 11093403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1CFB1395 for ; Wed, 14 Aug 2019 07:18:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2B292873E for ; Wed, 14 Aug 2019 07:18:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1FFC28748; Wed, 14 Aug 2019 07:18:30 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B4202873E for ; Wed, 14 Aug 2019 07:18:30 +0000 (UTC) Received: from localhost ([::1]:57714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hxnYD-0006AD-Ju for patchwork-qemu-devel@patchwork.kernel.org; Wed, 14 Aug 2019 03:18:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59362) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hxnUk-0002UF-Mi for qemu-devel@nongnu.org; Wed, 14 Aug 2019 03:14:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxnUj-0008Ev-IJ for qemu-devel@nongnu.org; Wed, 14 Aug 2019 03:14:54 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:41320) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hxnUg-0008DH-UO; Wed, 14 Aug 2019 03:14:51 -0400 Received: by mail-pg1-x543.google.com with SMTP id x15so42279496pgg.8; Wed, 14 Aug 2019 00:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lBGGTqXH/nhd6kXXGRtBAmp2V+9X81H4xeVXysgM8vc=; b=JcOFuN/n3cjUBwhdgeNQBJ1ddYXpMruTVteMswqBicFRuP8yNIbTIQLlx4iMLZ9C7z HfxjXSlx9629gP+XV+lWdPpmy/5aIfEIIssryPwHwKsAcpImaE+89JuiNXk9HyYek7J7 GLa+AxZ2UkjBNyRHAAtgzOSe/QZpzX6SQjW/8gi2dYzGbL7AcAHyRhfGiVkMDPK84eF+ gPjaVqTwjNowcQloQ/3w0RfNmIF2rOO6AeOTqSippNt+VZ3Um5jqRR4Rq9OPr/V0rggC kGlxj4L6PgN3iNwOBcMDjC3CuYqd3z6iPLGxRk3yN9RCSZQxe8uMGVcBEa9/52Z7jDQb BVdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lBGGTqXH/nhd6kXXGRtBAmp2V+9X81H4xeVXysgM8vc=; b=Zax6kg45G/poqX2+A7CY/UjaUhM5H3U6azTIr7r7+VmZdQtnZg+HNBj/uxeoNUuDU8 TZe/FMAsEX+z0PuSKO1iVEWJvx97e9CIMWk5hVor1kw4sIVQn8dZTOKlt94JqHT2WeZL wU3AOH/G9wqXdOYtjnw7aqypn26MsBQpTCDTdYx6z2UlyYQM1Dd95cosGgfTjrYp3oJL pSLHCMiYmUqFMKG7iMZrgQg5QhIAFT9pku8p2IjgyX0EA8+3XOmyApxIfeUgRaq42AhF T6UNs7h1u1rR8UWuSThAVj5/ac9qt86WA/16q6Neh6jgxu1VIyPb9qRyt6nbw7tVrwEk oTig== X-Gm-Message-State: APjAAAVHHNJL44DkAz6+fO4hN/dC8fwRZMZWnqP54KCxMk5fCYzVvZE/ 86U8qDArrUN5gYhG6SxAfe4= X-Google-Smtp-Source: APXvYqyY/U5rU/kObCQqACiW9x8q2meaCtvmWeHs1uZ+YsYbIQPuLcs6IefUwED2PD7uk9yELlrBxQ== X-Received: by 2002:a63:6c4:: with SMTP id 187mr35007414pgg.401.1565766889990; Wed, 14 Aug 2019 00:14:49 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id j187sm20086474pfg.178.2019.08.14.00.14.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 14 Aug 2019 00:14:49 -0700 (PDT) From: Rashmica Gupta To: peter.maydell@linaro.org, qemu-arm@nongnu.org Date: Wed, 14 Aug 2019 17:14:32 +1000 Message-Id: <20190814071433.22243-3-rashmica.g@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190814071433.22243-1-rashmica.g@gmail.com> References: <20190814071433.22243-1-rashmica.g@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v4 2/3] aspeed: add a GPIO controller to the SoC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@aj.id.au, qemu-devel@nongnu.org, aik@ozlabs.ru, joel@jms.id.au, Rashmica Gupta , clg@kaod.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Rashmica Gupta --- hw/arm/aspeed_soc.c | 17 +++++++++++++++++ include/hw/arm/aspeed_soc.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index c6fb3700f2..ff422c8ad1 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -124,6 +124,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .spis_num = 1, .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, + .gpio_typename = "aspeed.gpio-ast2400", .wdts_num = 2, .irqmap = aspeed_soc_ast2400_irqmap, .memmap = aspeed_soc_ast2400_memmap, @@ -136,6 +137,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .spis_num = 1, .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, + .gpio_typename = "aspeed.gpio-ast2400", .wdts_num = 2, .irqmap = aspeed_soc_ast2400_irqmap, .memmap = aspeed_soc_ast2400_memmap, @@ -148,6 +150,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .spis_num = 1, .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, + .gpio_typename = "aspeed.gpio-ast2400", .wdts_num = 2, .irqmap = aspeed_soc_ast2400_irqmap, .memmap = aspeed_soc_ast2400_memmap, @@ -160,6 +163,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .spis_num = 2, .fmc_typename = "aspeed.smc.ast2500-fmc", .spi_typename = aspeed_soc_ast2500_typenames, + .gpio_typename = "aspeed.gpio-ast2500", .wdts_num = 3, .irqmap = aspeed_soc_ast2500_irqmap, .memmap = aspeed_soc_ast2500_memmap, @@ -246,6 +250,9 @@ static void aspeed_soc_init(Object *obj) sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma), TYPE_ASPEED_XDMA); + + sysbus_init_child_obj(obj, "gpio", OBJECT(&s->gpio), sizeof(s->gpio), + sc->info->gpio_typename); } static void aspeed_soc_realize(DeviceState *dev, Error **errp) @@ -425,6 +432,16 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) sc->info->memmap[ASPEED_XDMA]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, aspeed_soc_get_irq(s, ASPEED_XDMA)); + + /* GPIO */ + object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->info->memmap[ASPEED_GPIO]); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, + aspeed_soc_get_irq(s, ASPEED_GPIO)); } static Property aspeed_soc_properties[] = { DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index cef605ad6b..fa04abddd8 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -22,6 +22,7 @@ #include "hw/ssi/aspeed_smc.h" #include "hw/watchdog/wdt_aspeed.h" #include "hw/net/ftgmac100.h" +#include "hw/gpio/aspeed_gpio.h" #define ASPEED_SPIS_NUM 2 #define ASPEED_WDTS_NUM 3 @@ -47,6 +48,7 @@ typedef struct AspeedSoCState { AspeedSDMCState sdmc; AspeedWDTState wdt[ASPEED_WDTS_NUM]; FTGMAC100State ftgmac100[ASPEED_MACS_NUM]; + AspeedGPIOState gpio; } AspeedSoCState; #define TYPE_ASPEED_SOC "aspeed-soc" @@ -60,6 +62,7 @@ typedef struct AspeedSoCInfo { int spis_num; const char *fmc_typename; const char **spi_typename; + const char *gpio_typename; int wdts_num; const int *irqmap; const hwaddr *memmap;