From patchwork Thu May 22 11:21:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 30594 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6656820369 for ; Thu, 22 May 2014 11:21:53 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wo20sf14582234obc.11 for ; Thu, 22 May 2014 04:21:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=lfoKlsZB7VVy0Y8/CWQFuTPByRWCNKfp7GifjgwFNbw=; b=UegmQ6MvTRxoUuX7x8UWfYoIuNEmbHSfg2oN9NbSLNeVmutgmgV1dpOUMNL0EZZPuV frguwoNSB9tdaTHCVobUc+0ZjBh+UP+n9m5RexWo9uwwaLweM6ePd3eedSPcCSjV189d xcCUDp8kDbuSWo/xuCgrXQPu7kj21xtZHlTQ8FufBg4c8Sz52Q094R8qsFINVZJ2YqLB iIDi6JJ+sX7LzhrTEoLALIGF50EVyTRMpDBeZ3O1OLeICZnRd2okBC6SxVx4pxlMunCm 8WfL9GMfvZymNvdsWC3wdxqiAkJjyjlZJqK/Y3Jpp8YRpi4+t9Qmxe5rVdDAihfFgUDu kLjA== X-Gm-Message-State: ALoCoQmCNSp3aO3aSTXqHN/pc1btlneC6HigQN+zX/DIwfFc/neBAe3TfXxFxtVcyG6cuw7ulM/8 X-Received: by 10.50.30.40 with SMTP id p8mr7469990igh.6.1400757712844; Thu, 22 May 2014 04:21:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.200 with SMTP id 66ls1229527qgf.24.gmail; Thu, 22 May 2014 04:21:52 -0700 (PDT) X-Received: by 10.52.72.4 with SMTP id z4mr53673vdu.71.1400757712744; Thu, 22 May 2014 04:21:52 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id x1si2356580vep.70.2014.05.22.04.21.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 May 2014 04:21:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ij19so829750vcb.23 for ; Thu, 22 May 2014 04:21:52 -0700 (PDT) X-Received: by 10.220.106.7 with SMTP id v7mr287914vco.46.1400757712670; Thu, 22 May 2014 04:21:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp189791vcb; Thu, 22 May 2014 04:21:52 -0700 (PDT) X-Received: by 10.68.253.73 with SMTP id zy9mr29798179pbc.114.1400757711529; Thu, 22 May 2014 04:21:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ul9si33208087pac.118.2014.05.22.04.21.50; Thu, 22 May 2014 04:21:51 -0700 (PDT) Received-SPF: none (google.com: linux-usb-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752630AbaEVLVt (ORCPT + 3 others); Thu, 22 May 2014 07:21:49 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:65282 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752212AbaEVLVs (ORCPT ); Thu, 22 May 2014 07:21:48 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N5Z000H43K7EE40@mailout1.w1.samsung.com> for linux-usb@vger.kernel.org; Thu, 22 May 2014 12:21:43 +0100 (BST) X-AuditID: cbfec7f5-b7f626d000004b39-b5-537dddc9e7d7 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id E3.85.19257.9CDDD735; Thu, 22 May 2014 12:21:45 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N5Z00AGX3K6G980@eusync3.samsung.com>; Thu, 22 May 2014 12:21:45 +0100 (BST) From: Marek Szyprowski To: linux-usb@vger.kernel.org Cc: Marek Szyprowski , Mark Brown , Dongjin Kim Subject: [PATCH v2] usb: usb5303: add support for reference clock specified in device tree Date: Thu, 22 May 2014 13:21:38 +0200 Message-id: <1400757698-10189-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJJMWRmVeSWpSXmKPExsVy+t/xq7on79YGGxw6YWSx6fp1VotFy1qZ LdYeuctuse/xGmYHFo+ds+6ye9y5tofNo2/LKkaPz5vkAliiuGxSUnMyy1KL9O0SuDJ+vvrC UnBCteLDtmmMDYwLZLsYOTkkBEwknn86xgphi0lcuLeerYuRi0NIYCmjRN/Bm0wQTh+TxN79 R5lBqtgEDCW63naxgdgiArISh6/8BopzcDALlEi8vKMCEhYWiJFYu3ILE4jNIqAqsezABhYQ m1fAQ2J75xpmiGVyEv9frmCawMi9gJFhFaNoamlyQXFSeq6RXnFibnFpXrpecn7uJkaI97/u YFx6zOoQowAHoxIPb0dWbbAQa2JZcWXuIUYJDmYlEd59Z4BCvCmJlVWpRfnxRaU5qcWHGJk4 OKUaGLNc23YKcBXemN0i3DMpTyfvyly5kGcHeLLa+srZP7zhProlZ+HRw46ZGzfqtd1qUtOX vph9YkX6vZKg1TpLbD+/Liz+Wj4jiO9P0tOsmtsTAi33xzx9mbEtal2l/o9VnOY3leamRQuF c88XDH7uzrjMrbf51ssHZtJ1OzZvUTB20VR9+PqbtxJLcUaioRZzUXEiAGhkycvcAQAA Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , USB3503 chip supports 8 values of reference clock. The value is specified by REF_SEL[1:0] pins and INT_N line. This patch add support for getting 'refclk' clock, enabling it and setting INT_N line according to the value of the gathered clock. If no clock has been specified, driver defaults to the old behaviour (assuming that clock has been specified by REF_SEL pins from primary reference clock frequencies table). Signed-off-by: Marek Szyprowski --- Hello, This extension to USB3503 driver is needed to add support for OdroidU3 board, which uses 24MHz reference clock, sourced directly from CLKOUT line from Exynos4412 SoC. Changelog: v2 - fixed issues pointed by Mark Brown - added optional refclk-frequency property, clock rate is read from DT instead of getting it from clock v1 - initial version Best regards Marek Szyprowski Samsung R&D Institute Poland --- Documentation/devicetree/bindings/usb/usb3503.txt | 8 +++ drivers/usb/misc/usb3503.c | 59 ++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb3503.txt b/Documentation/devicetree/bindings/usb/usb3503.txt index a018da4a7ad7..221ac0dbc678 100644 --- a/Documentation/devicetree/bindings/usb/usb3503.txt +++ b/Documentation/devicetree/bindings/usb/usb3503.txt @@ -15,6 +15,14 @@ Optional properties: - reset-gpios: Should specify GPIO for reset. - initial-mode: Should specify initial mode. (1 for HUB mode, 2 for STANDBY mode) +- refclk: Clock used for driving REFCLK signal (optional, if not provided + the driver assumes that clock signal is always available, its + rate is specified by REF_SEL pins and a value from the primary + reference clock frequencies table is used) +- refclk-frequency: Frequency of the REFCLK signal as defined by REF_SEL + pins (optional, if not provided, driver will not set rate of the + REFCLK signal and assume that a value from the primary reference + clock frequencies table is used) Examples: usb3503@08 { diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index a31641e18d19..f43c61989cef 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include @@ -57,10 +58,12 @@ struct usb3503 { enum usb3503_mode mode; struct regmap *regmap; struct device *dev; + struct clk *clk; u8 port_off_mask; int gpio_intn; int gpio_reset; int gpio_connect; + bool secondary_ref_clk; }; static int usb3503_reset(struct usb3503 *hub, int state) @@ -184,8 +187,58 @@ static int usb3503_probe(struct usb3503 *hub) hub->gpio_reset = pdata->gpio_reset; hub->mode = pdata->initial_mode; } else if (np) { + struct clk *clk; hub->port_off_mask = 0; + clk = devm_clk_get(dev, "refclk"); + if (IS_ERR(clk) && PTR_ERR(clk) != -ENOENT) { + dev_err(dev, "unable to request refclk (%d)\n", err); + return PTR_ERR(clk); + } + + if (!IS_ERR(clk)) { + u32 rate = 0; + hub->clk = clk; + + if (!of_property_read_u32(np, "refclk-frequency", + &rate)) { + + switch (rate) { + case 38400000: + case 26000000: + case 19200000: + case 12000000: + hub->secondary_ref_clk = 0; + break; + case 24000000: + case 27000000: + case 25000000: + case 50000000: + hub->secondary_ref_clk = 1; + break; + default: + dev_err(dev, + "unsupported reference clock rate (%d)\n", + (int) rate); + return -EINVAL; + } + err = clk_set_rate(hub->clk, rate); + if (err) { + dev_err(dev, + "unable to set reference clock rate to %d\n", + (int) rate); + return err; + } + } + + err = clk_prepare_enable(hub->clk); + if (err) { + dev_err(dev, + "unable to enable reference clock\n"); + return err; + } + } + property = of_get_property(np, "disabled-ports", &len); if (property && (len / sizeof(u32)) > 0) { int i; @@ -213,8 +266,10 @@ static int usb3503_probe(struct usb3503 *hub) dev_err(dev, "Ports disabled with no control interface\n"); if (gpio_is_valid(hub->gpio_intn)) { - err = devm_gpio_request_one(dev, hub->gpio_intn, - GPIOF_OUT_INIT_HIGH, "usb3503 intn"); + int val = hub->secondary_ref_clk ? GPIOF_OUT_INIT_LOW : + GPIOF_OUT_INIT_HIGH; + err = devm_gpio_request_one(dev, hub->gpio_intn, val, + "usb3503 intn"); if (err) { dev_err(dev, "unable to request GPIO %d as connect pin (%d)\n",