From patchwork Tue Jan 10 08:29:28 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: 640840 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2605298pvb; Tue, 10 Jan 2023 01:53:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXsMjIglaH1/A7wUyQarpFItCpPz7BVpMIv55o+2kY7f5m9uab1QLcwH++Z5LnyJKndo2iNs X-Received: by 2002:a05:6214:568b:b0:531:19c6:ee34 with SMTP id lm11-20020a056214568b00b0053119c6ee34mr79443493qvb.10.1673344383785; Tue, 10 Jan 2023 01:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673344383; cv=none; d=google.com; s=arc-20160816; b=DQkBUzc0rIZGH9cnq2WXQRb6CX45sjdG0TnAaUXtGNrEb/TGFQ3xe0PANZPcImBle+ hZA/jnRMa7faNNeIiNoz8k0M9yN5kjrLOjoy+ZzPcq2Om6V2A2xR4jZ12UoM5SXYckwF IM2XLJ9b5jV6j1wMZZQjGix4z8Fp51GZ/dDMlFdS/57wb+XCMJAkNAaeLSeAbOmYZtA+ yx1rPEjICCURPlUCjqRbkM0+SwzxerANIcMxtoXKsk38IjnBurINtAXO6MnWdiuTMQgI eIlNABwc88NMz7lGNRZ5fvxryBlA0O1v3juD+my5rp3h88YyizxZw03Xm82nCKJy98Wf H2JQ== 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=QHZbZq8rDV5dYN/QBaa8NmnHyz9kTXOyc+eKranyMc2WWOyoOjujtjkbkr0Iq4fTDJ 1/d3XCgNm5foTmWd3DMDn8va4buCekBGul0ULUA1RaxVq+rEWzwxyXr8oPg1ZGFKY8jC xiNgOOx/fFMsAOm9/+wGCSaJcQLHreq/mP4X5ZZ8adkBrSLKhMcWDgcqOw4O3rxsBLxj Ak4IjZFCaVRz9nDasEdVRYVRdYb6ahoBwfRkxQr4VpxcL/HmY+UYYW1wfJje4BK5zxT5 Q5NPUKbVTJhJOgRC8JNqBe7RMQyAr42qboEf7IrueKFxfC2/I6scRqdcqhLuhMNGyKJo 8y5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="l3/4IQsQ"; 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 m8-20020ad45dc8000000b00531de4aac51si6072200qvh.244.2023.01.10.01.53.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Jan 2023 01:53:03 -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="l3/4IQsQ"; 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 1pFA0x-0006c4-AA; Tue, 10 Jan 2023 03:29:47 -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 1pFA0v-0006ax-C2 for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:29:45 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFA0q-0006Hn-Jl for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:29:42 -0500 Received: by mail-wm1-x333.google.com with SMTP id p1-20020a05600c1d8100b003d8c9b191e0so9187994wms.4 for ; Tue, 10 Jan 2023 00:29:40 -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=l3/4IQsQcHjdJ8gVMLyumejQnIBIzZNC4o+TDUN2meomeWY//80u0fa+uJLXb3h0Ou cEiptMY1EKC4c5ZWx5jRP/2ng4NRdoCbdSCxlp5hV+pEx0KGwZYW5CVfshRKupEN+pFA ClFQh9c209MxqQ6KqVBTB5lJXaa89scw2GlJACbx80E7nQPbrpldImBjcs4D3ONNMb3T WJP/GC3chwTWjyl+L0raTUvb0qnConk7L8HXQut47mw0glneKfEcLCD3BU9m8r7pAlED YPHtf50bL8fEo2Bn4d8ISTxZld37fmSrwInhS6+XdKXZNN/DfQSGen6RoDlFIv7ptyPB SVoA== 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=U4bC0DPAyO/ocVCoDEYO20Z85x4FRNFs2tk3li6RxDsbjVffy6TBJx6YZFOhcgqf1v q+R3E0wppHt/UfEYOJB4bkHlQQ0jomAsVX98tj8mzJJIvPsUx2aTpO8+b1cqFK79MLUP BOpOQ7sctMTx9O+9iYK8I4OZqv1CS+fmKSmLPUxS5/AzL3W23cEb3WxDNnWGECxJHBAv rZWMXrrrwk3/LfTUKU671v8jklzkofjknHRRUYSp7X0EcuWsu+Gy7ZRST1Iy+OaHSeJD BGiNrCe9ZfxpG/7wduwMUzGOiCCRzvkHOU2HupBJoToh+hgX7S/c7YY5HUUXT7Ccyr+3 56Ew== X-Gm-Message-State: AFqh2koZ4DK2yyZBolKo9sQPNqeJ0ehseHp+/Fn9neQzMllKEW4l+/9r iBYG7Ca2fBXJdCp5DxNTJidOUjYS8WRnt/3s X-Received: by 2002:a05:600c:ac8:b0:3d7:7cea:b410 with SMTP id c8-20020a05600c0ac800b003d77ceab410mr48540659wmr.33.1673339379237; Tue, 10 Jan 2023 00:29:39 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id bg23-20020a05600c3c9700b003d1de805de5sm15998885wmb.16.2023.01.10.00.29.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 10 Jan 2023 00:29:38 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v2 1/5] hw/i2c/bitbang_i2c: Define TYPE_GPIO_I2C in public header Date: Tue, 10 Jan 2023 09:29:28 +0100 Message-Id: <20230110082932.24386-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230110082932.24386-1-philmd@linaro.org> References: <20230110082932.24386-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 Tue Jan 10 08:29:29 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: 640839 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2602699pvb; Tue, 10 Jan 2023 01:44:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXv5FmErK+JffrV0KpWDaqQsNdDeo0mqg5OMyhxuwM+Hl2qgAYAT6zKGQ4LxGl/KJdjPUVlt X-Received: by 2002:a05:622a:59cb:b0:3a8:299a:9843 with SMTP id gc11-20020a05622a59cb00b003a8299a9843mr100198292qtb.39.1673343891773; Tue, 10 Jan 2023 01:44:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673343891; cv=none; d=google.com; s=arc-20160816; b=NDJ5GaTUS8VjHozt0cYKZ1o5LvkeTPkrX3Y5+eVT6QB7/Tr6IcmB73K9UruQWEGS8U QORq77lxBT6DfFiG2TbwDLurFnH82ujJYtpV3pZOrte49ZSlEmHPYXbF+lSKq2eAJPez YuXWmyy5L3iZ7PNf5wWEzbwZQp/3Z5+tK/uyCMFsfzvBkNDEsa8zQtxPPRcY75L567/t eEnE1CBYovm+QvrgRe5lOhwRVDFlW64vMVcM51y4hrE7GW2CTcU4f1xL3wOcspTc2E4R 8hhTEbIu66Plo4wdnGPU4xgyLIhloy4qGPqxC35l5oS3OBZP9WZAw8VQjL1Q5I2ipPaG bycw== 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=v3M1/zcFPd3vv+dlrGtUYHUM39vAARLgXsUlmGSKvU+ZBPUEXl33aSTGzxrUXjEZP2 zlHIQFiDuraItVNO+d8K+KbuC7QF0ik/jO/SVkQeNS0d3eacaqjrOXHlziRx7Du3N71u b3o+jVTSQoBdxLaoNnQBaPMhz0hxkI5yl2LC8jRN0AYyFeGps7cb8yNKoiQdMN9ay7Dh pODgf8bGlSHRZPabZ55JPLJajo57OeUUzgQ9xFAChVUNONMYFYaDAtasVdtr8l6yjWo8 2yXpJLdr+YwWIUCz7b+bc7clvjsb9rd5D7ljBwrsnWkDmW60YQ2XbCdaY5tKV3XZDLAW gSYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Th+bt4yJ; 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 t25-20020a37ea19000000b006fee5da6a05si5848502qkj.590.2023.01.10.01.44.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Jan 2023 01:44:51 -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=Th+bt4yJ; 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 1pFA0z-0006dt-VN; Tue, 10 Jan 2023 03:29:49 -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 1pFA0x-0006cg-Sk for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:29:47 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFA0v-0006IH-Gr for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:29:47 -0500 Received: by mail-wm1-x336.google.com with SMTP id ay12-20020a05600c1e0c00b003d9ea12bafcso5778686wmb.3 for ; Tue, 10 Jan 2023 00:29:45 -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=Th+bt4yJ1lcPNJmp7mm2guWyOANYuNWceYvjvU+oRqcRB4ydQ1ifTIcBQBiktd0C6C cwcedNwb75CB+7lHWfu2nLFJB9IyBS1sjdh2pE+ItF4XdghndWH08OM1bxukCVW7iiNG ttBllF+GcbM5Bi6QyVtkNWCXv/DVs/I0Uo6B1y7KHEVIUAHlSQyp1m+1Vh685t0wQDOT 7lwxoO2stSbFWbes7TREhQ80c7+gKNziZz4ktlaUvZ4OkudyZD/ulLiMUVY383iA7qJ4 a61J93MviWrke6JreQEb4GBpj67WYxVqMtrI4MSe5LhwqEM0aoecQdU71i4ttj8OWuM4 3Yfg== 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=4tHJ3XWi4EyMqWR3npsLfFvab8TKizNfGB6+myyZkf69nVyzfLsf4ztqqs7573uDzI kxyL+qXVnD1ZV5oWob6msqyaH5g0UH03Diw5KYbZ5XeGF5excI04ZHMsDJ+2M5BXlmkU EE7tI9OuRAcEtAJEULdaYLMmS619VrjfmsDEBwLkZPTkIAChHeZ3A9gfDEq0MhgIY2mB 1FAZi5U0Cm+tH4/GrTeU7byqQTzz1GSCKMoG2fKFddXwTeSyAqkKZd3unVmiCWnqcSY0 Nz0VZxy9+XuJCHXlVVyf2ysTmnm05OLH6H9UeO3HEhw/2VZWsIp+Xf4e/pHy9Gi9P0p9 1FpQ== X-Gm-Message-State: AFqh2kq+omMOqduQsRe/XWL0cgNt4F3zJEshS5nBf+nD9Zph45XIv5sX 9lCn3tvknTpu4wJtOhRP/dN1Z7cMScbIcZnw X-Received: by 2002:a05:600c:1c11:b0:3d0:a531:5413 with SMTP id j17-20020a05600c1c1100b003d0a5315413mr47868871wms.34.1673339384053; Tue, 10 Jan 2023 00:29:44 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id o21-20020a1c7515000000b003d995a704fdsm13949842wmc.33.2023.01.10.00.29.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 10 Jan 2023 00:29:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v2 2/5] hw/i2c/bitbang_i2c: Remove unused dummy MemoryRegion Date: Tue, 10 Jan 2023 09:29:29 +0100 Message-Id: <20230110082932.24386-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230110082932.24386-1-philmd@linaro.org> References: <20230110082932.24386-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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 Tue Jan 10 08:29:30 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: 640838 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2600812pvb; Tue, 10 Jan 2023 01:39:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXtXsGUhSzoz/JZ+tEEPdcIGdfGoBLUmW41U1Db/Pz8qXTRq6Zn1kO4JqhtqnX3/vOlH/NQc X-Received: by 2002:ac8:1e19:0:b0:3a7:242:501 with SMTP id n25-20020ac81e19000000b003a702420501mr102264571qtl.46.1673343564452; Tue, 10 Jan 2023 01:39:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673343564; cv=none; d=google.com; s=arc-20160816; b=pHOrIEWI1WZh98bI3zTKH58fdGgenj+vQds1CN3hEcSuqUtXj/+Gq0f4pVLhBa3hFe 7w1XgVrFsi2lF72M2QvW1No4IkJNXMd4FGT8JSmQx8P2HxvFY+68JPTG98O+RU2DqbHX DQi+w4xRkmLL1fh4Exr1RanZkvDOLyLvimp8T2cGELHfANvNfUR6CyjsYjuX78MQu2al 6m7Zr5OwLxXFsOa+1pjF23AgrMztB9R5NWyqtQD9xDq6hT+OoIugk8nWJGawgVg47YnZ xkxEjnjHyn6KADACMpZIxQmtqFQy8TGauo8nXuTTNb9tC0L4n6jhUhbid+LgFE1QtVlH ehPg== 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=jhZ7THQ4caN9EvwShv45S8vs+c6OkD3KQH7K+/gPY44A6kg6I0MZhhENsb4l0E7SUf veTvRam8yxqHaRHroHG/QYASDGZr8pFP/4IOuAv5Q034wO56pEnLexE8qdoL+5hf0TRj lGwbaL2o+oxXEXEwP6dnrLgn3ukQntrmQJ9INYNLlFjDOkUVa+7llsODmRw1Fx+kMbkw OKZLav705tOadQTsglzUAi/pmAeSvqrsCGZ8nt5NRPYzsgvGcGDi1Hm2Y7aov9iIIX4u 6Yhg4c6zq85/frk4KaPnthXM+itOzRV2TTCteVgSbr37RR4VA6nWEY6izUa/GjMtlv6d EFkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IhhgT/jd"; 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 d19-20020ac851d3000000b003afe9ee26b7si15013qtn.641.2023.01.10.01.39.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Jan 2023 01:39:24 -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="IhhgT/jd"; 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 1pFA17-0006fh-5M; Tue, 10 Jan 2023 03:29:57 -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 1pFA11-0006eR-Sm for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:29:51 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFA10-0006JN-CH for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:29:51 -0500 Received: by mail-wm1-x32d.google.com with SMTP id m3so8200357wmq.0 for ; Tue, 10 Jan 2023 00:29:49 -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=IhhgT/jdED5YXPhBH+OO3KYG25RU8oHkoKptSPMMkUnvrq14RWge8xot7+BYF/fYoa IaTA3ZiPJpi6oEoZd6PTQVbWG19MVIgK8ftcN9yXUO8/yWGOsYHDaSs1CIdGaaFKJnFw wYcriEdUxNH7+5Q1kj+bk5xgiBb3YhCFXoiGe1mOwD66anFS+8mTrkHbgJqPX6DkFa9i D15FCq9Yn9OgmbTvVrp2GLhTsFD/wzhs2fxME7j1YGeTo+3AGRUrJCeO72J/hQJNeJgd kF1i1Elf94RvJ51+/XFTS7sHeGD1urKDepnvnANCumMrir4PbVmOwjboXRQHfGItpObo YJ3A== 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=abF+unEnq9nqf3wEKICqsGXcIMEvV8NQdDoklQYSfbDLg+4RAF3Ml84gPDdwT2KOld 4iwNBUI2CRjvDHXMyw9tKWY8cgZVAVM5HDfgoGd5aghvGxG6bjZXjbhLBumJyDYEWPoJ WYP/VML9RZhWqa2onPD7MgXHe3eAA1cbOFhlGBR5tBfiOTV02b6cLZglzVNwqCM3u+Yb k+xVk9HmSbjKnILpHQBRXWZezQ6c/o/JkFLYOfUb9okjFxir36a+ZMVHKN/O2cejkd3P oNzeqc5CoyWU5lcAndmF5aT4bsNdQJeEA0nj2BXrSaHI1gULuzNAqBK2yCy/1VQ7yD2g Tr4Q== X-Gm-Message-State: AFqh2kphh0J50THQq4ET8UjFTcmhMLKCzlIafWHnC3KGAgRvY8ACZUbN gxTylKQ7SuWTrXoJJcnhVT5F8xCRvokFVGQS X-Received: by 2002:a05:600c:ac8:b0:3d7:7cea:b410 with SMTP id c8-20020a05600c0ac800b003d77ceab410mr48541017wmr.33.1673339388858; Tue, 10 Jan 2023 00:29:48 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id c18-20020a05600c0ad200b003d9c97d82f2sm13869803wmr.8.2023.01.10.00.29.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 10 Jan 2023 00:29:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v2 3/5] hw/i2c/bitbang_i2c: Change state calling bitbang_i2c_set_state() helper Date: Tue, 10 Jan 2023 09:29:30 +0100 Message-Id: <20230110082932.24386-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230110082932.24386-1-philmd@linaro.org> References: <20230110082932.24386-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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 Tue Jan 10 08:29:31 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: 640830 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2577304pvb; Tue, 10 Jan 2023 00:31:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXt05K0sycIv8HEjY88Q6lG5J9cLL2Sf2+RqnfPK0hxWMuBYhxP6Y2lXaSIYfzL5Mu7QYOhx X-Received: by 2002:ac8:4255:0:b0:3ab:6b5f:6679 with SMTP id r21-20020ac84255000000b003ab6b5f6679mr86832397qtm.0.1673339483193; Tue, 10 Jan 2023 00:31:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673339483; cv=none; d=google.com; s=arc-20160816; b=em1kLmuYu9pFD26zno5Idl4ifAEU+nofGJncyUW5rLiIICNXdNNna9SxZG/by0N+Uc q/Z2M/6nzSCIJrsyDnllZJjoBEbTm/OXMo7y2RFClY3RK8/oe1SeZO/yBNj7POwTzDop 62Y0BEzxkloXhKLf+enkSoZ6WM04eZtMybePZliR+lTe+XoCQS6hRt+xYFz/duam6w/4 lS521RlMIENyH8oXP5FTEPSR+cpeZMHk20uHEZhfZWBydi019CUm6hzS9wyIt4UmHdP5 9eoFBx2xKz7EYSk+KODvNvlbYDlwdVS4EhVOEKKeKbieTWgDh17R+Lxloi4PuHvDZJ9W lAYA== 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=s3fAH0u4CO+FRORAz0QlHL8PSjAcVIMkkv12suNzz80=; b=ywheSBVWl6G2OTqN6ssMjXyHzbPccspxf1MejBhbDu7Nw8XPSNcA3jRWPFHaBWzf75 QbiCOzZRq/tz5QseAsa6J1oHD4z/1pVV1DE9dxm5mMspu7jRk5DI1jCcQfwR1sAbKe/E KI22hx2UIKHrBq5Dr71R28xTvwtURIA0/jFU/CoxNw/ht3t9JB37YdDmVrUdGiAoA9B3 Rh08GyIX6YwFDhXpAuajMkXwADTfAAr5oUF1QXYs3MZ406eZT1rNoxVLsbRbG+lzoMQ3 1oGsJvQ4gbKAT474hpuJ1ot7ukWJXy/3xzKqvHQ1cO8djG0cMxZ3gj+3SN1LgEh04Auf Q6aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kqb4yADb; 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 r23-20020ae9d617000000b00705b5a77153si3068182qkk.55.2023.01.10.00.31.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Jan 2023 00:31:23 -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=kqb4yADb; 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 1pFA1A-0006ho-S4; Tue, 10 Jan 2023 03:30:00 -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 1pFA19-0006gx-EB for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:29:59 -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 1pFA16-0006KD-M8 for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:29:59 -0500 Received: by mail-wm1-x32e.google.com with SMTP id k26-20020a05600c1c9a00b003d972646a7dso11167864wms.5 for ; Tue, 10 Jan 2023 00:29:54 -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=s3fAH0u4CO+FRORAz0QlHL8PSjAcVIMkkv12suNzz80=; b=kqb4yADbvtKvCnlbrNu9NIj6vjEzfUz7MjJsVWdfHRHd6SVBf7j6Y2l6Aes7kg+kD2 ttmODfhIPtZ2UOQN3OPJZ+3rRT+n/nnVYzGhYMeUWHny9svEcKlgYOKS9LPcYzOn2YtH pTEsFeyNtdqwiSIspy/7REabfK/W1EYM8RoaFL7kKGsI06KOWTDv6h7fyKfDk3t758Za rRTlAz+HBn6e7+LgWhFPDnhOoPHz+sb6v23dVQ3n/djjFEHPIVK/3IiBHLMoFyusudj6 mpg9YXXB99SwHV2vldlwtZXIcBvnLCZsCcctHF7MBJp3iXDaWfvl2QbmRF/f9/L+8j+l G3ng== 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=s3fAH0u4CO+FRORAz0QlHL8PSjAcVIMkkv12suNzz80=; b=Q17+13NeWW6AUnaG33bxq5cM8IqSNdFz34YRv7gwhYteW6B5Xn5gDAfmGKvsZXSELa Yz0y/wA63QPhaAVrkkhTXN5zSbZwurxe1LNCc791EVB/3tsx78CsucOtTXm0XbRrLaty xLRu5E6doFVSiGFewx5G+N8fSQ/oIR+fLXlAc8cXKQvlgWqBZcGY1y6XZu6KxdDzPKCP ar10RcId1nz5WdBkBeLA7HXgvocJXRhexbULRV+03Nywu9k51yVKGGfF/HjeqXWvws8B jAY4vUoA2hd9/lKZqEEwYmfCDKpXZ54+mnmowtvaRumCqJIo9lgU3p7ipf8AQRF523O6 ebQQ== X-Gm-Message-State: AFqh2krTeeDG682boMC7GuLjcXzrmeheTcolbB37//FCiZVUTaORDn8u LjqEdkp8uuycecUrbi/t6Od0XBJnEcihHpkA X-Received: by 2002:a05:600c:248:b0:3d3:5d47:271c with SMTP id 8-20020a05600c024800b003d35d47271cmr47600987wmj.12.1673339393679; Tue, 10 Jan 2023 00:29:53 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id f11-20020a05600c4e8b00b003d04e4ed873sm20981447wmq.22.2023.01.10.00.29.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 10 Jan 2023 00:29:53 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v2 4/5] hw/i2c/bitbang_i2c: Trace state changes Date: Tue, 10 Jan 2023 09:29:31 +0100 Message-Id: <20230110082932.24386-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230110082932.24386-1-philmd@linaro.org> References: <20230110082932.24386-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 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..8a67ff6fae 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 *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 Tue Jan 10 08:29:32 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: 640836 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2593688pvb; Tue, 10 Jan 2023 01:18:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXvySXjCp7vha+bG76c7E7IAxJId3QPMJQhwBZAYpNxCDTCLZwDtuoFeEbsF7aTcjOcgHuS4 X-Received: by 2002:a05:622a:1c09:b0:3a8:1e9f:47f5 with SMTP id bq9-20020a05622a1c0900b003a81e9f47f5mr92050191qtb.45.1673342286976; Tue, 10 Jan 2023 01:18:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673342286; cv=none; d=google.com; s=arc-20160816; b=Vs+lYVU9YFPr7IxbEBfno9B+aWl17vqJYfboGg+Yo8cZWcHTjOU1c3EZOdU/sHXoB1 M8fYt9KUIQExOpm3teshCEk1MF1/l2FDXIc++eKLWAHYXA9Yqq4Jns89T7GjI+FbYtvb NMgo+a4MJsoDwiL6BEFjGS/k/HKVw0g3MEPIL6RpeTiEV/caqwZeS2HdrDZtnmCRezKX duiv+jOQl+rBy+edlQUAXE3R/Nc4SDY9gh2ehS/5UQiP8m+zXeV3l67vqKs6x3OmAu3I ZrUUbRZdYmkUNCxwvpz8Ab//G2gMk8fA/OVJs5gCis9J8Wi8w7eWaFH/mmhAp7xPjOKa Zsgw== 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=YTYPqD95cY5TwqXLZ5zIgXtmsM6zTeYLc7VV77204BU=; b=x45jQ7m/W/3z7U8K3I+BX5BouQ3n8Tu467P2ek8dOr8YvmpDx2MF52TUamfT4KlKxH SXTBJf+k2QKno6tvT9DzFJpeomMFatn82R9erL83s7PROht65/fcAMNqEs/wjuH8DX3u gNrJHt9vKR8xDKgOB6YPzkEjli8phZ+siTtzUDPeZGFdwFbfa3PECCUG53M+e8Whk8RZ yrH4CJFsyesfOjnrFw0jPW5hlwvC1mowJo0Hy3qfAP2K+BFgRbm0xNlGnM/o17CsWc55 WY22jn+et1GCgAQPyubD9Kk8LwMR7R5YIj4NQsXhEU6DL9NnYhE5pT9WNEnN6NtUAlNm ZXIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eggjPYCc; 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 v6-20020a05620a440600b006ce8a7187d1si6278826qkp.36.2023.01.10.01.18.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Jan 2023 01:18:06 -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=eggjPYCc; 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 1pFA1D-0006l1-NS; Tue, 10 Jan 2023 03:30:03 -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 1pFA1C-0006j4-1p for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:30:02 -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 1pFA1A-0006Kk-1U for qemu-devel@nongnu.org; Tue, 10 Jan 2023 03:30:01 -0500 Received: by mail-wm1-x32e.google.com with SMTP id ja17so8178981wmb.3 for ; Tue, 10 Jan 2023 00:29:59 -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=YTYPqD95cY5TwqXLZ5zIgXtmsM6zTeYLc7VV77204BU=; b=eggjPYCc4xn/NK5p5yg68Sq4fZyFvEQtpAOmXKiQ0G+NdIfSHKHWSriObpl7Cvz1FE 9FV40vwFJmLxn02ypMbOi588HbamYm27/7Cf6fjbwGsgN5dE85Fxn65bFleAmA+5ufdq xjwBI8Zzs+7HyD/6iBW2ufpD3jylMG29FMO8qFzEgfn/oXxp9QtcSf+Z0gs53AGBxR3V +HaXe9wRAXcv9azkxqVxdWQ1p45VMsQDUvOoqU+p4gNTNgqldz/NpSa9/eJs70tM6mt9 uGnwcS2iDhidHTR8n9yY5gELuhYxtY9PJhSCPnljM/fuTIvjOT2cYxkfvQ4I0OCDmHIU ghZA== 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=YTYPqD95cY5TwqXLZ5zIgXtmsM6zTeYLc7VV77204BU=; b=duX4PjxwclOQRMNjQpT0/4KGVamncQ5Y0YFsk2mglzwSVveCyF9zlKwfB1ghejrcFV W3PP0R20Kt09bDoZBcak6sP/NLGTiEP9ZOrcGfIhqvc5T/JVMKGChz4/ae9AAeoJs4th VHplzps+34mgGeMmwamkETrn5bZTyHV8qMdXqGOGiYxUD1z7tZLxOQn5wyKkZF5DnBMg Ntvu2Klzpa90SHNFIXiYr52vDVNGboUsLVyaZSX2VU8QdT+YtK5WtfUhGd3EPJO70UW1 40eVdMuVET6271AK7LP7vfm+QNkk+OjLNlpWSSe55b2/JtB6hKvAhKtcd19dVq8rDoGZ aVmQ== X-Gm-Message-State: AFqh2kqEh7vGI5yXrw2OSdDqKLknf017InUcAxtVaQva/yaaku0sGQZy xDssb5Upb6QOGGzSveLpComfZD7abNUbLxoe X-Received: by 2002:a05:600c:4f48:b0:3c6:f7ff:6f87 with SMTP id m8-20020a05600c4f4800b003c6f7ff6f87mr49313237wmq.11.1673339398585; Tue, 10 Jan 2023 00:29:58 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id o5-20020a05600c510500b003b4ff30e566sm841192wms.3.2023.01.10.00.29.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 10 Jan 2023 00:29:58 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v2 5/5] hw/i2c/bitbang_i2c: Convert DPRINTF() to trace events Date: Tue, 10 Jan 2023 09:29:32 +0100 Message-Id: <20230110082932.24386-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230110082932.24386-1-philmd@linaro.org> References: <20230110082932.24386-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 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 8a67ff6fae..d6589f0d4a 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[] = { @@ -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