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

phy: rcar-gen3-usb2: add SoC-specific parameter for dedicated pins

This patch adds SoC-specific parameter to avoid reading/writing
specific registers wrongly if this driver runs on a SoC which doesn't
have dedicated pins (e.g. R-Car D3). This patch also changes the
value "has_otg" to "has_otg_pins" for slightly easier reading of
the code.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Yoshihiro Shimoda and committed by
Kishon Vijay Abraham I
9adaaa9e b56acc82

+21 -10
+21 -10
drivers/phy/renesas/phy-rcar-gen3-usb2.c
··· 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 20 #include <linux/of_address.h> 21 + #include <linux/of_device.h> 21 22 #include <linux/phy/phy.h> 22 23 #include <linux/platform_device.h> 23 24 #include <linux/pm_runtime.h> ··· 81 80 #define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */ 82 81 #define USB2_ADPCTRL_DRVVBUS BIT(4) 83 82 83 + #define RCAR_GEN3_PHY_HAS_DEDICATED_PINS 1 84 + 84 85 struct rcar_gen3_chan { 85 86 void __iomem *base; 86 87 struct extcon_dev *extcon; ··· 90 87 struct regulator *vbus; 91 88 struct work_struct work; 92 89 bool extcon_host; 93 - bool has_otg; 90 + bool has_otg_pins; 94 91 }; 95 92 96 93 static void rcar_gen3_phy_usb2_work(struct work_struct *work) ··· 237 234 bool is_b_device; 238 235 enum phy_mode cur_mode, new_mode; 239 236 240 - if (!ch->has_otg || !ch->phy->init_count) 237 + if (!ch->has_otg_pins || !ch->phy->init_count) 241 238 return -EIO; 242 239 243 240 if (!strncmp(buf, "host", strlen("host"))) ··· 275 272 { 276 273 struct rcar_gen3_chan *ch = dev_get_drvdata(dev); 277 274 278 - if (!ch->has_otg || !ch->phy->init_count) 275 + if (!ch->has_otg_pins || !ch->phy->init_count) 279 276 return -EIO; 280 277 281 278 return sprintf(buf, "%s\n", rcar_gen3_is_host(ch) ? "host" : ··· 314 311 writel(USB2_OC_TIMSET_INIT, usb2_base + USB2_OC_TIMSET); 315 312 316 313 /* Initialize otg part */ 317 - if (channel->has_otg) 314 + if (channel->has_otg_pins) 318 315 rcar_gen3_init_otg(channel); 319 316 320 317 return 0; ··· 388 385 } 389 386 390 387 static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = { 391 - { .compatible = "renesas,usb2-phy-r8a7795" }, 392 - { .compatible = "renesas,usb2-phy-r8a7796" }, 393 - { .compatible = "renesas,rcar-gen3-usb2-phy" }, 388 + { 389 + .compatible = "renesas,usb2-phy-r8a7795", 390 + .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS, 391 + }, 392 + { 393 + .compatible = "renesas,usb2-phy-r8a7796", 394 + .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS, 395 + }, 396 + { 397 + .compatible = "renesas,rcar-gen3-usb2-phy", 398 + }, 394 399 { } 395 400 }; 396 401 MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table); ··· 444 433 if (of_usb_get_dr_mode_by_phy(dev->of_node, 0) == USB_DR_MODE_OTG) { 445 434 int ret; 446 435 447 - channel->has_otg = true; 436 + channel->has_otg_pins = (uintptr_t)of_device_get_match_data(dev); 448 437 channel->extcon = devm_extcon_dev_allocate(dev, 449 438 rcar_gen3_phy_cable); 450 439 if (IS_ERR(channel->extcon)) ··· 486 475 dev_err(dev, "Failed to register PHY provider\n"); 487 476 ret = PTR_ERR(provider); 488 477 goto error; 489 - } else if (channel->has_otg) { 478 + } else if (channel->has_otg_pins) { 490 479 int ret; 491 480 492 481 ret = device_create_file(dev, &dev_attr_role); ··· 506 495 { 507 496 struct rcar_gen3_chan *channel = platform_get_drvdata(pdev); 508 497 509 - if (channel->has_otg) 498 + if (channel->has_otg_pins) 510 499 device_remove_file(&pdev->dev, &dev_attr_role); 511 500 512 501 pm_runtime_disable(&pdev->dev);