From patchwork Tue May 20 11:53:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 30419 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8DAA8202FE for ; Tue, 20 May 2014 11:54:02 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id w10sf940090pde.9 for ; Tue, 20 May 2014 04:54:01 -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=vgx9zyfGxp31BAl9VmIKhWVZTa52yQ/9wBEwxmyqlvs=; b=R6liajZn/VrcaNp3YbPDQ4/d5VIlSNePyrK4TcOp7vv9sJrL/Vr0bbJrBa1YOBhEVO ykuFmetsNwGRrz/hCBq/pLHGXI+t7i2r3hyW4jRGUPcvX8MSd3A9m8NQuKq4D1XhYKy3 Hu9THrPX9wcMLpmKi3ZoKwXSyiXtP6AhJod5q4HkLLpI+udNHuRmujDtJ3lP8GyL0Gdg o5NTQ6mHWB8lmI9JcRQ9Ku9shgv46lmW0tSAmGhPqAlEFi/5Cu66b6mcn3CYXgGKmFkW 87RGYDGgq/kLZRxdggyABP849UKeup9+mMzGxtnjeoq+YV8eAIwdrqwzaL61bi40D1H7 3ncg== X-Gm-Message-State: ALoCoQl2GUiOs+XhWm80Hpk62vicmKIrG7SiAQUDGNavmn0bInteyK9e8qWysgr5oEN+A5oqmG5a X-Received: by 10.66.233.65 with SMTP id tu1mr15968198pac.35.1400586841616; Tue, 20 May 2014 04:54:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.132 with SMTP id u4ls201358qga.36.gmail; Tue, 20 May 2014 04:54:01 -0700 (PDT) X-Received: by 10.52.110.195 with SMTP id ic3mr128050vdb.53.1400586841463; Tue, 20 May 2014 04:54:01 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id lv1si477502vcb.85.2014.05.20.04.54.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 May 2014 04:54:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.182 as permitted sender) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id sa20so427008veb.13 for ; Tue, 20 May 2014 04:54:01 -0700 (PDT) X-Received: by 10.221.37.1 with SMTP id tc1mr3214357vcb.32.1400586841345; Tue, 20 May 2014 04:54:01 -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 ib8csp23787vcb; Tue, 20 May 2014 04:54:00 -0700 (PDT) X-Received: by 10.66.124.137 with SMTP id mi9mr49482220pab.111.1400586840561; Tue, 20 May 2014 04:54:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id os9si24274416pac.155.2014.05.20.04.53.59; Tue, 20 May 2014 04:54:00 -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 S1753088AbaETLx6 (ORCPT + 3 others); Tue, 20 May 2014 07:53:58 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:18481 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752660AbaETLx5 (ORCPT ); Tue, 20 May 2014 07:53:57 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N5V008WNFPJ1QA0@mailout2.w1.samsung.com> for linux-usb@vger.kernel.org; Tue, 20 May 2014 12:53:43 +0100 (BST) X-AuditID: cbfec7f5-b7f626d000004b39-6b-537b425133f5 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 56.7B.19257.1524B735; Tue, 20 May 2014 12:53:53 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N5V0091JFPOJ9B0@eusync2.samsung.com>; Tue, 20 May 2014 12:53:53 +0100 (BST) From: Marek Szyprowski To: linux-usb@vger.kernel.org Cc: Marek Szyprowski , Mark Brown , Dongjin Kim Subject: [PATCH] usb: usb5303: add support for reference clock specified in device tree Date: Tue, 20 May 2014 13:53:42 +0200 Message-id: <1400586822-3837-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBJMWRmVeSWpSXmKPExsVy+t/xK7qBTtXBBj/v8ltsun6d1WLRslZm i7VH7rJb7Hu8htmBxWPnrLvsHneu7WHz6NuyitHj8ya5AJYoLpuU1JzMstQifbsErow3a7rY Co6JVdzuesPcwPhGsIuRk0NCwETiypJ2FghbTOLCvfVsXYxcHEICSxklml9PYoZw+pgkNrRM ZwepYhMwlOh628UGYosIyEocvvIbqIiDg1mgROLlHRUQU1ggUmLqNB+QChYBVYlTK5+BdfIK uEt0fX4HtUtO4v/LFUwTGLkXMDKsYhRNLU0uKE5KzzXSK07MLS7NS9dLzs/dxAjx/dcdjEuP WR1iFOBgVOLhlUitChZiTSwrrsw9xCjBwawkwqttWx0sxJuSWFmVWpQfX1Sak1p8iJGJg1Oq gdGD99L8eMET7+deFzicYHnS+oGc0gXZrk3bha2ucG1es+td7GvOxkOTQtcf3hs5MzHqZOfB jV/vOM3pLPiv/MD95JLqDKEaCeFjP9OcuWcsMpHm/Wv9/sf/8oeKNwt5S5buyLdOv7D0bOO8 JefXGcyJffJ7Wdj/B6UmVn78TbXVKiknpsV+bfRWYinOSDTUYi4qTgQAg/sfydsBAAA= 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.128.182 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 --- drivers/usb/misc/usb3503.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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. Best regards Marek Szyprowski Samsung R&D Institute Poland diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index a31641e18d19..52cb7549b775 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) @@ -186,6 +189,25 @@ static int usb3503_probe(struct usb3503 *hub) } else if (np) { hub->port_off_mask = 0; + hub->clk = devm_clk_get(dev, "refclk"); + if (!IS_ERR(hub->clk)) { + unsigned long rate; + + clk_prepare_enable(hub->clk); + rate = clk_get_rate(hub->clk); + + if (rate == 38400000 || rate == 26000000 || + rate == 19200000 || rate == 12000000) + hub->secondary_ref_clk = 0; + else if (rate == 24000000 || rate == 27000000 || + rate == 25000000 || rate == 50000000) + hub->secondary_ref_clk = 1; + else + dev_err(dev, + "unsupported reference clock rate (%d)\n", + rate); + } + property = of_get_property(np, "disabled-ports", &len); if (property && (len / sizeof(u32)) > 0) { int i; @@ -213,8 +235,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",