Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0ea7064 authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Felipe Balbi
Browse files

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: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarFabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent e65b36c0
Loading
Loading
Loading
Loading
+26 −29
Original line number Original line Diff line number Diff line
@@ -172,40 +172,37 @@ static void ab8500_usb_wd_linkstatus(struct ab8500_usb *ab, u8 bit)
	}
	}
}
}


static void ab8500_usb_phy_ctrl(struct ab8500_usb *ab, bool sel_host,
static void ab8500_usb_phy_enable(struct ab8500_usb *ab, bool sel_host)
					bool enable)
{
{
	u8 ctrl_reg;
	u8 bit;
	abx500_get_register_interruptible(ab->dev,
	bit = sel_host ? AB8500_BIT_PHY_CTRL_HOST_EN :
				AB8500_USB,
		AB8500_BIT_PHY_CTRL_DEVICE_EN;
				AB8500_USB_PHY_CTRL_REG,

				&ctrl_reg);
	abx500_mask_and_set_register_interruptible(ab->dev,
	if (sel_host) {
			AB8500_USB, AB8500_USB_PHY_CTRL_REG,
		if (enable)
			bit, bit);
			ctrl_reg |= AB8500_BIT_PHY_CTRL_HOST_EN;
		else
			ctrl_reg &= ~AB8500_BIT_PHY_CTRL_HOST_EN;
	} else {
		if (enable)
			ctrl_reg |= AB8500_BIT_PHY_CTRL_DEVICE_EN;
		else
			ctrl_reg &= ~AB8500_BIT_PHY_CTRL_DEVICE_EN;
}
}


	abx500_set_register_interruptible(ab->dev,
static void ab8500_usb_phy_disable(struct ab8500_usb *ab, bool sel_host)
				AB8500_USB,
{
				AB8500_USB_PHY_CTRL_REG,
	u8 bit;
				ctrl_reg);
	bit = sel_host ? AB8500_BIT_PHY_CTRL_HOST_EN :
		AB8500_BIT_PHY_CTRL_DEVICE_EN;

	ab8500_usb_wd_linkstatus(ab, bit);

	abx500_mask_and_set_register_interruptible(ab->dev,
			AB8500_USB, AB8500_USB_PHY_CTRL_REG,
			bit, 0);


	/* Needed to enable the phy.*/
	/* Needed to disable the phy.*/
	if (enable)
	ab8500_usb_wd_workaround(ab);
	ab8500_usb_wd_workaround(ab);
}
}


#define ab8500_usb_host_phy_en(ab)	ab8500_usb_phy_ctrl(ab, true, true)
#define ab8500_usb_host_phy_en(ab)	ab8500_usb_phy_enable(ab, true)
#define ab8500_usb_host_phy_dis(ab)	ab8500_usb_phy_ctrl(ab, true, false)
#define ab8500_usb_host_phy_dis(ab)	ab8500_usb_phy_disable(ab, true)
#define ab8500_usb_peri_phy_en(ab)	ab8500_usb_phy_ctrl(ab, false, true)
#define ab8500_usb_peri_phy_en(ab)	ab8500_usb_phy_enable(ab, false)
#define ab8500_usb_peri_phy_dis(ab)	ab8500_usb_phy_ctrl(ab, false, false)
#define ab8500_usb_peri_phy_dis(ab)	ab8500_usb_phy_disable(ab, false)


static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
		enum ab8505_usb_link_status lsts)
		enum ab8505_usb_link_status lsts)