| @@ -25,7 +25,7 @@ · 24 unmodified lines |
| 25 | 25 | #include <linux/delay.h> |
| 26 | 26 | #include <linux/kernel.h> |
| 27 | 27 | #include <linux/module.h> |
| 28 | | −#include <linux/platform_data/tc35876x.h> |
| 28 | +#include <linux/gpio/consumer.h> |
| 29 | 29 | |
| 30 | 30 | #include <asm/intel_scu_ipc.h> |
| 31 | 31 | |
| @@ -36,6 +36,11 @@ · 4 unmodified lines |
| 36 | 36 | |
| 37 | 37 | static struct i2c_client *tc35876x_client; |
| 38 | 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 | + |
| 39 | 44 | |
| 40 | 45 | #define FLD_MASK(start, end) (((1 << ((start) - (end) + 1)) - 1) << (end)) |
| 41 | 46 | #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end)) |
| @@ -316,27 +321,23 @@ static int tc35876x_regr(struct i2c_client *client, u16 reg, u32 *value) · 274 unmodified lines |
| 316 | 321 | |
| 317 | 322 | void tc35876x_set_bridge_reset_state(struct drm_device *dev, int state) |
| 318 | 323 | { |
| 319 | | − struct tc35876x_platform_data *pdata; |
| 320 | | − |
| 321 | 324 | if (WARN(!tc35876x_client, "%s called before probe", __func__)) |
| 322 | 325 | return; |
| 323 | 326 | |
| 324 | 327 | dev_dbg(&tc35876x_client->dev, "%s: state %d\n", __func__, state); |
| 325 | 328 | |
| 326 | | − pdata = dev_get_platdata(&tc35876x_client->dev); |
| 327 | | − |
| 328 | | − if (pdata->gpio_bridge_reset == -1) |
| 329 | + if (!bridge_reset) |
| 329 | 330 | return; |
| 330 | 331 | |
| 331 | 332 | if (state) { |
| 332 | | − gpio_set_value_cansleep(pdata->gpio_bridge_reset, 0); |
| 333 | + gpiod_set_value_cansleep(bridge_reset, 0); |
| 333 | 334 | mdelay(10); |
| 334 | 335 | } else { |
| 335 | 336 | /* Pull MIPI Bridge reset pin to Low */ |
| 336 | | − gpio_set_value_cansleep(pdata->gpio_bridge_reset, 0); |
| 337 | + gpiod_set_value_cansleep(bridge_reset, 0); |
| 337 | 338 | mdelay(20); |
| 338 | 339 | /* Pull MIPI Bridge reset pin to High */ |
| 339 | | − gpio_set_value_cansleep(pdata->gpio_bridge_reset, 1); |
| 340 | + gpiod_set_value_cansleep(bridge_reset, 1); |
| 340 | 341 | mdelay(40); |
| 341 | 342 | } |
| 342 | 343 | } |
| @@ -510,25 +511,20 @@ void tc35876x_brightness_control(struct drm_device *dev, int level) · 167 unmodified lines |
| 510 | 511 | |
| 511 | 512 | void tc35876x_toshiba_bridge_panel_off(struct drm_device *dev) |
| 512 | 513 | { |
| 513 | | − struct tc35876x_platform_data *pdata; |
| 514 | | − |
| 515 | 514 | if (WARN(!tc35876x_client, "%s called before probe", __func__)) |
| 516 | 515 | return; |
| 517 | 516 | |
| 518 | 517 | dev_dbg(&tc35876x_client->dev, "%s\n", __func__); |
| 519 | 518 | |
| 520 | | − pdata = dev_get_platdata(&tc35876x_client->dev); |
| 521 | | − |
| 522 | | − if (pdata->gpio_panel_bl_en != -1) |
| 523 | | − gpio_set_value_cansleep(pdata->gpio_panel_bl_en, 0); |
| 519 | + if (bridge_bl_enable) |
| 520 | + gpiod_set_value_cansleep(bridge_bl_enable, 0); |
| 524 | 521 | |
| 525 | | − if (pdata->gpio_panel_vadd != -1) |
| 526 | | − gpio_set_value_cansleep(pdata->gpio_panel_vadd, 0); |
| 522 | + if (backlight_voltage) |
| 523 | + gpiod_set_value_cansleep(backlight_voltage, 0); |
| 527 | 524 | } |
| 528 | 525 | |
| 529 | 526 | void tc35876x_toshiba_bridge_panel_on(struct drm_device *dev) |
| 530 | 527 | { |
| 531 | | − struct tc35876x_platform_data *pdata; |
| 532 | 528 | struct drm_psb_private *dev_priv = dev->dev_private; |
| 533 | 529 | |
| 534 | 530 | if (WARN(!tc35876x_client, "%s called before probe", __func__)) |
| @@ -536,10 +532,8 @@ void tc35876x_toshiba_bridge_panel_on(struct drm_device *dev) · 1 unmodified line |
| 536 | 532 | |
| 537 | 533 | dev_dbg(&tc35876x_client->dev, "%s\n", __func__); |
| 538 | 534 | |
| 539 | | − pdata = dev_get_platdata(&tc35876x_client->dev); |
| 540 | | − |
| 541 | | − if (pdata->gpio_panel_vadd != -1) { |
| 542 | | − gpio_set_value_cansleep(pdata->gpio_panel_vadd, 1); |
| 535 | + if (backlight_voltage) { |
| 536 | + gpiod_set_value_cansleep(backlight_voltage, 1); |
| 543 | 537 | msleep(260); |
| 544 | 538 | } |
| 545 | 539 | |
| @@ -571,8 +565,8 @@ void tc35876x_toshiba_bridge_panel_on(struct drm_device *dev) · 25 unmodified lines |
| 571 | 565 | "i2c write failed (%d)\n", ret); |
| 572 | 566 | } |
| 573 | 567 | |
| 574 | | − if (pdata->gpio_panel_bl_en != -1) |
| 575 | | − gpio_set_value_cansleep(pdata->gpio_panel_bl_en, 1); |
| 568 | + if (bridge_bl_enable) |
| 569 | + gpiod_set_value_cansleep(bridge_bl_enable, 1); |
| 576 | 570 | |
| 577 | 571 | tc35876x_brightness_control(dev, dev_priv->brightness_adjusted); |
| 578 | 572 | } |
| @@ -635,8 +629,6 @@ static int tc35876x_get_panel_info(struct drm_device *dev, int pipe, · 56 unmodified lines |
| 635 | 629 | static int tc35876x_bridge_probe(struct i2c_client *client, |
| 636 | 630 | const struct i2c_device_id *id) |
| 637 | 631 | { |
| 638 | | − struct tc35876x_platform_data *pdata; |
| 639 | | − |
| 640 | 632 | dev_info(&client->dev, "%s\n", __func__); |
| 641 | 633 | |
| 642 | 634 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
| @@ -645,26 +637,23 @@ static int tc35876x_bridge_probe(struct i2c_client *client, · 2 unmodified lines |
| 645 | 637 | return -ENODEV; |
| 646 | 638 | } |
| 647 | 639 | |
| 648 | | − pdata = dev_get_platdata(&client->dev); |
| 649 | | − if (!pdata) { |
| 650 | | − dev_err(&client->dev, "%s: no platform data\n", __func__); |
| 651 | | − return -ENODEV; |
| 652 | | − } |
| 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"); |
| 653 | 645 | |
| 654 | | − if (pdata->gpio_bridge_reset != -1) { |
| 655 | | − gpio_request(pdata->gpio_bridge_reset, "tc35876x bridge reset"); |
| 656 | | − gpio_direction_output(pdata->gpio_bridge_reset, 0); |
| 657 | | − } |
| 658 | | − |
| 659 | | − if (pdata->gpio_panel_bl_en != -1) { |
| 660 | | − gpio_request(pdata->gpio_panel_bl_en, "tc35876x panel bl en"); |
| 661 | | − gpio_direction_output(pdata->gpio_panel_bl_en, 0); |
| 662 | | − } |
| 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"); |
| 663 | 651 | |
| 664 | | − if (pdata->gpio_panel_vadd != -1) { |
| 665 | | − gpio_request(pdata->gpio_panel_vadd, "tc35876x panel vadd"); |
| 666 | | − gpio_direction_output(pdata->gpio_panel_vadd, 0); |
| 667 | | − } |
| 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"); |
| 668 | 657 | |
| 669 | 658 | tc35876x_client = client; |
| 670 | 659 | |
| @@ -673,19 +662,8 @@ static int tc35876x_bridge_probe(struct i2c_client *client, · 2 unmodified lines |
| 673 | 662 | |
| 674 | 663 | static int tc35876x_bridge_remove(struct i2c_client *client) |
| 675 | 664 | { |
| 676 | | − struct tc35876x_platform_data *pdata = dev_get_platdata(&client->dev); |
| 677 | | − |
| 678 | 665 | dev_dbg(&client->dev, "%s\n", __func__); |
| 679 | 666 | |
| 680 | | − if (pdata->gpio_bridge_reset != -1) |
| 681 | | − gpio_free(pdata->gpio_bridge_reset); |
| 682 | | − |
| 683 | | − if (pdata->gpio_panel_bl_en != -1) |
| 684 | | − gpio_free(pdata->gpio_panel_bl_en); |
| 685 | | − |
| 686 | | − if (pdata->gpio_panel_vadd != -1) |
| 687 | | − gpio_free(pdata->gpio_panel_vadd); |
| 688 | | − |
| 689 | 667 | tc35876x_client = NULL; |
| 690 | 668 | |
| 691 | 669 | return 0; |