2 * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
17 #define EDP_MAX_LANE 4
23 bool msm_edp_phy_ready(struct edp_phy
*phy
)
29 status
= edp_read(phy
->base
+
30 REG_EDP_PHY_GLB_PHY_STATUS
);
33 usleep_range(500, 1000);
37 pr_err("%s: PHY NOT ready\n", __func__
);
44 void msm_edp_phy_ctrl(struct edp_phy
*phy
, int enable
)
46 DBG("enable=%d", enable
);
49 edp_write(phy
->base
+ REG_EDP_PHY_CTRL
,
50 EDP_PHY_CTRL_SW_RESET
| EDP_PHY_CTRL_SW_RESET_PLL
);
51 /* Make sure fully reset */
53 usleep_range(500, 1000);
54 edp_write(phy
->base
+ REG_EDP_PHY_CTRL
, 0x000);
55 edp_write(phy
->base
+ REG_EDP_PHY_GLB_PD_CTL
, 0x3f);
56 edp_write(phy
->base
+ REG_EDP_PHY_GLB_CFG
, 0x1);
58 edp_write(phy
->base
+ REG_EDP_PHY_GLB_PD_CTL
, 0xc0);
62 /* voltage mode and pre emphasis cfg */
63 void msm_edp_phy_vm_pe_init(struct edp_phy
*phy
)
65 edp_write(phy
->base
+ REG_EDP_PHY_GLB_VM_CFG0
, 0x3);
66 edp_write(phy
->base
+ REG_EDP_PHY_GLB_VM_CFG1
, 0x64);
67 edp_write(phy
->base
+ REG_EDP_PHY_GLB_MISC9
, 0x6c);
70 void msm_edp_phy_vm_pe_cfg(struct edp_phy
*phy
, u32 v0
, u32 v1
)
72 edp_write(phy
->base
+ REG_EDP_PHY_GLB_VM_CFG0
, v0
);
73 edp_write(phy
->base
+ REG_EDP_PHY_GLB_VM_CFG1
, v1
);
76 void msm_edp_phy_lane_power_ctrl(struct edp_phy
*phy
, bool up
, u32 max_lane
)
82 data
= 0; /* power up */
84 data
= 0x7; /* power down */
86 for (i
= 0; i
< max_lane
; i
++)
87 edp_write(phy
->base
+ REG_EDP_PHY_LN_PD_CTL(i
) , data
);
89 /* power down unused lane */
90 data
= 0x7; /* power down */
91 for (i
= max_lane
; i
< EDP_MAX_LANE
; i
++)
92 edp_write(phy
->base
+ REG_EDP_PHY_LN_PD_CTL(i
) , data
);
95 void *msm_edp_phy_init(struct device
*dev
, void __iomem
*regbase
)
97 struct edp_phy
*phy
= NULL
;
99 phy
= devm_kzalloc(dev
, sizeof(*phy
), GFP_KERNEL
);