From patchwork Sun Dec 8 15:52:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Yushchenko X-Patchwork-Id: 13898615 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B97F1586CF for ; Sun, 8 Dec 2024 15:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733673167; cv=none; b=agIPTz4Utgqr1uYlc92leOduMklnwP9i3vEJOTLTJXLcsAZLC0tPta5XZkZhdEjYIKW92sXBWIFEPx7wgCERNQ9Qw6cpRyWUimjhtjymuBECUdQm8wa7TsuzKVYu/HUnsPbvtwqzuGGCu80AEkWdpipkdUbOj06zeFDdzQA51jk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733673167; c=relaxed/simple; bh=pR239TJH6DkmyjLOOWJrEa9qa6lKwq6zBqCCU7HNb+o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IsDKfh7+R70+Uwf0zl7D9QXqkNbTwjYgxzSK6vEkPhY9tINtmuHF5owkSFnX/SYV1RDzazH8Y3OC+VZ2OAscOeUK4dOIZmxfHu3FjGYMc8s4WnI2lEUO8+eukJ3YIwXPOkb2SoTgEQ5wcxfJdikkstxokFKLEcsvGyp1PxKF+kU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com; spf=pass smtp.mailfrom=cogentembedded.com; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b=d1Iv4bpY; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b="d1Iv4bpY" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-3011c7b39c7so7207341fa.1 for ; Sun, 08 Dec 2024 07:52:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20230601.gappssmtp.com; s=20230601; t=1733673164; x=1734277964; darn=vger.kernel.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=YM5DZdXZqiBry1GF0hiPMUU57y91Is3FbX9t5e3p81c=; b=d1Iv4bpYYgxKt8zGwpriFDplZs2LllAYlDDcdMvk+YGdmkeyc24NiIve5F85xmWY2B gGDjXGCL3uYJfGwbLxJvapUleLflyrW/AhZ35GbdiAIrPxJXzyUCjPFdVJWlx8FieEvP 4NPSLDNFX1fnlRk7HNOJhzmYVsv6RjPubGHwSuYGaKegtEr8JkVhl6JVK+DoWZ3/Yd++ uVoi76ppkhQv0h8fRHZNtom3fodCbWRadyntxgr82uEpM3LYsguzBnMzq1wb6b7Z6QJO dtxQsRvWVI9gPeytZS8XnbGY18/mOsj9FajuOOeYUDRjKF1PWm51HG3ACBPDTyQgXPAf qxkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733673164; x=1734277964; 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=YM5DZdXZqiBry1GF0hiPMUU57y91Is3FbX9t5e3p81c=; b=r4ZGh3T9u59R51Au/bnbfdNk0NRHGOICKRSBLlIBmicp+Q0Eon2o0PqYCzEagHOTHf LDzVVRMjt7yTZS2De3PwrysUrgugRx6grVKZArJc9+Fb8R23NzXRPgs+zEsKHc13NErD 9T6UyWBbU2JzuoH6GbrfYjX5bruRVpGitYA/Hpi7t/RB7rzsSUkMYpQjZc+L8BLO7bmR dO8TG0g1t0rxv/3gPUX93PN8bdiIx+48Vi65xogcY0bWVhdR4VQjc7cSL3g0MWIsX3Xq umuK/9ier4d9oTXRR5rBcrTJnszlECNX9ipy6XHQx9CM6WT2AHZqGmu9JpHZpli429K8 TM2Q== X-Forwarded-Encrypted: i=1; AJvYcCVSKa9HivJo2lRCHavSGOOWyA/AjlZps5ZWU7SqVwJuBr5Jl0MT6XuJWIytp6hSwrNZ/Iyr57bVRx3ZPA0doLprKg==@vger.kernel.org X-Gm-Message-State: AOJu0YwitkHWnZBC4wx/q2QmOEVY+Q2rSDgPsYu5H8FnfFEybnfZzWH/ wBxQ8nukuZCwLM/rLkduKCRQx9qusBe80IKvh7hq/YwjmKKbdvkEbkW46uHFV+o= X-Gm-Gg: ASbGncvFS4nqORvHkztJPu+jUPwfbn7KDARo8ewcMAKdmVxnRJKq2rT+YMIh6Zmvgz3 k7xHgaByZQwnqRHlDTxe7wLWUlq2RYX7uJgUyIqfaBLlC8DXh5ixyrvGdfrUu+cHidUaKrSpg/O 0nxL9xZgMczTl0uQjQ08MmXztak27KBJE0zzmhZXUkWBzctgx3dg8AGJLhwS0VzXifLuZQuGIpS VhTXjcxWBdDWexy2zXm8yikW0Q0cp2O0Xtg+RfeuJa5c5Lk8rdBcPRuDP+qtHWY X-Google-Smtp-Source: AGHT+IH0mhFJkzgTaRltbt/3f/uOZ0/C8ZdKxaDXSeoLslSVJ6jaMefU1FWkl1ufVYiQ/d2eGcmVPQ== X-Received: by 2002:a05:6512:2823:b0:53f:232e:31ea with SMTP id 2adb3069b0e04-53f232e3741mr1250833e87.54.1733673163671; Sun, 08 Dec 2024 07:52:43 -0800 (PST) Received: from cobook.home ([91.198.101.25]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53e3a1ce70bsm580882e87.66.2024.12.08.07.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:52:43 -0800 (PST) From: Nikita Yushchenko To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Geert Uytterhoeven Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege , Christian Mardmoeller , Dennis Ostermann , Nikita Yushchenko Subject: [PATCH net-next 1/4] net: renesas: rswitch: do not write to MPSM register at init time Date: Sun, 8 Dec 2024 20:52:33 +0500 Message-Id: <20241208155236.108582-2-nikita.yoush@cogentembedded.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241208155236.108582-1-nikita.yoush@cogentembedded.com> References: <20241208155236.108582-1-nikita.yoush@cogentembedded.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 MPSM register is used to execute mdio bus transactions. There is no need to initialize it early. Signed-off-by: Nikita Yushchenko --- drivers/net/ethernet/renesas/rswitch.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 8ac6ef532c6a..57d0f992f9a5 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1139,7 +1139,6 @@ static void rswitch_etha_enable_mii(struct rswitch_etha *etha) { rswitch_modify(etha->addr, MPIC, MPIC_PSMCS_MASK | MPIC_PSMHT_MASK, MPIC_PSMCS(etha->psmcs) | MPIC_PSMHT(0x06)); - rswitch_modify(etha->addr, MPSM, 0, MPSM_MFF_C45); } static int rswitch_etha_hw_init(struct rswitch_etha *etha, const u8 *mac) From patchwork Sun Dec 8 15:52:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Yushchenko X-Patchwork-Id: 13898616 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EA7D15B0EE for ; Sun, 8 Dec 2024 15:52:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733673169; cv=none; b=gZW7BDPnH1V4KcPH0o3muj1qSwZZcbZd829KmUGJ/FDegaJtqX5u+fT+qLmadqSADDXz2oQ7HRejIg8vyoYX8duLtC2zByC+YzjogvdZH6Mmw1vZ4/b3xGVMh0CXicoyglHU0JiqwA0dwoAREKyaZ1f2S1pqwxiU7I/zx7BpiYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733673169; c=relaxed/simple; bh=RWCtaYm/JVslyITM0sBPkX8+GSKakwBGh/MBx/cs9wU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OtalCBuOaoqOsrt5ufwdYMcu4S1bd/cPfxl2tJ5TjigIiBHjlyreRDMCCDePSaOmcikkjfJvVrZpCx/bUIaWLenL9tRUMkkb4yidtW1p8bvbnAnrhANIEFHqiJdyjb480MqOocSR+L7qRjdg5/ilnZyJMKuJHNLr1yvo7YMfIPA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com; spf=pass smtp.mailfrom=cogentembedded.com; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b=Yp5OhfG+; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b="Yp5OhfG+" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2f75c56f16aso29160481fa.0 for ; Sun, 08 Dec 2024 07:52:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20230601.gappssmtp.com; s=20230601; t=1733673165; x=1734277965; darn=vger.kernel.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=ZQxkVzK7EnNsOjYzKhrnJfnqM/CbI5Zj781Mc6uR9Vc=; b=Yp5OhfG+J9JKgunbNkXmnc13IO1iI1fkc+BxXTEkaXSfmRtjqzhRoinzRW7GUMExKG pTfSm6S5bppsl/ryi0REEUKPzZ4wcQrGQ9wb30ATElqKTtKZkpqdBUwBTEvU4YF0mTHB FAjLq+yfrc4YDyEzYgLUidQToRb684WbbOnd4rBkIrkosa3/KPrn2BimLwTS5ZQAaH/O XDs8CSeWhsAM8Qz3ucDh3H3BRjK7cOjxRzU2H3onNjZe4pQRuGDtaijRa3sfpKS7PWRj rpW3kuvC6nRwS36AOGT7OVooEtQ4NMeHoql4EMJxFRz0YCUG6w17Njidc4YIoSYliHZI c4Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733673165; x=1734277965; 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=ZQxkVzK7EnNsOjYzKhrnJfnqM/CbI5Zj781Mc6uR9Vc=; b=XahGednKar2Wc/hlUvPkc2B7mt3ggkrHoSl6/ss6lfoaVJ2vQ4oXRNeHKRTES5Ulao Wkh1dnrqouZtQkMHz7o3vJG+Mwe4LpqlhZzCHMR2bh7qlY60R3vxCDOyNEWrYiOVFQo2 Ej3+WfP428P3EQJBfk8AQ/A7T2JVWFAAEyo/Y8lyJ8iB+T9j8IBqdSKlrNqUuh81JOiW nUuzb5uYPb7bKO3Lg2r1crAOxqPn9CRh7w8DU3cxL7SiQvqyijUvucyRUNe+ubKLk8qx TQ4C3OPeOJQXVUw4+C6/Q1IvP3lhUgPSVV98482dMt8FsBcrj2bV3Z6CZUdHqAdObbR8 h74w== X-Forwarded-Encrypted: i=1; AJvYcCWOhh0+10+erWQzdR5WoQhMWiVwINH6jc81Zu5qDdYLfbDleS6Df0Mx99yrDKd595aVSV43VNkv8tTWobkSY5qhIA==@vger.kernel.org X-Gm-Message-State: AOJu0YwBrp/ieeYWokb0bbSnbifz8+RMoz0b+Oikd7xxjTu1JT7w6zRd jkmkpJVd0mPYZLZgFpxNjL1sl91v7wSMhx9rXrw+UngH/dzJ6tqBmzHEMkArkWVEJyUkL5eaHVO CBTE= X-Gm-Gg: ASbGnctTFJYDUP4wczzN7dwulfso6L/hj5AL214BLemD3fHkHGTnDcOvAK/57JDfXu5 eMQz6QCYdhnedXh00G1rNnF2dvfEurH9mJSpiGcoplw6BfzphywliGWdNZtacB33dvajUVAa09y AydPJyY20S8lSUfKiAFWSx4KxVDexzsRIsQNptGxKe3HD+XVaGbAIRO2xqlgeXPLxyvm48UWtA8 7jV2w4iNcnRBOatC3veDmVoCnHdaje9wvlsfVVnq+0KLHcRFapiRVmy2nZOJEeB X-Google-Smtp-Source: AGHT+IFN0e6LLKXo0Wdi3CnElwzhg/3WaQvnNCfHh7dkeACryOt6FCzNDEV9CQMLSH98javWI++cxQ== X-Received: by 2002:a05:6512:3092:b0:540:1d58:da72 with SMTP id 2adb3069b0e04-5401d58db83mr536069e87.4.1733673165577; Sun, 08 Dec 2024 07:52:45 -0800 (PST) Received: from cobook.home ([91.198.101.25]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53e3a1ce70bsm580882e87.66.2024.12.08.07.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:52:45 -0800 (PST) From: Nikita Yushchenko To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Geert Uytterhoeven Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege , Christian Mardmoeller , Dennis Ostermann , Nikita Yushchenko Subject: [PATCH net-next 2/4] net: renesas: rswitch: align mdio C45 operations with datasheet Date: Sun, 8 Dec 2024 20:52:34 +0500 Message-Id: <20241208155236.108582-3-nikita.yoush@cogentembedded.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241208155236.108582-1-nikita.yoush@cogentembedded.com> References: <20241208155236.108582-1-nikita.yoush@cogentembedded.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Per rswitch datasheet, software can know that mdio operation completed either by polling MPSM.PSME bit, or via interrupt. Instead, the driver currently polls for interrupt status bit. Although this still provides correct result, it requires additional register operations to clean the interrupt status bits, and generally looks wrong. Fix it to poll MPSM.PSME bit, as the datasheet suggests. Signed-off-by: Nikita Yushchenko --- drivers/net/ethernet/renesas/rswitch.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 57d0f992f9a5..120d56754692 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1177,32 +1177,26 @@ static int rswitch_etha_set_access(struct rswitch_etha *etha, bool read, if (devad == 0xffffffff) return -ENODEV; - writel(MMIS1_CLEAR_FLAGS, etha->addr + MMIS1); - val = MPSM_PSME | MPSM_MFF_C45; iowrite32((regad << 16) | (devad << 8) | (phyad << 3) | val, etha->addr + MPSM); - ret = rswitch_reg_wait(etha->addr, MMIS1, MMIS1_PAACS, MMIS1_PAACS); + ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0); if (ret) return ret; - rswitch_modify(etha->addr, MMIS1, MMIS1_PAACS, MMIS1_PAACS); - if (read) { writel((pop << 13) | (devad << 8) | (phyad << 3) | val, etha->addr + MPSM); - ret = rswitch_reg_wait(etha->addr, MMIS1, MMIS1_PRACS, MMIS1_PRACS); + ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0); if (ret) return ret; ret = (ioread32(etha->addr + MPSM) & MPSM_PRD_MASK) >> 16; - - rswitch_modify(etha->addr, MMIS1, MMIS1_PRACS, MMIS1_PRACS); } else { iowrite32((data << 16) | (pop << 13) | (devad << 8) | (phyad << 3) | val, etha->addr + MPSM); - ret = rswitch_reg_wait(etha->addr, MMIS1, MMIS1_PWACS, MMIS1_PWACS); + ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0); } return ret; From patchwork Sun Dec 8 15:52:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Yushchenko X-Patchwork-Id: 13898617 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71F7B161311 for ; Sun, 8 Dec 2024 15:52:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733673171; cv=none; b=LncVbyw59EDBHxE5tjyeqisBpBaQyQp/sOLm8df6BYWSEl4Brs3dkT2ZnqE5nm3ausOUHteEIwUsosXPJI9rNsInpZhrkw+IbHEf7VdigHpiI/o2uoRRyhDFfRlYVYQIUd92KuZKbiJQtIyP7blABPlHmiDl7PWS0fEk3fzv8Yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733673171; c=relaxed/simple; bh=W3XAcV3Mjj3KVk9T8n9IytlKibEylzK1ulVMw68GUA4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W7D6crHftrXbgERbBfqBCqQCAzISBMKGkH7IegZZO0VtoJ4nKWBcrneaAIg7prZOH1o/DCgfvz0b9/W9ER252LCndddkhQmBUEAhdJbTRlSXF9b3g6ejZHja/eheyWLIR51SI0qzyJLgAuMwlZOf3BxiG9RZhNzSNiUWdUq4OAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com; spf=pass smtp.mailfrom=cogentembedded.com; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b=HuLz2byx; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b="HuLz2byx" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-53f22fd6832so985376e87.1 for ; Sun, 08 Dec 2024 07:52:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20230601.gappssmtp.com; s=20230601; t=1733673168; x=1734277968; darn=vger.kernel.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=Vg2upxs4mtRpSPhYhiU3jXij7s08m89bnWpedFCJNHI=; b=HuLz2byxSDwXg7Ngw6/TGXKO3ZQGrdWYyTTAfKt814qaQ59AVddF5sjAJJ/ibUKjqU 8xa4WrlIMNb1Ce/G6aoZwDFmWJeFU30rmDyaFyR8B009rtLoiCdnYe1tkxtocCbmS5WI e6NS/PCRkBAfRvFBAANObn+4Lp/Hvkt0+VHvxuAFMB/fUKV9RICYpaGPCttlkXhslRkv zkWL97p2900mVTl9bsNCSx1d40OJccRZqFinJfXqCYRFHeUY4JzWi9FUQDuNSiG+JjXt eTsyXnc0GDcCk2F3cKcD2uv8+75sL5CbGcUgmSZF061zV6cJhMQVWt6225xLfjpwfZhQ 7SPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733673168; x=1734277968; 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=Vg2upxs4mtRpSPhYhiU3jXij7s08m89bnWpedFCJNHI=; b=MPj8LVLznTmnILre2sqFQlZTPnz29AfG//sudxFSmKmhVU/QNvKbC7zd/Mel6MUpaO GQQLZDvNo6xTnOG7QqULiWpJkwLZGSXcfweXPyCRaCehbPkBMLqfY65sbpSJozKAQygv 7NEwhnUmpCQjtZJlDstYjU5E2xsRZSTc+8LiCZvxpU0rFWimduL9J/n+ytgJlgYXPo94 Vm9vRO5GDKGC8yCdkW6QjIBnTXmLt7JEc9VBFCO7WApOXTO++GbmItmldny3p6hKmCHP BtdQy/M17PXNV8TT7YvOSa+jIcDYAiqLEvY903gwU3O0PQtDjoZM032mNbv0g0n9u58V 5Ejw== X-Forwarded-Encrypted: i=1; AJvYcCWVxXhhTl9+R4VIP/Oemr6MkhMy3s28QcO1XmRPizyv2vlBAJG1m983Znkr+SbZlatEbCCwO9ypYmv/5YwnvDgs5g==@vger.kernel.org X-Gm-Message-State: AOJu0YxXWnbRqgytzgrvQpK0OO0EMunE/A2Sms8uHmSEKSlKEEJZOWG9 hdWEAxaPaYPFDpyh9sb4IcQzP8uqwo5G01vndDwSqmJ/TKGx9csuXTMv71N+RP0= X-Gm-Gg: ASbGncuNk+DZ9Wj9qf5jrtXH/5i3DDQj3tstq+xxk8JFG9OftmC9bdyYS32osf63w4b T+28yUz+y/8hW6CU5123iNkv3A0/LqALSyWs4YKAP6HQikhRvfNPci/myLCLXXM4VcjBjuo13Sd GnEWsaCiO/8kgQ331uQXEkqGYlstYL4bsvZxUnMEpf/TWDnbGXn49vkRUHVAaC5zfkuQ4CuydlZ wqCP2zlOPgW7Vyo4kiWmeCg7PqtJebWxQENOB6wWSAM1cQ8bMOyGfA4ZxyUlGPI X-Google-Smtp-Source: AGHT+IFqYHH7wOS5mwp8GRa50qvmO5IVTtwcTYIqm5zeEE/lumQiP2cK0ka70R8JpyU75hFUVIIn4g== X-Received: by 2002:a05:6512:138a:b0:53f:a8c0:22a7 with SMTP id 2adb3069b0e04-53fa8c023aemr1206069e87.38.1733673167473; Sun, 08 Dec 2024 07:52:47 -0800 (PST) Received: from cobook.home ([91.198.101.25]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53e3a1ce70bsm580882e87.66.2024.12.08.07.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:52:47 -0800 (PST) From: Nikita Yushchenko To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Geert Uytterhoeven Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege , Christian Mardmoeller , Dennis Ostermann , Nikita Yushchenko Subject: [PATCH net-next 3/4] net: renesas: rswitch: use generic MPSM operation for mdio C45 Date: Sun, 8 Dec 2024 20:52:35 +0500 Message-Id: <20241208155236.108582-4-nikita.yoush@cogentembedded.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241208155236.108582-1-nikita.yoush@cogentembedded.com> References: <20241208155236.108582-1-nikita.yoush@cogentembedded.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce rswitch_etha_mpsm_op() that accepts values for MPSM register fields and executes the transaction. This avoids some code duptication, and can be used both for C45 and C22. Convert C45 read and write operations to use that. Signed-off-by: Nikita Yushchenko --- drivers/net/ethernet/renesas/rswitch.c | 51 +++++++++++++++----------- drivers/net/ethernet/renesas/rswitch.h | 17 ++++++--- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 120d56754692..8dc5ddfee01d 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1167,36 +1167,29 @@ static int rswitch_etha_hw_init(struct rswitch_etha *etha, const u8 *mac) return rswitch_etha_change_mode(etha, EAMC_OPC_OPERATION); } -static int rswitch_etha_set_access(struct rswitch_etha *etha, bool read, - int phyad, int devad, int regad, int data) +static int rswitch_etha_mpsm_op(struct rswitch_etha *etha, bool read, + unsigned int mmf, unsigned int pda, + unsigned int pra, unsigned int pop, + unsigned int prd) { - int pop = read ? MDIO_READ_C45 : MDIO_WRITE_C45; u32 val; int ret; - if (devad == 0xffffffff) - return -ENODEV; - - val = MPSM_PSME | MPSM_MFF_C45; - iowrite32((regad << 16) | (devad << 8) | (phyad << 3) | val, etha->addr + MPSM); + val = MPSM_PSME | + FIELD_PREP(MPSM_MFF, mmf) | + FIELD_PREP(MPSM_PDA, pda) | + FIELD_PREP(MPSM_PRA, pra) | + FIELD_PREP(MPSM_POP, pop) | + FIELD_PREP(MPSM_PRD, prd); + iowrite32(val, etha->addr + MPSM); ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0); if (ret) return ret; if (read) { - writel((pop << 13) | (devad << 8) | (phyad << 3) | val, etha->addr + MPSM); - - ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0); - if (ret) - return ret; - - ret = (ioread32(etha->addr + MPSM) & MPSM_PRD_MASK) >> 16; - } else { - iowrite32((data << 16) | (pop << 13) | (devad << 8) | (phyad << 3) | val, - etha->addr + MPSM); - - ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0); + val = ioread32(etha->addr + MPSM); + ret = FIELD_GET(MPSM_PRD, val); } return ret; @@ -1206,16 +1199,30 @@ static int rswitch_etha_mii_read_c45(struct mii_bus *bus, int addr, int devad, int regad) { struct rswitch_etha *etha = bus->priv; + int ret; - return rswitch_etha_set_access(etha, true, addr, devad, regad, 0); + ret = rswitch_etha_mpsm_op(etha, false, MPSM_MMF_C45, addr, devad, + MPSM_POP_ADDRESS, regad); + if (ret) + return ret; + + return rswitch_etha_mpsm_op(etha, true, MPSM_MMF_C45, addr, devad, + MPSM_POP_READ_C45, 0); } static int rswitch_etha_mii_write_c45(struct mii_bus *bus, int addr, int devad, int regad, u16 val) { struct rswitch_etha *etha = bus->priv; + int ret; + + ret = rswitch_etha_mpsm_op(etha, false, MPSM_MMF_C45, addr, devad, + MPSM_POP_ADDRESS, regad); + if (ret) + return ret; - return rswitch_etha_set_access(etha, false, addr, devad, regad, val); + return rswitch_etha_mpsm_op(etha, false, MPSM_MMF_C45, addr, devad, + MPSM_POP_WRITE, val); } /* Call of_node_put(port) after done */ diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h index 303883369b94..9ac55b4f5b14 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -732,13 +732,18 @@ enum rswitch_etha_mode { #define MPIC_LSC_1G (2 << MPIC_LSC_SHIFT) #define MPIC_LSC_2_5G (3 << MPIC_LSC_SHIFT) -#define MDIO_READ_C45 0x03 -#define MDIO_WRITE_C45 0x01 - #define MPSM_PSME BIT(0) -#define MPSM_MFF_C45 BIT(2) -#define MPSM_PRD_SHIFT 16 -#define MPSM_PRD_MASK GENMASK(31, MPSM_PRD_SHIFT) +#define MPSM_MFF BIT(2) +#define MPSM_MMF_C22 0 +#define MPSM_MMF_C45 1 +#define MPSM_PDA GENMASK(7, 3) +#define MPSM_PRA GENMASK(12, 8) +#define MPSM_POP GENMASK(14, 13) +#define MPSM_POP_ADDRESS 0 +#define MPSM_POP_WRITE 1 +#define MPSM_POP_READ_C22 2 +#define MPSM_POP_READ_C45 3 +#define MPSM_PRD GENMASK(31, 16) /* Completion flags */ #define MMIS1_PAACS BIT(2) /* Address */ From patchwork Sun Dec 8 15:52:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Yushchenko X-Patchwork-Id: 13898618 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48F991581E0 for ; Sun, 8 Dec 2024 15:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733673173; cv=none; b=AxjYspFjKb4KfdKZ4QZ+onujSezqfx2qwyodHeao0PvFspRRluLulTNuyr0+PYDrGlnfEEBGlDFwZeChwYJqk1Q2FXMC4YiP5Ccde/enqiyEwrAJTfA5W00+l5wg/Z+sgxEK8DnjmkwQ37RNFFdYXAJVxC9b306KvrRfYjvmVSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733673173; c=relaxed/simple; bh=HyyWUkVImKTbnfUbDT8H94jFhoM3eDYkpcrXi4gTshE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z5FqyDjrcFYTC1D1pVC07scsGvlz45JkRdLLrdhYFWPqxV2o/4siJoZCR5dE6h5SXvfpBnY1ShIbfaxG1H4d8KxYTYQ3f2K/xy1pFUbfGakEqHH3FshE4LR6wKZsa8z+v3aERHakZYD45Q9NDwvopZBzZPIijstCK4xxRirybKY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com; spf=pass smtp.mailfrom=cogentembedded.com; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b=x0Wk2VkA; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b="x0Wk2VkA" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-30219437e63so5976821fa.1 for ; Sun, 08 Dec 2024 07:52:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20230601.gappssmtp.com; s=20230601; t=1733673169; x=1734277969; darn=vger.kernel.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=gJl98tLA1KqA94ObFzxMBXTp9IXq9js5q87hBKbnvrg=; b=x0Wk2VkAF0goOOK9oA5ZQyOFU7541kKbRDUhCxBiBiP13EQpMeUSKSrSqThZcm7wFG BWCNbrThqdrJDPbgzoBc9XjN9x7/eh2pNT/HErJPJNx6yoLK5EnADw/7DozfAyWyNPvE h8/3n5yfZ2TYGY2rVOnVDzttFCE8SYVwib1Kirq+v2558bEIRb0SEc43PKJNSjvLi8AJ tG8SCmRhCdSw0YgX9/0wII4vH9fCU6CAoHNQo3qvAby1iZiV+RMvFbhdq8FPnNicYaDw DsGrcwjOxml7PyNKBnJlLCxLf2FbuttzNP+gEB5Ix2zZUGdwaJeOwDHzDBss6BwuUDHT i7Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733673169; x=1734277969; 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=gJl98tLA1KqA94ObFzxMBXTp9IXq9js5q87hBKbnvrg=; b=RxPUfooHJd2z1jJyIzH5KupaNUlpqpZ+V0TAEHeEiCtJj34XkM8aNf1JhBBLwSUt0U RjWVoxTkLFmHeqRPNLRwAaltiwWEjwbiQaQ2ukugPiNcyh0/6WtMN0y48xL0XRc0EhHL V7muPSj0SteNoPmk0cbrogbx/RSku4rYXSdFPlYGatrntLRPDiI9pVK8EabjSVfWs/fW Tb0NdNUY+0GS8/1x9bq7iaecG/LuPl1ttweWRTVYZP5tx72zw3gmFLhupsnN/kn0Zx1/ P1OLw1daDuI+nlYg30vG9u4vaRtQQwUH9gi3BCEBwUv8bDgWRiSfiuS2gfO2hugExEF/ dMSw== X-Forwarded-Encrypted: i=1; AJvYcCUUdCaopuJfxtYZTU1ClpD1I9f0cm6hCHycBJtnjYJooCndnatl1AOuPuas/G/9JGDMkVbd4UrD1vrxfdKeczSFrA==@vger.kernel.org X-Gm-Message-State: AOJu0Yy5Ztvx2nBFFLM131t3RYHULJGsQ65XCunIgiS4UqHwoY+AzeNw 6/CxsozVcOlN2uifQG4f1bBw6CNPOn2QOdm67XXKhpHIGsfLHrubr1gvMpBNPHY= X-Gm-Gg: ASbGnctd3jGqc0dl0pf6zQsPF0FPab7r8L9Med4MLVeTajvEp3vuuLzrq3yODl9VAWz izUY5uk78mchzDG6Y8pi5DPTq6fSnZ8kJ0xZeD0o7VnkKw7TGTWSgARInrb+5vkPo/QX0/sanqf fYKs9E6JVWhE/H8zGNUX0wa+OQe3TlSlKH5xpHLfFhEPROxn36aHu/ButOoZdcnMjzo+cccVW0/ xgblHgrbks7kXXmtSVJRzdoeqowG7daHyHteZB4gUKW9naHNRQDM9qu875rMkOG X-Google-Smtp-Source: AGHT+IH3PSTZTHavCvoa1I3kEsvmuL+iD0caZGd6QozHV+KkfcwNGoYPhdqy84lNEnLmvIZv5Ekjcg== X-Received: by 2002:a05:6512:6d2:b0:53e:16eb:d845 with SMTP id 2adb3069b0e04-53e2b7328d9mr3358489e87.18.1733673169476; Sun, 08 Dec 2024 07:52:49 -0800 (PST) Received: from cobook.home ([91.198.101.25]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53e3a1ce70bsm580882e87.66.2024.12.08.07.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:52:49 -0800 (PST) From: Nikita Yushchenko To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Geert Uytterhoeven Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege , Christian Mardmoeller , Dennis Ostermann , Nikita Yushchenko Subject: [PATCH net-next 4/4] net: renesas: rswitch: add mdio C22 support Date: Sun, 8 Dec 2024 20:52:36 +0500 Message-Id: <20241208155236.108582-5-nikita.yoush@cogentembedded.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241208155236.108582-1-nikita.yoush@cogentembedded.com> References: <20241208155236.108582-1-nikita.yoush@cogentembedded.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The generic MPSM operation added by the previous patch can be used both for C45 and C22. Add handlers for C22 operations. Signed-off-by: Nikita Yushchenko --- drivers/net/ethernet/renesas/rswitch.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 8dc5ddfee01d..444e7576b31c 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1225,6 +1225,23 @@ static int rswitch_etha_mii_write_c45(struct mii_bus *bus, int addr, int devad, MPSM_POP_WRITE, val); } +static int rswitch_etha_mii_read_c22(struct mii_bus *bus, int phyad, int regad) +{ + struct rswitch_etha *etha = bus->priv; + + return rswitch_etha_mpsm_op(etha, true, MPSM_MMF_C22, phyad, regad, + MPSM_POP_READ_C22, 0); +} + +static int rswitch_etha_mii_write_c22(struct mii_bus *bus, int phyad, + int regad, u16 val) +{ + struct rswitch_etha *etha = bus->priv; + + return rswitch_etha_mpsm_op(etha, false, MPSM_MMF_C22, phyad, regad, + MPSM_POP_WRITE, val); +} + /* Call of_node_put(port) after done */ static struct device_node *rswitch_get_port_node(struct rswitch_device *rdev) { @@ -1307,6 +1324,8 @@ static int rswitch_mii_register(struct rswitch_device *rdev) mii_bus->priv = rdev->etha; mii_bus->read_c45 = rswitch_etha_mii_read_c45; mii_bus->write_c45 = rswitch_etha_mii_write_c45; + mii_bus->read = rswitch_etha_mii_read_c22; + mii_bus->write = rswitch_etha_mii_write_c22; mii_bus->parent = &rdev->priv->pdev->dev; mdio_np = of_get_child_by_name(rdev->np_port, "mdio");