#include <linux/mfd/ricoh619.h>
#include <linux/irqdomain.h>
+static DEFINE_MUTEX(int_flag_mutex);
enum int_type {
SYS_INT = 0x1,
{
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])
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])
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)
int_sts[6] |= int_sts[7];
/* Call interrupt handler if enabled */
-
+ mutex_lock(&int_flag_mutex);
for (i = 0; i <RICOH619_NR_IRQS; ++i) {
const struct ricoh619_irq_data *data = &ricoh619_irqs[i];
if ((int_sts[data->mask_reg_index] & (1 << data->int_en_bit)) &&(ricoh619->group_irq_en[data->master_bit] & (1 << data->grp_index))){
handle_nested_irq(cur_irq);
}
}
+ mutex_unlock(&int_flag_mutex);
// printk(KERN_INFO "PMU: %s: out\n", __func__);
return IRQ_HANDLED;
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,
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;
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);
__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[] = {
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,
};