2 * drivers/mfd/rt5025-misc.c
3 * Driver foo Richtek RT5025 PMIC Misc Part
5 * Copyright (C) 2013 Richtek Electronics
6 * cy_huang <cy_huang@richtek.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/err.h>
16 #include <linux/i2c.h>
17 #include <linux/platform_device.h>
18 #include <linux/slab.h>
20 #include <linux/mfd/rt5025.h>
21 #include <linux/mfd/rt5025-misc.h>
23 struct rt5025_misc_info {
24 struct i2c_client *i2c;
27 static struct i2c_client *g_shdn;
28 void rt5025_power_off(void)
30 rt5025_set_bits(g_shdn, RT5025_SHDNCTRL_REG, RT5025_SHDNCTRL_MASK);
32 EXPORT_SYMBOL(rt5025_power_off);
34 static int __devinit rt5025_misc_reg_init(struct i2c_client *client, struct rt5025_misc_data *md)
38 rt5025_reg_write(client, RT5025_RESETCTRL_REG, md->RSTCtrl.val);
39 rt5025_assign_bits(client, RT5025_VSYSULVO_REG, RT5025_VSYSOFF_MASK, md->VSYSCtrl.val);
40 rt5025_reg_write(client, RT5025_PWRONCTRL_REG, md->PwrOnCfg.val);
41 rt5025_reg_write(client, RT5025_SHDNCTRL_REG, md->SHDNCtrl.val);
42 rt5025_reg_write(client, RT5025_PWROFFEN_REG, md->PwrOffCond.val);
47 static int __devinit rt5025_misc_probe(struct platform_device *pdev)
49 struct rt5025_chip *chip = dev_get_drvdata(pdev->dev.parent);
50 struct rt5025_platform_data *pdata = chip->dev->platform_data;
51 struct rt5025_misc_info *mi;
53 mi = kzalloc(sizeof(*mi), GFP_KERNEL);
58 rt5025_misc_reg_init(mi->i2c, pdata->misc_data);
60 //for shutdown control
63 platform_set_drvdata(pdev, mi);
67 static int __devexit rt5025_misc_remove(struct platform_device *pdev)
69 struct rt5025_misc_info *mi = platform_get_drvdata(pdev);
72 platform_set_drvdata(pdev, NULL);
76 static struct platform_driver rt5025_misc_driver =
79 .name = RT5025_DEVICE_NAME "-misc",
82 .probe = rt5025_misc_probe,
83 .remove = __devexit_p(rt5025_misc_remove),
86 static int __init rt5025_misc_init(void)
88 return platform_driver_register(&rt5025_misc_driver);
90 subsys_initcall_sync(rt5025_misc_init);
92 static void __exit rt5025_misc_exit(void)
94 platform_driver_unregister(&rt5025_misc_driver);
96 module_exit(rt5025_misc_exit);
98 MODULE_LICENSE("GPL v2");
99 MODULE_AUTHOR("CY Huang <cy_huang@richtek.com");
100 MODULE_DESCRIPTION("Misc driver for RT5025");
101 MODULE_ALIAS("platform:" RT5025_DEVICE_NAME "-misc");