aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@st.com>2013-04-03 04:45:11 -0400
committerFelipe Balbi <balbi@ti.com>2013-04-03 05:02:49 -0400
commit899f0f561b51506f40eb78c9c4aaeeabf97cf35c (patch)
tree99128d061eb057588adde2dec739dc848cc0091d /drivers/usb
parent77f4396ecb3396e518da60f915bbd4726732fd70 (diff)
usb: phy: ab8500-usb: adopt pinctrl support
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 <patrice.chotard@st.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/phy/phy-ab8500-usb.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 888dad65bf9b..90a3278d2820 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -33,6 +33,7 @@
33#include <linux/mfd/abx500/ab8500.h> 33#include <linux/mfd/abx500/ab8500.h>
34#include <linux/usb/musb-ux500.h> 34#include <linux/usb/musb-ux500.h>
35#include <linux/regulator/consumer.h> 35#include <linux/regulator/consumer.h>
36#include <linux/pinctrl/consumer.h>
36 37
37/* Bank AB8500_SYS_CTRL2_BLOCK */ 38/* Bank AB8500_SYS_CTRL2_BLOCK */
38#define AB8500_MAIN_WD_CTRL_REG 0x01 39#define AB8500_MAIN_WD_CTRL_REG 0x01
@@ -132,6 +133,8 @@ struct ab8500_usb {
132 struct regulator *v_ulpi; 133 struct regulator *v_ulpi;
133 int saved_v_ulpi; 134 int saved_v_ulpi;
134 int previous_link_status_state; 135 int previous_link_status_state;
136 struct pinctrl *pinctrl;
137 struct pinctrl_state *pins_sleep;
135}; 138};
136 139
137static inline struct ab8500_usb *phy_to_ab(struct usb_phy *x) 140static 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)
240 bit = sel_host ? AB8500_BIT_PHY_CTRL_HOST_EN : 243 bit = sel_host ? AB8500_BIT_PHY_CTRL_HOST_EN :
241 AB8500_BIT_PHY_CTRL_DEVICE_EN; 244 AB8500_BIT_PHY_CTRL_DEVICE_EN;
242 245
246 /* mux and configure USB pins to DEFAULT state */
247 ab->pinctrl = pinctrl_get_select(ab->dev, PINCTRL_STATE_DEFAULT);
248 if (IS_ERR(ab->pinctrl))
249 dev_err(ab->dev, "could not get/set default pinstate\n");
250
243 ab8500_usb_regulator_enable(ab); 251 ab8500_usb_regulator_enable(ab);
244 252
245 abx500_mask_and_set_register_interruptible(ab->dev, 253 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)
263 ab8500_usb_wd_workaround(ab); 271 ab8500_usb_wd_workaround(ab);
264 272
265 ab8500_usb_regulator_disable(ab); 273 ab8500_usb_regulator_disable(ab);
274
275 if (!IS_ERR(ab->pinctrl)) {
276 /* configure USB pins to SLEEP state */
277 ab->pins_sleep = pinctrl_lookup_state(ab->pinctrl,
278 PINCTRL_STATE_SLEEP);
279
280 if (IS_ERR(ab->pins_sleep))
281 dev_dbg(ab->dev, "could not get sleep pinstate\n");
282 else if (pinctrl_select_state(ab->pinctrl, ab->pins_sleep))
283 dev_err(ab->dev, "could not set pins to sleep state\n");
284
285 /* as USB pins are shared with idddet, release them to allow
286 * iddet to request them
287 */
288 pinctrl_put(ab->pinctrl);
289 }
266} 290}
267 291
268#define ab8500_usb_host_phy_en(ab) ab8500_usb_phy_enable(ab, true) 292#define ab8500_usb_host_phy_en(ab) ab8500_usb_phy_enable(ab, true)