{
int i = 0;
u32 val = 0;
- struct mfd_rk616 *rk616 = s->private;
- if(!rk616)
- {
- dev_err(rk616->dev,"no mfd rk616!\n");
- return 0;
- }
-
seq_printf(s, "\n>>>rk616_ctl reg");
for (i = 0; i < 16; i++) {
seq_printf(s, " %2x", i);
}
seq_printf(s, "\n-----------------------------------------------------------------");
- for(i=0;i<= (PHY_PRE_DIV_RATIO << 2);i+=4)
- {
- rk616->read_dev(rk616,RK616_HDMI_BASE + i,&val);
- //seq_printf(s,"reg%02x>>0x%08x\n",(i>>2),val);
- if((i>>2)%16==0)
- seq_printf(s,"\n>>>rk616_ctl %2x:",i>>2);
+ for(i=0; i<= PHY_PRE_DIV_RATIO; i++) {
+ hdmi_readl(i, &val);
+ if(i%16==0)
+ seq_printf(s,"\n>>>rk616_ctl %2x:", i);
seq_printf(s," %02x",val);
}
-
seq_printf(s, "\n-----------------------------------------------------------------\n");
return 0;
static ssize_t rk616_hdmi_reg_write (struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{
- struct mfd_rk616 *rk616 = file->f_path.dentry->d_inode->i_private;
u32 reg;
u32 val;
char kbuf[25];
if (copy_from_user(kbuf, buf, count))
return -EFAULT;
sscanf(kbuf, "%x%x", ®, &val);
- if ((reg < 0) || (reg > 0xed))
- {
- printk("it is no hdmi reg\n");
+ if ((reg < 0) || (reg > 0xed)) {
+ dev_info(hdmi->dev, "it is no hdmi reg\n");
return count;
}
- printk("/**********rk616 reg config******/");
- printk("\n reg=%x val=%x\n", reg, val);
-
- //sscanf(kbuf, "%x%x", ®, &val);
- dev_dbg(rk616->dev,"%s:reg:0x%04x val:0x%08x\n",__func__,reg, val);
- rk616->write_dev(rk616, RK616_HDMI_BASE + (reg << 2), &val);
+ dev_info(hdmi->dev, "/**********rk616 reg config******/");
+ dev_info(hdmi->dev, "\n reg=%x val=%x\n", reg, val);
+ hdmi_writel(reg, val);
return count;
}
// hdmi_irq();
rk616_hdmi_work();
}
-
- if (rk616_hdmi->rk616_drv->pdata->hdmi_irq == INVALID_GPIO)
+ if (rk616_hdmi->rk616_drv && rk616_hdmi->rk616_drv->pdata->hdmi_irq == INVALID_GPIO)
queue_delayed_work(hdmi->workqueue, &rk616_hdmi->rk616_delay_work, 100);
-
queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, msecs_to_jiffies(10));
mutex_unlock(&hdmi->enable_mutex);
return;
rk616_hdmi_work();
}
- if (rk616_hdmi->rk616_drv->pdata->hdmi_irq == INVALID_GPIO) {
+ if (rk616_hdmi->rk616_drv && rk616_hdmi->rk616_drv->pdata->hdmi_irq == INVALID_GPIO) {
queue_delayed_work(hdmi->workqueue, &rk616_hdmi->rk616_delay_work, 100);
}
}
}
-static void rk616_irq_work_func(struct work_struct *work)
+static void __maybe_unused rk616_irq_work_func(struct work_struct *work)
{
if((hdmi->suspend == 0) && (hdmi->enable == 1)) {
rk616_hdmi_work();
enable_irq(hdmi->irq);
}
-#if 1
static irqreturn_t rk616_hdmi_irq(int irq, void *dev_id)
{
struct work_struct *rk616_irq_work_struct;
+ struct rk616_hdmi *rk616_hdmi;
- rk616_irq_work_struct = dev_id;
- disable_irq_nosync(hdmi->irq);
- //printk(KERN_INFO "rk616_hdmi_irq irq triggered.\n");
- queue_work(hdmi->workqueue, rk616_irq_work_struct);
+ rk616_hdmi = container_of(hdmi, struct rk616_hdmi, g_hdmi);
+ if(rk616_hdmi->rk616_drv) {
+ rk616_irq_work_struct = dev_id;
+ disable_irq_nosync(hdmi->irq);
+ queue_work(hdmi->workqueue, rk616_irq_work_struct);
+ } else {
+ /* 3028a hdmi */
+ if((hdmi->suspend == 0) && (hdmi->enable == 1)) {
+ printk(KERN_INFO "line = %d, rk616_hdmi_irq irq triggered.\n", __LINE__);
+ rk616_hdmi_work();
+ }
+ }
return IRQ_HANDLED;
}
-#endif
+
static int __devinit rk616_hdmi_probe (struct platform_device *pdev)
{
int ret;
struct rk616_hdmi *rk616_hdmi;
-
- struct mfd_rk616 *rk616 = dev_get_drvdata(pdev->dev.parent);
- if(!rk616)
- {
- dev_err(&pdev->dev,"null mfd device rk616!\n");
- return -ENODEV;
- }
+ struct resource __maybe_unused *mem;
+ struct resource __maybe_unused *res;
rk616_hdmi = devm_kzalloc(&pdev->dev, sizeof(*rk616_hdmi), GFP_KERNEL);
if(!rk616_hdmi)
return -ENOMEM;
}
hdmi = &rk616_hdmi->g_hdmi;
- rk616_hdmi->rk616_drv = rk616;
+
+#ifdef CONFIG_ARCH_RK3026
+ rk616_hdmi->rk616_drv = NULL;
+#else
+ rk616_hdmi->rk616_drv = dev_get_drvdata(pdev->dev.parent);
+ if(!(rk616_hdmi->rk616_drv))
+ {
+ dev_err(&pdev->dev,"null mfd device rk616!\n");
+ return -ENODEV;
+ }
+
+#endif
hdmi->dev = &pdev->dev;
platform_set_drvdata(pdev, hdmi);
hdmi->xscale = 100;
hdmi->yscale = 100;
- ret = rk616_hdmi_initial();
hdmi_sys_init();
register_early_suspend(&hdmi->early_suspend);
#endif
- hdmi_register_display_sysfs(hdmi, NULL);
#ifdef CONFIG_SWITCH
hdmi->switch_hdmi.name="hdmi";
switch_dev_register(&(hdmi->switch_hdmi));
INIT_DELAYED_WORK(&rk616_hdmi->rk616_delay_work, rk616_delay_work_func);
/* get the IRQ */
- if(rk616->pdata->hdmi_irq != INVALID_GPIO)
- {
- INIT_WORK(&rk616_hdmi->rk616_irq_work_struct, rk616_irq_work_func);
- ret = gpio_request(rk616->pdata->hdmi_irq,"rk616_hdmi_irq");
- if(ret < 0)
- {
- dev_err(hdmi->dev,"request gpio for rk616 hdmi irq fail\n");
- }
- gpio_direction_input(rk616->pdata->hdmi_irq);
- hdmi->irq = gpio_to_irq(rk616->pdata->hdmi_irq);
- if(hdmi->irq <= 0) {
- dev_err(hdmi->dev, "failed to get hdmi irq resource (%d).\n", hdmi->irq);
- ret = -ENXIO;
- goto err1;
- }
-
- /* request the IRQ */
+ // if(rk616->pdata->hdmi_irq != INVALID_GPIO)
+
+#ifdef CONFIG_ARCH_RK3026
+ hdmi->hclk = clk_get(NULL,"pclk_hdmi");
+ if(IS_ERR(hdmi->hclk)) {
+ dev_err(hdmi->dev, "Unable to get hdmi hclk\n");
+ ret = -ENXIO;
+ goto err0;
+ }
+ clk_enable(hdmi->hclk);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(hdmi->dev, "Unable to get register resource\n");
+ ret = -ENXIO;
+ goto err0;
+ }
+ hdmi->regbase_phy = res->start;
+ hdmi->regsize_phy = (res->end - res->start) + 1;
+ mem = request_mem_region(res->start, (res->end - res->start) + 1, pdev->name);
+ if (!mem) {
+ dev_err(hdmi->dev, "failed to request mem region for hdmi\n");
+ ret = -ENOENT;
+ goto err0;
+ }
+
+ printk("res->start = 0x%x\n, xhc-------res->end = 0x%x\n", res->start, res->end);
+ hdmi->regbase = (int)ioremap(res->start, (res->end - res->start) + 1);
+ if (!hdmi->regbase) {
+ dev_err(hdmi->dev, "cannot ioremap registers\n");
+ ret = -ENXIO;
+ goto err1;
+ }
+
+ // rk30_mux_api_set(GPIO0A7_I2C3_SDA_HDMI_DDCSDA_NAME, GPIO0A_HDMI_DDCSDA);
+ // rk30_mux_api_set(GPIO0A6_I2C3_SCL_HDMI_DDCSCL_NAME, GPIO0A_HDMI_DDCSCL);
+ // rk30_mux_api_set(GPIO0B7_HDMI_HOTPLUGIN_NAME, GPIO0B_HDMI_HOTPLUGIN);
+ iomux_set(HDMI_DDCSDA);
+ iomux_set(HDMI_DDCSCL);
+ iomux_set(HDMI_HOTPLUGIN);
+
+ ret = rk616_hdmi_initial();
+ /* get the IRQ */
+ hdmi->irq = platform_get_irq(pdev, 0);
+ if(hdmi->irq <= 0) {
+ dev_err(hdmi->dev, "failed to get hdmi irq resource (%d).\n", hdmi->irq);
+ hdmi->irq = 0;
+ } else {
+ /* request the IRQ */
+ ret = request_irq(hdmi->irq, rk616_hdmi_irq, 0, dev_name(&pdev->dev), hdmi);
+ if (ret) {
+ dev_err(hdmi->dev, "hdmi request_irq failed (%d).\n", ret);
+ goto err1;
+ }
+ }
+#else
+ ret = rk616_hdmi_initial();
+ if(rk616_hdmi->rk616_drv->pdata->hdmi_irq != INVALID_GPIO) {
+ INIT_WORK(&rk616_hdmi->rk616_irq_work_struct, rk616_irq_work_func);
+ ret = gpio_request(rk616_hdmi->rk616_drv->pdata->hdmi_irq,"rk616_hdmi_irq");
+ if(ret < 0) {
+ dev_err(hdmi->dev,"request gpio for rk616 hdmi irq fail\n");
+ }
+ gpio_direction_input(rk616_hdmi->rk616_drv->pdata->hdmi_irq);
+ hdmi->irq = gpio_to_irq(rk616_hdmi->rk616_drv->pdata->hdmi_irq);
+ if(hdmi->irq <= 0) {
+ dev_err(hdmi->dev, "failed to get hdmi irq resource (%d).\n", hdmi->irq);
+ ret = -ENXIO;
+ goto err1;
+ }
+
+ /* request the IRQ */
ret = request_irq(hdmi->irq, rk616_hdmi_irq, IRQF_TRIGGER_LOW, dev_name(&pdev->dev), &rk616_hdmi->rk616_irq_work_struct);
- if (ret)
- {
- dev_err(hdmi->dev, "hdmi request_irq failed (%d).\n", ret);
- goto err1;
- }
- } else {
-
+ if (ret) {
+ dev_err(hdmi->dev, "hdmi request_irq failed (%d).\n", ret);
+ goto err1;
+ }
+ } else {
/* use roll polling method */
- hdmi->irq = 0;
+ hdmi->irq = 0;
}
+
+#endif
+ hdmi_register_display_sysfs(hdmi, NULL);
+
#if defined(CONFIG_DEBUG_FS)
- if(rk616->debugfs_dir)
- {
- debugfs_create_file("hdmi", S_IRUSR,rk616->debugfs_dir,rk616,&rk616_hdmi_reg_fops);
- }
+ if(rk616_hdmi->rk616_drv && rk616_hdmi->rk616_drv->debugfs_dir) {
+ debugfs_create_file("hdmi", S_IRUSR, rk616_hdmi->rk616_drv->debugfs_dir, rk616_hdmi->rk616_drv, &rk616_hdmi_reg_fops);
+ } else {
+ rk616_hdmi->debugfs_dir = debugfs_create_dir("rk616", NULL);
+ if (IS_ERR(rk616_hdmi->debugfs_dir)) {
+ dev_err(hdmi->dev,"failed to create debugfs dir for rk616!\n");
+ } else {
+ debugfs_create_file("hdmi", S_IRUSR, rk616_hdmi->debugfs_dir, rk616_hdmi, &rk616_hdmi_reg_fops);
+ }
+ }
#endif
// rk616_delay_work_func(NULL);
queue_delayed_work(hdmi->workqueue, &rk616_hdmi->rk616_delay_work, msecs_to_jiffies(0));
// static char edid_result = 0;
-
+#ifndef CONFIG_ARCH_RK3026
static int rk616_set_polarity(struct mfd_rk616 * rk616, int vic)
{
u32 val;
int ret;
u32 hdmi_polarity_mask = (3<<14);
- // printk("----------xhc---------vic = %d\n", vic);
switch(vic)
{
struct rk616_hdmi *rk616_hdmi;
rk616_hdmi = container_of(hdmi, struct rk616_hdmi, g_hdmi);
-
if (connect)
rk616_set_polarity(rk616_hdmi->rk616_drv, hdmi->vic);
{
u32 val;
int ret;
- ret = rk616->read_dev(rk616,CRU_CFGMISC_CON,&val);
- if(pol)
- val &= 0xffffffdf;
- else
- val |= 0x20;
- ret = rk616->write_dev(rk616,CRU_CFGMISC_CON,&val);
+ int int_pol_mask = (1 << 5);
+
+ if (pol)
+ val = 0x0;
+ else
+ val = 0x20;
+ ret = rk616->write_dev_bits(rk616, CRU_CFGMISC_CON, int_pol_mask, &val);
return 0;
}
+#endif
+
static inline void delay100us(void)
{
msleep(1);
value = mode->vsync_len;
hdmi_writel(VIDEO_EXT_VDURATION, value & 0xFF);
#endif
- //rk616_set_polarity(rk616_hdmi->rk616_drv, vpara->vic);
if(vpara->output_mode == OUTPUT_HDMI) {
rk616_hdmi_config_avi(vpara->vic, vpara->output_color);
hdmi_dbg(hdmi->dev, "[%s] sucess output DVI.\n", __FUNCTION__);
}
-#if 1
- hdmi_writel(0xed, 0x0f);
- hdmi_writel(0xe7, 0x96);
-#else
- if(hdmi->tmdsclk >= 148500000) {
- hdmi_writel(0xed, 0xc);
- hdmi_writel(0xe7, 0x78);
- }
- else {
- hdmi_writel(0xed, 0x3);
- hdmi_writel(0xe7, 0x1e);
- }
-#endif
+ // if(rk616_hdmi->rk616_drv) {
+ if (hdmi->set_vif) {
+ hdmi_writel(0xed, 0x0f);
+ hdmi_writel(0xe7, 0x96);
+ } else { // rk3028a
+ hdmi_writel(0xed, 0x1e);
+ hdmi_writel(0xe7, 0x2c);
+ hdmi_writel(0xe8, 0x01);
+ }
return 0;
}
u32 interrupt = 0;
// int value = 0;
+
hdmi_readl(INTERRUPT_STATUS1,&interrupt);
if(interrupt){
hdmi_writel(INTERRUPT_STATUS1, interrupt);
hdmi->config_audio = rk616_hdmi_config_audio;
hdmi->detect_hotplug = rk616_hdmi_detect_hotplug;
hdmi->read_edid = rk616_hdmi_read_edid;
- hdmi->set_vif = rk616_hdmi_set_vif;
-
- rk616_hdmi_reset();
+#ifdef CONFIG_ARCH_RK3026
+ rk3028_hdmi_reset_pclk();
+ rk616_hdmi_reset();
+#else
+ hdmi->set_vif = rk616_hdmi_set_vif;
+ rk616_hdmi_reset();
rk616_hdmi_init_pol_set(rk616_hdmi->rk616_drv, 0);
+#endif
+
if(hdmi->hdcp_power_on_cb)
rc = hdmi->hdcp_power_on_cb();