usb: phy: samsung: Pass set_isolation callback through driver data
This patch extends driver data structure with set_isolation callback, which allows to remove the need for checking for SoC type in a switch statement. Signed-off-by: Tomasz Figa <t.figa@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
0aa823a2ca
commit
3f339074ed
4 changed files with 23 additions and 35 deletions
|
@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(samsung_usbphy_parse_dt);
|
||||||
* Here 'on = true' would mean USB PHY block is isolated, hence
|
* Here 'on = true' would mean USB PHY block is isolated, hence
|
||||||
* de-activated and vice-versa.
|
* de-activated and vice-versa.
|
||||||
*/
|
*/
|
||||||
void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on)
|
void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy, bool on)
|
||||||
{
|
{
|
||||||
void __iomem *reg = NULL;
|
void __iomem *reg = NULL;
|
||||||
u32 reg_val;
|
u32 reg_val;
|
||||||
|
@ -84,33 +84,13 @@ void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (sphy->drv_data->cpu_type) {
|
|
||||||
case TYPE_S3C64XX:
|
|
||||||
/*
|
|
||||||
* Do nothing: We will add here once S3C64xx goes for DT support
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
case TYPE_EXYNOS4210:
|
|
||||||
/*
|
|
||||||
* Fall through since exynos4210 and exynos5250 have similar
|
|
||||||
* register architecture: two separate registers for host and
|
|
||||||
* device phy control with enable bit at position 0.
|
|
||||||
*/
|
|
||||||
case TYPE_EXYNOS5250:
|
|
||||||
if (sphy->phy_type == USB_PHY_TYPE_DEVICE) {
|
if (sphy->phy_type == USB_PHY_TYPE_DEVICE) {
|
||||||
reg = sphy->pmuregs +
|
reg = sphy->pmuregs + sphy->drv_data->devphy_reg_offset;
|
||||||
sphy->drv_data->devphy_reg_offset;
|
|
||||||
en_mask = sphy->drv_data->devphy_en_mask;
|
en_mask = sphy->drv_data->devphy_en_mask;
|
||||||
} else if (sphy->phy_type == USB_PHY_TYPE_HOST) {
|
} else if (sphy->phy_type == USB_PHY_TYPE_HOST) {
|
||||||
reg = sphy->pmuregs +
|
reg = sphy->pmuregs + sphy->drv_data->hostphy_reg_offset;
|
||||||
sphy->drv_data->hostphy_reg_offset;
|
|
||||||
en_mask = sphy->drv_data->hostphy_en_mask;
|
en_mask = sphy->drv_data->hostphy_en_mask;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dev_err(sphy->dev, "Invalid SoC type\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
reg_val = readl(reg);
|
reg_val = readl(reg);
|
||||||
|
|
||||||
|
@ -121,7 +101,7 @@ void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on)
|
||||||
|
|
||||||
writel(reg_val, reg);
|
writel(reg_val, reg);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation);
|
EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation_4210);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure the mode of working of usb-phy here: HOST/DEVICE.
|
* Configure the mode of working of usb-phy here: HOST/DEVICE.
|
||||||
|
|
|
@ -271,6 +271,7 @@ struct samsung_usbphy_drvdata {
|
||||||
u32 devphy_reg_offset;
|
u32 devphy_reg_offset;
|
||||||
u32 hostphy_reg_offset;
|
u32 hostphy_reg_offset;
|
||||||
int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long);
|
int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long);
|
||||||
|
void (*set_isolation)(struct samsung_usbphy *, bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -323,7 +324,8 @@ static inline const struct samsung_usbphy_drvdata
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int samsung_usbphy_parse_dt(struct samsung_usbphy *sphy);
|
extern int samsung_usbphy_parse_dt(struct samsung_usbphy *sphy);
|
||||||
extern void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on);
|
extern void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy,
|
||||||
|
bool on);
|
||||||
extern void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy);
|
extern void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy);
|
||||||
extern int samsung_usbphy_set_type(struct usb_phy *phy,
|
extern int samsung_usbphy_set_type(struct usb_phy *phy,
|
||||||
enum samsung_usb_phy_type phy_type);
|
enum samsung_usb_phy_type phy_type);
|
||||||
|
|
|
@ -284,8 +284,8 @@ static int samsung_usb2phy_init(struct usb_phy *phy)
|
||||||
/* Disable phy isolation */
|
/* Disable phy isolation */
|
||||||
if (sphy->plat && sphy->plat->pmu_isolation)
|
if (sphy->plat && sphy->plat->pmu_isolation)
|
||||||
sphy->plat->pmu_isolation(false);
|
sphy->plat->pmu_isolation(false);
|
||||||
else
|
else if (sphy->drv_data->set_isolation)
|
||||||
samsung_usbphy_set_isolation(sphy, false);
|
sphy->drv_data->set_isolation(sphy, false);
|
||||||
|
|
||||||
/* Selecting Host/OTG mode; After reset USB2.0PHY_CFG: HOST */
|
/* Selecting Host/OTG mode; After reset USB2.0PHY_CFG: HOST */
|
||||||
samsung_usbphy_cfg_sel(sphy);
|
samsung_usbphy_cfg_sel(sphy);
|
||||||
|
@ -342,8 +342,8 @@ static void samsung_usb2phy_shutdown(struct usb_phy *phy)
|
||||||
/* Enable phy isolation */
|
/* Enable phy isolation */
|
||||||
if (sphy->plat && sphy->plat->pmu_isolation)
|
if (sphy->plat && sphy->plat->pmu_isolation)
|
||||||
sphy->plat->pmu_isolation(true);
|
sphy->plat->pmu_isolation(true);
|
||||||
else
|
else if (sphy->drv_data->set_isolation)
|
||||||
samsung_usbphy_set_isolation(sphy, true);
|
sphy->drv_data->set_isolation(sphy, true);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&sphy->lock, flags);
|
spin_unlock_irqrestore(&sphy->lock, flags);
|
||||||
|
|
||||||
|
@ -442,6 +442,7 @@ static const struct samsung_usbphy_drvdata usb2phy_s3c64xx = {
|
||||||
.cpu_type = TYPE_S3C64XX,
|
.cpu_type = TYPE_S3C64XX,
|
||||||
.devphy_en_mask = S3C64XX_USBPHY_ENABLE,
|
.devphy_en_mask = S3C64XX_USBPHY_ENABLE,
|
||||||
.rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx,
|
.rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx,
|
||||||
|
.set_isolation = NULL, /* TODO */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct samsung_usbphy_drvdata usb2phy_exynos4 = {
|
static const struct samsung_usbphy_drvdata usb2phy_exynos4 = {
|
||||||
|
@ -449,6 +450,7 @@ static const struct samsung_usbphy_drvdata usb2phy_exynos4 = {
|
||||||
.devphy_en_mask = EXYNOS_USBPHY_ENABLE,
|
.devphy_en_mask = EXYNOS_USBPHY_ENABLE,
|
||||||
.hostphy_en_mask = EXYNOS_USBPHY_ENABLE,
|
.hostphy_en_mask = EXYNOS_USBPHY_ENABLE,
|
||||||
.rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx,
|
.rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx,
|
||||||
|
.set_isolation = samsung_usbphy_set_isolation_4210,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct samsung_usbphy_drvdata usb2phy_exynos5 = {
|
static struct samsung_usbphy_drvdata usb2phy_exynos5 = {
|
||||||
|
@ -456,6 +458,7 @@ static struct samsung_usbphy_drvdata usb2phy_exynos5 = {
|
||||||
.hostphy_en_mask = EXYNOS_USBPHY_ENABLE,
|
.hostphy_en_mask = EXYNOS_USBPHY_ENABLE,
|
||||||
.hostphy_reg_offset = EXYNOS_USBHOST_PHY_CTRL_OFFSET,
|
.hostphy_reg_offset = EXYNOS_USBHOST_PHY_CTRL_OFFSET,
|
||||||
.rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12,
|
.rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12,
|
||||||
|
.set_isolation = samsung_usbphy_set_isolation_4210,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
|
|
|
@ -184,7 +184,8 @@ static int samsung_usb3phy_init(struct usb_phy *phy)
|
||||||
samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE);
|
samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE);
|
||||||
|
|
||||||
/* Disable phy isolation */
|
/* Disable phy isolation */
|
||||||
samsung_usbphy_set_isolation(sphy, false);
|
if (sphy->drv_data->set_isolation)
|
||||||
|
sphy->drv_data->set_isolation(sphy, false);
|
||||||
|
|
||||||
/* Initialize usb phy registers */
|
/* Initialize usb phy registers */
|
||||||
samsung_exynos5_usb3phy_enable(sphy);
|
samsung_exynos5_usb3phy_enable(sphy);
|
||||||
|
@ -221,7 +222,8 @@ static void samsung_usb3phy_shutdown(struct usb_phy *phy)
|
||||||
samsung_exynos5_usb3phy_disable(sphy);
|
samsung_exynos5_usb3phy_disable(sphy);
|
||||||
|
|
||||||
/* Enable phy isolation */
|
/* Enable phy isolation */
|
||||||
samsung_usbphy_set_isolation(sphy, true);
|
if (sphy->drv_data->set_isolation)
|
||||||
|
sphy->drv_data->set_isolation(sphy, true);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&sphy->lock, flags);
|
spin_unlock_irqrestore(&sphy->lock, flags);
|
||||||
|
|
||||||
|
@ -304,6 +306,7 @@ static struct samsung_usbphy_drvdata usb3phy_exynos5 = {
|
||||||
.cpu_type = TYPE_EXYNOS5250,
|
.cpu_type = TYPE_EXYNOS5250,
|
||||||
.devphy_en_mask = EXYNOS_USBPHY_ENABLE,
|
.devphy_en_mask = EXYNOS_USBPHY_ENABLE,
|
||||||
.rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12,
|
.rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12,
|
||||||
|
.set_isolation = samsung_usbphy_set_isolation_4210,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
|
|
Loading…
Add table
Reference in a new issue