From patchwork Thu Jun 1 17:10:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 100964 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp861405obc; Thu, 1 Jun 2017 10:21:49 -0700 (PDT) X-Received: by 10.200.58.130 with SMTP id x2mr3302441qte.110.1496337709860; Thu, 01 Jun 2017 10:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496337709; cv=none; d=google.com; s=arc-20160816; b=0kB6sijmrexlAuVnvpWUcwBFR758TpAmqgB1wvEytoDc/wer2CvUSNIIdr4ZroEYUG oGAgntTqTu7Km+wKurEWSwsShD8uPkaQ3rq5Whd9qS/5pjtyHj5X5kBaX+iAO6kuKh5p 0125AKCGL7akzS93JvJRJLUwl06gn4op2WajHpifUlc3c7zndayfxYApEATCtG26QAzc qx/QGV1U1fXYJzYTx/Yd0xjBX2UsHWDPGKi02LLqt8KdwpqwtiRlysegfa0dq6UthTCk ibFyKASoJq0E//rUbIMW21uADlAczBcQT+ZKrD8Ncd2FgUo8qQ74luiHgfQstnZR5Mtq 3tEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=N39leYXVFaTQkXPWSdl+OUj0DLKoCy+XkRR/dpHgseE=; b=mmnRxXuxXiCZpORGlMq6ErJMrCdirVqkA93rn4VU3DD47iKwsupnDgmNHAE1Klon2w YpUUAQzWw4UQEuSMUhxU5qqJAu6zeFySN2e/+7sxXtGpZxbcijfAIpXn8lFfxd+BxG2N SJqFZE8rSFAaCe2Saxr29xUjCsbARR5GVvNuRZ9Pj/fUNpItYejIeiZ5JmnJcLnb8/3p FpUBPH0MQyUZ/AerFW8LRPRH91t8a4WBqGxY1diHKTbT1WW8w1Sa3we1V352tYM+4mwu /rdiJF75AIJH3Fxq95C3sa89t1XBML5H4lX5rzt5Qx5PO5sIvFyngNFmmcGl5Gt3mp0p P5bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b205si3933758qkg.149.2017.06.01.10.21.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Jun 2017 10:21:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGTn9-0002GA-7K for patch@linaro.org; Thu, 01 Jun 2017 13:21:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGTcc-0001B8-CI for qemu-devel@nongnu.org; Thu, 01 Jun 2017 13:10:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGTcb-0006Fq-2L for qemu-devel@nongnu.org; Thu, 01 Jun 2017 13:10:54 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37150) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGTca-0006F8-RW for qemu-devel@nongnu.org; Thu, 01 Jun 2017 13:10:53 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dGTcZ-0007Up-SW for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:10:51 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 1 Jun 2017 18:10:31 +0100 Message-Id: <1496337035-30213-24-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496337035-30213-1-git-send-email-peter.maydell@linaro.org> References: <1496337035-30213-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 23/27] aspeed: add some I2C devices to the Aspeed machines 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Cédric Le Goater Let's add an RTC to the palmetto BMC and a LM75 temperature sensor to the AST2500 EVB to start with. Signed-off-by: Cédric Le Goater Message-id: 1494827476-1487-5-git-send-email-clg@kaod.org Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell --- hw/arm/aspeed.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.7.4 diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 283c038..e824ea8 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -39,6 +39,7 @@ typedef struct AspeedBoardConfig { const char *fmc_model; const char *spi_model; uint32_t num_cs; + void (*i2c_init)(AspeedBoardState *bmc); } AspeedBoardConfig; enum { @@ -82,6 +83,9 @@ enum { SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) +static void palmetto_bmc_i2c_init(AspeedBoardState *bmc); +static void ast2500_evb_i2c_init(AspeedBoardState *bmc); + static const AspeedBoardConfig aspeed_boards[] = { [PALMETTO_BMC] = { .soc_name = "ast2400-a1", @@ -89,6 +93,7 @@ static const AspeedBoardConfig aspeed_boards[] = { .fmc_model = "n25q256a", .spi_model = "mx25l25635e", .num_cs = 1, + .i2c_init = palmetto_bmc_i2c_init, }, [AST2500_EVB] = { .soc_name = "ast2500-a1", @@ -96,6 +101,7 @@ static const AspeedBoardConfig aspeed_boards[] = { .fmc_model = "n25q256a", .spi_model = "mx25l25635e", .num_cs = 1, + .i2c_init = ast2500_evb_i2c_init, }, [ROMULUS_BMC] = { .soc_name = "ast2500-a1", @@ -223,9 +229,22 @@ static void aspeed_board_init(MachineState *machine, aspeed_board_binfo.ram_size = ram_size; aspeed_board_binfo.loader_start = sc->info->sdram_base; + if (cfg->i2c_init) { + cfg->i2c_init(bmc); + } + arm_load_kernel(ARM_CPU(first_cpu), &aspeed_board_binfo); } +static void palmetto_bmc_i2c_init(AspeedBoardState *bmc) +{ + AspeedSoCState *soc = &bmc->soc; + + /* The palmetto platform expects a ds3231 RTC but a ds1338 is + * enough to provide basic RTC features. Alarms will be missing */ + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68); +} + static void palmetto_bmc_init(MachineState *machine) { aspeed_board_init(machine, &aspeed_boards[PALMETTO_BMC]); @@ -250,6 +269,14 @@ static const TypeInfo palmetto_bmc_type = { .class_init = palmetto_bmc_class_init, }; +static void ast2500_evb_i2c_init(AspeedBoardState *bmc) +{ + AspeedSoCState *soc = &bmc->soc; + + /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d); +} + static void ast2500_evb_init(MachineState *machine) { aspeed_board_init(machine, &aspeed_boards[AST2500_EVB]);