From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687607; cv=none; d=zohomail.com; s=zohoarc; b=gEtH6Zz8V1MgT4bLyMJURwW8+0mHcIS2vA9lhLlYOrzyqhtLrvJaXdaZxQ75KiEEuyQLUMYTmZ39PDgban8fmb4bgrJYhwTxbU3iP5nZH0MWKCk0LP9p+xBg91pAGVEfUfxVyYqnxSIZ6/hiRhEaWVAKN8wtma3KNTP30VW9O9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687607; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0qhLZDHg7NiQXkA2abdR5Jwv1JYEcxWzvNhuxbCREw4=; b=jvnrStqsEu8uTAiPXMOc83FSBTDSKW8QzFYlgWcZKgNU+RTIYyVvww+nJhAw5sfUpXasXy2oipFK4b7xbXIuqwjjfOPMByBS+QTGxJmHG9xujqHctHymJAkkom4okjFa3+Evf8H1Pt0Na/5cOSquNIDTIKPIAY8DfEno6GiXQWg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687607696414.02035913376267; Wed, 18 Sep 2024 12:26:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gk-0004Yo-3N; Wed, 18 Sep 2024 15:23:18 -0400 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 <3kSjrZgUKCswBsD07y66y3w.u648w4C-vwDw3565y5C.69y@flex--tavip.bounces.google.com>) id 1sr0GV-0004S4-IC for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:04 -0400 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3kSjrZgUKCswBsD07y66y3w.u648w4C-vwDw3565y5C.69y@flex--tavip.bounces.google.com>) id 1sr0GT-0007I0-AR for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:02 -0400 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-2058456b864so2747935ad.3 for ; Wed, 18 Sep 2024 12:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687379; x=1727292179; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=0qhLZDHg7NiQXkA2abdR5Jwv1JYEcxWzvNhuxbCREw4=; b=lzJlkn3kyUpaFUTeKVL7PMy82fs5jPdTYX0XT1EDVK+2gWxv4a4bItMBMN9xpXHLC8 TCkJ8Izp4AEfKT6VUf0727khPsQ3YrYcnhCQbXCLYNaQ2zrzjkuOWIKvE2MtrLiG5tcx CBlNq+1wilmYRM6m9YygdmGCBft13vvCgSjqV7ReLoLu2tb+xn7E0PvSHnU9Hj1srZeK UNODdMyfjcgUED17gP8G/dHTPPEYgmuHJc6XJKQTSz/gjstD+QXv6H82QzDE9V6EBkok Q7R/t+gsgp+b3aNwL2JMbJDBXJUDQrkneenvrqwoeooD00+OUfaTx7r2jHpeHQ+w6yxQ s4SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687379; x=1727292179; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0qhLZDHg7NiQXkA2abdR5Jwv1JYEcxWzvNhuxbCREw4=; b=prUF3cYtqIDeNHe3EZv26gq3f7RZL50AGS7rf/2VP0sXnezABIwNn8vFlcs8m7xPL5 sqIFDxJU9CEpygw3avojxT2+sHK0YcnX/kNL9YNVEWyZ+7ebJdJJHfJeXlUEVaPTtoM+ mjf6PWboeLcHa36wUsSyW1eqbu1zxLlTwNuBRrQ46s/6up5zv7vtXKXCfCQ5Jbe5h2yv bL5W1v5c+9L6s1u/t7BZTPzOzXQJuQ7DOCm0++jGuGjlJu/7pj0dE5MF74BXFgvWYPQM c24aEcoUnHZb7E3W/3r0KzA+p5uRSQZjWjMN7YjsfhEfEsB4KJ6DtP7+ntvZtzJCfhpY USyg== X-Gm-Message-State: AOJu0YxpDH031Ylwat5bOVOvRNshqbu1oO8xfvRInQusWfjY+eiL6GNX h/3k8KBtIKOHNPYszBKLolWbED4YNh7nEFffNbgxR160clpX9mQ1sdPyamozkigjHME4XDEEFbq 2e+n3lumuB7adhIVsRUatZYz6j7f7+5Thz/fdIHRTQ4PYjEnRcBJT8iAAALeaBD7HyfcULTcrec sdU4jMXXLc7ToVuL4uD4s5Gea0Tw== X-Google-Smtp-Source: AGHT+IFn74F2I+W5pdjmXSv3xKnh6wy/Ob5mCc0z9361se/ceg12NjtuYInIsgZFd385X9SOmLfUq65Lsg== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:902:db07:b0:206:adb9:a12f with SMTP id d9443c01a7336-2076e39d640mr14692255ad.5.1726687377663; Wed, 18 Sep 2024 12:22:57 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:29 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-2-tavip@google.com> Subject: [PATCH 01/25] fifo32: add peek function From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::64a; envelope-from=3kSjrZgUKCswBsD07y66y3w.u648w4C-vwDw3565y5C.69y@flex--tavip.bounces.google.com; helo=mail-pl1-x64a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687609222116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add fifo32_peek() that returns the first element from the queue without popping it. Signed-off-by: Octavian Purdila --- include/qemu/fifo32.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/qemu/fifo32.h b/include/qemu/fifo32.h index 4e9fd1b5ef..9de1807375 100644 --- a/include/qemu/fifo32.h +++ b/include/qemu/fifo32.h @@ -140,6 +140,34 @@ static inline uint32_t fifo32_pop(Fifo32 *fifo) return ret; } =20 +/** + * fifo32_peek: + * @fifo: fifo to peek at + * + * Returns the value from the FIFO's head without poping it. Behaviour + * is undefined if the FIFO is empty. Clients are responsible for + * checking for emptiness using fifo32_is_empty(). + * + * Returns: the value from the FIFO's head + */ + +static inline uint32_t fifo32_peek(Fifo32 *fifo) +{ + uint32_t ret =3D 0, num; + const uint8_t *buf; + + buf =3D fifo8_peek_bufptr(&fifo->fifo, 4, &num); + if (num !=3D 4) { + return ret; + } + + for (int i =3D 0; i < sizeof(uint32_t); i++) { + ret |=3D buf[i] << (i * 8); + } + + return ret; +} + /** * There is no fifo32_pop_buf() because the data is not stored in the buff= er * as a set of native-order words. --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687836; cv=none; d=zohomail.com; s=zohoarc; b=m3b1edQp/cy6jf4w0vkzYqI1OmKTZh8lLbcyvjnhGiRYK+InlAKOxrGshG9OF11GigJfhqFE6Xg0MvZ8/zY+W5j8g5E7DW3DtG6s9D2WhMRtR/bae4yXSVt8B6AQ1CdTr+UDw/3pPE3WLPiigQsbT9VCp1W6AUK/EpH/9pttceE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687836; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Is1Pe9Ut7+FUOXRSBGio99L8BWy9EslIqrLBu7QfCA8=; b=UcpW0Y3gbnegIWv05O4PPizK8m0q0Q/OeiFxwR630aqa1yHQIWDKmf0GEvj7W8vSPcfpLzIiqExzjV5qw+8qArH9J2gbJXxbi+3mqnP5rNuniDVkvfrAd+FNeCOOTEr6x/8Y9uvkfZATAvmDzBAzTiT3MUm3uLT/MWQczgDcr6Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687836546645.524457932969; Wed, 18 Sep 2024 12:30:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gn-0004n0-LB; Wed, 18 Sep 2024 15:23:21 -0400 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 <3kyjrZgUKCs4DuF2908805y.w86Ay6E-xyFy578707E.8B0@flex--tavip.bounces.google.com>) id 1sr0GV-0004S6-V3 for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:04 -0400 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3kyjrZgUKCs4DuF2908805y.w86Ay6E-xyFy578707E.8B0@flex--tavip.bounces.google.com>) id 1sr0GU-0007II-B4 for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:03 -0400 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e02b5792baaso167264276.2 for ; Wed, 18 Sep 2024 12:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687381; x=1727292181; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Is1Pe9Ut7+FUOXRSBGio99L8BWy9EslIqrLBu7QfCA8=; b=2IwRO8Kja88wJ94RMDtGQzxOQLop42HhVFpqZsYDsHz+/hQxj3KRb8UQJt0qJhjQKN 0c5I8ObRYQNGAgt76qSQbKBpO3pnluugcnOUOtLdTzKwNVKJR4ikfCJwQTBaX644Aku8 TLJ/nc9I0VIODmcsFbTTLCn/yhWbGjralwu1UsXuSr08ZxvBYrA87RVI46rkYHLf658l u7nhV8PrZBSPSdgomG3eTguzZNgbzbwQbCcoNOVO9tHqOvT2RoOQLLKXzkB2/1A7ES+H HACbYAANpr4ZKXU8jtUho//9XyL2C5s1ydQ0m+owmKB5qDMvibVqRKsAbievR3xe2C9b 7ENA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687381; x=1727292181; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Is1Pe9Ut7+FUOXRSBGio99L8BWy9EslIqrLBu7QfCA8=; b=K5UsYYWpLAhd8SNUYbQc1cAz7MUfW79Cmgn3PIp1iA2JZnYt8fixPJCPViIPoLx100 8qN6sTQ56US2KZWuaaCTI1Gr2St2e8+OAgO6AsnXv4GV7v+3VVTxLO6IY03mSuzx/dAH bJlDD7LySjsptD55AK5H3/68eeaNuIGRuCA7fzLsYqszCeVhpoCqDHI3FsOdFCuL6o7y qTgg1XgtiCuG1qfjJudzcpyHmwKCuCuj/fOGqZX7MIg3iB1vGVtUIY72pyPP6JJ1HGh7 xz6EnXiIKzFwcvNFaAklNpu8IaOrT1XMa3/vNodLsuvxnpW2r1oKY2Isrxvz0YZ91Via tEqg== X-Gm-Message-State: AOJu0YzB+r5IoZ2trHjQUieJdVpUffBRfxmlw7WAVklfKHOOVTByJEkB 42gNpZeJo0B+izeg36QYpSjsB8HMzPfJXk98tEkAd92UjIlCGUX5yj2Rr1kXE6B6o8kbMZVfLsC mLLlB1OGRHZ6QAPgXub2MwcZxFv3Le+lwuGWKD28rzvqtFsnM27hNCgPtk1VBn6BfPpbB+GmBun 2X/wY7ehb8s7BOn5A0htPMtMEOeQ== X-Google-Smtp-Source: AGHT+IHkySxgEZYLi4WMd7ZmcuN6KJFEPSj3FgsG3HRJR+GWFLkWhXgxPgIOftl6XFM+Gn5BP1pwrnQ1cQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a25:e090:0:b0:e11:584f:c2ca with SMTP id 3f1490d57ef6-e1d9dc3c15bmr55129276.6.1726687379366; Wed, 18 Sep 2024 12:22:59 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:30 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-3-tavip@google.com> Subject: [PATCH 02/25] tests/unit: add fifo32 tests From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b4a; envelope-from=3kyjrZgUKCs4DuF2908805y.w86Ay6E-xyFy578707E.8B0@flex--tavip.bounces.google.com; helo=mail-yb1-xb4a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687838501116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add push/pop and peek tests for fifo32. Signed-off-by: Octavian Purdila --- tests/unit/test-fifo.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/unit/test-fifo.c b/tests/unit/test-fifo.c index 14153c41fa..d0e05ba95c 100644 --- a/tests/unit/test-fifo.c +++ b/tests/unit/test-fifo.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "migration/vmstate.h" #include "qemu/fifo8.h" +#include "qemu/fifo32.h" =20 const VMStateInfo vmstate_info_uint32; const VMStateInfo vmstate_info_buffer; @@ -432,6 +433,53 @@ static void test_fifo8_pushpop(void) fifo8_destroy(&fifo); } =20 +static void test_fifo32_pushpop(void) +{ + Fifo32 fifo; + uint32_t e; + + fifo32_create(&fifo, 2); + fifo32_push(&fifo, 0x11121314); + fifo32_push(&fifo, 0x21222324); + g_assert(fifo32_num_used(&fifo) =3D=3D 2); + + e =3D fifo32_pop(&fifo); + g_assert(e =3D=3D 0x11121314); + g_assert(fifo32_num_used(&fifo) =3D=3D 1); + + e =3D fifo32_peek(&fifo); + g_assert(e =3D=3D 0x21222324); + + g_assert(fifo32_num_used(&fifo) =3D=3D 1); + fifo32_destroy(&fifo); +} + +static void test_fifo32_peek(void) +{ + Fifo32 fifo; + uint32_t e; + + fifo32_create(&fifo, 2); + fifo32_push(&fifo, 0x11121314); + fifo32_push(&fifo, 0x21222324); + g_assert(fifo32_num_used(&fifo) =3D=3D 2); + + e =3D fifo32_peek(&fifo); + g_assert(e =3D=3D 0x11121314); + g_assert(fifo32_num_used(&fifo) =3D=3D 2); + + e =3D fifo32_pop(&fifo); + g_assert(e =3D=3D 0x11121314); + g_assert(fifo32_num_used(&fifo) =3D=3D 1); + + e =3D fifo32_peek(&fifo); + g_assert(e =3D=3D 0x21222324); + g_assert(fifo32_num_used(&fifo) =3D=3D 1); + + fifo32_destroy(&fifo); +} + + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); @@ -445,5 +493,7 @@ int main(int argc, char *argv[]) g_test_add_func("/fifo8/peek_bufptr_wrap", test_fifo8_peek_bufptr_wrap= ); g_test_add_func("/fifo8/pop_bufptr", test_fifo8_pop_bufptr); g_test_add_func("/fifo8/pop_bufptr_wrap", test_fifo8_pop_bufptr_wrap); + g_test_add_func("/fifo32/pushpop", test_fifo32_pushpop); + g_test_add_func("/fifo32/peek", test_fifo32_peek); return g_test_run(); } --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687582; cv=none; d=zohomail.com; s=zohoarc; b=BzbM+J+DtJMtZNnuiox7ATDVOZjvq9uNRwJz2ryKYpMR+NLR1KJKmyayeJ2o6rCRsIeMMY560uzlBbTzYNClHaz/0e6B3Si20JkiY+39H0brFzTgy2WkZ4T+cy3OhyqHHRRH8H4AvY0vv8d3GbNkE3lQuQLLubcDBGS+d7JiQDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687582; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C6JTu3BP64DCbGkO2oFE0GHtGHDLxSzLQw77GKNg3jc=; b=Ru2aArEjfaIpdUKd9VZTjaPEahzuzmeJPDAKV2ohhdaosTBJe7B7+IMPpe2oMI82A2m8Xxb2MG24WheRWZgvOC+FI5WNq4GhbGxpr66jzIe4OZy1dGYH2A73ncb89Uw/5Jtp10Pyc9qTRbgxax7dxViYejr5DcsDiPwnDMyVzmk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687582153414.8354536732825; Wed, 18 Sep 2024 12:26:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gm-0004gu-5J; Wed, 18 Sep 2024 15:23:20 -0400 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 <3lSjrZgUKCtAFwH4B2AA270.yA8C08G-z0H079A929G.AD2@flex--tavip.bounces.google.com>) id 1sr0Gb-0004V1-IG for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:10 -0400 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3lSjrZgUKCtAFwH4B2AA270.yA8C08G-z0H079A929G.AD2@flex--tavip.bounces.google.com>) id 1sr0GX-0007Iy-QZ for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:08 -0400 Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-718d7ec6ff8so78917b3a.1 for ; Wed, 18 Sep 2024 12:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687383; x=1727292183; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=C6JTu3BP64DCbGkO2oFE0GHtGHDLxSzLQw77GKNg3jc=; b=k5LGqpuTIRabb5brQSdi03BE+gCh23Rl3if6MT4DVibKrDmSgXirC0F19sGMVz9lLB uWkrPI4i4uNG+yZMyBxf2/wPxZwk1CuvuOnAbJFVhzsyl439SpwFjitzKmcPcP6wsjm6 ORweoJPn4JdKfBmoq5/IgfxRBEfUyk7njfbVVIsYGUHvVPl+T8WPo1/T/fQfK8+duksr hh5rX8jcVAVcdEe6I86/JCthD1weeipVVGd98aiCBeIDM3ON+/6eL00pi7NRWQWflozq zmUPmeybtGHUetCbRvp/C7kvIFhcidyYLZOtqunx0Sew3cJ42kpBF4hgDsmfXlGuildz UxgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687383; x=1727292183; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=C6JTu3BP64DCbGkO2oFE0GHtGHDLxSzLQw77GKNg3jc=; b=kjbtqjzAAvnqtJEZXzI4RiHi+4hRwoLUjIgnb/f65lCO2Z5R90eG2Gp+D1HlMiwZFR /qFI0CKmgTq/MDCGeW03sMEsRuyZcLClLw6B6zdvzsb1iYFXAadF5SKMUacKuXlMNxBa hCRsyw8Qswz5q+El+01o6aurDLYAiLMOztVVdHdbHoZD1sTeD99WlCEvf6xPLY/sCyww HABk+l+EYpnzPdQtB5oDjLm3MYP4d7jMgFHPbGCgFxy0fOzePPBrOLbdOJs2AZsVxY10 jVzx3MAHS4DyLjmviOuOiMcEdxT2qw+3dPxHOeOwEn5VQygaXV2JnuBGLXP1RbYAsowz SXKQ== X-Gm-Message-State: AOJu0Yx+3HOXSzRc/skPLZEefCdA/NK1p9ihj7p8ObRlhZ04v/3D9G41 f10SuxS9FgRtztOGhXBJHP/eDHYr0mmo79gxB0r8m8jvvgIMMcKl9ULp48ZJkkZ7c2lorZFmqJq TrkZabVovi1xWqTKHbmL+uGX71Wjl6GyBIF72mmGZTYUJwpIuwgOzrhuztN9RYjvkluIYrhTmqn m82niWD52WaNg/gEb46roOIm27NA== X-Google-Smtp-Source: AGHT+IEaqkuEi8ms6iQTiLPJXATA6Sl7fPKHzO0Qelm6fJtf6SBQ8us2t6RJoe9yRnkHcMmbhbmlcPqksA== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a05:6a00:8a84:b0:718:3270:24b1 with SMTP id d2e1a72fcca58-7198e12d13emr879b3a.0.1726687381167; Wed, 18 Sep 2024 12:23:01 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:31 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-4-tavip@google.com> Subject: [PATCH 03/25] scripts: add script to generate C header files from SVD XML files From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::44a; envelope-from=3lSjrZgUKCtAFwH4B2AA270.yA8C08G-z0H079A929G.AD2@flex--tavip.bounces.google.com; helo=mail-pf1-x44a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687583229116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Stanacar The CMSIS System View Description format(CMSIS-SVD) is an XML based description of Arm Cortex-M microcontrollers provided and maintained by sillicon vendors. It includes details such as peripherals registers (down to bitfields), peripheral register block addresses, reset values, etc. This script uses this information to create header files that makes it easier to emulate peripherals. The script can be used to create either peripheral specific headers or board / system specific information. Peripheral specific headers contains information such as register layout (using the qemu register fields infrastructure), register names, register write masks and register reset values, the latter using RegisterAccessInfo. Here is an excerpt from a generated header: #pragma once #include "hw/registerfields.h" /* Flexcomm */ #define FLEXCOMM_REGS_NO (1024) /* Peripheral Select and Flexcomm module ID */ REG32(FLEXCOMM_PSELID, 4088); /* Peripheral Select */ FIELD(FLEXCOMM_PSELID, PERSEL, 0, 3); /* Lock the peripheral select */ FIELD(FLEXCOMM_PSELID, LOCK, 3, 1); /* USART present indicator */ FIELD(FLEXCOMM_PSELID, USARTPRESENT, 4, 1); ... typedef enum { /* FLEXCOMM_PSELID_LOCK */ /* Peripheral select can be changed by software. */ FLEXCOMM_PSELID_LOCK_UNLOCKED =3D 0, /* Peripheral select is locked and cannot be changed until this * Flexcomm module or the entire device is reset. */ FLEXCOMM_PSELID_LOCK_LOCKED =3D 1, } FLEXCOMM_PSELID_LOCK_Enum; ... #define FLEXCOMM_REGISTER_ACCESS_INFO_ARRAY(_name) \ struct RegisterAccessInfo _name[FLEXCOMM_REGS_NO] =3D { \ [0 ... FLEXCOMM_REGS_NO -1] =3D { \ .name =3D "", \ .addr =3D -1, \ }, \ [R_FLEXCOMM_PSELID] =3D { \ .name =3D "PSELID", \ .addr =3D 0xFF8, \ .ro =3D 0xFFFFFFF0, \ .reset =3D 0x101000, \ }, \ [R_FLEXCOMM_PID] =3D { \ .name =3D "PID", \ .addr =3D 0xFFC, \ .ro =3D 0xFFFFFFFF, \ .reset =3D 0x0, \ }, \ } Board specific headers contains information about peripheral base register addresses. Signed-off-by: Stefan Stanacar [tavip: pylint fixes, generate layout with qemu register fields instead of bitfields, generate register names, romask and reset values] Signed-off-by: Octavian Purdila --- meson.build | 4 + scripts/svd-gen-header.py | 329 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 333 insertions(+) create mode 100755 scripts/svd-gen-header.py diff --git a/meson.build b/meson.build index 2d4bf71b24..57d0119733 100644 --- a/meson.build +++ b/meson.build @@ -3338,6 +3338,10 @@ tracetool_depends =3D files( 'scripts/tracetool/__init__.py', ) =20 +svd_gen_header =3D [ + python, files('scripts/svd-gen-header.py') +] + qemu_version_cmd =3D [find_program('scripts/qemu-version.sh'), meson.current_source_dir(), get_option('pkgversion'), meson.project_version()] diff --git a/scripts/svd-gen-header.py b/scripts/svd-gen-header.py new file mode 100755 index 0000000000..2ddcc65b5a --- /dev/null +++ b/scripts/svd-gen-header.py @@ -0,0 +1,329 @@ +#!/usr/bin/env python3 + +# Copyright 2024 Google LLC +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# Use this script to generate a C header file from an SVD xml +# +# Two mode of operations are supported: peripheral and system. +# +# When running in peripheral mode a header for a specific peripheral +# is going to be generated. It will define a type and structure with +# all of the available registers at the bitfield level. An array that +# contains the reigster names indexed by address is also going to be +# generated as well as a function to initialize registers to their +# reset values. +# +# Invocation example: +# +# svd_gen_header -i MIMXRT595S_cm33.xml -o flexcomm.h -p FLEXCOMM0 -t FLEX= COMM +# +# When running in system mode a header for a specific system / +# platform will be generated. It will define register base addresses +# and interrupt numbers for selected peripherals. +# +# Invocation example: +# +# svd_gen_header -i MIMXRT595S_cm33.xml -o rt500.h -s RT500 -p FLEXCOMM0 \ +# -p CLKCTL0 -p CLKCTL1 +# + +import argparse +import re +import os +import sys +import xml.etree.ElementTree +import pysvd + +data_type_by_bits =3D { + 8: "uint8_t", + 16: "uint16_t", + 32: "uint32_t", +} + + +def get_register_array_name_and_size(reg): + """Return register name and register array size. + + The SVD can define register arrays and pysvd encodes the whole set + as as regular register with their name prepended by []. + + Returns a tuple with the register name and the size of the array or + zero if this is not a register set. + + """ + + split =3D re.split(r"[\[\]]", reg.name) + return (split[0], int(split[1]) if len(split) > 1 else 0) + + +def generate_comment(indent, text): + """Generate a comment block with for the given text with the given + indentation level. + + If possible, use a single line /* */ comment block, otherwise use + a multiline comment block. + + Newlines are preseved but tabs are not. + + """ + + # preserve new lines + text =3D text.replace("\n", " \n ") + text =3D text.replace(" ", " ") + + if len(text) + len("/* */") + len(" " * indent) <=3D 80 and "\n" not = in text: + return f"{' '* indent}/* {text} */\n" + + out =3D " " * indent + "/*\n" + line =3D " " * indent + " *" + for word in re.split(r"[ ]", text): + if len(line) + len(word) >=3D 79 or word =3D=3D "\n": + out +=3D line + "\n" + line =3D " " * indent + " *" + if word !=3D "\n": + line +=3D " " + word + else: + line +=3D " " + word + + out +=3D line + "\n" + + out +=3D " " * indent + " */\n" + return out + + +def generate_registers(name, periph): + """Generate register offsets and fields + + Use registerfield macros to define register offsets and fields for + a given peripheral. + + """ + + regs =3D sorted(periph.registers, key=3Dlambda reg: reg.addressOffset) + out =3D generate_comment(0, periph.description) + out +=3D f"#define {name}_REGS_NO ({regs[-1].addressOffset // 4 + 1})\= n\n" + for reg in regs: + out +=3D generate_comment(0, reg.description) + reg_name, reg_array_size =3D get_register_array_name_and_size(reg) + if reg_array_size > 1: + for idx in range(0, reg_array_size): + addr =3D reg.addressOffset + idx * reg.size // 8 + out +=3D f"REG32({name}_{reg_name}{idx}, {addr});\n" + else: + addr =3D reg.addressOffset + out +=3D f"REG32({name}_{reg_name}, {addr});\n" + for field in reg.fields: + out +=3D generate_comment(0, field.description) + if reg_array_size > 1: + out +=3D f"SHARED_FIELD({name}_{reg_name}_{field.name}, " + out +=3D f"{field.bitOffset}, {field.bitWidth});\n" + else: + out +=3D f"FIELD({name}_{reg_name}, {field.name}, " + out +=3D f"{field.bitOffset}, {field.bitWidth});\n" + out +=3D "\n" + + return out + + +def generate_enum_values(name, periph): + """Generate enum values""" + + out =3D "\n" + for reg in periph.registers: + reg_name, _ =3D get_register_array_name_and_size(reg) + for field in reg.fields: + if hasattr(field, "enumeratedValues"): + out +=3D "typedef enum {\n" + for enum in field.enumeratedValues.enumeratedValues: + enum_name =3D f"{name}_{reg_name}_{field.name}_{enum.n= ame}" + out +=3D generate_comment(4, enum.description) + out +=3D f" {enum_name} =3D {enum.value},\n" + out +=3D f"}} {name}_{reg_name}_{field.name}_Enum;\n" + out +=3D "\n" + + return out + + +def create_wmask(reg): + """Generate write mask for a register. + + Generate a mask with all bits that are writable set to 1 + """ + + wmask =3D 0 + fields =3D sorted(reg.fields, key=3Dlambda field: field.bitOffset) + if len(fields) > 0: + for field in fields: + if field.access !=3D pysvd.type.access.read_only: + wmask |=3D ((1 << field.bitWidth) - 1) << field.bitOffset + else: + if reg.access !=3D pysvd.type.access.read_only: + wmask =3D 0xFFFFFFFF + return wmask + + +def create_romask(reg): + """Generate write mask for a register. + + Generate a mask with all bits that are readonly set to 1 + """ + + return ~create_wmask(reg) & 0xFFFFFFFF + + +def generate_register_access_info(name, periph): + """Generate RegisterAccessInfo array macro""" + + out =3D f"\n#define {name}_REGISTER_ACCESS_INFO_ARRAY(_name) \\\n" + out +=3D f" struct RegisterAccessInfo _name[{name}_REGS_NO] =3D {{ = \\\n" + out +=3D f" [0 ... {name}_REGS_NO - 1] =3D {{ \\\n" + out +=3D ' .name =3D "", \\\n' + out +=3D " .addr =3D -1, \\\n" + out +=3D " }, \\\n" + for reg in periph.registers: + reg_name, reg_array_size =3D get_register_array_name_and_size(reg) + if reg_array_size > 1: + for idx in range(0, reg_array_size): + out +=3D f" [R_{name}_{reg_name}{idx}] =3D {{ \\\n" + addr =3D reg.addressOffset + idx * reg.size // 8 + out +=3D f' .name =3D "{reg_name}{idx}", \\\n' + out +=3D f" .addr =3D 0x{addr:X}, \\\n" + out +=3D f" .ro =3D 0x{create_romask(reg):X}, \= \\n" + out +=3D f" .reset =3D 0x{reg.resetValue:X}, \\= \n" + out +=3D " }, \\\n" + else: + out +=3D f" [R_{name}_{reg_name}] =3D {{ \\\n" + out +=3D f' .name =3D "{reg_name}", \\\n' + out +=3D f" .addr =3D 0x{reg.addressOffset:X}, \\\n" + out +=3D f" .ro =3D 0x{create_romask(reg):X}, \\\n" + out +=3D f" .reset =3D 0x{reg.resetValue:X}, \\\n" + out +=3D " }, \\\n" + out +=3D " }\n" + + return out + + +def generate_peripheral_header(periph, name): + """Generate peripheral header + + The following information is generated: + + * typedef with all of the available registers and register fields, + position and mask defines for register fields. + + * enum values that encode register fields options. + + * a macro that defines the register names indexed by the relative + address of the register. + + * a function that sets the registers to their reset values + + """ + + out =3D generate_registers(name, periph) + + out +=3D generate_enum_values(name, periph) + + out +=3D generate_register_access_info(name, periph) + + return out + + +def get_same_class_peripherals(svd, periph): + """Get a list of peripherals that are instances of the same class.""" + + return [periph] + [ + p + for p in svd.peripherals + if p.derivedFrom and p.derivedFrom.name =3D=3D periph.name + ] + + +def generate_system_header(system, svd, periph): + """Generate base and irq defines for given list of peripherals""" + + out =3D "" + + for p in get_same_class_peripherals(svd, periph): + out +=3D f"#define {system}_{p.name}_BASE 0x{p.baseAddress:X}UL\n" + out +=3D "\n" + + for p in get_same_class_peripherals(svd, periph): + for irq in p.interrupts: + out +=3D f"#define {system}_{irq.name}_IRQn 0x{irq.value}UL\n" + out +=3D "\n" + + return out + + +def main(): + """Script to generate C header file from an SVD file""" + + parser =3D argparse.ArgumentParser() + parser.add_argument( + "-i", "--input", type=3Dstr, help=3D"Input SVD file", required=3DT= rue + ) + parser.add_argument( + "-o", "--output", type=3Dstr, help=3D"Output .h file", required=3D= True + ) + parser.add_argument( + "-p", + "--peripheral", + action=3D"append", + help=3D"peripheral name from the SVD file", + required=3DTrue, + ) + parser.add_argument( + "-t", + "--type-name", + type=3Dstr, + help=3D"name to be used for peripheral definitions", + required=3DFalse, + ) + parser.add_argument( + "-s", + "--system", + type=3Dstr, + help=3D"name to be used for the system definitions", + required=3DFalse, + ) + + args =3D parser.parse_args() + + node =3D xml.etree.ElementTree.parse(args.input).getroot() + svd =3D pysvd.element.Device(node) + + # Write license header + header =3D svd.licenseText.strip() + header +=3D f"\n\nAutomatically generated by {os.path.basename(__file_= _)} " + header +=3D f"from {os.path.basename(args.input)}" + out =3D generate_comment(0, header) + + # Write some generic defines + out +=3D "#pragma once\n\n" + + for name in args.peripheral: + periph =3D svd.find(name) + if periph: + if args.system: + out +=3D generate_system_header(args.system, svd, periph) + else: + out +=3D '#include "hw/register.h"\n\n' + out +=3D generate_peripheral_header( + periph, args.type_name if args.type_name else periph.n= ame + ) + else: + print(f"No such peripheral: {name}") + return 1 + + with open(args.output, "w", encoding=3D"ascii") as output: + output.write(out) + + return 0 + + +if __name__ =3D=3D "__main__": + sys.exit(main()) --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687634; cv=none; d=zohomail.com; s=zohoarc; b=FIXilGH9zYprFdmnnhwKKSYcFMn7SdDc+/sWci/bTk9OmymLJntgeGuMv9RXg03UZDBnCwV0l17pWxldfMrEhrXEb0AYmeBh38INZiv5lH/60dPDhmWCKnk4P67GhPf7DS7wQOj6NiylqydMc71d+QDMsftv4bjPGDRbRoRpk3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687634; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qKA21Q/Mut9jISnah7mMJgm1CeAx6m6ER6bFWDsO26E=; b=ICdjfcRIKNLfmR+jCu3nm9Ir3O4yhvRwlxmZxisY3QKdbb0IP0gvDoOGA5A27qOQrnK0ae9dN2QHQmsU42GLdZnrur/sJTDKJyHoIIvnb8livCePoglkR2eKPXmAmElIExyW0UCA8IiSqQmW6H9QRfSJ3SjAaWxvkq9kcGogT5U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687634528233.73988744275823; Wed, 18 Sep 2024 12:27:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Go-0004pY-8P; Wed, 18 Sep 2024 15:23:22 -0400 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 <3lyjrZgUKCtIHyJ6D4CC492.0CAE2AI-12J29BCB4BI.CF4@flex--tavip.bounces.google.com>) id 1sr0Ga-0004Um-JQ for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:10 -0400 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3lyjrZgUKCtIHyJ6D4CC492.0CAE2AI-12J29BCB4BI.CF4@flex--tavip.bounces.google.com>) id 1sr0GX-0007J6-Te for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:08 -0400 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e02fff66a83so204340276.0 for ; Wed, 18 Sep 2024 12:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687384; x=1727292184; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qKA21Q/Mut9jISnah7mMJgm1CeAx6m6ER6bFWDsO26E=; b=rbGUao4W7W1o0kK76cEmUbbSF/Gm1mlPWmN4jpdH6sy72xNbd7lerqfvXuLIe4GhjY YNJCcH0lz1Duk90L3bfmE0mP9i5KJgVXmPKhrz75z/Pp1ZMA5aqHe8RQ54MWYdXiXuVn F9aHln6lpQnRg2YIsCdSjYasb2eYLyKu1qeIWgrleqLeYrME8psRiAnqibgiQphMSy5r 0cpf05CU309kiznzGshYCPZF58z+OilUmr4ytDr+mtGL24ZaGmV8nTXmg4/Q9D5ChTU3 +L3Qz5PsF64DI+ANjQgdAvfrJ41sr8JyGwxti06G5h3klhbnu4SJe8TQxeFX6OgAQnXX nZWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687384; x=1727292184; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qKA21Q/Mut9jISnah7mMJgm1CeAx6m6ER6bFWDsO26E=; b=K6EBHQnz5VE5cWDAvVv22ofBzYV0uGjdBDUXsNJ0iqUqDKE5UC8WkwFkOXDaccd94X TbpMB/PnomkAVFr9t4r6dQZxfuGEEQvpT50K2YI/83F5NHr6L9i/yioF/HKro7eNyt0V xHZjgkfkA03HsV3aNpJ+MhRHS4ZWfhZ8aE6Q5IelVt53GJjPskq4HPkrM18wwCTWB2Fk tJ6x+UDXRC5apE6syVsD9Q8KK0GdPILhTpUpmV23OqQDd/XUHYAwdgJCMf4iR4Rtj2Uk PPLeZ2l/9fqPibbFU/kbPu7yCdcdurJ6iv8jKpKF7260TJ578VmLjQl0O2XBVlvR/37n GEFg== X-Gm-Message-State: AOJu0YyVYeiOqZdbAZeGuaprOQ+nztnCfeao62Kj1df3ctmrTyzbxKz4 f0XRbXlfisOZyxxl5hJkF18QDoJ/RNjXSMg97T2dtcEADCDoTlR+FsFmrumkEWqUi2s1Mr9eAmA f3aWwp80zMxpxCX+zjD4b2no2nfH+lSBdj3iJtWi6ckFI9ZA07KqUV6DTTDJjWKrUkxsEZ/IAfN Id5FgAnWnwgPjGPe+UGTgmCZFy7Q== X-Google-Smtp-Source: AGHT+IH4L2pe+i7jN1Pe/8DYC19Lp5kYQPEyWguMz4cZ7G+J2cnNsQtuNwZG9l0EnopINhsfp9AwIostGA== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a5b:704:0:b0:e0e:4350:d7de with SMTP id 3f1490d57ef6-e1d9dc3da43mr29038276.9.1726687383260; Wed, 18 Sep 2024 12:23:03 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:32 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-5-tavip@google.com> Subject: [PATCH 04/25] Add mcux-soc-svd subproject From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=3lyjrZgUKCtIHyJ6D4CC492.0CAE2AI-12J29BCB4BI.CF4@flex--tavip.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687635433116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add mcux-soc-svd subproject that contains SVD files that are going to be used to generate C header with register layout definitions and other helpers to create device models. Guard the subproject by a configuration option since it is rarely going to be used - whenever new headers will be generated. It is unlikely that already generated headers will be updated, with the exception of minor hardware revisions. Also export the rt595 SVD file which is going to be used by subsequent patches. TBD: switch to a qemu gitlab fork before merge Signed-off-by: Octavian Purdila --- hw/arm/svd/meson.build | 4 ++++ meson_options.txt | 3 +++ scripts/meson-buildoptions.sh | 4 ++++ subprojects/.gitignore | 1 + subprojects/mcux-soc-svd.wrap | 5 +++++ subprojects/packagefiles/mcux-soc-svd/meson.build | 5 +++++ 6 files changed, 22 insertions(+) create mode 100644 hw/arm/svd/meson.build create mode 100644 subprojects/mcux-soc-svd.wrap create mode 100644 subprojects/packagefiles/mcux-soc-svd/meson.build diff --git a/hw/arm/svd/meson.build b/hw/arm/svd/meson.build new file mode 100644 index 0000000000..7d83d2ccbc --- /dev/null +++ b/hw/arm/svd/meson.build @@ -0,0 +1,4 @@ +if get_option('mcux-soc-svd') + mcux_soc_svd =3D subproject('mcux-soc-svd') + rt595 =3D mcux_soc_svd.get_variable('rt595') +endif diff --git a/meson_options.txt b/meson_options.txt index 783b56bcb9..fb64db2d2a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -375,3 +375,6 @@ option('hexagon_idef_parser', type : 'boolean', value := true, =20 option('x86_version', type : 'combo', choices : ['0', '1', '2', '3', '4'],= value: '1', description: 'tweak required x86_64 architecture version beyond com= piler default') + +option('mcux-soc-svd', type : 'boolean', value : false, + description: 'enable targets to generate C headers from mcux-soc-sv= d') diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 107a8f69ce..0864952d80 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -41,6 +41,8 @@ meson_options_help() { printf "%s\n" ' --enable-lto Use link time optimization' printf "%s\n" ' --enable-malloc=3DCHOICE choose memory allocator to u= se [system] (choices:' printf "%s\n" ' jemalloc/system/tcmalloc)' + printf "%s\n" ' --enable-mcux-soc-svd enable targets to generate C h= eaders from mcux-' + printf "%s\n" ' soc-svd' printf "%s\n" ' --enable-module-upgrades try to load modules from alter= nate paths for' printf "%s\n" ' upgrades' printf "%s\n" ' --enable-rng-none dummy RNG, avoid using /dev/(u= )random and' @@ -395,6 +397,8 @@ _meson_option_parse() { --enable-malloc-trim) printf "%s" -Dmalloc_trim=3Denabled ;; --disable-malloc-trim) printf "%s" -Dmalloc_trim=3Ddisabled ;; --mandir=3D*) quote_sh "-Dmandir=3D$2" ;; + --enable-mcux-soc-svd) printf "%s" -Dmcux-soc-svd=3Dtrue ;; + --disable-mcux-soc-svd) printf "%s" -Dmcux-soc-svd=3Dfalse ;; --enable-membarrier) printf "%s" -Dmembarrier=3Denabled ;; --disable-membarrier) printf "%s" -Dmembarrier=3Ddisabled ;; --enable-module-upgrades) printf "%s" -Dmodule_upgrades=3Dtrue ;; diff --git a/subprojects/.gitignore b/subprojects/.gitignore index adca0266be..bca8693ef4 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -6,3 +6,4 @@ /keycodemapdb /libvfio-user /slirp +/mcux-soc-svd diff --git a/subprojects/mcux-soc-svd.wrap b/subprojects/mcux-soc-svd.wrap new file mode 100644 index 0000000000..80d18e8561 --- /dev/null +++ b/subprojects/mcux-soc-svd.wrap @@ -0,0 +1,5 @@ +[wrap-git] +url =3D https://github.com/nxp-mcuxpresso/mcux-soc-svd/ +revision =3D 7f6f9ef7420144fe14cd9bc4d8e0e3523232da04 +patch_directory =3D mcux-soc-svd +depth =3D 1 diff --git a/subprojects/packagefiles/mcux-soc-svd/meson.build b/subproject= s/packagefiles/mcux-soc-svd/meson.build new file mode 100644 index 0000000000..37c537d040 --- /dev/null +++ b/subprojects/packagefiles/mcux-soc-svd/meson.build @@ -0,0 +1,5 @@ +project('mcux-soc-svd') + +fs =3D import('fs') + +rt595 =3D fs.copyfile('MIMXRT595S/MIMXRT595S_cm33.xml') --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687608; cv=none; d=zohomail.com; s=zohoarc; b=aVR2W9FaUoxG8emMuhQi3X1evZOlLY6uVOJyWzn6hIM60NhljlPJGffmvtL4W1XJdyq+fpC0ZdznZwUS73j1nvYxlUhsMEMu6fUurBbjO+C/ycjF/jNJFFvoN/M55qaruRWxbvjyDRQSk1UKNFzEjxe1HRQPQ8rfDI9u94EHUIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687608; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lEVtRqlZJene7dTeaWQA40okr0fqxtlzPIuT5Zal7q4=; b=McKioZOy07fH4Y3q/MxWvcORwGnHR+Iqyblj4pimNeychtocjs9wnRxn58EEUs46BMa0AYx9dgYdUETPwrMr2UQmqATzBDVVFMQXY0JR9Y2dePv1h2P4L59DRdnboxRSLilMAbAvMpyT1+eMSPDuaZKmqoqw0qY3FFOBEz2UnEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687608042661.8146195825733; Wed, 18 Sep 2024 12:26:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gr-00054r-Pq; Wed, 18 Sep 2024 15:23:25 -0400 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 <3mSjrZgUKCtQJ0L8F6EE6B4.2ECG4CK-34L4BDED6DK.EH6@flex--tavip.bounces.google.com>) id 1sr0Gc-0004Vh-N5 for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:13 -0400 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3mSjrZgUKCtQJ0L8F6EE6B4.2ECG4CK-34L4BDED6DK.EH6@flex--tavip.bounces.google.com>) id 1sr0GZ-0007JM-Rx for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:10 -0400 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6ddd980af81so866567b3.2 for ; Wed, 18 Sep 2024 12:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687386; x=1727292186; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lEVtRqlZJene7dTeaWQA40okr0fqxtlzPIuT5Zal7q4=; b=BSHaJpsVkuWnn8mLgtpOPzEg6yxaajQKvMUCpHEw2S8SE+gsspM2cS1XZE7hJmglgV SjT5MiPoq/256lLYf8yOAjTBVhmJMshl/JzYd5n80/9odWyS7ZhL+mBTJmXd6vFB0e+L 13OSNx8bcfLjq1Q/CC2By1UR7ZUfzmDaZFkKShSPERqvhCQ6i+/xtWRGLw0td+9F6fLk 5aCBwtw2dLi1hjr7Nz5/JOYMyh87O7d/cNakOscE6Dd0FWit9+kE4ftTX+umDGNY+DTV YNzQmspgWEArYWNTBjmmUVUruwvnHkrDkJbGDTMDzifv+pOEUIkb3aLFEI+wVeHNpluj xTcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687386; x=1727292186; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lEVtRqlZJene7dTeaWQA40okr0fqxtlzPIuT5Zal7q4=; b=Ii3jnPmXnC1XPu+yR9BNrYmOjZLaDwmZ9EaW03t6TiyWXdeGsWnIR29RdI5HwhAg7v W7wa/52heZLUDD64SYnfqFd7MNCyLUnt2OCA0O7LCdqwYqpr8LG58awy2jXRBA6PiILe WZ7EKbywEDmJE6CdjMjzycFGqUAvg5tFX04Ac8HqpLGYR+gAw2aeP3lLJ57VEW1BCqc9 HaufBVpf4QbzHvDwjwsNUIDRKT0de+7veIf5ZGUO1qpSiMl5HNoBHwuy8Z430vkvw1QD cWlI31hQ/GAnEyv+bfttXxuBQmkhIITq3ktJEXTr+nrORrixyVeNPCHyGzjXkT7aJtsH on5Q== X-Gm-Message-State: AOJu0YxDmvN12QgoAYZs6OBj5dzipFRuQANMDQJX8A1m5CD2mL+XxzWM IwGkIF7mJv6M5TfZZbqYVSdNv2vq8D+BrHbeSBkUdMcM43NLW7wkggIobYulaR4bg6StNkk2pyV KoubR0nYmCivl8CWcSRLm6oHlyDIcR4XL5bRkXEQyl5getiTqHL3j7BsDbrmA8ra1vNDyL5/2mD ycbaby74tPCmUK4n/DYFNih4oC/A== X-Google-Smtp-Source: AGHT+IGfxGkXDdfCP6DbI5su4miHO/yemHL1KhNk7vT2hgJw5NXJ1I8hE7NeD92eXlVpKuAKu2ULXV8uNQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a81:b302:0:b0:6dd:b9bb:360a with SMTP id 00721157ae682-6ddb9bb38e2mr4274627b3.1.1726687385354; Wed, 18 Sep 2024 12:23:05 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:33 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-6-tavip@google.com> Subject: [PATCH 05/25] hw/misc: add support for flexcomm From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1149; envelope-from=3mSjrZgUKCtQJ0L8F6EE6B4.2ECG4CK-34L4BDED6DK.EH6@flex--tavip.bounces.google.com; helo=mail-yw1-x1149.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687609417116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for NXP's FLEXCOMM device model. FLEXCOMM is a generic serial communication module which support multiple functions: UART, SPI and I2C. These are configurable at runtime. An abstract FlexcomFunction class is created that will be extended for specific functions. Each function has a dedicated overlapped MemoryRegion that it is going to be activated when that particular function is selected. A generic MemoryRegion is used to map generic registers (PSELID, PID) that is always active but has a lower priority. The function memory region is trimed to not include the generic registers. The FlexcommFunction object also gets access to the (non-concurrently) shared register backstore. The patch includes an automatically generated header which contains the register layout and helpers. The header can be regenerated with the svd-flexcomm target when the build is configured with --enable-mcux-soc-svd. Signed-off-by: Octavian Purdila --- include/hw/arm/svd/flexcomm.h | 112 ++++++++++ include/hw/misc/flexcomm.h | 49 +++++ include/hw/misc/flexcomm_function.h | 47 ++++ hw/misc/flexcomm.c | 319 ++++++++++++++++++++++++++++ hw/arm/meson.build | 2 + hw/arm/svd/meson.build | 3 + hw/misc/Kconfig | 3 + hw/misc/meson.build | 2 + hw/misc/trace-events | 5 + 9 files changed, 542 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm.h create mode 100644 include/hw/misc/flexcomm.h create mode 100644 include/hw/misc/flexcomm_function.h create mode 100644 hw/misc/flexcomm.c diff --git a/include/hw/arm/svd/flexcomm.h b/include/hw/arm/svd/flexcomm.h new file mode 100644 index 0000000000..4639722bc7 --- /dev/null +++ b/include/hw/arm/svd/flexcomm.h @@ -0,0 +1,112 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#include "hw/register.h" + +/* Flexcomm */ +#define FLEXCOMM_REGS_NO (1024) + +/* Peripheral Select and Flexcomm module ID */ +REG32(FLEXCOMM_PSELID, 4088); +/* Peripheral Select */ +FIELD(FLEXCOMM_PSELID, PERSEL, 0, 3); +/* Lock the peripheral select */ +FIELD(FLEXCOMM_PSELID, LOCK, 3, 1); +/* USART present indicator */ +FIELD(FLEXCOMM_PSELID, USARTPRESENT, 4, 1); +/* SPI present indicator */ +FIELD(FLEXCOMM_PSELID, SPIPRESENT, 5, 1); +/* I2C present indicator */ +FIELD(FLEXCOMM_PSELID, I2CPRESENT, 6, 1); +/* I2S Present */ +FIELD(FLEXCOMM_PSELID, I2SPRESENT, 7, 1); +/* Flexcomm ID */ +FIELD(FLEXCOMM_PSELID, ID, 12, 20); + +/* Peripheral Identification */ +REG32(FLEXCOMM_PID, 4092); +/* Minor revision of module implementation */ +FIELD(FLEXCOMM_PID, Minor_Rev, 8, 4); +/* Major revision of module implementation */ +FIELD(FLEXCOMM_PID, Major_Rev, 12, 4); +/* Module identifier for the selected function */ +FIELD(FLEXCOMM_PID, ID, 16, 16); + + +typedef enum { + /* No peripheral selected. */ + FLEXCOMM_PSELID_PERSEL_NO_PERIPH_SELECTED =3D 0, + /* USART function selected */ + FLEXCOMM_PSELID_PERSEL_USART =3D 1, + /* SPI function selected */ + FLEXCOMM_PSELID_PERSEL_SPI =3D 2, + /* I2C */ + FLEXCOMM_PSELID_PERSEL_I2C =3D 3, + /* I2S Transmit */ + FLEXCOMM_PSELID_PERSEL_I2S_TRANSMIT =3D 4, + /* I2S Receive */ + FLEXCOMM_PSELID_PERSEL_I2S_RECEIVE =3D 5, +} FLEXCOMM_PSELID_PERSEL_Enum; + +typedef enum { + /* Peripheral select can be changed by software. */ + FLEXCOMM_PSELID_LOCK_UNLOCKED =3D 0, + /* + * Peripheral select is locked and cannot be changed until this Flexco= mm + * module or the entire device is reset. + */ + FLEXCOMM_PSELID_LOCK_LOCKED =3D 1, +} FLEXCOMM_PSELID_LOCK_Enum; + +typedef enum { + /* This Flexcomm module does not include the USART function. */ + FLEXCOMM_PSELID_USARTPRESENT_NOT_PRESENT =3D 0, + /* This Flexcomm module includes the USART function. */ + FLEXCOMM_PSELID_USARTPRESENT_PRESENT =3D 1, +} FLEXCOMM_PSELID_USARTPRESENT_Enum; + +typedef enum { + /* This Flexcomm module does not include the SPI function. */ + FLEXCOMM_PSELID_SPIPRESENT_NOT_PRESENT =3D 0, + /* This Flexcomm module includes the SPI function. */ + FLEXCOMM_PSELID_SPIPRESENT_PRESENT =3D 1, +} FLEXCOMM_PSELID_SPIPRESENT_Enum; + +typedef enum { + /* I2C Not Present */ + FLEXCOMM_PSELID_I2CPRESENT_NOT_PRESENT =3D 0, + /* I2C Present */ + FLEXCOMM_PSELID_I2CPRESENT_PRESENT =3D 1, +} FLEXCOMM_PSELID_I2CPRESENT_Enum; + +typedef enum { + /* I2S Not Present */ + FLEXCOMM_PSELID_I2SPRESENT_NOT_PRESENT =3D 0, + /* I2S Present */ + FLEXCOMM_PSELID_I2SPRESENT_PRESENT =3D 1, +} FLEXCOMM_PSELID_I2SPRESENT_Enum; + + +#define FLEXCOMM_REGISTER_ACCESS_INFO_ARRAY(_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_REGS_NO] =3D { \ + [0 ... FLEXCOMM_REGS_NO - 1] =3D { \ + .name =3D "", \ + .addr =3D -1, \ + }, \ + [R_FLEXCOMM_PSELID] =3D { \ + .name =3D "PSELID", \ + .addr =3D 0xFF8, \ + .ro =3D 0xFFFFFFF0, \ + .reset =3D 0x101000, \ + }, \ + [R_FLEXCOMM_PID] =3D { \ + .name =3D "PID", \ + .addr =3D 0xFFC, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + } diff --git a/include/hw/misc/flexcomm.h b/include/hw/misc/flexcomm.h new file mode 100644 index 0000000000..ea0fe77f26 --- /dev/null +++ b/include/hw/misc/flexcomm.h @@ -0,0 +1,49 @@ +/* + * QEMU model for NXP's FLEXCOMM + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_FLEXCOMM_H +#define HW_FLEXCOMM_H + +#include "hw/sysbus.h" +#include "hw/arm/svd/flexcomm.h" +#include "qemu/fifo32.h" + +#define FLEXCOMM_FUNC_USART 0 +#define FLEXCOMM_FUNC_SPI 1 +#define FLEXCOMM_FUNC_I2C 2 +#define FLEXCOMM_FUNC_I2S 3 +#define FLEXCOMM_FUNCTIONS 4 + +#define FLEXCOMM_FULL 0xF +#define FLEXCOMM_HSSPI (1 << FLEXCOMM_FUNC_SPI) +#define FLEXCOMM_PMICI2C (1 << FLEXCOMM_FUNC_I2C) + +#define FLEXCOMM_PERSEL_USART 1 +#define FLEXCOMM_PERSEL_SPI 2 +#define FLEXCOMM_PERSEL_I2C 3 +#define FLEXCOMM_PERSEL_I2S_TX 4 +#define FLEXCOMM_PERSEL_I2S_RX 5 + +#define TYPE_FLEXCOMM "flexcomm" +OBJECT_DECLARE_SIMPLE_TYPE(FlexcommState, FLEXCOMM); + +struct FlexcommState { + SysBusDevice parent_obj; + + MemoryRegion container; + MemoryRegion mmio; + uint32_t regs[FLEXCOMM_REGS_NO]; + uint32_t functions; + qemu_irq irq; + bool irq_state; +}; + +#endif /* HW_FLEXCOMM_H */ diff --git a/include/hw/misc/flexcomm_function.h b/include/hw/misc/flexcomm= _function.h new file mode 100644 index 0000000000..e498976927 --- /dev/null +++ b/include/hw/misc/flexcomm_function.h @@ -0,0 +1,47 @@ +/* + * QEMU model for NXP's FLEXCOMM + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_FLEXCOMM_FUNCTION_H +#define HW_FLEXCOMM_FUNCTION_H + +#include "qemu/fifo32.h" +#include "hw/sysbus.h" + +#define TYPE_FLEXCOMM_FUNCTION "flexcomm-function" +OBJECT_DECLARE_TYPE(FlexcommFunction, FlexcommFunctionClass, FLEXCOMM_FUNC= TION); + +struct FlexcommFunction { + SysBusDevice parent_obj; + + MemoryRegion mmio; + uint32_t *regs; +}; + +typedef void (*FlexcommFunctionSelect)(FlexcommFunction *f, bool selected); + +struct FlexcommFunctionClass { + SysBusDeviceClass parent_class; + + const MemoryRegionOps *mmio_ops; + const char *name; + FlexcommFunctionSelect select; +}; + +static inline void flexcomm_select(FlexcommFunction *obj, bool selected) +{ + FlexcommFunctionClass *klass =3D FLEXCOMM_FUNCTION_GET_CLASS(obj); + + klass->select(obj, selected); +} + +void flexcomm_set_irq(FlexcommFunction *f, bool irq); + +#endif /* HW_FLEXCOMM_FUNCTION_H */ diff --git a/hw/misc/flexcomm.c b/hw/misc/flexcomm.c new file mode 100644 index 0000000000..2337fb814c --- /dev/null +++ b/hw/misc/flexcomm.c @@ -0,0 +1,319 @@ +/* + * QEMU model for NXP's FLEXCOMM + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/mmap-alloc.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" +#include "migration/vmstate.h" +#include "exec/address-spaces.h" +#include "qapi/error.h" +#include "trace.h" +#include "migration/vmstate.h" +#include "hw/misc/flexcomm.h" + +#define REG(s, reg) (s->regs[R_FLEXCOMM_##reg]) +#define RF_WR(s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXCOMM_##reg, field, val) +#define RF_RD(s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXCOMM_##reg, field) + +#define modname "FLEXCOMM" + +#define FLEXCOMM_FUNC_MMIO_SIZE \ + ((FLEXCOMM_REGS_NO - 2) * sizeof(uint32_t)) + +static const FLEXCOMM_REGISTER_ACCESS_INFO_ARRAY(reg_info); + +static inline bool has_function(FlexcommState *s, int function) +{ + return s->functions & (1 << function); +} + +static inline int persel_to_function(FlexcommState *s) +{ + switch (RF_RD(s, PSELID, PERSEL)) { + case FLEXCOMM_PERSEL_USART: + return FLEXCOMM_FUNC_USART; + case FLEXCOMM_PERSEL_SPI: + return FLEXCOMM_FUNC_SPI; + case FLEXCOMM_PERSEL_I2C: + return FLEXCOMM_FUNC_I2C; + case FLEXCOMM_PERSEL_I2S_TX: + case FLEXCOMM_PERSEL_I2S_RX: + return FLEXCOMM_FUNC_I2S; + default: + return -1; + } +} + +static void flexcomm_func_select(FlexcommState *s, bool selected) +{ + FlexcommFunction *obj[] =3D { + FLEXCOMM_FUNCTION(&s->usart), + FLEXCOMM_FUNCTION(&s->spi), + FLEXCOMM_FUNCTION(&s->i2c), + }; + int f =3D persel_to_function(s); + + if (f >=3D 0 && f < ARRAY_SIZE(obj)) { + flexcomm_select(obj[f], selected); + } +} + +static void flexcomm_reset_enter(Object *o, ResetType type) +{ + FlexcommState *s =3D FLEXCOMM(o); + + trace_flexcomm_reset(); + + flexcomm_func_select(s, false); + + for (int i =3D 0; i < FLEXCOMM_REGS_NO; i++) { + hwaddr addr =3D reg_info[i].addr; + + if (addr !=3D -1) { + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D ®_info[i], + }; + + register_reset(&ri); + } + } + + RF_WR(s, PSELID, USARTPRESENT, has_function(s, FLEXCOMM_FUNC_USART)); + RF_WR(s, PSELID, SPIPRESENT, has_function(s, FLEXCOMM_FUNC_SPI)); + RF_WR(s, PSELID, I2CPRESENT, has_function(s, FLEXCOMM_FUNC_I2C)); + RF_WR(s, PSELID, I2SPRESENT, has_function(s, FLEXCOMM_FUNC_I2S)); + + s->irq_state =3D false; +} + +static void flexcomm_reset_exit(Object *o, ResetType type) +{ + FlexcommState *s =3D FLEXCOMM(o); + + qemu_set_irq(s->irq, s->irq_state); +} + + +static MemTxResult flexcomm_reg_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + FlexcommState *s =3D opaque; + MemTxResult ret =3D MEMTX_OK; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + + switch (addr) { + case A_FLEXCOMM_PSELID: + case A_FLEXCOMM_PID: + { + *data =3D s->regs[addr / 4]; + break; + } + default: + return MEMTX_ERROR; + } + + trace_flexcomm_reg_read(DEVICE(s)->id, rai->name, addr, *data); + return ret; +} + +static int flexcomm_check_function(FlexcommState *s) +{ + int f =3D persel_to_function(s); + + if (f < 0 || !has_function(s, f)) { + return -1; + } + + return f; +} + +static MemTxResult flexcomm_reg_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + FlexcommState *s =3D opaque; + MemTxResult ret =3D MEMTX_OK; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D rai, + }; + + trace_flexcomm_reg_write(DEVICE(s)->id, rai->name, addr, value); + + switch (addr) { + case A_FLEXCOMM_PID: + /* RO register, nothing do to */ + break; + case A_FLEXCOMM_PSELID: + { + if (RF_RD(s, PSELID, LOCK)) { + break; + } + + flexcomm_func_select(s, false); + + register_write(&ri, value, ~0, modname, false); + + if (flexcomm_check_function(s) < 0) { + RF_WR(s, PSELID, PERSEL, 0); + break; + } + + flexcomm_func_select(s, true); + break; + } + default: + return MEMTX_ERROR; + } + + return ret; +} + + +static const MemoryRegionOps flexcomm_ops =3D { + .read_with_attrs =3D flexcomm_reg_read, + .write_with_attrs =3D flexcomm_reg_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + .unaligned =3D false, + }, +}; + +static Property flexcomm_properties[] =3D { + DEFINE_PROP_UINT32("functions", FlexcommState, functions, + FLEXCOMM_FULL), + DEFINE_PROP_END_OF_LIST(), +}; + +static void flexcomm_init(Object *obj) +{ + FlexcommState *s =3D FLEXCOMM(obj); + DeviceState *dev =3D DEVICE(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + + memory_region_init(&s->container, obj, "container", sizeof(s->regs)); + memory_region_init_io(&s->mmio, obj, &flexcomm_ops, s, + TYPE_FLEXCOMM, sizeof(s->regs)); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->container); + sysbus_init_irq(sbd, &s->irq); +} + +static void flexcomm_func_realize_and_unref(FlexcommFunction *f, Error **e= rrp) +{ + FlexcommState *s =3D FLEXCOMM(OBJECT(f)->parent); + FlexcommFunctionClass *fc =3D FLEXCOMM_FUNCTION_GET_CLASS(f); + + f->regs =3D s->regs; + memory_region_add_subregion_overlap(&s->container, 0, &f->mmio, 0); + DEVICE(f)->id =3D g_strdup_printf("%s-%s", DEVICE(s)->id, fc->name); + sysbus_realize_and_unref(SYS_BUS_DEVICE(f), errp); + memory_region_set_enabled(&f->mmio, false); +} + +static void flexcomm_realize(DeviceState *dev, Error **errp) +{ + FlexcommState *s =3D FLEXCOMM(dev); + + memory_region_add_subregion_overlap(&s->container, 0, &s->mmio, -1); +} + +static const VMStateDescription vmstate_flexcomm =3D { + .name =3D "flexcomm", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32_ARRAY(regs, FlexcommState, FLEXCOMM_REGS_NO), + VMSTATE_BOOL(irq_state, FlexcommState), + VMSTATE_FIFO32(rx_fifo, FlexcommState), + VMSTATE_FIFO32(tx_fifo, FlexcommState), + VMSTATE_END_OF_LIST() + } +}; + +static void flexcomm_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + rc->phases.enter =3D flexcomm_reset_enter; + rc->phases.exit =3D flexcomm_reset_exit; + device_class_set_props(dc, flexcomm_properties); + dc->realize =3D flexcomm_realize; + dc->vmsd =3D &vmstate_flexcomm; +} + +void flexcomm_set_irq(FlexcommFunction *f, bool irq) +{ + FlexcommState *s =3D FLEXCOMM(OBJECT(f)->parent); + + if (s->irq_state !=3D irq) { + trace_flexcomm_irq(DEVICE(s)->id, irq); + qemu_set_irq(s->irq, irq); + s->irq_state =3D irq; + } +} + +static void flexcomm_function_select(FlexcommFunction *f, bool selected) +{ + FlexcommFunctionClass *fc =3D FLEXCOMM_FUNCTION_GET_CLASS(f); + + memory_region_set_enabled(&f->mmio, selected); +} + +static void flexcomm_function_init(Object *obj) +{ + FlexcommFunctionClass *fc =3D FLEXCOMM_FUNCTION_GET_CLASS(obj); + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(obj); + + memory_region_init_io(&f->mmio, obj, fc->mmio_ops, obj, fc->name, + FLEXCOMM_FUNC_MMIO_SIZE); +} + +static void flexcomm_function_class_init(ObjectClass *klass, void *data) +{ + FlexcommFunctionClass *fc =3D FLEXCOMM_FUNCTION_CLASS(klass); + + fc->select =3D flexcomm_function_select; +} + +static const TypeInfo flexcomm_types[] =3D { + { + .name =3D TYPE_FLEXCOMM, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(FlexcommState), + .instance_init =3D flexcomm_init, + .class_init =3D flexcomm_class_init, + }, + { + .name =3D TYPE_FLEXCOMM_FUNCTION, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(FlexcommFunction), + .abstract =3D true, + .class_size =3D sizeof(FlexcommFunctionClass), + .instance_init =3D flexcomm_function_init, + .class_init =3D flexcomm_function_class_init, + }, +}; + +DEFINE_TYPES(flexcomm_types); diff --git a/hw/arm/meson.build b/hw/arm/meson.build index 4059d0be2e..fdfd083f75 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -82,3 +82,5 @@ system_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('ve= xpress.c')) system_ss.add(when: 'CONFIG_Z2', if_true: files('z2.c')) =20 hw_arch +=3D {'arm': arm_ss} + +subdir('svd') diff --git a/hw/arm/svd/meson.build b/hw/arm/svd/meson.build index 7d83d2ccbc..4b0bbbbbdc 100644 --- a/hw/arm/svd/meson.build +++ b/hw/arm/svd/meson.build @@ -1,4 +1,7 @@ if get_option('mcux-soc-svd') mcux_soc_svd =3D subproject('mcux-soc-svd') rt595 =3D mcux_soc_svd.get_variable('rt595') + run_target('svd-flexcomm', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm.h', + '-p', 'FLEXCOMM0', '-t', 'FLEXCOMM']) endif diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 1e08785b83..14167ae9e8 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -213,4 +213,7 @@ config IOSB config XLNX_VERSAL_TRNG bool =20 +config FLEXCOMM + bool + source macio/Kconfig diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 2ca8717be2..749f688e84 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -157,3 +157,5 @@ system_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('= sbsa_ec.c')) =20 # HPPA devices system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c')) + +system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm.c')) diff --git a/hw/misc/trace-events b/hw/misc/trace-events index 1be0717c0c..419879fd65 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -362,3 +362,8 @@ aspeed_sli_read(uint64_t offset, unsigned int size, uin= t32_t data) "To 0x%" PRIx aspeed_sliio_write(uint64_t offset, unsigned int size, uint32_t data) "To = 0x%" PRIx64 " of size %u: 0x%" PRIx32 aspeed_sliio_read(uint64_t offset, unsigned int size, uint32_t data) "To 0= x%" PRIx64 " of size %u: 0x%" PRIx32 =20 +# flexcomm +flexcomm_reset(void) "" +flexcomm_irq(const char *id, uint8_t irq) "%s %d" +flexcomm_reg_read(const char *devname, const char *regname, uint32_t addr,= uint32_t val) "%s: %s[0x%04x] -> 0x%08x" +flexcomm_reg_write(const char *dename, const char *regname, uint32_t addr,= uint32_t val) "%s: %s[0x%04x] <- 0x%08x" --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687843; cv=none; d=zohomail.com; s=zohoarc; b=O04v1BCi6tvit+Pe2TNylr7kQjkfMaKFFZjjWRLpMLLKtuPz/toJ6QN16PdSxP2iZO7v3klzJwpe/qLFmyl885NzxDhBf3ZmZ76kX75ScfSezL2iwSeArrqf5XSLv3ZVJtlR8h+QlnaUSUB+IlpuDdvEVdZTEO+d7jQ7CtBvblw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687843; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=N0mLLGE0rv2nvuRlLPnX33wbjS5E+YrP6ov3cBLBWZc=; b=NJT2IM6mBB2zYnpes0+bdBbjsQKb8gxCSzR3l8G1DiAKlwhSiw4BdERTnE3Dpi/e1BOZbMaqbjE4jqWACgVZpAKhdvDMxvxRAxs5SuptR2UBrNBDPncMzmusklpE88UBrAp/xzOwD9EvKzDfcFZqzuB05I4meSyLqwzMCGYuMSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687843203298.43616467371874; Wed, 18 Sep 2024 12:30:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gs-00059V-Ql; Wed, 18 Sep 2024 15:23:26 -0400 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 <3myjrZgUKCtYL2NAH8GG8D6.4GEI6EM-56N6DFGF8FM.GJ8@flex--tavip.bounces.google.com>) id 1sr0Gd-0004WT-NB for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:13 -0400 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3myjrZgUKCtYL2NAH8GG8D6.4GEI6EM-56N6DFGF8FM.GJ8@flex--tavip.bounces.google.com>) id 1sr0Gb-0007Ji-AA for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:10 -0400 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e1cf5a262a1so1891781276.0 for ; Wed, 18 Sep 2024 12:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687387; x=1727292187; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=N0mLLGE0rv2nvuRlLPnX33wbjS5E+YrP6ov3cBLBWZc=; b=0m+g1g3jS+XnaulJIfhooxcEi94bm0jRNye9SD9g3hETthWoMs3Xmb+TVliqNgO1VE awH76I4FRzZSCRsIhMgiUwXZImCAAJ9OobDk1fejXygKdkl88P20KydInRR84KNuLV6y Jrqerd0+4DIyAAvAbATQx2O0xu3UwE4z1hacaNq4Tw44FcRUHcx7VDDCzmmSTX/zKgrI LZGk4DlSjfVicRyYkMUWtru0K5swlvxl7nWX5JdPYZ26c1EZY+FKjpHc4FEEGQ/COQYS 4VTS3Ktb0WcptV6IlT6nBAEvEjpN7+3ba9JpxQxAyePyglKjzFae6Xg/ha5dcmvfJEOq xibg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687387; x=1727292187; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N0mLLGE0rv2nvuRlLPnX33wbjS5E+YrP6ov3cBLBWZc=; b=gmZphhLgusDWnqt1B1l/mJl/yx2GC44pmxRh7q88YiUC6wTPwt/1ZPi7ZgR5+k6J2P VpCiyeSiuUgzShrPV6EHLCyORPsUF/Iew6hb9FZoGxRNGqFMuDivRVb9/rVchC/p2e2C pKfsbG1CwLdNrgaNCjm5S6nXTr/4JQe/QjXiSEl3BU2/QW8SiG5z2AiJ1y9NjWClylJI l+ulIqX7Q3Eko1GRCI0J570OkeASqoFoD0ADIUVCNzuiqin/eTEWnXN+CYRLxRgo1E9Y V8ykKYtuuxASDbTTyt/HV4g/PcnVcRK4PTs6TejNIVA2q3LMu/BJoemytNKjIedSS6q4 eADg== X-Gm-Message-State: AOJu0YxbUdx7A+5ObIIv4x3IsYzsnU8YrjDULzXmuWTG/Slqca1KCge3 UHFL703XXYMw1EEagXRUu9yHFdxqusv8X9IdhZabhC//iM+sh9cxMUdjzC9l5SSdXctBng6a+QW D47Xo4E18h2TM8R7fVHUkF6V4zowGgpxssZy0J9FrFJH5DwM81LrTIvri5amODVJNdlkN/jMPvL EZVJ/ZTceip0NOK+7lXKeDkeA7WA== X-Google-Smtp-Source: AGHT+IGiN+24hJHARIxCHe91zgdsq5LVt36r+C7rV42PSxNyzYourZrlN5RLRH4+YDF/damEVPHqm/iAsQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a05:6902:b0a:b0:e1a:a30e:3393 with SMTP id 3f1490d57ef6-e202732b68fmr4158276.0.1726687387063; Wed, 18 Sep 2024 12:23:07 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:34 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-7-tavip@google.com> Subject: [PATCH 06/25] hw/misc/flexcomm.c: add common fifo functionality From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=3myjrZgUKCtYL2NAH8GG8D6.4GEI6EM-56N6DFGF8FM.GJ8@flex--tavip.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687844334116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" FLEXCOMM SPI and USART share FIFO functionality. Add common helper functions to avoid code duplication. Signed-off-by: Octavian Purdila --- include/hw/misc/flexcomm.h | 2 + include/hw/misc/flexcomm_function.h | 8 +++ hw/misc/flexcomm.c | 83 +++++++++++++++++++++++++++++ hw/misc/trace-events | 1 + 4 files changed, 94 insertions(+) diff --git a/include/hw/misc/flexcomm.h b/include/hw/misc/flexcomm.h index ea0fe77f26..832d4cd29d 100644 --- a/include/hw/misc/flexcomm.h +++ b/include/hw/misc/flexcomm.h @@ -44,6 +44,8 @@ struct FlexcommState { uint32_t functions; qemu_irq irq; bool irq_state; + Fifo32 rx_fifo; + Fifo32 tx_fifo; }; =20 #endif /* HW_FLEXCOMM_H */ diff --git a/include/hw/misc/flexcomm_function.h b/include/hw/misc/flexcomm= _function.h index e498976927..3ff1677ff6 100644 --- a/include/hw/misc/flexcomm_function.h +++ b/include/hw/misc/flexcomm_function.h @@ -23,6 +23,8 @@ struct FlexcommFunction { =20 MemoryRegion mmio; uint32_t *regs; + Fifo32 *tx_fifo; + Fifo32 *rx_fifo; }; =20 typedef void (*FlexcommFunctionSelect)(FlexcommFunction *f, bool selected); @@ -32,6 +34,7 @@ struct FlexcommFunctionClass { =20 const MemoryRegionOps *mmio_ops; const char *name; + bool has_fifos; FlexcommFunctionSelect select; }; =20 @@ -43,5 +46,10 @@ static inline void flexcomm_select(FlexcommFunction *obj= , bool selected) } =20 void flexcomm_set_irq(FlexcommFunction *f, bool irq); +void flexcomm_update_fifostat(FlexcommFunction *f); +void flexcomm_clear_fifostat(FlexcommFunction *f, uint64_t value); +void flexcomm_init_fifos(FlexcommFunction *f, unsigned num); +void flexcomm_cleanup_fifos(FlexcommFunction *f); +void flexcomm_reset_fifos(FlexcommFunction *f); =20 #endif /* HW_FLEXCOMM_FUNCTION_H */ diff --git a/hw/misc/flexcomm.c b/hw/misc/flexcomm.c index 2337fb814c..a98d8845aa 100644 --- a/hw/misc/flexcomm.c +++ b/hw/misc/flexcomm.c @@ -22,6 +22,7 @@ #include "trace.h" #include "migration/vmstate.h" #include "hw/misc/flexcomm.h" +#include "hw/arm/svd/flexcomm_usart.h" =20 #define REG(s, reg) (s->regs[R_FLEXCOMM_##reg]) #define RF_WR(s, reg, field, val) \ @@ -219,12 +220,22 @@ static void flexcomm_init(Object *obj) sysbus_init_irq(sbd, &s->irq); } =20 +static void flexcomm_finalize(Object *obj) +{ + FlexcommState *s =3D FLEXCOMM(obj); + + /* release resources allocated by the function select (e.g. fifos) */ + flexcomm_func_select(s, false); +} + static void flexcomm_func_realize_and_unref(FlexcommFunction *f, Error **e= rrp) { FlexcommState *s =3D FLEXCOMM(OBJECT(f)->parent); FlexcommFunctionClass *fc =3D FLEXCOMM_FUNCTION_GET_CLASS(f); =20 f->regs =3D s->regs; + f->tx_fifo =3D &s->tx_fifo; + f->rx_fifo =3D &s->rx_fifo; memory_region_add_subregion_overlap(&s->container, 0, &f->mmio, 0); DEVICE(f)->id =3D g_strdup_printf("%s-%s", DEVICE(s)->id, fc->name); sysbus_realize_and_unref(SYS_BUS_DEVICE(f), errp); @@ -274,11 +285,82 @@ void flexcomm_set_irq(FlexcommFunction *f, bool irq) } } =20 +/* FIFO is shared between USART and SPI, provide common functions here */ +#define FIFO_REG(s, reg) (s->regs[R_FLEXCOMM_USART_FIFO##reg]) +#define FIFO_WR(s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXCOMM_USART_FIFO##reg, field, val) +#define FIFO_RD(s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXCOMM_USART_FIFO##reg, field) + +void flexcomm_update_fifostat(FlexcommFunction *f) +{ + int rxlvl =3D fifo32_num_used(f->rx_fifo); + int txlvl =3D fifo32_num_used(f->tx_fifo); + + FIFO_WR(f, STAT, RXLVL, rxlvl); + FIFO_WR(f, STAT, TXLVL, txlvl); + FIFO_WR(f, STAT, RXFULL, fifo32_is_full(f->rx_fifo) ? 1 : 0); + FIFO_WR(f, STAT, RXNOTEMPTY, !fifo32_is_empty(f->rx_fifo) ? 1 : 0); + FIFO_WR(f, STAT, TXNOTFULL, !fifo32_is_full(f->tx_fifo) ? 1 : 0); + FIFO_WR(f, STAT, TXEMPTY, fifo32_is_empty(f->tx_fifo) ? 1 : 0); + + if (FIFO_RD(f, TRIG, RXLVLENA) && (rxlvl > FIFO_RD(f, TRIG, RXLVL))) { + FIFO_WR(f, INTSTAT, RXLVL, 1); + } else { + FIFO_WR(f, INTSTAT, RXLVL, 0); + } + + if (FIFO_RD(f, TRIG, TXLVLENA) && (txlvl <=3D FIFO_RD(f, TRIG, TXLVL))= ) { + FIFO_WR(f, INTSTAT, TXLVL, 1); + } else { + FIFO_WR(f, INTSTAT, TXLVL, 0); + } + + trace_flexcomm_fifostat(DEVICE(f)->id, FIFO_REG(f, STAT), + FIFO_REG(f, INTSTAT)); +} + +void flexcomm_reset_fifos(FlexcommFunction *f) +{ + if (FIFO_RD(f, CFG, EMPTYRX)) { + FIFO_WR(f, CFG, EMPTYRX, 0); + fifo32_reset(f->rx_fifo); + } + if (FIFO_RD(f, CFG, EMPTYTX)) { + FIFO_WR(f, CFG, EMPTYTX, 0); + fifo32_reset(f->tx_fifo); + } +} + +void flexcomm_clear_fifostat(FlexcommFunction *f, uint64_t value) +{ + bool rxerr =3D FIELD_EX32(value, FLEXCOMM_USART_FIFOSTAT, RXERR); + bool txerr =3D FIELD_EX32(value, FLEXCOMM_USART_FIFOSTAT, TXERR); + + if (rxerr) { + FIFO_WR(f, STAT, RXERR, 0); + } + if (txerr) { + FIFO_WR(f, STAT, TXERR, 0); + } +} + static void flexcomm_function_select(FlexcommFunction *f, bool selected) { FlexcommFunctionClass *fc =3D FLEXCOMM_FUNCTION_GET_CLASS(f); =20 memory_region_set_enabled(&f->mmio, selected); + if (fc->has_fifos) { + if (selected) { + unsigned num =3D FIFO_RD(f, SIZE, FIFOSIZE); + + fifo32_create(f->tx_fifo, num); + fifo32_create(f->rx_fifo, num); + } else { + fifo32_destroy(f->tx_fifo); + fifo32_destroy(f->rx_fifo); + } + } } =20 static void flexcomm_function_init(Object *obj) @@ -303,6 +385,7 @@ static const TypeInfo flexcomm_types[] =3D { .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(FlexcommState), .instance_init =3D flexcomm_init, + .instance_finalize =3D flexcomm_finalize, .class_init =3D flexcomm_class_init, }, { diff --git a/hw/misc/trace-events b/hw/misc/trace-events index 419879fd65..dc245905dc 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -367,3 +367,4 @@ flexcomm_reset(void) "" flexcomm_irq(const char *id, uint8_t irq) "%s %d" flexcomm_reg_read(const char *devname, const char *regname, uint32_t addr,= uint32_t val) "%s: %s[0x%04x] -> 0x%08x" flexcomm_reg_write(const char *dename, const char *regname, uint32_t addr,= uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_fifostat(const char *id, uint32_t fifostat, uint32_t fifoinstat) = "%s: %08x %08x" --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687646; cv=none; d=zohomail.com; s=zohoarc; b=J6XikCjSdXU9luBNNuWQdeP8XVCh9r7fiMQGZKuviUwyo4uWBBkyAxveweH0CVbPYEzs2+Q4Zza02Vc7oSvTpQkyn4mbpElamYBLNlKdqHZFOXjfwNN6l7ZtWBIQjgHMi1V4m9SE9JbyzcJwv1vO5uLoGhs5nLxWm2qzSsJw4/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687646; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xmpqpcBa8Qo/XngN2ic3QcHcQRbwoEZX18IKXPSjlUw=; b=b/zNT+9m7VEzBKNswd1F2EcB0LRiW5+J4br9J42B2KZZ6V1Jeral9wDFV8921JratkAnUfoYQ6Pl3YizUmZG3kSbezd2lBj0SKg3bWlx4We9hHDXdBc3OfGZ0RcfZGI3YF5kn4uE0UOyVK7PlB0bP+N5UgTW/V3VC02BtqgfWTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687646914912.0062776716002; Wed, 18 Sep 2024 12:27:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gr-0004zj-2J; Wed, 18 Sep 2024 15:23:25 -0400 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 <3nCjrZgUKCtcM3OBI9HH9E7.5HFJ7FN-67O7EGHG9GN.HK9@flex--tavip.bounces.google.com>) id 1sr0Gi-0004ZO-3X for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:18 -0400 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3nCjrZgUKCtcM3OBI9HH9E7.5HFJ7FN-67O7EGHG9GN.HK9@flex--tavip.bounces.google.com>) id 1sr0Gd-0007KQ-Mm for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:15 -0400 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e03623b24ddso329410276.1 for ; Wed, 18 Sep 2024 12:23:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687390; x=1727292190; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xmpqpcBa8Qo/XngN2ic3QcHcQRbwoEZX18IKXPSjlUw=; b=Yf4IFczGgsfLjPsn1XJIQ5o7wT6aqwD9d/WlQJaxlAQmsJM6z8XM9Hv45YrUUe4ocw YofgT3OvMIWlX7DBhxsj+e641abRT3GZKhnK6zluge3zOYZFaCwgaxEUjqGWTOikhlu8 HWSc8RqkVFngRELkrTF17UyGeL0bo7oPeV3xKel90LwPQmGAN0b/hziTiO/4LmXlQpJn B3yOtBJsDhNmNeQO5t9jmCtqVlY9tROFlNTRJYOqywG5vGuJdHR9RGZh8Vvwe95yPjSk lneVzQWEpvo2q/rfoTP092G8RXrqi52XfpDf5KugmzLXCFAsGy+HVD6pVYz7eRbSFxNK nO/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687390; x=1727292190; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xmpqpcBa8Qo/XngN2ic3QcHcQRbwoEZX18IKXPSjlUw=; b=V0S0umDjLvHByqSaMCte3pvmFI5Vz72mEZO42OXKdpSrqQND5zh0dRH6FjKATkwZHy xD5lZC+sJpc2b0L0VAKvHcKMZr57e90qyv6FSEYqFe+RrWwufPseAgTrspCBa+fq1oWC 57vA8+HdB1tRbpPSmVLTDaWZNYCZPsXPfCrvaeHTgmAwfW2colnY5Ex52BSuzpIBeP6q 5Xwb7MsnXT8kLQTl3VthO5LT7ftYc9i8yQyA+8CtZKyQPuzLij3bOPnMI+uUx1FVGVWP s8bnbW+cv/5stwuwf8KdquMjHdTUzEzuI0w0f+akjDJ4Try9v+QmmGzEIKQvxBj4rJNW 046w== X-Gm-Message-State: AOJu0YyIsyML32EWS9Eo/aLRVbz8y+rS3QOHdIKiAI63zJb8PvLzQEXK tQvQXSWHMXZZPeV/Qn6obfmd3ofj+z7L6i1F4n3lqIhOAXn/jyHmvwNprcazCdqkA/dzr7Zbi8l UqXlOpO33BcN5OX2Lno7/Ce41DJeZuqwweNyG/3+/t/6v9WBz40qJ8NDHSA13PaVnsE3tUaYNw1 kDX7YHFAtB6C8ICn4YNqK0QN7ncw== X-Google-Smtp-Source: AGHT+IG/J21RX/4/rBb4vBdHgWjpP6SzuffZf3BdvxIoPfXuti3VGlLSwLiah7sDKGdGmUrVesPlc6mFGQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a25:8709:0:b0:e1f:eaf1:2254 with SMTP id 3f1490d57ef6-e1feaf12aa2mr24348276.8.1726687388992; Wed, 18 Sep 2024 12:23:08 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:35 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-8-tavip@google.com> Subject: [PATCH 07/25] hw/char: add support for flexcomm usart From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=3nCjrZgUKCtcM3OBI9HH9E7.5HFJ7FN-67O7EGHG9GN.HK9@flex--tavip.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687647596116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for NXP's flexcomm usart. It supports interupts and FIFO access but no DMA. The patch includes an automatically generated header which contains the register layout and helpers. The header can be regenerated with the svd-flexcomm-usart target when the build is configured with --enable-mcux-soc-svd. Signed-off-by: Octavian Purdila --- include/hw/arm/svd/flexcomm_usart.h | 1021 +++++++++++++++++++++++++++ include/hw/char/flexcomm_usart.h | 33 + include/hw/misc/flexcomm.h | 2 + hw/char/flexcomm_usart.c | 288 ++++++++ hw/misc/flexcomm.c | 3 + hw/arm/svd/meson.build | 3 + hw/char/meson.build | 1 + hw/char/trace-events | 8 + 8 files changed, 1359 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_usart.h create mode 100644 include/hw/char/flexcomm_usart.h create mode 100644 hw/char/flexcomm_usart.c diff --git a/include/hw/arm/svd/flexcomm_usart.h b/include/hw/arm/svd/flexc= omm_usart.h new file mode 100644 index 0000000000..fe560d5566 --- /dev/null +++ b/include/hw/arm/svd/flexcomm_usart.h @@ -0,0 +1,1021 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#include "hw/register.h" + +/* Flexcomm USART */ +#define FLEXCOMM_USART_REGS_NO (1024) + +/* USART Configuration */ +REG32(FLEXCOMM_USART_CFG, 0); +/* USART Enable */ +FIELD(FLEXCOMM_USART_CFG, ENABLE, 0, 1); +/* Data Length. Selects the data size for the USART. */ +FIELD(FLEXCOMM_USART_CFG, DATALEN, 2, 2); +/* Parity Select. Selects what type of parity is used by the USART. */ +FIELD(FLEXCOMM_USART_CFG, PARITYSEL, 4, 2); +/* Stop Length */ +FIELD(FLEXCOMM_USART_CFG, STOPLEN, 6, 1); +/* Mode 32 kHz */ +FIELD(FLEXCOMM_USART_CFG, MODE32K, 7, 1); +/* LIN Break Mode Enable */ +FIELD(FLEXCOMM_USART_CFG, LINMODE, 8, 1); +/* CTS Enable */ +FIELD(FLEXCOMM_USART_CFG, CTSEN, 9, 1); +/* Synchronous Enable. Selects synchronous or asynchronous operation. */ +FIELD(FLEXCOMM_USART_CFG, SYNCEN, 11, 1); +/* Clock Polarity */ +FIELD(FLEXCOMM_USART_CFG, CLKPOL, 12, 1); +/* Synchronous mode Master Select */ +FIELD(FLEXCOMM_USART_CFG, SYNCMST, 14, 1); +/* Loopback Mode */ +FIELD(FLEXCOMM_USART_CFG, LOOP, 15, 1); +/* Output Enable Turnaround Time Enable for RS-485 Operation. */ +FIELD(FLEXCOMM_USART_CFG, OETA, 18, 1); +/* Automatic Address Matching Enable */ +FIELD(FLEXCOMM_USART_CFG, AUTOADDR, 19, 1); +/* Output Enable Select */ +FIELD(FLEXCOMM_USART_CFG, OESEL, 20, 1); +/* Output Enable Polarity */ +FIELD(FLEXCOMM_USART_CFG, OEPOL, 21, 1); +/* Receive Data Polarity */ +FIELD(FLEXCOMM_USART_CFG, RXPOL, 22, 1); +/* Transmit data polarity */ +FIELD(FLEXCOMM_USART_CFG, TXPOL, 23, 1); + +/* USART Control */ +REG32(FLEXCOMM_USART_CTL, 4); +/* Break Enable */ +FIELD(FLEXCOMM_USART_CTL, TXBRKEN, 1, 1); +/* Enable Address Detect Mode */ +FIELD(FLEXCOMM_USART_CTL, ADDRDET, 2, 1); +/* Transmit Disable */ +FIELD(FLEXCOMM_USART_CTL, TXDIS, 6, 1); +/* Continuous Clock Generation */ +FIELD(FLEXCOMM_USART_CTL, CC, 8, 1); +/* Clear Continuous Clock */ +FIELD(FLEXCOMM_USART_CTL, CLRCCONRX, 9, 1); +/* Autobaud Enable */ +FIELD(FLEXCOMM_USART_CTL, AUTOBAUD, 16, 1); + +/* USART Status */ +REG32(FLEXCOMM_USART_STAT, 8); +/* Receiver Idle */ +FIELD(FLEXCOMM_USART_STAT, RXIDLE, 1, 1); +/* Transmitter Idle */ +FIELD(FLEXCOMM_USART_STAT, TXIDLE, 3, 1); +/* CTS value */ +FIELD(FLEXCOMM_USART_STAT, CTS, 4, 1); +/* Delta CTS */ +FIELD(FLEXCOMM_USART_STAT, DELTACTS, 5, 1); +/* Transmitter Disabled Status Flag */ +FIELD(FLEXCOMM_USART_STAT, TXDISSTAT, 6, 1); +/* Received Break */ +FIELD(FLEXCOMM_USART_STAT, RXBRK, 10, 1); +/* Delta Received Break */ +FIELD(FLEXCOMM_USART_STAT, DELTARXBRK, 11, 1); +/* Start */ +FIELD(FLEXCOMM_USART_STAT, START, 12, 1); +/* Framing Error Interrupt Flag */ +FIELD(FLEXCOMM_USART_STAT, FRAMERRINT, 13, 1); +/* Parity Error Interrupt Flag */ +FIELD(FLEXCOMM_USART_STAT, PARITYERRINT, 14, 1); +/* Received Noise Interrupt Flag */ +FIELD(FLEXCOMM_USART_STAT, RXNOISEINT, 15, 1); +/* Auto Baud Error */ +FIELD(FLEXCOMM_USART_STAT, ABERR, 16, 1); + +/* Interrupt Enable Read and Set for USART (not FIFO) Status */ +REG32(FLEXCOMM_USART_INTENSET, 12); +/* Transmit Idle Flag */ +FIELD(FLEXCOMM_USART_INTENSET, TXIDLEEN, 3, 1); +/* Delta CTS Input Flag */ +FIELD(FLEXCOMM_USART_INTENSET, DELTACTSEN, 5, 1); +/* Transmit Disabled Flag */ +FIELD(FLEXCOMM_USART_INTENSET, TXDISEN, 6, 1); +/* Delta Receive Break Enable */ +FIELD(FLEXCOMM_USART_INTENSET, DELTARXBRKEN, 11, 1); +/* Start Enable */ +FIELD(FLEXCOMM_USART_INTENSET, STARTEN, 12, 1); +/* Frame Error Enable */ +FIELD(FLEXCOMM_USART_INTENSET, FRAMERREN, 13, 1); +/* Parity Error Enble */ +FIELD(FLEXCOMM_USART_INTENSET, PARITYERREN, 14, 1); +/* Receive Noise Enable */ +FIELD(FLEXCOMM_USART_INTENSET, RXNOISEEN, 15, 1); +/* Auto Baud Error Enable */ +FIELD(FLEXCOMM_USART_INTENSET, ABERREN, 16, 1); + +/* Interrupt Enable Clear */ +REG32(FLEXCOMM_USART_INTENCLR, 16); +/* Transmit Idle Clear */ +FIELD(FLEXCOMM_USART_INTENCLR, TXIDLECLR, 3, 1); +/* Delta CTS Clear */ +FIELD(FLEXCOMM_USART_INTENCLR, DELTACTSCLR, 5, 1); +/* Transmit Disable Clear */ +FIELD(FLEXCOMM_USART_INTENCLR, TXDISCLR, 6, 1); +/* Delta Receive Break Clear */ +FIELD(FLEXCOMM_USART_INTENCLR, DELTARXBRKCLR, 11, 1); +/* Start Clear */ +FIELD(FLEXCOMM_USART_INTENCLR, STARTCLR, 12, 1); +/* Frame Error Clear */ +FIELD(FLEXCOMM_USART_INTENCLR, FRAMERRCLR, 13, 1); +/* Parity Error Clear */ +FIELD(FLEXCOMM_USART_INTENCLR, PARITYERRCLR, 14, 1); +/* Receive Noise Clear */ +FIELD(FLEXCOMM_USART_INTENCLR, RXNOISECLR, 15, 1); +/* Auto Baud Error Clear */ +FIELD(FLEXCOMM_USART_INTENCLR, ABERRCLR, 16, 1); + +/* Baud Rate Generator */ +REG32(FLEXCOMM_USART_BRG, 32); +/* Baud Rate Generator Value */ +FIELD(FLEXCOMM_USART_BRG, BRGVAL, 0, 16); + +/* Interrupt Status */ +REG32(FLEXCOMM_USART_INTSTAT, 36); +/* Transmitter Idle Flag */ +FIELD(FLEXCOMM_USART_INTSTAT, TXIDLE, 3, 1); +/* Delta CTS Change Flag */ +FIELD(FLEXCOMM_USART_INTSTAT, DELTACTS, 5, 1); +/* Transmitter Disabled Interrupt Flag */ +FIELD(FLEXCOMM_USART_INTSTAT, TXDISINT, 6, 1); +/* Delta Receiver Break Change Flag */ +FIELD(FLEXCOMM_USART_INTSTAT, DELTARXBRK, 11, 1); +/* Start Detected on Receiver Flag */ +FIELD(FLEXCOMM_USART_INTSTAT, START, 12, 1); +/* Framing Error Interrupt Flag */ +FIELD(FLEXCOMM_USART_INTSTAT, FRAMERRINT, 13, 1); +/* Parity Error Interrupt Flag */ +FIELD(FLEXCOMM_USART_INTSTAT, PARITYERRINT, 14, 1); +/* Received Noise Interrupt Flag */ +FIELD(FLEXCOMM_USART_INTSTAT, RXNOISEINT, 15, 1); +/* Auto Baud Error Interrupt Flag */ +FIELD(FLEXCOMM_USART_INTSTAT, ABERRINT, 16, 1); + +/* Oversample Selection Register for Asynchronous Communication */ +REG32(FLEXCOMM_USART_OSR, 40); +/* Oversample Selection Value */ +FIELD(FLEXCOMM_USART_OSR, OSRVAL, 0, 4); + +/* Address Register for Automatic Address Matching */ +REG32(FLEXCOMM_USART_ADDR, 44); +/* Address */ +FIELD(FLEXCOMM_USART_ADDR, ADDRESS, 0, 8); + +/* FIFO Configuration */ +REG32(FLEXCOMM_USART_FIFOCFG, 3584); +/* Enable the Transmit FIFO. */ +FIELD(FLEXCOMM_USART_FIFOCFG, ENABLETX, 0, 1); +/* Enable the Receive FIFO */ +FIELD(FLEXCOMM_USART_FIFOCFG, ENABLERX, 1, 1); +/* FIFO Size Configuration */ +FIELD(FLEXCOMM_USART_FIFOCFG, SIZE, 4, 2); +/* DMA Configuration for Transmit */ +FIELD(FLEXCOMM_USART_FIFOCFG, DMATX, 12, 1); +/* DMA Configuration for Receive */ +FIELD(FLEXCOMM_USART_FIFOCFG, DMARX, 13, 1); +/* Wake-up for Transmit FIFO Level */ +FIELD(FLEXCOMM_USART_FIFOCFG, WAKETX, 14, 1); +/* Wake-up for Receive FIFO Level */ +FIELD(FLEXCOMM_USART_FIFOCFG, WAKERX, 15, 1); +/* Empty Command for the Transmit FIFO */ +FIELD(FLEXCOMM_USART_FIFOCFG, EMPTYTX, 16, 1); +/* Empty Command for the Receive FIFO */ +FIELD(FLEXCOMM_USART_FIFOCFG, EMPTYRX, 17, 1); +/* Pop FIFO for Debug Reads */ +FIELD(FLEXCOMM_USART_FIFOCFG, POPDBG, 18, 1); + +/* FIFO Status */ +REG32(FLEXCOMM_USART_FIFOSTAT, 3588); +/* TX FIFO Error */ +FIELD(FLEXCOMM_USART_FIFOSTAT, TXERR, 0, 1); +/* RX FIFO Error */ +FIELD(FLEXCOMM_USART_FIFOSTAT, RXERR, 1, 1); +/* Peripheral Interrupt */ +FIELD(FLEXCOMM_USART_FIFOSTAT, PERINT, 3, 1); +/* Transmit FIFO Empty */ +FIELD(FLEXCOMM_USART_FIFOSTAT, TXEMPTY, 4, 1); +/* Transmit FIFO is Not Full */ +FIELD(FLEXCOMM_USART_FIFOSTAT, TXNOTFULL, 5, 1); +/* Receive FIFO is Not Empty */ +FIELD(FLEXCOMM_USART_FIFOSTAT, RXNOTEMPTY, 6, 1); +/* Receive FIFO is Full */ +FIELD(FLEXCOMM_USART_FIFOSTAT, RXFULL, 7, 1); +/* Transmit FIFO Current Level */ +FIELD(FLEXCOMM_USART_FIFOSTAT, TXLVL, 8, 5); +/* Receive FIFO Current Level */ +FIELD(FLEXCOMM_USART_FIFOSTAT, RXLVL, 16, 5); + +/* FIFO Trigger Settings for Interrupt and DMA Request */ +REG32(FLEXCOMM_USART_FIFOTRIG, 3592); +/* Transmit FIFO Level Trigger Enable. */ +FIELD(FLEXCOMM_USART_FIFOTRIG, TXLVLENA, 0, 1); +/* Receive FIFO Level Trigger Enable */ +FIELD(FLEXCOMM_USART_FIFOTRIG, RXLVLENA, 1, 1); +/* Transmit FIFO Level Trigger Point */ +FIELD(FLEXCOMM_USART_FIFOTRIG, TXLVL, 8, 4); +/* Receive FIFO Level Trigger Point */ +FIELD(FLEXCOMM_USART_FIFOTRIG, RXLVL, 16, 4); + +/* FIFO Interrupt Enable */ +REG32(FLEXCOMM_USART_FIFOINTENSET, 3600); +/* Transmit Error Interrupt Enable */ +FIELD(FLEXCOMM_USART_FIFOINTENSET, TXERR, 0, 1); +/* Receive Error Interrupt Enable */ +FIELD(FLEXCOMM_USART_FIFOINTENSET, RXERR, 1, 1); +/* Transmit FIFO Level Interrupt Enable */ +FIELD(FLEXCOMM_USART_FIFOINTENSET, TXLVL, 2, 1); +/* Receive FIFO Level Interrupt Enable */ +FIELD(FLEXCOMM_USART_FIFOINTENSET, RXLVL, 3, 1); + +/* FIFO Interrupt Enable Clear */ +REG32(FLEXCOMM_USART_FIFOINTENCLR, 3604); +/* Transmit Error Interrupt Enable */ +FIELD(FLEXCOMM_USART_FIFOINTENCLR, TXERR, 0, 1); +/* Receive Error Interrupt Enable */ +FIELD(FLEXCOMM_USART_FIFOINTENCLR, RXERR, 1, 1); +/* Transmit FIFO Level Interrupt Enable */ +FIELD(FLEXCOMM_USART_FIFOINTENCLR, TXLVL, 2, 1); +/* Receive FIFO Level Interrupt Enable */ +FIELD(FLEXCOMM_USART_FIFOINTENCLR, RXLVL, 3, 1); + +/* FIFO Interrupt Status */ +REG32(FLEXCOMM_USART_FIFOINTSTAT, 3608); +/* TX FIFO Error Interrupt Status */ +FIELD(FLEXCOMM_USART_FIFOINTSTAT, TXERR, 0, 1); +/* RX FIFO Error Interrupt Status */ +FIELD(FLEXCOMM_USART_FIFOINTSTAT, RXERR, 1, 1); +/* Transmit FIFO Level Interrupt Status */ +FIELD(FLEXCOMM_USART_FIFOINTSTAT, TXLVL, 2, 1); +/* Receive FIFO Level Interrupt Status */ +FIELD(FLEXCOMM_USART_FIFOINTSTAT, RXLVL, 3, 1); +/* Peripheral Interrupt Status */ +FIELD(FLEXCOMM_USART_FIFOINTSTAT, PERINT, 4, 1); + +/* FIFO Write Data */ +REG32(FLEXCOMM_USART_FIFOWR, 3616); +/* Transmit data to the FIFO */ +FIELD(FLEXCOMM_USART_FIFOWR, TXDATA, 0, 9); + +/* FIFO Read Data */ +REG32(FLEXCOMM_USART_FIFORD, 3632); +/* Received Data from the FIFO */ +FIELD(FLEXCOMM_USART_FIFORD, RXDATA, 0, 9); +/* Framing Error Status Flag */ +FIELD(FLEXCOMM_USART_FIFORD, FRAMERR, 13, 1); +/* Parity Error Status Flag */ +FIELD(FLEXCOMM_USART_FIFORD, PARITYERR, 14, 1); +/* Received Noise Flag */ +FIELD(FLEXCOMM_USART_FIFORD, RXNOISE, 15, 1); + +/* FIFO Data Read with No FIFO Pop */ +REG32(FLEXCOMM_USART_FIFORDNOPOP, 3648); +/* Received Data from the FIFO */ +FIELD(FLEXCOMM_USART_FIFORDNOPOP, RXDATA, 0, 9); +/* Framing Error Status Flag */ +FIELD(FLEXCOMM_USART_FIFORDNOPOP, FRAMERR, 13, 1); +/* Parity Error Status Flag */ +FIELD(FLEXCOMM_USART_FIFORDNOPOP, PARITYERR, 14, 1); +/* Received Noise Flag */ +FIELD(FLEXCOMM_USART_FIFORDNOPOP, RXNOISE, 15, 1); + +/* FIFO Size */ +REG32(FLEXCOMM_USART_FIFOSIZE, 3656); +/* FIFO Size */ +FIELD(FLEXCOMM_USART_FIFOSIZE, FIFOSIZE, 0, 5); + +/* Peripheral Identification */ +REG32(FLEXCOMM_USART_ID, 4092); +/* Aperture */ +FIELD(FLEXCOMM_USART_ID, APERTURE, 0, 8); +/* Minor revision of module implementation */ +FIELD(FLEXCOMM_USART_ID, MINOR_REV, 8, 4); +/* Major revision of module implementation */ +FIELD(FLEXCOMM_USART_ID, MAJOR_REV, 12, 4); +/* Module identifier for the selected function */ +FIELD(FLEXCOMM_USART_ID, ID, 16, 16); + + +typedef enum { + /* Disabled */ + FLEXCOMM_USART_CFG_ENABLE_DISABLED =3D 0, + /* Enabled. The USART is enabled for operation. */ + FLEXCOMM_USART_CFG_ENABLE_ENABLED =3D 1, +} FLEXCOMM_USART_CFG_ENABLE_Enum; + +typedef enum { + /* 7 bit data length */ + FLEXCOMM_USART_CFG_DATALEN_BIT_7 =3D 0, + /* 8 bit data length */ + FLEXCOMM_USART_CFG_DATALEN_BIT_8 =3D 1, + /* + * 9 bit data length. The 9th bit is commonly used for addressing in + * multidrop mode. See the ADDRDET[CTL]. + */ + FLEXCOMM_USART_CFG_DATALEN_BIT_9 =3D 2, +} FLEXCOMM_USART_CFG_DATALEN_Enum; + +typedef enum { + /* No parity */ + FLEXCOMM_USART_CFG_PARITYSEL_NO_PARITY =3D 0, + /* Even parity */ + FLEXCOMM_USART_CFG_PARITYSEL_EVEN_PARITY =3D 2, + /* Odd parity */ + FLEXCOMM_USART_CFG_PARITYSEL_ODD_PARITY =3D 3, +} FLEXCOMM_USART_CFG_PARITYSEL_Enum; + +typedef enum { + /* 1 stop bit */ + FLEXCOMM_USART_CFG_STOPLEN_BIT_1 =3D 0, + /* + * 2 stop bits. This setting should be used only for asynchronous + * communication. + */ + FLEXCOMM_USART_CFG_STOPLEN_BITS_2 =3D 1, +} FLEXCOMM_USART_CFG_STOPLEN_Enum; + +typedef enum { + /* Disabled. USART uses standard clocking. */ + FLEXCOMM_USART_CFG_MODE32K_DISABLED =3D 0, + /* Enabled */ + FLEXCOMM_USART_CFG_MODE32K_ENABLED =3D 1, +} FLEXCOMM_USART_CFG_MODE32K_Enum; + +typedef enum { + /* + * Disabled. Break detect and generate is configured for normal operat= ion. + */ + FLEXCOMM_USART_CFG_LINMODE_DISABLED =3D 0, + /* + * Enabled. Break detect and generate is configured for LIN bus operat= ion. + */ + FLEXCOMM_USART_CFG_LINMODE_ENABLED =3D 1, +} FLEXCOMM_USART_CFG_LINMODE_Enum; + +typedef enum { + /* + * No flow control. The transmitter does not receive any automatic flow + * control signal. + */ + FLEXCOMM_USART_CFG_CTSEN_DISABLED =3D 0, + /* + * Flow control enabled. The transmitter uses the CTS input (or RTS ou= tput + * in loopback mode) for flow control purposes. + */ + FLEXCOMM_USART_CFG_CTSEN_ENABLED =3D 1, +} FLEXCOMM_USART_CFG_CTSEN_Enum; + +typedef enum { + /* Asynchronous mode */ + FLEXCOMM_USART_CFG_SYNCEN_ASYNCHRONOUS_MODE =3D 0, + /* Synchronous mode */ + FLEXCOMM_USART_CFG_SYNCEN_SYNCHRONOUS_MODE =3D 1, +} FLEXCOMM_USART_CFG_SYNCEN_Enum; + +typedef enum { + /* Falling edge. RXD is sampled on the falling edge of SCLK. */ + FLEXCOMM_USART_CFG_CLKPOL_FALLING_EDGE =3D 0, + /* Rising edge. RXD is sampled on the rising edge of SCLK. */ + FLEXCOMM_USART_CFG_CLKPOL_RISING_EDGE =3D 1, +} FLEXCOMM_USART_CFG_CLKPOL_Enum; + +typedef enum { + /* Slave. When synchronous mode is enabled, the USART is a slave. */ + FLEXCOMM_USART_CFG_SYNCMST_SLAVE =3D 0, + /* Master. When synchronous mode is enabled, the USART is a master. */ + FLEXCOMM_USART_CFG_SYNCMST_MASTER =3D 1, +} FLEXCOMM_USART_CFG_SYNCMST_Enum; + +typedef enum { + /* Normal operation */ + FLEXCOMM_USART_CFG_LOOP_NORMAL =3D 0, + /* Loopback mode */ + FLEXCOMM_USART_CFG_LOOP_LOOPBACK =3D 1, +} FLEXCOMM_USART_CFG_LOOP_Enum; + +typedef enum { + /* Disabled */ + FLEXCOMM_USART_CFG_OETA_DISABLED =3D 0, + /* Enabled */ + FLEXCOMM_USART_CFG_OETA_ENABLED =3D 1, +} FLEXCOMM_USART_CFG_OETA_Enum; + +typedef enum { + /* Disabled */ + FLEXCOMM_USART_CFG_AUTOADDR_DISABLED =3D 0, + /* Enabled */ + FLEXCOMM_USART_CFG_AUTOADDR_ENABLED =3D 1, +} FLEXCOMM_USART_CFG_AUTOADDR_Enum; + +typedef enum { + /* + * Standard. The RTS signal is used as the standard flow control funct= ion. + */ + FLEXCOMM_USART_CFG_OESEL_STANDARD =3D 0, + /* + * RS-485. The RTS signal is configured to provide an output enable si= gnal + * to control an RS-485 transceiver. + */ + FLEXCOMM_USART_CFG_OESEL_RS_485 =3D 1, +} FLEXCOMM_USART_CFG_OESEL_Enum; + +typedef enum { + /* Low. If selected by OESEL, the output enable is active low. */ + FLEXCOMM_USART_CFG_OEPOL_LOW =3D 0, + /* High. If selected by OESEL, the output enable is active high. */ + FLEXCOMM_USART_CFG_OEPOL_HIGH =3D 1, +} FLEXCOMM_USART_CFG_OEPOL_Enum; + +typedef enum { + /* Standard */ + FLEXCOMM_USART_CFG_RXPOL_STANDARD =3D 0, + /* Inverted */ + FLEXCOMM_USART_CFG_RXPOL_INVERTED =3D 1, +} FLEXCOMM_USART_CFG_RXPOL_Enum; + +typedef enum { + /* Standard */ + FLEXCOMM_USART_CFG_TXPOL_STANDARD =3D 0, + /* Inverted */ + FLEXCOMM_USART_CFG_TXPOL_INVERTED =3D 1, +} FLEXCOMM_USART_CFG_TXPOL_Enum; + +typedef enum { + /* Normal operation */ + FLEXCOMM_USART_CTL_TXBRKEN_NORMAL =3D 0, + /* Continuous break */ + FLEXCOMM_USART_CTL_TXBRKEN_CONTINUOUS =3D 1, +} FLEXCOMM_USART_CTL_TXBRKEN_Enum; + +typedef enum { + /* Disabled. The USART presents all incoming data. */ + FLEXCOMM_USART_CTL_ADDRDET_DISABLED =3D 0, + /* Enabled */ + FLEXCOMM_USART_CTL_ADDRDET_ENABLED =3D 1, +} FLEXCOMM_USART_CTL_ADDRDET_Enum; + +typedef enum { + /* Not disabled. USART transmitter is not disabled. */ + FLEXCOMM_USART_CTL_TXDIS_ENABLED =3D 0, + /* + * Disabled. USART transmitter is disabled after any character current= ly + * being transmitted is complete. This feature can be used to facilita= te + * software flow control. + */ + FLEXCOMM_USART_CTL_TXDIS_DISABLED =3D 1, +} FLEXCOMM_USART_CTL_TXDIS_Enum; + +typedef enum { + /* Clock on character */ + FLEXCOMM_USART_CTL_CC_CLOCK_ON_CHARACTER =3D 0, + /* Continuous clock */ + FLEXCOMM_USART_CTL_CC_CONTINOUS_CLOCK =3D 1, +} FLEXCOMM_USART_CTL_CC_Enum; + +typedef enum { + /* No effect. No effect on the CC bit. */ + FLEXCOMM_USART_CTL_CLRCCONRX_NO_EFFECT =3D 0, + /* Auto-clear */ + FLEXCOMM_USART_CTL_CLRCCONRX_AUTO_CLEAR =3D 1, +} FLEXCOMM_USART_CTL_CLRCCONRX_Enum; + +typedef enum { + /* Disabled */ + FLEXCOMM_USART_CTL_AUTOBAUD_DISABLED =3D 0, + /* Enabled */ + FLEXCOMM_USART_CTL_AUTOBAUD_ENABLED =3D 1, +} FLEXCOMM_USART_CTL_AUTOBAUD_Enum; + +typedef enum { + /* The receiver is currently receiving data. */ + FLEXCOMM_USART_STAT_RXIDLE_RX_ACTIVE =3D 0, + /* The receiver is not currently receiving data. */ + FLEXCOMM_USART_STAT_RXIDLE_RX_IDLE =3D 1, +} FLEXCOMM_USART_STAT_RXIDLE_Enum; + +typedef enum { + /* The transmitter is currently sending data. */ + FLEXCOMM_USART_STAT_TXIDLE_TX_ACTIVE =3D 0, + /* The transmitter is not currently sending data. */ + FLEXCOMM_USART_STAT_TXIDLE_TX_IDLE =3D 1, +} FLEXCOMM_USART_STAT_TXIDLE_Enum; + +typedef enum { + /* + * Not Idle. Indicates that the USART transmitter is NOT fully idle af= ter + * being disabled. + */ + FLEXCOMM_USART_STAT_TXDISSTAT_TX_NOT_IDLE =3D 0, + /* + * Idle. Indicates that the USART transmitter is fully idle after being + * disabled (CTL[TXDIS] =3D 1). + */ + FLEXCOMM_USART_STAT_TXDISSTAT_TX_IDLE =3D 1, +} FLEXCOMM_USART_STAT_TXDISSTAT_Enum; + +typedef enum { + /* + * Enables an interrupt when the transmitter becomes idle (STAT[TXIDLE= ] =3D + * 1). + */ + FLEXCOMM_USART_INTENSET_TXIDLEEN_ENABLE =3D 1, +} FLEXCOMM_USART_INTENSET_TXIDLEEN_Enum; + +typedef enum { + /* + * Enables an interrupt when there is a change in the state of the CTS + * input. + */ + FLEXCOMM_USART_INTENSET_DELTACTSEN_ENABLE =3D 1, +} FLEXCOMM_USART_INTENSET_DELTACTSEN_Enum; + +typedef enum { + /* + * Enables an interrupt when the transmitter is fully disabled as indi= cated + * by the STAT[TXDISINT] flag. See the description of the STAT[TXDISIN= T] + * flag. + */ + FLEXCOMM_USART_INTENSET_TXDISEN_ENABLE =3D 1, +} FLEXCOMM_USART_INTENSET_TXDISEN_Enum; + +typedef enum { + /* Enable */ + FLEXCOMM_USART_INTENSET_DELTARXBRKEN_ENABLE =3D 1, +} FLEXCOMM_USART_INTENSET_DELTARXBRKEN_Enum; + +typedef enum { + /* Enables an interrupt when a received start bit has been detected. */ + FLEXCOMM_USART_INTENSET_STARTEN_ENABLE =3D 1, +} FLEXCOMM_USART_INTENSET_STARTEN_Enum; + +typedef enum { + /* Enables an interrupt when a framing error has been detected. */ + FLEXCOMM_USART_INTENSET_FRAMERREN_ENABLE =3D 1, +} FLEXCOMM_USART_INTENSET_FRAMERREN_Enum; + +typedef enum { + /* Enables an interrupt when a parity error has been detected. */ + FLEXCOMM_USART_INTENSET_PARITYERREN_ENABLE =3D 1, +} FLEXCOMM_USART_INTENSET_PARITYERREN_Enum; + +typedef enum { + /* + * Enables an interrupt when noise is detected. See the description of= the + * CTL[RXNOISEINT] bit. + */ + FLEXCOMM_USART_INTENSET_RXNOISEEN_ENABLE =3D 1, +} FLEXCOMM_USART_INTENSET_RXNOISEEN_Enum; + +typedef enum { + /* Enables an interrupt when an auto baud error occurs. */ + FLEXCOMM_USART_INTENSET_ABERREN_ENABLE =3D 1, +} FLEXCOMM_USART_INTENSET_ABERREN_Enum; + +typedef enum { + /* FCLK is used directly by the USART function. */ + FLEXCOMM_USART_BRG_BRGVAL_Zero =3D 0, + /* FCLK is divided by 2 before use by the USART function. */ + FLEXCOMM_USART_BRG_BRGVAL_One =3D 1, + /* FCLK is divided by 3 before use by the USART function. */ + FLEXCOMM_USART_BRG_BRGVAL_Two =3D 2, + /* FCLK is divided by 65,536 before use by the USART function. */ + FLEXCOMM_USART_BRG_BRGVAL_FFFF =3D 65535, +} FLEXCOMM_USART_BRG_BRGVAL_Enum; + +typedef enum { + /* Not supported */ + FLEXCOMM_USART_OSR_OSRVAL_zero =3D 0, + /* Not supported */ + FLEXCOMM_USART_OSR_OSRVAL_one =3D 1, + /* Not supported */ + FLEXCOMM_USART_OSR_OSRVAL_two =3D 2, + /* Not supported */ + FLEXCOMM_USART_OSR_OSRVAL_three =3D 3, + /* 5 function clocks are used to transmit and receive each data bit. */ + FLEXCOMM_USART_OSR_OSRVAL_four =3D 4, + /* 6 function clocks are used to transmit and receive each data bit. */ + FLEXCOMM_USART_OSR_OSRVAL_five =3D 5, + /* 16 function clocks are used to transmit and receive each data bit. = */ + FLEXCOMM_USART_OSR_OSRVAL_sixteen =3D 15, +} FLEXCOMM_USART_OSR_OSRVAL_Enum; + +typedef enum { + /* The transmit FIFO is not enabled. */ + FLEXCOMM_USART_FIFOCFG_ENABLETX_DISABLED =3D 0, + /* The transmit FIFO is enabled. */ + FLEXCOMM_USART_FIFOCFG_ENABLETX_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOCFG_ENABLETX_Enum; + +typedef enum { + /* The receive FIFO is not enabled. */ + FLEXCOMM_USART_FIFOCFG_ENABLERX_DISABLED =3D 0, + /* The receive FIFO is enabled. */ + FLEXCOMM_USART_FIFOCFG_ENABLERX_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOCFG_ENABLERX_Enum; + +typedef enum { + /* FIFO is configured as 16 entries of 8 bits. */ + FLEXCOMM_USART_FIFOCFG_SIZE_SIZE16 =3D 0, + /* Not used */ + FLEXCOMM_USART_FIFOCFG_SIZE_SIZEINVALID1 =3D 1, + /* Not used */ + FLEXCOMM_USART_FIFOCFG_SIZE_SIZEINVALID2 =3D 2, + /* Not used */ + FLEXCOMM_USART_FIFOCFG_SIZE_SIZEINVALID3 =3D 3, +} FLEXCOMM_USART_FIFOCFG_SIZE_Enum; + +typedef enum { + /* DMA is not used for the transmit function. */ + FLEXCOMM_USART_FIFOCFG_DMATX_DISABLED =3D 0, + /* + * Triggers DMA for the transmit function if the FIFO is not full. + * Generally, data interrupts would be disabled if DMA is enabled. + */ + FLEXCOMM_USART_FIFOCFG_DMATX_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOCFG_DMATX_Enum; + +typedef enum { + /* DMA is not used for the receive function. */ + FLEXCOMM_USART_FIFOCFG_DMARX_DISABLED =3D 0, + /* + * Triggers DMA for the receive function if the FIFO is not empty. + * Generally, data interrupts would be disabled if DMA is enabled. + */ + FLEXCOMM_USART_FIFOCFG_DMARX_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOCFG_DMARX_Enum; + +typedef enum { + /* Only enabled interrupts will wake up the device from low power mode= s. */ + FLEXCOMM_USART_FIFOCFG_WAKETX_DISABLED =3D 0, + /* + * A device wake-up for DMA will occur if the transmit FIFO level reac= hes + * the value specified by FIFOTRIG[TXLVL], even when the TXLVL interru= pt is + * not enabled. + */ + FLEXCOMM_USART_FIFOCFG_WAKETX_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOCFG_WAKETX_Enum; + +typedef enum { + /* Only enabled interrupts will wake up the device from low power mode= s. */ + FLEXCOMM_USART_FIFOCFG_WAKERX_DISABLED =3D 0, + /* + * A device wake-up for DMA will occur if the receive FIFO level reach= es + * the value specified by FIFOTRIG[RXLVL], even when the RXLVL interru= pt is + * not enabled. + */ + FLEXCOMM_USART_FIFOCFG_WAKERX_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOCFG_WAKERX_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_USART_FIFOCFG_EMPTYTX_NO_EFFECT =3D 0, + /* The TX FIFO is emptied. */ + FLEXCOMM_USART_FIFOCFG_EMPTYTX_EMPTY_THE_TX_FIFO =3D 1, +} FLEXCOMM_USART_FIFOCFG_EMPTYTX_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_USART_FIFOCFG_EMPTYRX_NO_EFFECT =3D 0, + /* The RX FIFO is emptied. */ + FLEXCOMM_USART_FIFOCFG_EMPTYRX_EMPTY_THE_RX_FIFO =3D 1, +} FLEXCOMM_USART_FIFOCFG_EMPTYRX_Enum; + +typedef enum { + /* Debug reads of the FIFO do not pop the FIFO. */ + FLEXCOMM_USART_FIFOCFG_POPDBG_DO_NOT_POP =3D 0, + /* A debug read will cause the FIFO to pop. */ + FLEXCOMM_USART_FIFOCFG_POPDBG_POP =3D 1, +} FLEXCOMM_USART_FIFOCFG_POPDBG_Enum; + +typedef enum { + /* A transmit FIFO error has not occurred. */ + FLEXCOMM_USART_FIFOSTAT_TXERR_NO_TXERR =3D 0, + /* + * A transmit FIFO error has occurred. This error could be an overflow + * caused by pushing data into a full FIFO, or by an underflow if the = FIFO + * is empty when data is needed. + */ + FLEXCOMM_USART_FIFOSTAT_TXERR_TXERR =3D 1, +} FLEXCOMM_USART_FIFOSTAT_TXERR_Enum; + +typedef enum { + /* A receive FIFO overflow has not occurred */ + FLEXCOMM_USART_FIFOSTAT_RXERR_NO_RXERR =3D 0, + /* + * A receive FIFO overflow has occurred, caused by software or DMA not + * emptying the FIFO fast enough + */ + FLEXCOMM_USART_FIFOSTAT_RXERR_RXERR =3D 1, +} FLEXCOMM_USART_FIFOSTAT_RXERR_Enum; + +typedef enum { + /* No Peripheral Interrupt */ + FLEXCOMM_USART_FIFOSTAT_PERINT_NO_PERINT =3D 0, + /* Peripheral Interrupt */ + FLEXCOMM_USART_FIFOSTAT_PERINT_PERINT =3D 1, +} FLEXCOMM_USART_FIFOSTAT_PERINT_Enum; + +typedef enum { + /* The transmit FIFO is not empty. */ + FLEXCOMM_USART_FIFOSTAT_TXEMPTY_TXFIFO_ISNOTEMPTY =3D 0, + /* + * The transmit FIFO is empty, although the peripheral may still be + * processing the last piece of data. + */ + FLEXCOMM_USART_FIFOSTAT_TXEMPTY_TXFIFO_ISEMPTY =3D 1, +} FLEXCOMM_USART_FIFOSTAT_TXEMPTY_Enum; + +typedef enum { + /* + * The transmit FIFO is full and another write would cause it to overf= low. + */ + FLEXCOMM_USART_FIFOSTAT_TXNOTFULL_TXFIFO_ISFULL =3D 0, + /* The transmit FIFO is not full, so more data can be written. */ + FLEXCOMM_USART_FIFOSTAT_TXNOTFULL_TXFIFO_ISNOTFULL =3D 1, +} FLEXCOMM_USART_FIFOSTAT_TXNOTFULL_Enum; + +typedef enum { + /* The receive FIFO is empty. */ + FLEXCOMM_USART_FIFOSTAT_RXNOTEMPTY_RXFIFO_ISEMPTY =3D 0, + /* The receive FIFO is not empty, so data can be read. */ + FLEXCOMM_USART_FIFOSTAT_RXNOTEMPTY_RXFIFO_ISNOTEMPTY =3D 1, +} FLEXCOMM_USART_FIFOSTAT_RXNOTEMPTY_Enum; + +typedef enum { + /* The receive FIFO is not full. */ + FLEXCOMM_USART_FIFOSTAT_RXFULL_RXFIFO_ISNOTFULL =3D 0, + /* The receive FIFO is full. */ + FLEXCOMM_USART_FIFOSTAT_RXFULL_RXFIFO_ISFULL =3D 1, +} FLEXCOMM_USART_FIFOSTAT_RXFULL_Enum; + +typedef enum { + /* Transmit FIFO level does not generate a FIFO level trigger. */ + FLEXCOMM_USART_FIFOTRIG_TXLVLENA_DISABLED =3D 0, + /* + * A trigger will be generated if the transmit FIFO level reaches the = value + * specified by the TXLVL field. + */ + FLEXCOMM_USART_FIFOTRIG_TXLVLENA_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOTRIG_TXLVLENA_Enum; + +typedef enum { + /* Receive FIFO level does not generate a FIFO level trigger. */ + FLEXCOMM_USART_FIFOTRIG_RXLVLENA_DISABLED =3D 0, + /* + * An trigger will be generated if the receive FIFO level reaches the = value + * specified by the RXLVL field. + */ + FLEXCOMM_USART_FIFOTRIG_RXLVLENA_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOTRIG_RXLVLENA_Enum; + +typedef enum { + /* Trigger when the TX FIFO becomes empty */ + FLEXCOMM_USART_FIFOTRIG_TXLVL_TXLVL0 =3D 0, + /* Trigger when the TX FIFO level decreases to 1 entry */ + FLEXCOMM_USART_FIFOTRIG_TXLVL_TXLVL1 =3D 1, + /* + * Trigger when the TX FIFO level decreases to 15 entries (is no longer + * full) + */ + FLEXCOMM_USART_FIFOTRIG_TXLVL_TXLVL15 =3D 15, +} FLEXCOMM_USART_FIFOTRIG_TXLVL_Enum; + +typedef enum { + /* Trigger when the RX FIFO has received 1 entry (is no longer empty) = */ + FLEXCOMM_USART_FIFOTRIG_RXLVL_RXLVL1 =3D 0, + /* Trigger when the RX FIFO has received 2 entries */ + FLEXCOMM_USART_FIFOTRIG_RXLVL_RXLVL2 =3D 1, + /* Trigger when the RX FIFO has received 16 entries (has become full) = */ + FLEXCOMM_USART_FIFOTRIG_RXLVL_RXLVL15 =3D 15, +} FLEXCOMM_USART_FIFOTRIG_RXLVL_Enum; + +typedef enum { + /* No interrupt will be generated for a transmit error. */ + FLEXCOMM_USART_FIFOINTENSET_TXERR_DISABLED =3D 0, + /* An interrupt will be generated when a transmit error occurs. */ + FLEXCOMM_USART_FIFOINTENSET_TXERR_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOINTENSET_TXERR_Enum; + +typedef enum { + /* No interrupt will be generated for a receive error. */ + FLEXCOMM_USART_FIFOINTENSET_RXERR_DISABLED =3D 0, + /* An interrupt will be generated when a receive error occurs. */ + FLEXCOMM_USART_FIFOINTENSET_RXERR_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOINTENSET_RXERR_Enum; + +typedef enum { + /* No interrupt will be generated based on the TX FIFO level. */ + FLEXCOMM_USART_FIFOINTENSET_TXLVL_DISABLED =3D 0, + /* + * If FIFOTRIG[TXLVLENA] =3D 1, then an interrupt will be generated wh= en the + * TX FIFO level decreases to the level specified by FIFOTRIG[TXLVL] + */ + FLEXCOMM_USART_FIFOINTENSET_TXLVL_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOINTENSET_TXLVL_Enum; + +typedef enum { + /* No interrupt will be generated based on the RX FIFO level. */ + FLEXCOMM_USART_FIFOINTENSET_RXLVL_DISABLED =3D 0, + /* + * If FIFOTRIG[RXLVLENA] =3D 1, an interrupt will be generated when th= e when + * the RX FIFO level increases to the level specified by FIFOTRIG[RXLV= L]. + */ + FLEXCOMM_USART_FIFOINTENSET_RXLVL_ENABLED =3D 1, +} FLEXCOMM_USART_FIFOINTENSET_RXLVL_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_USART_FIFOINTENCLR_TXERR_NO_EFFECT =3D 0, + /* Clear the interrupt */ + FLEXCOMM_USART_FIFOINTENCLR_TXERR_CLEAR_THE_TXERR =3D 1, +} FLEXCOMM_USART_FIFOINTENCLR_TXERR_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_USART_FIFOINTENCLR_RXERR_NO_EFFECT =3D 0, + /* Clear the interrupt */ + FLEXCOMM_USART_FIFOINTENCLR_RXERR_CLEAR_THE_RXERR =3D 1, +} FLEXCOMM_USART_FIFOINTENCLR_RXERR_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_USART_FIFOINTENCLR_TXLVL_NO_EFFECT =3D 0, + /* Clear the interrupt */ + FLEXCOMM_USART_FIFOINTENCLR_TXLVL_CLEAR_THE_TXLVL =3D 1, +} FLEXCOMM_USART_FIFOINTENCLR_TXLVL_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_USART_FIFOINTENCLR_RXLVL_NO_EFFECT =3D 0, + /* Clear the interrupt */ + FLEXCOMM_USART_FIFOINTENCLR_RXLVL_CLEAR_THE_RXLVL =3D 1, +} FLEXCOMM_USART_FIFOINTENCLR_RXLVL_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_USART_FIFOINTSTAT_TXERR_TXERR_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_USART_FIFOINTSTAT_TXERR_TXERR_ISPENDING =3D 1, +} FLEXCOMM_USART_FIFOINTSTAT_TXERR_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_USART_FIFOINTSTAT_RXERR_RXERR_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_USART_FIFOINTSTAT_RXERR_RXERR_ISPENDING =3D 1, +} FLEXCOMM_USART_FIFOINTSTAT_RXERR_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_USART_FIFOINTSTAT_TXLVL_TXLVL_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_USART_FIFOINTSTAT_TXLVL_TXLVL_ISPENDING =3D 1, +} FLEXCOMM_USART_FIFOINTSTAT_TXLVL_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_USART_FIFOINTSTAT_RXLVL_RXLVL_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_USART_FIFOINTSTAT_RXLVL_RXLVL_ISPENDING =3D 1, +} FLEXCOMM_USART_FIFOINTSTAT_RXLVL_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_USART_FIFOINTSTAT_PERINT_PERINT_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_USART_FIFOINTSTAT_PERINT_PERINT_ISPENDING =3D 1, +} FLEXCOMM_USART_FIFOINTSTAT_PERINT_Enum; + + +#define FLEXCOMM_USART_REGISTER_ACCESS_INFO_ARRAY(_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_USART_REGS_NO] =3D { \ + [0 ... FLEXCOMM_USART_REGS_NO - 1] =3D { \ + .name =3D "", \ + .addr =3D -1, \ + }, \ + [R_FLEXCOMM_USART_CFG] =3D { \ + .name =3D "CFG", \ + .addr =3D 0x0, \ + .ro =3D 0xFF032402, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_CTL] =3D { \ + .name =3D "CTL", \ + .addr =3D 0x4, \ + .ro =3D 0xFFFEFCB9, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_STAT] =3D { \ + .name =3D "STAT", \ + .addr =3D 0x8, \ + .ro =3D 0xFFFE07DF, \ + .reset =3D 0xA, \ + }, \ + [R_FLEXCOMM_USART_INTENSET] =3D { \ + .name =3D "INTENSET", \ + .addr =3D 0xC, \ + .ro =3D 0xFFFE0797, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_INTENCLR] =3D { \ + .name =3D "INTENCLR", \ + .addr =3D 0x10, \ + .ro =3D 0xFFFE0797, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_BRG] =3D { \ + .name =3D "BRG", \ + .addr =3D 0x20, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_INTSTAT] =3D { \ + .name =3D "INTSTAT", \ + .addr =3D 0x24, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_OSR] =3D { \ + .name =3D "OSR", \ + .addr =3D 0x28, \ + .ro =3D 0xFFFFFFF0, \ + .reset =3D 0xF, \ + }, \ + [R_FLEXCOMM_USART_ADDR] =3D { \ + .name =3D "ADDR", \ + .addr =3D 0x2C, \ + .ro =3D 0xFFFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOCFG] =3D { \ + .name =3D "FIFOCFG", \ + .addr =3D 0xE00, \ + .ro =3D 0xFFF80FFC, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOSTAT] =3D { \ + .name =3D "FIFOSTAT", \ + .addr =3D 0xE04, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x30, \ + }, \ + [R_FLEXCOMM_USART_FIFOTRIG] =3D { \ + .name =3D "FIFOTRIG", \ + .addr =3D 0xE08, \ + .ro =3D 0xFFF0F0FC, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOINTENSET] =3D { \ + .name =3D "FIFOINTENSET", \ + .addr =3D 0xE10, \ + .ro =3D 0xFFFFFFF0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOINTENCLR] =3D { \ + .name =3D "FIFOINTENCLR", \ + .addr =3D 0xE14, \ + .ro =3D 0xFFFFFFF0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOINTSTAT] =3D { \ + .name =3D "FIFOINTSTAT", \ + .addr =3D 0xE18, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOWR] =3D { \ + .name =3D "FIFOWR", \ + .addr =3D 0xE20, \ + .ro =3D 0xFFFFFE00, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFORD] =3D { \ + .name =3D "FIFORD", \ + .addr =3D 0xE30, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFORDNOPOP] =3D { \ + .name =3D "FIFORDNOPOP", \ + .addr =3D 0xE40, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOSIZE] =3D { \ + .name =3D "FIFOSIZE", \ + .addr =3D 0xE48, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x10, \ + }, \ + [R_FLEXCOMM_USART_ID] =3D { \ + .name =3D "ID", \ + .addr =3D 0xFFC, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0xE0102100, \ + }, \ + } diff --git a/include/hw/char/flexcomm_usart.h b/include/hw/char/flexcomm_us= art.h new file mode 100644 index 0000000000..e67b15208f --- /dev/null +++ b/include/hw/char/flexcomm_usart.h @@ -0,0 +1,33 @@ +/* + * QEMU model for NXP's FLEXCOMM USART + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_FLEXCOMM_USART_H +#define HW_FLEXCOMM_USART_H + +#include "hw/misc/flexcomm_function.h" +#include "chardev/char-fe.h" + +#define TYPE_FLEXCOMM_USART "flexcomm-usart" +OBJECT_DECLARE_TYPE(FlexcommUsartState, FlexcommUsartClass, FLEXCOMM_USART= ); + +struct FlexcommUsartState { + FlexcommFunction parent_obj; + + CharBackend chr; +}; + +struct FlexcommUsartClass { + FlexcommFunctionClass parent_obj; + + FlexcommFunctionSelect select; +}; + +#endif /* HW_FLEXCOMM_USART_H */ diff --git a/include/hw/misc/flexcomm.h b/include/hw/misc/flexcomm.h index 832d4cd29d..679b7ea64d 100644 --- a/include/hw/misc/flexcomm.h +++ b/include/hw/misc/flexcomm.h @@ -15,6 +15,7 @@ #include "hw/sysbus.h" #include "hw/arm/svd/flexcomm.h" #include "qemu/fifo32.h" +#include "hw/char/flexcomm_usart.h" =20 #define FLEXCOMM_FUNC_USART 0 #define FLEXCOMM_FUNC_SPI 1 @@ -46,6 +47,7 @@ struct FlexcommState { bool irq_state; Fifo32 rx_fifo; Fifo32 tx_fifo; + FlexcommUsartState usart; }; =20 #endif /* HW_FLEXCOMM_H */ diff --git a/hw/char/flexcomm_usart.c b/hw/char/flexcomm_usart.c new file mode 100644 index 0000000000..53ab5d8379 --- /dev/null +++ b/hw/char/flexcomm_usart.c @@ -0,0 +1,288 @@ +/* + * QEMU model for NXP's FLEXCOMM USART + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "qapi/error.h" +#include "trace.h" +#include "hw/misc/flexcomm.h" +#include "hw/char/flexcomm_usart.h" +#include "hw/arm/svd/flexcomm_usart.h" + +#define REG(s, reg) (s->regs[R_FLEXCOMM_USART_##reg]) +/* register field write helper macro */ +#define RF_RD(s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXCOMM_USART_##reg, field, val) +/* register field read helper macro */ +#define RF_WR(s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXCOMM_USART_##reg, field) + +static FLEXCOMM_USART_REGISTER_ACCESS_INFO_ARRAY(reg_info); + +static void flexcomm_usart_reset(FlexcommFunction *f) +{ + for (int i =3D 0; i < FLEXCOMM_USART_REGS_NO; i++) { + hwaddr addr =3D reg_info[i].addr; + + if (addr !=3D -1) { + struct RegisterInfo ri =3D { + .data =3D &f->regs[addr / 4], + .data_size =3D 4, + .access =3D ®_info[i], + }; + + register_reset(&ri); + } + } +} + +static void flexcomm_usart_irq_update(FlexcommFunction *f) +{ + bool irq, per_irqs, fifo_irqs, enabled =3D RF_WR(f, CFG, ENABLE); + + flexcomm_update_fifostat(f); + fifo_irqs =3D REG(f, FIFOINTSTAT) & REG(f, FIFOINTENSET); + + REG(f, INTSTAT) =3D REG(f, STAT) & REG(f, INTENSET); + per_irqs =3D REG(f, INTSTAT) !=3D 0; + + irq =3D enabled && (fifo_irqs || per_irqs); + + trace_flexcomm_usart_irq(DEVICE(f)->id, irq, fifo_irqs, per_irqs, enab= led); + flexcomm_set_irq(f, irq); +} + +static int flexcomm_usart_rx_space(void *opaque) +{ + FlexcommUsartState *s =3D FLEXCOMM_USART(opaque); + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(opaque); + + uint32_t ret =3D fifo32_num_free(f->rx_fifo); + + if (!RF_WR(f, CFG, ENABLE) || !RF_WR(f, FIFOCFG, ENABLERX)) { + ret =3D 0; + } + + trace_flexcomm_usart_rx_space(DEVICE(s)->id, ret); + + return ret; +} + +static void flexcomm_usart_rx(void *opaque, const uint8_t *buf, int size) +{ + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(opaque); + + if (!RF_WR(f, CFG, ENABLE) || !RF_WR(f, FIFOCFG, ENABLERX)) { + return; + } + + trace_flexcomm_usart_rx(DEVICE(f)->id); + + while (!fifo32_is_full(f->rx_fifo) && size) { + fifo32_push(f->rx_fifo, *buf++); + size--; + } + + flexcomm_usart_irq_update(f); +} + +static MemTxResult flexcomm_usart_reg_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(opaque); + FlexcommUsartState *s =3D FLEXCOMM_USART(opaque); + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + MemTxResult ret =3D MEMTX_OK; + + if (size !=3D 4) { + ret =3D MEMTX_ERROR; + goto out; + } + + switch (addr) { + case A_FLEXCOMM_USART_FIFORD: + { + if (!fifo32_is_empty(f->rx_fifo)) { + *data =3D fifo32_pop(f->rx_fifo); + qemu_chr_fe_accept_input(&s->chr); + } + break; + } + case A_FLEXCOMM_USART_FIFORDNOPOP: + { + if (!fifo32_is_empty(f->rx_fifo)) { + *data =3D fifo32_peek(f->rx_fifo); + } + break; + } + default: + *data =3D f->regs[addr / 4]; + break; + } + + flexcomm_usart_irq_update(f); + +out: + trace_flexcomm_usart_reg_read(DEVICE(f)->id, rai->name, addr, *data); + return ret; +} + +static MemTxResult flexcomm_usart_reg_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(opaque); + FlexcommUsartState *s =3D FLEXCOMM_USART(opaque); + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + struct RegisterInfo ri =3D { + .data =3D &f->regs[addr / 4], + .data_size =3D 4, + .access =3D rai, + }; + + trace_flexcomm_usart_reg_write(DEVICE(f)->id, rai->name, addr, value); + + switch (addr) { + case A_FLEXCOMM_USART_INTENCLR: + { + register_write(&ri, value, ~0, NULL, false); + REG(f, INTENSET) &=3D ~REG(f, INTENCLR); + break; + } + case A_FLEXCOMM_USART_FIFOCFG: + { + register_write(&ri, value, ~0, NULL, false); + flexcomm_reset_fifos(f); + break; + } + case A_FLEXCOMM_USART_FIFOSTAT: + { + flexcomm_clear_fifostat(f, value); + break; + } + case A_FLEXCOMM_USART_FIFOINTENSET: + { + REG(f, FIFOINTENSET) |=3D value; + break; + } + case A_FLEXCOMM_USART_FIFOINTENCLR: + { + register_write(&ri, value, ~0, NULL, false); + REG(f, FIFOINTENSET) &=3D ~value; + break; + } + case A_FLEXCOMM_USART_FIFOWR: + { + register_write(&ri, value, ~0, NULL, false); + + if (!fifo32_is_full(f->tx_fifo)) { + fifo32_push(f->tx_fifo, REG(f, FIFOWR)); + } + + if (!RF_WR(f, CFG, ENABLE) || !RF_WR(f, FIFOCFG, ENABLETX)) { + break; + } + + while (!fifo32_is_empty(f->tx_fifo)) { + uint32_t val32 =3D fifo32_pop(f->tx_fifo); + uint8_t val8 =3D val32 & 0xff; + + trace_flexcomm_usart_tx(DEVICE(f)->id); + qemu_chr_fe_write_all(&s->chr, &val8, sizeof(val8)); + } + break; + } + case A_FLEXCOMM_USART_CFG: + { + register_write(&ri, value, ~0, NULL, false); + break; + } + default: + register_write(&ri, value, ~0, NULL, false); + break; + } + + flexcomm_usart_irq_update(f); + + return MEMTX_OK; +} + +static void flexcomm_usart_select(FlexcommFunction *f, bool selected) +{ + FlexcommUsartState *s =3D FLEXCOMM_USART(f); + FlexcommUsartClass *uc =3D FLEXCOMM_USART_GET_CLASS(f); + + if (selected) { + qemu_chr_fe_set_handlers(&s->chr, flexcomm_usart_rx_space, + flexcomm_usart_rx, NULL, NULL, + s, NULL, true); + flexcomm_usart_reset(f); + } else { + qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, NULL, NULL, NULL, NU= LL, + false); + } + uc->select(f, selected); +} + +static const MemoryRegionOps flexcomm_usart_ops =3D { + .read_with_attrs =3D flexcomm_usart_reg_read, + .write_with_attrs =3D flexcomm_usart_reg_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + .unaligned =3D false, + }, +}; + +static Property flexcomm_usart_properties[] =3D { + DEFINE_PROP_CHR("chardev", FlexcommUsartState, chr), + DEFINE_PROP_END_OF_LIST(), +}; + +static void flexcomm_usart_realize(DeviceState *dev, Error **errp) +{ + qdev_prop_set_chr(dev, "chardev", qemu_chr_find(dev->id)); +} + +static void flexcomm_usart_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + FlexcommFunctionClass *fc =3D FLEXCOMM_FUNCTION_CLASS(klass); + FlexcommUsartClass *uc =3D FLEXCOMM_USART_CLASS(klass); + + device_class_set_props(dc, flexcomm_usart_properties); + dc->realize =3D flexcomm_usart_realize; + uc->select =3D fc->select; + fc->select =3D flexcomm_usart_select; + fc->name =3D "usart"; + fc->has_fifos =3D true; + fc->mmio_ops =3D &flexcomm_usart_ops; +} + +static const TypeInfo flexcomm_usart_types[] =3D { + { + .name =3D TYPE_FLEXCOMM_USART, + .parent =3D TYPE_FLEXCOMM_FUNCTION, + .instance_size =3D sizeof(FlexcommUsartState), + .class_init =3D flexcomm_usart_class_init, + .class_size =3D sizeof(FlexcommUsartClass), + }, +}; + +DEFINE_TYPES(flexcomm_usart_types); diff --git a/hw/misc/flexcomm.c b/hw/misc/flexcomm.c index a98d8845aa..a291148f27 100644 --- a/hw/misc/flexcomm.c +++ b/hw/misc/flexcomm.c @@ -23,6 +23,7 @@ #include "migration/vmstate.h" #include "hw/misc/flexcomm.h" #include "hw/arm/svd/flexcomm_usart.h" +#include "hw/char/flexcomm_usart.h" =20 #define REG(s, reg) (s->regs[R_FLEXCOMM_##reg]) #define RF_WR(s, reg, field, val) \ @@ -218,6 +219,7 @@ static void flexcomm_init(Object *obj) TYPE_FLEXCOMM, sizeof(s->regs)); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->container); sysbus_init_irq(sbd, &s->irq); + object_initialize_child(obj, "usart", &s->usart, TYPE_FLEXCOMM_USART); } =20 static void flexcomm_finalize(Object *obj) @@ -247,6 +249,7 @@ static void flexcomm_realize(DeviceState *dev, Error **= errp) FlexcommState *s =3D FLEXCOMM(dev); =20 memory_region_add_subregion_overlap(&s->container, 0, &s->mmio, -1); + flexcomm_func_realize_and_unref(FLEXCOMM_FUNCTION(&s->usart), errp); } =20 static const VMStateDescription vmstate_flexcomm =3D { diff --git a/hw/arm/svd/meson.build b/hw/arm/svd/meson.build index 4b0bbbbbdc..2bde34d15b 100644 --- a/hw/arm/svd/meson.build +++ b/hw/arm/svd/meson.build @@ -4,4 +4,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm.h', '-p', 'FLEXCOMM0', '-t', 'FLEXCOMM']) + run_target('svd-flexcomm-usart', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_usart.= h', + '-p', 'USART0', '-t', 'FLEXCOMM_USART']) endif diff --git a/hw/char/meson.build b/hw/char/meson.build index a4c4c5ff0f..761e4b817c 100644 --- a/hw/char/meson.build +++ b/hw/char/meson.build @@ -38,3 +38,4 @@ system_ss.add(when: 'CONFIG_GOLDFISH_TTY', if_true: files= ('goldfish_tty.c')) specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.= c')) specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c= ')) specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_vty.c')) +system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_usart.c')) diff --git a/hw/char/trace-events b/hw/char/trace-events index 59e1f734a7..578551b388 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -125,3 +125,11 @@ xen_console_unrealize(unsigned int idx) "idx %u" xen_console_realize(unsigned int idx, const char *chrdev) "idx %u chrdev %= s" xen_console_device_create(unsigned int idx) "idx %u" xen_console_device_destroy(unsigned int idx) "idx %u" + +# flexcomm_usart.c +flexcomm_usart_reg_read(const char *id, const char *reg_name, uint32_t add= r, uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_usart_reg_write(const char *id, const char *reg_name, uint32_t ad= dr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_usart_rx_space(const char *id, uint32_t rx) "%s: %d" +flexcomm_usart_rx(const char *id) "%s" +flexcomm_usart_tx(const char *id) "%s" +flexcomm_usart_irq(const char *id, bool irq, bool fifoirqs, bool perirqs, = bool enabled) "%s: %d %d %d %d" --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687842; cv=none; d=zohomail.com; s=zohoarc; b=Ej7AWdARa6eP46qWuSVRvmaLC8Bu1cGe4tcOv12aDgVuGYeF9seG3mohTXGXoctNKYDGY69EKzR10TQOhsQpiqs+S6h+MSgOxMgmFIWl99IXWSrEYtutwD69bc5vQMTFxJaf8Z3HqTByAKaksUOn+SrKpUaTIszv8Xo6+5S3iYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687842; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CDzav/GoioS247j60FjvTg5BYepYLV8hwnMK+f6n+3s=; b=DqYWMGG3dPW9BLsgA5aELvCwX64+TWYCaAqDrWBoPGUtCRtrD/HLQW3324r0Ub4dFrzLlSmIO8MqKj/vS/TJ7q9tdCgMw4joa5Ft6j9/AZVPF/+zmycVcxZwb+GalLCilz+76NyA8TAZqrHpQ4lpHWVstTGSQbJHPHoJR3gCwa0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687842556846.5730416630636; Wed, 18 Sep 2024 12:30:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gs-00058G-GY; Wed, 18 Sep 2024 15:23:26 -0400 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 <3nijrZgUKCtkO5QDKBJJBG9.7JHL9HP-89Q9GIJIBIP.JMB@flex--tavip.bounces.google.com>) id 1sr0Gm-0004gv-40 for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:20 -0400 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3nijrZgUKCtkO5QDKBJJBG9.7JHL9HP-89Q9GIJIBIP.JMB@flex--tavip.bounces.google.com>) id 1sr0Gf-0007Kj-PN for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:19 -0400 Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-6c8f99fef10so8285210a12.3 for ; Wed, 18 Sep 2024 12:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687391; x=1727292191; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CDzav/GoioS247j60FjvTg5BYepYLV8hwnMK+f6n+3s=; b=OtlLTctmRfMOKUUBX1VZSfpsJA07gWrODnNA2+Kxe95p34/5HYuksUKQ0DbKsK/hyE H0U+jUIVOCTR5vXqGXfj5FYPuQsyBNM72I9O54aXWGM0bZaxor7I5utfhGyeLfzGyX5S EXkyCSaK9SBYdLD4Pn2M/rTu5tft9pYKCoTHfPOzthZv1KtcyyJ6ZrDdWK5/veecIhSk Upci5x78jcMZc/6uWzg2T/ed0p1w5x4ZUnpq1FCMDbKTHTPfNVNz993tAqjn37M9qqSq Cy8gWQRp58TZZ9Bx7SlRaXtaqk7VjSqIpFzfqZqHGYzTrb9YDOa4eRxwFtqVnhXSmtVl N5Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687391; x=1727292191; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CDzav/GoioS247j60FjvTg5BYepYLV8hwnMK+f6n+3s=; b=izCKrWhXDGWWx89BIJ3DWSxge7EBPCAq4uHGm2CdlGaqnrXoiXigeZPCnfP+7i/AFT V0nj1xmxkmMMoslEnErCVZk0Aq68npvPygXLdoowvID5rnD3RYgOTl/OzI96V780K2xh Op2nNScwvTlKJdW9iX69zi+XoWGskl4U5gESnTHnyIZiVW8PfsOjpkdoHr9/vYqLN18V zHnNFmiyDYpNy8DFvXozafsUXY47Dnn2II6HnYZco7U9csFdIouoMqGE7UskAt66GsIP 0USuGu/NltuNe990L8hOnIwU7Xe0okGRwOXKuWTh7GCPIIrAqduO6mtuwXGDVZf3vK3S yGgQ== X-Gm-Message-State: AOJu0YxwyG0NiEQZ9JmYs0h6BOvbSPgKyaAzGJBHaHCzXN5ie4M+Qp2F mz0ghS+TSOupjmytu1wBhrAfVhczUFTxJLsnHzwZNqzRO6oHoUmmeNddxopdg3D0un43NHk7eQ5 0EnSm7fs659R2M+1M/UqH8b9SshOpILhM1QnV0sb7nM4I4i4u1cfhMGOgE+zcW2lZyfN2W7jd8F sxffoJh4AfOnGRMH33TDSfLHaalw== X-Google-Smtp-Source: AGHT+IH29Mb3545/0C6lseOfjIwxKDX1NukEuMi0xqHjwXJNF/kAwUsPVJTezBGsohIGOYS1RcY+dc9Qfg== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:902:e5c4:b0:205:66a5:5fc0 with SMTP id d9443c01a7336-20781b2fc94mr11273375ad.2.1726687390780; Wed, 18 Sep 2024 12:23:10 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:36 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-9-tavip@google.com> Subject: [PATCH 08/25] hw/i2c: add support for flexcomm i2c From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::549; envelope-from=3nijrZgUKCtkO5QDKBJJBG9.7JHL9HP-89Q9GIJIBIP.JMB@flex--tavip.bounces.google.com; helo=mail-pg1-x549.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687844414116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for NXP's flexcomm i2c. It does not support slave mode or DMA. The patch includes an automatically generated header which contains the register layout and helpers. The header can be regenerated with the svd-flexcomm-i2c target when the build is configured with --enable-mcux-soc-svd. Signed-off-by: Octavian Purdila --- include/hw/arm/svd/flexcomm_i2c.h | 1190 +++++++++++++++++++++++++++++ include/hw/i2c/flexcomm_i2c.h | 40 + include/hw/misc/flexcomm.h | 2 + hw/i2c/flexcomm_i2c.c | 250 ++++++ hw/misc/flexcomm.c | 3 + hw/arm/svd/meson.build | 3 + hw/i2c/meson.build | 1 + hw/i2c/trace-events | 10 + hw/misc/Kconfig | 1 + 9 files changed, 1500 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_i2c.h create mode 100644 include/hw/i2c/flexcomm_i2c.h create mode 100644 hw/i2c/flexcomm_i2c.c diff --git a/include/hw/arm/svd/flexcomm_i2c.h b/include/hw/arm/svd/flexcom= m_i2c.h new file mode 100644 index 0000000000..9017d48446 --- /dev/null +++ b/include/hw/arm/svd/flexcomm_i2c.h @@ -0,0 +1,1190 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#include "hw/register.h" + +/* I2C Bus Interface */ +#define FLEXCOMM_I2C_REGS_NO (1024) + +/* Configuration Register */ +REG32(FLEXCOMM_I2C_CFG, 2048); +/* Master Enable */ +FIELD(FLEXCOMM_I2C_CFG, MSTEN, 0, 1); +/* Slave Enable */ +FIELD(FLEXCOMM_I2C_CFG, SLVEN, 1, 1); +/* Monitor Enable */ +FIELD(FLEXCOMM_I2C_CFG, MONEN, 2, 1); +/* I2C bus Time-out Enable */ +FIELD(FLEXCOMM_I2C_CFG, TIMEOUTEN, 3, 1); +/* Monitor function Clock Stretching */ +FIELD(FLEXCOMM_I2C_CFG, MONCLKSTR, 4, 1); +/* High Speed mode Capable enable */ +FIELD(FLEXCOMM_I2C_CFG, HSCAPABLE, 5, 1); + +/* Status Register */ +REG32(FLEXCOMM_I2C_STAT, 2052); +/* Master Pending */ +FIELD(FLEXCOMM_I2C_STAT, MSTPENDING, 0, 1); +/* Master State code */ +FIELD(FLEXCOMM_I2C_STAT, MSTSTATE, 1, 3); +/* Master Arbitration Loss flag */ +FIELD(FLEXCOMM_I2C_STAT, MSTARBLOSS, 4, 1); +/* Master Start/Stop Error flag */ +FIELD(FLEXCOMM_I2C_STAT, MSTSTSTPERR, 6, 1); +/* Slave Pending */ +FIELD(FLEXCOMM_I2C_STAT, SLVPENDING, 8, 1); +/* Slave State */ +FIELD(FLEXCOMM_I2C_STAT, SLVSTATE, 9, 2); +/* Slave Not Stretching */ +FIELD(FLEXCOMM_I2C_STAT, SLVNOTSTR, 11, 1); +/* Slave address match Index T */ +FIELD(FLEXCOMM_I2C_STAT, SLVIDX, 12, 2); +/* Slave selected flag */ +FIELD(FLEXCOMM_I2C_STAT, SLVSEL, 14, 1); +/* Slave Deselected flag */ +FIELD(FLEXCOMM_I2C_STAT, SLVDESEL, 15, 1); +/* Monitor Ready */ +FIELD(FLEXCOMM_I2C_STAT, MONRDY, 16, 1); +/* Monitor Overflow flag */ +FIELD(FLEXCOMM_I2C_STAT, MONOV, 17, 1); +/* Monitor Active flag */ +FIELD(FLEXCOMM_I2C_STAT, MONACTIVE, 18, 1); +/* Monitor Idle flag */ +FIELD(FLEXCOMM_I2C_STAT, MONIDLE, 19, 1); +/* Event Time-out Interrupt flag */ +FIELD(FLEXCOMM_I2C_STAT, EVENTTIMEOUT, 24, 1); +/* SCL Time-out Interrupt flag */ +FIELD(FLEXCOMM_I2C_STAT, SCLTIMEOUT, 25, 1); + +/* Interrupt Enable Set Register */ +REG32(FLEXCOMM_I2C_INTENSET, 2056); +/* Master Pending interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, MSTPENDINGEN, 0, 1); +/* Master Arbitration Loss interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, MSTARBLOSSEN, 4, 1); +/* Master Start/Stop Error interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, MSTSTSTPERREN, 6, 1); +/* Slave Pending interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, SLVPENDINGEN, 8, 1); +/* Slave Not Stretching interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, SLVNOTSTREN, 11, 1); +/* Slave Deselect interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, SLVDESELEN, 15, 1); +/* Monitor data Ready interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, MONRDYEN, 16, 1); +/* Monitor Overrun interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, MONOVEN, 17, 1); +/* Monitor Idle interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, MONIDLEEN, 19, 1); +/* Event Time-out interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, EVENTTIMEOUTEN, 24, 1); +/* SCL Time-out interrupt Enable */ +FIELD(FLEXCOMM_I2C_INTENSET, SCLTIMEOUTEN, 25, 1); + +/* Interrupt Enable Clear Register */ +REG32(FLEXCOMM_I2C_INTENCLR, 2060); +/* Master Pending interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, MSTPENDINGCLR, 0, 1); +/* Master Arbitration Loss interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, MSTARBLOSSCLR, 4, 1); +/* Master Start/Stop Error interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, MSTSTSTPERRCLR, 6, 1); +/* Slave Pending interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, SLVPENDINGCLR, 8, 1); +/* Slave Not Stretching interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, SLVNOTSTRCLR, 11, 1); +/* Slave Deselect interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, SLVDESELCLR, 15, 1); +/* Monitor data Ready interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, MONRDYCLR, 16, 1); +/* Monitor Overrun interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, MONOVCLR, 17, 1); +/* Monitor Idle interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, MONIDLECLR, 19, 1); +/* Event time-out interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, EVENTTIMEOUTCLR, 24, 1); +/* SCL time-out interrupt clear */ +FIELD(FLEXCOMM_I2C_INTENCLR, SCLTIMEOUTCLR, 25, 1); + +/* Time-out Register */ +REG32(FLEXCOMM_I2C_TIMEOUT, 2064); +/* Time-out time value, the bottom 4 bits */ +FIELD(FLEXCOMM_I2C_TIMEOUT, TOMIN, 0, 4); +/* Time-out time value */ +FIELD(FLEXCOMM_I2C_TIMEOUT, TO, 4, 12); + +/* Clock Divider Register */ +REG32(FLEXCOMM_I2C_CLKDIV, 2068); +/* Divider Value */ +FIELD(FLEXCOMM_I2C_CLKDIV, DIVVAL, 0, 16); + +/* Interrupt Status Register */ +REG32(FLEXCOMM_I2C_INTSTAT, 2072); +/* Master Pending */ +FIELD(FLEXCOMM_I2C_INTSTAT, MSTPENDING, 0, 1); +/* Master Arbitration Loss flag */ +FIELD(FLEXCOMM_I2C_INTSTAT, MSTARBLOSS, 4, 1); +/* Master Start/Stop Error flag */ +FIELD(FLEXCOMM_I2C_INTSTAT, MSTSTSTPERR, 6, 1); +/* Slave Pending */ +FIELD(FLEXCOMM_I2C_INTSTAT, SLVPENDING, 8, 1); +/* Slave Not Stretching status */ +FIELD(FLEXCOMM_I2C_INTSTAT, SLVNOTSTR, 11, 1); +/* Slave Deselected flag */ +FIELD(FLEXCOMM_I2C_INTSTAT, SLVDESEL, 15, 1); +/* Monitor Ready */ +FIELD(FLEXCOMM_I2C_INTSTAT, MONRDY, 16, 1); +/* Monitor Overflow flag */ +FIELD(FLEXCOMM_I2C_INTSTAT, MONOV, 17, 1); +/* Monitor Idle flag */ +FIELD(FLEXCOMM_I2C_INTSTAT, MONIDLE, 19, 1); +/* Event Time-out Interrupt flag */ +FIELD(FLEXCOMM_I2C_INTSTAT, EVENTTIMEOUT, 24, 1); +/* SCL Time-out Interrupt flag */ +FIELD(FLEXCOMM_I2C_INTSTAT, SCLTIMEOUT, 25, 1); + +/* Master Control Register */ +REG32(FLEXCOMM_I2C_MSTCTL, 2080); +/* Master Continue(write-only) */ +FIELD(FLEXCOMM_I2C_MSTCTL, MSTCONTINUE, 0, 1); +/* Master Start control(write-only) */ +FIELD(FLEXCOMM_I2C_MSTCTL, MSTSTART, 1, 1); +/* Master Stop control(write-only) */ +FIELD(FLEXCOMM_I2C_MSTCTL, MSTSTOP, 2, 1); +/* Master DMA enable */ +FIELD(FLEXCOMM_I2C_MSTCTL, MSTDMA, 3, 1); + +/* Master Timing Register */ +REG32(FLEXCOMM_I2C_MSTTIME, 2084); +/* Master SCL Low time */ +FIELD(FLEXCOMM_I2C_MSTTIME, MSTSCLLOW, 0, 3); +/* Master SCL High time */ +FIELD(FLEXCOMM_I2C_MSTTIME, MSTSCLHIGH, 4, 3); + +/* Master Data Register */ +REG32(FLEXCOMM_I2C_MSTDAT, 2088); +/* Master function data register */ +FIELD(FLEXCOMM_I2C_MSTDAT, DATA, 0, 8); + +/* Slave Control Register */ +REG32(FLEXCOMM_I2C_SLVCTL, 2112); +/* Slave Continue */ +FIELD(FLEXCOMM_I2C_SLVCTL, SLVCONTINUE, 0, 1); +/* Slave NACK */ +FIELD(FLEXCOMM_I2C_SLVCTL, SLVNACK, 1, 1); +/* Slave DMA enable */ +FIELD(FLEXCOMM_I2C_SLVCTL, SLVDMA, 3, 1); +/* Automatic Acknowledge */ +FIELD(FLEXCOMM_I2C_SLVCTL, AUTOACK, 8, 1); +/* Automatic Match Read */ +FIELD(FLEXCOMM_I2C_SLVCTL, AUTOMATCHREAD, 9, 1); + +/* Slave Data Register */ +REG32(FLEXCOMM_I2C_SLVDAT, 2116); +/* Slave function data register */ +FIELD(FLEXCOMM_I2C_SLVDAT, DATA, 0, 8); + +/* Slave Address Register */ +REG32(FLEXCOMM_I2C_SLVADR0, 2120); +/* Slave Address n Disable */ +FIELD(FLEXCOMM_I2C_SLVADR0, SADISABLE, 0, 1); +/* Slave Address. */ +FIELD(FLEXCOMM_I2C_SLVADR0, SLVADR, 1, 7); +/* Automatic NACK operation */ +FIELD(FLEXCOMM_I2C_SLVADR0, AUTONACK, 15, 1); + +/* Slave Address Register */ +REG32(FLEXCOMM_I2C_SLVADR1, 2124); +/* Slave Address n Disable */ +FIELD(FLEXCOMM_I2C_SLVADR1, SADISABLE, 0, 1); +/* Slave Address. */ +FIELD(FLEXCOMM_I2C_SLVADR1, SLVADR, 1, 7); +/* Automatic NACK operation */ +FIELD(FLEXCOMM_I2C_SLVADR1, AUTONACK, 15, 1); + +/* Slave Address Register */ +REG32(FLEXCOMM_I2C_SLVADR2, 2128); +/* Slave Address n Disable */ +FIELD(FLEXCOMM_I2C_SLVADR2, SADISABLE, 0, 1); +/* Slave Address. */ +FIELD(FLEXCOMM_I2C_SLVADR2, SLVADR, 1, 7); +/* Automatic NACK operation */ +FIELD(FLEXCOMM_I2C_SLVADR2, AUTONACK, 15, 1); + +/* Slave Address Register */ +REG32(FLEXCOMM_I2C_SLVADR3, 2132); +/* Slave Address n Disable */ +FIELD(FLEXCOMM_I2C_SLVADR3, SADISABLE, 0, 1); +/* Slave Address. */ +FIELD(FLEXCOMM_I2C_SLVADR3, SLVADR, 1, 7); +/* Automatic NACK operation */ +FIELD(FLEXCOMM_I2C_SLVADR3, AUTONACK, 15, 1); + +/* Slave Qualification for Address 0 Register */ +REG32(FLEXCOMM_I2C_SLVQUAL0, 2136); +/* Qualify mode for slave address 0 */ +FIELD(FLEXCOMM_I2C_SLVQUAL0, QUALMODE0, 0, 1); +/* Slave address Qualifier for address 0 */ +FIELD(FLEXCOMM_I2C_SLVQUAL0, SLVQUAL0, 1, 7); + +/* Monitor Receiver Data Register */ +REG32(FLEXCOMM_I2C_MONRXDAT, 2176); +/* Monitor function Receiver Data */ +FIELD(FLEXCOMM_I2C_MONRXDAT, MONRXDAT, 0, 8); +/* Monitor Received Start */ +FIELD(FLEXCOMM_I2C_MONRXDAT, MONSTART, 8, 1); +/* Monitor Received Repeated Start */ +FIELD(FLEXCOMM_I2C_MONRXDAT, MONRESTART, 9, 1); +/* Monitor Received NACK */ +FIELD(FLEXCOMM_I2C_MONRXDAT, MONNACK, 10, 1); + +/* Peripheral Identification Register */ +REG32(FLEXCOMM_I2C_ID, 4092); +/* Aperture */ +FIELD(FLEXCOMM_I2C_ID, APERTURE, 0, 8); +/* Minor revision of module implementation */ +FIELD(FLEXCOMM_I2C_ID, MINOR_REV, 8, 4); +/* Major revision of module implementation */ +FIELD(FLEXCOMM_I2C_ID, MAJOR_REV, 12, 4); +/* Module identifier for the selected function */ +FIELD(FLEXCOMM_I2C_ID, ID, 16, 16); + + +typedef enum { + /* + * Disabled. The I2C Master function is disabled. When disabled, the M= aster + * configuration settings are not changed, but the Master function is + * internally reset. + */ + FLEXCOMM_I2C_CFG_MSTEN_DISABLED =3D 0, + /* Enabled. The I2C Master function is enabled. */ + FLEXCOMM_I2C_CFG_MSTEN_ENABLED =3D 1, +} FLEXCOMM_I2C_CFG_MSTEN_Enum; + +typedef enum { + /* + * Disabled. The I2C slave function is disabled. When disabled, the Sl= ave + * configuration settings are not changed, but the Slave function is + * internally reset. + */ + FLEXCOMM_I2C_CFG_SLVEN_DISABLED =3D 0, + /* Enabled. The I2C slave function is enabled. */ + FLEXCOMM_I2C_CFG_SLVEN_ENABLED =3D 1, +} FLEXCOMM_I2C_CFG_SLVEN_Enum; + +typedef enum { + /* + * Disabled. The I2C Monitor function is disabled. When disabled, the + * Monitor function configuration settings are not changed, but the Mo= nitor + * function is internally reset. + */ + FLEXCOMM_I2C_CFG_MONEN_DISABLED =3D 0, + /* Enabled. The I2C Monitor function is enabled. */ + FLEXCOMM_I2C_CFG_MONEN_ENABLED =3D 1, +} FLEXCOMM_I2C_CFG_MONEN_Enum; + +typedef enum { + /* + * Disabled. The time-out function is disabled. When disabled, the tim= e-out + * function is internally reset. + */ + FLEXCOMM_I2C_CFG_TIMEOUTEN_DISABLED =3D 0, + /* + * Enabled. The time-out function is enabled. Both types of time-out f= lags + * will be generated and will cause interrupts if those flags are enab= led. + * Typically, only one time-out flag will be used in a system. + */ + FLEXCOMM_I2C_CFG_TIMEOUTEN_ENABLED =3D 1, +} FLEXCOMM_I2C_CFG_TIMEOUTEN_Enum; + +typedef enum { + /* + * Disabled. The Monitor function will not perform clock stretching. + * Software or DMA may not always be able to read data provided by the + * Monitor function before it (the data) is overwritten. This mode can= be + * used when non-invasive monitoring is critical. + */ + FLEXCOMM_I2C_CFG_MONCLKSTR_DISABLED =3D 0, + /* + * Enabled. The Monitor function will perform clock stretching, to ens= ure + * that the software or DMA can read all incoming data supplied by the + * Monitor function. + */ + FLEXCOMM_I2C_CFG_MONCLKSTR_ENABLED =3D 1, +} FLEXCOMM_I2C_CFG_MONCLKSTR_Enum; + +typedef enum { + /* Fast mode Plus enable */ + FLEXCOMM_I2C_CFG_HSCAPABLE_FAST_MODE_PLUS =3D 0, + /* High Speed mode enable */ + FLEXCOMM_I2C_CFG_HSCAPABLE_HIGH_SPEED =3D 1, +} FLEXCOMM_I2C_CFG_HSCAPABLE_Enum; + +typedef enum { + /* + * In progress. Communication is in progress and the Master function is + * busy and cannot currently accept a command. + */ + FLEXCOMM_I2C_STAT_MSTPENDING_IN_PROGRESS =3D 0, + /* + * Pending. The Master function needs software service or is in the id= le + * state. If the master is not in the idle state, then the master is + * waiting to receive or transmit data, or is waiting for the NACK bit. + */ + FLEXCOMM_I2C_STAT_MSTPENDING_PENDING =3D 1, +} FLEXCOMM_I2C_STAT_MSTPENDING_Enum; + +typedef enum { + /* + * Idle. The Master function is available to be used for a new transac= tion. + */ + FLEXCOMM_I2C_STAT_MSTSTATE_IDLE =3D 0, + /* + * Receive ready. Received data is available (in Master Receiver mode). + * Address plus Read was previously sent and Acknowledged by a slave. + */ + FLEXCOMM_I2C_STAT_MSTSTATE_RECEIVE_READY =3D 1, + /* + * Transmit ready. Data can be transmitted (in Master Transmitter mode= ). + * Address plus Write was previously sent and Acknowledged by a slave. + */ + FLEXCOMM_I2C_STAT_MSTSTATE_TRANSMIT_READY =3D 2, + /* NACK Address. Slave NACKed address. */ + FLEXCOMM_I2C_STAT_MSTSTATE_NACK_ADDRESS =3D 3, + /* NACK Data. Slave NACKed transmitted data. */ + FLEXCOMM_I2C_STAT_MSTSTATE_NACK_DATA =3D 4, +} FLEXCOMM_I2C_STAT_MSTSTATE_Enum; + +typedef enum { + /* No Arbitration Loss has occurred */ + FLEXCOMM_I2C_STAT_MSTARBLOSS_NO_LOSS =3D 0, + /* + * Arbitration loss. The Master function has experienced an Arbitration + * Loss. At this point, the Master function has already stopped drivin= g the + * bus and has gone into an idle state. Software can respond by doing + * nothing, or by sending a Start (to attempt to gain control of the b= us + * when the bus next becomes idle). + */ + FLEXCOMM_I2C_STAT_MSTARBLOSS_ARBITRATION_LOSS =3D 1, +} FLEXCOMM_I2C_STAT_MSTARBLOSS_Enum; + +typedef enum { + /* No Start/Stop Error has occurred. */ + FLEXCOMM_I2C_STAT_MSTSTSTPERR_NO_ERROR =3D 0, + /* + * The Master function has experienced a Start/Stop Error. A Start or = Stop + * was detected at a time when Start or Stop is not allowed by the I2C + * specification. The Master interface has stopped driving the bus and= gone + * into an idle state; no action is required. A request for a Start co= uld + * be made, or software could attempt to make sure that the bus has not + * stalled. + */ + FLEXCOMM_I2C_STAT_MSTSTSTPERR_ERROR =3D 1, +} FLEXCOMM_I2C_STAT_MSTSTSTPERR_Enum; + +typedef enum { + /* + * In progress. The Slave function does not currently need software + * service. + */ + FLEXCOMM_I2C_STAT_SLVPENDING_IN_PROGRESS =3D 0, + /* + * Pending. The Slave function needs software service. Information abo= ut + * what is needed is in the Slave state field (SLVSTATE). + */ + FLEXCOMM_I2C_STAT_SLVPENDING_PENDING =3D 1, +} FLEXCOMM_I2C_STAT_SLVPENDING_Enum; + +typedef enum { + /* + * Slave address. Address plus R/W received. At least one of the 4 sla= ve + * addresses has been matched by hardware. + */ + FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_ADDRESS =3D 0, + /* Slave receive. Received data is available (in Slave Receiver mode).= */ + FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_RECEIVE =3D 1, + /* Slave transmit. Data can be transmitted (in Slave Transmitter mode)= . */ + FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_TRANSMIT =3D 2, +} FLEXCOMM_I2C_STAT_SLVSTATE_Enum; + +typedef enum { + /* + * Stretching. The slave function is currently stretching the I2C bus + * clock. Deep-Sleepmode cannot be entered at this time. + */ + FLEXCOMM_I2C_STAT_SLVNOTSTR_STRETCHING =3D 0, + /* + * Not stretching. The slave function is not currently stretching the = I2C + * bus clock. Deep-sleep mode can be entered at this time. + */ + FLEXCOMM_I2C_STAT_SLVNOTSTR_NOT_STRETCHING =3D 1, +} FLEXCOMM_I2C_STAT_SLVNOTSTR_Enum; + +typedef enum { + /* Address 0. Slave address 0 was matched. */ + FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS0 =3D 0, + /* Address 1. Slave address 1 was matched. */ + FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS1 =3D 1, + /* Address 2. Slave address 2 was matched. */ + FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS2 =3D 2, + /* Address 3. Slave address 3 was matched. */ + FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS3 =3D 3, +} FLEXCOMM_I2C_STAT_SLVIDX_Enum; + +typedef enum { + /* Not selected. The Slave function is not currently selected. */ + FLEXCOMM_I2C_STAT_SLVSEL_NOT_SELECTED =3D 0, + /* Selected. The Slave function is currently selected. */ + FLEXCOMM_I2C_STAT_SLVSEL_SELECTED =3D 1, +} FLEXCOMM_I2C_STAT_SLVSEL_Enum; + +typedef enum { + /* + * Not deselected. The Slave function has not become deselected. This = does + * not mean that the Slave is currently selected. That information is = in + * the SLVSEL flag. + */ + FLEXCOMM_I2C_STAT_SLVDESEL_NOT_DESELECTED =3D 0, + /* + * Deselected. The Slave function has become deselected. This is + * specifically caused by the SLVSEL flag changing from 1 to 0. See SL= VSEL + * for details about when that event occurs. + */ + FLEXCOMM_I2C_STAT_SLVDESEL_DESELECTED =3D 1, +} FLEXCOMM_I2C_STAT_SLVDESEL_Enum; + +typedef enum { + /* No data. The Monitor function does not currently have data availabl= e. */ + FLEXCOMM_I2C_STAT_MONRDY_NO_DATA =3D 0, + /* Data waiting. The Monitor function has data waiting to be read. */ + FLEXCOMM_I2C_STAT_MONRDY_DATA_WAITING =3D 1, +} FLEXCOMM_I2C_STAT_MONRDY_Enum; + +typedef enum { + /* No overrun. Monitor data has not overrun. */ + FLEXCOMM_I2C_STAT_MONOV_NO_OVERRUN =3D 0, + /* + * Overrun. A Monitor data overrun has occurred. An overrun can only h= appen + * when Monitor clock stretching not enabled via the CFG[MONCLKSTR] bi= t. + * Writing 1 to MONOV bit clears the MONOV flag. + */ + FLEXCOMM_I2C_STAT_MONOV_OVERRUN =3D 1, +} FLEXCOMM_I2C_STAT_MONOV_Enum; + +typedef enum { + /* Inactive. The Monitor function considers the I2C bus to be inactive= . */ + FLEXCOMM_I2C_STAT_MONACTIVE_INACTIVE =3D 0, + /* Active. The Monitor function considers the I2C bus to be active. */ + FLEXCOMM_I2C_STAT_MONACTIVE_ACTIVE =3D 1, +} FLEXCOMM_I2C_STAT_MONACTIVE_Enum; + +typedef enum { + /* + * Not idle. The I2C bus is not idle, or MONIDLE flag has been cleared= by + * software. + */ + FLEXCOMM_I2C_STAT_MONIDLE_NOT_IDLE =3D 0, + /* + * Idle. The I2C bus has gone idle at least once, since the last time + * MONIDLE flag was cleared by software. + */ + FLEXCOMM_I2C_STAT_MONIDLE_IDLE =3D 1, +} FLEXCOMM_I2C_STAT_MONIDLE_Enum; + +typedef enum { + /* No time-out. I2C bus events have not caused a time-out. */ + FLEXCOMM_I2C_STAT_EVENTTIMEOUT_NO_TIMEOUT =3D 0, + /* + * Event time-out. The time between I2C bus events has been longer tha= n the + * time specified by the TIMEOUT register. + */ + FLEXCOMM_I2C_STAT_EVENTTIMEOUT_EVEN_TIMEOUT =3D 1, +} FLEXCOMM_I2C_STAT_EVENTTIMEOUT_Enum; + +typedef enum { + /* No time-out. SCL low time has not caused a time-out. */ + FLEXCOMM_I2C_STAT_SCLTIMEOUT_NO_TIMEOUT =3D 0, + /* Time-out. SCL low time has caused a time-out. */ + FLEXCOMM_I2C_STAT_SCLTIMEOUT_TIMEOUT =3D 1, +} FLEXCOMM_I2C_STAT_SCLTIMEOUT_Enum; + +typedef enum { + /* Disabled. The MstPending interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_DISABLED =3D 0, + /* Enabled. The MstPending interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_Enum; + +typedef enum { + /* Disabled. The MstArbLoss interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_DISABLED =3D 0, + /* Enabled. The MstArbLoss interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_Enum; + +typedef enum { + /* Disabled. The MstStStpErr interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_DISABLED =3D 0, + /* Enabled. The MstStStpErr interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_Enum; + +typedef enum { + /* Disabled. The SlvPending interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_DISABLED =3D 0, + /* Enabled. The SlvPending interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_Enum; + +typedef enum { + /* Disabled. The SlvNotStr interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_DISABLED =3D 0, + /* Enabled. The SlvNotStr interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_Enum; + +typedef enum { + /* Disabled. The SlvDeSel interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_SLVDESELEN_DISABLED =3D 0, + /* Enabled. The SlvDeSel interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_SLVDESELEN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_SLVDESELEN_Enum; + +typedef enum { + /* Disabled. The MonRdy interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_MONRDYEN_DISABLED =3D 0, + /* Enabled. The MonRdy interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_MONRDYEN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_MONRDYEN_Enum; + +typedef enum { + /* Disabled. The MonOv interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_MONOVEN_DISABLED =3D 0, + /* Enabled. The MonOv interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_MONOVEN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_MONOVEN_Enum; + +typedef enum { + /* Disabled. The MonIdle interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_MONIDLEEN_DISABLED =3D 0, + /* Enabled. The MonIdle interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_MONIDLEEN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_MONIDLEEN_Enum; + +typedef enum { + /* Disabled. The Event time-out interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_DISABLED =3D 0, + /* Enabled. The Event time-out interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_Enum; + +typedef enum { + /* Disabled. The SCL time-out interrupt is disabled. */ + FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_DISABLED =3D 0, + /* Enabled. The SCL time-out interrupt is enabled. */ + FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_ENABLED =3D 1, +} FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_CLEAR_MSTPENDING =3D 1, +} FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_CLEAR_MSTARBLOSS =3D 1, +} FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_CLEAR_MSTSTSTPERR =3D 1, +} FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_CLEAR_SLVPENDING =3D 1, +} FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_CLEAR_SLVNOTSTR =3D 1, +} FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_CLEAR_SLVDESEL =3D 1, +} FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_MONRDYCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_MONRDYCLR_CLEAR_MONRDY =3D 1, +} FLEXCOMM_I2C_INTENCLR_MONRDYCLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_MONOVCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_MONOVCLR_CLEAR_MONOV =3D 1, +} FLEXCOMM_I2C_INTENCLR_MONOVCLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_MONIDLECLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_MONIDLECLR_CLEAR_MONIDLE =3D 1, +} FLEXCOMM_I2C_INTENCLR_MONIDLECLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_CLEAR_EVENTTIMEOUT =3D 1, +} FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_Enum; + +typedef enum { + /* No effect on interrupt */ + FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_NO_EFFECT =3D 0, + /* Clears the interrupt bit in INTENSET register */ + FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_CLEAR_SCLTIMEOUT =3D 1, +} FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_Enum; + +typedef enum { + /* A time-out will occur after 16 counts of the I2C function clock. */ + FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT16 =3D 0, + /* A time-out will occur after 32 counts of the I2C function clock. */ + FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT32 =3D 1, + /* A time-out will occur after 65,536 counts of the I2C function clock= . */ + FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT65K =3D 4095, +} FLEXCOMM_I2C_TIMEOUT_TO_Enum; + +typedef enum { + /* FCLK is used directly by the I2C. */ + FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKUNDIVIDED =3D 0, + /* FCLK is divided by 2 before being used by the I2C. */ + FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV2 =3D 1, + /* FCLK is divided by 3 before being used by the I2C. */ + FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV3 =3D 2, + /* FCLK is divided by 65,536 before being used by the I2C. */ + FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV65K =3D 65535, +} FLEXCOMM_I2C_CLKDIV_DIVVAL_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_MSTPENDING_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_SLVPENDING_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_SLVDESEL_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_MONRDY_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_MONOV_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_MONIDLE_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISNOTACTIVE =3D 0, + /* Active */ + FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISACTIVE =3D 1, +} FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_NO_EFFECT =3D 0, + /* + * Continue. Informs the Master function to continue to the next opera= tion. + * This action must done after writing transmit data, reading received + * data, or any other housekeeping related to the next bus operation. + */ + FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_CONTINUE =3D 1, +} FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_I2C_MSTCTL_MSTSTART_NO_EFFECT =3D 0, + /* + * Start. A Start will be generated on the I2C bus at the next allowed + * time. + */ + FLEXCOMM_I2C_MSTCTL_MSTSTART_START =3D 1, +} FLEXCOMM_I2C_MSTCTL_MSTSTART_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_I2C_MSTCTL_MSTSTOP_NO_EFFECT =3D 0, + /* + * Stop. A Stop will be generated on the I2C bus at the next allowed t= ime, + * preceded by a NACK to the slave if the master is receiving data fro= m the + * slave (in Master Receiver mode). + */ + FLEXCOMM_I2C_MSTCTL_MSTSTOP_STOP =3D 1, +} FLEXCOMM_I2C_MSTCTL_MSTSTOP_Enum; + +typedef enum { + /* Disable. No DMA requests are generated for master operation. */ + FLEXCOMM_I2C_MSTCTL_MSTDMA_DISABLED =3D 0, + /* + * Enable. A DMA request is generated for I2C master data operations. = When + * this I2C master is generating Acknowledge bits in Master Receiver m= ode, + * the acknowledge is generated automatically. + */ + FLEXCOMM_I2C_MSTCTL_MSTDMA_ENABLED =3D 1, +} FLEXCOMM_I2C_MSTCTL_MSTDMA_Enum; + +typedef enum { + /* + * 2 clocks. Minimum SCL low time is 2 clocks of the I2C clock pre-div= ider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_2CLOCKS =3D 0, + /* + * 3 clocks. Minimum SCL low time is 3 clocks of the I2C clock pre-div= ider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_3CLOCKS =3D 1, + /* + * 4 clocks. Minimum SCL low time is 4 clocks of the I2C clock pre-div= ider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_4CLOCKS =3D 2, + /* + * 5 clocks. Minimum SCL low time is 5 clocks of the I2C clock pre-div= ider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_5CLOCKS =3D 3, + /* + * 6 clocks. Minimum SCL low time is 6 clocks of the I2C clock pre-div= ider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_6CLOCKS =3D 4, + /* + * 7 clocks. Minimum SCL low time is 7 clocks of the I2C clock pre-div= ider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_7CLOCKS =3D 5, + /* + * 8 clocks. Minimum SCL low time is 8 clocks of the I2C clock pre-div= ider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_8CLOCKS =3D 6, + /* + * 9 clocks. Minimum SCL low time is 9 clocks of the I2C clock pre-div= ider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_9CLOCKS =3D 7, +} FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_Enum; + +typedef enum { + /* + * 2 clocks. Minimum SCL high time is 2 clocks of the I2C clock + * pre-divider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_2CLOCKS =3D 0, + /* + * 3 clocks. Minimum SCL high time is 3 clocks of the I2C clock pre-di= vider + * . + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_3CLOCKS =3D 1, + /* + * 4 clocks. Minimum SCL high time is 4 clocks of the I2C clock + * pre-divider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_4CLOCKS =3D 2, + /* + * 5 clocks. Minimum SCL high time is 5 clocks of the I2C clock + * pre-divider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_5CLOCKS =3D 3, + /* + * 6 clocks. Minimum SCL high time is 6 clocks of the I2C clock + * pre-divider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_6CLOCKS =3D 4, + /* + * 7 clocks. Minimum SCL high time is 7 clocks of the I2C clock + * pre-divider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_7CLOCKS =3D 5, + /* + * 8 clocks. Minimum SCL high time is 8 clocks of the I2C clock + * pre-divider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_8CLOCKS =3D 6, + /* + * 9 clocks. Minimum SCL high time is 9 clocks of the I2C clock + * pre-divider. + */ + FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_9CLOCKS =3D 7, +} FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_NO_EFFECT =3D 0, + /* + * Continue. Informs the Slave function to continue to the next operat= ion, + * by clearing the STAT[SLVPENDING] flag. This must be done after writ= ing + * transmit data, reading received data, or any other housekeeping rel= ated + * to the next bus operation. Automatic Operation has different + * requirements. SLVCONTINUE should not be set unless SLVPENDING =3D 1. + */ + FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_CONTINUE =3D 1, +} FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_I2C_SLVCTL_SLVNACK_NO_EFFECT =3D 0, + /* + * NACK. Causes the Slave function to NACK the master when the slave is + * receiving data from the master (in Slave Receiver mode). + */ + FLEXCOMM_I2C_SLVCTL_SLVNACK_NACK =3D 1, +} FLEXCOMM_I2C_SLVCTL_SLVNACK_Enum; + +typedef enum { + /* Disabled. No DMA requests are issued for Slave mode operation. */ + FLEXCOMM_I2C_SLVCTL_SLVDMA_DISABLED =3D 0, + /* + * Enabled. DMA requests are issued for I2C slave data transmission and + * reception. + */ + FLEXCOMM_I2C_SLVCTL_SLVDMA_ENABLED =3D 1, +} FLEXCOMM_I2C_SLVCTL_SLVDMA_Enum; + +typedef enum { + /* + * Normal, non-automatic operation. If AUTONACK =3D 0, then a SlvPendi= ng + * interrupt is generated when a matching address is received. If AUTO= NACK + * =3D 1, then received addresses are NACKed (ignored). + */ + FLEXCOMM_I2C_SLVCTL_AUTOACK_NORMAL =3D 0, + /* + * A header with matching SLVADR0 and matching direction as set by + * AUTOMATCHREAD will be ACKed immediately, allowing the master to mov= e on + * to the data bytes. If the address matches SLVADR0, but the direction + * does not match AUTOMATCHREAD, then the behavior will depend on the + * SLVADR0[AUTONACK] bit: if AUTONACK is set, then it will be Nacked; = if + * AUTONACK is clear, then a SlvPending interrupt is generated. + */ + FLEXCOMM_I2C_SLVCTL_AUTOACK_AUTOMATIC_ACK =3D 1, +} FLEXCOMM_I2C_SLVCTL_AUTOACK_Enum; + +typedef enum { + /* In Automatic Mode, the expected next operation is an I2C write. */ + FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_WRITE =3D 0, + /* In Automatic Mode, the expected next operation is an I2C read. */ + FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_READ =3D 1, +} FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_Enum; + +typedef enum { + /* Enabled. Slave Address n is enabled. */ + FLEXCOMM_I2C_SLVADR0_SADISABLE_ENABLED =3D 0, + /* Ignored. Slave Address n is ignored. */ + FLEXCOMM_I2C_SLVADR0_SADISABLE_DISABLED =3D 1, +} FLEXCOMM_I2C_SLVADR0_SADISABLE_Enum; + +typedef enum { + /* Normal operation, matching I2C addresses are not ignored. */ + FLEXCOMM_I2C_SLVADR0_AUTONACK_NORMAL =3D 0, + /* + * Automatic-only mode. All incoming addresses are ignored (NACKed), u= nless + * AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD + * matches the direction. + */ + FLEXCOMM_I2C_SLVADR0_AUTONACK_AUTOMATIC =3D 1, +} FLEXCOMM_I2C_SLVADR0_AUTONACK_Enum; + +typedef enum { + /* Enabled. Slave Address n is enabled. */ + FLEXCOMM_I2C_SLVADR1_SADISABLE_ENABLED =3D 0, + /* Ignored. Slave Address n is ignored. */ + FLEXCOMM_I2C_SLVADR1_SADISABLE_DISABLED =3D 1, +} FLEXCOMM_I2C_SLVADR1_SADISABLE_Enum; + +typedef enum { + /* Normal operation, matching I2C addresses are not ignored. */ + FLEXCOMM_I2C_SLVADR1_AUTONACK_NORMAL =3D 0, + /* + * Automatic-only mode. All incoming addresses are ignored (NACKed), u= nless + * AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD + * matches the direction. + */ + FLEXCOMM_I2C_SLVADR1_AUTONACK_AUTOMATIC =3D 1, +} FLEXCOMM_I2C_SLVADR1_AUTONACK_Enum; + +typedef enum { + /* Enabled. Slave Address n is enabled. */ + FLEXCOMM_I2C_SLVADR2_SADISABLE_ENABLED =3D 0, + /* Ignored. Slave Address n is ignored. */ + FLEXCOMM_I2C_SLVADR2_SADISABLE_DISABLED =3D 1, +} FLEXCOMM_I2C_SLVADR2_SADISABLE_Enum; + +typedef enum { + /* Normal operation, matching I2C addresses are not ignored. */ + FLEXCOMM_I2C_SLVADR2_AUTONACK_NORMAL =3D 0, + /* + * Automatic-only mode. All incoming addresses are ignored (NACKed), u= nless + * AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD + * matches the direction. + */ + FLEXCOMM_I2C_SLVADR2_AUTONACK_AUTOMATIC =3D 1, +} FLEXCOMM_I2C_SLVADR2_AUTONACK_Enum; + +typedef enum { + /* Enabled. Slave Address n is enabled. */ + FLEXCOMM_I2C_SLVADR3_SADISABLE_ENABLED =3D 0, + /* Ignored. Slave Address n is ignored. */ + FLEXCOMM_I2C_SLVADR3_SADISABLE_DISABLED =3D 1, +} FLEXCOMM_I2C_SLVADR3_SADISABLE_Enum; + +typedef enum { + /* Normal operation, matching I2C addresses are not ignored. */ + FLEXCOMM_I2C_SLVADR3_AUTONACK_NORMAL =3D 0, + /* + * Automatic-only mode. All incoming addresses are ignored (NACKed), u= nless + * AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD + * matches the direction. + */ + FLEXCOMM_I2C_SLVADR3_AUTONACK_AUTOMATIC =3D 1, +} FLEXCOMM_I2C_SLVADR3_AUTONACK_Enum; + +typedef enum { + /* + * Mask. The SLVQUAL0 field is used as a logical mask for matching add= ress + * 0. + */ + FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_MASK =3D 0, + /* + * Extend. The SLVQUAL0 field is used to extend address 0 matching in a + * range of addresses. + */ + FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_EXTEND =3D 1, +} FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_Enum; + +typedef enum { + /* + * No start detected. The Monitor function has not detected a Start ev= ent + * on the I2C bus. + */ + FLEXCOMM_I2C_MONRXDAT_MONSTART_NO_START_DETECTED =3D 0, + /* + * Start detected. The Monitor function has detected a Start event on = the + * I2C bus. + */ + FLEXCOMM_I2C_MONRXDAT_MONSTART_START_DETECTED =3D 1, +} FLEXCOMM_I2C_MONRXDAT_MONSTART_Enum; + +typedef enum { + /* + * No repeated start detected. The Monitor function has not detected a + * Repeated Start event on the I2C bus. + */ + FLEXCOMM_I2C_MONRXDAT_MONRESTART_NOT_DETECTED =3D 0, + /* + * Repeated start detected. The Monitor function has detected a Repeat= ed + * Start event on the I2C bus. + */ + FLEXCOMM_I2C_MONRXDAT_MONRESTART_DETECTED =3D 1, +} FLEXCOMM_I2C_MONRXDAT_MONRESTART_Enum; + +typedef enum { + /* + * Acknowledged. The data currently being provided by the Monitor func= tion + * was acknowledged by at least one master or slave receiver. + */ + FLEXCOMM_I2C_MONRXDAT_MONNACK_ACKNOWLEDGED =3D 0, + /* + * Not acknowledged. The data currently being provided by the Monitor + * function was not acknowledged by any receiver. + */ + FLEXCOMM_I2C_MONRXDAT_MONNACK_NOT_ACKNOWLEDGED =3D 1, +} FLEXCOMM_I2C_MONRXDAT_MONNACK_Enum; + + +#define FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY(_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_I2C_REGS_NO] =3D { \ + [0 ... FLEXCOMM_I2C_REGS_NO - 1] =3D { \ + .name =3D "", \ + .addr =3D -1, \ + }, \ + [R_FLEXCOMM_I2C_CFG] =3D { \ + .name =3D "CFG", \ + .addr =3D 0x800, \ + .ro =3D 0xFFFFFFC0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_STAT] =3D { \ + .name =3D "STAT", \ + .addr =3D 0x804, \ + .ro =3D 0xFCF57FAF, \ + .reset =3D 0x801, \ + }, \ + [R_FLEXCOMM_I2C_INTENSET] =3D { \ + .name =3D "INTENSET", \ + .addr =3D 0x808, \ + .ro =3D 0xFCF476AE, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTENCLR] =3D { \ + .name =3D "INTENCLR", \ + .addr =3D 0x80C, \ + .ro =3D 0xFCF476AE, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_TIMEOUT] =3D { \ + .name =3D "TIMEOUT", \ + .addr =3D 0x810, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFFFF, \ + }, \ + [R_FLEXCOMM_I2C_CLKDIV] =3D { \ + .name =3D "CLKDIV", \ + .addr =3D 0x814, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTSTAT] =3D { \ + .name =3D "INTSTAT", \ + .addr =3D 0x818, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x801, \ + }, \ + [R_FLEXCOMM_I2C_MSTCTL] =3D { \ + .name =3D "MSTCTL", \ + .addr =3D 0x820, \ + .ro =3D 0xFFFFFFF0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MSTTIME] =3D { \ + .name =3D "MSTTIME", \ + .addr =3D 0x824, \ + .ro =3D 0xFFFFFF88, \ + .reset =3D 0x77, \ + }, \ + [R_FLEXCOMM_I2C_MSTDAT] =3D { \ + .name =3D "MSTDAT", \ + .addr =3D 0x828, \ + .ro =3D 0xFFFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVCTL] =3D { \ + .name =3D "SLVCTL", \ + .addr =3D 0x840, \ + .ro =3D 0xFFFFFCF4, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVDAT] =3D { \ + .name =3D "SLVDAT", \ + .addr =3D 0x844, \ + .ro =3D 0xFFFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR0] =3D { \ + .name =3D "SLVADR0", \ + .addr =3D 0x848, \ + .ro =3D 0xFFFF7F00, \ + .reset =3D 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR1] =3D { \ + .name =3D "SLVADR1", \ + .addr =3D 0x84C, \ + .ro =3D 0xFFFF7F00, \ + .reset =3D 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR2] =3D { \ + .name =3D "SLVADR2", \ + .addr =3D 0x850, \ + .ro =3D 0xFFFF7F00, \ + .reset =3D 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR3] =3D { \ + .name =3D "SLVADR3", \ + .addr =3D 0x854, \ + .ro =3D 0xFFFF7F00, \ + .reset =3D 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVQUAL0] =3D { \ + .name =3D "SLVQUAL0", \ + .addr =3D 0x858, \ + .ro =3D 0xFFFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MONRXDAT] =3D { \ + .name =3D "MONRXDAT", \ + .addr =3D 0x880, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_I2C_ID] =3D { \ + .name =3D "ID", \ + .addr =3D 0xFFC, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0xE0301300, \ + }, \ + } diff --git a/include/hw/i2c/flexcomm_i2c.h b/include/hw/i2c/flexcomm_i2c.h new file mode 100644 index 0000000000..7b27e333d7 --- /dev/null +++ b/include/hw/i2c/flexcomm_i2c.h @@ -0,0 +1,40 @@ +/* + * QEMU model for NXP's FLEXCOMM I2C + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_FLEXCOMM_I2C_H +#define HW_FLEXCOMM_I2C_H + +#include "hw/i2c/i2c.h" +#include "hw/misc/flexcomm_function.h" + +#define TYPE_FLEXCOMM_I2C "flexcomm-i2c" +OBJECT_DECLARE_TYPE(FlexcommI2cState, FlexcommI2cClass, FLEXCOMM_I2C); + +struct FlexcommI2cState { + FlexcommFunction parent_obj; + + I2CBus *bus; +}; + +struct FlexcommI2cClass { + FlexcommFunctionClass parent_obj; + + FlexcommFunctionSelect select; +}; + +#define MSTSTATE_IDLE 0 +#define MSTSTATE_RXRDY 1 +#define MSTSTATE_TXRDY 2 +#define MSTSTATE_NAKADR 3 +#define MSTSTATE_NAKDAT 4 + + +#endif /* HW_FLEXCOMM_I2C_H */ diff --git a/include/hw/misc/flexcomm.h b/include/hw/misc/flexcomm.h index 679b7ea64d..c9f1cd3890 100644 --- a/include/hw/misc/flexcomm.h +++ b/include/hw/misc/flexcomm.h @@ -16,6 +16,7 @@ #include "hw/arm/svd/flexcomm.h" #include "qemu/fifo32.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" =20 #define FLEXCOMM_FUNC_USART 0 #define FLEXCOMM_FUNC_SPI 1 @@ -48,6 +49,7 @@ struct FlexcommState { Fifo32 rx_fifo; Fifo32 tx_fifo; FlexcommUsartState usart; + FlexcommI2cState i2c; }; =20 #endif /* HW_FLEXCOMM_H */ diff --git a/hw/i2c/flexcomm_i2c.c b/hw/i2c/flexcomm_i2c.c new file mode 100644 index 0000000000..e5341ec241 --- /dev/null +++ b/hw/i2c/flexcomm_i2c.c @@ -0,0 +1,250 @@ +/* + * QEMU model for NXP's FLEXCOMM I2C + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "qapi/error.h" +#include "trace.h" +#include "hw/i2c/flexcomm_i2c.h" +#include "hw/arm/svd/flexcomm_i2c.h" + +#define REG(s, reg) (s->regs[R_FLEXCOMM_I2C_##reg]) +#define RF_WR(s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXCOMM_I2C_##reg, field, val) +#define RF_RD(s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXCOMM_I2C_##reg, field) + +static FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY(reg_info); + +static void flexcomm_i2c_reset(FlexcommFunction *f) +{ + for (int i =3D 0; i < FLEXCOMM_I2C_REGS_NO; i++) { + hwaddr addr =3D reg_info[i].addr; + + if (addr !=3D -1) { + struct RegisterInfo ri =3D { + .data =3D &f->regs[addr / 4], + .data_size =3D 4, + .access =3D ®_info[i], + }; + + register_reset(&ri); + } + } +} + +static void flexcomm_i2c_irq_update(FlexcommFunction *f) +{ + bool enabled =3D RF_RD(f, CFG, MSTEN); + bool irq, per_irqs; + + REG(f, INTSTAT) =3D REG(f, STAT) & REG(f, INTENSET); + per_irqs =3D REG(f, INTSTAT) !=3D 0; + + irq =3D enabled && per_irqs; + + trace_flexcomm_i2c_irq(DEVICE(f)->id, irq, per_irqs, enabled); + flexcomm_set_irq(f, irq); +} + +static MemTxResult flexcomm_i2c_reg_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(opaque); + MemTxResult ret =3D MEMTX_OK; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + + if (size !=3D 4) { + ret =3D MEMTX_ERROR; + goto out; + } + + *data =3D f->regs[addr / 4]; + + flexcomm_i2c_irq_update(f); + +out: + trace_flexcomm_i2c_reg_read(DEVICE(f)->id, rai->name, addr, *data); + return ret; +} + +static MemTxResult flexcomm_i2c_reg_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(opaque); + FlexcommI2cState *s =3D FLEXCOMM_I2C(opaque); + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + struct RegisterInfo ri =3D { + .data =3D &f->regs[addr / 4], + .data_size =3D 4, + .access =3D rai, + }; + + trace_flexcomm_i2c_reg_write(DEVICE(f)->id, rai->name, addr, value); + + if (size !=3D 4) { + return MEMTX_ERROR; + } + + switch (addr) { + case A_FLEXCOMM_I2C_CFG: + { + register_write(&ri, value, ~0, NULL, false); + if (RF_RD(f, CFG, SLVEN)) { + qemu_log_mask(LOG_GUEST_ERROR, "I2C slave not supported"); + } + if (RF_RD(f, CFG, MONEN)) { + qemu_log_mask(LOG_GUEST_ERROR, "I2C monitoring not supported"); + } + break; + } + case A_FLEXCOMM_I2C_INTENCLR: + { + REG(f, INTENSET) &=3D ~value; + break; + } + case A_FLEXCOMM_I2C_TIMEOUT: + { + register_write(&ri, value, ~0, NULL, false); + /* The bottom 4 bits are hard-wired to 0xF */ + RF_WR(f, TIMEOUT, TOMIN, 0xf); + break; + } + case A_FLEXCOMM_I2C_MSTCTL: + { + register_write(&ri, value, ~0, NULL, false); + if (RF_RD(f, MSTCTL, MSTSTART)) { + uint8_t i2c_addr =3D RF_RD(f, MSTDAT, DATA); + bool recv =3D i2c_addr & 1; + + trace_flexcomm_i2c_start(DEVICE(s)->id, i2c_addr, recv); + if (i2c_start_transfer(s->bus, i2c_addr, recv)) { + RF_WR(f, STAT, MSTSTATE, MSTSTATE_NAKADR); + trace_flexcomm_i2c_nak(DEVICE(s)->id); + } else { + if (recv) { + uint8_t data =3D i2c_recv(s->bus); + + RF_WR(f, MSTDAT, DATA, data); + trace_flexcomm_i2c_rx(DEVICE(s)->id, data); + RF_WR(f, STAT, MSTSTATE, MSTSTATE_RXRDY); + } else { + RF_WR(f, STAT, MSTSTATE, MSTSTATE_TXRDY); + } + } + } + if (RF_RD(f, MSTCTL, MSTSTOP)) { + RF_WR(f, STAT, MSTSTATE, MSTSTATE_IDLE); + i2c_end_transfer(s->bus); + } + if (RF_RD(f, MSTCTL, MSTCONTINUE)) { + if (RF_RD(f, STAT, MSTSTATE) =3D=3D MSTSTATE_TXRDY) { + uint8_t data =3D RF_RD(f, MSTDAT, DATA); + + trace_flexcomm_i2c_tx(DEVICE(s)->id, data); + if (i2c_send(s->bus, data)) { + RF_WR(f, STAT, MSTSTATE, MSTSTATE_NAKDAT); + } + } else if (RF_RD(f, STAT, MSTSTATE) =3D=3D MSTSTATE_RXRDY) { + uint8_t data =3D i2c_recv(s->bus); + + RF_WR(f, MSTDAT, DATA, data); + trace_flexcomm_i2c_rx(DEVICE(s)->id, data); + } + } + break; + } + case A_FLEXCOMM_I2C_STAT: + { + /* write 1 to clear bits */ + REG(f, STAT) &=3D ~value; + break; + } + case A_FLEXCOMM_I2C_SLVCTL: + case A_FLEXCOMM_I2C_SLVDAT: + case A_FLEXCOMM_I2C_SLVADR0: + case A_FLEXCOMM_I2C_SLVADR1: + case A_FLEXCOMM_I2C_SLVADR2: + case A_FLEXCOMM_I2C_SLVADR3: + case A_FLEXCOMM_I2C_SLVQUAL0: + { + qemu_log_mask(LOG_GUEST_ERROR, "I2C slave not supported\n"); + break; + } + default: + register_write(&ri, value, ~0, NULL, false); + break; + } + + flexcomm_i2c_irq_update(f); + + return MEMTX_OK; +} + +static void flexcomm_i2c_select(FlexcommFunction *f, bool selected) +{ + FlexcommI2cClass *ic =3D FLEXCOMM_I2C_GET_CLASS(f); + + if (selected) { + flexcomm_i2c_reset(f); + } + ic->select(f, selected); +} + +static const MemoryRegionOps flexcomm_i2c_ops =3D { + .read_with_attrs =3D flexcomm_i2c_reg_read, + .write_with_attrs =3D flexcomm_i2c_reg_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + .unaligned =3D false, + }, +}; + +static void flexcomm_i2c_realize(DeviceState *dev, Error **errp) +{ + FlexcommI2cState *s =3D FLEXCOMM_I2C(dev); + + s->bus =3D i2c_init_bus(DEVICE(s), "bus"); +} + +static void flexcomm_i2c_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + FlexcommFunctionClass *fc =3D FLEXCOMM_FUNCTION_CLASS(klass); + FlexcommI2cClass *ic =3D FLEXCOMM_I2C_CLASS(klass); + + dc->realize =3D flexcomm_i2c_realize; + ic->select =3D fc->select; + fc->select =3D flexcomm_i2c_select; + fc->name =3D "i2c"; + fc->mmio_ops =3D &flexcomm_i2c_ops; +} + +static const TypeInfo flexcomm_i2c_types[] =3D { + { + .name =3D TYPE_FLEXCOMM_I2C, + .parent =3D TYPE_FLEXCOMM_FUNCTION, + .instance_size =3D sizeof(FlexcommI2cState), + .class_init =3D flexcomm_i2c_class_init, + .class_size =3D sizeof(FlexcommI2cClass), + }, +}; + +DEFINE_TYPES(flexcomm_i2c_types); diff --git a/hw/misc/flexcomm.c b/hw/misc/flexcomm.c index a291148f27..b1a2f01acf 100644 --- a/hw/misc/flexcomm.c +++ b/hw/misc/flexcomm.c @@ -24,6 +24,7 @@ #include "hw/misc/flexcomm.h" #include "hw/arm/svd/flexcomm_usart.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" =20 #define REG(s, reg) (s->regs[R_FLEXCOMM_##reg]) #define RF_WR(s, reg, field, val) \ @@ -220,6 +221,7 @@ static void flexcomm_init(Object *obj) sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->container); sysbus_init_irq(sbd, &s->irq); object_initialize_child(obj, "usart", &s->usart, TYPE_FLEXCOMM_USART); + object_initialize_child(obj, "i2c", &s->i2c, TYPE_FLEXCOMM_I2C); } =20 static void flexcomm_finalize(Object *obj) @@ -250,6 +252,7 @@ static void flexcomm_realize(DeviceState *dev, Error **= errp) =20 memory_region_add_subregion_overlap(&s->container, 0, &s->mmio, -1); flexcomm_func_realize_and_unref(FLEXCOMM_FUNCTION(&s->usart), errp); + flexcomm_func_realize_and_unref(FLEXCOMM_FUNCTION(&s->i2c), errp); } =20 static const VMStateDescription vmstate_flexcomm =3D { diff --git a/hw/arm/svd/meson.build b/hw/arm/svd/meson.build index 2bde34d15b..417491cd5c 100644 --- a/hw/arm/svd/meson.build +++ b/hw/arm/svd/meson.build @@ -7,4 +7,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm-usart', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_usart.= h', '-p', 'USART0', '-t', 'FLEXCOMM_USART']) + run_target('svd-flexcomm-i2c', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h', + '-p', 'I2C0', '-t', 'FLEXCOMM_I2C']) endif diff --git a/hw/i2c/meson.build b/hw/i2c/meson.build index c459adcb59..e7d79e6938 100644 --- a/hw/i2c/meson.build +++ b/hw/i2c/meson.build @@ -18,4 +18,5 @@ i2c_ss.add(when: 'CONFIG_PPC4XX', if_true: files('ppc4xx_= i2c.c')) i2c_ss.add(when: 'CONFIG_PCA954X', if_true: files('i2c_mux_pca954x.c')) i2c_ss.add(when: 'CONFIG_PMBUS', if_true: files('pmbus_device.c')) i2c_ss.add(when: 'CONFIG_BCM2835_I2C', if_true: files('bcm2835_i2c.c')) +i2c_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_i2c.c')) system_ss.add_all(when: 'CONFIG_I2C', if_true: i2c_ss) diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events index 6900e06eda..9f0175fab7 100644 --- a/hw/i2c/trace-events +++ b/hw/i2c/trace-events @@ -51,3 +51,13 @@ npcm7xx_smbus_recv_fifo(const char *id, uint8_t received= , uint8_t expected) "%s =20 pca954x_write_bytes(uint8_t value) "PCA954X write data: 0x%02x" pca954x_read_data(uint8_t value) "PCA954X read data: 0x%02x" + +# flexcomm_i2c.c + +flexcomm_i2c_reg_read(const char *id, const char *reg_name, uint32_t addr,= uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_i2c_reg_write(const char *id, const char *reg_name, uint32_t addr= , uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_i2c_start(const char *id, uint8_t addr, uint8_t recv) "%s: 0x%02x= %d" +flexcomm_i2c_rx(const char *id, uint8_t data) "%s: <- 0x%02x" +flexcomm_i2c_tx(const char *id, uint8_t data) "%s: -> 0x%02x" +flexcomm_i2c_nak(const char *id) "%s: <- nak" +flexcomm_i2c_irq(const char *id, bool irq, bool perirqs, bool enabled) "%s= : %d %d %d" diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 14167ae9e8..9a244fa01d 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -215,5 +215,6 @@ config XLNX_VERSAL_TRNG =20 config FLEXCOMM bool + select I2C =20 source macio/Kconfig --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687620; cv=none; d=zohomail.com; s=zohoarc; b=ZbkIpyRof1b6DTqx6reXknnD/25Lx/CtqxJg1CEwRu0zFz9xAElq9+CN0caTHENeAeeF8TL0gh9jryEaRDonxOe6Nx5+4VI894nLS+8yAdSQPnxn5fj19hvYo0zGmzW75uhRMEXPDjF4xp8kpv9afc5DAljQ70laU3NG4dlaRcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687620; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jP5z7sSHkw1b9h9KgFZakDgiL0/BzkQvHmswQcZugas=; b=UqqV8c1I0fb+cnymZsFmuztXNxd+kz27epEcjiPCX9Pc+7uxd4RZr17TPmhcLQzaEei5e06qWuTMwKgzKn+VxJmifB2bAyBnfk96TeaKqMUcYwumZV6ywfptep4iei42KtE4wJ4U6C7UHb6lCQJrleCZV1nnGgJEmm/764zd2Is= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172668762067639.38045571516727; Wed, 18 Sep 2024 12:27:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gu-0005IG-UZ; Wed, 18 Sep 2024 15:23:28 -0400 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 <3oCjrZgUKCtsQ7SFMDLLDIB.9LJNBJR-ABSBIKLKDKR.LOD@flex--tavip.bounces.google.com>) id 1sr0Gm-0004i2-Cr for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:20 -0400 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3oCjrZgUKCtsQ7SFMDLLDIB.9LJNBJR-ABSBIKLKDKR.LOD@flex--tavip.bounces.google.com>) id 1sr0Gi-0007Kt-2T for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:20 -0400 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e1dab3a941fso170450276.3 for ; Wed, 18 Sep 2024 12:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687393; x=1727292193; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jP5z7sSHkw1b9h9KgFZakDgiL0/BzkQvHmswQcZugas=; b=lahk8utkSGc+Nh4kAymY3TgYrlcAGaTXIJy0KZvPlWUPxLNlNAWrVIJVSsn81yKKTL 2d75JTKONi8d4DmawEMsQG30qBMRA6V5Xt4+c8ltDzM8dnnM5ThQxAb4BgCRaIipOUZT DEkLqReB4CVB/TpXDibskrZRBCRodHkuaAJB9Bml7ngxPwqO7FzvY0LPkPe8NW+MLEqz Ui1T1m+BbXMYgDrnjOAS1g13w1jgBZobQXwlQkQpskwfeVZPUQ/Cc6OWpa1tPWB7fDBt of634hGxXXAMEGbkRpl+CvPxirq2wyHXM/qlTy9fq4k8+UhLRSjULn6iArORSDgJO7hf nJww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687393; x=1727292193; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jP5z7sSHkw1b9h9KgFZakDgiL0/BzkQvHmswQcZugas=; b=ZuUEfudt3aqe3Aw02XJFa/qXpYGPfLgmYZQcvpetoXPLhml3eH4BmixoCllwJw6pZK 7RYjXAid2GUaKwo45vczgpxCdXK27vtbRL+ajine0NH40Yp+CG4X4CTMLuM8RPDn3/L9 AW8o3t64Luy7veo3roNrfQqiPQBl9Zi+rifZ9OO61pMdwVB9p+G7oJ1VBzqNyZiGmHgE CK5UG+8WLrZ/XK8zzBMU3O0f47u58vMw7jedcu8mhrIFyCaPMaYR65jaePTkaN/m7+nV cbRTXk3aDRofleQ/k4N3iSXlT/QjZtGmcUgx0Pq+CRROtMaFKGkgQvzQ6Mf69AU+EP5c Z5pw== X-Gm-Message-State: AOJu0YyVKGTWBFD4xt+WjgEET1CUhJjc8pr8NKXdRa5a/60Zt3Et8H4S 9YrEK7ishiCxoYRh3ltMaVrfBSMYq21JwWwLSm7Pybuonyc6LPY/vLwc2rYLyb9Zlp6akLIx9Z8 4PQmq0RFE1vv6Uu1V7kofei4fABU3hGZTc7pMLB51zdHCrSDeA/J1hq97z8Xp2iebr7OZ0cZ6x2 X2htHkRFwhbQvxCq+ugQkvRnNhww== X-Google-Smtp-Source: AGHT+IEsv9+i7UrgzN0ybTfZstd7Sp5UT0oY+IWYi+JrOm57zj2dn03mXGZzHEMTPJYEX4qA5tbdpLc8/g== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a05:6902:4f3:b0:e16:4d66:982e with SMTP id 3f1490d57ef6-e1daff85e4amr42596276.5.1726687392914; Wed, 18 Sep 2024 12:23:12 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:37 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-10-tavip@google.com> Subject: [PATCH 09/25] hw/ssi: add support for flexcomm spi From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b4a; envelope-from=3oCjrZgUKCtsQ7SFMDLLDIB.9LJNBJR-ABSBIKLKDKR.LOD@flex--tavip.bounces.google.com; helo=mail-yb1-xb4a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687621498116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sebastian Ene Add support for NXP's flexcomm spi. It supports FIFO access, interrupts and master mode only. It does not support DMA. The patch includes an automatically generated header which contains the register layout and helpers. The header can be regenerated with the svd-flexcomm-spi target when the build is configured with --enable-mcux-soc-svd. Signed-off-by: Sebastian Ene [tavip: add suport for CFG.SPOL, CFG.LSBF, TX control flags per FIFO entry and 8/16 bit access to FIFORD and FIFOWR, convert to Resettable interface, add support for migration] Signed-off-by: Octavian Purdila --- include/hw/arm/svd/flexcomm_spi.h | 1036 +++++++++++++++++++++++++++++ include/hw/misc/flexcomm.h | 2 + include/hw/ssi/flexcomm_spi.h | 36 + hw/misc/flexcomm.c | 3 + hw/ssi/flexcomm_spi.c | 422 ++++++++++++ hw/arm/svd/meson.build | 3 + hw/misc/Kconfig | 1 + hw/ssi/meson.build | 1 + hw/ssi/trace-events | 5 + 9 files changed, 1509 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_spi.h create mode 100644 include/hw/ssi/flexcomm_spi.h create mode 100644 hw/ssi/flexcomm_spi.c diff --git a/include/hw/arm/svd/flexcomm_spi.h b/include/hw/arm/svd/flexcom= m_spi.h new file mode 100644 index 0000000000..638efd3f07 --- /dev/null +++ b/include/hw/arm/svd/flexcomm_spi.h @@ -0,0 +1,1036 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#include "hw/register.h" + +/* Serial Peripheral Interfaces (SPI) */ +#define FLEXCOMM_SPI_REGS_NO (1024) + +/* Configuration Register */ +REG32(FLEXCOMM_SPI_CFG, 1024); +/* SPI Enable */ +FIELD(FLEXCOMM_SPI_CFG, ENABLE, 0, 1); +/* Master Mode Select */ +FIELD(FLEXCOMM_SPI_CFG, MASTER, 2, 1); +/* LSB First Mode Enable */ +FIELD(FLEXCOMM_SPI_CFG, LSBF, 3, 1); +/* Clock Phase Select */ +FIELD(FLEXCOMM_SPI_CFG, CPHA, 4, 1); +/* Clock Polarity Select */ +FIELD(FLEXCOMM_SPI_CFG, CPOL, 5, 1); +/* Loopback Mode Enable */ +FIELD(FLEXCOMM_SPI_CFG, LOOP, 7, 1); +/* SSEL0 Polarity Select */ +FIELD(FLEXCOMM_SPI_CFG, SPOL0, 8, 1); +/* SSEL1 Polarity Select */ +FIELD(FLEXCOMM_SPI_CFG, SPOL1, 9, 1); +/* SSEL2 Polarity Select */ +FIELD(FLEXCOMM_SPI_CFG, SPOL2, 10, 1); +/* SSEL3 Polarity Select */ +FIELD(FLEXCOMM_SPI_CFG, SPOL3, 11, 1); + +/* Delay Register */ +REG32(FLEXCOMM_SPI_DLY, 1028); +/* Pre-Delay */ +FIELD(FLEXCOMM_SPI_DLY, PRE_DELAY, 0, 4); +/* Post-Delay */ +FIELD(FLEXCOMM_SPI_DLY, POST_DELAY, 4, 4); +/* Frame Delay */ +FIELD(FLEXCOMM_SPI_DLY, FRAME_DELAY, 8, 4); +/* Transfer Delay */ +FIELD(FLEXCOMM_SPI_DLY, TRANSFER_DELAY, 12, 4); + +/* Status Register */ +REG32(FLEXCOMM_SPI_STAT, 1032); +/* Slave Select Assert */ +FIELD(FLEXCOMM_SPI_STAT, SSA, 4, 1); +/* Slave Select Deassert */ +FIELD(FLEXCOMM_SPI_STAT, SSD, 5, 1); +/* Stalled Status Flag */ +FIELD(FLEXCOMM_SPI_STAT, STALLED, 6, 1); +/* End Transfer Control */ +FIELD(FLEXCOMM_SPI_STAT, ENDTRANSFER, 7, 1); +/* Master Idle Status Flag */ +FIELD(FLEXCOMM_SPI_STAT, MSTIDLE, 8, 1); + +/* Interrupt Enable Register */ +REG32(FLEXCOMM_SPI_INTENSET, 1036); +/* Slave Select Assert Interrupt Enable */ +FIELD(FLEXCOMM_SPI_INTENSET, SSAEN, 4, 1); +/* Slave Select Deassert Interrupt Enable */ +FIELD(FLEXCOMM_SPI_INTENSET, SSDEN, 5, 1); +/* Master Idle Interrupt Enable */ +FIELD(FLEXCOMM_SPI_INTENSET, MSTIDLEEN, 8, 1); + +/* Interrupt Enable Clear Register */ +REG32(FLEXCOMM_SPI_INTENCLR, 1040); +/* Slave Select Assert Interrupt Enable */ +FIELD(FLEXCOMM_SPI_INTENCLR, SSAEN, 4, 1); +/* Slave Select Deassert Interrupt Enable */ +FIELD(FLEXCOMM_SPI_INTENCLR, SSDEN, 5, 1); +/* Master Idle Interrupt Enable */ +FIELD(FLEXCOMM_SPI_INTENCLR, MSTIDLE, 8, 1); + +/* Clock Divider Register */ +REG32(FLEXCOMM_SPI_DIV, 1060); +/* Rate Divider Value */ +FIELD(FLEXCOMM_SPI_DIV, DIVVAL, 0, 16); + +/* Interrupt Status Register */ +REG32(FLEXCOMM_SPI_INTSTAT, 1064); +/* Slave Select Assert Interrupt */ +FIELD(FLEXCOMM_SPI_INTSTAT, SSA, 4, 1); +/* Slave Select Deassert Interrupt */ +FIELD(FLEXCOMM_SPI_INTSTAT, SSD, 5, 1); +/* Master Idle Status Flag Interrupt */ +FIELD(FLEXCOMM_SPI_INTSTAT, MSTIDLE, 8, 1); + +/* FIFO Configuration Register */ +REG32(FLEXCOMM_SPI_FIFOCFG, 3584); +/* Enable the Transmit FIFO */ +FIELD(FLEXCOMM_SPI_FIFOCFG, ENABLETX, 0, 1); +/* Enable the Receive FIFO */ +FIELD(FLEXCOMM_SPI_FIFOCFG, ENABLERX, 1, 1); +/* FIFO Size Configuration */ +FIELD(FLEXCOMM_SPI_FIFOCFG, SIZE, 4, 2); +/* DMA Configuration for Transmit */ +FIELD(FLEXCOMM_SPI_FIFOCFG, DMATX, 12, 1); +/* DMA Configuration for Receive */ +FIELD(FLEXCOMM_SPI_FIFOCFG, DMARX, 13, 1); +/* Wake-up for Transmit FIFO Level */ +FIELD(FLEXCOMM_SPI_FIFOCFG, WAKETX, 14, 1); +/* Wake-up for Receive FIFO Level */ +FIELD(FLEXCOMM_SPI_FIFOCFG, WAKERX, 15, 1); +/* Empty Command for the Transmit FIFO */ +FIELD(FLEXCOMM_SPI_FIFOCFG, EMPTYTX, 16, 1); +/* Empty Command for the Receive FIFO */ +FIELD(FLEXCOMM_SPI_FIFOCFG, EMPTYRX, 17, 1); +/* Pop FIFO for Debug Reads */ +FIELD(FLEXCOMM_SPI_FIFOCFG, POPDBG, 18, 1); + +/* FIFO Status Register */ +REG32(FLEXCOMM_SPI_FIFOSTAT, 3588); +/* TX FIFO Error */ +FIELD(FLEXCOMM_SPI_FIFOSTAT, TXERR, 0, 1); +/* RX FIFO Error */ +FIELD(FLEXCOMM_SPI_FIFOSTAT, RXERR, 1, 1); +/* Peripheral Interrupt */ +FIELD(FLEXCOMM_SPI_FIFOSTAT, PERINT, 3, 1); +/* Transmit FIFO Empty */ +FIELD(FLEXCOMM_SPI_FIFOSTAT, TXEMPTY, 4, 1); +/* Transmit FIFO is Not Full */ +FIELD(FLEXCOMM_SPI_FIFOSTAT, TXNOTFULL, 5, 1); +/* Receive FIFO is Not Empty */ +FIELD(FLEXCOMM_SPI_FIFOSTAT, RXNOTEMPTY, 6, 1); +/* Receive FIFO is Full */ +FIELD(FLEXCOMM_SPI_FIFOSTAT, RXFULL, 7, 1); +/* Transmit FIFO Current Level */ +FIELD(FLEXCOMM_SPI_FIFOSTAT, TXLVL, 8, 5); +/* Receive FIFO Current Level */ +FIELD(FLEXCOMM_SPI_FIFOSTAT, RXLVL, 16, 5); + +/* FIFO Trigger Register */ +REG32(FLEXCOMM_SPI_FIFOTRIG, 3592); +/* Transmit FIFO Level Trigger Enable */ +FIELD(FLEXCOMM_SPI_FIFOTRIG, TXLVLENA, 0, 1); +/* Receive FIFO Level Trigger Enable */ +FIELD(FLEXCOMM_SPI_FIFOTRIG, RXLVLENA, 1, 1); +/* Transmit FIFO Level Trigger Point */ +FIELD(FLEXCOMM_SPI_FIFOTRIG, TXLVL, 8, 4); +/* Receive FIFO Level Trigger Point */ +FIELD(FLEXCOMM_SPI_FIFOTRIG, RXLVL, 16, 4); + +/* FIFO Interrupt Enable Register */ +REG32(FLEXCOMM_SPI_FIFOINTENSET, 3600); +/* TX Error Interrupt Enable */ +FIELD(FLEXCOMM_SPI_FIFOINTENSET, TXERR, 0, 1); +/* Receive Error Interrupt Enable */ +FIELD(FLEXCOMM_SPI_FIFOINTENSET, RXERR, 1, 1); +/* Transmit FIFO Level Interrupt Enable */ +FIELD(FLEXCOMM_SPI_FIFOINTENSET, TXLVL, 2, 1); +/* Receive FIFO Level Interrupt Enable */ +FIELD(FLEXCOMM_SPI_FIFOINTENSET, RXLVL, 3, 1); + +/* FIFO Interrupt Enable Clear Register */ +REG32(FLEXCOMM_SPI_FIFOINTENCLR, 3604); +/* TX Error Interrupt Enable */ +FIELD(FLEXCOMM_SPI_FIFOINTENCLR, TXERR, 0, 1); +/* Receive Error Interrupt Enable */ +FIELD(FLEXCOMM_SPI_FIFOINTENCLR, RXERR, 1, 1); +/* Transmit FIFO Level Interrupt Enable */ +FIELD(FLEXCOMM_SPI_FIFOINTENCLR, TXLVL, 2, 1); +/* Receive FIFO Level Interrupt Enable */ +FIELD(FLEXCOMM_SPI_FIFOINTENCLR, RXLVL, 3, 1); + +/* FIFO Interrupt Status Register */ +REG32(FLEXCOMM_SPI_FIFOINTSTAT, 3608); +/* TX FIFO Error Interrupt Status */ +FIELD(FLEXCOMM_SPI_FIFOINTSTAT, TXERR, 0, 1); +/* RX FIFO Error Interrupt Status */ +FIELD(FLEXCOMM_SPI_FIFOINTSTAT, RXERR, 1, 1); +/* Transmit FIFO Level Interrupt Status */ +FIELD(FLEXCOMM_SPI_FIFOINTSTAT, TXLVL, 2, 1); +/* Receive FIFO Level Interrupt Status */ +FIELD(FLEXCOMM_SPI_FIFOINTSTAT, RXLVL, 3, 1); +/* Peripheral Interrupt Status */ +FIELD(FLEXCOMM_SPI_FIFOINTSTAT, PERINT, 4, 1); + +/* FIFO Write Data Register */ +REG32(FLEXCOMM_SPI_FIFOWR, 3616); +/* Transmit Data to the FIFO */ +FIELD(FLEXCOMM_SPI_FIFOWR, TXDATA, 0, 16); +/* Transmit Slave Select 0 */ +FIELD(FLEXCOMM_SPI_FIFOWR, TXSSEL0_N, 16, 1); +/* Transmit Slave Select 1 */ +FIELD(FLEXCOMM_SPI_FIFOWR, TXSSEL1_N, 17, 1); +/* Transmit Slave Select 2 */ +FIELD(FLEXCOMM_SPI_FIFOWR, TXSSEL2_N, 18, 1); +/* Transmit Slave Select 3 */ +FIELD(FLEXCOMM_SPI_FIFOWR, TXSSEL3_N, 19, 1); +/* End of Transfer */ +FIELD(FLEXCOMM_SPI_FIFOWR, EOT, 20, 1); +/* End of Frame */ +FIELD(FLEXCOMM_SPI_FIFOWR, EOF, 21, 1); +/* Receive Ignore */ +FIELD(FLEXCOMM_SPI_FIFOWR, RXIGNORE, 22, 1); +/* Transmit Ignore */ +FIELD(FLEXCOMM_SPI_FIFOWR, TXIGNORE, 23, 1); +/* Data Length */ +FIELD(FLEXCOMM_SPI_FIFOWR, LEN, 24, 4); + +/* FIFO Read Data Register */ +REG32(FLEXCOMM_SPI_FIFORD, 3632); +/* Received Data from the FIFO */ +FIELD(FLEXCOMM_SPI_FIFORD, RXDATA, 0, 16); +/* Slave Select 0 for Receive */ +FIELD(FLEXCOMM_SPI_FIFORD, RXSSEL0_N, 16, 1); +/* Slave Select 1 for Receive */ +FIELD(FLEXCOMM_SPI_FIFORD, RXSSEL1_N, 17, 1); +/* Slave Select 2 for Receive */ +FIELD(FLEXCOMM_SPI_FIFORD, RXSSEL2_N, 18, 1); +/* Slave Select 3 for Receive */ +FIELD(FLEXCOMM_SPI_FIFORD, RXSSEL3_N, 19, 1); +/* Start of Transfer Flag */ +FIELD(FLEXCOMM_SPI_FIFORD, SOT, 20, 1); + +/* FIFO Data Read with no FIFO Pop Register */ +REG32(FLEXCOMM_SPI_FIFORDNOPOP, 3648); +/* Received Data from the FIFO */ +FIELD(FLEXCOMM_SPI_FIFORDNOPOP, RXDATA, 0, 16); +/* Slave Select 0 for Receive */ +FIELD(FLEXCOMM_SPI_FIFORDNOPOP, RXSSEL0_N, 16, 1); +/* Slave Select 1 for Receive */ +FIELD(FLEXCOMM_SPI_FIFORDNOPOP, RXSSEL1_N, 17, 1); +/* Slave Select 2 for Receive */ +FIELD(FLEXCOMM_SPI_FIFORDNOPOP, RXSSEL2_N, 18, 1); +/* Slave Select 3 for Receive */ +FIELD(FLEXCOMM_SPI_FIFORDNOPOP, RXSSEL3_N, 19, 1); +/* Start of Transfer Flag */ +FIELD(FLEXCOMM_SPI_FIFORDNOPOP, SOT, 20, 1); + +/* FIFO Size Register */ +REG32(FLEXCOMM_SPI_FIFOSIZE, 3656); +/* FIFO Size */ +FIELD(FLEXCOMM_SPI_FIFOSIZE, FIFOSIZE, 0, 5); + +/* Peripheral Identification Register */ +REG32(FLEXCOMM_SPI_ID, 4092); +/* Aperture */ +FIELD(FLEXCOMM_SPI_ID, APERTURE, 0, 8); +/* Minor revision of module implementation */ +FIELD(FLEXCOMM_SPI_ID, MINOR_REV, 8, 4); +/* Major revision of module implementation */ +FIELD(FLEXCOMM_SPI_ID, MAJOR_REV, 12, 4); +/* Module identifier for the selected function */ +FIELD(FLEXCOMM_SPI_ID, ID, 16, 16); + + +typedef enum { + /* + * Disabled. The SPI is disabled and the internal state machine and + * counters are reset. + */ + FLEXCOMM_SPI_CFG_ENABLE_DISABLED =3D 0, + /* Enabled. The SPI is enabled for operation. */ + FLEXCOMM_SPI_CFG_ENABLE_ENABLED =3D 1, +} FLEXCOMM_SPI_CFG_ENABLE_Enum; + +typedef enum { + /* + * Slave mode. The SPI will operate in slave mode. SCK, MOSI, and the = SSEL + * signals are inputs; MISO is an output. + */ + FLEXCOMM_SPI_CFG_MASTER_SLAVE_MODE =3D 0, + /* + * Master mode. The SPI will operate in master mode. SCK, MOSI, and the + * SSEL signals are outputs; MISO is an input. + */ + FLEXCOMM_SPI_CFG_MASTER_MASTER_MODE =3D 1, +} FLEXCOMM_SPI_CFG_MASTER_Enum; + +typedef enum { + /* + * Standard. Data is transmitted and received in standard MSB-first or= der. + */ + FLEXCOMM_SPI_CFG_LSBF_STANDARD =3D 0, + /* + * Reverse. Data is transmitted and received in reverse order (LSB fir= st). + */ + FLEXCOMM_SPI_CFG_LSBF_REVERSE =3D 1, +} FLEXCOMM_SPI_CFG_LSBF_Enum; + +typedef enum { + /* Change */ + FLEXCOMM_SPI_CFG_CPHA_CHANGE =3D 0, + /* Capture */ + FLEXCOMM_SPI_CFG_CPHA_CAPTURE =3D 1, +} FLEXCOMM_SPI_CFG_CPHA_Enum; + +typedef enum { + /* Low. The rest state of the clock (between transfers) is low. */ + FLEXCOMM_SPI_CFG_CPOL_LOW =3D 0, + /* High. The rest state of the clock (between transfers) is high. */ + FLEXCOMM_SPI_CFG_CPOL_HIGH =3D 1, +} FLEXCOMM_SPI_CFG_CPOL_Enum; + +typedef enum { + /* Disabled */ + FLEXCOMM_SPI_CFG_LOOP_DISABLED =3D 0, + /* Enabled */ + FLEXCOMM_SPI_CFG_LOOP_ENABLED =3D 1, +} FLEXCOMM_SPI_CFG_LOOP_Enum; + +typedef enum { + /* Low. The SSEL0 pin is active low. */ + FLEXCOMM_SPI_CFG_SPOL0_LOW =3D 0, + /* High. The SSEL0 pin is active high. */ + FLEXCOMM_SPI_CFG_SPOL0_HIGH =3D 1, +} FLEXCOMM_SPI_CFG_SPOL0_Enum; + +typedef enum { + /* Low. The SSEL1 pin is active low. */ + FLEXCOMM_SPI_CFG_SPOL1_LOW =3D 0, + /* High. The SSEL1 pin is active high. */ + FLEXCOMM_SPI_CFG_SPOL1_HIGH =3D 1, +} FLEXCOMM_SPI_CFG_SPOL1_Enum; + +typedef enum { + /* Low. The SSEL2 pin is active low. */ + FLEXCOMM_SPI_CFG_SPOL2_LOW =3D 0, + /* High. The SSEL2 pin is active high. */ + FLEXCOMM_SPI_CFG_SPOL2_HIGH =3D 1, +} FLEXCOMM_SPI_CFG_SPOL2_Enum; + +typedef enum { + /* Low. The SSEL3 pin is active low. */ + FLEXCOMM_SPI_CFG_SPOL3_LOW =3D 0, + /* High. The SSEL3 pin is active high. */ + FLEXCOMM_SPI_CFG_SPOL3_HIGH =3D 1, +} FLEXCOMM_SPI_CFG_SPOL3_Enum; + +typedef enum { + /* No additional time is inserted */ + FLEXCOMM_SPI_DLY_PRE_DELAY_PRE_DELAY0 =3D 0, + /* 1 SPI clock time is inserted */ + FLEXCOMM_SPI_DLY_PRE_DELAY_PRE_DELAY1 =3D 1, + /* 2 SPI clock times are inserted */ + FLEXCOMM_SPI_DLY_PRE_DELAY_PRE_DELAY2 =3D 2, + /* 15 SPI clock times are inserted */ + FLEXCOMM_SPI_DLY_PRE_DELAY_PRE_DELAY15 =3D 15, +} FLEXCOMM_SPI_DLY_PRE_DELAY_Enum; + +typedef enum { + /* No additional time is inserted */ + FLEXCOMM_SPI_DLY_POST_DELAY_POST_DELAY0 =3D 0, + /* 1 SPI clock time is inserted */ + FLEXCOMM_SPI_DLY_POST_DELAY_POST_DELAY1 =3D 1, + /* 2 SPI clock times are inserted */ + FLEXCOMM_SPI_DLY_POST_DELAY_POST_DELAY2 =3D 2, + /* 15 SPI clock times are inserted */ + FLEXCOMM_SPI_DLY_POST_DELAY_POST_DELAY15 =3D 15, +} FLEXCOMM_SPI_DLY_POST_DELAY_Enum; + +typedef enum { + /* No additional time is inserted */ + FLEXCOMM_SPI_DLY_FRAME_DELAY_FRAME_DELAY0 =3D 0, + /* 1 SPI clock time is inserted */ + FLEXCOMM_SPI_DLY_FRAME_DELAY_FRAME_DELAY1 =3D 1, + /* 2 SPI clock times are inserted */ + FLEXCOMM_SPI_DLY_FRAME_DELAY_FRAME_DELAY2 =3D 2, + /* 15 SPI clock times are inserted */ + FLEXCOMM_SPI_DLY_FRAME_DELAY_FRAME_DELAY15 =3D 15, +} FLEXCOMM_SPI_DLY_FRAME_DELAY_Enum; + +typedef enum { + /* + * The minimum time that SSEL is deasserted is 1 SPI clock time (zero-= added + * time) + */ + FLEXCOMM_SPI_DLY_TRANSFER_DELAY_TRANSFER_DELAY1 =3D 0, + /* The minimum time that SSEL is deasserted is 2 SPI clock times */ + FLEXCOMM_SPI_DLY_TRANSFER_DELAY_TRANSFER_DELAY2 =3D 1, + /* The minimum time that SSEL is deasserted is 3 SPI clock times */ + FLEXCOMM_SPI_DLY_TRANSFER_DELAY_TRANSFER_DELAY3 =3D 2, + /* The minimum time that SSEL is deasserted is 16 SPI clock times */ + FLEXCOMM_SPI_DLY_TRANSFER_DELAY_TRANSFER_DELAY16 =3D 15, +} FLEXCOMM_SPI_DLY_TRANSFER_DELAY_Enum; + +typedef enum { + /* + * Disabled. No interrupt will be generated when any Slave Select + * transitions from deasserted to asserted. + */ + FLEXCOMM_SPI_INTENSET_SSAEN_DISABLED =3D 0, + /* + * Enabled. An interrupt will be generated when any Slave Select + * transitions from deasserted to asserted. + */ + FLEXCOMM_SPI_INTENSET_SSAEN_ENABLED =3D 1, +} FLEXCOMM_SPI_INTENSET_SSAEN_Enum; + +typedef enum { + /* + * Disabled. No interrupt will be generated when all asserted Slave Se= lects + * transition to deasserted. + */ + FLEXCOMM_SPI_INTENSET_SSDEN_DISABLED =3D 0, + /* + * Enabled. An interrupt will be generated when all asserted Slave Sel= ects + * transition to deasserted. + */ + FLEXCOMM_SPI_INTENSET_SSDEN_ENABLED =3D 1, +} FLEXCOMM_SPI_INTENSET_SSDEN_Enum; + +typedef enum { + /* No interrupt will be generated when the SPI master function is idle= . */ + FLEXCOMM_SPI_INTENSET_MSTIDLEEN_DISABLED =3D 0, + /* + * An interrupt will be generated when the SPI master function is fully + * idle. + */ + FLEXCOMM_SPI_INTENSET_MSTIDLEEN_ENABLED =3D 1, +} FLEXCOMM_SPI_INTENSET_MSTIDLEEN_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_SPI_INTENCLR_SSAEN_NO_EFFECT =3D 0, + /* Clear the Slave Select Assert Interrupt Enable bit (INTENSET[SSAEN]= ) */ + FLEXCOMM_SPI_INTENCLR_SSAEN_CLEAR_THE_SSAEN =3D 1, +} FLEXCOMM_SPI_INTENCLR_SSAEN_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_SPI_INTENCLR_SSDEN_NO_EFFECT =3D 0, + /* Clear the Slave Select Deassert Interrupt Enable bit (INTENSET[SSDE= N]) */ + FLEXCOMM_SPI_INTENCLR_SSDEN_CLEAR_THE_SSDEN =3D 1, +} FLEXCOMM_SPI_INTENCLR_SSDEN_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_SPI_INTENCLR_MSTIDLE_NO_EFFECT =3D 0, + /* Clear the Master Idle Interrupt Enable bit (INTENSET[MSTIDLE]) */ + FLEXCOMM_SPI_INTENCLR_MSTIDLE_CLEAR_THE_MSTIDLE =3D 1, +} FLEXCOMM_SPI_INTENCLR_MSTIDLE_Enum; + +typedef enum { + /* Disabled */ + FLEXCOMM_SPI_INTSTAT_SSA_SSA_INTERRUPT_DISABLED =3D 0, + /* Enabled */ + FLEXCOMM_SPI_INTSTAT_SSA_SSA_INTERRUPT_ENABLED =3D 1, +} FLEXCOMM_SPI_INTSTAT_SSA_Enum; + +typedef enum { + /* Disabled */ + FLEXCOMM_SPI_INTSTAT_SSD_SSD_INTERRUPT_DISABLED =3D 0, + /* Enabled */ + FLEXCOMM_SPI_INTSTAT_SSD_SSD_INTERRUPT_ENABLED =3D 1, +} FLEXCOMM_SPI_INTSTAT_SSD_Enum; + +typedef enum { + /* Disabled */ + FLEXCOMM_SPI_INTSTAT_MSTIDLE_MSTIDLE_INTERRUPT_DISABLED =3D 0, + /* Enabled */ + FLEXCOMM_SPI_INTSTAT_MSTIDLE_MSTIDLE_INTERRUPT_ENABLED =3D 1, +} FLEXCOMM_SPI_INTSTAT_MSTIDLE_Enum; + +typedef enum { + /* The transmit FIFO is not enabled */ + FLEXCOMM_SPI_FIFOCFG_ENABLETX_DISABLED =3D 0, + /* The transmit FIFO is enabled */ + FLEXCOMM_SPI_FIFOCFG_ENABLETX_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOCFG_ENABLETX_Enum; + +typedef enum { + /* The receive FIFO is not enabled */ + FLEXCOMM_SPI_FIFOCFG_ENABLERX_DISABLED =3D 0, + /* The receive FIFO is enabled */ + FLEXCOMM_SPI_FIFOCFG_ENABLERX_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOCFG_ENABLERX_Enum; + +typedef enum { + /* FIFO is configured as 16 entries of 8 bits. */ + FLEXCOMM_SPI_FIFOCFG_SIZE_SIZE16ENTRIES8BITS =3D 0, + /* FIFO is configured as 8 entries of 16 bits. */ + FLEXCOMM_SPI_FIFOCFG_SIZE_SIZE8ENTRIES16BITS =3D 1, + /* Not used */ + FLEXCOMM_SPI_FIFOCFG_SIZE_SIZEINVALID2 =3D 2, + /* Not used */ + FLEXCOMM_SPI_FIFOCFG_SIZE_SIZEINVALID3 =3D 3, +} FLEXCOMM_SPI_FIFOCFG_SIZE_Enum; + +typedef enum { + /* DMA is not used for the transmit function */ + FLEXCOMM_SPI_FIFOCFG_DMATX_DISABLED =3D 0, + /* + * Issues DMA request for the transmit function if the FIFO is not ful= l. + * Generally, data interrupts would be disabled if DMA is enabled. + */ + FLEXCOMM_SPI_FIFOCFG_DMATX_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOCFG_DMATX_Enum; + +typedef enum { + /* DMA is not used for the receive function. */ + FLEXCOMM_SPI_FIFOCFG_DMARX_DISABLED =3D 0, + /* + * Issues a DMA request for the receive function if the FIFO is not em= pty. + * Generally, data interrupts would be disabled if DMA is enabled. + */ + FLEXCOMM_SPI_FIFOCFG_DMARX_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOCFG_DMARX_Enum; + +typedef enum { + /* + * Only enabled interrupts will wake up the device form reduced power = modes + */ + FLEXCOMM_SPI_FIFOCFG_WAKETX_DISABLED =3D 0, + /* + * A device wake-up for DMA will occur if the transmit FIFO level reac= hes + * the value specified by TXLVL in FIFOTRIG, even when the TXLVL inter= rupt + * is not enabled. + */ + FLEXCOMM_SPI_FIFOCFG_WAKETX_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOCFG_WAKETX_Enum; + +typedef enum { + /* + * Only enabled interrupts will wake up the device form reduced power + * modes. + */ + FLEXCOMM_SPI_FIFOCFG_WAKERX_DISABLED =3D 0, + /* + * A device wake-up for DMA will occur if the receive FIFO level reach= es + * the value specified by FIFOTRIG[RXLVL], even when the RXLVL interru= pt is + * not enabled. + */ + FLEXCOMM_SPI_FIFOCFG_WAKERX_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOCFG_WAKERX_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_SPI_FIFOCFG_EMPTYTX_NO_EFFECT =3D 0, + /* The TX FIFO is emptied */ + FLEXCOMM_SPI_FIFOCFG_EMPTYTX_EMPTY_THE_TX_FIFO =3D 1, +} FLEXCOMM_SPI_FIFOCFG_EMPTYTX_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_SPI_FIFOCFG_EMPTYRX_NO_EFFECT =3D 0, + /* The RX FIFO is emptied */ + FLEXCOMM_SPI_FIFOCFG_EMPTYRX_EMPTY_THE_RX_FIFO =3D 1, +} FLEXCOMM_SPI_FIFOCFG_EMPTYRX_Enum; + +typedef enum { + /* Debug reads of the FIFO do not pop the FIFO */ + FLEXCOMM_SPI_FIFOCFG_POPDBG_DO_NOT_POP =3D 0, + /* A debug read will cause the FIFO to pop */ + FLEXCOMM_SPI_FIFOCFG_POPDBG_POP =3D 1, +} FLEXCOMM_SPI_FIFOCFG_POPDBG_Enum; + +typedef enum { + /* A transmit FIFO error has not occurred. */ + FLEXCOMM_SPI_FIFOSTAT_TXERR_NO_TXERR =3D 0, + /* + * A transmit FIFO error has occurred. This error could be an overflow + * caused by pushing data into a full FIFO, or by an underflow if the = FIFO + * is empty when data is needed. + */ + FLEXCOMM_SPI_FIFOSTAT_TXERR_TXERR =3D 1, +} FLEXCOMM_SPI_FIFOSTAT_TXERR_Enum; + +typedef enum { + /* A receive FIFO overflow has not occurred */ + FLEXCOMM_SPI_FIFOSTAT_RXERR_NO_RXERR =3D 0, + /* + * A receive FIFO overflow has occurred, caused by software or DMA not + * emptying the FIFO fast enough + */ + FLEXCOMM_SPI_FIFOSTAT_RXERR_RXERR =3D 1, +} FLEXCOMM_SPI_FIFOSTAT_RXERR_Enum; + +typedef enum { + /* The peripheral function has not asserted an interrupt */ + FLEXCOMM_SPI_FIFOSTAT_PERINT_NO_PERINT =3D 0, + /* + * Indicates that the peripheral function has asserted an interrupt. M= ore + * information can be found by reading the peripheral's status register + * (STAT). + */ + FLEXCOMM_SPI_FIFOSTAT_PERINT_PERINT =3D 1, +} FLEXCOMM_SPI_FIFOSTAT_PERINT_Enum; + +typedef enum { + /* The transmit FIFO is not empty */ + FLEXCOMM_SPI_FIFOSTAT_TXEMPTY_TXFIFO_ISNOTEMPTY =3D 0, + /* + * The transmit FIFO is empty, although the peripheral may still be + * processing the last piece of data. + */ + FLEXCOMM_SPI_FIFOSTAT_TXEMPTY_TXFIFO_ISEMPTY =3D 1, +} FLEXCOMM_SPI_FIFOSTAT_TXEMPTY_Enum; + +typedef enum { + /* The transmit FIFO is full and another write would cause it to overf= low */ + FLEXCOMM_SPI_FIFOSTAT_TXNOTFULL_TXFIFO_ISFULL =3D 0, + /* The transmit FIFO is not full, so more data can be written */ + FLEXCOMM_SPI_FIFOSTAT_TXNOTFULL_TXFIFO_ISNOTFULL =3D 1, +} FLEXCOMM_SPI_FIFOSTAT_TXNOTFULL_Enum; + +typedef enum { + /* When 0, the receive FIFO is empty */ + FLEXCOMM_SPI_FIFOSTAT_RXNOTEMPTY_RXFIFO_ISEMPTY =3D 0, + /* When 1, the receive FIFO is not empty, so data can be read */ + FLEXCOMM_SPI_FIFOSTAT_RXNOTEMPTY_RXFIFO_ISNOTEMPTY =3D 1, +} FLEXCOMM_SPI_FIFOSTAT_RXNOTEMPTY_Enum; + +typedef enum { + /* The receive FIFO is not full */ + FLEXCOMM_SPI_FIFOSTAT_RXFULL_RXFIFO_ISNOTFULL =3D 0, + /* + * The receive FIFO is full. To prevent the peripheral from causing an + * overflow, data should be read out. + */ + FLEXCOMM_SPI_FIFOSTAT_RXFULL_RXFIFO_ISFULL =3D 1, +} FLEXCOMM_SPI_FIFOSTAT_RXFULL_Enum; + +typedef enum { + /* Transmit FIFO level does not generate a FIFO level trigger */ + FLEXCOMM_SPI_FIFOTRIG_TXLVLENA_DISABLED =3D 0, + /* + * An trigger will be generated if the transmit FIFO level reaches the + * value specified by the FIFOTRIG[TXLVL] field. + */ + FLEXCOMM_SPI_FIFOTRIG_TXLVLENA_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOTRIG_TXLVLENA_Enum; + +typedef enum { + /* Receive FIFO level does not generate a FIFO level trigger */ + FLEXCOMM_SPI_FIFOTRIG_RXLVLENA_DISABLED =3D 0, + /* + * An trigger will be generated if the receive FIFO level reaches the = value + * specified by the FIFOTRIG[RXLVL] field. + */ + FLEXCOMM_SPI_FIFOTRIG_RXLVLENA_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOTRIG_RXLVLENA_Enum; + +typedef enum { + /* Trigger when the TX FIFO becomes empty */ + FLEXCOMM_SPI_FIFOTRIG_TXLVL_TXLVL0 =3D 0, + /* Trigger when the TX FIFO level decreases to 1 entry */ + FLEXCOMM_SPI_FIFOTRIG_TXLVL_TXLVL1 =3D 1, + /* + * Trigger when the TX FIFO level decreases to 15 entries (is no longer + * full) + */ + FLEXCOMM_SPI_FIFOTRIG_TXLVL_TXLVL15 =3D 15, +} FLEXCOMM_SPI_FIFOTRIG_TXLVL_Enum; + +typedef enum { + /* Trigger when the RX FIFO has received 1 entry (is no longer empty) = */ + FLEXCOMM_SPI_FIFOTRIG_RXLVL_RXLVL1 =3D 0, + /* Trigger when the RX FIFO has received 2 entries */ + FLEXCOMM_SPI_FIFOTRIG_RXLVL_RXLVL2 =3D 1, + /* Trigger when the RX FIFO has received 16 entries (has become full) = */ + FLEXCOMM_SPI_FIFOTRIG_RXLVL_RXLVL15 =3D 15, +} FLEXCOMM_SPI_FIFOTRIG_RXLVL_Enum; + +typedef enum { + /* No interrupt will be generated for a transmit error */ + FLEXCOMM_SPI_FIFOINTENSET_TXERR_DISABLED =3D 0, + /* An interrupt will be generated when a transmit error occurs */ + FLEXCOMM_SPI_FIFOINTENSET_TXERR_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOINTENSET_TXERR_Enum; + +typedef enum { + /* No interrupt will be generated for a receive error */ + FLEXCOMM_SPI_FIFOINTENSET_RXERR_DISABLED =3D 0, + /* An interrupt will be generated when a receive error occurs */ + FLEXCOMM_SPI_FIFOINTENSET_RXERR_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOINTENSET_RXERR_Enum; + +typedef enum { + /* No interrupt will be generated based on the TX FIFO level */ + FLEXCOMM_SPI_FIFOINTENSET_TXLVL_DISABLED =3D 0, + /* + * If FIFOTRIG[TXLVLENA]=3D1, then an interrupt will be generated when= the TX + * FIFO level decreases to the level specified by FIFOTRIG[TXLVL] + */ + FLEXCOMM_SPI_FIFOINTENSET_TXLVL_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOINTENSET_TXLVL_Enum; + +typedef enum { + /* No interrupt will be generated based on the RX FIFO level */ + FLEXCOMM_SPI_FIFOINTENSET_RXLVL_DISABLED =3D 0, + /* + * If FIFOTRIG[RXLVLENA]=3D1, then an interrupt will be generated when= the RX + * FIFO level increases to the level specified by FIFOTRIG[RXLVL] + */ + FLEXCOMM_SPI_FIFOINTENSET_RXLVL_ENABLED =3D 1, +} FLEXCOMM_SPI_FIFOINTENSET_RXLVL_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_SPI_FIFOINTENCLR_TXERR_NO_EFFECT =3D 0, + /* Clear the TX Error Interrupt Enable bit FIFOINTENSET[TXERR] */ + FLEXCOMM_SPI_FIFOINTENCLR_TXERR_CLEAR_THE_TXERR =3D 1, +} FLEXCOMM_SPI_FIFOINTENCLR_TXERR_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_SPI_FIFOINTENCLR_RXERR_NO_EFFECT =3D 0, + /* Clear the Receive Error Interrupt Enable bit FIFOINTENSET[RXERR] */ + FLEXCOMM_SPI_FIFOINTENCLR_RXERR_CLEAR_THE_RXERR =3D 1, +} FLEXCOMM_SPI_FIFOINTENCLR_RXERR_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_SPI_FIFOINTENCLR_TXLVL_NO_EFFECT =3D 0, + /* Clear the Transmit FIFO Level Interrupt Enable bit FIFOINTENSET[TXL= VL] */ + FLEXCOMM_SPI_FIFOINTENCLR_TXLVL_CLEAR_THE_TXLVL =3D 1, +} FLEXCOMM_SPI_FIFOINTENCLR_TXLVL_Enum; + +typedef enum { + /* No effect */ + FLEXCOMM_SPI_FIFOINTENCLR_RXLVL_NO_EFFECT =3D 0, + /* Clear the Receive FIFO Level Interrupt Enable bit FIFOINTENSET[RXLV= L] */ + FLEXCOMM_SPI_FIFOINTENCLR_RXLVL_CLEAR_THE_RXLVL =3D 1, +} FLEXCOMM_SPI_FIFOINTENCLR_RXLVL_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_SPI_FIFOINTSTAT_TXERR_TXERR_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_SPI_FIFOINTSTAT_TXERR_TXERR_ISPENDING =3D 1, +} FLEXCOMM_SPI_FIFOINTSTAT_TXERR_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_SPI_FIFOINTSTAT_RXERR_RXERR_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_SPI_FIFOINTSTAT_RXERR_RXERR_ISPENDING =3D 1, +} FLEXCOMM_SPI_FIFOINTSTAT_RXERR_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_SPI_FIFOINTSTAT_TXLVL_TXLVL_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_SPI_FIFOINTSTAT_TXLVL_TXLVL_ISPENDING =3D 1, +} FLEXCOMM_SPI_FIFOINTSTAT_TXLVL_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_SPI_FIFOINTSTAT_RXLVL_RXLVL_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_SPI_FIFOINTSTAT_RXLVL_RXLVL_ISPENDING =3D 1, +} FLEXCOMM_SPI_FIFOINTSTAT_RXLVL_Enum; + +typedef enum { + /* Not pending */ + FLEXCOMM_SPI_FIFOINTSTAT_PERINT_PERINT_ISNOTPENDING =3D 0, + /* Pending */ + FLEXCOMM_SPI_FIFOINTSTAT_PERINT_PERINT_ISPENDING =3D 1, +} FLEXCOMM_SPI_FIFOINTSTAT_PERINT_Enum; + +typedef enum { + /* SSEL0 is asserted */ + FLEXCOMM_SPI_FIFOWR_TXSSEL0_N_ASSERTED =3D 0, + /* SSEL0 is not asserted */ + FLEXCOMM_SPI_FIFOWR_TXSSEL0_N_NOT_ASSERTED =3D 1, +} FLEXCOMM_SPI_FIFOWR_TXSSEL0_N_Enum; + +typedef enum { + /* SSEL1 is asserted */ + FLEXCOMM_SPI_FIFOWR_TXSSEL1_N_ASSERTED =3D 0, + /* SSEL1 is not asserted */ + FLEXCOMM_SPI_FIFOWR_TXSSEL1_N_NOT_ASSERTED =3D 1, +} FLEXCOMM_SPI_FIFOWR_TXSSEL1_N_Enum; + +typedef enum { + /* SSEL2 is asserted */ + FLEXCOMM_SPI_FIFOWR_TXSSEL2_N_ASSERTED =3D 0, + /* SSEL2 is not asserted */ + FLEXCOMM_SPI_FIFOWR_TXSSEL2_N_NOT_ASSERTED =3D 1, +} FLEXCOMM_SPI_FIFOWR_TXSSEL2_N_Enum; + +typedef enum { + /* SSEL3 is asserted */ + FLEXCOMM_SPI_FIFOWR_TXSSEL3_N_ASSERTED =3D 0, + /* SSEL3 is not asserted */ + FLEXCOMM_SPI_FIFOWR_TXSSEL3_N_NOT_ASSERTED =3D 1, +} FLEXCOMM_SPI_FIFOWR_TXSSEL3_N_Enum; + +typedef enum { + /* + * SSEL is not deasserted. This piece of data is not treated as the en= d of + * a transfer. SSEL will not be deasserted at the end of this data. + */ + FLEXCOMM_SPI_FIFOWR_EOT_NOT_DEASSERTED =3D 0, + /* + * SSEL is deasserted. This piece of data is treated as the end of a + * transfer. SSEL will be deasserted at the end of this piece of data. + */ + FLEXCOMM_SPI_FIFOWR_EOT_DEASSERTED =3D 1, +} FLEXCOMM_SPI_FIFOWR_EOT_Enum; + +typedef enum { + /* + * Data not EOF. This piece of data transmitted is not treated as the = end + * of a frame. + */ + FLEXCOMM_SPI_FIFOWR_EOF_NOT_EOF =3D 0, + /* + * Data EOF. This piece of data is treated as the end of a frame, caus= ing + * the Frame_delay time to be inserted before subsequent data is + * transmitted. + */ + FLEXCOMM_SPI_FIFOWR_EOF_EOF =3D 1, +} FLEXCOMM_SPI_FIFOWR_EOF_Enum; + +typedef enum { + /* + * Read received data. Received data must be read, to allow transmissi= on to + * proceed. SPI transmit will halt when the receive data FIFO is full.= In + * slave mode, an overrun error will occur if received data is not read + * before new data is received. + */ + FLEXCOMM_SPI_FIFOWR_RXIGNORE_READ =3D 0, + /* + * Ignore received data. Received data is ignored, allowing transmissi= on + * without reading unneeded received data. No receiver flags are gener= ated. + */ + FLEXCOMM_SPI_FIFOWR_RXIGNORE_IGNORE =3D 1, +} FLEXCOMM_SPI_FIFOWR_RXIGNORE_Enum; + +typedef enum { + /* Write transmit data */ + FLEXCOMM_SPI_FIFOWR_TXIGNORE_WRITETXDATA =3D 0, + /* Ignore transmit data */ + FLEXCOMM_SPI_FIFOWR_TXIGNORE_IGNORETXDATA =3D 1, +} FLEXCOMM_SPI_FIFOWR_TXIGNORE_Enum; + +typedef enum { + /* Data transfer is 4 bits in length */ + FLEXCOMM_SPI_FIFOWR_LEN_LEN_4BITS =3D 3, + /* Data transfer is 5 bits in length */ + FLEXCOMM_SPI_FIFOWR_LEN_LEN_5BITS =3D 4, + /* Data transfer is 16 bits in length */ + FLEXCOMM_SPI_FIFOWR_LEN_LEN_16BITS =3D 15, +} FLEXCOMM_SPI_FIFOWR_LEN_Enum; + +typedef enum { + /* Slave Select 0 is active */ + FLEXCOMM_SPI_FIFORD_RXSSEL0_N_RXSSEL0_ISACTIVE =3D 0, + /* Slave Select 0 is not active */ + FLEXCOMM_SPI_FIFORD_RXSSEL0_N_RXSSEL0_ISNOTACTIVE =3D 1, +} FLEXCOMM_SPI_FIFORD_RXSSEL0_N_Enum; + +typedef enum { + /* Slave Select 1 is active */ + FLEXCOMM_SPI_FIFORD_RXSSEL1_N_RXSSEL1_ISACTIVE =3D 0, + /* Slave Select 1 is not active */ + FLEXCOMM_SPI_FIFORD_RXSSEL1_N_RXSSEL1_ISNOTACTIVE =3D 1, +} FLEXCOMM_SPI_FIFORD_RXSSEL1_N_Enum; + +typedef enum { + /* Slave Select 2 is active */ + FLEXCOMM_SPI_FIFORD_RXSSEL2_N_RXSSEL2_ISACTIVE =3D 0, + /* Slave Select 2 is not active */ + FLEXCOMM_SPI_FIFORD_RXSSEL2_N_RXSSEL2_ISNOTACTIVE =3D 1, +} FLEXCOMM_SPI_FIFORD_RXSSEL2_N_Enum; + +typedef enum { + /* Slave Select 3 is active */ + FLEXCOMM_SPI_FIFORD_RXSSEL3_N_RXSSEL3_ISACTIVE =3D 0, + /* Slave Select 3 is not active */ + FLEXCOMM_SPI_FIFORD_RXSSEL3_N_RXSSEL3_ISNOTACTIVE =3D 1, +} FLEXCOMM_SPI_FIFORD_RXSSEL3_N_Enum; + +typedef enum { + /* + * This is not the 1st data after the SSELs went from deasserted to + * asserted + */ + FLEXCOMM_SPI_FIFORD_SOT_SOT0 =3D 0, + /* + * This is the 1st data after the SSELs went from deasserted to assert= ed + * (i.e., any previous transfer has ended). This information can be us= ed to + * identify the 1st piece of data in cases where the transfer length is + * greater than 16 bits. + */ + FLEXCOMM_SPI_FIFORD_SOT_SOT1 =3D 1, +} FLEXCOMM_SPI_FIFORD_SOT_Enum; + +typedef enum { + /* Not selected */ + FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL0_N_NOT_SELECTED =3D 0, + /* Selected */ + FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL0_N_RXSSEL0_N_SELECTED =3D 1, +} FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL0_N_Enum; + +typedef enum { + /* Not selected */ + FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL1_N_NOT_SELECTED =3D 0, + /* Selected */ + FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL1_N_RXSSEL1_N_SELECTED =3D 1, +} FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL1_N_Enum; + +typedef enum { + /* Not selected */ + FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL2_N_NOT_SELECTED =3D 0, + /* Selected */ + FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL2_N_RXSSEL2_N_SELECTED =3D 1, +} FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL2_N_Enum; + +typedef enum { + /* Not selected */ + FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL3_N_NOT_SELECTED =3D 0, + /* Selected */ + FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL3_N_RXSSEL3_N_SELECTED =3D 1, +} FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL3_N_Enum; + +typedef enum { + /* Not active */ + FLEXCOMM_SPI_FIFORDNOPOP_SOT_SOT_NOT_ACTIVE =3D 0, + /* Active */ + FLEXCOMM_SPI_FIFORDNOPOP_SOT_SOT_ACTIVE =3D 1, +} FLEXCOMM_SPI_FIFORDNOPOP_SOT_Enum; + + +#define FLEXCOMM_SPI_REGISTER_ACCESS_INFO_ARRAY(_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_SPI_REGS_NO] =3D { \ + [0 ... FLEXCOMM_SPI_REGS_NO - 1] =3D { \ + .name =3D "", \ + .addr =3D -1, \ + }, \ + [R_FLEXCOMM_SPI_CFG] =3D { \ + .name =3D "CFG", \ + .addr =3D 0x400, \ + .ro =3D 0xFFFFF042, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_DLY] =3D { \ + .name =3D "DLY", \ + .addr =3D 0x404, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_STAT] =3D { \ + .name =3D "STAT", \ + .addr =3D 0x408, \ + .ro =3D 0xFFFFFF4F, \ + .reset =3D 0x100, \ + }, \ + [R_FLEXCOMM_SPI_INTENSET] =3D { \ + .name =3D "INTENSET", \ + .addr =3D 0x40C, \ + .ro =3D 0xFFFFFECF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_INTENCLR] =3D { \ + .name =3D "INTENCLR", \ + .addr =3D 0x410, \ + .ro =3D 0xFFFFFECF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_DIV] =3D { \ + .name =3D "DIV", \ + .addr =3D 0x424, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_INTSTAT] =3D { \ + .name =3D "INTSTAT", \ + .addr =3D 0x428, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOCFG] =3D { \ + .name =3D "FIFOCFG", \ + .addr =3D 0xE00, \ + .ro =3D 0xFFF80FFC, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOSTAT] =3D { \ + .name =3D "FIFOSTAT", \ + .addr =3D 0xE04, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x30, \ + }, \ + [R_FLEXCOMM_SPI_FIFOTRIG] =3D { \ + .name =3D "FIFOTRIG", \ + .addr =3D 0xE08, \ + .ro =3D 0xFFF0F0FC, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOINTENSET] =3D { \ + .name =3D "FIFOINTENSET", \ + .addr =3D 0xE10, \ + .ro =3D 0xFFFFFFF0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOINTENCLR] =3D { \ + .name =3D "FIFOINTENCLR", \ + .addr =3D 0xE14, \ + .ro =3D 0xFFFFFFF0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOINTSTAT] =3D { \ + .name =3D "FIFOINTSTAT", \ + .addr =3D 0xE18, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOWR] =3D { \ + .name =3D "FIFOWR", \ + .addr =3D 0xE20, \ + .ro =3D 0xF0000000, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFORD] =3D { \ + .name =3D "FIFORD", \ + .addr =3D 0xE30, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFORDNOPOP] =3D { \ + .name =3D "FIFORDNOPOP", \ + .addr =3D 0xE40, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOSIZE] =3D { \ + .name =3D "FIFOSIZE", \ + .addr =3D 0xE48, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXCOMM_SPI_ID] =3D { \ + .name =3D "ID", \ + .addr =3D 0xFFC, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0xE0201200, \ + }, \ + } diff --git a/include/hw/misc/flexcomm.h b/include/hw/misc/flexcomm.h index c9f1cd3890..757453df97 100644 --- a/include/hw/misc/flexcomm.h +++ b/include/hw/misc/flexcomm.h @@ -17,6 +17,7 @@ #include "qemu/fifo32.h" #include "hw/char/flexcomm_usart.h" #include "hw/i2c/flexcomm_i2c.h" +#include "hw/ssi/flexcomm_spi.h" =20 #define FLEXCOMM_FUNC_USART 0 #define FLEXCOMM_FUNC_SPI 1 @@ -50,6 +51,7 @@ struct FlexcommState { Fifo32 tx_fifo; FlexcommUsartState usart; FlexcommI2cState i2c; + FlexcommSpiState spi; }; =20 #endif /* HW_FLEXCOMM_H */ diff --git a/include/hw/ssi/flexcomm_spi.h b/include/hw/ssi/flexcomm_spi.h new file mode 100644 index 0000000000..c39cc33de4 --- /dev/null +++ b/include/hw/ssi/flexcomm_spi.h @@ -0,0 +1,36 @@ +/* + * QEMU model for NXP's FLEXCOMM SPI + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_FLEXCOMM_SPI_H +#define HW_FLEXCOMM_SPI_H + +#include "hw/misc/flexcomm_function.h" +#include "hw/ssi/ssi.h" + +#define TYPE_FLEXCOMM_SPI "flexcomm-spi" +OBJECT_DECLARE_TYPE(FlexcommSpiState, FlexcommSpiClass, FLEXCOMM_SPI); + +struct FlexcommSpiState { + FlexcommFunction parent_obj; + + SSIBus *bus; + qemu_irq cs[4]; + bool cs_asserted[4]; + uint32_t tx_ctrl; +}; + +struct FlexcommSpiClass { + FlexcommFunctionClass parent_obj; + + FlexcommFunctionSelect select; +}; + +#endif /* HW_FLEXCOMM_SPI_H */ diff --git a/hw/misc/flexcomm.c b/hw/misc/flexcomm.c index b1a2f01acf..fef220eb5b 100644 --- a/hw/misc/flexcomm.c +++ b/hw/misc/flexcomm.c @@ -25,6 +25,7 @@ #include "hw/arm/svd/flexcomm_usart.h" #include "hw/char/flexcomm_usart.h" #include "hw/i2c/flexcomm_i2c.h" +#include "hw/ssi/flexcomm_spi.h" =20 #define REG(s, reg) (s->regs[R_FLEXCOMM_##reg]) #define RF_WR(s, reg, field, val) \ @@ -222,6 +223,7 @@ static void flexcomm_init(Object *obj) sysbus_init_irq(sbd, &s->irq); object_initialize_child(obj, "usart", &s->usart, TYPE_FLEXCOMM_USART); object_initialize_child(obj, "i2c", &s->i2c, TYPE_FLEXCOMM_I2C); + object_initialize_child(obj, "spi", &s->spi, TYPE_FLEXCOMM_SPI); } =20 static void flexcomm_finalize(Object *obj) @@ -253,6 +255,7 @@ static void flexcomm_realize(DeviceState *dev, Error **= errp) memory_region_add_subregion_overlap(&s->container, 0, &s->mmio, -1); flexcomm_func_realize_and_unref(FLEXCOMM_FUNCTION(&s->usart), errp); flexcomm_func_realize_and_unref(FLEXCOMM_FUNCTION(&s->i2c), errp); + flexcomm_func_realize_and_unref(FLEXCOMM_FUNCTION(&s->spi), errp); } =20 static const VMStateDescription vmstate_flexcomm =3D { diff --git a/hw/ssi/flexcomm_spi.c b/hw/ssi/flexcomm_spi.c new file mode 100644 index 0000000000..d8ecd37024 --- /dev/null +++ b/hw/ssi/flexcomm_spi.c @@ -0,0 +1,422 @@ +/* + * QEMU model for NXP's FLEXCOMM SPI + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "qemu/cutils.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "qapi/error.h" +#include "trace.h" +#include "migration/vmstate.h" +#include "hw/misc/flexcomm.h" +#include "hw/arm/svd/flexcomm_spi.h" + +#define REG(s, reg) (s->regs[R_FLEXCOMM_SPI_##reg]) +#define RF_WR(s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXCOMM_SPI_##reg, field, val) +#define RF_RD(s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXCOMM_SPI_##reg, field) + +#define FLEXCOMM_SSEL_ASSERTED (0) +#define FLEXCOMM_SSEL_DEASSERTED (1) + +#define FLEXCOMM_SPI_FIFOWR_LEN_MIN (3) +#define FLEXCOMM_SPI_FIFOWR_LEN_MAX (15) + +static const FLEXCOMM_SPI_REGISTER_ACCESS_INFO_ARRAY(reg_info); + +static void flexcomm_spi_reset(FlexcommFunction *f) +{ + for (int i =3D 0; i < FLEXCOMM_SPI_REGS_NO; i++) { + hwaddr addr =3D reg_info[i].addr; + + if (addr !=3D -1) { + struct RegisterInfo ri =3D { + .data =3D &f->regs[addr / 4], + .data_size =3D 4, + .access =3D ®_info[i], + }; + + register_reset(&ri); + } + } + + RF_WR(f, FIFOSIZE, FIFOSIZE, 0x8); +} + +static void flexcomm_spi_irq_update(FlexcommFunction *f) +{ + bool irq, per_irqs, fifo_irqs, enabled =3D RF_RD(f, CFG, ENABLE); + + flexcomm_update_fifostat(f); + fifo_irqs =3D REG(f, FIFOINTSTAT) & REG(f, FIFOINTENSET); + + REG(f, INTSTAT) =3D REG(f, STAT) & REG(f, INTENSET); + per_irqs =3D REG(f, INTSTAT) !=3D 0; + + irq =3D enabled && (fifo_irqs || per_irqs); + + trace_flexcomm_spi_irq(DEVICE(f)->id, irq, fifo_irqs, per_irqs, enable= d); + flexcomm_set_irq(f, irq); +} + +static void flexcomm_spi_select(FlexcommFunction *f, bool selected) +{ + FlexcommSpiState *s =3D FLEXCOMM_SPI(f); + FlexcommSpiClass *sc =3D FLEXCOMM_SPI_GET_CLASS(f); + + if (selected) { + bool spol[] =3D { + RF_RD(f, CFG, SPOL0), RF_RD(f, CFG, SPOL1), RF_RD(f, CFG, SPOL= 2), + RF_RD(f, CFG, SPOL3), + }; + + flexcomm_spi_reset(f); + for (int i =3D 0; i < ARRAY_SIZE(s->cs); i++) { + s->cs_asserted[i] =3D false; + qemu_set_irq(s->cs[i], !spol[i]); + } + } + sc->select(f, selected); +} + +static MemTxResult flexcomm_spi_reg_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(opaque); + MemTxResult ret =3D MEMTX_OK; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + + /* + * Allow 8/16 bits access to the FIFORD LSB half-word. This is support= ed by + * hardware and required for 1/2 byte(s) width DMA transfers. + */ + if (size !=3D 4 && addr !=3D A_FLEXCOMM_SPI_FIFORD) { + ret =3D MEMTX_ERROR; + goto out; + } + + switch (addr) { + case A_FLEXCOMM_SPI_FIFORD: + { + /* If we are running in loopback mode get the data from TX FIFO */ + if (RF_RD(f, CFG, LOOP) && + RF_RD(f, CFG, MASTER)) + { + if (!fifo32_is_empty(f->tx_fifo)) { + *data =3D fifo32_pop(f->tx_fifo); + } + break; + } + + if (!fifo32_is_empty(f->rx_fifo)) { + *data =3D fifo32_pop(f->rx_fifo); + } + break; + } + case A_FLEXCOMM_SPI_FIFORDNOPOP: + { + if (!fifo32_is_empty(f->rx_fifo)) { + *data =3D fifo32_peek(f->rx_fifo); + } + break; + } + default: + *data =3D f->regs[addr / 4]; + break; + } + + flexcomm_spi_irq_update(f); + +out: + trace_flexcomm_spi_reg_read(DEVICE(f)->id, rai->name, addr, *data); + return ret; +} + +static uint32_t fifowr_len_bits(uint32_t val) +{ + int len =3D FIELD_EX32(val, FLEXCOMM_SPI_FIFOWR, LEN); + + if (len < FLEXCOMM_SPI_FIFOWR_LEN_MIN || + len > FLEXCOMM_SPI_FIFOWR_LEN_MAX) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid spi xfer len %d\n", + __func__, val); + return 0; + } + + return len + 1; +} + +static inline uint32_t fifowr_len_bytes(uint32_t val) +{ + return fifowr_len_bits(val) > 8 ? 2 : 1; +} + +static uint32_t flexcomm_spi_xfer_word(FlexcommSpiState *s, uint32_t out_d= ata, + int bytes, bool be) +{ + uint32_t word =3D 0; + int out =3D 0; + + for (int i =3D 0; i < bytes; i++) { + if (be) { + int byte_offset =3D bytes - i - 1; + out =3D (out_data & (0xFF << byte_offset * 8)) >> byte_offset = * 8; + word |=3D ssi_transfer(s->bus, out) << byte_offset * 8; + } else { + out =3D (out_data & (0xFF << i * 8)) >> i * 8; + word |=3D ssi_transfer(s->bus, out) << i * 8; + } + } + + return word; +} + +static uint32_t flexcomm_spi_get_ss_mask(FlexcommSpiState *s, + uint32_t txfifo_val) +{ + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(s); + + uint32_t slave_select_mask =3D 0; + bool ss[] =3D { + FIELD_EX32(txfifo_val, FLEXCOMM_SPI_FIFOWR, TXSSEL0_N), + FIELD_EX32(txfifo_val, FLEXCOMM_SPI_FIFOWR, TXSSEL1_N), + FIELD_EX32(txfifo_val, FLEXCOMM_SPI_FIFOWR, TXSSEL2_N), + FIELD_EX32(txfifo_val, FLEXCOMM_SPI_FIFOWR, TXSSEL3_N), + }; + bool spol[] =3D { + RF_RD(f, CFG, SPOL0), RF_RD(f, CFG, SPOL1), RF_RD(f, CFG, SPOL2), + RF_RD(f, CFG, SPOL3), + }; + + for (int i =3D 0; i < ARRAY_SIZE(s->cs); i++) { + int irq_level =3D ss[i] ? spol[i] : !spol[i]; + + slave_select_mask |=3D (ss[i] << i); + s->cs_asserted[i] =3D ss[i]; + qemu_set_irq(s->cs[i], irq_level); + } + + return slave_select_mask; +} + +static MemTxResult flexcomm_spi_reg_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + FlexcommFunction *f =3D FLEXCOMM_FUNCTION(opaque); + FlexcommSpiState *s =3D FLEXCOMM_SPI(opaque); + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + struct RegisterInfo ri =3D { + .data =3D &f->regs[addr / 4], + .data_size =3D 4, + .access =3D rai, + }; + MemTxResult ret =3D MEMTX_OK; + + trace_flexcomm_spi_reg_write(DEVICE(f)->id, rai->name, addr, value); + + /* + * Allow 8/16 bits access to both the FIFOWR MSB and LSB half-words. T= he + * former is required for updating the control bits while the latter f= or DMA + * transfers of 1/2 byte(s) width. + */ + if (size !=3D 4 && (addr / 4 !=3D R_FLEXCOMM_SPI_FIFOWR)) { + return MEMTX_ERROR; + } + + switch (addr) { + case A_FLEXCOMM_SPI_CFG: + { + register_write(&ri, value, ~0, NULL, false); + break; + } + case A_FLEXCOMM_SPI_INTENCLR: + { + register_write(&ri, value, ~0, NULL, false); + REG(f, INTENSET) &=3D ~REG(f, INTENCLR); + break; + } + case A_FLEXCOMM_SPI_FIFOCFG: + { + register_write(&ri, value, ~0, NULL, false); + flexcomm_reset_fifos(f); + break; + } + case A_FLEXCOMM_SPI_FIFOSTAT: + { + flexcomm_clear_fifostat(f, value); + break; + } + case A_FLEXCOMM_SPI_FIFOINTENSET: + { + REG(f, FIFOINTENSET) |=3D value; + break; + } + case A_FLEXCOMM_SPI_FIFOINTENCLR: + { + register_write(&ri, value, ~0, NULL, false); + REG(f, FIFOINTENSET) &=3D ~REG(f, FIFOINTENCLR); + break; + } + /* update control bits but don't push into the FIFO */ + case A_FLEXCOMM_SPI_FIFOWR + 2: + { + if (value !=3D 0) { + s->tx_ctrl =3D value << 16; + } + break; + } + /* update control bits but don't push into the FIFO */ + case A_FLEXCOMM_SPI_FIFOWR + 3: + { + if (value !=3D 0) { + s->tx_ctrl =3D value << 24; + } + break; + } + case A_FLEXCOMM_SPI_FIFOWR: + { + /* fifo value contains both data and control bits */ + uint32_t txfifo_val; + uint16_t tx_data =3D FIELD_EX32(value, FLEXCOMM_SPI_FIFOWR, TXDATA= ); + uint32_t tx_ctrl =3D value & 0xffff0000; + + if (size > 2 && tx_ctrl !=3D 0) { + /* non-zero writes to control bits updates them */ + s->tx_ctrl =3D tx_ctrl; + } + + /* push the data and control bits into the FIFO */ + txfifo_val =3D tx_data | s->tx_ctrl; + + if (!fifo32_is_full(f->tx_fifo)) { + fifo32_push(f->tx_fifo, txfifo_val); + } + + if (!RF_RD(f, CFG, ENABLE) || !RF_RD(f, FIFOCFG, ENABLETX)) { + break; + } + + /* + * On loopback mode we just insert the values in the TX FIFO. On s= lave + * mode master needs to initiate the SPI transfer. + */ + if (RF_RD(f, CFG, LOOP) || !RF_RD(f, CFG, MASTER)) { + break; + } + + while (!fifo32_is_empty(f->tx_fifo)) { + txfifo_val =3D fifo32_pop(f->tx_fifo); + + uint32_t ss_mask =3D flexcomm_spi_get_ss_mask(s, txfifo_val); + uint32_t data =3D FIELD_EX32(txfifo_val, FLEXCOMM_SPI_FIFOWR, = TXDATA); + uint8_t bytes =3D fifowr_len_bytes(txfifo_val); + bool msb =3D !RF_RD(f, CFG, LSBF); + uint32_t val32; + + val32 =3D flexcomm_spi_xfer_word(s, data, bytes, msb); + + if (!fifo32_is_full(f->rx_fifo)) { + /* Append the mask that informs which client is active */ + val32 |=3D (ss_mask << R_FLEXCOMM_SPI_FIFORD_RXSSEL0_N_SHI= FT); + fifo32_push(f->rx_fifo, val32); + } + + /* If this is the end of the transfer raise the CS line */ + if (FIELD_EX32(txfifo_val, FLEXCOMM_SPI_FIFOWR, EOT)) { + bool spol[ARRAY_SIZE(s->cs)] =3D { + RF_RD(f, CFG, SPOL0), + RF_RD(f, CFG, SPOL1), + RF_RD(f, CFG, SPOL2), + RF_RD(f, CFG, SPOL3), + }; + + for (int i =3D 0; i < ARRAY_SIZE(s->cs); i++) { + if (s->cs_asserted[i]) { + s->cs_asserted[i] =3D false; + qemu_set_irq(s->cs[i], !spol[i]); + } + } + } + } + break; + } + default: + register_write(&ri, value, ~0, NULL, false); + break; + } + + flexcomm_spi_irq_update(f); + + return ret; +} + +static const MemoryRegionOps flexcomm_spi_ops =3D { + .read_with_attrs =3D flexcomm_spi_reg_read, + .write_with_attrs =3D flexcomm_spi_reg_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + .unaligned =3D false, + }, +}; + +static void flexcomm_spi_realize(DeviceState *dev, Error **error) +{ + FlexcommSpiState *s =3D FLEXCOMM_SPI(dev); + + s->bus =3D ssi_create_bus(DEVICE(s), "bus"); + qdev_init_gpio_out_named(DEVICE(s), s->cs, "cs", ARRAY_SIZE(s->cs)); +} + +static const VMStateDescription vmstate_flexcomm_spi =3D { + .name =3D "flexcomm-spi", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_BOOL_ARRAY(cs_asserted, FlexcommSpiState, 4), + VMSTATE_UINT32(tx_ctrl, FlexcommSpiState), + VMSTATE_END_OF_LIST() + } +}; + +static void flexcomm_spi_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + FlexcommFunctionClass *fc =3D FLEXCOMM_FUNCTION_CLASS(klass); + FlexcommSpiClass *sc =3D FLEXCOMM_SPI_CLASS(klass); + + dc->realize =3D flexcomm_spi_realize; + dc->vmsd =3D &vmstate_flexcomm_spi; + sc->select =3D fc->select; + fc->select =3D flexcomm_spi_select; + fc->name =3D "spi"; + fc->has_fifos =3D true; + fc->mmio_ops =3D &flexcomm_spi_ops; +} + +static const TypeInfo flexcomm_spi_types[] =3D { + { + .name =3D TYPE_FLEXCOMM_SPI, + .parent =3D TYPE_FLEXCOMM_FUNCTION, + .instance_size =3D sizeof(FlexcommSpiState), + .class_init =3D flexcomm_spi_class_init, + .class_size =3D sizeof(FlexcommSpiClass), + }, +}; + +DEFINE_TYPES(flexcomm_spi_types); diff --git a/hw/arm/svd/meson.build b/hw/arm/svd/meson.build index 417491cd5c..7f1c847caf 100644 --- a/hw/arm/svd/meson.build +++ b/hw/arm/svd/meson.build @@ -10,4 +10,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm-i2c', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h', '-p', 'I2C0', '-t', 'FLEXCOMM_I2C']) + run_target('svd-flexcomm-spi', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_spi.h', + '-p', 'SPI0', '-t', 'FLEXCOMM_SPI']) endif diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 9a244fa01d..b373e651e1 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -216,5 +216,6 @@ config XLNX_VERSAL_TRNG config FLEXCOMM bool select I2C + select SSI =20 source macio/Kconfig diff --git a/hw/ssi/meson.build b/hw/ssi/meson.build index b7ad7fca3b..4039e6d18d 100644 --- a/hw/ssi/meson.build +++ b/hw/ssi/meson.build @@ -13,3 +13,4 @@ system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_s= pi.c')) system_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_spi_host.c')) system_ss.add(when: 'CONFIG_BCM2835_SPI', if_true: files('bcm2835_spi.c')) system_ss.add(when: 'CONFIG_PNV_SPI', if_true: files('pnv_spi.c')) +system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_spi.c')) diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events index 089d269994..f849f1f8be 100644 --- a/hw/ssi/trace-events +++ b/hw/ssi/trace-events @@ -53,3 +53,8 @@ pnv_spi_rx_read_N2frame(void) "" pnv_spi_shift_rx(uint8_t byte, uint32_t index) "byte =3D 0x%2.2x into RDR = from payload index %d" pnv_spi_sequencer_stop_requested(const char* reason) "due to %s" pnv_spi_RDR_match(const char* result) "%s" + +# flexcomm_spi.c +flexcomm_spi_reg_read(const char *id, const char *reg_name, uint32_t addr,= uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_spi_reg_write(const char *id, const char *reg_name, uint32_t addr= , uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_spi_irq(const char *id, bool irq, bool fifoirqs, bool perirqs, bo= ol enabled) "%s: %d %d %d %d" --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687839; cv=none; d=zohomail.com; s=zohoarc; b=iu021vYH/RY647tvfOdEfov5Oo/yQUkywSzFeWODk3S9oVAjL0d5PcmgGOrEZ8Luo+XQ+pN6bmEpZePE8nNXQA7+ERx/bNxBzKRCkD54Zc2QazfqVU5mGMUZrYgH1b/y31UEzVaOdwypc4Ue86OQam5jnbswxbORXeE7VyBgjW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687839; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HAeQSkzCEZePNcBoJDM3Baj/gg8gWSiJ00m+9JcT8kk=; b=cnMPrL0l29vr3PyMH954tsdnm8FP5MOm3TFmgw53oKISnS6G2vJNUL5+pGX6V1w+P2DO5UGkjFfSIxDoMsIAdKjlWgT28F0g0gFfhb0ipa/zskySSlxgPuPx5CqSk6B1/8NeC3oscQgUEaxpXK4wzcNBh4cxTFkVj3+3Vgll1YY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172668783969853.43571460582871; Wed, 18 Sep 2024 12:30:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gu-0005F3-Ai; Wed, 18 Sep 2024 15:23:28 -0400 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 <3oijrZgUKCt0S9UHOFNNFKD.BNLPDLT-CDUDKMNMFMT.NQF@flex--tavip.bounces.google.com>) id 1sr0Gq-0004yk-FN for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:24 -0400 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3oijrZgUKCt0S9UHOFNNFKD.BNLPDLT-CDUDKMNMFMT.NQF@flex--tavip.bounces.google.com>) id 1sr0Gj-0007LO-6U for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:24 -0400 Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-7190c5e73cdso70076b3a.0 for ; Wed, 18 Sep 2024 12:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687396; x=1727292196; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HAeQSkzCEZePNcBoJDM3Baj/gg8gWSiJ00m+9JcT8kk=; b=La1t+hQSvIpIzhNkt4ZK2cZOodFfJoYMEaNucVtqEDLJrIVfZLzMT2x55JXZh4tLB/ 4WwdcSjH5TiyokSZ3GqKvgF/ylCHPBza5mCEUaAwm1LRkpNsILZw/eMTSgLjbOSxC44y wpVDZ8dqarkuc1jBLi+D1cCFZ3Gx46IO9fvU797MLZJzOw68cgM3gDhvE5QBDmfr66AE 9vfmj3APyEo7TXPlZfOLe8TgtCr2QKsPm0CGYR5sNQksS+9XLpXKFSZB3dCDYNkGBqLg 1VmXT2GWX9wlUP/lDjLNawfprf5Gv78NSZidQb004WAxrl4kjC0TKCNfjEUjwWlcudxj 4Rlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687396; x=1727292196; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HAeQSkzCEZePNcBoJDM3Baj/gg8gWSiJ00m+9JcT8kk=; b=DvXUU/7ZV8YT2CXCvW1NC39N83lKvgZsd/c+pNlF8lnlRYhzdXesVK6bphy0KmL9cV KFo0iFGlzTHjQqH27FfbHxnTuQKM+bGxuQnys52JnihZm+BvNdqJyij3BEi1TF05DtEB exh/2Hra/4/S2XaJdTN88XoquqaqCArH83Dg3INhZ8o7vSjLjuH/Fl1ek29NdMrOIVvb PnbhJ1n8vKJlUK0nhdR430OltdDJIEFxBAeEL8xxv9o75FkBlf5oLsHET/mH9pP6qSlX eL2pSu9y8mJzqJUqoeLVtSIsMHInljgA7NVzsGsLJKa6ay7Oy+xTjwUpv4CFtr6PpMxQ K9ZA== X-Gm-Message-State: AOJu0YxKGpi+GA3f/GBw7VpkrXQ7kCeLconLtsyZnAvWWTTU8ba+QOdL 4i07Uf+cJEJHB7FxC55JrMnAq0Vs/YVC4VoStZma1lUZfeFTprrgutfchqMSd/pIyanx8/N5OaN qZI1TRO+lAxuKHU6pZNRUNry3oj18mrE+B68CelQrnKp71tKHp5SLy5HaSAziRzWCc0x+LQnq+H NNa0HFi2xzBY64dV2LxSKKExAcQg== X-Google-Smtp-Source: AGHT+IH/spwBa/RW2I4havofNbqgYsgAOCFZH9EYDh4e0eOpSDIEzvZpVU3Q0GkyWPVOI4PV3m3Ed4U+Kg== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a62:e20d:0:b0:714:1436:1cef with SMTP id d2e1a72fcca58-719263496a4mr52109b3a.6.1726687394459; Wed, 18 Sep 2024 12:23:14 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:38 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-11-tavip@google.com> Subject: [PATCH 10/25] hw/misc: add support for RT500's clock controller From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::44a; envelope-from=3oijrZgUKCt0S9UHOFNNFKD.BNLPDLT-CDUDKMNMFMT.NQF@flex--tavip.bounces.google.com; helo=mail-pf1-x44a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, UPPERCASE_50_75=0.008, USER_IN_DEF_DKIM_WL=-7.5 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687840518116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It supports system and audio PLL initialization and SYSTICK and OSTIMER clock source selection. The patch includes automatically generated headers which contains the register layout and helpers. The headers can be regenerated with the svd-rt500-clkctl0 and svd-rt500-clkctl1 targets when the build is configured with --enable-mcux-soc-svd. Signed-off-by: Octavian Purdila --- include/hw/arm/svd/rt500_clkctl0.h | 2483 ++++++++++++++++++++ include/hw/arm/svd/rt500_clkctl1.h | 3396 ++++++++++++++++++++++++++++ include/hw/misc/rt500_clk_freqs.h | 18 + include/hw/misc/rt500_clkctl0.h | 35 + include/hw/misc/rt500_clkctl1.h | 36 + hw/misc/rt500_clkctl0.c | 253 +++ hw/misc/rt500_clkctl1.c | 238 ++ hw/arm/Kconfig | 5 + hw/arm/svd/meson.build | 6 + hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/trace-events | 8 + 12 files changed, 6482 insertions(+) create mode 100644 include/hw/arm/svd/rt500_clkctl0.h create mode 100644 include/hw/arm/svd/rt500_clkctl1.h create mode 100644 include/hw/misc/rt500_clk_freqs.h create mode 100644 include/hw/misc/rt500_clkctl0.h create mode 100644 include/hw/misc/rt500_clkctl1.h create mode 100644 hw/misc/rt500_clkctl0.c create mode 100644 hw/misc/rt500_clkctl1.c diff --git a/include/hw/arm/svd/rt500_clkctl0.h b/include/hw/arm/svd/rt500_= clkctl0.h new file mode 100644 index 0000000000..b5c86eed3e --- /dev/null +++ b/include/hw/arm/svd/rt500_clkctl0.h @@ -0,0 +1,2483 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#include "hw/register.h" + +/* Clock Controller 0 */ +#define RT500_CLKCTL0_REGS_NO (490) + +/* Clock Control 0 */ +REG32(RT500_CLKCTL0_PSCCTL0, 16); +/* DSP clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, DSP_CLK, 1, 1); +/* 128KB ROM Controller clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, ROM_CTRLR_CLK, 2, 1); +/* AXI Switch clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, AXI_SWITCH_CLK, 3, 1); +/* AXI Controller clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, AXI_CTLR_CLK, 4, 1); +/* POWERQUAD clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, POWERQUAD_CLK, 8, 1); +/* CASPER clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, CASPER_CLK, 9, 1); +/* HASHCRYPT clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, HASHCRYPT_CLK, 10, 1); +/* PUF clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, PUF_CLK, 11, 1); +/* Random Number Generator (RNG) clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, RNG_CLK, 12, 1); +/* FLEXSPI0 / OTFAD clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, FLEXSPI0_OTFAD_CLK, 16, 1); +/* OTP Controller clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, OTP_CTLR_CLK, 17, 1); +/* FLEXSPI1 clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, FLEXSPI1_CLK, 18, 1); +/* USB HS PHY clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, USBHS_PHY_CLK, 20, 1); +/* USB HS Device clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, USBHS_DEVICE_CLK, 21, 1); +/* USB HS Host clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, USBHS_HOST_CLK, 22, 1); +/* USB HS SRAM clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, USBHS_SRAM_CLK, 23, 1); +/* SCT clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, SCT_CLK, 24, 1); +/* GPU clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, GPU_CLK, 26, 1); +/* Display Controller clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, DISPLAY_CTLR_CLK, 27, 1); +/* MIPI-DSI Controller clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, MIPI_DSI_CTLR_CLK, 28, 1); +/* Smart DMA clock control */ +FIELD(RT500_CLKCTL0_PSCCTL0, SMARTDMA_CLK, 30, 1); + +/* Clock Control 1 */ +REG32(RT500_CLKCTL0_PSCCTL1, 20); +/* SDIO0 clock control */ +FIELD(RT500_CLKCTL0_PSCCTL1, SDIO0_CLK, 2, 1); +/* SDIO1 clock control */ +FIELD(RT500_CLKCTL0_PSCCTL1, SDIO1_CLK, 3, 1); +/* ACMP0 clock control */ +FIELD(RT500_CLKCTL0_PSCCTL1, ACMP0_CLK, 15, 1); +/* ADC0 clock control */ +FIELD(RT500_CLKCTL0_PSCCTL1, ADC0_CLK, 16, 1); +/* SHSGPIO0 clock control */ +FIELD(RT500_CLKCTL0_PSCCTL1, SHSGPIO0_CLK, 24, 1); + +/* Clock Control 2 */ +REG32(RT500_CLKCTL0_PSCCTL2, 24); +/* Micro-Tick Timer 0 clock control */ +FIELD(RT500_CLKCTL0_PSCCTL2, UTICK0_CLK, 0, 1); +/* Watchdog Timer 0 clock control */ +FIELD(RT500_CLKCTL0_PSCCTL2, WWDT0_CLK, 1, 1); +/* Power Management Controller clock control */ +FIELD(RT500_CLKCTL0_PSCCTL2, PMC_CLK, 29, 1); + +/* Clock Control 0 Set */ +REG32(RT500_CLKCTL0_PSCCTL0_SET, 64); +/* DSP clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, DSP_CLK, 1, 1); +/* 128KB ROM Controller clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, ROM_CTRLR_CLK, 2, 1); +/* AXI Switch clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, AXI_SWITCH_CLK, 3, 1); +/* AXI Controller clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, AXI_CTLR_CLK, 4, 1); +/* POWERQUAD clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, POWERQUAD_CLK, 8, 1); +/* CASPER clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, CASPER_CLK, 9, 1); +/* HASHCRYPT clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, HASHCRYPT_CLK, 10, 1); +/* PUF clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, PUF_CLK, 11, 1); +/* Random Number Generator (RNG) clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, RNG_CLK, 12, 1); +/* FLEXSPI0 / OTFAD clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, FLEXSPI0_OTFAD_CLK, 16, 1); +/* OTP Controller clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, OTP_CTLR_CLK, 17, 1); +/* FLEXSPI1 clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, FLEXSPI1_CLK, 18, 1); +/* USB HS PHY clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, USBHS_PHY_CLK, 20, 1); +/* USB HS Device clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, USBHS_DEVICE_CLK, 21, 1); +/* USB HS Host clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, USBHS_HOST_CLK, 22, 1); +/* USB HS SRAM clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, USBHS_SRAM_CLK, 23, 1); +/* SCT clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, SCT_CLK, 24, 1); +/* GPU clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, GPU_CLK, 26, 1); +/* Display Controller clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, DISPLAY_CTLR_CLK, 27, 1); +/* MIPI-DSI Controller clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, MIPI_DSI_CTLR_CLK, 28, 1); +/* Smart DMA clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_SET, SMARTDMA_CLK, 30, 1); + +/* Clock Control 1 Set */ +REG32(RT500_CLKCTL0_PSCCTL1_SET, 68); +/* SDIO0 clock set */ +FIELD(RT500_CLKCTL0_PSCCTL1_SET, SDIO0_CLK, 2, 1); +/* SDIO1 clock set */ +FIELD(RT500_CLKCTL0_PSCCTL1_SET, SDIO1_CLK, 3, 1); +/* ACMP0 clock set */ +FIELD(RT500_CLKCTL0_PSCCTL1_SET, ACMP0_CLK, 15, 1); +/* ADC0 clock set */ +FIELD(RT500_CLKCTL0_PSCCTL1_SET, ADC0_CLK, 16, 1); +/* SHSGPIO0 clock set */ +FIELD(RT500_CLKCTL0_PSCCTL1_SET, SHSGPIO0_CLK, 24, 1); + +/* Clock Control 2 Set */ +REG32(RT500_CLKCTL0_PSCCTL2_SET, 72); +/* Micro-Tick Timer 0 clock set */ +FIELD(RT500_CLKCTL0_PSCCTL2_SET, UTICK0_CLK, 0, 1); +/* Watchdog Timer 0 clock set */ +FIELD(RT500_CLKCTL0_PSCCTL2_SET, WWDT0_CLK, 1, 1); +/* Power Management Controller clock set */ +FIELD(RT500_CLKCTL0_PSCCTL2_SET, PMC, 29, 1); + +/* Clock Control 0 Clear */ +REG32(RT500_CLKCTL0_PSCCTL0_CLR, 112); +/* DSP clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, DSP_CLK, 1, 1); +/* 128KB ROM Controller clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, ROM_CTRLR_CLK, 2, 1); +/* AXI Switch clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, AXI_SWITCH_CLK, 3, 1); +/* AXI Controller clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, AXI_CTLR_CLK, 4, 1); +/* POWERQUAD clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, POWERQUAD_CLK, 8, 1); +/* CASPER clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, CASPER_CLK, 9, 1); +/* HASHCRYPT clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, HASHCRYPT_CLK, 10, 1); +/* PUF clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, PUF_CLK, 11, 1); +/* RNG clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, RNG_CLK, 12, 1); +/* FLEXSPI0 / OTFAD clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, FLEXSPI0_OTFAD_CLK, 16, 1); +/* OTP Controller clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, OTP_CTLR_CLK, 17, 1); +/* FLEXSPI1 clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, FLEXSPI1_CLK, 18, 1); +/* USB HS PHY clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, USBHS_PHY_CLK, 20, 1); +/* USB HS Device clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, USBHS_DEVICE_CLK, 21, 1); +/* USB HS Host clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, USBHS_HOST_CLK, 22, 1); +/* USB HS SRAM clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, USBHS_SRAM_CLK, 23, 1); +/* SCT clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, SCT_CLK, 24, 1); +/* GPU clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, GPU_CLK, 26, 1); +/* Display Controller clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, DISPLAY_CTLR_CLK, 27, 1); +/* MIPI-DSI Controller clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, MIPI_DSI_CTLR_CLK, 28, 1); +/* Smart DMA clock set */ +FIELD(RT500_CLKCTL0_PSCCTL0_CLR, SMARTDMA_CLK, 30, 1); + +/* Clock Control 1 Clear */ +REG32(RT500_CLKCTL0_PSCCTL1_CLR, 116); +/* SDIO0 clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL1_CLR, SDIO0_CLK, 2, 1); +/* SDIO1 clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL1_CLR, SDIO1_CLK, 3, 1); +/* ACMP0 clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL1_CLR, ACMP0_CLK, 15, 1); +/* ADC0 clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL1_CLR, ADC0_CLK, 16, 1); +/* SHSGPIO0 clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL1_CLR, SHSGPIO0_CLK, 24, 1); + +/* Clock Control 2 Clear */ +REG32(RT500_CLKCTL0_PSCCTL2_CLR, 120); +/* Micro-Tick Timer 0 clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL2_CLR, UTICK0_CLK, 0, 1); +/* Watchdog Timer 0 clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL2_CLR, WWDT0_CLK, 1, 1); +/* Power Management Controller clock clear */ +FIELD(RT500_CLKCTL0_PSCCTL2_CLR, PMC_CLK, 29, 1); + +/* Free Running Oscillator Control */ +REG32(RT500_CLKCTL0_FRO_CONTROL, 128); +/* Expected Count */ +FIELD(RT500_CLKCTL0_FRO_CONTROL, EXP_COUNT, 0, 16); +/* Threshold Range Upper Limit */ +FIELD(RT500_CLKCTL0_FRO_CONTROL, THRESH_RANGE_UP, 16, 5); +/* Threshold Range Lower Limit */ +FIELD(RT500_CLKCTL0_FRO_CONTROL, THRESH_RANGE_LOW, 21, 5); +/* Enable Tuning */ +FIELD(RT500_CLKCTL0_FRO_CONTROL, ENA_TUNE, 31, 1); + +/* Free Running Oscillator Captured Value */ +REG32(RT500_CLKCTL0_FRO_CAPVAL, 132); +/* Captured Value */ +FIELD(RT500_CLKCTL0_FRO_CAPVAL, CAPVAL, 0, 16); +/* Data Valid */ +FIELD(RT500_CLKCTL0_FRO_CAPVAL, DATA_VALID, 31, 1); + +/* Free Running Oscillator Trim */ +REG32(RT500_CLKCTL0_FRO_RDTRIM, 140); +/* It is the trim value supplied to the oscillator */ +FIELD(RT500_CLKCTL0_FRO_RDTRIM, TRIM, 0, 11); + +/* Free Running OscillatorSC Trim */ +REG32(RT500_CLKCTL0_FRO_SCTRIM, 144); +/* sc_trim value for the oscillator. */ +FIELD(RT500_CLKCTL0_FRO_SCTRIM, TRIM, 0, 6); + +/* FRO Clock Divider */ +REG32(RT500_CLKCTL0_FRODIVSEL, 264); +/* Select clock */ +FIELD(RT500_CLKCTL0_FRODIVSEL, SEL, 0, 2); + +/* FRO Clock Status */ +REG32(RT500_CLKCTL0_FROCLKSTATUS, 268); +/* FRO Clock OK */ +FIELD(RT500_CLKCTL0_FROCLKSTATUS, CLK_OK, 0, 1); + +/* FRO Enable Register */ +REG32(RT500_CLKCTL0_FRODIVOEN, 272); +/* FRO Divided-by-1 Clock Enable */ +FIELD(RT500_CLKCTL0_FRODIVOEN, FRO_DIV1_O_EN, 0, 1); +/* FRO Divided-by-2 Clock Enable */ +FIELD(RT500_CLKCTL0_FRODIVOEN, FRO_DIV2_O_EN, 1, 1); +/* FRO Divided-by-4 Clock Enable */ +FIELD(RT500_CLKCTL0_FRODIVOEN, FRO_DIV4_O_EN, 2, 1); +/* FRO Divided-by-8 Clock Enable */ +FIELD(RT500_CLKCTL0_FRODIVOEN, FRO_DIV8_O_EN, 3, 1); +/* FRO Divided-by-16 Clock Enable */ +FIELD(RT500_CLKCTL0_FRODIVOEN, FRO_DIV16_O_EN, 4, 1); + +/* Low Frequency Clock Divider */ +REG32(RT500_CLKCTL0_LOWFREQCLKDIV, 304); +/* Low Frequency Clock Divider Value */ +FIELD(RT500_CLKCTL0_LOWFREQCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_LOWFREQCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_LOWFREQCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL0_LOWFREQCLKDIV, REQFLAG, 31, 1); + +/* System Oscillator Control 0 */ +REG32(RT500_CLKCTL0_SYSOSCCTL0, 352); +/* Low Power Mode Enable */ +FIELD(RT500_CLKCTL0_SYSOSCCTL0, LP_ENABLE, 0, 1); +/* Bypass Enable */ +FIELD(RT500_CLKCTL0_SYSOSCCTL0, BYPASS_ENABLE, 1, 1); + +/* OSC Clock Source Select */ +REG32(RT500_CLKCTL0_SYSOSCBYPASS, 360); +/* Select SYSOSC Bypass */ +FIELD(RT500_CLKCTL0_SYSOSCBYPASS, SEL, 0, 3); + +/* Low Power Oscillator Control 0 */ +REG32(RT500_CLKCTL0_LPOSCCTL0, 400); +/* LPOSC Clock Ready */ +FIELD(RT500_CLKCTL0_LPOSCCTL0, CLKRDY, 31, 1); + +/* 32 KHz Oscillator Control 0 */ +REG32(RT500_CLKCTL0_OSC32KHZCTL0, 448); +/* 32 KHz Oscillator Enable */ +FIELD(RT500_CLKCTL0_OSC32KHZCTL0, ENA32KHZ, 0, 1); + +/* System PLL 0 Clock Select */ +REG32(RT500_CLKCTL0_SYSPLL0CLKSEL, 512); +/* System PLL0 Reference Input Clock Source */ +FIELD(RT500_CLKCTL0_SYSPLL0CLKSEL, SEL, 0, 3); + +/* System PLL0 Control 0 */ +REG32(RT500_CLKCTL0_SYSPLL0CTL0, 516); +/* SYSPLL0 BYPASS Mode */ +FIELD(RT500_CLKCTL0_SYSPLL0CTL0, BYPASS, 0, 1); +/* SYSPLL0 Reset */ +FIELD(RT500_CLKCTL0_SYSPLL0CTL0, RESET, 1, 1); +/* Hold Ring Off Control */ +FIELD(RT500_CLKCTL0_SYSPLL0CTL0, HOLDRINGOFF_ENA, 13, 1); +/* Multiplication Factor */ +FIELD(RT500_CLKCTL0_SYSPLL0CTL0, MULT, 16, 8); + +/* System PLL0 Lock Time Div2 */ +REG32(RT500_CLKCTL0_SYSPLL0LOCKTIMEDIV2, 524); +/* SYSPLL0 Lock Time Divide-by-2 */ +FIELD(RT500_CLKCTL0_SYSPLL0LOCKTIMEDIV2, LOCKTIMEDIV2, 0, 16); + +/* System PLL0 Numerator */ +REG32(RT500_CLKCTL0_SYSPLL0NUM, 528); +/* Numerator of the SYSPLL0 fractional loop divider */ +FIELD(RT500_CLKCTL0_SYSPLL0NUM, NUM, 0, 30); + +/* System PLL0 Denominator */ +REG32(RT500_CLKCTL0_SYSPLL0DENOM, 532); +/* Denominator of the SYSPLL0 fractional loop divider */ +FIELD(RT500_CLKCTL0_SYSPLL0DENOM, DENOM, 0, 30); + +/* System PLL0 PFD */ +REG32(RT500_CLKCTL0_SYSPLL0PFD, 536); +/* PLL Fractional Divider 0 */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD0, 0, 6); +/* PFD0 Clock Ready Status Flag */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD0_CLKRDY, 6, 1); +/* PFD0 Clock Gate */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD0_CLKGATE, 7, 1); +/* PLL Fractional Divider 1 */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD1, 8, 6); +/* PFD1 Clock Ready Status Flag */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD1_CLKRDY, 14, 1); +/* PFD1 Clock Gate */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD1_CLKGATE, 15, 1); +/* PLL Fractional Divider 2 */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD2, 16, 6); +/* PFD2 Clock Ready Status Flag */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD2_CLKRDY, 22, 1); +/* PFD2 Clock Gate */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD2_CLKGATE, 23, 1); +/* PLL Fractional Divider 3 */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD3, 24, 6); +/* PFD3 Clock Ready Status Flag */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD3_CLKRDY, 30, 1); +/* PFD3 Clock Gate */ +FIELD(RT500_CLKCTL0_SYSPLL0PFD, PFD3_CLKGATE, 31, 1); + +/* Main PLL Clock Divider */ +REG32(RT500_CLKCTL0_MAINPLLCLKDIV, 576); +/* Low Frequency Clock Divider Value */ +FIELD(RT500_CLKCTL0_MAINPLLCLKDIV, DIV, 0, 8); +/* Resets the divider counter */ +FIELD(RT500_CLKCTL0_MAINPLLCLKDIV, RESET, 29, 1); +/* Halts the divider counter */ +FIELD(RT500_CLKCTL0_MAINPLLCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_MAINPLLCLKDIV, REQFLAG, 31, 1); + +/* DSP PLL Clock Divider */ +REG32(RT500_CLKCTL0_DSPPLLCLKDIV, 580); +/* Low Frequency Clock Divider Value */ +FIELD(RT500_CLKCTL0_DSPPLLCLKDIV, DIV, 0, 8); +/* Resets the divider counter */ +FIELD(RT500_CLKCTL0_DSPPLLCLKDIV, RESET, 29, 1); +/* Halts the divider counter */ +FIELD(RT500_CLKCTL0_DSPPLLCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_DSPPLLCLKDIV, REQFLAG, 31, 1); + +/* AUX0 PLL Clock Divider */ +REG32(RT500_CLKCTL0_AUX0PLLCLKDIV, 584); +/* Low Frequency Clock Divider Value */ +FIELD(RT500_CLKCTL0_AUX0PLLCLKDIV, DIV, 0, 8); +/* Resets the divider counter */ +FIELD(RT500_CLKCTL0_AUX0PLLCLKDIV, RESET, 29, 1); +/* Halts the divider counter */ +FIELD(RT500_CLKCTL0_AUX0PLLCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_AUX0PLLCLKDIV, REQFLAG, 31, 1); + +/* AUX1 PLL Clock Divider */ +REG32(RT500_CLKCTL0_AUX1PLLCLKDIV, 588); +/* Low Frequency Clock Divider Value */ +FIELD(RT500_CLKCTL0_AUX1PLLCLKDIV, DIV, 0, 8); +/* Resets the divider counter */ +FIELD(RT500_CLKCTL0_AUX1PLLCLKDIV, RESET, 29, 1); +/* Halts the divider counter */ +FIELD(RT500_CLKCTL0_AUX1PLLCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_AUX1PLLCLKDIV, REQFLAG, 31, 1); + +/* System CPU AHB Clock Divider */ +REG32(RT500_CLKCTL0_SYSCPUAHBCLKDIV, 1024); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_SYSCPUAHBCLKDIV, DIV, 0, 8); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_SYSCPUAHBCLKDIV, REQFLAG, 31, 1); + +/* Main Clock Select A */ +REG32(RT500_CLKCTL0_MAINCLKSELA, 1072); +/* Control Main 1st Stage Control Clock Source */ +FIELD(RT500_CLKCTL0_MAINCLKSELA, SEL, 0, 2); + +/* Main Clock Select B */ +REG32(RT500_CLKCTL0_MAINCLKSELB, 1076); +/* Main Clock Source Selection */ +FIELD(RT500_CLKCTL0_MAINCLKSELB, SEL, 0, 2); + +/* PFC divider 0 (trace clock) */ +REG32(RT500_CLKCTL0_PFC0DIV, 1280); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_PFC0DIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_PFC0DIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_PFC0DIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_PFC0DIV, REQFLAG, 31, 1); + +/* PFC divider 1 (USB HS PHY bus clock) */ +REG32(RT500_CLKCTL0_PFC1DIV, 1284); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_PFC1DIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_PFC1DIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_PFC1DIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_PFC1DIV, REQFLAG, 31, 1); + +/* FlexSPI0 Functional Clock Select */ +REG32(RT500_CLKCTL0_FLEXSPI0FCLKSEL, 1568); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_FLEXSPI0FCLKSEL, SEL, 0, 3); + +/* FlexSPI0 Functional Clock Divider */ +REG32(RT500_CLKCTL0_FLEXSPI0FCLKDIV, 1572); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_FLEXSPI0FCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_FLEXSPI0FCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_FLEXSPI0FCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_FLEXSPI0FCLKDIV, REQFLAG, 31, 1); + +/* FlexSPI1 Functional Clock Select */ +REG32(RT500_CLKCTL0_FLEXSPI1FCLKSEL, 1584); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_FLEXSPI1FCLKSEL, SEL, 0, 3); + +/* FlexSPI1 Functional Clock Divider */ +REG32(RT500_CLKCTL0_FLEXSPI1FCLKDIV, 1588); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_FLEXSPI1FCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_FLEXSPI1FCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_FLEXSPI1FCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_FLEXSPI1FCLKDIV, REQFLAG, 31, 1); + +/* SCT Functional Clock Select */ +REG32(RT500_CLKCTL0_SCTFCLKSEL, 1600); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_SCTFCLKSEL, SEL, 0, 3); + +/* SCT Functional Clock Divider */ +REG32(RT500_CLKCTL0_SCTIN7CLKDIV, 1604); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_SCTIN7CLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_SCTIN7CLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_SCTIN7CLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_SCTIN7CLKDIV, REQFLAG, 31, 1); + +/* High Speed USB Functional Clock Select */ +REG32(RT500_CLKCTL0_USBHSFCLKSEL, 1632); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_USBHSFCLKSEL, SEL, 0, 3); + +/* High Speed USB Functional Clock Divider */ +REG32(RT500_CLKCTL0_USBHSFCLKDIV, 1636); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_USBHSFCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_USBHSFCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_USBHSFCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_USBHSFCLKDIV, REQFLAG, 31, 1); + +/* SDIO0 Functional Clock Select */ +REG32(RT500_CLKCTL0_SDIO0FCLKSEL, 1664); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_SDIO0FCLKSEL, SEL, 0, 3); + +/* SDIO0 Functional Clock Divider */ +REG32(RT500_CLKCTL0_SDIO0FCLKDIV, 1668); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_SDIO0FCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_SDIO0FCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_SDIO0FCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_SDIO0FCLKDIV, REQFLAG, 31, 1); + +/* SDIO1 Functional Clock Select */ +REG32(RT500_CLKCTL0_SDIO1FCLKSEL, 1680); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_SDIO1FCLKSEL, SEL, 0, 3); + +/* SDIO1 Functional Clock Divider */ +REG32(RT500_CLKCTL0_SDIO1FCLKDIV, 1684); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_SDIO1FCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_SDIO1FCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_SDIO1FCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_SDIO1FCLKDIV, REQFLAG, 31, 1); + +/* ADC0 Functional Clock Select 0 */ +REG32(RT500_CLKCTL0_ADC0FCLKSEL0, 1744); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_ADC0FCLKSEL0, SEL, 0, 3); + +/* ADC0 Functional Clock Select 1 */ +REG32(RT500_CLKCTL0_ADC0FCLKSEL1, 1748); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_ADC0FCLKSEL1, SEL, 0, 3); + +/* ADC0 Functional Clock Divider */ +REG32(RT500_CLKCTL0_ADC0FCLKDIV, 1752); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_ADC0FCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_ADC0FCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_ADC0FCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_ADC0FCLKDIV, REQFLAG, 31, 1); + +/* UTICK Functional Clock Select */ +REG32(RT500_CLKCTL0_UTICKFCLKSEL, 1792); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_UTICKFCLKSEL, SEL, 0, 3); + +/* WDT0 Functional Clock Select */ +REG32(RT500_CLKCTL0_WDT0FCLKSEL, 1824); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_WDT0FCLKSEL, SEL, 0, 3); + +/* 32 KHz Wake Clock Source Select */ +REG32(RT500_CLKCTL0_A32KHZWAKECLKSEL, 1840); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_A32KHZWAKECLKSEL, SEL, 0, 3); + +/* 32 KHz Wake Clock Divider */ +REG32(RT500_CLKCTL0_A32KHZWAKECLKDIV, 1844); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_A32KHZWAKECLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_A32KHZWAKECLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_A32KHZWAKECLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_A32KHZWAKECLKDIV, REQFLAG, 31, 1); + +/* SYSTICK Functional Clock Select */ +REG32(RT500_CLKCTL0_SYSTICKFCLKSEL, 1888); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_SYSTICKFCLKSEL, SEL, 0, 3); + +/* SYSTICK Functional Clock Divider */ +REG32(RT500_CLKCTL0_SYSTICKFCLKDIV, 1892); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_SYSTICKFCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_SYSTICKFCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_SYSTICKFCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_SYSTICKFCLKDIV, REQFLAG, 31, 1); + +/* MIPI-DSI PHY Clock Select */ +REG32(RT500_CLKCTL0_DPHYCLKSEL, 1904); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_DPHYCLKSEL, SEL, 0, 3); + +/* MIPI-DSI PHY Clock Divider */ +REG32(RT500_CLKCTL0_DPHYCLKDIV, 1908); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_DPHYCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_DPHYCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_DPHYCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_DPHYCLKDIV, REQFLAG, 31, 1); + +/* MIPI-DSI DPHY Escape Mode Clock Select */ +REG32(RT500_CLKCTL0_DPHYESCCLKSEL, 1912); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_DPHYESCCLKSEL, SEL, 0, 3); + +/* MIPI-DSI DPHY Escape Mode Receive Clock Divider */ +REG32(RT500_CLKCTL0_DPHYESCRXCLKDIV, 1916); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_DPHYESCRXCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_DPHYESCRXCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_DPHYESCRXCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_DPHYESCRXCLKDIV, REQFLAG, 31, 1); + +/* MIPI-DSI DPHY Escape Mode Tramsmit Clock Divider */ +REG32(RT500_CLKCTL0_DPHYESCTXCLKDIV, 1920); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_DPHYESCTXCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_DPHYESCTXCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_DPHYESCTXCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_DPHYESCTXCLKDIV, REQFLAG, 31, 1); + +/* GPU Clock Select */ +REG32(RT500_CLKCTL0_GPUCLKSEL, 1936); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_GPUCLKSEL, SEL, 0, 3); + +/* GPU Clock Divider */ +REG32(RT500_CLKCTL0_GPUCLKDIV, 1940); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_GPUCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_GPUCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_GPUCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_GPUCLKDIV, REQFLAG, 31, 1); + +/* LCDIF Pixel Clock Select */ +REG32(RT500_CLKCTL0_DCPIXELCLKSEL, 1952); +/* Select Clock Source */ +FIELD(RT500_CLKCTL0_DCPIXELCLKSEL, SEL, 0, 3); + +/* LCDIF Pixel Clock Divider */ +REG32(RT500_CLKCTL0_DCPIXELCLKDIV, 1956); +/* Clock Divider Value Selection */ +FIELD(RT500_CLKCTL0_DCPIXELCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL0_DCPIXELCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL0_DCPIXELCLKDIV, HALT, 30, 1); +/* Divider status flag */ +FIELD(RT500_CLKCTL0_DCPIXELCLKDIV, REQFLAG, 31, 1); + + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_DSP_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_DSP_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_DSP_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_ROM_CTRLR_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_ROM_CTRLR_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_ROM_CTRLR_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_AXI_SWITCH_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_AXI_SWITCH_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_AXI_SWITCH_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_AXI_CTLR_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_AXI_CTLR_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_AXI_CTLR_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_POWERQUAD_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_POWERQUAD_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_POWERQUAD_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_CASPER_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_CASPER_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_CASPER_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_HASHCRYPT_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_HASHCRYPT_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_HASHCRYPT_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_PUF_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_PUF_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_PUF_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_RNG_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_RNG_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_RNG_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_FLEXSPI0_OTFAD_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_FLEXSPI0_OTFAD_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_FLEXSPI0_OTFAD_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_OTP_CTLR_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_OTP_CTLR_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_OTP_CTLR_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_FLEXSPI1_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_FLEXSPI1_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_FLEXSPI1_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_USBHS_PHY_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_USBHS_PHY_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_USBHS_PHY_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_USBHS_DEVICE_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_USBHS_DEVICE_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_USBHS_DEVICE_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_USBHS_HOST_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_USBHS_HOST_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_USBHS_HOST_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_USBHS_SRAM_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_USBHS_SRAM_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_USBHS_SRAM_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_SCT_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_SCT_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_SCT_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_GPU_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_GPU_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_GPU_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_DISPLAY_CTLR_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_DISPLAY_CTLR_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_DISPLAY_CTLR_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_MIPI_DSI_CTLR_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_MIPI_DSI_CTLR_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_MIPI_DSI_CTLR_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL0_SMARTDMA_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL0_SMARTDMA_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL0_SMARTDMA_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL1_SDIO0_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL1_SDIO0_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL1_SDIO0_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL1_SDIO1_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL1_SDIO1_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL1_SDIO1_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL1_ACMP0_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL1_ACMP0_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL1_ACMP0_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL1_ADC0_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL1_ADC0_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL1_ADC0_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL1_SHSGPIO0_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL1_SHSGPIO0_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL1_SHSGPIO0_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL2_UTICK0_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL2_UTICK0_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL2_UTICK0_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL2_WWDT0_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL2_WWDT0_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL2_WWDT0_CLK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_PSCCTL2_PMC_CLK_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_PSCCTL2_PMC_CLK_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_PSCCTL2_PMC_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_DSP_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_DSP_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_DSP_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_ROM_CTRLR_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_ROM_CTRLR_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_ROM_CTRLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_AXI_SWITCH_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_AXI_SWITCH_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_AXI_SWITCH_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_AXI_CTLR_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_AXI_CTLR_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_AXI_CTLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_POWERQUAD_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_POWERQUAD_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_POWERQUAD_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_CASPER_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_CASPER_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_CASPER_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_HASHCRYPT_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_HASHCRYPT_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_HASHCRYPT_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_PUF_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_PUF_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_PUF_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_RNG_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_RNG_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_RNG_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI0_OTFAD_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI0_OTFAD_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI0_OTFAD_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_OTP_CTLR_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_OTP_CTLR_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_OTP_CTLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI1_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI1_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_USBHS_PHY_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_USBHS_PHY_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_USBHS_PHY_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_USBHS_DEVICE_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_USBHS_DEVICE_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_USBHS_DEVICE_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_USBHS_HOST_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_USBHS_HOST_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_USBHS_HOST_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_USBHS_SRAM_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_USBHS_SRAM_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_USBHS_SRAM_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_SCT_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_SCT_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_SCT_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_GPU_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_GPU_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_GPU_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_DISPLAY_CTLR_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_DISPLAY_CTLR_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_DISPLAY_CTLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_MIPI_DSI_CTLR_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_MIPI_DSI_CTLR_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_MIPI_DSI_CTLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_SET_SMARTDMA_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_SET_SMARTDMA_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL0_SET_SMARTDMA_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_SET_SDIO0_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_SET_SDIO0_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL1_SET_SDIO0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_SET_SDIO1_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_SET_SDIO1_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL1_SET_SDIO1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_SET_ACMP0_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_SET_ACMP0_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL1_SET_ACMP0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_SET_ADC0_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_SET_ADC0_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL1_SET_ADC0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_SET_SHSGPIO0_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_SET_SHSGPIO0_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL1_SET_SHSGPIO0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL2_SET_UTICK0_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL2 register */ + RT500_CLKCTL0_PSCCTL2_SET_UTICK0_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL2_SET_UTICK0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL2_SET_WWDT0_CLK_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL2 register */ + RT500_CLKCTL0_PSCCTL2_SET_WWDT0_CLK_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL2_SET_WWDT0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL2_SET_PMC_NO_EFFECT =3D 0, + /* Sets the corresponding bit in PSCCTL2 register */ + RT500_CLKCTL0_PSCCTL2_SET_PMC_CLK_ENABLE_SET =3D 1, +} RT500_CLKCTL0_PSCCTL2_SET_PMC_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_DSP_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_DSP_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_DSP_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_ROM_CTRLR_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_ROM_CTRLR_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_ROM_CTRLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_AXI_SWITCH_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_AXI_SWITCH_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_AXI_SWITCH_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_AXI_CTLR_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_AXI_CTLR_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_AXI_CTLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_POWERQUAD_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_POWERQUAD_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_POWERQUAD_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_CASPER_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_CASPER_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_CASPER_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_HASHCRYPT_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_HASHCRYPT_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_HASHCRYPT_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_PUF_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_PUF_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_PUF_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_RNG_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_RNG_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_RNG_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI0_OTFAD_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI0_OTFAD_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI0_OTFAD_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_OTP_CTLR_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_OTP_CTLR_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_OTP_CTLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI1_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI1_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_USBHS_PHY_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_USBHS_PHY_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_USBHS_PHY_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_USBHS_DEVICE_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_USBHS_DEVICE_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_USBHS_DEVICE_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_USBHS_HOST_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_USBHS_HOST_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_USBHS_HOST_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_USBHS_SRAM_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_USBHS_SRAM_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_USBHS_SRAM_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_SCT_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_SCT_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_SCT_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_GPU_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_GPU_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_GPU_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_DISPLAY_CTLR_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_DISPLAY_CTLR_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_DISPLAY_CTLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_MIPI_DSI_CTLR_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_MIPI_DSI_CTLR_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_MIPI_DSI_CTLR_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL0_CLR_SMARTDMA_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL0 register */ + RT500_CLKCTL0_PSCCTL0_CLR_SMARTDMA_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL0_CLR_SMARTDMA_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_CLR_SDIO0_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_CLR_SDIO0_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL1_CLR_SDIO0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_CLR_SDIO1_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_CLR_SDIO1_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL1_CLR_SDIO1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_CLR_ACMP0_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_CLR_ACMP0_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL1_CLR_ACMP0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_CLR_ADC0_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_CLR_ADC0_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL1_CLR_ADC0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL1_CLR_SHSGPIO0_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL1 register */ + RT500_CLKCTL0_PSCCTL1_CLR_SHSGPIO0_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL1_CLR_SHSGPIO0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL2_CLR_UTICK0_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL2 register */ + RT500_CLKCTL0_PSCCTL2_CLR_UTICK0_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL2_CLR_UTICK0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL2_CLR_WWDT0_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL2 register */ + RT500_CLKCTL0_PSCCTL2_CLR_WWDT0_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL2_CLR_WWDT0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PSCCTL2_CLR_PMC_CLK_NO_EFFECT =3D 0, + /* Clears the corresponding bit in PSCCTL2 register */ + RT500_CLKCTL0_PSCCTL2_CLR_PMC_CLK_CLK_ENABLE_CLEAR =3D 1, +} RT500_CLKCTL0_PSCCTL2_CLR_PMC_CLK_Enum; + +typedef enum { + /* Stop tuning */ + RT500_CLKCTL0_FRO_CONTROL_ENA_TUNE_ENA_TUNE_CLEAR =3D 0, + /* Start tuning */ + RT500_CLKCTL0_FRO_CONTROL_ENA_TUNE_ENA_TUNE_START =3D 1, +} RT500_CLKCTL0_FRO_CONTROL_ENA_TUNE_Enum; + +typedef enum { + /* CAPVAL data is not valid */ + RT500_CLKCTL0_FRO_CAPVAL_DATA_VALID_DATA_NOT_VALID =3D 0, + /* CAPVAL data is valid */ + RT500_CLKCTL0_FRO_CAPVAL_DATA_VALID_DATA_VALID =3D 1, +} RT500_CLKCTL0_FRO_CAPVAL_DATA_VALID_Enum; + +typedef enum { + /* FRO_DIV2 */ + RT500_CLKCTL0_FRODIVSEL_SEL_DIVIDEBY2 =3D 0, + /* FRO_DIV4 */ + RT500_CLKCTL0_FRODIVSEL_SEL_DIVIDEBY4 =3D 1, + /* FRO_DIV8 */ + RT500_CLKCTL0_FRODIVSEL_SEL_DIVIDEBY8 =3D 2, + /* FRO_DIV16 */ + RT500_CLKCTL0_FRODIVSEL_SEL_DIVIDEBY16 =3D 3, +} RT500_CLKCTL0_FRODIVSEL_SEL_Enum; + +typedef enum { + /* FRO clock has not yet reached 10% frequency accuracy */ + RT500_CLKCTL0_FROCLKSTATUS_CLK_OK_CLK_NOT_OK =3D 0, + /* FRO clock has reached 10% frequency accuracy */ + RT500_CLKCTL0_FROCLKSTATUS_CLK_OK_CLK_OK =3D 1, +} RT500_CLKCTL0_FROCLKSTATUS_CLK_OK_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV1_O_EN_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV1_O_EN_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_FRODIVOEN_FRO_DIV1_O_EN_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV2_O_EN_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV2_O_EN_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_FRODIVOEN_FRO_DIV2_O_EN_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV4_O_EN_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV4_O_EN_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_FRODIVOEN_FRO_DIV4_O_EN_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV8_O_EN_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV8_O_EN_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_FRODIVOEN_FRO_DIV8_O_EN_Enum; + +typedef enum { + /* Disable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV16_O_EN_CLK_DISABLE =3D 0, + /* Enable clock */ + RT500_CLKCTL0_FRODIVOEN_FRO_DIV16_O_EN_CLK_ENABLE =3D 1, +} RT500_CLKCTL0_FRODIVOEN_FRO_DIV16_O_EN_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_LOWFREQCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_LOWFREQCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_LOWFREQCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_LOWFREQCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_LOWFREQCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_LOWFREQCLKDIV_HALT_Enum; + +typedef enum { + /* The Divider change has finished */ + RT500_CLKCTL0_LOWFREQCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed */ + RT500_CLKCTL0_LOWFREQCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL0_LOWFREQCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Enable High Gain Mode (HP) */ + RT500_CLKCTL0_SYSOSCCTL0_LP_ENABLE_HIGH_GAIN_ENABLE =3D 0, + /* Enable Low Power mode (LP) */ + RT500_CLKCTL0_SYSOSCCTL0_LP_ENABLE_LOW_POWER_ENABLE =3D 1, +} RT500_CLKCTL0_SYSOSCCTL0_LP_ENABLE_Enum; + +typedef enum { + /* Enable Normal mode. Oscillation with crystal connected. */ + RT500_CLKCTL0_SYSOSCCTL0_BYPASS_ENABLE_NORMAL_ENABLE =3D 0, + /* + * Enable Bypass mode. In this mode a clock can be directly input into= the + * XTALIN pin. + */ + RT500_CLKCTL0_SYSOSCCTL0_BYPASS_ENABLE_BYPASS_ENABLE =3D 1, +} RT500_CLKCTL0_SYSOSCCTL0_BYPASS_ENABLE_Enum; + +typedef enum { + /* Select OSC Clock */ + RT500_CLKCTL0_SYSOSCBYPASS_SEL_SYOSC_CLOCK =3D 0, + /* Select Clock IN clock */ + RT500_CLKCTL0_SYSOSCBYPASS_SEL_CLOCK_IN =3D 1, + /* None; this may be selected to reduce power when no output is needed= */ + RT500_CLKCTL0_SYSOSCBYPASS_SEL_NONE =3D 7, +} RT500_CLKCTL0_SYSOSCBYPASS_SEL_Enum; + +typedef enum { + /* LPOSC clock is not ready */ + RT500_CLKCTL0_LPOSCCTL0_CLKRDY_CLK_NOT_READY =3D 0, + /* LPOSC clock is ready */ + RT500_CLKCTL0_LPOSCCTL0_CLKRDY_CLK_READY =3D 1, +} RT500_CLKCTL0_LPOSCCTL0_CLKRDY_Enum; + +typedef enum { + /* Disable oscillator */ + RT500_CLKCTL0_OSC32KHZCTL0_ENA32KHZ_ENA32KHZ_DISABLE =3D 0, + /* Enable oscillator */ + RT500_CLKCTL0_OSC32KHZCTL0_ENA32KHZ_ENA32KHZ_ENABLE =3D 1, +} RT500_CLKCTL0_OSC32KHZCTL0_ENA32KHZ_Enum; + +typedef enum { + /* FRO_DIV8 Clock */ + RT500_CLKCTL0_SYSPLL0CLKSEL_SEL_FRRO_DIV8 =3D 0, + /* OSC_CLK clock */ + RT500_CLKCTL0_SYSPLL0CLKSEL_SEL_OSC_CLK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL0_SYSPLL0CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_SYSPLL0CLKSEL_SEL_Enum; + +typedef enum { + /* PFD outputs are PFD-programmed clocks */ + RT500_CLKCTL0_SYSPLL0CTL0_BYPASS_PFD =3D 0, + /* + * Bypass Mode: PFD outputs are sourced directly from rhe reference in= put + * clock + */ + RT500_CLKCTL0_SYSPLL0CTL0_BYPASS_BYPASS =3D 1, +} RT500_CLKCTL0_SYSPLL0CTL0_BYPASS_Enum; + +typedef enum { + /* SYSPLL0 reset is removed */ + RT500_CLKCTL0_SYSPLL0CTL0_RESET_NO_RESET =3D 0, + /* SYSPLL0 is placed into reset */ + RT500_CLKCTL0_SYSPLL0CTL0_RESET_RESET =3D 1, +} RT500_CLKCTL0_SYSPLL0CTL0_RESET_Enum; + +typedef enum { + /* Disable */ + RT500_CLKCTL0_SYSPLL0CTL0_HOLDRINGOFF_ENA_DISABLE =3D 0, + /* Enable */ + RT500_CLKCTL0_SYSPLL0CTL0_HOLDRINGOFF_ENA_ENABLE =3D 1, +} RT500_CLKCTL0_SYSPLL0CTL0_HOLDRINGOFF_ENA_Enum; + +typedef enum { + /* Multiply by 16 */ + RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV16 =3D 16, + /* Multiply by 17 */ + RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV17 =3D 17, + /* Multiply by 18 */ + RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV18 =3D 18, + /* Multiply by 19 */ + RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV19 =3D 19, + /* Multiply by 20 */ + RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV20 =3D 20, + /* Multiply by 21 */ + RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV21 =3D 21, + /* Multiply by 22 */ + RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV22 =3D 22, +} RT500_CLKCTL0_SYSPLL0CTL0_MULT_Enum; + +typedef enum { + /* PFD0 clock is not ready */ + RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKRDY_NOTREADY =3D 0, + /* PFD0 clock is ready */ + RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKRDY_READY =3D 1, +} RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKRDY_Enum; + +typedef enum { + /* PFD0 clock is not gated */ + RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKGATE_NOTGATED =3D 0, + /* PFD0 clock is gated */ + RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKGATE_GATED =3D 1, +} RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKGATE_Enum; + +typedef enum { + /* PFD1 clock is not ready */ + RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKRDY_NOTREADY =3D 0, + /* PFD1 clock is ready */ + RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKRDY_READY =3D 1, +} RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKRDY_Enum; + +typedef enum { + /* PFD1 clock is not gated */ + RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKGATE_NOTGATED =3D 0, + /* PFD1 clock is gated */ + RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKGATE_GATED =3D 1, +} RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKGATE_Enum; + +typedef enum { + /* PFD2 clock is not ready */ + RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKRDY_NOTREADY =3D 0, + /* PFD2 clock is ready */ + RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKRDY_READY =3D 1, +} RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKRDY_Enum; + +typedef enum { + /* PFD2 clock is not gated */ + RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKGATE_NOTGATED =3D 0, + /* PFD2 clock is gated */ + RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKGATE_GATED =3D 1, +} RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKGATE_Enum; + +typedef enum { + /* PFD3 clock is not ready */ + RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKRDY_NOTREADY =3D 0, + /* PFD3 clock is ready */ + RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKRDY_READY =3D 1, +} RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKRDY_Enum; + +typedef enum { + /* PFD3 clock is not gated */ + RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKGATE_NOTGATED =3D 0, + /* PFD3 clock is gated */ + RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKGATE_GATED =3D 1, +} RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKGATE_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_SYSCPUAHBCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_SYSCPUAHBCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_SYSCPUAHBCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL0_MAINCLKSELA_SEL_LPOSC =3D 0, + /* FRODIV which is the output of the FRODIVSEL mux */ + RT500_CLKCTL0_MAINCLKSELA_SEL_FRO_8 =3D 1, + /* OSC_CLK clock */ + RT500_CLKCTL0_MAINCLKSELA_SEL_OSC_CLK =3D 2, + /* FRO_DIV1 clock */ + RT500_CLKCTL0_MAINCLKSELA_SEL_FRO =3D 3, +} RT500_CLKCTL0_MAINCLKSELA_SEL_Enum; + +typedef enum { + /* MAINCLKSELA 1st Stage Clock */ + RT500_CLKCTL0_MAINCLKSELB_SEL_MAINCLKSELA =3D 0, + /* Main System PLL Clock */ + RT500_CLKCTL0_MAINCLKSELB_SEL_SYSPLL =3D 1, + /* RTC 32 KHz Clock */ + RT500_CLKCTL0_MAINCLKSELB_SEL_RTC32KHZ =3D 2, +} RT500_CLKCTL0_MAINCLKSELB_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PFC0DIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_PFC0DIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_PFC0DIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PFC0DIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_PFC0DIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_PFC0DIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_PFC0DIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_PFC0DIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_PFC0DIV_REQFLAG_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PFC1DIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_PFC1DIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_PFC1DIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_PFC1DIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_PFC1DIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_PFC1DIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_PFC1DIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_PFC1DIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_PFC1DIV_REQFLAG_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_MAIN =3D 0, + /* Main System PLL Clock */ + RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_PLL =3D 1, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_AUX0_PLL =3D 2, + /* FRO_DIV1 Clock */ + RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_FRO_192M =3D 3, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_AUX1_PLL =3D 4, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_FLEXSPI0FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_FLEXSPI0FCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_FLEXSPI0FCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_FLEXSPI0FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_FLEXSPI0FCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_FLEXSPI0FCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_FLEXSPI0FCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_FLEXSPI0FCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_FLEXSPI0FCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_MAIN =3D 0, + /* Main System PLL Clock */ + RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_PLL =3D 1, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_AUX0_PLL =3D 2, + /* FRO_DIV1 Clock */ + RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_FRO_192M =3D 3, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_AUX1_PLL =3D 4, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_FLEXSPI1FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_FLEXSPI1FCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_FLEXSPI1FCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_FLEXSPI1FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_FLEXSPI1FCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_FLEXSPI1FCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_FLEXSPI1FCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_FLEXSPI1FCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_FLEXSPI1FCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL0_SCTFCLKSEL_SEL_MAIN =3D 0, + /* Main System PLL Clock */ + RT500_CLKCTL0_SCTFCLKSEL_SEL_PLL =3D 1, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL0_SCTFCLKSEL_SEL_AUX0_PLL =3D 2, + /* FRO_DIV1 Clock */ + RT500_CLKCTL0_SCTFCLKSEL_SEL_FRO_192M =3D 3, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL0_SCTFCLKSEL_SEL_AUX1_PLL =3D 4, + /* AUDIO PLL Clock */ + RT500_CLKCTL0_SCTFCLKSEL_SEL_AUDIO_PLL =3D 5, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_SCTFCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_SCTFCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_SCTIN7CLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_SCTIN7CLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_SCTIN7CLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_SCTIN7CLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_SCTIN7CLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_SCTIN7CLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_SCTIN7CLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_SCTIN7CLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_SCTIN7CLKDIV_REQFLAG_Enum; + +typedef enum { + /* OSC_CLK Clock */ + RT500_CLKCTL0_USBHSFCLKSEL_SEL_OSC_CLK =3D 0, + /* Main Clock */ + RT500_CLKCTL0_USBHSFCLKSEL_SEL_MAIN =3D 1, + /* AUX0_PLL_CLOCK */ + RT500_CLKCTL0_USBHSFCLKSEL_SEL_AUX0_PLL_CLOCK =3D 3, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_USBHSFCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_USBHSFCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_USBHSFCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_USBHSFCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_USBHSFCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_USBHSFCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_USBHSFCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_USBHSFCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_USBHSFCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_USBHSFCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_USBHSFCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL0_SDIO0FCLKSEL_SEL_MAIN =3D 0, + /* System PLL Clock */ + RT500_CLKCTL0_SDIO0FCLKSEL_SEL_PLL =3D 1, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL0_SDIO0FCLKSEL_SEL_AUX0_PLL =3D 2, + /* FRO_DIV2 */ + RT500_CLKCTL0_SDIO0FCLKSEL_SEL_FRO_DIV2 =3D 3, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL0_SDIO0FCLKSEL_SEL_AUX1_PLL =3D 4, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_SDIO0FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_SDIO0FCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_SDIO0FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_SDIO0FCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_SDIO0FCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_SDIO0FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_SDIO0FCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_SDIO0FCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_SDIO0FCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_SDIO0FCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_SDIO0FCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL0_SDIO1FCLKSEL_SEL_MAIN =3D 0, + /* Main System PLL Clock */ + RT500_CLKCTL0_SDIO1FCLKSEL_SEL_PLL =3D 1, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL0_SDIO1FCLKSEL_SEL_AUX0_PLL =3D 2, + /* FRO_DIV2 */ + RT500_CLKCTL0_SDIO1FCLKSEL_SEL_FRO_DIV2 =3D 3, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL0_SDIO1FCLKSEL_SEL_AUX1_PLL =3D 4, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_SDIO1FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_SDIO1FCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_SDIO1FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_SDIO1FCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_SDIO1FCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_SDIO1FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_SDIO1FCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_SDIO1FCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_SDIO1FCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_SDIO1FCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_SDIO1FCLKDIV_REQFLAG_Enum; + +typedef enum { + /* OSC_CLK Clock */ + RT500_CLKCTL0_ADC0FCLKSEL0_SEL_OSC_CLK =3D 0, + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL0_ADC0FCLKSEL0_SEL_LPOSC =3D 1, + /* FRO_DIV4 */ + RT500_CLKCTL0_ADC0FCLKSEL0_SEL_FRO_DIV4 =3D 2, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_ADC0FCLKSEL0_SEL_NONE =3D 7, +} RT500_CLKCTL0_ADC0FCLKSEL0_SEL_Enum; + +typedef enum { + /* ADC0FCLKSEL0 Multiplexed Output */ + RT500_CLKCTL0_ADC0FCLKSEL1_SEL_ADC0FCLKSEL0_MUX =3D 0, + /* SYSPLL0 MAIN_CLK (PFD0 Output) */ + RT500_CLKCTL0_ADC0FCLKSEL1_SEL_SYSPLL0_MAIN =3D 1, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL0_ADC0FCLKSEL1_SEL_SYSPLL0_AUX0_PLL =3D 2, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL0_ADC0FCLKSEL1_SEL_SYSPLL0_AUX1_PLL =3D 3, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_ADC0FCLKSEL1_SEL_NONE =3D 7, +} RT500_CLKCTL0_ADC0FCLKSEL1_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_ADC0FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_ADC0FCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_ADC0FCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_ADC0FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_ADC0FCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_ADC0FCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_ADC0FCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_ADC0FCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_ADC0FCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL0_UTICKFCLKSEL_SEL_LPOSC =3D 0, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_UTICKFCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_UTICKFCLKSEL_SEL_Enum; + +typedef enum { + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL0_WDT0FCLKSEL_SEL_LPOSC =3D 0, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_WDT0FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_WDT0FCLKSEL_SEL_Enum; + +typedef enum { + /* 32 KHz */ + RT500_CLKCTL0_A32KHZWAKECLKSEL_SEL_A32KHZ =3D 0, + /* Low Power Oscillator Clock (LPOSC); divided by 32 by default */ + RT500_CLKCTL0_A32KHZWAKECLKSEL_SEL_LPOSC =3D 1, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_A32KHZWAKECLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_A32KHZWAKECLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_A32KHZWAKECLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_A32KHZWAKECLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_A32KHZWAKECLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_A32KHZWAKECLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_A32KHZWAKECLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_A32KHZWAKECLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_A32KHZWAKECLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_A32KHZWAKECLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_A32KHZWAKECLKDIV_REQFLAG_Enum; + +typedef enum { + /* Systick Divider Output Clock */ + RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_SYSTICK_DIV_OUTPUT =3D 0, + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_LPOSC =3D 1, + /* 32 KHz RTC Clock */ + RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_A32KHZ_RTC =3D 2, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_SYSTICKFCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_SYSTICKFCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_SYSTICKFCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_SYSTICKFCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_SYSTICKFCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_SYSTICKFCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_SYSTICKFCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_SYSTICKFCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_SYSTICKFCLKDIV_REQFLAG_Enum; + +typedef enum { + /* FRO_DIV1 Clock */ + RT500_CLKCTL0_DPHYCLKSEL_SEL_FRO =3D 0, + /* SYSPLL0 MAIN_CLK (PFD0 Output) */ + RT500_CLKCTL0_DPHYCLKSEL_SEL_SYSPLL0_MAIN =3D 1, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL0_DPHYCLKSEL_SEL_SYSPLL0_AUX0 =3D 2, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL0_DPHYCLKSEL_SEL_SYSPLL0_AUX1 =3D 3, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_DPHYCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_DPHYCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_DPHYCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_DPHYCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_DPHYCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_DPHYCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_DPHYCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_DPHYCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_DPHYCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_DPHYCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_DPHYCLKDIV_REQFLAG_Enum; + +typedef enum { + /* FRO_DIV1 clock */ + RT500_CLKCTL0_DPHYESCCLKSEL_SEL_FRO_DIV1 =3D 0, + /* FRO_DIV16 Clock */ + RT500_CLKCTL0_DPHYESCCLKSEL_SEL_FRO_DIV16 =3D 1, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_DPHYESCCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_DPHYESCCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_DPHYESCRXCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_DPHYESCRXCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_DPHYESCRXCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_DPHYESCRXCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_DPHYESCRXCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_DPHYESCRXCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_DPHYESCRXCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_DPHYESCRXCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_DPHYESCRXCLKDIV_REQFLAG_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_DPHYESCTXCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_DPHYESCTXCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_DPHYESCTXCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_DPHYESCTXCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_DPHYESCTXCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_DPHYESCTXCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_DPHYESCTXCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_DPHYESCTXCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_DPHYESCTXCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL0_GPUCLKSEL_SEL_MAIN =3D 0, + /* FRO_DIV1 clock */ + RT500_CLKCTL0_GPUCLKSEL_SEL_FRO =3D 1, + /* SYSPLL0 MAIN_CLK (PFD0 Output) */ + RT500_CLKCTL0_GPUCLKSEL_SEL_SYSPLL0_MAIN =3D 2, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL0_GPUCLKSEL_SEL_SYSPLL0_AUX0 =3D 3, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL0_GPUCLKSEL_SEL_SYSPLL0_AUX1 =3D 4, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_GPUCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_GPUCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_GPUCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_GPUCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_GPUCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_GPUCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_GPUCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_GPUCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_GPUCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_GPUCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_GPUCLKDIV_REQFLAG_Enum; + +typedef enum { + /* MIPI-DSI PHY Clock */ + RT500_CLKCTL0_DCPIXELCLKSEL_SEL_MIPI_DSI_PHY =3D 0, + /* Main Clock */ + RT500_CLKCTL0_DCPIXELCLKSEL_SEL_MAIN =3D 1, + /* FRO_DIV1 Clock */ + RT500_CLKCTL0_DCPIXELCLKSEL_SEL_FRO =3D 2, + /* SYSPLL0 MAIN_CLK (PFD0 Output) */ + RT500_CLKCTL0_DCPIXELCLKSEL_SEL_SYSPLL0_MAIN =3D 3, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL0_DCPIXELCLKSEL_SEL_SYSPLL0_AUX0 =3D 4, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL0_DCPIXELCLKSEL_SEL_SYSPLL0_AUX1 =3D 5, + /* None; this may be selected to reduce power when no output is needed= . */ + RT500_CLKCTL0_DCPIXELCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL0_DCPIXELCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_DCPIXELCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL0_DCPIXELCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL0_DCPIXELCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL0_DCPIXELCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL0_DCPIXELCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL0_DCPIXELCLKDIV_HALT_Enum; + +typedef enum { + /* The change to the divider value has finished */ + RT500_CLKCTL0_DCPIXELCLKDIV_REQFLAG_DIVIDER_READY =3D 0, + /* A change is being made to the divider value */ + RT500_CLKCTL0_DCPIXELCLKDIV_REQFLAG_DIVIDER_NOT_READY =3D 1, +} RT500_CLKCTL0_DCPIXELCLKDIV_REQFLAG_Enum; + + +#define RT500_CLKCTL0_REGISTER_ACCESS_INFO_ARRAY(_name) \ + struct RegisterAccessInfo _name[RT500_CLKCTL0_REGS_NO] =3D { \ + [0 ... RT500_CLKCTL0_REGS_NO - 1] =3D { \ + .name =3D "", \ + .addr =3D -1, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL0] =3D { \ + .name =3D "PSCCTL0", \ + .addr =3D 0x10, \ + .ro =3D 0xA208E0E1, \ + .reset =3D 0x5, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL1] =3D { \ + .name =3D "PSCCTL1", \ + .addr =3D 0x14, \ + .ro =3D 0xFEFE7FF3, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL2] =3D { \ + .name =3D "PSCCTL2", \ + .addr =3D 0x18, \ + .ro =3D 0xDFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL0_SET] =3D { \ + .name =3D "PSCCTL0_SET", \ + .addr =3D 0x40, \ + .ro =3D 0xA208E0E1, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL1_SET] =3D { \ + .name =3D "PSCCTL1_SET", \ + .addr =3D 0x44, \ + .ro =3D 0xFEFE7FF3, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL2_SET] =3D { \ + .name =3D "PSCCTL2_SET", \ + .addr =3D 0x48, \ + .ro =3D 0xDFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL0_CLR] =3D { \ + .name =3D "PSCCTL0_CLR", \ + .addr =3D 0x70, \ + .ro =3D 0xA208E0E1, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL1_CLR] =3D { \ + .name =3D "PSCCTL1_CLR", \ + .addr =3D 0x74, \ + .ro =3D 0xFEFE7FF3, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL2_CLR] =3D { \ + .name =3D "PSCCTL2_CLR", \ + .addr =3D 0x78, \ + .ro =3D 0xDFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_FRO_CONTROL] =3D { \ + .name =3D "FRO_CONTROL", \ + .addr =3D 0x80, \ + .ro =3D 0x7C000000, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_FRO_CAPVAL] =3D { \ + .name =3D "FRO_CAPVAL", \ + .addr =3D 0x84, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_FRO_RDTRIM] =3D { \ + .name =3D "FRO_RDTRIM", \ + .addr =3D 0x8C, \ + .ro =3D 0xFFFFF800, \ + .reset =3D 0x3BF, \ + }, \ + [R_RT500_CLKCTL0_FRO_SCTRIM] =3D { \ + .name =3D "FRO_SCTRIM", \ + .addr =3D 0x90, \ + .ro =3D 0xFFFFFFC0, \ + .reset =3D 0x20, \ + }, \ + [R_RT500_CLKCTL0_FRODIVSEL] =3D { \ + .name =3D "FRODIVSEL", \ + .addr =3D 0x108, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_FROCLKSTATUS] =3D { \ + .name =3D "FROCLKSTATUS", \ + .addr =3D 0x10C, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_FRODIVOEN] =3D { \ + .name =3D "FRODIVOEN", \ + .addr =3D 0x110, \ + .ro =3D 0xFFFFFFE0, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_LOWFREQCLKDIV] =3D { \ + .name =3D "LOWFREQCLKDIV", \ + .addr =3D 0x130, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_SYSOSCCTL0] =3D { \ + .name =3D "SYSOSCCTL0", \ + .addr =3D 0x160, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_SYSOSCBYPASS] =3D { \ + .name =3D "SYSOSCBYPASS", \ + .addr =3D 0x168, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_LPOSCCTL0] =3D { \ + .name =3D "LPOSCCTL0", \ + .addr =3D 0x190, \ + .ro =3D 0x7FFFFFFF, \ + .reset =3D 0x807BC4D4, \ + }, \ + [R_RT500_CLKCTL0_OSC32KHZCTL0] =3D { \ + .name =3D "OSC32KHZCTL0", \ + .addr =3D 0x1C0, \ + .ro =3D 0xFFFFFFFE, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0CLKSEL] =3D { \ + .name =3D "SYSPLL0CLKSEL", \ + .addr =3D 0x200, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0CTL0] =3D { \ + .name =3D "SYSPLL0CTL0", \ + .addr =3D 0x204, \ + .ro =3D 0xFF00DFFC, \ + .reset =3D 0x160002, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0LOCKTIMEDIV2] =3D { \ + .name =3D "SYSPLL0LOCKTIMEDIV2", \ + .addr =3D 0x20C, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xCAFE, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0NUM] =3D { \ + .name =3D "SYSPLL0NUM", \ + .addr =3D 0x210, \ + .ro =3D 0xC0000000, \ + .reset =3D 0x4DD2F15, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0DENOM] =3D { \ + .name =3D "SYSPLL0DENOM", \ + .addr =3D 0x214, \ + .ro =3D 0xC0000000, \ + .reset =3D 0x1FFFFFDB, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0PFD] =3D { \ + .name =3D "SYSPLL0PFD", \ + .addr =3D 0x218, \ + .ro =3D 0x0, \ + .reset =3D 0x80808080, \ + }, \ + [R_RT500_CLKCTL0_MAINPLLCLKDIV] =3D { \ + .name =3D "MAINPLLCLKDIV", \ + .addr =3D 0x240, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_DSPPLLCLKDIV] =3D { \ + .name =3D "DSPPLLCLKDIV", \ + .addr =3D 0x244, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_AUX0PLLCLKDIV] =3D { \ + .name =3D "AUX0PLLCLKDIV", \ + .addr =3D 0x248, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_AUX1PLLCLKDIV] =3D { \ + .name =3D "AUX1PLLCLKDIV", \ + .addr =3D 0x24C, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_SYSCPUAHBCLKDIV] =3D { \ + .name =3D "SYSCPUAHBCLKDIV", \ + .addr =3D 0x400, \ + .ro =3D 0x7FFFFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_MAINCLKSELA] =3D { \ + .name =3D "MAINCLKSELA", \ + .addr =3D 0x430, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_MAINCLKSELB] =3D { \ + .name =3D "MAINCLKSELB", \ + .addr =3D 0x434, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_PFC0DIV] =3D { \ + .name =3D "PFC0DIV", \ + .addr =3D 0x500, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_PFC1DIV] =3D { \ + .name =3D "PFC1DIV", \ + .addr =3D 0x504, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_FLEXSPI0FCLKSEL] =3D { \ + .name =3D "FLEXSPI0FCLKSEL", \ + .addr =3D 0x620, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_FLEXSPI0FCLKDIV] =3D { \ + .name =3D "FLEXSPI0FCLKDIV", \ + .addr =3D 0x624, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_FLEXSPI1FCLKSEL] =3D { \ + .name =3D "FLEXSPI1FCLKSEL", \ + .addr =3D 0x630, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_FLEXSPI1FCLKDIV] =3D { \ + .name =3D "FLEXSPI1FCLKDIV", \ + .addr =3D 0x634, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_SCTFCLKSEL] =3D { \ + .name =3D "SCTFCLKSEL", \ + .addr =3D 0x640, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_SCTIN7CLKDIV] =3D { \ + .name =3D "SCTIN7CLKDIV", \ + .addr =3D 0x644, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_USBHSFCLKSEL] =3D { \ + .name =3D "USBHSFCLKSEL", \ + .addr =3D 0x660, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_USBHSFCLKDIV] =3D { \ + .name =3D "USBHSFCLKDIV", \ + .addr =3D 0x664, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_SDIO0FCLKSEL] =3D { \ + .name =3D "SDIO0FCLKSEL", \ + .addr =3D 0x680, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_SDIO0FCLKDIV] =3D { \ + .name =3D "SDIO0FCLKDIV", \ + .addr =3D 0x684, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_SDIO1FCLKSEL] =3D { \ + .name =3D "SDIO1FCLKSEL", \ + .addr =3D 0x690, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_SDIO1FCLKDIV] =3D { \ + .name =3D "SDIO1FCLKDIV", \ + .addr =3D 0x694, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_ADC0FCLKSEL0] =3D { \ + .name =3D "ADC0FCLKSEL0", \ + .addr =3D 0x6D0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_ADC0FCLKSEL1] =3D { \ + .name =3D "ADC0FCLKSEL1", \ + .addr =3D 0x6D4, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_ADC0FCLKDIV] =3D { \ + .name =3D "ADC0FCLKDIV", \ + .addr =3D 0x6D8, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_UTICKFCLKSEL] =3D { \ + .name =3D "UTICKFCLKSEL", \ + .addr =3D 0x700, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_WDT0FCLKSEL] =3D { \ + .name =3D "WDT0FCLKSEL", \ + .addr =3D 0x720, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL0_A32KHZWAKECLKSEL] =3D { \ + .name =3D "A32KHZWAKECLKSEL", \ + .addr =3D 0x730, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x1, \ + }, \ + [R_RT500_CLKCTL0_A32KHZWAKECLKDIV] =3D { \ + .name =3D "A32KHZWAKECLKDIV", \ + .addr =3D 0x734, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x1F, \ + }, \ + [R_RT500_CLKCTL0_SYSTICKFCLKSEL] =3D { \ + .name =3D "SYSTICKFCLKSEL", \ + .addr =3D 0x760, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_SYSTICKFCLKDIV] =3D { \ + .name =3D "SYSTICKFCLKDIV", \ + .addr =3D 0x764, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_DPHYCLKSEL] =3D { \ + .name =3D "DPHYCLKSEL", \ + .addr =3D 0x770, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_DPHYCLKDIV] =3D { \ + .name =3D "DPHYCLKDIV", \ + .addr =3D 0x774, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_DPHYESCCLKSEL] =3D { \ + .name =3D "DPHYESCCLKSEL", \ + .addr =3D 0x778, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_DPHYESCRXCLKDIV] =3D { \ + .name =3D "DPHYESCRXCLKDIV", \ + .addr =3D 0x77C, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000010, \ + }, \ + [R_RT500_CLKCTL0_DPHYESCTXCLKDIV] =3D { \ + .name =3D "DPHYESCTXCLKDIV", \ + .addr =3D 0x780, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000011, \ + }, \ + [R_RT500_CLKCTL0_GPUCLKSEL] =3D { \ + .name =3D "GPUCLKSEL", \ + .addr =3D 0x790, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_GPUCLKDIV] =3D { \ + .name =3D "GPUCLKDIV", \ + .addr =3D 0x794, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_DCPIXELCLKSEL] =3D { \ + .name =3D "DCPIXELCLKSEL", \ + .addr =3D 0x7A0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL0_DCPIXELCLKDIV] =3D { \ + .name =3D "DCPIXELCLKDIV", \ + .addr =3D 0x7A4, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + } diff --git a/include/hw/arm/svd/rt500_clkctl1.h b/include/hw/arm/svd/rt500_= clkctl1.h new file mode 100644 index 0000000000..5a83129c6e --- /dev/null +++ b/include/hw/arm/svd/rt500_clkctl1.h @@ -0,0 +1,3396 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#include "hw/register.h" + +/* Clock Controller 1 */ +#define RT500_CLKCTL1_REGS_NO (526) + +/* Clock Control 0 */ +REG32(RT500_CLKCTL1_PSCCTL0, 16); +/* Flexcomm Interface 0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC0_CLK, 8, 1); +/* Flexcomm Interface 1 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC1_CLK, 9, 1); +/* Flexcomm Interface 2 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC2_CLK, 10, 1); +/* Flexcomm Interface 3 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC3_CLK, 11, 1); +/* Flexcomm Interface 4 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC4_CLK, 12, 1); +/* Flexcomm Interface 5 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC5_CLK, 13, 1); +/* Flexcomm Interface 6 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC6_CLK, 14, 1); +/* Flexcomm Interface 7 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC7_CLK, 15, 1); +/* Flexcomm Interface 8 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC8_CLK, 16, 1); +/* Flexcomm Interface 9 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC9_CLK, 17, 1); +/* Flexcomm Interface 10 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC10_CLK, 18, 1); +/* Flexcomm Interface 11 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC11_CLK, 19, 1); +/* Flexcomm Interface 12 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC12_CLK, 20, 1); +/* Flexcomm Interface 13 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC13_CLK, 21, 1); +/* Flexcomm Interface 14 SPI clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC14_SPI_CLK, 22, 1); +/* Flexcomm Interface 15 I2C clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC15_I2C_CLK, 23, 1); +/* DMIC0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, DMIC0, 24, 1); +/* Flexcomm Interface 16 SPI clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FC16_SPI_CLK, 25, 1); +/* OS event timer bus clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, OSEVENT_TIMER, 27, 1); +/* FlexIO clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0, FlexIO, 29, 1); + +/* Clock Control 1 */ +REG32(RT500_CLKCTL1_PSCCTL1, 20); +/* Non-secure GPIO0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, HSGPIO0_CLK, 0, 1); +/* Non-secure GPIO1 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, HSGPIO1_CLK, 1, 1); +/* Non-secure GPIO2 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, HSGPIO2_CLK, 2, 1); +/* Non-secure GPIO3 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, HSGPIO3_CLK, 3, 1); +/* Non-secure GPIO4 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, HSGPIO4_CLK, 4, 1); +/* Non-secure GPIO5 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, HSGPIO5_CLK, 5, 1); +/* Non-secure GPIO6 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, HSGPIO6_CLK, 6, 1); +/* Non-secure GPIO7 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, HSGPIO7_CLK, 7, 1); +/* CRC clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, CRC_CLK, 16, 1); +/* DMAC0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, DMAC0_CLK, 23, 1); +/* DMAC1 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, DMAC1_CLK, 24, 1); +/* Messaging Unit clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, MU_CLK, 28, 1); +/* Semaphore clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, SEMA_CLK, 29, 1); +/* Frequency Measurement clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1, FREQME_CLK, 31, 1); + +/* Clock Control 2 */ +REG32(RT500_CLKCTL1_PSCCTL2, 24); +/* CT32BIT bit timer 0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, CT32BIT0_CLK, 0, 1); +/* CT32BIT bit timer 1 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, CT32BIT1_CLK, 1, 1); +/* CT32BIT bit timer 2 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, CT32BIT2_CLK, 2, 1); +/* CT32BIT bit timer 3 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, CT32BIT3_CLK, 3, 1); +/* CT32BIT bit timer 4 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, CT32BIT4_CLK, 4, 1); +/* RTC clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, RTCLITE_CLK, 7, 1); +/* Multi-Rate Timer 0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, MRT0_CLK, 8, 1); +/* Watchdog Timer 1 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, WWDT1_CLK, 10, 1); +/* I3C0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, I3C0_CLK, 16, 1); +/* I3C1 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, I3C1_CLK, 17, 1); +/* PINT clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, GPIOINTCTL_CLK, 30, 1); +/* INPUTMUX clock control */ +FIELD(RT500_CLKCTL1_PSCCTL2, PIMCTL_CLK, 31, 1); + +/* Clock Set 0 */ +REG32(RT500_CLKCTL1_PSCCTL0_SET, 64); +/* Flexcomm Interface 0 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC0_CLK, 8, 1); +/* Flexcomm Interface 1 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC1_CLK, 9, 1); +/* Flexcomm Interface 2 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC2_CLK, 10, 1); +/* Flexcomm Interface 3 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC3_CLK, 11, 1); +/* Flexcomm Interface 4 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC4_CLK, 12, 1); +/* Flexcomm Interface 5 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC5_CLK, 13, 1); +/* Flexcomm Interface 6 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC6_CLK, 14, 1); +/* Flexcomm Interface 7 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC7_CLK, 15, 1); +/* Flexcomm Interface 8 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC8_CLK, 16, 1); +/* Flexcomm Interface 9 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC9_CLK, 17, 1); +/* Flexcomm Interface 10 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC10_CLK, 18, 1); +/* Flexcomm Interface 11 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC11_CLK, 19, 1); +/* Flexcomm Interface 12 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC12_CLK, 20, 1); +/* Flexcomm Interface 13 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC13_CLK, 21, 1); +/* Flexcomm Interface 14 SPI clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC14_SPI_CLK, 22, 1); +/* Flexcomm Interface 15 I2C clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC15_I2C_CLK, 23, 1); +/* DMIC0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, DMIC0, 24, 1); +/* Flexcomm Interface 16 SPI clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FC16_SPI_CLK, 25, 1); +/* OS event timer bus clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, OSEVENT_TIMER, 27, 1); +/* FlexIO clock control */ +FIELD(RT500_CLKCTL1_PSCCTL0_SET, FlexIO, 29, 1); + +/* Clock Set 1 */ +REG32(RT500_CLKCTL1_PSCCTL1_SET, 68); +/* Non-secure GPIO0 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, HSGPIO0_CLK, 0, 1); +/* Non-secure GPIO1 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, HSGPIO1_CLK, 1, 1); +/* Non-secure GPIO2 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, HSGPIO2_CLK, 2, 1); +/* Non-secure GPIO3 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, HSGPIO3_CLK, 3, 1); +/* Non-secure GPIO4 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, HSGPIO4_CLK, 4, 1); +/* Non-secure GPIO5 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, HSGPIO5_CLK, 5, 1); +/* Non-secure GPIO6 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, HSGPIO6_CLK, 6, 1); +/* Non-secure GPIO7 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, HSGPIO7_CLK, 7, 1); +/* CRC clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, CRC_CLK, 16, 1); +/* DMAC0 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, DMAC0_CLK, 23, 1); +/* DMAC1 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, DMAC1_CLK, 24, 1); +/* Messaging Unit clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, MU_CLK, 28, 1); +/* Semaphore clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, SEMA_CLK, 29, 1); +/* Frequency Measurement clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL1_SET, FREQME_CLK, 31, 1); + +/* Clock Set 2 */ +REG32(RT500_CLKCTL1_PSCCTL2_SET, 72); +/* CT32BIT bit timer 0 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, CT32BIT0_CLK, 0, 1); +/* CT32BIT bit timer 1 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, CT32BIT1_CLK, 1, 1); +/* CT32BIT bit timer 2 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, CT32BIT2_CLK, 2, 1); +/* CT32BIT bit timer 3 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, CT32BIT3_CLK, 3, 1); +/* CT32BIT bit timer 4 clock set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, CT32BIT4_CLK, 4, 1); +/* RTC clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, RTCLITE_CLK, 7, 1); +/* Multi-Rate Timer 0 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, MRT0_CLK, 8, 1); +/* Watchdog Timer 1 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, WWDT1_CLK, 10, 1); +/* I3C0 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, I3C0_CLK, 16, 1); +/* I3C1 clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, I3C1_CLK, 17, 1); +/* PINT clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, GPIOINTCTL_CLK, 30, 1); +/* INPUTMUX clock control set */ +FIELD(RT500_CLKCTL1_PSCCTL2_SET, PIMCTL_CLK, 31, 1); + +/* Clock Clear 0 */ +REG32(RT500_CLKCTL1_PSCCTL0_CLR, 112); +/* Flexcomm Interface 0 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC0_CLK, 8, 1); +/* Flexcomm Interface 1 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC1_CLK, 9, 1); +/* Flexcomm Interface 2 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC2_CLK, 10, 1); +/* Flexcomm Interface 3 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC3_CLK, 11, 1); +/* Flexcomm Interface 4 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC4_CLK, 12, 1); +/* Flexcomm Interface 5 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC5_CLK, 13, 1); +/* Flexcomm Interface 6 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC6_CLK, 14, 1); +/* Flexcomm Interface 7 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC7_CLK, 15, 1); +/* Flexcomm Interface 8 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC8_CLK, 16, 1); +/* Flexcomm Interface 9 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC9_CLK, 17, 1); +/* Flexcomm Interface 10 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC10_CLK, 18, 1); +/* Flexcomm Interface 11 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC11_CLK, 19, 1); +/* Flexcomm Interface 12 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC12_CLK, 20, 1); +/* Flexcomm Interface 13 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC13_CLK, 21, 1); +/* Flexcomm Interface 14 SPI clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC14_SPI_CLK, 22, 1); +/* Flexcomm Interface 15 I2C clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC15_I2C_CLK, 23, 1); +/* DMIC0 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, DMIC0, 24, 1); +/* Flexcomm Interface 16 SPI clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FC16_SPI_CLK, 25, 1); +/* OS event timer bus clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, OSEVENT_TIMER, 27, 1); +/* FlexIO clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL0_CLR, FlexIO, 29, 1); + +/* Clock Clear 1 */ +REG32(RT500_CLKCTL1_PSCCTL1_CLR, 116); +/* Non-secure GPIO0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, HSGPIO0_CLK, 0, 1); +/* Non-secure GPIO1 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, HSGPIO1_CLK, 1, 1); +/* Non-secure GPIO2 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, HSGPIO2_CLK, 2, 1); +/* Non-secure GPIO3 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, HSGPIO3_CLK, 3, 1); +/* Non-secure GPIO4 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, HSGPIO4_CLK, 4, 1); +/* Non-secure GPIO5 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, HSGPIO5_CLK, 5, 1); +/* Non-secure GPIO6 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, HSGPIO6_CLK, 6, 1); +/* Non-secure GPIO7 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, HSGPIO7_CLK, 7, 1); +/* CRC clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, CRC_CLK, 16, 1); +/* DMAC0 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, DMAC0_CLK, 23, 1); +/* DMAC1 clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, DMAC1_CLK, 24, 1); +/* Messaging Unit clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, MU_CLK, 28, 1); +/* Semaphore clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, SEMA_CLK, 29, 1); +/* Frequency Measurement clock control */ +FIELD(RT500_CLKCTL1_PSCCTL1_CLR, FREQME_CLK, 31, 1); + +/* Clock Clear 2 */ +REG32(RT500_CLKCTL1_PSCCTL2_CLR, 120); +/* CT32BIT bit timer 0 clock clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, CT32BIT0_CLK, 0, 1); +/* CT32BIT bit timer 1 clock clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, CT32BIT1_CLK, 1, 1); +/* CT32BIT bit timer 2 clock clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, CT32BIT2_CLK, 2, 1); +/* CT32BIT bit timer 3 clock clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, CT32BIT3_CLK, 3, 1); +/* CT32BIT bit timer 4 clock clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, CT32BIT4_CLK, 4, 1); +/* RTC clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, RTCLITE_CLK, 7, 1); +/* Multi-Rate Timer 0 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, MRT0_CLK, 8, 1); +/* Watchdog Timer 1 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, WWDT1_CLK, 10, 1); +/* I3C0 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, I3C0_CLK, 16, 1); +/* I3C1 clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, I3C1_CLK, 17, 1); +/* PINT clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, GPIOINTCTL_CLK, 30, 1); +/* INPUTMUX clock control clear */ +FIELD(RT500_CLKCTL1_PSCCTL2_CLR, PIMCTL_CLK, 31, 1); + +/* Audio PLL0 Clock Select */ +REG32(RT500_CLKCTL1_AUDIOPLL0CLKSEL, 512); +/* Audio PLL0 Clock Select */ +FIELD(RT500_CLKCTL1_AUDIOPLL0CLKSEL, SEL, 0, 3); + +/* Audio PLL0 Control 0 */ +REG32(RT500_CLKCTL1_AUDIOPLL0CTL0, 516); +/* AUDIOPLL0 BYPASS Mode */ +FIELD(RT500_CLKCTL1_AUDIOPLL0CTL0, BYPASS, 0, 1); +/* AUDIOPLL0 Reset */ +FIELD(RT500_CLKCTL1_AUDIOPLL0CTL0, RESET, 1, 1); +/* Hold Ring Off Control */ +FIELD(RT500_CLKCTL1_AUDIOPLL0CTL0, HOLDRINGOFF_ENA, 13, 1); +/* Multiplication Factor */ +FIELD(RT500_CLKCTL1_AUDIOPLL0CTL0, MULT, 16, 8); + +/* Audio PLL0 Lock Time Divide-by-2 */ +REG32(RT500_CLKCTL1_AUDIOPLL0LOCKTIMEDIV2, 524); +/* AUDIOPLL0 Lock Time Divide-by-2 */ +FIELD(RT500_CLKCTL1_AUDIOPLL0LOCKTIMEDIV2, LOCKTIMEDIV2, 0, 16); + +/* Audio PLL0 Numerator */ +REG32(RT500_CLKCTL1_AUDIOPLL0NUM, 528); +/* Numerator */ +FIELD(RT500_CLKCTL1_AUDIOPLL0NUM, NUM, 0, 30); + +/* Audio PLL0 Denominator */ +REG32(RT500_CLKCTL1_AUDIOPLL0DENOM, 532); +/* Denominator */ +FIELD(RT500_CLKCTL1_AUDIOPLL0DENOM, DENOM, 0, 30); + +/* Audio PLL0 PFD */ +REG32(RT500_CLKCTL1_AUDIOPLL0PFD, 536); +/* PLL Fractional Divider 0 */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD0, 0, 6); +/* PFD0 Clock Ready Status Flag */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD0_CLKRDY, 6, 1); +/* PFD0 Clock Gate */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD0_CLKGATE, 7, 1); +/* PLL Fractional Divider 1 */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD1, 8, 6); +/* PFD1 Clock Ready Status Flag */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD1_CLKRDY, 14, 1); +/* PFD1 Clock Gate */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD1_CLKGATE, 15, 1); +/* PLL Fractional Divider 2 */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD2, 16, 6); +/* PFD2 Clock Ready Status Flag */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD2_CLKRDY, 22, 1); +/* PFD2 Clock Gate */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD2_CLKGATE, 23, 1); +/* PLL Fractional Divider 3 */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD3, 24, 6); +/* PFD3 Clock Ready Status Flag */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD3_CLKRDY, 30, 1); +/* PFD3 Clock Gate */ +FIELD(RT500_CLKCTL1_AUDIOPLL0PFD, PFD3_CLKGATE, 31, 1); + +/* Audio PLL Clock Divider */ +REG32(RT500_CLKCTL1_AUDIOPLLCLKDIV, 576); +/* Audio PLL Clock Divider Value */ +FIELD(RT500_CLKCTL1_AUDIOPLLCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_AUDIOPLLCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL1_AUDIOPLLCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_AUDIOPLLCLKDIV, REQFLAG, 31, 1); + +/* DSP CPU Clock Divider */ +REG32(RT500_CLKCTL1_DSPCPUCLKDIV, 1024); +/* DSP Clock Divider Value */ +FIELD(RT500_CLKCTL1_DSPCPUCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_DSPCPUCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL1_DSPCPUCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_DSPCPUCLKDIV, REQFLAG, 31, 1); + +/* DSP CPU Clock Select A */ +REG32(RT500_CLKCTL1_DSPCPUCLKSELA, 1072); +/* DSP Main 1st Stage Control Clock Source */ +FIELD(RT500_CLKCTL1_DSPCPUCLKSELA, SEL, 0, 2); + +/* DSP CPU Clock Select B */ +REG32(RT500_CLKCTL1_DSPCPUCLKSELB, 1076); +/* Main Clock Source */ +FIELD(RT500_CLKCTL1_DSPCPUCLKSELB, SEL, 0, 2); + +/* OS Event Timer Functional Clock Select */ +REG32(RT500_CLKCTL1_OSEVENTTFCLKSEL, 1152); +/* OS Event Timer Functional Clock Source */ +FIELD(RT500_CLKCTL1_OSEVENTTFCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 0 Clock Select */ +REG32(RT500_CLKCTL1_FRG0CLKSEL, 1280); +/* Fractional Generator 0 Clock Source */ +FIELD(RT500_CLKCTL1_FRG0CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 0 Control */ +REG32(RT500_CLKCTL1_FRG0CTL, 1284); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG0CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG0CTL, MULT, 8, 8); + +/* Flexcomm0 Clock Select */ +REG32(RT500_CLKCTL1_FC0FCLKSEL, 1288); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC0FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 1 Clock Select */ +REG32(RT500_CLKCTL1_FRG1CLKSEL, 1312); +/* Fractional Generator 1 Clock Source */ +FIELD(RT500_CLKCTL1_FRG1CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 1 Control */ +REG32(RT500_CLKCTL1_FRG1CTL, 1316); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG1CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG1CTL, MULT, 8, 8); + +/* Flexcomm1 Clock Select */ +REG32(RT500_CLKCTL1_FC1FCLKSEL, 1320); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC1FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 2 Clock Select */ +REG32(RT500_CLKCTL1_FRG2CLKSEL, 1344); +/* Fractional Generator 2 Clock Source */ +FIELD(RT500_CLKCTL1_FRG2CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 2 Control */ +REG32(RT500_CLKCTL1_FRG2CTL, 1348); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG2CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG2CTL, MULT, 8, 8); + +/* Flexcomm2 Clock Select */ +REG32(RT500_CLKCTL1_FC2FCLKSEL, 1352); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC2FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 3 Clock Select */ +REG32(RT500_CLKCTL1_FRG3CLKSEL, 1376); +/* Fractional Generator 3 Clock Source */ +FIELD(RT500_CLKCTL1_FRG3CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 3 Control */ +REG32(RT500_CLKCTL1_FRG3CTL, 1380); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG3CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG3CTL, MULT, 8, 8); + +/* Flexcomm3 Clock Select */ +REG32(RT500_CLKCTL1_FC3FCLKSEL, 1384); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC3FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 4 Clock Select */ +REG32(RT500_CLKCTL1_FRG4CLKSEL, 1408); +/* Fractional Generator 4 Clock Source */ +FIELD(RT500_CLKCTL1_FRG4CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 4 Control */ +REG32(RT500_CLKCTL1_FRG4CTL, 1412); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG4CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG4CTL, MULT, 8, 8); + +/* Flexcomm4 Clock Select */ +REG32(RT500_CLKCTL1_FC4FCLKSEL, 1416); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC4FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 5 Clock Select */ +REG32(RT500_CLKCTL1_FRG5CLKSEL, 1440); +/* Fractional Generator 5 Clock Source */ +FIELD(RT500_CLKCTL1_FRG5CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 5 Control */ +REG32(RT500_CLKCTL1_FRG5CTL, 1444); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG5CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG5CTL, MULT, 8, 8); + +/* Flexcomm5 Clock Select */ +REG32(RT500_CLKCTL1_FC5FCLKSEL, 1448); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC5FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 6 Clock Select */ +REG32(RT500_CLKCTL1_FRG6CLKSEL, 1472); +/* Fractional Generator 6 Clock Source */ +FIELD(RT500_CLKCTL1_FRG6CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 6 Control */ +REG32(RT500_CLKCTL1_FRG6CTL, 1476); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG6CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG6CTL, MULT, 8, 8); + +/* Flexcomm6 Clock Select */ +REG32(RT500_CLKCTL1_FC6FCLKSEL, 1480); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC6FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 7 Clock Select */ +REG32(RT500_CLKCTL1_FRG7CLKSEL, 1504); +/* Fractional Generator 7 Clock Source */ +FIELD(RT500_CLKCTL1_FRG7CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 7 Control */ +REG32(RT500_CLKCTL1_FRG7CTL, 1508); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG7CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG7CTL, MULT, 8, 8); + +/* Flexcomm7 Clock Select */ +REG32(RT500_CLKCTL1_FC7FCLKSEL, 1512); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC7FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 8 Clock Select */ +REG32(RT500_CLKCTL1_FRG8CLKSEL, 1536); +/* Fractional Generator 8 Clock Source */ +FIELD(RT500_CLKCTL1_FRG8CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 8 Control */ +REG32(RT500_CLKCTL1_FRG8CTL, 1540); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG8CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG8CTL, MULT, 8, 8); + +/* Flexcomm8 Clock Select */ +REG32(RT500_CLKCTL1_FC8FCLKSEL, 1544); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC8FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 9 Clock Select */ +REG32(RT500_CLKCTL1_FRG9CLKSEL, 1568); +/* Fractional Generator 9 Clock Source */ +FIELD(RT500_CLKCTL1_FRG9CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 9 Control */ +REG32(RT500_CLKCTL1_FRG9CTL, 1572); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG9CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG9CTL, MULT, 8, 8); + +/* Flexcomm9 Clock Select */ +REG32(RT500_CLKCTL1_FC9FCLKSEL, 1576); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC9FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 10 Clock Select */ +REG32(RT500_CLKCTL1_FRG10CLKSEL, 1600); +/* Fractional Generator 10 Clock Source */ +FIELD(RT500_CLKCTL1_FRG10CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 10 Control */ +REG32(RT500_CLKCTL1_FRG10CTL, 1604); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG10CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG10CTL, MULT, 8, 8); + +/* Flexcomm10 Clock Select */ +REG32(RT500_CLKCTL1_FC10FCLKSEL, 1608); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC10FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 11 Clock Select */ +REG32(RT500_CLKCTL1_FRG11CLKSEL, 1632); +/* Fractional Generator 11 Clock Source */ +FIELD(RT500_CLKCTL1_FRG11CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 11 Control */ +REG32(RT500_CLKCTL1_FRG11CTL, 1636); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG11CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG11CTL, MULT, 8, 8); + +/* Flexcomm11 Clock Select */ +REG32(RT500_CLKCTL1_FC11FCLKSEL, 1640); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC11FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 12 Clock Select */ +REG32(RT500_CLKCTL1_FRG12CLKSEL, 1664); +/* Fractional Generator 12 Clock Source */ +FIELD(RT500_CLKCTL1_FRG12CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 12 Control */ +REG32(RT500_CLKCTL1_FRG12CTL, 1668); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG12CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG12CTL, MULT, 8, 8); + +/* Flexcomm12 Clock Select */ +REG32(RT500_CLKCTL1_FC12FCLKSEL, 1672); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC12FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 13 Clock Select */ +REG32(RT500_CLKCTL1_FRG13CLKSEL, 1696); +/* Fractional Generator 13 Clock Source */ +FIELD(RT500_CLKCTL1_FRG13CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 13 Control */ +REG32(RT500_CLKCTL1_FRG13CTL, 1700); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG13CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG13CTL, MULT, 8, 8); + +/* Flexcomm13 Clock Select */ +REG32(RT500_CLKCTL1_FC13FCLKSEL, 1704); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC13FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 14 Clock Select */ +REG32(RT500_CLKCTL1_FRG14CLKSEL, 1728); +/* Fractional Generator 14 Clock Source */ +FIELD(RT500_CLKCTL1_FRG14CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 14 Control */ +REG32(RT500_CLKCTL1_FRG14CTL, 1732); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG14CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG14CTL, MULT, 8, 8); + +/* Flexcomm14 Clock Select */ +REG32(RT500_CLKCTL1_FC14FCLKSEL, 1736); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC14FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 15 Clock Select */ +REG32(RT500_CLKCTL1_FRG15CLKSEL, 1760); +/* Fractional Generator 15 Clock Source */ +FIELD(RT500_CLKCTL1_FRG15CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 15 Control */ +REG32(RT500_CLKCTL1_FRG15CTL, 1764); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG15CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG15CTL, MULT, 8, 8); + +/* Flexcomm15 Clock Select */ +REG32(RT500_CLKCTL1_FC15FCLKSEL, 1768); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC15FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 16 Clock Select */ +REG32(RT500_CLKCTL1_FRG16CLKSEL, 1792); +/* Fractional Generator 16 Clock Source */ +FIELD(RT500_CLKCTL1_FRG16CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 16 Control */ +REG32(RT500_CLKCTL1_FRG16CTL, 1796); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG16CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG16CTL, MULT, 8, 8); + +/* Flexcomm16 Clock Select */ +REG32(RT500_CLKCTL1_FC16FCLKSEL, 1800); +/* Flexcomm Functional Clock Source */ +FIELD(RT500_CLKCTL1_FC16FCLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 17 Clock Select */ +REG32(RT500_CLKCTL1_FRG17CLKSEL, 1824); +/* Fractional Generator 17 Clock Source */ +FIELD(RT500_CLKCTL1_FRG17CLKSEL, SEL, 0, 3); + +/* Fractional Rate Generator 17 Control */ +REG32(RT500_CLKCTL1_FRG17CTL, 1828); +/* + * Denominator of the fractional divider: DIV is equal to the programmed v= alue + * +1 + */ +FIELD(RT500_CLKCTL1_FRG17CTL, DIV, 0, 8); +/* + * Numerator of the fractional divider: MULT is equal to the programmed va= lue. + */ +FIELD(RT500_CLKCTL1_FRG17CTL, MULT, 8, 8); + +/* FlexIO Clock Select */ +REG32(RT500_CLKCTL1_FLEXIOCLKSEL, 1832); +/* FlexIO Functional Clock Source */ +FIELD(RT500_CLKCTL1_FLEXIOCLKSEL, SEL, 0, 3); + +/* FlexIO Clock Divider */ +REG32(RT500_CLKCTL1_FLEXIOCLKDIV, 1856); +/* FLEXIO Clock Divider Value */ +FIELD(RT500_CLKCTL1_FLEXIOCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_FLEXIOCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL1_FLEXIOCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_FLEXIOCLKDIV, REQFLAG, 31, 1); + +/* Fractional Rate Generator PLL Clock Divider */ +REG32(RT500_CLKCTL1_FRGPLLCLKDIV, 1888); +/* FRG PLL Clock Divider Value */ +FIELD(RT500_CLKCTL1_FRGPLLCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_FRGPLLCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL1_FRGPLLCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_FRGPLLCLKDIV, REQFLAG, 31, 1); + +/* DMIC0 Functional Clock Select */ +REG32(RT500_CLKCTL1_DMIC0FCLKSEL, 1920); +/* DMIC Functional Clock Source */ +FIELD(RT500_CLKCTL1_DMIC0FCLKSEL, SEL, 0, 3); + +/* DMIC0 Functional Clock Divider */ +REG32(RT500_CLKCTL1_DMIC0FCLKDIV, 1924); +/* 32 KHz Wake Clock Divider Value */ +FIELD(RT500_CLKCTL1_DMIC0FCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_DMIC0FCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL1_DMIC0FCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_DMIC0FCLKDIV, REQFLAG, 31, 1); + +/* CT32BIT bit timer index Functional Clock Select */ +REG32(RT500_CLKCTL1_CT32BITFCLKSEL0, 1952); +REG32(RT500_CLKCTL1_CT32BITFCLKSEL1, 1956); +REG32(RT500_CLKCTL1_CT32BITFCLKSEL2, 1960); +REG32(RT500_CLKCTL1_CT32BITFCLKSEL3, 1964); +REG32(RT500_CLKCTL1_CT32BITFCLKSEL4, 1968); +/* CT32BIT bit timer 0 Functional Clock Source */ +SHARED_FIELD(RT500_CLKCTL1_CT32BITFCLKSEL_SEL, 0, 3); + +/* Audio MCLK Clock Select */ +REG32(RT500_CLKCTL1_AUDIOMCLKSEL, 1984); +/* Audio MCLK Clock Source Select */ +FIELD(RT500_CLKCTL1_AUDIOMCLKSEL, SEL, 0, 3); + +/* Audio MCLK Clock Divider */ +REG32(RT500_CLKCTL1_AUDIOMCLKDIV, 1988); +/* Audio MCLK Clock Divider Value */ +FIELD(RT500_CLKCTL1_AUDIOMCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_AUDIOMCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL1_AUDIOMCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_AUDIOMCLKDIV, REQFLAG, 31, 1); + +/* CLKOUT Clock Select 0 */ +REG32(RT500_CLKCTL1_CLKOUTSEL0, 2016); +/* Clock Output Select 1st Stage */ +FIELD(RT500_CLKCTL1_CLKOUTSEL0, SEL, 0, 3); + +/* CLKOUT Clock Select 1 */ +REG32(RT500_CLKCTL1_CLKOUTSEL1, 2020); +/* Clock Out Source */ +FIELD(RT500_CLKCTL1_CLKOUTSEL1, SEL, 0, 3); + +/* CLKOUT Functional Clock Divider */ +REG32(RT500_CLKCTL1_CLKOUTFCLKDIV, 2024); +/* Clock-Out Clock Divider Value */ +FIELD(RT500_CLKCTL1_CLKOUTFCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_CLKOUTFCLKDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL1_CLKOUTFCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_CLKOUTFCLKDIV, REQFLAG, 31, 1); + +/* I3C0, I3C1 Functional Clock Select */ +REG32(RT500_CLKCTL1_I3C01FCLKSEL, 2048); +/* I3C0, I3C1 Clock Source */ +FIELD(RT500_CLKCTL1_I3C01FCLKSEL, SEL, 0, 3); + +/* I3C0, I3C1 Functional Slow Time Control Clock Select */ +REG32(RT500_CLKCTL1_I3C01FCLKSTCSEL, 2052); +/* I3C0, I3C1 Clock Source */ +FIELD(RT500_CLKCTL1_I3C01FCLKSTCSEL, SEL, 0, 3); + +/* I3C0, I3C1 Functional Slow Time Control Clock Divider */ +REG32(RT500_CLKCTL1_I3C01FCLKSTCDIV, 2056); +/* I3C0, I3C1 Clock Divider Value */ +FIELD(RT500_CLKCTL1_I3C01FCLKSTCDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_I3C01FCLKSTCDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL1_I3C01FCLKSTCDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_I3C01FCLKSTCDIV, REQFLAG, 31, 1); + +/* I3C0, I3C1 Functional Slow Clock Divider */ +REG32(RT500_CLKCTL1_I3C01FCLKSDIV, 2060); +/* I3C0, I3C1 Clock Divider Value */ +FIELD(RT500_CLKCTL1_I3C01FCLKSDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_I3C01FCLKSDIV, RESET, 29, 1); +/* Halt the Divider Counter */ +FIELD(RT500_CLKCTL1_I3C01FCLKSDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_I3C01FCLKSDIV, REQFLAG, 31, 1); + +/* I3C0, I3C1 Functional Clock Divider */ +REG32(RT500_CLKCTL1_I3C01FCLKDIV, 2064); +/* I3C0, I3C1 Clock Divider Value */ +FIELD(RT500_CLKCTL1_I3C01FCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_I3C01FCLKDIV, RESET, 29, 1); +/* Halts the Divider Counter */ +FIELD(RT500_CLKCTL1_I3C01FCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_I3C01FCLKDIV, REQFLAG, 31, 1); + +/* I3C01 Functional Clock Select */ +REG32(RT500_CLKCTL1_I3C01FCLKSTSTCLKSEL, 2068); +/* I3C0, I3C1 FCLK Test Clock Source */ +FIELD(RT500_CLKCTL1_I3C01FCLKSTSTCLKSEL, SEL, 0, 3); + +/* Watchdog Timer 1 Functional Clock Select */ +REG32(RT500_CLKCTL1_WDT1FCLKSEL, 2080); +/* WDT1 Functional Clock Source */ +FIELD(RT500_CLKCTL1_WDT1FCLKSEL, SEL, 0, 3); + +/* Analog Comparator 0 Clock Select */ +REG32(RT500_CLKCTL1_ACMP0FCLKSEL, 2096); +/* ACMP0 Fast Functional Clock Source */ +FIELD(RT500_CLKCTL1_ACMP0FCLKSEL, SEL, 0, 3); + +/* Analog comparator 0 FCLK divider */ +REG32(RT500_CLKCTL1_ACMP0FCLKDIV, 2100); +/* Clock Out Clock Divider Value */ +FIELD(RT500_CLKCTL1_ACMP0FCLKDIV, DIV, 0, 8); +/* Reset the Divider Counter */ +FIELD(RT500_CLKCTL1_ACMP0FCLKDIV, RESET, 29, 1); +/* Halts the Divider Counter */ +FIELD(RT500_CLKCTL1_ACMP0FCLKDIV, HALT, 30, 1); +/* Divider Status Flag */ +FIELD(RT500_CLKCTL1_ACMP0FCLKDIV, REQFLAG, 31, 1); + + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC2_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC2_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC2_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC3_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC3_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC3_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC4_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC4_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC4_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC5_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC5_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC5_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC6_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC6_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC6_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC7_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC7_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC7_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC8_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC8_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC8_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC9_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC9_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC9_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC10_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC10_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC10_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC11_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC11_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC11_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC12_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC12_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC12_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC13_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC13_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC13_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC14_SPI_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC14_SPI_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC14_SPI_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC15_I2C_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC15_I2C_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC15_I2C_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_DMIC0_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_DMIC0_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_DMIC0_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FC16_SPI_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FC16_SPI_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FC16_SPI_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_OSEVENT_TIMER_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_OSEVENT_TIMER_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_OSEVENT_TIMER_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL0_FlexIO_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL0_FlexIO_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_FlexIO_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_HSGPIO0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_HSGPIO1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO2_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO2_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_HSGPIO2_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO3_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO3_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_HSGPIO3_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO4_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO4_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_HSGPIO4_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO5_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO5_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_HSGPIO5_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO6_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO6_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_HSGPIO6_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO7_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_HSGPIO7_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_HSGPIO7_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_CRC_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_CRC_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CRC_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_DMAC0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_DMAC0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_DMAC0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_DMAC1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_DMAC1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_DMAC1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_MU_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_MU_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_MU_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_SEMA_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_SEMA_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SEMA_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL1_FREQME_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL1_FREQME_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_FREQME_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CT32BIT0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CT32BIT1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT2_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT2_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CT32BIT2_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT3_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT3_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CT32BIT3_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT4_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CT32BIT4_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CT32BIT4_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_RTCLITE_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_RTCLITE_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_RTCLITE_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_MRT0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_MRT0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_MRT0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_WWDT1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_WWDT1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_WWDT1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_I3C0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_I3C0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_I3C0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_I3C1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_I3C1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_I3C1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_GPIOINTCTL_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_GPIOINTCTL_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_GPIOINTCTL_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_PIMCTL_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_PIMCTL_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_PIMCTL_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC0_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC1_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC2_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC2_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC2_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC3_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC3_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC3_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC4_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC4_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC4_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC5_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC5_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC5_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC6_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC6_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC6_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC7_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC7_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC7_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC8_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC8_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC8_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC9_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC9_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC9_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC10_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC10_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC10_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC11_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC11_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC11_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC12_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC12_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC12_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC13_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC13_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC13_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC14_SPI_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC14_SPI_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC14_SPI_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC15_I2C_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC15_I2C_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC15_I2C_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_DMIC0_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_DMIC0_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_DMIC0_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FC16_SPI_CLK_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FC16_SPI_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FC16_SPI_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_OSEVENT_TIMER_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_OSEVENT_TIMER_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_OSEVENT_TIMER_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_SET_FlexIO_DISABLE =3D 0, + /* Sets the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_SET_FlexIO_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_SET_FlexIO_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO0_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_HSGPIO0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO1_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_HSGPIO1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO2_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO2_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_HSGPIO2_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO3_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO3_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_HSGPIO3_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO4_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO4_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_HSGPIO4_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO5_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO5_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_HSGPIO5_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO6_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO6_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_HSGPIO6_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO7_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_HSGPIO7_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_HSGPIO7_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_CRC_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_CRC_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_CRC_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_DMAC0_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_DMAC0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_DMAC0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_DMAC1_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_DMAC1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_DMAC1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_MU_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_MU_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_MU_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_SEMA_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_SEMA_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_SEMA_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_SET_FREQME_CLK_DISABLE =3D 0, + /* Sets the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_SET_FREQME_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_SET_FREQME_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT0_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT0_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_CT32BIT0_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT1_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT1_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_CT32BIT1_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT2_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT2_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_CT32BIT2_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT3_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT3_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_CT32BIT3_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT4_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_SET_CT32BIT4_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_CT32BIT4_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_RTCLITE_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_RTCLITE_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_RTCLITE_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_MRT0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_MRT0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_MRT0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_WWDT1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_WWDT1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_WWDT1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_I3C0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_I3C0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_I3C0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_I3C1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_I3C1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_I3C1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_GPIOINTCTL_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_GPIOINTCTL_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_GPIOINTCTL_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_PIMCTL_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_SET_PIMCTL_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_SET_PIMCTL_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC0_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC1_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC2_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC2_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC2_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC3_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC3_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC3_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC4_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC4_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC4_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC5_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC5_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC5_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC6_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC6_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC6_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC7_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC7_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC7_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC8_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC8_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC8_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC9_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC9_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC9_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC10_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC10_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC10_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC11_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC11_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC11_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC12_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC12_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC12_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC13_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC13_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC13_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC14_SPI_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC14_SPI_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC14_SPI_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC15_I2C_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC15_I2C_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC15_I2C_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_DMIC0_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_DMIC0_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_DMIC0_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FC16_SPI_CLK_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FC16_SPI_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FC16_SPI_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_OSEVENT_TIMER_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_OSEVENT_TIMER_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_OSEVENT_TIMER_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL0_CLR_FlexIO_DISABLE =3D 0, + /* Clears the PSCCTL0 bit */ + RT500_CLKCTL1_PSCCTL0_CLR_FlexIO_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL0_CLR_FlexIO_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO0_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO1_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO2_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO2_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO2_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO3_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO3_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO3_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO4_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO4_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO4_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO5_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO5_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO5_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO6_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO6_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO6_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO7_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO7_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_HSGPIO7_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_CRC_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_CRC_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_CRC_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_DMAC0_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_DMAC0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_DMAC0_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_DMAC1_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_DMAC1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_DMAC1_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_MU_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_MU_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_MU_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_SEMA_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_SEMA_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_SEMA_CLK_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_PSCCTL1_CLR_FREQME_CLK_DISABLE =3D 0, + /* Clears the PSCCTL1 bit */ + RT500_CLKCTL1_PSCCTL1_CLR_FREQME_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL1_CLR_FREQME_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT0_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT0_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT0_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT1_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT1_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT1_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT2_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT2_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT2_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT3_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT3_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT3_CLK_Enum; + +typedef enum { + /* No Effect */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT4_CLK_NO_EFFECT =3D 0, + /* Set Bit */ + RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT4_CLK_SET_BIT =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_CT32BIT4_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_RTCLITE_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_RTCLITE_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_RTCLITE_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_MRT0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_MRT0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_MRT0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_WWDT1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_WWDT1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_WWDT1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_I3C0_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_I3C0_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_I3C0_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_I3C1_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_I3C1_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_I3C1_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_GPIOINTCTL_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_GPIOINTCTL_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_GPIOINTCTL_CLK_Enum; + +typedef enum { + /* Disable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_PIMCTL_CLK_DISABLE =3D 0, + /* Enable Clock */ + RT500_CLKCTL1_PSCCTL2_CLR_PIMCTL_CLK_ENABLE =3D 1, +} RT500_CLKCTL1_PSCCTL2_CLR_PIMCTL_CLK_Enum; + +typedef enum { + /* FRO_DIV8 */ + RT500_CLKCTL1_AUDIOPLL0CLKSEL_SEL_FRRO_DIV8 =3D 0, + /* OSC_CLK clock (User-Selectable) */ + RT500_CLKCTL1_AUDIOPLL0CLKSEL_SEL_OSC_CLK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_AUDIOPLL0CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_AUDIOPLL0CLKSEL_SEL_Enum; + +typedef enum { + /* PFD outputs are PFD-programmed clocks */ + RT500_CLKCTL1_AUDIOPLL0CTL0_BYPASS_PFD =3D 0, + /* + * Bypass Mode. PFD outputs are sourced directly from the reference in= put + * clock + */ + RT500_CLKCTL1_AUDIOPLL0CTL0_BYPASS_BYPASS =3D 1, +} RT500_CLKCTL1_AUDIOPLL0CTL0_BYPASS_Enum; + +typedef enum { + /* AUDIOPLL0 reset is removed */ + RT500_CLKCTL1_AUDIOPLL0CTL0_RESET_NO_RESET =3D 0, + /* AUDIOPLL0 is placed into reset */ + RT500_CLKCTL1_AUDIOPLL0CTL0_RESET_RESET =3D 1, +} RT500_CLKCTL1_AUDIOPLL0CTL0_RESET_Enum; + +typedef enum { + /* Disable */ + RT500_CLKCTL1_AUDIOPLL0CTL0_HOLDRINGOFF_ENA_DISABLE =3D 0, + /* Enable */ + RT500_CLKCTL1_AUDIOPLL0CTL0_HOLDRINGOFF_ENA_ENABLE =3D 1, +} RT500_CLKCTL1_AUDIOPLL0CTL0_HOLDRINGOFF_ENA_Enum; + +typedef enum { + /* Multiply by 16 */ + RT500_CLKCTL1_AUDIOPLL0CTL0_MULT_DIV16 =3D 16, + /* Multiply by 17 */ + RT500_CLKCTL1_AUDIOPLL0CTL0_MULT_DIV17 =3D 17, + /* Multiply by 18 */ + RT500_CLKCTL1_AUDIOPLL0CTL0_MULT_DIV18 =3D 18, + /* Multiply by 19 */ + RT500_CLKCTL1_AUDIOPLL0CTL0_MULT_DIV19 =3D 19, + /* Multiply by 20 */ + RT500_CLKCTL1_AUDIOPLL0CTL0_MULT_DIV20 =3D 20, + /* Multiply by 21 */ + RT500_CLKCTL1_AUDIOPLL0CTL0_MULT_DIV21 =3D 21, + /* Multiply by 22 */ + RT500_CLKCTL1_AUDIOPLL0CTL0_MULT_DIV22 =3D 22, +} RT500_CLKCTL1_AUDIOPLL0CTL0_MULT_Enum; + +typedef enum { + /* Not ready */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD0_CLKRDY_NOT_READY =3D 0, + /* Ready */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD0_CLKRDY_READY =3D 1, +} RT500_CLKCTL1_AUDIOPLL0PFD_PFD0_CLKRDY_Enum; + +typedef enum { + /* PFD0 clock is not gated */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD0_CLKGATE_NOT_GATED =3D 0, + /* PFD0 clock is gated */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD0_CLKGATE_GATED =3D 1, +} RT500_CLKCTL1_AUDIOPLL0PFD_PFD0_CLKGATE_Enum; + +typedef enum { + /* Not ready */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD1_CLKRDY_NOT_READY =3D 0, + /* Ready */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD1_CLKRDY_READY =3D 1, +} RT500_CLKCTL1_AUDIOPLL0PFD_PFD1_CLKRDY_Enum; + +typedef enum { + /* PFD1 clock is not gated */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD1_CLKGATE_NOT_GATED =3D 0, + /* PFD1 clock is gated */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD1_CLKGATE_GATED =3D 1, +} RT500_CLKCTL1_AUDIOPLL0PFD_PFD1_CLKGATE_Enum; + +typedef enum { + /* Not ready */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD2_CLKRDY_NOT_READY =3D 0, + /* Ready */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD2_CLKRDY_READY =3D 1, +} RT500_CLKCTL1_AUDIOPLL0PFD_PFD2_CLKRDY_Enum; + +typedef enum { + /* PFD2 clock is not gated */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD2_CLKGATE_NOT_GATED =3D 0, + /* PFD2 clock is gated */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD2_CLKGATE_GATED =3D 1, +} RT500_CLKCTL1_AUDIOPLL0PFD_PFD2_CLKGATE_Enum; + +typedef enum { + /* Not ready */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD3_CLKRDY_NOT_READY =3D 0, + /* Ready */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD3_CLKRDY_READY =3D 1, +} RT500_CLKCTL1_AUDIOPLL0PFD_PFD3_CLKRDY_Enum; + +typedef enum { + /* PFD3 clock is not gated */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD3_CLKGATE_NOT_GATED =3D 0, + /* PFD3 clock is gated */ + RT500_CLKCTL1_AUDIOPLL0PFD_PFD3_CLKGATE_GATED =3D 1, +} RT500_CLKCTL1_AUDIOPLL0PFD_PFD3_CLKGATE_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_AUDIOPLLCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_AUDIOPLLCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_AUDIOPLLCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_AUDIOPLLCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_AUDIOPLLCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_AUDIOPLLCLKDIV_HALT_Enum; + +typedef enum { + /* The Divider change has finished */ + RT500_CLKCTL1_AUDIOPLLCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed */ + RT500_CLKCTL1_AUDIOPLLCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_AUDIOPLLCLKDIV_REQFLAG_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_DSPCPUCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_DSPCPUCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_DSPCPUCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_DSPCPUCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_DSPCPUCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_DSPCPUCLKDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_DSPCPUCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed. */ + RT500_CLKCTL1_DSPCPUCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_DSPCPUCLKDIV_REQFLAG_Enum; + +typedef enum { + /* FRO_DIV1 Clock */ + RT500_CLKCTL1_DSPCPUCLKSELA_SEL_FRO =3D 0, + /* OSC_CLK Clock */ + RT500_CLKCTL1_DSPCPUCLKSELA_SEL_OSC_CLK =3D 1, + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL1_DSPCPUCLKSELA_SEL_LPOSC =3D 2, +} RT500_CLKCTL1_DSPCPUCLKSELA_SEL_Enum; + +typedef enum { + /* MAINCLKSELA 1st Stage Clock */ + RT500_CLKCTL1_DSPCPUCLKSELB_SEL_MAINCLKSELA =3D 0, + /* Main System PLL Clock */ + RT500_CLKCTL1_DSPCPUCLKSELB_SEL_MAIN_PLL =3D 1, + /* DSP System PLL Clock */ + RT500_CLKCTL1_DSPCPUCLKSELB_SEL_DSP_PLL =3D 2, + /* RTC 32 KHz Clock */ + RT500_CLKCTL1_DSPCPUCLKSELB_SEL_RTC_32KHZ =3D 3, +} RT500_CLKCTL1_DSPCPUCLKSELB_SEL_Enum; + +typedef enum { + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL1_OSEVENTTFCLKSEL_SEL_LPOSC =3D 0, + /* RTC 32 KHz Clock */ + RT500_CLKCTL1_OSEVENTTFCLKSEL_SEL_RTC_32KHZ =3D 1, + /* HCLK Free-Running Clock (Global Time Stamping) */ + RT500_CLKCTL1_OSEVENTTFCLKSEL_SEL_TEAL =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_OSEVENTTFCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_OSEVENTTFCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG0CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG0CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG0CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG0CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG0CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC0FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC0FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC0FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC0FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG1CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG1CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG1CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG1CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG1CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC1FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC1FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC1FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC1FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG2CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG2CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG2CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG2CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG2CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC2FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC2FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC2FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC2FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG3CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG3CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG3CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG3CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG3CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC3FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC3FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC3FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC3FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG4CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG4CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG4CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG4CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG4CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC4FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC4FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC4FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC4FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG5CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG5CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG5CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG5CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG5CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC5FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC5FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC5FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC5FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG6CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG6CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG6CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG6CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG6CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC6FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC6FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC6FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC6FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG7CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG7CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG7CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG7CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG7CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC7FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC7FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC7FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC7FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG8CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG8CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG8CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG8CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG8CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC8FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC8FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC8FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC8FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG9CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG9CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG9CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG9CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG9CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC9FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC9FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC9FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC9FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG10CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG10CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG10CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG10CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG10CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC10FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC10FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC10FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC10FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG11CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG11CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG11CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG11CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG11CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC11FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC11FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC11FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC11FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG12CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG12CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG12CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG12CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG12CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC12FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC12FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC12FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC12FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG13CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG13CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG13CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG13CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG13CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC13FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC13FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC13FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC13FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG14CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG14CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG14CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG14CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG14CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC14FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC14FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC14FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC14FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG15CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG15CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG15CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG15CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG15CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC15FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC15FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC15FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC15FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG16CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG16CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG16CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG16CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG16CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FC16FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FC16FCLKSEL_SEL_MASTER_CLOCK =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FC16FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FC16FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_FRG17CLKSEL_SEL_MAIN =3D 0, + /* FRG PLL Clock */ + RT500_CLKCTL1_FRG17CLKSEL_SEL_FRG_PLL =3D 1, + /* FRO_DIV4 clock */ + RT500_CLKCTL1_FRG17CLKSEL_SEL_FRRO_DIV4 =3D 2, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FRG17CLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FRG17CLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV2 Clock */ + RT500_CLKCTL1_FLEXIOCLKSEL_SEL_FRRO_DIV2 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_FLEXIOCLKSEL_SEL_OSC_CLK =3D 1, + /* Master Clock In */ + RT500_CLKCTL1_FLEXIOCLKSEL_SEL_MASTER_CLKIN =3D 2, + /* FC17 FRG Clock */ + RT500_CLKCTL1_FLEXIOCLKSEL_SEL_FC17_FRG =3D 3, + /* None, output gated to reduce power */ + RT500_CLKCTL1_FLEXIOCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_FLEXIOCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_FLEXIOCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_FLEXIOCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_FLEXIOCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_FLEXIOCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_FLEXIOCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_FLEXIOCLKDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_FLEXIOCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed */ + RT500_CLKCTL1_FLEXIOCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_FLEXIOCLKDIV_REQFLAG_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_FRGPLLCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_FRGPLLCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_FRGPLLCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_FRGPLLCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_FRGPLLCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_FRGPLLCLKDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_FRGPLLCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed. */ + RT500_CLKCTL1_FRGPLLCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_FRGPLLCLKDIV_REQFLAG_Enum; + +typedef enum { + /* FRO Clock (Divided-by-4 selection) */ + RT500_CLKCTL1_DMIC0FCLKSEL_SEL_FRRO_DIV4 =3D 0, + /* Audio PLL Clock */ + RT500_CLKCTL1_DMIC0FCLKSEL_SEL_AUDIO_PLL =3D 1, + /* Master Clock In */ + RT500_CLKCTL1_DMIC0FCLKSEL_SEL_MASTER_CLOCK =3D 2, + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL1_DMIC0FCLKSEL_SEL_LPOSC =3D 3, + /* 32 KHz Wake Clock */ + RT500_CLKCTL1_DMIC0FCLKSEL_SEL_WAKE_32KHZ =3D 4, + /* None, output gated to reduce power */ + RT500_CLKCTL1_DMIC0FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_DMIC0FCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_DMIC0FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_DMIC0FCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_DMIC0FCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_DMIC0FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_DMIC0FCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_DMIC0FCLKDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_DMIC0FCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed. */ + RT500_CLKCTL1_DMIC0FCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_DMIC0FCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_CT32BITFCLKSEL_SEL_MAIN =3D 0, + /* FRO_DIV1 Clock */ + RT500_CLKCTL1_CT32BITFCLKSEL_SEL_FRO =3D 1, + /* Audio PLL Clock */ + RT500_CLKCTL1_CT32BITFCLKSEL_SEL_AUDIO_PLL =3D 2, + /* Master Clock In */ + RT500_CLKCTL1_CT32BITFCLKSEL_SEL_MASTER_CLOCK =3D 3, + /* 32 KHZ Wake Clock */ + RT500_CLKCTL1_CT32BITFCLKSEL_SEL_WAKE_32KHZ =3D 4, + /* None, output gated to reduce power */ + RT500_CLKCTL1_CT32BITFCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_CT32BITFCLKSEL_SEL_Enum; + +typedef enum { + /* FRO_DIV8 Clock */ + RT500_CLKCTL1_AUDIOMCLKSEL_SEL_FRRO_DIV8 =3D 0, + /* AUDIO PLL Clock (Shared Domain) */ + RT500_CLKCTL1_AUDIOMCLKSEL_SEL_AUDIO_PLL =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_AUDIOMCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_AUDIOMCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_AUDIOMCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_AUDIOMCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_AUDIOMCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_AUDIOMCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_AUDIOMCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_AUDIOMCLKDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_AUDIOMCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed. */ + RT500_CLKCTL1_AUDIOMCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_AUDIOMCLKDIV_REQFLAG_Enum; + +typedef enum { + /* OSC_CLK Clock */ + RT500_CLKCTL1_CLKOUTSEL0_SEL_OSC_CLK =3D 0, + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL1_CLKOUTSEL0_SEL_LPOSC =3D 1, + /* FRO_DIV2 Clock */ + RT500_CLKCTL1_CLKOUTSEL0_SEL_FRO =3D 2, + /* Main Clock */ + RT500_CLKCTL1_CLKOUTSEL0_SEL_MAIN =3D 3, + /* DSP Main Clock */ + RT500_CLKCTL1_CLKOUTSEL0_SEL_DSP_MAIN =3D 4, + /* None, output gated to reduce power */ + RT500_CLKCTL1_CLKOUTSEL0_SEL_NONE =3D 7, +} RT500_CLKCTL1_CLKOUTSEL0_SEL_Enum; + +typedef enum { + /* CLKOUTSEL0 Multiplexed Output */ + RT500_CLKCTL1_CLKOUTSEL1_SEL_CLKOUTSEL0_MUX_OUT =3D 0, + /* Main System PLL Clock */ + RT500_CLKCTL1_CLKOUTSEL1_SEL_MAIN_PLL =3D 1, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL1_CLKOUTSEL1_SEL_SYSPLL0_AUX0_PLL =3D 2, + /* DSP PLL Clock */ + RT500_CLKCTL1_CLKOUTSEL1_SEL_DSP_PLL =3D 3, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL1_CLKOUTSEL1_SEL_SYSPLL0_AUX1_PLL =3D 4, + /* AUDIO PLL Clock */ + RT500_CLKCTL1_CLKOUTSEL1_SEL_AUDIO_PLL =3D 5, + /* 32 KHz RTC Clock */ + RT500_CLKCTL1_CLKOUTSEL1_SEL_RTC_32KHZ =3D 6, + /* None, output gated to reduce power */ + RT500_CLKCTL1_CLKOUTSEL1_SEL_NONE =3D 7, +} RT500_CLKCTL1_CLKOUTSEL1_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_CLKOUTFCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_CLKOUTFCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_CLKOUTFCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_CLKOUTFCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_CLKOUTFCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_CLKOUTFCLKDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_CLKOUTFCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed */ + RT500_CLKCTL1_CLKOUTFCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_CLKOUTFCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_I3C01FCLKSEL_SEL_MAIN =3D 0, + /* FRO_DIV8 Clock */ + RT500_CLKCTL1_I3C01FCLKSEL_SEL_FRRO_DIV8 =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_I3C01FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_I3C01FCLKSEL_SEL_Enum; + +typedef enum { + /* I3C0 FCLK */ + RT500_CLKCTL1_I3C01FCLKSTCSEL_SEL_I3C0 =3D 0, + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL1_I3C01FCLKSTCSEL_SEL_LPOSC =3D 1, + /* None, output gated to reduce power */ + RT500_CLKCTL1_I3C01FCLKSTCSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_I3C01FCLKSTCSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_I3C01FCLKSTCDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_I3C01FCLKSTCDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_I3C01FCLKSTCDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_I3C01FCLKSTCDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_I3C01FCLKSTCDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_I3C01FCLKSTCDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_I3C01FCLKSTCDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed. */ + RT500_CLKCTL1_I3C01FCLKSTCDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_I3C01FCLKSTCDIV_REQFLAG_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_I3C01FCLKSDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_I3C01FCLKSDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_I3C01FCLKSDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_I3C01FCLKSDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_I3C01FCLKSDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_I3C01FCLKSDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_I3C01FCLKSDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed. */ + RT500_CLKCTL1_I3C01FCLKSDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_I3C01FCLKSDIV_REQFLAG_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_I3C01FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_I3C01FCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_I3C01FCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_I3C01FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_I3C01FCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_I3C01FCLKDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_I3C01FCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed. */ + RT500_CLKCTL1_I3C01FCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_I3C01FCLKDIV_REQFLAG_Enum; + +typedef enum { + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL1_I3C01FCLKSTSTCLKSEL_SEL_LPOSC =3D 0, + /* None, output gated to reduce power */ + RT500_CLKCTL1_I3C01FCLKSTSTCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_I3C01FCLKSTSTCLKSEL_SEL_Enum; + +typedef enum { + /* Low Power Oscillator Clock (LPOSC) */ + RT500_CLKCTL1_WDT1FCLKSEL_SEL_LPOSC =3D 0, + /* None, output gated to reduce power */ + RT500_CLKCTL1_WDT1FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_WDT1FCLKSEL_SEL_Enum; + +typedef enum { + /* Main Clock */ + RT500_CLKCTL1_ACMP0FCLKSEL_SEL_MAIN =3D 0, + /* FRO_DIV4 Clock */ + RT500_CLKCTL1_ACMP0FCLKSEL_SEL_FRRO_DIV4 =3D 1, + /* SYSPLL0 AUX0_PLL_Clock */ + RT500_CLKCTL1_ACMP0FCLKSEL_SEL_SYSPLL0_AUX0_PLL =3D 2, + /* SYSPLL0 AUX1_PLL_Clock */ + RT500_CLKCTL1_ACMP0FCLKSEL_SEL_SYSPLL0_AUX1_PLL =3D 3, + /* None, output gated to reduce power */ + RT500_CLKCTL1_ACMP0FCLKSEL_SEL_NONE =3D 7, +} RT500_CLKCTL1_ACMP0FCLKSEL_SEL_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_ACMP0FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =3D 0, + /* Reset the Divider Counter */ + RT500_CLKCTL1_ACMP0FCLKDIV_RESET_DIVIDER_COUNTER_RESET =3D 1, +} RT500_CLKCTL1_ACMP0FCLKDIV_RESET_Enum; + +typedef enum { + /* No effect */ + RT500_CLKCTL1_ACMP0FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =3D 0, + /* Halt (stop) the Divider Counter */ + RT500_CLKCTL1_ACMP0FCLKDIV_HALT_DIVIDER_COUNTER_HALT =3D 1, +} RT500_CLKCTL1_ACMP0FCLKDIV_HALT_Enum; + +typedef enum { + /* + * The Divider change has finished (clock being divided must be runnin= g for + * this status to change). + */ + RT500_CLKCTL1_ACMP0FCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =3D 0, + /* The Divider value has changed. */ + RT500_CLKCTL1_ACMP0FCLKDIV_REQFLAG_REQFLAG_CHANGED =3D 1, +} RT500_CLKCTL1_ACMP0FCLKDIV_REQFLAG_Enum; + + +#define RT500_CLKCTL1_REGISTER_ACCESS_INFO_ARRAY(_name) \ + struct RegisterAccessInfo _name[RT500_CLKCTL1_REGS_NO] =3D { \ + [0 ... RT500_CLKCTL1_REGS_NO - 1] =3D { \ + .name =3D "", \ + .addr =3D -1, \ + }, \ + [R_RT500_CLKCTL1_PSCCTL0] =3D { \ + .name =3D "PSCCTL0", \ + .addr =3D 0x10, \ + .ro =3D 0xD40000FF, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_PSCCTL1] =3D { \ + .name =3D "PSCCTL1", \ + .addr =3D 0x14, \ + .ro =3D 0x4E7EFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_PSCCTL2] =3D { \ + .name =3D "PSCCTL2", \ + .addr =3D 0x18, \ + .ro =3D 0x3FFCFA60, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_PSCCTL0_SET] =3D { \ + .name =3D "PSCCTL0_SET", \ + .addr =3D 0x40, \ + .ro =3D 0xD40000FF, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_PSCCTL1_SET] =3D { \ + .name =3D "PSCCTL1_SET", \ + .addr =3D 0x44, \ + .ro =3D 0x4E7EFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_PSCCTL2_SET] =3D { \ + .name =3D "PSCCTL2_SET", \ + .addr =3D 0x48, \ + .ro =3D 0x3FFCFA60, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_PSCCTL0_CLR] =3D { \ + .name =3D "PSCCTL0_CLR", \ + .addr =3D 0x70, \ + .ro =3D 0xD40000FF, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_PSCCTL1_CLR] =3D { \ + .name =3D "PSCCTL1_CLR", \ + .addr =3D 0x74, \ + .ro =3D 0x4E7EFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_PSCCTL2_CLR] =3D { \ + .name =3D "PSCCTL2_CLR", \ + .addr =3D 0x78, \ + .ro =3D 0x3FFCFA60, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_AUDIOPLL0CLKSEL] =3D { \ + .name =3D "AUDIOPLL0CLKSEL", \ + .addr =3D 0x200, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_AUDIOPLL0CTL0] =3D { \ + .name =3D "AUDIOPLL0CTL0", \ + .addr =3D 0x204, \ + .ro =3D 0xFF00DFFC, \ + .reset =3D 0x160002, \ + }, \ + [R_RT500_CLKCTL1_AUDIOPLL0LOCKTIMEDIV2] =3D { \ + .name =3D "AUDIOPLL0LOCKTIMEDIV2", \ + .addr =3D 0x20C, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xCAFE, \ + }, \ + [R_RT500_CLKCTL1_AUDIOPLL0NUM] =3D { \ + .name =3D "AUDIOPLL0NUM", \ + .addr =3D 0x210, \ + .ro =3D 0xC0000000, \ + .reset =3D 0x4DD2F15, \ + }, \ + [R_RT500_CLKCTL1_AUDIOPLL0DENOM] =3D { \ + .name =3D "AUDIOPLL0DENOM", \ + .addr =3D 0x214, \ + .ro =3D 0xC0000000, \ + .reset =3D 0x1FFFFFDB, \ + }, \ + [R_RT500_CLKCTL1_AUDIOPLL0PFD] =3D { \ + .name =3D "AUDIOPLL0PFD", \ + .addr =3D 0x218, \ + .ro =3D 0x0, \ + .reset =3D 0x80808080, \ + }, \ + [R_RT500_CLKCTL1_AUDIOPLLCLKDIV] =3D { \ + .name =3D "AUDIOPLLCLKDIV", \ + .addr =3D 0x240, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_DSPCPUCLKDIV] =3D { \ + .name =3D "DSPCPUCLKDIV", \ + .addr =3D 0x400, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_DSPCPUCLKSELA] =3D { \ + .name =3D "DSPCPUCLKSELA", \ + .addr =3D 0x430, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_DSPCPUCLKSELB] =3D { \ + .name =3D "DSPCPUCLKSELB", \ + .addr =3D 0x434, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_OSEVENTTFCLKSEL] =3D { \ + .name =3D "OSEVENTTFCLKSEL", \ + .addr =3D 0x480, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_FRG0CLKSEL] =3D { \ + .name =3D "FRG0CLKSEL", \ + .addr =3D 0x500, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG0CTL] =3D { \ + .name =3D "FRG0CTL", \ + .addr =3D 0x504, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC0FCLKSEL] =3D { \ + .name =3D "FC0FCLKSEL", \ + .addr =3D 0x508, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG1CLKSEL] =3D { \ + .name =3D "FRG1CLKSEL", \ + .addr =3D 0x520, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG1CTL] =3D { \ + .name =3D "FRG1CTL", \ + .addr =3D 0x524, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC1FCLKSEL] =3D { \ + .name =3D "FC1FCLKSEL", \ + .addr =3D 0x528, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG2CLKSEL] =3D { \ + .name =3D "FRG2CLKSEL", \ + .addr =3D 0x540, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG2CTL] =3D { \ + .name =3D "FRG2CTL", \ + .addr =3D 0x544, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC2FCLKSEL] =3D { \ + .name =3D "FC2FCLKSEL", \ + .addr =3D 0x548, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG3CLKSEL] =3D { \ + .name =3D "FRG3CLKSEL", \ + .addr =3D 0x560, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG3CTL] =3D { \ + .name =3D "FRG3CTL", \ + .addr =3D 0x564, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC3FCLKSEL] =3D { \ + .name =3D "FC3FCLKSEL", \ + .addr =3D 0x568, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG4CLKSEL] =3D { \ + .name =3D "FRG4CLKSEL", \ + .addr =3D 0x580, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG4CTL] =3D { \ + .name =3D "FRG4CTL", \ + .addr =3D 0x584, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC4FCLKSEL] =3D { \ + .name =3D "FC4FCLKSEL", \ + .addr =3D 0x588, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG5CLKSEL] =3D { \ + .name =3D "FRG5CLKSEL", \ + .addr =3D 0x5A0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG5CTL] =3D { \ + .name =3D "FRG5CTL", \ + .addr =3D 0x5A4, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC5FCLKSEL] =3D { \ + .name =3D "FC5FCLKSEL", \ + .addr =3D 0x5A8, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG6CLKSEL] =3D { \ + .name =3D "FRG6CLKSEL", \ + .addr =3D 0x5C0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG6CTL] =3D { \ + .name =3D "FRG6CTL", \ + .addr =3D 0x5C4, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC6FCLKSEL] =3D { \ + .name =3D "FC6FCLKSEL", \ + .addr =3D 0x5C8, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG7CLKSEL] =3D { \ + .name =3D "FRG7CLKSEL", \ + .addr =3D 0x5E0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG7CTL] =3D { \ + .name =3D "FRG7CTL", \ + .addr =3D 0x5E4, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC7FCLKSEL] =3D { \ + .name =3D "FC7FCLKSEL", \ + .addr =3D 0x5E8, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG8CLKSEL] =3D { \ + .name =3D "FRG8CLKSEL", \ + .addr =3D 0x600, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG8CTL] =3D { \ + .name =3D "FRG8CTL", \ + .addr =3D 0x604, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC8FCLKSEL] =3D { \ + .name =3D "FC8FCLKSEL", \ + .addr =3D 0x608, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG9CLKSEL] =3D { \ + .name =3D "FRG9CLKSEL", \ + .addr =3D 0x620, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG9CTL] =3D { \ + .name =3D "FRG9CTL", \ + .addr =3D 0x624, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC9FCLKSEL] =3D { \ + .name =3D "FC9FCLKSEL", \ + .addr =3D 0x628, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG10CLKSEL] =3D { \ + .name =3D "FRG10CLKSEL", \ + .addr =3D 0x640, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG10CTL] =3D { \ + .name =3D "FRG10CTL", \ + .addr =3D 0x644, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC10FCLKSEL] =3D { \ + .name =3D "FC10FCLKSEL", \ + .addr =3D 0x648, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG11CLKSEL] =3D { \ + .name =3D "FRG11CLKSEL", \ + .addr =3D 0x660, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG11CTL] =3D { \ + .name =3D "FRG11CTL", \ + .addr =3D 0x664, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC11FCLKSEL] =3D { \ + .name =3D "FC11FCLKSEL", \ + .addr =3D 0x668, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG12CLKSEL] =3D { \ + .name =3D "FRG12CLKSEL", \ + .addr =3D 0x680, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG12CTL] =3D { \ + .name =3D "FRG12CTL", \ + .addr =3D 0x684, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC12FCLKSEL] =3D { \ + .name =3D "FC12FCLKSEL", \ + .addr =3D 0x688, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG13CLKSEL] =3D { \ + .name =3D "FRG13CLKSEL", \ + .addr =3D 0x6A0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG13CTL] =3D { \ + .name =3D "FRG13CTL", \ + .addr =3D 0x6A4, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC13FCLKSEL] =3D { \ + .name =3D "FC13FCLKSEL", \ + .addr =3D 0x6A8, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG14CLKSEL] =3D { \ + .name =3D "FRG14CLKSEL", \ + .addr =3D 0x6C0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG14CTL] =3D { \ + .name =3D "FRG14CTL", \ + .addr =3D 0x6C4, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC14FCLKSEL] =3D { \ + .name =3D "FC14FCLKSEL", \ + .addr =3D 0x6C8, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG15CLKSEL] =3D { \ + .name =3D "FRG15CLKSEL", \ + .addr =3D 0x6E0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG15CTL] =3D { \ + .name =3D "FRG15CTL", \ + .addr =3D 0x6E4, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC15FCLKSEL] =3D { \ + .name =3D "FC15FCLKSEL", \ + .addr =3D 0x6E8, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG16CLKSEL] =3D { \ + .name =3D "FRG16CLKSEL", \ + .addr =3D 0x700, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG16CTL] =3D { \ + .name =3D "FRG16CTL", \ + .addr =3D 0x704, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FC16FCLKSEL] =3D { \ + .name =3D "FC16FCLKSEL", \ + .addr =3D 0x708, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG17CLKSEL] =3D { \ + .name =3D "FRG17CLKSEL", \ + .addr =3D 0x720, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FRG17CTL] =3D { \ + .name =3D "FRG17CTL", \ + .addr =3D 0x724, \ + .ro =3D 0xFFFF0000, \ + .reset =3D 0xFF, \ + }, \ + [R_RT500_CLKCTL1_FLEXIOCLKSEL] =3D { \ + .name =3D "FLEXIOCLKSEL", \ + .addr =3D 0x728, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_FLEXIOCLKDIV] =3D { \ + .name =3D "FLEXIOCLKDIV", \ + .addr =3D 0x740, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_FRGPLLCLKDIV] =3D { \ + .name =3D "FRGPLLCLKDIV", \ + .addr =3D 0x760, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_DMIC0FCLKSEL] =3D { \ + .name =3D "DMIC0FCLKSEL", \ + .addr =3D 0x780, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_DMIC0FCLKDIV] =3D { \ + .name =3D "DMIC0FCLKDIV", \ + .addr =3D 0x784, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_CT32BITFCLKSEL0] =3D { \ + .name =3D "CT32BITFCLKSEL0", \ + .addr =3D 0x7A0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_CT32BITFCLKSEL1] =3D { \ + .name =3D "CT32BITFCLKSEL1", \ + .addr =3D 0x7A4, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_CT32BITFCLKSEL2] =3D { \ + .name =3D "CT32BITFCLKSEL2", \ + .addr =3D 0x7A8, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_CT32BITFCLKSEL3] =3D { \ + .name =3D "CT32BITFCLKSEL3", \ + .addr =3D 0x7AC, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_CT32BITFCLKSEL4] =3D { \ + .name =3D "CT32BITFCLKSEL4", \ + .addr =3D 0x7B0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_AUDIOMCLKSEL] =3D { \ + .name =3D "AUDIOMCLKSEL", \ + .addr =3D 0x7C0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_AUDIOMCLKDIV] =3D { \ + .name =3D "AUDIOMCLKDIV", \ + .addr =3D 0x7C4, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_CLKOUTSEL0] =3D { \ + .name =3D "CLKOUTSEL0", \ + .addr =3D 0x7E0, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_CLKOUTSEL1] =3D { \ + .name =3D "CLKOUTSEL1", \ + .addr =3D 0x7E4, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_CLKOUTFCLKDIV] =3D { \ + .name =3D "CLKOUTFCLKDIV", \ + .addr =3D 0x7E8, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_I3C01FCLKSEL] =3D { \ + .name =3D "I3C01FCLKSEL", \ + .addr =3D 0x800, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_I3C01FCLKSTCSEL] =3D { \ + .name =3D "I3C01FCLKSTCSEL", \ + .addr =3D 0x804, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_I3C01FCLKSTCDIV] =3D { \ + .name =3D "I3C01FCLKSTCDIV", \ + .addr =3D 0x808, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_I3C01FCLKSDIV] =3D { \ + .name =3D "I3C01FCLKSDIV", \ + .addr =3D 0x80C, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_I3C01FCLKDIV] =3D { \ + .name =3D "I3C01FCLKDIV", \ + .addr =3D 0x810, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + [R_RT500_CLKCTL1_I3C01FCLKSTSTCLKSEL] =3D { \ + .name =3D "I3C01FCLKSTSTCLKSEL", \ + .addr =3D 0x814, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_WDT1FCLKSEL] =3D { \ + .name =3D "WDT1FCLKSEL", \ + .addr =3D 0x820, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_CLKCTL1_ACMP0FCLKSEL] =3D { \ + .name =3D "ACMP0FCLKSEL", \ + .addr =3D 0x830, \ + .ro =3D 0xFFFFFFF8, \ + .reset =3D 0x7, \ + }, \ + [R_RT500_CLKCTL1_ACMP0FCLKDIV] =3D { \ + .name =3D "ACMP0FCLKDIV", \ + .addr =3D 0x834, \ + .ro =3D 0x1FFFFF00, \ + .reset =3D 0x40000000, \ + }, \ + } diff --git a/include/hw/misc/rt500_clk_freqs.h b/include/hw/misc/rt500_clk_= freqs.h new file mode 100644 index 0000000000..1e366d4967 --- /dev/null +++ b/include/hw/misc/rt500_clk_freqs.h @@ -0,0 +1,18 @@ +/* + * QEMU model for RT500 Clock Controller + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_MISC_RT500_CLK_FREQS_H +#define HW_MISC_RT500_CLK_FREQS_H + +#define RTC32KHZ_CLK_HZ 32000 +#define LPOSC_CLK_HZ 1000000 + +#endif /* HW_MISC_RT500_CLK_FREQS_H */ diff --git a/include/hw/misc/rt500_clkctl0.h b/include/hw/misc/rt500_clkctl= 0.h new file mode 100644 index 0000000000..890743a2ce --- /dev/null +++ b/include/hw/misc/rt500_clkctl0.h @@ -0,0 +1,35 @@ +/* + * QEMU model for RT500 Clock Controller + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_MISC_RT500_CLKCTL0_H +#define HW_MISC_RT500_CLKCTL0_H + +#include "hw/arm/svd/rt500_clkctl0.h" +#include "hw/sysbus.h" + +#define TYPE_RT500_CLKCTL0 "rt500-clkctl0" +#define RT500_CLKCTL0(o) OBJECT_CHECK(RT500ClkCtl0State, o, TYPE_RT500_CLK= CTL0) + +#define SYSTICKFCLKSEL_DIVOUT 0 +#define SYSTICKFCLKSEL_LPOSC 1 +#define SYSTICKFCLKSEL_32KHZRTC 2 +#define SYSTICKFCLKSEL_NONE 7 + +typedef struct { + SysBusDevice parent_obj; + + MemoryRegion mmio; + uint32_t regs[RT500_CLKCTL0_REGS_NO]; + Clock *systick_clk; + Clock *sysclk; +} RT500ClkCtl0State; + +#endif /* HW_MISC_RT500_CLKCTL0_H */ diff --git a/include/hw/misc/rt500_clkctl1.h b/include/hw/misc/rt500_clkctl= 1.h new file mode 100644 index 0000000000..8b012b1357 --- /dev/null +++ b/include/hw/misc/rt500_clkctl1.h @@ -0,0 +1,36 @@ +/* + * QEMU model for RT500 Clock Controller + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + + +#ifndef HW_MISC_RT500_CLKCTL1_H +#define HW_MISC_RT500_CLKCTL1_H + +#include "hw/arm/svd/rt500_clkctl1.h" +#include "hw/sysbus.h" + +#define TYPE_RT500_CLKCTL1 "rt500-clkctl1" +#define RT500_CLKCTL1(o) OBJECT_CHECK(RT500ClkCtl1State, o, TYPE_RT500_CLK= CTL1) + +#define OSEVENTTFCLKSEL_LPOSC 0 +#define OSEVENTTFCLKSEL_32KHZRTC 1 +#define OSEVENTTFCLKSEL_HCLK 2 +#define OSEVENTTFCLKSEL_NONE 7 + +typedef struct { + SysBusDevice parent_obj; + + MemoryRegion mmio; + uint32_t regs[RT500_CLKCTL1_REGS_NO]; + Clock *sysclk; + Clock *ostimer_clk; +} RT500ClkCtl1State; + +#endif /* HW_MISC_RT500_CLKCTL1_H */ diff --git a/hw/misc/rt500_clkctl0.c b/hw/misc/rt500_clkctl0.c new file mode 100644 index 0000000000..7e7b176719 --- /dev/null +++ b/hw/misc/rt500_clkctl0.c @@ -0,0 +1,253 @@ +/* + * QEMU model for RT500 Clock Controller + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/clock.h" +#include "hw/irq.h" +#include "hw/qdev-clock.h" +#include "hw/qdev-properties.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "migration/vmstate.h" +#include "hw/misc/rt500_clkctl0.h" +#include "hw/misc/rt500_clk_freqs.h" + +#include "trace.h" + +#define REG(s, reg) (s->regs[R_RT500_CLKCTL0_##reg]) +#define RF_RD(s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, RT500_CLKCTL0_##reg, field) +#define RF_WR(s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, RT500_CLKCTL0_##reg, field, val) + +static const RT500_CLKCTL0_REGISTER_ACCESS_INFO_ARRAY(reg_info); + +static MemTxResult rt500_clkctl0_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + RT500ClkCtl0State *s =3D opaque; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + + switch (addr) { + case A_RT500_CLKCTL0_PSCCTL0_SET: + case A_RT500_CLKCTL0_PSCCTL1_SET: + case A_RT500_CLKCTL0_PSCCTL2_SET: + case A_RT500_CLKCTL0_PSCCTL0_CLR: + case A_RT500_CLKCTL0_PSCCTL1_CLR: + case A_RT500_CLKCTL0_PSCCTL2_CLR: + /* write only registers */ + return MEMTX_ERROR; + default: + *data =3D s->regs[addr / 4]; + break; + } + + trace_rt500_clkctl0_reg_read(rai->name, addr, *data); + return MEMTX_OK; +} + +static inline void set_systick_clk_from_div(RT500ClkCtl0State *s) +{ + uint32_t div =3D RF_RD(s, SYSTICKFCLKDIV, DIV) + 1; + uint32_t rate =3D clock_get_hz(s->sysclk); + + clock_set_hz(s->systick_clk, rate / div); +} + +static MemTxResult rt500_clkctl0_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + RT500ClkCtl0State *s =3D opaque; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D rai, + }; + + trace_rt500_clkctl0_reg_write(rai->name, addr, value); + + switch (addr) { + case A_RT500_CLKCTL0_PSCCTL0: + case A_RT500_CLKCTL0_PSCCTL1: + case A_RT500_CLKCTL0_PSCCTL2: + { + register_write(&ri, value, ~0, NULL, false); + break; + } + case A_RT500_CLKCTL0_PSCCTL0_SET: + case A_RT500_CLKCTL0_PSCCTL1_SET: + case A_RT500_CLKCTL0_PSCCTL2_SET: + { + uint32_t tmp; + + tmp =3D A_RT500_CLKCTL0_PSCCTL0 + (addr - A_RT500_CLKCTL0_PSCCTL0_= SET); + s->regs[tmp / 4] |=3D value; + break; + } + case A_RT500_CLKCTL0_PSCCTL0_CLR: + case A_RT500_CLKCTL0_PSCCTL1_CLR: + case A_RT500_CLKCTL0_PSCCTL2_CLR: + { + uint32_t tmp; + + tmp =3D A_RT500_CLKCTL0_PSCCTL0 + (addr - A_RT500_CLKCTL0_PSCCTL0_= CLR); + s->regs[tmp / 4] &=3D ~value; + break; + } + default: + register_write(&ri, value, ~0, NULL, false); + } + + switch (addr) { + case A_RT500_CLKCTL0_SYSPLL0PFD: + { + if (!RF_RD(s, SYSPLL0PFD, PFD0_CLKGATE)) { + RF_WR(s, SYSPLL0PFD, PFD0_CLKRDY, 1); + } else { + RF_WR(s, SYSPLL0PFD, PFD0_CLKRDY, 0); + } + if (!RF_RD(s, SYSPLL0PFD, PFD1_CLKGATE)) { + RF_WR(s, SYSPLL0PFD, PFD1_CLKRDY, 1); + } else { + RF_WR(s, SYSPLL0PFD, PFD1_CLKRDY, 0); + } + if (!RF_RD(s, SYSPLL0PFD, PFD2_CLKGATE)) { + RF_WR(s, SYSPLL0PFD, PFD2_CLKRDY, 1); + } else { + RF_WR(s, SYSPLL0PFD, PFD2_CLKRDY, 0); + } + if (!RF_RD(s, SYSPLL0PFD, PFD3_CLKGATE)) { + RF_WR(s, SYSPLL0PFD, PFD3_CLKRDY, 1); + } else { + RF_WR(s, SYSPLL0PFD, PFD3_CLKRDY, 0); + } + break; + } + case A_RT500_CLKCTL0_SYSTICKFCLKSEL: + { + switch (RF_RD(s, SYSTICKFCLKSEL, SEL)) { + case SYSTICKFCLKSEL_DIVOUT: + { + set_systick_clk_from_div(s); + break; + } + case SYSTICKFCLKSEL_LPOSC: + { + clock_set_hz(s->systick_clk, LPOSC_CLK_HZ); + break; + } + case SYSTICKFCLKSEL_32KHZRTC: + { + clock_set_hz(s->systick_clk, RTC32KHZ_CLK_HZ); + break; + } + case SYSTICKFCLKSEL_NONE: + { + clock_set_hz(s->systick_clk, 0); + break; + } + } + clock_propagate(s->systick_clk); + break; + } + case A_RT500_CLKCTL0_SYSTICKFCLKDIV: + { + if (RF_RD(s, SYSTICKFCLKSEL, SEL) =3D=3D SYSTICKFCLKSEL_DIVOUT) { + set_systick_clk_from_div(s); + clock_propagate(s->systick_clk); + } + break; + } + } + + return MEMTX_OK; +} + +static const MemoryRegionOps rt500_clkctl0_ops =3D { + .read_with_attrs =3D rt500_clkctl0_read, + .write_with_attrs =3D rt500_clkctl0_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + .unaligned =3D false, + }, +}; + +static void rt500_clkctl0_reset_enter(Object *obj, ResetType type) +{ + RT500ClkCtl0State *s =3D RT500_CLKCTL0(obj); + + for (int i =3D 0; i < RT500_CLKCTL0_REGS_NO; i++) { + hwaddr addr =3D reg_info[i].addr; + + if (addr !=3D -1) { + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D ®_info[i], + }; + + register_reset(&ri); + } + } + + /* clock OK immediately after reset */ + REG(s, FROCLKSTATUS) =3D 0x00000001; +} + +static void rt500_clkctl0_init(Object *obj) +{ + RT500ClkCtl0State *s =3D RT500_CLKCTL0(obj); + + memory_region_init_io(&s->mmio, obj, &rt500_clkctl0_ops, s, + TYPE_RT500_CLKCTL0, sizeof(s->regs)); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); + s->sysclk =3D qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0); + s->systick_clk =3D qdev_init_clock_out(DEVICE(s), "systick_clk"); +} + +static const VMStateDescription vmstate_rt500_clkctl0 =3D { + .name =3D "rt500-clkctl0", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32_ARRAY(regs, RT500ClkCtl0State, RT500_CLKCTL0_REGS_N= O), + VMSTATE_CLOCK(systick_clk, RT500ClkCtl0State), + VMSTATE_END_OF_LIST() + } +}; + +static void rt500_clkctl0_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + rc->phases.enter =3D rt500_clkctl0_reset_enter; + dc->vmsd =3D &vmstate_rt500_clkctl0; +} + +static const TypeInfo rt500_clkctl0_types[] =3D { + { + .name =3D TYPE_RT500_CLKCTL0, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(RT500ClkCtl0State), + .instance_init =3D rt500_clkctl0_init, + .class_init =3D rt500_clkctl0_class_init, + }, +}; + +DEFINE_TYPES(rt500_clkctl0_types); + diff --git a/hw/misc/rt500_clkctl1.c b/hw/misc/rt500_clkctl1.c new file mode 100644 index 0000000000..ed234ce0f6 --- /dev/null +++ b/hw/misc/rt500_clkctl1.c @@ -0,0 +1,238 @@ +/* + * QEMU model for RT500 Clock Controller + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/clock.h" +#include "hw/irq.h" +#include "hw/qdev-clock.h" +#include "hw/qdev-properties.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "migration/vmstate.h" +#include "hw/misc/rt500_clkctl1.h" +#include "hw/misc/rt500_clk_freqs.h" + +#include "trace.h" + +#define REG(s, reg) (s->regs[R_RT500_CLKCTL1_##reg]) +#define RF_RD(s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, RT500_CLKCTL1_##reg, field) +#define RF_WR(s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, RT500_CLKCTL1_##reg, field, val) + +static RT500_CLKCTL1_REGISTER_ACCESS_INFO_ARRAY(reg_info); + +static MemTxResult rt500_clkctl1_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + RT500ClkCtl1State *s =3D opaque; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + MemTxResult ret =3D MEMTX_OK; + + switch (addr) { + case A_RT500_CLKCTL1_PSCCTL0_SET: + case A_RT500_CLKCTL1_PSCCTL1_SET: + case A_RT500_CLKCTL1_PSCCTL2_SET: + case A_RT500_CLKCTL1_PSCCTL0_CLR: + case A_RT500_CLKCTL1_PSCCTL1_CLR: + case A_RT500_CLKCTL1_PSCCTL2_CLR: + /* write only registers */ + ret =3D MEMTX_ERROR; + break; + default: + *data =3D s->regs[addr / 4]; + break; + } + + trace_rt500_clkctl1_reg_read(rai->name, addr, *data); + return ret; +} + +static MemTxResult rt500_clkctl1_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + RT500ClkCtl1State *s =3D opaque; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D rai, + }; + + trace_rt500_clkctl1_reg_write(rai->name, addr, value); + + switch (addr) { + case A_RT500_CLKCTL1_PSCCTL0: + case A_RT500_CLKCTL1_PSCCTL1: + case A_RT500_CLKCTL1_PSCCTL2: + { + s->regs[addr / 4] =3D value | s->regs[addr / 4]; + break; + } + case A_RT500_CLKCTL1_PSCCTL0_SET: + case A_RT500_CLKCTL1_PSCCTL1_SET: + case A_RT500_CLKCTL1_PSCCTL2_SET: + { + uint32_t tmp; + + tmp =3D A_RT500_CLKCTL1_PSCCTL0 + (addr - A_RT500_CLKCTL1_PSCCTL0_= SET); + s->regs[tmp / 4] |=3D value; + break; + } + case A_RT500_CLKCTL1_PSCCTL0_CLR: + case A_RT500_CLKCTL1_PSCCTL1_CLR: + case A_RT500_CLKCTL1_PSCCTL2_CLR: + { + uint32_t tmp; + + tmp =3D A_RT500_CLKCTL1_PSCCTL0 + (addr - A_RT500_CLKCTL1_PSCCTL0_= CLR); + s->regs[tmp / 4] &=3D ~value; + break; + } + default: + register_write(&ri, value, ~0, NULL, false); + } + + switch (addr) { + case A_RT500_CLKCTL1_AUDIOPLL0PFD: + { + if (!RF_RD(s, AUDIOPLL0PFD, PFD0_CLKGATE)) { + RF_WR(s, AUDIOPLL0PFD, PFD0_CLKRDY, 1); + } else { + RF_WR(s, AUDIOPLL0PFD, PFD0_CLKRDY, 0); + } + if (!RF_RD(s, AUDIOPLL0PFD, PFD1_CLKGATE)) { + RF_WR(s, AUDIOPLL0PFD, PFD1_CLKRDY, 1); + } else { + RF_WR(s, AUDIOPLL0PFD, PFD1_CLKRDY, 0); + } + if (!RF_RD(s, AUDIOPLL0PFD, PFD2_CLKGATE)) { + RF_WR(s, AUDIOPLL0PFD, PFD2_CLKRDY, 1); + } else { + RF_WR(s, AUDIOPLL0PFD, PFD2_CLKRDY, 0); + } + if (!RF_RD(s, AUDIOPLL0PFD, PFD3_CLKGATE)) { + RF_WR(s, AUDIOPLL0PFD, PFD3_CLKRDY, 1); + } else { + RF_WR(s, AUDIOPLL0PFD, PFD3_CLKRDY, 0); + } + break; + } + case A_RT500_CLKCTL1_OSEVENTTFCLKSEL: + { + switch (RF_RD(s, OSEVENTTFCLKSEL, SEL)) { + case OSEVENTTFCLKSEL_LPOSC: + { + clock_set_hz(s->ostimer_clk, LPOSC_CLK_HZ); + break; + } + case OSEVENTTFCLKSEL_32KHZRTC: + { + clock_set_hz(s->ostimer_clk, RTC32KHZ_CLK_HZ); + break; + } + case OSEVENTTFCLKSEL_HCLK: + { + clock_set_hz(s->ostimer_clk, clock_get_hz(s->sysclk)); + break; + } + case OSEVENTTFCLKSEL_NONE: + { + clock_set_hz(s->ostimer_clk, 0); + break; + } + } + + clock_propagate(s->ostimer_clk); + break; + } + } + + return MEMTX_OK; +} + + +static const MemoryRegionOps rt500_clkctl1_ops =3D { + .read_with_attrs =3D rt500_clkctl1_read, + .write_with_attrs =3D rt500_clkctl1_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + .unaligned =3D false, + }, +}; + +static void rt500_clkctl1_reset(Object *obj, ResetType type) +{ + RT500ClkCtl1State *s =3D RT500_CLKCTL1(obj); + + for (int i =3D 0; i < RT500_CLKCTL1_REGS_NO; i++) { + hwaddr addr =3D reg_info[i].addr; + + if (addr !=3D -1) { + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D ®_info[i], + }; + + register_reset(&ri); + } + } +} + +static void rt500_clkctl1_init(Object *obj) +{ + RT500ClkCtl1State *s =3D RT500_CLKCTL1(obj); + + memory_region_init_io(&s->mmio, obj, &rt500_clkctl1_ops, s, + TYPE_RT500_CLKCTL1, sizeof(s->regs)); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); + s->sysclk =3D qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0); + s->ostimer_clk =3D qdev_init_clock_out(DEVICE(s), "ostimer_clk"); +} + +static const VMStateDescription vmstate_rt500_clkctl1 =3D { + .name =3D "rt500-clkctl1", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32_ARRAY(regs, RT500ClkCtl1State, RT500_CLKCTL1_REGS_N= O), + VMSTATE_CLOCK(ostimer_clk, RT500ClkCtl1State), + VMSTATE_END_OF_LIST() + } +}; + +static void rt500_clkctl1_class_init(ObjectClass *klass, void *data) +{ + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); + + rc->phases.enter =3D rt500_clkctl1_reset; + dc->vmsd =3D &vmstate_rt500_clkctl1; + +} + +static const TypeInfo rt500_clkctl1_types[] =3D { + { + .name =3D TYPE_RT500_CLKCTL1, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(RT500ClkCtl1State), + .instance_init =3D rt500_clkctl1_init, + .class_init =3D rt500_clkctl1_class_init, + } +}; + +DEFINE_TYPES(rt500_clkctl1_types); diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 1ad60da7aa..668135bc85 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -712,3 +712,8 @@ config ARMSSE select UNIMP select SSE_COUNTER select SSE_TIMER + +config RT500 + bool + select FLEXCOMM + select RT500_CLKCTL diff --git a/hw/arm/svd/meson.build b/hw/arm/svd/meson.build index 7f1c847caf..d017010b73 100644 --- a/hw/arm/svd/meson.build +++ b/hw/arm/svd/meson.build @@ -13,4 +13,10 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm-spi', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_spi.h', '-p', 'SPI0', '-t', 'FLEXCOMM_SPI']) + run_target('svd-rt500-clkctl0', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/rt500_clkctl0.h= ', + '-p', 'CLKCTL0', '-t', 'RT500_CLKCTL0']) + run_target('svd-rt500-clkctl1', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/rt500_clkctl1.h= ', + '-p', 'CLKCTL1', '-t', 'RT500_CLKCTL1']) endif diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index b373e651e1..02feb93840 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -218,4 +218,7 @@ config FLEXCOMM select I2C select SSI =20 +config RT500_CLKCTL + bool + source macio/Kconfig diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 749f688e84..e6d97b387c 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -159,3 +159,4 @@ system_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('= sbsa_ec.c')) system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c')) =20 system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm.c')) +system_ss.add(when: 'CONFIG_RT500_CLKCTL', if_true: files('rt500_clkctl0.c= ', 'rt500_clkctl1.c')) diff --git a/hw/misc/trace-events b/hw/misc/trace-events index dc245905dc..b19393dd36 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -368,3 +368,11 @@ flexcomm_irq(const char *id, uint8_t irq) "%s %d" flexcomm_reg_read(const char *devname, const char *regname, uint32_t addr,= uint32_t val) "%s: %s[0x%04x] -> 0x%08x" flexcomm_reg_write(const char *dename, const char *regname, uint32_t addr,= uint32_t val) "%s: %s[0x%04x] <- 0x%08x" flexcomm_fifostat(const char *id, uint32_t fifostat, uint32_t fifoinstat) = "%s: %08x %08x" + +# rt500_clkctl0.c +rt500_clkctl0_reg_read(const char *regname, uint32_t addr, uint32_t val) "= %s[0x%04x] -> 0x%08x" +rt500_clkctl0_reg_write(const char *regname, uint32_t addr, uint32_t val) = "%s[0x%04x] <- 0x%08x" + +# rt500_clkctl1.c +rt500_clkctl1_reg_read(const char *regname, uint32_t addr, uint32_t val) "= %s[0x%04x] -> 0x%08x" +rt500_clkctl1_reg_write(const char *regname, uint32_t addr, uint32_t val) = "%s[0x%04x] <- 0x%08x" --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687577; cv=none; d=zohomail.com; s=zohoarc; b=bu0OXUZ3I52mtiSRPT+Jf+km03moH7rjIGC0w8K2UokwkPNyiUSsm6ViavbQUrsL6VClynEMG30Gh80JwCcOZw09dDOu7TCwnpbwlWGuElmVzjoOSUUBtdg5oYaIlFBzh3zkJfO/WGOR4xFJ7E5prJjCFd2y7xmecsFcIfGQ15Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687577; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tgyt/8vZ0Kkxni+t/Qt5H/c3qmR/V6KsxWglrLdS5aA=; b=guBDEFGpdYv7TT6HL0jeCSajOqr5c3rbGPn/ivSjpzw06VONG0NxTitxDswvHnw5dqqObj5BDZ+n2m7I8Uv3QYZLk2xQ9sLLYgjVzDzXEOB4jIdwe73WSviSYNQKKxkGjfwBswvwdnz3roDFbv8VJXNGUxVdTtg/hDxsbd9z8j8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687577272336.0767019895154; Wed, 18 Sep 2024 12:26:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gu-0005DJ-3d; Wed, 18 Sep 2024 15:23:28 -0400 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 <3pCjrZgUKCt8UBWJQHPPHMF.DPNRFNV-EFWFMOPOHOV.PSH@flex--tavip.bounces.google.com>) id 1sr0Gq-0004zn-NT for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:24 -0400 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3pCjrZgUKCt8UBWJQHPPHMF.DPNRFNV-EFWFMOPOHOV.PSH@flex--tavip.bounces.google.com>) id 1sr0Gk-0007LV-Dn for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:24 -0400 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6cf78470a56so1039607b3.3 for ; Wed, 18 Sep 2024 12:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687396; x=1727292196; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=tgyt/8vZ0Kkxni+t/Qt5H/c3qmR/V6KsxWglrLdS5aA=; b=XrbUwKN44hlEOIN09M9YuaRyNWw1MUK02mCwY7H/ob6QIIpjBvFMFyEap8+UQLxSZK RB8DAVZ5eSWvoPEMDZc9SoZo3DCbdH2Tx8biySRhkmL9QD9OzwbvXz45SzVx3NpYObkO nt7ouN0lR8TFjTEccFbpWUlp8IkZqFRNo7uEbEJz03tU5d9+hoJMjBo4pKAn2g6FHRW9 FphpaaoC0dD6EVhH1wCi0XhUof0UrcOc3uCE6OWKFTJE2RtdDme+aQJG0taPhV58h6zs PHYQOJZhW/ue5USEkuuD/C0BZwfu4TP1nxcAqVYmsr1LkahQIslf9Zu1M9IFQcz53HPz 6IrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687396; x=1727292196; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tgyt/8vZ0Kkxni+t/Qt5H/c3qmR/V6KsxWglrLdS5aA=; b=WC77wg+If3elrq1ZzFxuM6NxzclLCS26qTsbcJQZVSFbaEHXGkyuNNAYfrYhQxpcwP nLoJzdEw6YndHIEpblmmVD2ZFmeRvRiEUxU4qZyaNlJXZRZfnj9EnIpluql14eJt8euU ZseAFs2X4+d4AIEmjmD59SU7zQi+gf+aiNk8rEjVrnHeV7LHYJXRv8wgsl31iens4l1w OAfRJTMYSV3Qb+HKa/omj66Vu+MzQ1G6AUHVsgKY6DBURnhiXxcYNtbqexNlQkFw8rPL 0lM3Po91b71RK3Jpn19EWAFqq8qFza2kgCDos0Np+Nbi2hs49P0/iZ7OLxu5Zf0d1tKD r9qg== X-Gm-Message-State: AOJu0YwuRHX21bcbUJTKoGFgbh5sFfpY+GBKdtQAFNkIxmTT9/kkEgFQ sRn+ie/UV20gDRVL6BkYCEfKN2K/SWFPzDH8w+nv8wnH9pH4NYxfPDAtvINxfD+E8IjAWHpVfHX aipNtK8Bt+lJhHNKjhvyDH/XCHdcXhJAIltXyDOXdWfxH4oYBhNGsK1P8/w3lldqBkNTy2NDrgL nLKHMVimT4miaYvCdUfs3RpXYjpA== X-Google-Smtp-Source: AGHT+IHGlz2QkqYoML4WrvIGl5kkiShYVCOM+CLgoK0zw7k/KfMNxrpCcoOLA6jFC7qyQ6ZhMhi+RmQMaQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a05:690c:4d43:b0:6db:cd39:4dad with SMTP id 00721157ae682-6dbcd395214mr10277957b3.5.1726687396411; Wed, 18 Sep 2024 12:23:16 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:39 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-12-tavip@google.com> Subject: [PATCH 11/25] hw/ssi: add support for flexspi From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::114a; envelope-from=3pCjrZgUKCt8UBWJQHPPHMF.DPNRFNV-EFWFMOPOHOV.PSH@flex--tavip.bounces.google.com; helo=mail-yw1-x114a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687579298116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is mostly a stub which completes SPI transactions as noops by masking out the error interrupts and never clearing the IPCMDDONE interrupt. Although incomplete, this allows software that uses NXP's mcuxpresso SDK to run the SDK board initialization functions. It also supports AHB memory access, aka XIP, for now as simple RAM memory regions. The patch includes an automatically generated header which contains the register layout and helpers. The header can be regenerated with the svd-flexspi target when the build is configured with --enable-mcux-soc-svd. Signed-off-by: Octavian Purdila --- include/hw/arm/svd/flexspi.h | 2656 ++++++++++++++++++++++++++++++++++ include/hw/ssi/flexspi.h | 31 + hw/ssi/flexspi.c | 181 +++ hw/arm/svd/meson.build | 3 + hw/ssi/Kconfig | 4 + hw/ssi/meson.build | 1 + hw/ssi/trace-events | 4 + 7 files changed, 2880 insertions(+) create mode 100644 include/hw/arm/svd/flexspi.h create mode 100644 include/hw/ssi/flexspi.h create mode 100644 hw/ssi/flexspi.c diff --git a/include/hw/arm/svd/flexspi.h b/include/hw/arm/svd/flexspi.h new file mode 100644 index 0000000000..828e2d6a7d --- /dev/null +++ b/include/hw/arm/svd/flexspi.h @@ -0,0 +1,2656 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#include "hw/register.h" + +/* FlexSPI */ +#define FLEXSPI_REGS_NO (267) + +/* Module Control Register 0 */ +REG32(FLEXSPI_MCR0, 0); +/* Software Reset */ +FIELD(FLEXSPI_MCR0, SWRESET, 0, 1); +/* Module Disable */ +FIELD(FLEXSPI_MCR0, MDIS, 1, 1); +/* Sample Clock source selection for Flash Reading */ +FIELD(FLEXSPI_MCR0, RXCLKSRC, 4, 2); +/* Serial root clock */ +FIELD(FLEXSPI_MCR0, SERCLKDIV, 8, 3); +/* Half Speed Serial Flash Access Enable. */ +FIELD(FLEXSPI_MCR0, HSEN, 11, 1); +/* Doze mode enable bit */ +FIELD(FLEXSPI_MCR0, DOZEEN, 12, 1); +/* + * This bit is used to enable SCLK output free-running. For FPGA applicati= ons, + * the external device may use SCLK as reference clock to its internal PLL. + */ +FIELD(FLEXSPI_MCR0, SCKFREERUNEN, 14, 1); +/* This bit is used to enable/disable the data learning feature. */ +FIELD(FLEXSPI_MCR0, LEARNEN, 15, 1); +/* Timeout wait cycle for IP command grant. */ +FIELD(FLEXSPI_MCR0, IPGRANTWAIT, 16, 8); +/* Timeout wait cycle for AHB command grant. */ +FIELD(FLEXSPI_MCR0, AHBGRANTWAIT, 24, 8); + +/* Module Control Register 1 */ +REG32(FLEXSPI_MCR1, 4); +/* AHB Bus wait */ +FIELD(FLEXSPI_MCR1, AHBBUSWAIT, 0, 16); +/* + * Command Sequence Execution will timeout and abort after SEQWAIT * 1024 + * Serial Root Clock cycles. When sequence execution timeout occurs, there= will + * be an interrupt generated (INTR[SEQTIMEOUT]) if this interrupt is enabl= ed + * (INTEN[SEQTIMEOUTEN] is set 0x1) and AHB command is ignored by arbitrat= or. + */ +FIELD(FLEXSPI_MCR1, SEQWAIT, 16, 16); + +/* Module Control Register 2 */ +REG32(FLEXSPI_MCR2, 8); +/* Clear AHB buffer */ +FIELD(FLEXSPI_MCR2, CLRAHBBUFOPT, 11, 1); +/* + * The sampling clock phase selection will be reset to phase 0 when this b= it is + * written with 0x1. This bit will be auto-cleared immediately. + */ +FIELD(FLEXSPI_MCR2, CLRLEARNPHASE, 14, 1); +/* + * All external devices are same devices (both in type and size) for + * A1/A2/B1/B2. + */ +FIELD(FLEXSPI_MCR2, SAMEDEVICEEN, 15, 1); +/* + * Wait cycle (in AHB clock cycle) for idle state before suspended command + * sequence resumed. + */ +FIELD(FLEXSPI_MCR2, RESUMEWAIT, 24, 8); + +/* AHB Bus Control Register */ +REG32(FLEXSPI_AHBCR, 12); +/* Parallel mode enabled for AHB triggered Command (both read and write). = */ +FIELD(FLEXSPI_AHBCR, APAREN, 0, 1); +/* Clear the status/pointers of AHB TX Buffer. Auto-cleared. */ +FIELD(FLEXSPI_AHBCR, CLRAHBTXBUF, 2, 1); +/* Enable AHB bus cachable read access support. */ +FIELD(FLEXSPI_AHBCR, CACHABLEEN, 3, 1); +/* Enable AHB bus bufferable write access support. */ +FIELD(FLEXSPI_AHBCR, BUFFERABLEEN, 4, 1); +/* AHB Read Prefetch Enable. */ +FIELD(FLEXSPI_AHBCR, PREFETCHEN, 5, 1); +/* + * AHB Read Address option bit. This option bit is intended to remove AHB = burst + * start address alignment limitation. + */ +FIELD(FLEXSPI_AHBCR, READADDROPT, 6, 1); +/* AHB Read Resume Disable */ +FIELD(FLEXSPI_AHBCR, RESUMEDISABLE, 7, 1); +/* AHB Read Size Alignment */ +FIELD(FLEXSPI_AHBCR, READSZALIGN, 10, 1); + +/* Interrupt Enable Register */ +REG32(FLEXSPI_INTEN, 16); +/* IP triggered Command Sequences Execution finished interrupt enable. */ +FIELD(FLEXSPI_INTEN, IPCMDDONEEN, 0, 1); +/* IP triggered Command Sequences Grant Timeout interrupt enable. */ +FIELD(FLEXSPI_INTEN, IPCMDGEEN, 1, 1); +/* AHB triggered Command Sequences Grant Timeout interrupt enable. */ +FIELD(FLEXSPI_INTEN, AHBCMDGEEN, 2, 1); +/* IP triggered Command Sequences Error Detected interrupt enable. */ +FIELD(FLEXSPI_INTEN, IPCMDERREN, 3, 1); +/* AHB triggered Command Sequences Error Detected interrupt enable. */ +FIELD(FLEXSPI_INTEN, AHBCMDERREN, 4, 1); +/* IP RX FIFO WaterMark available interrupt enable. */ +FIELD(FLEXSPI_INTEN, IPRXWAEN, 5, 1); +/* IP TX FIFO WaterMark empty interrupt enable. */ +FIELD(FLEXSPI_INTEN, IPTXWEEN, 6, 1); +/* Data Learning failed interrupt enable. */ +FIELD(FLEXSPI_INTEN, DATALEARNFAILEN, 7, 1); +/* + * SCLK is stopped during command sequence because Async RX FIFO full inte= rrupt + * enable. + */ +FIELD(FLEXSPI_INTEN, SCKSTOPBYRDEN, 8, 1); +/* + * SCLK is stopped during command sequence because Async TX FIFO empty + * interrupt enable. + */ +FIELD(FLEXSPI_INTEN, SCKSTOPBYWREN, 9, 1); +/* AHB Bus error interrupt enable. */ +FIELD(FLEXSPI_INTEN, AHBBUSERROREN, 10, 1); +/* Sequence execution timeout interrupt enable. */ +FIELD(FLEXSPI_INTEN, SEQTIMEOUTEN, 11, 1); +/* OTFAD key blob processing done interrupt enable. */ +FIELD(FLEXSPI_INTEN, KEYDONEEN, 12, 1); +/* OTFAD key blob processing error interrupt enable. */ +FIELD(FLEXSPI_INTEN, KEYERROREN, 13, 1); + +/* Interrupt Register */ +REG32(FLEXSPI_INTR, 20); +/* + * IP triggered Command Sequences Execution finished interrupt. This inter= rupt + * is also generated when there is IPCMDGE or IPCMDERR interrupt generated. + */ +FIELD(FLEXSPI_INTR, IPCMDDONE, 0, 1); +/* IP triggered Command Sequences Grant Timeout interrupt. */ +FIELD(FLEXSPI_INTR, IPCMDGE, 1, 1); +/* AHB triggered Command Sequences Grant Timeout interrupt. */ +FIELD(FLEXSPI_INTR, AHBCMDGE, 2, 1); +/* + * IP triggered Command Sequences Error Detected interrupt. When an error + * detected for IP command, this command will be ignored and not executed = at + * all. + */ +FIELD(FLEXSPI_INTR, IPCMDERR, 3, 1); +/* + * AHB triggered Command Sequences Error Detected interrupt. When an error + * detected for AHB command, this command will be ignored and not executed= at + * all. + */ +FIELD(FLEXSPI_INTR, AHBCMDERR, 4, 1); +/* IP RX FIFO watermark available interrupt. */ +FIELD(FLEXSPI_INTR, IPRXWA, 5, 1); +/* IP TX FIFO watermark empty interrupt. */ +FIELD(FLEXSPI_INTR, IPTXWE, 6, 1); +/* Data Learning failed interrupt. */ +FIELD(FLEXSPI_INTR, DATALEARNFAIL, 7, 1); +/* + * SCLK is stopped during command sequence because Async RX FIFO full + * interrupt. + */ +FIELD(FLEXSPI_INTR, SCKSTOPBYRD, 8, 1); +/* + * SCLK is stopped during command sequence because Async TX FIFO empty + * interrupt. + */ +FIELD(FLEXSPI_INTR, SCKSTOPBYWR, 9, 1); +/* + * AHB Bus timeout or AHB bus illegal access Flash during OTFAD key blob + * processing interrupt. + */ +FIELD(FLEXSPI_INTR, AHBBUSERROR, 10, 1); +/* Sequence execution timeout interrupt. */ +FIELD(FLEXSPI_INTR, SEQTIMEOUT, 11, 1); +/* OTFAD key blob processing done interrupt. */ +FIELD(FLEXSPI_INTR, KEYDONE, 12, 1); +/* OTFAD key blob processing error interrupt. */ +FIELD(FLEXSPI_INTR, KEYERROR, 13, 1); + +/* LUT Key Register */ +REG32(FLEXSPI_LUTKEY, 24); +/* The Key to lock or unlock LUT. */ +FIELD(FLEXSPI_LUTKEY, KEY, 0, 32); + +/* LUT Control Register */ +REG32(FLEXSPI_LUTCR, 28); +/* Lock LUT */ +FIELD(FLEXSPI_LUTCR, LOCK, 0, 1); +/* Unlock LUT */ +FIELD(FLEXSPI_LUTCR, UNLOCK, 1, 1); + +/* AHB RX Buffer 0 Control Register 0 */ +REG32(FLEXSPI_AHBRXBUF0CR0, 32); +/* AHB RX Buffer Size in 64 bits. */ +FIELD(FLEXSPI_AHBRXBUF0CR0, BUFSZ, 0, 8); +/* This AHB RX Buffer is assigned according to AHB Master with ID (MSTR_ID= ). */ +FIELD(FLEXSPI_AHBRXBUF0CR0, MSTRID, 16, 4); +/* + * This priority for AHB Master Read which this AHB RX Buffer is assigned.= 7 is + * the highest priority, 0 the lowest. + */ +FIELD(FLEXSPI_AHBRXBUF0CR0, PRIORITY, 24, 3); +/* AHB Read Prefetch Enable for current AHB RX Buffer corresponding Master= . */ +FIELD(FLEXSPI_AHBRXBUF0CR0, PREFETCHEN, 31, 1); + +/* AHB RX Buffer 1 Control Register 0 */ +REG32(FLEXSPI_AHBRXBUF1CR0, 36); +/* AHB RX Buffer Size in 64 bits. */ +FIELD(FLEXSPI_AHBRXBUF1CR0, BUFSZ, 0, 8); +/* This AHB RX Buffer is assigned according to AHB Master with ID (MSTR_ID= ). */ +FIELD(FLEXSPI_AHBRXBUF1CR0, MSTRID, 16, 4); +/* + * This priority for AHB Master Read which this AHB RX Buffer is assigned.= 7 is + * the highest priority, 0 the lowest. + */ +FIELD(FLEXSPI_AHBRXBUF1CR0, PRIORITY, 24, 3); +/* AHB Read Prefetch Enable for current AHB RX Buffer corresponding Master= . */ +FIELD(FLEXSPI_AHBRXBUF1CR0, PREFETCHEN, 31, 1); + +/* AHB RX Buffer 2 Control Register 0 */ +REG32(FLEXSPI_AHBRXBUF2CR0, 40); +/* AHB RX Buffer Size in 64 bits. */ +FIELD(FLEXSPI_AHBRXBUF2CR0, BUFSZ, 0, 8); +/* This AHB RX Buffer is assigned according to AHB Master with ID (MSTR_ID= ). */ +FIELD(FLEXSPI_AHBRXBUF2CR0, MSTRID, 16, 4); +/* + * This priority for AHB Master Read which this AHB RX Buffer is assigned.= 7 is + * the highest priority, 0 the lowest. + */ +FIELD(FLEXSPI_AHBRXBUF2CR0, PRIORITY, 24, 3); +/* AHB Read Prefetch Enable for current AHB RX Buffer corresponding Master= . */ +FIELD(FLEXSPI_AHBRXBUF2CR0, PREFETCHEN, 31, 1); + +/* AHB RX Buffer 3 Control Register 0 */ +REG32(FLEXSPI_AHBRXBUF3CR0, 44); +/* AHB RX Buffer Size in 64 bits. */ +FIELD(FLEXSPI_AHBRXBUF3CR0, BUFSZ, 0, 8); +/* This AHB RX Buffer is assigned according to AHB Master with ID (MSTR_ID= ). */ +FIELD(FLEXSPI_AHBRXBUF3CR0, MSTRID, 16, 4); +/* + * This priority for AHB Master Read which this AHB RX Buffer is assigned.= 7 is + * the highest priority, 0 the lowest. + */ +FIELD(FLEXSPI_AHBRXBUF3CR0, PRIORITY, 24, 3); +/* AHB Read Prefetch Enable for current AHB RX Buffer corresponding Master= . */ +FIELD(FLEXSPI_AHBRXBUF3CR0, PREFETCHEN, 31, 1); + +/* AHB RX Buffer 4 Control Register 0 */ +REG32(FLEXSPI_AHBRXBUF4CR0, 48); +/* AHB RX Buffer Size in 64 bits. */ +FIELD(FLEXSPI_AHBRXBUF4CR0, BUFSZ, 0, 8); +/* This AHB RX Buffer is assigned according to AHB Master with ID (MSTR_ID= ). */ +FIELD(FLEXSPI_AHBRXBUF4CR0, MSTRID, 16, 4); +/* + * This priority for AHB Master Read which this AHB RX Buffer is assigned.= 7 is + * the highest priority, 0 the lowest. + */ +FIELD(FLEXSPI_AHBRXBUF4CR0, PRIORITY, 24, 3); +/* AHB Read Prefetch Enable for current AHB RX Buffer corresponding Master= . */ +FIELD(FLEXSPI_AHBRXBUF4CR0, PREFETCHEN, 31, 1); + +/* AHB RX Buffer 5 Control Register 0 */ +REG32(FLEXSPI_AHBRXBUF5CR0, 52); +/* AHB RX Buffer Size in 64 bits. */ +FIELD(FLEXSPI_AHBRXBUF5CR0, BUFSZ, 0, 8); +/* This AHB RX Buffer is assigned according to AHB Master with ID (MSTR_ID= ). */ +FIELD(FLEXSPI_AHBRXBUF5CR0, MSTRID, 16, 4); +/* + * This priority for AHB Master Read which this AHB RX Buffer is assigned.= 7 is + * the highest priority, 0 the lowest. + */ +FIELD(FLEXSPI_AHBRXBUF5CR0, PRIORITY, 24, 3); +/* AHB Read Prefetch Enable for current AHB RX Buffer corresponding Master= . */ +FIELD(FLEXSPI_AHBRXBUF5CR0, PREFETCHEN, 31, 1); + +/* AHB RX Buffer 6 Control Register 0 */ +REG32(FLEXSPI_AHBRXBUF6CR0, 56); +/* AHB RX Buffer Size in 64 bits. */ +FIELD(FLEXSPI_AHBRXBUF6CR0, BUFSZ, 0, 8); +/* This AHB RX Buffer is assigned according to AHB Master with ID (MSTR_ID= ). */ +FIELD(FLEXSPI_AHBRXBUF6CR0, MSTRID, 16, 4); +/* + * This priority for AHB Master Read which this AHB RX Buffer is assigned.= 7 is + * the highest priority, 0 the lowest. + */ +FIELD(FLEXSPI_AHBRXBUF6CR0, PRIORITY, 24, 3); +/* AHB Read Prefetch Enable for current AHB RX Buffer corresponding Master= . */ +FIELD(FLEXSPI_AHBRXBUF6CR0, PREFETCHEN, 31, 1); + +/* AHB RX Buffer 7 Control Register 0 */ +REG32(FLEXSPI_AHBRXBUF7CR0, 60); +/* AHB RX Buffer Size in 64 bits. */ +FIELD(FLEXSPI_AHBRXBUF7CR0, BUFSZ, 0, 8); +/* This AHB RX Buffer is assigned according to AHB Master with ID (MSTR_ID= ). */ +FIELD(FLEXSPI_AHBRXBUF7CR0, MSTRID, 16, 4); +/* + * This priority for AHB Master Read which this AHB RX Buffer is assigned.= 7 is + * the highest priority, 0 the lowest. + */ +FIELD(FLEXSPI_AHBRXBUF7CR0, PRIORITY, 24, 3); +/* AHB Read Prefetch Enable for current AHB RX Buffer corresponding Master= . */ +FIELD(FLEXSPI_AHBRXBUF7CR0, PREFETCHEN, 31, 1); + +/* Flash Control Register 0 */ +REG32(FLEXSPI_FLSHA1CR0, 96); +/* Flash Size in KByte. */ +FIELD(FLEXSPI_FLSHA1CR0, FLSHSZ, 0, 23); + +/* Flash Control Register 0 */ +REG32(FLEXSPI_FLSHA2CR0, 100); +/* Flash Size in KByte. */ +FIELD(FLEXSPI_FLSHA2CR0, FLSHSZ, 0, 23); + +/* Flash Control Register 0 */ +REG32(FLEXSPI_FLSHB1CR0, 104); +/* Flash Size in KByte. */ +FIELD(FLEXSPI_FLSHB1CR0, FLSHSZ, 0, 23); + +/* Flash Control Register 0 */ +REG32(FLEXSPI_FLSHB2CR0, 108); +/* Flash Size in KByte. */ +FIELD(FLEXSPI_FLSHB2CR0, FLSHSZ, 0, 23); + +/* Flash Control Register 1 */ +REG32(FLEXSPI_FLSHCR1A1, 112); +/* Serial Flash CS setup time. */ +FIELD(FLEXSPI_FLSHCR1A1, TCSS, 0, 5); +/* Serial Flash CS Hold time. */ +FIELD(FLEXSPI_FLSHCR1A1, TCSH, 5, 5); +/* Word Addressable. */ +FIELD(FLEXSPI_FLSHCR1A1, WA, 10, 1); +/* Column Address Size. */ +FIELD(FLEXSPI_FLSHCR1A1, CAS, 11, 4); +/* CS interval unit */ +FIELD(FLEXSPI_FLSHCR1A1, CSINTERVALUNIT, 15, 1); +/* + * This field is used to set the minimum interval between flash device chip + * select deassertion and flash device chip select assertion. If external = flash + * has a limitation on the interval between command sequences, this field + * should be set accordingly. If there is no limitation, set this field wi= th + * value 0x0. + */ +FIELD(FLEXSPI_FLSHCR1A1, CSINTERVAL, 16, 16); + +/* Flash Control Register 1 */ +REG32(FLEXSPI_FLSHCR1A2, 116); +/* Serial Flash CS setup time. */ +FIELD(FLEXSPI_FLSHCR1A2, TCSS, 0, 5); +/* Serial Flash CS Hold time. */ +FIELD(FLEXSPI_FLSHCR1A2, TCSH, 5, 5); +/* Word Addressable. */ +FIELD(FLEXSPI_FLSHCR1A2, WA, 10, 1); +/* Column Address Size. */ +FIELD(FLEXSPI_FLSHCR1A2, CAS, 11, 4); +/* CS interval unit */ +FIELD(FLEXSPI_FLSHCR1A2, CSINTERVALUNIT, 15, 1); +/* + * This field is used to set the minimum interval between flash device chip + * select deassertion and flash device chip select assertion. If external = flash + * has a limitation on the interval between command sequences, this field + * should be set accordingly. If there is no limitation, set this field wi= th + * value 0x0. + */ +FIELD(FLEXSPI_FLSHCR1A2, CSINTERVAL, 16, 16); + +/* Flash Control Register 1 */ +REG32(FLEXSPI_FLSHCR1B1, 120); +/* Serial Flash CS setup time. */ +FIELD(FLEXSPI_FLSHCR1B1, TCSS, 0, 5); +/* Serial Flash CS Hold time. */ +FIELD(FLEXSPI_FLSHCR1B1, TCSH, 5, 5); +/* Word Addressable. */ +FIELD(FLEXSPI_FLSHCR1B1, WA, 10, 1); +/* Column Address Size. */ +FIELD(FLEXSPI_FLSHCR1B1, CAS, 11, 4); +/* CS interval unit */ +FIELD(FLEXSPI_FLSHCR1B1, CSINTERVALUNIT, 15, 1); +/* + * This field is used to set the minimum interval between flash device chip + * select deassertion and flash device chip select assertion. If external = flash + * has a limitation on the interval between command sequences, this field + * should be set accordingly. If there is no limitation, set this field wi= th + * value 0x0. + */ +FIELD(FLEXSPI_FLSHCR1B1, CSINTERVAL, 16, 16); + +/* Flash Control Register 1 */ +REG32(FLEXSPI_FLSHCR1B2, 124); +/* Serial Flash CS setup time. */ +FIELD(FLEXSPI_FLSHCR1B2, TCSS, 0, 5); +/* Serial Flash CS Hold time. */ +FIELD(FLEXSPI_FLSHCR1B2, TCSH, 5, 5); +/* Word Addressable. */ +FIELD(FLEXSPI_FLSHCR1B2, WA, 10, 1); +/* Column Address Size. */ +FIELD(FLEXSPI_FLSHCR1B2, CAS, 11, 4); +/* CS interval unit */ +FIELD(FLEXSPI_FLSHCR1B2, CSINTERVALUNIT, 15, 1); +/* + * This field is used to set the minimum interval between flash device chip + * select deassertion and flash device chip select assertion. If external = flash + * has a limitation on the interval between command sequences, this field + * should be set accordingly. If there is no limitation, set this field wi= th + * value 0x0. + */ +FIELD(FLEXSPI_FLSHCR1B2, CSINTERVAL, 16, 16); + +/* Flash Control Register 2 */ +REG32(FLEXSPI_FLSHCR2A1, 128); +/* Sequence Index for AHB Read triggered Command in LUT. */ +FIELD(FLEXSPI_FLSHCR2A1, ARDSEQID, 0, 4); +/* Sequence Number for AHB Read triggered Command in LUT. */ +FIELD(FLEXSPI_FLSHCR2A1, ARDSEQNUM, 5, 3); +/* Sequence Index for AHB Write triggered Command. */ +FIELD(FLEXSPI_FLSHCR2A1, AWRSEQID, 8, 4); +/* Sequence Number for AHB Write triggered Command. */ +FIELD(FLEXSPI_FLSHCR2A1, AWRSEQNUM, 13, 3); +/* + * For certain devices (such as FPGA), it need some time to write data into + * internal memory after the command sequences finished on FlexSPI interfa= ce. + * If another Read command sequence comes before previous programming fini= shed + * internally, the read data may be wrong. This field is used to hold AHB = Bus + * ready for AHB write access to wait the programming finished in external + * device. Then there will be no AHB read command triggered before the + * programming finished in external device. The Wait cycle between AHB + * triggered command sequences finished on FlexSPI interface and AHB retur= n Bus + * ready: AWRWAIT * AWRWAITUNIT + */ +FIELD(FLEXSPI_FLSHCR2A1, AWRWAIT, 16, 12); +/* AWRWAIT unit */ +FIELD(FLEXSPI_FLSHCR2A1, AWRWAITUNIT, 28, 3); +/* + * Clear the instruction pointer which is internally saved pointer by + * JMP_ON_CS. + */ +FIELD(FLEXSPI_FLSHCR2A1, CLRINSTRPTR, 31, 1); + +/* Flash Control Register 2 */ +REG32(FLEXSPI_FLSHCR2A2, 132); +/* Sequence Index for AHB Read triggered Command in LUT. */ +FIELD(FLEXSPI_FLSHCR2A2, ARDSEQID, 0, 4); +/* Sequence Number for AHB Read triggered Command in LUT. */ +FIELD(FLEXSPI_FLSHCR2A2, ARDSEQNUM, 5, 3); +/* Sequence Index for AHB Write triggered Command. */ +FIELD(FLEXSPI_FLSHCR2A2, AWRSEQID, 8, 4); +/* Sequence Number for AHB Write triggered Command. */ +FIELD(FLEXSPI_FLSHCR2A2, AWRSEQNUM, 13, 3); +/* + * For certain devices (such as FPGA), it need some time to write data into + * internal memory after the command sequences finished on FlexSPI interfa= ce. + * If another Read command sequence comes before previous programming fini= shed + * internally, the read data may be wrong. This field is used to hold AHB = Bus + * ready for AHB write access to wait the programming finished in external + * device. Then there will be no AHB read command triggered before the + * programming finished in external device. The Wait cycle between AHB + * triggered command sequences finished on FlexSPI interface and AHB retur= n Bus + * ready: AWRWAIT * AWRWAITUNIT + */ +FIELD(FLEXSPI_FLSHCR2A2, AWRWAIT, 16, 12); +/* AWRWAIT unit */ +FIELD(FLEXSPI_FLSHCR2A2, AWRWAITUNIT, 28, 3); +/* + * Clear the instruction pointer which is internally saved pointer by + * JMP_ON_CS. + */ +FIELD(FLEXSPI_FLSHCR2A2, CLRINSTRPTR, 31, 1); + +/* Flash Control Register 2 */ +REG32(FLEXSPI_FLSHCR2B1, 136); +/* Sequence Index for AHB Read triggered Command in LUT. */ +FIELD(FLEXSPI_FLSHCR2B1, ARDSEQID, 0, 4); +/* Sequence Number for AHB Read triggered Command in LUT. */ +FIELD(FLEXSPI_FLSHCR2B1, ARDSEQNUM, 5, 3); +/* Sequence Index for AHB Write triggered Command. */ +FIELD(FLEXSPI_FLSHCR2B1, AWRSEQID, 8, 4); +/* Sequence Number for AHB Write triggered Command. */ +FIELD(FLEXSPI_FLSHCR2B1, AWRSEQNUM, 13, 3); +/* + * For certain devices (such as FPGA), it need some time to write data into + * internal memory after the command sequences finished on FlexSPI interfa= ce. + * If another Read command sequence comes before previous programming fini= shed + * internally, the read data may be wrong. This field is used to hold AHB = Bus + * ready for AHB write access to wait the programming finished in external + * device. Then there will be no AHB read command triggered before the + * programming finished in external device. The Wait cycle between AHB + * triggered command sequences finished on FlexSPI interface and AHB retur= n Bus + * ready: AWRWAIT * AWRWAITUNIT + */ +FIELD(FLEXSPI_FLSHCR2B1, AWRWAIT, 16, 12); +/* AWRWAIT unit */ +FIELD(FLEXSPI_FLSHCR2B1, AWRWAITUNIT, 28, 3); +/* + * Clear the instruction pointer which is internally saved pointer by + * JMP_ON_CS. + */ +FIELD(FLEXSPI_FLSHCR2B1, CLRINSTRPTR, 31, 1); + +/* Flash Control Register 2 */ +REG32(FLEXSPI_FLSHCR2B2, 140); +/* Sequence Index for AHB Read triggered Command in LUT. */ +FIELD(FLEXSPI_FLSHCR2B2, ARDSEQID, 0, 4); +/* Sequence Number for AHB Read triggered Command in LUT. */ +FIELD(FLEXSPI_FLSHCR2B2, ARDSEQNUM, 5, 3); +/* Sequence Index for AHB Write triggered Command. */ +FIELD(FLEXSPI_FLSHCR2B2, AWRSEQID, 8, 4); +/* Sequence Number for AHB Write triggered Command. */ +FIELD(FLEXSPI_FLSHCR2B2, AWRSEQNUM, 13, 3); +/* + * For certain devices (such as FPGA), it need some time to write data into + * internal memory after the command sequences finished on FlexSPI interfa= ce. + * If another Read command sequence comes before previous programming fini= shed + * internally, the read data may be wrong. This field is used to hold AHB = Bus + * ready for AHB write access to wait the programming finished in external + * device. Then there will be no AHB read command triggered before the + * programming finished in external device. The Wait cycle between AHB + * triggered command sequences finished on FlexSPI interface and AHB retur= n Bus + * ready: AWRWAIT * AWRWAITUNIT + */ +FIELD(FLEXSPI_FLSHCR2B2, AWRWAIT, 16, 12); +/* AWRWAIT unit */ +FIELD(FLEXSPI_FLSHCR2B2, AWRWAITUNIT, 28, 3); +/* + * Clear the instruction pointer which is internally saved pointer by + * JMP_ON_CS. + */ +FIELD(FLEXSPI_FLSHCR2B2, CLRINSTRPTR, 31, 1); + +/* Flash Control Register 4 */ +REG32(FLEXSPI_FLSHCR4, 148); +/* + * Write mask option bit 1. This option bit could be used to remove AHB an= d IP + * write burst start address alignment limitation. + */ +FIELD(FLEXSPI_FLSHCR4, WMOPT1, 0, 1); +/* + * Write mask enable bit for flash device on port A. When write mask funct= ion + * is needed for memory device on port A, this bit must be set. + */ +FIELD(FLEXSPI_FLSHCR4, WMENA, 2, 1); + +/* IP Control Register 0 */ +REG32(FLEXSPI_IPCR0, 160); +/* Serial Flash Address for IP command. */ +FIELD(FLEXSPI_IPCR0, SFAR, 0, 32); + +/* IP Control Register 1 */ +REG32(FLEXSPI_IPCR1, 164); +/* Flash Read/Program Data Size (in Bytes) for IP command. */ +FIELD(FLEXSPI_IPCR1, IDATSZ, 0, 16); +/* Sequence Index in LUT for IP command. */ +FIELD(FLEXSPI_IPCR1, ISEQID, 16, 4); +/* Sequence Number for IP command: ISEQNUM+1. */ +FIELD(FLEXSPI_IPCR1, ISEQNUM, 24, 3); +/* Parallel mode Enabled for IP command. */ +FIELD(FLEXSPI_IPCR1, IPAREN, 31, 1); + +/* IP Command Register */ +REG32(FLEXSPI_IPCMD, 176); +/* Setting this bit will trigger an IP Command. */ +FIELD(FLEXSPI_IPCMD, TRG, 0, 1); + +/* Data Learn Pattern Register */ +REG32(FLEXSPI_DLPR, 180); +/* Data Learning Pattern. */ +FIELD(FLEXSPI_DLPR, DLP, 0, 32); + +/* IP RX FIFO Control Register */ +REG32(FLEXSPI_IPRXFCR, 184); +/* Clear all valid data entries in IP RX FIFO. */ +FIELD(FLEXSPI_IPRXFCR, CLRIPRXF, 0, 1); +/* IP RX FIFO reading by DMA enabled. */ +FIELD(FLEXSPI_IPRXFCR, RXDMAEN, 1, 1); +/* Watermark level is (RXWMRK+1)*64 bits. */ +FIELD(FLEXSPI_IPRXFCR, RXWMRK, 2, 7); + +/* IP TX FIFO Control Register */ +REG32(FLEXSPI_IPTXFCR, 188); +/* Clear all valid data entries in IP TX FIFO. */ +FIELD(FLEXSPI_IPTXFCR, CLRIPTXF, 0, 1); +/* IP TX FIFO filling by DMA enabled. */ +FIELD(FLEXSPI_IPTXFCR, TXDMAEN, 1, 1); +/* Watermark level is (TXWMRK+1)*64 Bits. */ +FIELD(FLEXSPI_IPTXFCR, TXWMRK, 2, 7); + +/* DLL Control Register 0 */ +REG32(FLEXSPI_DLLCRA, 192); +/* DLL calibration enable. */ +FIELD(FLEXSPI_DLLCRA, DLLEN, 0, 1); +/* DLL reset */ +FIELD(FLEXSPI_DLLCRA, DLLRESET, 1, 1); +/* + * The delay target for slave delay line is: ((SLVDLYTARGET+1) * 1/32 * cl= ock + * cycle of reference clock (serial root clock). If serial root clock is >= =3D 100 + * MHz, DLLEN set to 0x1, OVRDEN set to =3D0x0, then SLVDLYTARGET setting = of 0 is + * recommended. + */ +FIELD(FLEXSPI_DLLCRA, SLVDLYTARGET, 3, 4); +/* Slave clock delay line delay cell number selection override enable. */ +FIELD(FLEXSPI_DLLCRA, OVRDEN, 8, 1); +/* Slave clock delay line delay cell number selection override value. */ +FIELD(FLEXSPI_DLLCRA, OVRDVAL, 9, 6); + +/* DLL Control Register 0 */ +REG32(FLEXSPI_DLLCRB, 196); +/* DLL calibration enable. */ +FIELD(FLEXSPI_DLLCRB, DLLEN, 0, 1); +/* DLL reset */ +FIELD(FLEXSPI_DLLCRB, DLLRESET, 1, 1); +/* + * The delay target for slave delay line is: ((SLVDLYTARGET+1) * 1/32 * cl= ock + * cycle of reference clock (serial root clock). If serial root clock is >= =3D 100 + * MHz, DLLEN set to 0x1, OVRDEN set to =3D0x0, then SLVDLYTARGET setting = of 0 is + * recommended. + */ +FIELD(FLEXSPI_DLLCRB, SLVDLYTARGET, 3, 4); +/* Slave clock delay line delay cell number selection override enable. */ +FIELD(FLEXSPI_DLLCRB, OVRDEN, 8, 1); +/* Slave clock delay line delay cell number selection override value. */ +FIELD(FLEXSPI_DLLCRB, OVRDVAL, 9, 6); + +/* Status Register 0 */ +REG32(FLEXSPI_STS0, 224); +/* + * This status bit indicates the state machine in SEQ_CTL is idle and ther= e is + * command sequence executing on FlexSPI interface. + */ +FIELD(FLEXSPI_STS0, SEQIDLE, 0, 1); +/* + * This status bit indicates the state machine in ARB_CTL is busy and ther= e is + * command sequence granted by arbitrator and not finished yet on FlexSPI + * interface. When ARB_CTL state (ARBIDLE=3D0x1) is idle, there will be no + * transaction on FlexSPI interface also (SEQIDLE=3D0x1). So this bit shou= ld be + * polled to wait for FlexSPI controller become idle instead of SEQIDLE. + */ +FIELD(FLEXSPI_STS0, ARBIDLE, 1, 1); +/* + * This status field indicates the trigger source of current command seque= nce + * granted by arbitrator. This field value is meaningless when ARB_CTL is = not + * busy (STS0[ARBIDLE]=3D0x1). + */ +FIELD(FLEXSPI_STS0, ARBCMDSRC, 2, 2); +/* Indicate the sampling clock phase selection on Port A after Data Learni= ng. */ +FIELD(FLEXSPI_STS0, DATALEARNPHASEA, 4, 4); + +/* Status Register 1 */ +REG32(FLEXSPI_STS1, 228); +/* + * Indicates the sequence index when an AHB command error is detected. This + * field will be cleared when INTR[AHBCMDERR] is write-1-clear(w1c). + */ +FIELD(FLEXSPI_STS1, AHBCMDERRID, 0, 4); +/* + * Indicates the Error Code when AHB command Error detected. This field wi= ll be + * cleared when INTR[AHBCMDERR] is write-1-clear(w1c). + */ +FIELD(FLEXSPI_STS1, AHBCMDERRCODE, 8, 4); +/* Indicates the sequence Index when IP command error detected. */ +FIELD(FLEXSPI_STS1, IPCMDERRID, 16, 4); +/* + * Indicates the Error Code when IP command Error detected. This field wil= l be + * cleared when INTR[IPCMDERR] is write-1-clear(w1c). + */ +FIELD(FLEXSPI_STS1, IPCMDERRCODE, 24, 4); + +/* Status Register 2 */ +REG32(FLEXSPI_STS2, 232); +/* Flash A sample clock slave delay line locked. */ +FIELD(FLEXSPI_STS2, ASLVLOCK, 0, 1); +/* Flash A sample clock reference delay line locked. */ +FIELD(FLEXSPI_STS2, AREFLOCK, 1, 1); +/* Flash A sample clock slave delay line delay cell number selection . */ +FIELD(FLEXSPI_STS2, ASLVSEL, 2, 6); +/* Flash A sample clock reference delay line delay cell number selection. = */ +FIELD(FLEXSPI_STS2, AREFSEL, 8, 6); +/* Flash B sample clock slave delay line locked. */ +FIELD(FLEXSPI_STS2, BSLVLOCK, 16, 1); +/* Flash B sample clock reference delay line locked. */ +FIELD(FLEXSPI_STS2, BREFLOCK, 17, 1); +/* Flash B sample clock slave delay line delay cell number selection. */ +FIELD(FLEXSPI_STS2, BSLVSEL, 18, 6); +/* Flash B sample clock reference delay line delay cell number selection. = */ +FIELD(FLEXSPI_STS2, BREFSEL, 24, 6); + +/* AHB Suspend Status Register */ +REG32(FLEXSPI_AHBSPNDSTS, 236); +/* Indicates if an AHB read prefetch command sequence has been suspended. = */ +FIELD(FLEXSPI_AHBSPNDSTS, ACTIVE, 0, 1); +/* AHB RX BUF ID for suspended command sequence. */ +FIELD(FLEXSPI_AHBSPNDSTS, BUFID, 1, 3); +/* The Data size left for suspended command sequence (in byte). */ +FIELD(FLEXSPI_AHBSPNDSTS, DATLFT, 16, 16); + +/* IP RX FIFO Status Register */ +REG32(FLEXSPI_IPRXFSTS, 240); +/* Fill level of IP RX FIFO. */ +FIELD(FLEXSPI_IPRXFSTS, FILL, 0, 8); +/* Total Read Data Counter: RDCNTR * 64 Bits. */ +FIELD(FLEXSPI_IPRXFSTS, RDCNTR, 16, 16); + +/* IP TX FIFO Status Register */ +REG32(FLEXSPI_IPTXFSTS, 244); +/* Fill level of IP TX FIFO. */ +FIELD(FLEXSPI_IPTXFSTS, FILL, 0, 8); +/* Total Write Data Counter: WRCNTR * 64 Bits. */ +FIELD(FLEXSPI_IPTXFSTS, WRCNTR, 16, 16); + +/* IP RX FIFO Data Register x */ +REG32(FLEXSPI_RFDR0, 256); +REG32(FLEXSPI_RFDR1, 260); +REG32(FLEXSPI_RFDR2, 264); +REG32(FLEXSPI_RFDR3, 268); +REG32(FLEXSPI_RFDR4, 272); +REG32(FLEXSPI_RFDR5, 276); +REG32(FLEXSPI_RFDR6, 280); +REG32(FLEXSPI_RFDR7, 284); +REG32(FLEXSPI_RFDR8, 288); +REG32(FLEXSPI_RFDR9, 292); +REG32(FLEXSPI_RFDR10, 296); +REG32(FLEXSPI_RFDR11, 300); +REG32(FLEXSPI_RFDR12, 304); +REG32(FLEXSPI_RFDR13, 308); +REG32(FLEXSPI_RFDR14, 312); +REG32(FLEXSPI_RFDR15, 316); +REG32(FLEXSPI_RFDR16, 320); +REG32(FLEXSPI_RFDR17, 324); +REG32(FLEXSPI_RFDR18, 328); +REG32(FLEXSPI_RFDR19, 332); +REG32(FLEXSPI_RFDR20, 336); +REG32(FLEXSPI_RFDR21, 340); +REG32(FLEXSPI_RFDR22, 344); +REG32(FLEXSPI_RFDR23, 348); +REG32(FLEXSPI_RFDR24, 352); +REG32(FLEXSPI_RFDR25, 356); +REG32(FLEXSPI_RFDR26, 360); +REG32(FLEXSPI_RFDR27, 364); +REG32(FLEXSPI_RFDR28, 368); +REG32(FLEXSPI_RFDR29, 372); +REG32(FLEXSPI_RFDR30, 376); +REG32(FLEXSPI_RFDR31, 380); +/* RX Data. */ +SHARED_FIELD(FLEXSPI_RFDR_RXDATA, 0, 32); + +/* IP TX FIFO Data Register x */ +REG32(FLEXSPI_TFDR0, 384); +REG32(FLEXSPI_TFDR1, 388); +REG32(FLEXSPI_TFDR2, 392); +REG32(FLEXSPI_TFDR3, 396); +REG32(FLEXSPI_TFDR4, 400); +REG32(FLEXSPI_TFDR5, 404); +REG32(FLEXSPI_TFDR6, 408); +REG32(FLEXSPI_TFDR7, 412); +REG32(FLEXSPI_TFDR8, 416); +REG32(FLEXSPI_TFDR9, 420); +REG32(FLEXSPI_TFDR10, 424); +REG32(FLEXSPI_TFDR11, 428); +REG32(FLEXSPI_TFDR12, 432); +REG32(FLEXSPI_TFDR13, 436); +REG32(FLEXSPI_TFDR14, 440); +REG32(FLEXSPI_TFDR15, 444); +REG32(FLEXSPI_TFDR16, 448); +REG32(FLEXSPI_TFDR17, 452); +REG32(FLEXSPI_TFDR18, 456); +REG32(FLEXSPI_TFDR19, 460); +REG32(FLEXSPI_TFDR20, 464); +REG32(FLEXSPI_TFDR21, 468); +REG32(FLEXSPI_TFDR22, 472); +REG32(FLEXSPI_TFDR23, 476); +REG32(FLEXSPI_TFDR24, 480); +REG32(FLEXSPI_TFDR25, 484); +REG32(FLEXSPI_TFDR26, 488); +REG32(FLEXSPI_TFDR27, 492); +REG32(FLEXSPI_TFDR28, 496); +REG32(FLEXSPI_TFDR29, 500); +REG32(FLEXSPI_TFDR30, 504); +REG32(FLEXSPI_TFDR31, 508); +/* TX Data */ +SHARED_FIELD(FLEXSPI_TFDR_TXDATA, 0, 32); + +/* LUT x */ +REG32(FLEXSPI_LUT0, 512); +REG32(FLEXSPI_LUT1, 516); +REG32(FLEXSPI_LUT2, 520); +REG32(FLEXSPI_LUT3, 524); +REG32(FLEXSPI_LUT4, 528); +REG32(FLEXSPI_LUT5, 532); +REG32(FLEXSPI_LUT6, 536); +REG32(FLEXSPI_LUT7, 540); +REG32(FLEXSPI_LUT8, 544); +REG32(FLEXSPI_LUT9, 548); +REG32(FLEXSPI_LUT10, 552); +REG32(FLEXSPI_LUT11, 556); +REG32(FLEXSPI_LUT12, 560); +REG32(FLEXSPI_LUT13, 564); +REG32(FLEXSPI_LUT14, 568); +REG32(FLEXSPI_LUT15, 572); +REG32(FLEXSPI_LUT16, 576); +REG32(FLEXSPI_LUT17, 580); +REG32(FLEXSPI_LUT18, 584); +REG32(FLEXSPI_LUT19, 588); +REG32(FLEXSPI_LUT20, 592); +REG32(FLEXSPI_LUT21, 596); +REG32(FLEXSPI_LUT22, 600); +REG32(FLEXSPI_LUT23, 604); +REG32(FLEXSPI_LUT24, 608); +REG32(FLEXSPI_LUT25, 612); +REG32(FLEXSPI_LUT26, 616); +REG32(FLEXSPI_LUT27, 620); +REG32(FLEXSPI_LUT28, 624); +REG32(FLEXSPI_LUT29, 628); +REG32(FLEXSPI_LUT30, 632); +REG32(FLEXSPI_LUT31, 636); +REG32(FLEXSPI_LUT32, 640); +REG32(FLEXSPI_LUT33, 644); +REG32(FLEXSPI_LUT34, 648); +REG32(FLEXSPI_LUT35, 652); +REG32(FLEXSPI_LUT36, 656); +REG32(FLEXSPI_LUT37, 660); +REG32(FLEXSPI_LUT38, 664); +REG32(FLEXSPI_LUT39, 668); +REG32(FLEXSPI_LUT40, 672); +REG32(FLEXSPI_LUT41, 676); +REG32(FLEXSPI_LUT42, 680); +REG32(FLEXSPI_LUT43, 684); +REG32(FLEXSPI_LUT44, 688); +REG32(FLEXSPI_LUT45, 692); +REG32(FLEXSPI_LUT46, 696); +REG32(FLEXSPI_LUT47, 700); +REG32(FLEXSPI_LUT48, 704); +REG32(FLEXSPI_LUT49, 708); +REG32(FLEXSPI_LUT50, 712); +REG32(FLEXSPI_LUT51, 716); +REG32(FLEXSPI_LUT52, 720); +REG32(FLEXSPI_LUT53, 724); +REG32(FLEXSPI_LUT54, 728); +REG32(FLEXSPI_LUT55, 732); +REG32(FLEXSPI_LUT56, 736); +REG32(FLEXSPI_LUT57, 740); +REG32(FLEXSPI_LUT58, 744); +REG32(FLEXSPI_LUT59, 748); +REG32(FLEXSPI_LUT60, 752); +REG32(FLEXSPI_LUT61, 756); +REG32(FLEXSPI_LUT62, 760); +REG32(FLEXSPI_LUT63, 764); +/* OPERAND0 */ +SHARED_FIELD(FLEXSPI_LUT_OPERAND0, 0, 8); +/* NUM_PADS0 */ +SHARED_FIELD(FLEXSPI_LUT_NUM_PADS0, 8, 2); +/* OPCODE */ +SHARED_FIELD(FLEXSPI_LUT_OPCODE0, 10, 6); +/* OPERAND1 */ +SHARED_FIELD(FLEXSPI_LUT_OPERAND1, 16, 8); +/* NUM_PADS1 */ +SHARED_FIELD(FLEXSPI_LUT_NUM_PADS1, 24, 2); +/* OPCODE1 */ +SHARED_FIELD(FLEXSPI_LUT_OPCODE1, 26, 6); + +/* HADDR REMAP START ADDR */ +REG32(FLEXSPI_HADDRSTART, 1056); +/* AHB Bus address remap function enable */ +FIELD(FLEXSPI_HADDRSTART, REMAPEN, 0, 1); +/* HADDR start address */ +FIELD(FLEXSPI_HADDRSTART, ADDRSTART, 12, 20); + +/* HADDR REMAP END ADDR */ +REG32(FLEXSPI_HADDREND, 1060); +/* HADDR remap range's end address, 4K aligned */ +FIELD(FLEXSPI_HADDREND, ENDSTART, 12, 20); + +/* HADDR REMAP OFFSET */ +REG32(FLEXSPI_HADDROFFSET, 1064); +/* + * HADDR offset field, remapped address will be + * ADDR[31:12]=3DADDR_original[31:12]+ADDROFFSET + */ +FIELD(FLEXSPI_HADDROFFSET, ADDROFFSET, 12, 20); + + +typedef enum { + /* No impact */ + FLEXSPI_MCR0_SWRESET_val0 =3D 0, + /* Software reset */ + FLEXSPI_MCR0_SWRESET_val1 =3D 1, +} FLEXSPI_MCR0_SWRESET_Enum; + +typedef enum { + /* No impact */ + FLEXSPI_MCR0_MDIS_val0 =3D 0, + /* Module disable */ + FLEXSPI_MCR0_MDIS_val1 =3D 1, +} FLEXSPI_MCR0_MDIS_Enum; + +typedef enum { + /* + * Dummy Read strobe generated by FlexSPI Controller and loopback + * internally. + */ + FLEXSPI_MCR0_RXCLKSRC_val0 =3D 0, + /* + * Dummy Read strobe generated by FlexSPI Controller and loopback from= DQS + * pad. + */ + FLEXSPI_MCR0_RXCLKSRC_val1 =3D 1, + /* Flash provided Read strobe and input from DQS pad */ + FLEXSPI_MCR0_RXCLKSRC_val3 =3D 3, +} FLEXSPI_MCR0_RXCLKSRC_Enum; + +typedef enum { + /* Divided by 1 */ + FLEXSPI_MCR0_SERCLKDIV_val0 =3D 0, + /* Divided by 2 */ + FLEXSPI_MCR0_SERCLKDIV_val1 =3D 1, + /* Divided by 3 */ + FLEXSPI_MCR0_SERCLKDIV_val2 =3D 2, + /* Divided by 4 */ + FLEXSPI_MCR0_SERCLKDIV_val3 =3D 3, + /* Divided by 5 */ + FLEXSPI_MCR0_SERCLKDIV_val4 =3D 4, + /* Divided by 6 */ + FLEXSPI_MCR0_SERCLKDIV_val5 =3D 5, + /* Divided by 7 */ + FLEXSPI_MCR0_SERCLKDIV_val6 =3D 6, + /* Divided by 8 */ + FLEXSPI_MCR0_SERCLKDIV_val7 =3D 7, +} FLEXSPI_MCR0_SERCLKDIV_Enum; + +typedef enum { + /* Disable divide by 2 of serial flash clock for half clock frequency.= */ + FLEXSPI_MCR0_HSEN_val0 =3D 0, + /* Enable divide by 2 of serial flash clock for half clock frequency. = */ + FLEXSPI_MCR0_HSEN_val1 =3D 1, +} FLEXSPI_MCR0_HSEN_Enum; + +typedef enum { + /* + * Doze mode support disabled. AHB clock and serial clock will not be = gated + * off when there is doze mode request from system. + */ + FLEXSPI_MCR0_DOZEEN_val0 =3D 0, + /* + * Doze mode support enabled. AHB clock and serial clock will be gated= off + * when there is doze mode request from system. + */ + FLEXSPI_MCR0_DOZEEN_val1 =3D 1, +} FLEXSPI_MCR0_DOZEEN_Enum; + +typedef enum { + /* Disable SCLK output free-running. */ + FLEXSPI_MCR0_SCKFREERUNEN_DISABLE =3D 0, + /* Enable SCLK output free-running. */ + FLEXSPI_MCR0_SCKFREERUNEN_ENABLE =3D 1, +} FLEXSPI_MCR0_SCKFREERUNEN_Enum; + +typedef enum { + /* Disable the data learning feature. */ + FLEXSPI_MCR0_LEARNEN_DISABLE =3D 0, + /* Enable the data learning feature. */ + FLEXSPI_MCR0_LEARNEN_ENABLE =3D 1, +} FLEXSPI_MCR0_LEARNEN_Enum; + +typedef enum { + /* + * AHB RX/TX Buffer will not be cleared automatically when FlexSPI ret= urns + * Stop mode ACK. + */ + FLEXSPI_MCR2_CLRAHBBUFOPT_val0 =3D 0, + /* + * AHB RX/TX Buffer will be cleared automatically when FlexSPI returns= Stop + * mode ACK. + */ + FLEXSPI_MCR2_CLRAHBBUFOPT_val1 =3D 1, +} FLEXSPI_MCR2_CLRAHBBUFOPT_Enum; + +typedef enum { + /* No impact */ + FLEXSPI_MCR2_CLRLEARNPHASE_val0 =3D 0, + /* + * The sampling clock phase selection will be reset to phase 0 when th= is + * bit is written with 0x1. This bit will be auto-cleared immediately. + */ + FLEXSPI_MCR2_CLRLEARNPHASE_val1 =3D 1, +} FLEXSPI_MCR2_CLRLEARNPHASE_Enum; + +typedef enum { + /* + * In Individual mode, FLSHA1CRx/FLSHA2CRx/FLSHB1CRx/FLSHB2CRx register + * setting will be applied to Flash A1/A2/B1/B2 separately. In Parallel + * mode, FLSHA1CRx register setting will be applied to Flash A1 and B1, + * FLSHA2CRx register setting will be applied to Flash A2 and B2. + * FLSHB1CRx/FLSHB2CRx register setting will be ignored. + */ + FLEXSPI_MCR2_SAMEDEVICEEN_individual_parallel =3D 0, + /* + * FLSHA1CR0/FLSHA1CR1/FLSHA1CR2 register setting will be applied to F= lash + * A1/A2/B1/B2. FLSHA2CRx/FLSHB1CRx/FLSHB2CRx will be ignored. + */ + FLEXSPI_MCR2_SAMEDEVICEEN_ENABLE =3D 1, +} FLEXSPI_MCR2_SAMEDEVICEEN_Enum; + +typedef enum { + /* Flash will be accessed in Individual mode. */ + FLEXSPI_AHBCR_APAREN_individual =3D 0, + /* Flash will be accessed in Parallel mode. */ + FLEXSPI_AHBCR_APAREN_ENABLE =3D 1, +} FLEXSPI_AHBCR_APAREN_Enum; + +typedef enum { + /* No function. */ + FLEXSPI_AHBCR_CLRAHBTXBUF_val0 =3D 0, + /* Clear operation enable. */ + FLEXSPI_AHBCR_CLRAHBTXBUF_val1 =3D 1, +} FLEXSPI_AHBCR_CLRAHBTXBUF_Enum; + +typedef enum { + /* + * Disabled. When there is AHB bus cachable read access, FlexSPI will = not + * check whether it hit AHB TX Buffer. + */ + FLEXSPI_AHBCR_CACHABLEEN_val0 =3D 0, + /* + * Enabled. When there is AHB bus cachable read access, FlexSPI will c= heck + * whether it hit AHB TX Buffer first. + */ + FLEXSPI_AHBCR_CACHABLEEN_val1 =3D 1, +} FLEXSPI_AHBCR_CACHABLEEN_Enum; + +typedef enum { + /* + * Disabled. For all AHB write accesses (bufferable or non-bufferable), + * FlexSPI will return AHB Bus ready after all data is transmitted to + * external device and AHB command finished. + */ + FLEXSPI_AHBCR_BUFFERABLEEN_val0 =3D 0, + /* + * Enabled. For AHB bufferable write access, FlexSPI will return AHB B= us + * ready when the AHB command is granted by arbitrator and will not wa= it + * for AHB command finished. + */ + FLEXSPI_AHBCR_BUFFERABLEEN_val1 =3D 1, +} FLEXSPI_AHBCR_BUFFERABLEEN_Enum; + +typedef enum { + /* + * There is AHB read burst start address alignment limitation when fla= sh is + * accessed in parallel mode or flash is word-addressable. + */ + FLEXSPI_AHBCR_READADDROPT_val0 =3D 0, + /* + * There is no AHB read burst start address alignment limitation. Flex= SPI + * will fetch more data than AHB burst required to meet the alignment + * requirement. + */ + FLEXSPI_AHBCR_READADDROPT_val1 =3D 1, +} FLEXSPI_AHBCR_READADDROPT_Enum; + +typedef enum { + /* Suspended AHB read prefetch will start to resume when AHB is IDLE */ + FLEXSPI_AHBCR_RESUMEDISABLE_val0 =3D 0, + /* Suspended AHB read prefetch will not resume once it is aborted */ + FLEXSPI_AHBCR_RESUMEDISABLE_val1 =3D 1, +} FLEXSPI_AHBCR_RESUMEDISABLE_Enum; + +typedef enum { + /* + * AHB read size will be decided by other register setting like + * PREFETCH_EN,OTFAD_EN... + */ + FLEXSPI_AHBCR_READSZALIGN_val0 =3D 0, + /* AHB read size to up size to 8 bytes aligned, no prefetching */ + FLEXSPI_AHBCR_READSZALIGN_val1 =3D 1, +} FLEXSPI_AHBCR_READSZALIGN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_IPCMDDONEEN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_IPCMDDONEEN_value1 =3D 1, +} FLEXSPI_INTEN_IPCMDDONEEN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_IPCMDGEEN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_IPCMDGEEN_value1 =3D 1, +} FLEXSPI_INTEN_IPCMDGEEN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_AHBCMDGEEN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_AHBCMDGEEN_value1 =3D 1, +} FLEXSPI_INTEN_AHBCMDGEEN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_IPCMDERREN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_IPCMDERREN_value1 =3D 1, +} FLEXSPI_INTEN_IPCMDERREN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_AHBCMDERREN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_AHBCMDERREN_value1 =3D 1, +} FLEXSPI_INTEN_AHBCMDERREN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_IPRXWAEN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_IPRXWAEN_value1 =3D 1, +} FLEXSPI_INTEN_IPRXWAEN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_IPTXWEEN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_IPTXWEEN_value1 =3D 1, +} FLEXSPI_INTEN_IPTXWEEN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_DATALEARNFAILEN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_DATALEARNFAILEN_value1 =3D 1, +} FLEXSPI_INTEN_DATALEARNFAILEN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_SCKSTOPBYRDEN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_SCKSTOPBYRDEN_value1 =3D 1, +} FLEXSPI_INTEN_SCKSTOPBYRDEN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_SCKSTOPBYWREN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_SCKSTOPBYWREN_value1 =3D 1, +} FLEXSPI_INTEN_SCKSTOPBYWREN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_AHBBUSERROREN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_AHBBUSERROREN_value1 =3D 1, +} FLEXSPI_INTEN_AHBBUSERROREN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_SEQTIMEOUTEN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_SEQTIMEOUTEN_value1 =3D 1, +} FLEXSPI_INTEN_SEQTIMEOUTEN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_KEYDONEEN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_KEYDONEEN_value1 =3D 1, +} FLEXSPI_INTEN_KEYDONEEN_Enum; + +typedef enum { + /* Disable interrupt or no impact */ + FLEXSPI_INTEN_KEYERROREN_value0 =3D 0, + /* Enable interrupt */ + FLEXSPI_INTEN_KEYERROREN_value1 =3D 1, +} FLEXSPI_INTEN_KEYERROREN_Enum; + +typedef enum { + /* No impact */ + FLEXSPI_LUTCR_LOCK_value0 =3D 0, + /* Lock LUT, LUT will be locked and can't be written */ + FLEXSPI_LUTCR_LOCK_value1 =3D 1, +} FLEXSPI_LUTCR_LOCK_Enum; + +typedef enum { + /* No impact */ + FLEXSPI_LUTCR_UNLOCK_value0 =3D 0, + /* Unlock LUT, the LUT can be written */ + FLEXSPI_LUTCR_UNLOCK_value1 =3D 1, +} FLEXSPI_LUTCR_UNLOCK_Enum; + +typedef enum { + /* No prefetch */ + FLEXSPI_AHBRXBUF0CR0_PREFETCHEN_value0 =3D 0, + /* Prefetch enable */ + FLEXSPI_AHBRXBUF0CR0_PREFETCHEN_value1 =3D 1, +} FLEXSPI_AHBRXBUF0CR0_PREFETCHEN_Enum; + +typedef enum { + /* No prefetch */ + FLEXSPI_AHBRXBUF1CR0_PREFETCHEN_value0 =3D 0, + /* Prefetch enable */ + FLEXSPI_AHBRXBUF1CR0_PREFETCHEN_value1 =3D 1, +} FLEXSPI_AHBRXBUF1CR0_PREFETCHEN_Enum; + +typedef enum { + /* No prefetch */ + FLEXSPI_AHBRXBUF2CR0_PREFETCHEN_value0 =3D 0, + /* Prefetch enable */ + FLEXSPI_AHBRXBUF2CR0_PREFETCHEN_value1 =3D 1, +} FLEXSPI_AHBRXBUF2CR0_PREFETCHEN_Enum; + +typedef enum { + /* No prefetch */ + FLEXSPI_AHBRXBUF3CR0_PREFETCHEN_value0 =3D 0, + /* Prefetch enable */ + FLEXSPI_AHBRXBUF3CR0_PREFETCHEN_value1 =3D 1, +} FLEXSPI_AHBRXBUF3CR0_PREFETCHEN_Enum; + +typedef enum { + /* No prefetch */ + FLEXSPI_AHBRXBUF4CR0_PREFETCHEN_value0 =3D 0, + /* Prefetch enable */ + FLEXSPI_AHBRXBUF4CR0_PREFETCHEN_value1 =3D 1, +} FLEXSPI_AHBRXBUF4CR0_PREFETCHEN_Enum; + +typedef enum { + /* No prefetch */ + FLEXSPI_AHBRXBUF5CR0_PREFETCHEN_value0 =3D 0, + /* Prefetch enable */ + FLEXSPI_AHBRXBUF5CR0_PREFETCHEN_value1 =3D 1, +} FLEXSPI_AHBRXBUF5CR0_PREFETCHEN_Enum; + +typedef enum { + /* No prefetch */ + FLEXSPI_AHBRXBUF6CR0_PREFETCHEN_value0 =3D 0, + /* Prefetch enable */ + FLEXSPI_AHBRXBUF6CR0_PREFETCHEN_value1 =3D 1, +} FLEXSPI_AHBRXBUF6CR0_PREFETCHEN_Enum; + +typedef enum { + /* No prefetch */ + FLEXSPI_AHBRXBUF7CR0_PREFETCHEN_value0 =3D 0, + /* Prefetch enable */ + FLEXSPI_AHBRXBUF7CR0_PREFETCHEN_value1 =3D 1, +} FLEXSPI_AHBRXBUF7CR0_PREFETCHEN_Enum; + +typedef enum { + /* This bit should be set as 0 when external Flash is byte addressable= . */ + FLEXSPI_FLSHCR1A1_WA_value0 =3D 0, + /* + * This bit should be set as 1 when external Flash is word addressable= . If + * Flash is word addressable, it should be accessed in terms of 16 bit= s. At + * this time, FlexSPI will not transmit Flash address bit 0 to external + * Flash. + */ + FLEXSPI_FLSHCR1A1_WA_value1 =3D 1, +} FLEXSPI_FLSHCR1A1_WA_Enum; + +typedef enum { + /* The CS interval unit is 1 serial clock cycle */ + FLEXSPI_FLSHCR1A1_CSINTERVALUNIT_val0 =3D 0, + /* The CS interval unit is 256 serial clock cycle */ + FLEXSPI_FLSHCR1A1_CSINTERVALUNIT_val1 =3D 1, +} FLEXSPI_FLSHCR1A1_CSINTERVALUNIT_Enum; + +typedef enum { + /* This bit should be set as 0 when external Flash is byte addressable= . */ + FLEXSPI_FLSHCR1A2_WA_value0 =3D 0, + /* + * This bit should be set as 1 when external Flash is word addressable= . If + * Flash is word addressable, it should be accessed in terms of 16 bit= s. At + * this time, FlexSPI will not transmit Flash address bit 0 to external + * Flash. + */ + FLEXSPI_FLSHCR1A2_WA_value1 =3D 1, +} FLEXSPI_FLSHCR1A2_WA_Enum; + +typedef enum { + /* The CS interval unit is 1 serial clock cycle */ + FLEXSPI_FLSHCR1A2_CSINTERVALUNIT_val0 =3D 0, + /* The CS interval unit is 256 serial clock cycle */ + FLEXSPI_FLSHCR1A2_CSINTERVALUNIT_val1 =3D 1, +} FLEXSPI_FLSHCR1A2_CSINTERVALUNIT_Enum; + +typedef enum { + /* This bit should be set as 0 when external Flash is byte addressable= . */ + FLEXSPI_FLSHCR1B1_WA_value0 =3D 0, + /* + * This bit should be set as 1 when external Flash is word addressable= . If + * Flash is word addressable, it should be accessed in terms of 16 bit= s. At + * this time, FlexSPI will not transmit Flash address bit 0 to external + * Flash. + */ + FLEXSPI_FLSHCR1B1_WA_value1 =3D 1, +} FLEXSPI_FLSHCR1B1_WA_Enum; + +typedef enum { + /* The CS interval unit is 1 serial clock cycle */ + FLEXSPI_FLSHCR1B1_CSINTERVALUNIT_val0 =3D 0, + /* The CS interval unit is 256 serial clock cycle */ + FLEXSPI_FLSHCR1B1_CSINTERVALUNIT_val1 =3D 1, +} FLEXSPI_FLSHCR1B1_CSINTERVALUNIT_Enum; + +typedef enum { + /* This bit should be set as 0 when external Flash is byte addressable= . */ + FLEXSPI_FLSHCR1B2_WA_value0 =3D 0, + /* + * This bit should be set as 1 when external Flash is word addressable= . If + * Flash is word addressable, it should be accessed in terms of 16 bit= s. At + * this time, FlexSPI will not transmit Flash address bit 0 to external + * Flash. + */ + FLEXSPI_FLSHCR1B2_WA_value1 =3D 1, +} FLEXSPI_FLSHCR1B2_WA_Enum; + +typedef enum { + /* The CS interval unit is 1 serial clock cycle */ + FLEXSPI_FLSHCR1B2_CSINTERVALUNIT_val0 =3D 0, + /* The CS interval unit is 256 serial clock cycle */ + FLEXSPI_FLSHCR1B2_CSINTERVALUNIT_val1 =3D 1, +} FLEXSPI_FLSHCR1B2_CSINTERVALUNIT_Enum; + +typedef enum { + /* The AWRWAIT unit is 2 AHB clock cycle */ + FLEXSPI_FLSHCR2A1_AWRWAITUNIT_val0 =3D 0, + /* The AWRWAIT unit is 8 AHB clock cycle */ + FLEXSPI_FLSHCR2A1_AWRWAITUNIT_val1 =3D 1, + /* The AWRWAIT unit is 32 AHB clock cycle */ + FLEXSPI_FLSHCR2A1_AWRWAITUNIT_val2 =3D 2, + /* The AWRWAIT unit is 128 AHB clock cycle */ + FLEXSPI_FLSHCR2A1_AWRWAITUNIT_val3 =3D 3, + /* The AWRWAIT unit is 512 AHB clock cycle */ + FLEXSPI_FLSHCR2A1_AWRWAITUNIT_val4 =3D 4, + /* The AWRWAIT unit is 2048 AHB clock cycle */ + FLEXSPI_FLSHCR2A1_AWRWAITUNIT_val5 =3D 5, + /* The AWRWAIT unit is 8192 AHB clock cycle */ + FLEXSPI_FLSHCR2A1_AWRWAITUNIT_val6 =3D 6, + /* The AWRWAIT unit is 32768 AHB clock cycle */ + FLEXSPI_FLSHCR2A1_AWRWAITUNIT_val7 =3D 7, +} FLEXSPI_FLSHCR2A1_AWRWAITUNIT_Enum; + +typedef enum { + /* The AWRWAIT unit is 2 AHB clock cycle */ + FLEXSPI_FLSHCR2A2_AWRWAITUNIT_val0 =3D 0, + /* The AWRWAIT unit is 8 AHB clock cycle */ + FLEXSPI_FLSHCR2A2_AWRWAITUNIT_val1 =3D 1, + /* The AWRWAIT unit is 32 AHB clock cycle */ + FLEXSPI_FLSHCR2A2_AWRWAITUNIT_val2 =3D 2, + /* The AWRWAIT unit is 128 AHB clock cycle */ + FLEXSPI_FLSHCR2A2_AWRWAITUNIT_val3 =3D 3, + /* The AWRWAIT unit is 512 AHB clock cycle */ + FLEXSPI_FLSHCR2A2_AWRWAITUNIT_val4 =3D 4, + /* The AWRWAIT unit is 2048 AHB clock cycle */ + FLEXSPI_FLSHCR2A2_AWRWAITUNIT_val5 =3D 5, + /* The AWRWAIT unit is 8192 AHB clock cycle */ + FLEXSPI_FLSHCR2A2_AWRWAITUNIT_val6 =3D 6, + /* The AWRWAIT unit is 32768 AHB clock cycle */ + FLEXSPI_FLSHCR2A2_AWRWAITUNIT_val7 =3D 7, +} FLEXSPI_FLSHCR2A2_AWRWAITUNIT_Enum; + +typedef enum { + /* The AWRWAIT unit is 2 AHB clock cycle */ + FLEXSPI_FLSHCR2B1_AWRWAITUNIT_val0 =3D 0, + /* The AWRWAIT unit is 8 AHB clock cycle */ + FLEXSPI_FLSHCR2B1_AWRWAITUNIT_val1 =3D 1, + /* The AWRWAIT unit is 32 AHB clock cycle */ + FLEXSPI_FLSHCR2B1_AWRWAITUNIT_val2 =3D 2, + /* The AWRWAIT unit is 128 AHB clock cycle */ + FLEXSPI_FLSHCR2B1_AWRWAITUNIT_val3 =3D 3, + /* The AWRWAIT unit is 512 AHB clock cycle */ + FLEXSPI_FLSHCR2B1_AWRWAITUNIT_val4 =3D 4, + /* The AWRWAIT unit is 2048 AHB clock cycle */ + FLEXSPI_FLSHCR2B1_AWRWAITUNIT_val5 =3D 5, + /* The AWRWAIT unit is 8192 AHB clock cycle */ + FLEXSPI_FLSHCR2B1_AWRWAITUNIT_val6 =3D 6, + /* The AWRWAIT unit is 32768 AHB clock cycle */ + FLEXSPI_FLSHCR2B1_AWRWAITUNIT_val7 =3D 7, +} FLEXSPI_FLSHCR2B1_AWRWAITUNIT_Enum; + +typedef enum { + /* The AWRWAIT unit is 2 AHB clock cycle */ + FLEXSPI_FLSHCR2B2_AWRWAITUNIT_val0 =3D 0, + /* The AWRWAIT unit is 8 AHB clock cycle */ + FLEXSPI_FLSHCR2B2_AWRWAITUNIT_val1 =3D 1, + /* The AWRWAIT unit is 32 AHB clock cycle */ + FLEXSPI_FLSHCR2B2_AWRWAITUNIT_val2 =3D 2, + /* The AWRWAIT unit is 128 AHB clock cycle */ + FLEXSPI_FLSHCR2B2_AWRWAITUNIT_val3 =3D 3, + /* The AWRWAIT unit is 512 AHB clock cycle */ + FLEXSPI_FLSHCR2B2_AWRWAITUNIT_val4 =3D 4, + /* The AWRWAIT unit is 2048 AHB clock cycle */ + FLEXSPI_FLSHCR2B2_AWRWAITUNIT_val5 =3D 5, + /* The AWRWAIT unit is 8192 AHB clock cycle */ + FLEXSPI_FLSHCR2B2_AWRWAITUNIT_val6 =3D 6, + /* The AWRWAIT unit is 32768 AHB clock cycle */ + FLEXSPI_FLSHCR2B2_AWRWAITUNIT_val7 =3D 7, +} FLEXSPI_FLSHCR2B2_AWRWAITUNIT_Enum; + +typedef enum { + /* + * DQS pin will be used as Write Mask when writing to external device. + * There is no limitation on AHB/IP write burst start address alignment + * when flash is accessed in individual mode. + */ + FLEXSPI_FLSHCR4_WMOPT1_DISABLE =3D 0, + /* + * DQS pin will not be used as Write Mask when writing to external dev= ice. + * There is limitation on AHB/IP write burst start address alignment w= hen + * flash is accessed in individual mode. + */ + FLEXSPI_FLSHCR4_WMOPT1_ENABLE =3D 1, +} FLEXSPI_FLSHCR4_WMOPT1_Enum; + +typedef enum { + /* + * Write mask is disabled, DQS(RWDS) pin will not be driven when writi= ng to + * external device. + */ + FLEXSPI_FLSHCR4_WMENA_val0 =3D 0, + /* + * Write mask is enabled, DQS(RWDS) pin will be driven by FlexSPI as w= rite + * mask output when writing to external device. + */ + FLEXSPI_FLSHCR4_WMENA_val1 =3D 1, +} FLEXSPI_FLSHCR4_WMENA_Enum; + +typedef enum { + /* Flash will be accessed in Individual mode. */ + FLEXSPI_IPCR1_IPAREN_DISABLE =3D 0, + /* Flash will be accessed in Parallel mode. */ + FLEXSPI_IPCR1_IPAREN_ENABLE =3D 1, +} FLEXSPI_IPCR1_IPAREN_Enum; + +typedef enum { + /* No function. */ + FLEXSPI_IPRXFCR_CLRIPRXF_value0 =3D 0, + /* A clock cycle pulse to clear all valid data entries in IP RX FIFO. = */ + FLEXSPI_IPRXFCR_CLRIPRXF_value1 =3D 1, +} FLEXSPI_IPRXFCR_CLRIPRXF_Enum; + +typedef enum { + /* IP RX FIFO would be read by processor. */ + FLEXSPI_IPRXFCR_RXDMAEN_val0 =3D 0, + /* IP RX FIFO would be read by DMA. */ + FLEXSPI_IPRXFCR_RXDMAEN_val1 =3D 1, +} FLEXSPI_IPRXFCR_RXDMAEN_Enum; + +typedef enum { + /* No function. */ + FLEXSPI_IPTXFCR_CLRIPTXF_value0 =3D 0, + /* A clock cycle pulse to clear all valid data entries in IP TX FIFO. = */ + FLEXSPI_IPTXFCR_CLRIPTXF_value1 =3D 1, +} FLEXSPI_IPTXFCR_CLRIPTXF_Enum; + +typedef enum { + /* IP TX FIFO would be filled by processor. */ + FLEXSPI_IPTXFCR_TXDMAEN_val0 =3D 0, + /* IP TX FIFO would be filled by DMA. */ + FLEXSPI_IPTXFCR_TXDMAEN_val1 =3D 1, +} FLEXSPI_IPTXFCR_TXDMAEN_Enum; + +typedef enum { + /* DLL calibration is disabled */ + FLEXSPI_DLLCRA_DLLEN_value0 =3D 0, + /* DLL calibration is enabled */ + FLEXSPI_DLLCRA_DLLEN_value1 =3D 1, +} FLEXSPI_DLLCRA_DLLEN_Enum; + +typedef enum { + /* No function. */ + FLEXSPI_DLLCRA_DLLRESET_value0 =3D 0, + /* Software could force a reset on DLL by setting this field to 0x1. */ + FLEXSPI_DLLCRA_DLLRESET_value1 =3D 1, +} FLEXSPI_DLLCRA_DLLRESET_Enum; + +typedef enum { + /* + * Slave clock delay line delay cell number selection override is disa= bled. + */ + FLEXSPI_DLLCRA_OVRDEN_value0 =3D 0, + /* + * Slave clock delay line delay cell number selection override is enab= led. + */ + FLEXSPI_DLLCRA_OVRDEN_value1 =3D 1, +} FLEXSPI_DLLCRA_OVRDEN_Enum; + +typedef enum { + /* DLL calibration is disabled */ + FLEXSPI_DLLCRB_DLLEN_value0 =3D 0, + /* DLL calibration is enabled */ + FLEXSPI_DLLCRB_DLLEN_value1 =3D 1, +} FLEXSPI_DLLCRB_DLLEN_Enum; + +typedef enum { + /* No function. */ + FLEXSPI_DLLCRB_DLLRESET_value0 =3D 0, + /* Software could force a reset on DLL by setting this field to 0x1. */ + FLEXSPI_DLLCRB_DLLRESET_value1 =3D 1, +} FLEXSPI_DLLCRB_DLLRESET_Enum; + +typedef enum { + /* + * Slave clock delay line delay cell number selection override is disa= bled. + */ + FLEXSPI_DLLCRB_OVRDEN_value0 =3D 0, + /* + * Slave clock delay line delay cell number selection override is enab= led. + */ + FLEXSPI_DLLCRB_OVRDEN_value1 =3D 1, +} FLEXSPI_DLLCRB_OVRDEN_Enum; + +typedef enum { + /* State machine in SEQ_CTL is not idle. */ + FLEXSPI_STS0_SEQIDLE_value0 =3D 0, + /* State machine in SEQ_CTL is idle. */ + FLEXSPI_STS0_SEQIDLE_value1 =3D 1, +} FLEXSPI_STS0_SEQIDLE_Enum; + +typedef enum { + /* Triggered by AHB read command. */ + FLEXSPI_STS0_ARBCMDSRC_val0 =3D 0, + /* Triggered by AHB write command. */ + FLEXSPI_STS0_ARBCMDSRC_val1 =3D 1, + /* + * Triggered by IP command (triggered by setting register bit IPCMD[TR= G]). + */ + FLEXSPI_STS0_ARBCMDSRC_val2 =3D 2, + /* Triggered by suspended command (resumed). */ + FLEXSPI_STS0_ARBCMDSRC_val3 =3D 3, +} FLEXSPI_STS0_ARBCMDSRC_Enum; + +typedef enum { + /* No error. */ + FLEXSPI_STS1_AHBCMDERRCODE_val0 =3D 0, + /* AHB Write command with JMP_ON_CS instruction used in the sequence. = */ + FLEXSPI_STS1_AHBCMDERRCODE_val2 =3D 2, + /* There is unknown instruction opcode in the sequence. */ + FLEXSPI_STS1_AHBCMDERRCODE_val3 =3D 3, + /* Instruction DUMMY_SDR/DUMMY_RWDS_SDR used in DDR sequence. */ + FLEXSPI_STS1_AHBCMDERRCODE_val4 =3D 4, + /* Instruction DUMMY_DDR/DUMMY_RWDS_DDR used in SDR sequence. */ + FLEXSPI_STS1_AHBCMDERRCODE_val5 =3D 5, + /* Sequence execution timeout. */ + FLEXSPI_STS1_AHBCMDERRCODE_val6 =3D 14, +} FLEXSPI_STS1_AHBCMDERRCODE_Enum; + +typedef enum { + /* No error. */ + FLEXSPI_STS1_IPCMDERRCODE_val0 =3D 0, + /* IP command with JMP_ON_CS instruction used in the sequence. */ + FLEXSPI_STS1_IPCMDERRCODE_val2 =3D 2, + /* There is unknown instruction opcode in the sequence. */ + FLEXSPI_STS1_IPCMDERRCODE_val3 =3D 3, + /* Instruction DUMMY_SDR/DUMMY_RWDS_SDR used in DDR sequence. */ + FLEXSPI_STS1_IPCMDERRCODE_val4 =3D 4, + /* Instruction DUMMY_DDR/DUMMY_RWDS_DDR used in SDR sequence. */ + FLEXSPI_STS1_IPCMDERRCODE_val5 =3D 5, + /* + * Flash access start address exceed the whole flash address range + * (A1/A2/B1/B2). + */ + FLEXSPI_STS1_IPCMDERRCODE_val6 =3D 6, + /* Sequence execution timeout. */ + FLEXSPI_STS1_IPCMDERRCODE_val7 =3D 14, + /* Flash boundary crossed. */ + FLEXSPI_STS1_IPCMDERRCODE_val8 =3D 15, +} FLEXSPI_STS1_IPCMDERRCODE_Enum; + +typedef enum { + /* Flash A sample clock slave delay line is not locked */ + FLEXSPI_STS2_ASLVLOCK_val0 =3D 0, + /* Flash A sample clock slave delay line is locked */ + FLEXSPI_STS2_ASLVLOCK_val1 =3D 1, +} FLEXSPI_STS2_ASLVLOCK_Enum; + +typedef enum { + /* Flash A sample clock reference delay line is not locked */ + FLEXSPI_STS2_AREFLOCK_val0 =3D 0, + /* Flash A sample clock reference delay line is locked */ + FLEXSPI_STS2_AREFLOCK_val1 =3D 1, +} FLEXSPI_STS2_AREFLOCK_Enum; + +typedef enum { + /* Flash B sample clock slave delay line is not locked. */ + FLEXSPI_STS2_BSLVLOCK_val0 =3D 0, + /* Flash B sample clock slave delay line is locked. */ + FLEXSPI_STS2_BSLVLOCK_val1 =3D 1, +} FLEXSPI_STS2_BSLVLOCK_Enum; + +typedef enum { + /* Flash B sample clock reference delay line is not locked. */ + FLEXSPI_STS2_BREFLOCK_val0 =3D 0, + /* Flash B sample clock reference delay line is locked. */ + FLEXSPI_STS2_BREFLOCK_val1 =3D 1, +} FLEXSPI_STS2_BREFLOCK_Enum; + +typedef enum { + /* No suspended AHB read prefetch command. */ + FLEXSPI_AHBSPNDSTS_ACTIVE_val0 =3D 0, + /* An AHB read prefetch command sequence has been suspended. */ + FLEXSPI_AHBSPNDSTS_ACTIVE_val1 =3D 1, +} FLEXSPI_AHBSPNDSTS_ACTIVE_Enum; + +typedef enum { + /* HADDR REMAP Disabled */ + FLEXSPI_HADDRSTART_REMAPEN_val0 =3D 0, + /* HADDR REMAP Enabled */ + FLEXSPI_HADDRSTART_REMAPEN_val1 =3D 1, +} FLEXSPI_HADDRSTART_REMAPEN_Enum; + + +#define FLEXSPI_REGISTER_ACCESS_INFO_ARRAY(_name) \ + struct RegisterAccessInfo _name[FLEXSPI_REGS_NO] =3D { \ + [0 ... FLEXSPI_REGS_NO - 1] =3D { \ + .name =3D "", \ + .addr =3D -1, \ + }, \ + [R_FLEXSPI_MCR0] =3D { \ + .name =3D "MCR0", \ + .addr =3D 0x0, \ + .ro =3D 0x20CC, \ + .reset =3D 0xFFFF80C2, \ + }, \ + [R_FLEXSPI_MCR1] =3D { \ + .name =3D "MCR1", \ + .addr =3D 0x4, \ + .ro =3D 0x0, \ + .reset =3D 0xFFFFFFFF, \ + }, \ + [R_FLEXSPI_MCR2] =3D { \ + .name =3D "MCR2", \ + .addr =3D 0x8, \ + .ro =3D 0xFF37FF, \ + .reset =3D 0x200081F7, \ + }, \ + [R_FLEXSPI_AHBCR] =3D { \ + .name =3D "AHBCR", \ + .addr =3D 0xC, \ + .ro =3D 0xFFFFFB02, \ + .reset =3D 0x18, \ + }, \ + [R_FLEXSPI_INTEN] =3D { \ + .name =3D "INTEN", \ + .addr =3D 0x10, \ + .ro =3D 0xFFFFC000, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_INTR] =3D { \ + .name =3D "INTR", \ + .addr =3D 0x14, \ + .ro =3D 0xFFFFE000, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUTKEY] =3D { \ + .name =3D "LUTKEY", \ + .addr =3D 0x18, \ + .ro =3D 0x0, \ + .reset =3D 0x5AF05AF0, \ + }, \ + [R_FLEXSPI_LUTCR] =3D { \ + .name =3D "LUTCR", \ + .addr =3D 0x1C, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x2, \ + }, \ + [R_FLEXSPI_AHBRXBUF0CR0] =3D { \ + .name =3D "AHBRXBUF0CR0", \ + .addr =3D 0x20, \ + .ro =3D 0x78F0FF00, \ + .reset =3D 0x80000010, \ + }, \ + [R_FLEXSPI_AHBRXBUF1CR0] =3D { \ + .name =3D "AHBRXBUF1CR0", \ + .addr =3D 0x24, \ + .ro =3D 0x78F0FF00, \ + .reset =3D 0x80010010, \ + }, \ + [R_FLEXSPI_AHBRXBUF2CR0] =3D { \ + .name =3D "AHBRXBUF2CR0", \ + .addr =3D 0x28, \ + .ro =3D 0x78F0FF00, \ + .reset =3D 0x80020010, \ + }, \ + [R_FLEXSPI_AHBRXBUF3CR0] =3D { \ + .name =3D "AHBRXBUF3CR0", \ + .addr =3D 0x2C, \ + .ro =3D 0x78F0FF00, \ + .reset =3D 0x80030010, \ + }, \ + [R_FLEXSPI_AHBRXBUF4CR0] =3D { \ + .name =3D "AHBRXBUF4CR0", \ + .addr =3D 0x30, \ + .ro =3D 0x78F0FF00, \ + .reset =3D 0x80040010, \ + }, \ + [R_FLEXSPI_AHBRXBUF5CR0] =3D { \ + .name =3D "AHBRXBUF5CR0", \ + .addr =3D 0x34, \ + .ro =3D 0x78F0FF00, \ + .reset =3D 0x80050010, \ + }, \ + [R_FLEXSPI_AHBRXBUF6CR0] =3D { \ + .name =3D "AHBRXBUF6CR0", \ + .addr =3D 0x38, \ + .ro =3D 0x78F0FF00, \ + .reset =3D 0x80060010, \ + }, \ + [R_FLEXSPI_AHBRXBUF7CR0] =3D { \ + .name =3D "AHBRXBUF7CR0", \ + .addr =3D 0x3C, \ + .ro =3D 0x78F0FF00, \ + .reset =3D 0x80070010, \ + }, \ + [R_FLEXSPI_FLSHA1CR0] =3D { \ + .name =3D "FLSHA1CR0", \ + .addr =3D 0x60, \ + .ro =3D 0xFF800000, \ + .reset =3D 0x10000, \ + }, \ + [R_FLEXSPI_FLSHA2CR0] =3D { \ + .name =3D "FLSHA2CR0", \ + .addr =3D 0x64, \ + .ro =3D 0xFF800000, \ + .reset =3D 0x10000, \ + }, \ + [R_FLEXSPI_FLSHB1CR0] =3D { \ + .name =3D "FLSHB1CR0", \ + .addr =3D 0x68, \ + .ro =3D 0xFF800000, \ + .reset =3D 0x10000, \ + }, \ + [R_FLEXSPI_FLSHB2CR0] =3D { \ + .name =3D "FLSHB2CR0", \ + .addr =3D 0x6C, \ + .ro =3D 0xFF800000, \ + .reset =3D 0x10000, \ + }, \ + [R_FLEXSPI_FLSHCR1A1] =3D { \ + .name =3D "FLSHCR1A1", \ + .addr =3D 0x70, \ + .ro =3D 0x0, \ + .reset =3D 0x63, \ + }, \ + [R_FLEXSPI_FLSHCR1A2] =3D { \ + .name =3D "FLSHCR1A2", \ + .addr =3D 0x74, \ + .ro =3D 0x0, \ + .reset =3D 0x63, \ + }, \ + [R_FLEXSPI_FLSHCR1B1] =3D { \ + .name =3D "FLSHCR1B1", \ + .addr =3D 0x78, \ + .ro =3D 0x0, \ + .reset =3D 0x63, \ + }, \ + [R_FLEXSPI_FLSHCR1B2] =3D { \ + .name =3D "FLSHCR1B2", \ + .addr =3D 0x7C, \ + .ro =3D 0x0, \ + .reset =3D 0x63, \ + }, \ + [R_FLEXSPI_FLSHCR2A1] =3D { \ + .name =3D "FLSHCR2A1", \ + .addr =3D 0x80, \ + .ro =3D 0x1010, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_FLSHCR2A2] =3D { \ + .name =3D "FLSHCR2A2", \ + .addr =3D 0x84, \ + .ro =3D 0x1010, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_FLSHCR2B1] =3D { \ + .name =3D "FLSHCR2B1", \ + .addr =3D 0x88, \ + .ro =3D 0x1010, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_FLSHCR2B2] =3D { \ + .name =3D "FLSHCR2B2", \ + .addr =3D 0x8C, \ + .ro =3D 0x1010, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_FLSHCR4] =3D { \ + .name =3D "FLSHCR4", \ + .addr =3D 0x94, \ + .ro =3D 0xFFFFFFFA, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_IPCR0] =3D { \ + .name =3D "IPCR0", \ + .addr =3D 0xA0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_IPCR1] =3D { \ + .name =3D "IPCR1", \ + .addr =3D 0xA4, \ + .ro =3D 0x78F00000, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_IPCMD] =3D { \ + .name =3D "IPCMD", \ + .addr =3D 0xB0, \ + .ro =3D 0xFFFFFFFE, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_DLPR] =3D { \ + .name =3D "DLPR", \ + .addr =3D 0xB4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_IPRXFCR] =3D { \ + .name =3D "IPRXFCR", \ + .addr =3D 0xB8, \ + .ro =3D 0xFFFFFE00, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_IPTXFCR] =3D { \ + .name =3D "IPTXFCR", \ + .addr =3D 0xBC, \ + .ro =3D 0xFFFFFE00, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_DLLCRA] =3D { \ + .name =3D "DLLCRA", \ + .addr =3D 0xC0, \ + .ro =3D 0xFFFF8084, \ + .reset =3D 0x100, \ + }, \ + [R_FLEXSPI_DLLCRB] =3D { \ + .name =3D "DLLCRB", \ + .addr =3D 0xC4, \ + .ro =3D 0xFFFF8084, \ + .reset =3D 0x100, \ + }, \ + [R_FLEXSPI_STS0] =3D { \ + .name =3D "STS0", \ + .addr =3D 0xE0, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x2, \ + }, \ + [R_FLEXSPI_STS1] =3D { \ + .name =3D "STS1", \ + .addr =3D 0xE4, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_STS2] =3D { \ + .name =3D "STS2", \ + .addr =3D 0xE8, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x1000100, \ + }, \ + [R_FLEXSPI_AHBSPNDSTS] =3D { \ + .name =3D "AHBSPNDSTS", \ + .addr =3D 0xEC, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_IPRXFSTS] =3D { \ + .name =3D "IPRXFSTS", \ + .addr =3D 0xF0, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_IPTXFSTS] =3D { \ + .name =3D "IPTXFSTS", \ + .addr =3D 0xF4, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR0] =3D { \ + .name =3D "RFDR0", \ + .addr =3D 0x100, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR1] =3D { \ + .name =3D "RFDR1", \ + .addr =3D 0x104, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR2] =3D { \ + .name =3D "RFDR2", \ + .addr =3D 0x108, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR3] =3D { \ + .name =3D "RFDR3", \ + .addr =3D 0x10C, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR4] =3D { \ + .name =3D "RFDR4", \ + .addr =3D 0x110, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR5] =3D { \ + .name =3D "RFDR5", \ + .addr =3D 0x114, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR6] =3D { \ + .name =3D "RFDR6", \ + .addr =3D 0x118, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR7] =3D { \ + .name =3D "RFDR7", \ + .addr =3D 0x11C, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR8] =3D { \ + .name =3D "RFDR8", \ + .addr =3D 0x120, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR9] =3D { \ + .name =3D "RFDR9", \ + .addr =3D 0x124, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR10] =3D { \ + .name =3D "RFDR10", \ + .addr =3D 0x128, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR11] =3D { \ + .name =3D "RFDR11", \ + .addr =3D 0x12C, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR12] =3D { \ + .name =3D "RFDR12", \ + .addr =3D 0x130, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR13] =3D { \ + .name =3D "RFDR13", \ + .addr =3D 0x134, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR14] =3D { \ + .name =3D "RFDR14", \ + .addr =3D 0x138, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR15] =3D { \ + .name =3D "RFDR15", \ + .addr =3D 0x13C, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR16] =3D { \ + .name =3D "RFDR16", \ + .addr =3D 0x140, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR17] =3D { \ + .name =3D "RFDR17", \ + .addr =3D 0x144, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR18] =3D { \ + .name =3D "RFDR18", \ + .addr =3D 0x148, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR19] =3D { \ + .name =3D "RFDR19", \ + .addr =3D 0x14C, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR20] =3D { \ + .name =3D "RFDR20", \ + .addr =3D 0x150, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR21] =3D { \ + .name =3D "RFDR21", \ + .addr =3D 0x154, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR22] =3D { \ + .name =3D "RFDR22", \ + .addr =3D 0x158, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR23] =3D { \ + .name =3D "RFDR23", \ + .addr =3D 0x15C, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR24] =3D { \ + .name =3D "RFDR24", \ + .addr =3D 0x160, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR25] =3D { \ + .name =3D "RFDR25", \ + .addr =3D 0x164, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR26] =3D { \ + .name =3D "RFDR26", \ + .addr =3D 0x168, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR27] =3D { \ + .name =3D "RFDR27", \ + .addr =3D 0x16C, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR28] =3D { \ + .name =3D "RFDR28", \ + .addr =3D 0x170, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR29] =3D { \ + .name =3D "RFDR29", \ + .addr =3D 0x174, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR30] =3D { \ + .name =3D "RFDR30", \ + .addr =3D 0x178, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_RFDR31] =3D { \ + .name =3D "RFDR31", \ + .addr =3D 0x17C, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR0] =3D { \ + .name =3D "TFDR0", \ + .addr =3D 0x180, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR1] =3D { \ + .name =3D "TFDR1", \ + .addr =3D 0x184, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR2] =3D { \ + .name =3D "TFDR2", \ + .addr =3D 0x188, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR3] =3D { \ + .name =3D "TFDR3", \ + .addr =3D 0x18C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR4] =3D { \ + .name =3D "TFDR4", \ + .addr =3D 0x190, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR5] =3D { \ + .name =3D "TFDR5", \ + .addr =3D 0x194, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR6] =3D { \ + .name =3D "TFDR6", \ + .addr =3D 0x198, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR7] =3D { \ + .name =3D "TFDR7", \ + .addr =3D 0x19C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR8] =3D { \ + .name =3D "TFDR8", \ + .addr =3D 0x1A0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR9] =3D { \ + .name =3D "TFDR9", \ + .addr =3D 0x1A4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR10] =3D { \ + .name =3D "TFDR10", \ + .addr =3D 0x1A8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR11] =3D { \ + .name =3D "TFDR11", \ + .addr =3D 0x1AC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR12] =3D { \ + .name =3D "TFDR12", \ + .addr =3D 0x1B0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR13] =3D { \ + .name =3D "TFDR13", \ + .addr =3D 0x1B4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR14] =3D { \ + .name =3D "TFDR14", \ + .addr =3D 0x1B8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR15] =3D { \ + .name =3D "TFDR15", \ + .addr =3D 0x1BC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR16] =3D { \ + .name =3D "TFDR16", \ + .addr =3D 0x1C0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR17] =3D { \ + .name =3D "TFDR17", \ + .addr =3D 0x1C4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR18] =3D { \ + .name =3D "TFDR18", \ + .addr =3D 0x1C8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR19] =3D { \ + .name =3D "TFDR19", \ + .addr =3D 0x1CC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR20] =3D { \ + .name =3D "TFDR20", \ + .addr =3D 0x1D0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR21] =3D { \ + .name =3D "TFDR21", \ + .addr =3D 0x1D4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR22] =3D { \ + .name =3D "TFDR22", \ + .addr =3D 0x1D8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR23] =3D { \ + .name =3D "TFDR23", \ + .addr =3D 0x1DC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR24] =3D { \ + .name =3D "TFDR24", \ + .addr =3D 0x1E0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR25] =3D { \ + .name =3D "TFDR25", \ + .addr =3D 0x1E4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR26] =3D { \ + .name =3D "TFDR26", \ + .addr =3D 0x1E8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR27] =3D { \ + .name =3D "TFDR27", \ + .addr =3D 0x1EC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR28] =3D { \ + .name =3D "TFDR28", \ + .addr =3D 0x1F0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR29] =3D { \ + .name =3D "TFDR29", \ + .addr =3D 0x1F4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR30] =3D { \ + .name =3D "TFDR30", \ + .addr =3D 0x1F8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_TFDR31] =3D { \ + .name =3D "TFDR31", \ + .addr =3D 0x1FC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT0] =3D { \ + .name =3D "LUT0", \ + .addr =3D 0x200, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT1] =3D { \ + .name =3D "LUT1", \ + .addr =3D 0x204, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT2] =3D { \ + .name =3D "LUT2", \ + .addr =3D 0x208, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT3] =3D { \ + .name =3D "LUT3", \ + .addr =3D 0x20C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT4] =3D { \ + .name =3D "LUT4", \ + .addr =3D 0x210, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT5] =3D { \ + .name =3D "LUT5", \ + .addr =3D 0x214, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT6] =3D { \ + .name =3D "LUT6", \ + .addr =3D 0x218, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT7] =3D { \ + .name =3D "LUT7", \ + .addr =3D 0x21C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT8] =3D { \ + .name =3D "LUT8", \ + .addr =3D 0x220, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT9] =3D { \ + .name =3D "LUT9", \ + .addr =3D 0x224, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT10] =3D { \ + .name =3D "LUT10", \ + .addr =3D 0x228, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT11] =3D { \ + .name =3D "LUT11", \ + .addr =3D 0x22C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT12] =3D { \ + .name =3D "LUT12", \ + .addr =3D 0x230, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT13] =3D { \ + .name =3D "LUT13", \ + .addr =3D 0x234, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT14] =3D { \ + .name =3D "LUT14", \ + .addr =3D 0x238, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT15] =3D { \ + .name =3D "LUT15", \ + .addr =3D 0x23C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT16] =3D { \ + .name =3D "LUT16", \ + .addr =3D 0x240, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT17] =3D { \ + .name =3D "LUT17", \ + .addr =3D 0x244, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT18] =3D { \ + .name =3D "LUT18", \ + .addr =3D 0x248, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT19] =3D { \ + .name =3D "LUT19", \ + .addr =3D 0x24C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT20] =3D { \ + .name =3D "LUT20", \ + .addr =3D 0x250, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT21] =3D { \ + .name =3D "LUT21", \ + .addr =3D 0x254, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT22] =3D { \ + .name =3D "LUT22", \ + .addr =3D 0x258, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT23] =3D { \ + .name =3D "LUT23", \ + .addr =3D 0x25C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT24] =3D { \ + .name =3D "LUT24", \ + .addr =3D 0x260, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT25] =3D { \ + .name =3D "LUT25", \ + .addr =3D 0x264, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT26] =3D { \ + .name =3D "LUT26", \ + .addr =3D 0x268, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT27] =3D { \ + .name =3D "LUT27", \ + .addr =3D 0x26C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT28] =3D { \ + .name =3D "LUT28", \ + .addr =3D 0x270, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT29] =3D { \ + .name =3D "LUT29", \ + .addr =3D 0x274, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT30] =3D { \ + .name =3D "LUT30", \ + .addr =3D 0x278, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT31] =3D { \ + .name =3D "LUT31", \ + .addr =3D 0x27C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT32] =3D { \ + .name =3D "LUT32", \ + .addr =3D 0x280, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT33] =3D { \ + .name =3D "LUT33", \ + .addr =3D 0x284, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT34] =3D { \ + .name =3D "LUT34", \ + .addr =3D 0x288, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT35] =3D { \ + .name =3D "LUT35", \ + .addr =3D 0x28C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT36] =3D { \ + .name =3D "LUT36", \ + .addr =3D 0x290, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT37] =3D { \ + .name =3D "LUT37", \ + .addr =3D 0x294, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT38] =3D { \ + .name =3D "LUT38", \ + .addr =3D 0x298, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT39] =3D { \ + .name =3D "LUT39", \ + .addr =3D 0x29C, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT40] =3D { \ + .name =3D "LUT40", \ + .addr =3D 0x2A0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT41] =3D { \ + .name =3D "LUT41", \ + .addr =3D 0x2A4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT42] =3D { \ + .name =3D "LUT42", \ + .addr =3D 0x2A8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT43] =3D { \ + .name =3D "LUT43", \ + .addr =3D 0x2AC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT44] =3D { \ + .name =3D "LUT44", \ + .addr =3D 0x2B0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT45] =3D { \ + .name =3D "LUT45", \ + .addr =3D 0x2B4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT46] =3D { \ + .name =3D "LUT46", \ + .addr =3D 0x2B8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT47] =3D { \ + .name =3D "LUT47", \ + .addr =3D 0x2BC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT48] =3D { \ + .name =3D "LUT48", \ + .addr =3D 0x2C0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT49] =3D { \ + .name =3D "LUT49", \ + .addr =3D 0x2C4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT50] =3D { \ + .name =3D "LUT50", \ + .addr =3D 0x2C8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT51] =3D { \ + .name =3D "LUT51", \ + .addr =3D 0x2CC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT52] =3D { \ + .name =3D "LUT52", \ + .addr =3D 0x2D0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT53] =3D { \ + .name =3D "LUT53", \ + .addr =3D 0x2D4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT54] =3D { \ + .name =3D "LUT54", \ + .addr =3D 0x2D8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT55] =3D { \ + .name =3D "LUT55", \ + .addr =3D 0x2DC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT56] =3D { \ + .name =3D "LUT56", \ + .addr =3D 0x2E0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT57] =3D { \ + .name =3D "LUT57", \ + .addr =3D 0x2E4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT58] =3D { \ + .name =3D "LUT58", \ + .addr =3D 0x2E8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT59] =3D { \ + .name =3D "LUT59", \ + .addr =3D 0x2EC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT60] =3D { \ + .name =3D "LUT60", \ + .addr =3D 0x2F0, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT61] =3D { \ + .name =3D "LUT61", \ + .addr =3D 0x2F4, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT62] =3D { \ + .name =3D "LUT62", \ + .addr =3D 0x2F8, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_LUT63] =3D { \ + .name =3D "LUT63", \ + .addr =3D 0x2FC, \ + .ro =3D 0x0, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_HADDRSTART] =3D { \ + .name =3D "HADDRSTART", \ + .addr =3D 0x420, \ + .ro =3D 0xFFE, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_HADDREND] =3D { \ + .name =3D "HADDREND", \ + .addr =3D 0x424, \ + .ro =3D 0xFFF, \ + .reset =3D 0x0, \ + }, \ + [R_FLEXSPI_HADDROFFSET] =3D { \ + .name =3D "HADDROFFSET", \ + .addr =3D 0x428, \ + .ro =3D 0xFFF, \ + .reset =3D 0x0, \ + }, \ + } diff --git a/include/hw/ssi/flexspi.h b/include/hw/ssi/flexspi.h new file mode 100644 index 0000000000..51699e1ceb --- /dev/null +++ b/include/hw/ssi/flexspi.h @@ -0,0 +1,31 @@ +/* + * QEMU model for FLEXSPI + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_RT500_FLEXSPI_H +#define HW_RT500_FLEXSPI_H + +#include "hw/sysbus.h" +#include "hw/ssi/ssi.h" +#include "hw/arm/svd/flexspi.h" + +#define TYPE_FLEXSPI "flexspi" +#define FLEXSPI(obj) OBJECT_CHECK(FlexSpiState, (obj), TYPE_FLEXSPI) + +typedef struct { + SysBusDevice parent_obj; + + MemoryRegion mmio; + uint32_t regs[FLEXSPI_REGS_NO]; + MemoryRegion mem; + uint64_t mmap_size; +} FlexSpiState; + +#endif /* HW_RT500_FLEXSPI_H */ diff --git a/hw/ssi/flexspi.c b/hw/ssi/flexspi.c new file mode 100644 index 0000000000..d5d9e4f098 --- /dev/null +++ b/hw/ssi/flexspi.c @@ -0,0 +1,181 @@ +/* + * QEMU model for FLEXSPI + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/mmap-alloc.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/units.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" +#include "migration/vmstate.h" +#include "exec/address-spaces.h" +#include "hw/ssi/flexspi.h" +#include "hw/arm/svd/flexspi.h" + +#include "trace.h" + +#define REG(s, reg) (s->regs[R_FLEXSPI_##reg]) +#define RF_WR(s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXSPI_##reg, field, val) +#define RF_RD(s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXSPI_##reg, field) + +static FLEXSPI_REGISTER_ACCESS_INFO_ARRAY(reg_info); + +static void flexspi_reset_enter(Object *obj, ResetType type) +{ + FlexSpiState *s =3D FLEXSPI(obj); + + for (int i =3D 0; i < FLEXSPI_REGS_NO; i++) { + hwaddr addr =3D reg_info[i].addr; + + if (addr !=3D -1) { + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D ®_info[i], + }; + + register_reset(&ri); + } + } + + /* idle immediately after reset */ + RF_WR(s, STS0, SEQIDLE, 1); +} + +static MemTxResult flexspi_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + FlexSpiState *s =3D opaque; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + MemTxResult ret =3D MEMTX_OK; + + switch (addr) { + default: + *data =3D s->regs[addr / 4]; + break; + } + + trace_flexspi_reg_read(DEVICE(s)->id, rai->name, addr, *data); + return ret; +} + + +static MemTxResult flexspi_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + FlexSpiState *s =3D opaque; + const struct RegisterAccessInfo *rai =3D ®_info[addr / 4]; + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D rai, + }; + + trace_flexspi_reg_write(DEVICE(s)->id, rai->name, addr, value); + + switch (addr) { + case A_FLEXSPI_MCR0: + { + register_write(&ri, value, ~0, NULL, false); + + if (RF_RD(s, MCR0, SWRESET)) { + RF_WR(s, MCR0, SWRESET, 0); + } + break; + } + case A_FLEXSPI_INTR: + { + /* fake SPI transfer completion */ + RF_WR(s, INTR, IPCMDDONE, 1); + break; + } + default: + register_write(&ri, value, ~0, NULL, false); + break; + } + + return MEMTX_OK; +} + +static const MemoryRegionOps flexspi_ops =3D { + .read_with_attrs =3D flexspi_read, + .write_with_attrs =3D flexspi_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + .unaligned =3D false, + }, +}; + +static Property flexspi_properties[] =3D { + DEFINE_PROP_UINT64("mmap_size", FlexSpiState, mmap_size, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static void flexspi_init(Object *obj) +{ + FlexSpiState *s =3D FLEXSPI(obj); + + memory_region_init_io(&s->mmio, obj, &flexspi_ops, s, TYPE_FLEXSPI, + sizeof(s->regs)); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); +} + +static void flexspi_realize(DeviceState *dev, Error **errp) +{ + FlexSpiState *s =3D FLEXSPI(dev); + + if (s->mmap_size) { + memory_region_init_ram(&s->mem, OBJECT(s), DEVICE(s)->id, s->mmap_= size, + NULL); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mem); + } +} + +static const VMStateDescription vmstate_flexspi =3D { + .name =3D "flexspi", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32_ARRAY(regs, FlexSpiState, FLEXSPI_REGS_NO), + VMSTATE_END_OF_LIST() + } +}; + +static void flexspi_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + rc->phases.enter =3D flexspi_reset_enter; + dc->realize =3D flexspi_realize; + dc->vmsd =3D &vmstate_flexspi; + device_class_set_props(dc, flexspi_properties); +} + +static const TypeInfo flexspi_types[] =3D { + { + .name =3D TYPE_FLEXSPI, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(FlexSpiState), + .instance_init =3D flexspi_init, + .class_init =3D flexspi_class_init, + }, +}; + +DEFINE_TYPES(flexspi_types); diff --git a/hw/arm/svd/meson.build b/hw/arm/svd/meson.build index d017010b73..7e59eda0d3 100644 --- a/hw/arm/svd/meson.build +++ b/hw/arm/svd/meson.build @@ -19,4 +19,7 @@ if get_option('mcux-soc-svd') run_target('svd-rt500-clkctl1', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/rt500_clkctl1.h= ', '-p', 'CLKCTL1', '-t', 'RT500_CLKCTL1']) + run_target('svd-flexspi', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexspi.h', + '-p', 'FLEXSPI0', '-t', 'FLEXSPI']) endif diff --git a/hw/ssi/Kconfig b/hw/ssi/Kconfig index 8d180de7cf..e3de40e6b6 100644 --- a/hw/ssi/Kconfig +++ b/hw/ssi/Kconfig @@ -28,3 +28,7 @@ config BCM2835_SPI config PNV_SPI bool select SSI + +config FLEXSPI + bool + select SSI diff --git a/hw/ssi/meson.build b/hw/ssi/meson.build index 4039e6d18d..1822c5e6c7 100644 --- a/hw/ssi/meson.build +++ b/hw/ssi/meson.build @@ -14,3 +14,4 @@ system_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_s= pi_host.c')) system_ss.add(when: 'CONFIG_BCM2835_SPI', if_true: files('bcm2835_spi.c')) system_ss.add(when: 'CONFIG_PNV_SPI', if_true: files('pnv_spi.c')) system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_spi.c')) +system_ss.add(when: 'CONFIG_FLEXSPI', if_true: files('flexspi.c')) diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events index f849f1f8be..dd2f04cb22 100644 --- a/hw/ssi/trace-events +++ b/hw/ssi/trace-events @@ -58,3 +58,7 @@ pnv_spi_RDR_match(const char* result) "%s" flexcomm_spi_reg_read(const char *id, const char *reg_name, uint32_t addr,= uint32_t val) " %s: %s[0x%04x] -> 0x%08x" flexcomm_spi_reg_write(const char *id, const char *reg_name, uint32_t addr= , uint32_t val) "%s: %s[0x%04x] <- 0x%08x" flexcomm_spi_irq(const char *id, bool irq, bool fifoirqs, bool perirqs, bo= ol enabled) "%s: %d %d %d %d" + +# flexspi.c +flexspi_reg_read(const char *id, const char *reg_name, uint32_t addr, uint= 32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexspi_reg_write(const char *id, const char *reg_name, uint32_t addr, uin= t32_t val) "%s: %s[0x%04x] <- 0x%08x" --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687575; cv=none; d=zohomail.com; s=zohoarc; b=PEvH33J2H9UBVozhKGkvi2U9ps3yPCP0lQRccdClXIhfN6UhyigbUv95aHJ8iTCPD0oC9x5hQyFYFTMV5DKN1y21n2dd57uVltrJvqHlgZI8+zxmfgYvd23Shh5J81+vLg01Uol198MFN0Y0Rg/RcAzgAD4BcuLFIIh7ShyI06w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687575; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gcELb4vmI6i6TROsDuXTGW+UuF2bxMwin+dPiYf+hTU=; b=jQurNBTl2ou7hlwUOFv6MYByR76YFvKNIE1y1qsxpV/MbicdhWCAIYNlyOmSmLsq3JO4qd7AKGHGvvkYl/9Hc3iVkF0XBkaj3e1JWUndTv1OZ9hlolYUPu7bpJGHT5ml/P1Xocw8TmhEci6s9Rj2MGTxxOZndPgRZj2ts61pkzE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687575960343.65641693426585; Wed, 18 Sep 2024 12:26:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gw-0005QM-NW; Wed, 18 Sep 2024 15:23:30 -0400 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 <3pijrZgUKCuEWDYLSJRRJOH.FRPTHPX-GHYHOQRQJQX.RUJ@flex--tavip.bounces.google.com>) id 1sr0Gu-0005Fu-DC for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:28 -0400 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3pijrZgUKCuEWDYLSJRRJOH.FRPTHPX-GHYHOQRQJQX.RUJ@flex--tavip.bounces.google.com>) id 1sr0Go-0007M9-8I for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:28 -0400 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-207302f244aso1376845ad.0 for ; Wed, 18 Sep 2024 12:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687400; x=1727292200; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=gcELb4vmI6i6TROsDuXTGW+UuF2bxMwin+dPiYf+hTU=; b=GGfUrYOymvc32288psoRP6UH9MuBUUGEKngv0rIFdF7d1MdgxFAP/0lJPaC0aqa6Gk W4ZFKrrtuZQ9JWJmuXJ+TXQGt2+zRFSrpvvj08dD9eBxcdcWgZwVymNMZnGfwod1/iF7 i/bt3j1yi5EuwDR5kKfFlDbN1s8iY5ROdu2dVuOqeWAjBm7s5+dOIc66H/DLckWTxFcx fZ2zRjlP0LMJc2SjwdCcy8/pO+Q+LF392c1tzE5weCsSQCQ0xGFieX7GM76TF6lGkmni DnxC+TxyUcM1nbgh0rIjhozumLnZM05WSgNKLdzGfyMoinTzR5jdf41Sdd8L2v86NHs8 eUgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687400; x=1727292200; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gcELb4vmI6i6TROsDuXTGW+UuF2bxMwin+dPiYf+hTU=; b=QF3GtlX0dlAVIcK2/4zSCjJhLjLkhpws9X5dPm2pVl6Qg9SjRvhWFw1aMGqfXq74ds mrJcwBYodmElISdQ/F1DcDfW79Zudlohtokp9dNFSL7ri9v+hXSewGDfXJpPaF9DzniS 3SPYhciVO6TFlq3rZhWthL7ovv2/flZ1xm5JMF1Kx9LUjePpPsUXH+K7WSeWBvLVGMuL pokv+9CYSAqtMHlmpkWX5KeB9ARAUKHWs34kibeVHpD8nUMYitBkAk1HHpDBbD1NRppA 4pxT/g+tpZ8btI5lnkHN9/kt7OAofJA6iTcIyShGol2D4iIrhAtF0UBQqW6E4/1jB1n8 zNxQ== X-Gm-Message-State: AOJu0YwaKTVuat9mBLelbfWghzrPLCPwlQ5gGWTllvJ4aFb+THhfd+te Q8mlOJaY6d2id0YvoERxTKhyV9XOxiRMmuv/+RCrOHbMYaAQOenHx6/p1RCrL/9zlVxVY/v6tTH CIG7ykNV/pREnCnSA2q4y8pTWRU17aqNNs0slNHhAo9Ml+bwux3lunZ5BBH5jT7q40Ffz23mIyF TN7C28Ngj0b/Ytw5XQMBKpHMrqwA== X-Google-Smtp-Source: AGHT+IHmalR8Gyz0ScYaJCOHkElst2+atKBzqG8Bw0uVDpOR473vAhS48VN5MnZnf+i2t+7Er14aWClKkQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:903:186:b0:206:a574:b4f3 with SMTP id d9443c01a7336-2076e31465dmr11110315ad.1.1726687398054; Wed, 18 Sep 2024 12:23:18 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:40 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-13-tavip@google.com> Subject: [PATCH 12/25] hw/misc: add support for RT500's reset controller From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::64a; envelope-from=3pijrZgUKCuEWDYLSJRRJOH.FRPTHPX-GHYHOQRQJQX.RUJ@flex--tavip.bounces.google.com; helo=mail-pl1-x64a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, UPPERCASE_50_75=0.008, USER_IN_DEF_DKIM_WL=-7.5 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687577597116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The RT500 reset controller has two instances that have the same register layout but with different fields for some registers. The model only provides set and clear functionality for the various reset lines which is common for both instances. Because of that only one type is implemented for both controllers. The patch includes automatically generated headers which contains the register layout and helpers. The header can be regenerated with the svd-rstctl0 and svd-rstctl1 targets when the build is configured with --enable-mcux-soc-svd. Signed-off-by: Octavian Purdila --- include/hw/arm/svd/rt500_rstctl0.h | 858 +++++++++++++++++ include/hw/arm/svd/rt500_rstctl1.h | 1371 ++++++++++++++++++++++++++++ include/hw/misc/rt500_rstctl.h | 32 + hw/misc/rt500_rstctl.c | 258 ++++++ hw/arm/svd/meson.build | 6 + hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/trace-events | 4 + 8 files changed, 2533 insertions(+) create mode 100644 include/hw/arm/svd/rt500_rstctl0.h create mode 100644 include/hw/arm/svd/rt500_rstctl1.h create mode 100644 include/hw/misc/rt500_rstctl.h create mode 100644 hw/misc/rt500_rstctl.c diff --git a/include/hw/arm/svd/rt500_rstctl0.h b/include/hw/arm/svd/rt500_= rstctl0.h new file mode 100644 index 0000000000..63d7c986dd --- /dev/null +++ b/include/hw/arm/svd/rt500_rstctl0.h @@ -0,0 +1,858 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#include "hw/register.h" + +/* Reset Controller 0 */ +#define RT500_RSTCTL0_REGS_NO (31) + +/* System Reset Status Register */ +REG32(RT500_RSTCTL0_SYSRSTSTAT, 0); +/* VDD CORE Power-On Reset (POR) was detected */ +FIELD(RT500_RSTCTL0_SYSRSTSTAT, VDD_POR, 0, 1); +/* RESETN pin reset was detected */ +FIELD(RT500_RSTCTL0_SYSRSTSTAT, PAD_RESET, 4, 1); +/* ARM reset was detected */ +FIELD(RT500_RSTCTL0_SYSRSTSTAT, ARM_RESET, 5, 1); +/* WatchDog Timer 0 reset was detected */ +FIELD(RT500_RSTCTL0_SYSRSTSTAT, WDT0_RESET, 6, 1); +/* WatchDog Timer 1 reset was detected */ +FIELD(RT500_RSTCTL0_SYSRSTSTAT, WDT1_RESET, 7, 1); + +/* Peripheral Reset Control Register 0 */ +REG32(RT500_RSTCTL0_PRSTCTL0, 16); +/* Fusion F1 DSP reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, DSP, 1, 1); +/* AXI Switch reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, AXI_SWITCH, 3, 1); +/* POWERQUAD reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, POWERQUAD, 8, 1); +/* CASPER reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, CASPER, 9, 1); +/* Hash-Crypt reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, HASHCRYPT, 10, 1); +/* PUF reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, PUF, 11, 1); +/* RNG reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, RNG, 12, 1); +/* FLEXSPI0 and OTFAD reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, FLEXSPI0_OTFAD, 16, 1); +/* FLEXSPI1 reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, FLEXSPI1, 18, 1); +/* USB PHY reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, USBHS_PHY, 20, 1); +/* USB HS Device reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, USBHS_DEVICE, 21, 1); +/* USB HOST reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, USBHS_HOST, 22, 1); +/* USB RAM reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, USBHS_SRAM, 23, 1); +/* SCTimer reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, SCT, 24, 1); +/* GPU reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, GPU, 26, 1); +/* LCDIF Display Controller reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, DISPLAY_CONTROLLER, 27, 1); +/* MIPI Digital serial Interface controller reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, MIPI_DSI_CONTROLLER, 28, 1); +/* MIPI DSI PHY reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, MIPI_DSI_PHY, 29, 1); +/* SMARTDMA Event/Algorithm handler reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL0, SMARTDMA, 30, 1); + +/* Peripheral Reset Control Register 1 */ +REG32(RT500_RSTCTL0_PRSTCTL1, 20); +/* SDIO0 reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL1, SDIO0, 2, 1); +/* SDIO1 reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL1, SDIO1, 3, 1); +/* Analog comparator reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL1, ACMP0, 15, 1); +/* Analog-to-Digital converter reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL1, ADC0, 16, 1); +/* Secure GPIO 0 reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL1, SHSGPIO0, 24, 1); + +/* Peripheral Reset Control Register 2 */ +REG32(RT500_RSTCTL0_PRSTCTL2, 24); +/* Micro-tick timer reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL2, UTICK0, 0, 1); +/* Watchdog timer reset control */ +FIELD(RT500_RSTCTL0_PRSTCTL2, WWDT0, 1, 1); + +/* Peripheral Reset Control Register 0 SET */ +REG32(RT500_RSTCTL0_PRSTCTL0_SET, 64); +/* Fusion_ DSP reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, DSP, 1, 1); +/* AXI SWITCH reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, AXI_SWITCH, 3, 1); +/* POWERQUAD reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, POWERQUAD, 8, 1); +/* CASPER reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, CASPER, 9, 1); +/* HASHCRYPT reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, HASHCRYPT, 10, 1); +/* PUF reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, PUF, 11, 1); +/* RNG reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, RNG, 12, 1); +/* FLEXSPI0 and OTFAD reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, FLEXSPI0_OTFAD, 16, 1); +/* FLEXSPI1 reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, FLEXSPI1, 18, 1); +/* USB PHY reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, USBHS_PHY, 20, 1); +/* USB Device reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, USBHS_DEVICE, 21, 1); +/* USB HOST reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, USBHS_HOST, 22, 1); +/* USBHS SRAM reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, USBHS_SRAM, 23, 1); +/* SCTimer reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, SCT, 24, 1); +/* GPU reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, GPU, 26, 1); +/* LCDIF DISPLAY CONTROLLER reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, DISPLAY_CONTROLLER, 27, 1); +/* MIPI DSI controller reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, MIPI_DSI_CONTROLLER, 28, 1); +/* MIPI DSI PHY reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, MIPI_DSI_PHY, 29, 1); +/* SMARTDMA Event/Algorithm handler reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL0_SET, SMARTDMA, 30, 1); + +/* Peripheral Reset Control Register 1 SET */ +REG32(RT500_RSTCTL0_PRSTCTL1_SET, 68); +/* SDIO0 reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL1_SET, SDIO0, 2, 1); +/* SDIO1 reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL1_SET, SDIO1, 3, 1); +/* ACMP0 reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL1_SET, ACMP0, 15, 1); +/* ADC0 reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL1_SET, ADC0, 16, 1); +/* SHSGPIO0 reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL1_SET, SHSGPIO0, 24, 1); + +/* Peripheral Reset Control Register 2 SET */ +REG32(RT500_RSTCTL0_PRSTCTL2_SET, 72); +/* Micro-tick timer 0 reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL2_SET, UTICK0, 0, 1); +/* WWDT0 reset set */ +FIELD(RT500_RSTCTL0_PRSTCTL2_SET, WWDT0, 1, 1); + +/* Peripheral Reset Control Register 0 CLR */ +REG32(RT500_RSTCTL0_PRSTCTL0_CLR, 112); +/* Fusion_ F1 DSP reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, DSP, 1, 1); +/* AXI SWITCH reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, AXI_SWITCH, 3, 1); +/* POWERQUAD reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, POWERQUAD, 8, 1); +/* CASPER reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, CASPER, 9, 1); +/* HASHCRYPT reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, HASHCRYPT, 10, 1); +/* PUF reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, PUF, 11, 1); +/* RNG reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, RNG, 12, 1); +/* FLEXSPI0 and OTFAD reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, FLEXSPI0_OTFAD, 16, 1); +/* FLEXSPI1 reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, FLEXSPI1, 18, 1); +/* USB PHY reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, USBHS_PHY, 20, 1); +/* USB DEVICE reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, USBHS_DEVICE, 21, 1); +/* USB HOST reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, USBHS_HOST, 22, 1); +/* USBHS SRAM reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, USBHS_SRAM, 23, 1); +/* SCT reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, SCT, 24, 1); +/* GPU reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, GPU, 26, 1); +/* LCDIF DISPLAY CONTROLLER reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, DISPLAY_CONTROLLER, 27, 1); +/* MIPI DSI controller reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, MIPI_DSI_CONTROLLER, 28, 1); +/* MIPI DSI PHY reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, MIPI_DSI_PHY, 29, 1); +/* SMARTDMA Event/Algorithm handler reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL0_CLR, SMARTDMA, 30, 1); + +/* Peripheral Reset Control Register 1 CLR */ +REG32(RT500_RSTCTL0_PRSTCTL1_CLR, 116); +/* SDIO0 reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL1_CLR, SDIO0, 2, 1); +/* SDIO1 reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL1_CLR, SDIO1, 3, 1); +/* ACMP0 reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL1_CLR, ACMP0, 15, 1); +/* ADC0 reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL1_CLR, ADC0, 16, 1); +/* Secure HSGPIO0 reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL1_CLR, SHSGPIO0, 24, 1); + +/* Peripheral Reset Control Register 2 CLR */ +REG32(RT500_RSTCTL0_PRSTCTL2_CLR, 120); +/* Micro-tick timer 0 reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL2_CLR, UTICK0, 0, 1); +/* WWDT0 reset clear */ +FIELD(RT500_RSTCTL0_PRSTCTL2_CLR, WWDT0, 1, 1); + + +typedef enum { + /* No VDD CORE POR event is detected */ + RT500_RSTCTL0_SYSRSTSTAT_VDD_POR_VDD_POR_EVENT_IS_NOT_DETECTED =3D 0, + /* VDD CORE POR event was detected */ + RT500_RSTCTL0_SYSRSTSTAT_VDD_POR_VDD_POR_EVENT_WAS_DETECTED =3D 1, +} RT500_RSTCTL0_SYSRSTSTAT_VDD_POR_Enum; + +typedef enum { + /* No RESETN pin event is detected */ + RT500_RSTCTL0_SYSRSTSTAT_PAD_RESET_PAD_RESET_IS_NOT_DETECTED =3D 0, + /* RESETN pin event was detected. Write '1' to clear this bit */ + RT500_RSTCTL0_SYSRSTSTAT_PAD_RESET_PAD_RESET_WAS_DETECTED =3D 1, +} RT500_RSTCTL0_SYSRSTSTAT_PAD_RESET_Enum; + +typedef enum { + /* No ARM reset event is detected */ + RT500_RSTCTL0_SYSRSTSTAT_ARM_RESET_ARM_RESET_IS_NOT_DETECTED =3D 0, + /* ARM reset was detected. Write '1' to clear this bit */ + RT500_RSTCTL0_SYSRSTSTAT_ARM_RESET_ARM_RESET_WAS_DETECTED =3D 1, +} RT500_RSTCTL0_SYSRSTSTAT_ARM_RESET_Enum; + +typedef enum { + /* No WDT0 reset event detected */ + RT500_RSTCTL0_SYSRSTSTAT_WDT0_RESET_WDT0_RESET_IS_NOT_DETECTED =3D 0, + /* WDT0 reset event detected. Write '1' to clear this bit */ + RT500_RSTCTL0_SYSRSTSTAT_WDT0_RESET_WDT0_RESET_WAS_DETECTED =3D 1, +} RT500_RSTCTL0_SYSRSTSTAT_WDT0_RESET_Enum; + +typedef enum { + /* No WDT1 reset event detected */ + RT500_RSTCTL0_SYSRSTSTAT_WDT1_RESET_WDT1_RESET_IS_NOT_DETECTED =3D 0, + /* WDT1 reset event detected. Write '1' to clear this bit */ + RT500_RSTCTL0_SYSRSTSTAT_WDT1_RESET_WDT1_RESET_WAS_DETECTED =3D 1, +} RT500_RSTCTL0_SYSRSTSTAT_WDT1_RESET_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_DSP_DSP_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_DSP_DSP_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_DSP_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_AXI_SWITCH_AXI_SWITCH_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_AXI_SWITCH_AXI_SWITCH_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_AXI_SWITCH_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_POWERQUAD_POWERQUAD_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_POWERQUAD_POWERQUAD_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_POWERQUAD_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_CASPER_CASPER_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_CASPER_CASPER_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CASPER_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_HASHCRYPT_HASHCRYPT_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_HASHCRYPT_HASHCRYPT_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_HASHCRYPT_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_PUF_PUF_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_PUF_PUF_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_PUF_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_RNG_RNG_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_RNG_RNG_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_RNG_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_FLEXSPI0_OTFAD_FLEXSPI0_OTFAD_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_FLEXSPI0_OTFAD_FLEXSPI0_OTFAD_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_FLEXSPI0_OTFAD_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_FLEXSPI1_FLEXSPI1_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_FLEXSPI1_FLEXSPI1_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_FLEXSPI1_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_USBHS_PHY_USBHS_PHY_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_USBHS_PHY_USBHS_PHY_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_USBHS_PHY_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_USBHS_DEVICE_USBHS_DEVICE_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_USBHS_DEVICE_USBHS_DEVICE_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_USBHS_DEVICE_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_USBHS_HOST_USBHS_HOST_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_USBHS_HOST_USBHS_HOST_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_USBHS_HOST_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_USBHS_SRAM_USBHS_SRAM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_USBHS_SRAM_USBHS_SRAM_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_USBHS_SRAM_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_SCT_SCT_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_SCT_SCT_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SCT_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_GPU_GPU_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_GPU_GPU_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_GPU_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_DISPLAY_CONTROLLER_DISPLAY_CONTROLLER_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_DISPLAY_CONTROLLER_DISPLAY_CONTROLLER_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_DISPLAY_CONTROLLER_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_MIPI_DSI_CONTROLLER_MIPI_DSI_CONTROLLER_CLR =3D= 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_MIPI_DSI_CONTROLLER_MIPI_DSI_CONTROLLER_SET =3D= 1, +} RT500_RSTCTL0_PRSTCTL0_MIPI_DSI_CONTROLLER_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_MIPI_DSI_PHY_MIPI_DSI_PHY_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_MIPI_DSI_PHY_MIPI_DSI_PHY_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_MIPI_DSI_PHY_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL0_SMARTDMA_SMARTDMA_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL0_SMARTDMA_SMARTDMA_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SMARTDMA_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL1_SDIO0_SDIO0_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL1_SDIO0_SDIO0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_SDIO0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL1_SDIO1_SDIO1_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL1_SDIO1_SDIO1_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_SDIO1_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL1_ACMP0_ACMP0_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL1_ACMP0_ACMP0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_ACMP0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL1_ADC0_ADC0_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL1_ADC0_ADC0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_ADC0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL1_SHSGPIO0_SHSGPIO0_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL1_SHSGPIO0_SHSGPIO0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_SHSGPIO0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL2_UTICK0_UTICK0_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL2_UTICK0_UTICK0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL2_UTICK0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL0_PRSTCTL2_WWDT0_WWDT0_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL0_PRSTCTL2_WWDT0_WWDT0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL2_WWDT0_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_DSP_DSP_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_DSP_DSP_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_DSP_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_AXI_SWITCH_AXI_SWITCH_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_AXI_SWITCH_AXI_SWITCH_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_AXI_SWITCH_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_POWERQUAD_POWERQUAD_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_POWERQUAD_POWERQUAD_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_POWERQUAD_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_CASPER_CASPER_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_CASPER_CASPER_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_CASPER_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_HASHCRYPT_HASHCRYPT_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_HASHCRYPT_HASHCRYPT_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_HASHCRYPT_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_PUF_PUF_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_PUF_PUF_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_PUF_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_RNG_RNG_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_RNG_RNG_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_RNG_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_FLEXSPI0_OTFAD_FLEXSPI0_OTFAD_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_FLEXSPI0_OTFAD_FLEXSPI0_OTFAD_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_FLEXSPI0_OTFAD_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_FLEXSPI1_FLEXSPI1_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_FLEXSPI1_FLEXSPI1_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_FLEXSPI1_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_USBHS_PHY_USBHS_PHY_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_USBHS_PHY_USBHS_PHY_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_USBHS_PHY_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_USBHS_DEVICE_USBHS_DEVICE_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_USBHS_DEVICE_USBHS_DEVICE_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_USBHS_DEVICE_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_USBHS_HOST_USBHS_HOST_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_USBHS_HOST_USBHS_HOST_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_USBHS_HOST_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_USBHS_SRAM_USBHS_SRAM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_USBHS_SRAM_USBHS_SRAM_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_USBHS_SRAM_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_SCT_SCT_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_SCT_SCT_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_SCT_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_GPU_GPU_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_GPU_GPU_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_GPU_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_DISPLAY_CONTROLLER_DISPLAY_CONTROLLER_CLR = =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_DISPLAY_CONTROLLER_DISPLAY_CONTROLLER_SET = =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_DISPLAY_CONTROLLER_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_MIPI_DSI_CONTROLLER_MIPI_DSI_CONTROLLER_CLR= =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_MIPI_DSI_CONTROLLER_MIPI_DSI_CONTROLLER_SET= =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_MIPI_DSI_CONTROLLER_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_MIPI_DSI_PHY_MIPI_DSI_PHY_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_MIPI_DSI_PHY_MIPI_DSI_PHY_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_MIPI_DSI_PHY_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL0_PRSTCTL0_SET_SMARTDMA_SMARTDMA_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_SET_SMARTDMA_SMARTDMA_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_SET_SMARTDMA_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_SET_SDIO0_SDIO0_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_SET_SDIO0_SDIO0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_SET_SDIO0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_SET_SDIO1_SDIO1_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_SET_SDIO1_SDIO1_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_SET_SDIO1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_SET_ACMP0_ACMP0_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_SET_ACMP0_ACMP0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_SET_ACMP0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_SET_ADC0_ADC0_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_SET_ADC0_ADC0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_SET_ADC0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_SET_SHSGPIO0_SHSGPIO0_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_SET_SHSGPIO0_SHSGPIO0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_SET_SHSGPIO0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL2_SET_UTICK0_UTICK0_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL0_PRSTCTL2_SET_UTICK0_UTICK0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL2_SET_UTICK0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL2_SET_WWDT0_WWDT0_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL0_PRSTCTL2_SET_WWDT0_WWDT0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL2_SET_WWDT0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_DSP_DSP_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_DSP_DSP_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_DSP_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_AXI_SWITCH_AXI_SWITCH_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_AXI_SWITCH_AXI_SWITCH_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_AXI_SWITCH_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_POWERQUAD_POWERQUAD_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_POWERQUAD_POWERQUAD_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_POWERQUAD_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_CASPER_CASPER_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_CASPER_CASPER_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_CASPER_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_HASHCRYPT_HASHCRYPT_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_HASHCRYPT_HASHCRYPT_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_HASHCRYPT_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_PUF_PUF_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_PUF_PUF_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_PUF_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_RNG_RNG_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_RNG_RNG_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_RNG_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_FLEXSPI0_OTFAD_FLEXSPI0_OTFAD_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_FLEXSPI0_OTFAD_FLEXSPI0_OTFAD_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_FLEXSPI0_OTFAD_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_FLEXSPI1_FLEXSPI1_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_FLEXSPI1_FLEXSPI1_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_FLEXSPI1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_PHY_USBHS_PHY_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_PHY_USBHS_PHY_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_PHY_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_DEVICE_USBHS_DEVICE_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_DEVICE_USBHS_DEVICE_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_DEVICE_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_HOST_USBHS_HOST_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_HOST_USBHS_HOST_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_HOST_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_SRAM_USBHS_SRAM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_SRAM_USBHS_SRAM_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_USBHS_SRAM_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_SCT_SCT_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_SCT_SCT_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_SCT_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_GPU_GPU_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_GPU_GPU_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_GPU_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_DISPLAY_CONTROLLER_DISPLAY_CONTROLLER_CLR = =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_DISPLAY_CONTROLLER_DISPLAY_CONTROLLER_SET = =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_DISPLAY_CONTROLLER_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_MIPI_DSI_CONTROLLER_MIPI_DSI_CONTROLLER_CLR= =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_MIPI_DSI_CONTROLLER_MIPI_DSI_CONTROLLER_SET= =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_MIPI_DSI_CONTROLLER_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_MIPI_DSI_PHY_MIPI_DSI_PHY_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_MIPI_DSI_PHY_MIPI_DSI_PHY_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_MIPI_DSI_PHY_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL0_CLR_SMARTDMA_SMARTDMA_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL0_PRSTCTL0_CLR_SMARTDMA_SMARTDMA_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL0_CLR_SMARTDMA_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_CLR_SDIO0_SDIO0_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_CLR_SDIO0_SDIO0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_CLR_SDIO0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_CLR_SDIO1_SDIO1_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_CLR_SDIO1_SDIO1_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_CLR_SDIO1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_CLR_ACMP0_ACMP0_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_CLR_ACMP0_ACMP0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_CLR_ACMP0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_CLR_ADC0_ADC0_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_CLR_ADC0_ADC0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_CLR_ADC0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL1_CLR_SHSGPIO0_SHSGPIO0_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL0_PRSTCTL1_CLR_SHSGPIO0_SHSGPIO0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL1_CLR_SHSGPIO0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL2_CLR_UTICK0_UTICK0_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL0_PRSTCTL2_CLR_UTICK0_UTICK0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL2_CLR_UTICK0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL0_PRSTCTL2_CLR_WWDT0_WWDT0_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL0_PRSTCTL2_CLR_WWDT0_WWDT0_SET =3D 1, +} RT500_RSTCTL0_PRSTCTL2_CLR_WWDT0_Enum; + + +#define RT500_RSTCTL0_REGISTER_ACCESS_INFO_ARRAY(_name) \ + struct RegisterAccessInfo _name[RT500_RSTCTL0_REGS_NO] =3D { \ + [0 ... RT500_RSTCTL0_REGS_NO - 1] =3D { \ + .name =3D "", \ + .addr =3D -1, \ + }, \ + [R_RT500_RSTCTL0_SYSRSTSTAT] =3D { \ + .name =3D "SYSRSTSTAT", \ + .addr =3D 0x0, \ + .ro =3D 0xFFFFFF0E, \ + .reset =3D 0x1, \ + }, \ + [R_RT500_RSTCTL0_PRSTCTL0] =3D { \ + .name =3D "PRSTCTL0", \ + .addr =3D 0x10, \ + .ro =3D 0x820AE0F5, \ + .reset =3D 0x7DF51F0A, \ + }, \ + [R_RT500_RSTCTL0_PRSTCTL1] =3D { \ + .name =3D "PRSTCTL1", \ + .addr =3D 0x14, \ + .ro =3D 0xFEFE7FF3, \ + .reset =3D 0x101800C, \ + }, \ + [R_RT500_RSTCTL0_PRSTCTL2] =3D { \ + .name =3D "PRSTCTL2", \ + .addr =3D 0x18, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x1C000001, \ + }, \ + [R_RT500_RSTCTL0_PRSTCTL0_SET] =3D { \ + .name =3D "PRSTCTL0_SET", \ + .addr =3D 0x40, \ + .ro =3D 0x820AE0F5, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL0_PRSTCTL1_SET] =3D { \ + .name =3D "PRSTCTL1_SET", \ + .addr =3D 0x44, \ + .ro =3D 0xFEFE7FF3, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL0_PRSTCTL2_SET] =3D { \ + .name =3D "PRSTCTL2_SET", \ + .addr =3D 0x48, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL0_PRSTCTL0_CLR] =3D { \ + .name =3D "PRSTCTL0_CLR", \ + .addr =3D 0x70, \ + .ro =3D 0x820AE0F5, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL0_PRSTCTL1_CLR] =3D { \ + .name =3D "PRSTCTL1_CLR", \ + .addr =3D 0x74, \ + .ro =3D 0xFEFE7FF3, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL0_PRSTCTL2_CLR] =3D { \ + .name =3D "PRSTCTL2_CLR", \ + .addr =3D 0x78, \ + .ro =3D 0xFFFFFFFC, \ + .reset =3D 0x0, \ + }, \ + } diff --git a/include/hw/arm/svd/rt500_rstctl1.h b/include/hw/arm/svd/rt500_= rstctl1.h new file mode 100644 index 0000000000..6b331c653f --- /dev/null +++ b/include/hw/arm/svd/rt500_rstctl1.h @@ -0,0 +1,1371 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#include "hw/register.h" + +/* Reset Controller 1 */ +#define RT500_RSTCTL1_REGS_NO (31) + +/* System Reset Status Register */ +REG32(RT500_RSTCTL1_SYSRSTSTAT, 0); +/* VDD Power-On Reset (POR) was detected */ +FIELD(RT500_RSTCTL1_SYSRSTSTAT, VDD_POR, 0, 1); +/* RESETN pin reset was detected */ +FIELD(RT500_RSTCTL1_SYSRSTSTAT, PAD_RESET, 4, 1); +/* ARM reset was detected */ +FIELD(RT500_RSTCTL1_SYSRSTSTAT, ARM_RESET, 5, 1); +/* WDT0 reset was detected */ +FIELD(RT500_RSTCTL1_SYSRSTSTAT, WDT0_RESET, 6, 1); +/* WDT1 reset was detected */ +FIELD(RT500_RSTCTL1_SYSRSTSTAT, WDT1_RESET, 7, 1); + +/* Peripheral Reset Control Register 0 */ +REG32(RT500_RSTCTL1_PRSTCTL0, 16); +/* Flexcomm0 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM0, 8, 1); +/* Flexcomm1 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM1, 9, 1); +/* Flexcomm2 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM2, 10, 1); +/* Flexcomm3 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM3, 11, 1); +/* Flexcomm4 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM4, 12, 1); +/* Flexcomm5 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM5, 13, 1); +/* Flexcomm6 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM6, 14, 1); +/* Flexcomm7 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM7, 15, 1); +/* Flexcomm8 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM8, 16, 1); +/* Flexcomm9 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM9, 17, 1); +/* Flexcomm10 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM10, 18, 1); +/* Flexcomm11 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM11, 19, 1); +/* Flexcomm12 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM12, 20, 1); +/* Flexcomm13 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM13, 21, 1); +/* Flexcomm14 SPI0 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM14, 22, 1); +/* Flexcomm15 I2C reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM15_I2C, 23, 1); +/* DMIC0 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, DMIC0, 24, 1); +/* Flexcomm SPI reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXCOMM16, 25, 1); +/* OSEVENT Timer reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, OSEVENT_TIMER, 27, 1); +/* FLEXIO reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL0, FLEXIO, 29, 1); + +/* Peripheral Reset Control Register 1 */ +REG32(RT500_RSTCTL1_PRSTCTL1, 20); +/* HSGPIO[7:0] reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, HSGPIO0, 0, 1); +/* HSGPIO[7:0] reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, HSGPIO1, 1, 1); +/* HSGPIO[7:0] reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, HSGPIO2, 2, 1); +/* HSGPIO[7:0] reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, HSGPIO3, 3, 1); +/* HSGPIO[7:0] reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, HSGPIO4, 4, 1); +/* HSGPIO[7:0] reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, HSGPIO5, 5, 1); +/* HSGPIO[7:0] reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, HSGPIO6, 6, 1); +/* HSGPIO[7:0] reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, HSGPIO7, 7, 1); +/* CRC reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, CRC, 16, 1); +/* DMAC reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, DMAC0, 23, 1); +/* DMAC reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, DMAC1, 24, 1); +/* MU reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, MU, 28, 1); +/* SEMA reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, SEMA, 29, 1); +/* FREQME reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL1, FREQME, 31, 1); + +/* Peripheral Reset Control Register 2 */ +REG32(RT500_RSTCTL1_PRSTCTL2, 24); +/* CT32BIT[4:0] reset */ +FIELD(RT500_RSTCTL1_PRSTCTL2, CT32BIT0, 0, 1); +/* CT32BIT[4:0] reset */ +FIELD(RT500_RSTCTL1_PRSTCTL2, CT32BIT1, 1, 1); +/* CT32BIT[4:0] reset */ +FIELD(RT500_RSTCTL1_PRSTCTL2, CT32BIT2, 2, 1); +/* CT32BIT[4:0] reset */ +FIELD(RT500_RSTCTL1_PRSTCTL2, CT32BIT3, 3, 1); +/* CT32BIT[4:0] reset */ +FIELD(RT500_RSTCTL1_PRSTCTL2, CT32BIT4, 4, 1); +/* MRT0 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL2, MRT0, 8, 1); +/* WWDT1 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL2, WWDT1, 10, 1); +/* I3C0 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL2, I3C0, 16, 1); +/* I3C1 reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL2, I3C1, 17, 1); +/* GPIOINTCTL reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL2, GPIOINTCTL, 30, 1); +/* INPUTMUX reset control */ +FIELD(RT500_RSTCTL1_PRSTCTL2, PIMCTL, 31, 1); + +/* Peripheral Reset Control Register 0 SET */ +REG32(RT500_RSTCTL1_PRSTCTL0_SET, 64); +/* Flexcomm0 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM0, 8, 1); +/* Flexcomm1 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM1, 9, 1); +/* Flexcomm2 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM2, 10, 1); +/* Flexcomm3 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM3, 11, 1); +/* Flexcomm4 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM4, 12, 1); +/* Flexcomm5 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM5, 13, 1); +/* Flexcomm6 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM6, 14, 1); +/* Flexcomm7 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM7, 15, 1); +/* Flexcomm8 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM8, 16, 1); +/* Flexcomm9 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM9, 17, 1); +/* Flexcomm10 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM10, 18, 1); +/* Flexcomm11 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM11, 19, 1); +/* Flexcomm12 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM12, 20, 1); +/* Flexcomm13 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM13, 21, 1); +/* Flexcomm14 SPI0 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM14, 22, 1); +/* Flexcomm15 I2C reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM15_I2C, 23, 1); +/* DMIC0 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, DMIC0, 24, 1); +/* Flexcomm16 SPI1 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXCOMM16, 25, 1); +/* OSEVENT Timer reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, OSEVENT_TIMER, 27, 1); +/* FEXIO reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL0_SET, FLEXIO, 29, 1); + +/* Peripheral Reset Control Register 1 SET */ +REG32(RT500_RSTCTL1_PRSTCTL1_SET, 68); +/* HSGPIO0 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, HSGPIO0, 0, 1); +/* HSGPIO1 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, HSGPIO1, 1, 1); +/* HSGPIO2 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, HSGPIO2, 2, 1); +/* HSGPIO3 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, HSGPIO3, 3, 1); +/* HSGPIO4 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, HSGPIO4, 4, 1); +/* HSGPIO5 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, HSGPIO5, 5, 1); +/* HSGPIO6 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, HSGPIO6, 6, 1); +/* HSGPIO7 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, HSGPIO7, 7, 1); +/* CRC reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, CRC, 16, 1); +/* DMAC0 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, DMAC0, 23, 1); +/* DMAC1 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, DMAC1, 24, 1); +/* MU reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, MU, 28, 1); +/* SEMA reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, SEMA, 29, 1); +/* FREQME reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL1_SET, FREQME, 31, 1); + +/* Peripheral Reset Control Register 2 SET */ +REG32(RT500_RSTCTL1_PRSTCTL2_SET, 72); +/* CT32BIT0 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, CT32BIT0, 0, 1); +/* CT32BIT1 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, CT32BIT1, 1, 1); +/* CT32BIT2 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, CT32BIT2, 2, 1); +/* CT32BIT3 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, CT32BIT3, 3, 1); +/* CT32BIT4 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, CT32BIT4, 4, 1); +/* MRT0 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, MRT0, 8, 1); +/* WWDT1 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, WWDT1, 10, 1); +/* I3C0 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, I3C0, 16, 1); +/* I3C1 reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, I3C1, 17, 1); +/* GPIOINTCTL reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, GPIOINTCTL, 30, 1); +/* PIMCTL reset set */ +FIELD(RT500_RSTCTL1_PRSTCTL2_SET, PIMCTL, 31, 1); + +/* Peripheral Reset Control Register 0 CLR */ +REG32(RT500_RSTCTL1_PRSTCTL0_CLR, 112); +/* Flexcomm0 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM0, 8, 1); +/* Flexcomm1 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM1, 9, 1); +/* Flexcomm2 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM2, 10, 1); +/* Flexcomm3 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM3, 11, 1); +/* Flexcomm4 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM4, 12, 1); +/* Flexcomm5 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM5, 13, 1); +/* Flexcomm6 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM6, 14, 1); +/* Flexcomm7 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM7, 15, 1); +/* Flexcomm8 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM8, 16, 1); +/* Flexcomm9 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM9, 17, 1); +/* Flexcomm10 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM10, 18, 1); +/* Flexcomm11 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM11, 19, 1); +/* Flexcomm12 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM12, 20, 1); +/* Flexcomm13 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM13, 21, 1); +/* FLexcomm SPI0 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM14, 22, 1); +/* Flexcomm I2C reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM15_I2C, 23, 1); +/* DMIC0 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, DMIC0, 24, 1); +/* Flexcomm SPI1 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXCOMM16, 25, 1); +/* OSEVENT Timer reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, OSEVENT_TIMER, 27, 1); +/* FLEXIO reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL0_CLR, FLEXIO, 29, 1); + +/* Peripheral Reset Control Register 1 CLR */ +REG32(RT500_RSTCTL1_PRSTCTL1_CLR, 116); +/* HSGPIO0 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, HSGPIO0, 0, 1); +/* HSGPIO1 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, HSGPIO1, 1, 1); +/* HSGPIO2 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, HSGPIO2, 2, 1); +/* HSGPIO3 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, HSGPIO3, 3, 1); +/* HSGPIO4 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, HSGPIO4, 4, 1); +/* HSGPIO5 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, HSGPIO5, 5, 1); +/* HSGPIO6 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, HSGPIO6, 6, 1); +/* HSGPIO7 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, HSGPIO7, 7, 1); +/* CRC reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, CRC, 16, 1); +/* DMAC0 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, DMAC0, 23, 1); +/* DMAC1 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, DMAC1, 24, 1); +/* MU reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, MU, 28, 1); +/* SMEA reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, SEMA, 29, 1); +/* FREQME reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL1_CLR, FREQME, 31, 1); + +/* Peripheral Reset Control Register 2 CLR */ +REG32(RT500_RSTCTL1_PRSTCTL2_CLR, 120); +/* CT32BIT0 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, CT32BIT0, 0, 1); +/* CT32BIT1 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, CT32BIT1, 1, 1); +/* CT32BIT2 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, CT32BIT2, 2, 1); +/* CT32BIT3 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, CT32BIT3, 3, 1); +/* CT32BIT4 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, CT32BIT4, 4, 1); +/* MRT0 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, MRT0, 8, 1); +/* WWDT1 reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, WWDT1, 10, 1); +/* I3C[1:0] reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, I3C0, 16, 1); +/* I3C[1:0] reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, I3C1, 17, 1); +/* GPIOINTCTL reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, GPIOINTCTL, 30, 1); +/* PIMCTL reset clear */ +FIELD(RT500_RSTCTL1_PRSTCTL2_CLR, PIMCTL, 31, 1); + + +typedef enum { + /* No VDD POR event is detected */ + RT500_RSTCTL1_SYSRSTSTAT_VDD_POR_VDD_POR_EVENT_IS_NOT_DETECTED =3D 0, + /* VDD POR event was detected */ + RT500_RSTCTL1_SYSRSTSTAT_VDD_POR_VDD_POR_EVENT_WAS_DETECTED =3D 1, +} RT500_RSTCTL1_SYSRSTSTAT_VDD_POR_Enum; + +typedef enum { + /* No RESETN pin event is detected */ + RT500_RSTCTL1_SYSRSTSTAT_PAD_RESET_PAD_RESET_IS_NOT_DETECTED =3D 0, + /* RESETN pin reset event was detected */ + RT500_RSTCTL1_SYSRSTSTAT_PAD_RESET_PAD_RESET_WAS_DETECTED =3D 1, +} RT500_RSTCTL1_SYSRSTSTAT_PAD_RESET_Enum; + +typedef enum { + /* No ARM reset event is detected */ + RT500_RSTCTL1_SYSRSTSTAT_ARM_RESET_ARM_RESET_IS_NOT_DETECTED =3D 0, + /* ARM reset was detected */ + RT500_RSTCTL1_SYSRSTSTAT_ARM_RESET_ARM_RESET_WAS_DETECTED =3D 1, +} RT500_RSTCTL1_SYSRSTSTAT_ARM_RESET_Enum; + +typedef enum { + /* No WDT0 reset event is detected */ + RT500_RSTCTL1_SYSRSTSTAT_WDT0_RESET_WDT0_RESET_IS_NOT_DETECTED =3D 0, + /* WDT0 reset was detected */ + RT500_RSTCTL1_SYSRSTSTAT_WDT0_RESET_WDT0_RESET_WAS_DETECTED =3D 1, +} RT500_RSTCTL1_SYSRSTSTAT_WDT0_RESET_Enum; + +typedef enum { + /* No WDT1 reset event is detected */ + RT500_RSTCTL1_SYSRSTSTAT_WDT1_RESET_WDT1_RESET_IS_NOT_DETECTED =3D 0, + /* WDT1 reset was detected */ + RT500_RSTCTL1_SYSRSTSTAT_WDT1_RESET_WDT1_RESET_WAS_DETECTED =3D 1, +} RT500_RSTCTL1_SYSRSTSTAT_WDT1_RESET_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM0_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM0_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM1_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM1_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM1_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM2_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM2_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM2_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM3_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM3_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM3_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM4_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM4_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM4_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM5_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM5_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM5_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM6_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM6_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM6_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM7_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM7_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM7_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM8_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM8_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM8_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM9_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM9_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM9_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM10_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM10_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM10_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM11_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM11_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM11_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM12_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM12_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM12_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM13_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM13_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM13_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM14_FLEXCOMM_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM14_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM14_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM15_I2C_FLEXCOMM15_I2C_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM15_I2C_FLEXCOMM15_I2C_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM15_I2C_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_DMIC0_DMIC0_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_DMIC0_DMIC0_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_DMIC0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM16_FLEXCOMM16_SPI1_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXCOMM16_FLEXCOMM16_SPI1_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXCOMM16_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_OSEVENT_TIMER_OSEVENT_TIMER_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_OSEVENT_TIMER_OSEVENT_TIMER_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_OSEVENT_TIMER_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXIO_FLEXIO_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL0_FLEXIO_FLEXIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_FLEXIO_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO0_HSGPIO_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO0_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_HSGPIO0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO1_HSGPIO_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO1_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_HSGPIO1_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO2_HSGPIO_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO2_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_HSGPIO2_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO3_HSGPIO_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO3_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_HSGPIO3_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO4_HSGPIO_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO4_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_HSGPIO4_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO5_HSGPIO_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO5_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_HSGPIO5_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO6_HSGPIO_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO6_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_HSGPIO6_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO7_HSGPIO_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_HSGPIO7_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_HSGPIO7_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_CRC_CRC_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_CRC_CRC_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CRC_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_DMAC0_DMAC_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_DMAC0_DMAC_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_DMAC0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_DMAC1_DMAC_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_DMAC1_DMAC_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_DMAC1_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_MU_MU_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_MU_MU_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_MU_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_SEMA_SEMA_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_SEMA_SEMA_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SEMA_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL1_FREQME_FREQME_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL1_FREQME_FREQME_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_FREQME_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT0_CT32BIT_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT0_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CT32BIT0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT1_CT32BIT_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT1_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CT32BIT1_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT2_CT32BIT_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT2_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CT32BIT2_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT3_CT32BIT_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT3_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CT32BIT3_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT4_CT32BIT_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_CT32BIT4_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CT32BIT4_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_MRT0_MRT0_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_MRT0_MRT0_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_MRT0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_WWDT1_WWDT1_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_WWDT1_WWDT1_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_WWDT1_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_I3C0_I3C_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_I3C0_I3C_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_I3C0_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_I3C1_I3C_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_I3C1_I3C_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_I3C1_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_GPIOINTCTL_GPIOINTCTL_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_GPIOINTCTL_GPIOINTCTL_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_GPIOINTCTL_Enum; + +typedef enum { + /* Clear Reset */ + RT500_RSTCTL1_PRSTCTL2_PIMCTL_PIMCTL_CLR =3D 0, + /* Set Reset */ + RT500_RSTCTL1_PRSTCTL2_PIMCTL_PIMCTL_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_PIMCTL_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM0_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM0_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM0_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM1_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM1_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM1_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM2_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM2_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM2_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM3_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM3_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM3_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM4_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM4_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM4_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM5_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM5_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM5_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM6_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM6_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM6_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM7_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM7_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM7_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM8_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM8_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM8_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM9_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM9_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM9_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM10_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM10_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM10_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM11_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM11_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM11_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM12_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM12_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM12_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM13_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM13_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM13_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM14_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM14_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM14_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM15_I2C_FLEXCOMM15_I2C_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM15_I2C_FLEXCOMM15_I2C_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM15_I2C_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_DMIC0_FLEXCOMM_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_DMIC0_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_DMIC0_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM16_FLEXCOMM16_SPI1_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM16_FLEXCOMM16_SPI1_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXCOMM16_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_OSEVENT_TIMER_OSEVENT_TIMER_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_OSEVENT_TIMER_OSEVENT_TIMER_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_OSEVENT_TIMER_Enum; + +typedef enum { + /* No Effect */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXIO_FLEXIO_CLR =3D 0, + /* Sets the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_SET_FLEXIO_FLEXIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_SET_FLEXIO_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO0_HSGPIO_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO0_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO1_HSGPIO_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO1_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO2_HSGPIO_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO2_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO2_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO3_HSGPIO_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO3_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO3_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO4_HSGPIO_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO4_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO4_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO5_HSGPIO_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO5_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO5_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO6_HSGPIO_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO6_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO6_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO7_HSGPIO_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO7_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_HSGPIO7_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_CRC_CRC_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_CRC_CRC_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_CRC_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_DMAC0_DMAC_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_DMAC0_DMAC_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_DMAC0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_DMAC1_DMAC_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_DMAC1_DMAC_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_DMAC1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_MU_MU_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_MU_MU_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_MU_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_SEMA_SEMA_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_SEMA_SEMA_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_SEMA_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_SET_FREQME_FREQME_CLR =3D 0, + /* Sets the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_SET_FREQME_FREQME_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_SET_FREQME_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT0_CT32BIT_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT0_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT1_CT32BIT_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT1_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT2_CT32BIT_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT2_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT2_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT3_CT32BIT_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT3_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT3_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT4_CT32BIT_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT4_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_CT32BIT4_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_MRT0_MRT0_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_MRT0_MRT0_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_MRT0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_WWDT1_WWDT1_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_WWDT1_WWDT1_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_WWDT1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_I3C0_I3C_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_I3C0_I3C_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_I3C0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_I3C1_I3C_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_I3C1_I3C_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_I3C1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_GPIOINTCTL_GPIOINTCTL_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_GPIOINTCTL_GPIOINTCTL_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_GPIOINTCTL_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_SET_PIMCTL_PIMCTL_CLR =3D 0, + /* Sets the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_SET_PIMCTL_PIMCTL_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_SET_PIMCTL_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM0_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM0_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM1_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM1_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM2_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM2_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM2_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM3_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM3_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM3_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM4_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM4_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM4_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM5_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM5_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM5_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM6_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM6_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM6_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM7_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM7_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM7_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM8_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM8_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM8_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM9_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM9_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM9_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM10_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM10_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM10_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM11_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM11_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM11_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM12_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM12_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM12_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM13_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM13_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM13_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM14_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM14_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM14_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM15_I2C_FLEXCOMM15_I2C_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM15_I2C_FLEXCOMM15_I2C_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM15_I2C_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_DMIC0_FLEXCOMM_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_DMIC0_FLEXCOMM_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_DMIC0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM16_FLEXCOMM16_SPI1_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM16_FLEXCOMM16_SPI1_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXCOMM16_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_OSEVENT_TIMER_OSEVENT_TIMER_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_OSEVENT_TIMER_OSEVENT_TIMER_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_OSEVENT_TIMER_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXIO_FLEXIO_CLR =3D 0, + /* Clears the PRSTCTL0 Bit */ + RT500_RSTCTL1_PRSTCTL0_CLR_FLEXIO_FLEXIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL0_CLR_FLEXIO_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO0_HSGPIO_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO0_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO1_HSGPIO_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO1_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO2_HSGPIO_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO2_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO2_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO3_HSGPIO_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO3_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO3_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO4_HSGPIO_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO4_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO4_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO5_HSGPIO_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO5_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO5_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO6_HSGPIO_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO6_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO6_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO7_HSGPIO_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO7_HSGPIO_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_HSGPIO7_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_CRC_CRC_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_CRC_CRC_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_CRC_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_DMAC0_DMAC_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_DMAC0_DMAC_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_DMAC0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_DMAC1_DMAC_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_DMAC1_DMAC_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_DMAC1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_MU_MU_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_MU_MU_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_MU_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_SEMA_SEMA_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_SEMA_SEMA_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_SEMA_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL1_CLR_FREQME_FREQME_CLR =3D 0, + /* Clears the PRSTCTL1 Bit */ + RT500_RSTCTL1_PRSTCTL1_CLR_FREQME_FREQME_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL1_CLR_FREQME_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT0_CT32BIT_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT0_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT1_CT32BIT_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT1_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT2_CT32BIT_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT2_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT2_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT3_CT32BIT_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT3_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT3_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT4_CT32BIT_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT4_CT32BIT_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_CT32BIT4_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_MRT0_MRT0_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_MRT0_MRT0_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_MRT0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_WWDT1_WWDT1_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_WWDT1_WWDT1_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_WWDT1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_I3C0_I3C_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_I3C0_I3C_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_I3C0_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_I3C1_I3C_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_I3C1_I3C_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_I3C1_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_GPIOINTCTL_GPIOINTCTL_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_GPIOINTCTL_GPIOINTCTL_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_GPIOINTCTL_Enum; + +typedef enum { + /* No effect */ + RT500_RSTCTL1_PRSTCTL2_CLR_PIMCTL_PIMCTL_CLR =3D 0, + /* Clears the PRSTCTL2 Bit */ + RT500_RSTCTL1_PRSTCTL2_CLR_PIMCTL_PIMCTL_SET =3D 1, +} RT500_RSTCTL1_PRSTCTL2_CLR_PIMCTL_Enum; + + +#define RT500_RSTCTL1_REGISTER_ACCESS_INFO_ARRAY(_name) \ + struct RegisterAccessInfo _name[RT500_RSTCTL1_REGS_NO] =3D { \ + [0 ... RT500_RSTCTL1_REGS_NO - 1] =3D { \ + .name =3D "", \ + .addr =3D -1, \ + }, \ + [R_RT500_RSTCTL1_SYSRSTSTAT] =3D { \ + .name =3D "SYSRSTSTAT", \ + .addr =3D 0x0, \ + .ro =3D 0xFFFFFFFF, \ + .reset =3D 0x1, \ + }, \ + [R_RT500_RSTCTL1_PRSTCTL0] =3D { \ + .name =3D "PRSTCTL0", \ + .addr =3D 0x10, \ + .ro =3D 0xD40000FF, \ + .reset =3D 0x1C0FF00, \ + }, \ + [R_RT500_RSTCTL1_PRSTCTL1] =3D { \ + .name =3D "PRSTCTL1", \ + .addr =3D 0x14, \ + .ro =3D 0x4E7EFF00, \ + .reset =3D 0xB18100FF, \ + }, \ + [R_RT500_RSTCTL1_PRSTCTL2] =3D { \ + .name =3D "PRSTCTL2", \ + .addr =3D 0x18, \ + .ro =3D 0x3FFCFAE0, \ + .reset =3D 0xC001011F, \ + }, \ + [R_RT500_RSTCTL1_PRSTCTL0_SET] =3D { \ + .name =3D "PRSTCTL0_SET", \ + .addr =3D 0x40, \ + .ro =3D 0xD40000FF, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL1_PRSTCTL1_SET] =3D { \ + .name =3D "PRSTCTL1_SET", \ + .addr =3D 0x44, \ + .ro =3D 0x4E7EFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL1_PRSTCTL2_SET] =3D { \ + .name =3D "PRSTCTL2_SET", \ + .addr =3D 0x48, \ + .ro =3D 0x3FFCFAE0, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL1_PRSTCTL0_CLR] =3D { \ + .name =3D "PRSTCTL0_CLR", \ + .addr =3D 0x70, \ + .ro =3D 0xD40000FF, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL1_PRSTCTL1_CLR] =3D { \ + .name =3D "PRSTCTL1_CLR", \ + .addr =3D 0x74, \ + .ro =3D 0x4E7EFF00, \ + .reset =3D 0x0, \ + }, \ + [R_RT500_RSTCTL1_PRSTCTL2_CLR] =3D { \ + .name =3D "PRSTCTL2_CLR", \ + .addr =3D 0x78, \ + .ro =3D 0x3FFCFAE0, \ + .reset =3D 0x0, \ + }, \ + } diff --git a/include/hw/misc/rt500_rstctl.h b/include/hw/misc/rt500_rstctl.h new file mode 100644 index 0000000000..ae7e304b2e --- /dev/null +++ b/include/hw/misc/rt500_rstctl.h @@ -0,0 +1,32 @@ +/* + * QEMU model for RT500 Reset Controller + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_MISC_RT500_RSTCTL_H +#define HW_MISC_RT500_RSTCTL_H + +#include "hw/arm/svd/rt500_rstctl0.h" +#include "hw/arm/svd/rt500_rstctl1.h" +#include "hw/sysbus.h" + +#define TYPE_RT500_RSTCTL "rt500-rstctl" +#define RT500_RSTCTL(o) OBJECT_CHECK(RT500RstCtlState, o, TYPE_RT500_RSTCT= L) + +#define TYPE_RT500_RSTCTL0 "rt500-rstctl0" +#define TYPE_RT500_RSTCTL1 "rt500-rstctl1" + +typedef struct { + SysBusDevice parent_obj; + + MemoryRegion mmio; + uint32_t regs[RT500_RSTCTL1_REGS_NO]; +} RT500RstCtlState; + +#endif /* HW_MISC_RT500_RSTCTL_H */ diff --git a/hw/misc/rt500_rstctl.c b/hw/misc/rt500_rstctl.c new file mode 100644 index 0000000000..a6e818c0a0 --- /dev/null +++ b/hw/misc/rt500_rstctl.c @@ -0,0 +1,258 @@ +/* + * QEMU model for RT500 Reset Controller + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "migration/vmstate.h" +#include "hw/misc/rt500_rstctl.h" + +#include "trace.h" + +/* + * There are two intances for RSTCTL with the same register names and layo= ut but + * with different fields. + */ +#define BUILD_BUG_REG_ADDR(reg) \ + QEMU_BUILD_BUG_ON((int)A_RT500_RSTCTL0_##reg !=3D (int)A_RT500_RSTCTL1= _##reg) + +#define REG(s, reg) (s->regs[R_RT500_RSTCTL0_##reg]) +#define RF_WR(s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, RT500_RSTCTL0_##reg, field, val) +#define RF_RD(s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, RT500_RSTCTL0_##reg, field) + +#define RSTCTL_SYSRSTSTAT_WMASK (BITS(7, 4) | BIT(0)) +#define RSTCL0_PRSCTL0_WMASK (BITS(30, 26) | BITS(24, 20) | BIT(18) | \ + BIT(16) | BITS(12, 8) | BIT(3) | BIT(1)) +#define RSTCL0_PRSCTL1_WMASK (BIT(24) | BITS(16, 15) | BITS(3, 2)) +#define RSTCL0_PRSCTL2_WMASK (BITS(1, 0)) +#define RSTCL1_PRSCTL0_WMASK (BIT(29) | BIT(27) | BITS(25, 8)) +#define RSTCL1_PRSCTL1_WMASK (BIT(31) | BITS(29, 28) | BITS(24, 23) | \ + BIT(16) | BITS(7, 0)) +#define RSTCL1_PRSCTL2_WMASK (BITS(31, 30) | BITS(17, 16) | BIT(10) | \ + BIT(8) | BITS(4, 0)) + + +/* + * The two RSTCLK modules have different write register masks. + */ +typedef struct { + SysBusDeviceClass parent; + const struct RegisterAccessInfo *reg_info; + int reg_info_num; +} RT500RstCtlClass; + +#define RT500_RSTCTL_CLASS(klass) \ + OBJECT_CLASS_CHECK(RT500RstCtlClass, (klass), TYPE_RT500_RSTCTL) +#define RT500_RSTCTL_GET_CLASS(obj) \ + OBJECT_GET_CLASS(RT500RstCtlClass, (obj), TYPE_RT500_RSTCTL) + +BUILD_BUG_REG_ADDR(SYSRSTSTAT); +BUILD_BUG_REG_ADDR(PRSTCTL0); +BUILD_BUG_REG_ADDR(PRSTCTL1); +BUILD_BUG_REG_ADDR(PRSTCTL2); +BUILD_BUG_REG_ADDR(PRSTCTL0_SET); +BUILD_BUG_REG_ADDR(PRSTCTL1_SET); +BUILD_BUG_REG_ADDR(PRSTCTL2_SET); +BUILD_BUG_REG_ADDR(PRSTCTL0_CLR); +BUILD_BUG_REG_ADDR(PRSTCTL1_CLR); +BUILD_BUG_REG_ADDR(PRSTCTL2_CLR); + +static MemTxResult rt500_rstctl_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + RT500RstCtlState *s =3D opaque; + RT500RstCtlClass *c =3D RT500_RSTCTL_GET_CLASS(s); + const struct RegisterAccessInfo *rai =3D &c->reg_info[addr / 4]; + MemTxResult ret =3D MEMTX_OK; + + switch (addr) { + case A_RT500_RSTCTL0_SYSRSTSTAT: + case A_RT500_RSTCTL0_PRSTCTL0: + case A_RT500_RSTCTL0_PRSTCTL1: + case A_RT500_RSTCTL0_PRSTCTL2: + *data =3D s->regs[addr / 4]; + break; + default: + ret =3D MEMTX_ERROR; + } + + trace_rt500_rstctl_reg_read(DEVICE(s)->id, rai->name, addr, *data); + return ret; +} + +static MemTxResult rt500_rstctl_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + RT500RstCtlState *s =3D opaque; + RT500RstCtlClass *c =3D RT500_RSTCTL_GET_CLASS(s); + const struct RegisterAccessInfo *rai =3D &c->reg_info[addr / 4]; + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D rai, + }; + + trace_rt500_rstctl_reg_write(DEVICE(s)->id, rai->name, addr, value); + + switch (addr) { + case A_RT500_RSTCTL0_SYSRSTSTAT: + { + /* write 1 to clear bits */ + REG(s, SYSRSTSTAT) &=3D ~value; + break; + } + case A_RT500_RSTCTL0_PRSTCTL0: + case A_RT500_RSTCTL0_PRSTCTL1: + case A_RT500_RSTCTL0_PRSTCTL2: + { + register_write(&ri, value, ~0, NULL, false); + break; + } + case A_RT500_RSTCTL0_PRSTCTL0_SET: + case A_RT500_RSTCTL0_PRSTCTL1_SET: + case A_RT500_RSTCTL0_PRSTCTL2_SET: + { + uint32_t tmp; + + tmp =3D A_RT500_RSTCTL0_PRSTCTL0 + (addr - A_RT500_RSTCTL0_PRSTCTL= 0_SET); + s->regs[tmp / 4] |=3D value; + break; + } + case A_RT500_RSTCTL0_PRSTCTL0_CLR: + case A_RT500_RSTCTL0_PRSTCTL1_CLR: + case A_RT500_RSTCTL0_PRSTCTL2_CLR: + { + uint32_t tmp; + + tmp =3D A_RT500_RSTCTL0_PRSTCTL0 + (addr - A_RT500_RSTCTL0_PRSTCTL= 0_CLR); + s->regs[tmp / 4] &=3D ~value; + break; + } + } + + return MEMTX_OK; +} + +static const MemoryRegionOps rt500_rstctl_ops =3D { + .read_with_attrs =3D rt500_rstctl_read, + .write_with_attrs =3D rt500_rstctl_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + .unaligned =3D false, + }, +}; + +static void rt500_rstctl_reset_enter(Object *obj, ResetType type) +{ + RT500RstCtlState *s =3D RT500_RSTCTL(obj); + RT500RstCtlClass *c =3D RT500_RSTCTL_GET_CLASS(s); + + for (int i =3D 0; i < c->reg_info_num; i++) { + hwaddr addr =3D c->reg_info[i].addr; + + if (addr !=3D -1) { + struct RegisterInfo ri =3D { + .data =3D &s->regs[addr / 4], + .data_size =3D 4, + .access =3D &c->reg_info[i], + }; + + register_reset(&ri); + } + } +} + +static void rt500_rstctl_init(Object *obj) +{ + RT500RstCtlState *s =3D RT500_RSTCTL(obj); + + memory_region_init_io(&s->mmio, obj, &rt500_rstctl_ops, s, + TYPE_RT500_RSTCTL, sizeof(s->regs)); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); +} + +static const VMStateDescription vmstate_rt500_rstcl0 =3D { + .name =3D "rt500-rstctl0", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32_ARRAY(regs, RT500RstCtlState, RT500_RSTCTL0_REGS_NO= ), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_rt500_rstcl1 =3D { + .name =3D "rt500-rstctl1", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32_ARRAY(regs, RT500RstCtlState, RT500_RSTCTL1_REGS_NO= ), + VMSTATE_END_OF_LIST() + } +}; + +static void rt500_rstctl0_class_init(ObjectClass *klass, void *data) +{ + RT500RstCtlClass *rc =3D RT500_RSTCTL_CLASS(klass); + static const RT500_RSTCTL0_REGISTER_ACCESS_INFO_ARRAY(reg_info); + DeviceClass *dc =3D DEVICE_CLASS(klass); + + RESETTABLE_CLASS(klass)->phases.enter =3D rt500_rstctl_reset_enter; + dc->vmsd =3D &vmstate_rt500_rstcl0; + rc->reg_info =3D reg_info; + rc->reg_info_num =3D ARRAY_SIZE(reg_info); +} + +static void rt500_rstctl1_class_init(ObjectClass *klass, void *data) +{ + RT500RstCtlClass *rc =3D RT500_RSTCTL_CLASS(klass); + static const RT500_RSTCTL1_REGISTER_ACCESS_INFO_ARRAY(reg_info); + DeviceClass *dc =3D DEVICE_CLASS(klass); + + RESETTABLE_CLASS(klass)->phases.enter =3D rt500_rstctl_reset_enter; + dc->vmsd =3D &vmstate_rt500_rstcl1; + rc->reg_info =3D reg_info; + rc->reg_info_num =3D ARRAY_SIZE(reg_info); +} + +static const TypeInfo rt500_rstctl_types[] =3D { + { + .name =3D TYPE_RT500_RSTCTL, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(RT500RstCtlState), + .instance_init =3D rt500_rstctl_init, + .abstract =3D true, + }, + { + .name =3D TYPE_RT500_RSTCTL0, + .parent =3D TYPE_RT500_RSTCTL, + .class_init =3D rt500_rstctl0_class_init, + .class_size =3D sizeof(RT500RstCtlClass), + }, + { + .name =3D TYPE_RT500_RSTCTL1, + .parent =3D TYPE_RT500_RSTCTL, + .class_init =3D rt500_rstctl1_class_init, + .class_size =3D sizeof(RT500RstCtlClass), + }, +}; + +DEFINE_TYPES(rt500_rstctl_types); diff --git a/hw/arm/svd/meson.build b/hw/arm/svd/meson.build index 7e59eda0d3..25f4917089 100644 --- a/hw/arm/svd/meson.build +++ b/hw/arm/svd/meson.build @@ -22,4 +22,10 @@ if get_option('mcux-soc-svd') run_target('svd-flexspi', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexspi.h', '-p', 'FLEXSPI0', '-t', 'FLEXSPI']) + run_target('svd-rt500-rstctl0', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/rt500_rstctl0.h= ', + '-p', 'RSTCTL0', '-t', 'RT500_RSTCTL0']) + run_target('svd-rt500-rstctl1', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/rt500_rstctl1.h= ', + '-p', 'RSTCTL1', '-t', 'RT500_RSTCTL1']) endif diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 02feb93840..4b688aead2 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -221,4 +221,7 @@ config FLEXCOMM config RT500_CLKCTL bool =20 +config RT500_RSTCTL + bool + source macio/Kconfig diff --git a/hw/misc/meson.build b/hw/misc/meson.build index e6d97b387c..faaf2671ba 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -160,3 +160,4 @@ system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi= .c')) =20 system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm.c')) system_ss.add(when: 'CONFIG_RT500_CLKCTL', if_true: files('rt500_clkctl0.c= ', 'rt500_clkctl1.c')) +system_ss.add(when: 'CONFIG_RT500_RSTCTL', if_true: files('rt500_rstctl.c'= )) diff --git a/hw/misc/trace-events b/hw/misc/trace-events index b19393dd36..721ebe4bb7 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -376,3 +376,7 @@ rt500_clkctl0_reg_write(const char *regname, uint32_t a= ddr, uint32_t val) "%s[0x # rt500_clkctl1.c rt500_clkctl1_reg_read(const char *regname, uint32_t addr, uint32_t val) "= %s[0x%04x] -> 0x%08x" rt500_clkctl1_reg_write(const char *regname, uint32_t addr, uint32_t val) = "%s[0x%04x] <- 0x%08x" + +# rt500_rstctl.c +rt500_rstctl_reg_read(const char *id, const char *regname, uint32_t addr, = uint32_t val) "%s: %s[0x%04x] -> 0x%08x" +rt500_rstctl_reg_write(const char *id, const char *regname, uint32_t addr,= uint32_t val) "%s: %s[0x%04x] <- 0x%08x" --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687794; cv=none; d=zohomail.com; s=zohoarc; b=mAymOH53+EMTMgaBqAXr47b2pMvFuIiL5JvGZjJ6lHSEyW9Z/q84UvT9CTgJoR+7Py8shuUaLsG7WURDK3Fk2V4RL9Cg8ZdgXs4R/EwFq7xYnHnd1ncGaM8lwvC4ICuQ3fJf4eLM/3mrPpJQlYtd0ilK/8RtLnA+jQn5zEI4SRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687794; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GrK+BQYlzxSPdexV/TzOeuXg9hd8/cvlkJBL4VfsdQk=; b=ijTBfaK7M6nL4YIFj2WB2zcP0himWObNZEmC2J1mHwi/1caio9Rc8uKS+uQaneo8eXKDQ7Y56woMgDPOyL7eCgWPUZuEpVV3Pcmm2/y7aAZQdTK/hwH5IZkveBcOx9+1qPz7WNuqxoqcuPLep88/UqH2TpSHXPr7tQ/AkOWu+Lo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687794555354.33862649860964; Wed, 18 Sep 2024 12:29:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0H1-0005jH-EI; Wed, 18 Sep 2024 15:23:35 -0400 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 <3pyjrZgUKCuIXEZMTKSSKPI.GSQUIQY-HIZIPRSRKRY.SVK@flex--tavip.bounces.google.com>) id 1sr0Gt-0005BD-7E for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:27 -0400 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3pyjrZgUKCuIXEZMTKSSKPI.GSQUIQY-HIZIPRSRKRY.SVK@flex--tavip.bounces.google.com>) id 1sr0Gq-0007MW-M5 for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:26 -0400 Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-7cbe272efa6so7482780a12.3 for ; Wed, 18 Sep 2024 12:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687401; x=1727292201; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=GrK+BQYlzxSPdexV/TzOeuXg9hd8/cvlkJBL4VfsdQk=; b=PqBQGp6ZG7SDe4iVpdsPL2U5PSUzrPqBXGEfm212PG2v8IdsGjVX78dNSo6YEV8v8T UyxoEL3XjUNiOGdfNOHwcNvBL+DZE82KCHMbqbQMX+Oqz4hznufFiubxOmc+5CY7cPT8 ZYFjiDqIbH3u0TRpdpMWjt2wnqBI7+kpHTWc0Cq2D6+n4TO+uUR9TvI9ljDbP74hJI9p w+Qkjc4BJF/RJidmLwwlUAsa9zqyGMIS7mtDQycAkilUBa2RyXhlZpvPfZzMDkC5K6bK sIN7ryYzpwDNE8b02670iT3RBdzneiNd8mnPIX9asc14enCO7W3B4yO/P26BmZGeENXm 0x9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687401; x=1727292201; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GrK+BQYlzxSPdexV/TzOeuXg9hd8/cvlkJBL4VfsdQk=; b=D9yJh1F5YnAgUJDK3hyXjjZ2Cl6tvrfSMITOHBveVOdOSZS7DUGxYlfOw6r06lIUu0 nZz7du/jBK2QxbyIAuQwb48zskevoh0x7NYyL4crr0E1ICrh2Odog8ga1wggL2/PELYq JEn8deCKh686YgdG6teMBt7P5YrGw+6eawgMeL/6OhAlxBRDZV35lPdZD1RhnmBhapmI jQ+5n9+fjSTqaNbHgog5vQeTkgMn23v0asd/EJZKsij7XCg8NeCK+gYUKYNBb5Py1wrf Y5QQPnrFcTnV1FkBiEOAjgC/Ry5t4nhuElVNaVAu0f1nCENhg5JqKH4Hsl3j0mFitai+ h6MA== X-Gm-Message-State: AOJu0YzMN9mPiU+H9WejsuBj1NzxVQK1SP4mQEeMFfAiS97RPtP6t4HE 410yII2cDtA1keot2QwX3oJkc1DUfJdfFYMC0a9P5zAEJ3MT4ZmUKoS3N4nj0NL/5plMgf3QvV7 tJN8cCbaX97kkXkZCX02UrOrWQ+2nzfodRmrjfo4ZFqMPN7P+Ig40hWC0w15lrOvnA4eYRcmUuV GqW6XL6UbANcotONk9d/JTPZZxiw== X-Google-Smtp-Source: AGHT+IHUgiNcSOH917K8/God65dLqgP7bXryyinA7VP84c4TPbfNN0Br8KqnC00ugfHUV8qiCPJ2nQhg0Q== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a05:6a02:497:b0:76c:26a8:e0dc with SMTP id 41be03b00d2f7-7db205d4bb4mr101001a12.5.1726687399914; Wed, 18 Sep 2024 12:23:19 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:41 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-14-tavip@google.com> Subject: [PATCH 13/25] hw/arm: add basic support for the RT500 SoC From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::549; envelope-from=3pyjrZgUKCuIXEZMTKSSKPI.GSQUIQY-HIZIPRSRKRY.SVK@flex--tavip.bounces.google.com; helo=mail-pg1-x549.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687796306116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add basic support for the RT500 SoC. It supports enough peripherals to run the NXP's microXpresso SDK hello world example. The patch includes an automatically generated header which contains peripheral base addreses and interrupt numbers. The header can be regenerated with the svd-rt500 target when the build is configured with --enable-mcux-soc-svd. Signed-off-by: Octavian Purdila --- include/hw/arm/rt500.h | 44 +++++ include/hw/arm/svd/rt500.h | 63 +++++++ hw/arm/rt500.c | 329 +++++++++++++++++++++++++++++++++++++ hw/arm/Kconfig | 2 + hw/arm/meson.build | 1 + hw/arm/svd/meson.build | 4 + 6 files changed, 443 insertions(+) create mode 100644 include/hw/arm/rt500.h create mode 100644 include/hw/arm/svd/rt500.h create mode 100644 hw/arm/rt500.c diff --git a/include/hw/arm/rt500.h b/include/hw/arm/rt500.h new file mode 100644 index 0000000000..26e08c39a6 --- /dev/null +++ b/include/hw/arm/rt500.h @@ -0,0 +1,44 @@ +/* + * i.MX RT500 platforms. + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_ARM_RT500_H +#define HW_ARM_RT500_H + +#include "hw/arm/armv7m.h" +#include "hw/misc/flexcomm.h" +#include "hw/misc/rt500_clkctl0.h" +#include "hw/misc/rt500_clkctl1.h" +#include "hw/ssi/flexspi.h" +#include "hw/misc/rt500_rstctl.h" + +#define TYPE_RT500 "rt500" +#define RT500(obj) OBJECT_CHECK(RT500State, (obj), TYPE_RT500) + +#define RT500_FLEXCOMM_NUM (17) +#define RT500_FLEXSPI_NUM (2) +#define RT500_RSTCTL_NUM (2) + +typedef struct RT500State { + SysBusDevice parent_obj; + + ARMv7MState armv7m; + MemoryRegion *mem; + FlexcommState flexcomm[RT500_FLEXCOMM_NUM]; + RT500ClkCtl0State clkctl0; + RT500ClkCtl1State clkctl1; + FlexSpiState flexspi[RT500_FLEXSPI_NUM]; + RT500RstCtlState rstctl[RT500_RSTCTL_NUM]; + + Clock *sysclk; + Clock *refclk; +} RT500State; + +#endif /* HW_ARM_RT500_H */ diff --git a/include/hw/arm/svd/rt500.h b/include/hw/arm/svd/rt500.h new file mode 100644 index 0000000000..3594258f2e --- /dev/null +++ b/include/hw/arm/svd/rt500.h @@ -0,0 +1,63 @@ +/* + * Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause + * + * Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml + */ +#pragma once + +#define RT500_FLEXCOMM0_BASE 0x40106000UL +#define RT500_FLEXCOMM1_BASE 0x40107000UL +#define RT500_FLEXCOMM2_BASE 0x40108000UL +#define RT500_FLEXCOMM3_BASE 0x40109000UL +#define RT500_FLEXCOMM4_BASE 0x40122000UL +#define RT500_FLEXCOMM5_BASE 0x40123000UL +#define RT500_FLEXCOMM6_BASE 0x40124000UL +#define RT500_FLEXCOMM7_BASE 0x40125000UL +#define RT500_FLEXCOMM14_BASE 0x40126000UL +#define RT500_FLEXCOMM15_BASE 0x40127000UL +#define RT500_FLEXCOMM16_BASE 0x40128000UL +#define RT500_FLEXCOMM8_BASE 0x40209000UL +#define RT500_FLEXCOMM9_BASE 0x4020A000UL +#define RT500_FLEXCOMM10_BASE 0x4020B000UL +#define RT500_FLEXCOMM11_BASE 0x4020C000UL +#define RT500_FLEXCOMM12_BASE 0x4020D000UL +#define RT500_FLEXCOMM13_BASE 0x4020E000UL + +#define RT500_FLEXCOMM0_IRQn 0x14UL +#define RT500_FLEXCOMM1_IRQn 0x15UL +#define RT500_FLEXCOMM2_IRQn 0x16UL +#define RT500_FLEXCOMM3_IRQn 0x17UL +#define RT500_FLEXCOMM4_IRQn 0x18UL +#define RT500_FLEXCOMM5_IRQn 0x19UL +#define RT500_FLEXCOMM6_IRQn 0x43UL +#define RT500_FLEXCOMM7_IRQn 0x44UL +#define RT500_FLEXCOMM14_IRQn 0x20UL +#define RT500_FLEXCOMM15_IRQn 0x21UL +#define RT500_FLEXCOMM16_IRQn 0x66UL +#define RT500_FLEXCOMM8_IRQn 0x60UL +#define RT500_FLEXCOMM9_IRQn 0x61UL +#define RT500_FLEXCOMM10_IRQn 0x62UL +#define RT500_FLEXCOMM11_IRQn 0x63UL +#define RT500_FLEXCOMM12_IRQn 0x64UL +#define RT500_FLEXCOMM13_IRQn 0x65UL + +#define RT500_CLKCTL0_BASE 0x40001000UL + + +#define RT500_CLKCTL1_BASE 0x40021000UL + + +#define RT500_FLEXSPI0_BASE 0x40134000UL + +#define RT500_FLEXSPI0_FLEXSPI1_IRQn 0x42UL + +#define RT500_FLEXSPI1_BASE 0x4013C000UL + +#define RT500_FLEXSPI0_FLEXSPI1_IRQn 0x42UL + +#define RT500_RSTCTL0_BASE 0x40000000UL + + +#define RT500_RSTCTL1_BASE 0x40020000UL + + diff --git a/hw/arm/rt500.c b/hw/arm/rt500.c new file mode 100644 index 0000000000..9e4cfb539e --- /dev/null +++ b/hw/arm/rt500.c @@ -0,0 +1,329 @@ +/* + * i.MX RT500 platforms. + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/sysbus.h" +#include "hw/arm/boot.h" +#include "hw/boards.h" +#include "hw/irq.h" +#include "qemu/log.h" +#include "qemu/datadir.h" +#include "qemu/units.h" +#include "exec/address-spaces.h" +#include "sysemu/reset.h" +#include "sysemu/runstate.h" +#include "sysemu/sysemu.h" +#include "hw/arm/armv7m.h" +#include "hw/loader.h" +#include "hw/qdev-clock.h" +#include "hw/misc/unimp.h" +#include "hw/arm/rt500.h" +#include "hw/arm/svd/rt500.h" + +#define MMAP_SRAM_CODE_BASE (0x0) +#define MMAP_SRAM_DATA_BASE (0x20000000) +#define MMAP_SRAM_SIZE (5 * MiB) +#define MMAP_BOOT_ROM_BASE (0x03000000) +#define MMAP_BOOT_ROM_SIZE (192 * KiB) +#define MMAP_SDMA_RAM_BASE (0x24100000) +#define MMAP_SDMA_RAM_SIZE (32 * KiB) +#define MMAP_FLEXSPI0_BASE (0x08000000) +#define MMAP_FLEXSPI0_SIZE (128 * MiB) +#define MMAP_FLEXSPI1_BASE (0x28000000) +#define MMAP_FLEXSPI1_SIZE (128 * MiB) + +#define SECURE_OFFSET (0x10000000) + +#define RT500_NUM_IRQ (RT500_FLEXCOMM16_IRQn + 1) + +typedef enum MemInfoType { + MEM_RAM, + MEM_ROM, + MEM_ALIAS +} MemInfoType; + +static void do_sys_reset(void *opaque, int n, int level) +{ + if (level) { + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); + } +} + +static void rt500_init(Object *obj) +{ + RT500State *s =3D RT500(obj); + + /* Add ARMv7-M device */ + object_initialize_child(obj, "armv7m", &s->armv7m, TYPE_ARMV7M); + + for (int i =3D 0; i < RT500_FLEXCOMM_NUM; i++) { + char *id =3D g_strdup_printf("flexcomm%d", i); + + object_initialize_child(obj, id, &s->flexcomm[i], TYPE_FLEXCOMM); + DEVICE(&s->flexcomm[i])->id =3D id; + } + + object_initialize_child(obj, "clkctl0", &s->clkctl0, TYPE_RT500_CLKCTL= 0); + object_initialize_child(obj, "clkctl1", &s->clkctl1, TYPE_RT500_CLKCTL= 1); + + /* Initialize clocks */ + s->sysclk =3D qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0); + s->refclk =3D qdev_init_clock_in(DEVICE(s), "refclk", NULL, NULL, 0); + + for (int i =3D 0; i < RT500_FLEXSPI_NUM; i++) { + char *id =3D g_strdup_printf("flexspi%d", i); + + object_initialize_child(obj, id, &s->flexspi[i], TYPE_FLEXSPI); + DEVICE(&s->flexspi[i])->id =3D id; + } + + for (int i =3D 0; i < RT500_RSTCTL_NUM; i++) { + static const char *types[] =3D { + TYPE_RT500_RSTCTL0, TYPE_RT500_RSTCTL1 + }; + char *id =3D g_strdup_printf("rstctl%d", i); + + object_initialize_child(obj, id, &s->rstctl[i], types[i]); + DEVICE(&s->rstctl[i])->id =3D id; + } +} + +static void rt500_realize_memory(RT500State *s, Error **errp) +{ + static const struct { + const char *name; + hwaddr base; + size_t size; + MemInfoType type; + int alias_for; + } mem_info[] =3D { + { + .name =3D "SRAM (code bus)", + .base =3D MMAP_SRAM_CODE_BASE, + .size =3D MMAP_SRAM_SIZE, + .type =3D MEM_RAM, + }, + { + .name =3D "BOOT-ROM", + .base =3D MMAP_BOOT_ROM_BASE, + .size =3D MMAP_BOOT_ROM_SIZE, + .type =3D MEM_ROM, + }, + { + .name =3D "Smart DMA RAM", + .base =3D MMAP_SDMA_RAM_BASE, + .size =3D MMAP_SDMA_RAM_SIZE, + .type =3D MEM_RAM, + }, + { + .name =3D "SRAM (data bus)", + .base =3D MMAP_SRAM_DATA_BASE, + .size =3D MMAP_SRAM_SIZE, + .type =3D MEM_ALIAS, + .alias_for =3D 0 + }, + }; + + s->mem =3D g_malloc_n(2 * ARRAY_SIZE(mem_info), sizeof(MemoryRegion)); + for (int i =3D 0; i < ARRAY_SIZE(mem_info); i++) { + const char *name =3D mem_info[i].name; + int size =3D mem_info[i].size; + int type =3D mem_info[i].type; + int alias_for =3D mem_info[i].alias_for; + MemoryRegion *mem =3D &s->mem[i]; + uint32_t base =3D mem_info[i].base; + MemoryRegion *sec_mem; + char sec_name[256]; + + switch (type) { + case MEM_RAM: + memory_region_init_ram(mem, OBJECT(s), name, size, errp); + break; + case MEM_ROM: + memory_region_init_rom(mem, OBJECT(s), name, size, errp); + break; + case MEM_ALIAS: + { + MemoryRegion *orig =3D &s->mem[alias_for]; + + memory_region_init_alias(mem, OBJECT(s), name, orig, 0, size); + break; + } + default: + g_assert_not_reached(); + } + + memory_region_add_subregion(get_system_memory(), base, mem); + + /* create secure alias */ + snprintf(sec_name, sizeof(sec_name), "SECURE %s", name); + sec_mem =3D &s->mem[ARRAY_SIZE(mem_info) + i]; + if (type =3D=3D MEM_ALIAS) { + mem =3D &s->mem[alias_for]; + } + memory_region_init_alias(sec_mem, OBJECT(s), sec_name, mem, 0, siz= e); + memory_region_add_subregion(get_system_memory(), base + SECURE_OFF= SET, + sec_mem); + + if (mem_info[i].type =3D=3D MEM_ROM) { + char *fname =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, "rt500.rom= "); + + if (fname) { + int fsize =3D get_image_size(fname); + int ret; + + if (fsize > size) { + error_setg(errp, "rom file too big: %d > %d", fsize, s= ize); + } else { + ret =3D load_image_targphys(fname, base, size); + if (ret < 0) { + error_setg(errp, "could not load rom: %s", fname); + } + } + } + g_free(fname); + } + } +} + +static void rt500_realize(DeviceState *dev, Error **errp) +{ + MachineState *ms =3D MACHINE(qdev_get_machine()); + RT500State *s =3D RT500(dev); + + rt500_realize_memory(s, errp); + + /* Setup ARMv7M CPU */ + qdev_prop_set_uint32(DEVICE(&s->armv7m), "num-irq", RT500_NUM_IRQ); + qdev_prop_set_uint8(DEVICE(&s->armv7m), "num-prio-bits", 3); + qdev_prop_set_string(DEVICE(&s->armv7m), "cpu-type", "cortex-m33-arm-c= pu"); + object_property_set_link(OBJECT(&s->armv7m), "memory", + OBJECT(get_system_memory()), &error_abort); + if (!ms->kernel_filename) { + qdev_prop_set_uint32(DEVICE(&s->armv7m), "init-nsvtor", + MMAP_BOOT_ROM_BASE); + qdev_prop_set_uint32(DEVICE(&s->armv7m), "init-svtor", + MMAP_BOOT_ROM_BASE + SECURE_OFFSET); + } + + qdev_connect_clock_in(DEVICE(&s->armv7m), "cpuclk", s->sysclk); + qdev_connect_clock_in(DEVICE(&s->armv7m), "refclk", + qdev_get_clock_out(DEVICE(&s->clkctl0), "systick_clk"= )); + + sysbus_realize_and_unref(SYS_BUS_DEVICE(&s->armv7m), errp); + qdev_connect_gpio_out_named(DEVICE(&s->armv7m), "SYSRESETREQ", 0, + qemu_allocate_irq(&do_sys_reset, NULL, 0)); + + /* Setup FLEXCOMM */ + for (int i =3D 0; i < RT500_FLEXCOMM_NUM; i++) { + static const uint32_t addr[] =3D { + RT500_FLEXCOMM0_BASE, RT500_FLEXCOMM1_BASE, RT500_FLEXCOMM2_BA= SE, + RT500_FLEXCOMM3_BASE, RT500_FLEXCOMM4_BASE, RT500_FLEXCOMM5_BA= SE, + RT500_FLEXCOMM6_BASE, RT500_FLEXCOMM7_BASE, RT500_FLEXCOMM8_BA= SE, + RT500_FLEXCOMM8_BASE, RT500_FLEXCOMM10_BASE, RT500_FLEXCOMM11_= BASE, + RT500_FLEXCOMM12_BASE, RT500_FLEXCOMM13_BASE, RT500_FLEXCOMM14= _BASE, + RT500_FLEXCOMM15_BASE, RT500_FLEXCOMM16_BASE + }; + static const int irq[] =3D { + RT500_FLEXCOMM0_IRQn, RT500_FLEXCOMM1_IRQn, RT500_FLEXCOMM2_IR= Qn, + RT500_FLEXCOMM3_IRQn, RT500_FLEXCOMM4_IRQn, RT500_FLEXCOMM5_IR= Qn, + RT500_FLEXCOMM6_IRQn, RT500_FLEXCOMM7_IRQn, RT500_FLEXCOMM8_IR= Qn, + RT500_FLEXCOMM9_IRQn, RT500_FLEXCOMM10_IRQn, RT500_FLEXCOMM11_= IRQn, + RT500_FLEXCOMM12_IRQn, RT500_FLEXCOMM13_IRQn, RT500_FLEXCOMM14= _IRQn, + RT500_FLEXCOMM15_IRQn, RT500_FLEXCOMM16_IRQn + }; + static const int functions[] =3D { + FLEXCOMM_FULL, FLEXCOMM_FULL, FLEXCOMM_FULL, + FLEXCOMM_FULL, FLEXCOMM_FULL, FLEXCOMM_FULL, + FLEXCOMM_FULL, FLEXCOMM_FULL, FLEXCOMM_FULL, + FLEXCOMM_FULL, FLEXCOMM_FULL, FLEXCOMM_FULL, + FLEXCOMM_FULL, FLEXCOMM_FULL, FLEXCOMM_HSSPI, + FLEXCOMM_PMICI2C, FLEXCOMM_HSSPI + }; + DeviceState *ds =3D DEVICE(&s->flexcomm[i]); + + qdev_prop_set_uint32(ds, "functions", functions[i]); + sysbus_realize_and_unref(SYS_BUS_DEVICE(ds), errp); + sysbus_mmio_map(SYS_BUS_DEVICE(ds), 0, addr[i]); + sysbus_connect_irq(SYS_BUS_DEVICE(ds), 0, + qdev_get_gpio_in(DEVICE(&s->armv7m), irq[i])); + } + + /* Setup CTLCTL0 */ + qdev_connect_clock_in(DEVICE(&s->clkctl0), "sysclk", s->sysclk); + sysbus_realize_and_unref(SYS_BUS_DEVICE(DEVICE(&s->clkctl0)), errp); + sysbus_mmio_map(SYS_BUS_DEVICE(DEVICE(&s->clkctl0)), 0, RT500_CLKCTL0_= BASE); + + /* Setup CTLCTL1 */ + qdev_connect_clock_in(DEVICE(&s->clkctl1), "sysclk", s->sysclk); + sysbus_realize_and_unref(SYS_BUS_DEVICE(DEVICE(&s->clkctl1)), errp); + sysbus_mmio_map(SYS_BUS_DEVICE(DEVICE(&s->clkctl1)), 0, RT500_CLKCTL1_= BASE); + + /* Setup FlexSPI */ + for (int i =3D 0; i < RT500_FLEXSPI_NUM; i++) { + static const uint32_t addr[] =3D { + RT500_FLEXSPI0_BASE, RT500_FLEXSPI1_BASE + }; + static const uint32_t mmap_base[] =3D { + MMAP_FLEXSPI0_BASE, MMAP_FLEXSPI1_BASE + }; + static const uint32_t mmap_size[] =3D { + MMAP_FLEXSPI0_SIZE, MMAP_FLEXSPI1_SIZE, + }; + DeviceState *ds =3D DEVICE(&s->flexspi[i]); + + qdev_prop_set_uint32(ds, "mmap_size", mmap_size[i]); + sysbus_realize_and_unref(SYS_BUS_DEVICE(ds), errp); + sysbus_mmio_map(SYS_BUS_DEVICE(ds), 0, addr[i]); + sysbus_mmio_map(SYS_BUS_DEVICE(ds), 1, mmap_base[i]); + } + + /* Setup reset controllers */ + for (int i =3D 0; i < RT500_RSTCTL_NUM; i++) { + DeviceState *ds =3D DEVICE(&s->rstctl[i]); + static const uint32_t addr[] =3D { + RT500_RSTCTL0_BASE, RT500_RSTCTL1_BASE + }; + + sysbus_realize_and_unref(SYS_BUS_DEVICE(ds), errp); + sysbus_mmio_map(SYS_BUS_DEVICE(ds), 0, addr[i]); + } +} + +static void rt500_unrealize(DeviceState *ds) +{ + RT500State *s =3D RT500(ds); + + g_free(s->mem); +} + +static void rt500_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + + dc->realize =3D rt500_realize; + dc->unrealize =3D rt500_unrealize; + dc->desc =3D "RT500 (ARM Cortex-M33)"; +} + +static const TypeInfo rt500_types[] =3D { + { + .name =3D TYPE_RT500, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(RT500State), + .instance_init =3D rt500_init, + .class_init =3D rt500_class_init, + }, +}; + +DEFINE_TYPES(rt500_types); + diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 668135bc85..d1443e8f89 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -717,3 +717,5 @@ config RT500 bool select FLEXCOMM select RT500_CLKCTL + select FLEXSPI + select RT500_RSTCTL diff --git a/hw/arm/meson.build b/hw/arm/meson.build index fdfd083f75..d0be157092 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -63,6 +63,7 @@ arm_ss.add(when: 'CONFIG_XEN', if_true: files( 'xen-stubs.c', 'xen-pvh.c', )) +arm_ss.add(when: 'CONFIG_RT500', if_true: files('rt500.c')) =20 system_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c')) system_ss.add(when: 'CONFIG_CHEETAH', if_true: files('palm.c')) diff --git a/hw/arm/svd/meson.build b/hw/arm/svd/meson.build index 25f4917089..b7480e7d48 100644 --- a/hw/arm/svd/meson.build +++ b/hw/arm/svd/meson.build @@ -28,4 +28,8 @@ if get_option('mcux-soc-svd') run_target('svd-rt500-rstctl1', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/rt500_rstctl1.h= ', '-p', 'RSTCTL1', '-t', 'RT500_RSTCTL1']) + run_target('svd-rt500', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/rt500.h', + '-s', 'RT500', '-p', 'FLEXCOMM0', '-p', 'CLKCTL0', '-p', 'CLKCTL1', + '-p', 'FLEXSPI0', '-p', 'FLEXSPI1', '-p', 'RSTCTL0', '-p', 'RSTCTL1'= ]) endif --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687658; cv=none; d=zohomail.com; s=zohoarc; b=fm6b2bD2S7o8uV/fTrM6OgVnGbGDEmh7ckWDbXlJupe0jESViEHJW7nq1jWZECsTh+bKeVAUX/0a2AUCY8ytXUcN+ocSP8UyiN0aoItYs7MLSbI8ooW8lqKa0PbDSz8KU1vXajlgA3NhRL9hxKZk9S/eaPYmRk4glabrMeWn0Gw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687658; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QCo9xmek7WzVKGlXYZp97A3tCGxyI9d8cl8h6DAFK9k=; b=T2/D1EGgTsLTW4qcV962hKcxmEEsXLSUjRBCnbJCuarHav4gXAkuCpQX3ct7fEbZkGYpoTMDPC5nCzLLOtuiJbWGhomiTg8YHZViiaFX55FvI62+HHzmljEhqTxM+VFaui0yzLA3csDJqaoaeU5OQLZeHr4nU8G3cr7j6Z4+Aio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687658002149.3952631619061; Wed, 18 Sep 2024 12:27:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0Gx-0005Rv-1X; Wed, 18 Sep 2024 15:23:31 -0400 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 <3qSjrZgUKCuQZGbOVMUUMRK.IUSWKSa-JKbKRTUTMTa.UXM@flex--tavip.bounces.google.com>) id 1sr0Gs-00056e-3k for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:26 -0400 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3qSjrZgUKCuQZGbOVMUUMRK.IUSWKSa-JKbKRTUTMTa.UXM@flex--tavip.bounces.google.com>) id 1sr0Gq-0007Ml-Dj for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:25 -0400 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e1ce98dcafaso156242276.0 for ; Wed, 18 Sep 2024 12:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687403; x=1727292203; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QCo9xmek7WzVKGlXYZp97A3tCGxyI9d8cl8h6DAFK9k=; b=iinyZjCQTuejRDUbt0T16qB9Ta6lh6Vb+mYMdiCdo2PYSbPGL94h//1s5eeuoDhUge Z+d3uh2ieZnrgAaCgxxiqB1V7YLd5DHf2RVS6MopyC4z9WsfpfEDH5wKI4DdXsYZO4tD Gg39FKliYDLoJLE9vkFOjA+53x5vA1KJTuJuv6flhlar5vWU3P5Sdfo+q+f0hGx/JLup ANdPc1QMdJ1Kcj4uRnkdPaaBggy1O740HjkVsfd3TRe+kxiMH+Tkxir4T5RBLEIqXTSH ELRfCNSFXD4Yznr7w2Au7dl+sqnENV7jmU8OQRwP1ZYNQ4auJL07uGTvuqZBBS14xWWk tZCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687403; x=1727292203; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QCo9xmek7WzVKGlXYZp97A3tCGxyI9d8cl8h6DAFK9k=; b=QVdbes2o8IZ/EcCJzedm8M2dU7dGXIFFQFmdZvjHnoHoCQvVX42MI1jz5sWQxCBB55 1J+mppKWedQY60siva4I2dex+rpTFsobIIgKj5KBSE5nJm2EgPn2NzB4J0uHryeb2Gp/ CBPuGVyRNUmfuxaQi2KeL5OQE5Arn6FzSUzAtOUaMBVkDDpfZM9pm8auK8n1Lkwn7EpR N9R9+KsuyhYTNcZsRFK+P1HPuBVeQCPONpXys7ny/bH28yF6QA/SadwMoPXXb4KPhhLY x4pkkbF+6Sg1mTaZWZ0KFBdvfq2e/sKSQMu8KQh4YanP01CGJCd2MIk6ol6SX9hdl1kj ZmUA== X-Gm-Message-State: AOJu0YxBYC0+AEX163p4iMMsUAEn6qC+Ksn6eZimUNvq9Gx+gFWK3nLF zKCNQ+WdOf4QlnSsMdkHC/M+JpEUuSpFKLUdM0PdPnnUexezicVkzZNTKzxvRYlgmA7zaVDz2yU B5QBrx7XToAfP3p8O8X+eB6qtvTS8jzdhkTuOGTMk+JSYzIed+DaGvHrXdXyF8v9tjV0a+evVOE 6OcoNeJ+5V3loBT2QaUUJYsuFxtg== X-Google-Smtp-Source: AGHT+IE/K1DBINNp25PoxaoZXcwpsBX5JQnt0JkDAysIV9W73EIYqJ8j4R2tK5FysQbYttZzbNSjur+0ng== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a25:aa01:0:b0:e05:6532:166 with SMTP id 3f1490d57ef6-e1daff60717mr45920276.1.1726687401837; Wed, 18 Sep 2024 12:23:21 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:42 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-15-tavip@google.com> Subject: [PATCH 14/25] hw/arm: add RT595-EVK board From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=3qSjrZgUKCuQZGbOVMUUMRK.IUSWKSa-JKbKRTUTMTa.UXM@flex--tavip.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687659477116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add basic support for the RT595-EVK board, enough to be able to run the NXP's microXpresso SDK hello world example. Signed-off-by: Octavian Purdila --- hw/arm/rt595-evk.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++ hw/arm/Kconfig | 5 ++++ hw/arm/meson.build | 1 + 3 files changed, 70 insertions(+) create mode 100644 hw/arm/rt595-evk.c diff --git a/hw/arm/rt595-evk.c b/hw/arm/rt595-evk.c new file mode 100644 index 0000000000..e5daecc8b8 --- /dev/null +++ b/hw/arm/rt595-evk.c @@ -0,0 +1,64 @@ +/* + * i.MX RT595 EVK + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "elf.h" +#include "exec/address-spaces.h" +#include "hw/loader.h" +#include "hw/sysbus.h" +#include "hw/boards.h" +#include "qemu/log.h" +#include "hw/arm/armv7m.h" +#include "hw/arm/boot.h" +#include "qapi/error.h" +#include "hw/arm/rt500.h" +#include "hw/qdev-clock.h" +#include "sysemu/reset.h" + +static void rt595_evk_reset(MachineState *ms, ShutdownCause reason) +{ + /* + * CPU reset is not done by default, we need to do it manually when the + * machine is reset. + */ + cpu_reset(first_cpu); + + qemu_devices_reset(reason); +} + +static void rt595_evk_init(MachineState *ms) +{ + RT500State *s; + Clock *sysclk; + + sysclk =3D clock_new(OBJECT(ms), "SYSCLK"); + clock_set_hz(sysclk, 200000000); + + s =3D RT500(object_new(TYPE_RT500)); + qdev_connect_clock_in(DEVICE(s), "sysclk", sysclk); + object_property_add_child(OBJECT(ms), "soc", OBJECT(s)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(s), &error_fatal); + + if (ms->kernel_filename) { + armv7m_load_kernel(ARM_CPU(first_cpu), ms->kernel_filename, 0, 0); + } +} + +static void rt595_evk_machine_init(MachineClass *mc) +{ + mc->desc =3D "RT595 EVK Machine (ARM Cortex-M33)"; + mc->init =3D rt595_evk_init; + mc->reset =3D rt595_evk_reset; + + mc->ignore_memory_transaction_failures =3D true; +} + +DEFINE_MACHINE("rt595-evk", rt595_evk_machine_init); diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index d1443e8f89..6720a41f65 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -719,3 +719,8 @@ config RT500 select RT500_CLKCTL select FLEXSPI select RT500_RSTCTL + +config RT595_EVK + bool + default y + select RT500 diff --git a/hw/arm/meson.build b/hw/arm/meson.build index d0be157092..f8c227c633 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -64,6 +64,7 @@ arm_ss.add(when: 'CONFIG_XEN', if_true: files( 'xen-pvh.c', )) arm_ss.add(when: 'CONFIG_RT500', if_true: files('rt500.c')) +arm_ss.add(when: 'CONFIG_RT595_EVK', if_true: files('rt595-evk.c')) =20 system_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c')) system_ss.add(when: 'CONFIG_CHEETAH', if_true: files('palm.c')) --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687821; cv=none; d=zohomail.com; s=zohoarc; b=A1Ta9QWTbGEX79qWI7TaXfssMhetLI5b4s0nH3FipuB8v/mOi/ElahKQ+gi+2Nx1VumlRXWfU1QWXrrbWJ458JcBVkHk0GP3WPiVbGCHLxmbdt77ofPSFJfX2vqRHveG3C4sGnk90JcsDwG61wzz/8kzhVK7PMWCOZbPuQJdEo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687821; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LH2iO35jx1TQ4g6EFz+L7zqP2G1PAY0VCA+0NbB5ci8=; b=UO5HG3S87a8iEfm88NB5vPVG2GIfozZ+lDRblM5MFDjzC5MsHv1mFmuN1TD3ZYd4b6+b7vuqvfDmzZIXVCf+ZC9nmqmsb7O9fy8HWpuLldi9s3hEydW/L+g15CsHW1pNRfLcfxhtMPoIJ0uaiPobZEF4MTbdOrByRYHpoHBI5+k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687821018246.71260355101435; Wed, 18 Sep 2024 12:30:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0H1-0005jm-Db; Wed, 18 Sep 2024 15:23:35 -0400 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 <3qyjrZgUKCuYbIdQXOWWOTM.KWUYMUc-LMdMTVWVOVc.WZO@flex--tavip.bounces.google.com>) id 1sr0Gu-0005Io-Va for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:29 -0400 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3qyjrZgUKCuYbIdQXOWWOTM.KWUYMUc-LMdMTVWVOVc.WZO@flex--tavip.bounces.google.com>) id 1sr0Gs-0007Nf-C5 for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:27 -0400 Received: by mail-pf1-x449.google.com with SMTP id d2e1a72fcca58-7190c5e73cdso70487b3a.0 for ; Wed, 18 Sep 2024 12:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687405; x=1727292205; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LH2iO35jx1TQ4g6EFz+L7zqP2G1PAY0VCA+0NbB5ci8=; b=SWcgBzuyDFS1jIlrD4ukMp4WKe1YkNjY+LtgtUjbGENMxHFBJYRmL8bBJIVudVGz4b 2ICWubBkM4qDVjF6Jz3UsQ56SgWZBhi5TaCr9NIPHTb+ljSpahqrs9Fr3jgpdH9zinA0 BvIVtSGCRxFUXOlICSU3jbaoBLUb59qFOhu3omLRHDcgYem8x2c5XvUMZmiZk5CtMCzV M+kn2GQRiF1zhFCsiO+weNjzqTYSoK6JEpzxOQSJQn/JdDi1wXqnj7WTCwNVop7nFWDe HIItjQNC/+pnz1eyXPq3iYsRuZA9TvWsQup/xCBNfq2YwGvLL3UvSEbznPxn9hvphI0C 5qVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687405; x=1727292205; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LH2iO35jx1TQ4g6EFz+L7zqP2G1PAY0VCA+0NbB5ci8=; b=wzg5GsHmuE33mHWBZcKWo+lwEt+2z18zE2FUAEEzFAOZqizZ93FSGMOKRcEjlqja5n Cl9ZEl8/LwzzcRjd7ZL4M/+n2i2WK/1KEWRjoGlwE/qBp/vSCetFzsCjZcnY+JqIt+7K 1w8Q/aSxiKEBNDtMDgLEp/TzasemM31VItaDvRG/3JjXMLD52Lhkl/FTQsIEq5Bd9P3i XD1B4ELZa79pAXCmAYNGOKZpuiJ4K3FOEDYiGv2pLLPH74MCpFt7x2fUXvFH1evH0bIy LlNFGnIVw30RrvFPBKDDKiRuDoHlg+IK66J0PPRd14TcoTWtPKyJLzZMBjbE4ul6eTkE zvpA== X-Gm-Message-State: AOJu0YxbmFdJm809Hp7NAoaBzp8j36C2ViI44jXnZeA5GVAz0fguB19j 9lqP85K6WwMi8q3mIRqxRrs/EjuTUq/XWPW/j/q+5wz9v3NphgBHt06IcJEU9feCu4vMEkTJOEv yYWlagrgXWMCvpv8Rv6c31YM1jemqiHWtpiXlf1XEQjzGET0fQ0PQHmvs3xrJK+0BaEZv+fYNVe Yi4eZPiu8Uv+vL3zsVkita3kG/GQ== X-Google-Smtp-Source: AGHT+IEjoG7zUr2P2Fy4LWtZgZy8Y1sFKzhVgMbcwUQWX/mPhvM6Zr0Z3hH6QtqK5TNvxJMI/PT+shKS9Q== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a05:6a00:6f28:b0:70e:9de1:992e with SMTP id d2e1a72fcca58-71926060114mr60644b3a.1.1726687403885; Wed, 18 Sep 2024 12:23:23 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:43 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-16-tavip@google.com> Subject: [PATCH 15/25] tests/qtest: add register access macros and functions From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::449; envelope-from=3qyjrZgUKCuYbIdQXOWWOTM.KWUYMUc-LMdMTVWVOVc.WZO@flex--tavip.bounces.google.com; helo=mail-pf1-x449.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687822159116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add utility macros for accessing register or register bit fields in tests, e.g.: REG32_WRITE(FLEXCOMM, PSELID, persel); g_assert(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL) =3D=3D persel); Signed-off-by: Octavian Purdila --- tests/qtest/reg-utils.h | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/qtest/reg-utils.h diff --git a/tests/qtest/reg-utils.h b/tests/qtest/reg-utils.h new file mode 100644 index 0000000000..e09aaf3333 --- /dev/null +++ b/tests/qtest/reg-utils.h @@ -0,0 +1,70 @@ +/* + * Register access utilities for device tests. + * + * Copyright (C) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#ifndef _REG_UTILS_H +#define _REG_UTILS_H + +#include "libqtest-single.h" +#include "hw/registerfields.h" + +#ifdef DEBUG_REG +#define debug(fmt, args...) fprintf(stderr, fmt, ## args) +#else +#define debug(fmt, args...) +#endif + +#define _REG_OFF(mod, reg) (A_##mod##_##reg) + +#define REG32_READ(mod, reg) \ + ({ \ + uint32_t value; \ + value =3D readl(mod##_BASE + _REG_OFF(mod, reg)); \ + debug("[%s] -> %08x\n", #reg, value); \ + value; \ + }) + +#define REG32_WRITE(mod, reg, value) \ + do { \ + debug("[%s] <- %08x\n", #reg, value); \ + writel(mod##_BASE + _REG_OFF(mod, reg), value); \ + } while (0) + +#define REG_FIELD_VAL(v, mod, reg, field) \ + FIELD_EX32(v, mod##_##reg, field) \ + +#define REG32_READ_FIELD(mod, reg, field) \ + REG_FIELD_VAL(REG32_READ(mod, reg), mod, reg, field) + +#define REG32_WRITE_FIELD(mod, reg, field, val) \ + do { \ + uint32_t _tmp =3D REG32_READ(mod, reg); \ + _tmp =3D FIELD_DP32(_tmp, mod##_##reg, field, val); \ + REG32_WRITE(mod, reg, _tmp); \ + } while (0) + +#define REG32_WRITE_FIELD_NOUPDATE(mod, reg, field, val) \ + do { \ + uint32_t _tmp =3D FIELD_DP32(0, mod##_##reg, field, val); \ + REG32_WRITE(mod, reg, _tmp); \ + } while (0) + +#define WAIT_REG32_FIELD(ns, mod, reg, field, val) \ + do { \ + clock_step(ns); \ + g_assert_cmpuint(REG32_READ_FIELD(mod, reg, field), =3D=3D, val); = \ + } while (0) + +#define REG32_READ_FAIL(mod, reg) \ + readl_fail(mod##_BASE + _REG_OFF(mod, reg)) + +#define REG32_WRITE_FAIL(mod, reg, value) \ + writel_fail(mod##_BASE + _REG_OFF(mod, reg), value) + +#endif /* _REG_UTILS_H */ --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687561; cv=none; d=zohomail.com; s=zohoarc; b=LEG2UUnnyJejXXTbBKi2X7zQ3TfAoiTlk+PswVwtJe85nOCWiIQESmxA19YGaZo/d82GQ5Zllnio+E5eHLe3xl0v9twT9pehMmxDzgkJNcn7bTZnGpUulwxeB/x0BpxfwUWDtppShRQDS8MZBbLMkCxFsth0HTp4aIHvC0V51KE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687561; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zkqCq3UBOk2L0o2tmmbXwYQ/qvmJvwtlw+/zSEQNzWA=; b=Az7SlfjKOe7/+wyvmjRbXybeSUY45rLlq9BT6pVG/k0uOmaYHazbeb3UBqADtfdgneUbkxgPetiUpBlnsLA04l2VK2/mTuki3CJl8R/NDTcrDmRCUH/ApkNwUXUqGsbRpoXS0V8/9hiLlktJMze1oNY1u5LzY0rKGDWzlSBmsgk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687561517975.919460672678; Wed, 18 Sep 2024 12:26:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0H3-0005ua-RB; Wed, 18 Sep 2024 15:23:37 -0400 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 <3rSjrZgUKCugdKfSZQYYQVO.MYWaOWe-NOfOVXYXQXe.YbQ@flex--tavip.bounces.google.com>) id 1sr0Gz-0005e0-Ty for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:34 -0400 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3rSjrZgUKCugdKfSZQYYQVO.MYWaOWe-NOfOVXYXQXe.YbQ@flex--tavip.bounces.google.com>) id 1sr0Gw-0007OI-SN for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:33 -0400 Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-7db0c10238eso243a12.1 for ; Wed, 18 Sep 2024 12:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687407; x=1727292207; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=zkqCq3UBOk2L0o2tmmbXwYQ/qvmJvwtlw+/zSEQNzWA=; b=GUrodj3Ss+XC+4y9ux3iEhUWHNcJXyTpCK2grQI8ff/c23if+7QzZU7EAeU4gP0Slp MdRwZX8bWFQUsFEmxcPDud1pihuN59DZc0OXzE+xjTgXIWhIFwmIPDh0WclGbeZdwa2R o9QZE/KjpBcOOjYr/u976y+8ctPch2MTH603Mtcus/TapkgrHIfSFIkVV7EyJ1Abr3pY 5NBvZhHLF4eQ5EsPzpaZfR3QfKTeix6p9D3kMwDsFo12fobwVBITCWlXjxTJfjzSi96B k4a9U/KUSkwVL5wKqMS0eBIjClHQu5RdE81/gm4IpAzFA/P+rW8JSRuTeyoRu5xpACFg AXOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687407; x=1727292207; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zkqCq3UBOk2L0o2tmmbXwYQ/qvmJvwtlw+/zSEQNzWA=; b=kFJIFj8eh5e0jUL6dkRWg6nxNK4ruwBHmFw8KS+JD7Pd12ROmwC5Yipb2t9PxP4Ns7 6ViRZhhEcsn0k4XIxJzoMg/udoF+plGxsFpiPQq5Bx3clgBu8nhgnwPGl1iCrNDQhYWn pSMpSLZYt6uL24A1ritEgqHoOmVneyKB6uHeSWQAsoGGdyhCedlZGzWqrcVR4eKZGwHM ohcJNoh8XDBqenlsqeWBgpHacwIROncqJrwrjChyAkJmVIiaX6T9N0/Y8n5/XHxRr/p2 51fygYM80Ajio00dOq72oQVqdtABFxlb/WEKFP1fEY/VLlgvcCEKBICL7ZNghc4DKHg7 BTJA== X-Gm-Message-State: AOJu0YzTkeK/2Mymrx9LMHrWBDUrbC+eOqKDEvQPn3fEt9YUPYEgseno fnoh9c8UMe3q2k41gxwix5zWKanTcmkZ6fknlG6pQzeRcS3Y1rXprAUdgPsjhCLYte4kV3KNQ9K HQKBViDtSzK0Mw5JnNwS6Ivsw2Olnkai3A308Pgtl3ninWOXadGpQesWCEn4KPCkADaF+yPLyl6 YQfZld9MUFB8dsbFtNamywsLtyOQ== X-Google-Smtp-Source: AGHT+IFFnTJnAHcDVQHG9k5Fbg6XW/RStSCi8m3xgHv3+kPEOAQhOeU6Mrf6t7YEgzR1PNAkRWCvKUqwvw== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a63:1916:0:b0:7a1:f561:8c99 with SMTP id 41be03b00d2f7-7db2f8517dbmr37036a12.6.1726687405779; Wed, 18 Sep 2024 12:23:25 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:44 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-17-tavip@google.com> Subject: [PATCH 16/25] system/qtest: add APIS to check for memory access failures From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::549; envelope-from=3rSjrZgUKCugdKfSZQYYQVO.MYWaOWe-NOfOVXYXQXe.YbQ@flex--tavip.bounces.google.com; helo=mail-pg1-x549.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687563224116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add read*/write*_fail qtest APIs to check for memory access failures. Signed-off-by: Octavian Purdila --- tests/qtest/libqtest-single.h | 92 +++++++++++++++++++++++++++++++++++ tests/qtest/libqtest.h | 76 +++++++++++++++++++++++++++++ system/qtest.c | 44 ++++++++++------- tests/qtest/libqtest.c | 73 ++++++++++++++++++++++++++- 4 files changed, 265 insertions(+), 20 deletions(-) diff --git a/tests/qtest/libqtest-single.h b/tests/qtest/libqtest-single.h index 851724cbcb..c22037c8b2 100644 --- a/tests/qtest/libqtest-single.h +++ b/tests/qtest/libqtest-single.h @@ -265,6 +265,98 @@ static inline uint64_t readq(uint64_t addr) return qtest_readq(global_qtest, addr); } =20 +/** + * writeb_fail: + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes an 8-bit value to memory expecting a failure. + */ +static inline void writeb_fail(uint64_t addr, uint8_t value) +{ + qtest_writeb_fail(global_qtest, addr, value); +} + +/** + * writew_fail: + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes a 16-bit value to memory expecting a failure. + */ +static inline void writew_fail(uint64_t addr, uint16_t value) +{ + qtest_writew_fail(global_qtest, addr, value); +} + +/** + * writel_fail: + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes a 32-bit value to memory expecting a failure. + */ +static inline void writel_fail(uint64_t addr, uint32_t value) +{ + qtest_writel_fail(global_qtest, addr, value); +} + +/** + * writeq_fail: + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes a 64-bit value to memory expecting a failure. + */ +static inline void writeq_fail(uint64_t addr, uint64_t value) +{ + qtest_writeq_fail(global_qtest, addr, value); +} + +/** + * readb_fail: + * @addr: Guest address to read from. + * + * Reads an 8-bit value from memory expecting a failure. + */ +static inline void readb_fail(uint64_t addr) +{ + qtest_readb_fail(global_qtest, addr); +} + +/** + * readw_fail: + * @addr: Guest address to read from. + * + * Reads a 16-bit value from memory expecting a failure. + */ +static inline void readw_fail(uint64_t addr) +{ + qtest_readw_fail(global_qtest, addr); +} + +/** + * readl_fail: + * @addr: Guest address to read from. + * + * Reads a 32-bit value from memory expecting a failure. + */ +static inline void readl_fail(uint64_t addr) +{ + qtest_readl_fail(global_qtest, addr); +} + +/** + * readq_fail: + * @addr: Guest address to read from. + * + * Reads a 64-bit value from memory expecting a failure. + */ +static inline void readq_fail(uint64_t addr) +{ + qtest_readq_fail(global_qtest, addr); +} + /** * memread: * @addr: Guest address to read from. diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index beb96b18eb..f9bbeb2e60 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -549,6 +549,82 @@ uint32_t qtest_readl(QTestState *s, uint64_t addr); */ uint64_t qtest_readq(QTestState *s, uint64_t addr); =20 +/** + * qtest_writeb_fail: + * @s: #QTestState instance to operate on. + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes an 8-bit value to memory expecting a failure. + */ +void qtest_writeb_fail(QTestState *s, uint64_t addr, uint8_t value); + +/** + * qtest_writew_fail: + * @s: #QTestState instance to operate on. + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes a 16-bit value to memory expecting a failure. + */ +void qtest_writew_fail(QTestState *s, uint64_t addr, uint16_t value); + +/** + * qtest_writel_fail: + * @s: #QTestState instance to operate on. + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes a 32-bit value to memory expecting a failure. + */ +void qtest_writel_fail(QTestState *s, uint64_t addr, uint32_t value); + +/** + * qtest_writeq_fail: + * @s: #QTestState instance to operate on. + * @addr: Guest address to write to. + * @value: Value being written. + * + * Writes a 64-bit value to memory expecting a failure. + */ +void qtest_writeq_fail(QTestState *s, uint64_t addr, uint64_t value); + +/** + * qtest_readb_fail: + * @s: #QTestState instance to operate on. + * @addr: Guest address to read from. + * + * Reads an 8-bit value from memory expecting a failure. + */ +void qtest_readb_fail(QTestState *s, uint64_t addr); + +/** + * qtest_readw_fail: + * @s: #QTestState instance to operate on. + * @addr: Guest address to read from. + * + * Reads a 16-bit value from memory expecting a failure. + */ +void qtest_readw_fail(QTestState *s, uint64_t addr); + +/** + * qtest_readl_fail: + * @s: #QTestState instance to operate on. + * @addr: Guest address to read from. + * + * Reads a 32-bit value from memory expecting a failure. + */ +void qtest_readl_fail(QTestState *s, uint64_t addr); + +/** + * qtest_readq_fail: + * @s: #QTestState instance to operate on. + * @addr: Guest address to read from. + * + * Reads a 64-bit value from memory expecting a failure. + */ +void qtest_readq_fail(QTestState *s, uint64_t addr); + /** * qtest_memread: * @s: #QTestState instance to operate on. diff --git a/system/qtest.c b/system/qtest.c index 12703a2045..95bb80a2bc 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -514,26 +514,30 @@ static void qtest_process_command(CharBackend *chr, g= char **words) =20 if (words[0][5] =3D=3D 'b') { uint8_t data =3D value; - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIE= D, - &data, 1); + ret =3D address_space_write(first_cpu->as, addr, + MEMTXATTRS_UNSPECIFIED, &data, 1); } else if (words[0][5] =3D=3D 'w') { uint16_t data =3D value; tswap16s(&data); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIE= D, - &data, 2); + ret =3D address_space_write(first_cpu->as, addr, + MEMTXATTRS_UNSPECIFIED, &data, 2); } else if (words[0][5] =3D=3D 'l') { uint32_t data =3D value; tswap32s(&data); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIE= D, - &data, 4); + ret =3D address_space_write(first_cpu->as, addr, + MEMTXATTRS_UNSPECIFIED, &data, 4); } else if (words[0][5] =3D=3D 'q') { uint64_t data =3D value; tswap64s(&data); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIE= D, - &data, 8); + ret =3D address_space_write(first_cpu->as, addr, + MEMTXATTRS_UNSPECIFIED, &data, 8); } qtest_send_prefix(chr); - qtest_send(chr, "OK\n"); + if (ret =3D=3D MEMTX_OK) { + qtest_send(chr, "OK\n"); + } else { + qtest_send(chr, "FAIL\n"); + } } else if (strcmp(words[0], "readb") =3D=3D 0 || strcmp(words[0], "readw") =3D=3D 0 || strcmp(words[0], "readl") =3D=3D 0 || @@ -548,26 +552,30 @@ static void qtest_process_command(CharBackend *chr, g= char **words) =20 if (words[0][4] =3D=3D 'b') { uint8_t data; - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 1); + ret =3D address_space_read(first_cpu->as, addr, + MEMTXATTRS_UNSPECIFIED, &data, 1); value =3D data; } else if (words[0][4] =3D=3D 'w') { uint16_t data; - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 2); + ret =3D address_space_read(first_cpu->as, addr, + MEMTXATTRS_UNSPECIFIED, &data, 2); value =3D tswap16(data); } else if (words[0][4] =3D=3D 'l') { uint32_t data; - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 4); + ret =3D address_space_read(first_cpu->as, addr, + MEMTXATTRS_UNSPECIFIED, &data, 4); value =3D tswap32(data); } else if (words[0][4] =3D=3D 'q') { - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &value, 8); + ret =3D address_space_read(first_cpu->as, addr, + MEMTXATTRS_UNSPECIFIED, &value, 8); tswap64s(&value); } qtest_send_prefix(chr); - qtest_sendf(chr, "OK 0x%016" PRIx64 "\n", value); + if (ret =3D=3D MEMTX_OK) { + qtest_sendf(chr, "OK 0x%016" PRIx64 "\n", value); + } else { + qtest_sendf(chr, "FAIL\n"); + } } else if (strcmp(words[0], "read") =3D=3D 0) { g_autoptr(GString) enc =3D NULL; uint64_t addr, len; diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 9d07de1fbd..4055d6b953 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -666,7 +666,7 @@ static GString *qtest_client_socket_recv_line(QTestStat= e *s) return line; } =20 -static gchar **qtest_rsp_args(QTestState *s, int expected_args) +static gchar **_qtest_rsp_args(QTestState *s, int expected_args, bool fail) { GString *line; gchar **words; @@ -700,7 +700,11 @@ redo: } =20 g_assert(words[0] !=3D NULL); - g_assert_cmpstr(words[0], =3D=3D, "OK"); + if (fail) { + g_assert_cmpstr(words[0], =3D=3D, "FAIL"); + } else { + g_assert_cmpstr(words[0], =3D=3D, "OK"); + } =20 for (i =3D 0; i < expected_args; i++) { g_assert(words[i] !=3D NULL); @@ -709,6 +713,11 @@ redo: return words; } =20 +static gchar **qtest_rsp_args(QTestState *s, int expected_args) +{ + return _qtest_rsp_args(s, expected_args, false); +} + static void qtest_rsp(QTestState *s) { gchar **words =3D qtest_rsp_args(s, 0); @@ -716,6 +725,13 @@ static void qtest_rsp(QTestState *s) g_strfreev(words); } =20 +static void qtest_rsp_fail(QTestState *s) +{ + gchar **words =3D _qtest_rsp_args(s, 0, true); + + g_strfreev(words); +} + static int qtest_query_target_endianness(QTestState *s) { gchar **args; @@ -1103,6 +1119,13 @@ static void qtest_write(QTestState *s, const char *c= md, uint64_t addr, qtest_rsp(s); } =20 +static void qtest_write_fail(QTestState *s, const char *cmd, uint64_t addr, + uint64_t value) +{ + qtest_sendf(s, "%s 0x%" PRIx64 " 0x%" PRIx64 "\n", cmd, addr, value); + qtest_rsp_fail(s); +} + void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value) { qtest_write(s, "writeb", addr, value); @@ -1123,6 +1146,26 @@ void qtest_writeq(QTestState *s, uint64_t addr, uint= 64_t value) qtest_write(s, "writeq", addr, value); } =20 +void qtest_writeb_fail(QTestState *s, uint64_t addr, uint8_t value) +{ + qtest_write_fail(s, "writeb", addr, value); +} + +void qtest_writew_fail(QTestState *s, uint64_t addr, uint16_t value) +{ + qtest_write_fail(s, "writew", addr, value); +} + +void qtest_writel_fail(QTestState *s, uint64_t addr, uint32_t value) +{ + qtest_write_fail(s, "writel", addr, value); +} + +void qtest_writeq_fail(QTestState *s, uint64_t addr, uint64_t value) +{ + qtest_write_fail(s, "writeq", addr, value); +} + static uint64_t qtest_read(QTestState *s, const char *cmd, uint64_t addr) { gchar **args; @@ -1138,6 +1181,12 @@ static uint64_t qtest_read(QTestState *s, const char= *cmd, uint64_t addr) return value; } =20 +static void qtest_read_fail(QTestState *s, const char *cmd, uint64_t addr) +{ + qtest_sendf(s, "%s 0x%" PRIx64 "\n", cmd, addr); + qtest_rsp_fail(s); +} + uint8_t qtest_readb(QTestState *s, uint64_t addr) { return qtest_read(s, "readb", addr); @@ -1158,6 +1207,26 @@ uint64_t qtest_readq(QTestState *s, uint64_t addr) return qtest_read(s, "readq", addr); } =20 +void qtest_readb_fail(QTestState *s, uint64_t addr) +{ + qtest_read_fail(s, "readb", addr); +} + +void qtest_readw_fail(QTestState *s, uint64_t addr) +{ + qtest_read_fail(s, "readw", addr); +} + +void qtest_readl_fail(QTestState *s, uint64_t addr) +{ + qtest_read_fail(s, "readl", addr); +} + +void qtest_readq_fail(QTestState *s, uint64_t addr) +{ + qtest_read(s, "readq", addr); +} + static int hex2nib(char ch) { if (ch >=3D '0' && ch <=3D '9') { --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687489; cv=none; d=zohomail.com; s=zohoarc; b=mwFf4MPAoZII0pWutErPY1Z0hOYQHOkgBbPjICXPkXj0Wukv/JXJU6i2SaQGoB8yeNx24pfFlHCwIOSbkfVCZaTzHiD/k2jj8bvwuhA2bGJFS85R3ZUIVTfUPr6GAr5xy2n8iMCzOryrBaqcEBsS7DbjsJlZaq8kkXp7uxSel28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687489; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HmWuRxg44yVQ0HmHhf9/Qn51jwseOfLAmYdAlCa+aBg=; b=bdXtIuqaclErCdH4MLeTRV+E1QIud/A4q5yn/Q3STPuiBrV8Cq1Vq7f/B4HROBnOe9Nmi/QobwxC9RzbECEprix3/GGDFzqBsa32afgK9RAiaXSyioG85oTT7BVKE5yHf3ZJfMLSAzCdQS7tI0Km0WCKgiSIw64t5JZSCYha6YQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687489056866.629492814123; Wed, 18 Sep 2024 12:24:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0H0-0005ej-FK; Wed, 18 Sep 2024 15:23:34 -0400 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 <3ryjrZgUKCuofMhUbSaaSXQ.OaYcQYg-PQhQXZaZSZg.adS@flex--tavip.bounces.google.com>) id 1sr0Gy-0005XD-9P for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:32 -0400 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3ryjrZgUKCuofMhUbSaaSXQ.OaYcQYg-PQhQXZaZSZg.adS@flex--tavip.bounces.google.com>) id 1sr0Gw-0007OY-KT for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:32 -0400 Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-2d8759255d4so200065a91.3 for ; Wed, 18 Sep 2024 12:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687409; x=1727292209; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HmWuRxg44yVQ0HmHhf9/Qn51jwseOfLAmYdAlCa+aBg=; b=b04drPva2CUU7OQDCreihGEaMgqW4Jm/PGYoCO25zJLd5K/09sIgo8UpgyDbFja5jr seJ0JVwo1FsVCyBpyLFtIziyBo20vF4yEb/bE5HL5Gd7Zae7H6ocRa/19UzBi0/0r2bE DoUGcxQNJzOskz7jJsKkchjK3OC7EbNhujU/Wd4KNM7TpU/j7FlZ9ydMlOvhXn5ZwOYg P6ie7XxADsXe9joed+HfUlQs+vAC8U2Yb0Wo+O1ntAFCreSIH4Fzi5TlKRxsXdT3HkQ8 /1J0JkjR4zwHcI0GqHtO2RwRSIstIH2Kp7c+JHp2Oo0UER41l0Hx8igcUvBi5Q83vTPo tv8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687409; x=1727292209; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HmWuRxg44yVQ0HmHhf9/Qn51jwseOfLAmYdAlCa+aBg=; b=runJSs0vFOwWaavRCsk62I7/m1lcBVrT9yuN1eODMRWtAVvjO9fqAWuB2O0fU7dk8n Klz0RmjlwyZyAewTqUvNIculktEP5r/PI+Nd3y4YGu0sfwGm9KEJONyq1L4h/rrvO825 0BlHdvuInp2ZSVyRilGK/H7QIhPqOkPzhuPjaBlH3npwnXAGl/WxEE4XRpLOBkObhDta Ga6HRbRvNMeukSekPCd4O4ufZWTcNz7s5dagnwU/oyZ9c4dSH3ODtmg6ypOO/nJqLgz7 na0wsL6n7OlbBiR+ljpO8abkSTdIz5DXYLpLso2HK1XHxNvaPpelpmqZALMDtXhWkWKE RDlg== X-Gm-Message-State: AOJu0YwuFoJ4JaXMk8LYCDOlx/DZ4+ehFPKJnkZd7I/vUKVCAxSCo2mo 0LbuNbUOlzHBAFxsqdmxnJJjEpb5fmeXRjtfKE0IMLgxSlTytIepVSRjRf/sSkLA/e1jVfdvyPw LQ5upNhCiYKfryEVV7g4iWInjWxQAxZDHqGFlIdO+r2jtxjzSsl0vXCiOjQLL6Wgi/35wsbBByY 1yO7NT2exS6D8sAbttz2r+bFwSQQ== X-Google-Smtp-Source: AGHT+IFCuELIg7JeqLtjD4NokVRS2wPk3+ZOc7k9/OwlvjKyjaUuRs3Q7rCruWU+rk1pc5GJRyXY4UUg/g== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:90a:ebc9:b0:2d8:8e8a:2b06 with SMTP id 98e67ed59e1d1-2dbb9ebabf8mr66302a91.4.1726687407717; Wed, 18 Sep 2024 12:23:27 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:45 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-18-tavip@google.com> Subject: [PATCH 17/25] tests/qtest: add flexcomm tests From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1049; envelope-from=3ryjrZgUKCuofMhUbSaaSXQ.OaYcQYg-PQhQXZaZSZg.adS@flex--tavip.bounces.google.com; helo=mail-pj1-x1049.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687490986116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add flexcomm function selection unit tests. Signed-off-by: Octavian Purdila --- tests/qtest/flexcomm-test.c | 82 +++++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 1 + 2 files changed, 83 insertions(+) create mode 100644 tests/qtest/flexcomm-test.c diff --git a/tests/qtest/flexcomm-test.c b/tests/qtest/flexcomm-test.c new file mode 100644 index 0000000000..ffbee8bfb8 --- /dev/null +++ b/tests/qtest/flexcomm-test.c @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/main-loop.h" +#include "exec/memory.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" + +#include "hw/misc/flexcomm.h" +#include "hw/arm/svd/flexcomm.h" +#include "hw/arm/svd/rt500.h" +#include "reg-utils.h" + +#define FLEXCOMM_BASE RT500_FLEXCOMM0_BASE + +static void select_test(gconstpointer data) +{ + static const unsigned persel[] =3D { + FLEXCOMM_PERSEL_USART, + FLEXCOMM_PERSEL_SPI, + FLEXCOMM_PERSEL_I2C, + }; + + g_assert(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL) =3D=3D 0); + + /* no register access until a function is selected */ + readl_fail(FLEXCOMM_BASE); + writel_fail(FLEXCOMM_BASE, 0); + + for (int i =3D 0; i < ARRAY_SIZE(persel); i++) { + + REG32_WRITE(FLEXCOMM, PSELID, persel[i]); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL), =3D= =3D, + persel[i]); + + /* test that we can access function registers */ + writel(FLEXCOMM_BASE, 0xabcd); + readl(FLEXCOMM_BASE); + } + + /* try to select something invalid */ + REG32_WRITE(FLEXCOMM, PSELID, 7); + /* check for no function selected */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL), =3D=3D, 0= ); + + /* now select and lock USART */ + REG32_WRITE(FLEXCOMM, PSELID, + FIELD_DP32(FLEXCOMM_PERSEL_USART, FLEXCOMM_PSELID, LOCK, 1= )); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL), =3D=3D, + FLEXCOMM_PERSEL_USART); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, LOCK), =3D=3D, 1); + + /* try to change the selection to spi */ + REG32_WRITE(FLEXCOMM, PSELID, FLEXCOMM_PERSEL_SPI); + /* it should still be locked USART */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL), =3D=3D, + FLEXCOMM_PERSEL_USART); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, LOCK), =3D=3D, 1); +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + + qtest_add_data_func("/flexcomm/select", NULL, select_test); + qtest_start("-M rt595-evk"); + ret =3D g_test_run(); + qtest_end(); + + return ret; +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index fc852f3d8b..cb35778ce6 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -231,6 +231,7 @@ qtests_arm =3D \ (config_all_devices.has_key('CONFIG_FSI_APB2OPB_ASPEED') ? ['aspeed_fsi-= test'] : []) + \ (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') and config_all_devices.has_key('CONFIG_DM163')? ['dm163-test'] : []) + \ + (config_all_devices.has_key('CONFIG_FLEXCOMM')? ['flexcomm-test'] : []) = + \ ['arm-cpu-features', 'boot-serial-test'] =20 --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687515; cv=none; d=zohomail.com; s=zohoarc; b=g3Ns+dlN8cre6dcIFjrRhVL2iazTi1RGNKjza6AoDP4sA66A0dKfxB+mudzZsR0JOB43WI2UOa25mNLWWplRfIBvI2ai3arxJgoAgNYsQ4nEsh5yyCPTbI+lVp3whmIldyKQMQGKHfPFdQl5wz7F6tZn4oU+iXH8XZtr5zYHN7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687515; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qQDUuF9XVaipz2hDBHHb91aQ5InNBlB0RUH5QeH9jBY=; b=iCJDoBYTEUNtbfN04U2Knw5KokpoQA/Q308KBW9vtVachnHEqkpD4anXCCy+MpCyQA5KMyoglFBq9cyGIK3UmVmxMUNpm7Utkm+BM47+++q4zHmvjroubs+3468/zPEdAstkDr6OQYiAYZUPxh84BewbnNkamWomt67AOj4gB7k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687515671786.9923067817043; Wed, 18 Sep 2024 12:25:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0H5-00062N-O3; Wed, 18 Sep 2024 15:23:39 -0400 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 <3sijrZgUKCu0iPkXeVddVaT.RdbfTbj-STkTacdcVcj.dgV@flex--tavip.bounces.google.com>) id 1sr0H1-0005kD-EQ for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:35 -0400 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3sijrZgUKCu0iPkXeVddVaT.RdbfTbj-STkTacdcVcj.dgV@flex--tavip.bounces.google.com>) id 1sr0Gz-0007P3-9p for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:35 -0400 Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-2d86e9da90cso170602a91.2 for ; Wed, 18 Sep 2024 12:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687411; x=1727292211; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qQDUuF9XVaipz2hDBHHb91aQ5InNBlB0RUH5QeH9jBY=; b=kCNmi6uI1F5HI27yM70fod3tE2Zu83gaxNTDYkB6C7i6cI3xh6mmbHmkl7xtqycYap SyKChQ4U7D6lb2Mbcl8nD+p8nCzBI86JBPr5YlxlEKotvpEgF+rS2JEqg7rCrPGvcUNG EW+RfctLANhDByDp8efz7uqEYIy/dLSdTv5xQRcLOU2OEYsMXBvvlO6C4t0OUnXmeTJX EF0JXnbRqejNoph12pBrHpdrfCHZtfqNBtIiOTrt/5t9AgoKHha3nSs6ddKbO1TPe+4I qBWt9DoyiJZqK7hkjOcWYspPSg1Ua2Wev4OHSztXr+/n0+InhmWKMq309TqX+2dWHWAm FBHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687411; x=1727292211; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qQDUuF9XVaipz2hDBHHb91aQ5InNBlB0RUH5QeH9jBY=; b=N4mn2aVv0PKNOX1fvAFSe0hX0BqM0tbA6ZoJjR5burmppkLNRzhK3Lwqek6T8Vqjud /Y2QjvqCpRsMrrIe2C7QmMs3LzYOUcL5SRpxj3hCBTfVd/tVPGNs0jZ8d8KwR7gl8QNm s5uF5gHPwomMk9wASTtB8m6/KqWGxE6TedZcQlbMO6OuzbJTdxmqlp1ZNtYfGua226pz 3k8FjYVi5QIpSTYBMQX7VK/E4Zb4JXhpiPMUDv02AvICCLGUTpajAFoZ8RKhWcM6bkZ9 Q/hIO4iCTPLh65ObFsrK+kLCRQ7L+jtKm8nkDt6e9XWIuNmfY26TDe7yUKSela5InwPW Ghhw== X-Gm-Message-State: AOJu0YwAcC9G9tH3qP7t4zi9wmYrh0pIsyBwEYTlEyH7WhOVelcxFsAh z4m5Ev0oOEoojCJm64ZEYFoQsTD5/PdS7Scqa1fdvc3Rs+aEfModSKu6+oQrXAMgClW4Vc6Roo8 T+B5RICbEyDVkUTU30ahNBnfAK2sJbRP2Kd5ZTnePClr9NNF/2zZRGd5b1gtPHjAPX8XTiMWtAZ ORXHWFUkZkE1ogxwnWLIZDI3iqKA== X-Google-Smtp-Source: AGHT+IFDFMJUpZrCAEeIn+HiGIBc12KYFGqfM7gJDS2mow81LIz/WemWUpZm8v9nxPOtG0nEP4azeILagw== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:903:2305:b0:206:928c:bfd9 with SMTP id d9443c01a7336-2076e3f8db8mr13640235ad.6.1726687410096; Wed, 18 Sep 2024 12:23:30 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:46 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-19-tavip@google.com> Subject: [PATCH 18/25] tests/qtest: add flexcomm usart tests From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1049; envelope-from=3sijrZgUKCu0iPkXeVddVaT.RdbfTbj-STkTacdcVcj.dgV@flex--tavip.bounces.google.com; helo=mail-pj1-x1049.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687517210116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add flexcomm usart polling and irq unit tests. Signed-off-by: Octavian Purdila --- tests/qtest/flexcomm-usart-test.c | 316 ++++++++++++++++++++++++++++++ tests/qtest/meson.build | 3 +- 2 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/flexcomm-usart-test.c diff --git a/tests/qtest/flexcomm-usart-test.c b/tests/qtest/flexcomm-usart= -test.c new file mode 100644 index 0000000000..0ffa49dd6f --- /dev/null +++ b/tests/qtest/flexcomm-usart-test.c @@ -0,0 +1,316 @@ +/* + * Copyright (C) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include + +#include "io/channel-socket.h" +#include "qemu/config-file.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qapi/error.h" +#include "qemu/sockets.h" +#include "sysemu/sysemu.h" +#include "qemu/main-loop.h" +#include "qemu/option.h" +#include "exec/memory.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" + +#include "hw/misc/flexcomm.h" +#include "hw/arm/svd/flexcomm_usart.h" +#include "hw/arm/svd/rt500.h" +#include "reg-utils.h" + +#define FLEXCOMM_BASE RT500_FLEXCOMM0_BASE +#define FLEXCOMM_USART_BASE RT500_FLEXCOMM0_BASE +#define DEVICE_NAME "/machine/soc/flexcomm0" + +struct TestState { + QTestState *qtest; + QIOChannel *ioc; +}; + +static void polling_test(gconstpointer user_data) +{ + struct TestState *t =3D (struct TestState *)user_data; + uint32_t tmp; + char byte; + int fifo_size; + QDict *resp; + + resp =3D qmp("{\"execute\": \"system_reset\"}"); + qdict_unref(resp); + + /* select and lock USART */ + tmp =3D FIELD_DP32(FLEXCOMM_PERSEL_USART, FLEXCOMM_PSELID, LOCK, 1); + REG32_WRITE(FLEXCOMM, PSELID, tmp); + + fifo_size =3D REG32_READ_FIELD(FLEXCOMM_USART, FIFOSIZE, FIFOSIZE); + + /* enable USART */ + REG32_WRITE_FIELD(FLEXCOMM_USART, CFG, ENABLE, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, CFG, ENABLE), =3D=3D= , 1); + + /* enable TX and RX FIFO */ + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOCFG, ENABLETX, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOCFG, ENABLETX), + =3D=3D, 1); + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOCFG, ENABLERX, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOCFG, ENABLERX), + =3D=3D, 1); + + /* test writes and fifo counters wrap */ + for (int i =3D 0; i < fifo_size / 2; i++) { + /* check fifostat */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, RXFULL= ), + =3D=3D, 0); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, RXNOTE= MPTY), + =3D=3D, 0); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, TXNOTF= ULL), + =3D=3D, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, TXEMPT= Y), + =3D=3D, 1); + + REG32_WRITE(FLEXCOMM_USART, FIFOWR, 'a' + i); + qio_channel_read(t->ioc, &byte, 1, &error_abort); + g_assert_cmpuint(byte, =3D=3D, 'a' + i); + } + + /* test reads and fifo level */ + + for (int i =3D 0; i < fifo_size / 2; i++) { + byte =3D 'A' + i; + g_assert_cmpuint(qio_channel_write(t->ioc, &byte, 1, &error_abort), + =3D=3D, 1); + } + + /* wait for the RXLVL to update */ + WAIT_REG32_FIELD(1000, FLEXCOMM_USART, FIFOSTAT, RXLVL, + fifo_size / 2); + + /* check fifo stat */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, RXFULL), + =3D=3D, 0); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, RXNOTEMPTY= ), + =3D=3D, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, TXNOTFULL), + =3D=3D, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, TXEMPTY), + =3D=3D, 1); + + /* send until FIFO is full */ + for (int i =3D fifo_size / 2; i < fifo_size; i++) { + byte =3D 'A' + i; + g_assert_cmpuint(qio_channel_write(t->ioc, &byte, 1, &error_abort), + =3D=3D, 1); + } + + /* wait for the RXLVL to update */ + WAIT_REG32_FIELD(1000, FLEXCOMM_USART, FIFOSTAT, RXLVL, fifo_size); + + /* check fifo stat */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, RXFULL), + =3D=3D, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, RXNOTEMPTY= ), + =3D=3D, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, TXNOTFULL), + =3D=3D, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, TXEMPTY), + =3D=3D, 1); + + /* check read no pop */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFORDNOPOP, RXDATA), + =3D=3D, 'A'); + + /* now read from the fifo */ + for (int i =3D 0; i < fifo_size; i++) { + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFORD, RXDATA), + =3D=3D, 'A' + i); + } + + /* check fifostat */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, RXFULL), = =3D=3D, 0); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, RXNOTEMPTY= ), + =3D=3D, 0); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, TXNOTFULL), + =3D=3D, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, TXEMPTY), + =3D=3D, 1); +} + +static void irq_test(gconstpointer user_data) +{ + struct TestState *t =3D (struct TestState *)user_data; + char buf[256] =3D { 0, }; + uint32_t tmp; + QDict *resp; + + resp =3D qmp("{\"execute\": \"system_reset\"}"); + qdict_unref(resp); + + qtest_irq_intercept_out_named(t->qtest, DEVICE_NAME, + SYSBUS_DEVICE_GPIO_IRQ); + + /* select and lock FLEXCOMM_USART */ + tmp =3D FIELD_DP32(FLEXCOMM_PERSEL_USART, FLEXCOMM_PSELID, LOCK, 1); + REG32_WRITE(FLEXCOMM, PSELID, tmp); + + /* + * set RX IRQ/DMA trigger level to 4 bytes - value 3 in FIFOTRIG + * + * 0000 - Trigger when the RX FIFO has received 1 entry (is no longer = empty) + * 0001 - Trigger when the RX FIFO has received 2 entries + * 1111 - Trigger when the RX FIFO has received 16 entries (has become= full) + */ + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOTRIG, RXLVL, 3); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOTRIG, RXLVL), + =3D=3D, 3); + + /* enable RX trigger for IRQ/DMA */ + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOTRIG, RXLVLENA, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOTRIG, RXLVLENA), + =3D=3D, 1); + + /* enable RXLVL interrupt */ + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOINTENSET, RXLVL, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOINTENSET, RXLVL), + =3D=3D, 1); + + /* enable FLEXCOMM_USART */ + REG32_WRITE_FIELD(FLEXCOMM_USART, CFG, ENABLE, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, CFG, ENABLE), + =3D=3D, 1); + + /* enable TX and RX FIFO */ + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOCFG, ENABLETX, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOCFG, ENABLETX), + =3D=3D, 1); + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOCFG, ENABLERX, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOCFG, ENABLERX), + =3D=3D, 1); + + /* check interrupt status */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOINTSTAT, RXLVL), + =3D=3D, 0); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOINTSTAT, TXLVL), + =3D=3D, 0); + g_assert_false(get_irq(0)); + + /* enable TX trigger for IRQ/DMA */ + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOTRIG, TXLVLENA, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOTRIG, TXLVLENA), + =3D=3D, 1); + + /* enable irq for TX */ + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOINTENSET, TXLVL, 1); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOINTENSET, TXLVL), + =3D=3D, 1); + + /* check TX irq */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOINTSTAT, TXLVL), + =3D=3D, 1); + g_assert_true(get_irq(0)); + + /* disable irq for TX */ + REG32_WRITE_FIELD(FLEXCOMM_USART, FIFOTRIG, TXLVLENA, 0); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOTRIG, TXLVLENA), + =3D=3D, 0); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOINTSTAT, TXLVL), + =3D=3D, 0); + g_assert_false(get_irq(0)); + + /* send 3 bytes */ + g_assert_cmpuint(qio_channel_write(t->ioc, buf, 3, &error_abort), + =3D=3D, 3); + + /* check that we have 3 bytes in the fifo */ + WAIT_REG32_FIELD(1000, FLEXCOMM_USART, FIFOSTAT, RXLVL, 3); + + /* and no interrupt has been triggered yet */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOINTSTAT, RXLVL), + =3D=3D, 0); + g_assert_false(get_irq(0)); + + /* push it over the edge */ + g_assert_cmpuint(qio_channel_write(t->ioc, buf, 1, &error_abort), =3D= =3D, 1); + + /* check that we have 4 bytes in the fifo */ + WAIT_REG32_FIELD(1000, FLEXCOMM_USART, FIFOSTAT, RXLVL, 4); + + /* and the interrupt has been triggered */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOINTSTAT, RXLVL), + =3D=3D, 1); + g_assert_true(get_irq(0)); + + /* read one byte from the fifo */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFORD, RXDATA), + =3D=3D, 0); + + /* we should have 3 bytes in the FIFO */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOSTAT, RXLVL), + =3D=3D, 3); + + /* and no interrupts active */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_USART, FIFOINTSTAT, RXLVL), + =3D=3D, 0); + g_assert_false(get_irq(0)); +} + +static void close_ioc(void *ioc) +{ + qio_channel_close(ioc, NULL); +} + +int main(int argc, char **argv) +{ + int ret; + struct TestState test; + char *tmp_path =3D g_dir_make_tmp("qemu-flexcomm-usart-test.XXXXXX", N= ULL); + SocketAddress addr =3D { + .type =3D SOCKET_ADDRESS_TYPE_UNIX, + .u.q_unix.path =3D g_build_filename(tmp_path, "sock", NULL), + }; + char *args; + QIOChannelSocket *lioc; + + module_call_init(MODULE_INIT_QOM); + g_test_init(&argc, &argv, NULL); + + lioc =3D qio_channel_socket_new(); + qio_channel_socket_listen_sync(lioc, &addr, 1, &error_abort); + + qtest_add_data_func("/flexcomm-usart/polling", &test, polling_test); + qtest_add_data_func("/flexcomm-usart/irq", &test, irq_test); + + args =3D g_strdup_printf("-M rt595-evk " + "-chardev socket,id=3Dflexcomm0-usart,path=3D%s= ", + addr.u.q_unix.path); + test.qtest =3D qtest_start(args); + + qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); + test.ioc =3D QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort)= ); + g_assert(test.ioc); + qtest_add_abrt_handler(close_ioc, test.ioc); + + ret =3D g_test_run(); + + qtest_end(); + + qtest_remove_abrt_handler(test.ioc); + g_unlink(addr.u.q_unix.path); + g_free(addr.u.q_unix.path); + g_rmdir(tmp_path); + g_free(tmp_path); + g_free(args); + object_unref(OBJECT(test.ioc)); + object_unref(OBJECT(lioc)); + + return ret; +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index cb35778ce6..663e44f3c6 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -231,7 +231,7 @@ qtests_arm =3D \ (config_all_devices.has_key('CONFIG_FSI_APB2OPB_ASPEED') ? ['aspeed_fsi-= test'] : []) + \ (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') and config_all_devices.has_key('CONFIG_DM163')? ['dm163-test'] : []) + \ - (config_all_devices.has_key('CONFIG_FLEXCOMM')? ['flexcomm-test'] : []) = + \ + (config_all_devices.has_key('CONFIG_FLEXCOMM') ? ['flexcomm-test', 'flex= comm-usart-test'] : []) + \ ['arm-cpu-features', 'boot-serial-test'] =20 @@ -348,6 +348,7 @@ qtests =3D { 'virtio-net-failover': files('migration-helpers.c'), 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'), 'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'), + 'flexcomm-usart-test': [io], } =20 if vnc.found() --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687666; cv=none; d=zohomail.com; s=zohoarc; b=b2C3B7nJYGxxCYK5GJg1mXXr7Cz45rTPhrEWEgsZBAj3r5ISdvFGHZ51cNvn55d187SEgcKiOWPdJWybTRlcmRC88Lvtei72czbBQbw/EfPAUK3runwaXtBiC3RhpHuejym1VopB0J7Dg4kN2aTWvpW/N/E5Htrpj0SkOIMnMVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687666; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BasiRtQN5aAXKK780JUMkf3D1GTFkZQUDjsTNmgnDHw=; b=Grb0JgRWm9E6BnC1ngaTXYszZKxDRDLnH3CJL0AnOTcQsu8uG9UtYwLB694P5vYJWTLjccZsfRkPG3zE2wWJEsV76+GFe0CvFsNSVdM0yp0TPoK6cdezsm/Hit3X86yHkPgIuZW5gBl/fQGgWNiiBTRzOTSUKjrXO9dEJvBdTFY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172668766624370.81051567222607; Wed, 18 Sep 2024 12:27:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0H4-0005xV-FA; Wed, 18 Sep 2024 15:23:38 -0400 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 <3syjrZgUKCu4jQlYfWeeWbU.SecgUck-TUlUbdedWdk.ehW@flex--tavip.bounces.google.com>) id 1sr0H1-0005m8-R6 for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:35 -0400 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3syjrZgUKCu4jQlYfWeeWbU.SecgUck-TUlUbdedWdk.ehW@flex--tavip.bounces.google.com>) id 1sr0H0-0007PT-0V for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:35 -0400 Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-2db446a3d28so202845a91.2 for ; Wed, 18 Sep 2024 12:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687412; x=1727292212; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BasiRtQN5aAXKK780JUMkf3D1GTFkZQUDjsTNmgnDHw=; b=p3eemXqhfZCwbUzvszRaUHP7iKOrtuENZsNBLULly6tuUGMuF3QvIiS2eVfy6FZWvA iv6F4Er0MKY6c2cxubVOrSFEj0vSEySoIZZ2zvqKp4rrP5G5PrujvTg3AGnix6GGRTR7 OITM5tZAij7iDMIILmP1Bptk8NUVpMESysw3HmmXfXywSrKi288hHwR7QhvSBriR6V1u awKUW/DGQPe8lIP5jgz2q4mCJxQ7AVzW0jkiF2LjYqyKDszqibrqRHIK3o72m2CS9dJh SdGDHGZ9FdLMsfBEmOwRTP1eo+R6Aw0V7tFYGx/9qySEszfP9G2LAYYsUTqXkY4EG02Q fMlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687412; x=1727292212; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BasiRtQN5aAXKK780JUMkf3D1GTFkZQUDjsTNmgnDHw=; b=U6bMMgMwcKk02zAhZ8KK8+Hv1NZGlh+HM2gB6KQROUo4SV4keTEZOlzeQjWpB0n0vQ 8WhjsWQpMdHem9r58e8AuxiKIBJBwBFHG3KrMDHG8K3FTicmQED/4oEG8ebBtORW4e4Q t0BXGSAIzF5FFfBHOqwjnw8Wzn/vpbo/42RYEQ8cd6yXut7JEz24NTkeLPtiKRhOGoSj Nt5qw3FZUIVwTOYxFlZpXMTZdMpNau3s44DLkbOWFvQtkrbrTH8vejV1a5lIF+lZ4dAe FADoWQoix9AedfGrA6Ojwibkx2UFyxOuOWeRKGpUyWFdY7/ow1T4pbdorrrF9DPPtVWq u2oQ== X-Gm-Message-State: AOJu0YxSsNHnmk9gL3gYi4bdjOL/cN2xsyz2tFAtcFNstGrutBaZ5+xc W9eLNq71VdH93D5hq0Lex9swOsCmAurmv//cyoJtrVMXLcB+crYQGt6SGa8xspo6CrlXN5+iImk 1Jf/9cBcqX06SOEfvw3D1t0jXEUb1YmN5XOVx+kVjmRAF8/I4XHuHq4O/GR701B8VaXP6iOlQK3 QPsQY+YfkzX0B20rWtUfaqWQOtmQ== X-Google-Smtp-Source: AGHT+IE9pugV1W1gjuJk7mMtSsgn3Hz3rKDHUkp0c70pIqllMcHBraati2zSX2yJMxPbsD2VPV2Khw7cDA== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:90b:17d2:b0:2d8:e7ef:7d1e with SMTP id 98e67ed59e1d1-2dbb9f199eemr66045a91.7.1726687411869; Wed, 18 Sep 2024 12:23:31 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:47 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-20-tavip@google.com> Subject: [PATCH 19/25] hw/misc: add i2c-tester From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1049; envelope-from=3syjrZgUKCu4jQlYfWeeWbU.SecgUck-TUlUbdedWdk.ehW@flex--tavip.bounces.google.com; helo=mail-pj1-x1049.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687667782116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a simple i2c peripheral to be used for testing I2C device models. The peripheral has a fixed number of registers that can be read and written. Signed-off-by: Octavian Purdila --- include/hw/misc/i2c_tester.h | 30 ++++++++++ hw/misc/i2c_tester.c | 109 +++++++++++++++++++++++++++++++++++ hw/misc/Kconfig | 5 ++ hw/misc/meson.build | 2 + 4 files changed, 146 insertions(+) create mode 100644 include/hw/misc/i2c_tester.h create mode 100644 hw/misc/i2c_tester.c diff --git a/include/hw/misc/i2c_tester.h b/include/hw/misc/i2c_tester.h new file mode 100644 index 0000000000..f6b6491008 --- /dev/null +++ b/include/hw/misc/i2c_tester.h @@ -0,0 +1,30 @@ +/* + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_I2C_TESTER_H +#define HW_I2C_TESTER_H + +#include "qemu/osdep.h" +#include "hw/i2c/i2c.h" +#include "hw/irq.h" + +#define I2C_TESTER_NUM_REGS 0x31 + +#define TYPE_I2C_TESTER "i2c-tester" +#define I2C_TESTER(obj) OBJECT_CHECK(I2cTesterState, (obj), TYPE_I2C_TESTE= R) + +typedef struct { + I2CSlave i2c; + bool set_reg_idx; + uint8_t reg_idx; + uint8_t regs[I2C_TESTER_NUM_REGS]; +} I2cTesterState; + +#endif /* HW_I2C_TESTER_H */ diff --git a/hw/misc/i2c_tester.c b/hw/misc/i2c_tester.c new file mode 100644 index 0000000000..77ce8bf91a --- /dev/null +++ b/hw/misc/i2c_tester.c @@ -0,0 +1,109 @@ +/* + * Simple I2C peripheral for testing I2C device models. + * + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "hw/misc/i2c_tester.h" + +#include "qemu/log.h" +#include "qemu/module.h" +#include "migration/vmstate.h" + +static void i2c_tester_reset_enter(Object *o, ResetType type) +{ + I2cTesterState *s =3D I2C_TESTER(o); + + s->set_reg_idx =3D false; + s->reg_idx =3D 0; + memset(s->regs, 0, I2C_TESTER_NUM_REGS); +} + +static int i2c_tester_event(I2CSlave *i2c, enum i2c_event event) +{ + I2cTesterState *s =3D I2C_TESTER(i2c); + + if (event =3D=3D I2C_START_SEND) { + s->set_reg_idx =3D true; + } + + return 0; +} + +static uint8_t i2c_tester_rx(I2CSlave *i2c) +{ + I2cTesterState *s =3D I2C_TESTER(i2c); + + if (s->reg_idx >=3D I2C_TESTER_NUM_REGS) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid reg 0x%02x\n", __func_= _, + s->reg_idx); + return I2C_NACK; + } + + return s->regs[s->reg_idx]; +} + +static int i2c_tester_tx(I2CSlave *i2c, uint8_t data) +{ + I2cTesterState *s =3D I2C_TESTER(i2c); + + if (s->set_reg_idx) { + /* Setting the register in which the operation will be done. */ + s->reg_idx =3D data; + s->set_reg_idx =3D false; + return 0; + } + + if (s->reg_idx >=3D I2C_TESTER_NUM_REGS) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid reg 0x%02x\n", __func_= _, + s->reg_idx); + return I2C_NACK; + } + + /* Write reg data. */ + s->regs[s->reg_idx] =3D data; + + return 0; +} + +static const VMStateDescription vmstate_i2c_tester =3D { + .name =3D "i2c-tester", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_I2C_SLAVE(i2c, I2cTesterState), + VMSTATE_BOOL(set_reg_idx, I2cTesterState), + VMSTATE_UINT8(reg_idx, I2cTesterState), + VMSTATE_UINT8_ARRAY(regs, I2cTesterState, I2C_TESTER_NUM_REGS), + VMSTATE_END_OF_LIST() + } +}; + +static void i2c_tester_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + ResettableClass *rc =3D RESETTABLE_CLASS(oc); + I2CSlaveClass *isc =3D I2C_SLAVE_CLASS(oc); + + rc->phases.enter =3D i2c_tester_reset_enter; + dc->vmsd =3D &vmstate_i2c_tester; + isc->event =3D i2c_tester_event; + isc->recv =3D i2c_tester_rx; + isc->send =3D i2c_tester_tx; +} + +static const TypeInfo i2c_tester_types[] =3D { + { + .name =3D TYPE_I2C_TESTER, + .parent =3D TYPE_I2C_SLAVE, + .instance_size =3D sizeof(I2cTesterState), + .class_init =3D i2c_tester_class_init + }, +}; + +DEFINE_TYPES(i2c_tester_types); diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 4b688aead2..3e93c12c8e 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -213,6 +213,11 @@ config IOSB config XLNX_VERSAL_TRNG bool =20 +config I2C_TESTER + bool + default y if TEST_DEVICES + depends on I2C + config FLEXCOMM bool select I2C diff --git a/hw/misc/meson.build b/hw/misc/meson.build index faaf2671ba..4f22231fa3 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -158,6 +158,8 @@ system_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('= sbsa_ec.c')) # HPPA devices system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c')) =20 +system_ss.add(when: 'CONFIG_I2C_TESTER', if_true: files('i2c_tester.c')) + system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm.c')) system_ss.add(when: 'CONFIG_RT500_CLKCTL', if_true: files('rt500_clkctl0.c= ', 'rt500_clkctl1.c')) system_ss.add(when: 'CONFIG_RT500_RSTCTL', if_true: files('rt500_rstctl.c'= )) --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687773; cv=none; d=zohomail.com; s=zohoarc; b=cdYrkI20znbT/cKeZibyEh1dOQ9WZ+Rp9Fkb+RcASxWboDDWQzr10UfNsJKWSdIySR3s6uktONTqnF8NCvdgrSkyRlmpvNzhSwsJ4LJhmgtHeyTFU2nYJqK4WlUNe7rda++8V+q3lsc+fOf0XaSmVhmOhoLeQjVCNqcU3vsjFTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687773; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=j5CsnkrzorKCa1JKdBu6zJdVCIAE7wiQPKdUlC6Xodk=; b=R/Kd1YV4wLiEMF0UCqce5k0M1dgGmraiFn16SQOvEWOyZvkbuIGlTqdAdgG3zCxTGt9UtSfRS2d47O36fMSIteG3nZ8Rgci66eBBAM+IRTK8SbSPngMMk8GNofuc7aWTznQ+7OL/CqMHQDpbMh6eNklNeU/eR1xsiK2MDaPKLOw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687773431315.9771831452017; Wed, 18 Sep 2024 12:29:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0H6-00064v-BU; Wed, 18 Sep 2024 15:23:40 -0400 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 <3tSjrZgUKCvAlSnahYggYdW.UgeiWem-VWnWdfgfYfm.gjY@flex--tavip.bounces.google.com>) id 1sr0H4-0005wW-7T for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:38 -0400 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3tSjrZgUKCvAlSnahYggYdW.UgeiWem-VWnWdfgfYfm.gjY@flex--tavip.bounces.google.com>) id 1sr0H2-0007Py-EK for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:37 -0400 Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-7190c5e73cdso70788b3a.0 for ; Wed, 18 Sep 2024 12:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687415; x=1727292215; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=j5CsnkrzorKCa1JKdBu6zJdVCIAE7wiQPKdUlC6Xodk=; b=eDl230l9bIYG93zlieor77rVvz/LSQXHsKjCBmAdj/na7dDSBz9wizbK88eQD0fZVy zBRLyy0W0/4i17Vj/vvYkjdR9k5O1xWoTyo6AWP8HaAGKM9wRF4C8xyX4XjsgK5LCn/S Z6stsTvMjYdnw3+/PCS3Wiwq5gS8FKr/b/ilx8tpu6TIcx0LJqJEj0P6KgV3EPXQAG8r fBut1c6t4e+wJbbntsvaMvX8Kl+4f3X/oBAz9MjFnZ9geEgDOqN++VC4pefe9oTxTSnh I1Xl+aKuFWKT0tVqTzSzg772pdu4OeqisbkGr/yWobJfq895D6LgA63OrelzuHteds3t UN3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687415; x=1727292215; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=j5CsnkrzorKCa1JKdBu6zJdVCIAE7wiQPKdUlC6Xodk=; b=MRrR5aYbJLcFBWjAWyn2m6FgeSMRxjsnwB0jM5ZqXCpF9xBNpFsAuEydtakW4SUUD1 BBhNGflc/bbExl3dwkFcxawwe5EpPHacNjJdbCKVQ94bEz27yYAVMnnP9qZRafDZK/fx dTmxKQOU/hImO1vaNaaGc8otZejQfHhnDZtDjlFn28eJlPircOm7E8e8Tt5yhHsQhlF5 7vGZZnnkSAr/rmcFkOr75vKP5Lv6CeMHJyWq7yNf1USSARFrcDY66KY3TzFXBhpy6DUN dPOoD/V1j0jctDVmChzJvLifIda55ItjRVXevt/FnEODGeqBBEcqxIQNVvsApCswOGkL Y/eQ== X-Gm-Message-State: AOJu0YymOag+KqVYeCMy/YjT8lvXGuY+pmtqGHGq663R5XZAgLPfK/bT Sd8k7d4njRDiv3kIAlfjr+dMAfOSaaG1AvP/dwugjyFnpNjBvgTrPy8vOr9Dvff3NQhWorgic9v +ZDUhSUG3hJvYvOjpb6ezMEcyWPGtTO7WV5TJnPscAKXeegGVPYrXCt9w7pvWALww27jwRH0gPW HDA+MenntcZ9ztRQt6To6Kzlk5hw== X-Google-Smtp-Source: AGHT+IF2luWrPonjjl6Z2oIL7v55+3iflPoD++N7H/zqtc9j/3ZEBELLQW+6Rd3cqgi8AZpWLNNxg8JbXQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a05:6a00:6419:b0:70d:1285:bbcf with SMTP id d2e1a72fcca58-71925fa7878mr71729b3a.0.1726687413707; Wed, 18 Sep 2024 12:23:33 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:48 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-21-tavip@google.com> Subject: [PATCH 20/25] tests/qtest: add tests for flexcomm i2c From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::44a; envelope-from=3tSjrZgUKCvAlSnahYggYdW.UgeiWem-VWnWdfgfYfm.gjY@flex--tavip.bounces.google.com; helo=mail-pf1-x44a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687778068116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add master mode tests for flexcomm i2c. Signed-off-by: Octavian Purdila --- tests/qtest/flexcomm-i2c-test.c | 170 ++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 2 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/flexcomm-i2c-test.c diff --git a/tests/qtest/flexcomm-i2c-test.c b/tests/qtest/flexcomm-i2c-tes= t.c new file mode 100644 index 0000000000..45f31da7de --- /dev/null +++ b/tests/qtest/flexcomm-i2c-test.c @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2024 Google LLC. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "qemu/config-file.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qapi/error.h" +#include "qemu/sockets.h" +#include "sysemu/sysemu.h" +#include "qemu/main-loop.h" +#include "qemu/option.h" +#include "exec/memory.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-core.h" + +#include "hw/misc/flexcomm.h" +#include "hw/arm/svd/flexcomm_i2c.h" +#include "hw/arm/svd/rt500.h" +#include "hw/misc/i2c_tester.h" +#include "reg-utils.h" + +#define PERIPH_ADDR (0x50) +#define INVALID_ADDR (0x10) + +#define REG_ADDR 11 +#define REG_VALUE 0xAA + +#define FLEXCOMM_BASE RT500_FLEXCOMM0_BASE +#define FLEXCOMM_I2C_BASE RT500_FLEXCOMM0_BASE +#define DEVICE_NAME "/machine/soc/flexcomm0" + +struct TestState { + QTestState *qtest; +}; + +static void master_test(gconstpointer user_data) +{ + struct TestState *t =3D (struct TestState *)user_data; + uint32_t tmp; + + qtest_irq_intercept_out_named(t->qtest, DEVICE_NAME, + SYSBUS_DEVICE_GPIO_IRQ); + + /* Select and lock I2C */ + tmp =3D FLEXCOMM_PERSEL_I2C; + FIELD_DP32(tmp, FLEXCOMM_PSELID, LOCK, 1); + REG32_WRITE(FLEXCOMM, PSELID, tmp); + + /* Enable master mode */ + REG32_WRITE_FIELD(FLEXCOMM_I2C, CFG, MSTEN, 1); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, CFG, MSTEN) =3D=3D 1); + + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTPENDING) =3D=3D 1); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_IDLE); + + /* Enable interrupts */ + REG32_WRITE_FIELD(FLEXCOMM_I2C, INTENSET, MSTPENDINGEN, 1); + g_assert_true(get_irq(0)); + + /* start for invalid address */ + REG32_WRITE(FLEXCOMM_I2C, MSTDAT, INVALID_ADDR); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTART, 1); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_NAKADR); + g_assert_true(get_irq(0)); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTOP, 1); + + /* write past the last register */ + REG32_WRITE_FIELD(FLEXCOMM_I2C, MSTDAT, DATA, PERIPH_ADDR); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTART, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_TXRDY); + REG32_WRITE_FIELD(FLEXCOMM_I2C, MSTDAT, DATA, I2C_TESTER_NUM_REGS + 10= ); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTCONTINUE, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_TXRDY); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTCONTINUE, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_NAKDAT); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTOP, 1); + + /* write value to register */ + REG32_WRITE_FIELD(FLEXCOMM_I2C, MSTDAT, DATA, PERIPH_ADDR); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTART, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_TXRDY); + REG32_WRITE_FIELD(FLEXCOMM_I2C, MSTDAT, DATA, REG_ADDR); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTCONTINUE, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_TXRDY); + REG32_WRITE_FIELD(FLEXCOMM_I2C, MSTDAT, DATA, REG_VALUE); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTCONTINUE, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_TXRDY); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTOP, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_IDLE); + + /* read value back from register */ + REG32_WRITE_FIELD(FLEXCOMM_I2C, MSTDAT, DATA, PERIPH_ADDR); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTART, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_TXRDY); + REG32_WRITE_FIELD(FLEXCOMM_I2C, MSTDAT, DATA, REG_ADDR); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTCONTINUE, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_TXRDY); + REG32_WRITE_FIELD(FLEXCOMM_I2C, MSTDAT, DATA, (PERIPH_ADDR + 1)); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTART, 1); + g_assert_true(get_irq(0)); + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_RXRDY); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_I2C, MSTDAT, DATA), =3D=3D, + REG_VALUE); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTOP, 1); + + /* + * Check that the master ended the transaction (i.e. i2c_end_transfer = was + * called). If the master does not properly end the transaction this w= ould + * be seen as a restart and it would not be NACKed. + */ + REG32_WRITE_FIELD(FLEXCOMM_I2C, MSTDAT, DATA, INVALID_ADDR); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTART, 1); + + g_assert(REG32_READ_FIELD(FLEXCOMM_I2C, STAT, MSTSTATE) =3D=3D + MSTSTATE_NAKADR); + g_assert_true(get_irq(0)); + REG32_WRITE_FIELD_NOUPDATE(FLEXCOMM_I2C, MSTCTL, MSTSTOP, 1); + + /* Disable interrupts */ + REG32_WRITE_FIELD(FLEXCOMM_I2C, INTENCLR, MSTPENDINGCLR, 1); + g_assert_false(get_irq(0)); +} + +int main(int argc, char **argv) +{ + int ret; + struct TestState test; + + module_call_init(MODULE_INIT_QOM); + g_test_init(&argc, &argv, NULL); + + qtest_add_data_func("/flexcomm-i2c/master", &test, master_test); + + test.qtest =3D qtest_start("-M rt595-evk " + "-device i2c-tester,address=3D0x50,bus=3D/flexco= mm0-i2c"); + ret =3D g_test_run(); + qtest_end(); + + return ret; +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 663e44f3c6..74fef28551 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -231,7 +231,7 @@ qtests_arm =3D \ (config_all_devices.has_key('CONFIG_FSI_APB2OPB_ASPEED') ? ['aspeed_fsi-= test'] : []) + \ (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') and config_all_devices.has_key('CONFIG_DM163')? ['dm163-test'] : []) + \ - (config_all_devices.has_key('CONFIG_FLEXCOMM') ? ['flexcomm-test', 'flex= comm-usart-test'] : []) + \ + (config_all_devices.has_key('CONFIG_FLEXCOMM') ? ['flexcomm-test', 'flex= comm-usart-test', 'flexcomm-i2c-test'] : []) + \ ['arm-cpu-features', 'boot-serial-test'] =20 --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687536; cv=none; d=zohomail.com; s=zohoarc; b=ZNtdOBDYLz7CaqXBsXDj5Mvlw2ZaZFHcnSAezYbOP+JaqZ5qQS1CdfQrm1rO5EEUkF4gqzYevKZuRetNOzCt9n/gVIwRJJopjRGRstytCeXp30TaNZlQPMdriH8YYZZifd28U81Va+LHKLwhDKC9qNhyDK9uSnCJ2ellq08RR9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687536; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TBdugsch+GIptmS7cOiUEz9KzkCdjmId5XX/UAGHjcE=; b=ZmmpMk9LtAmtnUqj1FEFrDQBsFzRKgyLaSqZYtI8vFAT3VOQmu/OG1+m0RvqFTPMjSfeLF639/7k5VCLN1afEw0tuqg9YP4WjH3EJvZflPsFSsHoA7vWXf+4zGOiHn/ZQvStoavGqlYRZ5Pj2sN7db4hrfGzlNnUisgylxZuXpo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687536132998.7563365318775; Wed, 18 Sep 2024 12:25:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0H7-0006BS-RY; Wed, 18 Sep 2024 15:23:41 -0400 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 <3tyjrZgUKCvInUpcjaiiafY.WigkYgo-XYpYfhihaho.ila@flex--tavip.bounces.google.com>) id 1sr0H5-00063I-Uy for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:39 -0400 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3tyjrZgUKCvInUpcjaiiafY.WigkYgo-XYpYfhihaho.ila@flex--tavip.bounces.google.com>) id 1sr0H4-0007QV-IV for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:39 -0400 Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-2d8b7c662ccso266295a91.0 for ; Wed, 18 Sep 2024 12:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687416; x=1727292216; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TBdugsch+GIptmS7cOiUEz9KzkCdjmId5XX/UAGHjcE=; b=FsLEMBnJvyFeAErvCkjt/FCXDR+SJbLVs2D2xMS9tv1MTE0vwKi42NCsLk2VBd5YKq tqLB0nC0K1Xtpw/EnEyonKibsuC6+VlvwiC9zUxITwvEIUlgohBrnrO6jWq01KKxXMlc +NYSIAlKAYtPLnPpwZ42YrwCIgKsT1mBmafUY1lSlVhmWZitEhAWjN5K7JvMc7Ai48ns kg2DYOltBTkxtXL0AezeeQK6qVEXgL/bO33QMnM25DhJUg/LvR1kBcU7ypS6kdUManV0 VPOhPjPeDOr+t5ddr7B/77h8jYNifwBTLJJDw67H/W4tmJiSmS+NQxZzxz4NDHa7MWet zNoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687416; x=1727292216; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TBdugsch+GIptmS7cOiUEz9KzkCdjmId5XX/UAGHjcE=; b=wIIAkEgaGUDZYc+P2MvuoRPUw7yt8+M+3mSJ82GMVHcfRc/gA1LdQRHmwD0JRoZccv jadl0JNUtvYX2VsVxrYh1SaS6Rt8tmWMBlWT7G906r9CyTWmVi9e4E+Hh11IEYg+yB9i j9XirB8qVHdnbxxOummzPuB0rEpkSNtrFx7ARybNsOij/rp/2HiAYmJBYglCGmtUrXBt m0iAQFMe5J4gptro2EArqhOwmgkQrHC0q0WyWqHvpyREWovY2pOnFasRvdnJgRScGjEC B19oArOwArsdoIr2f4fgxRy6xnGx6oXUOOmD09vakBPoeU/grbemOukRZ8gN3j7MjpCv ItPg== X-Gm-Message-State: AOJu0Yz652fvgGiK+0VeVHFQqDCOyyQJYkRmHaZ1tl0JcIPsAsAHALlL UE38tZLk7uaVezcKYm4DGrp9jxfIlV99hJIDfR37cbcVVw+Q/HR82rST/wDyBrEqQbioQKXV3qj imWhiPmihb5qjhcxuojgqnQk/sc2aFHo+zwpUDVy4ydmZELSRqiZWGEsJTc5vxFiyBVKWEpf7JH RUsZ9UUJimaJPF7iGi9t3cmwGvYw== X-Google-Smtp-Source: AGHT+IE9RANLv8donXWCo7OHxNyPfn0FnPh3Mr+E0BZj9ZDA+HoHcDMPTrUv39jv2ewnlDPc6SOsCksUUQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:90b:3a84:b0:2d8:82ab:1999 with SMTP id 98e67ed59e1d1-2db9ff6cda4mr43406a91.1.1726687415723; Wed, 18 Sep 2024 12:23:35 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:49 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-22-tavip@google.com> Subject: [PATCH 21/25] hw/ssi: allow NULL realize callbacks for peripherals From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1049; envelope-from=3tyjrZgUKCvInUpcjaiiafY.WigkYgo-XYpYfhihaho.ila@flex--tavip.bounces.google.com; helo=mail-pj1-x1049.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687536891116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Octavian Purdila --- hw/ssi/ssi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/ssi/ssi.c b/hw/ssi/ssi.c index 3f357e8f16..d1f3ce7c22 100644 --- a/hw/ssi/ssi.c +++ b/hw/ssi/ssi.c @@ -105,7 +105,9 @@ static void ssi_peripheral_realize(DeviceState *dev, Er= ror **errp) } s->spc =3D ssc; =20 - ssc->realize(s, errp); + if (ssc->realize) { + ssc->realize(s, errp); + } } =20 static Property ssi_peripheral_properties[] =3D { --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687482; cv=none; d=zohomail.com; s=zohoarc; b=PWg+gP3P6x9DLsX/WqPOkt/OYzKUfsUMCSi00qqvbKIL4b1FPLV4Njc3+dscrgS2xOuqonYGhLBfU6sOMz1DVMUTdhCO1gRq85a347UNE1ihmTjrTjQR7xB1nLhmIyna/qrDzm5KalU5Wci21URBFXJrXOSxMxgLNk45/hZa688= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687482; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mcht1UrN4o7a748za6EPwH1dmZHR+9K1RZ6hCAmN+lI=; b=Ns79CNaWGfoXo3sdX3S0V/qbydM/6FUH8AUtbFynAWHEQoWyP2SSYF2VIxj2XYlO/b5V8r+kVZ+WPZqxB8iet40qdpKJ6w4SNczYQhcoEJFfA7VYEY2+ew9t3RDHM3JqRqaXxkP+0lJG7SKfIJbvQOfbXuX62H538gPFBwMEEv4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687482898662.6484559082269; Wed, 18 Sep 2024 12:24:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0HB-0006Sp-VE; Wed, 18 Sep 2024 15:23:45 -0400 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 <3uSjrZgUKCvQpWrelckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--tavip.bounces.google.com>) id 1sr0H9-0006K9-Rg for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:43 -0400 Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3uSjrZgUKCvQpWrelckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--tavip.bounces.google.com>) id 1sr0H8-0007RC-45 for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:43 -0400 Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-206b912491eso12762505ad.0 for ; Wed, 18 Sep 2024 12:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687419; x=1727292219; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mcht1UrN4o7a748za6EPwH1dmZHR+9K1RZ6hCAmN+lI=; b=1FSy1Man3j5Q6YQ8ep3L0mHftBs9+R+3qBBAVEASTF9PCbiCUx9J+tHFML4SQ/R1Hj h5YomAbt3sP6Km7IiUvriuxoxqiT0WD7qi+G26Hdwp6TFh17oLz9DayzrgbiV5BqlkL0 CUYFx8iznga4nbfYImdqNzHqv+hBUHtcXLm4X99jaLkB98RVaddIdKOJpiHh5clzKmWB 8Mx5MXU0btX6C66x0ZuFjwwxpwkykr/yeNu7c0yoDamIWuUsw5VSThHH0zR1K8eMArwh 9fwbIC07m2OwEkiP+vfDjaEwT31c/H5HvCZYN+1UKWJyChuCQm/+KAbgBHKdyFInDSo1 T3TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687419; x=1727292219; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mcht1UrN4o7a748za6EPwH1dmZHR+9K1RZ6hCAmN+lI=; b=rufJ0N5Q/W9NLuRGEvb2vWKT98r067kKlWN2GX5DG1hcfsHdk6WN9HfvEHZTPV+7QD JLjK/VINe9hpSI5NHqmIJ38AqUh4nso6h+J91sO6iBAxa7LWtRL6qsa6KAsBQ/URkUYV +GBSnMx2/WEBhr3bRYnOk3EOzovZTC8ZeGk70ECCLuZ0NIfnjuxRPOLuNCFQFOI4oJGO CY6P1NL6QHrhlXSRayBxqDG7lIVQfeEl76fVo1B9FEgzRB0EtVVoPy3apKtoVD53bkf7 uQ5+af1KuanXbJAmz4aUU+MRszdYe9gZrZYZn2QtfNZC8lD0eOh/qZL3TA0fBlkwc6oA BZUA== X-Gm-Message-State: AOJu0Yzh/x6TjU/qANyTmOIK9QqAPyeW1HkalPc+MgnKhF0YmpNXcvaI 6wXCo+bOIcIp01icqO6D2AzNafHiSC3dn7kVUnxd9/qO87x8ZtYw4E3g7XwMw3lqNk2EmnVZOi/ tRsFRKZhpvXgFlin48h3GIvturJGinMzH3hjsxVYhIxAqvQdbg4D54sDofaf69gaW9pnaEAdZ6B NTX/z5n2nx2kSCYfc5KSrjg7UeBg== X-Google-Smtp-Source: AGHT+IFumOnyLqv5J02XQqn8ZjlwZgw+QflJFXmX8qjlVZTiSy/Y/YtmA/2k4SYTA4kmWIIOqKQUJoKluQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:902:e204:b0:1fb:1658:926 with SMTP id d9443c01a7336-208cc3b9e48mr3785ad.6.1726687417742; Wed, 18 Sep 2024 12:23:37 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:50 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-23-tavip@google.com> Subject: [PATCH 22/25] hw/misc: add spi-tester From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::649; envelope-from=3uSjrZgUKCvQpWrelckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--tavip.bounces.google.com; helo=mail-pl1-x649.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687485137116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a simple SPI peripheral that echoes back received data. Useful for testing SPI controllers. Signed-off-by: Octavian Purdila --- include/hw/misc/spi_tester.h | 32 +++++++++++++++++ hw/misc/spi_tester.c | 67 ++++++++++++++++++++++++++++++++++++ hw/misc/Kconfig | 5 +++ hw/misc/meson.build | 1 + 4 files changed, 105 insertions(+) create mode 100644 include/hw/misc/spi_tester.h create mode 100644 hw/misc/spi_tester.c diff --git a/include/hw/misc/spi_tester.h b/include/hw/misc/spi_tester.h new file mode 100644 index 0000000000..8935f3f1af --- /dev/null +++ b/include/hw/misc/spi_tester.h @@ -0,0 +1,32 @@ +/* + * Simple SPI peripheral device used for SPI controller testing. + * + * Copyright (c) 2024 Google LLC. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_SPI_TESTER_H +#define HW_SPI_TESTER_H + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/bswap.h" +#include "hw/irq.h" +#include "hw/ssi/ssi.h" +#include "qemu/timer.h" +#include "hw/qdev-properties.h" + +#define TYPE_SPI_TESTER "spi-tester" +#define SPI_TESTER(obj) OBJECT_CHECK(SpiTesterState, (obj), TYPE_SPI_TESTE= R) + +typedef struct { + SSIPeripheral ssidev; + bool cs; +} SpiTesterState; + +#endif /* HW_SPI_TESTER_H */ diff --git a/hw/misc/spi_tester.c b/hw/misc/spi_tester.c new file mode 100644 index 0000000000..2793ce52dc --- /dev/null +++ b/hw/misc/spi_tester.c @@ -0,0 +1,67 @@ +/* + * Simple SPI peripheral echo device used for SPI controller testing. + * + * Copyright (c) 2024 Google LLC. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "migration/vmstate.h" +#include "hw/misc/spi_tester.h" + +static uint32_t spi_tester_transfer(SSIPeripheral *dev, uint32_t value) +{ + SpiTesterState *s =3D SPI_TESTER(dev); + + if (s->cs) { + return 0; + } + + return value; +} + +static int spi_tester_set_cs(SSIPeripheral *dev, bool select) +{ + SpiTesterState *s =3D SPI_TESTER(dev); + + s->cs =3D select; + + return 0; +} + +static const VMStateDescription vmstate_spi_tester =3D { + .name =3D "spi-tester", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_SSI_PERIPHERAL(ssidev, SpiTesterState), + VMSTATE_BOOL(cs, SpiTesterState), + VMSTATE_END_OF_LIST() + } +}; + +static void spi_tester_class_init(ObjectClass *klass, void *data) +{ + SSIPeripheralClass *k =3D SSI_PERIPHERAL_CLASS(klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->vmsd =3D &vmstate_spi_tester; + k->transfer =3D spi_tester_transfer; + k->set_cs =3D spi_tester_set_cs; + k->cs_polarity =3D SSI_CS_LOW; +} + +static const TypeInfo spi_tester_types[] =3D { + { + .name =3D TYPE_SPI_TESTER, + .parent =3D TYPE_SSI_PERIPHERAL, + .instance_size =3D sizeof(SpiTesterState), + .class_init =3D spi_tester_class_init, + }, +}; + +DEFINE_TYPES(spi_tester_types); diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 3e93c12c8e..484ee3149f 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -218,6 +218,11 @@ config I2C_TESTER default y if TEST_DEVICES depends on I2C =20 +config SPI_TESTER + bool + default y if TEST_DEVICES + depends on SSI + config FLEXCOMM bool select I2C diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 4f22231fa3..413171f379 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -159,6 +159,7 @@ system_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('= sbsa_ec.c')) system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c')) =20 system_ss.add(when: 'CONFIG_I2C_TESTER', if_true: files('i2c_tester.c')) +system_ss.add(when: 'CONFIG_SPI_TESTER', if_true: files('spi_tester.c')) =20 system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm.c')) system_ss.add(when: 'CONFIG_RT500_CLKCTL', if_true: files('rt500_clkctl0.c= ', 'rt500_clkctl1.c')) --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687472; cv=none; d=zohomail.com; s=zohoarc; b=BJpcnMLgTAmQB7fT8pttRQYumYE5n7WWoL60eWmPwYGoKXcoUZyPLugO9yG9vJjTtc+xOzUg4uvi0Zx308n2h7LvBPFhHQSIu98z7/q07N746YZCxuvuNrlHDRdROTQT5k7BcYqCOxCoM48J9SO7PJSAfnHfoj1h2w+MgY2Njxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687472; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CWax01LO11cCMxk7XAjv93ylNJE01EbdgJ7/Pszq034=; b=IXpF8k46rle7zgF/S2CXxlCnFmq5oN9Vcggd/Zz7HHO3FSG46R21FPFO7UZw/3+hsQbqQEAud+kPZxP8VS4IpstgsyyX6AedgRegulVwHIZ1CPL5R/4DzFYSKWqcR1lINKV+TLEswub3Y2t8CClmeXcty8zCwYdq9O/yxuob/iA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687472977775.7146582144322; Wed, 18 Sep 2024 12:24:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0HE-0006ey-Kb; Wed, 18 Sep 2024 15:23:49 -0400 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 <3uyjrZgUKCvYrYtgnemmejc.amkocks-bctcjlmlels.mpe@flex--tavip.bounces.google.com>) id 1sr0HB-0006PP-7N for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:45 -0400 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3uyjrZgUKCvYrYtgnemmejc.amkocks-bctcjlmlels.mpe@flex--tavip.bounces.google.com>) id 1sr0H8-0007RO-Uf for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:44 -0400 Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-71985a317fcso50010b3a.1 for ; Wed, 18 Sep 2024 12:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687421; x=1727292221; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CWax01LO11cCMxk7XAjv93ylNJE01EbdgJ7/Pszq034=; b=zGhet/009glFKP7BXtgbv4pDmJ7s7lZoJHOGR9GQ4/Vot2oOYiHjsgOtqL5/TIbBmU ptuJTfwQfqUdT18ap8MSeuPEk2+DOMbIo8ZXZG7ZmwoKOzKkID54daYGnvK7yK63JhIp 1PjCIph8Q5GM3zuEuDna9W/Eo1ZproFVfUTApjpLYstL9w3TpV3vcVwey/4jZDVLC/Ka Uxl8/CkqGi9lyHPTpVygHVnEPlGe3XZ8ZMMJZpfOtO3j8ajAq1p2TEyecWKkUlszgcNF wXmyMsbikapeZ3yLsnvjkSOP9K/flc5THw53on4QAQGZ/thABpRqcUEr+0svBiS26oYD xPFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687421; x=1727292221; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CWax01LO11cCMxk7XAjv93ylNJE01EbdgJ7/Pszq034=; b=pFrUGzgA4YVdIwbPIOMF2PATs6usPRx9qfcM5SDo4ZXfzFe3KnS9nQWV94+5kt0bRd Ud/wD0hzlBtmnIhlb9EDqzNYCybJYDF22tvV/aB+yoAK/laj4/Id8td3E3tZD9MCGjLc is+cp4DM0O5v+TlbuzRl5AjPb73Sn2D/XYXhtSapgAW1ZQsuH4rAEPBw2wwlCbQ4iMGI MOZeEu7n+9BIExzWS1W9+tXbuDJlDrXDeMtXwQTH6vCznZBN9ImV+dXpLegRMvcLo3nr BVL4xmIEYY61UFJOQt0P1Mfrms66gTvW42mtdfAIDcE55m6lXPQ9eVSuK/nU1yiGHUsX a+PA== X-Gm-Message-State: AOJu0Yy83ayf/dDedWxt9C7BkxRdjzWiCDyB6ONneAciIcaMMAoNzyVu mrYBLSmbLKdlSanOPwowvY6BY7mqBEz16mh2jMhOm9bhVLCxbfESB6rwuh6OUejuk6dDbq6iNiD ZXektRNpieXzSj3fzJV5pS3dvDhNqCHvuMO5OL5jWc659AvS9HPDs4E/dw7C4bvs/uJ4GwL3ELo wu+x+cxcEHvZKY/9EQeo6/cDgJ5w== X-Google-Smtp-Source: AGHT+IHvipsDN/lR67gcLqKAQStRGIe/Xifx2ShSlVwhQHbSb87y5XlxAEKzi/jyANlbDjk5JNKAxYhJdA== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a62:aa14:0:b0:717:9798:a8ca with SMTP id d2e1a72fcca58-719262286femr63984b3a.4.1726687419607; Wed, 18 Sep 2024 12:23:39 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:51 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-24-tavip@google.com> Subject: [PATCH 23/25] tests/qtest: add tests for flexcomm spi From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::44a; envelope-from=3uyjrZgUKCvYrYtgnemmejc.amkocks-bctcjlmlels.mpe@flex--tavip.bounces.google.com; helo=mail-pf1-x44a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687475118116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sebastian Ene Add master and loopback tests for flexcomm spi. Signed-off-by: Sebastian Ene [tavip: add master mode test, convert to qtest] Signed-off-by: Octavian Purdila --- tests/qtest/flexcomm-spi-test.c | 145 ++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 2 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/flexcomm-spi-test.c diff --git a/tests/qtest/flexcomm-spi-test.c b/tests/qtest/flexcomm-spi-tes= t.c new file mode 100644 index 0000000000..4658835b8f --- /dev/null +++ b/tests/qtest/flexcomm-spi-test.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2024 Google LLC. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "qemu/config-file.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qapi/error.h" +#include "qemu/sockets.h" +#include "sysemu/sysemu.h" +#include "qemu/main-loop.h" +#include "qemu/option.h" +#include "exec/memory.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-core.h" + +#include "hw/misc/flexcomm.h" +#include "hw/arm/svd/flexcomm_spi.h" +#include "hw/arm/svd/rt500.h" +#include "reg-utils.h" + +/* The number of words sent on the SPI in loopback mode. */ +#define SEQ_LOOPBACK_MODE (8) + +/* This value is used to set the cycle counter for the spi tester */ +#define SPI_TESTER_CONFIG (0x10) + +#define FLEXCOMM_BASE RT500_FLEXCOMM0_BASE +#define FLEXCOMM_SPI_BASE RT500_FLEXCOMM0_BASE +#define DEVICE_NAME "/machine/soc/flexcomm0" + +static void configure_spi(bool master, bool is_loopback_mode) +{ + uint32_t tmp; + + /* Select and lock SPI */ + tmp =3D FLEXCOMM_PERSEL_SPI; + FIELD_DP32(tmp, FLEXCOMM_PSELID, LOCK, 1); + REG32_WRITE(FLEXCOMM, PSELID, tmp); + + /* Disable the FIFO */ + REG32_WRITE_FIELD(FLEXCOMM_SPI, CFG, ENABLE, 0); + REG32_WRITE_FIELD(FLEXCOMM_SPI, FIFOCFG, ENABLETX, 0); + REG32_WRITE_FIELD(FLEXCOMM_SPI, FIFOCFG, ENABLERX, 0); + + if (is_loopback_mode) { + /* Set up SPI interface - loop mode, master mode */ + REG32_WRITE_FIELD(FLEXCOMM_SPI, CFG, LOOP, 1); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, CFG, LOOP) =3D=3D 1); + } + + if (master) { + REG32_WRITE_FIELD(FLEXCOMM_SPI, CFG, MASTER, 1); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, CFG, MASTER) =3D=3D 1); + } else { + REG32_WRITE_FIELD(FLEXCOMM_SPI, CFG, MASTER, 0); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, CFG, MASTER) =3D=3D 0); + } + + /* Enable the FIFO */ + REG32_WRITE_FIELD(FLEXCOMM_SPI, FIFOCFG, ENABLETX, 1); + REG32_WRITE_FIELD(FLEXCOMM_SPI, FIFOCFG, ENABLERX, 1); + + /* Enable the SPI */ + REG32_WRITE_FIELD(FLEXCOMM_SPI, CFG, ENABLE, 1); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, CFG, ENABLE) =3D=3D 1); +} + +/* The SPI controller running in master mode can run in loopback mode for = */ +/* internal testing. Transmit and receive lines are connected together. */ +static void loopback_test(gconstpointer user_data) +{ + configure_spi(true, true); + + /* Write a sequence */ + for (int i =3D 0; i < SEQ_LOOPBACK_MODE; i++) { + REG32_WRITE(FLEXCOMM_SPI, FIFOWR, i); + } + + /* Read the sequence back */ + for (int i =3D 0; i < SEQ_LOOPBACK_MODE; i++) { + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, FIFORD, RXDATA) =3D=3D i); + } +} + +static void master_test(gconstpointer user_data) +{ + uint32_t tmp; + + configure_spi(true, false); + + REG32_WRITE_FIELD(FLEXCOMM_SPI, CFG, LSBF, 1); + + /* single 16bit word transfer */ + + tmp =3D FIELD_DP32(0x1122, FLEXCOMM_SPI_FIFOWR, EOT, 1); + tmp =3D FIELD_DP32(tmp, FLEXCOMM_SPI_FIFOWR, TXSSEL0_N, 1); + tmp =3D FIELD_DP32(tmp, FLEXCOMM_SPI_FIFOWR, LEN, 0xF); + REG32_WRITE(FLEXCOMM_SPI, FIFOWR, tmp); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, FIFOSTAT, RXNOTEMPTY) =3D=3D 1= ); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM_SPI, FIFORD, RXDATA), + =3D=3D, 0x1122); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, FIFOSTAT, RXNOTEMPTY) =3D=3D 0= ); + + /* multi word 8 bits transfer */ + + tmp =3D FIELD_DP32(0x11, FLEXCOMM_SPI_FIFOWR, TXSSEL0_N, 1); + tmp =3D FIELD_DP32(tmp, FLEXCOMM_SPI_FIFOWR, LEN, 0x7); + REG32_WRITE(FLEXCOMM_SPI, FIFOWR, tmp); + tmp =3D 0x22; + FIELD_DP32(tmp, FLEXCOMM_SPI_FIFOWR, EOT, 1); + FIELD_DP32(tmp, FLEXCOMM_SPI_FIFOWR, TXSSEL0_N, 1); + FIELD_DP32(tmp, FLEXCOMM_SPI_FIFOWR, LEN, 0x7); + REG32_WRITE(FLEXCOMM_SPI, FIFOWR, tmp); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, FIFOSTAT, RXNOTEMPTY) =3D=3D 1= ); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, FIFORD, RXDATA) =3D=3D 0x11); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, FIFOSTAT, RXNOTEMPTY) =3D=3D 1= ); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, FIFORD, RXDATA) =3D=3D 0x22); + g_assert(REG32_READ_FIELD(FLEXCOMM_SPI, FIFOSTAT, RXNOTEMPTY) =3D=3D 0= ); +} + +int main(int argc, char **argv) +{ + int ret; + + module_call_init(MODULE_INIT_QOM); + g_test_init(&argc, &argv, NULL); + + qtest_add_data_func("/flexcomm-spi/loopack", NULL, loopback_test); + qtest_add_data_func("/flexcomm-spi/master", NULL, master_test); + + qtest_start("-M rt595-evk -device spi-tester,bus=3D/flexcomm0-spi"); + ret =3D g_test_run(); + qtest_end(); + + return ret; +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 74fef28551..2cb0fa08c0 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -231,7 +231,7 @@ qtests_arm =3D \ (config_all_devices.has_key('CONFIG_FSI_APB2OPB_ASPEED') ? ['aspeed_fsi-= test'] : []) + \ (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') and config_all_devices.has_key('CONFIG_DM163')? ['dm163-test'] : []) + \ - (config_all_devices.has_key('CONFIG_FLEXCOMM') ? ['flexcomm-test', 'flex= comm-usart-test', 'flexcomm-i2c-test'] : []) + \ + (config_all_devices.has_key('CONFIG_FLEXCOMM') ? ['flexcomm-test', 'flex= comm-usart-test', 'flexcomm-i2c-test', 'flexcomm-spi-test'] : []) + \ ['arm-cpu-features', 'boot-serial-test'] =20 --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687753; cv=none; d=zohomail.com; s=zohoarc; b=n5fNVPI1OhbKEclAi3t2/JKb58k4XEmBxQ1MgKAtQTMKhUEPUSm9UnZzQ5YOkpvNwEED4bmasFdvbcD6tTQZeuRW493y2fc0QxvMt/QYRbKMiAznyaUcnzLHrkdSZ/EcgIBriZikFOsSM3GikTOzD5WBhP5pR2bmsj3adSxxk14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687753; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UuK6tEDguSgEq4sOmbOCdqmyqurQ/O4ePv8cGHfnsdc=; b=m42KcmfvEJxbbPJmzH0uSKS6Zd5OqUNToiByxdW/NMOCOvAQUi+w60PtqQWLnNT6jANhQx2igcVCU/QaIorJNEwDc4zksPs//HGq4DZRaFrQOE/ScAbxVyptHDZmCUqp9kGZUxNyqmWueCUscq0J0r1NzIo2RYKO36jkF7HQzW0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687753189507.7601104369361; Wed, 18 Sep 2024 12:29:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0HD-0006Xj-1G; Wed, 18 Sep 2024 15:23:47 -0400 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 <3vSjrZgUKCvgyf0nulttlqj.htrvjrz-ij0jqstslsz.twl@flex--tavip.bounces.google.com>) id 1sr0HB-0006Pm-Aa for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:45 -0400 Received: from mail-pg1-x54a.google.com ([2607:f8b0:4864:20::54a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3vSjrZgUKCvgyf0nulttlqj.htrvjrz-ij0jqstslsz.twl@flex--tavip.bounces.google.com>) id 1sr0H9-0007Ra-Jd for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:45 -0400 Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-7cf58491fe9so7104a12.0 for ; Wed, 18 Sep 2024 12:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687422; x=1727292222; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=UuK6tEDguSgEq4sOmbOCdqmyqurQ/O4ePv8cGHfnsdc=; b=aYpUCMDVgxoI6mBrESeIzBFjYKSwRoT+WOxPae/kEC06zTIZecaGyz1sOnUmUeXEAE dxlydeamEalKnLgW5yzhzMsLEV6YnXsds0ts7saICHheHGSrmRfTIgwjIsSoPPWaPOg5 H13h3Q+2nx/cy2PUMds6L7vxJoe4Jd6LajnSoaXEV4N0Q+mUvzamuDfk9NGAHsuvm0Xn fgWBITsKHBbbNxxtDx7dr6v9CryO1Mn7B80NLD0fT4qcL1td5ER5OAegi4iKM8GOLu5E UwEQ48PHSRZwrHq/qtBtJMQn1jIU3ksHTXo1P6cvFQ52gKR9gX1AIBRXkyIc0tB++kgj 61Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687422; x=1727292222; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UuK6tEDguSgEq4sOmbOCdqmyqurQ/O4ePv8cGHfnsdc=; b=loBH+GJa4zPAi1JLMIl6YSBmT9PkeQNR0Z/sukvrTbLFZR2gNo78RJKAouRBxZXkiX x4qwd2NXlm3WiF9TdWX2r73jGSR3Qj4f1+b2JMn2ngp1Ehbxpxi+U9Dd/Hp7wxrsqtzf E+3vtzVr6IywrgjaiMvtEwilCqx36g8u0XG300a7W1Yv6qRyVDJrg4YlaPa4D6Pppv6B 76/WqGSDFMZ29aVUYCgm0ROiuMVLCDYrudRrJVHeklmpH8Y8tj1170YoVJfFsjNQzEzD 1sbex8IxdAQ+q76Fl9d+OCh6qROhkahmYO7DN/LCvl+3wp6N3Bz4GGU6cLd39y8TPkPZ /LCw== X-Gm-Message-State: AOJu0Yz36LVrNv+A3T5CCzt8npwUejPVCrg1/YaMXrWWzi7Fom2vcmYE mpM7ImJfe6gLTZZHR+P6IZcZmPsyR+tEg8IUB3AKYQxzL2lcOBu+o4M12wUmeJ9k9THFCNP6hoV zIr98QZIoQW0eLjBVeERvJ4C7pgGOHNS9LI4pAOhJJep2bS73IPAIluo4bXt2nKqzt7EdQ5905O YzwO+gO2rC8Ly9BOWI0FA7Ba8uJQ== X-Google-Smtp-Source: AGHT+IF/VVcq0q2HFZVgs0XnP3tsz9awQau2u9tqGE/EyDNtIWx67p5un+DCPyjL/VX/cn54XKMhHglZ6Q== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:902:d486:b0:206:a574:b4f1 with SMTP id d9443c01a7336-20782a68cfcmr17873365ad.8.1726687421442; Wed, 18 Sep 2024 12:23:41 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:52 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-25-tavip@google.com> Subject: [PATCH 24/25] systems/qtest: add device clock APIs From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::54a; envelope-from=3vSjrZgUKCvgyf0nulttlqj.htrvjrz-ij0jqstslsz.twl@flex--tavip.bounces.google.com; helo=mail-pg1-x54a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5, WEIRD_QUOTING=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687753917116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add qtest APIs to check the device clock frequency. Signed-off-by: Octavian Purdila --- include/hw/qdev-clock.h | 10 +++++++ tests/qtest/libqtest-single.h | 24 +++++++++++++++++ tests/qtest/libqtest.h | 22 +++++++++++++++ hw/core/qdev-clock.c | 2 +- system/qtest.c | 51 +++++++++++++++++++++++++++++++++++ tests/qtest/libqtest.c | 29 ++++++++++++++++++++ 6 files changed, 137 insertions(+), 1 deletion(-) diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h index ffa0f7ba09..19ed34ae88 100644 --- a/include/hw/qdev-clock.h +++ b/include/hw/qdev-clock.h @@ -15,6 +15,7 @@ #define QDEV_CLOCK_H =20 #include "hw/clock.h" +#include "hw/qdev-core.h" =20 /** * qdev_init_clock_in: @@ -161,4 +162,13 @@ typedef struct ClockPortInitElem ClockPortInitArray[]; */ void qdev_init_clocks(DeviceState *dev, const ClockPortInitArray clocks); =20 +/** + * qdev_get_clocklist: + * @dev: the device to find clock for + * @name: clock name + * + * Returns: a named clock list entry or NULL if the clock was not found + */ +NamedClockList *qdev_get_clocklist(DeviceState *dev, const char *name); + #endif /* QDEV_CLOCK_H */ diff --git a/tests/qtest/libqtest-single.h b/tests/qtest/libqtest-single.h index c22037c8b2..51eb69ff74 100644 --- a/tests/qtest/libqtest-single.h +++ b/tests/qtest/libqtest-single.h @@ -408,4 +408,28 @@ static inline int64_t clock_step(int64_t step) return qtest_clock_step(global_qtest, step); } =20 +/** + * qtest_qdev_clock_in_get_hz: + * @path: QOM path of a device. + * @name: Clock name. + * + * Returns: device clock frequency in HZ + */ +static inline uint64_t dev_clock_in_get_hz(const char *path, const char *n= ame) +{ + return qtest_dev_clock_in_get_hz(global_qtest, path, name); +} + +/** + * qtest_qdev_clock_out_get_hz: + * @path: QOM path of a device. + * @name: Clock name. + * + * Returns: device clock frequency in HZ + */ +static inline uint64_t dev_clock_out_get_hz(const char *path, const char *= name) +{ + return qtest_dev_clock_out_get_hz(global_qtest, path, name); +} + #endif diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index f9bbeb2e60..cfb7098985 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -1169,4 +1169,26 @@ bool have_qemu_img(void); */ bool mkimg(const char *file, const char *fmt, unsigned size_mb); =20 +/** + * qtest_qdev_clock_in_get_hz: + * @s: #QTestState instance to operate on. + * @path: QOM path of a device. + * @name: Clock name. + * + * Returns: device clock frequency in HZ + */ +uint64_t qtest_dev_clock_in_get_hz(QTestState *s, const char *path, + const char *name); + +/** + * qtest_qdev_clock_out_get_hz: + * @s: #QTestState instance to operate on. + * @path: QOM path of a device. + * @name: Clock name. + * + * Returns: device clock frequency in HZ + */ +uint64_t qtest_dev_clock_out_get_hz(QTestState *s, const char *path, + const char *name); + #endif diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c index 82799577f3..3c9e2d5d73 100644 --- a/hw/core/qdev-clock.c +++ b/hw/core/qdev-clock.c @@ -144,7 +144,7 @@ void qdev_init_clocks(DeviceState *dev, const ClockPort= InitArray clocks) } } =20 -static NamedClockList *qdev_get_clocklist(DeviceState *dev, const char *na= me) +NamedClockList *qdev_get_clocklist(DeviceState *dev, const char *name) { NamedClockList *ncl; =20 diff --git a/system/qtest.c b/system/qtest.c index 95bb80a2bc..465666a416 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -19,6 +19,7 @@ #include "exec/ioport.h" #include "exec/memory.h" #include "exec/tswap.h" +#include "hw/qdev-clock.h" #include "hw/qdev-core.h" #include "hw/irq.h" #include "hw/core/cpu.h" @@ -245,6 +246,20 @@ static void *qtest_server_send_opaque; * * Forcibly set the given interrupt pin to the given level. * + * Device clock frequency + * """""""""""""""""""""" + * + * .. code-block:: none + * + * > qdev_clock_out_get_hz QOM-PATH CLOCK-NAME + * < OK HZ + * + * .. code-block:: none + * + * > qdev_clock_in_get_hz QOM-PATH CLOCK-NAME + * < OK HZ + * + * where HZ is the clock frequency in hertz. */ =20 static int hex2nib(char ch) @@ -758,6 +773,42 @@ static void qtest_process_command(CharBackend *chr, gc= har **words) qtest_send_prefix(chr); qtest_sendf(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); + } else if (strcmp(words[0], "qdev_clock_in_get_hz") =3D=3D 0 || + strcmp(words[0], "qdev_clock_out_get_hz") =3D=3D 0) { + bool is_outbound =3D words[0][11] =3D=3D 'o'; + DeviceState *dev; + NamedClockList *ncl; + + g_assert(words[1]); + g_assert(words[2]); + + dev =3D DEVICE(object_resolve_path(words[1], NULL)); + if (!dev) { + qtest_send_prefix(chr); + qtest_send(chr, "FAIL Unknown device\n"); + return; + } + + ncl =3D qdev_get_clocklist(dev, words[2]); + if (!ncl) { + qtest_send_prefix(chr); + qtest_send(chr, "FAIL Unknown clock\n"); + return; + } + + if (is_outbound && !ncl->output) { + qtest_send_prefix(chr); + qtest_send(chr, "FAIL Not an output clock\n"); + return; + } + + if (!is_outbound && ncl->output) { + qtest_send_prefix(chr); + qtest_send(chr, "FAIL Not an input clock\n"); + return; + } + + qtest_sendf(chr, "OK %u\n", clock_get_hz(ncl->clock)); } else if (process_command_cb && process_command_cb(chr, words)) { /* Command got consumed by the callback handler */ } else { diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 4055d6b953..cc11b5f42e 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -2065,3 +2065,32 @@ bool mkimg(const char *file, const char *fmt, unsign= ed size_mb) =20 return ret && !err; } + +static uint64_t qtest_dev_clock_get_hz(QTestState *s, const char *path, + const char *name, bool out) +{ + gchar **args; + int ret; + uint64_t value; + + qtest_sendf(s, "qdev_clock_%s_get_hz %s %s\n", out ? "out" : "in", + path, name); + args =3D qtest_rsp_args(s, 2); + ret =3D qemu_strtou64(args[1], NULL, 0, &value); + g_assert(!ret); + g_strfreev(args); + + return value; +} + +uint64_t qtest_dev_clock_out_get_hz(QTestState *s, const char *path, + const char *name) +{ + return qtest_dev_clock_get_hz(s, path, name, true); +} + +uint64_t qtest_dev_clock_in_get_hz(QTestState *s, const char *path, + const char *name) +{ + return qtest_dev_clock_get_hz(s, path, name, false); +} --=20 2.46.0.662.g92d0881bb0-goog From nobody Sun Nov 24 02:38:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687499; cv=none; d=zohomail.com; s=zohoarc; b=MzWgiH9qWedOi8VVhxfLtur8fhYpYYtkczqB+Fd3FBYUA5bzcMEQY+9+FqtLjzXCEQtxRbVLY1WBR8QTACrSVVJTFc3eNexHJyA/8Yd7i5s30tfuzY3kP3QlAmT41++LO8Ov6XKyZ59wUd8z1uwvsLncHDjYhoOJrVsbAj+eZo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687499; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Gdr/8f8sshXupQWm/G/RvTijKtdDW7RFn/Icv2CMyog=; b=Q772TQuVq0jcjzIZKl+b9LHrz0418MCLrZM/9prtM+DH5XRuBbKRaOAF9mKoPXccbNcODp3Pt1Lq9u8Ah4jmyfFwDlwba7LY/I9b//mPqSlXb3RbkQw2rDQMQdzmFYgzTwRdy7DBVsrHsoTFHDD72kw+KVCjzpxZG2P67yxgSZM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687499579399.604764307241; Wed, 18 Sep 2024 12:24:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0HF-0006kS-VI; Wed, 18 Sep 2024 15:23:49 -0400 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 <3vyjrZgUKCvovcxkriqqing.eqosgow-fgxgnpqpipw.qti@flex--tavip.bounces.google.com>) id 1sr0HD-0006b0-OH for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:47 -0400 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3vyjrZgUKCvovcxkriqqing.eqosgow-fgxgnpqpipw.qti@flex--tavip.bounces.google.com>) id 1sr0HB-0007Ry-Oh for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:47 -0400 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6cf78470a56so1048287b3.3 for ; Wed, 18 Sep 2024 12:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687423; x=1727292223; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Gdr/8f8sshXupQWm/G/RvTijKtdDW7RFn/Icv2CMyog=; b=24MRqNA7KH7YpXj3ihxAdmlq3fGOqoh7L0hScpm4tN5bP1qKrU8DqAPAzMC2cdgJEt yteiQbXPVICs3N0kZlr356xew+7oDSz8ISg+lQUzmRVz3p2ca8q5aBMufCEkRwc+sG25 TiGVg5wdaVktFEngXVsqjYFWaQoKrYm8MVQyQDqk04IFWePGKVv09DZe1lZCmTSl2wgl bn+N+F4dqvPQb8YvRdtMXfKx6/Uf/hqAIYkUXeJ8vPIa0jpnQR+TTs1Qn9TNnEZmwvcB RT8DzAbdBKyrxjxxU9GIRJVZ4GodvI4qa9YdCyETutbPZ3oyDdrYu8Rx/rthAgJsO+jQ H1Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687423; x=1727292223; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Gdr/8f8sshXupQWm/G/RvTijKtdDW7RFn/Icv2CMyog=; b=xMx8PZPwYfjgOFXwbFNFwfmJlQT/p2KK6WewN2sd4qVRpkYbZ0h9yEFap3tfNoETCI v67IMLWLw9OOiCNrNEthW96Qk3z9IWYbCbFXomHMZiFea/OJKtCqDrkQLFnCUD+ssAnb AtVVxAAbKnwlZqsKcuk62Z0hNCcHrXmi2vNyyJiJVPHHrpgbS0Vj57pQigsxcm3r95hb koxUDbuQTHVHbooJ2+bd5ybLu1UL/TMdnwti8CMzMJezanIzdRB3gR3vLbRFd1cwKFxu ls0iFmCOVyfn/FQJXibc/g1Lvx1cg64WMBz76vdtKx0p/veyU/aa38drw6yS+gLHY5j+ PDCQ== X-Gm-Message-State: AOJu0YwUxaIGYmYRRdN+Cb1lrS/OcyDZ3gZJrBYlolCK39Tt027jrrbW Il2r+T6QPAnK7OEA54Ty7xq/GEyKUgFnmf7nXQV2au/Nr5yqwU8a5o/OUg5kPhAYzi3yplnRYz4 5dKj6XIo1AqSpCFu9vYtoNT35xHp6WpCaA/Nb19ZZpxwEudbymJmZ8zDF8SU8BaLZcfXm1cFQEW tkCjx5VFpaL2WpxjuJ2FFlhDeSdQ== X-Google-Smtp-Source: AGHT+IEFXnZp3tmrB4jcZJm99tMD7U5OnNJamHyzcf0v1PAJ4H44wNoKM+8dlPQOGGDiyYi7nqQjnDOfbQ== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a81:b302:0:b0:6dd:b9bb:360a with SMTP id 00721157ae682-6ddb9bb38e2mr4274857b3.1.1726687423152; Wed, 18 Sep 2024 12:23:43 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:53 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-26-tavip@google.com> Subject: [PATCH 25/25] tests/qtest: add tests for RT500's clock controller From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::114a; envelope-from=3vyjrZgUKCvovcxkriqqing.eqosgow-fgxgnpqpipw.qti@flex--tavip.bounces.google.com; helo=mail-yw1-x114a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687501115116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add test to exercise clocks set and clear, system PLL initialization, audio PLL initialization, systick and ostimer clock source selection. Signed-off-by: Octavian Purdila --- tests/qtest/rt500-clkctl-test.c | 195 ++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 1 + 2 files changed, 196 insertions(+) create mode 100644 tests/qtest/rt500-clkctl-test.c diff --git a/tests/qtest/rt500-clkctl-test.c b/tests/qtest/rt500-clkctl-tes= t.c new file mode 100644 index 0000000000..d5b83d81da --- /dev/null +++ b/tests/qtest/rt500-clkctl-test.c @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/main-loop.h" +#include "exec/memory.h" +#include "hw/clock.h" +#include "hw/irq.h" +#include "hw/qdev-clock.h" +#include "hw/qdev-properties.h" + +#include "hw/misc/rt500_clkctl0.h" +#include "hw/misc/rt500_clkctl1.h" +#include "hw/misc/rt500_clk_freqs.h" +#include "hw/arm/svd/rt500.h" +#include "reg-utils.h" + +#define SYSCLK_HZ 200000000 +#define CLKCTL0_NAME "/machine/soc/clkctl0" +#define CLKCTL1_NAME "/machine/soc/clkctl1" + +static void pscctl_test(gconstpointer user_data) +{ + /* rom controller clock should be enabled at reset */ + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, PSCCTL0, ROM_CTRLR_CLK) =3D= =3D 1); + + /* DSP clk is disabled at reset */ + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, PSCCTL0, DSP_CLK) =3D=3D 0); + + /* check PSCTL_SET functionality */ + REG32_WRITE_FIELD_NOUPDATE(RT500_CLKCTL0, PSCCTL0_SET, DSP_CLK, 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, PSCCTL0, DSP_CLK) =3D=3D 1); + + /* check PSCTL_CLR functionality */ + REG32_WRITE_FIELD_NOUPDATE(RT500_CLKCTL0, PSCCTL0_CLR, DSP_CLK, 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, PSCCTL0, DSP_CLK) =3D=3D 0); + + /* FLEXIO clk is disabled at reset */ + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, PSCCTL0, FlexIO) =3D=3D 0); + + /* check PSCTL_SET functionality */ + REG32_WRITE_FIELD_NOUPDATE(RT500_CLKCTL1, PSCCTL0_SET, FlexIO, 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, PSCCTL0, FlexIO) =3D=3D 1); + + /* check PSCTL_CLR functionality */ + REG32_WRITE_FIELD_NOUPDATE(RT500_CLKCTL1, PSCCTL0_CLR, FlexIO, 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, PSCCTL0, FlexIO) =3D=3D 0); +} + +static void audiopll0pfd_test(gconstpointer user_data) +{ + /* audio plls are gated at boot */ + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD3_CLKGATE) = =3D=3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD2_CLKGATE) = =3D=3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD1_CLKGATE) = =3D=3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD0_CLKGATE) = =3D=3D 1); + + /* ,,, and clocks are not ready */ + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD3_CLKRDY) = =3D=3D 0); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD2_CLKRDY) = =3D=3D 0); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD1_CLKRDY) = =3D=3D 0); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD0_CLKRDY) = =3D=3D 0); + + /* ungate all plls and check that clocks are ready */ + REG32_WRITE_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD3_CLKGATE, 0); + REG32_WRITE_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD2_CLKGATE, 0); + REG32_WRITE_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD1_CLKGATE, 0); + REG32_WRITE_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD0_CLKGATE, 0); + + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD3_CLKRDY) = =3D=3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD2_CLKRDY) = =3D=3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD1_CLKRDY) = =3D=3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL1, AUDIOPLL0PFD, PFD0_CLKRDY) = =3D=3D 1); +} + +static void syspll0pfd_test(gconstpointer user_data) +{ + /* system plls are gated at boot */ + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD3_CLKGATE) =3D= =3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD2_CLKGATE) =3D= =3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD1_CLKGATE) =3D= =3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD0_CLKGATE) =3D= =3D 1); + + /* ,,, and clocks are not ready */ + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD3_CLKRDY) =3D= =3D 0); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD2_CLKRDY) =3D= =3D 0); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD1_CLKRDY) =3D= =3D 0); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD0_CLKRDY) =3D= =3D 0); + + /* ungate all plls and check that clocks are ready */ + REG32_WRITE_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD3_CLKGATE, 0); + REG32_WRITE_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD2_CLKGATE, 0); + REG32_WRITE_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD1_CLKGATE, 0); + REG32_WRITE_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD0_CLKGATE, 0); + + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD3_CLKRDY) =3D= =3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD2_CLKRDY) =3D= =3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD1_CLKRDY) =3D= =3D 1); + g_assert(REG32_READ_FIELD(RT500_CLKCTL0, SYSPLL0PFD, PFD0_CLKRDY) =3D= =3D 1); +} + +static void systick_clk_test(gconstpointer user_data) +{ + /* systick is not running at reset */ + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL0_NAME, "systick_clk"), = =3D=3D, 0); + + /* select divout no divisor */ + REG32_WRITE_FIELD(RT500_CLKCTL0, SYSTICKFCLKSEL, SEL, + SYSTICKFCLKSEL_DIVOUT); + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL0_NAME, "systick_clk"), + =3D=3D, SYSCLK_HZ); + + /* change divisor to 2 */ + REG32_WRITE_FIELD(RT500_CLKCTL0, SYSTICKFCLKDIV, DIV, 1); + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL0_NAME, "systick_clk"), + =3D=3D, SYSCLK_HZ / 2); + + /* select lpsoc */ + REG32_WRITE_FIELD(RT500_CLKCTL0, SYSTICKFCLKSEL, SEL, + SYSTICKFCLKSEL_LPOSC); + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL0_NAME, "systick_clk"), + =3D=3D, LPOSC_CLK_HZ); + + /* select lpsoc */ + REG32_WRITE_FIELD(RT500_CLKCTL0, SYSTICKFCLKSEL, SEL, + SYSTICKFCLKSEL_32KHZRTC); + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL0_NAME, "systick_clk"), + =3D=3D, RTC32KHZ_CLK_HZ); + + /* disable clock */ + REG32_WRITE_FIELD(RT500_CLKCTL0, SYSTICKFCLKSEL, SEL, + SYSTICKFCLKSEL_NONE); + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL0_NAME, "systick_clk"), + =3D=3D, 0); +} + +static void ostimer_clk_test(gconstpointer user_data) +{ + /* systick is not running at reset */ + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL1_NAME, "ostimer_clk"), = =3D=3D, 0); + + /* select lpsoc */ + REG32_WRITE_FIELD(RT500_CLKCTL1, OSEVENTTFCLKSEL, SEL, + OSEVENTTFCLKSEL_LPOSC); + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL1_NAME, "ostimer_clk"), = =3D=3D, + LPOSC_CLK_HZ); + + /* select 32khz RTC */ + REG32_WRITE_FIELD(RT500_CLKCTL1, OSEVENTTFCLKSEL, SEL, + OSEVENTTFCLKSEL_32KHZRTC); + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL1_NAME, "ostimer_clk"), = =3D=3D, + RTC32KHZ_CLK_HZ); + + /* select hclk */ + REG32_WRITE_FIELD(RT500_CLKCTL1, OSEVENTTFCLKSEL, SEL, + OSEVENTTFCLKSEL_HCLK); + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL1_NAME, "ostimer_clk"), = =3D=3D, + SYSCLK_HZ); + + /* disable clock */ + REG32_WRITE_FIELD(RT500_CLKCTL1, OSEVENTTFCLKSEL, SEL, + OSEVENTTFCLKSEL_NONE); + g_assert_cmpuint(dev_clock_out_get_hz(CLKCTL1_NAME, "ostimer_clk"), = =3D=3D, 0); +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + + qtest_add_data_func("/rt500-clkctl/pscctl-test", NULL, pscctl_test); + qtest_add_data_func("/rt500-clkctl/syspll0pfd-test", NULL, + syspll0pfd_test); + qtest_add_data_func("/rt500-clkctl/audiopll0pfd-test", NULL, + audiopll0pfd_test); + g_test_add_data_func("/rt500-clkctl/systick-test", NULL, + systick_clk_test); + g_test_add_data_func("/rt500-clkctl/ostimer-clk-test", NULL, + ostimer_clk_test); + + qtest_start("-M rt595-evk"); + ret =3D g_test_run(); + qtest_end(); + + return ret; +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 2cb0fa08c0..101f6889f6 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -232,6 +232,7 @@ qtests_arm =3D \ (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') and config_all_devices.has_key('CONFIG_DM163')? ['dm163-test'] : []) + \ (config_all_devices.has_key('CONFIG_FLEXCOMM') ? ['flexcomm-test', 'flex= comm-usart-test', 'flexcomm-i2c-test', 'flexcomm-spi-test'] : []) + \ + (config_all_devices.has_key('CONFIG_RT500_CLKCTL') ? ['rt500-clkctl-test= '] : []) + \ ['arm-cpu-features', 'boot-serial-test'] =20 --=20 2.46.0.662.g92d0881bb0-goog