diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-08 23:02:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-08 23:02:54 -0500 |
commit | 3a7dbed7f23cdde8394e9adf92cc222856e0fc1e (patch) | |
tree | a83fa52d24d2457acadf4c1bc72ea3a3e294b57d /drivers/mfd/syscon.c | |
parent | f2fb38049c724558c590c31e57627f6ba8d48a5b (diff) | |
parent | a3b63979f8a32af9e975a793fd0f612d42072740 (diff) |
Merge tag 'mfd-for-linus-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
Pull MFD updates from Lee Jones:
"Changes to the core:
- Honour PLATFORM_DEVID_NONE and PLATFORM_DEVID_AUTO dev IDs
Changes to existing drivers:
- IRQ additions/fixes; axp20x, da9063-core
- Code simplification; i2c-dln2
- Regmap additions/fixes; max77693
- Error checking/handling improvements; dln2, db8500-prcmu
- Bug fixes; dln2, wm8350-core
- DT support/documentation; max77693, max77686, tps65217, twl4030-power,
gpio-tc3589x
- Decouple syscon interface from platform devices
- Use MFD hotplug registration; rtsx_usb, viperboard, hid-sensor-hub
- Regulator fixups; sec-core
- Power Management additions/fixes; rts5227, tc6393xb
- Remove relic/redundant code; ab8500-sysctrl, lpc_sch, max77693-private
- Clean-up/coding style changes; tps65090
- Clk additions/fixes; tc6393xb, tc6387xb, t7l66xb
- Add USB-SPI support; dln2
- Trivial changes; max14577, arizona-spi, lpc_sch, wm8997-tables, wm5102-tables
wm5110-tables, axp20x, atmel-hlcdc, rtsx_pci
New drivers/supported devices:
- axp288 PMIC support added to axp20x
- s2mps13 support added to sec-core
- New support for Diolan DLN-2
- New support for atmel-hlcdc"
* tag 'mfd-for-linus-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (55 commits)
mfd: rtsx: Add func to split u32 into register
mfd: atmel-hlcdc: Add Kconfig option description and name
mfd: da9063: Get irq base dynamically before registering device
mfd: max14577: Fix obvious typo in company name in copyright
mfd: axp20x: Constify axp20x_acpi_match and rid unused warning
mfd: t7l66xb: prepare/unprepare clocks
mfd: tc6387xb: prepare/unprepare clocks
mfd: dln2: add support for USB-SPI module
mfd: wm5110: Add missing registers for AIF2 channels 3-6
mfd: tc3589x: get rid of static base
mfd: arizona: Document HP_CTRL_1L and HP_CTRL_1R registers
mfd: wm8997: Mark INTERRUPT_STATUS_2_MASK as readable
mfd: tc6393xb: Prepare/unprepare clocks
mfd: tps65090: Fix bonkers indenting strategy
mfd: tc6393xb: Fail ohci suspend if full state restore is required
mfd: lpc_sch: Don't call mfd_remove_devices()
mfd: wm8350-core: Fix probable mask then right shift defect
mfd: ab8500-sysctrl: Drop ab8500_restart
mfd: db8500-prcmu: Provide sane error path values
mfd: db8500-prcmu: Check return of devm_ioremap for error
...
Diffstat (limited to 'drivers/mfd/syscon.c')
-rw-r--r-- | drivers/mfd/syscon.c | 96 |
1 files changed, 74 insertions, 22 deletions
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index ca15878ce5c0..72373b113885 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/list.h> | ||
18 | #include <linux/of.h> | 19 | #include <linux/of.h> |
19 | #include <linux/of_address.h> | 20 | #include <linux/of_address.h> |
20 | #include <linux/of_platform.h> | 21 | #include <linux/of_platform.h> |
@@ -22,31 +23,94 @@ | |||
22 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
23 | #include <linux/regmap.h> | 24 | #include <linux/regmap.h> |
24 | #include <linux/mfd/syscon.h> | 25 | #include <linux/mfd/syscon.h> |
26 | #include <linux/slab.h> | ||
25 | 27 | ||
26 | static struct platform_driver syscon_driver; | 28 | static struct platform_driver syscon_driver; |
27 | 29 | ||
30 | static DEFINE_SPINLOCK(syscon_list_slock); | ||
31 | static LIST_HEAD(syscon_list); | ||
32 | |||
28 | struct syscon { | 33 | struct syscon { |
34 | struct device_node *np; | ||
29 | struct regmap *regmap; | 35 | struct regmap *regmap; |
36 | struct list_head list; | ||
37 | }; | ||
38 | |||
39 | static struct regmap_config syscon_regmap_config = { | ||
40 | .reg_bits = 32, | ||
41 | .val_bits = 32, | ||
42 | .reg_stride = 4, | ||
30 | }; | 43 | }; |
31 | 44 | ||
32 | static int syscon_match_node(struct device *dev, void *data) | 45 | static struct syscon *of_syscon_register(struct device_node *np) |
33 | { | 46 | { |
34 | struct device_node *dn = data; | 47 | struct syscon *syscon; |
48 | struct regmap *regmap; | ||
49 | void __iomem *base; | ||
50 | int ret; | ||
51 | struct regmap_config syscon_config = syscon_regmap_config; | ||
52 | |||
53 | if (!of_device_is_compatible(np, "syscon")) | ||
54 | return ERR_PTR(-EINVAL); | ||
55 | |||
56 | syscon = kzalloc(sizeof(*syscon), GFP_KERNEL); | ||
57 | if (!syscon) | ||
58 | return ERR_PTR(-ENOMEM); | ||
59 | |||
60 | base = of_iomap(np, 0); | ||
61 | if (!base) { | ||
62 | ret = -ENOMEM; | ||
63 | goto err_map; | ||
64 | } | ||
65 | |||
66 | /* Parse the device's DT node for an endianness specification */ | ||
67 | if (of_property_read_bool(np, "big-endian")) | ||
68 | syscon_config.val_format_endian = REGMAP_ENDIAN_BIG; | ||
69 | else if (of_property_read_bool(np, "little-endian")) | ||
70 | syscon_config.val_format_endian = REGMAP_ENDIAN_LITTLE; | ||
71 | |||
72 | regmap = regmap_init_mmio(NULL, base, &syscon_config); | ||
73 | if (IS_ERR(regmap)) { | ||
74 | pr_err("regmap init failed\n"); | ||
75 | ret = PTR_ERR(regmap); | ||
76 | goto err_regmap; | ||
77 | } | ||
78 | |||
79 | syscon->regmap = regmap; | ||
80 | syscon->np = np; | ||
81 | |||
82 | spin_lock(&syscon_list_slock); | ||
83 | list_add_tail(&syscon->list, &syscon_list); | ||
84 | spin_unlock(&syscon_list_slock); | ||
35 | 85 | ||
36 | return (dev->of_node == dn) ? 1 : 0; | 86 | return syscon; |
87 | |||
88 | err_regmap: | ||
89 | iounmap(base); | ||
90 | err_map: | ||
91 | kfree(syscon); | ||
92 | return ERR_PTR(ret); | ||
37 | } | 93 | } |
38 | 94 | ||
39 | struct regmap *syscon_node_to_regmap(struct device_node *np) | 95 | struct regmap *syscon_node_to_regmap(struct device_node *np) |
40 | { | 96 | { |
41 | struct syscon *syscon; | 97 | struct syscon *entry, *syscon = NULL; |
42 | struct device *dev; | ||
43 | 98 | ||
44 | dev = driver_find_device(&syscon_driver.driver, NULL, np, | 99 | spin_lock(&syscon_list_slock); |
45 | syscon_match_node); | ||
46 | if (!dev) | ||
47 | return ERR_PTR(-EPROBE_DEFER); | ||
48 | 100 | ||
49 | syscon = dev_get_drvdata(dev); | 101 | list_for_each_entry(entry, &syscon_list, list) |
102 | if (entry->np == np) { | ||
103 | syscon = entry; | ||
104 | break; | ||
105 | } | ||
106 | |||
107 | spin_unlock(&syscon_list_slock); | ||
108 | |||
109 | if (!syscon) | ||
110 | syscon = of_syscon_register(np); | ||
111 | |||
112 | if (IS_ERR(syscon)) | ||
113 | return ERR_CAST(syscon); | ||
50 | 114 | ||
51 | return syscon->regmap; | 115 | return syscon->regmap; |
52 | } | 116 | } |
@@ -110,17 +174,6 @@ struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np, | |||
110 | } | 174 | } |
111 | EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle); | 175 | EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle); |
112 | 176 | ||
113 | static const struct of_device_id of_syscon_match[] = { | ||
114 | { .compatible = "syscon", }, | ||
115 | { }, | ||
116 | }; | ||
117 | |||
118 | static struct regmap_config syscon_regmap_config = { | ||
119 | .reg_bits = 32, | ||
120 | .val_bits = 32, | ||
121 | .reg_stride = 4, | ||
122 | }; | ||
123 | |||
124 | static int syscon_probe(struct platform_device *pdev) | 177 | static int syscon_probe(struct platform_device *pdev) |
125 | { | 178 | { |
126 | struct device *dev = &pdev->dev; | 179 | struct device *dev = &pdev->dev; |
@@ -167,7 +220,6 @@ static struct platform_driver syscon_driver = { | |||
167 | .driver = { | 220 | .driver = { |
168 | .name = "syscon", | 221 | .name = "syscon", |
169 | .owner = THIS_MODULE, | 222 | .owner = THIS_MODULE, |
170 | .of_match_table = of_syscon_match, | ||
171 | }, | 223 | }, |
172 | .probe = syscon_probe, | 224 | .probe = syscon_probe, |
173 | .id_table = syscon_ids, | 225 | .id_table = syscon_ids, |