From patchwork Thu Jul 31 21:25:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 4659011 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E9CAB9F377 for ; Thu, 31 Jul 2014 21:25:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 292732012E for ; Thu, 31 Jul 2014 21:25:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 405C2200FF for ; Thu, 31 Jul 2014 21:25:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753037AbaGaVZz (ORCPT ); Thu, 31 Jul 2014 17:25:55 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:48738 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753220AbaGaVZy (ORCPT ); Thu, 31 Jul 2014 17:25:54 -0400 Received: by mail-lb0-f169.google.com with SMTP id s7so2523449lbd.0 for ; Thu, 31 Jul 2014 14:25:52 -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=bkKr62hibTdZEUKefRP9F9ULQM8ObuBorgeDXlvVvs8=; b=SIxz6ByFrjLoigfdfov472z7onGAHgY+BA8G9KGClit9qgn4hLGe9Vfe9oyYfX4IHm O9aAVGzs1vvQk0o0CmWHZCAXMpMRM/fny5JrYaqXiRhhpOEDMJ7r4PI81JNH/fN2s2O6 qpt951aPHeojvrDmXLhfxmotWhWIS+qzoAf6ynxvOHkQuKnGtKiFcbCxdrmVbs76Eyn7 9CUB8seqk/E9pTlVZMGwNFjqjlOS6UaxV9ttWhDrphGBx4shfeIsgTQ/BENgUQoPfenz 0rEme/tJ8H+qjnc83cIKXsx7NE3+tWLTGIDcC6z+gInd67nYWXcy2Fx5vK9S0cjTDUnB AIzA== X-Gm-Message-State: ALoCoQmmys6qIUviRv8GDMF4IYiqTqgzViQx2G8x5y6LtzQp0/Eg5+CRr16qWyL3tdE9wTpzVp9x X-Received: by 10.152.27.197 with SMTP id v5mr935316lag.84.1406841952921; Thu, 31 Jul 2014 14:25:52 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp19-216.pppoe.mtu-net.ru. [81.195.19.216]) by mx.google.com with ESMTPSA id kz1sm2681795lab.11.2014.07.31.14.25.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 31 Jul 2014 14:25:52 -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 v3 2/2] rcar_can: add device tree support Cc: linux-sh@vger.kernel.org, vksavl@gmail.com From: Sergei Shtylyov Organization: Cogent Embedded Date: Fri, 1 Aug 2014 01:25:53 +0400 MIME-Version: 1.0 Message-Id: <201408010125.54723.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 3: - resolved rejects due to the 'clock_select' variable declaration being moved to the CAN clock handling patch. 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 | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 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,16 +739,21 @@ static int rcar_can_probe(struct platfor struct net_device *ndev; struct resource *mem; void __iomem *addr; - u32 clock_select; + 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; } - clock_select = pdata->clock_select; irq = platform_get_irq(pdev, 0); if (!irq) { @@ -888,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,