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: 13093160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E4225C5479D for ; Mon, 9 Jan 2023 08:53:58 +0000 (UTC) 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-Google-Smtp-Source: AMrXdXv/yMuHySQCqNp8xbpmsp6zifHByLh+tS3DoniKpFc9X5QZoLqqCKUcoT2S3V6MmypMlT++Ug== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13093161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 01F47C54EBD for ; Mon, 9 Jan 2023 08:56:18 +0000 (UTC) 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-Google-Smtp-Source: AMrXdXufQG2X1eCE8JnAfjKtamsyf3n9SMfccZW6Hai5SYaLAAZvUy5ow82sgBta3QrSKUkSvOGLQQ== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13093158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 428F1C54EBD for ; Mon, 9 Jan 2023 08:52:19 +0000 (UTC) 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-Google-Smtp-Source: AMrXdXtS91dqPbY3Qxa3bG7T8QYG25CtG/Qr4puJts/y450mJVh/rLKLkzsus9hKjRdhFIjGnPATRQ== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13093135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B700AC54EBE for ; Mon, 9 Jan 2023 08:42:29 +0000 (UTC) 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-Google-Smtp-Source: AMrXdXvKDoXCpO710anHJ+MP8kgYaVpcJdz8EJ+vPpBA95qMGpIuVzkD+GBGhdekglU9CCDdVG/ckw== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13093159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7426CC67871 for ; Mon, 9 Jan 2023 08:53:08 +0000 (UTC) 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-Google-Smtp-Source: AMrXdXv/ymE/p71F/4Lx6ghQg2jauI3V1Aqt/e83Ivhiqc90LIMsL9bOdgQwluW0WT0jR8M08lWjFw== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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