From patchwork Tue Jul 29 22:53:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 4643611 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 8DC24C0338 for ; Tue, 29 Jul 2014 22:53:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5BBCB20142 for ; Tue, 29 Jul 2014 22:53:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69DD52012D for ; Tue, 29 Jul 2014 22:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754471AbaG2Wxr (ORCPT ); Tue, 29 Jul 2014 18:53:47 -0400 Received: from mail-lb0-f175.google.com ([209.85.217.175]:34365 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754461AbaG2Wxp (ORCPT ); Tue, 29 Jul 2014 18:53:45 -0400 Received: by mail-lb0-f175.google.com with SMTP id 10so261812lbg.6 for ; Tue, 29 Jul 2014 15:53:41 -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=RzIDwKgJePCoqW6+6EMNIVcJ7+37fzQ3dIOPIj5Utnc=; b=ZYzKBVDXHqgCLIACpQC6DUKQRKH+mzMmCr2NiPTFIljM0O6OjMz8hyk017bNcJP8sY mFlShzJMXcu6hVAyySNCGGJU9lRQGjYL0Q0g3Ch5HaA2zq18oL7CTEIxOQv/u7Wt5PLY 64p5sxlMvwlu3yxOEf3TWQGSwHdMHYL3GR5NBYMmoJaW03N5KG+4rgdEJmIw2iLL2oyi 2I9OlcGy0KpAJwvFPVJX+my+rAlO7ZXMRwbIv9Fl1+jJ/tSEgRC48b3hBTJtJ+uqfP6t U0oQyzcwDSOQbem2agO3+KM37oX4e6N/C0R+8cgDC8xUtLEPSPJbNCYNODN4mKeVpSOR /9Nw== X-Gm-Message-State: ALoCoQnuJ8w0Ru9p1S84XdeojGFSvEhXn6yAzQUShulKSy0zjcbTElaHBaWChbxbw97e4i/oK4zh X-Received: by 10.152.27.66 with SMTP id r2mr214590lag.34.1406674421801; Tue, 29 Jul 2014 15:53:41 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp23-117.pppoe.mtu-net.ru. [81.195.23.117]) by mx.google.com with ESMTPSA id cj12sm184071lad.38.2014.07.29.15.53.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 29 Jul 2014 15:53:40 -0700 (PDT) To: netdev@vger.kernel.org, wg@grandegger.com, mkl@pengutronix.de, linux-can@vger.kernel.org, robh+dt@kernel.org, grant.likely@linaro.org, devicetree@vger.kernel.org Subject: [PATCH v2 2/2] rcar_can: add device tree support Cc: linux-sh@vger.kernel.org, vksavl@gmail.com From: Sergei Shtylyov Organization: Cogent Embedded Date: Wed, 30 Jul 2014 02:53:41 +0400 MIME-Version: 1.0 Message-Id: <201407300253.42491.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=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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. Signed-off-by: Sergei Shtylyov --- The patch is against the 'linux-can-next.git' repo plus the CAN clock handling patch I've just posted. Changes in version 2: - split the device tree bindings document into a separate patch; - replaced 0 with CLKR_CLKP1 in the 'clock_select' variable intializer - reversed the condition in the *if* stetement handling the reading of the CAN clock selector from the device tree or the paltfrom data; - renamed the "clock-select" property to "renesas,can-clock-select"; - rebased the patch on top of the CAN clock handling fix. drivers/net/can/rcar_can.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 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: linux-can-next/drivers/net/can/rcar_can.c =================================================================== --- linux-can-next.orig/drivers/net/can/rcar_can.c +++ linux-can-next/drivers/net/can/rcar_can.c @@ -20,6 +20,7 @@ #include #include #include +#include #define RCAR_CAN_DRV_NAME "rcar_can" @@ -738,13 +739,20 @@ static int rcar_can_probe(struct platfor struct net_device *ndev; struct resource *mem; void __iomem *addr; + u32 clock_select = CLKR_CLKP1; 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) { + of_property_read_u32(pdev->dev.of_node, + "renesas,can-clock-select", &clock_select); + } else { + pdata = dev_get_platdata(&pdev->dev); + if (!pdata) { + dev_err(&pdev->dev, "No platform data provided!\n"); + goto fail; + } + clock_select = pdata->clock_select; } irq = platform_get_irq(pdev, 0); @@ -776,13 +784,12 @@ static int rcar_can_probe(struct platfor goto fail_clk; } - if (pdata->clock_select > CLKR_CLKEXT) { + if (clock_select > CLKR_CLKEXT) { err = -EINVAL; dev_err(&pdev->dev, "invalid CAN clock selected\n"); goto fail_clk; } - priv->can_clk = devm_clk_get(&pdev->dev, - clock_names[pdata->clock_select]); + priv->can_clk = devm_clk_get(&pdev->dev, clock_names[clock_select]); if (IS_ERR(priv->can_clk)) { err = PTR_ERR(priv->can_clk); dev_err(&pdev->dev, "cannot get CAN clock: %d\n", err); @@ -794,7 +801,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->can_clk); priv->can.bittiming_const = &rcar_can_bittiming_const; priv->can.do_set_mode = rcar_can_do_set_mode; @@ -887,10 +894,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,