Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2274386pxb; Mon, 11 Jan 2021 05:47:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXZMel6PMuGhzRLQaPEdPlPIWZAJ9Ylb2dqr7JZ99G/XM59Z9p4iTPtT7i50BsmROCJIiZ X-Received: by 2002:a50:a692:: with SMTP id e18mr13906476edc.233.1610372863362; Mon, 11 Jan 2021 05:47:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372863; cv=none; d=google.com; s=arc-20160816; b=SC93PrdpUPyDq5ONYX26BxKIUPQ/gwQSRIQiZuADP2rXoue93yMXXD/LOCaVmRGaX0 QLMnY8tG/9KyIcRfKiEYvq/ZMOtsCRgJiW6pFvqJZzaHy4r73VfpVmdktp3PxU99ZCdk keu9eD9+7qDmTCpuHz+lcI+pLggsPAo6hlU8D2hh0d+AVmFDGTq7/NakqcOWR/6LcghM AebZ/8EXkiASurwUq+n0MsvyOkPr7Io2Qn4HOForeIsYixliaOMc2ZA+FwKm9uDsHysx iUo7EqPoQUKaptAZ8NH0BHJqTP3DJ6lwp65yD23mTta0k4WXEYiGedhjfErzhowSH67j Im0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=exyrmcK46jAR5Rfda2ErgYi59Dj91jgET6nBFytHyuk=; b=mt+qr81SCd3OOP+LGdSCb6HTe6eTDltxdsu+bMUVuL4drJJcrjyyYSQ+iqyEfIFnPt wjlywI2hPcgh47h7zw9SPGe0EeiWrV+q2ypcLBUobu3/PtyzwHwpMLwUnOZonsOFMNPO qKHGdW3khZXy2g0HR4Uf7unbpCQVIh0hVOws8WgHZM2Nk2TfNWsFEH0P84eBHfAl6ktD u4qZ/q2uThckNcxDUWjECby4xE1urcApajwQfJqlaVnxiITOdj8lodIOPrZLQQqNYy8I d5VmVK5t+42tvyEU0rBh/I6w5oEdyttb/KXIeXbOtXX03Pb1VgDT355chOspxVMNCcHg JZzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2jNKQyMR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f20si6447785ejx.289.2021.01.11.05.47.19; Mon, 11 Jan 2021 05:47:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2jNKQyMR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731711AbhAKNpX (ORCPT + 99 others); Mon, 11 Jan 2021 08:45:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:58652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731418AbhAKNLf (ORCPT ); Mon, 11 Jan 2021 08:11:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5EE692250F; Mon, 11 Jan 2021 13:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370653; bh=XDAwESQ4s9euZtoYkuxHhJ1wUbaYZ6pzGd2Ec/bDwO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2jNKQyMRmG58ZdpIMbYLq+wuTBPz+WgKkSZp3RxcTVs4HfdawcjHjwHj55jzS2jBt +5Ny4iNGyI2AoFttU2NvACUkmaf4NeCr+ITskQr/bFAmYdoAeXe5fNCHedgElkIehv 6XfjGbZrJcVkgViRcZR8c/8oB1OKV7qxaqf+mz3Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Blumenstingl , Hauke Mehrtens , Florian Fainelli , Jakub Kicinski Subject: [PATCH 5.4 40/92] net: dsa: lantiq_gswip: Fix GSWIP_MII_CFG(p) register access Date: Mon, 11 Jan 2021 14:01:44 +0100 Message-Id: <20210111130041.081687151@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Blumenstingl [ Upstream commit 709a3c9dff2a639966ae7d8ba6239d2b8aba036d ] There is one GSWIP_MII_CFG register for each switch-port except the CPU port. The register offset for the first port is 0x0, 0x02 for the second, 0x04 for the third and so on. Update the driver to not only restrict the GSWIP_MII_CFG registers to ports 0, 1 and 5. Handle ports 0..5 instead but skip the CPU port. This means we are not overwriting the configuration for the third port (port two since we start counting from zero) with the settings for the sixth port (with number five) anymore. The GSWIP_MII_PCDU(p) registers are not updated because there's really only three (one for each of the following ports: 0, 1, 5). Fixes: 14fceff4771e51 ("net: dsa: Add Lantiq / Intel DSA driver for vrx200") Signed-off-by: Martin Blumenstingl Acked-by: Hauke Mehrtens Reviewed-by: Florian Fainelli Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/lantiq_gswip.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -92,9 +92,7 @@ GSWIP_MDIO_PHY_FDUP_MASK) /* GSWIP MII Registers */ -#define GSWIP_MII_CFG0 0x00 -#define GSWIP_MII_CFG1 0x02 -#define GSWIP_MII_CFG5 0x04 +#define GSWIP_MII_CFGp(p) (0x2 * (p)) #define GSWIP_MII_CFG_EN BIT(14) #define GSWIP_MII_CFG_LDCLKDIS BIT(12) #define GSWIP_MII_CFG_MODE_MIIP 0x0 @@ -392,17 +390,9 @@ static void gswip_mii_mask(struct gswip_ static void gswip_mii_mask_cfg(struct gswip_priv *priv, u32 clear, u32 set, int port) { - switch (port) { - case 0: - gswip_mii_mask(priv, clear, set, GSWIP_MII_CFG0); - break; - case 1: - gswip_mii_mask(priv, clear, set, GSWIP_MII_CFG1); - break; - case 5: - gswip_mii_mask(priv, clear, set, GSWIP_MII_CFG5); - break; - } + /* There's no MII_CFG register for the CPU port */ + if (!dsa_is_cpu_port(priv->ds, port)) + gswip_mii_mask(priv, clear, set, GSWIP_MII_CFGp(port)); } static void gswip_mii_mask_pcdu(struct gswip_priv *priv, u32 clear, u32 set, @@ -806,9 +796,8 @@ static int gswip_setup(struct dsa_switch gswip_mdio_mask(priv, 0xff, 0x09, GSWIP_MDIO_MDC_CFG1); /* Disable the xMII link */ - gswip_mii_mask_cfg(priv, GSWIP_MII_CFG_EN, 0, 0); - gswip_mii_mask_cfg(priv, GSWIP_MII_CFG_EN, 0, 1); - gswip_mii_mask_cfg(priv, GSWIP_MII_CFG_EN, 0, 5); + for (i = 0; i < priv->hw_info->max_ports; i++) + gswip_mii_mask_cfg(priv, GSWIP_MII_CFG_EN, 0, i); /* enable special tag insertion on cpu port */ gswip_switch_mask(priv, 0, GSWIP_FDMA_PCTRL_STEN,