aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2017-10-12 13:04:17 -0400
committerThierry Reding <treding@nvidia.com>2017-12-13 08:16:39 -0500
commit880cee0b7ff379ebcf1f3d839fa59d1bcd726797 (patch)
tree0140c82e5ed33d68057c25e80195961a9b07fd2a
parent7772fdaef939891d790c3461a4d1681417e0f51f (diff)
drm/tegra: sor: Parameterize register offsets
Future Tegra generations have an increased number of display controllers that can drive individual SORs. In order to support that, the offset and layout of some registers has changed in backwards-incompatible ways. Use parameterized register offsets to support this. Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/gpu/drm/tegra/sor.c203
1 files changed, 127 insertions, 76 deletions
diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 2fba6c2bd486..d51399587aca 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -144,12 +144,29 @@ static const struct tegra_sor_hdmi_settings tegra210_sor_hdmi_defaults[] = {
144}; 144};
145#endif 145#endif
146 146
147struct tegra_sor_regs {
148 unsigned int head_state0;
149 unsigned int head_state1;
150 unsigned int head_state2;
151 unsigned int head_state3;
152 unsigned int head_state4;
153 unsigned int head_state5;
154 unsigned int pll0;
155 unsigned int pll1;
156 unsigned int pll2;
157 unsigned int pll3;
158 unsigned int dp_padctl0;
159 unsigned int dp_padctl2;
160};
161
147struct tegra_sor_soc { 162struct tegra_sor_soc {
148 bool supports_edp; 163 bool supports_edp;
149 bool supports_lvds; 164 bool supports_lvds;
150 bool supports_hdmi; 165 bool supports_hdmi;
151 bool supports_dp; 166 bool supports_dp;
152 167
168 const struct tegra_sor_regs *regs;
169
153 const struct tegra_sor_hdmi_settings *settings; 170 const struct tegra_sor_hdmi_settings *settings;
154 unsigned int num_settings; 171 unsigned int num_settings;
155 172
@@ -387,23 +404,23 @@ static int tegra_sor_dp_train_fast(struct tegra_sor *sor,
387 /* disable LVDS mode */ 404 /* disable LVDS mode */
388 tegra_sor_writel(sor, 0, SOR_LVDS); 405 tegra_sor_writel(sor, 0, SOR_LVDS);
389 406
390 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 407 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
391 value |= SOR_DP_PADCTL_TX_PU_ENABLE; 408 value |= SOR_DP_PADCTL_TX_PU_ENABLE;
392 value &= ~SOR_DP_PADCTL_TX_PU_MASK; 409 value &= ~SOR_DP_PADCTL_TX_PU_MASK;
393 value |= SOR_DP_PADCTL_TX_PU(2); /* XXX: don't hardcode? */ 410 value |= SOR_DP_PADCTL_TX_PU(2); /* XXX: don't hardcode? */
394 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 411 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
395 412
396 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 413 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
397 value |= SOR_DP_PADCTL_CM_TXD_3 | SOR_DP_PADCTL_CM_TXD_2 | 414 value |= SOR_DP_PADCTL_CM_TXD_3 | SOR_DP_PADCTL_CM_TXD_2 |
398 SOR_DP_PADCTL_CM_TXD_1 | SOR_DP_PADCTL_CM_TXD_0; 415 SOR_DP_PADCTL_CM_TXD_1 | SOR_DP_PADCTL_CM_TXD_0;
399 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 416 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
400 417
401 usleep_range(10, 100); 418 usleep_range(10, 100);
402 419
403 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 420 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
404 value &= ~(SOR_DP_PADCTL_CM_TXD_3 | SOR_DP_PADCTL_CM_TXD_2 | 421 value &= ~(SOR_DP_PADCTL_CM_TXD_3 | SOR_DP_PADCTL_CM_TXD_2 |
405 SOR_DP_PADCTL_CM_TXD_1 | SOR_DP_PADCTL_CM_TXD_0); 422 SOR_DP_PADCTL_CM_TXD_1 | SOR_DP_PADCTL_CM_TXD_0);
406 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 423 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
407 424
408 err = drm_dp_aux_prepare(sor->aux, DP_SET_ANSI_8B10B); 425 err = drm_dp_aux_prepare(sor->aux, DP_SET_ANSI_8B10B);
409 if (err < 0) 426 if (err < 0)
@@ -895,31 +912,31 @@ static void tegra_sor_mode_set(struct tegra_sor *sor,
895 */ 912 */
896 913
897 value = ((mode->vtotal & 0x7fff) << 16) | (mode->htotal & 0x7fff); 914 value = ((mode->vtotal & 0x7fff) << 16) | (mode->htotal & 0x7fff);
898 tegra_sor_writel(sor, value, SOR_HEAD_STATE1(dc->pipe)); 915 tegra_sor_writel(sor, value, sor->soc->regs->head_state1 + dc->pipe);
899 916
900 /* sync end = sync width - 1 */ 917 /* sync end = sync width - 1 */
901 vse = mode->vsync_end - mode->vsync_start - 1; 918 vse = mode->vsync_end - mode->vsync_start - 1;
902 hse = mode->hsync_end - mode->hsync_start - 1; 919 hse = mode->hsync_end - mode->hsync_start - 1;
903 920
904 value = ((vse & 0x7fff) << 16) | (hse & 0x7fff); 921 value = ((vse & 0x7fff) << 16) | (hse & 0x7fff);
905 tegra_sor_writel(sor, value, SOR_HEAD_STATE2(dc->pipe)); 922 tegra_sor_writel(sor, value, sor->soc->regs->head_state2 + dc->pipe);
906 923
907 /* blank end = sync end + back porch */ 924 /* blank end = sync end + back porch */
908 vbe = vse + (mode->vtotal - mode->vsync_end); 925 vbe = vse + (mode->vtotal - mode->vsync_end);
909 hbe = hse + (mode->htotal - mode->hsync_end); 926 hbe = hse + (mode->htotal - mode->hsync_end);
910 927
911 value = ((vbe & 0x7fff) << 16) | (hbe & 0x7fff); 928 value = ((vbe & 0x7fff) << 16) | (hbe & 0x7fff);
912 tegra_sor_writel(sor, value, SOR_HEAD_STATE3(dc->pipe)); 929 tegra_sor_writel(sor, value, sor->soc->regs->head_state3 + dc->pipe);
913 930
914 /* blank start = blank end + active */ 931 /* blank start = blank end + active */
915 vbs = vbe + mode->vdisplay; 932 vbs = vbe + mode->vdisplay;
916 hbs = hbe + mode->hdisplay; 933 hbs = hbe + mode->hdisplay;
917 934
918 value = ((vbs & 0x7fff) << 16) | (hbs & 0x7fff); 935 value = ((vbs & 0x7fff) << 16) | (hbs & 0x7fff);
919 tegra_sor_writel(sor, value, SOR_HEAD_STATE4(dc->pipe)); 936 tegra_sor_writel(sor, value, sor->soc->regs->head_state4 + dc->pipe);
920 937
921 /* XXX interlacing support */ 938 /* XXX interlacing support */
922 tegra_sor_writel(sor, 0x001, SOR_HEAD_STATE5(dc->pipe)); 939 tegra_sor_writel(sor, 0x001, sor->soc->regs->head_state5 + dc->pipe);
923} 940}
924 941
925static int tegra_sor_detach(struct tegra_sor *sor) 942static int tegra_sor_detach(struct tegra_sor *sor)
@@ -1001,10 +1018,10 @@ static int tegra_sor_power_down(struct tegra_sor *sor)
1001 return err; 1018 return err;
1002 } 1019 }
1003 1020
1004 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 1021 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
1005 value &= ~(SOR_DP_PADCTL_PD_TXD_3 | SOR_DP_PADCTL_PD_TXD_0 | 1022 value &= ~(SOR_DP_PADCTL_PD_TXD_3 | SOR_DP_PADCTL_PD_TXD_0 |
1006 SOR_DP_PADCTL_PD_TXD_1 | SOR_DP_PADCTL_PD_TXD_2); 1023 SOR_DP_PADCTL_PD_TXD_1 | SOR_DP_PADCTL_PD_TXD_2);
1007 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 1024 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
1008 1025
1009 /* stop lane sequencer */ 1026 /* stop lane sequencer */
1010 value = SOR_LANE_SEQ_CTL_TRIGGER | SOR_LANE_SEQ_CTL_SEQUENCE_UP | 1027 value = SOR_LANE_SEQ_CTL_TRIGGER | SOR_LANE_SEQ_CTL_SEQUENCE_UP |
@@ -1024,20 +1041,20 @@ static int tegra_sor_power_down(struct tegra_sor *sor)
1024 if ((value & SOR_LANE_SEQ_CTL_TRIGGER) != 0) 1041 if ((value & SOR_LANE_SEQ_CTL_TRIGGER) != 0)
1025 return -ETIMEDOUT; 1042 return -ETIMEDOUT;
1026 1043
1027 value = tegra_sor_readl(sor, SOR_PLL2); 1044 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1028 value |= SOR_PLL2_PORT_POWERDOWN; 1045 value |= SOR_PLL2_PORT_POWERDOWN;
1029 tegra_sor_writel(sor, value, SOR_PLL2); 1046 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
1030 1047
1031 usleep_range(20, 100); 1048 usleep_range(20, 100);
1032 1049
1033 value = tegra_sor_readl(sor, SOR_PLL0); 1050 value = tegra_sor_readl(sor, sor->soc->regs->pll0);
1034 value |= SOR_PLL0_VCOPD | SOR_PLL0_PWR; 1051 value |= SOR_PLL0_VCOPD | SOR_PLL0_PWR;
1035 tegra_sor_writel(sor, value, SOR_PLL0); 1052 tegra_sor_writel(sor, value, sor->soc->regs->pll0);
1036 1053
1037 value = tegra_sor_readl(sor, SOR_PLL2); 1054 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1038 value |= SOR_PLL2_SEQ_PLLCAPPD; 1055 value |= SOR_PLL2_SEQ_PLLCAPPD;
1039 value |= SOR_PLL2_SEQ_PLLCAPPD_ENFORCE; 1056 value |= SOR_PLL2_SEQ_PLLCAPPD_ENFORCE;
1040 tegra_sor_writel(sor, value, SOR_PLL2); 1057 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
1041 1058
1042 usleep_range(20, 100); 1059 usleep_range(20, 100);
1043 1060
@@ -1528,40 +1545,40 @@ static void tegra_sor_edp_enable(struct drm_encoder *encoder)
1528 value |= SOR_CLK_CNTRL_DP_CLK_SEL_SINGLE_DPCLK; 1545 value |= SOR_CLK_CNTRL_DP_CLK_SEL_SINGLE_DPCLK;
1529 tegra_sor_writel(sor, value, SOR_CLK_CNTRL); 1546 tegra_sor_writel(sor, value, SOR_CLK_CNTRL);
1530 1547
1531 value = tegra_sor_readl(sor, SOR_PLL2); 1548 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1532 value &= ~SOR_PLL2_BANDGAP_POWERDOWN; 1549 value &= ~SOR_PLL2_BANDGAP_POWERDOWN;
1533 tegra_sor_writel(sor, value, SOR_PLL2); 1550 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
1534 usleep_range(20, 100); 1551 usleep_range(20, 100);
1535 1552
1536 value = tegra_sor_readl(sor, SOR_PLL3); 1553 value = tegra_sor_readl(sor, sor->soc->regs->pll3);
1537 value |= SOR_PLL3_PLL_VDD_MODE_3V3; 1554 value |= SOR_PLL3_PLL_VDD_MODE_3V3;
1538 tegra_sor_writel(sor, value, SOR_PLL3); 1555 tegra_sor_writel(sor, value, sor->soc->regs->pll3);
1539 1556
1540 value = SOR_PLL0_ICHPMP(0xf) | SOR_PLL0_VCOCAP_RST | 1557 value = SOR_PLL0_ICHPMP(0xf) | SOR_PLL0_VCOCAP_RST |
1541 SOR_PLL0_PLLREG_LEVEL_V45 | SOR_PLL0_RESISTOR_EXT; 1558 SOR_PLL0_PLLREG_LEVEL_V45 | SOR_PLL0_RESISTOR_EXT;
1542 tegra_sor_writel(sor, value, SOR_PLL0); 1559 tegra_sor_writel(sor, value, sor->soc->regs->pll0);
1543 1560
1544 value = tegra_sor_readl(sor, SOR_PLL2); 1561 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1545 value |= SOR_PLL2_SEQ_PLLCAPPD; 1562 value |= SOR_PLL2_SEQ_PLLCAPPD;
1546 value &= ~SOR_PLL2_SEQ_PLLCAPPD_ENFORCE; 1563 value &= ~SOR_PLL2_SEQ_PLLCAPPD_ENFORCE;
1547 value |= SOR_PLL2_LVDS_ENABLE; 1564 value |= SOR_PLL2_LVDS_ENABLE;
1548 tegra_sor_writel(sor, value, SOR_PLL2); 1565 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
1549 1566
1550 value = SOR_PLL1_TERM_COMPOUT | SOR_PLL1_TMDS_TERM; 1567 value = SOR_PLL1_TERM_COMPOUT | SOR_PLL1_TMDS_TERM;
1551 tegra_sor_writel(sor, value, SOR_PLL1); 1568 tegra_sor_writel(sor, value, sor->soc->regs->pll1);
1552 1569
1553 while (true) { 1570 while (true) {
1554 value = tegra_sor_readl(sor, SOR_PLL2); 1571 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1555 if ((value & SOR_PLL2_SEQ_PLLCAPPD_ENFORCE) == 0) 1572 if ((value & SOR_PLL2_SEQ_PLLCAPPD_ENFORCE) == 0)
1556 break; 1573 break;
1557 1574
1558 usleep_range(250, 1000); 1575 usleep_range(250, 1000);
1559 } 1576 }
1560 1577
1561 value = tegra_sor_readl(sor, SOR_PLL2); 1578 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1562 value &= ~SOR_PLL2_POWERDOWN_OVERRIDE; 1579 value &= ~SOR_PLL2_POWERDOWN_OVERRIDE;
1563 value &= ~SOR_PLL2_PORT_POWERDOWN; 1580 value &= ~SOR_PLL2_PORT_POWERDOWN;
1564 tegra_sor_writel(sor, value, SOR_PLL2); 1581 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
1565 1582
1566 /* 1583 /*
1567 * power up 1584 * power up
@@ -1574,18 +1591,18 @@ static void tegra_sor_edp_enable(struct drm_encoder *encoder)
1574 tegra_sor_writel(sor, value, SOR_CLK_CNTRL); 1591 tegra_sor_writel(sor, value, SOR_CLK_CNTRL);
1575 1592
1576 /* step 1 */ 1593 /* step 1 */
1577 value = tegra_sor_readl(sor, SOR_PLL2); 1594 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1578 value |= SOR_PLL2_SEQ_PLLCAPPD_ENFORCE | SOR_PLL2_PORT_POWERDOWN | 1595 value |= SOR_PLL2_SEQ_PLLCAPPD_ENFORCE | SOR_PLL2_PORT_POWERDOWN |
1579 SOR_PLL2_BANDGAP_POWERDOWN; 1596 SOR_PLL2_BANDGAP_POWERDOWN;
1580 tegra_sor_writel(sor, value, SOR_PLL2); 1597 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
1581 1598
1582 value = tegra_sor_readl(sor, SOR_PLL0); 1599 value = tegra_sor_readl(sor, sor->soc->regs->pll0);
1583 value |= SOR_PLL0_VCOPD | SOR_PLL0_PWR; 1600 value |= SOR_PLL0_VCOPD | SOR_PLL0_PWR;
1584 tegra_sor_writel(sor, value, SOR_PLL0); 1601 tegra_sor_writel(sor, value, sor->soc->regs->pll0);
1585 1602
1586 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 1603 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
1587 value &= ~SOR_DP_PADCTL_PAD_CAL_PD; 1604 value &= ~SOR_DP_PADCTL_PAD_CAL_PD;
1588 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 1605 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
1589 1606
1590 /* step 2 */ 1607 /* step 2 */
1591 err = tegra_io_rail_power_on(TEGRA_IO_RAIL_LVDS); 1608 err = tegra_io_rail_power_on(TEGRA_IO_RAIL_LVDS);
@@ -1595,28 +1612,28 @@ static void tegra_sor_edp_enable(struct drm_encoder *encoder)
1595 usleep_range(5, 100); 1612 usleep_range(5, 100);
1596 1613
1597 /* step 3 */ 1614 /* step 3 */
1598 value = tegra_sor_readl(sor, SOR_PLL2); 1615 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1599 value &= ~SOR_PLL2_BANDGAP_POWERDOWN; 1616 value &= ~SOR_PLL2_BANDGAP_POWERDOWN;
1600 tegra_sor_writel(sor, value, SOR_PLL2); 1617 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
1601 1618
1602 usleep_range(20, 100); 1619 usleep_range(20, 100);
1603 1620
1604 /* step 4 */ 1621 /* step 4 */
1605 value = tegra_sor_readl(sor, SOR_PLL0); 1622 value = tegra_sor_readl(sor, sor->soc->regs->pll0);
1606 value &= ~SOR_PLL0_VCOPD; 1623 value &= ~SOR_PLL0_VCOPD;
1607 value &= ~SOR_PLL0_PWR; 1624 value &= ~SOR_PLL0_PWR;
1608 tegra_sor_writel(sor, value, SOR_PLL0); 1625 tegra_sor_writel(sor, value, sor->soc->regs->pll0);
1609 1626
1610 value = tegra_sor_readl(sor, SOR_PLL2); 1627 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1611 value &= ~SOR_PLL2_SEQ_PLLCAPPD_ENFORCE; 1628 value &= ~SOR_PLL2_SEQ_PLLCAPPD_ENFORCE;
1612 tegra_sor_writel(sor, value, SOR_PLL2); 1629 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
1613 1630
1614 usleep_range(200, 1000); 1631 usleep_range(200, 1000);
1615 1632
1616 /* step 5 */ 1633 /* step 5 */
1617 value = tegra_sor_readl(sor, SOR_PLL2); 1634 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
1618 value &= ~SOR_PLL2_PORT_POWERDOWN; 1635 value &= ~SOR_PLL2_PORT_POWERDOWN;
1619 tegra_sor_writel(sor, value, SOR_PLL2); 1636 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
1620 1637
1621 /* XXX not in TRM */ 1638 /* XXX not in TRM */
1622 for (value = 0, i = 0; i < 5; i++) 1639 for (value = 0, i = 0; i < 5; i++)
@@ -1632,7 +1649,7 @@ static void tegra_sor_edp_enable(struct drm_encoder *encoder)
1632 dev_err(sor->dev, "failed to set parent clock: %d\n", err); 1649 dev_err(sor->dev, "failed to set parent clock: %d\n", err);
1633 1650
1634 /* power DP lanes */ 1651 /* power DP lanes */
1635 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 1652 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
1636 1653
1637 if (link.num_lanes <= 2) 1654 if (link.num_lanes <= 2)
1638 value &= ~(SOR_DP_PADCTL_PD_TXD_3 | SOR_DP_PADCTL_PD_TXD_2); 1655 value &= ~(SOR_DP_PADCTL_PD_TXD_3 | SOR_DP_PADCTL_PD_TXD_2);
@@ -1649,7 +1666,7 @@ static void tegra_sor_edp_enable(struct drm_encoder *encoder)
1649 else 1666 else
1650 value |= SOR_DP_PADCTL_PD_TXD_0; 1667 value |= SOR_DP_PADCTL_PD_TXD_0;
1651 1668
1652 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 1669 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
1653 1670
1654 value = tegra_sor_readl(sor, SOR_DP_LINKCTL0); 1671 value = tegra_sor_readl(sor, SOR_DP_LINKCTL0);
1655 value &= ~SOR_DP_LINKCTL_LANE_COUNT_MASK; 1672 value &= ~SOR_DP_LINKCTL_LANE_COUNT_MASK;
@@ -1693,9 +1710,9 @@ static void tegra_sor_edp_enable(struct drm_encoder *encoder)
1693 tegra_sor_writel(sor, value, SOR_DP_TPG); 1710 tegra_sor_writel(sor, value, SOR_DP_TPG);
1694 1711
1695 /* enable pad calibration logic */ 1712 /* enable pad calibration logic */
1696 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 1713 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
1697 value |= SOR_DP_PADCTL_PAD_CAL_PD; 1714 value |= SOR_DP_PADCTL_PAD_CAL_PD;
1698 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 1715 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
1699 1716
1700 err = drm_dp_link_probe(sor->aux, &link); 1717 err = drm_dp_link_probe(sor->aux, &link);
1701 if (err < 0) 1718 if (err < 0)
@@ -2017,38 +2034,38 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
2017 2034
2018 usleep_range(20, 100); 2035 usleep_range(20, 100);
2019 2036
2020 value = tegra_sor_readl(sor, SOR_PLL2); 2037 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
2021 value &= ~SOR_PLL2_BANDGAP_POWERDOWN; 2038 value &= ~SOR_PLL2_BANDGAP_POWERDOWN;
2022 tegra_sor_writel(sor, value, SOR_PLL2); 2039 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
2023 2040
2024 usleep_range(20, 100); 2041 usleep_range(20, 100);
2025 2042
2026 value = tegra_sor_readl(sor, SOR_PLL3); 2043 value = tegra_sor_readl(sor, sor->soc->regs->pll3);
2027 value &= ~SOR_PLL3_PLL_VDD_MODE_3V3; 2044 value &= ~SOR_PLL3_PLL_VDD_MODE_3V3;
2028 tegra_sor_writel(sor, value, SOR_PLL3); 2045 tegra_sor_writel(sor, value, sor->soc->regs->pll3);
2029 2046
2030 value = tegra_sor_readl(sor, SOR_PLL0); 2047 value = tegra_sor_readl(sor, sor->soc->regs->pll0);
2031 value &= ~SOR_PLL0_VCOPD; 2048 value &= ~SOR_PLL0_VCOPD;
2032 value &= ~SOR_PLL0_PWR; 2049 value &= ~SOR_PLL0_PWR;
2033 tegra_sor_writel(sor, value, SOR_PLL0); 2050 tegra_sor_writel(sor, value, sor->soc->regs->pll0);
2034 2051
2035 value = tegra_sor_readl(sor, SOR_PLL2); 2052 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
2036 value &= ~SOR_PLL2_SEQ_PLLCAPPD_ENFORCE; 2053 value &= ~SOR_PLL2_SEQ_PLLCAPPD_ENFORCE;
2037 tegra_sor_writel(sor, value, SOR_PLL2); 2054 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
2038 2055
2039 usleep_range(200, 400); 2056 usleep_range(200, 400);
2040 2057
2041 value = tegra_sor_readl(sor, SOR_PLL2); 2058 value = tegra_sor_readl(sor, sor->soc->regs->pll2);
2042 value &= ~SOR_PLL2_POWERDOWN_OVERRIDE; 2059 value &= ~SOR_PLL2_POWERDOWN_OVERRIDE;
2043 value &= ~SOR_PLL2_PORT_POWERDOWN; 2060 value &= ~SOR_PLL2_PORT_POWERDOWN;
2044 tegra_sor_writel(sor, value, SOR_PLL2); 2061 tegra_sor_writel(sor, value, sor->soc->regs->pll2);
2045 2062
2046 usleep_range(20, 100); 2063 usleep_range(20, 100);
2047 2064
2048 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 2065 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
2049 value |= SOR_DP_PADCTL_PD_TXD_3 | SOR_DP_PADCTL_PD_TXD_0 | 2066 value |= SOR_DP_PADCTL_PD_TXD_3 | SOR_DP_PADCTL_PD_TXD_0 |
2050 SOR_DP_PADCTL_PD_TXD_1 | SOR_DP_PADCTL_PD_TXD_2; 2067 SOR_DP_PADCTL_PD_TXD_1 | SOR_DP_PADCTL_PD_TXD_2;
2051 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 2068 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
2052 2069
2053 while (true) { 2070 while (true) {
2054 value = tegra_sor_readl(sor, SOR_LANE_SEQ_CTL); 2071 value = tegra_sor_readl(sor, SOR_LANE_SEQ_CTL);
@@ -2166,9 +2183,9 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
2166 tegra_sor_writel(sor, value, SOR_STATE1); 2183 tegra_sor_writel(sor, value, SOR_STATE1);
2167 2184
2168 /* power up pad calibration */ 2185 /* power up pad calibration */
2169 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 2186 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
2170 value &= ~SOR_DP_PADCTL_PAD_CAL_PD; 2187 value &= ~SOR_DP_PADCTL_PAD_CAL_PD;
2171 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 2188 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
2172 2189
2173 /* production settings */ 2190 /* production settings */
2174 settings = tegra_sor_hdmi_find_settings(sor, mode->clock * 1000); 2191 settings = tegra_sor_hdmi_find_settings(sor, mode->clock * 1000);
@@ -2178,24 +2195,24 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
2178 return; 2195 return;
2179 } 2196 }
2180 2197
2181 value = tegra_sor_readl(sor, SOR_PLL0); 2198 value = tegra_sor_readl(sor, sor->soc->regs->pll0);
2182 value &= ~SOR_PLL0_ICHPMP_MASK; 2199 value &= ~SOR_PLL0_ICHPMP_MASK;
2183 value &= ~SOR_PLL0_VCOCAP_MASK; 2200 value &= ~SOR_PLL0_VCOCAP_MASK;
2184 value |= SOR_PLL0_ICHPMP(settings->ichpmp); 2201 value |= SOR_PLL0_ICHPMP(settings->ichpmp);
2185 value |= SOR_PLL0_VCOCAP(settings->vcocap); 2202 value |= SOR_PLL0_VCOCAP(settings->vcocap);
2186 tegra_sor_writel(sor, value, SOR_PLL0); 2203 tegra_sor_writel(sor, value, sor->soc->regs->pll0);
2187 2204
2188 tegra_sor_dp_term_calibrate(sor); 2205 tegra_sor_dp_term_calibrate(sor);
2189 2206
2190 value = tegra_sor_readl(sor, SOR_PLL1); 2207 value = tegra_sor_readl(sor, sor->soc->regs->pll1);
2191 value &= ~SOR_PLL1_LOADADJ_MASK; 2208 value &= ~SOR_PLL1_LOADADJ_MASK;
2192 value |= SOR_PLL1_LOADADJ(settings->loadadj); 2209 value |= SOR_PLL1_LOADADJ(settings->loadadj);
2193 tegra_sor_writel(sor, value, SOR_PLL1); 2210 tegra_sor_writel(sor, value, sor->soc->regs->pll1);
2194 2211
2195 value = tegra_sor_readl(sor, SOR_PLL3); 2212 value = tegra_sor_readl(sor, sor->soc->regs->pll3);
2196 value &= ~SOR_PLL3_BG_VREF_LEVEL_MASK; 2213 value &= ~SOR_PLL3_BG_VREF_LEVEL_MASK;
2197 value |= SOR_PLL3_BG_VREF_LEVEL(settings->bg_vref); 2214 value |= SOR_PLL3_BG_VREF_LEVEL(settings->bg_vref);
2198 tegra_sor_writel(sor, value, SOR_PLL3); 2215 tegra_sor_writel(sor, value, sor->soc->regs->pll3);
2199 2216
2200 value = settings->drive_current[0] << 24 | 2217 value = settings->drive_current[0] << 24 |
2201 settings->drive_current[1] << 16 | 2218 settings->drive_current[1] << 16 |
@@ -2209,16 +2226,16 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
2209 settings->preemphasis[3] << 0; 2226 settings->preemphasis[3] << 0;
2210 tegra_sor_writel(sor, value, SOR_LANE_PREEMPHASIS0); 2227 tegra_sor_writel(sor, value, SOR_LANE_PREEMPHASIS0);
2211 2228
2212 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 2229 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
2213 value &= ~SOR_DP_PADCTL_TX_PU_MASK; 2230 value &= ~SOR_DP_PADCTL_TX_PU_MASK;
2214 value |= SOR_DP_PADCTL_TX_PU_ENABLE; 2231 value |= SOR_DP_PADCTL_TX_PU_ENABLE;
2215 value |= SOR_DP_PADCTL_TX_PU(settings->tx_pu); 2232 value |= SOR_DP_PADCTL_TX_PU(settings->tx_pu);
2216 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 2233 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
2217 2234
2218 /* power down pad calibration */ 2235 /* power down pad calibration */
2219 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); 2236 value = tegra_sor_readl(sor, sor->soc->regs->dp_padctl0);
2220 value |= SOR_DP_PADCTL_PAD_CAL_PD; 2237 value |= SOR_DP_PADCTL_PAD_CAL_PD;
2221 tegra_sor_writel(sor, value, SOR_DP_PADCTL0); 2238 tegra_sor_writel(sor, value, sor->soc->regs->dp_padctl0);
2222 2239
2223 /* miscellaneous display controller settings */ 2240 /* miscellaneous display controller settings */
2224 value = VSYNC_H_POSITION(1); 2241 value = VSYNC_H_POSITION(1);
@@ -2250,16 +2267,16 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
2250 dev_err(sor->dev, "failed to power up SOR: %d\n", err); 2267 dev_err(sor->dev, "failed to power up SOR: %d\n", err);
2251 2268
2252 /* configure dynamic range of output */ 2269 /* configure dynamic range of output */
2253 value = tegra_sor_readl(sor, SOR_HEAD_STATE0(dc->pipe)); 2270 value = tegra_sor_readl(sor, sor->soc->regs->head_state0 + dc->pipe);
2254 value &= ~SOR_HEAD_STATE_RANGECOMPRESS_MASK; 2271 value &= ~SOR_HEAD_STATE_RANGECOMPRESS_MASK;
2255 value &= ~SOR_HEAD_STATE_DYNRANGE_MASK; 2272 value &= ~SOR_HEAD_STATE_DYNRANGE_MASK;
2256 tegra_sor_writel(sor, value, SOR_HEAD_STATE0(dc->pipe)); 2273 tegra_sor_writel(sor, value, sor->soc->regs->head_state0 + dc->pipe);
2257 2274
2258 /* configure colorspace */ 2275 /* configure colorspace */
2259 value = tegra_sor_readl(sor, SOR_HEAD_STATE0(dc->pipe)); 2276 value = tegra_sor_readl(sor, sor->soc->regs->head_state0 + dc->pipe);
2260 value &= ~SOR_HEAD_STATE_COLORSPACE_MASK; 2277 value &= ~SOR_HEAD_STATE_COLORSPACE_MASK;
2261 value |= SOR_HEAD_STATE_COLORSPACE_RGB; 2278 value |= SOR_HEAD_STATE_COLORSPACE_RGB;
2262 tegra_sor_writel(sor, value, SOR_HEAD_STATE0(dc->pipe)); 2279 tegra_sor_writel(sor, value, sor->soc->regs->head_state0 + dc->pipe);
2263 2280
2264 tegra_sor_mode_set(sor, mode, state); 2281 tegra_sor_mode_set(sor, mode, state);
2265 2282
@@ -2488,19 +2505,51 @@ static const u8 tegra124_sor_xbar_cfg[5] = {
2488 0, 1, 2, 3, 4 2505 0, 1, 2, 3, 4
2489}; 2506};
2490 2507
2508static const struct tegra_sor_regs tegra124_sor_regs = {
2509 .head_state0 = 0x05,
2510 .head_state1 = 0x07,
2511 .head_state2 = 0x09,
2512 .head_state3 = 0x0b,
2513 .head_state4 = 0x0d,
2514 .head_state5 = 0x0f,
2515 .pll0 = 0x17,
2516 .pll1 = 0x18,
2517 .pll2 = 0x19,
2518 .pll3 = 0x1a,
2519 .dp_padctl0 = 0x5c,
2520 .dp_padctl2 = 0x73,
2521};
2522
2491static const struct tegra_sor_soc tegra124_sor = { 2523static const struct tegra_sor_soc tegra124_sor = {
2492 .supports_edp = true, 2524 .supports_edp = true,
2493 .supports_lvds = true, 2525 .supports_lvds = true,
2494 .supports_hdmi = false, 2526 .supports_hdmi = false,
2495 .supports_dp = false, 2527 .supports_dp = false,
2528 .regs = &tegra124_sor_regs,
2496 .xbar_cfg = tegra124_sor_xbar_cfg, 2529 .xbar_cfg = tegra124_sor_xbar_cfg,
2497}; 2530};
2498 2531
2532static const struct tegra_sor_regs tegra210_sor_regs = {
2533 .head_state0 = 0x05,
2534 .head_state1 = 0x07,
2535 .head_state2 = 0x09,
2536 .head_state3 = 0x0b,
2537 .head_state4 = 0x0d,
2538 .head_state5 = 0x0f,
2539 .pll0 = 0x17,
2540 .pll1 = 0x18,
2541 .pll2 = 0x19,
2542 .pll3 = 0x1a,
2543 .dp_padctl0 = 0x5c,
2544 .dp_padctl2 = 0x73,
2545};
2546
2499static const struct tegra_sor_soc tegra210_sor = { 2547static const struct tegra_sor_soc tegra210_sor = {
2500 .supports_edp = true, 2548 .supports_edp = true,
2501 .supports_lvds = false, 2549 .supports_lvds = false,
2502 .supports_hdmi = false, 2550 .supports_hdmi = false,
2503 .supports_dp = false, 2551 .supports_dp = false,
2552 .regs = &tegra210_sor_regs,
2504 .xbar_cfg = tegra124_sor_xbar_cfg, 2553 .xbar_cfg = tegra124_sor_xbar_cfg,
2505}; 2554};
2506 2555
@@ -2514,6 +2563,8 @@ static const struct tegra_sor_soc tegra210_sor1 = {
2514 .supports_hdmi = true, 2563 .supports_hdmi = true,
2515 .supports_dp = true, 2564 .supports_dp = true,
2516 2565
2566 .regs = &tegra210_sor_regs,
2567
2517 .num_settings = ARRAY_SIZE(tegra210_sor_hdmi_defaults), 2568 .num_settings = ARRAY_SIZE(tegra210_sor_hdmi_defaults),
2518 .settings = tegra210_sor_hdmi_defaults, 2569 .settings = tegra210_sor_hdmi_defaults,
2519 2570