Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Lad, Prabhakar and committed by
Mauro Carvalho Chehab
187d42d6 5e95814f

+93 -1
+48
Documentation/devicetree/bindings/media/i2c/adv7343.txt
··· 1 + * Analog Devices adv7343 video encoder 2 + 3 + The ADV7343 are high speed, digital-to-analog video encoders in a 64-lead LQFP 4 + package. Six high speed, 3.3 V, 11-bit video DACs provide support for composite 5 + (CVBS), S-Video (Y-C), and component (YPrPb/RGB) analog outputs in standard 6 + definition (SD), enhanced definition (ED), or high definition (HD) video 7 + formats. 8 + 9 + Required Properties : 10 + - compatible: Must be "adi,adv7343" 11 + 12 + Optional Properties : 13 + - adi,power-mode-sleep-mode: on enable the current consumption is reduced to 14 + micro ampere level. All DACs and the internal PLL 15 + circuit are disabled. 16 + - adi,power-mode-pll-ctrl: PLL and oversampling control. This control allows 17 + internal PLL 1 circuit to be powered down and the 18 + oversampling to be switched off. 19 + - ad,adv7343-power-mode-dac: array configuring the power on/off DAC's 1..6, 20 + 0 = OFF and 1 = ON, Default value when this 21 + property is not specified is <0 0 0 0 0 0>. 22 + - ad,adv7343-sd-config-dac-out: array configure SD DAC Output's 1 and 2, 0 = OFF 23 + and 1 = ON, Default value when this property is 24 + not specified is <0 0>. 25 + 26 + Example: 27 + 28 + i2c0@1c22000 { 29 + ... 30 + ... 31 + 32 + adv7343@2a { 33 + compatible = "adi,adv7343"; 34 + reg = <0x2a>; 35 + 36 + port { 37 + adv7343_1: endpoint { 38 + adi,power-mode-sleep-mode; 39 + adi,power-mode-pll-ctrl; 40 + /* Use DAC1..3, DAC6 */ 41 + adi,dac-enable = <1 1 1 0 0 1>; 42 + /* Use SD DAC output 1 */ 43 + adi,sd-dac-enable = <1 0>; 44 + }; 45 + }; 46 + }; 47 + ... 48 + };
+45 -1
drivers/media/i2c/adv7343.c
··· 30 30 #include <media/v4l2-async.h> 31 31 #include <media/v4l2-device.h> 32 32 #include <media/v4l2-ctrls.h> 33 + #include <media/v4l2-of.h> 33 34 34 35 #include "adv7343_regs.h" 35 36 ··· 400 399 return err; 401 400 } 402 401 402 + static struct adv7343_platform_data * 403 + adv7343_get_pdata(struct i2c_client *client) 404 + { 405 + struct adv7343_platform_data *pdata; 406 + struct device_node *np; 407 + 408 + if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) 409 + return client->dev.platform_data; 410 + 411 + np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL); 412 + if (!np) 413 + return NULL; 414 + 415 + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); 416 + if (!pdata) 417 + goto done; 418 + 419 + pdata->mode_config.sleep_mode = 420 + of_property_read_bool(np, "adi,power-mode-sleep-mode"); 421 + 422 + pdata->mode_config.pll_control = 423 + of_property_read_bool(np, "adi,power-mode-pll-ctrl"); 424 + 425 + of_property_read_u32_array(np, "adi,dac-enable", 426 + pdata->mode_config.dac, 6); 427 + 428 + of_property_read_u32_array(np, "adi,sd-dac-enable", 429 + pdata->sd_config.sd_dac_out, 2); 430 + 431 + done: 432 + of_node_put(np); 433 + return pdata; 434 + } 435 + 403 436 static int adv7343_probe(struct i2c_client *client, 404 437 const struct i2c_device_id *id) 405 438 { ··· 452 417 return -ENOMEM; 453 418 454 419 /* Copy board specific information here */ 455 - state->pdata = client->dev.platform_data; 420 + state->pdata = adv7343_get_pdata(client); 456 421 457 422 state->reg00 = 0x80; 458 423 state->reg01 = 0x00; ··· 518 483 519 484 MODULE_DEVICE_TABLE(i2c, adv7343_id); 520 485 486 + #if IS_ENABLED(CONFIG_OF) 487 + static const struct of_device_id adv7343_of_match[] = { 488 + {.compatible = "adi,adv7343", }, 489 + { /* sentinel */ }, 490 + }; 491 + MODULE_DEVICE_TABLE(of, adv7343_of_match); 492 + #endif 493 + 521 494 static struct i2c_driver adv7343_driver = { 522 495 .driver = { 496 + .of_match_table = of_match_ptr(adv7343_of_match), 523 497 .owner = THIS_MODULE, 524 498 .name = "adv7343", 525 499 },