#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
-#include <linux/of_gpio.h>
#include <linux/i2c.h>
#include <linux/uaccess.h>
#if defined(CONFIG_DEBUG_FS)
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#endif
+#include <linux/of_gpio.h>
+#include <linux/of_device.h>
#include "cat66121_hdmi.h"
#include "cat66121_hdmi_hw.h"
hdmi_drv->detect_hotplug = cat66121_hdmi_sys_detect_hpd;
hdmi_drv->read_edid = cat66121_hdmi_sys_read_edid;
- hdmi_drv->workqueue = create_singlethread_workqueue("hdmi");
- INIT_DELAYED_WORK(&(hdmi->delay_work), hdmi_work);
-
#ifdef CONFIG_HAS_EARLYSUSPEND
hdmi_drv->early_suspend.suspend = hdmi_early_suspend;
hdmi_drv->early_suspend.resume = hdmi_early_resume;
return 0;
}
+#if defined(CONFIG_OF)
+static const struct of_device_id cat66121_dt_ids[] = {
+ {.compatible = "ite,cat66121",},
+ {}
+};
+MODULE_DEVICE_TABLE(of, cat66121_dt_ids);
+#endif
+
static int cat66121_hdmi_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id)
{
int rc = 0;
+ printk("%s,line=%d\n", __func__,__LINE__);
+
+ if (client->dev.of_node) {
+ if (!of_match_device(cat66121_dt_ids, &client->dev)) {
+ dev_err(&client->dev,"Failed to find matching dt id\n");
+ return -EINVAL;
+ }
+ }
+
cat66121_hdmi = kzalloc(sizeof(struct cat66121_hdmi_pdata), GFP_KERNEL);
if(!cat66121_hdmi)
{
memset(hdmi, 0, sizeof(struct hdmi));
hdmi->dev = &client->dev;
+ rk_hdmi_parse_dt(hdmi);
+ //power on
+ rk_hdmi_pwr_enable(hdmi);
+
if(cat66121_detect_device()!=1){
dev_err(hdmi->dev, "can't find it66121 device \n");
rc = -ENXIO;
}
cat66121_hdmi->plug_status = -1;
-
- rk_hdmi_parse_dt(hdmi);
rk_hdmi_drv_init(hdmi);
-
- //power on
- rk_hdmi_pwr_enable(hdmi);
cat66121_hdmi_sys_init(hdmi);
-#if defined(CONFIG_DEBUG_FS)
- {
- struct dentry *debugfs_dir = debugfs_create_dir("it66121", NULL);
- if (IS_ERR(debugfs_dir))
- {
- dev_err(&client->dev,"failed to create debugfs dir for it66121!\n");
- }
- else
- debugfs_create_file("hdmi", S_IRUSR,debugfs_dir,hdmi,&hdmi_reg_fops);
- }
-#endif
+ hdmi->workqueue = create_singlethread_workqueue("hdmi");
+ INIT_DELAYED_WORK(&(hdmi->delay_work), hdmi_work);
if(gpio_is_valid(hdmi->irq)) {
- cat66121_irq_work_func(NULL);
+ //cat66121_irq_work_func(NULL);
if((rc = gpio_request(hdmi->irq, "hdmi gpio")) < 0)
{
- dev_err(&client->dev, "fail to request gpio %d\n", client->irq);
+ dev_err(&client->dev, "fail to request gpio %d\n", hdmi->irq);
goto err_request_lcdc;
}
cat66121_hdmi->gpio = hdmi->irq;
//gpio_pull_updown(hdmi->irq, GPIOPullUp); //TODO Daisen
gpio_direction_input(hdmi->irq);
- if((rc = request_threaded_irq(hdmi->irq, NULL ,cat66121_thread_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT, dev_name(&client->dev), hdmi)) < 0)
+ hdmi->irq = gpio_to_irq(hdmi->irq);
+ if(hdmi->irq <= 0) {
+ dev_err(hdmi->dev, "failed to get hdmi irq resource (%d).\n", hdmi->irq);
+ goto err_request_irq;
+ }
+
+ if((rc = request_threaded_irq(hdmi->irq, NULL ,cat66121_thread_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT, dev_name(&client->dev), hdmi)) < 0)
{
dev_err(&client->dev, "fail to request hdmi irq\n");
goto err_request_irq;
cat66121_irq_work_func(NULL);
}
+#if defined(CONFIG_DEBUG_FS)
+ {
+ struct dentry *debugfs_dir = debugfs_create_dir("it66121", NULL);
+ if (IS_ERR(debugfs_dir))
+ {
+ dev_err(&client->dev,"failed to create debugfs dir for it66121!\n");
+ }
+ else
+ debugfs_create_file("hdmi", S_IRUSR,debugfs_dir,hdmi,&hdmi_reg_fops);
+ }
+#endif
+
dev_info(&client->dev, "cat66121 hdmi i2c probe ok\n");
return 0;
err_request_irq:
- gpio_free(client->irq);
+ gpio_free(hdmi->irq);
err_request_lcdc:
kfree(hdmi);
hdmi = NULL;
.driver = {
.name = "cat66121_hdmi",
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(cat66121_dt_ids),
},
.probe = cat66121_hdmi_i2c_probe,
.remove = cat66121_hdmi_i2c_remove,
*/
int rk_hdmi_pwr_ctr_parse_dt(struct hdmi *dev_drv)
{
- struct device_node *root = of_parse_phandle(dev_drv->dev->of_node,
- "power_ctr", 0);
+ struct device_node *root = of_find_node_by_name(dev_drv->dev->of_node,
+ "power_ctr");
struct device_node *child;
struct rk_disp_pwr_ctr_list *pwr_ctr;
struct list_head *pos;
if (pwr_ctr->type == GPIO) {
gpio_direction_output(pwr_ctr->gpio,pwr_ctr->atv_val);
mdelay(pwr_ctr->delay);
- if(pwr_ctr->is_rst == 1)
- gpio_direction_output(pwr_ctr->gpio,((pwr_ctr->atv_val == 1) ? 0:1));
+ if(pwr_ctr->is_rst == 1) {
+ if(pwr_ctr->atv_val == 1)
+ gpio_set_value(pwr_ctr->gpio, 0);
+ else
+ gpio_set_value(pwr_ctr->gpio, 1);
+
+ mdelay(pwr_ctr->delay);
+ }
}
}
pwr_ctr = &pwr_ctr_list->pwr_ctr;
if (pwr_ctr->type == GPIO) {
gpio_set_value(pwr_ctr->gpio,pwr_ctr->atv_val);
- if(pwr_ctr->is_rst == 1)
- gpio_direction_output(pwr_ctr->gpio,((pwr_ctr->atv_val == 1) ? 0:1));
+ if(pwr_ctr->is_rst == 1) {
+ if(pwr_ctr->atv_val == 1)
+ gpio_set_value(pwr_ctr->gpio, 0);
+ else
+ gpio_set_value(pwr_ctr->gpio, 1);
+ }
}
}