/* drivers/regulator/rk29-pwm-regulator.c\r
- *
- * Copyright (C) 2010 ROCKCHIP, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-/*******************************************************************/
-/* COPYRIGHT (C) ROCK-CHIPS FUZHOU . ALL RIGHTS RESERVED. */
-/*******************************************************************
+ *\r
+ * Copyright (C) 2010 ROCKCHIP, Inc.\r
+ *\r
+ * This software is licensed under the terms of the GNU General Public\r
+ * License version 2, as published by the Free Software Foundation, and\r
+ * may be copied, distributed, and modified under those terms.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ */\r
+/*******************************************************************/\r
+/* COPYRIGHT (C) ROCK-CHIPS FUZHOU . ALL RIGHTS RESERVED. */\r
+/*******************************************************************\r
FILE : rk29-pwm-regulator.c\r
DESC : rk29 pwm regulator driver\r
AUTHOR : hxy\r
DATE : 2010-12-20\r
-NOTES :
-$LOG: GPIO.C,V $
-REVISION 0.01
-********************************************************************/
-
-
-#include <linux/bug.h>
+NOTES :\r
+$LOG: GPIO.C,V $\r
+REVISION 0.01\r
+********************************************************************/\r
+\r
+\r
+#include <linux/bug.h>\r
#include <linux/err.h>\r
+#include <linux/hardirq.h>\r
#include <linux/platform_device.h>\r
#include <linux/kernel.h>\r
#include <linux/clk.h>\r
#include <asm/io.h>\r
#include <linux/delay.h>\r
-#include <linux/regulator/driver.h>
+#include <linux/regulator/driver.h>\r
#include <linux/regulator/rk29-pwm-regulator.h>\r
#include <mach/iomux.h>\r
#include <linux/gpio.h>\r
-
-
-#if 0
-#define DBG(x...) printk(KERN_INFO x)
-#else
-#define DBG(x...)
-#endif
+\r
+\r
+#if 0\r
+#define DBG(x...) printk(KERN_INFO x)\r
+#else\r
+#define DBG(x...)\r
+#endif\r
\r
\r
#define PWM_VCORE_120 40\r
return -1;\r
}\r
\r
- usleep_range(10*1000, 10*1000);\r
+ if (in_atomic() || irqs_disabled())\r
+ mdelay(10);\r
+ else\r
+ usleep_range(10*1000, 10*1000);\r
\r
\r
return (0);\r
{\r
DBG("Enter %s\n",__FUNCTION__);\r
return 0;\r
-}
-
+}\r
+\r
static int pwm_regulator_enable(struct regulator_dev *dev)\r
{\r
DBG("Enter %s\n",__FUNCTION__);\r
return 0;\r
-}
-
+}\r
+\r
static int pwm_regulator_disable(struct regulator_dev *dev)\r
{\r
DBG("Enter %s\n",__FUNCTION__);\r
return 0;\r
-}
-
+}\r
+\r
static int pwm_regulator_get_voltage(struct regulator_dev *dev)\r
{\r
struct pwm_platform_data *pdata = rdev_get_drvdata(dev);\r
DBG("Enter %s\n",__FUNCTION__); \r
\r
return (pdata->pwm_voltage*1000);\r
-}
-
+}\r
+\r
static int pwm_regulator_set_voltage(struct regulator_dev *dev,\r
int min_uV, int max_uV)\r
{ \r
DBG("%s: min_uV = %d, max_uV = %d\n",__FUNCTION__, min_uV,max_uV);\r
\r
if (min_mV < voltage_map[0] ||max_mA > voltage_map[size-1])\r
- return -EINVAL;
-
+ return -EINVAL;\r
+ \r
for (i = 0; i < size; i++)\r
{\r
if (voltage_map[i] >= min_mV)\r
- break;
+ break;\r
}\r
-
+\r
\r
vol = voltage_map[i];\r
\r
\r
return 0;\r
\r
-}
-
+}\r
+\r
static struct regulator_ops pwm_voltage_ops = {\r
.list_voltage = pwm_regulator_list_voltage,\r
.set_voltage =pwm_regulator_set_voltage,\r
.disable = pwm_regulator_disable,\r
.is_enabled = pwm_regulator_is_enabled,\r
};\r
-
+\r
static struct regulator_desc pwm_regulator= {\r
.name = "pwm-regulator",\r
.ops = &pwm_voltage_ops,\r
.type = REGULATOR_VOLTAGE,\r
};\r
-
+\r
static int __devinit pwm_regulator_probe(struct platform_device *pdev)\r
{\r
\r
struct pwm_platform_data *pdata = pdev->dev.platform_data;\r
struct regulator_dev *rdev;\r
int ret ;\r
-
- if (!pdata)
- return -ENODEV;
-
- if (!pdata->pwm_voltage)
- pdata->pwm_voltage = 1200; // default 1.2v
-
+\r
+ if (!pdata)\r
+ return -ENODEV;\r
+\r
+ if (!pdata->pwm_voltage)\r
+ pdata->pwm_voltage = 1200; // default 1.2v\r
+\r
rdev = regulator_register(&pwm_regulator, &pdev->dev,\r
pdata->init_data, pdata);\r
if (IS_ERR(rdev)) {\r
- dev_dbg(&pdev->dev, "couldn't register regulator\n");
+ dev_dbg(&pdev->dev, "couldn't register regulator\n");\r
return PTR_ERR(rdev);\r
}\r
\r
\r
return ret;\r
\r
-}
+}\r
static int __devexit pwm_regulator_remove(struct platform_device *pdev)\r
{\r
struct pwm_platform_data *pdata = pdev->dev.platform_data;\r
},\r
.remove = __devexit_p(pwm_regulator_remove),\r
};\r
-
+\r
\r
static int __init pwm_regulator_module_init(void)\r
-{
+{\r
return platform_driver_probe(&pwm_regulator_driver, pwm_regulator_probe);\r
-}
-
+}\r
+\r
static void __exit pwm_regulator_module_exit(void)\r
-{
+{\r
platform_driver_unregister(&pwm_regulator_driver);\r
-}
+}\r
\r
\r
subsys_initcall(pwm_regulator_module_init);\r
\r
module_exit(pwm_regulator_module_exit);\r
-
-MODULE_LICENSE("GPL");
+\r
+MODULE_LICENSE("GPL");\r
MODULE_AUTHOR("hxy <hxy@rock-chips.com>");\r
MODULE_DESCRIPTION("k29 pwm change driver");\r