usb: phy: ab8500-usb: move phy tuning values on separate functions
Move each chip's PHY tuning value set code to a separate function to improve code readability. Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Maxime Coquelin <maxime.coquelin@st.com> Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
Родитель
b3affc3991
Коммит
16604a3c27
|
@ -771,6 +771,86 @@ static int ab8500_usb_irq_setup(struct platform_device *pdev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ab8500_usb_set_ab8500_tuning_values(struct ab8500_usb *ab)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
/* Enable the PBT/Bank 0x12 access */
|
||||||
|
err = abx500_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS, 0x01);
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to enable bank12 access err=%d\n",
|
||||||
|
err);
|
||||||
|
|
||||||
|
err = abx500_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEBUG, AB8500_USB_PHY_TUNE1, 0xC8);
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to set PHY_TUNE1 register err=%d\n",
|
||||||
|
err);
|
||||||
|
|
||||||
|
err = abx500_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEBUG, AB8500_USB_PHY_TUNE2, 0x00);
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to set PHY_TUNE2 register err=%d\n",
|
||||||
|
err);
|
||||||
|
|
||||||
|
err = abx500_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEBUG, AB8500_USB_PHY_TUNE3, 0x78);
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to set PHY_TUNE3 regester err=%d\n",
|
||||||
|
err);
|
||||||
|
|
||||||
|
/* Switch to normal mode/disable Bank 0x12 access */
|
||||||
|
err = abx500_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS, 0x00);
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to switch bank12 access err=%d\n",
|
||||||
|
err);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ab8500_usb_set_ab8505_tuning_values(struct ab8500_usb *ab)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
/* Enable the PBT/Bank 0x12 access */
|
||||||
|
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS,
|
||||||
|
0x01, 0x01);
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to enable bank12 access err=%d\n",
|
||||||
|
err);
|
||||||
|
|
||||||
|
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEBUG, AB8500_USB_PHY_TUNE1,
|
||||||
|
0xC8, 0xC8);
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to set PHY_TUNE1 register err=%d\n",
|
||||||
|
err);
|
||||||
|
|
||||||
|
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEBUG, AB8500_USB_PHY_TUNE2,
|
||||||
|
0x60, 0x60);
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to set PHY_TUNE2 register err=%d\n",
|
||||||
|
err);
|
||||||
|
|
||||||
|
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEBUG, AB8500_USB_PHY_TUNE3,
|
||||||
|
0xFC, 0x80);
|
||||||
|
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to set PHY_TUNE3 regester err=%d\n",
|
||||||
|
err);
|
||||||
|
|
||||||
|
/* Switch to normal mode/disable Bank 0x12 access */
|
||||||
|
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
||||||
|
AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS,
|
||||||
|
0x00, 0x00);
|
||||||
|
if (err < 0)
|
||||||
|
dev_err(ab->dev, "Failed to switch bank12 access err=%d\n",
|
||||||
|
err);
|
||||||
|
}
|
||||||
|
|
||||||
static int ab8500_usb_probe(struct platform_device *pdev)
|
static int ab8500_usb_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct ab8500_usb *ab;
|
struct ab8500_usb *ab;
|
||||||
|
@ -835,81 +915,12 @@ static int ab8500_usb_probe(struct platform_device *pdev)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Phy tuning values for AB8500 > v2.0 */
|
if (is_ab8500(ab->ab8500) && !is_ab8500_2p0_or_earlier(ab->ab8500))
|
||||||
if (is_ab8500(ab->ab8500) && !is_ab8500_2p0_or_earlier(ab->ab8500)) {
|
/* Phy tuning values for AB8500 > v2.0 */
|
||||||
/* Enable the PBT/Bank 0x12 access */
|
ab8500_usb_set_ab8500_tuning_values(ab);
|
||||||
err = abx500_set_register_interruptible(ab->dev,
|
else if (is_ab8505(ab->ab8500))
|
||||||
AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS, 0x01);
|
/* Phy tuning values for AB8505 */
|
||||||
if (err < 0)
|
ab8500_usb_set_ab8505_tuning_values(ab);
|
||||||
dev_err(ab->dev, "Failed to enable bank12 access err=%d\n",
|
|
||||||
err);
|
|
||||||
|
|
||||||
err = abx500_set_register_interruptible(ab->dev,
|
|
||||||
AB8500_DEBUG, AB8500_USB_PHY_TUNE1, 0xC8);
|
|
||||||
if (err < 0)
|
|
||||||
dev_err(ab->dev, "Failed to set PHY_TUNE1 register err=%d\n",
|
|
||||||
err);
|
|
||||||
|
|
||||||
err = abx500_set_register_interruptible(ab->dev,
|
|
||||||
AB8500_DEBUG, AB8500_USB_PHY_TUNE2, 0x00);
|
|
||||||
if (err < 0)
|
|
||||||
dev_err(ab->dev, "Failed to set PHY_TUNE2 register err=%d\n",
|
|
||||||
err);
|
|
||||||
|
|
||||||
err = abx500_set_register_interruptible(ab->dev,
|
|
||||||
AB8500_DEBUG, AB8500_USB_PHY_TUNE3, 0x78);
|
|
||||||
if (err < 0)
|
|
||||||
dev_err(ab->dev, "Failed to set PHY_TUNE3 regester err=%d\n",
|
|
||||||
err);
|
|
||||||
|
|
||||||
/* Switch to normal mode/disable Bank 0x12 access */
|
|
||||||
err = abx500_set_register_interruptible(ab->dev,
|
|
||||||
AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS, 0x00);
|
|
||||||
if (err < 0)
|
|
||||||
dev_err(ab->dev, "Failed to switch bank12 access err=%d\n",
|
|
||||||
err);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Phy tuning values for AB8505 */
|
|
||||||
if (is_ab8505(ab->ab8500)) {
|
|
||||||
/* Enable the PBT/Bank 0x12 access */
|
|
||||||
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
|
||||||
AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS,
|
|
||||||
0x01, 0x01);
|
|
||||||
if (err < 0)
|
|
||||||
dev_err(ab->dev, "Failed to enable bank12 access err=%d\n",
|
|
||||||
err);
|
|
||||||
|
|
||||||
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
|
||||||
AB8500_DEBUG, AB8500_USB_PHY_TUNE1,
|
|
||||||
0xC8, 0xC8);
|
|
||||||
if (err < 0)
|
|
||||||
dev_err(ab->dev, "Failed to set PHY_TUNE1 register err=%d\n",
|
|
||||||
err);
|
|
||||||
|
|
||||||
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
|
||||||
AB8500_DEBUG, AB8500_USB_PHY_TUNE2,
|
|
||||||
0x60, 0x60);
|
|
||||||
if (err < 0)
|
|
||||||
dev_err(ab->dev, "Failed to set PHY_TUNE2 register err=%d\n",
|
|
||||||
err);
|
|
||||||
|
|
||||||
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
|
||||||
AB8500_DEBUG, AB8500_USB_PHY_TUNE3,
|
|
||||||
0xFC, 0x80);
|
|
||||||
|
|
||||||
if (err < 0)
|
|
||||||
dev_err(ab->dev, "Failed to set PHY_TUNE3 regester err=%d\n",
|
|
||||||
err);
|
|
||||||
|
|
||||||
/* Switch to normal mode/disable Bank 0x12 access */
|
|
||||||
err = abx500_mask_and_set_register_interruptible(ab->dev,
|
|
||||||
AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS,
|
|
||||||
0x00, 0x00);
|
|
||||||
if (err < 0)
|
|
||||||
dev_err(ab->dev, "Failed to switch bank12 access err=%d\n",
|
|
||||||
err);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Needed to enable ID detection. */
|
/* Needed to enable ID detection. */
|
||||||
ab8500_usb_wd_workaround(ab);
|
ab8500_usb_wd_workaround(ab);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче