From patchwork Thu Feb 15 17:35:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 772933 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp954414wre; Thu, 15 Feb 2024 09:39:34 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWm6Dx7qvRjSKDdNKkSaaSiZBWWP3U6Y/AIktQnXMVfuZ6uVEfHXIXhSiv7dlttQaGMip2GWojXTxONbrU6u+dA X-Google-Smtp-Source: AGHT+IGAp6XSeVwzd5bTnwkSdwI++401q8pewzUcldI4MecKkqg/+lnZHAheb6nng0y4d7VnjP/A X-Received: by 2002:a05:6808:1818:b0:3bf:e9d3:f405 with SMTP id bh24-20020a056808181800b003bfe9d3f405mr3081986oib.36.1708018774571; Thu, 15 Feb 2024 09:39:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708018774; cv=none; d=google.com; s=arc-20160816; b=ta9CNattnAri65XX05Xh0MXuK9KAQK9f72HjKorU4Pii9ToPEBj9+WC87Gchtz3O5Y 5uDaccW3jtpPzcq9JuhWyEyp4TtC9XoBUt04cPvmmOb8i20lBVnuFpK/kx0B0EoWXmMv 3khncrhKEF9mwImm1F5ex4jcM5ZL7iFBKoHUh++eROZWPeAcJ/rEkthiI2OwmIMW+AUL mLh1SpeIaaG2bZwLSukFHlGvJi8rHgWwmqSBvavX5lQhFrTdLR7ICxl4pRXS3ocWmO/o S42LlA5VZw05ryzkTuobZEbX0v1ngjL4qfZBubujgFh8EdhEHcCojTznrVB6sT4hojtv 9AXg== 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:to:from :dkim-signature; bh=o3y6YUYAQdESHng1mrtNwKZAA53wIJnmasw8N4/0cpA=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=U7EdbNK9fLLCn7MfFZheX/GlZ6oVht7fMKsQaUzlIFhipOhN7YpT71NQFprEaMW2/B LpOs0kfj/DerFSMZfXOEhhE8Tz95+9Ze/N6Pd9lGZFHahf6HCpZvssAEMlOlq6fWUOUp WUFT6Gj5RvReOEjxADZ5f9GnJzsA0f8PE0B/LBoXZqPNmYrTlQxN87hMCqhJvF4bXpDF MxN3aPvOn/8U0IeH8/XO64oYJURA99jHfB2lRy5NauzOi1m2fi5cfPnp8pVsqjT0wOA7 23a1t5Nv+ibIU9VGe8EFfQiSeFqqafOoe2ljLhWKeabA8c8F1LC5WAD/5Mdho4wQYfIW +UoQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pv+KMq3K; 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 t11-20020ac86a0b000000b0042dd9db8bfasi185921qtr.66.2024.02.15.09.39.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Feb 2024 09:39:34 -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=pv+KMq3K; 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 1raff5-0001JR-DB; Thu, 15 Feb 2024 12:36:39 -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 1rafeN-00082F-Ba for qemu-devel@nongnu.org; Thu, 15 Feb 2024 12:35:56 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rafeH-0003yZ-Sa for qemu-devel@nongnu.org; Thu, 15 Feb 2024 12:35:54 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33d066f8239so454849f8f.1 for ; Thu, 15 Feb 2024 09:35:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708018548; x=1708623348; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=o3y6YUYAQdESHng1mrtNwKZAA53wIJnmasw8N4/0cpA=; b=pv+KMq3Kf5KlN70FTlTUDShhmpJRNZzLEgjurfVECZ63zH/Q8iNt0HD9gGkc/RN82J zFjC/kfWWC2XnyFV1fV3ZbFIWYUKSVm2ZK5jElevkmBwPgzgWvY2SCp085YjZtottgBf Oin/sEleWF0qXvgqW/Li6U0mt6Y/qtzG30A3GjWbNb2J6VVsOKMaDz3sRlWstBBcdqUb ryAYLiNrIfDFQPWo0GhyQXQ6N1lipxaWfUqpSpUScVI2yCFj0kSZtYCV0pZgulJh4PF8 xcEwN4G2zcPVCihoISNCM22Id5vYh8pxdmMYjWzJR2btJoO9mzOdK0ZMLzqI9w1AvNuo QQhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708018548; x=1708623348; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o3y6YUYAQdESHng1mrtNwKZAA53wIJnmasw8N4/0cpA=; b=bcPWS0Ggp4io+86w1vLTXdBYJzNnmF1uW8tVaxec41zFVKe3yIjSCBuSXnNo/lImCE LA38coPvTKXpTIos64XYN4QOeuvnyWfzGIDa6wKEmmx9HHEzpkoFRxTKuQTSKLa4D94m uxBd3C5y7tU+7O9QnSBCRwCjUvM6ju8U23nc5ntnO/OHy60iFbE2Sw1yCD0T/g2kJTon DAvrzoqYkgpN85KSkGbTvlMzcWHtNsx7LT/b7uuMfdiKrPnf3xdlvr92XROG5CzQkRx3 MknZtRn1zFAiKiKShiEG2bkmcTIigNHDaBUrCSd8huKSfDdcNBTEttOdQ5i6fafgxy1L bF4w== X-Gm-Message-State: AOJu0YyFyeNGUr3ZzDUSMagY3A96kClVlXhnVN8PDb8OYf12hDunot66 ppUjtk/DbPhXlYmsxo9KNgpoV6MFJJa3rp8Aj5vuddhFdke0plbnW78LdEbSbEq+OP8Ug5ro6sw Q X-Received: by 2002:a5d:5106:0:b0:33c:f574:3706 with SMTP id s6-20020a5d5106000000b0033cf5743706mr1864803wrt.63.1708018548354; Thu, 15 Feb 2024 09:35:48 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id q16-20020adfea10000000b0033cfa00e497sm2384129wrm.64.2024.02.15.09.35.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 09:35:48 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/35] hw/arm/stellaris: Convert I2C controller to Resettable interface Date: Thu, 15 Feb 2024 17:35:23 +0000 Message-Id: <20240215173538.2430599-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215173538.2430599-1-peter.maydell@linaro.org> References: <20240215173538.2430599-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Philippe Mathieu-Daudé Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé Message-id: 20240213155214.13619-3-philmd@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/stellaris.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 4fa857970b4..d3a12fe51c5 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -462,7 +462,10 @@ static void stellaris_sys_instance_init(Object *obj) s->sysclk = qdev_init_clock_out(DEVICE(s), "SYSCLK"); } -/* I2C controller. */ +/* + * I2C controller. + * ??? For now we only implement the master interface. + */ #define TYPE_STELLARIS_I2C "stellaris-i2c" OBJECT_DECLARE_SIMPLE_TYPE(stellaris_i2c_state, STELLARIS_I2C) @@ -607,10 +610,17 @@ static void stellaris_i2c_write(void *opaque, hwaddr offset, stellaris_i2c_update(s); } -static void stellaris_i2c_reset(stellaris_i2c_state *s) +static void stellaris_i2c_reset_enter(Object *obj, ResetType type) { + stellaris_i2c_state *s = STELLARIS_I2C(obj); + if (s->mcs & STELLARIS_I2C_MCS_BUSBSY) i2c_end_transfer(s->bus); +} + +static void stellaris_i2c_reset_hold(Object *obj) +{ + stellaris_i2c_state *s = STELLARIS_I2C(obj); s->msa = 0; s->mcs = 0; @@ -619,6 +629,12 @@ static void stellaris_i2c_reset(stellaris_i2c_state *s) s->mimr = 0; s->mris = 0; s->mcr = 0; +} + +static void stellaris_i2c_reset_exit(Object *obj) +{ + stellaris_i2c_state *s = STELLARIS_I2C(obj); + stellaris_i2c_update(s); } @@ -658,8 +674,6 @@ static void stellaris_i2c_init(Object *obj) memory_region_init_io(&s->iomem, obj, &stellaris_i2c_ops, s, "i2c", 0x1000); sysbus_init_mmio(sbd, &s->iomem); - /* ??? For now we only implement the master interface. */ - stellaris_i2c_reset(s); } /* Analogue to Digital Converter. This is only partially implemented, @@ -1396,7 +1410,11 @@ type_init(stellaris_machine_init) static void stellaris_i2c_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + ResettableClass *rc = RESETTABLE_CLASS(klass); + rc->phases.enter = stellaris_i2c_reset_enter; + rc->phases.hold = stellaris_i2c_reset_hold; + rc->phases.exit = stellaris_i2c_reset_exit; dc->vmsd = &vmstate_stellaris_i2c; }