aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-10-17 04:50:27 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-10-17 04:50:27 -0400
commit283776e9b72502c71c34f489e1015841bd8681ab (patch)
tree759db9c9b48f3ec457be959d1236633b94b14181
parentb3207c65dfafae27e7c492cb9188c0dc0eeaf3fd (diff)
parent2fb850092fd95198a0a4746f07b80077d5a3aa37 (diff)
Merge tag 'phy-for-4.14-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy into usb-linus
Kishon writes: phy: for 4.14 -rc *) Handle error return values in rockchip-typec and tegra-xusb *) Fix MUX error check and ioremap_resource error check in mvebu-cp110-comphy *) Fix NULL pointer dereference error in phy-mtk-tphy *) Make sure pipe selector is not set to incompatible value *) Fix flaky aux channel communication with rockchip-typec PHY *) Fix DP monitors detection issue in rockchip-typec PHY Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
-rw-r--r--drivers/phy/marvell/phy-mvebu-cp110-comphy.c18
-rw-r--r--drivers/phy/mediatek/phy-mtk-tphy.c3
-rw-r--r--drivers/phy/rockchip/phy-rockchip-typec.c82
-rw-r--r--drivers/phy/tegra/xusb.c2
4 files changed, 73 insertions, 32 deletions
diff --git a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
index 73ebad6634a7..89c887ea5557 100644
--- a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
+++ b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
@@ -111,6 +111,8 @@
111#define MVEBU_COMPHY_CONF6_40B BIT(18) 111#define MVEBU_COMPHY_CONF6_40B BIT(18)
112#define MVEBU_COMPHY_SELECTOR 0x1140 112#define MVEBU_COMPHY_SELECTOR 0x1140
113#define MVEBU_COMPHY_SELECTOR_PHY(n) ((n) * 0x4) 113#define MVEBU_COMPHY_SELECTOR_PHY(n) ((n) * 0x4)
114#define MVEBU_COMPHY_PIPE_SELECTOR 0x1144
115#define MVEBU_COMPHY_PIPE_SELECTOR_PIPE(n) ((n) * 0x4)
114 116
115#define MVEBU_COMPHY_LANES 6 117#define MVEBU_COMPHY_LANES 6
116#define MVEBU_COMPHY_PORTS 3 118#define MVEBU_COMPHY_PORTS 3
@@ -468,13 +470,17 @@ static int mvebu_comphy_power_on(struct phy *phy)
468{ 470{
469 struct mvebu_comphy_lane *lane = phy_get_drvdata(phy); 471 struct mvebu_comphy_lane *lane = phy_get_drvdata(phy);
470 struct mvebu_comphy_priv *priv = lane->priv; 472 struct mvebu_comphy_priv *priv = lane->priv;
471 int ret; 473 int ret, mux;
472 u32 mux, val; 474 u32 val;
473 475
474 mux = mvebu_comphy_get_mux(lane->id, lane->port, lane->mode); 476 mux = mvebu_comphy_get_mux(lane->id, lane->port, lane->mode);
475 if (mux < 0) 477 if (mux < 0)
476 return -ENOTSUPP; 478 return -ENOTSUPP;
477 479
480 regmap_read(priv->regmap, MVEBU_COMPHY_PIPE_SELECTOR, &val);
481 val &= ~(0xf << MVEBU_COMPHY_PIPE_SELECTOR_PIPE(lane->id));
482 regmap_write(priv->regmap, MVEBU_COMPHY_PIPE_SELECTOR, val);
483
478 regmap_read(priv->regmap, MVEBU_COMPHY_SELECTOR, &val); 484 regmap_read(priv->regmap, MVEBU_COMPHY_SELECTOR, &val);
479 val &= ~(0xf << MVEBU_COMPHY_SELECTOR_PHY(lane->id)); 485 val &= ~(0xf << MVEBU_COMPHY_SELECTOR_PHY(lane->id));
480 val |= mux << MVEBU_COMPHY_SELECTOR_PHY(lane->id); 486 val |= mux << MVEBU_COMPHY_SELECTOR_PHY(lane->id);
@@ -526,6 +532,10 @@ static int mvebu_comphy_power_off(struct phy *phy)
526 val &= ~(0xf << MVEBU_COMPHY_SELECTOR_PHY(lane->id)); 532 val &= ~(0xf << MVEBU_COMPHY_SELECTOR_PHY(lane->id));
527 regmap_write(priv->regmap, MVEBU_COMPHY_SELECTOR, val); 533 regmap_write(priv->regmap, MVEBU_COMPHY_SELECTOR, val);
528 534
535 regmap_read(priv->regmap, MVEBU_COMPHY_PIPE_SELECTOR, &val);
536 val &= ~(0xf << MVEBU_COMPHY_PIPE_SELECTOR_PIPE(lane->id));
537 regmap_write(priv->regmap, MVEBU_COMPHY_PIPE_SELECTOR, val);
538
529 return 0; 539 return 0;
530} 540}
531 541
@@ -576,8 +586,8 @@ static int mvebu_comphy_probe(struct platform_device *pdev)
576 return PTR_ERR(priv->regmap); 586 return PTR_ERR(priv->regmap);
577 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 587 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
578 priv->base = devm_ioremap_resource(&pdev->dev, res); 588 priv->base = devm_ioremap_resource(&pdev->dev, res);
579 if (!priv->base) 589 if (IS_ERR(priv->base))
580 return -ENOMEM; 590 return PTR_ERR(priv->base);
581 591
582 for_each_available_child_of_node(pdev->dev.of_node, child) { 592 for_each_available_child_of_node(pdev->dev.of_node, child) {
583 struct mvebu_comphy_lane *lane; 593 struct mvebu_comphy_lane *lane;
diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index e3baad78521f..721a2a1c97ef 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -27,6 +27,7 @@
27/* banks shared by multiple phys */ 27/* banks shared by multiple phys */
28#define SSUSB_SIFSLV_V1_SPLLC 0x000 /* shared by u3 phys */ 28#define SSUSB_SIFSLV_V1_SPLLC 0x000 /* shared by u3 phys */
29#define SSUSB_SIFSLV_V1_U2FREQ 0x100 /* shared by u2 phys */ 29#define SSUSB_SIFSLV_V1_U2FREQ 0x100 /* shared by u2 phys */
30#define SSUSB_SIFSLV_V1_CHIP 0x300 /* shared by u3 phys */
30/* u2 phy bank */ 31/* u2 phy bank */
31#define SSUSB_SIFSLV_V1_U2PHY_COM 0x000 32#define SSUSB_SIFSLV_V1_U2PHY_COM 0x000
32/* u3/pcie/sata phy banks */ 33/* u3/pcie/sata phy banks */
@@ -762,7 +763,7 @@ static void phy_v1_banks_init(struct mtk_tphy *tphy,
762 case PHY_TYPE_USB3: 763 case PHY_TYPE_USB3:
763 case PHY_TYPE_PCIE: 764 case PHY_TYPE_PCIE:
764 u3_banks->spllc = tphy->sif_base + SSUSB_SIFSLV_V1_SPLLC; 765 u3_banks->spllc = tphy->sif_base + SSUSB_SIFSLV_V1_SPLLC;
765 u3_banks->chip = NULL; 766 u3_banks->chip = tphy->sif_base + SSUSB_SIFSLV_V1_CHIP;
766 u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V1_U3PHYD; 767 u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V1_U3PHYD;
767 u3_banks->phya = instance->port_base + SSUSB_SIFSLV_V1_U3PHYA; 768 u3_banks->phya = instance->port_base + SSUSB_SIFSLV_V1_U3PHYA;
768 break; 769 break;
diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
index 4d2c57f21d76..a958c9bced01 100644
--- a/drivers/phy/rockchip/phy-rockchip-typec.c
+++ b/drivers/phy/rockchip/phy-rockchip-typec.c
@@ -443,14 +443,34 @@ static inline int property_enable(struct rockchip_typec_phy *tcphy,
443 return regmap_write(tcphy->grf_regs, reg->offset, val | mask); 443 return regmap_write(tcphy->grf_regs, reg->offset, val | mask);
444} 444}
445 445
446static void tcphy_dp_aux_set_flip(struct rockchip_typec_phy *tcphy)
447{
448 u16 tx_ana_ctrl_reg_1;
449
450 /*
451 * Select the polarity of the xcvr:
452 * 1, Reverses the polarity (If TYPEC, Pulls ups aux_p and pull
453 * down aux_m)
454 * 0, Normal polarity (if TYPEC, pulls up aux_m and pulls down
455 * aux_p)
456 */
457 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1);
458 if (!tcphy->flip)
459 tx_ana_ctrl_reg_1 |= BIT(12);
460 else
461 tx_ana_ctrl_reg_1 &= ~BIT(12);
462 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
463}
464
446static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy) 465static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
447{ 466{
467 u16 tx_ana_ctrl_reg_1;
448 u16 rdata, rdata2, val; 468 u16 rdata, rdata2, val;
449 469
450 /* disable txda_cal_latch_en for rewrite the calibration values */ 470 /* disable txda_cal_latch_en for rewrite the calibration values */
451 rdata = readl(tcphy->base + TX_ANA_CTRL_REG_1); 471 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1);
452 val = rdata & 0xdfff; 472 tx_ana_ctrl_reg_1 &= ~BIT(13);
453 writel(val, tcphy->base + TX_ANA_CTRL_REG_1); 473 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
454 474
455 /* 475 /*
456 * read a resistor calibration code from CMN_TXPUCAL_CTRL[6:0] and 476 * read a resistor calibration code from CMN_TXPUCAL_CTRL[6:0] and
@@ -472,9 +492,8 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
472 * Activate this signal for 1 clock cycle to sample new calibration 492 * Activate this signal for 1 clock cycle to sample new calibration
473 * values. 493 * values.
474 */ 494 */
475 rdata = readl(tcphy->base + TX_ANA_CTRL_REG_1); 495 tx_ana_ctrl_reg_1 |= BIT(13);
476 val = rdata | 0x2000; 496 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
477 writel(val, tcphy->base + TX_ANA_CTRL_REG_1);
478 usleep_range(150, 200); 497 usleep_range(150, 200);
479 498
480 /* set TX Voltage Level and TX Deemphasis to 0 */ 499 /* set TX Voltage Level and TX Deemphasis to 0 */
@@ -482,8 +501,10 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
482 /* re-enable decap */ 501 /* re-enable decap */
483 writel(0x100, tcphy->base + TX_ANA_CTRL_REG_2); 502 writel(0x100, tcphy->base + TX_ANA_CTRL_REG_2);
484 writel(0x300, tcphy->base + TX_ANA_CTRL_REG_2); 503 writel(0x300, tcphy->base + TX_ANA_CTRL_REG_2);
485 writel(0x2008, tcphy->base + TX_ANA_CTRL_REG_1); 504 tx_ana_ctrl_reg_1 |= BIT(3);
486 writel(0x2018, tcphy->base + TX_ANA_CTRL_REG_1); 505 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
506 tx_ana_ctrl_reg_1 |= BIT(4);
507 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
487 508
488 writel(0, tcphy->base + TX_ANA_CTRL_REG_5); 509 writel(0, tcphy->base + TX_ANA_CTRL_REG_5);
489 510
@@ -494,8 +515,10 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
494 writel(0x1001, tcphy->base + TX_ANA_CTRL_REG_4); 515 writel(0x1001, tcphy->base + TX_ANA_CTRL_REG_4);
495 516
496 /* re-enables Bandgap reference for LDO */ 517 /* re-enables Bandgap reference for LDO */
497 writel(0x2098, tcphy->base + TX_ANA_CTRL_REG_1); 518 tx_ana_ctrl_reg_1 |= BIT(7);
498 writel(0x2198, tcphy->base + TX_ANA_CTRL_REG_1); 519 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
520 tx_ana_ctrl_reg_1 |= BIT(8);
521 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
499 522
500 /* 523 /*
501 * re-enables the transmitter pre-driver, driver data selection MUX, 524 * re-enables the transmitter pre-driver, driver data selection MUX,
@@ -505,27 +528,26 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
505 writel(0x303, tcphy->base + TX_ANA_CTRL_REG_2); 528 writel(0x303, tcphy->base + TX_ANA_CTRL_REG_2);
506 529
507 /* 530 /*
508 * BIT 12: Controls auxda_polarity, which selects the polarity of the 531 * Do some magic undocumented stuff, some of which appears to
509 * xcvr: 532 * undo the "re-enables Bandgap reference for LDO" above.
510 * 1, Reverses the polarity (If TYPEC, Pulls ups aux_p and pull
511 * down aux_m)
512 * 0, Normal polarity (if TYPE_C, pulls up aux_m and pulls down
513 * aux_p)
514 */ 533 */
515 val = 0xa078; 534 tx_ana_ctrl_reg_1 |= BIT(15);
516 if (!tcphy->flip) 535 tx_ana_ctrl_reg_1 &= ~BIT(8);
517 val |= BIT(12); 536 tx_ana_ctrl_reg_1 &= ~BIT(7);
518 writel(val, tcphy->base + TX_ANA_CTRL_REG_1); 537 tx_ana_ctrl_reg_1 |= BIT(6);
538 tx_ana_ctrl_reg_1 |= BIT(5);
539 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
519 540
520 writel(0, tcphy->base + TX_ANA_CTRL_REG_3); 541 writel(0, tcphy->base + TX_ANA_CTRL_REG_3);
521 writel(0, tcphy->base + TX_ANA_CTRL_REG_4); 542 writel(0, tcphy->base + TX_ANA_CTRL_REG_4);
522 writel(0, tcphy->base + TX_ANA_CTRL_REG_5); 543 writel(0, tcphy->base + TX_ANA_CTRL_REG_5);
523 544
524 /* 545 /*
525 * Controls low_power_swing_en, set the voltage swing of the driver 546 * Controls low_power_swing_en, don't set the voltage swing of the
526 * to 400mv. The values below are peak to peak (differential) values. 547 * driver to 400mv. The values below are peak to peak (differential)
548 * values.
527 */ 549 */
528 writel(4, tcphy->base + TXDA_COEFF_CALC_CTRL); 550 writel(0, tcphy->base + TXDA_COEFF_CALC_CTRL);
529 writel(0, tcphy->base + TXDA_CYA_AUXDA_CYA); 551 writel(0, tcphy->base + TXDA_CYA_AUXDA_CYA);
530 552
531 /* Controls tx_high_z_tm_en */ 553 /* Controls tx_high_z_tm_en */
@@ -555,6 +577,7 @@ static int tcphy_phy_init(struct rockchip_typec_phy *tcphy, u8 mode)
555 reset_control_deassert(tcphy->tcphy_rst); 577 reset_control_deassert(tcphy->tcphy_rst);
556 578
557 property_enable(tcphy, &cfg->typec_conn_dir, tcphy->flip); 579 property_enable(tcphy, &cfg->typec_conn_dir, tcphy->flip);
580 tcphy_dp_aux_set_flip(tcphy);
558 581
559 tcphy_cfg_24m(tcphy); 582 tcphy_cfg_24m(tcphy);
560 583
@@ -685,8 +708,11 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
685 if (tcphy->mode == new_mode) 708 if (tcphy->mode == new_mode)
686 goto unlock_ret; 709 goto unlock_ret;
687 710
688 if (tcphy->mode == MODE_DISCONNECT) 711 if (tcphy->mode == MODE_DISCONNECT) {
689 tcphy_phy_init(tcphy, new_mode); 712 ret = tcphy_phy_init(tcphy, new_mode);
713 if (ret)
714 goto unlock_ret;
715 }
690 716
691 /* wait TCPHY for pipe ready */ 717 /* wait TCPHY for pipe ready */
692 for (timeout = 0; timeout < 100; timeout++) { 718 for (timeout = 0; timeout < 100; timeout++) {
@@ -760,10 +786,12 @@ static int rockchip_dp_phy_power_on(struct phy *phy)
760 */ 786 */
761 if (new_mode == MODE_DFP_DP && tcphy->mode != MODE_DISCONNECT) { 787 if (new_mode == MODE_DFP_DP && tcphy->mode != MODE_DISCONNECT) {
762 tcphy_phy_deinit(tcphy); 788 tcphy_phy_deinit(tcphy);
763 tcphy_phy_init(tcphy, new_mode); 789 ret = tcphy_phy_init(tcphy, new_mode);
764 } else if (tcphy->mode == MODE_DISCONNECT) { 790 } else if (tcphy->mode == MODE_DISCONNECT) {
765 tcphy_phy_init(tcphy, new_mode); 791 ret = tcphy_phy_init(tcphy, new_mode);
766 } 792 }
793 if (ret)
794 goto unlock_ret;
767 795
768 ret = readx_poll_timeout(readl, tcphy->base + DP_MODE_CTL, 796 ret = readx_poll_timeout(readl, tcphy->base + DP_MODE_CTL,
769 val, val & DP_MODE_A2, 1000, 797 val, val & DP_MODE_A2, 1000,
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 3cbcb2537657..4307bf0013e1 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -454,6 +454,8 @@ tegra_xusb_find_port_node(struct tegra_xusb_padctl *padctl, const char *type,
454 char *name; 454 char *name;
455 455
456 name = kasprintf(GFP_KERNEL, "%s-%u", type, index); 456 name = kasprintf(GFP_KERNEL, "%s-%u", type, index);
457 if (!name)
458 return ERR_PTR(-ENOMEM);
457 np = of_find_node_by_name(np, name); 459 np = of_find_node_by_name(np, name);
458 kfree(name); 460 kfree(name);
459 } 461 }