From patchwork Thu Aug 23 13:07:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 10573795 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 676135A4 for ; Thu, 23 Aug 2018 13:08:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54FEB2B268 for ; Thu, 23 Aug 2018 13:08:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DB802B1D1; Thu, 23 Aug 2018 13:08:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E6662C0C0 for ; Thu, 23 Aug 2018 13:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729485AbeHWQhj (ORCPT ); Thu, 23 Aug 2018 12:37:39 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:22425 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727655AbeHWQhj (ORCPT ); Thu, 23 Aug 2018 12:37:39 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 23 Aug 2018 22:07:59 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 6D3898A5BF; Thu, 23 Aug 2018 22:07:59 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.53,278,1531753200"; d="scan'208";a="288866730" Received: from unknown (HELO fabrizio-dev.ree.adwin.renesas.com) ([10.226.36.250]) by relmlii1.idc.renesas.com with ESMTP; 23 Aug 2018 22:07:56 +0900 From: Fabrizio Castro To: Wolfgang Grandegger , Marc Kleine-Budde Cc: Fabrizio Castro , Sergei Shtylyov , "David S. Miller" , linux-can@vger.kernel.org, netdev@vger.kernel.org, Simon Horman , Geert Uytterhoeven , Chris Paterson , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH 1/3][can-next] can: rcar_can: Fix erroneous registration Date: Thu, 23 Aug 2018 14:07:31 +0100 Message-Id: <1535029653-7418-2-git-send-email-fabrizio.castro@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535029653-7418-1-git-send-email-fabrizio.castro@bp.renesas.com> References: <1535029653-7418-1-git-send-email-fabrizio.castro@bp.renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Assigning 2 to "renesas,can-clock-select" tricks the driver into registering the CAN interface, even though we don't want that. This patch fixes this problem and also allows for architectures missing some of the clocks (e.g. RZ/G2) to behave as expected. Fixes: 862e2b6af9413b43 ("can: rcar_can: support all input clocks") Signed-off-by: Fabrizio Castro Signed-off-by: Chris Paterson Reviewed-by: Simon Horman --- This patch applies on linux-can-next-for-4.19-20180727 drivers/net/can/rcar/rcar_can.c | 43 +++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/drivers/net/can/rcar/rcar_can.c b/drivers/net/can/rcar/rcar_can.c index 11662f4..fbd9284 100644 --- a/drivers/net/can/rcar/rcar_can.c +++ b/drivers/net/can/rcar/rcar_can.c @@ -21,9 +21,13 @@ #include #include #include +#include #define RCAR_CAN_DRV_NAME "rcar_can" +#define RCAR_SUPPORTED_CLOCKS (BIT(CLKR_CLKP1) | BIT(CLKR_CLKP2) | \ + BIT(CLKR_CLKEXT)) + /* Mailbox configuration: * mailbox 60 - 63 - Rx FIFO mailboxes * mailbox 56 - 59 - Tx FIFO mailboxes @@ -745,10 +749,12 @@ static int rcar_can_probe(struct platform_device *pdev) u32 clock_select = CLKR_CLKP1; int err = -ENODEV; int irq; + uintptr_t allowed_clks = RCAR_SUPPORTED_CLOCKS; if (pdev->dev.of_node) { of_property_read_u32(pdev->dev.of_node, "renesas,can-clock-select", &clock_select); + allowed_clks = (uintptr_t)of_device_get_match_data(&pdev->dev); } else { pdata = dev_get_platdata(&pdev->dev); if (!pdata) { @@ -789,7 +795,7 @@ static int rcar_can_probe(struct platform_device *pdev) goto fail_clk; } - if (clock_select >= ARRAY_SIZE(clock_names)) { + if (!(BIT(clock_select) & allowed_clks)) { err = -EINVAL; dev_err(&pdev->dev, "invalid CAN clock selected\n"); goto fail_clk; @@ -899,13 +905,34 @@ static int __maybe_unused rcar_can_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(rcar_can_pm_ops, rcar_can_suspend, rcar_can_resume); static const struct of_device_id rcar_can_of_table[] __maybe_unused = { - { .compatible = "renesas,can-r8a7778" }, - { .compatible = "renesas,can-r8a7779" }, - { .compatible = "renesas,can-r8a7790" }, - { .compatible = "renesas,can-r8a7791" }, - { .compatible = "renesas,rcar-gen1-can" }, - { .compatible = "renesas,rcar-gen2-can" }, - { .compatible = "renesas,rcar-gen3-can" }, + { + .compatible = "renesas,can-r8a7778", + .data = (void *)RCAR_SUPPORTED_CLOCKS, + }, + { + .compatible = "renesas,can-r8a7779", + .data = (void *)RCAR_SUPPORTED_CLOCKS, + }, + { + .compatible = "renesas,can-r8a7790", + .data = (void *)RCAR_SUPPORTED_CLOCKS, + }, + { + .compatible = "renesas,can-r8a7791", + .data = (void *)RCAR_SUPPORTED_CLOCKS, + }, + { + .compatible = "renesas,rcar-gen1-can", + .data = (void *)RCAR_SUPPORTED_CLOCKS, + }, + { + .compatible = "renesas,rcar-gen2-can", + .data = (void *)RCAR_SUPPORTED_CLOCKS, + }, + { + .compatible = "renesas,rcar-gen3-can", + .data = (void *)RCAR_SUPPORTED_CLOCKS, + }, { } }; MODULE_DEVICE_TABLE(of, rcar_can_of_table); From patchwork Thu Aug 23 13:07:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 10573791 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9600713B6 for ; Thu, 23 Aug 2018 13:08:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F2012B315 for ; Thu, 23 Aug 2018 13:08:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6134C2B1F0; Thu, 23 Aug 2018 13:08:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC44B2C0C1 for ; Thu, 23 Aug 2018 13:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729688AbeHWQhn (ORCPT ); Thu, 23 Aug 2018 12:37:43 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:22425 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727655AbeHWQhn (ORCPT ); Thu, 23 Aug 2018 12:37:43 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 23 Aug 2018 22:08:03 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id C786C8A5EB; Thu, 23 Aug 2018 22:08:03 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.53,278,1531753200"; d="scan'208";a="288866735" Received: from unknown (HELO fabrizio-dev.ree.adwin.renesas.com) ([10.226.36.250]) by relmlii1.idc.renesas.com with ESMTP; 23 Aug 2018 22:08:00 +0900 From: Fabrizio Castro To: Wolfgang Grandegger , Marc Kleine-Budde Cc: Fabrizio Castro , Sergei Shtylyov , "David S. Miller" , linux-can@vger.kernel.org, netdev@vger.kernel.org, Simon Horman , Geert Uytterhoeven , Chris Paterson , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH 2/3][can-next] can: rcar_can: Add RZ/G2 support Date: Thu, 23 Aug 2018 14:07:32 +0100 Message-Id: <1535029653-7418-3-git-send-email-fabrizio.castro@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535029653-7418-1-git-send-email-fabrizio.castro@bp.renesas.com> References: <1535029653-7418-1-git-send-email-fabrizio.castro@bp.renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP RZ/G2 devices don't have clkp2, therefore this commit adds a generic compatible string for them to allow for proper checking during probe. Signed-off-by: Fabrizio Castro Signed-off-by: Chris Paterson Reviewed-by: Simon Horman --- This patch applies on linux-can-next-for-4.19-20180727 drivers/net/can/rcar/rcar_can.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/can/rcar/rcar_can.c b/drivers/net/can/rcar/rcar_can.c index fbd9284..397208e 100644 --- a/drivers/net/can/rcar/rcar_can.c +++ b/drivers/net/can/rcar/rcar_can.c @@ -27,6 +27,7 @@ #define RCAR_SUPPORTED_CLOCKS (BIT(CLKR_CLKP1) | BIT(CLKR_CLKP2) | \ BIT(CLKR_CLKEXT)) +#define RZG2_SUPPORTED_CLOCKS (BIT(CLKR_CLKP1) | BIT(CLKR_CLKEXT)) /* Mailbox configuration: * mailbox 60 - 63 - Rx FIFO mailboxes @@ -933,6 +934,10 @@ static const struct of_device_id rcar_can_of_table[] __maybe_unused = { .compatible = "renesas,rcar-gen3-can", .data = (void *)RCAR_SUPPORTED_CLOCKS, }, + { + .compatible = "renesas,rzg-gen2-can", + .data = (void *)RZG2_SUPPORTED_CLOCKS, + }, { } }; MODULE_DEVICE_TABLE(of, rcar_can_of_table); From patchwork Thu Aug 23 13:07:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 10573805 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6FFAA13B6 for ; Thu, 23 Aug 2018 13:08:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60FF128D28 for ; Thu, 23 Aug 2018 13:08:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5428A2A657; Thu, 23 Aug 2018 13:08:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E414B28D28 for ; Thu, 23 Aug 2018 13:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729779AbeHWQhu (ORCPT ); Thu, 23 Aug 2018 12:37:50 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:22425 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727655AbeHWQht (ORCPT ); Thu, 23 Aug 2018 12:37:49 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 23 Aug 2018 22:08:10 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 826A38A602; Thu, 23 Aug 2018 22:08:10 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.53,278,1531753200"; d="scan'208";a="288866750" Received: from unknown (HELO fabrizio-dev.ree.adwin.renesas.com) ([10.226.36.250]) by relmlii1.idc.renesas.com with ESMTP; 23 Aug 2018 22:08:06 +0900 From: Fabrizio Castro To: Wolfgang Grandegger , Marc Kleine-Budde , Rob Herring , Mark Rutland Cc: Fabrizio Castro , Sergei Shtylyov , "David S. Miller" , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, Simon Horman , Geert Uytterhoeven , Chris Paterson , Biju Das , linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] dt-bindings: can: rcar_can: Add r8a774a1 support Date: Thu, 23 Aug 2018 14:07:33 +0100 Message-Id: <1535029653-7418-4-git-send-email-fabrizio.castro@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535029653-7418-1-git-send-email-fabrizio.castro@bp.renesas.com> References: <1535029653-7418-1-git-send-email-fabrizio.castro@bp.renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Document RZ/G2M (r8a774a1) SoC specific bindings and RZ/G2 generic bindings. Signed-off-by: Fabrizio Castro Signed-off-by: Chris Paterson Reviewed-by: Biju Das Reviewed-by: Simon Horman --- This patch applies on next-20180823 Documentation/devicetree/bindings/net/can/rcar_can.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/net/can/rcar_can.txt b/Documentation/devicetree/bindings/net/can/rcar_can.txt index 94a7f33..ae8fccc 100644 --- a/Documentation/devicetree/bindings/net/can/rcar_can.txt +++ b/Documentation/devicetree/bindings/net/can/rcar_can.txt @@ -4,6 +4,7 @@ Renesas R-Car CAN controller Device Tree Bindings Required properties: - compatible: "renesas,can-r8a7743" if CAN controller is a part of R8A7743 SoC. "renesas,can-r8a7745" if CAN controller is a part of R8A7745 SoC. + "renesas,can-r8a774a1" if CAN controller is a part of R8A774A1 SoC. "renesas,can-r8a7778" if CAN controller is a part of R8A7778 SoC. "renesas,can-r8a7779" if CAN controller is a part of R8A7779 SoC. "renesas,can-r8a7790" if CAN controller is a part of R8A7790 SoC. @@ -17,6 +18,7 @@ Required properties: "renesas,rcar-gen2-can" for a generic R-Car Gen2 or RZ/G1 compatible device. "renesas,rcar-gen3-can" for a generic R-Car Gen3 compatible device. + "renesas,rzg-gen2-can" for a generic RZ/G2 compatible device. When compatible with the generic version, nodes must list the SoC-specific version corresponding to the platform first followed by the generic version. @@ -24,7 +26,9 @@ Required properties: - reg: physical base address and size of the R-Car CAN register map. - interrupts: interrupt specifier for the sole interrupt. - clocks: phandles and clock specifiers for 3 CAN clock inputs. -- clock-names: 3 clock input name strings: "clkp1", "clkp2", "can_clk". +- clock-names: 2 clock input name strings for RZ/G2: "clkp1", "can_clk". + 3 clock input name strings for every other SoC: "clkp1", "clkp2", + "can_clk". - pinctrl-0: pin control group to be used for this controller. - pinctrl-names: must be "default". @@ -41,8 +45,9 @@ using the below properties: Optional properties: - renesas,can-clock-select: R-Car CAN Clock Source Select. Valid values are: <0x0> (default) : Peripheral clock (clkp1) - <0x1> : Peripheral clock (clkp2) - <0x3> : Externally input clock + <0x1> : Peripheral clock (clkp2) (not supported by + RZ/G2 devices) + <0x3> : External input clock Example -------