display: JDI: config backlight level when kernel init

1. Remove the gpio 26 config in board-flo-pmic.c
   since this gpio is already config as PWM function in LK.

2. Add pwm_init function implementation.

3. Config backlight level in pm8xxx_led_probe(), and remove the
   pwm_request() part in panel probe function.

Change-Id: I3ce71a9c792ce155bebabd80a24a8ff8fc361ae9
Signed-off-by: yetta_wu <yetta_wu@asus.com>
This commit is contained in:
yetta_wu 2013-04-12 23:32:12 +08:00 committed by Iliyan Malchev
parent a7957398f7
commit 8ca7624ab7
4 changed files with 42 additions and 37 deletions

View file

@ -31,6 +31,9 @@
#include "board-flo.h"
#include <mach/board_asustek.h>
#include <linux/mfd/pm8xxx/core.h>
#include <linux/mfd/pm8xxx/pwm.h>
struct pm8xxx_gpio_init {
unsigned gpio;
struct pm_gpio config;
@ -132,8 +135,8 @@ static struct pm8xxx_gpio_init pm8921_gpios[] __initdata = {
PM8921_GPIO_OUTPUT_BUFCONF(25, 0, LOW, CMOS), /* DISP_RESET_N */
//PM8921_GPIO_OUTPUT_FUNC(26, 0, PM_GPIO_FUNC_2), /* Bl: Off, PWM mode */
//PM8921_GPIO_OUTPUT_VIN(30, 1, PM_GPIO_VIN_VPH), /* SMB349 susp line */
/* Bl: On, PWM mode */
PM8921_GPIO_OUTPUT_FUNC_L17(26, 1, PM_GPIO_FUNC_2),
/* Bl: On, PWM mode */
/* remove pwm function config because bootloader have done this*/
PM8921_GPIO_OUTPUT(2, 1, HIGH), /* SLIMPORT_PWR_DWN */
PM8921_GPIO_OUTPUT(1, 0, HIGH), /* SLIMPORT_RESET_N */
PM8921_GPIO_OUTPUT_FUNC(44, 0, PM_GPIO_FUNC_2),
@ -339,11 +342,40 @@ static struct pm8xxx_led_config pm8921_led_configs[] = {
},
};
#define PWM_FREQ_HZ 300
#define PWM_PERIOD_USEC (USEC_PER_SEC / PWM_FREQ_HZ)
#define PWM_LEVEL 255
#define PWM_DUTY_LEVEL \
(PWM_PERIOD_USEC / PWM_LEVEL)
#define BL_INIT_LEVEL 102 /* 255 x 40% */
struct pwm_device *bl_lpm;
static void apq8064_pm8921_pwm_init(void)
{
int ret;
pr_info("%s+\n", __func__);
bl_lpm = pwm_request(2, "backlight");
ret = pwm_config(bl_lpm, PWM_DUTY_LEVEL * BL_INIT_LEVEL,
PWM_PERIOD_USEC);
if (ret)
pr_err("pwm_config on lpm failed %d\n", ret);
ret = pwm_enable(bl_lpm);
if (ret)
pr_err("pwm enable failed for bl %d\n", BL_INIT_LEVEL);
pr_info("%s-\n", __func__);
}
static struct pm8xxx_led_platform_data apq8064_pm8921_leds_pdata = {
.led_core = &pm8921_led_core_pdata,
.configs = pm8921_led_configs,
.num_configs = ARRAY_SIZE(pm8921_led_configs),
.use_pwm = 1,
.pwm_init = apq8064_pm8921_pwm_init,
};
static struct pm8xxx_adc_amux apq8064_pm8921_adc_channels_data[] = {

View file

@ -1274,6 +1274,10 @@ static int __devinit pm8xxx_led_probe(struct platform_device *pdev)
}
}
/* Config PWM */
if ((pdata) && (pdata->pwm_init))
pdata->pwm_init();
return 0;
fail_id_check:

View file

@ -41,13 +41,10 @@
static int gpio_LCD_BL_EN = gpio_LCD_BL_EN_SR2;
static int gpio_LCM_XRES = gpio_LCM_XRES_SR2;
static bool first_cmd = true;
static bool first = true;
static hw_rev hw_revision;
static unsigned gpio;
static struct pm_gpio config;
static struct mipi_dsi_panel_platform_data *mipi_JDI_pdata;
static struct pwm_device *bl_lpm;
extern struct pwm_device *bl_lpm;
static struct dsi_buf JDI_tx_buf;
static struct dsi_buf JDI_rx_buf;
@ -256,14 +253,6 @@ static void mipi_JDI_set_backlight(struct msm_fb_data_type *mfd)
pr_debug("%s: back light level %d\n", __func__, mfd->bl_level);
if (first) {
ret = pm8xxx_gpio_config(gpio, &config);
if (ret)
pr_err("%s: pm8xxx_gpio_config failed: ret=%d\n",
__func__, ret);
first = false;
}
if (bl_lpm) {
if (mfd->bl_level) {
if (hw_revision != 0x3) {
@ -317,14 +306,6 @@ static void mipi_JDI_set_recovery_backlight(struct msm_fb_data_type *mfd)
pr_info("%s: backlight level %d\n", __func__, recovery_backlight);
if (first) {
ret = pm8xxx_gpio_config(gpio, &config);
if (ret)
pr_err("%s: pm8xxx_gpio_config failed: ret=%d\n",
__func__, ret);
first = false;
}
if (bl_lpm) {
if (hw_revision != 0x3) {
ret = pwm_config(bl_lpm, PWM_DUTY_LEVEL *
@ -402,11 +383,10 @@ static int __devinit mipi_JDI_lcd_probe(struct platform_device *pdev)
if (mipi_JDI_pdata == NULL) {
pr_err("%s.invalid platform data.\n", __func__);
return -ENODEV;
} else {
bl_lpm = pwm_request(mipi_JDI_pdata->gpio[0],
"backlight");
}
/* already request bl_lpm in leds_pm8xxx.c, pm8xxx_led_probe() */
if (bl_lpm == NULL || IS_ERR(bl_lpm)) {
pr_err("%s pwm_request() failed\n", __func__);
bl_lpm = NULL;
@ -423,18 +403,6 @@ static int __devinit mipi_JDI_lcd_probe(struct platform_device *pdev)
gpio_LCM_XRES = gpio_LCM_XRES_SR1;
}
/* set PWM config */
gpio = gpio_PWM;
config.direction = PM_GPIO_DIR_OUT;
config.output_buffer = PM_GPIO_OUT_BUF_CMOS;
config.output_value = 0;
config.pull = PM_GPIO_PULL_NO;
config.vin_sel = PM_GPIO_VIN_L17;
config.out_strength = PM_GPIO_STRENGTH_HIGH;
config.function = PM_GPIO_FUNC_2;
config.inv_int_pol = 0;
config.disable_pin = 0;
pr_info("%s-\n", __func__);
return 0;
}

View file

@ -136,5 +136,6 @@ struct pm8xxx_led_platform_data {
struct pm8xxx_led_config *configs;
u32 num_configs;
int use_pwm;
void (*pwm_init) (void);
};
#endif /* __LEDS_PM8XXX_H__ */