/**************************************************************************** * internal functions ***************************************************************************/ static int brightness_set_pwm(int pwm_num, enum led_brightness level,struct PWM_config *config_data) { struct pwm_spec_config pwm_setting; pwm_setting.pwm_no = pwm_num; pwm_setting.mode = PWM_MODE_FIFO; //new mode fifo and periodical mode // pwm_setting.clk_div = CLK_DIV1; // pwm_setting.clk_src = PWM_CLK_NEW_MODE_BLOCK_DIV_BY_1625; if(config_data->div) { pwm_setting.clk_div = config_data->div; backlight_PWM_div = config_data->div; } else pwm_setting.clk_div = CLK_DIV1; if(config_data->clock_source) pwm_setting.clk_src = PWM_CLK_NEW_MODE_BLOCK; else pwm_setting.clk_src = PWM_CLK_NEW_MODE_BLOCK_DIV_BY_1625; if(config_data->High_duration && config_data->low_duration) { pwm_setting.PWM_MODE_FIFO_REGS.HDURATION = config_data->High_duration; pwm_setting.PWM_MODE_FIFO_REGS.LDURATION = config_data->low_duration; } else { pwm_setting.PWM_MODE_FIFO_REGS.HDURATION = 4; pwm_setting.PWM_MODE_FIFO_REGS.LDURATION = 4; } pwm_setting.PWM_MODE_FIFO_REGS.IDLE_VALUE = 0; pwm_setting.PWM_MODE_FIFO_REGS.GUARD_VALUE = 0; pwm_setting.PWM_MODE_FIFO_REGS.STOP_BITPOS_VALUE = 63; // pwm_setting.PWM_MODE_FIFO_REGS.HDURATION = 4; // pwm_setting.PWM_MODE_FIFO_REGS.LDURATION = 4; pwm_setting.PWM_MODE_FIFO_REGS.GDURATION = 0; pwm_setting.PWM_MODE_FIFO_REGS.WAVE_NUM = 0; printf("[LEDS]uboot: backlight_set_pwm:duty is %d\n", level); if(level > 0) { pwm_setting.PWM_MODE_FIFO_REGS.SEND_DATA0 = ((1 << 30) - 1); pwm_setting.PWM_MODE_FIFO_REGS.SEND_DATA1 = 0 ; pwm_set_spec_config(&pwm_setting); } else { mt_set_pwm_disable(pwm_setting.pwm_no); mt_power_off (pwm_setting.pwm_no); } return 0; }
ssize_t gpio_FL_Disable(void) { mt_set_pwm_disable(fl_pwm_num); mt_pwm_power_off(fl_pwm_num); mt_set_gpio_mode(48, GPIO_MODE_00); mt_set_gpio_dir(48, GPIO_DIR_OUT); mt_set_gpio_out(48, GPIO_OUT_ZERO); return 0; }
static int brightness_set_pwm(int pwm_num, enum led_brightness level,struct PWM_config *config_data) { struct pwm_spec_config pwm_setting; pwm_setting.pwm_no = pwm_num; pwm_setting.mode = PWM_MODE_FIFO; //new mode fifo and periodical mode // pwm_setting.clk_div = CLK_DIV1; // pwm_setting.clk_src = PWM_CLK_NEW_MODE_BLOCK_DIV_BY_1625; if(config_data->div) { pwm_setting.clk_div = config_data->div; backlight_PWM_div = config_data->div; } else pwm_setting.clk_div = CLK_DIV1; if(config_data->clock_source) pwm_setting.clk_src = PWM_CLK_NEW_MODE_BLOCK; else pwm_setting.clk_src = PWM_CLK_NEW_MODE_BLOCK_DIV_BY_1625; pwm_setting.clk_src = PWM_CLK_NEW_MODE_BLOCK; if(config_data->High_duration && config_data->low_duration) { pwm_setting.PWM_MODE_FIFO_REGS.HDURATION = config_data->High_duration; pwm_setting.PWM_MODE_FIFO_REGS.LDURATION = config_data->low_duration; } else { pwm_setting.PWM_MODE_FIFO_REGS.HDURATION = 4; pwm_setting.PWM_MODE_FIFO_REGS.LDURATION = 4; } pwm_setting.PWM_MODE_FIFO_REGS.IDLE_VALUE = 0; pwm_setting.PWM_MODE_FIFO_REGS.GUARD_VALUE = 0; pwm_setting.PWM_MODE_FIFO_REGS.STOP_BITPOS_VALUE = 63; // pwm_setting.PWM_MODE_FIFO_REGS.HDURATION = 4; // pwm_setting.PWM_MODE_FIFO_REGS.LDURATION = 4; pwm_setting.PWM_MODE_FIFO_REGS.GDURATION = 0; pwm_setting.PWM_MODE_FIFO_REGS.WAVE_NUM = 0; printf("[LEDS]uboot: backlight_set_pwm:duty is %d\n", level); if(level > 0) { pwm_setting.PWM_MODE_FIFO_REGS.SEND_DATA0 = ((1 << 30) - 1); pwm_setting.PWM_MODE_FIFO_REGS.SEND_DATA1 = 0 ; pwm_set_spec_config(&pwm_setting); } else { mt_set_pwm_disable(pwm_setting.pwm_no); mt_power_off (pwm_setting.pwm_no); } //hongmei temp change for camry&megan #if defined(JRD_CAMRY_BORAD) mt_set_gpio_mode(GPIO68,1); //baoqiang add:GPIO_PWM_3_PIN-GPIO68,GPIO_PWM_3_PIN_M_PWM-1 //printf("[qbq]uboot:backlight set gpio pwm mode\n"); #endif return 0; }