2 * ti-sysc.c - Texas Instruments sysc interconnect target driver
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.
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.
15 #include <linux/clk.h>
16 #include <linux/clkdev.h>
17 #include <linux/delay.h>
18 #include <linux/module.h>
19 #include <linux/platform_device.h>
20 #include <linux/pm_domain.h>
21 #include <linux/pm_runtime.h>
22 #include <linux/reset.h>
23 #include <linux/of_address.h>
24 #include <linux/of_platform.h>
25 #include <linux/slab.h>
26 #include <linux/iopoll.h>
28 #include <linux/platform_data/ti-sysc.h>
30 #include <dt-bindings/bus/ti-sysc.h>
32 #define MAX_MODULE_SOFTRESET_WAIT 10000
34 static const char * const reg_names
[] = { "rev", "sysc", "syss", };
50 static const char * const clock_names
[SYSC_ICK
+ 1] = { "fck", "ick", };
52 #define SYSC_IDLEMODE_MASK 3
53 #define SYSC_CLOCKACTIVITY_MASK 3
56 * struct sysc - TI sysc interconnect target module registers and capabilities
57 * @dev: struct device pointer
58 * @module_pa: physical address of the interconnect target module
59 * @module_size: size of the interconnect target module
60 * @module_va: virtual address of the interconnect target module
61 * @offsets: register offsets from module base
62 * @clocks: clocks used by the interconnect target module
63 * @clock_roles: clock role names for the found clocks
64 * @nr_clocks: number of clocks used by the interconnect target module
65 * @legacy_mode: configured for legacy mode if set
66 * @cap: interconnect target module capabilities
67 * @cfg: interconnect target module configuration
68 * @name: name if available
69 * @revision: interconnect target module revision
70 * @needs_resume: runtime resume needed on resume from suspend
76 void __iomem
*module_va
;
77 int offsets
[SYSC_MAX_REGS
];
79 const char **clock_roles
;
81 struct reset_control
*rsts
;
82 const char *legacy_mode
;
83 const struct sysc_capabilities
*cap
;
84 struct sysc_config cfg
;
85 struct ti_sysc_cookie cookie
;
90 bool child_needs_resume
;
91 struct delayed_work idle_work
;
94 void sysc_write(struct sysc
*ddata
, int offset
, u32 value
)
96 writel_relaxed(value
, ddata
->module_va
+ offset
);
99 static u32
sysc_read(struct sysc
*ddata
, int offset
)
101 if (ddata
->cfg
.quirks
& SYSC_QUIRK_16BIT
) {
104 val
= readw_relaxed(ddata
->module_va
+ offset
);
105 val
|= (readw_relaxed(ddata
->module_va
+ offset
+ 4) << 16);
110 return readl_relaxed(ddata
->module_va
+ offset
);
113 static bool sysc_opt_clks_needed(struct sysc
*ddata
)
115 return !!(ddata
->cfg
.quirks
& SYSC_QUIRK_OPT_CLKS_NEEDED
);
118 static u32
sysc_read_revision(struct sysc
*ddata
)
120 int offset
= ddata
->offsets
[SYSC_REVISION
];
125 return sysc_read(ddata
, offset
);
128 static int sysc_get_one_clock(struct sysc
*ddata
, const char *name
)
130 int error
, i
, index
= -ENODEV
;
132 if (!strncmp(clock_names
[SYSC_FCK
], name
, 3))
134 else if (!strncmp(clock_names
[SYSC_ICK
], name
, 3))
138 for (i
= SYSC_OPTFCK0
; i
< SYSC_MAX_CLOCKS
; i
++) {
139 if (!ddata
->clocks
[i
]) {
147 dev_err(ddata
->dev
, "clock %s not added\n", name
);
151 ddata
->clocks
[index
] = devm_clk_get(ddata
->dev
, name
);
152 if (IS_ERR(ddata
->clocks
[index
])) {
153 if (PTR_ERR(ddata
->clocks
[index
]) == -ENOENT
)
156 dev_err(ddata
->dev
, "clock get error for %s: %li\n",
157 name
, PTR_ERR(ddata
->clocks
[index
]));
159 return PTR_ERR(ddata
->clocks
[index
]);
162 error
= clk_prepare(ddata
->clocks
[index
]);
164 dev_err(ddata
->dev
, "clock prepare error for %s: %i\n",
173 static int sysc_get_clocks(struct sysc
*ddata
)
175 struct device_node
*np
= ddata
->dev
->of_node
;
176 struct property
*prop
;
178 int nr_fck
= 0, nr_ick
= 0, i
, error
= 0;
180 ddata
->clock_roles
= devm_kcalloc(ddata
->dev
,
182 sizeof(*ddata
->clock_roles
),
184 if (!ddata
->clock_roles
)
187 of_property_for_each_string(np
, "clock-names", prop
, name
) {
188 if (!strncmp(clock_names
[SYSC_FCK
], name
, 3))
190 if (!strncmp(clock_names
[SYSC_ICK
], name
, 3))
192 ddata
->clock_roles
[ddata
->nr_clocks
] = name
;
196 if (ddata
->nr_clocks
< 1)
199 if (ddata
->nr_clocks
> SYSC_MAX_CLOCKS
) {
200 dev_err(ddata
->dev
, "too many clocks for %pOF\n", np
);
205 if (nr_fck
> 1 || nr_ick
> 1) {
206 dev_err(ddata
->dev
, "max one fck and ick for %pOF\n", np
);
211 ddata
->clocks
= devm_kcalloc(ddata
->dev
,
212 ddata
->nr_clocks
, sizeof(*ddata
->clocks
),
217 for (i
= 0; i
< ddata
->nr_clocks
; i
++) {
218 error
= sysc_get_one_clock(ddata
, ddata
->clock_roles
[i
]);
219 if (error
&& error
!= -ENOENT
)
227 * sysc_init_resets - reset module on init
228 * @ddata: device driver data
230 * A module can have both OCP softreset control and external rstctrl.
231 * If more complicated rstctrl resets are needed, please handle these
232 * directly from the child device driver and map only the module reset
233 * for the parent interconnect target module device.
235 * Automatic reset of the module on init can be skipped with the
236 * "ti,no-reset-on-init" device tree property.
238 static int sysc_init_resets(struct sysc
*ddata
)
243 devm_reset_control_array_get_optional_exclusive(ddata
->dev
);
244 if (IS_ERR(ddata
->rsts
))
245 return PTR_ERR(ddata
->rsts
);
247 if (ddata
->cfg
.quirks
& SYSC_QUIRK_NO_RESET_ON_INIT
)
250 error
= reset_control_assert(ddata
->rsts
);
255 error
= reset_control_deassert(ddata
->rsts
);
263 * sysc_parse_and_check_child_range - parses module IO region from ranges
264 * @ddata: device driver data
266 * In general we only need rev, syss, and sysc registers and not the whole
267 * module range. But we do want the offsets for these registers from the
268 * module base. This allows us to check them against the legacy hwmod
269 * platform data. Let's also check the ranges are configured properly.
271 static int sysc_parse_and_check_child_range(struct sysc
*ddata
)
273 struct device_node
*np
= ddata
->dev
->of_node
;
274 const __be32
*ranges
;
275 u32 nr_addr
, nr_size
;
278 ranges
= of_get_property(np
, "ranges", &len
);
280 dev_err(ddata
->dev
, "missing ranges for %pOF\n", np
);
285 len
/= sizeof(*ranges
);
288 dev_err(ddata
->dev
, "incomplete ranges for %pOF\n", np
);
293 error
= of_property_read_u32(np
, "#address-cells", &nr_addr
);
297 error
= of_property_read_u32(np
, "#size-cells", &nr_size
);
301 if (nr_addr
!= 1 || nr_size
!= 1) {
302 dev_err(ddata
->dev
, "invalid ranges for %pOF\n", np
);
308 ddata
->module_pa
= of_translate_address(np
, ranges
++);
309 ddata
->module_size
= be32_to_cpup(ranges
);
314 static struct device_node
*stdout_path
;
316 static void sysc_init_stdout_path(struct sysc
*ddata
)
318 struct device_node
*np
= NULL
;
321 if (IS_ERR(stdout_path
))
327 np
= of_find_node_by_path("/chosen");
331 uart
= of_get_property(np
, "stdout-path", NULL
);
335 np
= of_find_node_by_path(uart
);
344 stdout_path
= ERR_PTR(-ENODEV
);
347 static void sysc_check_quirk_stdout(struct sysc
*ddata
,
348 struct device_node
*np
)
350 sysc_init_stdout_path(ddata
);
351 if (np
!= stdout_path
)
354 ddata
->cfg
.quirks
|= SYSC_QUIRK_NO_IDLE_ON_INIT
|
355 SYSC_QUIRK_NO_RESET_ON_INIT
;
359 * sysc_check_one_child - check child configuration
360 * @ddata: device driver data
361 * @np: child device node
363 * Let's avoid messy situations where we have new interconnect target
364 * node but children have "ti,hwmods". These belong to the interconnect
365 * target node and are managed by this driver.
367 static int sysc_check_one_child(struct sysc
*ddata
,
368 struct device_node
*np
)
372 name
= of_get_property(np
, "ti,hwmods", NULL
);
374 dev_warn(ddata
->dev
, "really a child ti,hwmods property?");
376 sysc_check_quirk_stdout(ddata
, np
);
381 static int sysc_check_children(struct sysc
*ddata
)
383 struct device_node
*child
;
386 for_each_child_of_node(ddata
->dev
->of_node
, child
) {
387 error
= sysc_check_one_child(ddata
, child
);
396 * So far only I2C uses 16-bit read access with clockactivity with revision
397 * in two registers with stride of 4. We can detect this based on the rev
398 * register size to configure things far enough to be able to properly read
399 * the revision register.
401 static void sysc_check_quirk_16bit(struct sysc
*ddata
, struct resource
*res
)
403 if (resource_size(res
) == 8)
404 ddata
->cfg
.quirks
|= SYSC_QUIRK_16BIT
| SYSC_QUIRK_USE_CLOCKACT
;
408 * sysc_parse_one - parses the interconnect target module registers
409 * @ddata: device driver data
410 * @reg: register to parse
412 static int sysc_parse_one(struct sysc
*ddata
, enum sysc_registers reg
)
414 struct resource
*res
;
421 name
= reg_names
[reg
];
427 res
= platform_get_resource_byname(to_platform_device(ddata
->dev
),
428 IORESOURCE_MEM
, name
);
430 ddata
->offsets
[reg
] = -ENODEV
;
435 ddata
->offsets
[reg
] = res
->start
- ddata
->module_pa
;
436 if (reg
== SYSC_REVISION
)
437 sysc_check_quirk_16bit(ddata
, res
);
442 static int sysc_parse_registers(struct sysc
*ddata
)
446 for (i
= 0; i
< SYSC_MAX_REGS
; i
++) {
447 error
= sysc_parse_one(ddata
, i
);
456 * sysc_check_registers - check for misconfigured register overlaps
457 * @ddata: device driver data
459 static int sysc_check_registers(struct sysc
*ddata
)
461 int i
, j
, nr_regs
= 0, nr_matches
= 0;
463 for (i
= 0; i
< SYSC_MAX_REGS
; i
++) {
464 if (ddata
->offsets
[i
] < 0)
467 if (ddata
->offsets
[i
] > (ddata
->module_size
- 4)) {
468 dev_err(ddata
->dev
, "register outside module range");
473 for (j
= 0; j
< SYSC_MAX_REGS
; j
++) {
474 if (ddata
->offsets
[j
] < 0)
477 if (ddata
->offsets
[i
] == ddata
->offsets
[j
])
484 dev_err(ddata
->dev
, "missing registers\n");
489 if (nr_matches
> nr_regs
) {
490 dev_err(ddata
->dev
, "overlapping registers: (%i/%i)",
491 nr_regs
, nr_matches
);
500 * syc_ioremap - ioremap register space for the interconnect target module
501 * @ddata: device driver data
503 * Note that the interconnect target module registers can be anywhere
504 * within the interconnect target module range. For example, SGX has
505 * them at offset 0x1fc00 in the 32MB module address space. And cpsw
506 * has them at offset 0x1200 in the CPSW_WR child. Usually the
507 * the interconnect target module registers are at the beginning of
508 * the module range though.
510 static int sysc_ioremap(struct sysc
*ddata
)
514 size
= max3(ddata
->offsets
[SYSC_REVISION
],
515 ddata
->offsets
[SYSC_SYSCONFIG
],
516 ddata
->offsets
[SYSC_SYSSTATUS
]);
518 if (size
< 0 || (size
+ sizeof(u32
)) > ddata
->module_size
)
521 ddata
->module_va
= devm_ioremap(ddata
->dev
,
524 if (!ddata
->module_va
)
531 * sysc_map_and_check_registers - ioremap and check device registers
532 * @ddata: device driver data
534 static int sysc_map_and_check_registers(struct sysc
*ddata
)
538 error
= sysc_parse_and_check_child_range(ddata
);
542 error
= sysc_check_children(ddata
);
546 error
= sysc_parse_registers(ddata
);
550 error
= sysc_ioremap(ddata
);
554 error
= sysc_check_registers(ddata
);
562 * sysc_show_rev - read and show interconnect target module revision
563 * @bufp: buffer to print the information to
564 * @ddata: device driver data
566 static int sysc_show_rev(char *bufp
, struct sysc
*ddata
)
570 if (ddata
->offsets
[SYSC_REVISION
] < 0)
571 return sprintf(bufp
, ":NA");
573 len
= sprintf(bufp
, ":%08x", ddata
->revision
);
578 static int sysc_show_reg(struct sysc
*ddata
,
579 char *bufp
, enum sysc_registers reg
)
581 if (ddata
->offsets
[reg
] < 0)
582 return sprintf(bufp
, ":NA");
584 return sprintf(bufp
, ":%x", ddata
->offsets
[reg
]);
587 static int sysc_show_name(char *bufp
, struct sysc
*ddata
)
592 return sprintf(bufp
, ":%s", ddata
->name
);
596 * sysc_show_registers - show information about interconnect target module
597 * @ddata: device driver data
599 static void sysc_show_registers(struct sysc
*ddata
)
605 for (i
= 0; i
< SYSC_MAX_REGS
; i
++)
606 bufp
+= sysc_show_reg(ddata
, bufp
, i
);
608 bufp
+= sysc_show_rev(bufp
, ddata
);
609 bufp
+= sysc_show_name(bufp
, ddata
);
611 dev_dbg(ddata
->dev
, "%llx:%x%s\n",
612 ddata
->module_pa
, ddata
->module_size
,
616 static int __maybe_unused
sysc_runtime_suspend(struct device
*dev
)
618 struct ti_sysc_platform_data
*pdata
;
622 ddata
= dev_get_drvdata(dev
);
627 if (ddata
->legacy_mode
) {
628 pdata
= dev_get_platdata(ddata
->dev
);
632 if (!pdata
->idle_module
)
635 error
= pdata
->idle_module(dev
, &ddata
->cookie
);
637 dev_err(dev
, "%s: could not idle: %i\n",
643 for (i
= 0; i
< ddata
->nr_clocks
; i
++) {
644 if (IS_ERR_OR_NULL(ddata
->clocks
[i
]))
647 if (i
>= SYSC_OPTFCK0
&& !sysc_opt_clks_needed(ddata
))
650 clk_disable(ddata
->clocks
[i
]);
654 ddata
->enabled
= false;
659 static int __maybe_unused
sysc_runtime_resume(struct device
*dev
)
661 struct ti_sysc_platform_data
*pdata
;
665 ddata
= dev_get_drvdata(dev
);
670 if (ddata
->legacy_mode
) {
671 pdata
= dev_get_platdata(ddata
->dev
);
675 if (!pdata
->enable_module
)
678 error
= pdata
->enable_module(dev
, &ddata
->cookie
);
680 dev_err(dev
, "%s: could not enable: %i\n",
686 for (i
= 0; i
< ddata
->nr_clocks
; i
++) {
687 if (IS_ERR_OR_NULL(ddata
->clocks
[i
]))
690 if (i
>= SYSC_OPTFCK0
&& !sysc_opt_clks_needed(ddata
))
693 error
= clk_enable(ddata
->clocks
[i
]);
699 ddata
->enabled
= true;
704 static int __maybe_unused
sysc_noirq_suspend(struct device
*dev
)
708 ddata
= dev_get_drvdata(dev
);
710 if (ddata
->cfg
.quirks
& SYSC_QUIRK_LEGACY_IDLE
)
713 return pm_runtime_force_suspend(dev
);
716 static int __maybe_unused
sysc_noirq_resume(struct device
*dev
)
720 ddata
= dev_get_drvdata(dev
);
722 if (ddata
->cfg
.quirks
& SYSC_QUIRK_LEGACY_IDLE
)
725 return pm_runtime_force_resume(dev
);
728 static const struct dev_pm_ops sysc_pm_ops
= {
729 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_noirq_suspend
, sysc_noirq_resume
)
730 SET_RUNTIME_PM_OPS(sysc_runtime_suspend
,
735 /* Module revision register based quirks */
736 struct sysc_revision_quirk
{
747 #define SYSC_QUIRK(optname, optbase, optrev, optsysc, optsyss, \
748 optrev_val, optrevmask, optquirkmask) \
752 .rev_offset = (optrev), \
753 .sysc_offset = (optsysc), \
754 .syss_offset = (optsyss), \
755 .revision = (optrev_val), \
756 .revision_mask = (optrevmask), \
757 .quirks = (optquirkmask), \
760 static const struct sysc_revision_quirk sysc_revision_quirks
[] = {
761 /* These drivers need to be fixed to not use pm_runtime_irq_safe() */
762 SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffff00ff,
763 SYSC_QUIRK_LEGACY_IDLE
| SYSC_QUIRK_OPT_CLKS_IN_RESET
),
764 SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000020, 0xffffffff,
765 SYSC_QUIRK_LEGACY_IDLE
),
766 SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000030, 0xffffffff,
767 SYSC_QUIRK_LEGACY_IDLE
),
768 SYSC_QUIRK("sham", 0, 0x100, 0x110, 0x114, 0x40000c03, 0xffffffff,
769 SYSC_QUIRK_LEGACY_IDLE
),
770 SYSC_QUIRK("smartreflex", 0, -1, 0x24, -1, 0x00000000, 0xffffffff,
771 SYSC_QUIRK_LEGACY_IDLE
),
772 SYSC_QUIRK("smartreflex", 0, -1, 0x38, -1, 0x00000000, 0xffffffff,
773 SYSC_QUIRK_LEGACY_IDLE
),
774 SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff,
775 SYSC_QUIRK_LEGACY_IDLE
),
776 /* Some timers on omap4 and later */
777 SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x50002100, 0xffffffff,
778 SYSC_QUIRK_LEGACY_IDLE
),
779 SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x4fff1301, 0xffff00ff,
780 SYSC_QUIRK_LEGACY_IDLE
),
781 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff,
782 SYSC_QUIRK_LEGACY_IDLE
),
783 /* Uarts on omap4 and later */
784 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffff00ff,
785 SYSC_QUIRK_LEGACY_IDLE
),
786 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x47422e03, 0xffffffff,
787 SYSC_QUIRK_LEGACY_IDLE
),
790 SYSC_QUIRK("adc", 0, 0, 0x10, -1, 0x47300001, 0xffffffff, 0),
791 SYSC_QUIRK("atl", 0, 0, -1, -1, 0x0a070100, 0xffffffff, 0),
792 SYSC_QUIRK("aess", 0, 0, 0x10, -1, 0x40000000, 0xffffffff, 0),
793 SYSC_QUIRK("cm", 0, 0, -1, -1, 0x40000301, 0xffffffff, 0),
794 SYSC_QUIRK("control", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0),
795 SYSC_QUIRK("cpgmac", 0, 0x1200, 0x1208, 0x1204, 0x4edb1902,
797 SYSC_QUIRK("dcan", 0, 0, -1, -1, 0xffffffff, 0xffffffff, 0),
798 SYSC_QUIRK("dcan", 0, 0, -1, -1, 0x00001401, 0xffffffff, 0),
799 SYSC_QUIRK("dwc3", 0, 0, 0x10, -1, 0x500a0200, 0xffffffff, 0),
800 SYSC_QUIRK("epwmss", 0, 0, 0x4, -1, 0x47400001, 0xffffffff, 0),
801 SYSC_QUIRK("gpu", 0, 0x1fc00, 0x1fc10, -1, 0, 0, 0),
802 SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x00000006, 0xffffffff, 0),
803 SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x0000000a, 0xffffffff, 0),
804 SYSC_QUIRK("hsi", 0, 0, 0x10, 0x14, 0x50043101, 0xffffffff, 0),
805 SYSC_QUIRK("iss", 0, 0, 0x10, -1, 0x40000101, 0xffffffff, 0),
806 SYSC_QUIRK("i2c", 0, 0, 0x10, 0x90, 0x5040000a, 0xfffff0f0, 0),
807 SYSC_QUIRK("lcdc", 0, 0, 0x54, -1, 0x4f201000, 0xffffffff, 0),
808 SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44306302, 0xffffffff, 0),
809 SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44307b02, 0xffffffff, 0),
810 SYSC_QUIRK("mcbsp", 0, -1, 0x8c, -1, 0, 0, 0),
811 SYSC_QUIRK("mcspi", 0, 0, 0x10, -1, 0x40300a0b, 0xffff00ff, 0),
812 SYSC_QUIRK("mcspi", 0, 0, 0x110, 0x114, 0x40300a0b, 0xffffffff, 0),
813 SYSC_QUIRK("mailbox", 0, 0, 0x10, -1, 0x00000400, 0xffffffff, 0),
814 SYSC_QUIRK("m3", 0, 0, -1, -1, 0x5f580105, 0x0fff0f00, 0),
815 SYSC_QUIRK("ocp2scp", 0, 0, 0x10, 0x14, 0x50060005, 0xfffffff0, 0),
816 SYSC_QUIRK("ocp2scp", 0, 0, -1, -1, 0x50060007, 0xffffffff, 0),
817 SYSC_QUIRK("padconf", 0, 0, 0x10, -1, 0x4fff0800, 0xffffffff, 0),
818 SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000100, 0xffffffff, 0),
819 SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x00004102, 0xffffffff, 0),
820 SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000400, 0xffffffff, 0),
821 SYSC_QUIRK("scm", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0),
822 SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4e8b0100, 0xffffffff, 0),
823 SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4f000100, 0xffffffff, 0),
824 SYSC_QUIRK("scm", 0, 0, -1, -1, 0x40000900, 0xffffffff, 0),
825 SYSC_QUIRK("scrm", 0, 0, -1, -1, 0x00000010, 0xffffffff, 0),
826 SYSC_QUIRK("sdio", 0, 0, 0x10, -1, 0x40202301, 0xffff0ff0, 0),
827 SYSC_QUIRK("sdio", 0, 0x2fc, 0x110, 0x114, 0x31010000, 0xffffffff, 0),
828 SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff, 0),
829 SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40000902, 0xffffffff, 0),
830 SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40002903, 0xffffffff, 0),
831 SYSC_QUIRK("spinlock", 0, 0, 0x10, -1, 0x50020000, 0xffffffff, 0),
832 SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -1, 0x00000020, 0xffffffff, 0),
833 SYSC_QUIRK("rtc", 0, 0x74, 0x78, -1, 0x4eb01908, 0xffff00f0, 0),
834 SYSC_QUIRK("timer32k", 0, 0, 0x4, -1, 0x00000060, 0xffffffff, 0),
835 SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000004, 0xffffffff, 0),
836 SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff, 0),
837 SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050,
839 SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xfffff0f0, 0),
840 SYSC_QUIRK("vfpe", 0, 0, 0x104, -1, 0x4d001200, 0xffffffff, 0),
844 static void sysc_init_revision_quirks(struct sysc
*ddata
)
846 const struct sysc_revision_quirk
*q
;
849 for (i
= 0; i
< ARRAY_SIZE(sysc_revision_quirks
); i
++) {
850 q
= &sysc_revision_quirks
[i
];
852 if (q
->base
&& q
->base
!= ddata
->module_pa
)
855 if (q
->rev_offset
>= 0 &&
856 q
->rev_offset
!= ddata
->offsets
[SYSC_REVISION
])
859 if (q
->sysc_offset
>= 0 &&
860 q
->sysc_offset
!= ddata
->offsets
[SYSC_SYSCONFIG
])
863 if (q
->syss_offset
>= 0 &&
864 q
->syss_offset
!= ddata
->offsets
[SYSC_SYSSTATUS
])
867 if (q
->revision
== ddata
->revision
||
868 (q
->revision
& q
->revision_mask
) ==
869 (ddata
->revision
& q
->revision_mask
)) {
870 ddata
->name
= q
->name
;
871 ddata
->cfg
.quirks
|= q
->quirks
;
876 static int sysc_reset(struct sysc
*ddata
)
878 int offset
= ddata
->offsets
[SYSC_SYSCONFIG
];
881 if (ddata
->legacy_mode
|| offset
< 0 ||
882 ddata
->cfg
.quirks
& SYSC_QUIRK_NO_RESET_ON_INIT
)
886 * Currently only support reset status in sysstatus.
887 * Warn and return error in all other cases
889 if (!ddata
->cfg
.syss_mask
) {
890 dev_err(ddata
->dev
, "No ti,syss-mask. Reset failed\n");
894 val
= sysc_read(ddata
, offset
);
895 val
|= (0x1 << ddata
->cap
->regbits
->srst_shift
);
896 sysc_write(ddata
, offset
, val
);
898 /* Poll on reset status */
899 offset
= ddata
->offsets
[SYSC_SYSSTATUS
];
901 return readl_poll_timeout(ddata
->module_va
+ offset
, val
,
902 (val
& ddata
->cfg
.syss_mask
) == 0x0,
903 100, MAX_MODULE_SOFTRESET_WAIT
);
906 /* At this point the module is configured enough to read the revision */
907 static int sysc_init_module(struct sysc
*ddata
)
911 if (ddata
->cfg
.quirks
& SYSC_QUIRK_NO_IDLE_ON_INIT
) {
912 ddata
->revision
= sysc_read_revision(ddata
);
916 error
= pm_runtime_get_sync(ddata
->dev
);
918 pm_runtime_put_noidle(ddata
->dev
);
923 error
= sysc_reset(ddata
);
925 dev_err(ddata
->dev
, "Reset failed with %d\n", error
);
926 pm_runtime_put_sync(ddata
->dev
);
931 ddata
->revision
= sysc_read_revision(ddata
);
932 pm_runtime_put_sync(ddata
->dev
);
935 sysc_init_revision_quirks(ddata
);
940 static int sysc_init_sysc_mask(struct sysc
*ddata
)
942 struct device_node
*np
= ddata
->dev
->of_node
;
946 error
= of_property_read_u32(np
, "ti,sysc-mask", &val
);
951 ddata
->cfg
.sysc_val
= val
& ddata
->cap
->sysc_mask
;
953 ddata
->cfg
.sysc_val
= ddata
->cap
->sysc_mask
;
958 static int sysc_init_idlemode(struct sysc
*ddata
, u8
*idlemodes
,
961 struct device_node
*np
= ddata
->dev
->of_node
;
962 struct property
*prop
;
966 of_property_for_each_u32(np
, name
, prop
, p
, val
) {
967 if (val
>= SYSC_NR_IDLEMODES
) {
968 dev_err(ddata
->dev
, "invalid idlemode: %i\n", val
);
971 *idlemodes
|= (1 << val
);
977 static int sysc_init_idlemodes(struct sysc
*ddata
)
981 error
= sysc_init_idlemode(ddata
, &ddata
->cfg
.midlemodes
,
986 error
= sysc_init_idlemode(ddata
, &ddata
->cfg
.sidlemodes
,
995 * Only some devices on omap4 and later have SYSCONFIG reset done
996 * bit. We can detect this if there is no SYSSTATUS at all, or the
997 * SYSTATUS bit 0 is not used. Note that some SYSSTATUS registers
998 * have multiple bits for the child devices like OHCI and EHCI.
999 * Depends on SYSC being parsed first.
1001 static int sysc_init_syss_mask(struct sysc
*ddata
)
1003 struct device_node
*np
= ddata
->dev
->of_node
;
1007 error
= of_property_read_u32(np
, "ti,syss-mask", &val
);
1009 if ((ddata
->cap
->type
== TI_SYSC_OMAP4
||
1010 ddata
->cap
->type
== TI_SYSC_OMAP4_TIMER
) &&
1011 (ddata
->cfg
.sysc_val
& SYSC_OMAP4_SOFTRESET
))
1012 ddata
->cfg
.quirks
|= SYSC_QUIRK_RESET_STATUS
;
1017 if (!(val
& 1) && (ddata
->cfg
.sysc_val
& SYSC_OMAP4_SOFTRESET
))
1018 ddata
->cfg
.quirks
|= SYSC_QUIRK_RESET_STATUS
;
1020 ddata
->cfg
.syss_mask
= val
;
1026 * Many child device drivers need to have fck and opt clocks available
1027 * to get the clock rate for device internal configuration etc.
1029 static int sysc_child_add_named_clock(struct sysc
*ddata
,
1030 struct device
*child
,
1034 struct clk_lookup
*l
;
1040 clk
= clk_get(child
, name
);
1047 clk
= clk_get(ddata
->dev
, name
);
1051 l
= clkdev_create(clk
, name
, dev_name(child
));
1060 static int sysc_child_add_clocks(struct sysc
*ddata
,
1061 struct device
*child
)
1065 for (i
= 0; i
< ddata
->nr_clocks
; i
++) {
1066 error
= sysc_child_add_named_clock(ddata
,
1068 ddata
->clock_roles
[i
]);
1069 if (error
&& error
!= -EEXIST
) {
1070 dev_err(ddata
->dev
, "could not add child clock %s: %i\n",
1071 ddata
->clock_roles
[i
], error
);
1080 static struct device_type sysc_device_type
= {
1083 static struct sysc
*sysc_child_to_parent(struct device
*dev
)
1085 struct device
*parent
= dev
->parent
;
1087 if (!parent
|| parent
->type
!= &sysc_device_type
)
1090 return dev_get_drvdata(parent
);
1093 static int __maybe_unused
sysc_child_runtime_suspend(struct device
*dev
)
1098 ddata
= sysc_child_to_parent(dev
);
1100 error
= pm_generic_runtime_suspend(dev
);
1104 if (!ddata
->enabled
)
1107 return sysc_runtime_suspend(ddata
->dev
);
1110 static int __maybe_unused
sysc_child_runtime_resume(struct device
*dev
)
1115 ddata
= sysc_child_to_parent(dev
);
1117 if (!ddata
->enabled
) {
1118 error
= sysc_runtime_resume(ddata
->dev
);
1121 "%s error: %i\n", __func__
, error
);
1124 return pm_generic_runtime_resume(dev
);
1127 #ifdef CONFIG_PM_SLEEP
1128 static int sysc_child_suspend_noirq(struct device
*dev
)
1133 ddata
= sysc_child_to_parent(dev
);
1135 dev_dbg(ddata
->dev
, "%s %s\n", __func__
,
1136 ddata
->name
? ddata
->name
: "");
1138 error
= pm_generic_suspend_noirq(dev
);
1140 dev_err(dev
, "%s error at %i: %i\n",
1141 __func__
, __LINE__
, error
);
1146 if (!pm_runtime_status_suspended(dev
)) {
1147 error
= pm_generic_runtime_suspend(dev
);
1149 dev_dbg(dev
, "%s busy at %i: %i\n",
1150 __func__
, __LINE__
, error
);
1155 error
= sysc_runtime_suspend(ddata
->dev
);
1157 dev_err(dev
, "%s error at %i: %i\n",
1158 __func__
, __LINE__
, error
);
1163 ddata
->child_needs_resume
= true;
1169 static int sysc_child_resume_noirq(struct device
*dev
)
1174 ddata
= sysc_child_to_parent(dev
);
1176 dev_dbg(ddata
->dev
, "%s %s\n", __func__
,
1177 ddata
->name
? ddata
->name
: "");
1179 if (ddata
->child_needs_resume
) {
1180 ddata
->child_needs_resume
= false;
1182 error
= sysc_runtime_resume(ddata
->dev
);
1185 "%s runtime resume error: %i\n",
1188 error
= pm_generic_runtime_resume(dev
);
1191 "%s generic runtime resume: %i\n",
1195 return pm_generic_resume_noirq(dev
);
1199 struct dev_pm_domain sysc_child_pm_domain
= {
1201 SET_RUNTIME_PM_OPS(sysc_child_runtime_suspend
,
1202 sysc_child_runtime_resume
,
1204 USE_PLATFORM_PM_SLEEP_OPS
1205 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_child_suspend_noirq
,
1206 sysc_child_resume_noirq
)
1211 * sysc_legacy_idle_quirk - handle children in omap_device compatible way
1212 * @ddata: device driver data
1213 * @child: child device driver
1215 * Allow idle for child devices as done with _od_runtime_suspend().
1216 * Otherwise many child devices will not idle because of the permanent
1217 * parent usecount set in pm_runtime_irq_safe().
1219 * Note that the long term solution is to just modify the child device
1220 * drivers to not set pm_runtime_irq_safe() and then this can be just
1223 static void sysc_legacy_idle_quirk(struct sysc
*ddata
, struct device
*child
)
1225 if (!ddata
->legacy_mode
)
1228 if (ddata
->cfg
.quirks
& SYSC_QUIRK_LEGACY_IDLE
)
1229 dev_pm_domain_set(child
, &sysc_child_pm_domain
);
1232 static int sysc_notifier_call(struct notifier_block
*nb
,
1233 unsigned long event
, void *device
)
1235 struct device
*dev
= device
;
1239 ddata
= sysc_child_to_parent(dev
);
1244 case BUS_NOTIFY_ADD_DEVICE
:
1245 error
= sysc_child_add_clocks(ddata
, dev
);
1248 sysc_legacy_idle_quirk(ddata
, dev
);
1257 static struct notifier_block sysc_nb
= {
1258 .notifier_call
= sysc_notifier_call
,
1261 /* Device tree configured quirks */
1262 struct sysc_dts_quirk
{
1267 static const struct sysc_dts_quirk sysc_dts_quirks
[] = {
1268 { .name
= "ti,no-idle-on-init",
1269 .mask
= SYSC_QUIRK_NO_IDLE_ON_INIT
, },
1270 { .name
= "ti,no-reset-on-init",
1271 .mask
= SYSC_QUIRK_NO_RESET_ON_INIT
, },
1274 static int sysc_init_dts_quirks(struct sysc
*ddata
)
1276 struct device_node
*np
= ddata
->dev
->of_node
;
1277 const struct property
*prop
;
1281 ddata
->legacy_mode
= of_get_property(np
, "ti,hwmods", NULL
);
1283 for (i
= 0; i
< ARRAY_SIZE(sysc_dts_quirks
); i
++) {
1284 prop
= of_get_property(np
, sysc_dts_quirks
[i
].name
, &len
);
1288 ddata
->cfg
.quirks
|= sysc_dts_quirks
[i
].mask
;
1291 error
= of_property_read_u32(np
, "ti,sysc-delay-us", &val
);
1294 dev_warn(ddata
->dev
, "bad ti,sysc-delay-us: %i\n",
1298 ddata
->cfg
.srst_udelay
= (u8
)val
;
1304 static void sysc_unprepare(struct sysc
*ddata
)
1308 for (i
= 0; i
< SYSC_MAX_CLOCKS
; i
++) {
1309 if (!IS_ERR_OR_NULL(ddata
->clocks
[i
]))
1310 clk_unprepare(ddata
->clocks
[i
]);
1315 * Common sysc register bits found on omap2, also known as type1
1317 static const struct sysc_regbits sysc_regbits_omap2
= {
1318 .dmadisable_shift
= -ENODEV
,
1325 .autoidle_shift
= 0,
1328 static const struct sysc_capabilities sysc_omap2
= {
1329 .type
= TI_SYSC_OMAP2
,
1330 .sysc_mask
= SYSC_OMAP2_CLOCKACTIVITY
| SYSC_OMAP2_EMUFREE
|
1331 SYSC_OMAP2_ENAWAKEUP
| SYSC_OMAP2_SOFTRESET
|
1332 SYSC_OMAP2_AUTOIDLE
,
1333 .regbits
= &sysc_regbits_omap2
,
1336 /* All omap2 and 3 timers, and timers 1, 2 & 10 on omap 4 and 5 */
1337 static const struct sysc_capabilities sysc_omap2_timer
= {
1338 .type
= TI_SYSC_OMAP2_TIMER
,
1339 .sysc_mask
= SYSC_OMAP2_CLOCKACTIVITY
| SYSC_OMAP2_EMUFREE
|
1340 SYSC_OMAP2_ENAWAKEUP
| SYSC_OMAP2_SOFTRESET
|
1341 SYSC_OMAP2_AUTOIDLE
,
1342 .regbits
= &sysc_regbits_omap2
,
1343 .mod_quirks
= SYSC_QUIRK_USE_CLOCKACT
,
1347 * SHAM2 (SHA1/MD5) sysc found on omap3, a variant of sysc_regbits_omap2
1348 * with different sidle position
1350 static const struct sysc_regbits sysc_regbits_omap3_sham
= {
1351 .dmadisable_shift
= -ENODEV
,
1352 .midle_shift
= -ENODEV
,
1354 .clkact_shift
= -ENODEV
,
1355 .enwkup_shift
= -ENODEV
,
1357 .autoidle_shift
= 0,
1358 .emufree_shift
= -ENODEV
,
1361 static const struct sysc_capabilities sysc_omap3_sham
= {
1362 .type
= TI_SYSC_OMAP3_SHAM
,
1363 .sysc_mask
= SYSC_OMAP2_SOFTRESET
| SYSC_OMAP2_AUTOIDLE
,
1364 .regbits
= &sysc_regbits_omap3_sham
,
1368 * AES register bits found on omap3 and later, a variant of
1369 * sysc_regbits_omap2 with different sidle position
1371 static const struct sysc_regbits sysc_regbits_omap3_aes
= {
1372 .dmadisable_shift
= -ENODEV
,
1373 .midle_shift
= -ENODEV
,
1375 .clkact_shift
= -ENODEV
,
1376 .enwkup_shift
= -ENODEV
,
1378 .autoidle_shift
= 0,
1379 .emufree_shift
= -ENODEV
,
1382 static const struct sysc_capabilities sysc_omap3_aes
= {
1383 .type
= TI_SYSC_OMAP3_AES
,
1384 .sysc_mask
= SYSC_OMAP2_SOFTRESET
| SYSC_OMAP2_AUTOIDLE
,
1385 .regbits
= &sysc_regbits_omap3_aes
,
1389 * Common sysc register bits found on omap4, also known as type2
1391 static const struct sysc_regbits sysc_regbits_omap4
= {
1392 .dmadisable_shift
= 16,
1395 .clkact_shift
= -ENODEV
,
1396 .enwkup_shift
= -ENODEV
,
1399 .autoidle_shift
= -ENODEV
,
1402 static const struct sysc_capabilities sysc_omap4
= {
1403 .type
= TI_SYSC_OMAP4
,
1404 .sysc_mask
= SYSC_OMAP4_DMADISABLE
| SYSC_OMAP4_FREEEMU
|
1405 SYSC_OMAP4_SOFTRESET
,
1406 .regbits
= &sysc_regbits_omap4
,
1409 static const struct sysc_capabilities sysc_omap4_timer
= {
1410 .type
= TI_SYSC_OMAP4_TIMER
,
1411 .sysc_mask
= SYSC_OMAP4_DMADISABLE
| SYSC_OMAP4_FREEEMU
|
1412 SYSC_OMAP4_SOFTRESET
,
1413 .regbits
= &sysc_regbits_omap4
,
1417 * Common sysc register bits found on omap4, also known as type3
1419 static const struct sysc_regbits sysc_regbits_omap4_simple
= {
1420 .dmadisable_shift
= -ENODEV
,
1423 .clkact_shift
= -ENODEV
,
1424 .enwkup_shift
= -ENODEV
,
1425 .srst_shift
= -ENODEV
,
1426 .emufree_shift
= -ENODEV
,
1427 .autoidle_shift
= -ENODEV
,
1430 static const struct sysc_capabilities sysc_omap4_simple
= {
1431 .type
= TI_SYSC_OMAP4_SIMPLE
,
1432 .regbits
= &sysc_regbits_omap4_simple
,
1436 * SmartReflex sysc found on omap34xx
1438 static const struct sysc_regbits sysc_regbits_omap34xx_sr
= {
1439 .dmadisable_shift
= -ENODEV
,
1440 .midle_shift
= -ENODEV
,
1441 .sidle_shift
= -ENODEV
,
1443 .enwkup_shift
= -ENODEV
,
1444 .srst_shift
= -ENODEV
,
1445 .emufree_shift
= -ENODEV
,
1446 .autoidle_shift
= -ENODEV
,
1449 static const struct sysc_capabilities sysc_34xx_sr
= {
1450 .type
= TI_SYSC_OMAP34XX_SR
,
1451 .sysc_mask
= SYSC_OMAP2_CLOCKACTIVITY
,
1452 .regbits
= &sysc_regbits_omap34xx_sr
,
1453 .mod_quirks
= SYSC_QUIRK_USE_CLOCKACT
| SYSC_QUIRK_UNCACHED
|
1454 SYSC_QUIRK_LEGACY_IDLE
,
1458 * SmartReflex sysc found on omap36xx and later
1460 static const struct sysc_regbits sysc_regbits_omap36xx_sr
= {
1461 .dmadisable_shift
= -ENODEV
,
1462 .midle_shift
= -ENODEV
,
1464 .clkact_shift
= -ENODEV
,
1466 .srst_shift
= -ENODEV
,
1467 .emufree_shift
= -ENODEV
,
1468 .autoidle_shift
= -ENODEV
,
1471 static const struct sysc_capabilities sysc_36xx_sr
= {
1472 .type
= TI_SYSC_OMAP36XX_SR
,
1473 .sysc_mask
= SYSC_OMAP3_SR_ENAWAKEUP
,
1474 .regbits
= &sysc_regbits_omap36xx_sr
,
1475 .mod_quirks
= SYSC_QUIRK_UNCACHED
| SYSC_QUIRK_LEGACY_IDLE
,
1478 static const struct sysc_capabilities sysc_omap4_sr
= {
1479 .type
= TI_SYSC_OMAP4_SR
,
1480 .regbits
= &sysc_regbits_omap36xx_sr
,
1481 .mod_quirks
= SYSC_QUIRK_LEGACY_IDLE
,
1485 * McASP register bits found on omap4 and later
1487 static const struct sysc_regbits sysc_regbits_omap4_mcasp
= {
1488 .dmadisable_shift
= -ENODEV
,
1489 .midle_shift
= -ENODEV
,
1491 .clkact_shift
= -ENODEV
,
1492 .enwkup_shift
= -ENODEV
,
1493 .srst_shift
= -ENODEV
,
1494 .emufree_shift
= -ENODEV
,
1495 .autoidle_shift
= -ENODEV
,
1498 static const struct sysc_capabilities sysc_omap4_mcasp
= {
1499 .type
= TI_SYSC_OMAP4_MCASP
,
1500 .regbits
= &sysc_regbits_omap4_mcasp
,
1504 * FS USB host found on omap4 and later
1506 static const struct sysc_regbits sysc_regbits_omap4_usb_host_fs
= {
1507 .dmadisable_shift
= -ENODEV
,
1508 .midle_shift
= -ENODEV
,
1510 .clkact_shift
= -ENODEV
,
1512 .srst_shift
= -ENODEV
,
1513 .emufree_shift
= -ENODEV
,
1514 .autoidle_shift
= -ENODEV
,
1517 static const struct sysc_capabilities sysc_omap4_usb_host_fs
= {
1518 .type
= TI_SYSC_OMAP4_USB_HOST_FS
,
1519 .sysc_mask
= SYSC_OMAP2_ENAWAKEUP
,
1520 .regbits
= &sysc_regbits_omap4_usb_host_fs
,
1523 static const struct sysc_regbits sysc_regbits_dra7_mcan
= {
1524 .dmadisable_shift
= -ENODEV
,
1525 .midle_shift
= -ENODEV
,
1526 .sidle_shift
= -ENODEV
,
1527 .clkact_shift
= -ENODEV
,
1530 .emufree_shift
= -ENODEV
,
1531 .autoidle_shift
= -ENODEV
,
1534 static const struct sysc_capabilities sysc_dra7_mcan
= {
1535 .type
= TI_SYSC_DRA7_MCAN
,
1536 .sysc_mask
= SYSC_DRA7_MCAN_ENAWAKEUP
| SYSC_OMAP4_SOFTRESET
,
1537 .regbits
= &sysc_regbits_dra7_mcan
,
1540 static int sysc_init_pdata(struct sysc
*ddata
)
1542 struct ti_sysc_platform_data
*pdata
= dev_get_platdata(ddata
->dev
);
1543 struct ti_sysc_module_data mdata
;
1546 if (!pdata
|| !ddata
->legacy_mode
)
1549 mdata
.name
= ddata
->legacy_mode
;
1550 mdata
.module_pa
= ddata
->module_pa
;
1551 mdata
.module_size
= ddata
->module_size
;
1552 mdata
.offsets
= ddata
->offsets
;
1553 mdata
.nr_offsets
= SYSC_MAX_REGS
;
1554 mdata
.cap
= ddata
->cap
;
1555 mdata
.cfg
= &ddata
->cfg
;
1557 if (!pdata
->init_module
)
1560 error
= pdata
->init_module(ddata
->dev
, &mdata
, &ddata
->cookie
);
1561 if (error
== -EEXIST
)
1567 static int sysc_init_match(struct sysc
*ddata
)
1569 const struct sysc_capabilities
*cap
;
1571 cap
= of_device_get_match_data(ddata
->dev
);
1577 ddata
->cfg
.quirks
|= ddata
->cap
->mod_quirks
;
1582 static void ti_sysc_idle(struct work_struct
*work
)
1586 ddata
= container_of(work
, struct sysc
, idle_work
.work
);
1588 if (pm_runtime_active(ddata
->dev
))
1589 pm_runtime_put_sync(ddata
->dev
);
1592 static const struct of_device_id sysc_match_table
[] = {
1593 { .compatible
= "simple-bus", },
1597 static int sysc_probe(struct platform_device
*pdev
)
1599 struct ti_sysc_platform_data
*pdata
= dev_get_platdata(&pdev
->dev
);
1603 ddata
= devm_kzalloc(&pdev
->dev
, sizeof(*ddata
), GFP_KERNEL
);
1607 ddata
->dev
= &pdev
->dev
;
1608 platform_set_drvdata(pdev
, ddata
);
1610 error
= sysc_init_match(ddata
);
1614 error
= sysc_init_dts_quirks(ddata
);
1618 error
= sysc_get_clocks(ddata
);
1622 error
= sysc_map_and_check_registers(ddata
);
1626 error
= sysc_init_sysc_mask(ddata
);
1630 error
= sysc_init_idlemodes(ddata
);
1634 error
= sysc_init_syss_mask(ddata
);
1638 error
= sysc_init_pdata(ddata
);
1642 error
= sysc_init_resets(ddata
);
1646 pm_runtime_enable(ddata
->dev
);
1647 error
= sysc_init_module(ddata
);
1651 error
= pm_runtime_get_sync(ddata
->dev
);
1653 pm_runtime_put_noidle(ddata
->dev
);
1654 pm_runtime_disable(ddata
->dev
);
1658 sysc_show_registers(ddata
);
1660 ddata
->dev
->type
= &sysc_device_type
;
1661 error
= of_platform_populate(ddata
->dev
->of_node
, sysc_match_table
,
1662 pdata
? pdata
->auxdata
: NULL
,
1667 INIT_DELAYED_WORK(&ddata
->idle_work
, ti_sysc_idle
);
1669 /* At least earlycon won't survive without deferred idle */
1670 if (ddata
->cfg
.quirks
& (SYSC_QUIRK_NO_IDLE_ON_INIT
|
1671 SYSC_QUIRK_NO_RESET_ON_INIT
)) {
1672 schedule_delayed_work(&ddata
->idle_work
, 3000);
1674 pm_runtime_put(&pdev
->dev
);
1677 if (!of_get_available_child_count(ddata
->dev
->of_node
))
1678 reset_control_assert(ddata
->rsts
);
1683 pm_runtime_put_sync(&pdev
->dev
);
1684 pm_runtime_disable(&pdev
->dev
);
1686 sysc_unprepare(ddata
);
1691 static int sysc_remove(struct platform_device
*pdev
)
1693 struct sysc
*ddata
= platform_get_drvdata(pdev
);
1696 cancel_delayed_work_sync(&ddata
->idle_work
);
1698 error
= pm_runtime_get_sync(ddata
->dev
);
1700 pm_runtime_put_noidle(ddata
->dev
);
1701 pm_runtime_disable(ddata
->dev
);
1705 of_platform_depopulate(&pdev
->dev
);
1707 pm_runtime_put_sync(&pdev
->dev
);
1708 pm_runtime_disable(&pdev
->dev
);
1709 reset_control_assert(ddata
->rsts
);
1712 sysc_unprepare(ddata
);
1717 static const struct of_device_id sysc_match
[] = {
1718 { .compatible
= "ti,sysc-omap2", .data
= &sysc_omap2
, },
1719 { .compatible
= "ti,sysc-omap2-timer", .data
= &sysc_omap2_timer
, },
1720 { .compatible
= "ti,sysc-omap4", .data
= &sysc_omap4
, },
1721 { .compatible
= "ti,sysc-omap4-timer", .data
= &sysc_omap4_timer
, },
1722 { .compatible
= "ti,sysc-omap4-simple", .data
= &sysc_omap4_simple
, },
1723 { .compatible
= "ti,sysc-omap3430-sr", .data
= &sysc_34xx_sr
, },
1724 { .compatible
= "ti,sysc-omap3630-sr", .data
= &sysc_36xx_sr
, },
1725 { .compatible
= "ti,sysc-omap4-sr", .data
= &sysc_omap4_sr
, },
1726 { .compatible
= "ti,sysc-omap3-sham", .data
= &sysc_omap3_sham
, },
1727 { .compatible
= "ti,sysc-omap-aes", .data
= &sysc_omap3_aes
, },
1728 { .compatible
= "ti,sysc-mcasp", .data
= &sysc_omap4_mcasp
, },
1729 { .compatible
= "ti,sysc-usb-host-fs",
1730 .data
= &sysc_omap4_usb_host_fs
, },
1731 { .compatible
= "ti,sysc-dra7-mcan", .data
= &sysc_dra7_mcan
, },
1734 MODULE_DEVICE_TABLE(of
, sysc_match
);
1736 static struct platform_driver sysc_driver
= {
1737 .probe
= sysc_probe
,
1738 .remove
= sysc_remove
,
1741 .of_match_table
= sysc_match
,
1746 static int __init
sysc_init(void)
1748 bus_register_notifier(&platform_bus_type
, &sysc_nb
);
1750 return platform_driver_register(&sysc_driver
);
1752 module_init(sysc_init
);
1754 static void __exit
sysc_exit(void)
1756 bus_unregister_notifier(&platform_bus_type
, &sysc_nb
);
1757 platform_driver_unregister(&sysc_driver
);
1759 module_exit(sysc_exit
);
1761 MODULE_DESCRIPTION("TI sysc interconnect target driver");
1762 MODULE_LICENSE("GPL v2");