From patchwork Fri Aug 1 11:49:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 4662451 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 D5A58C0338 for ; Fri, 1 Aug 2014 11:49:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 10F092020A for ; Fri, 1 Aug 2014 11:49:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3204220204 for ; Fri, 1 Aug 2014 11:49:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754750AbaHALtc (ORCPT ); Fri, 1 Aug 2014 07:49:32 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:47064 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754559AbaHALtb (ORCPT ); Fri, 1 Aug 2014 07:49:31 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 01 Aug 2014 20:49:29 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id EDAAE44B2D; Fri, 1 Aug 2014 20:49:29 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id D473E280A6; Fri, 1 Aug 2014 20:49:29 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id CF99E280A0; Fri, 1 Aug 2014 20:49:29 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id WAJ29175; Fri, 1 Aug 2014 20:49:29 +0900 X-IronPort-AV: E=Sophos;i="5.01,779,1399993200"; d="scan'208";a="167024658" Received: from mail-sg1lp0092.outbound.protection.outlook.com (HELO APAC01-SG1-obe.outbound.protection.outlook.com) ([207.46.51.92]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 01 Aug 2014 20:49:28 +0900 Received: from [10.161.20.147] (211.11.155.147) by HKXPR06MB328.apcprd06.prod.outlook.com (10.141.133.18) with Microsoft SMTP Server (TLS) id 15.0.995.14; Fri, 1 Aug 2014 11:49:27 +0000 Message-ID: <53DB7EC4.5010705@renesas.com> Date: Fri, 1 Aug 2014 20:49:24 +0900 From: Yoshihiro Shimoda User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: SH-Linux , "linux-usb@vger.kernel.org" CC: "devicetree@vger.kernel.org" , Grant Likely , Rob Herring Subject: [PATCH 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKNPR03CA018.apcprd03.prod.outlook.com (10.141.16.28) To HKXPR06MB328.apcprd06.prod.outlook.com (10.141.133.18) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 029097202E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(6049001)(6009001)(189002)(199002)(74502001)(77096002)(74662001)(87266999)(77982001)(66066001)(23736002)(54356999)(83506001)(65956001)(50986999)(31966008)(36756003)(65806001)(106356001)(85306004)(229853001)(47776003)(79102001)(81542001)(92566001)(64126003)(76482001)(33656002)(92726001)(19580405001)(85852003)(20776003)(102836001)(83322001)(64706001)(19580395003)(81342001)(80316001)(86362001)(107046002)(80022001)(21056001)(42186005)(99396002)(65816999)(50466002)(83072002)(46102001)(101416001)(4396001)(105586002)(87976001)(95666004); DIR:OUT; SFP:; SCL:1; SRVR:HKXPR06MB328; H:[10.161.20.147]; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:1; LANG:en; X-OriginatorOrg: renesas.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 This driver supports other SoCs, but they need boards/Soc depend code. So, this patch adds device tree support for R-Car H2 and M2 initially. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/common.c | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 1b9bf8d..845a889 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -438,6 +439,34 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) /* * platform functions */ +static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev) +{ + struct renesas_usbhs_platform_info *info; + struct renesas_usbhs_driver_param *dparam; + u32 tmp; + int gpio; + + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); + if (!info) + return NULL; + + dparam = &info->driver_param; + + if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7790")) + dparam->type = USBHS_TYPE_R8A7790; + + if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7791")) + dparam->type = USBHS_TYPE_R8A7791; + + if (!of_property_read_u32(dev->of_node, "buswait_bwait", &tmp)) + dparam->buswait_bwait = tmp; + gpio = of_get_named_gpio_flags(dev->of_node, "enable-gpio", 0, NULL); + if (gpio > 0) + dparam->enable_gpio = gpio; + + return info; +} + static int usbhs_probe(struct platform_device *pdev) { struct renesas_usbhs_platform_info *info = dev_get_platdata(&pdev->dev); @@ -446,6 +475,10 @@ static int usbhs_probe(struct platform_device *pdev) struct resource *res, *irq_res; int ret; + /* check device node */ + if (pdev->dev.of_node) + info = pdev->dev.platform_data = usbhs_parse_dt(&pdev->dev); + /* check platform information */ if (!info) { dev_err(&pdev->dev, "no platform information\n"); @@ -685,10 +718,20 @@ static const struct dev_pm_ops usbhsc_pm_ops = { .runtime_resume = usbhsc_runtime_nop, }; +#ifdef CONFIG_OF +static const struct of_device_id usbhs_of_match[] = { + { .compatible = "renesas,usbhs-r8a7790"}, + { .compatible = "renesas,usbhs-r8a7791"}, + { }, +}; +MODULE_DEVICE_TABLE(of, usbhs_of_match); +#endif + static struct platform_driver renesas_usbhs_driver = { .driver = { .name = "renesas_usbhs", .pm = &usbhsc_pm_ops, + .of_match_table = of_match_ptr(usbhs_of_match), }, .probe = usbhs_probe, .remove = usbhs_remove,