int hi6xxx_pmic_set_voltage(struct hi6xxx_regulator_vset_regs *vset_regs, unsigned int mask,int shift,int index) { unsigned char value_u8 = 0; unsigned int value_u32 = 0; unsigned long regulator_spin_flag = 0; /* * the spin-lock just for actomic option */ spin_lock_irqsave(®ulator_pmic_spinlock, regulator_spin_flag); /* * though value_u32 is 0,and high 24 bits is 0; * we also only get low 8 bits. */ value_u32 = (unsigned int)hi6xxx_pmic_reg_read(vset_regs->vset_reg)&0xff; BSP_REG_SETBITS(&value_u32,0,shift,mask,index); value_u8 = (unsigned char)value_u32; hi6xxx_pmic_reg_write(vset_regs->vset_reg,value_u8); spin_unlock_irqrestore(®ulator_pmic_spinlock, regulator_spin_flag); return 0; }
static void hi6xxx_save_shutdown_time(void) { unsigned int save; unsigned int msecs = 0; if ( hi6xxx_shutdown_time_start != 0){ msecs = jiffies_to_msecs(jiffies - hi6xxx_shutdown_time_start); save = (unsigned int)(msecs/1000) + 1; if(save > 0xff) save = 0xff; hi6xxx_pmic_reg_write(PMU_RSVED7,(unsigned char)save); } else { hi6xxx_pmic_reg_write(PMU_RSVED7, 0x0); } }
int hi6xxx_pmic_off(struct hi6xxx_regulator_ctrl_regs *ctrl_regs,unsigned int mask,int shift,int flag) { unsigned char value_u8 = 0; unsigned int value_u32 = 0; unsigned long regulator_spin_flag = 0; /* * the spin-lock just for actomic option */ spin_lock_irqsave(®ulator_pmic_spinlock, regulator_spin_flag); /* * though value_u32 is 0,and high 24 bits is 0; * we also only get low 8 bits. */ BSP_REG_SETBITS(&value_u32,0,shift,mask,flag); value_u8 = (unsigned char)value_u32; hi6xxx_pmic_reg_write(ctrl_regs->disable_reg,value_u8); spin_unlock_irqrestore(®ulator_pmic_spinlock, regulator_spin_flag); return 0; }