diff options
author | Lad, Prabhakar <prabhakar.csengg@gmail.com> | 2013-07-20 01:21:06 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-07-26 12:21:40 -0400 |
commit | 187d42d6da62aa3eb3d76866584382625f141b3c (patch) | |
tree | cc1e1ccacd9df78cdbdb413a56d00c501ca0668b /drivers/media/i2c/adv7343.c | |
parent | 5e95814ff3f2a6ea7d76e822bbc3b0c0b94495a4 (diff) |
[media] media: i2c: adv7343: add OF support
add OF support for the adv7343 driver.
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/i2c/adv7343.c')
-rw-r--r-- | drivers/media/i2c/adv7343.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c index f0238fb3e3e2..aeb56c53e39f 100644 --- a/drivers/media/i2c/adv7343.c +++ b/drivers/media/i2c/adv7343.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <media/v4l2-async.h> | 30 | #include <media/v4l2-async.h> |
31 | #include <media/v4l2-device.h> | 31 | #include <media/v4l2-device.h> |
32 | #include <media/v4l2-ctrls.h> | 32 | #include <media/v4l2-ctrls.h> |
33 | #include <media/v4l2-of.h> | ||
33 | 34 | ||
34 | #include "adv7343_regs.h" | 35 | #include "adv7343_regs.h" |
35 | 36 | ||
@@ -399,6 +400,40 @@ static int adv7343_initialize(struct v4l2_subdev *sd) | |||
399 | return err; | 400 | return err; |
400 | } | 401 | } |
401 | 402 | ||
403 | static struct adv7343_platform_data * | ||
404 | adv7343_get_pdata(struct i2c_client *client) | ||
405 | { | ||
406 | struct adv7343_platform_data *pdata; | ||
407 | struct device_node *np; | ||
408 | |||
409 | if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) | ||
410 | return client->dev.platform_data; | ||
411 | |||
412 | np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL); | ||
413 | if (!np) | ||
414 | return NULL; | ||
415 | |||
416 | pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); | ||
417 | if (!pdata) | ||
418 | goto done; | ||
419 | |||
420 | pdata->mode_config.sleep_mode = | ||
421 | of_property_read_bool(np, "adi,power-mode-sleep-mode"); | ||
422 | |||
423 | pdata->mode_config.pll_control = | ||
424 | of_property_read_bool(np, "adi,power-mode-pll-ctrl"); | ||
425 | |||
426 | of_property_read_u32_array(np, "adi,dac-enable", | ||
427 | pdata->mode_config.dac, 6); | ||
428 | |||
429 | of_property_read_u32_array(np, "adi,sd-dac-enable", | ||
430 | pdata->sd_config.sd_dac_out, 2); | ||
431 | |||
432 | done: | ||
433 | of_node_put(np); | ||
434 | return pdata; | ||
435 | } | ||
436 | |||
402 | static int adv7343_probe(struct i2c_client *client, | 437 | static int adv7343_probe(struct i2c_client *client, |
403 | const struct i2c_device_id *id) | 438 | const struct i2c_device_id *id) |
404 | { | 439 | { |
@@ -417,7 +452,7 @@ static int adv7343_probe(struct i2c_client *client, | |||
417 | return -ENOMEM; | 452 | return -ENOMEM; |
418 | 453 | ||
419 | /* Copy board specific information here */ | 454 | /* Copy board specific information here */ |
420 | state->pdata = client->dev.platform_data; | 455 | state->pdata = adv7343_get_pdata(client); |
421 | 456 | ||
422 | state->reg00 = 0x80; | 457 | state->reg00 = 0x80; |
423 | state->reg01 = 0x00; | 458 | state->reg01 = 0x00; |
@@ -483,8 +518,17 @@ static const struct i2c_device_id adv7343_id[] = { | |||
483 | 518 | ||
484 | MODULE_DEVICE_TABLE(i2c, adv7343_id); | 519 | MODULE_DEVICE_TABLE(i2c, adv7343_id); |
485 | 520 | ||
521 | #if IS_ENABLED(CONFIG_OF) | ||
522 | static const struct of_device_id adv7343_of_match[] = { | ||
523 | {.compatible = "adi,adv7343", }, | ||
524 | { /* sentinel */ }, | ||
525 | }; | ||
526 | MODULE_DEVICE_TABLE(of, adv7343_of_match); | ||
527 | #endif | ||
528 | |||
486 | static struct i2c_driver adv7343_driver = { | 529 | static struct i2c_driver adv7343_driver = { |
487 | .driver = { | 530 | .driver = { |
531 | .of_match_table = of_match_ptr(adv7343_of_match), | ||
488 | .owner = THIS_MODULE, | 532 | .owner = THIS_MODULE, |
489 | .name = "adv7343", | 533 | .name = "adv7343", |
490 | }, | 534 | }, |