From patchwork Fri Jan 29 00:58:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)\" via" X-Patchwork-Id: 12054861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC65FC433DB for ; Fri, 29 Jan 2021 01:05:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E30064DED for ; Fri, 29 Jan 2021 01:05:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E30064DED Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=nongnu.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5IEQ-0004Q9-DB for qemu-devel@archiver.kernel.org; Thu, 28 Jan 2021 20:05:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3C18TYAgKCh4QOB4INMBAIIAF8.6IGK8GO-78P8FHIHAHO.ILA@flex--wuhaotsh.bounces.google.com>) id 1l5ICs-00032K-V7 for qemu-devel@nongnu.org; Thu, 28 Jan 2021 20:04:14 -0500 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]:41933) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3C18TYAgKCh4QOB4INMBAIIAF8.6IGK8GO-78P8FHIHAHO.ILA@flex--wuhaotsh.bounces.google.com>) id 1l5ICr-0004W9-Ek for qemu-devel@nongnu.org; Thu, 28 Jan 2021 20:04:14 -0500 Received: by mail-pj1-x104a.google.com with SMTP id o3so4621082pju.6 for ; Thu, 28 Jan 2021 17:04:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=ELaBYRMM2IbotDCIKyZuXyvpnGXxuQRotS+jnVcGgmk=; b=HRCvWaTXgEvzg559vIeY9WNgVG9kk+zzl5IXFom0uQQwXHbONTVsqbRRLGCVHBTGhU CUL3H/Buhk0LRyckH/GKyIJCoAVLA63/YBKw3G+prWDJxsaK3fywZkqRM3gMipTd1UyU HmCj3yDxTM9ETyXarFXLevgY3H0tgTkCltYOb4kR2vWswE05aK+VKfxQQSSKfauD8kgS Khn/6aqXDtgJWKhRB+oDOlOja8jzuwWznDpX8zWAECoRyB/F0Ed4bbMCCjM5FFksGX9/ /+wvRJpWYSkwW4WDU41h4T/QOaa516riIjjgTb/xCp73k2LNTODdJ03Fd778aYReZP4o Ar8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ELaBYRMM2IbotDCIKyZuXyvpnGXxuQRotS+jnVcGgmk=; b=opckq6X+6IBQZwo7nY0Ke5EimLjxTam4Snz1pxzr11U9X2nOI+KhjkO/XYBb7CtL3l RP7mDmtTx+B6DzPe7uJiCX8janhLoLyyyN1H+9eK/ND6mH/YSdaeaE7lVxaheFJ+ysoz bQYr15K9CTKQfu8lKM2pGGlw0nsx6p6E9Mz7K7C1JDAM7IIoRNJwXx1TZChpf+zJB4LQ uTgU97PWDh07T3gtDqGTFVDTwpsbMvU2fZSRrznNcYyh2Rqy+VTrW5kCy8oRTeT97M+a stUcMxzLuNDZNaJhTgzXyDKIoy4hV0qF8p+UTcxOgmMPIpRWnqGuxB3MpphGL/cP+Thu Yq6Q== X-Gm-Message-State: AOAM53210F98IEaO+UhED8NqnQWNuaUxRWTGgQ+v9uVos1P5XfMJEyan k7/KorydoJ8vlaOjA16YZ3nMh/9+THKenA== X-Google-Smtp-Source: ABdhPJwFkNUN7HOClSDQdQ2F4yv8IdEinemvAlG/iu7lciK4ZW9rxJw6d4c4792ccwYmFgz4jErteU4BTfHIVQ== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:10:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:90a:4209:: with SMTP id o9mr2049452pjg.75.1611882251532; Thu, 28 Jan 2021 17:04:11 -0800 (PST) Date: Thu, 28 Jan 2021 16:58:42 -0800 In-Reply-To: <20210129005845.416272-1-wuhaotsh@google.com> Message-Id: <20210129005845.416272-4-wuhaotsh@google.com> Mime-Version: 1.0 References: <20210129005845.416272-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH v2 3/6] hw/arm: Add I2C sensors for NPCM750 eval board To: peter.maydell@linaro.org Received-SPF: pass client-ip=2607:f8b0:4864:20::104a; envelope-from=3C18TYAgKCh4QOB4INMBAIIAF8.6IGK8GO-78P8FHIHAHO.ILA@flex--wuhaotsh.bounces.google.com; helo=mail-pj1-x104a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action 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: cminyard@mvista.com, venture@google.com, hskinnemoen@google.com, qemu-devel@nongnu.org, wuhaotsh@google.com, kfting@nuvoton.com, qemu-arm@nongnu.org, Avi.Fishman@nuvoton.com, dje@google.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: Hao Wu X-Patchwork-Original-From: wuhaotsh--- via From: "Zhijian Li (Fujitsu)\" via" Add I2C temperature sensors for NPCM750 eval board. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu Reviewed-by: Peter Maydell --- hw/arm/npcm7xx_boards.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c index 3fdd5cab01..47a215bd01 100644 --- a/hw/arm/npcm7xx_boards.c +++ b/hw/arm/npcm7xx_boards.c @@ -98,6 +98,24 @@ static NPCM7xxState *npcm7xx_create_soc(MachineState *machine, return NPCM7XX(obj); } +static I2CBus *npcm7xx_i2c_get_bus(NPCM7xxState *soc, uint32_t num) +{ + g_assert(num < ARRAY_SIZE(soc->smbus)); + return I2C_BUS(qdev_get_child_bus(DEVICE(&soc->smbus[num]), "i2c-bus")); +} + +static void npcm750_evb_i2c_init(NPCM7xxState *soc) +{ + /* lm75 temperature sensor on SVB, tmp105 is compatible */ + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 0), "tmp105", 0x48); + /* lm75 temperature sensor on EB, tmp105 is compatible */ + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), "tmp105", 0x48); + /* tmp100 temperature sensor on EB, tmp105 is compatible */ + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 2), "tmp105", 0x48); + /* tmp100 temperature sensor on SVB, tmp105 is compatible */ + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 6), "tmp105", 0x48); +} + static void npcm750_evb_init(MachineState *machine) { NPCM7xxState *soc; @@ -108,6 +126,7 @@ static void npcm750_evb_init(MachineState *machine) npcm7xx_load_bootrom(machine, soc); npcm7xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, 0)); + npcm750_evb_i2c_init(soc); npcm7xx_load_kernel(machine, soc); }