From patchwork Mon Aug 4 10:48:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 4669551 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 B5809C0338 for ; Mon, 4 Aug 2014 10:48:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A990720220 for ; Mon, 4 Aug 2014 10:48:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C394200DE for ; Mon, 4 Aug 2014 10:48:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751409AbaHDKsL (ORCPT ); Mon, 4 Aug 2014 06:48:11 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:20049 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752084AbaHDKsJ (ORCPT ); Mon, 4 Aug 2014 06:48:09 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie1.idc.renesas.com with ESMTP; 04 Aug 2014 19:48:08 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id D9EE542B4B; Mon, 4 Aug 2014 19:48:08 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id C1F6D8002E; Mon, 4 Aug 2014 19:48:08 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id B9D788002D; Mon, 4 Aug 2014 19:48:08 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id VAA25503; Mon, 4 Aug 2014 19:48:08 +0900 X-IronPort-AV: E=Sophos;i="5.01,797,1399993200"; d="scan'208";a="166112529" Received: from mail-hk1lp0121.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.121]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 04 Aug 2014 19:48:08 +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; Mon, 4 Aug 2014 10:48:06 +0000 Message-ID: <53DF64E3.6040000@renesas.com> Date: Mon, 4 Aug 2014 19:48:03 +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 v2 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKXPR04CA004.apcprd04.prod.outlook.com (10.242.96.34) To HKXPR06MB328.apcprd06.prod.outlook.com (10.141.133.18) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 0293D40691 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(6049001)(6009001)(189002)(199002)(81542001)(54356999)(92566001)(77096002)(76482001)(47776003)(74662001)(79102001)(74502001)(36756003)(85306004)(106356001)(229853001)(50986999)(64126003)(77982001)(23756003)(66066001)(20776003)(85852003)(102836001)(64706001)(65816999)(19580395003)(83322001)(81342001)(80316001)(107046002)(21056001)(86362001)(46102001)(59896001)(42186005)(99396002)(33656002)(80022001)(83506001)(50466002)(83072002)(65956001)(92726001)(31966008)(19580405001)(87266999)(87976001)(95666004)(4396001)(105586002)(101416001); 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 | 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,