aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Figa <t.figa@samsung.com>2013-05-16 05:57:09 -0400
committerFelipe Balbi <balbi@ti.com>2013-05-28 13:06:49 -0400
commit3f339074edfa0d531edaa6bd095f718e58b50a7d (patch)
treeec7554d94bdff7ded19e0c269425a19b055c43e4
parent0aa823a2ca02cd21c587713e8195a2ffb8bd7872 (diff)
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>
-rw-r--r--drivers/usb/phy/phy-samsung-usb.c36
-rw-r--r--drivers/usb/phy/phy-samsung-usb.h4
-rw-r--r--drivers/usb/phy/phy-samsung-usb2.c11
-rw-r--r--drivers/usb/phy/phy-samsung-usb3.c7
4 files changed, 23 insertions, 35 deletions
diff --git a/drivers/usb/phy/phy-samsung-usb.c b/drivers/usb/phy/phy-samsung-usb.c
index c40ea321ae46..7a1ed90bd58e 100644
--- a/drivers/usb/phy/phy-samsung-usb.c
+++ b/drivers/usb/phy/phy-samsung-usb.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(samsung_usbphy_parse_dt);
73 * Here 'on = true' would mean USB PHY block is isolated, hence 73 * Here 'on = true' would mean USB PHY block is isolated, hence
74 * de-activated and vice-versa. 74 * de-activated and vice-versa.
75 */ 75 */
76void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on) 76void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy, bool on)
77{ 77{
78 void __iomem *reg = NULL; 78 void __iomem *reg = NULL;
79 u32 reg_val; 79 u32 reg_val;
@@ -84,32 +84,12 @@ void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on)
84 return; 84 return;
85 } 85 }
86 86
87 switch (sphy->drv_data->cpu_type) { 87 if (sphy->phy_type == USB_PHY_TYPE_DEVICE) {
88 case TYPE_S3C64XX: 88 reg = sphy->pmuregs + sphy->drv_data->devphy_reg_offset;
89 /* 89 en_mask = sphy->drv_data->devphy_en_mask;
90 * Do nothing: We will add here once S3C64xx goes for DT support 90 } else if (sphy->phy_type == USB_PHY_TYPE_HOST) {
91 */ 91 reg = sphy->pmuregs + sphy->drv_data->hostphy_reg_offset;
92 break; 92 en_mask = sphy->drv_data->hostphy_en_mask;
93 case TYPE_EXYNOS4210:
94 /*
95 * Fall through since exynos4210 and exynos5250 have similar
96 * register architecture: two separate registers for host and
97 * device phy control with enable bit at position 0.
98 */
99 case TYPE_EXYNOS5250:
100 if (sphy->phy_type == USB_PHY_TYPE_DEVICE) {
101 reg = sphy->pmuregs +
102 sphy->drv_data->devphy_reg_offset;
103 en_mask = sphy->drv_data->devphy_en_mask;
104 } else if (sphy->phy_type == USB_PHY_TYPE_HOST) {
105 reg = sphy->pmuregs +
106 sphy->drv_data->hostphy_reg_offset;
107 en_mask = sphy->drv_data->hostphy_en_mask;
108 }
109 break;
110 default:
111 dev_err(sphy->dev, "Invalid SoC type\n");
112 return;
113 } 93 }
114 94
115 reg_val = readl(reg); 95 reg_val = readl(reg);
@@ -121,7 +101,7 @@ void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on)
121 101
122 writel(reg_val, reg); 102 writel(reg_val, reg);
123} 103}
124EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation); 104EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation_4210);
125 105
126/* 106/*
127 * Configure the mode of working of usb-phy here: HOST/DEVICE. 107 * Configure the mode of working of usb-phy here: HOST/DEVICE.
diff --git a/drivers/usb/phy/phy-samsung-usb.h b/drivers/usb/phy/phy-samsung-usb.h
index 0336f6b02bc4..52037841ff2e 100644
--- a/drivers/usb/phy/phy-samsung-usb.h
+++ b/drivers/usb/phy/phy-samsung-usb.h
@@ -271,6 +271,7 @@ struct samsung_usbphy_drvdata {
271 u32 devphy_reg_offset; 271 u32 devphy_reg_offset;
272 u32 hostphy_reg_offset; 272 u32 hostphy_reg_offset;
273 int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long); 273 int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long);
274 void (*set_isolation)(struct samsung_usbphy *, bool);
274}; 275};
275 276
276/* 277/*
@@ -323,7 +324,8 @@ static inline const struct samsung_usbphy_drvdata
323} 324}
324 325
325extern int samsung_usbphy_parse_dt(struct samsung_usbphy *sphy); 326extern int samsung_usbphy_parse_dt(struct samsung_usbphy *sphy);
326extern void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on); 327extern void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy,
328 bool on);
327extern void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy); 329extern void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy);
328extern int samsung_usbphy_set_type(struct usb_phy *phy, 330extern int samsung_usbphy_set_type(struct usb_phy *phy,
329 enum samsung_usb_phy_type phy_type); 331 enum samsung_usb_phy_type phy_type);
diff --git a/drivers/usb/phy/phy-samsung-usb2.c b/drivers/usb/phy/phy-samsung-usb2.c
index be6031d50a6d..a01247e03e58 100644
--- a/drivers/usb/phy/phy-samsung-usb2.c
+++ b/drivers/usb/phy/phy-samsung-usb2.c
@@ -284,8 +284,8 @@ static int samsung_usb2phy_init(struct usb_phy *phy)
284 /* Disable phy isolation */ 284 /* Disable phy isolation */
285 if (sphy->plat && sphy->plat->pmu_isolation) 285 if (sphy->plat && sphy->plat->pmu_isolation)
286 sphy->plat->pmu_isolation(false); 286 sphy->plat->pmu_isolation(false);
287 else 287 else if (sphy->drv_data->set_isolation)
288 samsung_usbphy_set_isolation(sphy, false); 288 sphy->drv_data->set_isolation(sphy, false);
289 289
290 /* Selecting Host/OTG mode; After reset USB2.0PHY_CFG: HOST */ 290 /* Selecting Host/OTG mode; After reset USB2.0PHY_CFG: HOST */
291 samsung_usbphy_cfg_sel(sphy); 291 samsung_usbphy_cfg_sel(sphy);
@@ -342,8 +342,8 @@ static void samsung_usb2phy_shutdown(struct usb_phy *phy)
342 /* Enable phy isolation */ 342 /* Enable phy isolation */
343 if (sphy->plat && sphy->plat->pmu_isolation) 343 if (sphy->plat && sphy->plat->pmu_isolation)
344 sphy->plat->pmu_isolation(true); 344 sphy->plat->pmu_isolation(true);
345 else 345 else if (sphy->drv_data->set_isolation)
346 samsung_usbphy_set_isolation(sphy, true); 346 sphy->drv_data->set_isolation(sphy, true);
347 347
348 spin_unlock_irqrestore(&sphy->lock, flags); 348 spin_unlock_irqrestore(&sphy->lock, flags);
349 349
@@ -442,6 +442,7 @@ static const struct samsung_usbphy_drvdata usb2phy_s3c64xx = {
442 .cpu_type = TYPE_S3C64XX, 442 .cpu_type = TYPE_S3C64XX,
443 .devphy_en_mask = S3C64XX_USBPHY_ENABLE, 443 .devphy_en_mask = S3C64XX_USBPHY_ENABLE,
444 .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, 444 .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx,
445 .set_isolation = NULL, /* TODO */
445}; 446};
446 447
447static const struct samsung_usbphy_drvdata usb2phy_exynos4 = { 448static const struct samsung_usbphy_drvdata usb2phy_exynos4 = {
@@ -449,6 +450,7 @@ static const struct samsung_usbphy_drvdata usb2phy_exynos4 = {
449 .devphy_en_mask = EXYNOS_USBPHY_ENABLE, 450 .devphy_en_mask = EXYNOS_USBPHY_ENABLE,
450 .hostphy_en_mask = EXYNOS_USBPHY_ENABLE, 451 .hostphy_en_mask = EXYNOS_USBPHY_ENABLE,
451 .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, 452 .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx,
453 .set_isolation = samsung_usbphy_set_isolation_4210,
452}; 454};
453 455
454static struct samsung_usbphy_drvdata usb2phy_exynos5 = { 456static struct samsung_usbphy_drvdata usb2phy_exynos5 = {
@@ -456,6 +458,7 @@ static struct samsung_usbphy_drvdata usb2phy_exynos5 = {
456 .hostphy_en_mask = EXYNOS_USBPHY_ENABLE, 458 .hostphy_en_mask = EXYNOS_USBPHY_ENABLE,
457 .hostphy_reg_offset = EXYNOS_USBHOST_PHY_CTRL_OFFSET, 459 .hostphy_reg_offset = EXYNOS_USBHOST_PHY_CTRL_OFFSET,
458 .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, 460 .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12,
461 .set_isolation = samsung_usbphy_set_isolation_4210,
459}; 462};
460 463
461#ifdef CONFIG_OF 464#ifdef CONFIG_OF
diff --git a/drivers/usb/phy/phy-samsung-usb3.c b/drivers/usb/phy/phy-samsung-usb3.c
index ec44b35fb24a..3a30a5edde98 100644
--- a/drivers/usb/phy/phy-samsung-usb3.c
+++ b/drivers/usb/phy/phy-samsung-usb3.c
@@ -184,7 +184,8 @@ static int samsung_usb3phy_init(struct usb_phy *phy)
184 samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE); 184 samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE);
185 185
186 /* Disable phy isolation */ 186 /* Disable phy isolation */
187 samsung_usbphy_set_isolation(sphy, false); 187 if (sphy->drv_data->set_isolation)
188 sphy->drv_data->set_isolation(sphy, false);
188 189
189 /* Initialize usb phy registers */ 190 /* Initialize usb phy registers */
190 samsung_exynos5_usb3phy_enable(sphy); 191 samsung_exynos5_usb3phy_enable(sphy);
@@ -221,7 +222,8 @@ static void samsung_usb3phy_shutdown(struct usb_phy *phy)
221 samsung_exynos5_usb3phy_disable(sphy); 222 samsung_exynos5_usb3phy_disable(sphy);
222 223
223 /* Enable phy isolation */ 224 /* Enable phy isolation */
224 samsung_usbphy_set_isolation(sphy, true); 225 if (sphy->drv_data->set_isolation)
226 sphy->drv_data->set_isolation(sphy, true);
225 227
226 spin_unlock_irqrestore(&sphy->lock, flags); 228 spin_unlock_irqrestore(&sphy->lock, flags);
227 229
@@ -304,6 +306,7 @@ static struct samsung_usbphy_drvdata usb3phy_exynos5 = {
304 .cpu_type = TYPE_EXYNOS5250, 306 .cpu_type = TYPE_EXYNOS5250,
305 .devphy_en_mask = EXYNOS_USBPHY_ENABLE, 307 .devphy_en_mask = EXYNOS_USBPHY_ENABLE,
306 .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, 308 .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12,
309 .set_isolation = samsung_usbphy_set_isolation_4210,
307}; 310};
308 311
309#ifdef CONFIG_OF 312#ifdef CONFIG_OF