Skip to content

Commit 156f252

Browse files
kyungmin-parkLiam Girdwood
authored andcommitted
drivers: regulator: add Maxim 8998 driver
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> This patch adds voltage regulator driver for Maxim 8998 chip. This chip is used on Samsung Aquila and GONI boards and provides following functionalities: - 4 BUCK voltage converters, 17 LDO power regulators and 5 other power controllers - battery charger This patch adds basic driver for voltage regulators and MAX 8998 MFD core. Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
1 parent 51bd694 commit 156f252

8 files changed

Lines changed: 981 additions & 0 deletions

File tree

‎drivers/mfd/Kconfig‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,16 @@ config MFD_MAX8925
252252
accessing the device, additional drivers must be enabled in order
253253
to use the functionality of the device.
254254

255+
config MFD_MAX8998
256+
bool "Maxim Semiconductor MAX8998 PMIC Support"
257+
depends on I2C=y
258+
select MFD_CORE
259+
help
260+
Say yes here to support for Maxim Semiconductor MAX8998. This is
261+
a Power Management IC. This driver provies common support for
262+
accessing the device, additional drivers must be enabled in order
263+
to use the functionality of the device.
264+
255265
config MFD_WM8400
256266
tristate "Support Wolfson Microelectronics WM8400"
257267
select MFD_CORE

‎drivers/mfd/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o
5656
obj-$(CONFIG_PMIC_DA903X) += da903x.o
5757
max8925-objs := max8925-core.o max8925-i2c.o
5858
obj-$(CONFIG_MFD_MAX8925) += max8925.o
59+
obj-$(CONFIG_MFD_MAX8998) += max8998.o
5960

6061
pcf50633-objs := pcf50633-core.o pcf50633-irq.o
6162
obj-$(CONFIG_MFD_PCF50633) += pcf50633.o

‎drivers/mfd/max8998.c‎

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
* max8698.c - mfd core driver for the Maxim 8998
3+
*
4+
* Copyright (C) 2009-2010 Samsung Electronics
5+
* Kyungmin Park <kyungmin.park@samsung.com>
6+
* Marek Szyprowski <m.szyprowski@samsung.com>
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
*/
22+
23+
#include <linux/module.h>
24+
#include <linux/moduleparam.h>
25+
#include <linux/init.h>
26+
#include <linux/slab.h>
27+
#include <linux/i2c.h>
28+
#include <linux/mutex.h>
29+
#include <linux/mfd/core.h>
30+
#include <linux/mfd/max8998.h>
31+
#include <linux/mfd/max8998-private.h>
32+
33+
static struct mfd_cell max8998_devs[] = {
34+
{
35+
.name = "max8998-pmic",
36+
}
37+
};
38+
39+
static int max8998_i2c_device_read(struct max8998_dev *max8998, u8 reg, u8 *dest)
40+
{
41+
struct i2c_client *client = max8998->i2c_client;
42+
int ret;
43+
44+
mutex_lock(&max8998->iolock);
45+
ret = i2c_smbus_read_byte_data(client, reg);
46+
mutex_unlock(&max8998->iolock);
47+
if (ret < 0)
48+
return ret;
49+
50+
ret &= 0xff;
51+
*dest = ret;
52+
return 0;
53+
}
54+
55+
static int max8998_i2c_device_write(struct max8998_dev *max8998, u8 reg, u8 value)
56+
{
57+
struct i2c_client *client = max8998->i2c_client;
58+
int ret;
59+
60+
mutex_lock(&max8998->iolock);
61+
ret = i2c_smbus_write_byte_data(client, reg, value);
62+
mutex_unlock(&max8998->iolock);
63+
return ret;
64+
}
65+
66+
static int max8998_i2c_device_update(struct max8998_dev *max8998, u8 reg,
67+
u8 val, u8 mask)
68+
{
69+
struct i2c_client *client = max8998->i2c_client;
70+
int ret;
71+
72+
mutex_lock(&max8998->iolock);
73+
ret = i2c_smbus_read_byte_data(client, reg);
74+
if (ret >= 0) {
75+
u8 old_val = ret & 0xff;
76+
u8 new_val = (val & mask) | (old_val & (~mask));
77+
ret = i2c_smbus_write_byte_data(client, reg, new_val);
78+
if (ret >= 0)
79+
ret = 0;
80+
}
81+
mutex_unlock(&max8998->iolock);
82+
return ret;
83+
}
84+
85+
static int max8998_i2c_probe(struct i2c_client *i2c,
86+
const struct i2c_device_id *id)
87+
{
88+
struct max8998_dev *max8998;
89+
int ret = 0;
90+
91+
max8998 = kzalloc(sizeof(struct max8998_dev), GFP_KERNEL);
92+
if (max8998 == NULL) {
93+
kfree(i2c);
94+
return -ENOMEM;
95+
}
96+
97+
i2c_set_clientdata(i2c, max8998);
98+
max8998->dev = &i2c->dev;
99+
max8998->i2c_client = i2c;
100+
max8998->dev_read = max8998_i2c_device_read;
101+
max8998->dev_write = max8998_i2c_device_write;
102+
max8998->dev_update = max8998_i2c_device_update;
103+
mutex_init(&max8998->iolock);
104+
105+
ret = mfd_add_devices(max8998->dev, -1,
106+
max8998_devs, ARRAY_SIZE(max8998_devs),
107+
NULL, 0);
108+
if (ret < 0)
109+
goto err;
110+
111+
return ret;
112+
113+
err:
114+
mfd_remove_devices(max8998->dev);
115+
kfree(max8998);
116+
return ret;
117+
}
118+
119+
static int max8998_i2c_remove(struct i2c_client *i2c)
120+
{
121+
struct max8998_dev *max8998 = i2c_get_clientdata(i2c);
122+
123+
mfd_remove_devices(max8998->dev);
124+
kfree(max8998);
125+
126+
return 0;
127+
}
128+
129+
static const struct i2c_device_id max8998_i2c_id[] = {
130+
{ "max8998", 0 },
131+
{ }
132+
};
133+
MODULE_DEVICE_TABLE(i2c, max8998_i2c_id);
134+
135+
static struct i2c_driver max8998_i2c_driver = {
136+
.driver = {
137+
.name = "max8998",
138+
.owner = THIS_MODULE,
139+
},
140+
.probe = max8998_i2c_probe,
141+
.remove = max8998_i2c_remove,
142+
.id_table = max8998_i2c_id,
143+
};
144+
145+
static int __init max8998_i2c_init(void)
146+
{
147+
return i2c_add_driver(&max8998_i2c_driver);
148+
}
149+
/* init early so consumer devices can complete system boot */
150+
subsys_initcall(max8998_i2c_init);
151+
152+
static void __exit max8998_i2c_exit(void)
153+
{
154+
i2c_del_driver(&max8998_i2c_driver);
155+
}
156+
module_exit(max8998_i2c_exit);
157+
158+
MODULE_DESCRIPTION("MAXIM 8998 multi-function core driver");
159+
MODULE_AUTHOR("Kyungmin Park <kyungmin.park@samsung.com>");
160+
MODULE_LICENSE("GPL");

‎drivers/regulator/Kconfig‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ config REGULATOR_MAX8925
100100
help
101101
Say y here to support the voltage regulaltor of Maxim MAX8925 PMIC.
102102

103+
config REGULATOR_MAX8998
104+
tristate "Maxim 8998 voltage regulator"
105+
depends on I2C
106+
default n
107+
help
108+
This driver controls a Maxim 8998 voltage output regulator
109+
via I2C bus. The provided regulator is suitable for S3C6410
110+
and S5PC1XX chips to control VCC_CORE and VCC_USIM voltages.
111+
103112
config REGULATOR_TWL4030
104113
bool "TI TWL4030/TWL5030/TWL6030/TPS695x0 PMIC"
105114
depends on TWL4030_CORE

‎drivers/regulator/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
1717
obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o
1818
obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o
1919
obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o
20+
obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
2021
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
2122
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
2223
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o

0 commit comments

Comments
 (0)