From patchwork Wed Jan 11 14:05:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yegor Yefremov X-Patchwork-Id: 9510137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 29CF96075C for ; Wed, 11 Jan 2017 14:05:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1877B28632 for ; Wed, 11 Jan 2017 14:05:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CC9928646; Wed, 11 Jan 2017 14:05:56 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 91D2D28632 for ; Wed, 11 Jan 2017 14:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759883AbdAKOFw (ORCPT ); Wed, 11 Jan 2017 09:05:52 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33772 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759902AbdAKOFu (ORCPT ); Wed, 11 Jan 2017 09:05:50 -0500 Received: by mail-wm0-f66.google.com with SMTP id r144so28153204wme.0; Wed, 11 Jan 2017 06:05:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CKwi2gqmSPiRxgOtaecnfL2RbiKenfAXK9crxjfkmOs=; b=NacQSr0PnIGkmYq3tJzWWIrhyJ6KsWbj6e5mPiqtlOt7SU+yA/4h2ZokasTeH1vn2V wmDj+7GFd9Rlq/EuP0pREFXG0D3y7Abaq8UGEt09+Pa9u8pEQBu6K1PpWmh6PrODF0oE 1hMdu5N6Bcvy7cfWCZGCPRk7CQjVD2NzGEkTHI+GfTnzknMrowNWPahTwFmzhOh9nnC2 JZBqBQjjU8PCoDy00G5cZf5Fj/rKku5Oj7WpBAKW+0IoF1Hy5Sc02JKD6KywofQvhN9d bCPqLe0qydfZkdR6u65utvv/9U6YY1aZyWPOwejO560noo7q1qX9f7lqsdNv+yG9HrXI 4YMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CKwi2gqmSPiRxgOtaecnfL2RbiKenfAXK9crxjfkmOs=; b=Jy6pg9F2/LRGJMcANQ5rBard/rtffZpMLGl0nFKL85nqFWpy0JpK1YDwSK206QcFZM Xi3Y/QIJnWZR0e2b12HCMqUeW7CFeyrySIsnjMCVXta4WgAffJ8C7AiIpo4ZiwSH/cdu 071OnCIp7hliNf0da3EESQKf5Jd6IfigACxOZQcwOtCnuWFfLrCM00FpNFeDJMao2VSY kDlrR+Rgck9ZJo3Eed6vW/ZGQK4eruwFMd+SrsQbf3qGEaQUJRQtyK0I5Fev6CaPgTdq FMNeXocM8PR5Paec5mp6hhBCgPFvlKXnqQUN7O79vFXNjfp1mel/7/0N04fsi5rCEprO v6wg== X-Gm-Message-State: AIkVDXJOqjBy9i0+xxWnT3GN0pdiOfL3m2u/rgqRA8pMw0PSGbYZy/49HjcrTOYz94TQCQ== X-Received: by 10.28.164.196 with SMTP id n187mr3264389wme.44.1484143548753; Wed, 11 Jan 2017 06:05:48 -0800 (PST) Received: from development1.visionsystems.de (mail.visionsystems.de. [213.209.99.202]) by smtp.gmail.com with ESMTPSA id v2sm8670174wja.41.2017.01.11.06.05.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jan 2017 06:05:47 -0800 (PST) From: yegorslists@googlemail.com To: linux-can@vger.kernel.org Cc: linux-omap@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org, jean-michel.hautbois@vodalys.com, andrej.skvortzov@gmail.com, hs@denx.de, Anton Glukhov , Yegor Yefremov Subject: [PATCH v2 3/3] can: ti_hecc: Add DT support for TI HECC module Date: Wed, 11 Jan 2017 15:05:21 +0100 Message-Id: <1484143521-4898-4-git-send-email-yegorslists@googlemail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1484143521-4898-1-git-send-email-yegorslists@googlemail.com> References: <1484143521-4898-1-git-send-email-yegorslists@googlemail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anton Glukhov These patch set adds device tree support for TI HECC module. Signed-off-by: Anton Glukhov Signed-off-by: Yegor Yefremov --- Changes v1 -> v2: - change compatible to "ti,am3505" - remove CONFIG_OF - don't set int_line to 0 explicitly drivers/net/can/ti_hecc.c | 54 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c index 680d1ff..fd3d9fc 100644 --- a/drivers/net/can/ti_hecc.c +++ b/drivers/net/can/ti_hecc.c @@ -46,6 +46,8 @@ #include #include #include +#include +#include #include #include @@ -872,19 +874,62 @@ static const struct net_device_ops ti_hecc_netdev_ops = { .ndo_change_mtu = can_change_mtu, }; +static const struct of_device_id ti_hecc_dt_ids[] = { + { + .compatible = "ti,am3505", + }, + { } +}; +MODULE_DEVICE_TABLE(of, ti_hecc_dt_ids); + +static struct ti_hecc_platform_data *hecc_parse_dt(struct device *dev) +{ + struct ti_hecc_platform_data *pdata; + struct device_node *np = dev->of_node; + + pdata = devm_kzalloc(dev, sizeof(struct ti_hecc_platform_data), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + if (of_property_read_u32(np, "ti,scc-ram-offset", &pdata->scc_ram_offset)) { + dev_err(dev, "Missing scc-ram-offset property in the DT.\n"); + return ERR_PTR(-EINVAL); + } + + if (of_property_read_u32(np, "ti,hecc-ram-offset", &pdata->hecc_ram_offset)) { + dev_err(dev, "Missing hecc-ram-offset property in the DT.\n"); + return ERR_PTR(-EINVAL); + } + + if (of_property_read_u32(np, "ti,mbx-offset", &pdata->mbx_offset)) { + dev_err(dev, "Missing mbx-offset property in the DT.\n"); + return ERR_PTR(-EINVAL); + } + + of_property_read_u32(dev->of_node, "ti,int-line", &pdata->int_line); + + return pdata; +} + static int ti_hecc_probe(struct platform_device *pdev) { struct net_device *ndev = (struct net_device *)0; struct ti_hecc_priv *priv; - struct ti_hecc_platform_data *pdata; + struct ti_hecc_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct device_node *np = pdev->dev.of_node; struct resource *mem, *irq; void __iomem *addr; int err = -ENODEV; - pdata = dev_get_platdata(&pdev->dev); + if (!pdata && np) { + pdata = hecc_parse_dt(&pdev->dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + } + if (!pdata) { - dev_err(&pdev->dev, "No platform data\n"); - goto probe_exit; + dev_err(&pdev->dev, "Platform data missing\n"); + return -EINVAL; } mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1037,6 +1082,7 @@ static int ti_hecc_resume(struct platform_device *pdev) static struct platform_driver ti_hecc_driver = { .driver = { .name = DRV_NAME, + .of_match_table = ti_hecc_dt_ids, }, .probe = ti_hecc_probe, .remove = ti_hecc_remove,