From patchwork Wed May 29 09:12:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13678498 X-Patchwork-Delegate: kuba@kernel.org Received: from andre.telenet-ops.be (andre.telenet-ops.be [195.130.132.53]) (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 2B7F316A376 for ; Wed, 29 May 2024 09:12:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716973948; cv=none; b=gxCb8l2ZzPemWkzfszVDz8AJrQGESuPlHuksBB+grt/6ZdIbyQKmARZ6VILMrMs9zfKHsmMwX8wPLCa7duBlShF4OWt3FW3t1ER2H5pYbJ7zKe3Q55suwldhYl6o3Hi7G8y8wOcDWFNhxQJTcK1R9Le7STKC+auwS0CoNXcWccI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716973948; c=relaxed/simple; bh=Aoeyse/5ysEW/UvrhwpMZ2TkXZT/GadS0r8x0ILWLmg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mqn7JHair7rWA3EwSwNXQVWfhMsulcUyKyYNDMYV8f3K6mW4y9X2qJy+O+ZTYGxNh4CRqL03mUpxt+KwoNfh72A/lCxhBqPJuk1/VH1DevWDVVhOszkeY10/dUwoeRzU9E9a3BLW29Vjd/37+Y/aQw70fn6I65urgJOILRxdmjI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:1b01:1838:131c:4de4]) by andre.telenet-ops.be with bizsmtp id UxCJ2C0013VPV9V01xCJnl; Wed, 29 May 2024 11:12:18 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1sCFL5-00GF9V-EB; Wed, 29 May 2024 11:12:17 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1sCFM1-008w8Z-Qt; Wed, 29 May 2024 11:12:17 +0200 From: Geert Uytterhoeven To: Marc Kleine-Budde , Vincent Mailhol , Wolfram Sang Cc: linux-can@vger.kernel.org, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/3] can: rcar_canfd: Simplify clock handling Date: Wed, 29 May 2024 11:12:13 +0200 Message-Id: <2cf38c10b83c8e5c04d68b17a930b6d9dbf66f40.1716973640.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The main CAN clock is either the internal CANFD clock, or the external CAN clock. Hence replace the two-valued enum by a simple boolean flag. Consolidate all CANFD clock handling inside a single branch. Signed-off-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang --- drivers/net/can/rcar/rcar_canfd.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index b828427187353d6f..474840b58e8f13f1 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -508,12 +508,6 @@ */ #define RCANFD_CFFIFO_IDX 0 -/* fCAN clock select register settings */ -enum rcar_canfd_fcanclk { - RCANFD_CANFDCLK = 0, /* CANFD clock */ - RCANFD_EXTCLK, /* Externally input clock */ -}; - struct rcar_canfd_global; struct rcar_canfd_hw_info { @@ -545,8 +539,8 @@ struct rcar_canfd_global { struct platform_device *pdev; /* Respective platform device */ struct clk *clkp; /* Peripheral clock */ struct clk *can_clk; /* fCAN clock */ - enum rcar_canfd_fcanclk fcan; /* CANFD or Ext clock */ unsigned long channels_mask; /* Enabled channels mask */ + bool extclk; /* CANFD or Ext clock */ bool fdmode; /* CAN FD or Classical CAN only mode */ struct reset_control *rstc1; struct reset_control *rstc2; @@ -777,7 +771,7 @@ static void rcar_canfd_configure_controller(struct rcar_canfd_global *gpriv) cfg |= RCANFD_GCFG_CMPOC; /* Set External Clock if selected */ - if (gpriv->fcan != RCANFD_CANFDCLK) + if (gpriv->extclk) cfg |= RCANFD_GCFG_DCS; rcar_canfd_set_bit(gpriv->base, RCANFD_GCFG, cfg); @@ -1941,16 +1935,12 @@ static int rcar_canfd_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(gpriv->can_clk), "cannot get canfd clock\n"); - gpriv->fcan = RCANFD_CANFDCLK; - + /* CANFD clock may be further divided within the IP */ + fcan_freq = clk_get_rate(gpriv->can_clk) / info->postdiv; } else { - gpriv->fcan = RCANFD_EXTCLK; + fcan_freq = clk_get_rate(gpriv->can_clk); + gpriv->extclk = true; } - fcan_freq = clk_get_rate(gpriv->can_clk); - - if (gpriv->fcan == RCANFD_CANFDCLK) - /* CANFD clock is further divided by (1/2) within the IP */ - fcan_freq /= info->postdiv; addr = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(addr)) { @@ -2060,7 +2050,7 @@ static int rcar_canfd_probe(struct platform_device *pdev) platform_set_drvdata(pdev, gpriv); dev_info(dev, "global operational state (clk %d, fdmode %d)\n", - gpriv->fcan, gpriv->fdmode); + gpriv->extclk, gpriv->fdmode); return 0; fail_channel: From patchwork Wed May 29 09:12:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13678499 X-Patchwork-Delegate: kuba@kernel.org Received: from michel.telenet-ops.be (michel.telenet-ops.be [195.130.137.88]) (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 47F51167DAB for ; Wed, 29 May 2024 09:12:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.88 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716973949; cv=none; b=VjSzb/R+OL6NBlmkngB/Er6NmhedvrJL+RsJiY+BhvPZxfjKYqMllJW9l77JQghfx4nAeLi9DMBil3bhbxe7h9EOCpRVwiiW2ETa1ZSLnqJUVMjQ9Z5xbHA7wsUcJcAYh10Wtl67j5NvKeOSzuW5CGyLR/rmhsZb2AB+HsbYFRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716973949; c=relaxed/simple; bh=FaQW69bwWIIghwkQdBMochv1fi+x9fc0JtNMz7gRvgY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PMkGo3qVc7LNNtNUeuzb99e9FQww3hOApwkGUhTUybbWu2a2D5HfW1dQeZMXDOJvdcFXPpwlN9ahGYzRAsTtOSyCFZB0uHixCAPfcrjIkQZF1JTaCv6IZBf1EQOj4ZndyQBL56/N4UHbIO21/AazG3TerwdT6Q6NNdv0wySXOxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:1b01:1838:131c:4de4]) by michel.telenet-ops.be with bizsmtp id UxCJ2C0013VPV9V06xCJ24; Wed, 29 May 2024 11:12:18 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1sCFL5-00GF9Y-Ek; Wed, 29 May 2024 11:12:17 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1sCFM1-008w8c-RZ; Wed, 29 May 2024 11:12:17 +0200 From: Geert Uytterhoeven To: Marc Kleine-Budde , Vincent Mailhol , Wolfram Sang Cc: linux-can@vger.kernel.org, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/3] can: rcar_canfd: Improve printing of global operational state Date: Wed, 29 May 2024 11:12:14 +0200 Message-Id: <14c8c5ce026e9fec128404706d1c73c8ffa11ced.1716973640.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace the printing of internal numerical values by the printing of strings reflecting their meaning, to make the message self-explanatory. Signed-off-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang --- drivers/net/can/rcar/rcar_canfd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 474840b58e8f13f1..c2c1c47bcc7a166c 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -2049,8 +2049,9 @@ static int rcar_canfd_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, gpriv); - dev_info(dev, "global operational state (clk %d, fdmode %d)\n", - gpriv->extclk, gpriv->fdmode); + dev_info(dev, "global operational state (%s clk, %s mode)\n", + gpriv->extclk ? "ext" : "canfd", + gpriv->fdmode ? "fd" : "classical"); return 0; fail_channel: From patchwork Wed May 29 09:12:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13678501 X-Patchwork-Delegate: kuba@kernel.org Received: from andre.telenet-ops.be (andre.telenet-ops.be [195.130.132.53]) (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 2B7B016A375 for ; Wed, 29 May 2024 09:12:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716973949; cv=none; b=duHP+616F56BCWycxk/nHiGynuw2egUNr44S0sPc9+KAwWfMlelWOwNLxJV/ybsdLkGMpYMhjaJBY3m2Y1GMRFJ3oWsxomeN5N40Y+nll7S1MzB5IiLWmuOmXO1tYV8vGlZ4NV31fUYkwcUsfakT+6VRyFyKcAtOV4KFDb2ojzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716973949; c=relaxed/simple; bh=6DRVo83b+DRVEiT4o5Gr1b8cmp/ONQYcfrCg5VurbFY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j5DKV2mXp5GRHm2xUOsgR4xYvTR3HGvZ6M4ohobm6zUxbqnqiUGT0fvqC5uUeu0Y4ihJP3uzsXxSeyI19ZYkwp0CZgYudvv0NceZzmZUw0PQx0RF+2uxvL6wxBHfZKyep+VqHUflbZfA4xUKfixsGRSg8XIbKZ54JMpq5sxL71M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:1b01:1838:131c:4de4]) by andre.telenet-ops.be with bizsmtp id UxCJ2C0033VPV9V01xCJnm; Wed, 29 May 2024 11:12:18 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1sCFL5-00GF9b-FS; Wed, 29 May 2024 11:12:17 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1sCFM1-008w8h-SP; Wed, 29 May 2024 11:12:17 +0200 From: Geert Uytterhoeven To: Marc Kleine-Budde , Vincent Mailhol , Wolfram Sang Cc: linux-can@vger.kernel.org, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 3/3] can: rcar_canfd: Remove superfluous parentheses in address calculations Date: Wed, 29 May 2024 11:12:15 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org There is no need to wrap simple variables or multiplications inside parentheses. Signed-off-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang --- drivers/net/can/rcar/rcar_canfd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index c2c1c47bcc7a166c..c919668bbe7a5541 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -627,28 +627,28 @@ static inline void rcar_canfd_update(u32 mask, u32 val, u32 __iomem *reg) static inline u32 rcar_canfd_read(void __iomem *base, u32 offset) { - return readl(base + (offset)); + return readl(base + offset); } static inline void rcar_canfd_write(void __iomem *base, u32 offset, u32 val) { - writel(val, base + (offset)); + writel(val, base + offset); } static void rcar_canfd_set_bit(void __iomem *base, u32 reg, u32 val) { - rcar_canfd_update(val, val, base + (reg)); + rcar_canfd_update(val, val, base + reg); } static void rcar_canfd_clear_bit(void __iomem *base, u32 reg, u32 val) { - rcar_canfd_update(val, 0, base + (reg)); + rcar_canfd_update(val, 0, base + reg); } static void rcar_canfd_update_bit(void __iomem *base, u32 reg, u32 mask, u32 val) { - rcar_canfd_update(mask, val, base + (reg)); + rcar_canfd_update(mask, val, base + reg); } static void rcar_canfd_get_data(struct rcar_canfd_channel *priv, @@ -659,7 +659,7 @@ static void rcar_canfd_get_data(struct rcar_canfd_channel *priv, lwords = DIV_ROUND_UP(cf->len, sizeof(u32)); for (i = 0; i < lwords; i++) *((u32 *)cf->data + i) = - rcar_canfd_read(priv->base, off + (i * sizeof(u32))); + rcar_canfd_read(priv->base, off + i * sizeof(u32)); } static void rcar_canfd_put_data(struct rcar_canfd_channel *priv, @@ -669,7 +669,7 @@ static void rcar_canfd_put_data(struct rcar_canfd_channel *priv, lwords = DIV_ROUND_UP(cf->len, sizeof(u32)); for (i = 0; i < lwords; i++) - rcar_canfd_write(priv->base, off + (i * sizeof(u32)), + rcar_canfd_write(priv->base, off + i * sizeof(u32), *((u32 *)cf->data + i)); }