Revert "unicode: Don't special case ignorable code points"
[linux.git] / drivers / mfd / bcm590xx.c
blob8b56786d85d0182acf91da203b5f943556c08422
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Broadcom BCM590xx PMU
5 * Copyright 2014 Linaro Limited
6 * Author: Matt Porter <mporter@linaro.org>
7 */
9 #include <linux/err.h>
10 #include <linux/i2c.h>
11 #include <linux/init.h>
12 #include <linux/mfd/bcm590xx.h>
13 #include <linux/mfd/core.h>
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/of.h>
17 #include <linux/regmap.h>
18 #include <linux/slab.h>
20 static const struct mfd_cell bcm590xx_devs[] = {
22 .name = "bcm590xx-vregs",
26 static const struct regmap_config bcm590xx_regmap_config_pri = {
27 .reg_bits = 8,
28 .val_bits = 8,
29 .max_register = BCM590XX_MAX_REGISTER_PRI,
30 .cache_type = REGCACHE_MAPLE,
33 static const struct regmap_config bcm590xx_regmap_config_sec = {
34 .reg_bits = 8,
35 .val_bits = 8,
36 .max_register = BCM590XX_MAX_REGISTER_SEC,
37 .cache_type = REGCACHE_MAPLE,
40 static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
42 struct bcm590xx *bcm590xx;
43 int ret;
45 bcm590xx = devm_kzalloc(&i2c_pri->dev, sizeof(*bcm590xx), GFP_KERNEL);
46 if (!bcm590xx)
47 return -ENOMEM;
49 i2c_set_clientdata(i2c_pri, bcm590xx);
50 bcm590xx->dev = &i2c_pri->dev;
51 bcm590xx->i2c_pri = i2c_pri;
53 bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri,
54 &bcm590xx_regmap_config_pri);
55 if (IS_ERR(bcm590xx->regmap_pri)) {
56 ret = PTR_ERR(bcm590xx->regmap_pri);
57 dev_err(&i2c_pri->dev, "primary regmap init failed: %d\n", ret);
58 return ret;
61 /* Secondary I2C slave address is the base address with A(2) asserted */
62 bcm590xx->i2c_sec = i2c_new_dummy_device(i2c_pri->adapter,
63 i2c_pri->addr | BIT(2));
64 if (IS_ERR(bcm590xx->i2c_sec)) {
65 dev_err(&i2c_pri->dev, "failed to add secondary I2C device\n");
66 return PTR_ERR(bcm590xx->i2c_sec);
68 i2c_set_clientdata(bcm590xx->i2c_sec, bcm590xx);
70 bcm590xx->regmap_sec = devm_regmap_init_i2c(bcm590xx->i2c_sec,
71 &bcm590xx_regmap_config_sec);
72 if (IS_ERR(bcm590xx->regmap_sec)) {
73 ret = PTR_ERR(bcm590xx->regmap_sec);
74 dev_err(&bcm590xx->i2c_sec->dev,
75 "secondary regmap init failed: %d\n", ret);
76 goto err;
79 ret = devm_mfd_add_devices(&i2c_pri->dev, -1, bcm590xx_devs,
80 ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL);
81 if (ret < 0) {
82 dev_err(&i2c_pri->dev, "failed to add sub-devices: %d\n", ret);
83 goto err;
86 return 0;
88 err:
89 i2c_unregister_device(bcm590xx->i2c_sec);
90 return ret;
93 static const struct of_device_id bcm590xx_of_match[] = {
94 { .compatible = "brcm,bcm59056" },
95 { }
97 MODULE_DEVICE_TABLE(of, bcm590xx_of_match);
99 static const struct i2c_device_id bcm590xx_i2c_id[] = {
100 { "bcm59056" },
103 MODULE_DEVICE_TABLE(i2c, bcm590xx_i2c_id);
105 static struct i2c_driver bcm590xx_i2c_driver = {
106 .driver = {
107 .name = "bcm590xx",
108 .of_match_table = bcm590xx_of_match,
110 .probe = bcm590xx_i2c_probe,
111 .id_table = bcm590xx_i2c_id,
113 module_i2c_driver(bcm590xx_i2c_driver);
115 MODULE_AUTHOR("Matt Porter <mporter@linaro.org>");
116 MODULE_DESCRIPTION("BCM590xx multi-function driver");
117 MODULE_LICENSE("GPL v2");