aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy
diff options
context:
space:
mode:
authorFabio Baltieri <fabio.baltieri@linaro.org>2013-04-03 04:45:07 -0400
committerFelipe Balbi <balbi@ti.com>2013-04-03 05:01:45 -0400
commitc0ea70646ad66a83f09562621babae4700c2f322 (patch)
tree986730190bc608a6f9f04ebdf9a20ab8b1911f97 /drivers/usb/phy
parente65b36c02613764aa703ef0be0a3c2c57ea91625 (diff)
usb: phy: ab8500-usb: split ab8500_usb_phy_ctrl
Split ab8500_usb_phy_ctrl into separate enable/disable functions to make the code more linear and readable. 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/phy')
-rw-r--r--drivers/usb/phy/phy-ab8500-usb.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 1bc24d4c25e7..58b194b72432 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -172,40 +172,37 @@ static void ab8500_usb_wd_linkstatus(struct ab8500_usb *ab, u8 bit)
172 } 172 }
173} 173}
174 174
175static void ab8500_usb_phy_ctrl(struct ab8500_usb *ab, bool sel_host, 175static void ab8500_usb_phy_enable(struct ab8500_usb *ab, bool sel_host)
176 bool enable)
177{ 176{
178 u8 ctrl_reg; 177 u8 bit;
179 abx500_get_register_interruptible(ab->dev, 178 bit = sel_host ? AB8500_BIT_PHY_CTRL_HOST_EN :
180 AB8500_USB, 179 AB8500_BIT_PHY_CTRL_DEVICE_EN;
181 AB8500_USB_PHY_CTRL_REG,
182 &ctrl_reg);
183 if (sel_host) {
184 if (enable)
185 ctrl_reg |= AB8500_BIT_PHY_CTRL_HOST_EN;
186 else
187 ctrl_reg &= ~AB8500_BIT_PHY_CTRL_HOST_EN;
188 } else {
189 if (enable)
190 ctrl_reg |= AB8500_BIT_PHY_CTRL_DEVICE_EN;
191 else
192 ctrl_reg &= ~AB8500_BIT_PHY_CTRL_DEVICE_EN;
193 }
194 180
195 abx500_set_register_interruptible(ab->dev, 181 abx500_mask_and_set_register_interruptible(ab->dev,
196 AB8500_USB, 182 AB8500_USB, AB8500_USB_PHY_CTRL_REG,
197 AB8500_USB_PHY_CTRL_REG, 183 bit, bit);
198 ctrl_reg); 184}
199 185
200 /* Needed to enable the phy.*/ 186static void ab8500_usb_phy_disable(struct ab8500_usb *ab, bool sel_host)
201 if (enable) 187{
202 ab8500_usb_wd_workaround(ab); 188 u8 bit;
189 bit = sel_host ? AB8500_BIT_PHY_CTRL_HOST_EN :
190 AB8500_BIT_PHY_CTRL_DEVICE_EN;
191
192 ab8500_usb_wd_linkstatus(ab, bit);
193
194 abx500_mask_and_set_register_interruptible(ab->dev,
195 AB8500_USB, AB8500_USB_PHY_CTRL_REG,
196 bit, 0);
197
198 /* Needed to disable the phy.*/
199 ab8500_usb_wd_workaround(ab);
203} 200}
204 201
205#define ab8500_usb_host_phy_en(ab) ab8500_usb_phy_ctrl(ab, true, true) 202#define ab8500_usb_host_phy_en(ab) ab8500_usb_phy_enable(ab, true)
206#define ab8500_usb_host_phy_dis(ab) ab8500_usb_phy_ctrl(ab, true, false) 203#define ab8500_usb_host_phy_dis(ab) ab8500_usb_phy_disable(ab, true)
207#define ab8500_usb_peri_phy_en(ab) ab8500_usb_phy_ctrl(ab, false, true) 204#define ab8500_usb_peri_phy_en(ab) ab8500_usb_phy_enable(ab, false)
208#define ab8500_usb_peri_phy_dis(ab) ab8500_usb_phy_ctrl(ab, false, false) 205#define ab8500_usb_peri_phy_dis(ab) ab8500_usb_phy_disable(ab, false)
209 206
210static int ab8505_usb_link_status_update(struct ab8500_usb *ab, 207static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
211 enum ab8505_usb_link_status lsts) 208 enum ab8505_usb_link_status lsts)