From patchwork Wed Apr 3 08:45:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 15844 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5304123E21 for ; Wed, 3 Apr 2013 08:48:20 +0000 (UTC) Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by fiordland.canonical.com (Postfix) with ESMTP id E17C0A18485 for ; Wed, 3 Apr 2013 08:48:19 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id m1sf2137571ves.7 for ; Wed, 03 Apr 2013 01:48:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=jPx7wFIQDxDQ5vu/l9B8cP8+SpxoyOnEhf9I0jHTXX0=; b=nGJxkhS3Bd/KXjAMqxO0K0whtSJY83dpRhEZJSkKLk0G16TpWu2yoi9zbmS5Ey7557 2bgTzEssarUUGENltla9uKF/pQQ2kPsaouUWklpQn7e72sn1pZOGzieJzio99gyWRADk DRTDUCQxnaoIDDbThUaTvv0RkROXpZIEmGwxDBUmXv8ZuQuPOoCe4giVd59/IThBJgn8 HaLx2ljfcLqrEHyXSR4WquIrXMWMBhTxuL4FDj0/DJLC81nEmfg3XsoS8fYfu6AKwpLK dHVx39itd2NJJAcUsCpy9+i9xsr8KuyV/Lg+Zy3MNCbmBgrIxTRqhkAupMlcNkZf2X96 k+cw== X-Received: by 10.224.58.77 with SMTP id f13mr694542qah.7.1364978899409; Wed, 03 Apr 2013 01:48:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.18.162 with SMTP id x2ls779416qed.37.gmail; Wed, 03 Apr 2013 01:48:19 -0700 (PDT) X-Received: by 10.52.17.174 with SMTP id p14mr388044vdd.125.1364978899271; Wed, 03 Apr 2013 01:48:19 -0700 (PDT) Received: from mail-vb0-x230.google.com (mail-vb0-x230.google.com [2607:f8b0:400c:c02::230]) by mx.google.com with ESMTPS id gy7si4277128vcb.20.2013.04.03.01.48.19 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Apr 2013 01:48:19 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::230; Received: by mail-vb0-f48.google.com with SMTP id p13so258321vbe.7 for ; Wed, 03 Apr 2013 01:48:19 -0700 (PDT) X-Received: by 10.52.31.103 with SMTP id z7mr435573vdh.56.1364978899186; Wed, 03 Apr 2013 01:48:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp160661ved; Wed, 3 Apr 2013 01:48:18 -0700 (PDT) X-Received: by 10.14.182.72 with SMTP id n48mr1977984eem.3.1364978898100; Wed, 03 Apr 2013 01:48:18 -0700 (PDT) Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by mx.google.com with ESMTPS id a9si7632276eem.3.2013.04.03.01.48.17 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Apr 2013 01:48:18 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.44 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=74.125.83.44; Received: by mail-ee0-f44.google.com with SMTP id l10so563707eei.17 for ; Wed, 03 Apr 2013 01:48:17 -0700 (PDT) X-Received: by 10.14.111.72 with SMTP id v48mr1924847eeg.11.1364978897603; Wed, 03 Apr 2013 01:48:17 -0700 (PDT) Received: from localhost ([2a01:2003:1:1e91:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id h5sm6929420eem.1.2013.04.03.01.48.10 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 03 Apr 2013 01:48:16 -0700 (PDT) From: Fabio Baltieri To: Felipe Balbi Cc: Linus Walleij , Praveena Nadahally , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Patrice Chotard , Fabio Baltieri Subject: [PATCH 10/12] usb: phy: ab8500-usb: adopt pinctrl support Date: Wed, 3 Apr 2013 10:45:11 +0200 Message-Id: <1364978713-19612-11-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1364978713-19612-1-git-send-email-fabio.baltieri@linaro.org> References: <1364978713-19612-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQnmzcmwZRiaiarhnUYC4y5TQNnTSq5ZjHuhkBOro2CFU1MdckKM32nB+hauU5p7dBR6Wy46 X-Original-Sender: fabio.baltieri@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Patrice Chotard Amend the ab8500-usb driver to optionally take a pin control handle and set the state of the pins to "default" on ab8500_usb_phy_enable and to "sleep" on ab8500_usb_phy_disable. The pinctrl handle is released on ab8500_usb_phy_disable because USB pins are shared with ab8505_micro_usb_iddet driver. Signed-off-by: Patrice Chotard Acked-by: Linus Walleij Signed-off-by: Fabio Baltieri --- drivers/usb/phy/phy-ab8500-usb.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c index ff27058..0875e2b 100644 --- a/drivers/usb/phy/phy-ab8500-usb.c +++ b/drivers/usb/phy/phy-ab8500-usb.c @@ -33,6 +33,7 @@ #include #include #include +#include /* Bank AB8500_SYS_CTRL2_BLOCK */ #define AB8500_MAIN_WD_CTRL_REG 0x01 @@ -132,6 +133,8 @@ struct ab8500_usb { struct regulator *v_ulpi; int saved_v_ulpi; int previous_link_status_state; + struct pinctrl *pinctrl; + struct pinctrl_state *pins_sleep; }; static inline struct ab8500_usb *phy_to_ab(struct usb_phy *x) @@ -240,6 +243,11 @@ static void ab8500_usb_phy_enable(struct ab8500_usb *ab, bool sel_host) bit = sel_host ? AB8500_BIT_PHY_CTRL_HOST_EN : AB8500_BIT_PHY_CTRL_DEVICE_EN; + /* mux and configure USB pins to DEFAULT state */ + ab->pinctrl = pinctrl_get_select(ab->dev, PINCTRL_STATE_DEFAULT); + if (IS_ERR(ab->pinctrl)) + dev_err(ab->dev, "could not get/set default pinstate\n"); + ab8500_usb_regulator_enable(ab); abx500_mask_and_set_register_interruptible(ab->dev, @@ -263,6 +271,22 @@ static void ab8500_usb_phy_disable(struct ab8500_usb *ab, bool sel_host) ab8500_usb_wd_workaround(ab); ab8500_usb_regulator_disable(ab); + + if (!IS_ERR(ab->pinctrl)) { + /* configure USB pins to SLEEP state */ + ab->pins_sleep = pinctrl_lookup_state(ab->pinctrl, + PINCTRL_STATE_SLEEP); + + if (IS_ERR(ab->pins_sleep)) + dev_dbg(ab->dev, "could not get sleep pinstate\n"); + else if (pinctrl_select_state(ab->pinctrl, ab->pins_sleep)) + dev_err(ab->dev, "could not set pins to sleep state\n"); + + /* as USB pins are shared with idddet, release them to allow + * iddet to request them + */ + pinctrl_put(ab->pinctrl); + } } #define ab8500_usb_host_phy_en(ab) ab8500_usb_phy_enable(ab, true)