From patchwork Tue Jul 1 22:27:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 4462741 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D55FEBEEAA for ; Tue, 1 Jul 2014 22:27:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EDEE620304 for ; Tue, 1 Jul 2014 22:27:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EFE14202EB for ; Tue, 1 Jul 2014 22:27:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030257AbaGAW1G (ORCPT ); Tue, 1 Jul 2014 18:27:06 -0400 Received: from mail-la0-f48.google.com ([209.85.215.48]:57848 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965066AbaGAW1E (ORCPT ); Tue, 1 Jul 2014 18:27:04 -0400 Received: by mail-la0-f48.google.com with SMTP id el20so6294268lab.7 for ; Tue, 01 Jul 2014 15:27:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:cc:from:organization:date :mime-version:content-type:content-transfer-encoding:message-id; bh=FxJnJ3m1ARy9cZ1t4FoAiLNEc4YLKjrIoJR4vsh9pL4=; b=jxec/8naJgBMCa0XR2X/7hppcfDPRPwFBs77ZE6YNRKb30xMoSD3lfV152Qkd0ZFc6 WxuCD9KWtT39xXgJCgVs8VpC8EdM3amLq7mzba6z3ScVtyuSQo1dWS74kXIeuUBYUVh9 +d0APO9pQcbMcZoJ6O3jSBQDzq6nmkJQY+P78EsUQGDM8FpftJp7aJgwWDU28oLL82iX EVYpU4Zw9xofPnkkNGA6fWlFX3u/Hl4jA+y5D/W0K9UgSYgRgyk5ag1LSnJ5z4E3loso OQtavikh/b9b/UKk/zvglHZbOqiGkRsr9Jj17JNp0MDQzwrMABNCKYexgDmVAHfxyDYR D9cw== X-Gm-Message-State: ALoCoQm/zXxvYNvC6AnoeYcdPfxyiTcIp7sVZSYAP859VFiNQg+z6tsl0ehKcsYNksK/pnnofIVi X-Received: by 10.112.164.146 with SMTP id yq18mr37269736lbb.5.1404253622055; Tue, 01 Jul 2014 15:27:02 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp83-237-248-215.pppoe.mtu-net.ru. [83.237.248.215]) by mx.google.com with ESMTPSA id v15sm10819287laz.45.2014.07.01.15.27.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 01 Jul 2014 15:27:01 -0700 (PDT) To: netdev@vger.kernel.org, wg@grandegger.com, mkl@pengutronix.de, linux-can@vger.kernel.org, robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, grant.likely@linaro.org, devicetree@vger.kernel.org Subject: [PATCH] rcar_can: add device tree support Cc: linux-sh@vger.kernel.org, vksavl@gmail.com, rdunlap@infradead.org, linux-doc@vger.kernel.org From: Sergei Shtylyov Organization: Cogent Embedded Date: Wed, 2 Jul 2014 02:27:03 +0400 MIME-Version: 1.0 Message-Id: <201407020227.04235.sergei.shtylyov@cogentembedded.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support of the device tree probing for the Renesas R-Car CAN controllers documenting the device tree bindings as necessary. Signed-off-by: Sergei Shtylyov --- The patch is against the Dave Miller's 'net-next.git' repo ('linux-can-next.git' repo still doesn't have the R-Car CAN driver for some reason). Documentation/devicetree/bindings/net/can/rcar_can.txt | 40 +++++++++++++++++ drivers/net/can/rcar_can.c | 28 +++++++++-- 2 files changed, 63 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: net-next/Documentation/devicetree/bindings/net/can/rcar_can.txt =================================================================== --- /dev/null +++ net-next/Documentation/devicetree/bindings/net/can/rcar_can.txt @@ -0,0 +1,40 @@ +Renesas R-Car CAN controller Device Tree Bindings +------------------------------------------------- + +Required properties: +- compatible: "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. + "renesas,can-r8a7791" if CAN controller is a part of R8A7791 SoC. +- reg: physical base address and size of the R-Car CAN register map. +- interrupts: interrupt specifier for the sole interrupt. +- clocks: phandle and clock specifier for the R-Car CAN clock input. +- pinctrl-0: pin control group to be used for this controller. +- pinctrl-names: must be "default". + +Optional properties: +- clock-select: R-Car CAN Clock Source Select. Valid values are: + <0x0> (default) : Peripheral clock (clkp1) + <0x1> : Peripheral clock (clkp2) + <0x3> : Externally input clock + +Example +------- + +SoC common .dtsi file: + + can0: can@e6e80000 { + compatible = "renesas,can-r8a7791"; + reg = <0 0xe6e80000 0 0x1000>; + interrupts = <0 186 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp9_clks R8A7791_CLK_RCAN0>; + status = "disabled"; + }; + +Board specific .dts file: + +&can0 { + pinctrl-0 = <&can0_pins>; + pinctrl-names = "default"; + status = "okay"; +}; Index: net-next/drivers/net/can/rcar_can.c =================================================================== --- net-next.orig/drivers/net/can/rcar_can.c +++ net-next/drivers/net/can/rcar_can.c @@ -20,6 +20,7 @@ #include #include #include +#include #define RCAR_CAN_DRV_NAME "rcar_can" @@ -722,13 +723,20 @@ static int rcar_can_probe(struct platfor struct net_device *ndev; struct resource *mem; void __iomem *addr; + u32 clock_select = 0; int err = -ENODEV; int irq; - pdata = dev_get_platdata(&pdev->dev); - if (!pdata) { - dev_err(&pdev->dev, "No platform data provided!\n"); - goto fail; + if (!pdev->dev.of_node) { + pdata = dev_get_platdata(&pdev->dev); + if (!pdata) { + dev_err(&pdev->dev, "No platform data provided!\n"); + goto fail; + } + clock_select = pdata->clock_select; + } else { + of_property_read_u32(pdev->dev.of_node, "clock-select", + &clock_select); } irq = platform_get_irq(pdev, 0); @@ -765,7 +773,7 @@ static int rcar_can_probe(struct platfor ndev->flags |= IFF_ECHO; priv->ndev = ndev; priv->regs = addr; - priv->clock_select = pdata->clock_select; + priv->clock_select = clock_select; priv->can.clock.freq = clk_get_rate(priv->clk); priv->can.bittiming_const = &rcar_can_bittiming_const; priv->can.do_set_mode = rcar_can_do_set_mode; @@ -858,10 +866,20 @@ static int __maybe_unused rcar_can_resum 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" }, + { } +}; +MODULE_DEVICE_TABLE(of, rcar_can_of_table); + static struct platform_driver rcar_can_driver = { .driver = { .name = RCAR_CAN_DRV_NAME, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rcar_can_of_table), .pm = &rcar_can_pm_ops, }, .probe = rcar_can_probe,