diff --git a/tp2bmc/patches/linux/0001-regulator-fixed-perserve-boot-state.patch b/tp2bmc/patches/linux/0001-regulator-fixed-perserve-boot-state.patch index 8b3857e7..c849b743 100644 --- a/tp2bmc/patches/linux/0001-regulator-fixed-perserve-boot-state.patch +++ b/tp2bmc/patches/linux/0001-regulator-fixed-perserve-boot-state.patch @@ -1,7 +1,7 @@ -From 0b07e2ee094cf855450eaade75836d8cf446664a Mon Sep 17 00:00:00 2001 +From c6135e0fbf2e5e1d6a5aa57b84179956bb45faba Mon Sep 17 00:00:00 2001 From: Sven Rademakers Date: Sun, 14 Jul 2024 17:26:39 +0100 -Subject: [PATCH] regulator-fixed: perserve boot state +Subject: [PATCH 1/2] regulator-fixed: perserve boot state Maintain a shadow bitmap of the latches in memory, so that when hot rebooting the initialization of those latches can be omitted. @@ -11,16 +11,16 @@ the initialization of those latches can be omitted. * added an get function that reads the shadow bitmap to check which latches are currently on. --- - drivers/gpio/gpio-latch.c | 80 ++++++++++++++++++++++++++++++--- + drivers/gpio/gpio-latch.c | 78 ++++++++++++++++++++++++++++++--- drivers/regulator/fixed.c | 23 ++++++---- include/linux/regulator/fixed.h | 1 + - 3 files changed, 91 insertions(+), 13 deletions(-) + 3 files changed, 89 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-latch.c b/drivers/gpio/gpio-latch.c -index d7c3b20c8482..71a9d43eed33 100644 +index d7c3b20c8482..ee6b17cab53b 100644 --- a/drivers/gpio/gpio-latch.c +++ b/drivers/gpio/gpio-latch.c -@@ -45,8 +45,12 @@ +@@ -45,8 +45,11 @@ #include #include #include @@ -28,12 +28,11 @@ index d7c3b20c8482..71a9d43eed33 100644 +#include #include "gpiolib.h" -+#define LABEL_NVMEM_CELL "latch_state" +#define TURING_PI2_LATCH_STATE_ADDR 0x0709010c struct gpio_latch_priv { struct gpio_chip gc; -@@ -56,6 +60,7 @@ struct gpio_latch_priv { +@@ -56,6 +59,7 @@ struct gpio_latch_priv { unsigned int setup_duration_ns; unsigned int clock_duration_ns; unsigned long *shadow; @@ -41,7 +40,7 @@ index d7c3b20c8482..71a9d43eed33 100644 /* * Depending on whether any of the underlying GPIOs may sleep we either * use a mutex or a spinlock to protect our shadow map. -@@ -68,7 +73,16 @@ struct gpio_latch_priv { +@@ -68,7 +72,16 @@ struct gpio_latch_priv { static int gpio_latch_get_direction(struct gpio_chip *gc, unsigned int offset) { @@ -59,7 +58,7 @@ index d7c3b20c8482..71a9d43eed33 100644 } static void gpio_latch_set_unlocked(struct gpio_latch_priv *priv, -@@ -78,16 +92,21 @@ static void gpio_latch_set_unlocked(struct gpio_latch_priv *priv, +@@ -78,16 +91,20 @@ static void gpio_latch_set_unlocked(struct gpio_latch_priv *priv, int latch = offset / priv->n_latched_gpios; int i; @@ -78,12 +77,11 @@ index d7c3b20c8482..71a9d43eed33 100644 ndelay(priv->clock_duration_ns); set(priv->clk_gpios->desc[latch], 0); + -+ printk(KERN_DEBUG "gpio_latch: write: 0x%x", buffer); + memcpy_toio(priv->shadow, &buffer, sizeof(unsigned long)); } static void gpio_latch_set(struct gpio_chip *gc, unsigned int offset, int val) -@@ -128,6 +147,48 @@ static bool gpio_latch_can_sleep(struct gpio_latch_priv *priv, unsigned int n_la +@@ -128,6 +145,48 @@ static bool gpio_latch_can_sleep(struct gpio_latch_priv *priv, unsigned int n_la return false; } @@ -132,7 +130,7 @@ index d7c3b20c8482..71a9d43eed33 100644 /* * Some value which is still acceptable to delay in atomic context. * If we need to go higher we might have to switch to usleep_range(), -@@ -157,8 +218,7 @@ static int gpio_latch_probe(struct platform_device *pdev) +@@ -157,8 +216,7 @@ static int gpio_latch_probe(struct platform_device *pdev) n_latches = priv->clk_gpios->ndescs; priv->n_latched_gpios = priv->latched_gpios->ndescs; @@ -142,7 +140,7 @@ index d7c3b20c8482..71a9d43eed33 100644 if (!priv->shadow) return -ENOMEM; -@@ -187,6 +247,9 @@ static int gpio_latch_probe(struct platform_device *pdev) +@@ -187,6 +245,9 @@ static int gpio_latch_probe(struct platform_device *pdev) } priv->gc.get_direction = gpio_latch_get_direction; @@ -152,7 +150,7 @@ index d7c3b20c8482..71a9d43eed33 100644 priv->gc.ngpio = n_latches * priv->n_latched_gpios; priv->gc.owner = THIS_MODULE; priv->gc.base = -1; -@@ -197,6 +260,12 @@ static int gpio_latch_probe(struct platform_device *pdev) +@@ -197,6 +258,12 @@ static int gpio_latch_probe(struct platform_device *pdev) return devm_gpiochip_add_data(&pdev->dev, &priv->gc, priv); } @@ -165,7 +163,7 @@ index d7c3b20c8482..71a9d43eed33 100644 static const struct of_device_id gpio_latch_ids[] = { { .compatible = "gpio-latch", -@@ -211,6 +280,7 @@ static struct platform_driver gpio_latch_driver = { +@@ -211,6 +278,7 @@ static struct platform_driver gpio_latch_driver = { .of_match_table = gpio_latch_ids, }, .probe = gpio_latch_probe, diff --git a/tp2bmc/patches/linux/9000-Add-turingmachines-tp2-nodes-compat.patch b/tp2bmc/patches/linux/0002-gpio-aggregator-Add-turingmachines-tp2-nodes-compati.patch similarity index 59% rename from tp2bmc/patches/linux/9000-Add-turingmachines-tp2-nodes-compat.patch rename to tp2bmc/patches/linux/0002-gpio-aggregator-Add-turingmachines-tp2-nodes-compati.patch index 07c2066e..186a66ae 100644 --- a/tp2bmc/patches/linux/9000-Add-turingmachines-tp2-nodes-compat.patch +++ b/tp2bmc/patches/linux/0002-gpio-aggregator-Add-turingmachines-tp2-nodes-compati.patch @@ -1,7 +1,7 @@ -From 81d9505285d3ac75b26d7db97ff88b3bb4c3280c Mon Sep 17 00:00:00 2001 +From 11b63ef4e71e30e3736cd69a00b8d0618a7867b7 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 20 May 2023 20:53:14 -0600 -Subject: [PATCH 3/3] gpio: aggregator: Add "turingmachines,tp2-nodes" +Subject: [PATCH 2/2] gpio: aggregator: Add "turingmachines,tp2-nodes" compatible --- @@ -9,17 +9,17 @@ Subject: [PATCH 3/3] gpio: aggregator: Add "turingmachines,tp2-nodes" 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c -index 9b0adbdddbfc..92afa9ce8a77 100644 +index 38e0fff9afe7..e128be5d13eb 100644 --- a/drivers/gpio/gpio-aggregator.c +++ b/drivers/gpio/gpio-aggregator.c -@@ -536,6 +536,7 @@ static const struct of_device_id gpio_aggregator_dt_ids[] = { +@@ -605,6 +605,7 @@ static const struct of_device_id gpio_aggregator_dt_ids[] = { * Add GPIO-operated devices controlled from userspace below, - * or use "driver_override" in sysfs + * or use "driver_override" in sysfs. */ -+ { .compatible = "turing,pi2-nodes", }, ++ { .compatible = "turing,pi2-nodes", }, {} }; MODULE_DEVICE_TABLE(of, gpio_aggregator_dt_ids); -- -2.39.2 +2.45.2 diff --git a/tp2bmc/patches/linux/Add-support-for-Allwinner-PWM-on-D1-T113s-R329-SoCs.patch b/tp2bmc/patches/linux/Add-support-for-Allwinner-PWM-on-D1-T113s-R329-SoCs.patch index cb59ba93..5b5f2d01 100644 --- a/tp2bmc/patches/linux/Add-support-for-Allwinner-PWM-on-D1-T113s-R329-SoCs.patch +++ b/tp2bmc/patches/linux/Add-support-for-Allwinner-PWM-on-D1-T113s-R329-SoCs.patch @@ -1,127 +1,8 @@ -From patchwork Wed Jan 31 12:59:14 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Aleksandr Shubin -X-Patchwork-Id: 13539410 -Return-Path: - -X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on - aws-us-west-2-korg-lkml-1.web.codeaurora.org -Received: from bombadil.infradead.org (bombadil.infradead.org - [198.137.202.133]) - (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) - (No client certificate requested) - by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BEEAC47258 - for ; - Wed, 31 Jan 2024 13:00:05 +0000 (UTC) -DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; - d=lists.infradead.org; s=bombadil.20210309; h=Sender: - Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: - List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: - Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: - Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: - List-Owner; bh=g1avdJr9EJbJhAmFKWysfcYn65vylVycwGiaX+hUb+o=; b=qJtfaBnCTnBg9f - YZ84ncy3NjfvP6YVQs++N3Xrikv42qq6A+jZvX3dB+8spts2/YuHy9/hD46xKkB/UVV/97W85eRdx - I3v9z0huZmP0ogDJhL6UcTSgX+0yORQyW16fU0FJE8ut0frM4xixzO6IzAEFTXE2OFVJcGxpkyiOa - S1D/ZgzPmLweQhBebygjUNIyfWaeifVx2ivI1BKIXOIAAHhYQerbmdWReNfECOk9BuJ4TY44888cK - YbGK4JqBp1bggdAH0XqDxHQGtC/HJe2aNNzOaRAWs8CUgcK3dINLPDKXUSFNamEuDuSdNXbUnj5f1 - kMUKFRoNwhbDyJrdTcUw==; -Received: from localhost ([::1] helo=bombadil.infradead.org) - by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) - id 1rVAC1-00000003TNy-3ecH; - Wed, 31 Jan 2024 12:59:53 +0000 -Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) - by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) - id 1rVABy-00000003TJP-1XnP; - Wed, 31 Jan 2024 12:59:51 +0000 -Received: by mail-lf1-x135.google.com with SMTP id - 2adb3069b0e04-511207d62b6so2041513e87.1; - Wed, 31 Jan 2024 04:59:48 -0800 (PST) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=gmail.com; s=20230601; t=1706705987; x=1707310787; - darn=lists.infradead.org; - h=content-transfer-encoding:mime-version:references:in-reply-to - :message-id:date:subject:cc:to:from:from:to:cc:subject:date - :message-id:reply-to; - bh=oAfvNX5JYKiOP5F5+HHWWQpkc2VYumz0VDstxq+2dC0=; - b=CVhEpK0EuUx9RJ9FqqEJVNWrQvaFplEK6S+34FR9Dd/e3HumsXMlt+cdMdLD5dVTwL - Bv4cA3+I11kmI8UOsEyZyFwYScwmYE59DXsOFt/QGdDwo82VfAXV20cw/s2bf5F8Sh7e - J7hdugbWtX8VZoi0RYMCu/nkhkxqOPHaUQ6tOlqIeX7gMaOyphyQs/1dz8yJB2Olq/vE - donWx67qVjpTCOvoNPUbXxUXqCVIKc0tGI4DztRgZ82KOwJby50oos2XgLagZ/cmA2wY - aAPq/ZVBOytX4VJlv85a8/s9gyOS/ZUzNljl0Fd3VoOnOOxSFahMq/WsyGY2DtVpvIOQ - uYfw== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1706705987; x=1707310787; - h=content-transfer-encoding:mime-version:references:in-reply-to - :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=oAfvNX5JYKiOP5F5+HHWWQpkc2VYumz0VDstxq+2dC0=; - b=LzLnyq20+YKN1ZefzSuKqNoEU+9QTxnjnUw7PzG2NxJ3Qa44bRvy3N/o+EJ/pMjWuA - vdZjmrhZ6ZloyxF027pOTEJXI9FrvJJcAGsJm7LoF1drBKdO5UQfUJqlIMGIqms+UaSb - yYzmwW6HgmTjjC2Zp0Lsrlzw1WGt7bHA7oLfH32bX07I2cdJbqP/9kSZBOWAiyM8Rwj/ - 4JFxuQ1v2YQTl0r0jh/2S1s+OJpZm1SSY4nm5Tb0sMoHmwXrKEbh4DKrRQVXu/V1VU3x - E5levz55NwMzh560trRUOQ8UX1J9mj8YKp/XzRd7cFQUPysme5UCIH9p2+ksSLVziXbN - +dsQ== -X-Gm-Message-State: AOJu0YxPUJbxjg/91sbZzmMZcVyA6CP+2kbxoaSCMg8Rg8MMN0s5IvSf - lKyMT4ZAAp1/l0miyYmByMqBEZyAYI3fcXo5gajcwJ/kK+6J940= -X-Google-Smtp-Source: - AGHT+IHozbh85wcnYCXZXYDLJCLM9XGLrWwtHro3SkQvoxBuxVb086cAn/J1lYCBdkXRqYub3zJ7qw== -X-Received: by 2002:ac2:4950:0:b0:50e:9355:a24b with SMTP id - o16-20020ac24950000000b0050e9355a24bmr1003200lfi.22.1706705986343; - Wed, 31 Jan 2024 04:59:46 -0800 (PST) -Received: from localhost.localdomain ([188.162.49.60]) - by smtp.gmail.com with ESMTPSA id - h25-20020a19ca59000000b00510faaa62cfsm1361135lfj.222.2024.01.31.04.59.43 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 31 Jan 2024 04:59:45 -0800 (PST) +From 0ade3a4309c6f9ef34aba51aaf1a866cae48481e Mon Sep 17 00:00:00 2001 From: Aleksandr Shubin -To: linux-kernel@vger.kernel.org -Cc: Aleksandr Shubin , - Conor Dooley , - =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , - Rob Herring , - Krzysztof Kozlowski , - Conor Dooley , Chen-Yu Tsai , - Jernej Skrabec , - Samuel Holland , - Paul Walmsley , - Palmer Dabbelt , Albert Ou , - Philipp Zabel , - Marc Kleine-Budde , - Maksim Kiselev , - Cristian Ciocaltea , - John Watts , Cheo Fusi , - linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, - linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, - linux-riscv@lists.infradead.org -Subject: [PATCH v8 1/3] dt-bindings: pwm: Add binding for Allwinner - D1/T113-S3/R329 PWM controller Date: Wed, 31 Jan 2024 15:59:14 +0300 -Message-Id: <20240131125920.2879433-2-privatesub2@gmail.com> -X-Mailer: git-send-email 2.25.1 -In-Reply-To: <20240131125920.2879433-1-privatesub2@gmail.com> -References: <20240131125920.2879433-1-privatesub2@gmail.com> -MIME-Version: 1.0 -X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 -X-CRM114-CacheID: sfid-20240131_045950_454851_364D21BE -X-CRM114-Status: GOOD ( 15.47 ) -X-BeenThere: linux-arm-kernel@lists.infradead.org -X-Mailman-Version: 2.1.34 -Precedence: list -List-Id: -List-Unsubscribe: - , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: - , - -Sender: "linux-arm-kernel" -Errors-To: - linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org +Subject: [PATCH 1/3] dt-bindings: pwm: Add binding for Allwinner + D1/T113-S3/R329 PWM controller Allwinner's D1, T113-S3 and R329 SoCs have a new pwm controller witch is different from the previous pwm-sun4i. @@ -241,128 +122,14 @@ index 000000000000..716f75776006 + }; + +... +-- +2.45.2 + -From patchwork Wed Jan 31 12:59:15 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 8bit -X-Patchwork-Submitter: Aleksandr Shubin -X-Patchwork-Id: 13539411 -Return-Path: - -X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on - aws-us-west-2-korg-lkml-1.web.codeaurora.org -Received: from bombadil.infradead.org (bombadil.infradead.org - [198.137.202.133]) - (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) - (No client certificate requested) - by smtp.lore.kernel.org (Postfix) with ESMTPS id 03CF9C47DB3 - for ; - Wed, 31 Jan 2024 13:00:30 +0000 (UTC) -DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; - d=lists.infradead.org; s=bombadil.20210309; h=Sender: - Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: - List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: - Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: - Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: - List-Owner; bh=s0NxbtQs25ewdS+vQ+JYVT89daQdLz5+ks95gu+AWN0=; b=n4SyeHnbtYg49M - 672QEfb6Zcm8Mlq1MUyeMMlIhFQs0oinHZctMe/0zV1ZGZ5i5wNrpR8m21JOcEXtI9N2PTVU+GtJm - 6Ska4t6ZCS4ejfkVqoVkuSe4F8Yy+urA6TqOP8puECL8IFnasytXrSCiuU0O99TCNivN8i2D0088d - oG8LeiieGlLVx1uq58yS9pijxOVTMyt+poGxrFbm1xCuhLesc98t0HXcoh9Ut+lKbbr7ACU9DBhGM - wxRAjG+cOeq3wNikWxJucRq/Wis7KHZ3D0XGj9F69kKLaAHxYu9+8DulbkmdMKqR741Qy5FmGBs+O - Awjp428vTr0pXxwYInLg==; -Received: from localhost ([::1] helo=bombadil.infradead.org) - by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) - id 1rVACK-00000003TdO-1hFY; - Wed, 31 Jan 2024 13:00:12 +0000 -Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) - by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) - id 1rVAC5-00000003TOW-1ggL; - Wed, 31 Jan 2024 13:00:00 +0000 -Received: by mail-lf1-x133.google.com with SMTP id - 2adb3069b0e04-511207d62b6so2041717e87.1; - Wed, 31 Jan 2024 04:59:55 -0800 (PST) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=gmail.com; s=20230601; t=1706705994; x=1707310794; - darn=lists.infradead.org; - h=content-transfer-encoding:mime-version:references:in-reply-to - :message-id:date:subject:cc:to:from:from:to:cc:subject:date - :message-id:reply-to; - bh=LJEpMRsYLlgFAcmZofqzHXt8kLBT+ut7O+m2hghOxj0=; - b=hxHe2gaiQULu5vEkbW8wwFAGL/Hf609zhJVJw3f4WYhl+RuhK4+aO72wxObzzeUI25 - bn5rrWfkLm1JYi4KGzsG5eKZshNmtXj6aqSD5qlfrlukL16aBWK3wJvZts/2Ti5N4QSK - nv7zsPAvVRJq+oZwU93rsBNDuX4eZqGX6sghWKTVgoWsW8LcHKc7pRULn+gwXXOf6G4l - YS7YWqatVs0LGfZnzA5rYwxSpcdGDkI9Dfxbz38Nnz7XOjwlcQgQ32/X9raTVqxxOICa - kpZKigNB/rXmyTTEn69Vfw5EsaIICCrXBeeLl+jctSIN9X0uICwloEFY3K0uHZQKQSSd - E75g== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1706705994; x=1707310794; - h=content-transfer-encoding:mime-version:references:in-reply-to - :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=LJEpMRsYLlgFAcmZofqzHXt8kLBT+ut7O+m2hghOxj0=; - b=jDFR+WsuUNfHnbJWLK84JOb2/VHg1iaDfuYF91dfug2Mwh9i6XSHXGunU31z2ScaU7 - Pg4vR4gSbN1wKwM+yPerEoWdvMus57PpUyUp/fAzU8UTiJZ2I1NWL9U4xEm6JKebokLs - D62DsJs+6ZmSdKVhBhCFB9RTL4lBXQqbcsqsz16CncBS+dhKC8Y615QM692eyMsfdugo - 55N4pGwEmCudCAimOIM2pMvLesOkEwTv8Ca3MZewyU645rL0elBf53B3Y3hk1Y/yyMT6 - GvLxSEMY2XgS6+KonU4sonHQqakSlUn5SGagcFe10nYoJzt+7LzAiqC13zjnT6+B6j6P - 9dwg== -X-Gm-Message-State: AOJu0YxDo1dgJrid0u1rqbfrQDdSGpXdKVofRaw7o7ji1Qn1WUvSipCO - GSiXBKCqaUCuvJn6WwBvkToEYnBVq7nKQIFWTo+sDaFbd4hcUdM= -X-Google-Smtp-Source: - AGHT+IGtgxJeyTQhG/aZasLr02uoyai6dB5Gw7iYCnTUM1O222ECB10oOjsvDI3WT6CNzRqjzcrFkA== -X-Received: by 2002:a05:6512:ea0:b0:510:1b51:e431 with SMTP id - bi32-20020a0565120ea000b005101b51e431mr1592192lfb.4.1706705993605; - Wed, 31 Jan 2024 04:59:53 -0800 (PST) -Received: from localhost.localdomain ([188.162.49.60]) - by smtp.gmail.com with ESMTPSA id - h25-20020a19ca59000000b00510faaa62cfsm1361135lfj.222.2024.01.31.04.59.50 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 31 Jan 2024 04:59:53 -0800 (PST) +From c512c54f99e61e40c6363f5a03a8d4ca5abddf05 Mon Sep 17 00:00:00 2001 From: Aleksandr Shubin -To: linux-kernel@vger.kernel.org -Cc: Aleksandr Shubin , - Brandon Cheo Fusi , =?utf-8?q?Uwe_Kleine-K=C3=B6ni?= - =?utf-8?q?g?= , - Rob Herring , - Krzysztof Kozlowski , - Conor Dooley , Chen-Yu Tsai , - Jernej Skrabec , - Samuel Holland , - Paul Walmsley , - Palmer Dabbelt , Albert Ou , - Philipp Zabel , - Cristian Ciocaltea , - John Watts , Marc Kleine-Budde , - Maksim Kiselev , linux-pwm@vger.kernel.org, - devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, - linux-sunxi@lists.linux.dev, linux-riscv@lists.infradead.org -Subject: [PATCH v8 2/3] pwm: Add Allwinner's D1/T113-S3/R329 SoCs PWM support Date: Wed, 31 Jan 2024 15:59:15 +0300 -Message-Id: <20240131125920.2879433-3-privatesub2@gmail.com> -X-Mailer: git-send-email 2.25.1 -In-Reply-To: <20240131125920.2879433-1-privatesub2@gmail.com> -References: <20240131125920.2879433-1-privatesub2@gmail.com> -MIME-Version: 1.0 -X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 -X-CRM114-CacheID: sfid-20240131_045957_628592_EEA312F1 -X-CRM114-Status: GOOD ( 31.42 ) -X-BeenThere: linux-arm-kernel@lists.infradead.org -X-Mailman-Version: 2.1.34 -Precedence: list -List-Id: -List-Unsubscribe: - , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: - , - -Sender: "linux-arm-kernel" -Errors-To: - linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org +Subject: [PATCH 2/3] pwm: Add Allwinner's D1/T113-S3/R329 SoCs PWM support Allwinner's D1, T113-S3 and R329 SoCs have a quite different PWM controllers with ones supported by pwm-sun4i driver. @@ -800,128 +567,14 @@ index 000000000000..19bf3f495155 +MODULE_AUTHOR("Aleksandr Shubin "); +MODULE_DESCRIPTION("Allwinner sun20i PWM driver"); +MODULE_LICENSE("GPL"); +-- +2.45.2 -From patchwork Wed Jan 31 12:59:16 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Aleksandr Shubin -X-Patchwork-Id: 13539412 -Return-Path: - -X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on - aws-us-west-2-korg-lkml-1.web.codeaurora.org -Received: from bombadil.infradead.org (bombadil.infradead.org - [198.137.202.133]) - (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) - (No client certificate requested) - by smtp.lore.kernel.org (Postfix) with ESMTPS id 51419C47258 - for ; - Wed, 31 Jan 2024 13:00:43 +0000 (UTC) -DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; - d=lists.infradead.org; s=bombadil.20210309; h=Sender: - Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: - List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: - Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: - Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: - List-Owner; bh=c2S3MnnlfH3cC6yGru/ZdOx4a33A75T+65kq7cjRgkE=; b=WHXjWaL/e1NiPQ - eGJjN3b5I3tYI9D8fhDRMpQA3N7K4pcjJN2I5UM2vmdVoqvw0BLRBs8XXD/solz9f6uoBYim3N2EX - OxYyvzMCs9mgQ/Uk47sv2DEzHmCtkJUUNQT+AoAHTPxk8eMPVyhFb2p1AbQW0MpZ9qpq/tTikqN1m - tvNvqKLy+kUQcqyr1nfxB3PRrk1iSDWnFpWJ402otIcQPtiOhcI9Oy0SjIEkRRF0QgUcXMDKWCn9X - Odzr3Hq8mLK3rAnv7P7IClXtySm0KtTo5NLANaakf7OOhtCZZu/VaXUBfrdsX8PJvJPFaxR4fnZgd - kDyjcsvZOIkiBbOLfSBw==; -Received: from localhost ([::1] helo=bombadil.infradead.org) - by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) - id 1rVACX-00000003Tmd-0BOT; - Wed, 31 Jan 2024 13:00:25 +0000 -Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) - by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) - id 1rVACB-00000003TTo-2f1o; - Wed, 31 Jan 2024 13:00:06 +0000 -Received: by mail-lf1-x12f.google.com with SMTP id - 2adb3069b0e04-51025cafb51so7505797e87.2; - Wed, 31 Jan 2024 05:00:02 -0800 (PST) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=gmail.com; s=20230601; t=1706706000; x=1707310800; - darn=lists.infradead.org; - h=content-transfer-encoding:mime-version:references:in-reply-to - :message-id:date:subject:cc:to:from:from:to:cc:subject:date - :message-id:reply-to; - bh=Qk5axihAKFS9+0dIUTMZ/jrL2YTkFropx3eyJ2mG6qU=; - b=XXPay0935Bp3pcCfiTxOn6Snscj9Nw7mGd+7gjuCwgc5LUKMv7ZsEJ3hVQtIp2WKqV - KAdMVnQgC/mEGsxAREUUDhlKEiuI6DSRsck4312ZRQ6EtnZ3Cc8B/QrXq4tGIpXDqGCn - wG/PCG0hnkKev8JmTsTOdoTVqhUQeuxAp3cKJsrzWzlq5C8+W48kVU5QWM2v7/7o6LiV - bxqMEidvvY9UuP+GgLkogYAp6+ZM9369xaWoIQVVpOavqXhQiXfpDE9eX2XQGAg6etl+ - 2eneFQJHS79KiWae0ZRbl3wBarv6XEVpx/VLPFXzcgCzDtfRQJbRWS0x3TzSKcQiaIz2 - +Tfw== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1706706000; x=1707310800; - h=content-transfer-encoding:mime-version:references:in-reply-to - :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=Qk5axihAKFS9+0dIUTMZ/jrL2YTkFropx3eyJ2mG6qU=; - b=EYGM5gI80pwV/nUPGWTbaVpk8itS3amBZfU61xVQYpoPfZ+1nci7PmKeycitnMisb5 - s9ZLDtXa45W8xcav5kKFWlXL1BkqqKjz0dZXQ57NSbIlCmgDutDx5P+PE8snq2PevdQ9 - Vo6Ol7xeDXsVQRPgrCYeIFnRJ70/3wJKtKDM60NT/SKNpjMzCNs663SitWsC4kZeqX6S - ivtV9/HMc0oJe2IIdoOwcjC9S4iZA1VXn3qvXK2OJRZ6shMaZ4tniKZS1k2tTQlo+jgo - cBbAM6j18gdqe7V+qV95p0aMYEcWU3mBDMD0A8vLO/3Dr8OworeWqnhwPIb0n24ahDWj - ZTnw== -X-Gm-Message-State: AOJu0Yxaw92L+7QpsBH4rCE3NXOZWq6wwt7+AwMlx1hOGok+a+V5iXLn - wluPIJKfm4yZ4OxQzM8zZtGiNI3tpob6VJCEXSX6kSn8R14GYb8= -X-Google-Smtp-Source: - AGHT+IFlj/2UQlXVTsP85U+sX9Z4Xg+m+7M8urgFGxXNNIrMtV2ixCb6BE8A2Y9DZeChVhyFjSIIgA== -X-Received: by 2002:a05:6512:3b93:b0:511:1ed7:61bd with SMTP id - g19-20020a0565123b9300b005111ed761bdmr1608967lfv.54.1706706000644; - Wed, 31 Jan 2024 05:00:00 -0800 (PST) -Received: from localhost.localdomain ([188.162.49.60]) - by smtp.gmail.com with ESMTPSA id - h25-20020a19ca59000000b00510faaa62cfsm1361135lfj.222.2024.01.31.04.59.57 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 31 Jan 2024 04:59:59 -0800 (PST) + +From 8ff94844f724956f6b2a28a2b5a7a2f28061fa7a Mon Sep 17 00:00:00 2001 From: Aleksandr Shubin -To: linux-kernel@vger.kernel.org -Cc: Aleksandr Shubin , =?utf-8?q?Uwe_Kleine-K=C3=B6ni?= - =?utf-8?q?g?= , - Rob Herring , - Krzysztof Kozlowski , - Conor Dooley , Chen-Yu Tsai , - Jernej Skrabec , - Samuel Holland , - Paul Walmsley , - Palmer Dabbelt , Albert Ou , - Philipp Zabel , - Maksim Kiselev , - Cristian Ciocaltea , - Marc Kleine-Budde , John Watts , - Cheo Fusi , linux-pwm@vger.kernel.org, - devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, - linux-sunxi@lists.linux.dev, linux-riscv@lists.infradead.org -Subject: [PATCH v8 3/3] riscv: dts: allwinner: d1: Add pwm node Date: Wed, 31 Jan 2024 15:59:16 +0300 -Message-Id: <20240131125920.2879433-4-privatesub2@gmail.com> -X-Mailer: git-send-email 2.25.1 -In-Reply-To: <20240131125920.2879433-1-privatesub2@gmail.com> -References: <20240131125920.2879433-1-privatesub2@gmail.com> -MIME-Version: 1.0 -X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 -X-CRM114-CacheID: sfid-20240131_050003_781094_6C718EFA -X-CRM114-Status: GOOD ( 11.29 ) -X-BeenThere: linux-arm-kernel@lists.infradead.org -X-Mailman-Version: 2.1.34 -Precedence: list -List-Id: -List-Unsubscribe: - , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: - , - -Sender: "linux-arm-kernel" -Errors-To: - linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org +Subject: [PATCH 3/3] riscv: dts: allwinner: d1: Add pwm node D1 and T113s contain a pwm controller with 8 channels. This controller is supported by the sun20i-pwm driver. @@ -957,3 +610,6 @@ index 5a9d7f5a75b4..435a1e66aa6a 100644 ccu: clock-controller@2001000 { compatible = "allwinner,sun20i-d1-ccu"; reg = <0x2001000 0x1000>; +-- +2.45.2 + diff --git a/tp2bmc/patches/linux/i2c.patch b/tp2bmc/patches/linux/i2c.patch index 7781c5b6..3c6b57bd 100644 --- a/tp2bmc/patches/linux/i2c.patch +++ b/tp2bmc/patches/linux/i2c.patch @@ -1,4 +1,4 @@ -From ea22df4372eb4114242d52f77122a9a2af449c42 Mon Sep 17 00:00:00 2001 +From ee66a87c03cf41932978f2f28ec77808a12ce5b4 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 19 Mar 2024 16:51:51 -0600 Subject: [PATCH 1/5] i2c: mv64xxx: Clear bus errors before transfer @@ -30,10 +30,10 @@ Signed-off-by: Sam Edwards 1 file changed, 6 insertions(+) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c -index fd8403b07fa6..cfc16909fba3 100644 +index dc160cbc3155..958c52c799d4 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c -@@ -753,6 +753,7 @@ mv64xxx_i2c_xfer_core(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) +@@ -752,6 +752,7 @@ mv64xxx_i2c_xfer_core(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) { struct mv64xxx_i2c_data *drv_data = i2c_get_adapdata(adap); int rc, ret = num; @@ -41,7 +41,7 @@ index fd8403b07fa6..cfc16909fba3 100644 rc = pm_runtime_resume_and_get(&adap->dev); if (rc) -@@ -762,6 +763,11 @@ mv64xxx_i2c_xfer_core(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) +@@ -761,6 +762,11 @@ mv64xxx_i2c_xfer_core(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) drv_data->msgs = msgs; drv_data->num_msgs = num; @@ -54,10 +54,10 @@ index fd8403b07fa6..cfc16909fba3 100644 rc = mv64xxx_i2c_offload_xfer(drv_data); else -- -2.43.2 +2.45.2 -From 320ff147586aed8828b09cf04b79acbe4edfde41 Mon Sep 17 00:00:00 2001 +From aedfcd08fe249fe54515a3fbb28a474db7ee8851 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 19 Mar 2024 16:52:10 -0600 Subject: [PATCH 2/5] i2c: mv64xxx: Clean up the private data struct @@ -73,10 +73,10 @@ Signed-off-by: Sam Edwards 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c -index cfc16909fba3..bb048e655be7 100644 +index 958c52c799d4..8b931c803f30 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c -@@ -83,7 +83,7 @@ +@@ -82,7 +82,7 @@ #define MV64XXX_I2C_BRIDGE_STATUS_ERROR BIT(0) /* Driver states */ @@ -85,7 +85,7 @@ index cfc16909fba3..bb048e655be7 100644 MV64XXX_I2C_STATE_INVALID, MV64XXX_I2C_STATE_IDLE, MV64XXX_I2C_STATE_WAITING_FOR_START_COND, -@@ -95,7 +95,7 @@ enum { +@@ -94,7 +94,7 @@ enum { }; /* Driver actions */ @@ -94,7 +94,7 @@ index cfc16909fba3..bb048e655be7 100644 MV64XXX_I2C_ACTION_INVALID, MV64XXX_I2C_ACTION_CONTINUE, MV64XXX_I2C_ACTION_SEND_RESTART, -@@ -121,21 +121,21 @@ struct mv64xxx_i2c_data { +@@ -120,21 +120,21 @@ struct mv64xxx_i2c_data { struct i2c_msg *msgs; int num_msgs; int irq; @@ -128,10 +128,10 @@ index cfc16909fba3..bb048e655be7 100644 struct clk *reg_clk; wait_queue_head_t waitq; -- -2.43.2 +2.45.2 -From 892d0f467511d5de00ef520189e0128391ab88bc Mon Sep 17 00:00:00 2001 +From bb4cc1d84b21d54da170fc2a037563bd5350ffaa Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 19 Mar 2024 16:52:15 -0600 Subject: [PATCH 3/5] i2c: mv64xxx: Refactor FSM @@ -164,7 +164,7 @@ Signed-off-by: Sam Edwards 1 file changed, 186 insertions(+), 85 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c -index bb048e655be7..dfbbedc95318 100644 +index 8b931c803f30..2ead2d39dc3f 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -4,10 +4,12 @@ @@ -184,7 +184,7 @@ index bb048e655be7..dfbbedc95318 100644 */ #include #include -@@ -86,12 +88,24 @@ +@@ -85,12 +87,24 @@ enum mv64xxx_i2c_state { MV64XXX_I2C_STATE_INVALID, MV64XXX_I2C_STATE_IDLE, @@ -215,7 +215,7 @@ index bb048e655be7..dfbbedc95318 100644 }; /* Driver actions */ -@@ -232,9 +246,73 @@ mv64xxx_i2c_hw_init(struct mv64xxx_i2c_data *drv_data) +@@ -231,9 +245,73 @@ mv64xxx_i2c_hw_init(struct mv64xxx_i2c_data *drv_data) drv_data->state = MV64XXX_I2C_STATE_IDLE; } @@ -289,7 +289,7 @@ index bb048e655be7..dfbbedc95318 100644 /* * If state is idle, then this is likely the remnants of an old * operation that driver has given up on or the user has killed. -@@ -245,99 +323,122 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) +@@ -244,99 +322,122 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) return; } @@ -486,7 +486,7 @@ index bb048e655be7..dfbbedc95318 100644 } } -@@ -611,7 +712,7 @@ mv64xxx_i2c_execute_msg(struct mv64xxx_i2c_data *drv_data, struct i2c_msg *msg, +@@ -610,7 +711,7 @@ mv64xxx_i2c_execute_msg(struct mv64xxx_i2c_data *drv_data, struct i2c_msg *msg, spin_lock_irqsave(&drv_data->lock, flags); @@ -496,10 +496,10 @@ index bb048e655be7..dfbbedc95318 100644 drv_data->send_stop = is_last; drv_data->block = 1; -- -2.43.2 +2.45.2 -From acc21df71e9338f37cd6003005f2b5a3f7fef553 Mon Sep 17 00:00:00 2001 +From dc6fcc9da064279e883182c0bdd56b31b1336c0f Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 19 Mar 2024 16:52:21 -0600 Subject: [PATCH 4/5] i2c: mv64xxx: Allow continuing after read @@ -529,10 +529,10 @@ Signed-off-by: Sam Edwards 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c -index dfbbedc95318..1f2ee436213d 100644 +index 2ead2d39dc3f..514d7ba5c9a3 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c -@@ -116,9 +116,9 @@ enum mv64xxx_i2c_action { +@@ -115,9 +115,9 @@ enum mv64xxx_i2c_action { MV64XXX_I2C_ACTION_SEND_ADDR_1, MV64XXX_I2C_ACTION_SEND_ADDR_2, MV64XXX_I2C_ACTION_SEND_DATA, @@ -544,7 +544,7 @@ index dfbbedc95318..1f2ee436213d 100644 }; struct mv64xxx_i2c_regs { -@@ -395,16 +395,15 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) +@@ -394,16 +394,15 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) case MV64XXX_I2C_STATE_READ: if (drv_data->bytes_left == 0) { @@ -568,7 +568,7 @@ index dfbbedc95318..1f2ee436213d 100644 /* * bytes_left counts the remaining read actions to send -@@ -419,6 +418,8 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) +@@ -418,6 +417,8 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) if (drv_data->bytes_left == 0) drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_ACK; } @@ -577,7 +577,7 @@ index dfbbedc95318..1f2ee436213d 100644 break; case MV64XXX_I2C_STATE_WRITE: -@@ -458,6 +459,11 @@ static void mv64xxx_i2c_send_start(struct mv64xxx_i2c_data *drv_data) +@@ -457,6 +458,11 @@ static void mv64xxx_i2c_send_start(struct mv64xxx_i2c_data *drv_data) static void mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) { @@ -589,7 +589,7 @@ index dfbbedc95318..1f2ee436213d 100644 switch(drv_data->action) { case MV64XXX_I2C_ACTION_SEND_RESTART: /* We should only get here if we have further messages */ -@@ -504,27 +510,6 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) +@@ -503,27 +509,6 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) drv_data->reg_base + drv_data->reg_offsets.control); break; @@ -618,10 +618,10 @@ index dfbbedc95318..1f2ee436213d 100644 default: dev_err(&drv_data->adapter.dev, -- -2.43.2 +2.45.2 -From 2281aba7f1a750fd2834d4d250437747e0281816 Mon Sep 17 00:00:00 2001 +From 72edc1a1eaa36e85f56e7ce4a7d438f3adee7449 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 19 Mar 2024 16:52:25 -0600 Subject: [PATCH 5/5] i2c: mv64xxx: Implement I2C_FUNC_NOSTART @@ -670,10 +670,10 @@ Signed-off-by: Sam Edwards 1 file changed, 97 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c -index 1f2ee436213d..4771585b03b1 100644 +index 514d7ba5c9a3..30b21e7c21ff 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c -@@ -100,6 +100,7 @@ enum mv64xxx_i2c_state { +@@ -99,6 +99,7 @@ enum mv64xxx_i2c_state { enum mv64xxx_i2c_event { MV64XXX_I2C_EVENT_INVALID, MV64XXX_I2C_EVENT_STARTED, @@ -681,7 +681,7 @@ index 1f2ee436213d..4771585b03b1 100644 MV64XXX_I2C_EVENT_ADDR_ACK, MV64XXX_I2C_EVENT_ADDR_NO_ACK, MV64XXX_I2C_EVENT_WR_ACK, -@@ -112,7 +113,7 @@ enum mv64xxx_i2c_event { +@@ -111,7 +112,7 @@ enum mv64xxx_i2c_event { enum mv64xxx_i2c_action { MV64XXX_I2C_ACTION_INVALID, MV64XXX_I2C_ACTION_CONTINUE, @@ -690,7 +690,7 @@ index 1f2ee436213d..4771585b03b1 100644 MV64XXX_I2C_ACTION_SEND_ADDR_1, MV64XXX_I2C_ACTION_SEND_ADDR_2, MV64XXX_I2C_ACTION_SEND_DATA, -@@ -129,6 +130,7 @@ struct mv64xxx_i2c_regs { +@@ -128,6 +129,7 @@ struct mv64xxx_i2c_regs { u8 status; u8 clock; u8 soft_reset; @@ -698,7 +698,7 @@ index 1f2ee436213d..4771585b03b1 100644 }; struct mv64xxx_i2c_data { -@@ -185,6 +187,7 @@ static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_sun4i = { +@@ -184,6 +186,7 @@ static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_sun4i = { .status = 0x10, .clock = 0x14, .soft_reset = 0x18, @@ -706,7 +706,7 @@ index 1f2ee436213d..4771585b03b1 100644 }; static void -@@ -306,9 +309,9 @@ mv64xxx_i2c_decode_status(struct mv64xxx_i2c_data *drv_data, u32 status) +@@ -305,9 +308,9 @@ mv64xxx_i2c_decode_status(struct mv64xxx_i2c_data *drv_data, u32 status) } static void @@ -718,7 +718,7 @@ index 1f2ee436213d..4771585b03b1 100644 enum mv64xxx_i2c_state prev_state = drv_data->state; drv_data->action = MV64XXX_I2C_ACTION_INVALID; -@@ -329,7 +332,6 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) +@@ -328,7 +331,6 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) * 2) Handle hardware event driven state transitions * 3) Perform internal state transitions and action emission */ @@ -726,7 +726,7 @@ index 1f2ee436213d..4771585b03b1 100644 /* Handle event; determine state transition */ switch (event) { -@@ -337,6 +339,7 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) +@@ -336,6 +338,7 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) drv_data->state = MV64XXX_I2C_STATE_SEND_ADDR_1; break; @@ -734,7 +734,7 @@ index 1f2ee436213d..4771585b03b1 100644 case MV64XXX_I2C_EVENT_ADDR_ACK: if ((drv_data->state == MV64XXX_I2C_STATE_SEND_ADDR_1) && (drv_data->msg->flags & I2C_M_TEN)) -@@ -399,7 +402,7 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) +@@ -398,7 +401,7 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; drv_data->state = MV64XXX_I2C_STATE_IDLE; } else { @@ -743,7 +743,7 @@ index 1f2ee436213d..4771585b03b1 100644 drv_data->state = MV64XXX_I2C_STATE_RESTART; } } else { -@@ -429,7 +432,7 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) +@@ -428,7 +431,7 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; drv_data->state = MV64XXX_I2C_STATE_IDLE; } else { @@ -752,7 +752,7 @@ index 1f2ee436213d..4771585b03b1 100644 drv_data->state = MV64XXX_I2C_STATE_RESTART; } } else { -@@ -445,18 +448,40 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) +@@ -444,18 +447,40 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) static void mv64xxx_i2c_send_start(struct mv64xxx_i2c_data *drv_data) { @@ -794,7 +794,7 @@ index 1f2ee436213d..4771585b03b1 100644 mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) { if (drv_data->action & MV64XXX_I2C_ACTION_RECEIVE) -@@ -465,7 +490,7 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) +@@ -464,7 +489,7 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) drv_data->action &= ~MV64XXX_I2C_ACTION_RECEIVE; switch(drv_data->action) { @@ -803,7 +803,7 @@ index 1f2ee436213d..4771585b03b1 100644 /* We should only get here if we have further messages */ BUG_ON(drv_data->num_msgs == 0); -@@ -482,6 +507,10 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) +@@ -481,6 +506,10 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) * Thankfully, do not advertise support for that feature. */ drv_data->send_stop = drv_data->num_msgs == 1; @@ -814,7 +814,7 @@ index 1f2ee436213d..4771585b03b1 100644 break; case MV64XXX_I2C_ACTION_CONTINUE: -@@ -526,6 +555,8 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) +@@ -525,6 +554,8 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) wake_up(&drv_data->waitq); break; } @@ -823,7 +823,7 @@ index 1f2ee436213d..4771585b03b1 100644 } static void -@@ -596,6 +627,7 @@ static irqreturn_t +@@ -595,6 +626,7 @@ static irqreturn_t mv64xxx_i2c_intr(int irq, void *dev_id) { struct mv64xxx_i2c_data *drv_data = dev_id; @@ -831,7 +831,7 @@ index 1f2ee436213d..4771585b03b1 100644 u32 status; irqreturn_t rc = IRQ_NONE; -@@ -618,8 +650,11 @@ mv64xxx_i2c_intr(int irq, void *dev_id) +@@ -617,8 +649,11 @@ mv64xxx_i2c_intr(int irq, void *dev_id) ndelay(100); status = readl(drv_data->reg_base + drv_data->reg_offsets.status); @@ -845,7 +845,7 @@ index 1f2ee436213d..4771585b03b1 100644 if (drv_data->irq_clear_inverted) writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_IFLG, -@@ -831,7 +866,55 @@ mv64xxx_i2c_can_offload(struct mv64xxx_i2c_data *drv_data) +@@ -830,7 +865,55 @@ mv64xxx_i2c_can_offload(struct mv64xxx_i2c_data *drv_data) static u32 mv64xxx_i2c_functionality(struct i2c_adapter *adap) { @@ -902,7 +902,7 @@ index 1f2ee436213d..4771585b03b1 100644 } static int -@@ -841,6 +924,9 @@ mv64xxx_i2c_xfer_core(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) +@@ -840,6 +923,9 @@ mv64xxx_i2c_xfer_core(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) int rc, ret = num; u32 status; @@ -913,5 +913,5 @@ index 1f2ee436213d..4771585b03b1 100644 if (rc) return rc; -- -2.43.2 +2.45.2 diff --git a/tp2bmc/patches/linux/realtek-switch.patch b/tp2bmc/patches/linux/realtek-switch.patch index 673b2347..784513a5 100644 --- a/tp2bmc/patches/linux/realtek-switch.patch +++ b/tp2bmc/patches/linux/realtek-switch.patch @@ -1,435 +1,52 @@ -From df33ec7097216f888d1311a6d3fd42ba259524ca Mon Sep 17 00:00:00 2001 +From 98700d5b9f4bc8803003d828b6e9da2dbb6c3ca0 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 28 Feb 2024 15:34:56 -0700 -Subject: [PATCH 01/11] local: hack in RTL8370MB-CG to dsa driver +Subject: [PATCH] local: hack in RTL8370MB-CG to dsa driver ---- - drivers/net/dsa/realtek/rtl8365mb.c | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c -index 41ea3b5a42b1..f8c7b2bca205 100644 ---- a/drivers/net/dsa/realtek/rtl8365mb.c -+++ b/drivers/net/dsa/realtek/rtl8365mb.c -@@ -554,6 +554,19 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = { - .jam_table = rtl8365mb_init_jam_8365mb_vc, - .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), - }, -+ { -+ .name = "RTL8370MB-CG", -+ .chip_id = 0x6368, -+ .chip_ver = 0x0010, -+ .extints = { -+ { 8, 1, PHY_INTF(MII) | PHY_INTF(TMII) | -+ PHY_INTF(RMII) | PHY_INTF(RGMII) }, -+ { 9, 2, PHY_INTF(MII) | PHY_INTF(TMII) | -+ PHY_INTF(RMII) | PHY_INTF(RGMII) }, -+ }, -+ .jam_table = rtl8365mb_init_jam_8365mb_vc, -+ .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), -+ }, - }; - - enum rtl8365mb_stp_state { --- -2.43.2 - - -From e061ef217a9977a9a044018eb6eeede7be9a00c6 Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Wed, 6 Mar 2024 17:42:37 -0700 -Subject: [PATCH 02/11] local: realtek: cmd_{read,write} -> i2c_addr - ---- - drivers/net/dsa/realtek/realtek-mdio.c | 2 -- - drivers/net/dsa/realtek/realtek-smi.c | 7 +++---- - drivers/net/dsa/realtek/realtek.h | 6 ++---- - drivers/net/dsa/realtek/rtl8365mb.c | 3 +-- - drivers/net/dsa/realtek/rtl8366rb.c | 3 +-- - 5 files changed, 7 insertions(+), 14 deletions(-) - -diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c -index 292e6d087e8b..0f29e6273b4a 100644 ---- a/drivers/net/dsa/realtek/realtek-mdio.c -+++ b/drivers/net/dsa/realtek/realtek-mdio.c -@@ -184,8 +184,6 @@ static int realtek_mdio_probe(struct mdio_device *mdiodev) - priv->chip_data = (void *)priv + sizeof(*priv); - - priv->clk_delay = var->clk_delay; -- priv->cmd_read = var->cmd_read; -- priv->cmd_write = var->cmd_write; - priv->ops = var->ops; - - priv->write_reg_noack = realtek_mdio_write; -diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c -index ff13563059c5..ca808ac52ebc 100644 ---- a/drivers/net/dsa/realtek/realtek-smi.c -+++ b/drivers/net/dsa/realtek/realtek-smi.c -@@ -208,7 +208,7 @@ static int realtek_smi_read_reg(struct realtek_priv *priv, u32 addr, u32 *data) - realtek_smi_start(priv); - - /* Send READ command */ -- ret = realtek_smi_write_byte(priv, priv->cmd_read); -+ ret = realtek_smi_write_byte(priv, (priv->i2c_addr << 1) | 1); - if (ret) - goto out; - -@@ -249,7 +249,7 @@ static int realtek_smi_write_reg(struct realtek_priv *priv, - realtek_smi_start(priv); - - /* Send WRITE command */ -- ret = realtek_smi_write_byte(priv, priv->cmd_write); -+ ret = realtek_smi_write_byte(priv, (priv->i2c_addr << 1)); - if (ret) - goto out; - -@@ -447,8 +447,7 @@ static int realtek_smi_probe(struct platform_device *pdev) - /* Link forward and backward */ - priv->dev = dev; - priv->clk_delay = var->clk_delay; -- priv->cmd_read = var->cmd_read; -- priv->cmd_write = var->cmd_write; -+ priv->i2c_addr = var->i2c_addr; - priv->ops = var->ops; - - priv->setup_interface = realtek_smi_setup_mdio; -diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h -index 4fa7c6ba874a..9fce9fc1a4a7 100644 ---- a/drivers/net/dsa/realtek/realtek.h -+++ b/drivers/net/dsa/realtek/realtek.h -@@ -59,8 +59,7 @@ struct realtek_priv { - int mdio_addr; - - unsigned int clk_delay; -- u8 cmd_read; -- u8 cmd_write; -+ u8 i2c_addr; - spinlock_t lock; /* Locks around command writes */ - struct dsa_switch *ds; - struct irq_domain *irqdomain; -@@ -120,8 +119,7 @@ struct realtek_variant { - const struct dsa_switch_ops *ds_ops_mdio; - const struct realtek_ops *ops; - unsigned int clk_delay; -- u8 cmd_read; -- u8 cmd_write; -+ u8 i2c_addr; - size_t chip_data_sz; - }; - -diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c -index f8c7b2bca205..f07763ff4f59 100644 ---- a/drivers/net/dsa/realtek/rtl8365mb.c -+++ b/drivers/net/dsa/realtek/rtl8365mb.c -@@ -2182,8 +2182,7 @@ const struct realtek_variant rtl8365mb_variant = { - .ds_ops_mdio = &rtl8365mb_switch_ops_mdio, - .ops = &rtl8365mb_ops, - .clk_delay = 10, -- .cmd_read = 0xb9, -- .cmd_write = 0xb8, -+ .i2c_addr = 0x5c, - .chip_data_sz = sizeof(struct rtl8365mb), - }; - EXPORT_SYMBOL_GPL(rtl8365mb_variant); -diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c -index 7868ef237f6c..de06505299da 100644 ---- a/drivers/net/dsa/realtek/rtl8366rb.c -+++ b/drivers/net/dsa/realtek/rtl8366rb.c -@@ -1890,8 +1890,7 @@ const struct realtek_variant rtl8366rb_variant = { - .ds_ops_mdio = &rtl8366rb_switch_ops_mdio, - .ops = &rtl8366rb_ops, - .clk_delay = 10, -- .cmd_read = 0xa9, -- .cmd_write = 0xa8, -+ .i2c_addr = 0x54, - .chip_data_sz = sizeof(struct rtl8366rb), - }; - EXPORT_SYMBOL_GPL(rtl8366rb_variant); --- -2.43.2 - - -From 3ce670fc2ce09cabd6f18c9c2028a11c167081dd Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Fri, 8 Mar 2024 22:38:34 -0700 -Subject: [PATCH 03/11] local: realtek: clean up `chip_data` - ---- - drivers/net/dsa/realtek/realtek-mdio.c | 1 - - drivers/net/dsa/realtek/realtek-smi.c | 1 - - drivers/net/dsa/realtek/realtek.h | 2 +- - drivers/net/dsa/realtek/rtl8365mb.c | 38 +++++++++++++------------- - drivers/net/dsa/realtek/rtl8366rb.c | 8 +++--- - 5 files changed, 24 insertions(+), 26 deletions(-) - -diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c -index 0f29e6273b4a..cde06e1ffa34 100644 ---- a/drivers/net/dsa/realtek/realtek-mdio.c -+++ b/drivers/net/dsa/realtek/realtek-mdio.c -@@ -181,7 +181,6 @@ static int realtek_mdio_probe(struct mdio_device *mdiodev) - priv->mdio_addr = mdiodev->addr; - priv->bus = mdiodev->bus; - priv->dev = &mdiodev->dev; -- priv->chip_data = (void *)priv + sizeof(*priv); - - priv->clk_delay = var->clk_delay; - priv->ops = var->ops; -diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c -index ca808ac52ebc..b6dc3798600c 100644 ---- a/drivers/net/dsa/realtek/realtek-smi.c -+++ b/drivers/net/dsa/realtek/realtek-smi.c -@@ -423,7 +423,6 @@ static int realtek_smi_probe(struct platform_device *pdev) - priv = devm_kzalloc(dev, sizeof(*priv) + var->chip_data_sz, GFP_KERNEL); - if (!priv) - return -ENOMEM; -- priv->chip_data = (void *)priv + sizeof(*priv); - - mutex_init(&priv->map_lock); - -diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h -index 9fce9fc1a4a7..61adcd66703f 100644 ---- a/drivers/net/dsa/realtek/realtek.h -+++ b/drivers/net/dsa/realtek/realtek.h -@@ -79,7 +79,7 @@ struct realtek_priv { - int vlan4k_enabled; - - char buf[4096]; -- void *chip_data; /* Per-chip extra variant data */ -+ char chip_data[]; /* Per-chip extra variant data */ - }; - - /* -diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c -index f07763ff4f59..205645ded149 100644 ---- a/drivers/net/dsa/realtek/rtl8365mb.c -+++ b/drivers/net/dsa/realtek/rtl8365mb.c -@@ -852,7 +852,7 @@ static int rtl8365mb_dsa_phy_write(struct dsa_switch *ds, int phy, int regnum, - static const struct rtl8365mb_extint * - rtl8365mb_get_port_extint(struct realtek_priv *priv, int port) - { -- struct rtl8365mb *mb = priv->chip_data; -+ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; - int i; - - for (i = 0; i < RTL8365MB_MAX_NUM_EXTINTS; i++) { -@@ -877,7 +877,7 @@ rtl8365mb_get_tag_protocol(struct dsa_switch *ds, int port, - struct rtl8365mb_cpu *cpu; - struct rtl8365mb *mb; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - cpu = &mb->cpu; - - if (cpu->position == RTL8365MB_CPU_POS_BEFORE_CRC) -@@ -1105,7 +1105,7 @@ static void rtl8365mb_phylink_mac_link_down(struct dsa_switch *ds, int port, - struct rtl8365mb *mb; - int ret; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - p = &mb->ports[port]; - cancel_delayed_work_sync(&p->mib_work); - -@@ -1133,7 +1133,7 @@ static void rtl8365mb_phylink_mac_link_up(struct dsa_switch *ds, int port, - struct rtl8365mb *mb; - int ret; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - p = &mb->ports[port]; - schedule_delayed_work(&p->mib_work, 0); - -@@ -1289,7 +1289,7 @@ static void rtl8365mb_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *da - int ret; - int i; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - - mutex_lock(&mb->mib_lock); - for (i = 0; i < RTL8365MB_MIB_END; i++) { -@@ -1336,7 +1336,7 @@ static void rtl8365mb_get_phy_stats(struct dsa_switch *ds, int port, - struct rtl8365mb_mib_counter *mib; - struct rtl8365mb *mb; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - mib = &rtl8365mb_mib_counters[RTL8365MB_MIB_dot3StatsSymbolErrors]; - - mutex_lock(&mb->mib_lock); -@@ -1373,7 +1373,7 @@ static void rtl8365mb_get_mac_stats(struct dsa_switch *ds, int port, - int ret; - int i; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - - mutex_lock(&mb->mib_lock); - for (i = 0; i < RTL8365MB_MIB_END; i++) { -@@ -1437,7 +1437,7 @@ static void rtl8365mb_get_ctrl_stats(struct dsa_switch *ds, int port, - struct rtl8365mb_mib_counter *mib; - struct rtl8365mb *mb; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - mib = &rtl8365mb_mib_counters[RTL8365MB_MIB_dot3ControlInUnknownOpcodes]; - - mutex_lock(&mb->mib_lock); -@@ -1465,7 +1465,7 @@ static void rtl8365mb_stats_update(struct realtek_priv *priv, int port) - [RTL8365MB_MIB_dot3StatsFCSErrors] = 1, - [RTL8365MB_MIB_dot3StatsLateCollisions] = 1, - }; -- struct rtl8365mb *mb = priv->chip_data; -+ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; - struct rtnl_link_stats64 *stats; - int ret; - int i; -@@ -1544,7 +1544,7 @@ static void rtl8365mb_get_stats64(struct dsa_switch *ds, int port, - struct rtl8365mb_port *p; - struct rtl8365mb *mb; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - p = &mb->ports[port]; - - spin_lock(&p->stats_lock); -@@ -1554,7 +1554,7 @@ static void rtl8365mb_get_stats64(struct dsa_switch *ds, int port, - - static void rtl8365mb_stats_setup(struct realtek_priv *priv) - { -- struct rtl8365mb *mb = priv->chip_data; -+ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; - int i; - - /* Per-chip global mutex to protect MIB counter access, since doing -@@ -1580,7 +1580,7 @@ static void rtl8365mb_stats_setup(struct realtek_priv *priv) - - static void rtl8365mb_stats_teardown(struct realtek_priv *priv) - { -- struct rtl8365mb *mb = priv->chip_data; -+ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; - int i; - - for (i = 0; i < priv->num_ports; i++) { -@@ -1707,7 +1707,7 @@ static int rtl8365mb_irq_disable(struct realtek_priv *priv) - - static int rtl8365mb_irq_setup(struct realtek_priv *priv) - { -- struct rtl8365mb *mb = priv->chip_data; -+ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; - struct device_node *intc; - u32 irq_trig; - int virq; -@@ -1826,7 +1826,7 @@ static int rtl8365mb_irq_setup(struct realtek_priv *priv) - - static void rtl8365mb_irq_teardown(struct realtek_priv *priv) - { -- struct rtl8365mb *mb = priv->chip_data; -+ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; - int virq; - int i; - -@@ -1848,7 +1848,7 @@ static void rtl8365mb_irq_teardown(struct realtek_priv *priv) - - static int rtl8365mb_cpu_config(struct realtek_priv *priv) - { -- struct rtl8365mb *mb = priv->chip_data; -+ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; - struct rtl8365mb_cpu *cpu = &mb->cpu; - u32 val; - int ret; -@@ -1882,7 +1882,7 @@ static int rtl8365mb_change_tag_protocol(struct dsa_switch *ds, - struct rtl8365mb_cpu *cpu; - struct rtl8365mb *mb; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - cpu = &mb->cpu; - - switch (proto) { -@@ -1908,7 +1908,7 @@ static int rtl8365mb_change_tag_protocol(struct dsa_switch *ds, - - static int rtl8365mb_switch_init(struct realtek_priv *priv) - { -- struct rtl8365mb *mb = priv->chip_data; -+ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; - const struct rtl8365mb_chip_info *ci; - int ret; - int i; -@@ -1961,7 +1961,7 @@ static int rtl8365mb_setup(struct dsa_switch *ds) - int ret; - int i; - -- mb = priv->chip_data; -+ mb = (struct rtl8365mb *)priv->chip_data; - cpu = &mb->cpu; - - ret = rtl8365mb_reset_chip(priv); -@@ -2085,7 +2085,7 @@ static int rtl8365mb_get_chip_id_and_ver(struct regmap *map, u32 *id, u32 *ver) - - static int rtl8365mb_detect(struct realtek_priv *priv) - { -- struct rtl8365mb *mb = priv->chip_data; -+ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; - u32 chip_id; - u32 chip_ver; - int ret; -diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c -index de06505299da..23dee1ce1d4a 100644 ---- a/drivers/net/dsa/realtek/rtl8366rb.c -+++ b/drivers/net/dsa/realtek/rtl8366rb.c -@@ -812,7 +812,7 @@ static int rtl8366rb_setup(struct dsa_switch *ds) - int ret; - int i; - -- rb = priv->chip_data; -+ rb = (struct rtl8366rb *)priv->chip_data; - - ret = regmap_read(priv->map, RTL8366RB_CHIP_ID_REG, &chip_id); - if (ret) { -@@ -1299,7 +1299,7 @@ static int rtl8366rb_vlan_filtering(struct dsa_switch *ds, int port, - struct rtl8366rb *rb; - int ret; - -- rb = priv->chip_data; -+ rb = (struct rtl8366rb *)priv->chip_data; - - dev_dbg(priv->dev, "port %d: %s VLAN filtering\n", port, - vlan_filtering ? "enable" : "disable"); -@@ -1409,7 +1409,7 @@ static int rtl8366rb_change_mtu(struct dsa_switch *ds, int port, int new_mtu) - int i; - - /* Cache the per-port MTU setting */ -- rb = priv->chip_data; -+ rb = (struct rtl8366rb *)priv->chip_data; - rb->max_mtu[port] = new_mtu; - - /* Roof out the MTU for the entire switch to the greatest -@@ -1615,7 +1615,7 @@ static int rtl8366rb_set_mc_index(struct realtek_priv *priv, int port, int index - bool pvid_enabled; - int ret; - -- rb = priv->chip_data; -+ rb = (struct rtl8366rb *)priv->chip_data; - pvid_enabled = !!index; - - if (port >= priv->num_ports || index >= RTL8366RB_NUM_VLANS) --- -2.43.2 +local: realtek: cmd_{read,write} -> i2c_addr +local: realtek: clean up `chip_data` -From 1bd0e9b71f9b092592db87488920be09a2a35bc2 Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Fri, 8 Mar 2024 22:56:42 -0700 -Subject: [PATCH 04/11] local: realtek: simplify/clean up regmap config +local: realtek: simplify/clean up regmap config + +local: realtek: kill off `realtek_smi_write_reg_noack` + +local: realtek: become an i2c driver, not platform + +local: realtek: Implement "Realtek"/"RTK" I2C mode + +local: realtek: add back GPIO support + +local: begin improving tagging decoder +local: realtek: trap standalone ports rather than use the isolation matrix + +local: realtek: implement bridge offload --- - drivers/net/dsa/realtek/realtek-mdio.c | 21 ++------------------- - drivers/net/dsa/realtek/realtek-smi.c | 20 ++------------------ - 2 files changed, 4 insertions(+), 37 deletions(-) + drivers/net/dsa/realtek/Kconfig | 2 + + drivers/net/dsa/realtek/realtek-mdio.c | 27 +- + drivers/net/dsa/realtek/realtek-smi.c | 498 ++++++++++--------------- + drivers/net/dsa/realtek/realtek.h | 11 +- + drivers/net/dsa/realtek/rtl8365mb.c | 201 ++++++++-- + drivers/net/dsa/realtek/rtl8366rb.c | 15 +- + net/dsa/tag_rtl8_4.c | 20 +- + 7 files changed, 397 insertions(+), 377 deletions(-) +diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig +index 060165a85fb7..81a0e0270557 100644 +--- a/drivers/net/dsa/realtek/Kconfig ++++ b/drivers/net/dsa/realtek/Kconfig +@@ -31,6 +31,8 @@ config NET_DSA_REALTEK_SMI + depends on NET_DSA_REALTEK_RTL8365MB || NET_DSA_REALTEK_RTL8366RB + depends on NET_DSA_REALTEK_RTL8365MB || !NET_DSA_REALTEK_RTL8365MB + depends on NET_DSA_REALTEK_RTL8366RB || !NET_DSA_REALTEK_RTL8366RB ++ select I2C_GPIO ++ select REGMAP_I2C + help + Select to enable support for registering switches connected + through SMI. diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c -index cde06e1ffa34..8622d9c0833d 100644 +index 292e6d087e8b..d9bd65842fb9 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -114,12 +114,8 @@ static void realtek_mdio_unlock(void *ctx) @@ -475,75 +92,15 @@ index cde06e1ffa34..8622d9c0833d 100644 priv->map_nolock = devm_regmap_init(dev, NULL, priv, &rc); if (IS_ERR(priv->map_nolock)) { ret = PTR_ERR(priv->map_nolock); -diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c -index b6dc3798600c..26d60dbf01bd 100644 ---- a/drivers/net/dsa/realtek/realtek-smi.c -+++ b/drivers/net/dsa/realtek/realtek-smi.c -@@ -325,11 +325,8 @@ static void realtek_smi_unlock(void *ctx) - } - - static const struct regmap_config realtek_smi_regmap_config = { -- .reg_bits = 10, /* A4..A0 R4..R0 */ -+ .reg_bits = 16, - .val_bits = 16, -- .reg_stride = 1, -- /* PHY regs are at 0x8000 */ -- .max_register = 0xffff, - .reg_format_endian = REGMAP_ENDIAN_BIG, - .reg_read = realtek_smi_read, - .reg_write = realtek_smi_write, -@@ -338,19 +335,6 @@ static const struct regmap_config realtek_smi_regmap_config = { - .unlock = realtek_smi_unlock, - }; - --static const struct regmap_config realtek_smi_nolock_regmap_config = { -- .reg_bits = 10, /* A4..A0 R4..R0 */ -- .val_bits = 16, -- .reg_stride = 1, -- /* PHY regs are at 0x8000 */ -- .max_register = 0xffff, -- .reg_format_endian = REGMAP_ENDIAN_BIG, -- .reg_read = realtek_smi_read, -- .reg_write = realtek_smi_write, -- .cache_type = REGCACHE_NONE, -- .disable_locking = true, --}; -- - static int realtek_smi_mdio_read(struct mii_bus *bus, int addr, int regnum) - { - struct realtek_priv *priv = bus->priv; -@@ -435,7 +419,7 @@ static int realtek_smi_probe(struct platform_device *pdev) - return ret; - } +@@ -181,15 +164,9 @@ static int realtek_mdio_probe(struct mdio_device *mdiodev) + priv->mdio_addr = mdiodev->addr; + priv->bus = mdiodev->bus; + priv->dev = &mdiodev->dev; +- priv->chip_data = (void *)priv + sizeof(*priv); -- rc = realtek_smi_nolock_regmap_config; -+ rc.disable_locking = true; - priv->map_nolock = devm_regmap_init(dev, NULL, priv, &rc); - if (IS_ERR(priv->map_nolock)) { - ret = PTR_ERR(priv->map_nolock); --- -2.43.2 - - -From 42670d4213d6c03b52707408810e309691d01b5b Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Mon, 11 Mar 2024 23:11:55 -0600 -Subject: [PATCH 05/11] local: realtek: kill off `realtek_smi_write_reg_noack` - ---- - drivers/net/dsa/realtek/realtek-mdio.c | 2 -- - drivers/net/dsa/realtek/realtek-smi.c | 26 +++----------------------- - drivers/net/dsa/realtek/realtek.h | 1 - - drivers/net/dsa/realtek/rtl8365mb.c | 4 ++-- - drivers/net/dsa/realtek/rtl8366rb.c | 4 ++-- - 5 files changed, 7 insertions(+), 30 deletions(-) - -diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c -index 8622d9c0833d..f8c479d0e5a1 100644 ---- a/drivers/net/dsa/realtek/realtek-mdio.c -+++ b/drivers/net/dsa/realtek/realtek-mdio.c -@@ -168,8 +168,6 @@ static int realtek_mdio_probe(struct mdio_device *mdiodev) - priv->clk_delay = var->clk_delay; +- priv->clk_delay = var->clk_delay; +- priv->cmd_read = var->cmd_read; +- priv->cmd_write = var->cmd_write; priv->ops = var->ops; - priv->write_reg_noack = realtek_mdio_write; @@ -552,168 +109,20 @@ index 8622d9c0833d..f8c479d0e5a1 100644 dev_set_drvdata(dev, priv); diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c -index 26d60dbf01bd..53a6018d54b8 100644 ---- a/drivers/net/dsa/realtek/realtek-smi.c -+++ b/drivers/net/dsa/realtek/realtek-smi.c -@@ -162,12 +162,6 @@ static int realtek_smi_write_byte(struct realtek_priv *priv, u8 data) - return realtek_smi_wait_for_ack(priv); - } - --static int realtek_smi_write_byte_noack(struct realtek_priv *priv, u8 data) --{ -- realtek_smi_write_bits(priv, data, 8); -- return 0; --} -- - static int realtek_smi_read_byte0(struct realtek_priv *priv, u8 *data) - { - u32 t; -@@ -238,8 +232,7 @@ static int realtek_smi_read_reg(struct realtek_priv *priv, u32 addr, u32 *data) - return ret; - } - --static int realtek_smi_write_reg(struct realtek_priv *priv, -- u32 addr, u32 data, bool ack) -+static int realtek_smi_write_reg(struct realtek_priv *priv, u32 addr, u32 data) - { - unsigned long flags; - int ret; -@@ -269,10 +262,7 @@ static int realtek_smi_write_reg(struct realtek_priv *priv, - goto out; - - /* Write DATA[15:8] */ -- if (ack) -- ret = realtek_smi_write_byte(priv, data >> 8); -- else -- ret = realtek_smi_write_byte_noack(priv, data >> 8); -+ ret = realtek_smi_write_byte(priv, data >> 8); - if (ret) - goto out; - -@@ -285,22 +275,13 @@ static int realtek_smi_write_reg(struct realtek_priv *priv, - return ret; - } - --/* There is one single case when we need to use this accessor and that -- * is when issueing soft reset. Since the device reset as soon as we write -- * that bit, no ACK will come back for natural reasons. -- */ --static int realtek_smi_write_reg_noack(void *ctx, u32 reg, u32 val) --{ -- return realtek_smi_write_reg(ctx, reg, val, false); --} -- - /* Regmap accessors */ - - static int realtek_smi_write(void *ctx, u32 reg, u32 val) - { - struct realtek_priv *priv = ctx; - -- return realtek_smi_write_reg(priv, reg, val, true); -+ return realtek_smi_write_reg(priv, reg, val); - } - - static int realtek_smi_read(void *ctx, u32 reg, u32 *val) -@@ -434,7 +415,6 @@ static int realtek_smi_probe(struct platform_device *pdev) - priv->ops = var->ops; - - priv->setup_interface = realtek_smi_setup_mdio; -- priv->write_reg_noack = realtek_smi_write_reg_noack; - - dev_set_drvdata(dev, priv); - spin_lock_init(&priv->lock); -diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h -index 61adcd66703f..eed9bb3ed10a 100644 ---- a/drivers/net/dsa/realtek/realtek.h -+++ b/drivers/net/dsa/realtek/realtek.h -@@ -73,7 +73,6 @@ struct realtek_priv { - - const struct realtek_ops *ops; - int (*setup_interface)(struct dsa_switch *ds); -- int (*write_reg_noack)(void *ctx, u32 addr, u32 data); - - int vlan_enabled; - int vlan4k_enabled; -diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c -index 205645ded149..b723ade207c9 100644 ---- a/drivers/net/dsa/realtek/rtl8365mb.c -+++ b/drivers/net/dsa/realtek/rtl8365mb.c -@@ -1940,8 +1940,8 @@ static int rtl8365mb_reset_chip(struct realtek_priv *priv) - { - u32 val; - -- priv->write_reg_noack(priv, RTL8365MB_CHIP_RESET_REG, -- FIELD_PREP(RTL8365MB_CHIP_RESET_HW_MASK, 1)); -+ regmap_write(priv->map, RTL8365MB_CHIP_RESET_REG, -+ FIELD_PREP(RTL8365MB_CHIP_RESET_HW_MASK, 1)); - - /* Realtek documentation says the chip needs 1 second to reset. Sleep - * for 100 ms before accessing any registers to prevent ACK timeouts. -diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c -index 23dee1ce1d4a..3f2084bc0b02 100644 ---- a/drivers/net/dsa/realtek/rtl8366rb.c -+++ b/drivers/net/dsa/realtek/rtl8366rb.c -@@ -1760,8 +1760,8 @@ static int rtl8366rb_reset_chip(struct realtek_priv *priv) - u32 val; - int ret; - -- priv->write_reg_noack(priv, RTL8366RB_RESET_CTRL_REG, -- RTL8366RB_CHIP_CTRL_RESET_HW); -+ regmap_write(priv->map, RTL8366RB_RESET_CTRL_REG, -+ RTL8366RB_CHIP_CTRL_RESET_HW); - do { - usleep_range(20000, 25000); - ret = regmap_read(priv->map, RTL8366RB_RESET_CTRL_REG, &val); --- -2.43.2 - - -From 53bf34da29f84eba84a0c22387f476a0a13d6b61 Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Mon, 11 Mar 2024 23:19:50 -0600 -Subject: [PATCH 06/11] local: realtek: become an i2c driver, not platform - ---- - drivers/net/dsa/realtek/Kconfig | 1 + - drivers/net/dsa/realtek/realtek-mdio.c | 1 - - drivers/net/dsa/realtek/realtek-smi.c | 293 ++----------------------- - drivers/net/dsa/realtek/realtek.h | 4 - - 4 files changed, 17 insertions(+), 282 deletions(-) - -diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig -index 060165a85fb7..ee74ef09511d 100644 ---- a/drivers/net/dsa/realtek/Kconfig -+++ b/drivers/net/dsa/realtek/Kconfig -@@ -31,6 +31,7 @@ config NET_DSA_REALTEK_SMI - depends on NET_DSA_REALTEK_RTL8365MB || NET_DSA_REALTEK_RTL8366RB - depends on NET_DSA_REALTEK_RTL8365MB || !NET_DSA_REALTEK_RTL8365MB - depends on NET_DSA_REALTEK_RTL8366RB || !NET_DSA_REALTEK_RTL8366RB -+ select REGMAP_I2C - help - Select to enable support for registering switches connected - through SMI. -diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c -index f8c479d0e5a1..d9bd65842fb9 100644 ---- a/drivers/net/dsa/realtek/realtek-mdio.c -+++ b/drivers/net/dsa/realtek/realtek-mdio.c -@@ -165,7 +165,6 @@ static int realtek_mdio_probe(struct mdio_device *mdiodev) - priv->bus = mdiodev->bus; - priv->dev = &mdiodev->dev; - -- priv->clk_delay = var->clk_delay; - priv->ops = var->ops; - - np = dev->of_node; -diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c -index 53a6018d54b8..1aeb32a1c068 100644 +index 755546ed8db6..fe7fa886436f 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c -@@ -34,263 +34,13 @@ +@@ -31,283 +31,86 @@ + #include + #include + #include ++#include #include #include #include --#include + #include +#include ++#include #include #include #include @@ -723,15 +132,30 @@ index 53a6018d54b8..1aeb32a1c068 100644 -#define REALTEK_SMI_ACK_RETRY_COUNT 5 - -static inline void realtek_smi_clk_delay(struct realtek_priv *priv) --{ ++static int realtek_smi_rtk_read(void *ctx, const void *reg, size_t reg_size, ++ void *val, size_t val_size) + { - ndelay(priv->clk_delay); -} -- ++ struct device *dev = ctx; ++ struct i2c_client *i2c = to_i2c_client(dev); ++ int ret; + -static void realtek_smi_start(struct realtek_priv *priv) -{ - /* Set GPIO pins to output mode, with initial state: - * SCK = 0, SDA = 1 -- */ ++ /* In "Realtek" I2C mode, read transfers aren't quite the same as those ++ * of standard I2C. A conventional I2C read involves a write transfer ++ * to specify the register, followed by a read transfer to retrieve the ++ * value. The "Realtek" mode uses a single transfer, but the adapter ++ * sends 2 extra bytes after the address byte to specify the register ++ * before the bus turns around to complete the read operation. ++ * ++ * This can be accomplished through prudent use of the NOSTART flag to ++ * insert the register bytes into the middle of a read transfer without ++ * the device being any the wiser. + */ - gpiod_direction_output(priv->mdc, 0); - gpiod_direction_output(priv->mdio, 1); - realtek_smi_clk_delay(priv); @@ -829,7 +253,30 @@ index 53a6018d54b8..1aeb32a1c068 100644 - if (++retry_cnt > REALTEK_SMI_ACK_RETRY_COUNT) { - dev_err(priv->dev, "ACK timeout\n"); - return -ETIMEDOUT; -- } ++ struct i2c_msg xfer[] = { ++ /* Start a transfer and send only the start byte ++ * (address and R/W̅ bit) */ ++ { ++ .addr = i2c->addr, ++ .flags = I2C_M_RD, ++ .len = 0 ++ }, ++ ++ /* Send 2 extra bytes to specify the register */ ++ { ++ .addr = i2c->addr, ++ .flags = I2C_M_NOSTART, ++ .len = reg_size, ++ .buf = (void *)reg ++ }, ++ ++ /* Now turn the bus around and finish the read */ ++ { ++ .addr = i2c->addr, ++ .flags = I2C_M_RD | I2C_M_NOSTART, ++ .len = val_size, ++ .buf = val + } - } while (1); - - return 0; @@ -838,7 +285,13 @@ index 53a6018d54b8..1aeb32a1c068 100644 -static int realtek_smi_write_byte(struct realtek_priv *priv, u8 data) -{ - realtek_smi_write_bits(priv, data, 8); -- return realtek_smi_wait_for_ack(priv); +- return realtek_smi_wait_for_ack(priv); +-} +- +-static int realtek_smi_write_byte_noack(struct realtek_priv *priv, u8 data) +-{ +- realtek_smi_write_bits(priv, data, 8); +- return 0; -} - -static int realtek_smi_read_byte0(struct realtek_priv *priv, u8 *data) @@ -877,11 +330,12 @@ index 53a6018d54b8..1aeb32a1c068 100644 - int ret; - - spin_lock_irqsave(&priv->lock, flags); -- ++ }; + - realtek_smi_start(priv); - - /* Send READ command */ -- ret = realtek_smi_write_byte(priv, (priv->i2c_addr << 1) | 1); +- ret = realtek_smi_write_byte(priv, priv->cmd_read); - if (ret) - goto out; - @@ -909,19 +363,30 @@ index 53a6018d54b8..1aeb32a1c068 100644 - spin_unlock_irqrestore(&priv->lock, flags); - - return ret; --} -- --static int realtek_smi_write_reg(struct realtek_priv *priv, u32 addr, u32 data) --{ ++ ret = i2c_transfer(i2c->adapter, xfer, ARRAY_SIZE(xfer)); ++ if (ret == ARRAY_SIZE(xfer)) ++ return 0; ++ else if (ret < 0) ++ return ret; ++ else ++ return -EIO; + } + +-static int realtek_smi_write_reg(struct realtek_priv *priv, +- u32 addr, u32 data, bool ack) ++static int realtek_smi_rtk_write(void *ctx, const void *data, size_t count) + { - unsigned long flags; -- int ret; -- ++ struct device *dev = ctx; ++ struct i2c_client *i2c = to_i2c_client(dev); + int ret; + - spin_lock_irqsave(&priv->lock, flags); - - realtek_smi_start(priv); - - /* Send WRITE command */ -- ret = realtek_smi_write_byte(priv, (priv->i2c_addr << 1)); +- ret = realtek_smi_write_byte(priv, priv->cmd_write); - if (ret) - goto out; - @@ -941,7 +406,16 @@ index 53a6018d54b8..1aeb32a1c068 100644 - goto out; - - /* Write DATA[15:8] */ -- ret = realtek_smi_write_byte(priv, data >> 8); +- if (ack) +- ret = realtek_smi_write_byte(priv, data >> 8); ++ /* Writes, on the other hand, are no different in 'rtk' mode. */ ++ ret = i2c_master_send(i2c, data, count); ++ if (ret == count) ++ return 0; ++ else if (ret < 0) ++ return ret; + else +- ret = realtek_smi_write_byte_noack(priv, data >> 8); - if (ret) - goto out; - @@ -954,13 +428,22 @@ index 53a6018d54b8..1aeb32a1c068 100644 - return ret; -} - +-/* There is one single case when we need to use this accessor and that +- * is when issueing soft reset. Since the device reset as soon as we write +- * that bit, no ACK will come back for natural reasons. +- */ +-static int realtek_smi_write_reg_noack(void *ctx, u32 reg, u32 val) +-{ +- return realtek_smi_write_reg(ctx, reg, val, false); +-} +- -/* Regmap accessors */ - -static int realtek_smi_write(void *ctx, u32 reg, u32 val) -{ - struct realtek_priv *priv = ctx; - -- return realtek_smi_write_reg(priv, reg, val); +- return realtek_smi_write_reg(priv, reg, val, true); -} - -static int realtek_smi_read(void *ctx, u32 reg, u32 *val) @@ -968,22 +451,49 @@ index 53a6018d54b8..1aeb32a1c068 100644 - struct realtek_priv *priv = ctx; - - return realtek_smi_read_reg(priv, reg, val); --} -- ++ return -EIO; + } + static void realtek_smi_lock(void *ctx) - { - struct realtek_priv *priv = ctx; -@@ -309,8 +59,7 @@ static const struct regmap_config realtek_smi_regmap_config = { - .reg_bits = 16, +@@ -325,32 +128,17 @@ static void realtek_smi_unlock(void *ctx) + } + + static const struct regmap_config realtek_smi_regmap_config = { +- .reg_bits = 10, /* A4..A0 R4..R0 */ ++ .reg_bits = 16, .val_bits = 16, - .reg_format_endian = REGMAP_ENDIAN_BIG, +- .reg_stride = 1, +- /* PHY regs are at 0x8000 */ +- .max_register = 0xffff, +- .reg_format_endian = REGMAP_ENDIAN_BIG, - .reg_read = realtek_smi_read, - .reg_write = realtek_smi_write, ++ .reg_format_endian = REGMAP_ENDIAN_LITTLE, + .val_format_endian = REGMAP_ENDIAN_LITTLE, ++ .read = realtek_smi_rtk_read, ++ .write = realtek_smi_rtk_write, .cache_type = REGCACHE_NONE, .lock = realtek_smi_lock, .unlock = realtek_smi_unlock, -@@ -373,10 +122,10 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds) + }; + +-static const struct regmap_config realtek_smi_nolock_regmap_config = { +- .reg_bits = 10, /* A4..A0 R4..R0 */ +- .val_bits = 16, +- .reg_stride = 1, +- /* PHY regs are at 0x8000 */ +- .max_register = 0xffff, +- .reg_format_endian = REGMAP_ENDIAN_BIG, +- .reg_read = realtek_smi_read, +- .reg_write = realtek_smi_write, +- .cache_type = REGCACHE_NONE, +- .disable_locking = true, +-}; +- + static int realtek_smi_mdio_read(struct mii_bus *bus, int addr, int regnum) + { + struct realtek_priv *priv = bus->priv; +@@ -408,10 +196,10 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds) return ret; } @@ -996,7 +506,22 @@ index 53a6018d54b8..1aeb32a1c068 100644 struct realtek_priv *priv; struct regmap_config rc; struct device_node *np; -@@ -393,7 +142,7 @@ static int realtek_smi_probe(struct platform_device *pdev) +@@ -420,24 +208,29 @@ static int realtek_smi_probe(struct platform_device *pdev) + var = of_device_get_match_data(dev); + np = dev->of_node; + ++ /* The "Realtek" protocol variant requires nonstandard functionality */ ++ if (!i2c_check_functionality(client->adapter, I2C_FUNC_NOSTART)) { ++ dev_err(dev, "'rtk' mode needs bus with NOSTART support\n"); ++ return -ENODEV; ++ } ++ + priv = devm_kzalloc(dev, sizeof(*priv) + var->chip_data_sz, GFP_KERNEL); + if (!priv) + return -ENOMEM; +- priv->chip_data = (void *)priv + sizeof(*priv); + + mutex_init(&priv->map_lock); rc = realtek_smi_regmap_config; rc.lock_arg = priv; @@ -1005,31 +530,34 @@ index 53a6018d54b8..1aeb32a1c068 100644 if (IS_ERR(priv->map)) { ret = PTR_ERR(priv->map); dev_err(dev, "regmap init failed: %d\n", ret); -@@ -401,7 +150,7 @@ static int realtek_smi_probe(struct platform_device *pdev) + return ret; } - rc.disable_locking = true; +- rc = realtek_smi_nolock_regmap_config; - priv->map_nolock = devm_regmap_init(dev, NULL, priv, &rc); ++ rc.disable_locking = true; + priv->map_nolock = devm_regmap_init_i2c(client, &rc); if (IS_ERR(priv->map_nolock)) { ret = PTR_ERR(priv->map_nolock); dev_err(dev, "regmap init failed: %d\n", ret); -@@ -410,13 +159,11 @@ static int realtek_smi_probe(struct platform_device *pdev) +@@ -446,15 +239,11 @@ static int realtek_smi_probe(struct platform_device *pdev) /* Link forward and backward */ priv->dev = dev; - priv->clk_delay = var->clk_delay; -- priv->i2c_addr = var->i2c_addr; +- priv->cmd_read = var->cmd_read; +- priv->cmd_write = var->cmd_write; priv->ops = var->ops; priv->setup_interface = realtek_smi_setup_mdio; +- priv->write_reg_noack = realtek_smi_write_reg_noack; - dev_set_drvdata(dev, priv); + i2c_set_clientdata(client, priv); spin_lock_init(&priv->lock); /* TODO: if power is software controlled, set up any regulators here */ -@@ -435,14 +182,6 @@ static int realtek_smi_probe(struct platform_device *pdev) +@@ -473,14 +262,6 @@ static int realtek_smi_probe(struct platform_device *pdev) dev_dbg(dev, "deasserted RESET\n"); } @@ -1044,28 +572,20 @@ index 53a6018d54b8..1aeb32a1c068 100644 priv->leds_disabled = of_property_read_bool(np, "realtek,disable-leds"); ret = priv->ops->detect(priv); -@@ -468,12 +207,12 @@ static int realtek_smi_probe(struct platform_device *pdev) +@@ -506,9 +287,9 @@ static int realtek_smi_probe(struct platform_device *pdev) return 0; } --static int realtek_smi_remove(struct platform_device *pdev) +-static void realtek_smi_remove(struct platform_device *pdev) +static void realtek_smi_remove(struct i2c_client *client) { - struct realtek_priv *priv = platform_get_drvdata(pdev); + struct realtek_priv *priv = i2c_get_clientdata(client); if (!priv) -- return 0; -+ return; - - dsa_unregister_switch(priv->ds); - if (priv->slave_mii_bus) -@@ -483,19 +222,19 @@ static int realtek_smi_remove(struct platform_device *pdev) - if (priv->reset) + return; +@@ -522,16 +303,16 @@ static void realtek_smi_remove(struct platform_device *pdev) gpiod_set_value(priv->reset, 1); - -- return 0; -+ return; } -static void realtek_smi_shutdown(struct platform_device *pdev) @@ -1073,223 +593,35 @@ index 53a6018d54b8..1aeb32a1c068 100644 { - struct realtek_priv *priv = platform_get_drvdata(pdev); + struct realtek_priv *priv = i2c_get_clientdata(client); - - if (!priv) - return; - - dsa_switch_shutdown(priv->ds); - -- platform_set_drvdata(pdev, NULL); -+ i2c_set_clientdata(client, NULL); - } - - static const struct of_device_id realtek_smi_of_match[] = { -@@ -515,7 +254,7 @@ static const struct of_device_id realtek_smi_of_match[] = { - }; - MODULE_DEVICE_TABLE(of, realtek_smi_of_match); - --static struct platform_driver realtek_smi_driver = { -+static struct i2c_driver realtek_smi_driver = { - .driver = { - .name = "realtek-smi", - .of_match_table = realtek_smi_of_match, -@@ -524,7 +263,7 @@ static struct platform_driver realtek_smi_driver = { - .remove = realtek_smi_remove, - .shutdown = realtek_smi_shutdown, - }; --module_platform_driver(realtek_smi_driver); -+module_i2c_driver(realtek_smi_driver); - - MODULE_AUTHOR("Linus Walleij "); - MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via SMI interface"); -diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h -index eed9bb3ed10a..cd2b9e774044 100644 ---- a/drivers/net/dsa/realtek/realtek.h -+++ b/drivers/net/dsa/realtek/realtek.h -@@ -49,8 +49,6 @@ struct rtl8366_vlan_4k { - struct realtek_priv { - struct device *dev; - struct gpio_desc *reset; -- struct gpio_desc *mdc; -- struct gpio_desc *mdio; - struct regmap *map; - struct regmap *map_nolock; - struct mutex map_lock; -@@ -58,8 +56,6 @@ struct realtek_priv { - struct mii_bus *bus; - int mdio_addr; - -- unsigned int clk_delay; -- u8 i2c_addr; - spinlock_t lock; /* Locks around command writes */ - struct dsa_switch *ds; - struct irq_domain *irqdomain; --- -2.43.2 - - -From 8f6ff7666048234af439687962ed8fc72209c542 Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Wed, 13 Mar 2024 19:48:18 -0600 -Subject: [PATCH 07/11] local: realtek: Implement "Realtek"/"RTK" I2C mode - ---- - drivers/net/dsa/realtek/realtek-smi.c | 79 ++++++++++++++++++++++++++- - 1 file changed, 78 insertions(+), 1 deletion(-) - -diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c -index 1aeb32a1c068..01e0634ce999 100644 ---- a/drivers/net/dsa/realtek/realtek-smi.c -+++ b/drivers/net/dsa/realtek/realtek-smi.c -@@ -41,6 +41,75 @@ - - #include "realtek.h" - -+static int realtek_smi_rtk_read(void *ctx, const void *reg, size_t reg_size, -+ void *val, size_t val_size) -+{ -+ struct device *dev = ctx; -+ struct i2c_client *i2c = to_i2c_client(dev); -+ int ret; -+ -+ /* In "Realtek" I2C mode, read transfers aren't quite the same as those -+ * of standard I2C. A conventional I2C read involves a write transfer -+ * to specify the register, followed by a read transfer to retrieve the -+ * value. The "Realtek" mode uses a single transfer, but the adapter -+ * sends 2 extra bytes after the address byte to specify the register -+ * before the bus turns around to complete the read operation. -+ * -+ * This can be accomplished through prudent use of the NOSTART flag to -+ * insert the register bytes into the middle of a read transfer without -+ * the device being any the wiser. -+ */ -+ struct i2c_msg xfer[] = { -+ /* Start a transfer and send only the start byte -+ * (address and R/W̅ bit) */ -+ { -+ .addr = i2c->addr, -+ .flags = I2C_M_RD, -+ .len = 0 -+ }, -+ -+ /* Send 2 extra bytes to specify the register */ -+ { -+ .addr = i2c->addr, -+ .flags = I2C_M_NOSTART, -+ .len = reg_size, -+ .buf = (void *)reg -+ }, -+ -+ /* Now turn the bus around and finish the read */ -+ { -+ .addr = i2c->addr, -+ .flags = I2C_M_RD | I2C_M_NOSTART, -+ .len = val_size, -+ .buf = val -+ } -+ }; -+ -+ ret = i2c_transfer(i2c->adapter, xfer, ARRAY_SIZE(xfer)); -+ if (ret == ARRAY_SIZE(xfer)) -+ return 0; -+ else if (ret < 0) -+ return ret; -+ else -+ return -EIO; -+} -+ -+static int realtek_smi_rtk_write(void *ctx, const void *data, size_t count) -+{ -+ struct device *dev = ctx; -+ struct i2c_client *i2c = to_i2c_client(dev); -+ int ret; -+ -+ /* Writes, on the other hand, are no different in 'rtk' mode. */ -+ ret = i2c_master_send(i2c, data, count); -+ if (ret == count) -+ return 0; -+ else if (ret < 0) -+ return ret; -+ else -+ return -EIO; -+} -+ - static void realtek_smi_lock(void *ctx) - { - struct realtek_priv *priv = ctx; -@@ -58,8 +127,10 @@ static void realtek_smi_unlock(void *ctx) - static const struct regmap_config realtek_smi_regmap_config = { - .reg_bits = 16, - .val_bits = 16, -- .reg_format_endian = REGMAP_ENDIAN_BIG, -+ .reg_format_endian = REGMAP_ENDIAN_LITTLE, - .val_format_endian = REGMAP_ENDIAN_LITTLE, -+ .read = realtek_smi_rtk_read, -+ .write = realtek_smi_rtk_write, - .cache_type = REGCACHE_NONE, - .lock = realtek_smi_lock, - .unlock = realtek_smi_unlock, -@@ -134,6 +205,12 @@ static int realtek_smi_probe(struct i2c_client *client) - var = of_device_get_match_data(dev); - np = dev->of_node; - -+ /* The "Realtek" protocol variant requires nonstandard functionality */ -+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_NOSTART)) { -+ dev_err(dev, "'rtk' mode needs bus with NOSTART support\n"); -+ return -ENODEV; -+ } -+ - priv = devm_kzalloc(dev, sizeof(*priv) + var->chip_data_sz, GFP_KERNEL); + if (!priv) - return -ENOMEM; --- -2.43.2 - - -From 675d9d3af6a2e07dd71577876f2b2bffb422f794 Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Tue, 12 Mar 2024 03:41:04 -0600 -Subject: [PATCH 08/11] local: realtek: add back GPIO support - ---- - drivers/net/dsa/realtek/Kconfig | 1 + - drivers/net/dsa/realtek/realtek-smi.c | 114 ++++++++++++++++++++++++++ - 2 files changed, 115 insertions(+) - -diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig -index ee74ef09511d..81a0e0270557 100644 ---- a/drivers/net/dsa/realtek/Kconfig -+++ b/drivers/net/dsa/realtek/Kconfig -@@ -31,6 +31,7 @@ config NET_DSA_REALTEK_SMI - depends on NET_DSA_REALTEK_RTL8365MB || NET_DSA_REALTEK_RTL8366RB - depends on NET_DSA_REALTEK_RTL8365MB || !NET_DSA_REALTEK_RTL8365MB - depends on NET_DSA_REALTEK_RTL8366RB || !NET_DSA_REALTEK_RTL8366RB -+ select I2C_GPIO - select REGMAP_I2C - help - Select to enable support for registering switches connected -diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c -index 01e0634ce999..fce1daac3557 100644 ---- a/drivers/net/dsa/realtek/realtek-smi.c -+++ b/drivers/net/dsa/realtek/realtek-smi.c -@@ -31,10 +31,13 @@ - #include - #include - #include -+#include - #include - #include - #include -+#include - #include -+#include - #include - #include - #include -@@ -342,6 +345,117 @@ static struct i2c_driver realtek_smi_driver = { + return; + + dsa_switch_shutdown(priv->ds); + +- platform_set_drvdata(pdev, NULL); ++ i2c_set_clientdata(client, NULL); + } + + static const struct of_device_id realtek_smi_of_match[] = { +@@ -551,16 +332,127 @@ static const struct of_device_id realtek_smi_of_match[] = { }; - module_i2c_driver(realtek_smi_driver); + MODULE_DEVICE_TABLE(of, realtek_smi_of_match); +-static struct platform_driver realtek_smi_driver = { ++static struct i2c_driver realtek_smi_driver = { + .driver = { + .name = "realtek-smi", + .of_match_table = realtek_smi_of_match, + }, + .probe = realtek_smi_probe, +- .remove_new = realtek_smi_remove, ++ .remove = realtek_smi_remove, + .shutdown = realtek_smi_shutdown, + }; +-module_platform_driver(realtek_smi_driver); ++module_i2c_driver(realtek_smi_driver); ++ +struct realtek_smi_plat_priv { + struct i2c_adapter adap; + struct i2c_algo_bit_data algo; @@ -1400,87 +732,77 @@ index 01e0634ce999..fce1daac3557 100644 + .remove_new = realtek_smi_plat_remove, +}; +module_platform_driver(realtek_smi_plat_driver); -+ + MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via SMI interface"); - MODULE_LICENSE("GPL"); --- -2.43.2 - - -From e2474c1d276b790b55b9518df4e0f1959221db65 Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Thu, 21 Mar 2024 16:39:46 -0600 -Subject: [PATCH 09/11] local: begin improving tagging decoder - ---- - net/dsa/tag_rtl8_4.c | 20 +++++++++++++++----- - 1 file changed, 15 insertions(+), 5 deletions(-) - -diff --git a/net/dsa/tag_rtl8_4.c b/net/dsa/tag_rtl8_4.c -index 4f67834fd121..f9181cff5f0e 100644 ---- a/net/dsa/tag_rtl8_4.c -+++ b/net/dsa/tag_rtl8_4.c -@@ -35,8 +35,13 @@ - * X | reserved - * ------------+------------- - * REASON | reason for forwarding packet to CPU -- * | 0: packet was forwarded or flooded to CPU -- * | 80: packet was trapped to CPU -+ * | 0x00: packet was forwarded or flooded to CPU -+ * | 0x41: dot1x unauthorized -+ * | 0x4B: port learning limit exceeded -+ * | 0x50: unknown unicast destination MAC -+ * | 0x51: unknown multicast destination MAC -+ * | 0x54: unknown source MAC -+ * | 0x55: unmatched source MAC - * FID_EN | 1: packet has an FID - * | 0: no FID - * FID | FID of packet (if FID_EN=1) -@@ -92,8 +97,13 @@ - #define RTL8_4_PROTOCOL GENMASK(15, 8) - #define RTL8_4_PROTOCOL_RTL8365MB 0x04 - #define RTL8_4_REASON GENMASK(7, 0) --#define RTL8_4_REASON_FORWARD 0 --#define RTL8_4_REASON_TRAP 80 -+#define RTL8_4_REASON_FORWARD 0x00 -+#define RTL8_4_REASON_1XUNAUTH 0x41 -+#define RTL8_4_REASON_LUT_OVER 0x4B -+#define RTL8_4_REASON_UNK_UNICAST 0x50 -+#define RTL8_4_REASON_UNK_MULTICAST 0x51 -+#define RTL8_4_REASON_UNK_SOURCE 0x54 -+#define RTL8_4_REASON_UNMATCH_SOURCE 0x55 +diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h +index 790488e9c667..f0d53deba425 100644 +--- a/drivers/net/dsa/realtek/realtek.h ++++ b/drivers/net/dsa/realtek/realtek.h +@@ -49,8 +49,6 @@ struct rtl8366_vlan_4k { + struct realtek_priv { + struct device *dev; + struct gpio_desc *reset; +- struct gpio_desc *mdc; +- struct gpio_desc *mdio; + struct regmap *map; + struct regmap *map_nolock; + struct mutex map_lock; +@@ -58,9 +56,6 @@ struct realtek_priv { + struct mii_bus *bus; + int mdio_addr; - #define RTL8_4_LEARN_DIS BIT(5) +- unsigned int clk_delay; +- u8 cmd_read; +- u8 cmd_write; + spinlock_t lock; /* Locks around command writes */ + struct dsa_switch *ds; + struct irq_domain *irqdomain; +@@ -74,13 +69,12 @@ struct realtek_priv { -@@ -188,7 +198,7 @@ static int rtl8_4_read_tag(struct sk_buff *skb, struct net_device *dev, - return -ENOENT; - } + const struct realtek_ops *ops; + int (*setup_interface)(struct dsa_switch *ds); +- int (*write_reg_noack)(void *ctx, u32 addr, u32 data); -- if (reason != RTL8_4_REASON_TRAP) -+ if (reason == RTL8_4_REASON_FORWARD) - dsa_default_offload_fwd_mark(skb); + int vlan_enabled; + int vlan4k_enabled; + + char buf[4096]; +- void *chip_data; /* Per-chip extra variant data */ ++ char chip_data[]; /* Per-chip extra variant data */ + }; + + /* +@@ -120,8 +114,7 @@ struct realtek_variant { + const struct dsa_switch_ops *ds_ops_mdio; + const struct realtek_ops *ops; + unsigned int clk_delay; +- u8 cmd_read; +- u8 cmd_write; ++ u8 i2c_addr; + size_t chip_data_sz; + }; - return 0; --- -2.43.2 - - -From b7c86d836c03ba9a8254d564697792612aed9e90 Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Thu, 21 Mar 2024 19:10:46 -0600 -Subject: [PATCH 10/11] local: realtek: trap standalone ports rather than use - the isolation matrix - ---- - drivers/net/dsa/realtek/rtl8365mb.c | 63 +++++++++++++++++++++++++++-- - 1 file changed, 59 insertions(+), 4 deletions(-) - diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c -index b723ade207c9..d4f0374d9dac 100644 +index b072045eb154..31e60994e54e 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c -@@ -281,6 +281,18 @@ +@@ -275,12 +275,33 @@ + #define RTL8365MB_LUT_PORT_LEARN_LIMIT_REG(_physport) \ + (RTL8365MB_LUT_PORT_LEARN_LIMIT_BASE + (_physport)) + ++/* Port-based EFID registers */ ++#define RTL8365MB_PORT_EFID_BASE 0x0A32 ++#define RTL8365MB_PORT_EFID_REG(_physport) \ ++ (RTL8365MB_PORT_EFID_BASE + ((_physport) >> 2)) ++#define RTL8365MB_PORT_EFID_OFFSET(_physport) \ ++ (((_physport) & 0x3) << 2) ++#define RTL8365MB_PORT_EFID_MASK(_physport) \ ++ (0x7 << RTL8365MB_PORT_EFID_OFFSET((_physport))) ++ + /* Port isolation (forwarding mask) registers */ + #define RTL8365MB_PORT_ISOLATION_REG_BASE 0x08A2 + #define RTL8365MB_PORT_ISOLATION_REG(_physport) \ (RTL8365MB_PORT_ISOLATION_REG_BASE + (_physport)) #define RTL8365MB_PORT_ISOLATION_MASK 0x07FF @@ -1499,7 +821,27 @@ index b723ade207c9..d4f0374d9dac 100644 /* MSTP port state registers - indexed by tree instance */ #define RTL8365MB_MSTI_CTRL_BASE 0x0A00 #define RTL8365MB_MSTI_CTRL_REG(_msti, _physport) \ -@@ -597,6 +609,12 @@ enum rtl8365mb_cpu_rxlen { +@@ -554,6 +575,19 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = { + .jam_table = rtl8365mb_init_jam_8365mb_vc, + .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), + }, ++ { ++ .name = "RTL8370MB-CG", ++ .chip_id = 0x6368, ++ .chip_ver = 0x0010, ++ .extints = { ++ { 8, 1, PHY_INTF(MII) | PHY_INTF(TMII) | ++ PHY_INTF(RMII) | PHY_INTF(RGMII) }, ++ { 9, 2, PHY_INTF(MII) | PHY_INTF(TMII) | ++ PHY_INTF(RMII) | PHY_INTF(RGMII) }, ++ }, ++ .jam_table = rtl8365mb_init_jam_8365mb_vc, ++ .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), ++ }, + }; + + enum rtl8365mb_stp_state { +@@ -584,6 +618,12 @@ enum rtl8365mb_cpu_rxlen { RTL8365MB_CPU_RXLEN_64BYTES = 1, }; @@ -1512,7 +854,43 @@ index b723ade207c9..d4f0374d9dac 100644 /** * struct rtl8365mb_cpu - CPU port configuration * @enable: enable/disable hardware insertion of CPU tag in switch->CPU frames -@@ -1228,6 +1246,43 @@ static int rtl8365mb_port_set_isolation(struct realtek_priv *priv, int port, +@@ -839,7 +879,7 @@ static int rtl8365mb_dsa_phy_write(struct dsa_switch *ds, int phy, int regnum, + static const struct rtl8365mb_extint * + rtl8365mb_get_port_extint(struct realtek_priv *priv, int port) + { +- struct rtl8365mb *mb = priv->chip_data; ++ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; + int i; + + for (i = 0; i < RTL8365MB_MAX_NUM_EXTINTS; i++) { +@@ -864,7 +904,7 @@ rtl8365mb_get_tag_protocol(struct dsa_switch *ds, int port, + struct rtl8365mb_cpu *cpu; + struct rtl8365mb *mb; + +- mb = priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; + cpu = &mb->cpu; + + if (cpu->position == RTL8365MB_CPU_POS_BEFORE_CRC) +@@ -1092,7 +1132,7 @@ static void rtl8365mb_phylink_mac_link_down(struct dsa_switch *ds, int port, + struct rtl8365mb *mb; + int ret; + +- mb = priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; + p = &mb->ports[port]; + cancel_delayed_work_sync(&p->mib_work); + +@@ -1120,7 +1160,7 @@ static void rtl8365mb_phylink_mac_link_up(struct dsa_switch *ds, int port, + struct rtl8365mb *mb; + int ret; + +- mb = priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; + p = &mb->ports[port]; + schedule_delayed_work(&p->mib_work, 0); + +@@ -1215,6 +1255,107 @@ static int rtl8365mb_port_set_isolation(struct realtek_priv *priv, int port, return regmap_write(priv->map, RTL8365MB_PORT_ISOLATION_REG(port), mask); } @@ -1550,67 +928,9 @@ index b723ade207c9..d4f0374d9dac 100644 + RTL8365MB_DOT1X_UNAUTH_ACT_REG(port), + RTL8365MB_DOT1X_UNAUTH_ACT_MASK(port), + RTL8365MB_DOT1X_ACTION_TRAP << -+ RTL8365MB_DOT1X_UNAUTH_ACT_OFFSET(port)); -+} -+ - static int rtl8365mb_mib_counter_read(struct realtek_priv *priv, int port, - u32 offset, u32 length, u64 *mibvalue) - { -@@ -2003,13 +2058,13 @@ static int rtl8365mb_setup(struct dsa_switch *ds) - if (dsa_is_unused_port(priv->ds, i)) - continue; - -- /* Forward only to the CPU */ -- ret = rtl8365mb_port_set_isolation(priv, i, cpu->mask); -+ /* Clear the port's isolation mask */ -+ ret = rtl8365mb_port_set_isolation(priv, i, 0); - if (ret) - goto out_teardown_irq; - -- /* Disable learning */ -- ret = rtl8365mb_port_set_learning(priv, i, false); -+ /* Trap all ingress traffic on this port */ -+ ret = rtl8365mb_port_set_trapping(priv, i, true); - if (ret) - goto out_teardown_irq; - --- -2.43.2 - - -From e88bfa1bf5804123596c625c5bb18b40e60c2246 Mon Sep 17 00:00:00 2001 -From: Sam Edwards -Date: Fri, 22 Mar 2024 17:43:16 -0600 -Subject: [PATCH 11/11] local: realtek: implement bridge offload - ---- - drivers/net/dsa/realtek/rtl8365mb.c | 80 +++++++++++++++++++++++++++++ - 1 file changed, 80 insertions(+) - -diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c -index d4f0374d9dac..61f8dac3c914 100644 ---- a/drivers/net/dsa/realtek/rtl8365mb.c -+++ b/drivers/net/dsa/realtek/rtl8365mb.c -@@ -275,6 +275,15 @@ - #define RTL8365MB_LUT_PORT_LEARN_LIMIT_REG(_physport) \ - (RTL8365MB_LUT_PORT_LEARN_LIMIT_BASE + (_physport)) - -+/* Port-based EFID registers */ -+#define RTL8365MB_PORT_EFID_BASE 0x0A32 -+#define RTL8365MB_PORT_EFID_REG(_physport) \ -+ (RTL8365MB_PORT_EFID_BASE + ((_physport) >> 2)) -+#define RTL8365MB_PORT_EFID_OFFSET(_physport) \ -+ (((_physport) & 0x3) << 2) -+#define RTL8365MB_PORT_EFID_MASK(_physport) \ -+ (0x7 << RTL8365MB_PORT_EFID_OFFSET((_physport))) ++ RTL8365MB_DOT1X_UNAUTH_ACT_OFFSET(port)); ++} + - /* Port isolation (forwarding mask) registers */ - #define RTL8365MB_PORT_ISOLATION_REG_BASE 0x08A2 - #define RTL8365MB_PORT_ISOLATION_REG(_physport) \ -@@ -1283,6 +1292,70 @@ static int rtl8365mb_port_set_trapping(struct realtek_priv *priv, int port, - RTL8365MB_DOT1X_UNAUTH_ACT_OFFSET(port)); - } - +static int rtl8365mb_port_set_efid(struct realtek_priv *priv, int port, u8 efid) +{ + return regmap_update_bits(priv->map, RTL8365MB_PORT_EFID_REG(port), @@ -1678,17 +998,174 @@ index d4f0374d9dac..61f8dac3c914 100644 static int rtl8365mb_mib_counter_read(struct realtek_priv *priv, int port, u32 offset, u32 length, u64 *mibvalue) { -@@ -2016,6 +2089,9 @@ static int rtl8365mb_setup(struct dsa_switch *ds) +@@ -1276,7 +1417,7 @@ static void rtl8365mb_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *da + int ret; + int i; + +- mb = priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; + + mutex_lock(&mb->mib_lock); + for (i = 0; i < RTL8365MB_MIB_END; i++) { +@@ -1322,7 +1463,7 @@ static void rtl8365mb_get_phy_stats(struct dsa_switch *ds, int port, + struct rtl8365mb_mib_counter *mib; + struct rtl8365mb *mb; + +- mb = priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; + mib = &rtl8365mb_mib_counters[RTL8365MB_MIB_dot3StatsSymbolErrors]; + + mutex_lock(&mb->mib_lock); +@@ -1359,7 +1500,7 @@ static void rtl8365mb_get_mac_stats(struct dsa_switch *ds, int port, + int ret; + int i; + +- mb = priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; + + mutex_lock(&mb->mib_lock); + for (i = 0; i < RTL8365MB_MIB_END; i++) { +@@ -1423,7 +1564,7 @@ static void rtl8365mb_get_ctrl_stats(struct dsa_switch *ds, int port, + struct rtl8365mb_mib_counter *mib; + struct rtl8365mb *mb; + +- mb = priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; + mib = &rtl8365mb_mib_counters[RTL8365MB_MIB_dot3ControlInUnknownOpcodes]; + + mutex_lock(&mb->mib_lock); +@@ -1451,7 +1592,7 @@ static void rtl8365mb_stats_update(struct realtek_priv *priv, int port) + [RTL8365MB_MIB_dot3StatsFCSErrors] = 1, + [RTL8365MB_MIB_dot3StatsLateCollisions] = 1, + }; +- struct rtl8365mb *mb = priv->chip_data; ++ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; + struct rtnl_link_stats64 *stats; + int ret; + int i; +@@ -1530,7 +1671,7 @@ static void rtl8365mb_get_stats64(struct dsa_switch *ds, int port, + struct rtl8365mb_port *p; + struct rtl8365mb *mb; + +- mb = priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; + p = &mb->ports[port]; + + spin_lock(&p->stats_lock); +@@ -1540,7 +1681,7 @@ static void rtl8365mb_get_stats64(struct dsa_switch *ds, int port, + + static void rtl8365mb_stats_setup(struct realtek_priv *priv) + { +- struct rtl8365mb *mb = priv->chip_data; ++ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; + int i; + + /* Per-chip global mutex to protect MIB counter access, since doing +@@ -1566,7 +1707,7 @@ static void rtl8365mb_stats_setup(struct realtek_priv *priv) + + static void rtl8365mb_stats_teardown(struct realtek_priv *priv) + { +- struct rtl8365mb *mb = priv->chip_data; ++ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; + int i; + + for (i = 0; i < priv->num_ports; i++) { +@@ -1693,7 +1834,7 @@ static int rtl8365mb_irq_disable(struct realtek_priv *priv) + + static int rtl8365mb_irq_setup(struct realtek_priv *priv) + { +- struct rtl8365mb *mb = priv->chip_data; ++ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; + struct device_node *intc; + u32 irq_trig; + int virq; +@@ -1812,7 +1953,7 @@ static int rtl8365mb_irq_setup(struct realtek_priv *priv) + + static void rtl8365mb_irq_teardown(struct realtek_priv *priv) + { +- struct rtl8365mb *mb = priv->chip_data; ++ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; + int virq; + int i; + +@@ -1834,7 +1975,7 @@ static void rtl8365mb_irq_teardown(struct realtek_priv *priv) + + static int rtl8365mb_cpu_config(struct realtek_priv *priv) + { +- struct rtl8365mb *mb = priv->chip_data; ++ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; + struct rtl8365mb_cpu *cpu = &mb->cpu; + u32 val; + int ret; +@@ -1868,7 +2009,7 @@ static int rtl8365mb_change_tag_protocol(struct dsa_switch *ds, + struct rtl8365mb_cpu *cpu; + struct rtl8365mb *mb; + +- mb = priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; + cpu = &mb->cpu; + + switch (proto) { +@@ -1894,7 +2035,7 @@ static int rtl8365mb_change_tag_protocol(struct dsa_switch *ds, + + static int rtl8365mb_switch_init(struct realtek_priv *priv) + { +- struct rtl8365mb *mb = priv->chip_data; ++ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; + const struct rtl8365mb_chip_info *ci; + int ret; + int i; +@@ -1926,8 +2067,8 @@ static int rtl8365mb_reset_chip(struct realtek_priv *priv) + { + u32 val; + +- priv->write_reg_noack(priv, RTL8365MB_CHIP_RESET_REG, +- FIELD_PREP(RTL8365MB_CHIP_RESET_HW_MASK, 1)); ++ regmap_write(priv->map, RTL8365MB_CHIP_RESET_REG, ++ FIELD_PREP(RTL8365MB_CHIP_RESET_HW_MASK, 1)); + + /* Realtek documentation says the chip needs 1 second to reset. Sleep + * for 100 ms before accessing any registers to prevent ACK timeouts. +@@ -1947,7 +2088,10 @@ static int rtl8365mb_setup(struct dsa_switch *ds) int ret; int i; +- mb = priv->chip_data; + ds->fdb_isolation = true; + ds->max_num_bridges = 7; + - mb = (struct rtl8365mb *)priv->chip_data; ++ mb = (struct rtl8365mb *)priv->chip_data; cpu = &mb->cpu; -@@ -2201,6 +2277,8 @@ static const struct dsa_switch_ops rtl8365mb_switch_ops_smi = { + ret = rtl8365mb_reset_chip(priv); +@@ -1989,13 +2133,13 @@ static int rtl8365mb_setup(struct dsa_switch *ds) + if (dsa_is_unused_port(priv->ds, i)) + continue; + +- /* Forward only to the CPU */ +- ret = rtl8365mb_port_set_isolation(priv, i, cpu->mask); ++ /* Clear the port's isolation mask */ ++ ret = rtl8365mb_port_set_isolation(priv, i, 0); + if (ret) + goto out_teardown_irq; + +- /* Disable learning */ +- ret = rtl8365mb_port_set_learning(priv, i, false); ++ /* Trap all ingress traffic on this port */ ++ ret = rtl8365mb_port_set_trapping(priv, i, true); + if (ret) + goto out_teardown_irq; + +@@ -2071,7 +2215,7 @@ static int rtl8365mb_get_chip_id_and_ver(struct regmap *map, u32 *id, u32 *ver) + + static int rtl8365mb_detect(struct realtek_priv *priv) + { +- struct rtl8365mb *mb = priv->chip_data; ++ struct rtl8365mb *mb = (struct rtl8365mb *)priv->chip_data; + u32 chip_id; + u32 chip_ver; + int ret; +@@ -2132,6 +2276,8 @@ static const struct dsa_switch_ops rtl8365mb_switch_ops_smi = { .get_stats64 = rtl8365mb_get_stats64, .port_change_mtu = rtl8365mb_port_change_mtu, .port_max_mtu = rtl8365mb_port_max_mtu, @@ -1697,7 +1174,7 @@ index d4f0374d9dac..61f8dac3c914 100644 }; static const struct dsa_switch_ops rtl8365mb_switch_ops_mdio = { -@@ -2224,6 +2302,8 @@ static const struct dsa_switch_ops rtl8365mb_switch_ops_mdio = { +@@ -2155,6 +2301,8 @@ static const struct dsa_switch_ops rtl8365mb_switch_ops_mdio = { .get_stats64 = rtl8365mb_get_stats64, .port_change_mtu = rtl8365mb_port_change_mtu, .port_max_mtu = rtl8365mb_port_max_mtu, @@ -1706,6 +1183,122 @@ index d4f0374d9dac..61f8dac3c914 100644 }; static const struct realtek_ops rtl8365mb_ops = { +@@ -2168,8 +2316,7 @@ const struct realtek_variant rtl8365mb_variant = { + .ds_ops_mdio = &rtl8365mb_switch_ops_mdio, + .ops = &rtl8365mb_ops, + .clk_delay = 10, +- .cmd_read = 0xb9, +- .cmd_write = 0xb8, ++ .i2c_addr = 0x5c, + .chip_data_sz = sizeof(struct rtl8365mb), + }; + EXPORT_SYMBOL_GPL(rtl8365mb_variant); +diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c +index e3b6a470ca67..4c8b6e238eb0 100644 +--- a/drivers/net/dsa/realtek/rtl8366rb.c ++++ b/drivers/net/dsa/realtek/rtl8366rb.c +@@ -808,7 +808,7 @@ static int rtl8366rb_setup(struct dsa_switch *ds) + int ret; + int i; + +- rb = priv->chip_data; ++ rb = (struct rtl8366rb *)priv->chip_data; + + ret = regmap_read(priv->map, RTL8366RB_CHIP_ID_REG, &chip_id); + if (ret) { +@@ -1331,7 +1331,7 @@ static int rtl8366rb_vlan_filtering(struct dsa_switch *ds, int port, + struct rtl8366rb *rb; + int ret; + +- rb = priv->chip_data; ++ rb = (struct rtl8366rb *)priv->chip_data; + + dev_dbg(priv->dev, "port %d: %s VLAN filtering\n", port, + vlan_filtering ? "enable" : "disable"); +@@ -1441,7 +1441,7 @@ static int rtl8366rb_change_mtu(struct dsa_switch *ds, int port, int new_mtu) + int i; + + /* Cache the per-port MTU setting */ +- rb = priv->chip_data; ++ rb = (struct rtl8366rb *)priv->chip_data; + rb->max_mtu[port] = new_mtu; + + /* Roof out the MTU for the entire switch to the greatest +@@ -1654,7 +1654,7 @@ static int rtl8366rb_set_mc_index(struct realtek_priv *priv, int port, int index + bool pvid_enabled; + int ret; + +- rb = priv->chip_data; ++ rb = (struct rtl8366rb *)priv->chip_data; + pvid_enabled = !!index; + + if (port >= priv->num_ports || index >= RTL8366RB_NUM_VLANS) +@@ -1799,8 +1799,8 @@ static int rtl8366rb_reset_chip(struct realtek_priv *priv) + u32 val; + int ret; + +- priv->write_reg_noack(priv, RTL8366RB_RESET_CTRL_REG, +- RTL8366RB_CHIP_CTRL_RESET_HW); ++ regmap_write(priv->map, RTL8366RB_RESET_CTRL_REG, ++ RTL8366RB_CHIP_CTRL_RESET_HW); + do { + usleep_range(20000, 25000); + ret = regmap_read(priv->map, RTL8366RB_RESET_CTRL_REG, &val); +@@ -1929,8 +1929,7 @@ const struct realtek_variant rtl8366rb_variant = { + .ds_ops_mdio = &rtl8366rb_switch_ops_mdio, + .ops = &rtl8366rb_ops, + .clk_delay = 10, +- .cmd_read = 0xa9, +- .cmd_write = 0xa8, ++ .i2c_addr = 0x54, + .chip_data_sz = sizeof(struct rtl8366rb), + }; + EXPORT_SYMBOL_GPL(rtl8366rb_variant); +diff --git a/net/dsa/tag_rtl8_4.c b/net/dsa/tag_rtl8_4.c +index 15c2bae2b429..152d016a22f9 100644 +--- a/net/dsa/tag_rtl8_4.c ++++ b/net/dsa/tag_rtl8_4.c +@@ -35,8 +35,13 @@ + * X | reserved + * ------------+------------- + * REASON | reason for forwarding packet to CPU +- * | 0: packet was forwarded or flooded to CPU +- * | 80: packet was trapped to CPU ++ * | 0x00: packet was forwarded or flooded to CPU ++ * | 0x41: dot1x unauthorized ++ * | 0x4B: port learning limit exceeded ++ * | 0x50: unknown unicast destination MAC ++ * | 0x51: unknown multicast destination MAC ++ * | 0x54: unknown source MAC ++ * | 0x55: unmatched source MAC + * FID_EN | 1: packet has an FID + * | 0: no FID + * FID | FID of packet (if FID_EN=1) +@@ -92,8 +97,13 @@ + #define RTL8_4_PROTOCOL GENMASK(15, 8) + #define RTL8_4_PROTOCOL_RTL8365MB 0x04 + #define RTL8_4_REASON GENMASK(7, 0) +-#define RTL8_4_REASON_FORWARD 0 +-#define RTL8_4_REASON_TRAP 80 ++#define RTL8_4_REASON_FORWARD 0x00 ++#define RTL8_4_REASON_1XUNAUTH 0x41 ++#define RTL8_4_REASON_LUT_OVER 0x4B ++#define RTL8_4_REASON_UNK_UNICAST 0x50 ++#define RTL8_4_REASON_UNK_MULTICAST 0x51 ++#define RTL8_4_REASON_UNK_SOURCE 0x54 ++#define RTL8_4_REASON_UNMATCH_SOURCE 0x55 + + #define RTL8_4_LEARN_DIS BIT(5) + +@@ -188,7 +198,7 @@ static int rtl8_4_read_tag(struct sk_buff *skb, struct net_device *dev, + return -ENOENT; + } + +- if (reason != RTL8_4_REASON_TRAP) ++ if (reason == RTL8_4_REASON_FORWARD) + dsa_default_offload_fwd_mark(skb); + + return 0; -- -2.43.2 +2.45.2