static int aml_bl_update_status(struct backlight_device *bd)
{
    struct aml_bl *amlbl = bl_get_data(bd);
    int brightness = bd->props.brightness;
#ifdef CONFIG_ARCH_MESON6  
	static int led_pwm_off = 0; 
#endif
    DPRINT("%s() brightness=%d\n", __FUNCTION__, brightness);
    DPRINT("%s() pdata->set_bl_level=%p\n", __FUNCTION__, amlbl->pdata->set_bl_level);

/*
    if (bd->props.power != FB_BLANK_UNBLANK)
        brightness = 0;
    if (bd->props.fb_blank != FB_BLANK_UNBLANK)
        brightness = 0;
*/

    if (brightness < 0)
        brightness = 0;
    else if (brightness > 255)
        brightness = 255;

#ifdef CONFIG_ARCH_MESON6           
    if (led_pwm_off && brightness > 0) {
    	switch_mod_gate_by_type(MOD_LED_PWM, 1);
    	led_pwm_off = 0;
    }
#endif /* CONFIG_ARCH_MESON6 */

#ifndef CONFIG_MESON_CS_DCDC_REGULATOR
    if ((brightness > 0) && (0 == IS_CLK_GATE_ON(VGHL_PWM))) {
        CLK_GATE_ON(VGHL_PWM);
        DPRINT("%s() CLK_GATE_ON(VGHL_PWM)\n", __FUNCTION__);
    }
#endif

    if (amlbl->pdata->set_bl_level)
        amlbl->pdata->set_bl_level(brightness);

#ifndef CONFIG_MESON_CS_DCDC_REGULATOR
    if ((brightness == 0) && (IS_CLK_GATE_ON(VGHL_PWM))) {
        CLK_GATE_OFF(VGHL_PWM);
        DPRINT("%s() CLK_GATE_OFF(VGHL_PWM)\n", __FUNCTION__);
    }
#endif

#ifdef CONFIG_ARCH_MESON6       
    if (brightness == 0) {
    	switch_mod_gate_by_type(MOD_LED_PWM, 0);
    	led_pwm_off = 1;
    }
#endif /* CONFIG_ARCH_MESON6 */

    return 0;
}
Пример #2
0
static void set_usb_phy_config(int cfg)
{
    const int time_dly = 500;
    usb_aml_regs_t * usb_aml_regs = (usb_aml_regs_t * )PREI_USB_PHY_REG_BASE;
    usb_config_data_t config;
    usb_ctrl_data_t control;

    /*CLK_GATE_ON(USB0);*/
    if (!IS_CLK_GATE_ON(USB0)) {
            SET_CBUS_REG_MASK(GCLK_REG_USB0, GCLK_MASK_USB0);
    }
    /*printf("%s %d\n", __func__, __LINE__);*/
    cfg = cfg;//avoid compiler warning
    /**P_RESET1_REGISTER = (1<<2);//usb reset*/
	writel((1 << 2),P_RESET1_REGISTER);	//usb reset
    udelay(time_dly);//by Sam: delay after reset

  	config.d32 = usb_aml_regs->config;

//    config.b.clk_sel    = 0;
//    config.b.clk_div    = 1; 
//    config.b.clk_32k_alt_sel = 1;
  	usb_aml_regs->config = config.d32;

    control.d32 = usb_aml_regs->ctrl;
    control.b.fsel = 5;
    control.b.por = 1;
    usb_aml_regs->ctrl = control.d32;
    udelay(time_dly);

    control.b.por = 0;
    usb_aml_regs->ctrl = control.d32;
    udelay(time_dly);//by Sam: delay 0.5s to wait usb clam down

    control.d32 = usb_aml_regs->ctrl;
    if(!control.b.clk_detected){
        printf("Error, usb phy clock not detected!\n");
    }

    return;
}
Пример #3
0
static void set_usb_phy_config(int cfg)
{
    const int time_dly = 500;
    u2p_aml_regs_t * u2p_aml_regs = (u2p_aml_regs_t * )PREI_USB_PHY_2_REG_BASE;
    usb_aml_regs_t * usb_aml_regs = (usb_aml_regs_t * )PREI_USB_PHY_3_REG_BASE;
    
    u2p_r0_t u2p_r0;
    usb_r0_t usb_r0;
    usb_r4_t usb_r4;

    if (!IS_CLK_GATE_ON(USB0)) {
            SET_CBUS_REG_MASK(GCLK_REG_USB0, GCLK_MASK_USB0);
    }
    /*printf("%s %d\n", __func__, __LINE__);*/
    cfg = cfg;//avoid compiler warning
    /**P_RESET1_REGISTER = (1<<2);//usb reset*/
	  writel((1 << 2),P_RESET1_REGISTER);	//usb reset
    udelay(time_dly);//by Sam: delay after reset

		u2p_r0.d32 = u2p_aml_regs->u2p_r0;
		u2p_r0.b.fsel = 5;
    u2p_r0.b.por = 1;
		u2p_aml_regs->u2p_r0 = u2p_r0.d32;

		u2p_r0.d32 = u2p_aml_regs->u2p_r0;
		u2p_r0.b.por = 0;
		u2p_aml_regs->u2p_r0 = u2p_r0.d32;		
		
  	usb_r0.d32 = usb_aml_regs->usb_r0;	
		usb_r0.b.u2d_act = 1;
		usb_aml_regs->usb_r0 = usb_r0.d32;	
		
    usb_r4.d32 = usb_aml_regs->usb_r4;
    usb_r4.b.p21_SLEEPM0 = 1;
    usb_aml_regs->usb_r4 = usb_r4.d32;	
    
    udelay(time_dly);	
    return;
}