#include <linux/seq_file.h>
#endif
-//#define EDP_BIST_MODE
+/*#define EDP_BIST_MODE*/
static struct rk32_edp *rk32_edp;
static int rk32_edp_pre_init(void)
{
u32 val;
- val = GRF_EDP_REF_CLK_SEL_INTER |
- (GRF_EDP_REF_CLK_SEL_INTER << 16);
+ val = GRF_EDP_REF_CLK_SEL_INTER | (GRF_EDP_REF_CLK_SEL_INTER << 16);
writel_relaxed(val, RK_GRF_VIRT + RK3288_GRF_SOC_CON12);
val = 0x80008000;
{
struct rk_screen *screen = &edp->screen;
u32 val = 0;
-
+
screen->lcdc_id = 1;
if (screen->lcdc_id == 1) /*select lcdc*/
val = EDP_SEL_VOP_LIT | (EDP_SEL_VOP_LIT << 16);
val = EDP_SEL_VOP_LIT << 16;
writel_relaxed(val, RK_GRF_VIRT + RK3288_GRF_SOC_CON6);
-
rk32_edp_reset(edp);
rk32_edp_init_refclk(edp);
rk32_edp_init_interrupt(edp);
-
rk32_edp_enable_sw_function(edp);
-
rk32_edp_init_analog_func(edp);
-
rk32_edp_init_hpd(edp);
rk32_edp_init_aux(edp);
*/
/* Read Extension Flag, Number of 128-byte EDID extension blocks */
- retval = rk32_edp_read_byte_from_i2c(edp, EDID_ADDR, EDID_EXTENSION_FLAG,
- &extend_block);
+ retval = rk32_edp_read_byte_from_i2c(edp,
+ EDID_ADDR, EDID_EXTENSION_FLAG, &extend_block);
if (retval < 0) {
dev_err(edp->dev, "EDID extension flag failed!\n");
return -EIO;
dev_dbg(edp->dev, "EDID data includes a single extension!\n");
/* Read EDID data */
- retval = rk32_edp_read_bytes_from_i2c(edp, EDID_ADDR, EDID_HEADER,
- EDID_LENGTH, &edid[EDID_HEADER]);
+ retval = rk32_edp_read_bytes_from_i2c(edp,
+ EDID_ADDR, EDID_HEADER,
+ EDID_LENGTH, &edid[EDID_HEADER]);
if (retval != 0) {
dev_err(edp->dev, "EDID Read failed!\n");
return -EIO;
}
/* Read additional EDID data */
- retval = rk32_edp_read_bytes_from_i2c(edp, EDID_ADDR, EDID_LENGTH,
- EDID_LENGTH, &edid[EDID_LENGTH]);
+ retval = rk32_edp_read_bytes_from_i2c(edp,
+ EDID_ADDR, EDID_LENGTH,
+ EDID_LENGTH, &edid[EDID_LENGTH]);
if (retval != 0) {
dev_err(edp->dev, "EDID Read failed!\n");
return -EIO;
return 0;
}
- retval = rk32_edp_read_byte_from_dpcd(edp, DPCD_TEST_REQUEST,
- &test_vector);
+ retval = rk32_edp_read_byte_from_dpcd(edp,
+ DPCD_TEST_REQUEST, &test_vector);
if (retval < 0) {
dev_err(edp->dev, "DPCD EDID Read failed!\n");
return retval;
dev_info(edp->dev, "EDID data does not include any extensions.\n");
/* Read EDID data */
- retval = rk32_edp_read_bytes_from_i2c(edp, EDID_ADDR, EDID_HEADER,
- EDID_LENGTH, &edid[EDID_HEADER]);
+ retval = rk32_edp_read_bytes_from_i2c(edp,
+ EDID_ADDR, EDID_HEADER,
+ EDID_LENGTH, &edid[EDID_HEADER]);
if (retval != 0) {
dev_err(edp->dev, "EDID Read failed!\n");
return -EIO;
return 0;
}
- retval = rk32_edp_read_byte_from_dpcd(edp,DPCD_TEST_REQUEST,
- &test_vector);
+ retval = rk32_edp_read_byte_from_dpcd(edp,
+ DPCD_TEST_REQUEST, &test_vector);
if (retval < 0) {
dev_err(edp->dev, "DPCD EDID Read failed!\n");
return retval;
if (retval < 0)
return retval;
- for (i=0 ;i < 12; i++)
+ for (i = 0; i < 12; i++)
dev_info(edp->dev, "%d:>>0x%02x\n", i, buf[i]);
/* Read EDID */
for (i = 0; i < 3; i++) {
*/
rk32_edp_reset_macro(edp);
-
- retval = rk32_edp_get_max_rx_bandwidth(edp, &edp->link_train.link_rate);
- retval = rk32_edp_get_max_rx_lane_count(edp, &edp->link_train.lane_count);
+
+ retval = rk32_edp_get_max_rx_bandwidth(edp,
+ &edp->link_train.link_rate);
+ retval = rk32_edp_get_max_rx_lane_count(edp,
+ &edp->link_train.lane_count);
dev_info(edp->dev, "max link rate:%d.%dGps max number of lanes:%d\n",
edp->link_train.link_rate * 27/100,
edp->link_train.link_rate*27%100,
edp->link_train.lane_count);
-
+
if ((edp->link_train.link_rate != LINK_RATE_1_62GBPS) &&
(edp->link_train.link_rate != LINK_RATE_2_70GBPS)) {
dev_warn(edp->dev, "Rx Max Link Rate is abnormal :%x !"
}
rk32_edp_analog_power_ctr(edp, 1);
-
+
return 0;
}
mdelay(1);
val = rk32_edp_wait_hw_lt_done(edp);
}
-
+
val = rk32_edp_get_hw_lt_status(edp);
if (val)
dev_err(edp->dev, "hw lt err:%d\n", val);
return val;
-
+
}
static int rk32_edp_set_link_train(struct rk32_edp *edp)
{
return -ETIMEDOUT;
}
- usleep_range(1, 1);
+ udelay(1);
}
/* Set to use the register calculated M/N video */
return -ETIMEDOUT;
}
- usleep_range(1000, 1000);
+ mdelay(1);
}
if (retval != 0)
{
int ret = 0;
struct rk32_edp *edp = rk32_edp;
-
+
rk32_edp_clk_enable(edp);
rk32_edp_pre_init();
//goto out;
}
-
+
ret = rk32_edp_enable_scramble(edp, 0);
if (ret) {
dev_err(edp->dev, "unable to set scramble\n");
rk32_edp_enable_enhanced_mode(edp, 1);*/
ret = rk32_edp_set_link_train(edp);
- if (ret)
+ if (ret)
dev_err(edp->dev, "link train failed!\n");
- else
+ else
dev_info(edp->dev, "link training success.\n");
rk32_edp_set_lane_count(edp, edp->link_train.lane_count);
return ret;
-
+
}
-
-static int rk32_edp_disable(void )
+
+static int rk32_edp_disable(void)
{
struct rk32_edp *edp = rk32_edp;
rk32_edp_reset(edp);
rk32_edp_analog_power_ctr(edp, 0);
rk32_edp_clk_disable(edp);
-
+
return 0;
}
dev_err(edp->dev, "no edp device!\n");
return -ENODEV;
}
-
-
+
+
rk32_edp_read_bytes_from_dpcd(edp,
DPCD_SYMBOL_ERR_CONUT_LANE0, 12, buf);
- for (i=0;i< 12;i++) {
- seq_printf(s,"0x%02x>>0x%02x\n",0x210 + i, buf[i]);
- }
+ for (i = 0; i < 12; i++)
+ seq_printf(s, "0x%02x>>0x%02x\n", 0x210 + i, buf[i]);
return 0;
}
return -ENODEV;
}
rk32_edp_read_edid(edp);
- seq_printf(s,"edid");
+ seq_puts(s, "edid");
return 0;
}
}
platform_set_drvdata(pdev, edp);
dev_set_name(edp->dev, "rk32-edp");
-
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
edp->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(edp->regs)) {
return PTR_ERR(edp->regs);
}
- edp->pd = devm_clk_get(&pdev->dev,"pd_edp");
- if (IS_ERR(edp->pd)) {
+ edp->pd = devm_clk_get(&pdev->dev, "pd_edp");
+ if (IS_ERR(edp->pd))
dev_err(&pdev->dev, "cannot get pd\n");
- }
- edp->clk_edp = devm_clk_get(&pdev->dev,"clk_edp");
+ edp->clk_edp = devm_clk_get(&pdev->dev, "clk_edp");
if (IS_ERR(edp->clk_edp)) {
dev_err(&pdev->dev, "cannot get clk_edp\n");
return PTR_ERR(edp->clk_edp);
}
- edp->clk_24m = devm_clk_get(&pdev->dev,"clk_edp_24m");
+ edp->clk_24m = devm_clk_get(&pdev->dev, "clk_edp_24m");
if (IS_ERR(edp->clk_24m)) {
dev_err(&pdev->dev, "cannot get clk_edp_24m\n");
return PTR_ERR(edp->clk_24m);
}
- edp->pclk = devm_clk_get(&pdev->dev,"pclk_edp");
+ edp->pclk = devm_clk_get(&pdev->dev, "pclk_edp");
if (IS_ERR(edp->pclk)) {
dev_err(&pdev->dev, "cannot get pclk\n");
return PTR_ERR(edp->pclk);
if (IS_ERR(edp->debugfs_dir)) {
dev_err(edp->dev, "failed to create debugfs dir for edp!\n");
} else {
- debugfs_create_file("dpcd", S_IRUSR,edp->debugfs_dir,
+ debugfs_create_file("dpcd", S_IRUSR, edp->debugfs_dir,
edp, &edp_dpcd_debugfs_fops);
- debugfs_create_file("edid", S_IRUSR,edp->debugfs_dir,
+ debugfs_create_file("edid", S_IRUSR, edp->debugfs_dir,
edp, &edp_edid_debugfs_fops);
- debugfs_create_file("reg", S_IRUSR,edp->debugfs_dir,
+ debugfs_create_file("reg", S_IRUSR, edp->debugfs_dir,
edp, &edp_reg_debugfs_fops);
}
-
+
#endif
dev_info(&pdev->dev, "rk32 edp driver probe success\n");
{
u32 val;
-
+
if (enable)
val = LANE3_MAP_LOGIC_LANE_0 | LANE2_MAP_LOGIC_LANE_1 |
LANE1_MAP_LOGIC_LANE_2 | LANE0_MAP_LOGIC_LANE_3;
else
val = LANE3_MAP_LOGIC_LANE_3 | LANE2_MAP_LOGIC_LANE_2 |
LANE1_MAP_LOGIC_LANE_1 | LANE0_MAP_LOGIC_LANE_0;
-
+
writel(val, edp->regs + LANE_MAP);
}
val = 0x58;
writel(val, edp->regs + PLL_REG_4);
-
+
val = 0x22;
writel(val, edp->regs + PLL_REG_5);
-
+
val = 0x19;
writel(val, edp->regs + SSC_REG);
val = 0x87;
writel(val, edp->regs + DP_BIAS);
val = 0x55;
writel(val, edp->regs + DP_RESERVE2);
-
-
+
+
/*val = DRIVE_DVDD_BIT_1_0625V | VCO_BIT_600_MICRO;
writel(val, edp->regs + ANALOG_CTL_3);
writel(0x4f, edp->regs + COMMON_INT_STA_2);
writel(0xff, edp->regs + COMMON_INT_STA_3);
writel(0x27, edp->regs + COMMON_INT_STA_4);
-
+
writel(0x7f, edp->regs + DP_INT_STA);
/* 0:mask,1: unmask */
{
u32 val;
- //writel(RST_DP_TX, edp->regs + TX_SW_RST);
-
rk32_edp_stop_video(edp);
rk32_edp_enable_video_mute(edp, 0);
PD_CH3 | PD_CH2 | PD_CH1 | PD_CH0;
writel(val, edp->regs + DP_PWRDN);
udelay(10);
- writel(0x0,edp->regs + DP_PWRDN);
+ writel(0x0, edp->regs + DP_PWRDN);
} else {
val = PD_EXP_BG | PD_AUX | PD_PLL |
PD_CH3 | PD_CH2 | PD_CH1 | PD_CH0;
} else {
wt++;
udelay(5);
- }
+ }
}
/* Enable Serdes FIFO function and Link symbol clock domain module */
*bwtype = val;
}
-void rk32_edp_hw_link_training_en(struct rk32_edp * edp)
+void rk32_edp_hw_link_training_en(struct rk32_edp *edp)
{
u32 val;
val = HW_LT_EN;
#else
val = readl(edp->regs + DP_INT_STA);
if (val&HW_LT_DONE) {
- writel(val,edp->regs + DP_INT_STA);
+ writel(val, edp->regs + DP_INT_STA);
return 0;
- }
- else
+ } else {
return 1;
+ }
#endif
}
-int rk32_edp_get_hw_lt_status(struct rk32_edp * edp)
+int rk32_edp_get_hw_lt_status(struct rk32_edp *edp)
{
u32 val;
val = readl(edp->regs + HW_LT_CTL);
val |= MACRO_RST;
writel(val, edp->regs + PHY_TEST);
-
+
udelay(10);
val &= ~MACRO_RST;
val = CHA_CRI(4) | CHA_CTRL;
writel(val, edp->regs + SYS_CTL_2);
- //val = 0x0;
- //writel(val, edp->regs + SYS_CTL_3);
+ /*val = 0x0;
+ writel(val, edp->regs + SYS_CTL_3);*/
val = VID_HRES_TH(2) | VID_VRES_TH(0);
writel(val, edp->regs + VIDEO_CTL_8);
{
struct video_info *video_info = &edp->video_info;
struct rk_screen *screen = &edp->screen;
- u16 x_total ,y_total, x_act;
+ u16 x_total, y_total, x_act;
u32 val;
x_total = screen->mode.left_margin + screen->mode.right_margin +
screen->mode.xres + screen->mode.hsync_len;
val = BIST_EN | BIST_WH_64 | BIST_TYPE_COLR_BAR;
writel(val, edp->regs + VIDEO_CTL_4);
-#ifndef CONFIG_RK_FPGA
- //val = (GRF_EDP_BIST_EN << 16) | GRF_EDP_BIST_EN;
- //writel_relaxed(val,RK_GRF_VIRT + RK3288_GRF_SOC_CON8);
-#endif
-
val = readl(edp->regs + VIDEO_CTL_10);
val &= ~F_SEL;
writel(val, edp->regs + VIDEO_CTL_10);
return 0;
-
+
}
void rk32_edp_enable_video_master(struct rk32_edp *edp, bool enable)
val = INT_HPD;
writel(val, edp->regs + DP_INT_STA);
}
-