From patchwork Wed Jan 11 08:50:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 641250 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp3139903pvb; Wed, 11 Jan 2023 00:52:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXtPwDtjYXaQCtbZqjvj2kP/hyg+nvYgI3AzlGF3jrLcIoJjep9TLKadXcD9vdsOeG2s55xA X-Received: by 2002:ac8:138c:0:b0:3a5:758d:8f5e with SMTP id h12-20020ac8138c000000b003a5758d8f5emr8813237qtj.19.1673427165090; Wed, 11 Jan 2023 00:52:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673427165; cv=none; d=google.com; s=arc-20160816; b=AIqpfhV1PYACaLDn4Gy+08/bGYdoMW+CBmFGka/r04vrrJ6yh5AF5WqHElSESJ0lbp baOoK/H39Pp9VVuQ4o9/OZoFS4PoquR6HilCZ7tF3nQZdUXBX9mG1kv4feuxUXqzvVge tr28wvQvcXxkFzDd4ejM+xUIYsQLRe0Q/WdXJYkiQH5Xmw5gaoPd9CxNLSTt6av5hY+W t+WHT93DzvELje/g/DM28B6eRqZU6NSrTSacPQdzfCbKgOvZmqUjhUm5bG2kyaI+wPOg cjRbmrYueVUJ53NmOcq1UKS4xra08GA4i1p2vV7K3FZLbcVD46BILAGPgsd3K2gU09oW VrTg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rqfudLgvWami2CjesLmeGlPtQtwdVZ+Jj9zyr+J7ES0=; b=RDwrHygxxImeBCjbvOJlXo2FPmhiefUfQy28dQYVuYqr6iGhU3ssSUs7d3VbTum7bu 6UYtEifhGhkQ7vOFX+tf5+mMqfqinZgz0xR8l3bkk2IDh5lNgLycwfuMx6DgUtOGaUcU VvVCSYR8fHuG3tXV3X6sNgAdYBiv8r+Uz+K6wJlyPWPcgfiM1qkjq48mvK7d1XjW1ULC ijQhQeWkrW8VtzINnYUWXXoKXn+AQ9BCiOX+akL92Bcj5VLFTQFZSbe13tkBLV9xxOw6 QcC30m6yoCsdjJ2Gu4ZJuS+OebcM9UPU3qt0hBOh9olqyv4Rj2Pc49JpGvO2JtPlV9Zc XB+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jczFMNTW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTP id y23-20020a05620a0e1700b006f41f08600dsi7685781qkm.670.2023.01.11.00.52.44 for ; Wed, 11 Jan 2023 00:52:45 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jczFMNTW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFWoa-0003Ex-Rx; Wed, 11 Jan 2023 03:50:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFWoV-0003AS-JR for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:28 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFWoT-0007bg-7f for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:27 -0500 Received: by mail-wr1-x434.google.com with SMTP id j7so9288911wrn.9 for ; Wed, 11 Jan 2023 00:50:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rqfudLgvWami2CjesLmeGlPtQtwdVZ+Jj9zyr+J7ES0=; b=jczFMNTWQboy88S4lf0GnHBvBod3ophmlNQm+X0fkQYN7Yokkl3HfouvXkX31GbR6+ MJHIeWdz/SlJq1NJ6q4pW1Bze91qgjXOAz0rbizPv+dOB8ZSLRTCTryqugLb4bMb2K2H ECuv+f9ZxNzWY+xv8H2Dhl9tev8bTIEmhT6TW2BuZLEUK5s2aF2jSv16PdlAwKXXuwFR IugBfUVMwKurlWsV85+PhOjU5boR+ZwP9L1bTRYuo78xJgFt5/NnwWKXN+rjnvqe4Z+t qyPFm9ZAkd2XOmM1EOA0ZxPBG+B/wTkaAhn/JlAYqAnhjHRNWhDGymseT1uDmoM0tfpd 3xGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rqfudLgvWami2CjesLmeGlPtQtwdVZ+Jj9zyr+J7ES0=; b=6ZXN8yRvNKqFWCMn6kkIzZtVxfsXijG9mgt0qd9c5BHQGCHNGxE//CdtTqpdWLZRNR ldyGW5foiCiTeDGCwgaXnho4jiVcF8Ga1aSd0Ecu1fFdg+FP+DAOV9s2ZNkAIqlkLFdP ZBGyr+UHeingvowzRKeb1rUh0KQVmS9PhchP64gWGyXSVDznG6CZSLTUlrRTbH9R58hI y4BXDm4QtiALJRByRsDDRTotasxL1ISPL9mKPtv5NamSJXUqSFlwRiGYyOBIfRdhS0+Q TGUhi1QetCzw0AVkz/IaKrny5ghFtPFtOI/WtIS8+oY/N1GqgtsPuu6/aJqXYB2QxFgN FCEQ== X-Gm-Message-State: AFqh2krLKdcexuCjBC/lvy1qMF0nY8dXMARrXrvNxPSkOPbjyXVg21bf npC0lr9aD34Al3LEszFE3ZC7ZHCWoBL26yiy X-Received: by 2002:a05:6000:1e04:b0:273:e385:1a89 with SMTP id bj4-20020a0560001e0400b00273e3851a89mr43507356wrb.67.1673427023360; Wed, 11 Jan 2023 00:50:23 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id j17-20020adff011000000b002a64e575b4esm13421054wro.47.2023.01.11.00.50.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Jan 2023 00:50:22 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 1/5] hw/i2c/bitbang_i2c: Define TYPE_GPIO_I2C in public header Date: Wed, 11 Jan 2023 09:50:12 +0100 Message-Id: <20230111085016.44551-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230111085016.44551-1-philmd@linaro.org> References: <20230111085016.44551-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org Define TYPE_GPIO_I2C in the public "hw/i2c/bitbang_i2c.h" header and use it in hw/arm/musicpal.c. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/arm/musicpal.c | 3 ++- hw/i2c/bitbang_i2c.c | 1 - include/hw/i2c/bitbang_i2c.h | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index b65c020115..813232682f 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -25,6 +25,7 @@ #include "hw/block/flash.h" #include "ui/console.h" #include "hw/i2c/i2c.h" +#include "hw/i2c/bitbang_i2c.h" #include "hw/irq.h" #include "hw/or-irq.h" #include "hw/audio/wm8750.h" @@ -1300,7 +1301,7 @@ static void musicpal_init(MachineState *machine) dev = sysbus_create_simple(TYPE_MUSICPAL_GPIO, MP_GPIO_BASE, qdev_get_gpio_in(pic, MP_GPIO_IRQ)); - i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL); + i2c_dev = sysbus_create_simple(TYPE_GPIO_I2C, -1, NULL); i2c = (I2CBus *)qdev_get_child_bus(i2c_dev, "i2c"); lcd_dev = sysbus_create_simple(TYPE_MUSICPAL_LCD, MP_LCD_BASE, NULL); diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c index e9a0612a04..ac84bf0262 100644 --- a/hw/i2c/bitbang_i2c.c +++ b/hw/i2c/bitbang_i2c.c @@ -162,7 +162,6 @@ void bitbang_i2c_init(bitbang_i2c_interface *s, I2CBus *bus) /* GPIO interface. */ -#define TYPE_GPIO_I2C "gpio_i2c" OBJECT_DECLARE_SIMPLE_TYPE(GPIOI2CState, GPIO_I2C) struct GPIOI2CState { diff --git a/include/hw/i2c/bitbang_i2c.h b/include/hw/i2c/bitbang_i2c.h index 92334e9016..a079e6d70f 100644 --- a/include/hw/i2c/bitbang_i2c.h +++ b/include/hw/i2c/bitbang_i2c.h @@ -3,6 +3,8 @@ #include "hw/i2c/i2c.h" +#define TYPE_GPIO_I2C "gpio_i2c" + typedef struct bitbang_i2c_interface bitbang_i2c_interface; #define BITBANG_I2C_SDA 0 From patchwork Wed Jan 11 08:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 641251 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp3140212pvb; Wed, 11 Jan 2023 00:53:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXtbdVfQlAX7grp1ikzB68eBNy5W0eRs7NV8iGawJpW98WHMqOEFHcdyPT5SUq8P6/7oe8cj X-Received: by 2002:a0c:fe64:0:b0:51e:e977:8b80 with SMTP id b4-20020a0cfe64000000b0051ee9778b80mr88788184qvv.29.1673427229135; Wed, 11 Jan 2023 00:53:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673427229; cv=none; d=google.com; s=arc-20160816; b=Aq610tW5t7yRJTkFn2r9Tfot1DdP+9UjW4cAEVwj6PbHSmb5XxTl+rH/YLP+yjgPad 0zYoeH3sgzJddTsgc5vVaiakgPoe9Q1kB5kJERJsZj/zQK+BeA1oVddtIO/9a4IA85Cm GyAH2Y6bY8+JPxtd2yi4vAF03n5Na421xgGtFoAJkKAAbeEDvfpH8iQHGB/tJFrWGc1P 2htwRg/nOFs4lUo6FW6FTMfIVR/1RuaS21bOPijUZsg1OfJ5UDHOSjrEvf/tmRzO7FOo zwfxpJtvYk3jd3dL4V3acqK83Exg2FuFg3OnhZBC1L+myrJ6TmM0+aicQy8i3JVp3JWk fHtw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QqhX9d7OWrlFhlOYzosdT2uap07wVT4JcGVQZKlWVp8=; b=DixY2yXVtcGaziMAFKzUnLLSnB24dmeAQw3AOClJOO10sWCncdtoy6U2vGQlgUOayK tFdNt26MBMIMsrDhtM6f8SMaBnIpXHL3Geb5BseQ+R1QrTpxq5GnaxP8fy1ZWNcAVifG IzW3BM+zviHG/ST3hhYAIiMTZ86PsXvRkIzyYtEUy0WcmP/7VLHwYn1Qw+XjP/I4g3Vx Xfmtk3ZzLvQuRdR9LEs4kZl/CT71JnK1qI3OLOWqyifAT4+Jzt2oQDf25fW30EtGE4zN LYlDmWAi+MejFiE/93FcSg+rfCtBOxt1tHmUmW6JVMQql+fRMTNph+U+eXSPLULPCmtK O7sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Qs+/e/za"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTP id k14-20020ad45bee000000b004c6c476f0b6si7731697qvc.124.2023.01.11.00.53.49 for ; Wed, 11 Jan 2023 00:53:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Qs+/e/za"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFWos-0003RP-Sc; Wed, 11 Jan 2023 03:50:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFWoa-0003FF-GT for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:32 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFWoY-0007cL-1X for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:32 -0500 Received: by mail-wm1-x32f.google.com with SMTP id l26so10571224wme.5 for ; Wed, 11 Jan 2023 00:50:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QqhX9d7OWrlFhlOYzosdT2uap07wVT4JcGVQZKlWVp8=; b=Qs+/e/zaOY/tJH6z6W0tOYMKOhvkFd9y6V+YqgPBZonuTIpeatoplaVdgk5DpTYx9R p59vu8uTu/MlpaznSOIUN6F7I5ksUMELsLmLRzfyJfM1oyvhVvbwnYGekI/VvFt7wolc fyxcMxjHDbV1P+qk1qyfsIGbb0EYr/8b4qQ4C18KNNqpVGqnBo7TEX++7rsVT9btOGNI LjFkGF4cpvrG709+IKOvq+QhoktGMdFjkIzGOJRY6apnmi/5NreOgSrPxnuiq6fBvAic oPxOTCv3Shv0rlRZJCqQ1kRG6VK9uAL7pt9rqfY4mKw+wdEe6uUGjNC0v1VOeUmZu6ha UQTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QqhX9d7OWrlFhlOYzosdT2uap07wVT4JcGVQZKlWVp8=; b=JIoiIxxbtfZZy2xlUxSJnGQ4sfWgk/zNiqp2dMJ51k1sJBJtWRpLUL5V+iKQrNo7Ab AizQ8hcijVThPUuCmLdaxt4Ujb+KW7ztzhNP6kx9aPOJTXEvRgFTL8GyP2MPnRzG90AI Q52pTL48gVbFbMylb/Vm+nMoF2yMR/AHtzw8k9Odbnl4SgKHgrKgwPDrFWSenq50RDdN 5haCqVwQb0YqXIbsSeF2kjW834lLi0LVdUQsXvymPZTkL8PCvEJSne4NV+uS3PO8sWQL b4hIYkKgIMsi38eAn+dsBQR17op2DcADvwRhArwc8C+XHkv++Om2p5gcIKvCLPLNB94h lsqg== X-Gm-Message-State: AFqh2krdXoBY0/KpMndGCbYNx2DO8jevJxDYFzpBusKkgTmimJ7lG9B7 VAH7WKMUUOPHOo3KZEcx1kIbxXVr1pdS3/n7 X-Received: by 2002:a05:600c:1da3:b0:3d3:4dbc:75ef with SMTP id p35-20020a05600c1da300b003d34dbc75efmr51264789wms.17.1673427028123; Wed, 11 Jan 2023 00:50:28 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c511300b003d9862ec435sm5963864wms.20.2023.01.11.00.50.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Jan 2023 00:50:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 2/5] hw/i2c/bitbang_i2c: Remove unused dummy MemoryRegion Date: Wed, 11 Jan 2023 09:50:13 +0100 Message-Id: <20230111085016.44551-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230111085016.44551-1-philmd@linaro.org> References: <20230111085016.44551-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/i2c/bitbang_i2c.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c index ac84bf0262..e41cb63daa 100644 --- a/hw/i2c/bitbang_i2c.c +++ b/hw/i2c/bitbang_i2c.c @@ -165,9 +165,10 @@ void bitbang_i2c_init(bitbang_i2c_interface *s, I2CBus *bus) OBJECT_DECLARE_SIMPLE_TYPE(GPIOI2CState, GPIO_I2C) struct GPIOI2CState { + /*< private >*/ SysBusDevice parent_obj; + /*< public >*/ - MemoryRegion dummy_iomem; bitbang_i2c_interface bitbang; int last_level; qemu_irq out; @@ -188,12 +189,8 @@ static void gpio_i2c_init(Object *obj) { DeviceState *dev = DEVICE(obj); GPIOI2CState *s = GPIO_I2C(obj); - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); I2CBus *bus; - memory_region_init(&s->dummy_iomem, obj, "gpio_i2c", 0); - sysbus_init_mmio(sbd, &s->dummy_iomem); - bus = i2c_init_bus(dev, "i2c"); bitbang_i2c_init(&s->bitbang, bus); From patchwork Wed Jan 11 08:50:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 641248 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp3139681pvb; Wed, 11 Jan 2023 00:51:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXvT7f4RP/95QUFlmXfoxmsN5lcL/cjKWrcIMohWJXF57661w5x20XNHEpHsp9zoLZUei7xa X-Received: by 2002:a0c:ee43:0:b0:51e:25a4:1122 with SMTP id m3-20020a0cee43000000b0051e25a41122mr99770425qvs.2.1673427116759; Wed, 11 Jan 2023 00:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673427116; cv=none; d=google.com; s=arc-20160816; b=ThQhN1EKz8RGE9enxE8DSkl/MauOlUqvWgudE2sU9bXZ4z+mIv7CA0WCcm9o2zMMYT WC6GPp7p8H4XA8zcSIrZijlzi9mw840c6nA8pmrNUT/KcvgdyWtCnak5GNaMeWUG3h4a uMJCFvIt8xh95jpz+7pxyyRIq1pPgRrls7M3Jm3K9wJUBnBvLkOChKVqXihFzi+QmdYx HwZEUGNvG+BFBG0F5lxTkXDHlkcJPIIa3iZZXbV8vKt7wFU08WknZVbCrJjWqBa4qRci xrBCSLR4QjOIon6dWqJBPff4wHBLn9SYGsdZTX3bL4XzXf83JiZ2ZhRfAjV1j+IaFcVO l/sQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iDnNDu+oMICH4wdH8XoWszonkd1H38BArRChhxQlZUY=; b=JWh14sczm9L2R8qIld6gNlMCuXDMoSOXq+YOoEUjSbS0CBoCS0viZVbDtrK3veMQ8q i7ugSXrEcJBdsVn28MSibWmOMtskbhdNbnotmVZxFB6LQ2JBBGVp0LyJ15Dwdf8N7U/o uVDbX1CKyNwhOLjRjfUZJYg1nLuuUmbi3cXD1XpMOi726pFaU9jXblQKseer2gNjaw/s Y0xa+C34G4jRzoD79JZJiEBQUBPyThTc0uS1g6/xRJLowctupgOGDcrd2YoAPE9+/WHn gEKlfVqFabzuQ+banpkPGzF2v1nNpwwkpzMSGEpFFpNoy49O94ECBWSC75VJw+VakJBV ZNyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pke7i96a; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 7-20020a05621420e700b004c6d74d313dsi7838696qvk.351.2023.01.11.00.51.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jan 2023 00:51:56 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pke7i96a; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFWos-0003Pf-8U; Wed, 11 Jan 2023 03:50:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFWof-0003Gd-7m for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:38 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFWod-0007e7-5A for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:36 -0500 Received: by mail-wm1-x335.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so8981328wma.1 for ; Wed, 11 Jan 2023 00:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iDnNDu+oMICH4wdH8XoWszonkd1H38BArRChhxQlZUY=; b=pke7i96aicODUbCCMtqiAD2ggXYbBh6JXivqZQnOJcDKrpvoEqSo2zJdwGmIvBl5xg yZwHRTWd1YcQeBG+IwX5uOKCEduo52I6In69jv0X3S+YzGAcTVX6D0+Y6dbTU7Ls/ad6 bpGKkwtYpbh5ye2Mel9659WNHyoPyvd2vAe8xzniRJjNwgIaSltGBiE3KpXY5RDlDjA5 VY1uw59ca2BZAylmcBhhjm7nP30hl6mqix6EXJu7RvSjUvSro24XUOI1CW0k7mff1ME0 8rcb7+Im4ceBdlUokHnO+nITYF+LRaqfnoRhvTL+f/HX6yNDRbhZfgyaTg4dMtayr4Ew lxeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iDnNDu+oMICH4wdH8XoWszonkd1H38BArRChhxQlZUY=; b=mIgS7iGkvehZYr/Or5yNNr9OuQndQjvQTo0A/KtaIsaTDowg0M8n+Yjck2bo0gVEc2 o5NbGstY1STtZXVRRfktv3cS3wj8T9YbWXJp1vZOt+t5JpMAxnxDs0G9qd6xSW2baTrX IWRUmSH92tUqa4xxf92VPIwN2W2z/JOeDCL8z4NRvP4LTKfwCsnsYyLzy553uJ4QleFs OllTGq5HkEdJf2u6YTwmi7GfMuOpm3UD7zglNxuOn6G2brica50Y3o3VHztk2a/praJz yu3koGxfIwYa2b+8fAxroTuVXKMnIPMoIoVkBXN0ZU1Kn1sfOPqPg+dg8WHIaEU/C3Lx ThnQ== X-Gm-Message-State: AFqh2koGtTt4U072lngFBzUC8olu4gKRYv0sjyL1OV0x946s37PPUq4P fO3YCzn5potrhH5fug8Go9VZXhzOumJzEgNw X-Received: by 2002:a05:600c:1d25:b0:3d3:50b9:b192 with SMTP id l37-20020a05600c1d2500b003d350b9b192mr61983619wms.18.1673427033020; Wed, 11 Jan 2023 00:50:33 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c511300b003d9862ec435sm5964179wms.20.2023.01.11.00.50.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Jan 2023 00:50:32 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 3/5] hw/i2c/bitbang_i2c: Change state calling bitbang_i2c_set_state() helper Date: Wed, 11 Jan 2023 09:50:14 +0100 Message-Id: <20230111085016.44551-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230111085016.44551-1-philmd@linaro.org> References: <20230111085016.44551-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/i2c/bitbang_i2c.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c index e41cb63daa..bf4b781393 100644 --- a/hw/i2c/bitbang_i2c.c +++ b/hw/i2c/bitbang_i2c.c @@ -26,13 +26,19 @@ do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0) #define DPRINTF(fmt, ...) do {} while(0) #endif +static void bitbang_i2c_set_state(bitbang_i2c_interface *i2c, + bitbang_i2c_state state) +{ + i2c->state = state; +} + static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c) { DPRINTF("STOP\n"); if (i2c->current_addr >= 0) i2c_end_transfer(i2c->bus); i2c->current_addr = -1; - i2c->state = STOPPED; + bitbang_i2c_set_state(i2c, STOPPED); } /* Set device data pin. */ @@ -69,7 +75,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) if (level == 0) { DPRINTF("START\n"); /* START condition. */ - i2c->state = SENDING_BIT7; + bitbang_i2c_set_state(i2c, SENDING_BIT7); i2c->current_addr = -1; } else { /* STOP condition. */ @@ -96,7 +102,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) case SENDING_BIT7 ... SENDING_BIT0: i2c->buffer = (i2c->buffer << 1) | data; /* will end up in WAITING_FOR_ACK */ - i2c->state++; + bitbang_i2c_set_state(i2c, i2c->state + 1); return bitbang_i2c_ret(i2c, 1); case WAITING_FOR_ACK: @@ -117,13 +123,14 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) * device we were sending to decided to NACK us). */ DPRINTF("Got NACK\n"); + bitbang_i2c_set_state(i2c, SENT_NACK); bitbang_i2c_enter_stop(i2c); return bitbang_i2c_ret(i2c, 1); } if (i2c->current_addr & 1) { - i2c->state = RECEIVING_BIT7; + bitbang_i2c_set_state(i2c, RECEIVING_BIT7); } else { - i2c->state = SENDING_BIT7; + bitbang_i2c_set_state(i2c, SENDING_BIT7); } return bitbang_i2c_ret(i2c, 0); } @@ -134,18 +141,18 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) case RECEIVING_BIT6 ... RECEIVING_BIT0: data = i2c->buffer >> 7; /* will end up in SENDING_ACK */ - i2c->state++; + bitbang_i2c_set_state(i2c, i2c->state + 1); i2c->buffer <<= 1; return bitbang_i2c_ret(i2c, data); case SENDING_ACK: - i2c->state = RECEIVING_BIT7; if (data != 0) { DPRINTF("NACKED\n"); - i2c->state = SENT_NACK; + bitbang_i2c_set_state(i2c, SENT_NACK); i2c_nack(i2c->bus); } else { DPRINTF("ACKED\n"); + bitbang_i2c_set_state(i2c, RECEIVING_BIT7); } return bitbang_i2c_ret(i2c, 1); } From patchwork Wed Jan 11 08:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 641252 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp3140635pvb; Wed, 11 Jan 2023 00:55:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXvwlZ1z+WNkLX4gTAGzq2WSNFZMHFyG6HrcsjDxt4UGNpba2Ruw4SaC9ue0+npg4Wc3+FFp X-Received: by 2002:a05:6214:5616:b0:531:ab19:4193 with SMTP id mg22-20020a056214561600b00531ab194193mr59182788qvb.2.1673427318189; Wed, 11 Jan 2023 00:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673427318; cv=none; d=google.com; s=arc-20160816; b=VdIGzi+7Ntmm+IMrwBWExLm0q1A2EOYFonAZz1IPKr3Tk4fal1UKXHZ5wamNYtZ32Y WJI7KK25LcWcmBTCld1fRWhODMYd6VIm1da/TMYd2KESV34Cz7IyEe+z3uYr5NNmHKAt hwQBTEsy3+xlAK9TRpQahFcZALh0/G1B88B0BP8hthDvYHo+Rjvl059wzBDyvxY9UMOn KUNoizf9saa1u2GPKusugJ7EmOlf7FLUyNQ96EsT9QMR3BZocbfoEb4i56MbZl11lA25 hP/IoDY3Z6S39sK+qEyobdEvnFPDP3DnCBvpLeR1N0c14cnb75s396HJyBp7BKizmnvw cViA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F1k/7mPGH5gDcWWku0OjBNNAk942aGuA5NQSFVWJSqE=; b=EqzJb/xsKuO2IJl4HXSRFWji266f6LmVv/+VRM8ClC54atBWecv33qEUXdwxBufRLh Q0rupy9xJFEOc+r6Lbtn1kuzu3oM+Xu3uG5pgVIZt1TYaJWJAJdU6WoMsPDScPxP8OKi 8WUWkiRjZekt/vEbyRzmm+nCCPKJRqSNwvCl09bLkpWDYrPzExnfhG60ms+AqLIG6+yq cbI7XeaqmqxqjeZjdkmaZvL021UDcZLNx5D9hCAE+q91kjCL+LGscoujy70OxpILX0Nc X1HHvJAyjA2iU7Fwb2ARJbfTWG/DskJbMZVErTWAjbac/cfEnpMYjp0Kf0RaoVYCXEKn W80A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YdQP44Uz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id iu5-20020ad45cc5000000b004c750d8def9si8016105qvb.240.2023.01.11.00.55.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jan 2023 00:55:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YdQP44Uz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFWot-0003Rt-4j; Wed, 11 Jan 2023 03:50:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFWoj-0003Jt-NC for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:42 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFWoh-0007hK-Kt for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:41 -0500 Received: by mail-wr1-x42e.google.com with SMTP id d17so14307800wrs.2 for ; Wed, 11 Jan 2023 00:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F1k/7mPGH5gDcWWku0OjBNNAk942aGuA5NQSFVWJSqE=; b=YdQP44UzORDUM2gwiED1ZAncZYIEgNPk70Z3okWesFAwhaGWfhuhu6JLrgH40cEJtF TTpCt2psGRmAcEKuYxWBi3EjnyH0zeyDXAtc1wfDFYIwUr/Sc08EVNfeS5pYFF/86aCm 0LcYjO11dWnRTvtqy+jX5yd3a8YKoLpnOn67MkbtcDjix9WTJLdrcvxpT3I66SlMo9Dm uQjc4WCRLuhxjVvTmQDGprBglJYCqQOVZJ+hKrnM2KxqxLyeFjJzJ3VS/JdE55ZjnAZl rd/dTscwK1UsoJU3wbYzAOr1OqVCFqhpBkXJ+FFvE/+RsOEqMOJxdSWhfsauAaWxbHLz FaiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F1k/7mPGH5gDcWWku0OjBNNAk942aGuA5NQSFVWJSqE=; b=G8islpwpYhiqsiigudBM/qRCi0c15EZh86kDlmf53NK8wC1/E6iEmEiVEA16n6qdNH ijIvFMI3tpYXcKNHQ9MQ2UdOZ6VxA5MeP4TifKbG6YXmd7JsT4upWbpPrrazrvQloc93 HUjMboaCxr1bDa6nWA8Pad4edpOFCtdU+AfVMLjbWmVwzFu0+FGWTDHsvb7xakItG9/Z yUDCUUF+hC24OyUQ6B+kE7NWr7pdHeSXzhQBQyqZtmEZ1waxtj9uuaf9M+yIQdWFNWRE AbbYRKkgwkPegSOufZNceRYchnsSb0yQGdZr8xY0uy9L7IxNEs8IXhW6EuikDWXZ30Tm 0VNQ== X-Gm-Message-State: AFqh2koqwD259tI1xOE1tZyj89Dyj3smjkUaJlo4AFMN7ZCz4V9aDRYS Uilh2G013l6kDvbjTYMhj4frIsm2i7yrTpbE X-Received: by 2002:a5d:4587:0:b0:27f:a81:b819 with SMTP id p7-20020a5d4587000000b0027f0a81b819mr40538188wrq.22.1673427037903; Wed, 11 Jan 2023 00:50:37 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id m10-20020a056000008a00b002683695bf97sm13029515wrx.58.2023.01.11.00.50.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Jan 2023 00:50:37 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 4/5] hw/i2c/bitbang_i2c: Trace state changes Date: Wed, 11 Jan 2023 09:50:15 +0100 Message-Id: <20230111085016.44551-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230111085016.44551-1-philmd@linaro.org> References: <20230111085016.44551-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org Trace bitbang state machine changes with trace events. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- hw/i2c/bitbang_i2c.c | 33 ++++++++++++++++++++++++++++----- hw/i2c/trace-events | 3 +++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c index bf4b781393..efc49b7502 100644 --- a/hw/i2c/bitbang_i2c.c +++ b/hw/i2c/bitbang_i2c.c @@ -16,6 +16,7 @@ #include "hw/sysbus.h" #include "qemu/module.h" #include "qom/object.h" +#include "trace.h" //#define DEBUG_BITBANG_I2C @@ -26,15 +27,41 @@ do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0) #define DPRINTF(fmt, ...) do {} while(0) #endif +/* bitbang_i2c_state enum to name */ +static const char * const sname[] = { +#define NAME(e) [e] = stringify(e) + NAME(STOPPED), + [SENDING_BIT7] = "SENDING_BIT7 (START)", + NAME(SENDING_BIT6), + NAME(SENDING_BIT5), + NAME(SENDING_BIT4), + NAME(SENDING_BIT3), + NAME(SENDING_BIT2), + NAME(SENDING_BIT1), + NAME(SENDING_BIT0), + NAME(WAITING_FOR_ACK), + [RECEIVING_BIT7] = "RECEIVING_BIT7 (ACK)", + NAME(RECEIVING_BIT6), + NAME(RECEIVING_BIT5), + NAME(RECEIVING_BIT4), + NAME(RECEIVING_BIT3), + NAME(RECEIVING_BIT2), + NAME(RECEIVING_BIT1), + NAME(RECEIVING_BIT0), + NAME(SENDING_ACK), + NAME(SENT_NACK) +#undef NAME +}; + static void bitbang_i2c_set_state(bitbang_i2c_interface *i2c, bitbang_i2c_state state) { + trace_bitbang_i2c_state(sname[i2c->state], sname[state]); i2c->state = state; } static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c) { - DPRINTF("STOP\n"); if (i2c->current_addr >= 0) i2c_end_transfer(i2c->bus); i2c->current_addr = -1; @@ -73,7 +100,6 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) return bitbang_i2c_nop(i2c); } if (level == 0) { - DPRINTF("START\n"); /* START condition. */ bitbang_i2c_set_state(i2c, SENDING_BIT7); i2c->current_addr = -1; @@ -122,7 +148,6 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) /* NACK (either addressing a nonexistent device, or the * device we were sending to decided to NACK us). */ - DPRINTF("Got NACK\n"); bitbang_i2c_set_state(i2c, SENT_NACK); bitbang_i2c_enter_stop(i2c); return bitbang_i2c_ret(i2c, 1); @@ -147,11 +172,9 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) case SENDING_ACK: if (data != 0) { - DPRINTF("NACKED\n"); bitbang_i2c_set_state(i2c, SENT_NACK); i2c_nack(i2c->bus); } else { - DPRINTF("ACKED\n"); bitbang_i2c_set_state(i2c, RECEIVING_BIT7); } return bitbang_i2c_ret(i2c, 1); diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events index af181d43ee..2a479c1c12 100644 --- a/hw/i2c/trace-events +++ b/hw/i2c/trace-events @@ -1,5 +1,8 @@ # See docs/devel/tracing.rst for syntax documentation. +# bitbang_i2c.c +bitbang_i2c_state(const char *old_state, const char *new_state) "state %s -> %s" + # core.c i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)" From patchwork Wed Jan 11 08:50:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 641253 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp3140940pvb; Wed, 11 Jan 2023 00:56:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXsm6IlauDtYmfwsOfJCcsn7Em+YZthP+a0uA/fJTgUwh20VYTkmuRI80uuYJBv5TUQQ7iiZ X-Received: by 2002:ac8:6f0d:0:b0:3ad:fdb5:46c3 with SMTP id bs13-20020ac86f0d000000b003adfdb546c3mr13501513qtb.8.1673427377208; Wed, 11 Jan 2023 00:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673427377; cv=none; d=google.com; s=arc-20160816; b=FGjJ+9X2xZNVoah1uIjPgOyQdusuEE5MpP4PE64cmAVOnmLL6Tm8z1mP8uI3FMxDnR loo+23z1z8T/6fzEYKKJJoMkZ1onaYSunqMJ89C2CieYl4732/ABj+3LIuHqiDAOzgPE bGoKE4ryVQp1cVPUSG5h7Lw9it1pmR5itNj2Tm5jxngodAopVEqpPqoVPlgYMd1QERsI eQsFYUDz8mqut2tjTg7T3Yn+r/AT5a+JW79myyUTBQ642AvvtR8P+A82baWtZ+Pwq8kF O8BGz/Y6/7rvRbs0pqTX9wiDZkk6MghoLdnu06DC74hYImPolQSICSl0a8B/YykdHOLH JjqQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Uj4vMJ6IjNLjq+M6XLE4uewGsLuqMTdFQ7srLl6Qez8=; b=NNwyw+x7XZWjHipmJguKDllm4x1ja+ZhEMIz+1tinSJM7W2Hxz1km0ttW3BVVPL5S7 B4FG5EFX6fxFmRw8SrOh0UAcybhVWh0e8QAKBgDdc3yiCl9C0BVyWtqmMDgu5ZqIwGti 9wIxmLtYUoqEQ4IwvVtVmVuVb9nP0Mq0Ft84b61s56HxEoBNkmSaft4vPrq5A+d9TlVY NI9RQZOEfv2YRvMSFTA7pd77FPWVlvyBQ+CDsEcLWSIR/uCuZrxJ6uUpYf9h+Uc5kd1L hl/cop8h5Qe6YeNAkdb4BFmu6nvsL73FF7qlDhhKPmheJPlsgaKbZegMjoYSXYdPVMln Go9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nn7K67Cq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTP id m1-20020a05620a24c100b006fbefe777e6si8283026qkn.654.2023.01.11.00.56.17 for ; Wed, 11 Jan 2023 00:56:17 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nn7K67Cq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFWot-0003SC-QM; Wed, 11 Jan 2023 03:50:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFWop-0003Lw-7z for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:49 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFWom-0007jT-LH for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:46 -0500 Received: by mail-wr1-x433.google.com with SMTP id h16so14288141wrz.12 for ; Wed, 11 Jan 2023 00:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Uj4vMJ6IjNLjq+M6XLE4uewGsLuqMTdFQ7srLl6Qez8=; b=nn7K67CqhIZdqQiZ0FRG+l8zJK2tXJlgfvl+gnULYM5YIJhcEFfmSXLfvO+O2kZPHg 5M8QgibkrAU8jtvEWWWn9cdrAQX+n41+4To2eGIdEtzAgSabo+Hm05POkgMtE/BVlLFu c4PUTL53OvDx1MrZfnQHuOli/kl0pVa/4/yvkOKy+myzVeeOJf08vzkuGy0K/7FwDxm2 5yoUuWxBRSROlBK7mx+MxYLreTOaXf2jQTPMNRED15hJwfsbKZaMuVLKH+hJ/beQZQba ihZT0E7Oj03U4VUxwrUSFoo5wiNwkn93PzsQy4RnT5NlrWM6GLYO65nrb9I6a7JObfYs 4TFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uj4vMJ6IjNLjq+M6XLE4uewGsLuqMTdFQ7srLl6Qez8=; b=RrAHc316aNaDWDEmgiDw9rYqtXgtw6Y5EWJgL0R0GwNV3gtO/QelB3DHr3NlIH8S3z JPgAIqvKzKR9o8U86bI2FrkrVaiDiDahc3IT+3oJsA1u/UEUAbJSWZb/0CMDtdLhdYnd PydT2tl3XO8OaaH8RayrduSRJsclzCncLGTDiCZYQVP6txa/INUyLFf0xYiy2Hon7Y7M FIOHX2v7Y19x2+ij7hSYwPlwL8FTzs3evAuMKs7JrLbdshmhMmE4FQVybDbBZApaYc3j 0GENa0Fqk49UhJwlhxTeiwpUdKmXDr4ehAkV+gC9gWYzEJbdrdhMDdt5j8LSbDZG+mcS HRmA== X-Gm-Message-State: AFqh2kqGrC3BWEy+BOkFzRzG9VQqkaolf5jQvzQ9hgDoLs3ecGA4rzkv avs6o3PzwpWs4s0z9unimwTxOHA9L0QFPIii X-Received: by 2002:a5d:630d:0:b0:2ac:5b46:9c85 with SMTP id i13-20020a5d630d000000b002ac5b469c85mr15283173wru.68.1673427042808; Wed, 11 Jan 2023 00:50:42 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id l13-20020adfe58d000000b00296730b5c3esm13272686wrm.102.2023.01.11.00.50.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Jan 2023 00:50:42 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 5/5] hw/i2c/bitbang_i2c: Convert DPRINTF() to trace events Date: Wed, 11 Jan 2023 09:50:16 +0100 Message-Id: <20230111085016.44551-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230111085016.44551-1-philmd@linaro.org> References: <20230111085016.44551-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org Convert the remaining DPRINTF debug macro uses to tracepoints. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/i2c/bitbang_i2c.c | 18 ++++++------------ hw/i2c/trace-events | 4 ++++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c index efc49b7502..bb18954765 100644 --- a/hw/i2c/bitbang_i2c.c +++ b/hw/i2c/bitbang_i2c.c @@ -18,14 +18,6 @@ #include "qom/object.h" #include "trace.h" -//#define DEBUG_BITBANG_I2C - -#ifdef DEBUG_BITBANG_I2C -#define DPRINTF(fmt, ...) \ -do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) do {} while(0) -#endif /* bitbang_i2c_state enum to name */ static const char * const sname[] = { @@ -71,8 +63,10 @@ static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c) /* Set device data pin. */ static int bitbang_i2c_ret(bitbang_i2c_interface *i2c, int level) { + trace_bitbang_i2c_data(i2c->last_clock, i2c->last_data, + i2c->device_out, level); i2c->device_out = level; - //DPRINTF("%d %d %d\n", i2c->last_clock, i2c->last_data, i2c->device_out); + return level & i2c->last_data; } @@ -137,11 +131,11 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) if (i2c->current_addr < 0) { i2c->current_addr = i2c->buffer; - DPRINTF("Address 0x%02x\n", i2c->current_addr); + trace_bitbang_i2c_addr(i2c->current_addr); ret = i2c_start_transfer(i2c->bus, i2c->current_addr >> 1, i2c->current_addr & 1); } else { - DPRINTF("Sent 0x%02x\n", i2c->buffer); + trace_bitbang_i2c_send(i2c->buffer); ret = i2c_send(i2c->bus, i2c->buffer); } if (ret) { @@ -161,7 +155,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) } case RECEIVING_BIT7: i2c->buffer = i2c_recv(i2c->bus); - DPRINTF("RX byte 0x%02x\n", i2c->buffer); + trace_bitbang_i2c_recv(i2c->buffer); /* Fall through... */ case RECEIVING_BIT6 ... RECEIVING_BIT0: data = i2c->buffer >> 7; diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events index 2a479c1c12..b0ab237b0f 100644 --- a/hw/i2c/trace-events +++ b/hw/i2c/trace-events @@ -2,6 +2,10 @@ # bitbang_i2c.c bitbang_i2c_state(const char *old_state, const char *new_state) "state %s -> %s" +bitbang_i2c_addr(uint8_t addr) "Address 0x%02x" +bitbang_i2c_send(uint8_t byte) "TX byte 0x%02x" +bitbang_i2c_recv(uint8_t byte) "RX byte 0x%02x" +bitbang_i2c_data(unsigned dat, unsigned clk, unsigned old_out, unsigned new_out) "dat %u clk %u out %u -> %u" # core.c