aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGyungoh Yoo <jack.yoo@skyworksinc.com>2015-02-27 01:42:21 -0500
committerLee Jones <lee.jones@linaro.org>2015-03-12 05:08:12 -0400
commit2698dc22292e3e5fc2b24b2748018dcc09d70989 (patch)
tree10dcdb06579ab9461144d90c87aaefa492fb413a
parentccd173c541e7d3c864730e334dac36a8b6487a25 (diff)
mfd: Add support for Skyworks SKY81452 driver
Signed-off-by: Gyungoh Yoo <jack.yoo@skyworksinc.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--drivers/mfd/Kconfig12
-rw-r--r--drivers/mfd/Makefile1
-rw-r--r--drivers/mfd/sky81452.c108
-rw-r--r--include/linux/mfd/sky81452.h31
4 files changed, 152 insertions, 0 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b277f37ae3be..5e68fdef64e7 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -791,6 +791,18 @@ config MFD_SM501_GPIO
791 lines on the SM501. The platform data is used to supply the 791 lines on the SM501. The platform data is used to supply the
792 base number for the first GPIO line to register. 792 base number for the first GPIO line to register.
793 793
794config MFD_SKY81452
795 tristate "Skyworks Solutions SKY81452"
796 select MFD_CORE
797 select REGMAP_I2C
798 depends on I2C
799 help
800 This is the core driver for the Skyworks SKY81452 backlight and
801 voltage regulator device.
802
803 This driver can also be built as a module. If so, the module
804 will be called sky81452.
805
794config MFD_SMSC 806config MFD_SMSC
795 bool "SMSC ECE1099 series chips" 807 bool "SMSC ECE1099 series chips"
796 depends on I2C=y 808 depends on I2C=y
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 5ebe443b595a..0e5cfeba107c 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -180,6 +180,7 @@ obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o
180obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o 180obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o
181obj-$(CONFIG_MFD_DLN2) += dln2.o 181obj-$(CONFIG_MFD_DLN2) += dln2.o
182obj-$(CONFIG_MFD_RT5033) += rt5033.o 182obj-$(CONFIG_MFD_RT5033) += rt5033.o
183obj-$(CONFIG_MFD_SKY81452) += sky81452.o
183 184
184intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o 185intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o
185obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o 186obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o
diff --git a/drivers/mfd/sky81452.c b/drivers/mfd/sky81452.c
new file mode 100644
index 000000000000..b0c9b0415650
--- /dev/null
+++ b/drivers/mfd/sky81452.c
@@ -0,0 +1,108 @@
1/*
2 * sky81452.c SKY81452 MFD driver
3 *
4 * Copyright 2014 Skyworks Solutions Inc.
5 * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/err.h>
24#include <linux/slab.h>
25#include <linux/i2c.h>
26#include <linux/regmap.h>
27#include <linux/mfd/core.h>
28#include <linux/mfd/sky81452.h>
29
30static const struct regmap_config sky81452_config = {
31 .reg_bits = 8,
32 .val_bits = 8,
33};
34
35static int sky81452_probe(struct i2c_client *client,
36 const struct i2c_device_id *id)
37{
38 struct device *dev = &client->dev;
39 const struct sky81452_platform_data *pdata = dev_get_platdata(dev);
40 struct mfd_cell cells[2];
41 struct regmap *regmap;
42 int ret;
43
44 if (!pdata) {
45 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
46 if (!pdata)
47 return -ENOMEM;
48 }
49
50 regmap = devm_regmap_init_i2c(client, &sky81452_config);
51 if (IS_ERR(regmap)) {
52 dev_err(dev, "failed to initialize.err=%ld\n", PTR_ERR(regmap));
53 return PTR_ERR(regmap);
54 }
55
56 i2c_set_clientdata(client, regmap);
57
58 memset(cells, 0, sizeof(cells));
59 cells[0].name = "sky81452-backlight";
60 cells[0].of_compatible = "skyworks,sky81452-backlight";
61 cells[0].platform_data = pdata->bl_pdata;
62 cells[0].pdata_size = sizeof(*pdata->bl_pdata);
63 cells[1].name = "sky81452-regulator";
64 cells[1].platform_data = pdata->regulator_init_data;
65 cells[1].pdata_size = sizeof(*pdata->regulator_init_data);
66
67 ret = mfd_add_devices(dev, -1, cells, ARRAY_SIZE(cells), NULL, 0, NULL);
68 if (ret)
69 dev_err(dev, "failed to add child devices. err=%d\n", ret);
70
71 return ret;
72}
73
74static int sky81452_remove(struct i2c_client *client)
75{
76 mfd_remove_devices(&client->dev);
77 return 0;
78}
79
80static const struct i2c_device_id sky81452_ids[] = {
81 { "sky81452" },
82 { }
83};
84MODULE_DEVICE_TABLE(i2c, sky81452_ids);
85
86#ifdef CONFIG_OF
87static const struct of_device_id sky81452_of_match[] = {
88 { .compatible = "skyworks,sky81452", },
89 { }
90};
91MODULE_DEVICE_TABLE(of, sky81452_of_match);
92#endif
93
94static struct i2c_driver sky81452_driver = {
95 .driver = {
96 .name = "sky81452",
97 .of_match_table = of_match_ptr(sky81452_of_match),
98 },
99 .probe = sky81452_probe,
100 .remove = sky81452_remove,
101 .id_table = sky81452_ids,
102};
103
104module_i2c_driver(sky81452_driver);
105
106MODULE_DESCRIPTION("Skyworks SKY81452 MFD driver");
107MODULE_AUTHOR("Gyungoh Yoo <jack.yoo@skyworksinc.com>");
108MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/sky81452.h b/include/linux/mfd/sky81452.h
new file mode 100644
index 000000000000..b0925fa3e9ef
--- /dev/null
+++ b/include/linux/mfd/sky81452.h
@@ -0,0 +1,31 @@
1/*
2 * sky81452.h SKY81452 MFD driver
3 *
4 * Copyright 2014 Skyworks Solutions Inc.
5 * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef _SKY81452_H
21#define _SKY81452_H
22
23#include <linux/platform_data/sky81452-backlight.h>
24#include <linux/regulator/machine.h>
25
26struct sky81452_platform_data {
27 struct sky81452_bl_platform_data *bl_pdata;
28 struct regulator_init_data *regulator_init_data;
29};
30
31#endif