Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tomasz Figa and committed by
Felipe Balbi
3f339074 0aa823a2

+23 -35
+8 -28
drivers/usb/phy/phy-samsung-usb.c
··· 73 73 * Here 'on = true' would mean USB PHY block is isolated, hence 74 74 * de-activated and vice-versa. 75 75 */ 76 - void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on) 76 + void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy, bool on) 77 77 { 78 78 void __iomem *reg = NULL; 79 79 u32 reg_val; ··· 84 84 return; 85 85 } 86 86 87 - switch (sphy->drv_data->cpu_type) { 88 - case TYPE_S3C64XX: 89 - /* 90 - * Do nothing: We will add here once S3C64xx goes for DT support 91 - */ 92 - break; 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; 87 + if (sphy->phy_type == USB_PHY_TYPE_DEVICE) { 88 + reg = sphy->pmuregs + sphy->drv_data->devphy_reg_offset; 89 + en_mask = sphy->drv_data->devphy_en_mask; 90 + } else if (sphy->phy_type == USB_PHY_TYPE_HOST) { 91 + reg = sphy->pmuregs + sphy->drv_data->hostphy_reg_offset; 92 + en_mask = sphy->drv_data->hostphy_en_mask; 113 93 } 114 94 115 95 reg_val = readl(reg); ··· 101 121 102 122 writel(reg_val, reg); 103 123 } 104 - EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation); 124 + EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation_4210); 105 125 106 126 /* 107 127 * Configure the mode of working of usb-phy here: HOST/DEVICE.
+3 -1
drivers/usb/phy/phy-samsung-usb.h
··· 271 271 u32 devphy_reg_offset; 272 272 u32 hostphy_reg_offset; 273 273 int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long); 274 + void (*set_isolation)(struct samsung_usbphy *, bool); 274 275 }; 275 276 276 277 /* ··· 324 323 } 325 324 326 325 extern int samsung_usbphy_parse_dt(struct samsung_usbphy *sphy); 327 - extern void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on); 326 + extern void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy, 327 + bool on); 328 328 extern void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy); 329 329 extern int samsung_usbphy_set_type(struct usb_phy *phy, 330 330 enum samsung_usb_phy_type phy_type);
+7 -4
drivers/usb/phy/phy-samsung-usb2.c
··· 284 284 /* Disable phy isolation */ 285 285 if (sphy->plat && sphy->plat->pmu_isolation) 286 286 sphy->plat->pmu_isolation(false); 287 - else 288 - samsung_usbphy_set_isolation(sphy, false); 287 + else if (sphy->drv_data->set_isolation) 288 + sphy->drv_data->set_isolation(sphy, false); 289 289 290 290 /* Selecting Host/OTG mode; After reset USB2.0PHY_CFG: HOST */ 291 291 samsung_usbphy_cfg_sel(sphy); ··· 342 342 /* Enable phy isolation */ 343 343 if (sphy->plat && sphy->plat->pmu_isolation) 344 344 sphy->plat->pmu_isolation(true); 345 - else 346 - samsung_usbphy_set_isolation(sphy, true); 345 + else if (sphy->drv_data->set_isolation) 346 + sphy->drv_data->set_isolation(sphy, true); 347 347 348 348 spin_unlock_irqrestore(&sphy->lock, flags); 349 349 ··· 442 442 .cpu_type = TYPE_S3C64XX, 443 443 .devphy_en_mask = S3C64XX_USBPHY_ENABLE, 444 444 .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, 445 + .set_isolation = NULL, /* TODO */ 445 446 }; 446 447 447 448 static const struct samsung_usbphy_drvdata usb2phy_exynos4 = { ··· 450 449 .devphy_en_mask = EXYNOS_USBPHY_ENABLE, 451 450 .hostphy_en_mask = EXYNOS_USBPHY_ENABLE, 452 451 .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, 452 + .set_isolation = samsung_usbphy_set_isolation_4210, 453 453 }; 454 454 455 455 static struct samsung_usbphy_drvdata usb2phy_exynos5 = { ··· 458 456 .hostphy_en_mask = EXYNOS_USBPHY_ENABLE, 459 457 .hostphy_reg_offset = EXYNOS_USBHOST_PHY_CTRL_OFFSET, 460 458 .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, 459 + .set_isolation = samsung_usbphy_set_isolation_4210, 461 460 }; 462 461 463 462 #ifdef CONFIG_OF
+5 -2
drivers/usb/phy/phy-samsung-usb3.c
··· 184 184 samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE); 185 185 186 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 190 /* Initialize usb phy registers */ 190 191 samsung_exynos5_usb3phy_enable(sphy); ··· 222 221 samsung_exynos5_usb3phy_disable(sphy); 223 222 224 223 /* Enable phy isolation */ 225 - samsung_usbphy_set_isolation(sphy, true); 224 + if (sphy->drv_data->set_isolation) 225 + sphy->drv_data->set_isolation(sphy, true); 226 226 227 227 spin_unlock_irqrestore(&sphy->lock, flags); 228 228 ··· 306 304 .cpu_type = TYPE_EXYNOS5250, 307 305 .devphy_en_mask = EXYNOS_USBPHY_ENABLE, 308 306 .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, 307 + .set_isolation = samsung_usbphy_set_isolation_4210, 309 308 }; 310 309 311 310 #ifdef CONFIG_OF