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

usb: phy: samsung: Pass enable/disable callbacks through driver data

To remove unnecessary if statements, this patch introduces phy_enable
and phy_disable callbacks in driver data structure that implement
SoC-specific PHY initialization and deinitialization.

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
84035f09 3f339074

+15 -13
+2
drivers/usb/phy/phy-samsung-usb.h
··· 272 272 u32 hostphy_reg_offset; 273 273 int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long); 274 274 void (*set_isolation)(struct samsung_usbphy *, bool); 275 + void (*phy_enable)(struct samsung_usbphy *); 276 + void (*phy_disable)(struct samsung_usbphy *); 275 277 }; 276 278 277 279 /*
+8 -8
drivers/usb/phy/phy-samsung-usb2.c
··· 291 291 samsung_usbphy_cfg_sel(sphy); 292 292 293 293 /* Initialize usb phy registers */ 294 - if (sphy->drv_data->cpu_type == TYPE_EXYNOS5250) 295 - samsung_exynos5_usb2phy_enable(sphy); 296 - else 297 - samsung_usb2phy_enable(sphy); 294 + sphy->drv_data->phy_enable(sphy); 298 295 299 296 spin_unlock_irqrestore(&sphy->lock, flags); 300 297 ··· 331 334 } 332 335 333 336 /* De-initialize usb phy registers */ 334 - if (sphy->drv_data->cpu_type == TYPE_EXYNOS5250) 335 - samsung_exynos5_usb2phy_disable(sphy); 336 - else 337 - samsung_usb2phy_disable(sphy); 337 + sphy->drv_data->phy_disable(sphy); 338 338 339 339 /* Enable phy isolation */ 340 340 if (sphy->plat && sphy->plat->pmu_isolation) ··· 437 443 .devphy_en_mask = S3C64XX_USBPHY_ENABLE, 438 444 .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, 439 445 .set_isolation = NULL, /* TODO */ 446 + .phy_enable = samsung_usb2phy_enable, 447 + .phy_disable = samsung_usb2phy_disable, 440 448 }; 441 449 442 450 static const struct samsung_usbphy_drvdata usb2phy_exynos4 = { ··· 447 451 .hostphy_en_mask = EXYNOS_USBPHY_ENABLE, 448 452 .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, 449 453 .set_isolation = samsung_usbphy_set_isolation_4210, 454 + .phy_enable = samsung_usb2phy_enable, 455 + .phy_disable = samsung_usb2phy_disable, 450 456 }; 451 457 452 458 static struct samsung_usbphy_drvdata usb2phy_exynos5 = { ··· 457 459 .hostphy_reg_offset = EXYNOS_USBHOST_PHY_CTRL_OFFSET, 458 460 .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, 459 461 .set_isolation = samsung_usbphy_set_isolation_4210, 462 + .phy_enable = samsung_exynos5_usb2phy_enable, 463 + .phy_disable = samsung_exynos5_usb2phy_disable, 460 464 }; 461 465 462 466 #ifdef CONFIG_OF
+5 -5
drivers/usb/phy/phy-samsung-usb3.c
··· 65 65 return reg; 66 66 } 67 67 68 - static int samsung_exynos5_usb3phy_enable(struct samsung_usbphy *sphy) 68 + static void samsung_exynos5_usb3phy_enable(struct samsung_usbphy *sphy) 69 69 { 70 70 void __iomem *regs = sphy->regs; 71 71 u32 phyparam0; ··· 133 133 134 134 phyclkrst &= ~(PHYCLKRST_PORTRESET); 135 135 writel(phyclkrst, regs + EXYNOS5_DRD_PHYCLKRST); 136 - 137 - return 0; 138 136 } 139 137 140 138 static void samsung_exynos5_usb3phy_disable(struct samsung_usbphy *sphy) ··· 186 188 sphy->drv_data->set_isolation(sphy, false); 187 189 188 190 /* Initialize usb phy registers */ 189 - samsung_exynos5_usb3phy_enable(sphy); 191 + sphy->drv_data->phy_enable(sphy); 190 192 191 193 spin_unlock_irqrestore(&sphy->lock, flags); 192 194 ··· 217 219 samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE); 218 220 219 221 /* De-initialize usb phy registers */ 220 - samsung_exynos5_usb3phy_disable(sphy); 222 + sphy->drv_data->phy_disable(sphy); 221 223 222 224 /* Enable phy isolation */ 223 225 if (sphy->drv_data->set_isolation) ··· 305 307 .devphy_en_mask = EXYNOS_USBPHY_ENABLE, 306 308 .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, 307 309 .set_isolation = samsung_usbphy_set_isolation_4210, 310 + .phy_enable = samsung_exynos5_usb3phy_enable, 311 + .phy_disable = samsung_exynos5_usb3phy_disable, 308 312 }; 309 313 310 314 #ifdef CONFIG_OF