From patchwork Wed Mar 18 18:37:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gamari X-Patchwork-Id: 6042931 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 877119F691 for ; Wed, 18 Mar 2015 18:45:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B23DF2041D for ; Wed, 18 Mar 2015 18:45:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 107AD20444 for ; Wed, 18 Mar 2015 18:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756314AbbCRSpL (ORCPT ); Wed, 18 Mar 2015 14:45:11 -0400 Received: from mail.smart-cactus.org ([54.187.36.80]:44708 "EHLO mail.smart-cactus.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756282AbbCRSpK (ORCPT ); Wed, 18 Mar 2015 14:45:10 -0400 Received: from ben-laptop.wireless.umass.edu (gamari.physics.umass.edu [128.119.56.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: ben@smart-cactus.org) by mail.smart-cactus.org (Postfix) with ESMTPSA id 46B5A57D87; Wed, 18 Mar 2015 18:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.smart-cactus.org; s=mail; t=1426703486; bh=JqC+szgD0LRskE9aD9pJnvGJ+bgbaYlJefc8GNSrxl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AYUh2u7zyh0e2qTW2MK8MJPAnqigCNmU1JoeKSQBTbEp9MUwhBxKVRMBJ8Ilpkpt+ 0LFBW00/aaNbH5DDFP0okXeR3lp1FjzB15D0SQaJQK58obAwL+g2K0RDbzUqMtc/LZ +fkZoar2TXnTOCjPQseG4KpmNfL83F5Sb5CH/4Eg= From: Ben Gamari To: linux-usb@vger.kernel.org, linux-arm@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: afaerber@suse.de, Ben Gamari Subject: [PATCH] usb/misc/usb3503: Always read refclk frequency from DT Date: Wed, 18 Mar 2015 14:37:45 -0400 Message-Id: <1426703865-31868-2-git-send-email-ben@smart-cactus.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1426703865-31868-1-git-send-email-ben@smart-cactus.org> References: <1426703865-31868-1-git-send-email-ben@smart-cactus.org> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_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 This is necessary to set REF_SEL appropriately in uses where refclk is always available. Signed-off-by: Ben Gamari Acked-by: Marek Szyprowski --- drivers/usb/misc/usb3503.c | 47 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index 258d2f5..64ff5b9 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -186,8 +186,31 @@ static int usb3503_probe(struct usb3503 *hub) hub->mode = pdata->initial_mode; } else if (np) { struct clk *clk; + u32 rate = 0; hub->port_off_mask = 0; + 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; + } + } + clk = devm_clk_get(dev, "refclk"); if (IS_ERR(clk) && PTR_ERR(clk) != -ENOENT) { dev_err(dev, "unable to request refclk (%ld)\n", @@ -196,31 +219,9 @@ static int usb3503_probe(struct usb3503 *hub) } 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; - } + if (rate != 0) { err = clk_set_rate(hub->clk, rate); if (err) { dev_err(dev,