.. | .. |
---|
22 | 22 | * |
---|
23 | 23 | */ |
---|
24 | 24 | |
---|
25 | | -#include "mdfld_dsi_dpi.h" |
---|
26 | | -#include "mdfld_output.h" |
---|
27 | | -#include "mdfld_dsi_pkg_sender.h" |
---|
28 | | -#include "tc35876x-dsi-lvds.h" |
---|
29 | | -#include <linux/platform_data/tc35876x.h> |
---|
| 25 | +#include <linux/delay.h> |
---|
30 | 26 | #include <linux/kernel.h> |
---|
31 | 27 | #include <linux/module.h> |
---|
| 28 | +#include <linux/gpio/consumer.h> |
---|
| 29 | + |
---|
32 | 30 | #include <asm/intel_scu_ipc.h> |
---|
| 31 | + |
---|
| 32 | +#include "mdfld_dsi_dpi.h" |
---|
| 33 | +#include "mdfld_dsi_pkg_sender.h" |
---|
| 34 | +#include "mdfld_output.h" |
---|
| 35 | +#include "tc35876x-dsi-lvds.h" |
---|
33 | 36 | |
---|
34 | 37 | static struct i2c_client *tc35876x_client; |
---|
35 | 38 | static struct i2c_client *cmi_lcd_i2c_client; |
---|
| 39 | +/* Panel GPIOs */ |
---|
| 40 | +static struct gpio_desc *bridge_reset; |
---|
| 41 | +static struct gpio_desc *bridge_bl_enable; |
---|
| 42 | +static struct gpio_desc *backlight_voltage; |
---|
| 43 | + |
---|
36 | 44 | |
---|
37 | 45 | #define FLD_MASK(start, end) (((1 << ((start) - (end) + 1)) - 1) << (end)) |
---|
38 | 46 | #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end)) |
---|
.. | .. |
---|
313 | 321 | |
---|
314 | 322 | void tc35876x_set_bridge_reset_state(struct drm_device *dev, int state) |
---|
315 | 323 | { |
---|
316 | | - struct tc35876x_platform_data *pdata; |
---|
317 | | - |
---|
318 | 324 | if (WARN(!tc35876x_client, "%s called before probe", __func__)) |
---|
319 | 325 | return; |
---|
320 | 326 | |
---|
321 | 327 | dev_dbg(&tc35876x_client->dev, "%s: state %d\n", __func__, state); |
---|
322 | 328 | |
---|
323 | | - pdata = dev_get_platdata(&tc35876x_client->dev); |
---|
324 | | - |
---|
325 | | - if (pdata->gpio_bridge_reset == -1) |
---|
| 329 | + if (!bridge_reset) |
---|
326 | 330 | return; |
---|
327 | 331 | |
---|
328 | 332 | if (state) { |
---|
329 | | - gpio_set_value_cansleep(pdata->gpio_bridge_reset, 0); |
---|
| 333 | + gpiod_set_value_cansleep(bridge_reset, 0); |
---|
330 | 334 | mdelay(10); |
---|
331 | 335 | } else { |
---|
332 | 336 | /* Pull MIPI Bridge reset pin to Low */ |
---|
333 | | - gpio_set_value_cansleep(pdata->gpio_bridge_reset, 0); |
---|
| 337 | + gpiod_set_value_cansleep(bridge_reset, 0); |
---|
334 | 338 | mdelay(20); |
---|
335 | 339 | /* Pull MIPI Bridge reset pin to High */ |
---|
336 | | - gpio_set_value_cansleep(pdata->gpio_bridge_reset, 1); |
---|
| 340 | + gpiod_set_value_cansleep(bridge_reset, 1); |
---|
337 | 341 | mdelay(40); |
---|
338 | 342 | } |
---|
339 | 343 | } |
---|
.. | .. |
---|
507 | 511 | |
---|
508 | 512 | void tc35876x_toshiba_bridge_panel_off(struct drm_device *dev) |
---|
509 | 513 | { |
---|
510 | | - struct tc35876x_platform_data *pdata; |
---|
511 | | - |
---|
512 | 514 | if (WARN(!tc35876x_client, "%s called before probe", __func__)) |
---|
513 | 515 | return; |
---|
514 | 516 | |
---|
515 | 517 | dev_dbg(&tc35876x_client->dev, "%s\n", __func__); |
---|
516 | 518 | |
---|
517 | | - pdata = dev_get_platdata(&tc35876x_client->dev); |
---|
| 519 | + if (bridge_bl_enable) |
---|
| 520 | + gpiod_set_value_cansleep(bridge_bl_enable, 0); |
---|
518 | 521 | |
---|
519 | | - if (pdata->gpio_panel_bl_en != -1) |
---|
520 | | - gpio_set_value_cansleep(pdata->gpio_panel_bl_en, 0); |
---|
521 | | - |
---|
522 | | - if (pdata->gpio_panel_vadd != -1) |
---|
523 | | - gpio_set_value_cansleep(pdata->gpio_panel_vadd, 0); |
---|
| 522 | + if (backlight_voltage) |
---|
| 523 | + gpiod_set_value_cansleep(backlight_voltage, 0); |
---|
524 | 524 | } |
---|
525 | 525 | |
---|
526 | 526 | void tc35876x_toshiba_bridge_panel_on(struct drm_device *dev) |
---|
527 | 527 | { |
---|
528 | | - struct tc35876x_platform_data *pdata; |
---|
529 | 528 | struct drm_psb_private *dev_priv = dev->dev_private; |
---|
530 | 529 | |
---|
531 | 530 | if (WARN(!tc35876x_client, "%s called before probe", __func__)) |
---|
.. | .. |
---|
533 | 532 | |
---|
534 | 533 | dev_dbg(&tc35876x_client->dev, "%s\n", __func__); |
---|
535 | 534 | |
---|
536 | | - pdata = dev_get_platdata(&tc35876x_client->dev); |
---|
537 | | - |
---|
538 | | - if (pdata->gpio_panel_vadd != -1) { |
---|
539 | | - gpio_set_value_cansleep(pdata->gpio_panel_vadd, 1); |
---|
| 535 | + if (backlight_voltage) { |
---|
| 536 | + gpiod_set_value_cansleep(backlight_voltage, 1); |
---|
540 | 537 | msleep(260); |
---|
541 | 538 | } |
---|
542 | 539 | |
---|
.. | .. |
---|
568 | 565 | "i2c write failed (%d)\n", ret); |
---|
569 | 566 | } |
---|
570 | 567 | |
---|
571 | | - if (pdata->gpio_panel_bl_en != -1) |
---|
572 | | - gpio_set_value_cansleep(pdata->gpio_panel_bl_en, 1); |
---|
| 568 | + if (bridge_bl_enable) |
---|
| 569 | + gpiod_set_value_cansleep(bridge_bl_enable, 1); |
---|
573 | 570 | |
---|
574 | 571 | tc35876x_brightness_control(dev, dev_priv->brightness_adjusted); |
---|
575 | 572 | } |
---|
.. | .. |
---|
632 | 629 | static int tc35876x_bridge_probe(struct i2c_client *client, |
---|
633 | 630 | const struct i2c_device_id *id) |
---|
634 | 631 | { |
---|
635 | | - struct tc35876x_platform_data *pdata; |
---|
636 | | - |
---|
637 | 632 | dev_info(&client->dev, "%s\n", __func__); |
---|
638 | 633 | |
---|
639 | 634 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
---|
.. | .. |
---|
642 | 637 | return -ENODEV; |
---|
643 | 638 | } |
---|
644 | 639 | |
---|
645 | | - pdata = dev_get_platdata(&client->dev); |
---|
646 | | - if (!pdata) { |
---|
647 | | - dev_err(&client->dev, "%s: no platform data\n", __func__); |
---|
648 | | - return -ENODEV; |
---|
649 | | - } |
---|
| 640 | + bridge_reset = devm_gpiod_get_optional(&client->dev, "bridge-reset", GPIOD_OUT_LOW); |
---|
| 641 | + if (IS_ERR(bridge_reset)) |
---|
| 642 | + return PTR_ERR(bridge_reset); |
---|
| 643 | + if (bridge_reset) |
---|
| 644 | + gpiod_set_consumer_name(bridge_reset, "tc35876x bridge reset"); |
---|
650 | 645 | |
---|
651 | | - if (pdata->gpio_bridge_reset != -1) { |
---|
652 | | - gpio_request(pdata->gpio_bridge_reset, "tc35876x bridge reset"); |
---|
653 | | - gpio_direction_output(pdata->gpio_bridge_reset, 0); |
---|
654 | | - } |
---|
| 646 | + bridge_bl_enable = devm_gpiod_get_optional(&client->dev, "bl-en", GPIOD_OUT_LOW); |
---|
| 647 | + if (IS_ERR(bridge_bl_enable)) |
---|
| 648 | + return PTR_ERR(bridge_bl_enable); |
---|
| 649 | + if (bridge_bl_enable) |
---|
| 650 | + gpiod_set_consumer_name(bridge_bl_enable, "tc35876x panel bl en"); |
---|
655 | 651 | |
---|
656 | | - if (pdata->gpio_panel_bl_en != -1) { |
---|
657 | | - gpio_request(pdata->gpio_panel_bl_en, "tc35876x panel bl en"); |
---|
658 | | - gpio_direction_output(pdata->gpio_panel_bl_en, 0); |
---|
659 | | - } |
---|
660 | | - |
---|
661 | | - if (pdata->gpio_panel_vadd != -1) { |
---|
662 | | - gpio_request(pdata->gpio_panel_vadd, "tc35876x panel vadd"); |
---|
663 | | - gpio_direction_output(pdata->gpio_panel_vadd, 0); |
---|
664 | | - } |
---|
| 652 | + backlight_voltage = devm_gpiod_get_optional(&client->dev, "vadd", GPIOD_OUT_LOW); |
---|
| 653 | + if (IS_ERR(backlight_voltage)) |
---|
| 654 | + return PTR_ERR(backlight_voltage); |
---|
| 655 | + if (backlight_voltage) |
---|
| 656 | + gpiod_set_consumer_name(backlight_voltage, "tc35876x panel vadd"); |
---|
665 | 657 | |
---|
666 | 658 | tc35876x_client = client; |
---|
667 | 659 | |
---|
.. | .. |
---|
670 | 662 | |
---|
671 | 663 | static int tc35876x_bridge_remove(struct i2c_client *client) |
---|
672 | 664 | { |
---|
673 | | - struct tc35876x_platform_data *pdata = dev_get_platdata(&client->dev); |
---|
674 | | - |
---|
675 | 665 | dev_dbg(&client->dev, "%s\n", __func__); |
---|
676 | | - |
---|
677 | | - if (pdata->gpio_bridge_reset != -1) |
---|
678 | | - gpio_free(pdata->gpio_bridge_reset); |
---|
679 | | - |
---|
680 | | - if (pdata->gpio_panel_bl_en != -1) |
---|
681 | | - gpio_free(pdata->gpio_panel_bl_en); |
---|
682 | | - |
---|
683 | | - if (pdata->gpio_panel_vadd != -1) |
---|
684 | | - gpio_free(pdata->gpio_panel_vadd); |
---|
685 | 666 | |
---|
686 | 667 | tc35876x_client = NULL; |
---|
687 | 668 | |
---|
.. | .. |
---|
766 | 747 | return -EINVAL; |
---|
767 | 748 | } |
---|
768 | 749 | |
---|
769 | | - client = i2c_new_device(adapter, &info); |
---|
770 | | - if (!client) { |
---|
771 | | - pr_err("%s: i2c_new_device() failed\n", __func__); |
---|
| 750 | + client = i2c_new_client_device(adapter, &info); |
---|
| 751 | + if (IS_ERR(client)) { |
---|
| 752 | + pr_err("%s: creating I2C device failed\n", __func__); |
---|
772 | 753 | i2c_put_adapter(adapter); |
---|
773 | | - return -EINVAL; |
---|
| 754 | + return PTR_ERR(client); |
---|
774 | 755 | } |
---|
775 | 756 | |
---|
776 | 757 | return 0; |
---|
.. | .. |
---|
784 | 765 | .commit = mdfld_dsi_dpi_commit, |
---|
785 | 766 | }; |
---|
786 | 767 | |
---|
787 | | -static const struct drm_encoder_funcs tc35876x_encoder_funcs = { |
---|
788 | | - .destroy = drm_encoder_cleanup, |
---|
789 | | -}; |
---|
790 | | - |
---|
791 | 768 | const struct panel_funcs mdfld_tc35876x_funcs = { |
---|
792 | | - .encoder_funcs = &tc35876x_encoder_funcs, |
---|
793 | 769 | .encoder_helper_funcs = &tc35876x_encoder_helper_funcs, |
---|
794 | 770 | .get_config_mode = tc35876x_get_config_mode, |
---|
795 | 771 | .get_panel_info = tc35876x_get_panel_info, |
---|