From patchwork Mon Jan 9 08:41:17 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: 640585 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2028710pvb; Mon, 9 Jan 2023 00:53:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXvDDl9veFWkCr1HFkR+a+Ra/j6/JkHgVOqi4p/kt6d3LEH/dwWcVYmI9fmI6g4uyf3y0kF6 X-Received: by 2002:aed:27c2:0:b0:3ac:5748:54a0 with SMTP id m2-20020aed27c2000000b003ac574854a0mr7809071qtg.67.1673254438563; Mon, 09 Jan 2023 00:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673254438; cv=none; d=google.com; s=arc-20160816; b=sBwdGXsuUVC80atbWcfZvfmuzchHMmvLIZKDEnQ4UoRqQWP1VcsPI3SSzKeAfKn+bO P4Hvui+weBB0oNbrZ8lLuhx9ziWIKn51WjZSJii+d32K3qrREKC93XFOTjidPhYRRTt2 Hs3n36WxlG9LESMS8frH1MPwMdISFGFwBLDOKblQzRCcVZ7T5e3+0k2wlrtlkTz67PPQ trB5senyCKiIz9BYjSuRFvCtQsUYhuoLbndSLrUh50ryojozxwRFCFyItnhMSzgI5HDB C/eEEo7FmybZTKI6if/y2ONKhI0Gdoy8ASnfJsMXgkHlOyfttb5f53thQr76o7Q8KeMR dxXQ== 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=HTqoT3kxPcjorZ3mugLt6fynVNQ3ed1VmFMT7P6iTBY=; b=fbOahD+RL0Yg+ht+q6VHT1tSstvu5f9A3eb0uOeF34SzpdNvxu/XRhJGhBAzIzLc22 OYcSOrgQLwgpBfHXmdq9KWHaclLe5e7ysIzUdMyFdKbqb4kgWTpGKCsEp+i6v2KavZZL 04jmUmrKl9nYuBngktfWBrt0wxxXqmjrJlwwPHmuzUnkpjNp0MU83D8sxbXcalKy20xl Y97Z1X2LbUuyrvKbfzefWZsQoJhI0zarNjVn+UiKqe7u8PebKroRJd0gadCoFDRzm1SM KrJ+c4tNHpJh8GdyIlgu0t5qJ9S7y7iAyT88IGrfCc30iNJy4LQonrzL7XuXhYJqu6S0 T1Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YgSNwICS; 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 y18-20020a05620a25d200b006fca83b669dsi4348751qko.61.2023.01.09.00.53.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 00:53:58 -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=YgSNwICS; 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 1pEnin-0005fj-E1; Mon, 09 Jan 2023 03:41:33 -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 1pEnim-0005fJ-5M for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:32 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEnik-0001iJ-8x for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:31 -0500 Received: by mail-wm1-x32e.google.com with SMTP id m8-20020a05600c3b0800b003d96f801c48so8416285wms.0 for ; Mon, 09 Jan 2023 00:41: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=HTqoT3kxPcjorZ3mugLt6fynVNQ3ed1VmFMT7P6iTBY=; b=YgSNwICSTdBN20I0dQ+7Tcgu3fsIsNfGWs9BHqt5lyQ1ieWs23OzjVVDtIbh7od5Uq vU3/iqdr6GLDXuo7UwGD5oTZobSr+a3VwqcXpLNjIj4y1iypO9dUHn86gmbyPtyTmmMh ue3XZGBqbY/ct6j9iLdhzyERR5kVQ8Y2fCOUTDJ+B7WFNV2761P7BBx5M23t3nlciafi qUmrAEtP/CXRlLwjaCrTtDM5wyfHZzWRsz5xrmALIzPe59pGgzN6t2n5l+j0DQqiyGAo Yi1lk+UPa0+16MWa77rOK3IvVFFFYpXTSfR8pxEWrma1Rlo1+9JwRLrYV6Og67v6/G65 lkqw== 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=HTqoT3kxPcjorZ3mugLt6fynVNQ3ed1VmFMT7P6iTBY=; b=cAuZsB5F4NzeLz3kiGifLBHcF+iqjz0toFDsk/DpKK1tUuOf264f55VVnneq20zZuA G0eEYNlhJea85h/IcxYb7v3bT/JgUXEUvQMnooFSgekI0Q1DzgMXieGFM9i4nd8CpHu6 Tm5+ut/EozrI6B6tWuyu0FhMN/Zkg2XkSIMwPuaMTvxTx40IdmvIxBUbD+5r3+3v5xeX xzOMgx0Cz+oFHwxGpqQ6XfCbEw3nTEAFfd2VePPdS7a413yDjg7Qt/nNioK9SV54Kk73 7MRB1aXAVyoNX0ZX+uHX2h+0MOq0+4rHKKc9DvNDlIQkdzKZyr592mzSIlMN3N6rv1P/ rUpA== X-Gm-Message-State: AFqh2koggBeYS4iwYOxPmr7pwvpQ2ybieys5NODBeMlw9cKJ8XThgyl+ BuGo8GdoETbrDvozuN3wKbYg0TanY9HvGdxw X-Received: by 2002:a05:600c:21d9:b0:3d1:d396:1adc with SMTP id x25-20020a05600c21d900b003d1d3961adcmr55848029wmj.14.1673253688366; Mon, 09 Jan 2023 00:41:28 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id bg42-20020a05600c3caa00b003b4cba4ef71sm17107033wmb.41.2023.01.09.00.41.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 00:41:28 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas Huth , qemu-arm@nongnu.org, qemu-trivial@nongnu.org, Jan Kiszka , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/5] hw/i2c/bitbang_i2c: Define TYPE_GPIO_I2C in public header Date: Mon, 9 Jan 2023 09:41:17 +0100 Message-Id: <20230109084121.72138-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109084121.72138-1-philmd@linaro.org> References: <20230109084121.72138-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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 Mon Jan 9 08:41:18 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: 640586 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2029343pvb; Mon, 9 Jan 2023 00:56:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXuPCFT/+uVgJRGaA+m1vx6y+hhIzGGg4/Km8iWr47zDKY0UG2jajty5rFIAlEP4DzYRxiGI X-Received: by 2002:ad4:5345:0:b0:4c7:8c96:6730 with SMTP id v5-20020ad45345000000b004c78c966730mr81797412qvs.42.1673254578635; Mon, 09 Jan 2023 00:56:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673254578; cv=none; d=google.com; s=arc-20160816; b=o4WCD/LHta3f5XMmybUtKqSpJkLTdo5l1ZwM0XUcL5JHm8FEgzZdhB/gixLaK4dh6o RrNHCZNF/0hQgxwk6z07yf67FB14YY3HK3EdIwA68iBFtuwNkD9g4cBqTwuthMq5tB6p 6GDLomyJ9T6WxUECrqMsg5q5no/heYF5Um0xvKtZe/ssAFatpv2hFh/PDSx6xzTl07dS ymYa8ruiJX+gYDGXIOVdTD3YagkFhlc7cX8tiz2PIqQxmvrq6wuZLiknqlxvrWXw/ITJ UfoVDOzpbnc2EwaqKZV4eU1dXHEWnt/qjxqPsTJQcB4WrIWeStSqmK7GbH8V/wTlO7mZ ZCvg== 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=YkFjYPFzUw/uhM0dOjJ0XXnVDH6Pxtvb+WDPgdl3CFI=; b=m3TtJ3rMwgaYvq/bsGeZ3p4PKCfimZb57kCiM8PDo2ZRkzN28Ssouc7is/Lhkp710I uX34nhbFikmTMZ+UA2d6AWNMFdHkSeSXcxjNsm37r/p973pcWjF8qk2lf4mcZ7E2vdEZ P7myQnHctb1sA4skBlD4abF/kXA9Jwv0B0paUiqVmZOBYezBXVBMET8BBM4S8e1blxv0 r0GNaqQDkYVVyPo7AUtmYUlrE1opjYmbUWxGFgL1c3CH+l9WjdQA70b2m+dSWS3AXSWZ 5t9N4F8OYN7r24Cch1ABxNF1AqDashYXmqQNOBkMbjRpAJ14iYSNR+witvSIdguvxjsA WApw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nRIdU1I4; 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 bs15-20020a05620a470f00b006fee1a48f4dsi4407650qkb.457.2023.01.09.00.56.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 00:56: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=nRIdU1I4; 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 1pEnis-0005hS-0c; Mon, 09 Jan 2023 03:41:38 -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 1pEnip-0005gH-JO for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:35 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEnio-0001iG-13 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:35 -0500 Received: by mail-wm1-x332.google.com with SMTP id l26so5694976wme.5 for ; Mon, 09 Jan 2023 00:41:33 -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=YkFjYPFzUw/uhM0dOjJ0XXnVDH6Pxtvb+WDPgdl3CFI=; b=nRIdU1I4i/bx4omiQof6SvnSGznHC44HR/u63P8ElDOfpec0llDkAI4gb6La1cdk+C CvsLIQYQvuBnSMMaxZet3az4SDSMy8IaKHg13IwNLhQNEvtyIGYoYYgcJatOgxiMIBRK HPlJAkaue0yWQDYRy3lW3Bb5mfnEflZM/ILfiS+GdAhtl1eltQ1dEpovlsm6tm3Pb9/r XvhcQee0t5Tn2fZEiYWghX1u5sP3mvAmDbkHhzDTVedYrT5aFFRGglCuUmsrdcF2vjwU HovPSR84gjU3iEVsf7fa4NCttov0vtnfc8P0oL86sfE0wTRlAOzBw3CKiPhoFqVT82Db ssig== 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=YkFjYPFzUw/uhM0dOjJ0XXnVDH6Pxtvb+WDPgdl3CFI=; b=2JUTYkvIC36C2G9yfdFJr04tQ5CdjqJIdcL6B2OYjz4+Ms91z+jsgA/TZ+WGpVlmaq Ax57AI3PDYDOzGvfJ2eCokam/IkPdpgMmCQYzDl0TEmYt++h4SjhxRK55XcgP1X7D0l/ 15lPvuYtbt0WzM0FWl25U2vjCUKAuoEjZgfpIJ3nuFVDPqZ3BNmaPTvHTdS72NTcjR8P 4EdaYkNd9nJjjK9e0iUA5fMHdN2K0mgre2Vikj+I/w+ThQQUEk03gU80b4irUMv1Zf96 2kiy/ddLJdB9LDVtKWNT/kSc83GyitJuoCbouDn0YYU0YAuyUqgSQQPeIEE4ZQpFRm18 Qztg== X-Gm-Message-State: AFqh2kr0J4zCMWdK4IpjCURVXbbn06zBqRSjc/Vp0rCIrZq7zMfTei9S B2dvUMetr+MZN1qylLZUzcxrsJmkB35trUyR X-Received: by 2002:a05:600c:1e24:b0:3d0:8643:caf1 with SMTP id ay36-20020a05600c1e2400b003d08643caf1mr46383087wmb.16.1673253693165; Mon, 09 Jan 2023 00:41:33 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id v10-20020a05600c444a00b003d998412db6sm16163677wmn.28.2023.01.09.00.41.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 00:41:32 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas Huth , qemu-arm@nongnu.org, qemu-trivial@nongnu.org, Jan Kiszka , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/5] hw/i2c/bitbang_i2c: Remove unused dummy MemoryRegion Date: Mon, 9 Jan 2023 09:41:18 +0100 Message-Id: <20230109084121.72138-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109084121.72138-1-philmd@linaro.org> References: <20230109084121.72138-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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=ham 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 Mon Jan 9 08:41:19 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: 640583 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2028316pvb; Mon, 9 Jan 2023 00:52:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXuZX7wLKtfqElsUUic7sgFeut1FcAj7FOfl7V0A7BhgnZGObaFFOLC+Je4fFeQ8HDHAXZz5 X-Received: by 2002:ac8:4d82:0:b0:3ad:13ac:9815 with SMTP id a2-20020ac84d82000000b003ad13ac9815mr4499249qtw.10.1673254338687; Mon, 09 Jan 2023 00:52:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673254338; cv=none; d=google.com; s=arc-20160816; b=kU7TKrHNQs2qB/dVbbrH2UgXbr36jH0VqTXt8Twy+UR2d9B/2kzZ8sRmUVEPMbGbKr fzwOBvwNWs1qP3LpqWyfIDQ6fEVHeI1XA5SHprC+WJa9vfSsegTErFCAaC5LFtlKMuWG NyXZBN04afnFR4/1M9T7vvwaXFQJuZRvL02T3xG2mLCHlGc5KFGnJJ1ATvHwQkki0Eb/ VxfdbXApzupUsBbx3br5Lmxfd2YrZI31Z57Oi53fnY6oSA8uo6yUXUN0tqL5sAlta09Z oGvGFgIKjA/KA7r/m+ATCYw2sl3oZba7uNlm+T3YkuuZX5Xx0iDm6HT2W1qL+GP9n+O7 xafg== 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=mW/xOcmu0qY6WycKJ96K7bzJF3hE191cAtI16SbiYiY=; b=YkYEMIDlZI8dAhLKqWwTcZp0vtE5tFhivHN76boO9pUJaSmxhgIJ9CotCoIDUl8VZz R2DLMzgEMgAG8RN86frOJFvj+MYyXh0Bx8iykn/lyY5J2nLq307onJZPqHrpjX1CE3HM Y3ev0quwcWQsWJUDt2cu5dG+n/vGP9+8B24W5zrfXhZ/7c+AA/+/g558ARFZf4EGfvjz xCRiPs3b1ZcBONWQQur8RnqxVZnx6y4dRER1uQKEWm0d+v1FZsd5hARWO/zu8k0ca+U0 ASNscbcGrwJMCwnms47ySIl307yaaM4IRPFTMuNJoqk+pi2HTNCL8doB0AiFEXVkliWF fDPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bin2DoOy; 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 w29-20020a05620a0e9d00b00705ba9d0d81si935406qkm.225.2023.01.09.00.52.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 00:52: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=bin2DoOy; 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 1pEnix-0005kw-Pi; Mon, 09 Jan 2023 03:41:43 -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 1pEniv-0005iD-LR for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:42 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEnit-0002CB-Bh for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:41 -0500 Received: by mail-wm1-x32c.google.com with SMTP id p1-20020a05600c1d8100b003d8c9b191e0so5987388wms.4 for ; Mon, 09 Jan 2023 00:41:38 -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=mW/xOcmu0qY6WycKJ96K7bzJF3hE191cAtI16SbiYiY=; b=bin2DoOyGNeYdFHOhQHvOFswCq6sz0R8SGKtIo26F6R9oMwJ9a/0JuuPi/BtpqD25G n+fkpJ5Js/Cnax6qKNnzKJZZDkB7D6UfZXXahdNXD29XvRMev0Ljyiv5Bvpep6L5KHva Upw/te0XC1WcTZPL+SLKac1t4IUbsMf2ttkIQfjNBGz5XhtSQobkDnZl7HznJEug3jXc LMvU3BFn9hJb36clU2LtV5CMSHEa0OVMdgXHQ9DC+GT+nVSgEXtPfRXPYZGKrvYmjvCx OZCON9QvIzl/xh2eXqD+HuWBYTUOVUF/JEL3IRchgRkR1xgWzJPA0vM3kARKJI9yFRFi n46w== 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=mW/xOcmu0qY6WycKJ96K7bzJF3hE191cAtI16SbiYiY=; b=q0Dpfig8FMRNv7GW9JJ/hsm1SbX2vA1sP45jApbLGXNe59t1HiGF2PhZYGzrHiImYf REbQEw93qAEaEp9G5qvbkCig13PCdUoLnVupN7eqVTkJLV1CNdMybtXcIyHKpzX7I/NA oNVIlNyOvoR3keW48J6PiQFqLq1O1hkImK8KTFLvlFJEymsobaJ5GYl0BFbtkSkvaVrH ZYOjk9WbArSi0hlNcL0kzkUx8xWf6XAPiJDPb/SeDSYvCsg8IvBe/wV9IcazVNYt1aPn xg4Mt5MyTSGtzmF9ALMQr0TWD7eMWHHZH2s5v3Pl1d5yT21fri1eoTfxmGhO5AoFu2xP QKPg== X-Gm-Message-State: AFqh2kppJoqm9FTzwY23g9PllWuqbGFGuBBXKXSGu3vAZaw7x2mGkZY6 Rpc0eX7ldmHHk/n3MImKlrOwQSfnIcX8lVhY X-Received: by 2002:a05:600c:44c9:b0:3d1:f6b3:2ce3 with SMTP id f9-20020a05600c44c900b003d1f6b32ce3mr55081306wmo.35.1673253697877; Mon, 09 Jan 2023 00:41:37 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id i14-20020a05600c354e00b003d1d5a83b2esm16588329wmq.35.2023.01.09.00.41.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 00:41:37 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas Huth , qemu-arm@nongnu.org, qemu-trivial@nongnu.org, Jan Kiszka , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 3/5] hw/i2c/bitbang_i2c: Change state calling bitbang_i2c_set_state() helper Date: Mon, 9 Jan 2023 09:41:19 +0100 Message-Id: <20230109084121.72138-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109084121.72138-1-philmd@linaro.org> References: <20230109084121.72138-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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 Mon Jan 9 08:41:20 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: 640582 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2025659pvb; Mon, 9 Jan 2023 00:42:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXt/IQ8XeY8DRKZ6iUifSujjqyvS+ZEF/IM7VaOGXMYax/TkqRg2jNd/tK9RBCxcjsSM3aXI X-Received: by 2002:ac8:7386:0:b0:3a8:1896:e2fc with SMTP id t6-20020ac87386000000b003a81896e2fcmr90334291qtp.35.1673253749307; Mon, 09 Jan 2023 00:42:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673253749; cv=none; d=google.com; s=arc-20160816; b=AdxIwiJFS2i2buwiFicqELO40PJWp9sVG974j7TaEHbhMIks44TUH/0mz/Rodu8ZfN a1OkrZRSkOLL05784DNPSamWvzfaSP2SQYNreUdjebb/Fq9whqpdMBFgxZnButnH1W0p IdrRVhVWiWzWdjY/vihexOOJ3//ZfF8QAf4KRe3GAY7CYHFMGc8qZ9V2inqoyw9etLeM mwVB1CKkdIn+rfKd4ZJwIcdpODy/SfyI3UCFugVeqwScLf8jEkaFgRZPgzXz3cNp54Iz BncQwiWA73OS2D6qLFWFb2oakXKVyiNGEfevlwiMMbVc42ev0oYQ0/ZGZFdzSbrQQbRi teeQ== 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=jJ6oumXx0s46lM7s2kykoKISxxsiXAQ5N5QK1WgQl4I=; b=0wyezJoCQEYUOcyMOa7ZojXH9+bCmDfONPYHeu3yNMjkuz1zmqV622rHWm+mDoR5Um NB4JD3weq74k146Sa1rQHlnO0uPfflKsUgr417gs/J0b7hpjzhyiPLNKIPzgABgMU216 8aJYOYfVBUKTQFJz9OG0tgOvIsdHbJJiTSN9G2vxKzmYF3faS7PfVjPdZfT4mXMr42Xn 6o1+5bFwgTInrt6HvxExzewUpwyYQZ66qPeU03XtNPUCFtL9a3tWXzoPZwjURMXN/ud7 lQfqDVs20qT/J4HBSvy4ympCcyP9e8BFdIgHqBIPmBrlXUcT2EqwCbEdoFx/M48VTrcw v4kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yavy+ORR; 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 bc8-20020a05622a1cc800b003ab4b7617b5si4013191qtb.197.2023.01.09.00.42.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 00:42:29 -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=Yavy+ORR; 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 1pEnj2-0005mh-Dg; Mon, 09 Jan 2023 03:41:48 -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 1pEnj0-0005lo-9C for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:46 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEniy-0002Ie-5l for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:46 -0500 Received: by mail-wm1-x329.google.com with SMTP id i17-20020a05600c355100b003d99434b1cfso6004670wmq.1 for ; Mon, 09 Jan 2023 00:41:43 -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=jJ6oumXx0s46lM7s2kykoKISxxsiXAQ5N5QK1WgQl4I=; b=Yavy+ORRYI+PCW0FoOAkryDjunEHMv4VbCloNwKNkbyRCzdm3JuXUcf5dL2TcZzORV FlN+ZBJdM1WsonoO+v2ie0zDvNXeEkFn0mD6spBnYchyENb4McReZMoJQaKJTlThEYTE 2ZcsUdVlKu1LtOjIfc7d5FJZbXdHbkr/mgOQ5cX4GUaek2SND/8i/QbbpmHDH9JiP2SY qLKI/E5rl10jbQPQCThC9IiMsj3LALX8dImKXdl/4ayPZbRjPTgyuULmtAgM3+EMKGw7 uiPrkQrTuk2Mzn85K+dH6IrSiPbfJomnuTPwt36OSEhmjtRaCyzmAUOmd1k9cBUpPZ52 SQfg== 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=jJ6oumXx0s46lM7s2kykoKISxxsiXAQ5N5QK1WgQl4I=; b=xwU6dwKHwVQ5LcrKnXWAvy7PvQNATJ0Pj71bZCmPdjWmqEvJIUFjmRFLkJ9uvSsv8o /USc0S8lpCRd9VOdor2iZhKFUv5/aaZtjbaWUqxZK3kg6LPxOLyE9VuSwaaf2LWsodNk nC2pNE313XookQODQQRPIS/6sNvIWoDXM7bEgS8poj1+BIK4e0/CdNZtaDiBqJvCWcBP RINbIM9LDwR0J3w3I08n2Rp/TZpYBYm6SK9+IMN4WgEDMjQvhkgRsx/IXVK17co4V7i8 f1Uys094SKaM3xWeCIVe7DfMmutSSB/AhPbPiBzHknGR3ryGjiTYmpUw+Yc8fRGc0Xc6 nbXg== X-Gm-Message-State: AFqh2kqu8umuzvbvEkJohRHv+XRznMisfZankUS270zJ5zDVFM+bkez/ SbmIYKHLkmQmjzC8lTrcKcCQEgn9uNWXD0ni X-Received: by 2002:a05:600c:1c9d:b0:3d1:f3eb:c718 with SMTP id k29-20020a05600c1c9d00b003d1f3ebc718mr55762456wms.19.1673253702592; Mon, 09 Jan 2023 00:41:42 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id e18-20020a05600c4e5200b003d9876aa04asm12553969wmq.41.2023.01.09.00.41.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 00:41:42 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas Huth , qemu-arm@nongnu.org, qemu-trivial@nongnu.org, Jan Kiszka , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 4/5] hw/i2c/bitbang_i2c: Trace state changes Date: Mon, 9 Jan 2023 09:41:20 +0100 Message-Id: <20230109084121.72138-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109084121.72138-1-philmd@linaro.org> References: <20230109084121.72138-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/i2c/bitbang_i2c.c | 34 +++++++++++++++++++++++++++++----- hw/i2c/trace-events | 3 +++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c index bf4b781393..9fa19cf8b1 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,42 @@ 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 *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_BIT7), + 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 +101,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 +149,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 +173,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 Mon Jan 9 08:41:21 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: 640584 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2028505pvb; Mon, 9 Jan 2023 00:53:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXteLUJ4LDIDkLJiGY77FyQOlhaoCxS7DDBwcxk/pYO+KIsroARxMb0XCdB1ZqzCG4riQOKi X-Received: by 2002:a05:622a:4818:b0:3ac:e03e:f93f with SMTP id fb24-20020a05622a481800b003ace03ef93fmr4777111qtb.2.1673254388035; Mon, 09 Jan 2023 00:53:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673254388; cv=none; d=google.com; s=arc-20160816; b=PmV5xSpORigBQ4GuBBqRqAAyMoVp/LSiF/cU1bkPZlgMNHt0qOG002a6YlhTFGGY85 YHXL0X1sxhoqqZxFiFPQB2rGeaTP8K8+h4d9e9VQtwdL3mSiZqaZ7grxtBSpubZx6NEp rQJ+wi8wQDKNP86PVOVLvYWEXDvIRr/hP4aiLfyLDWwbulL0wBWlZjakK9TztrL4T5yL l5EqfR3D5dwxUkxkkb+4R19olNga1rqNFCSkMQEPuDSDhqs5JIAHkGYanucxNMizdni4 lUHvb03CC5ptYxxoulWoA4hXbr9G5Wl7gjmg/xNNkWrVOOz6k03Rfx7vxjGTY6i+T4Uc n0Ew== 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=rJ7Ld9KMG3cV36Q3MxoGtMbfv5FoM/NwLMR+8A4FApY=; b=o44r8PPXJm8iAGScaD+eUTZ28RSy6QhR/uZMSclP82MpxWElFZ9CjHKrQ+bzEnGz2Q T24ZO3bcAtLR+VNzZSTq+ORwYJMkvuOHlZKS3dn45PpuhUh2NgOeCVZvqj+5Hd8ooP59 DVOjWqmnm+Rsr13uOxRHlK2X/xnCO89tNXiuijs9R4mUwCqWIrLc7r74xYOLIhUrS+By 4uVopQ1tdUKgv9M/cKdhUqRDV4WDlqOXqRol39VTLlzvEYhsCEzmwZJDQjNkFzt/eMb8 0yZF3sZ21t7tRdxsryE9g8jjVT3+JYqG3kY9gYgsxpSSb1Ydx7K3crWlVt197YFCtrs6 Q1uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qachPbsK; 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 p14-20020ac8740e000000b003970f9f8769si4118119qtq.560.2023.01.09.00.53.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 00:53:08 -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=qachPbsK; 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 1pEnj6-0005pV-0J; Mon, 09 Jan 2023 03:41:52 -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 1pEnj5-0005or-1p for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:51 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEnj2-0002M7-SB for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:50 -0500 Received: by mail-wm1-x330.google.com with SMTP id p3-20020a05600c1d8300b003d9ee5f125bso1924442wms.4 for ; Mon, 09 Jan 2023 00:41:48 -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=rJ7Ld9KMG3cV36Q3MxoGtMbfv5FoM/NwLMR+8A4FApY=; b=qachPbsKzMR+AMKRNhD4UGtfFP1ArC77+F3/gsw6SbkjSbjkhLM6aJGpEJJWb8SFIK VnWxvcR7jgak923oQrD2S4R5+lQ+F/DYuesknN5e3oU++WaLkaGO/20/K8poZwG2yT/s TsW3t/rysBYtNucAGyfWro+1sVL5zJlBoi6IwzzjU6RStYfS+RlUh9WRxuzsSh7gh/A2 khag8XexU0XnotBkg71iwCIh1PRY1F7ztlk6118KFsXP6iDYE/7Fj0GgOSDFON9VPTs6 vdaxuD4XYWo9dsEj7pL1CTsFN74fvgElldGAd5Mwd6iWjxai0HJTtLV+twrpujKkKzEP RQPg== 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=rJ7Ld9KMG3cV36Q3MxoGtMbfv5FoM/NwLMR+8A4FApY=; b=rco7oE5NvcuWLCI26B69LE2J27yFMIk+UT1MANAlDj4d1xX/cZmZt88J+pUtPzU+Gu tGorTlnYCRUYJ4vHR/0KV78p1FWopapnactr/jrcmY+elZ9QqS3svQuxI7gKeGNdwKID te2y/gVdAkfAdZYniY9jwpT8pMVC2CX8LtEOoIQBukhI871Pfexd9U+e2c47KVoQz32w FkzS03Q9WKxKESSEZQRXxGDRW3LIF6ikpBXKRHYd3DvOKZ/ADwi4Mv2ogEqDAPKlzB2+ H7HMyeESZy+ZB09qh6u4Fl4JjX18JuMEJ1S8/00CCMeAhcFHGmjCfc+bhu1ch1xG41Jh JomQ== X-Gm-Message-State: AFqh2kpVlQBXl84d79QPvxu4Iw14ZYPT7z85vTSuQmxgxC42TqgWMTUU fpWWomAjI7VBAPnf5Ds/QjBvLl2CXZyGX0cr X-Received: by 2002:a7b:ce8e:0:b0:3d7:1b84:e377 with SMTP id q14-20020a7bce8e000000b003d71b84e377mr47660529wmj.27.1673253707375; Mon, 09 Jan 2023 00:41:47 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id he5-20020a05600c540500b003d9ed40a512sm4853414wmb.45.2023.01.09.00.41.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 00:41:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas Huth , qemu-arm@nongnu.org, qemu-trivial@nongnu.org, Jan Kiszka , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 5/5] hw/i2c/bitbang_i2c: Convert DPRINTF() to trace events Date: Mon, 9 Jan 2023 09:41:21 +0100 Message-Id: <20230109084121.72138-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109084121.72138-1-philmd@linaro.org> References: <20230109084121.72138-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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 9fa19cf8b1..ffc5b95410 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 *sname[] = { @@ -72,8 +64,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; } @@ -138,11 +132,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) { @@ -162,7 +156,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