From patchwork Sat Mar 1 01:07: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: 3745681 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 B74B1BF13A for ; Sat, 1 Mar 2014 00:08:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AEAA7202DD for ; Sat, 1 Mar 2014 00:08:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1687202A7 for ; Sat, 1 Mar 2014 00:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752729AbaCAAIE (ORCPT ); Fri, 28 Feb 2014 19:08:04 -0500 Received: from mail-lb0-f169.google.com ([209.85.217.169]:42353 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752323AbaCAAIC (ORCPT ); Fri, 28 Feb 2014 19:08:02 -0500 Received: by mail-lb0-f169.google.com with SMTP id l4so2373910lbv.28 for ; Fri, 28 Feb 2014 16:08:00 -0800 (PST) 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=1YdbleeEb2EjW9AqDlKFWgfVNeFVi/JMKW6ct+mvLcg=; b=Bfpi0CaWz2KAfOEvIm/9u60PGPzUyAdDgw4ltCC6qVfW22Qq4zQ/wTLxzz9rIy0bmU sITTZTAIe1K4aBQGTWlCzucdD8SuiPl4TBD2MywdhE2/LCFqQIdFxt1rvXEiYci+LLOY gmeiw8dnTd88f5LkP6WfeIzuPHmLnGzwSy+5V358OW8FXVTuG/86i4cySLgjpx2h4i47 nB6C5poBP7+2IqqLiDQpuymXNeEyeGkynRwUECM50D2L0oTwSd/qsNrolAocujxmvAxe As6SMDkRC6SmP4jKc8FMvC+maqmuU66DT6ZFxqc5DlKm89fikcJ0hpVEAc8roN/i1SdA ahKQ== X-Gm-Message-State: ALoCoQncw3twqVerzAbd7SwF8GtO+Ah/yU9aPZUfkwefs4LffoiDTKWkF2EovvF4N1CF3/qBYuFh X-Received: by 10.112.85.6 with SMTP id d6mr12637942lbz.8.1393632480277; Fri, 28 Feb 2014 16:08:00 -0800 (PST) Received: from wasted.cogentembedded.com (ppp83-237-61-45.pppoe.mtu-net.ru. [83.237.61.45]) by mx.google.com with ESMTPSA id qx7sm5842530lbb.9.2014.02.28.16.07.58 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Feb 2014 16:07:59 -0800 (PST) To: balbi@ti.com, linux-usb@vger.kernel.org, robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, grant.likely@linaro.org, devicetree@vger.kernel.org Subject: [PATCH v2] phy-rcar-gen2-usb: add device tree support Cc: gregkh@linuxfoundation.org, linux-sh@vger.kernel.org, valentine.barshak@cogentembedded.com, rob@landley.net, linux-doc@vger.kernel.org From: Sergei Shtylyov Organization: Cogent Embedded Date: Sat, 1 Mar 2014 04:07:53 +0300 MIME-Version: 1.0 Message-Id: <201403010407.54639.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=-3.8 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 generation 2 SoCs documenting the device tree binding as necessary. Signed-off-by: Sergei Shtylyov --- This patch is against the 'next' branch of Felipe Balbi's 'usb.git' repo. Changes in version 2: - restored devm_clk_get() call and the error handling logic in the probe() method, removed clk_put() call in the remove() method. Documentation/devicetree/bindings/usb/rcar-gen2-phy.txt | 29 +++++++++++ drivers/usb/phy/phy-rcar-gen2-usb.c | 42 ++++++++++++++-- 2 files changed, 68 insertions(+), 3 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: usb/Documentation/devicetree/bindings/usb/rcar-gen2-phy.txt =================================================================== --- /dev/null +++ usb/Documentation/devicetree/bindings/usb/rcar-gen2-phy.txt @@ -0,0 +1,29 @@ +* Renesas R-Car generation 2 USB PHY + +This file provides information on what the device node for the R-Car generation +2 USB PHY contains. + +Required properties: +- compatible: "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. + "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC. +- reg: offset and length of the register block. +- clocks: clock phandle and specifier pair. +- clock-names: string, clock input name, must be "usbhs". + +Optional properties: +- renesas,channel0-pci: boolean, specify when USB channel 0 should be connected + to PCI EHCI/OHCI; otherwise, it will be connected to the + USBHS controller. +- renesas,channel2-pci: boolean, specify when USB channel 2 should be connected + to PCI EHCI/OHCI; otherwise, it will be connected to the + USBSS controller (xHCI). + +Example (Lager board): + + usb-phy@e6590100 { + compatible = "renesas,usb-phy-r8a7790"; + reg = <0 0xe6590100 0 0x100>; + clocks = <&mstp7_clks R8A7790_CLK_HSUSB>; + clock-names = "usbhs"; + renesas,channel2-pci; + }; Index: usb/drivers/usb/phy/phy-rcar-gen2-usb.c =================================================================== --- usb.orig/drivers/usb/phy/phy-rcar-gen2-usb.c +++ usb/drivers/usb/phy/phy-rcar-gen2-usb.c @@ -1,8 +1,8 @@ /* * Renesas R-Car Gen2 USB phy driver * - * Copyright (C) 2013 Renesas Solutions Corp. - * Copyright (C) 2013 Cogent Embedded, Inc. + * Copyright (C) 2013-2014 Renesas Solutions Corp. + * Copyright (C) 2013-2014 Cogent Embedded, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -167,6 +168,37 @@ out: spin_unlock_irqrestore(&priv->lock, flags); } +#ifdef CONFIG_OF +static struct rcar_gen2_phy_platform_data * +rcar_gen2_usb_phy_parse_dt(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct rcar_gen2_phy_platform_data *pdata; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return NULL; + + pdata->chan0_pci = of_property_read_bool(np, "renesas,channel0-pci"); + pdata->chan2_pci = of_property_read_bool(np, "renesas,channel2-pci"); + + return pdata; +} + +static const struct of_device_id rcar_gen2_usb_phy_match_table[] = { + { .compatible = "renesas,usb-phy-r8a7790" }, + { .compatible = "renesas,usb-phy-r8a7791" }, + { } +}; +MODULE_DEVICE_TABLE(of, rcar_gen2_usb_phy_match_table); +#else +static inline struct rcar_gen2_phy_platform_data * +rcar_gen2_usb_phy_parse_dt(struct device *dev) +{ + return NULL; +} +#endif + static int rcar_gen2_usb_phy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -177,7 +209,10 @@ static int rcar_gen2_usb_phy_probe(struc struct clk *clk; int retval; - pdata = dev_get_platdata(dev); + if (dev->of_node) + pdata = rcar_gen2_usb_phy_parse_dt(dev); + else + pdata = dev_get_platdata(dev); if (!pdata) { dev_err(dev, "No platform data\n"); return -EINVAL; @@ -236,6 +271,7 @@ static int rcar_gen2_usb_phy_remove(stru static struct platform_driver rcar_gen2_usb_phy_driver = { .driver = { .name = "usb_phy_rcar_gen2", + .of_match_table = of_match_ptr(rcar_gen2_usb_phy_match_table), }, .probe = rcar_gen2_usb_phy_probe, .remove = rcar_gen2_usb_phy_remove,