mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
rk616: update rk616 driver,add dts property
This commit is contained in:
33
arch/arm/boot/dts/rk616.dtsi
Normal file
33
arch/arm/boot/dts/rk616.dtsi
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
&rk616 {
|
||||
compatible = "rockchip,rk616";
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
rk616,scl_rate = <100000>;
|
||||
rk616,lcd0_func = <INPUT>;
|
||||
rk616,lcd1_func = <UNUSED>;
|
||||
rk616,lvds_ch_nr = <1>;
|
||||
|
||||
hdmi: hdmi{
|
||||
compatible = "rk616,rk616-hdmi";
|
||||
reg = <0x0400,0x0400>;
|
||||
};
|
||||
|
||||
codec: codec{
|
||||
compatible = "rk616,rk616-code";
|
||||
reg = <0x0800,0x0400>;
|
||||
};
|
||||
|
||||
mipi: mipi-pyh{
|
||||
compatible = "rk616,mipi-phy";
|
||||
reg = <0x0c00,0x0400>;
|
||||
};
|
||||
|
||||
mipi: mipi-ctrl{
|
||||
compatible = "rk616,mipi-ctrl";
|
||||
reg = <0x1000,0x0400>;
|
||||
};
|
||||
};
|
||||
@@ -472,6 +472,56 @@ static int rk616_core_resume(struct device* dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static struct rk616_platform_data *rk616_parse_dt(struct mfd_rk616 *rk616)
|
||||
{
|
||||
struct rk616_platform_data *pdata = NULL;
|
||||
struct device_node *rk616_np = rk616->dev->of_node;
|
||||
int val = 0,gpio = 0;
|
||||
|
||||
if (!rk616_np) {
|
||||
printk("could not find rk616 node\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pdata = devm_kzalloc(rk616->dev, sizeof(struct rk616_platform_data), GFP_KERNEL);
|
||||
if (!pdata) {
|
||||
dev_err(&rk616->dev, "rk616_platform_data kmalloc fail!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!of_property_read_u32(rk616_np, "rk616,scl_rate", &val))
|
||||
pdata->scl_rate = val;
|
||||
|
||||
if(!of_property_read_u32(rk616_np, "rk616,lcd0_func", &val))
|
||||
pdata->lcd0_func = val;
|
||||
|
||||
if(!of_property_read_u32(rk616_np, "rk616,lcd1_func", &val))
|
||||
pdata->lcd1_func = val;
|
||||
|
||||
if(!of_property_read_u32(rk616_np, "rk616,lvds_ch_nr", &val))
|
||||
pdata->lvds_ch_nr = val;
|
||||
|
||||
gpio = of_get_named_gpio(rk616_np,"rk616,hdmi_irq_gpio", 0);
|
||||
if (!gpio_is_valid(gpio))
|
||||
printk("invalid hdmi_irq_gpio: %d\n",gpio);
|
||||
pdata->hdmi_irq = gpio;
|
||||
|
||||
gpio = of_get_named_gpio(rk616_np,"rk616,spk_ctl_gpio", 0);
|
||||
if (!gpio_is_valid(gpio))
|
||||
printk("invalid spk_ctl_gpio: %d\n",gpio);
|
||||
pdata->spk_ctl_gpio = gpio;
|
||||
//TODO Daisen >>pwr gpio wait to add
|
||||
|
||||
return pdata;
|
||||
}
|
||||
#else
|
||||
static struct rk616_platform_data *rk616_parse_dt(struct mfd_rk616 *rk616)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int rk616_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id)
|
||||
{
|
||||
@@ -479,6 +529,13 @@ static int rk616_i2c_probe(struct i2c_client *client,const struct i2c_device_id
|
||||
struct mfd_rk616 *rk616 = NULL;
|
||||
struct clk *iis_clk;
|
||||
|
||||
if (client->dev.of_node) {
|
||||
if (!of_match_device(rk616_dt_ids, &client->dev)) {
|
||||
dev_err(&client->dev, "Failed to find matching dt id\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
|
||||
{
|
||||
dev_err(&client->dev, "Must have I2C_FUNC_I2C.\n");
|
||||
@@ -492,7 +549,7 @@ static int rk616_i2c_probe(struct i2c_client *client,const struct i2c_device_id
|
||||
}
|
||||
|
||||
rk616->dev = &client->dev;
|
||||
rk616->pdata = client->dev.platform_data;
|
||||
rk616->pdata = rk616_parse_dt(rk616);
|
||||
rk616->client = client;
|
||||
i2c_set_clientdata(client, rk616);
|
||||
dev_set_drvdata(rk616->dev,rk616);
|
||||
@@ -565,6 +622,15 @@ static void rk616_core_shutdown(struct i2c_client *client)
|
||||
}
|
||||
|
||||
|
||||
#if defined(CONFIG_OF)
|
||||
static const struct of_device_id rk616_dt_ids[] = {
|
||||
{.compatible = "rockchip,rk616",},
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rk616_dt_ids);
|
||||
#endif
|
||||
|
||||
|
||||
static const struct i2c_device_id id_table[] = {
|
||||
{"rk616", 0 },
|
||||
{ }
|
||||
@@ -576,6 +642,7 @@ static struct i2c_driver rk616_i2c_driver = {
|
||||
.owner = THIS_MODULE,
|
||||
.suspend = &rk616_core_suspend,
|
||||
.resume = &rk616_core_resume,
|
||||
.of_match_table = of_match_ptr(rk616_dt_ids),
|
||||
},
|
||||
.probe = &rk616_i2c_probe,
|
||||
.remove = &rk616_i2c_remove,
|
||||
|
||||
@@ -211,6 +211,7 @@ static int __devinit rk616_hdmi_probe (struct platform_device *pdev)
|
||||
struct rk616_hdmi *rk616_hdmi;
|
||||
struct resource __maybe_unused *mem;
|
||||
struct resource __maybe_unused *res;
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
|
||||
rk616_hdmi = devm_kzalloc(&pdev->dev, sizeof(*rk616_hdmi), GFP_KERNEL);
|
||||
if(!rk616_hdmi)
|
||||
@@ -443,6 +444,15 @@ static void rk616_hdmi_shutdown(struct platform_device *pdev)
|
||||
hdmi_dbg(hdmi->dev, "rk616 hdmi shut down.\n");
|
||||
}
|
||||
|
||||
#if defined(CONFIG_OF)
|
||||
static const struct of_device_id rk616_hdmi_of_match[] = {
|
||||
{.compatible = "rockchip,rk616-hdmi",},
|
||||
{}
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, rk616_hdmi_of_match);
|
||||
#endif
|
||||
|
||||
static struct platform_driver rk616_hdmi_driver = {
|
||||
.probe = rk616_hdmi_probe,
|
||||
.remove = __devexit_p(rk616_hdmi_remove),
|
||||
@@ -453,6 +463,7 @@ static struct platform_driver rk616_hdmi_driver = {
|
||||
.name = "rk616-hdmi",
|
||||
#endif
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(rk616_hdmi_of_match),
|
||||
},
|
||||
.shutdown = rk616_hdmi_shutdown,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user