Skip to content

Commit 3d50b59

Browse files
mediatek-jitaoChun-Kuang Hu
authored andcommitted
drm/mediatek: add the mipitx driving control
Add a property in device tree to control the driving by different board. Reviewed-by: Matthias Brugger <[email protected]> Signed-off-by: Jitao Shi <[email protected]> Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 6d3a4ae commit 3d50b59

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

drivers/gpu/drm/mediatek/mtk_mipi_tx.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@ static int mtk_mipi_tx_probe(struct platform_device *pdev)
125125
return ret;
126126
}
127127

128+
ret = of_property_read_u32(dev->of_node, "drive-strength-microamp",
129+
&mipi_tx->mipitx_drive);
130+
/* If can't get the "mipi_tx->mipitx_drive", set it default 0x8 */
131+
if (ret < 0)
132+
mipi_tx->mipitx_drive = 4600;
133+
134+
/* check the mipitx_drive valid */
135+
if (mipi_tx->mipitx_drive > 6000 || mipi_tx->mipitx_drive < 3000) {
136+
dev_warn(dev, "drive-strength-microamp is invalid %d, not in 3000 ~ 6000\n",
137+
mipi_tx->mipitx_drive);
138+
mipi_tx->mipitx_drive = clamp_val(mipi_tx->mipitx_drive, 3000,
139+
6000);
140+
}
141+
128142
ref_clk_name = __clk_get_name(ref_clk);
129143

130144
ret = of_property_read_string(dev->of_node, "clock-output-names",

drivers/gpu/drm/mediatek/mtk_mipi_tx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct mtk_mipi_tx {
2727
struct device *dev;
2828
void __iomem *regs;
2929
u32 data_rate;
30+
u32 mipitx_drive;
3031
const struct mtk_mipitx_data *driver_data;
3132
struct clk_hw pll_hw;
3233
struct clk *pll;

drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#define RG_DSI_BG_CORE_EN BIT(7)
1818
#define RG_DSI_PAD_TIEL_SEL BIT(8)
1919

20+
#define MIPITX_VOLTAGE_SEL 0x0010
21+
#define RG_DSI_HSTX_LDO_REF_SEL (0xf << 6)
22+
2023
#define MIPITX_PLL_PWR 0x0028
2124
#define MIPITX_PLL_CON0 0x002c
2225
#define MIPITX_PLL_CON1 0x0030
@@ -123,6 +126,10 @@ static void mtk_mipi_tx_power_on_signal(struct phy *phy)
123126
mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_D3_SW_CTL_EN, DSI_SW_CTL_EN);
124127
mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_CK_SW_CTL_EN, DSI_SW_CTL_EN);
125128

129+
mtk_mipi_tx_update_bits(mipi_tx, MIPITX_VOLTAGE_SEL,
130+
RG_DSI_HSTX_LDO_REF_SEL,
131+
(mipi_tx->mipitx_drive - 3000) / 200 << 6);
132+
126133
mtk_mipi_tx_set_bits(mipi_tx, MIPITX_CK_CKMODE_EN, DSI_CK_CKMODE_EN);
127134
}
128135

0 commit comments

Comments
 (0)