blob: 168e51f90ca9fba0bd350fbb063948400f66ee76 [file] [log] [blame]
Tony Lindgren0eecc632017-10-10 14:23:43 -07001/*
2 * ti-sysc.c - Texas Instruments sysc interconnect target driver
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/io.h>
15#include <linux/clk.h>
Tony Lindgren2c355ff2018-02-22 13:58:03 -080016#include <linux/clkdev.h>
Tony Lindgrena885f0f2018-02-22 14:03:48 -080017#include <linux/delay.h>
Tony Lindgren0eecc632017-10-10 14:23:43 -070018#include <linux/module.h>
19#include <linux/platform_device.h>
Tony Lindgrena885f0f2018-02-22 14:03:48 -080020#include <linux/pm_domain.h>
Tony Lindgren0eecc632017-10-10 14:23:43 -070021#include <linux/pm_runtime.h>
Tony Lindgren50622362018-04-16 10:20:27 -070022#include <linux/reset.h>
Tony Lindgren0eecc632017-10-10 14:23:43 -070023#include <linux/of_address.h>
24#include <linux/of_platform.h>
Tony Lindgren2c355ff2018-02-22 13:58:03 -080025#include <linux/slab.h>
26
Tony Lindgren70a65242017-12-15 09:41:09 -080027#include <linux/platform_data/ti-sysc.h>
28
29#include <dt-bindings/bus/ti-sysc.h>
Tony Lindgren0eecc632017-10-10 14:23:43 -070030
Tony Lindgren0eecc632017-10-10 14:23:43 -070031static const char * const reg_names[] = { "rev", "sysc", "syss", };
32
33enum sysc_clocks {
34 SYSC_FCK,
35 SYSC_ICK,
Tony Lindgren09dfe582018-04-16 10:25:52 -070036 SYSC_OPTFCK0,
37 SYSC_OPTFCK1,
38 SYSC_OPTFCK2,
39 SYSC_OPTFCK3,
40 SYSC_OPTFCK4,
41 SYSC_OPTFCK5,
42 SYSC_OPTFCK6,
43 SYSC_OPTFCK7,
Tony Lindgren0eecc632017-10-10 14:23:43 -070044 SYSC_MAX_CLOCKS,
45};
46
Tony Lindgren09dfe582018-04-16 10:25:52 -070047static const char * const clock_names[SYSC_ICK + 1] = { "fck", "ick", };
Tony Lindgren0eecc632017-10-10 14:23:43 -070048
Tony Lindgrenc5a2de92017-12-15 09:41:23 -080049#define SYSC_IDLEMODE_MASK 3
50#define SYSC_CLOCKACTIVITY_MASK 3
51
Tony Lindgren0eecc632017-10-10 14:23:43 -070052/**
53 * struct sysc - TI sysc interconnect target module registers and capabilities
54 * @dev: struct device pointer
55 * @module_pa: physical address of the interconnect target module
56 * @module_size: size of the interconnect target module
57 * @module_va: virtual address of the interconnect target module
58 * @offsets: register offsets from module base
59 * @clocks: clocks used by the interconnect target module
Tony Lindgren09dfe582018-04-16 10:25:52 -070060 * @clock_roles: clock role names for the found clocks
61 * @nr_clocks: number of clocks used by the interconnect target module
Tony Lindgren0eecc632017-10-10 14:23:43 -070062 * @legacy_mode: configured for legacy mode if set
Tony Lindgren70a65242017-12-15 09:41:09 -080063 * @cap: interconnect target module capabilities
64 * @cfg: interconnect target module configuration
Tony Lindgren566a9b052017-12-15 09:41:19 -080065 * @name: name if available
66 * @revision: interconnect target module revision
Tony Lindgren62020f22018-02-22 13:59:44 -080067 * @needs_resume: runtime resume needed on resume from suspend
Tony Lindgren0eecc632017-10-10 14:23:43 -070068 */
69struct sysc {
70 struct device *dev;
71 u64 module_pa;
72 u32 module_size;
73 void __iomem *module_va;
74 int offsets[SYSC_MAX_REGS];
Tony Lindgren09dfe582018-04-16 10:25:52 -070075 struct clk **clocks;
76 const char **clock_roles;
77 int nr_clocks;
Tony Lindgren50622362018-04-16 10:20:27 -070078 struct reset_control *rsts;
Tony Lindgren0eecc632017-10-10 14:23:43 -070079 const char *legacy_mode;
Tony Lindgren70a65242017-12-15 09:41:09 -080080 const struct sysc_capabilities *cap;
81 struct sysc_config cfg;
Tony Lindgrenef70b0b2018-02-22 14:00:25 -080082 struct ti_sysc_cookie cookie;
Tony Lindgren566a9b052017-12-15 09:41:19 -080083 const char *name;
84 u32 revision;
Tony Lindgren62020f22018-02-22 13:59:44 -080085 bool enabled;
86 bool needs_resume;
Tony Lindgrena885f0f2018-02-22 14:03:48 -080087 bool child_needs_resume;
Tony Lindgren76f0f772018-02-23 08:28:45 -080088 struct delayed_work idle_work;
Tony Lindgren0eecc632017-10-10 14:23:43 -070089};
90
Tony Lindgren566a9b052017-12-15 09:41:19 -080091static u32 sysc_read(struct sysc *ddata, int offset)
92{
93 if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) {
94 u32 val;
95
96 val = readw_relaxed(ddata->module_va + offset);
97 val |= (readw_relaxed(ddata->module_va + offset + 4) << 16);
98
99 return val;
100 }
101
102 return readl_relaxed(ddata->module_va + offset);
103}
104
Tony Lindgren09dfe582018-04-16 10:25:52 -0700105static bool sysc_opt_clks_needed(struct sysc *ddata)
106{
107 return !!(ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_NEEDED);
108}
109
Tony Lindgren0eecc632017-10-10 14:23:43 -0700110static u32 sysc_read_revision(struct sysc *ddata)
111{
Tony Lindgren566a9b052017-12-15 09:41:19 -0800112 int offset = ddata->offsets[SYSC_REVISION];
113
114 if (offset < 0)
115 return 0;
116
117 return sysc_read(ddata, offset);
Tony Lindgren0eecc632017-10-10 14:23:43 -0700118}
119
Tony Lindgren09dfe582018-04-16 10:25:52 -0700120static int sysc_get_one_clock(struct sysc *ddata, const char *name)
Tony Lindgren0eecc632017-10-10 14:23:43 -0700121{
Tony Lindgren09dfe582018-04-16 10:25:52 -0700122 int error, i, index = -ENODEV;
Tony Lindgren0eecc632017-10-10 14:23:43 -0700123
Tony Lindgren09dfe582018-04-16 10:25:52 -0700124 if (!strncmp(clock_names[SYSC_FCK], name, 3))
125 index = SYSC_FCK;
126 else if (!strncmp(clock_names[SYSC_ICK], name, 3))
127 index = SYSC_ICK;
128
129 if (index < 0) {
130 for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) {
131 if (!clock_names[i]) {
132 index = i;
133 break;
134 }
135 }
Tony Lindgren0eecc632017-10-10 14:23:43 -0700136 }
Tony Lindgren09dfe582018-04-16 10:25:52 -0700137
138 if (index < 0) {
139 dev_err(ddata->dev, "clock %s not added\n", name);
140 return index;
141 }
Tony Lindgren0eecc632017-10-10 14:23:43 -0700142
143 ddata->clocks[index] = devm_clk_get(ddata->dev, name);
144 if (IS_ERR(ddata->clocks[index])) {
145 if (PTR_ERR(ddata->clocks[index]) == -ENOENT)
146 return 0;
147
148 dev_err(ddata->dev, "clock get error for %s: %li\n",
149 name, PTR_ERR(ddata->clocks[index]));
150
151 return PTR_ERR(ddata->clocks[index]);
152 }
153
154 error = clk_prepare(ddata->clocks[index]);
155 if (error) {
156 dev_err(ddata->dev, "clock prepare error for %s: %i\n",
157 name, error);
158
159 return error;
160 }
161
162 return 0;
163}
164
165static int sysc_get_clocks(struct sysc *ddata)
166{
Tony Lindgren09dfe582018-04-16 10:25:52 -0700167 struct device_node *np = ddata->dev->of_node;
168 struct property *prop;
169 const char *name;
170 int nr_fck = 0, nr_ick = 0, i, error = 0;
Tony Lindgren0eecc632017-10-10 14:23:43 -0700171
Tony Lindgren09dfe582018-04-16 10:25:52 -0700172 ddata->clock_roles = devm_kzalloc(ddata->dev,
173 sizeof(*ddata->clock_roles) *
174 SYSC_MAX_CLOCKS,
175 GFP_KERNEL);
176 if (!ddata->clock_roles)
177 return -ENOMEM;
178
179 of_property_for_each_string(np, "clock-names", prop, name) {
180 if (!strncmp(clock_names[SYSC_FCK], name, 3))
181 nr_fck++;
182 if (!strncmp(clock_names[SYSC_ICK], name, 3))
183 nr_ick++;
184 ddata->clock_roles[ddata->nr_clocks] = name;
185 ddata->nr_clocks++;
186 }
187
188 if (ddata->nr_clocks < 1)
189 return 0;
190
191 if (ddata->nr_clocks > SYSC_MAX_CLOCKS) {
192 dev_err(ddata->dev, "too many clocks for %pOF\n", np);
193
194 return -EINVAL;
195 }
196
197 if (nr_fck > 1 || nr_ick > 1) {
198 dev_err(ddata->dev, "max one fck and ick for %pOF\n", np);
199
200 return -EINVAL;
201 }
202
203 ddata->clocks = devm_kzalloc(ddata->dev,
204 sizeof(*ddata->clocks) * ddata->nr_clocks,
205 GFP_KERNEL);
206 if (!ddata->clocks)
207 return -ENOMEM;
208
209 for (i = 0; i < ddata->nr_clocks; i++) {
210 error = sysc_get_one_clock(ddata, ddata->clock_roles[i]);
Tony Lindgren0eecc632017-10-10 14:23:43 -0700211 if (error && error != -ENOENT)
212 return error;
213 }
214
215 return 0;
216}
217
218/**
Tony Lindgren50622362018-04-16 10:20:27 -0700219 * sysc_init_resets - reset module on init
220 * @ddata: device driver data
221 *
222 * A module can have both OCP softreset control and external rstctrl.
223 * If more complicated rstctrl resets are needed, please handle these
224 * directly from the child device driver and map only the module reset
225 * for the parent interconnect target module device.
226 *
227 * Automatic reset of the module on init can be skipped with the
228 * "ti,no-reset-on-init" device tree property.
229 */
230static int sysc_init_resets(struct sysc *ddata)
231{
232 int error;
233
234 ddata->rsts =
235 devm_reset_control_array_get_optional_exclusive(ddata->dev);
236 if (IS_ERR(ddata->rsts))
237 return PTR_ERR(ddata->rsts);
238
239 if (ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)
240 goto deassert;
241
242 error = reset_control_assert(ddata->rsts);
243 if (error)
244 return error;
245
246deassert:
247 error = reset_control_deassert(ddata->rsts);
248 if (error)
249 return error;
250
251 return 0;
252}
253
254/**
Tony Lindgren0eecc632017-10-10 14:23:43 -0700255 * sysc_parse_and_check_child_range - parses module IO region from ranges
256 * @ddata: device driver data
257 *
258 * In general we only need rev, syss, and sysc registers and not the whole
259 * module range. But we do want the offsets for these registers from the
260 * module base. This allows us to check them against the legacy hwmod
261 * platform data. Let's also check the ranges are configured properly.
262 */
263static int sysc_parse_and_check_child_range(struct sysc *ddata)
264{
265 struct device_node *np = ddata->dev->of_node;
266 const __be32 *ranges;
267 u32 nr_addr, nr_size;
268 int len, error;
269
270 ranges = of_get_property(np, "ranges", &len);
271 if (!ranges) {
272 dev_err(ddata->dev, "missing ranges for %pOF\n", np);
273
274 return -ENOENT;
275 }
276
277 len /= sizeof(*ranges);
278
279 if (len < 3) {
280 dev_err(ddata->dev, "incomplete ranges for %pOF\n", np);
281
282 return -EINVAL;
283 }
284
285 error = of_property_read_u32(np, "#address-cells", &nr_addr);
286 if (error)
287 return -ENOENT;
288
289 error = of_property_read_u32(np, "#size-cells", &nr_size);
290 if (error)
291 return -ENOENT;
292
293 if (nr_addr != 1 || nr_size != 1) {
294 dev_err(ddata->dev, "invalid ranges for %pOF\n", np);
295
296 return -EINVAL;
297 }
298
299 ranges++;
300 ddata->module_pa = of_translate_address(np, ranges++);
301 ddata->module_size = be32_to_cpup(ranges);
302
Tony Lindgren0eecc632017-10-10 14:23:43 -0700303 return 0;
304}
305
Tony Lindgren3bb37c82018-02-22 14:05:14 -0800306static struct device_node *stdout_path;
307
308static void sysc_init_stdout_path(struct sysc *ddata)
309{
310 struct device_node *np = NULL;
311 const char *uart;
312
313 if (IS_ERR(stdout_path))
314 return;
315
316 if (stdout_path)
317 return;
318
319 np = of_find_node_by_path("/chosen");
320 if (!np)
321 goto err;
322
323 uart = of_get_property(np, "stdout-path", NULL);
324 if (!uart)
325 goto err;
326
327 np = of_find_node_by_path(uart);
328 if (!np)
329 goto err;
330
331 stdout_path = np;
332
333 return;
334
335err:
336 stdout_path = ERR_PTR(-ENODEV);
337}
338
339static void sysc_check_quirk_stdout(struct sysc *ddata,
340 struct device_node *np)
341{
342 sysc_init_stdout_path(ddata);
343 if (np != stdout_path)
344 return;
345
346 ddata->cfg.quirks |= SYSC_QUIRK_NO_IDLE_ON_INIT |
347 SYSC_QUIRK_NO_RESET_ON_INIT;
348}
349
Tony Lindgren0eecc632017-10-10 14:23:43 -0700350/**
351 * sysc_check_one_child - check child configuration
352 * @ddata: device driver data
353 * @np: child device node
354 *
355 * Let's avoid messy situations where we have new interconnect target
356 * node but children have "ti,hwmods". These belong to the interconnect
357 * target node and are managed by this driver.
358 */
359static int sysc_check_one_child(struct sysc *ddata,
360 struct device_node *np)
361{
362 const char *name;
363
364 name = of_get_property(np, "ti,hwmods", NULL);
365 if (name)
366 dev_warn(ddata->dev, "really a child ti,hwmods property?");
367
Tony Lindgren3bb37c82018-02-22 14:05:14 -0800368 sysc_check_quirk_stdout(ddata, np);
369
Tony Lindgren0eecc632017-10-10 14:23:43 -0700370 return 0;
371}
372
373static int sysc_check_children(struct sysc *ddata)
374{
375 struct device_node *child;
376 int error;
377
378 for_each_child_of_node(ddata->dev->of_node, child) {
379 error = sysc_check_one_child(ddata, child);
380 if (error)
381 return error;
382 }
383
384 return 0;
385}
386
Tony Lindgrena7199e22017-12-15 09:41:14 -0800387/*
388 * So far only I2C uses 16-bit read access with clockactivity with revision
389 * in two registers with stride of 4. We can detect this based on the rev
390 * register size to configure things far enough to be able to properly read
391 * the revision register.
392 */
393static void sysc_check_quirk_16bit(struct sysc *ddata, struct resource *res)
394{
Tony Lindgrendd57ac12018-02-22 14:09:57 -0800395 if (resource_size(res) == 8)
Tony Lindgrena7199e22017-12-15 09:41:14 -0800396 ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT;
Tony Lindgrena7199e22017-12-15 09:41:14 -0800397}
398
Tony Lindgren0eecc632017-10-10 14:23:43 -0700399/**
400 * sysc_parse_one - parses the interconnect target module registers
401 * @ddata: device driver data
402 * @reg: register to parse
403 */
404static int sysc_parse_one(struct sysc *ddata, enum sysc_registers reg)
405{
406 struct resource *res;
407 const char *name;
408
409 switch (reg) {
410 case SYSC_REVISION:
411 case SYSC_SYSCONFIG:
412 case SYSC_SYSSTATUS:
413 name = reg_names[reg];
414 break;
415 default:
416 return -EINVAL;
417 }
418
419 res = platform_get_resource_byname(to_platform_device(ddata->dev),
420 IORESOURCE_MEM, name);
421 if (!res) {
Tony Lindgren0eecc632017-10-10 14:23:43 -0700422 ddata->offsets[reg] = -ENODEV;
423
424 return 0;
425 }
426
427 ddata->offsets[reg] = res->start - ddata->module_pa;
Tony Lindgrena7199e22017-12-15 09:41:14 -0800428 if (reg == SYSC_REVISION)
429 sysc_check_quirk_16bit(ddata, res);
Tony Lindgren0eecc632017-10-10 14:23:43 -0700430
431 return 0;
432}
433
434static int sysc_parse_registers(struct sysc *ddata)
435{
436 int i, error;
437
438 for (i = 0; i < SYSC_MAX_REGS; i++) {
439 error = sysc_parse_one(ddata, i);
440 if (error)
441 return error;
442 }
443
444 return 0;
445}
446
447/**
448 * sysc_check_registers - check for misconfigured register overlaps
449 * @ddata: device driver data
450 */
451static int sysc_check_registers(struct sysc *ddata)
452{
453 int i, j, nr_regs = 0, nr_matches = 0;
454
455 for (i = 0; i < SYSC_MAX_REGS; i++) {
456 if (ddata->offsets[i] < 0)
457 continue;
458
459 if (ddata->offsets[i] > (ddata->module_size - 4)) {
460 dev_err(ddata->dev, "register outside module range");
461
462 return -EINVAL;
463 }
464
465 for (j = 0; j < SYSC_MAX_REGS; j++) {
466 if (ddata->offsets[j] < 0)
467 continue;
468
469 if (ddata->offsets[i] == ddata->offsets[j])
470 nr_matches++;
471 }
472 nr_regs++;
473 }
474
475 if (nr_regs < 1) {
476 dev_err(ddata->dev, "missing registers\n");
477
478 return -EINVAL;
479 }
480
481 if (nr_matches > nr_regs) {
482 dev_err(ddata->dev, "overlapping registers: (%i/%i)",
483 nr_regs, nr_matches);
484
485 return -EINVAL;
486 }
487
488 return 0;
489}
490
491/**
492 * syc_ioremap - ioremap register space for the interconnect target module
493 * @ddata: deviec driver data
494 *
495 * Note that the interconnect target module registers can be anywhere
496 * within the first child device address space. For example, SGX has
497 * them at offset 0x1fc00 in the 32MB module address space. We just
498 * what we need around the interconnect target module registers.
499 */
500static int sysc_ioremap(struct sysc *ddata)
501{
502 u32 size = 0;
503
504 if (ddata->offsets[SYSC_SYSSTATUS] >= 0)
505 size = ddata->offsets[SYSC_SYSSTATUS];
506 else if (ddata->offsets[SYSC_SYSCONFIG] >= 0)
507 size = ddata->offsets[SYSC_SYSCONFIG];
508 else if (ddata->offsets[SYSC_REVISION] >= 0)
509 size = ddata->offsets[SYSC_REVISION];
510 else
511 return -EINVAL;
512
513 size &= 0xfff00;
514 size += SZ_256;
515
516 ddata->module_va = devm_ioremap(ddata->dev,
517 ddata->module_pa,
518 size);
519 if (!ddata->module_va)
520 return -EIO;
521
522 return 0;
523}
524
525/**
526 * sysc_map_and_check_registers - ioremap and check device registers
527 * @ddata: device driver data
528 */
529static int sysc_map_and_check_registers(struct sysc *ddata)
530{
531 int error;
532
533 error = sysc_parse_and_check_child_range(ddata);
534 if (error)
535 return error;
536
537 error = sysc_check_children(ddata);
538 if (error)
539 return error;
540
541 error = sysc_parse_registers(ddata);
542 if (error)
543 return error;
544
545 error = sysc_ioremap(ddata);
546 if (error)
547 return error;
548
549 error = sysc_check_registers(ddata);
550 if (error)
551 return error;
552
553 return 0;
554}
555
556/**
557 * sysc_show_rev - read and show interconnect target module revision
558 * @bufp: buffer to print the information to
559 * @ddata: device driver data
560 */
561static int sysc_show_rev(char *bufp, struct sysc *ddata)
562{
Tony Lindgren566a9b052017-12-15 09:41:19 -0800563 int len;
Tony Lindgren0eecc632017-10-10 14:23:43 -0700564
565 if (ddata->offsets[SYSC_REVISION] < 0)
566 return sprintf(bufp, ":NA");
567
Tony Lindgren566a9b052017-12-15 09:41:19 -0800568 len = sprintf(bufp, ":%08x", ddata->revision);
Tony Lindgren0eecc632017-10-10 14:23:43 -0700569
570 return len;
571}
572
573static int sysc_show_reg(struct sysc *ddata,
574 char *bufp, enum sysc_registers reg)
575{
576 if (ddata->offsets[reg] < 0)
577 return sprintf(bufp, ":NA");
578
579 return sprintf(bufp, ":%x", ddata->offsets[reg]);
580}
581
Tony Lindgrena885f0f2018-02-22 14:03:48 -0800582static int sysc_show_name(char *bufp, struct sysc *ddata)
583{
584 if (!ddata->name)
585 return 0;
586
587 return sprintf(bufp, ":%s", ddata->name);
588}
589
Tony Lindgren0eecc632017-10-10 14:23:43 -0700590/**
591 * sysc_show_registers - show information about interconnect target module
592 * @ddata: device driver data
593 */
594static void sysc_show_registers(struct sysc *ddata)
595{
596 char buf[128];
597 char *bufp = buf;
598 int i;
599
600 for (i = 0; i < SYSC_MAX_REGS; i++)
601 bufp += sysc_show_reg(ddata, bufp, i);
602
603 bufp += sysc_show_rev(bufp, ddata);
Tony Lindgrena885f0f2018-02-22 14:03:48 -0800604 bufp += sysc_show_name(bufp, ddata);
Tony Lindgren0eecc632017-10-10 14:23:43 -0700605
606 dev_dbg(ddata->dev, "%llx:%x%s\n",
607 ddata->module_pa, ddata->module_size,
608 buf);
609}
610
Arnd Bergmanna4a5d492017-10-13 11:25:32 +0200611static int __maybe_unused sysc_runtime_suspend(struct device *dev)
Tony Lindgren0eecc632017-10-10 14:23:43 -0700612{
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800613 struct ti_sysc_platform_data *pdata;
Tony Lindgren0eecc632017-10-10 14:23:43 -0700614 struct sysc *ddata;
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800615 int error = 0, i;
Tony Lindgren0eecc632017-10-10 14:23:43 -0700616
617 ddata = dev_get_drvdata(dev);
618
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800619 if (!ddata->enabled)
Tony Lindgren0eecc632017-10-10 14:23:43 -0700620 return 0;
621
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800622 if (ddata->legacy_mode) {
623 pdata = dev_get_platdata(ddata->dev);
624 if (!pdata)
625 return 0;
626
627 if (!pdata->idle_module)
628 return -ENODEV;
629
630 error = pdata->idle_module(dev, &ddata->cookie);
631 if (error)
632 dev_err(dev, "%s: could not idle: %i\n",
633 __func__, error);
634
635 goto idled;
636 }
637
Tony Lindgren09dfe582018-04-16 10:25:52 -0700638 for (i = 0; i < ddata->nr_clocks; i++) {
Tony Lindgren0eecc632017-10-10 14:23:43 -0700639 if (IS_ERR_OR_NULL(ddata->clocks[i]))
640 continue;
Tony Lindgren09dfe582018-04-16 10:25:52 -0700641
642 if (i >= SYSC_OPTFCK0 && !sysc_opt_clks_needed(ddata))
643 break;
644
Tony Lindgren0eecc632017-10-10 14:23:43 -0700645 clk_disable(ddata->clocks[i]);
646 }
647
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800648idled:
649 ddata->enabled = false;
650
651 return error;
Tony Lindgren0eecc632017-10-10 14:23:43 -0700652}
653
Arnd Bergmanna4a5d492017-10-13 11:25:32 +0200654static int __maybe_unused sysc_runtime_resume(struct device *dev)
Tony Lindgren0eecc632017-10-10 14:23:43 -0700655{
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800656 struct ti_sysc_platform_data *pdata;
Tony Lindgren0eecc632017-10-10 14:23:43 -0700657 struct sysc *ddata;
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800658 int error = 0, i;
Tony Lindgren0eecc632017-10-10 14:23:43 -0700659
660 ddata = dev_get_drvdata(dev);
661
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800662 if (ddata->enabled)
Tony Lindgren0eecc632017-10-10 14:23:43 -0700663 return 0;
664
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800665 if (ddata->legacy_mode) {
666 pdata = dev_get_platdata(ddata->dev);
667 if (!pdata)
668 return 0;
669
670 if (!pdata->enable_module)
671 return -ENODEV;
672
673 error = pdata->enable_module(dev, &ddata->cookie);
674 if (error)
675 dev_err(dev, "%s: could not enable: %i\n",
676 __func__, error);
677
678 goto awake;
679 }
680
Tony Lindgren09dfe582018-04-16 10:25:52 -0700681 for (i = 0; i < ddata->nr_clocks; i++) {
Tony Lindgren0eecc632017-10-10 14:23:43 -0700682 if (IS_ERR_OR_NULL(ddata->clocks[i]))
683 continue;
Tony Lindgren09dfe582018-04-16 10:25:52 -0700684
685 if (i >= SYSC_OPTFCK0 && !sysc_opt_clks_needed(ddata))
686 break;
687
Tony Lindgren0eecc632017-10-10 14:23:43 -0700688 error = clk_enable(ddata->clocks[i]);
689 if (error)
690 return error;
691 }
692
Tony Lindgrenef70b0b2018-02-22 14:00:25 -0800693awake:
694 ddata->enabled = true;
695
696 return error;
Tony Lindgren0eecc632017-10-10 14:23:43 -0700697}
698
Tony Lindgren62020f22018-02-22 13:59:44 -0800699#ifdef CONFIG_PM_SLEEP
700static int sysc_suspend(struct device *dev)
701{
702 struct sysc *ddata;
Tony Lindgrenef55f822018-04-16 10:27:15 -0700703 int error;
Tony Lindgren62020f22018-02-22 13:59:44 -0800704
705 ddata = dev_get_drvdata(dev);
706
Tony Lindgrene7420c22018-04-16 10:26:46 -0700707 if (ddata->cfg.quirks & (SYSC_QUIRK_RESOURCE_PROVIDER |
708 SYSC_QUIRK_LEGACY_IDLE))
709 return 0;
710
Tony Lindgren62020f22018-02-22 13:59:44 -0800711 if (!ddata->enabled)
712 return 0;
713
Tony Lindgrenef55f822018-04-16 10:27:15 -0700714 dev_dbg(ddata->dev, "%s %s\n", __func__,
715 ddata->name ? ddata->name : "");
716
717 error = pm_runtime_put_sync_suspend(dev);
718 if (error < 0) {
719 dev_warn(ddata->dev, "%s not idle %i %s\n",
720 __func__, error,
721 ddata->name ? ddata->name : "");
722
723 return 0;
724 }
725
Tony Lindgren62020f22018-02-22 13:59:44 -0800726 ddata->needs_resume = true;
727
Tony Lindgrenef55f822018-04-16 10:27:15 -0700728 return 0;
Tony Lindgren62020f22018-02-22 13:59:44 -0800729}
730
731static int sysc_resume(struct device *dev)
732{
733 struct sysc *ddata;
Tony Lindgrenef55f822018-04-16 10:27:15 -0700734 int error;
Tony Lindgren62020f22018-02-22 13:59:44 -0800735
736 ddata = dev_get_drvdata(dev);
Tony Lindgrene7420c22018-04-16 10:26:46 -0700737
738 if (ddata->cfg.quirks & (SYSC_QUIRK_RESOURCE_PROVIDER |
739 SYSC_QUIRK_LEGACY_IDLE))
740 return 0;
741
742 if (ddata->needs_resume) {
743 dev_dbg(ddata->dev, "%s %s\n", __func__,
744 ddata->name ? ddata->name : "");
745
Tony Lindgrenef55f822018-04-16 10:27:15 -0700746 error = pm_runtime_get_sync(dev);
747 if (error < 0) {
748 dev_err(ddata->dev, "%s error %i %s\n",
749 __func__, error,
750 ddata->name ? ddata->name : "");
Tony Lindgrene7420c22018-04-16 10:26:46 -0700751
Tony Lindgrenef55f822018-04-16 10:27:15 -0700752 return error;
753 }
754
755 ddata->needs_resume = false;
Tony Lindgrene7420c22018-04-16 10:26:46 -0700756 }
757
758 return 0;
759}
760
761static int sysc_noirq_suspend(struct device *dev)
762{
763 struct sysc *ddata;
764
765 ddata = dev_get_drvdata(dev);
766
767 if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
768 return 0;
769
770 if (!(ddata->cfg.quirks & SYSC_QUIRK_RESOURCE_PROVIDER))
771 return 0;
772
773 if (!ddata->enabled)
774 return 0;
775
776 dev_dbg(ddata->dev, "%s %s\n", __func__,
777 ddata->name ? ddata->name : "");
778
779 ddata->needs_resume = true;
780
781 return sysc_runtime_suspend(dev);
782}
783
784static int sysc_noirq_resume(struct device *dev)
785{
786 struct sysc *ddata;
787
788 ddata = dev_get_drvdata(dev);
789
790 if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
791 return 0;
792
793 if (!(ddata->cfg.quirks & SYSC_QUIRK_RESOURCE_PROVIDER))
794 return 0;
795
Tony Lindgren62020f22018-02-22 13:59:44 -0800796 if (ddata->needs_resume) {
Tony Lindgrenef55f822018-04-16 10:27:15 -0700797 dev_dbg(ddata->dev, "%s %s\n", __func__,
798 ddata->name ? ddata->name : "");
799
Tony Lindgren62020f22018-02-22 13:59:44 -0800800 ddata->needs_resume = false;
801
802 return sysc_runtime_resume(dev);
803 }
804
805 return 0;
806}
807#endif
808
Tony Lindgren0eecc632017-10-10 14:23:43 -0700809static const struct dev_pm_ops sysc_pm_ops = {
Tony Lindgren62020f22018-02-22 13:59:44 -0800810 SET_SYSTEM_SLEEP_PM_OPS(sysc_suspend, sysc_resume)
Tony Lindgrene7420c22018-04-16 10:26:46 -0700811 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_noirq_suspend, sysc_noirq_resume)
Tony Lindgren0eecc632017-10-10 14:23:43 -0700812 SET_RUNTIME_PM_OPS(sysc_runtime_suspend,
813 sysc_runtime_resume,
814 NULL)
815};
816
Tony Lindgrena885f0f2018-02-22 14:03:48 -0800817/* Module revision register based quirks */
818struct sysc_revision_quirk {
819 const char *name;
820 u32 base;
821 int rev_offset;
822 int sysc_offset;
823 int syss_offset;
824 u32 revision;
825 u32 revision_mask;
826 u32 quirks;
827};
828
829#define SYSC_QUIRK(optname, optbase, optrev, optsysc, optsyss, \
830 optrev_val, optrevmask, optquirkmask) \
831 { \
832 .name = (optname), \
833 .base = (optbase), \
834 .rev_offset = (optrev), \
835 .sysc_offset = (optsysc), \
836 .syss_offset = (optsyss), \
837 .revision = (optrev_val), \
838 .revision_mask = (optrevmask), \
839 .quirks = (optquirkmask), \
840 }
841
842static const struct sysc_revision_quirk sysc_revision_quirks[] = {
Tony Lindgrene7420c22018-04-16 10:26:46 -0700843 /* These need to use noirq_suspend */
844 SYSC_QUIRK("control", 0, 0, 0x10, -1, 0x40000900, 0xffffffff,
845 SYSC_QUIRK_RESOURCE_PROVIDER),
846 SYSC_QUIRK("i2c", 0, 0, 0x10, 0x90, 0x5040000a, 0xffffffff,
847 SYSC_QUIRK_RESOURCE_PROVIDER),
848 SYSC_QUIRK("mcspi", 0, 0, 0x10, -1, 0x40300a0b, 0xffffffff,
849 SYSC_QUIRK_RESOURCE_PROVIDER),
850 SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000100, 0xffffffff,
851 SYSC_QUIRK_RESOURCE_PROVIDER),
852 SYSC_QUIRK("ocp2scp", 0, 0, 0x10, 0x14, 0x50060005, 0xffffffff,
853 SYSC_QUIRK_RESOURCE_PROVIDER),
854 SYSC_QUIRK("padconf", 0, 0, 0x10, -1, 0x4fff0800, 0xffffffff,
855 SYSC_QUIRK_RESOURCE_PROVIDER),
856 SYSC_QUIRK("scm", 0, 0, 0x10, -1, 0x40000900, 0xffffffff,
857 SYSC_QUIRK_RESOURCE_PROVIDER),
858 SYSC_QUIRK("scrm", 0, 0, -1, -1, 0x00000010, 0xffffffff,
859 SYSC_QUIRK_RESOURCE_PROVIDER),
860 SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff,
861 SYSC_QUIRK_RESOURCE_PROVIDER),
862
Tony Lindgrena885f0f2018-02-22 14:03:48 -0800863 /* These drivers need to be fixed to not use pm_runtime_irq_safe() */
864 SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffffffff,
Tony Lindgren09dfe582018-04-16 10:25:52 -0700865 SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_OPT_CLKS_IN_RESET),
Tony Lindgrena885f0f2018-02-22 14:03:48 -0800866 SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000020, 0xffffffff,
867 SYSC_QUIRK_LEGACY_IDLE),
868 SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000030, 0xffffffff,
869 SYSC_QUIRK_LEGACY_IDLE),
870 SYSC_QUIRK("sham", 0, 0x100, 0x110, 0x114, 0x40000c03, 0xffffffff,
871 SYSC_QUIRK_LEGACY_IDLE),
872 SYSC_QUIRK("smartreflex", 0, -1, 0x24, -1, 0x00000000, 0xffffffff,
873 SYSC_QUIRK_LEGACY_IDLE),
874 SYSC_QUIRK("smartreflex", 0, -1, 0x38, -1, 0x00000000, 0xffffffff,
875 SYSC_QUIRK_LEGACY_IDLE),
876 SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff,
877 SYSC_QUIRK_LEGACY_IDLE),
Tony Lindgren8cde5d52018-04-16 10:25:15 -0700878 /* Some timers on omap4 and later */
879 SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x4fff1301, 0xffffffff,
880 SYSC_QUIRK_LEGACY_IDLE),
Tony Lindgrena885f0f2018-02-22 14:03:48 -0800881 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff,
882 SYSC_QUIRK_LEGACY_IDLE),
Tony Lindgrend708bb12018-04-16 10:25:32 -0700883 /* Uarts on omap4 and later */
884 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffffffff,
885 SYSC_QUIRK_LEGACY_IDLE),
Tony Lindgren7e27e5d2018-04-20 14:54:16 -0700886
887 /* These devices don't yet suspend properly without legacy setting */
888 SYSC_QUIRK("sdio", 0, 0, 0x10, -1, 0x40202301, 0xffffffff,
889 SYSC_QUIRK_LEGACY_IDLE),
890 SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xffffffff,
891 SYSC_QUIRK_LEGACY_IDLE),
892 SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0d00, 0xffffffff,
893 SYSC_QUIRK_LEGACY_IDLE),
Tony Lindgrena885f0f2018-02-22 14:03:48 -0800894};
895
896static void sysc_init_revision_quirks(struct sysc *ddata)
897{
898 const struct sysc_revision_quirk *q;
899 int i;
900
901 for (i = 0; i < ARRAY_SIZE(sysc_revision_quirks); i++) {
902 q = &sysc_revision_quirks[i];
903
904 if (q->base && q->base != ddata->module_pa)
905 continue;
906
907 if (q->rev_offset >= 0 &&
908 q->rev_offset != ddata->offsets[SYSC_REVISION])
909 continue;
910
911 if (q->sysc_offset >= 0 &&
912 q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG])
913 continue;
914
915 if (q->syss_offset >= 0 &&
916 q->syss_offset != ddata->offsets[SYSC_SYSSTATUS])
917 continue;
918
919 if (q->revision == ddata->revision ||
920 (q->revision & q->revision_mask) ==
921 (ddata->revision & q->revision_mask)) {
922 ddata->name = q->name;
923 ddata->cfg.quirks |= q->quirks;
924 }
925 }
926}
927
Tony Lindgren566a9b052017-12-15 09:41:19 -0800928/* At this point the module is configured enough to read the revision */
929static int sysc_init_module(struct sysc *ddata)
930{
931 int error;
932
Tony Lindgrena885f0f2018-02-22 14:03:48 -0800933 if (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE_ON_INIT) {
934 ddata->revision = sysc_read_revision(ddata);
935 goto rev_quirks;
936 }
937
Tony Lindgren566a9b052017-12-15 09:41:19 -0800938 error = pm_runtime_get_sync(ddata->dev);
939 if (error < 0) {
940 pm_runtime_put_noidle(ddata->dev);
941
942 return 0;
943 }
Tony Lindgren50622362018-04-16 10:20:27 -0700944
Tony Lindgren566a9b052017-12-15 09:41:19 -0800945 ddata->revision = sysc_read_revision(ddata);
946 pm_runtime_put_sync(ddata->dev);
947
Tony Lindgrena885f0f2018-02-22 14:03:48 -0800948rev_quirks:
949 sysc_init_revision_quirks(ddata);
950
Tony Lindgren566a9b052017-12-15 09:41:19 -0800951 return 0;
952}
953
Tony Lindgrenc5a2de92017-12-15 09:41:23 -0800954static int sysc_init_sysc_mask(struct sysc *ddata)
955{
956 struct device_node *np = ddata->dev->of_node;
957 int error;
958 u32 val;
959
960 error = of_property_read_u32(np, "ti,sysc-mask", &val);
961 if (error)
962 return 0;
963
964 if (val)
965 ddata->cfg.sysc_val = val & ddata->cap->sysc_mask;
966 else
967 ddata->cfg.sysc_val = ddata->cap->sysc_mask;
968
969 return 0;
970}
971
972static int sysc_init_idlemode(struct sysc *ddata, u8 *idlemodes,
973 const char *name)
974{
975 struct device_node *np = ddata->dev->of_node;
976 struct property *prop;
977 const __be32 *p;
978 u32 val;
979
980 of_property_for_each_u32(np, name, prop, p, val) {
981 if (val >= SYSC_NR_IDLEMODES) {
982 dev_err(ddata->dev, "invalid idlemode: %i\n", val);
983 return -EINVAL;
984 }
985 *idlemodes |= (1 << val);
986 }
987
988 return 0;
989}
990
991static int sysc_init_idlemodes(struct sysc *ddata)
992{
993 int error;
994
995 error = sysc_init_idlemode(ddata, &ddata->cfg.midlemodes,
996 "ti,sysc-midle");
997 if (error)
998 return error;
999
1000 error = sysc_init_idlemode(ddata, &ddata->cfg.sidlemodes,
1001 "ti,sysc-sidle");
1002 if (error)
1003 return error;
1004
1005 return 0;
1006}
1007
1008/*
1009 * Only some devices on omap4 and later have SYSCONFIG reset done
1010 * bit. We can detect this if there is no SYSSTATUS at all, or the
1011 * SYSTATUS bit 0 is not used. Note that some SYSSTATUS registers
1012 * have multiple bits for the child devices like OHCI and EHCI.
1013 * Depends on SYSC being parsed first.
1014 */
1015static int sysc_init_syss_mask(struct sysc *ddata)
1016{
1017 struct device_node *np = ddata->dev->of_node;
1018 int error;
1019 u32 val;
1020
1021 error = of_property_read_u32(np, "ti,syss-mask", &val);
1022 if (error) {
1023 if ((ddata->cap->type == TI_SYSC_OMAP4 ||
1024 ddata->cap->type == TI_SYSC_OMAP4_TIMER) &&
1025 (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET))
1026 ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS;
1027
1028 return 0;
1029 }
1030
1031 if (!(val & 1) && (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET))
1032 ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS;
1033
1034 ddata->cfg.syss_mask = val;
1035
1036 return 0;
1037}
1038
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001039/*
Tony Lindgren8b2830ba2018-04-16 10:26:09 -07001040 * Many child device drivers need to have fck and opt clocks available
1041 * to get the clock rate for device internal configuration etc.
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001042 */
Tony Lindgren8b2830ba2018-04-16 10:26:09 -07001043static int sysc_child_add_named_clock(struct sysc *ddata,
1044 struct device *child,
1045 const char *name)
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001046{
Tony Lindgren8b2830ba2018-04-16 10:26:09 -07001047 struct clk *clk;
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001048 struct clk_lookup *l;
Tony Lindgren8b2830ba2018-04-16 10:26:09 -07001049 int error = 0;
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001050
Tony Lindgren8b2830ba2018-04-16 10:26:09 -07001051 if (!name)
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001052 return 0;
1053
Tony Lindgren8b2830ba2018-04-16 10:26:09 -07001054 clk = clk_get(child, name);
1055 if (!IS_ERR(clk)) {
1056 clk_put(clk);
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001057
1058 return -EEXIST;
1059 }
1060
Tony Lindgren8b2830ba2018-04-16 10:26:09 -07001061 clk = clk_get(ddata->dev, name);
1062 if (IS_ERR(clk))
1063 return -ENODEV;
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001064
Tony Lindgren8b2830ba2018-04-16 10:26:09 -07001065 l = clkdev_create(clk, name, dev_name(child));
1066 if (!l)
1067 error = -ENOMEM;
1068
1069 clk_put(clk);
1070
1071 return error;
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001072}
1073
Tony Lindgren09dfe582018-04-16 10:25:52 -07001074static int sysc_child_add_clocks(struct sysc *ddata,
1075 struct device *child)
1076{
1077 int i, error;
1078
1079 for (i = 0; i < ddata->nr_clocks; i++) {
1080 error = sysc_child_add_named_clock(ddata,
1081 child,
1082 ddata->clock_roles[i]);
1083 if (error && error != -EEXIST) {
1084 dev_err(ddata->dev, "could not add child clock %s: %i\n",
1085 ddata->clock_roles[i], error);
1086
1087 return error;
1088 }
1089 }
1090
1091 return 0;
1092}
1093
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001094static struct device_type sysc_device_type = {
1095};
1096
1097static struct sysc *sysc_child_to_parent(struct device *dev)
1098{
1099 struct device *parent = dev->parent;
1100
1101 if (!parent || parent->type != &sysc_device_type)
1102 return NULL;
1103
1104 return dev_get_drvdata(parent);
1105}
1106
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001107static int __maybe_unused sysc_child_runtime_suspend(struct device *dev)
1108{
1109 struct sysc *ddata;
1110 int error;
1111
1112 ddata = sysc_child_to_parent(dev);
1113
1114 error = pm_generic_runtime_suspend(dev);
1115 if (error)
1116 return error;
1117
1118 if (!ddata->enabled)
1119 return 0;
1120
1121 return sysc_runtime_suspend(ddata->dev);
1122}
1123
1124static int __maybe_unused sysc_child_runtime_resume(struct device *dev)
1125{
1126 struct sysc *ddata;
1127 int error;
1128
1129 ddata = sysc_child_to_parent(dev);
1130
1131 if (!ddata->enabled) {
1132 error = sysc_runtime_resume(ddata->dev);
1133 if (error < 0)
1134 dev_err(ddata->dev,
1135 "%s error: %i\n", __func__, error);
1136 }
1137
1138 return pm_generic_runtime_resume(dev);
1139}
1140
1141#ifdef CONFIG_PM_SLEEP
1142static int sysc_child_suspend_noirq(struct device *dev)
1143{
1144 struct sysc *ddata;
1145 int error;
1146
1147 ddata = sysc_child_to_parent(dev);
1148
Tony Lindgrenef55f822018-04-16 10:27:15 -07001149 dev_dbg(ddata->dev, "%s %s\n", __func__,
1150 ddata->name ? ddata->name : "");
1151
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001152 error = pm_generic_suspend_noirq(dev);
Tony Lindgrenef55f822018-04-16 10:27:15 -07001153 if (error) {
1154 dev_err(dev, "%s error at %i: %i\n",
1155 __func__, __LINE__, error);
1156
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001157 return error;
Tony Lindgrenef55f822018-04-16 10:27:15 -07001158 }
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001159
1160 if (!pm_runtime_status_suspended(dev)) {
1161 error = pm_generic_runtime_suspend(dev);
Tony Lindgrenef55f822018-04-16 10:27:15 -07001162 if (error) {
1163 dev_err(dev, "%s error at %i: %i\n",
1164 __func__, __LINE__, error);
1165
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001166 return error;
Tony Lindgrenef55f822018-04-16 10:27:15 -07001167 }
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001168
1169 error = sysc_runtime_suspend(ddata->dev);
Tony Lindgrenef55f822018-04-16 10:27:15 -07001170 if (error) {
1171 dev_err(dev, "%s error at %i: %i\n",
1172 __func__, __LINE__, error);
1173
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001174 return error;
Tony Lindgrenef55f822018-04-16 10:27:15 -07001175 }
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001176
1177 ddata->child_needs_resume = true;
1178 }
1179
1180 return 0;
1181}
1182
1183static int sysc_child_resume_noirq(struct device *dev)
1184{
1185 struct sysc *ddata;
1186 int error;
1187
1188 ddata = sysc_child_to_parent(dev);
1189
Tony Lindgrenef55f822018-04-16 10:27:15 -07001190 dev_dbg(ddata->dev, "%s %s\n", __func__,
1191 ddata->name ? ddata->name : "");
1192
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001193 if (ddata->child_needs_resume) {
1194 ddata->child_needs_resume = false;
1195
1196 error = sysc_runtime_resume(ddata->dev);
1197 if (error)
1198 dev_err(ddata->dev,
1199 "%s runtime resume error: %i\n",
1200 __func__, error);
1201
1202 error = pm_generic_runtime_resume(dev);
1203 if (error)
1204 dev_err(ddata->dev,
1205 "%s generic runtime resume: %i\n",
1206 __func__, error);
1207 }
1208
1209 return pm_generic_resume_noirq(dev);
1210}
1211#endif
1212
1213struct dev_pm_domain sysc_child_pm_domain = {
1214 .ops = {
1215 SET_RUNTIME_PM_OPS(sysc_child_runtime_suspend,
1216 sysc_child_runtime_resume,
1217 NULL)
1218 USE_PLATFORM_PM_SLEEP_OPS
1219 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_child_suspend_noirq,
1220 sysc_child_resume_noirq)
1221 }
1222};
1223
1224/**
1225 * sysc_legacy_idle_quirk - handle children in omap_device compatible way
1226 * @ddata: device driver data
1227 * @child: child device driver
1228 *
1229 * Allow idle for child devices as done with _od_runtime_suspend().
1230 * Otherwise many child devices will not idle because of the permanent
1231 * parent usecount set in pm_runtime_irq_safe().
1232 *
1233 * Note that the long term solution is to just modify the child device
1234 * drivers to not set pm_runtime_irq_safe() and then this can be just
1235 * dropped.
1236 */
1237static void sysc_legacy_idle_quirk(struct sysc *ddata, struct device *child)
1238{
1239 if (!ddata->legacy_mode)
1240 return;
1241
1242 if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
1243 dev_pm_domain_set(child, &sysc_child_pm_domain);
1244}
1245
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001246static int sysc_notifier_call(struct notifier_block *nb,
1247 unsigned long event, void *device)
1248{
1249 struct device *dev = device;
1250 struct sysc *ddata;
1251 int error;
1252
1253 ddata = sysc_child_to_parent(dev);
1254 if (!ddata)
1255 return NOTIFY_DONE;
1256
1257 switch (event) {
1258 case BUS_NOTIFY_ADD_DEVICE:
Tony Lindgren09dfe582018-04-16 10:25:52 -07001259 error = sysc_child_add_clocks(ddata, dev);
1260 if (error)
1261 return error;
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001262 sysc_legacy_idle_quirk(ddata, dev);
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001263 break;
1264 default:
1265 break;
1266 }
1267
1268 return NOTIFY_DONE;
1269}
1270
1271static struct notifier_block sysc_nb = {
1272 .notifier_call = sysc_notifier_call,
1273};
1274
Tony Lindgren566a9b052017-12-15 09:41:19 -08001275/* Device tree configured quirks */
1276struct sysc_dts_quirk {
1277 const char *name;
1278 u32 mask;
1279};
1280
1281static const struct sysc_dts_quirk sysc_dts_quirks[] = {
1282 { .name = "ti,no-idle-on-init",
1283 .mask = SYSC_QUIRK_NO_IDLE_ON_INIT, },
1284 { .name = "ti,no-reset-on-init",
1285 .mask = SYSC_QUIRK_NO_RESET_ON_INIT, },
1286};
1287
1288static int sysc_init_dts_quirks(struct sysc *ddata)
1289{
1290 struct device_node *np = ddata->dev->of_node;
1291 const struct property *prop;
1292 int i, len, error;
1293 u32 val;
1294
1295 ddata->legacy_mode = of_get_property(np, "ti,hwmods", NULL);
1296
1297 for (i = 0; i < ARRAY_SIZE(sysc_dts_quirks); i++) {
1298 prop = of_get_property(np, sysc_dts_quirks[i].name, &len);
1299 if (!prop)
Tony Lindgrend39b6ea2018-02-15 09:18:55 -08001300 continue;
Tony Lindgren566a9b052017-12-15 09:41:19 -08001301
1302 ddata->cfg.quirks |= sysc_dts_quirks[i].mask;
1303 }
1304
1305 error = of_property_read_u32(np, "ti,sysc-delay-us", &val);
1306 if (!error) {
1307 if (val > 255) {
1308 dev_warn(ddata->dev, "bad ti,sysc-delay-us: %i\n",
1309 val);
1310 }
1311
1312 ddata->cfg.srst_udelay = (u8)val;
1313 }
1314
1315 return 0;
1316}
1317
Tony Lindgren0eecc632017-10-10 14:23:43 -07001318static void sysc_unprepare(struct sysc *ddata)
1319{
1320 int i;
1321
1322 for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
1323 if (!IS_ERR_OR_NULL(ddata->clocks[i]))
1324 clk_unprepare(ddata->clocks[i]);
1325 }
1326}
1327
Tony Lindgren70a65242017-12-15 09:41:09 -08001328/*
1329 * Common sysc register bits found on omap2, also known as type1
1330 */
1331static const struct sysc_regbits sysc_regbits_omap2 = {
1332 .dmadisable_shift = -ENODEV,
1333 .midle_shift = 12,
1334 .sidle_shift = 3,
1335 .clkact_shift = 8,
1336 .emufree_shift = 5,
1337 .enwkup_shift = 2,
1338 .srst_shift = 1,
1339 .autoidle_shift = 0,
1340};
1341
1342static const struct sysc_capabilities sysc_omap2 = {
1343 .type = TI_SYSC_OMAP2,
1344 .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY | SYSC_OMAP2_EMUFREE |
1345 SYSC_OMAP2_ENAWAKEUP | SYSC_OMAP2_SOFTRESET |
1346 SYSC_OMAP2_AUTOIDLE,
1347 .regbits = &sysc_regbits_omap2,
1348};
1349
1350/* All omap2 and 3 timers, and timers 1, 2 & 10 on omap 4 and 5 */
1351static const struct sysc_capabilities sysc_omap2_timer = {
1352 .type = TI_SYSC_OMAP2_TIMER,
1353 .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY | SYSC_OMAP2_EMUFREE |
1354 SYSC_OMAP2_ENAWAKEUP | SYSC_OMAP2_SOFTRESET |
1355 SYSC_OMAP2_AUTOIDLE,
1356 .regbits = &sysc_regbits_omap2,
1357 .mod_quirks = SYSC_QUIRK_USE_CLOCKACT,
1358};
1359
1360/*
1361 * SHAM2 (SHA1/MD5) sysc found on omap3, a variant of sysc_regbits_omap2
1362 * with different sidle position
1363 */
1364static const struct sysc_regbits sysc_regbits_omap3_sham = {
1365 .dmadisable_shift = -ENODEV,
1366 .midle_shift = -ENODEV,
1367 .sidle_shift = 4,
1368 .clkact_shift = -ENODEV,
1369 .enwkup_shift = -ENODEV,
1370 .srst_shift = 1,
1371 .autoidle_shift = 0,
1372 .emufree_shift = -ENODEV,
1373};
1374
1375static const struct sysc_capabilities sysc_omap3_sham = {
1376 .type = TI_SYSC_OMAP3_SHAM,
1377 .sysc_mask = SYSC_OMAP2_SOFTRESET | SYSC_OMAP2_AUTOIDLE,
1378 .regbits = &sysc_regbits_omap3_sham,
1379};
1380
1381/*
1382 * AES register bits found on omap3 and later, a variant of
1383 * sysc_regbits_omap2 with different sidle position
1384 */
1385static const struct sysc_regbits sysc_regbits_omap3_aes = {
1386 .dmadisable_shift = -ENODEV,
1387 .midle_shift = -ENODEV,
1388 .sidle_shift = 6,
1389 .clkact_shift = -ENODEV,
1390 .enwkup_shift = -ENODEV,
1391 .srst_shift = 1,
1392 .autoidle_shift = 0,
1393 .emufree_shift = -ENODEV,
1394};
1395
1396static const struct sysc_capabilities sysc_omap3_aes = {
1397 .type = TI_SYSC_OMAP3_AES,
1398 .sysc_mask = SYSC_OMAP2_SOFTRESET | SYSC_OMAP2_AUTOIDLE,
1399 .regbits = &sysc_regbits_omap3_aes,
1400};
1401
1402/*
1403 * Common sysc register bits found on omap4, also known as type2
1404 */
1405static const struct sysc_regbits sysc_regbits_omap4 = {
1406 .dmadisable_shift = 16,
1407 .midle_shift = 4,
1408 .sidle_shift = 2,
1409 .clkact_shift = -ENODEV,
1410 .enwkup_shift = -ENODEV,
1411 .emufree_shift = 1,
1412 .srst_shift = 0,
1413 .autoidle_shift = -ENODEV,
1414};
1415
1416static const struct sysc_capabilities sysc_omap4 = {
1417 .type = TI_SYSC_OMAP4,
1418 .sysc_mask = SYSC_OMAP4_DMADISABLE | SYSC_OMAP4_FREEEMU |
1419 SYSC_OMAP4_SOFTRESET,
1420 .regbits = &sysc_regbits_omap4,
1421};
1422
1423static const struct sysc_capabilities sysc_omap4_timer = {
1424 .type = TI_SYSC_OMAP4_TIMER,
1425 .sysc_mask = SYSC_OMAP4_DMADISABLE | SYSC_OMAP4_FREEEMU |
1426 SYSC_OMAP4_SOFTRESET,
1427 .regbits = &sysc_regbits_omap4,
1428};
1429
1430/*
1431 * Common sysc register bits found on omap4, also known as type3
1432 */
1433static const struct sysc_regbits sysc_regbits_omap4_simple = {
1434 .dmadisable_shift = -ENODEV,
1435 .midle_shift = 2,
1436 .sidle_shift = 0,
1437 .clkact_shift = -ENODEV,
1438 .enwkup_shift = -ENODEV,
1439 .srst_shift = -ENODEV,
1440 .emufree_shift = -ENODEV,
1441 .autoidle_shift = -ENODEV,
1442};
1443
1444static const struct sysc_capabilities sysc_omap4_simple = {
1445 .type = TI_SYSC_OMAP4_SIMPLE,
1446 .regbits = &sysc_regbits_omap4_simple,
1447};
1448
1449/*
1450 * SmartReflex sysc found on omap34xx
1451 */
1452static const struct sysc_regbits sysc_regbits_omap34xx_sr = {
1453 .dmadisable_shift = -ENODEV,
1454 .midle_shift = -ENODEV,
1455 .sidle_shift = -ENODEV,
1456 .clkact_shift = 20,
1457 .enwkup_shift = -ENODEV,
1458 .srst_shift = -ENODEV,
1459 .emufree_shift = -ENODEV,
1460 .autoidle_shift = -ENODEV,
1461};
1462
1463static const struct sysc_capabilities sysc_34xx_sr = {
1464 .type = TI_SYSC_OMAP34XX_SR,
1465 .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY,
1466 .regbits = &sysc_regbits_omap34xx_sr,
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001467 .mod_quirks = SYSC_QUIRK_USE_CLOCKACT | SYSC_QUIRK_UNCACHED |
1468 SYSC_QUIRK_LEGACY_IDLE,
Tony Lindgren70a65242017-12-15 09:41:09 -08001469};
1470
1471/*
1472 * SmartReflex sysc found on omap36xx and later
1473 */
1474static const struct sysc_regbits sysc_regbits_omap36xx_sr = {
1475 .dmadisable_shift = -ENODEV,
1476 .midle_shift = -ENODEV,
1477 .sidle_shift = 24,
1478 .clkact_shift = -ENODEV,
1479 .enwkup_shift = 26,
1480 .srst_shift = -ENODEV,
1481 .emufree_shift = -ENODEV,
1482 .autoidle_shift = -ENODEV,
1483};
1484
1485static const struct sysc_capabilities sysc_36xx_sr = {
1486 .type = TI_SYSC_OMAP36XX_SR,
Tony Lindgren3267c082018-01-22 09:32:53 -08001487 .sysc_mask = SYSC_OMAP3_SR_ENAWAKEUP,
Tony Lindgren70a65242017-12-15 09:41:09 -08001488 .regbits = &sysc_regbits_omap36xx_sr,
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001489 .mod_quirks = SYSC_QUIRK_UNCACHED | SYSC_QUIRK_LEGACY_IDLE,
Tony Lindgren70a65242017-12-15 09:41:09 -08001490};
1491
1492static const struct sysc_capabilities sysc_omap4_sr = {
1493 .type = TI_SYSC_OMAP4_SR,
1494 .regbits = &sysc_regbits_omap36xx_sr,
Tony Lindgrena885f0f2018-02-22 14:03:48 -08001495 .mod_quirks = SYSC_QUIRK_LEGACY_IDLE,
Tony Lindgren70a65242017-12-15 09:41:09 -08001496};
1497
1498/*
1499 * McASP register bits found on omap4 and later
1500 */
1501static const struct sysc_regbits sysc_regbits_omap4_mcasp = {
1502 .dmadisable_shift = -ENODEV,
1503 .midle_shift = -ENODEV,
1504 .sidle_shift = 0,
1505 .clkact_shift = -ENODEV,
1506 .enwkup_shift = -ENODEV,
1507 .srst_shift = -ENODEV,
1508 .emufree_shift = -ENODEV,
1509 .autoidle_shift = -ENODEV,
1510};
1511
1512static const struct sysc_capabilities sysc_omap4_mcasp = {
1513 .type = TI_SYSC_OMAP4_MCASP,
1514 .regbits = &sysc_regbits_omap4_mcasp,
1515};
1516
1517/*
1518 * FS USB host found on omap4 and later
1519 */
1520static const struct sysc_regbits sysc_regbits_omap4_usb_host_fs = {
1521 .dmadisable_shift = -ENODEV,
1522 .midle_shift = -ENODEV,
1523 .sidle_shift = 24,
1524 .clkact_shift = -ENODEV,
1525 .enwkup_shift = 26,
1526 .srst_shift = -ENODEV,
1527 .emufree_shift = -ENODEV,
1528 .autoidle_shift = -ENODEV,
1529};
1530
1531static const struct sysc_capabilities sysc_omap4_usb_host_fs = {
1532 .type = TI_SYSC_OMAP4_USB_HOST_FS,
1533 .sysc_mask = SYSC_OMAP2_ENAWAKEUP,
1534 .regbits = &sysc_regbits_omap4_usb_host_fs,
1535};
1536
Tony Lindgrenef70b0b2018-02-22 14:00:25 -08001537static int sysc_init_pdata(struct sysc *ddata)
1538{
1539 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev);
1540 struct ti_sysc_module_data mdata;
1541 int error = 0;
1542
1543 if (!pdata || !ddata->legacy_mode)
1544 return 0;
1545
1546 mdata.name = ddata->legacy_mode;
1547 mdata.module_pa = ddata->module_pa;
1548 mdata.module_size = ddata->module_size;
1549 mdata.offsets = ddata->offsets;
1550 mdata.nr_offsets = SYSC_MAX_REGS;
1551 mdata.cap = ddata->cap;
1552 mdata.cfg = &ddata->cfg;
1553
1554 if (!pdata->init_module)
1555 return -ENODEV;
1556
1557 error = pdata->init_module(ddata->dev, &mdata, &ddata->cookie);
1558 if (error == -EEXIST)
1559 error = 0;
1560
1561 return error;
1562}
1563
Tony Lindgren70a65242017-12-15 09:41:09 -08001564static int sysc_init_match(struct sysc *ddata)
1565{
1566 const struct sysc_capabilities *cap;
1567
1568 cap = of_device_get_match_data(ddata->dev);
1569 if (!cap)
1570 return -EINVAL;
1571
1572 ddata->cap = cap;
1573 if (ddata->cap)
1574 ddata->cfg.quirks |= ddata->cap->mod_quirks;
1575
1576 return 0;
1577}
1578
Tony Lindgren76f0f772018-02-23 08:28:45 -08001579static void ti_sysc_idle(struct work_struct *work)
1580{
1581 struct sysc *ddata;
1582
1583 ddata = container_of(work, struct sysc, idle_work.work);
1584
1585 if (pm_runtime_active(ddata->dev))
1586 pm_runtime_put_sync(ddata->dev);
1587}
1588
Tony Lindgrenc4bebea2018-04-16 10:24:54 -07001589static const struct of_device_id sysc_match_table[] = {
1590 { .compatible = "simple-bus", },
1591 { /* sentinel */ },
1592};
1593
Tony Lindgren0eecc632017-10-10 14:23:43 -07001594static int sysc_probe(struct platform_device *pdev)
1595{
Tony Lindgrenef70b0b2018-02-22 14:00:25 -08001596 struct ti_sysc_platform_data *pdata = dev_get_platdata(&pdev->dev);
Tony Lindgren0eecc632017-10-10 14:23:43 -07001597 struct sysc *ddata;
1598 int error;
1599
1600 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
1601 if (!ddata)
1602 return -ENOMEM;
1603
1604 ddata->dev = &pdev->dev;
Tony Lindgren566a9b052017-12-15 09:41:19 -08001605 platform_set_drvdata(pdev, ddata);
Tony Lindgren0eecc632017-10-10 14:23:43 -07001606
Tony Lindgren70a65242017-12-15 09:41:09 -08001607 error = sysc_init_match(ddata);
1608 if (error)
1609 return error;
1610
Tony Lindgren566a9b052017-12-15 09:41:19 -08001611 error = sysc_init_dts_quirks(ddata);
1612 if (error)
1613 goto unprepare;
1614
Tony Lindgren0eecc632017-10-10 14:23:43 -07001615 error = sysc_get_clocks(ddata);
1616 if (error)
1617 return error;
1618
1619 error = sysc_map_and_check_registers(ddata);
1620 if (error)
1621 goto unprepare;
1622
Tony Lindgrenc5a2de92017-12-15 09:41:23 -08001623 error = sysc_init_sysc_mask(ddata);
1624 if (error)
1625 goto unprepare;
1626
1627 error = sysc_init_idlemodes(ddata);
1628 if (error)
1629 goto unprepare;
1630
1631 error = sysc_init_syss_mask(ddata);
1632 if (error)
1633 goto unprepare;
1634
Tony Lindgrenef70b0b2018-02-22 14:00:25 -08001635 error = sysc_init_pdata(ddata);
1636 if (error)
1637 goto unprepare;
1638
Tony Lindgren50622362018-04-16 10:20:27 -07001639 error = sysc_init_resets(ddata);
1640 if (error)
1641 return error;
Tony Lindgren566a9b052017-12-15 09:41:19 -08001642
Tony Lindgren50622362018-04-16 10:20:27 -07001643 pm_runtime_enable(ddata->dev);
Tony Lindgren566a9b052017-12-15 09:41:19 -08001644 error = sysc_init_module(ddata);
1645 if (error)
1646 goto unprepare;
1647
Tony Lindgren0eecc632017-10-10 14:23:43 -07001648 error = pm_runtime_get_sync(ddata->dev);
1649 if (error < 0) {
1650 pm_runtime_put_noidle(ddata->dev);
1651 pm_runtime_disable(ddata->dev);
1652 goto unprepare;
1653 }
1654
Tony Lindgren0eecc632017-10-10 14:23:43 -07001655 sysc_show_registers(ddata);
1656
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001657 ddata->dev->type = &sysc_device_type;
Tony Lindgrenc4bebea2018-04-16 10:24:54 -07001658 error = of_platform_populate(ddata->dev->of_node, sysc_match_table,
1659 pdata ? pdata->auxdata : NULL,
Tony Lindgrenef70b0b2018-02-22 14:00:25 -08001660 ddata->dev);
Tony Lindgren0eecc632017-10-10 14:23:43 -07001661 if (error)
1662 goto err;
1663
Tony Lindgren76f0f772018-02-23 08:28:45 -08001664 INIT_DELAYED_WORK(&ddata->idle_work, ti_sysc_idle);
1665
1666 /* At least earlycon won't survive without deferred idle */
1667 if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE_ON_INIT |
1668 SYSC_QUIRK_NO_RESET_ON_INIT)) {
1669 schedule_delayed_work(&ddata->idle_work, 3000);
1670 } else {
1671 pm_runtime_put(&pdev->dev);
1672 }
Tony Lindgren0eecc632017-10-10 14:23:43 -07001673
Tony Lindgren50622362018-04-16 10:20:27 -07001674 if (!of_get_available_child_count(ddata->dev->of_node))
1675 reset_control_assert(ddata->rsts);
1676
Tony Lindgren0eecc632017-10-10 14:23:43 -07001677 return 0;
1678
1679err:
Tony Lindgren0eecc632017-10-10 14:23:43 -07001680 pm_runtime_put_sync(&pdev->dev);
1681 pm_runtime_disable(&pdev->dev);
1682unprepare:
1683 sysc_unprepare(ddata);
1684
1685 return error;
1686}
1687
Tony Lindgren684be5a2017-10-13 10:48:40 -07001688static int sysc_remove(struct platform_device *pdev)
1689{
1690 struct sysc *ddata = platform_get_drvdata(pdev);
1691 int error;
1692
Tony Lindgren76f0f772018-02-23 08:28:45 -08001693 cancel_delayed_work_sync(&ddata->idle_work);
1694
Tony Lindgren684be5a2017-10-13 10:48:40 -07001695 error = pm_runtime_get_sync(ddata->dev);
1696 if (error < 0) {
1697 pm_runtime_put_noidle(ddata->dev);
1698 pm_runtime_disable(ddata->dev);
1699 goto unprepare;
1700 }
1701
1702 of_platform_depopulate(&pdev->dev);
1703
Tony Lindgren684be5a2017-10-13 10:48:40 -07001704 pm_runtime_put_sync(&pdev->dev);
1705 pm_runtime_disable(&pdev->dev);
Tony Lindgren50622362018-04-16 10:20:27 -07001706 reset_control_assert(ddata->rsts);
Tony Lindgren684be5a2017-10-13 10:48:40 -07001707
1708unprepare:
1709 sysc_unprepare(ddata);
1710
1711 return 0;
1712}
1713
Tony Lindgren0eecc632017-10-10 14:23:43 -07001714static const struct of_device_id sysc_match[] = {
Tony Lindgren70a65242017-12-15 09:41:09 -08001715 { .compatible = "ti,sysc-omap2", .data = &sysc_omap2, },
1716 { .compatible = "ti,sysc-omap2-timer", .data = &sysc_omap2_timer, },
1717 { .compatible = "ti,sysc-omap4", .data = &sysc_omap4, },
1718 { .compatible = "ti,sysc-omap4-timer", .data = &sysc_omap4_timer, },
1719 { .compatible = "ti,sysc-omap4-simple", .data = &sysc_omap4_simple, },
1720 { .compatible = "ti,sysc-omap3430-sr", .data = &sysc_34xx_sr, },
1721 { .compatible = "ti,sysc-omap3630-sr", .data = &sysc_36xx_sr, },
1722 { .compatible = "ti,sysc-omap4-sr", .data = &sysc_omap4_sr, },
1723 { .compatible = "ti,sysc-omap3-sham", .data = &sysc_omap3_sham, },
1724 { .compatible = "ti,sysc-omap-aes", .data = &sysc_omap3_aes, },
1725 { .compatible = "ti,sysc-mcasp", .data = &sysc_omap4_mcasp, },
1726 { .compatible = "ti,sysc-usb-host-fs",
1727 .data = &sysc_omap4_usb_host_fs, },
Tony Lindgren0eecc632017-10-10 14:23:43 -07001728 { },
1729};
1730MODULE_DEVICE_TABLE(of, sysc_match);
1731
1732static struct platform_driver sysc_driver = {
1733 .probe = sysc_probe,
Tony Lindgren684be5a2017-10-13 10:48:40 -07001734 .remove = sysc_remove,
Tony Lindgren0eecc632017-10-10 14:23:43 -07001735 .driver = {
1736 .name = "ti-sysc",
1737 .of_match_table = sysc_match,
1738 .pm = &sysc_pm_ops,
1739 },
1740};
Tony Lindgren2c355ff2018-02-22 13:58:03 -08001741
1742static int __init sysc_init(void)
1743{
1744 bus_register_notifier(&platform_bus_type, &sysc_nb);
1745
1746 return platform_driver_register(&sysc_driver);
1747}
1748module_init(sysc_init);
1749
1750static void __exit sysc_exit(void)
1751{
1752 bus_unregister_notifier(&platform_bus_type, &sysc_nb);
1753 platform_driver_unregister(&sysc_driver);
1754}
1755module_exit(sysc_exit);
Tony Lindgren0eecc632017-10-10 14:23:43 -07001756
1757MODULE_DESCRIPTION("TI sysc interconnect target driver");
1758MODULE_LICENSE("GPL v2");