From: 张晴 Date: Fri, 6 Jun 2014 03:04:37 +0000 (+0800) Subject: rk3288:pmic:ricoh619:add some lock and modify suspend func X-Git-Tag: firefly_0821_release~5173 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=771f732bdb8900459786cb0c4ccd005e581d84e4;p=firefly-linux-kernel-4.4.55.git rk3288:pmic:ricoh619:add some lock and modify suspend func --- diff --git a/drivers/mfd/ricoh619-irq.c b/drivers/mfd/ricoh619-irq.c index e3fba0d99b9c..472a75502bd9 100755 --- a/drivers/mfd/ricoh619-irq.c +++ b/drivers/mfd/ricoh619-irq.c @@ -31,6 +31,7 @@ #include #include +static DEFINE_MUTEX(int_flag_mutex); enum int_type { SYS_INT = 0x1, @@ -226,6 +227,7 @@ static void ricoh619_irq_unmask(struct irq_data *irq_data) { struct ricoh619 *ricoh619 = irq_data_get_irq_chip_data(irq_data); const struct ricoh619_irq_data *data= irq_to_ricoh619_irq(ricoh619,irq_data->irq); + mutex_lock(&int_flag_mutex); ricoh619->group_irq_en[data->master_bit] |= (1 << data->grp_index); if (ricoh619->group_irq_en[data->master_bit]) @@ -237,12 +239,14 @@ static void ricoh619_irq_unmask(struct irq_data *irq_data) else ricoh619->irq_en_reg[data->mask_reg_index] |= 1 << data->int_en_bit; + mutex_unlock(&int_flag_mutex); } static void ricoh619_irq_mask(struct irq_data *irq_data) { struct ricoh619 *ricoh619 = irq_data_get_irq_chip_data(irq_data); const struct ricoh619_irq_data *data= irq_to_ricoh619_irq(ricoh619,irq_data->irq); + mutex_lock(&int_flag_mutex); ricoh619->group_irq_en[data->master_bit] &= ~(1 << data->grp_index); if (!ricoh619->group_irq_en[data->master_bit]) @@ -254,6 +258,7 @@ static void ricoh619_irq_mask(struct irq_data *irq_data) else ricoh619->irq_en_reg[data->mask_reg_index] &= ~(1 << data->int_en_bit); + mutex_unlock(&int_flag_mutex); } static void ricoh619_irq_sync_unlock(struct irq_data *irq_data) @@ -423,7 +428,7 @@ static irqreturn_t ricoh619_irq(int irq, void *data) int_sts[6] |= int_sts[7]; /* Call interrupt handler if enabled */ - + mutex_lock(&int_flag_mutex); for (i = 0; i mask_reg_index] & (1 << data->int_en_bit)) &&(ricoh619->group_irq_en[data->master_bit] & (1 << data->grp_index))){ @@ -432,6 +437,7 @@ static irqreturn_t ricoh619_irq(int irq, void *data) handle_nested_irq(cur_irq); } } + mutex_unlock(&int_flag_mutex); // printk(KERN_INFO "PMU: %s: out\n", __func__); return IRQ_HANDLED; @@ -439,8 +445,10 @@ static irqreturn_t ricoh619_irq(int irq, void *data) static struct irq_chip ricoh619_irq_chip = { .name = "ricoh619", - .irq_mask = ricoh619_irq_mask, - .irq_unmask = ricoh619_irq_unmask, + //.irq_mask = ricoh619_irq_mask, + //.irq_unmask = ricoh619_irq_unmask, + .irq_enable = ricoh619_irq_unmask, + .irq_disable = ricoh619_irq_mask, .irq_bus_lock = ricoh619_irq_lock, .irq_bus_sync_unlock = ricoh619_irq_sync_unlock, .irq_set_type = ricoh619_irq_set_type, diff --git a/drivers/mfd/ricoh619.c b/drivers/mfd/ricoh619.c index feb23c8c96e8..0893bd1b0f05 100755 --- a/drivers/mfd/ricoh619.c +++ b/drivers/mfd/ricoh619.c @@ -429,7 +429,7 @@ static int ricoh619_device_shutdown(struct i2c_client *client) return 0; } EXPORT_SYMBOL_GPL(ricoh619_device_shutdown); -static int ricoh619_power_off(void) +static void ricoh619_power_off(void) { int ret,i=0; uint8_t val,charge_state; @@ -912,9 +912,10 @@ extern u8 ricoh619_pwr_key_reg; int ricoh619_pwrkey_wakeup = 0; static int ricoh619_i2c_suspend(struct i2c_client *client, pm_message_t state) { -// if (g_ricoh619->chip_irq) -// disable_irq(g_ricoh619->chip_irq); // printk("PMU: %s: \n",__func__); + + if (g_ricoh619->chip_irq) + disable_irq(g_ricoh619->chip_irq); ricoh619_pwrkey_wakeup = 1; __ricoh619_write(client, RICOH619_INT_IR_SYS, 0x0); //Clear PWR_KEY IRQ __ricoh619_read(client, RICOH619_INT_IR_SYS, &ricoh619_pwr_key_reg); @@ -932,10 +933,33 @@ static int ricoh619_i2c_resume(struct i2c_client *client) __ricoh619_write(client, RICOH619_INT_IR_SYS, 0x0); //Clear PWR_KEY IRQ } */ -// enable_irq(g_ricoh619->chip_irq); + + if (g_ricoh619->chip_irq) + enable_irq(g_ricoh619->chip_irq); return 0; } +static int ricoh619_i2c_late_suspend(struct device *dev) +{ + struct i2c_client *client = i2c_verify_client(dev); + + ricoh619_i2c_suspend(client,PMSG_SUSPEND); + return 0; +} + +static int rockchip_i2c_late_resume(struct device *dev) +{ + struct i2c_client *client = i2c_verify_client(dev); + + ricoh619_i2c_resume(client); + return 0; +} + +static const struct dev_pm_ops ricoh619_i2c_dev_pm= { + .suspend_late = ricoh619_i2c_late_suspend, + .resume_early = rockchip_i2c_late_resume, +}; + #endif static const struct i2c_device_id ricoh619_i2c_id[] = { @@ -952,20 +976,19 @@ static const struct of_device_id ricoh619_dt_match[] = { MODULE_DEVICE_TABLE(of, ricoh619_dt_match); #endif - static struct i2c_driver ricoh619_i2c_driver = { .driver = { .name = "ricoh619", .owner = THIS_MODULE, + #ifdef CONFIG_PM + .pm = (&ricoh619_i2c_dev_pm), + #endif .of_match_table = of_match_ptr(ricoh619_dt_match), }, .probe = ricoh619_i2c_probe, .remove = ricoh619_i2c_remove, .shutdown = ricoh619_device_shutdown, -#ifdef CONFIG_PM - .suspend = ricoh619_i2c_suspend, - .resume = ricoh619_i2c_resume, -#endif + .id_table = ricoh619_i2c_id, };