aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/soc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-09 13:01:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-09 13:01:15 -0400
commit0160e00ae8e987be8822745fb166aa76451c9bcc (patch)
treedeca2d09a729155ed0cb631f2bc8f557e634ab06 /drivers/base/soc.c
parentc81ee18e97e4e3162169a749eb7f2b79b3510c7a (diff)
parentb6942b68f85ed3161c91741791ec6f1779574919 (diff)
Merge tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM SoC driver updates from Olof Johansson: "Driver updates for ARM SoCs: Reset subsystem, merged through arm-soc by tradition: - Make bool drivers explicitly non-modular - New support for i.MX7 and Arria10 reset controllers PATA driver for Palmchip BK371 (acked by Tejun) Power domain drivers for i.MX (GPC, GPCv2) - Moved out of mach-imx for GPC - Bunch of tweaks, fixes, etc PMC support for Tegra186 SoC detection support for Renesas RZ/G1H and RZ/G1N Move Tegra flow controller driver from mach directory to drivers/soc - (Power management / CPU power driver) Misc smaller tweaks for other platforms" * tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (60 commits) soc: pm-domain: Fix the mangled urls soc: renesas: rcar-sysc: Add support for R-Car H3 ES2.0 soc: renesas: rcar-sysc: Add support for fixing up power area tables soc: renesas: Register SoC device early soc: imx: gpc: add workaround for i.MX6QP to the GPC PD driver dt-bindings: imx-gpc: add i.MX6 QuadPlus compatible soc: imx: gpc: add defines for domain index soc: imx: Add GPCv2 power gating driver dt-bindings: Add GPCv2 power gating driver ARM/clk: move the ICST library to drivers/clk ARM: plat-versatile: remove stale clock header ARM: keystone: Drop PM domain support for k2g soc: ti: Add ti_sci_pm_domains driver dt-bindings: Add TI SCI PM Domains PM / Domains: Do not check if simple providers have phandle cells PM / Domains: Add generic data pointer to genpd data struct soc/tegra: Add initial flowctrl support for Tegra132/210 soc/tegra: flowctrl: Add basic platform driver soc/tegra: Move Tegra flowctrl driver ARM: tegra: Remove unnecessary inclusion of flowctrl header ...
Diffstat (limited to 'drivers/base/soc.c')
-rw-r--r--drivers/base/soc.c52
1 files changed, 34 insertions, 18 deletions
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index dc26e5949a32..909dedae4c4e 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -109,15 +109,18 @@ static void soc_release(struct device *dev)
109 kfree(soc_dev); 109 kfree(soc_dev);
110} 110}
111 111
112static struct soc_device_attribute *early_soc_dev_attr;
113
112struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr) 114struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr)
113{ 115{
114 struct soc_device *soc_dev; 116 struct soc_device *soc_dev;
115 int ret; 117 int ret;
116 118
117 if (!soc_bus_type.p) { 119 if (!soc_bus_type.p) {
118 ret = bus_register(&soc_bus_type); 120 if (early_soc_dev_attr)
119 if (ret) 121 return ERR_PTR(-EBUSY);
120 goto out1; 122 early_soc_dev_attr = soc_dev_attr;
123 return NULL;
121 } 124 }
122 125
123 soc_dev = kzalloc(sizeof(*soc_dev), GFP_KERNEL); 126 soc_dev = kzalloc(sizeof(*soc_dev), GFP_KERNEL);
@@ -159,45 +162,53 @@ void soc_device_unregister(struct soc_device *soc_dev)
159 ida_simple_remove(&soc_ida, soc_dev->soc_dev_num); 162 ida_simple_remove(&soc_ida, soc_dev->soc_dev_num);
160 163
161 device_unregister(&soc_dev->dev); 164 device_unregister(&soc_dev->dev);
165 early_soc_dev_attr = NULL;
162} 166}
163 167
164static int __init soc_bus_register(void) 168static int __init soc_bus_register(void)
165{ 169{
166 if (soc_bus_type.p) 170 int ret;
167 return 0;
168 171
169 return bus_register(&soc_bus_type); 172 ret = bus_register(&soc_bus_type);
173 if (ret)
174 return ret;
175
176 if (early_soc_dev_attr)
177 return PTR_ERR(soc_device_register(early_soc_dev_attr));
178
179 return 0;
170} 180}
171core_initcall(soc_bus_register); 181core_initcall(soc_bus_register);
172 182
173static int soc_device_match_one(struct device *dev, void *arg) 183static int soc_device_match_attr(const struct soc_device_attribute *attr,
184 const struct soc_device_attribute *match)
174{ 185{
175 struct soc_device *soc_dev = container_of(dev, struct soc_device, dev);
176 const struct soc_device_attribute *match = arg;
177
178 if (match->machine && 186 if (match->machine &&
179 (!soc_dev->attr->machine || 187 (!attr->machine || !glob_match(match->machine, attr->machine)))
180 !glob_match(match->machine, soc_dev->attr->machine)))
181 return 0; 188 return 0;
182 189
183 if (match->family && 190 if (match->family &&
184 (!soc_dev->attr->family || 191 (!attr->family || !glob_match(match->family, attr->family)))
185 !glob_match(match->family, soc_dev->attr->family)))
186 return 0; 192 return 0;
187 193
188 if (match->revision && 194 if (match->revision &&
189 (!soc_dev->attr->revision || 195 (!attr->revision || !glob_match(match->revision, attr->revision)))
190 !glob_match(match->revision, soc_dev->attr->revision)))
191 return 0; 196 return 0;
192 197
193 if (match->soc_id && 198 if (match->soc_id &&
194 (!soc_dev->attr->soc_id || 199 (!attr->soc_id || !glob_match(match->soc_id, attr->soc_id)))
195 !glob_match(match->soc_id, soc_dev->attr->soc_id)))
196 return 0; 200 return 0;
197 201
198 return 1; 202 return 1;
199} 203}
200 204
205static int soc_device_match_one(struct device *dev, void *arg)
206{
207 struct soc_device *soc_dev = container_of(dev, struct soc_device, dev);
208
209 return soc_device_match_attr(soc_dev->attr, arg);
210}
211
201/* 212/*
202 * soc_device_match - identify the SoC in the machine 213 * soc_device_match - identify the SoC in the machine
203 * @matches: zero-terminated array of possible matches 214 * @matches: zero-terminated array of possible matches
@@ -230,6 +241,11 @@ const struct soc_device_attribute *soc_device_match(
230 break; 241 break;
231 ret = bus_for_each_dev(&soc_bus_type, NULL, (void *)matches, 242 ret = bus_for_each_dev(&soc_bus_type, NULL, (void *)matches,
232 soc_device_match_one); 243 soc_device_match_one);
244 if (ret < 0 && early_soc_dev_attr)
245 ret = soc_device_match_attr(early_soc_dev_attr,
246 matches);
247 if (ret < 0)
248 return NULL;
233 if (!ret) 249 if (!ret)
234 matches++; 250 matches++;
235 else 251 else