#include <linux/regulator/machine.h>
#include <linux/regmap.h>
#include <linux/delay.h>
+#include <linux/syscore_ops.h>
struct ricoh619 *g_ricoh619;
struct sleep_control_data {
#define SLEEP_INIT(_id, _reg) \
[RICOH619_DS_##_id] = {.reg_add = _reg}
-
+/*
static struct sleep_control_data sleep_data[] = {
SLEEP_INIT(DC1, 0x16),
SLEEP_INIT(DC2, 0x17),
SLEEP_INIT(PSO4, 0x29),
SLEEP_INIT(LDORTC1, 0x2A),
};
+*/
static inline int __ricoh619_read(struct i2c_client *client,
u8 reg, uint8_t *val)
{
}
static struct i2c_client *ricoh619_i2c_client;
-static int ricoh619_device_shutdown(struct i2c_client *client)
+static void ricoh619_device_shutdown(void)
{
int ret;
uint8_t val;
ret = ricoh619_write(ricoh619->dev, RICOH619_INTC_INTEN, 0);
ret = ricoh619_clr_bits(ricoh619->dev,RICOH619_PWR_REP_CNT,(0x1<<0));//Not repeat power ON after power off(Power Off/N_OE)
mutex_lock(&ricoh619->io_lock);
- msleep(100);
- return 0;
+ mdelay(100);
}
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;
}
EXPORT_SYMBOL_GPL(ricoh619_power_off);
+#if 0
static int ricoh619_gpio_get(struct gpio_chip *gc, unsigned offset)
{
struct ricoh619 *ricoh619 = container_of(gc, struct ricoh619, gpio_chip);
return -EIO;
}
-
static void ricoh619_gpio_init(struct ricoh619 *ricoh619,
struct ricoh619_platform_data *pdata)
{
if (ret)
dev_warn(ricoh619->dev, "GPIO registration failed: %d\n", ret);
}
-
+#endif
static int ricoh619_remove_subdev(struct device *dev, void *unused)
{
platform_device_unregister(to_platform_device(dev));
return device_for_each_child(ricoh619->dev, NULL,
ricoh619_remove_subdev);
}
-
+#if 0
static int ricoh619_add_subdevs(struct ricoh619 *ricoh619,
struct ricoh619_platform_data *pdata)
{
ricoh619_remove_subdevs(ricoh619);
return ret;
}
-
+#endif
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
#include <linux/seq_file.h>
static struct ricoh619_platform_data *ricoh619_parse_dt(struct ricoh619 *ricoh619)
{
struct ricoh619_platform_data *pdata;
- struct device_node *regs,*ricoh619_pmic_np;
- int i, count;
+ struct device_node *ricoh619_pmic_np;
ricoh619_pmic_np = of_node_get(ricoh619->dev->of_node);
if (!ricoh619_pmic_np) {
}
#endif
+static struct syscore_ops ricoh619_syscore_ops = {
+ .shutdown = ricoh619_device_shutdown,
+};
+
static void ricoh619_noe_init(struct ricoh619 *ricoh)
{
int ret;
static int ricoh619_pre_init(struct ricoh619 *ricoh619)
{
int ret=0;
- u8 val;
printk("%s,line=%d\n", __func__,__LINE__);
/*
ret = ricoh619_read(ricoh619->dev,0x09,&val);
ricoh619_debuginit(ricoh619);
ricoh619_i2c_client = client;
+ register_syscore_ops(&ricoh619_syscore_ops);
return 0;
err:
mfd_remove_devices(ricoh619->dev);
static int ricoh619_i2c_remove(struct i2c_client *client)
{
struct ricoh619 *ricoh619 = i2c_get_clientdata(client);
+
+ unregister_syscore_ops(&ricoh619_syscore_ops);
ricoh619_remove_subdevs(ricoh619);
return 0;
}
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);
}
static int ricoh619_i2c_resume(struct i2c_client *client)
{
+ /*
uint8_t reg_val;
int ret;
- /*
ret = __ricoh619_read(client, RICOH619_INT_IR_SYS, ®_val);
if(ricoh619_pwr_key_reg & 0x01) { //If PWR_KEY wakeup
//printk("PMU: %s: PWR_KEY Wakeup %08x\n",__func__,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,
};