From patchwork Wed Sep 3 05:25:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 4830621 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 C1E55C0338 for ; Wed, 3 Sep 2014 05:26:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F066A201CD for ; Wed, 3 Sep 2014 05:26:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 115C4200CC for ; Wed, 3 Sep 2014 05:26:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753283AbaICF0H (ORCPT ); Wed, 3 Sep 2014 01:26:07 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:25566 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752518AbaICF0F (ORCPT ); Wed, 3 Sep 2014 01:26:05 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie3.idc.renesas.com with ESMTP; 03 Sep 2014 14:26:04 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 491A646DB5; Wed, 3 Sep 2014 14:26:04 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 3D03F180A1; Wed, 3 Sep 2014 14:26:04 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 392BD180A0; Wed, 3 Sep 2014 14:26:04 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id QBC10978; Wed, 3 Sep 2014 14:26:04 +0900 X-IronPort-AV: E=Sophos;i="5.04,454,1406559600"; d="scan'208";a="169280150" Received: from mail-hk1lp0122.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.122]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 03 Sep 2014 14:26:02 +0900 Received: from [10.161.20.147] (211.11.155.147) by SINPR06MB332.apcprd06.prod.outlook.com (10.141.110.18) with Microsoft SMTP Server (TLS) id 15.0.1019.16; Wed, 3 Sep 2014 05:26:00 +0000 Message-ID: <5406A664.2050501@renesas.com> Date: Wed, 3 Sep 2014 14:25:56 +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: Greg Kroah-Hartman , Felipe Balbi CC: Rob Herring , "pawel.moll@arm.com" , "mark.rutland@arm.com" , "ijc+devicetree@hellion.org.uk" , "galak@codeaurora.org" , "devicetree@vger.kernel.org" , "linux-usb@vger.kernel.org" , SH-Linux , Kuninori Morimoto , Ulrich Hecht Subject: [PATCH v3 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKXPR06CA011.apcprd06.prod.outlook.com (10.141.129.41) To SINPR06MB332.apcprd06.prod.outlook.com (10.141.110.18) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 032334F434 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019014)(6009001)(6049001)(189002)(199003)(4396001)(74662001)(74502001)(95666004)(64126003)(101416001)(23756003)(31966008)(33656002)(107046002)(87976001)(229853001)(85852003)(83072002)(46102001)(76482001)(92566001)(86362001)(92726001)(85306004)(81342001)(36756003)(81542001)(80316001)(21056001)(83322001)(79102001)(19580395003)(19580405001)(106356001)(105586002)(50466002)(65816999)(87266999)(54356999)(99396002)(50986999)(77982001)(80022001)(66066001)(65956001)(65806001)(64706001)(20776003)(47776003)(102836001)(77096002)(42186005)(90102001); DIR:OUT; SFP:1102; SCL:1; SRVR:SINPR06MB332; H:[10.161.20.147]; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:1; A: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=-8.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 Acked-by: Kuninori Morimoto --- drivers/usb/renesas_usbhs/common.c | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 1b9bf8d..b3b6813 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -438,6 +440,43 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) /* * platform functions */ +static const struct of_device_id usbhs_of_match[] = { + { + .compatible = "renesas,usbhs-r8a7790", + .data = (void *)USBHS_TYPE_R8A7790, + }, + { + .compatible = "renesas,usbhs-r8a7791", + .data = (void *)USBHS_TYPE_R8A7791, + }, + { }, +}; +MODULE_DEVICE_TABLE(of, usbhs_of_match); + +static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev) +{ + struct renesas_usbhs_platform_info *info; + struct renesas_usbhs_driver_param *dparam; + const struct of_device_id *of_id = of_match_device(usbhs_of_match, dev); + u32 tmp; + int gpio; + + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); + if (!info) + return NULL; + + dparam = &info->driver_param; + dparam->type = of_id ? (u32)of_id->data : 0; + if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp)) + dparam->buswait_bwait = tmp; + gpio = of_get_named_gpio_flags(dev->of_node, "renesas,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 +485,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"); @@ -689,6 +732,7 @@ 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,