video: backlight: use gpio request and free apis for backlight pin
Sanjay Singh Rawat [Tue, 26 Jun 2012 10:46:56 +0000 (15:46 +0530)]
- Gpio freeing function does disabling job.
- If backlight pin is an sfio, we have to claim the gpio. So that we can use
the gpio api's to configure it as sfio.

bug 984440
bug 858120

Change-Id: I583bf4a486d2d9a6d9b78ee459b1962379eafd3b
Signed-off-by: Sanjay Singh Rawat <srawat@nvidia.com>
Reviewed-on: http://git-master/r/109564
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

arch/arm/mach-tegra/board-enterprise-panel.c
arch/arm/mach-tegra/board-whistler-panel.c
arch/arm/mach-tegra/include/mach/dc.h
drivers/video/backlight/tegra_pwm_bl.c
drivers/video/tegra/dc/dc.c
include/linux/tegra_pwm_bl.h

index d63806a..622a113 100644 (file)
@@ -194,7 +194,6 @@ static struct platform_tegra_pwm_backlight_data enterprise_disp1_backlight_data
        .which_dc               = 0,
        .which_pwm              = TEGRA_PWM_PM1,
        .gpio_conf_to_sfio      = TEGRA_GPIO_PW1,
-       .switch_to_sfio         = &tegra_gpio_disable,
        .max_brightness         = 255,
        .dft_brightness         = 224,
        .notify         = enterprise_backlight_notify,
index 26dcb5f..dfab34a 100644 (file)
@@ -62,7 +62,6 @@ static struct platform_tegra_pwm_backlight_data whistler_disp1_backlight_data =
        .max_brightness = 256,
        .dft_brightness = 77,
        .gpio_conf_to_sfio      = TEGRA_GPIO_PW1,
-       .switch_to_sfio         = &tegra_gpio_disable,
        .period = 0x1F,
        .clk_div = 3,
        .clk_select = 2,
index 51c8649..dcce1be 100644 (file)
@@ -616,7 +616,6 @@ unsigned tegra_dc_get_out_max_pixclock(const struct tegra_dc *dc);
 
 struct tegra_dc_pwm_params {
        int which_pwm;
-       void (*switch_to_sfio)(int);
        int gpio_conf_to_sfio;
        unsigned int period;
        unsigned int clk_div;
index 4be691c..a9a429e 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/tegra_pwm_bl.h>
+#include <linux/gpio.h>
 #include <mach/dc.h>
 
 struct tegra_pwm_bl_data {
@@ -112,11 +113,17 @@ static int tegra_pwm_backlight_probe(struct platform_device *pdev)
        tbl->check_fb = data->check_fb;
        tbl->params.which_pwm = data->which_pwm;
        tbl->params.gpio_conf_to_sfio = data->gpio_conf_to_sfio;
-       tbl->params.switch_to_sfio = data->switch_to_sfio;
        tbl->params.period = data->period;
        tbl->params.clk_div = data->clk_div;
        tbl->params.clk_select = data->clk_select;
 
+       /* If backlight pin is sfio, request for it */
+       if (gpio_is_valid(tbl->params.gpio_conf_to_sfio)) {
+               ret = gpio_request(tbl->params.gpio_conf_to_sfio, "disp_bl");
+               if (ret)
+                       dev_err(&pdev->dev, "backlight gpio request failed\n");
+       }
+
        memset(&props, 0, sizeof(struct backlight_properties));
        props.type = BACKLIGHT_RAW;
        props.max_brightness = data->max_brightness;
@@ -129,6 +136,9 @@ static int tegra_pwm_backlight_probe(struct platform_device *pdev)
        }
 
        bl->props.brightness = data->dft_brightness;
+
+       if (gpio_is_valid(tbl->params.gpio_conf_to_sfio))
+               gpio_free(tbl->params.gpio_conf_to_sfio);
        backlight_update_status(bl);
 
        platform_set_drvdata(pdev, bl);
index 640ef98..0c937b9 100644 (file)
@@ -906,11 +906,6 @@ tegra_dc_config_pwm(struct tegra_dc *dc, struct tegra_dc_pwm_params *cfg)
        cmd_state = tegra_dc_readl(dc, DC_CMD_STATE_ACCESS);
        tegra_dc_writel(dc, (cmd_state | (1 << 2)), DC_CMD_STATE_ACCESS);
 
-       if (cfg->switch_to_sfio && cfg->gpio_conf_to_sfio)
-               cfg->switch_to_sfio(cfg->gpio_conf_to_sfio);
-       else
-               dev_err(&dc->ndev->dev, "Error: Need gpio_conf_to_sfio\n");
-
        switch (cfg->which_pwm) {
        case TEGRA_PWM_PM0:
                /* Select the LM0 on PM0 */
index 71a81f2..3ed5e8a 100644 (file)
@@ -17,7 +17,6 @@
 struct platform_tegra_pwm_backlight_data {
        int which_dc;
        int which_pwm;
-       void (*switch_to_sfio)(int);
        int gpio_conf_to_sfio;
        unsigned int dft_brightness;
        unsigned int max_brightness;