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 static void sysc_parse_dts_quirks(struct sysc
*ddata
, struct device_node
*np
,
97 void sysc_write(struct sysc
*ddata
, int offset
, u32 value
)
99 writel_relaxed(value
, ddata
->module_va
+ offset
);
102 static u32
sysc_read(struct sysc
*ddata
, int offset
)
104 if (ddata
->cfg
.quirks
& SYSC_QUIRK_16BIT
) {
107 val
= readw_relaxed(ddata
->module_va
+ offset
);
108 val
|= (readw_relaxed(ddata
->module_va
+ offset
+ 4) << 16);
113 return readl_relaxed(ddata
->module_va
+ offset
);
116 static bool sysc_opt_clks_needed(struct sysc
*ddata
)
118 return !!(ddata
->cfg
.quirks
& SYSC_QUIRK_OPT_CLKS_NEEDED
);
121 static u32
sysc_read_revision(struct sysc
*ddata
)
123 int offset
= ddata
->offsets
[SYSC_REVISION
];
128 return sysc_read(ddata
, offset
);
131 static int sysc_get_one_clock(struct sysc
*ddata
, const char *name
)
133 int error
, i
, index
= -ENODEV
;
135 if (!strncmp(clock_names
[SYSC_FCK
], name
, 3))
137 else if (!strncmp(clock_names
[SYSC_ICK
], name
, 3))
141 for (i
= SYSC_OPTFCK0
; i
< SYSC_MAX_CLOCKS
; i
++) {
142 if (!ddata
->clocks
[i
]) {
150 dev_err(ddata
->dev
, "clock %s not added\n", name
);
154 ddata
->clocks
[index
] = devm_clk_get(ddata
->dev
, name
);
155 if (IS_ERR(ddata
->clocks
[index
])) {
156 if (PTR_ERR(ddata
->clocks
[index
]) == -ENOENT
)
159 dev_err(ddata
->dev
, "clock get error for %s: %li\n",
160 name
, PTR_ERR(ddata
->clocks
[index
]));
162 return PTR_ERR(ddata
->clocks
[index
]);
165 error
= clk_prepare(ddata
->clocks
[index
]);
167 dev_err(ddata
->dev
, "clock prepare error for %s: %i\n",
176 static int sysc_get_clocks(struct sysc
*ddata
)
178 struct device_node
*np
= ddata
->dev
->of_node
;
179 struct property
*prop
;
181 int nr_fck
= 0, nr_ick
= 0, i
, error
= 0;
183 ddata
->clock_roles
= devm_kcalloc(ddata
->dev
,
185 sizeof(*ddata
->clock_roles
),
187 if (!ddata
->clock_roles
)
190 of_property_for_each_string(np
, "clock-names", prop
, name
) {
191 if (!strncmp(clock_names
[SYSC_FCK
], name
, 3))
193 if (!strncmp(clock_names
[SYSC_ICK
], name
, 3))
195 ddata
->clock_roles
[ddata
->nr_clocks
] = name
;
199 if (ddata
->nr_clocks
< 1)
202 if (ddata
->nr_clocks
> SYSC_MAX_CLOCKS
) {
203 dev_err(ddata
->dev
, "too many clocks for %pOF\n", np
);
208 if (nr_fck
> 1 || nr_ick
> 1) {
209 dev_err(ddata
->dev
, "max one fck and ick for %pOF\n", np
);
214 ddata
->clocks
= devm_kcalloc(ddata
->dev
,
215 ddata
->nr_clocks
, sizeof(*ddata
->clocks
),
220 for (i
= 0; i
< SYSC_MAX_CLOCKS
; i
++) {
221 const char *name
= ddata
->clock_roles
[i
];
226 error
= sysc_get_one_clock(ddata
, name
);
227 if (error
&& error
!= -ENOENT
)
235 * sysc_init_resets - reset module on init
236 * @ddata: device driver data
238 * A module can have both OCP softreset control and external rstctrl.
239 * If more complicated rstctrl resets are needed, please handle these
240 * directly from the child device driver and map only the module reset
241 * for the parent interconnect target module device.
243 * Automatic reset of the module on init can be skipped with the
244 * "ti,no-reset-on-init" device tree property.
246 static int sysc_init_resets(struct sysc
*ddata
)
251 devm_reset_control_array_get_optional_exclusive(ddata
->dev
);
252 if (IS_ERR(ddata
->rsts
))
253 return PTR_ERR(ddata
->rsts
);
255 if (ddata
->cfg
.quirks
& SYSC_QUIRK_NO_RESET_ON_INIT
)
258 error
= reset_control_assert(ddata
->rsts
);
263 error
= reset_control_deassert(ddata
->rsts
);
271 * sysc_parse_and_check_child_range - parses module IO region from ranges
272 * @ddata: device driver data
274 * In general we only need rev, syss, and sysc registers and not the whole
275 * module range. But we do want the offsets for these registers from the
276 * module base. This allows us to check them against the legacy hwmod
277 * platform data. Let's also check the ranges are configured properly.
279 static int sysc_parse_and_check_child_range(struct sysc
*ddata
)
281 struct device_node
*np
= ddata
->dev
->of_node
;
282 const __be32
*ranges
;
283 u32 nr_addr
, nr_size
;
286 ranges
= of_get_property(np
, "ranges", &len
);
288 dev_err(ddata
->dev
, "missing ranges for %pOF\n", np
);
293 len
/= sizeof(*ranges
);
296 dev_err(ddata
->dev
, "incomplete ranges for %pOF\n", np
);
301 error
= of_property_read_u32(np
, "#address-cells", &nr_addr
);
305 error
= of_property_read_u32(np
, "#size-cells", &nr_size
);
309 if (nr_addr
!= 1 || nr_size
!= 1) {
310 dev_err(ddata
->dev
, "invalid ranges for %pOF\n", np
);
316 ddata
->module_pa
= of_translate_address(np
, ranges
++);
317 ddata
->module_size
= be32_to_cpup(ranges
);
322 static struct device_node
*stdout_path
;
324 static void sysc_init_stdout_path(struct sysc
*ddata
)
326 struct device_node
*np
= NULL
;
329 if (IS_ERR(stdout_path
))
335 np
= of_find_node_by_path("/chosen");
339 uart
= of_get_property(np
, "stdout-path", NULL
);
343 np
= of_find_node_by_path(uart
);
352 stdout_path
= ERR_PTR(-ENODEV
);
355 static void sysc_check_quirk_stdout(struct sysc
*ddata
,
356 struct device_node
*np
)
358 sysc_init_stdout_path(ddata
);
359 if (np
!= stdout_path
)
362 ddata
->cfg
.quirks
|= SYSC_QUIRK_NO_IDLE_ON_INIT
|
363 SYSC_QUIRK_NO_RESET_ON_INIT
;
367 * sysc_check_one_child - check child configuration
368 * @ddata: device driver data
369 * @np: child device node
371 * Let's avoid messy situations where we have new interconnect target
372 * node but children have "ti,hwmods". These belong to the interconnect
373 * target node and are managed by this driver.
375 static int sysc_check_one_child(struct sysc
*ddata
,
376 struct device_node
*np
)
380 name
= of_get_property(np
, "ti,hwmods", NULL
);
382 dev_warn(ddata
->dev
, "really a child ti,hwmods property?");
384 sysc_check_quirk_stdout(ddata
, np
);
385 sysc_parse_dts_quirks(ddata
, np
, true);
390 static int sysc_check_children(struct sysc
*ddata
)
392 struct device_node
*child
;
395 for_each_child_of_node(ddata
->dev
->of_node
, child
) {
396 error
= sysc_check_one_child(ddata
, child
);
405 * So far only I2C uses 16-bit read access with clockactivity with revision
406 * in two registers with stride of 4. We can detect this based on the rev
407 * register size to configure things far enough to be able to properly read
408 * the revision register.
410 static void sysc_check_quirk_16bit(struct sysc
*ddata
, struct resource
*res
)
412 if (resource_size(res
) == 8)
413 ddata
->cfg
.quirks
|= SYSC_QUIRK_16BIT
| SYSC_QUIRK_USE_CLOCKACT
;
417 * sysc_parse_one - parses the interconnect target module registers
418 * @ddata: device driver data
419 * @reg: register to parse
421 static int sysc_parse_one(struct sysc
*ddata
, enum sysc_registers reg
)
423 struct resource
*res
;
430 name
= reg_names
[reg
];
436 res
= platform_get_resource_byname(to_platform_device(ddata
->dev
),
437 IORESOURCE_MEM
, name
);
439 ddata
->offsets
[reg
] = -ENODEV
;
444 ddata
->offsets
[reg
] = res
->start
- ddata
->module_pa
;
445 if (reg
== SYSC_REVISION
)
446 sysc_check_quirk_16bit(ddata
, res
);
451 static int sysc_parse_registers(struct sysc
*ddata
)
455 for (i
= 0; i
< SYSC_MAX_REGS
; i
++) {
456 error
= sysc_parse_one(ddata
, i
);
465 * sysc_check_registers - check for misconfigured register overlaps
466 * @ddata: device driver data
468 static int sysc_check_registers(struct sysc
*ddata
)
470 int i
, j
, nr_regs
= 0, nr_matches
= 0;
472 for (i
= 0; i
< SYSC_MAX_REGS
; i
++) {
473 if (ddata
->offsets
[i
] < 0)
476 if (ddata
->offsets
[i
] > (ddata
->module_size
- 4)) {
477 dev_err(ddata
->dev
, "register outside module range");
482 for (j
= 0; j
< SYSC_MAX_REGS
; j
++) {
483 if (ddata
->offsets
[j
] < 0)
486 if (ddata
->offsets
[i
] == ddata
->offsets
[j
])
493 dev_err(ddata
->dev
, "missing registers\n");
498 if (nr_matches
> nr_regs
) {
499 dev_err(ddata
->dev
, "overlapping registers: (%i/%i)",
500 nr_regs
, nr_matches
);
509 * syc_ioremap - ioremap register space for the interconnect target module
510 * @ddata: device driver data
512 * Note that the interconnect target module registers can be anywhere
513 * within the interconnect target module range. For example, SGX has
514 * them at offset 0x1fc00 in the 32MB module address space. And cpsw
515 * has them at offset 0x1200 in the CPSW_WR child. Usually the
516 * the interconnect target module registers are at the beginning of
517 * the module range though.
519 static int sysc_ioremap(struct sysc
*ddata
)
523 size
= max3(ddata
->offsets
[SYSC_REVISION
],
524 ddata
->offsets
[SYSC_SYSCONFIG
],
525 ddata
->offsets
[SYSC_SYSSTATUS
]);
527 if (size
< 0 || (size
+ sizeof(u32
)) > ddata
->module_size
)
530 ddata
->module_va
= devm_ioremap(ddata
->dev
,
533 if (!ddata
->module_va
)
540 * sysc_map_and_check_registers - ioremap and check device registers
541 * @ddata: device driver data
543 static int sysc_map_and_check_registers(struct sysc
*ddata
)
547 error
= sysc_parse_and_check_child_range(ddata
);
551 error
= sysc_check_children(ddata
);
555 error
= sysc_parse_registers(ddata
);
559 error
= sysc_ioremap(ddata
);
563 error
= sysc_check_registers(ddata
);
571 * sysc_show_rev - read and show interconnect target module revision
572 * @bufp: buffer to print the information to
573 * @ddata: device driver data
575 static int sysc_show_rev(char *bufp
, struct sysc
*ddata
)
579 if (ddata
->offsets
[SYSC_REVISION
] < 0)
580 return sprintf(bufp
, ":NA");
582 len
= sprintf(bufp
, ":%08x", ddata
->revision
);
587 static int sysc_show_reg(struct sysc
*ddata
,
588 char *bufp
, enum sysc_registers reg
)
590 if (ddata
->offsets
[reg
] < 0)
591 return sprintf(bufp
, ":NA");
593 return sprintf(bufp
, ":%x", ddata
->offsets
[reg
]);
596 static int sysc_show_name(char *bufp
, struct sysc
*ddata
)
601 return sprintf(bufp
, ":%s", ddata
->name
);
605 * sysc_show_registers - show information about interconnect target module
606 * @ddata: device driver data
608 static void sysc_show_registers(struct sysc
*ddata
)
614 for (i
= 0; i
< SYSC_MAX_REGS
; i
++)
615 bufp
+= sysc_show_reg(ddata
, bufp
, i
);
617 bufp
+= sysc_show_rev(bufp
, ddata
);
618 bufp
+= sysc_show_name(bufp
, ddata
);
620 dev_dbg(ddata
->dev
, "%llx:%x%s\n",
621 ddata
->module_pa
, ddata
->module_size
,
625 static int __maybe_unused
sysc_runtime_suspend(struct device
*dev
)
627 struct ti_sysc_platform_data
*pdata
;
631 ddata
= dev_get_drvdata(dev
);
636 if (ddata
->legacy_mode
) {
637 pdata
= dev_get_platdata(ddata
->dev
);
641 if (!pdata
->idle_module
)
644 error
= pdata
->idle_module(dev
, &ddata
->cookie
);
646 dev_err(dev
, "%s: could not idle: %i\n",
652 for (i
= 0; i
< ddata
->nr_clocks
; i
++) {
653 if (IS_ERR_OR_NULL(ddata
->clocks
[i
]))
656 if (i
>= SYSC_OPTFCK0
&& !sysc_opt_clks_needed(ddata
))
659 clk_disable(ddata
->clocks
[i
]);
663 ddata
->enabled
= false;
668 static int __maybe_unused
sysc_runtime_resume(struct device
*dev
)
670 struct ti_sysc_platform_data
*pdata
;
674 ddata
= dev_get_drvdata(dev
);
679 if (ddata
->legacy_mode
) {
680 pdata
= dev_get_platdata(ddata
->dev
);
684 if (!pdata
->enable_module
)
687 error
= pdata
->enable_module(dev
, &ddata
->cookie
);
689 dev_err(dev
, "%s: could not enable: %i\n",
695 for (i
= 0; i
< ddata
->nr_clocks
; i
++) {
696 if (IS_ERR_OR_NULL(ddata
->clocks
[i
]))
699 if (i
>= SYSC_OPTFCK0
&& !sysc_opt_clks_needed(ddata
))
702 error
= clk_enable(ddata
->clocks
[i
]);
708 ddata
->enabled
= true;
713 static int __maybe_unused
sysc_noirq_suspend(struct device
*dev
)
717 ddata
= dev_get_drvdata(dev
);
719 if (ddata
->cfg
.quirks
& SYSC_QUIRK_LEGACY_IDLE
)
722 return pm_runtime_force_suspend(dev
);
725 static int __maybe_unused
sysc_noirq_resume(struct device
*dev
)
729 ddata
= dev_get_drvdata(dev
);
731 if (ddata
->cfg
.quirks
& SYSC_QUIRK_LEGACY_IDLE
)
734 return pm_runtime_force_resume(dev
);
737 static const struct dev_pm_ops sysc_pm_ops
= {
738 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_noirq_suspend
, sysc_noirq_resume
)
739 SET_RUNTIME_PM_OPS(sysc_runtime_suspend
,
744 /* Module revision register based quirks */
745 struct sysc_revision_quirk
{
756 #define SYSC_QUIRK(optname, optbase, optrev, optsysc, optsyss, \
757 optrev_val, optrevmask, optquirkmask) \
761 .rev_offset = (optrev), \
762 .sysc_offset = (optsysc), \
763 .syss_offset = (optsyss), \
764 .revision = (optrev_val), \
765 .revision_mask = (optrevmask), \
766 .quirks = (optquirkmask), \
769 static const struct sysc_revision_quirk sysc_revision_quirks
[] = {
770 /* These drivers need to be fixed to not use pm_runtime_irq_safe() */
771 SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffff00ff,
772 SYSC_QUIRK_LEGACY_IDLE
| SYSC_QUIRK_OPT_CLKS_IN_RESET
),
773 SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000020, 0xffffffff,
774 SYSC_QUIRK_LEGACY_IDLE
),
775 SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000030, 0xffffffff,
776 SYSC_QUIRK_LEGACY_IDLE
),
777 SYSC_QUIRK("sham", 0, 0x100, 0x110, 0x114, 0x40000c03, 0xffffffff,
778 SYSC_QUIRK_LEGACY_IDLE
),
779 SYSC_QUIRK("smartreflex", 0, -1, 0x24, -1, 0x00000000, 0xffffffff,
780 SYSC_QUIRK_LEGACY_IDLE
),
781 SYSC_QUIRK("smartreflex", 0, -1, 0x38, -1, 0x00000000, 0xffffffff,
782 SYSC_QUIRK_LEGACY_IDLE
),
783 SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff,
785 /* Some timers on omap4 and later */
786 SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x50002100, 0xffffffff,
788 SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x4fff1301, 0xffff00ff,
790 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff,
791 SYSC_QUIRK_LEGACY_IDLE
),
792 /* Uarts on omap4 and later */
793 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffff00ff,
794 SYSC_QUIRK_LEGACY_IDLE
),
795 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x47422e03, 0xffffffff,
796 SYSC_QUIRK_LEGACY_IDLE
),
799 SYSC_QUIRK("adc", 0, 0, 0x10, -1, 0x47300001, 0xffffffff, 0),
800 SYSC_QUIRK("atl", 0, 0, -1, -1, 0x0a070100, 0xffffffff, 0),
801 SYSC_QUIRK("aess", 0, 0, 0x10, -1, 0x40000000, 0xffffffff, 0),
802 SYSC_QUIRK("cm", 0, 0, -1, -1, 0x40000301, 0xffffffff, 0),
803 SYSC_QUIRK("control", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0),
804 SYSC_QUIRK("cpgmac", 0, 0x1200, 0x1208, 0x1204, 0x4edb1902,
806 SYSC_QUIRK("dcan", 0, 0, -1, -1, 0xffffffff, 0xffffffff, 0),
807 SYSC_QUIRK("dcan", 0, 0, -1, -1, 0x00001401, 0xffffffff, 0),
808 SYSC_QUIRK("dwc3", 0, 0, 0x10, -1, 0x500a0200, 0xffffffff, 0),
809 SYSC_QUIRK("epwmss", 0, 0, 0x4, -1, 0x47400001, 0xffffffff, 0),
810 SYSC_QUIRK("gpu", 0, 0x1fc00, 0x1fc10, -1, 0, 0, 0),
811 SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x00000006, 0xffffffff, 0),
812 SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x0000000a, 0xffffffff, 0),
813 SYSC_QUIRK("hsi", 0, 0, 0x10, 0x14, 0x50043101, 0xffffffff, 0),
814 SYSC_QUIRK("iss", 0, 0, 0x10, -1, 0x40000101, 0xffffffff, 0),
815 SYSC_QUIRK("i2c", 0, 0, 0x10, 0x90, 0x5040000a, 0xfffff0f0, 0),
816 SYSC_QUIRK("lcdc", 0, 0, 0x54, -1, 0x4f201000, 0xffffffff, 0),
817 SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44306302, 0xffffffff, 0),
818 SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44307b02, 0xffffffff, 0),
819 SYSC_QUIRK("mcbsp", 0, -1, 0x8c, -1, 0, 0, 0),
820 SYSC_QUIRK("mcspi", 0, 0, 0x10, -1, 0x40300a0b, 0xffff00ff, 0),
821 SYSC_QUIRK("mcspi", 0, 0, 0x110, 0x114, 0x40300a0b, 0xffffffff, 0),
822 SYSC_QUIRK("mailbox", 0, 0, 0x10, -1, 0x00000400, 0xffffffff, 0),
823 SYSC_QUIRK("m3", 0, 0, -1, -1, 0x5f580105, 0x0fff0f00, 0),
824 SYSC_QUIRK("ocp2scp", 0, 0, 0x10, 0x14, 0x50060005, 0xfffffff0, 0),
825 SYSC_QUIRK("ocp2scp", 0, 0, -1, -1, 0x50060007, 0xffffffff, 0),
826 SYSC_QUIRK("padconf", 0, 0, 0x10, -1, 0x4fff0800, 0xffffffff, 0),
827 SYSC_QUIRK("padconf", 0, 0, -1, -1, 0x40001100, 0xffffffff, 0),
828 SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000100, 0xffffffff, 0),
829 SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x00004102, 0xffffffff, 0),
830 SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000400, 0xffffffff, 0),
831 SYSC_QUIRK("scm", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0),
832 SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4e8b0100, 0xffffffff, 0),
833 SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4f000100, 0xffffffff, 0),
834 SYSC_QUIRK("scm", 0, 0, -1, -1, 0x40000900, 0xffffffff, 0),
835 SYSC_QUIRK("scrm", 0, 0, -1, -1, 0x00000010, 0xffffffff, 0),
836 SYSC_QUIRK("sdio", 0, 0, 0x10, -1, 0x40202301, 0xffff0ff0, 0),
837 SYSC_QUIRK("sdio", 0, 0x2fc, 0x110, 0x114, 0x31010000, 0xffffffff, 0),
838 SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff, 0),
839 SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40000902, 0xffffffff, 0),
840 SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40002903, 0xffffffff, 0),
841 SYSC_QUIRK("spinlock", 0, 0, 0x10, -1, 0x50020000, 0xffffffff, 0),
842 SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -1, 0x00000020, 0xffffffff, 0),
843 SYSC_QUIRK("rtc", 0, 0x74, 0x78, -1, 0x4eb01908, 0xffff00f0, 0),
844 SYSC_QUIRK("timer32k", 0, 0, 0x4, -1, 0x00000060, 0xffffffff, 0),
845 SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000004, 0xffffffff, 0),
846 SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000008, 0xffffffff, 0),
847 SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff, 0),
848 SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -1, 0x50700101, 0xffffffff, 0),
849 SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050,
851 SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xfffff0f0, 0),
852 SYSC_QUIRK("vfpe", 0, 0, 0x104, -1, 0x4d001200, 0xffffffff, 0),
856 static void sysc_init_revision_quirks(struct sysc
*ddata
)
858 const struct sysc_revision_quirk
*q
;
861 for (i
= 0; i
< ARRAY_SIZE(sysc_revision_quirks
); i
++) {
862 q
= &sysc_revision_quirks
[i
];
864 if (q
->base
&& q
->base
!= ddata
->module_pa
)
867 if (q
->rev_offset
>= 0 &&
868 q
->rev_offset
!= ddata
->offsets
[SYSC_REVISION
])
871 if (q
->sysc_offset
>= 0 &&
872 q
->sysc_offset
!= ddata
->offsets
[SYSC_SYSCONFIG
])
875 if (q
->syss_offset
>= 0 &&
876 q
->syss_offset
!= ddata
->offsets
[SYSC_SYSSTATUS
])
879 if (q
->revision
== ddata
->revision
||
880 (q
->revision
& q
->revision_mask
) ==
881 (ddata
->revision
& q
->revision_mask
)) {
882 ddata
->name
= q
->name
;
883 ddata
->cfg
.quirks
|= q
->quirks
;
888 static int sysc_reset(struct sysc
*ddata
)
890 int offset
= ddata
->offsets
[SYSC_SYSCONFIG
];
893 if (ddata
->legacy_mode
|| offset
< 0 ||
894 ddata
->cfg
.quirks
& SYSC_QUIRK_NO_RESET_ON_INIT
)
898 * Currently only support reset status in sysstatus.
899 * Warn and return error in all other cases
901 if (!ddata
->cfg
.syss_mask
) {
902 dev_err(ddata
->dev
, "No ti,syss-mask. Reset failed\n");
906 val
= sysc_read(ddata
, offset
);
907 val
|= (0x1 << ddata
->cap
->regbits
->srst_shift
);
908 sysc_write(ddata
, offset
, val
);
910 /* Poll on reset status */
911 offset
= ddata
->offsets
[SYSC_SYSSTATUS
];
913 return readl_poll_timeout(ddata
->module_va
+ offset
, val
,
914 (val
& ddata
->cfg
.syss_mask
) == 0x0,
915 100, MAX_MODULE_SOFTRESET_WAIT
);
918 /* At this point the module is configured enough to read the revision */
919 static int sysc_init_module(struct sysc
*ddata
)
923 if (ddata
->cfg
.quirks
& SYSC_QUIRK_NO_IDLE_ON_INIT
) {
924 ddata
->revision
= sysc_read_revision(ddata
);
928 error
= pm_runtime_get_sync(ddata
->dev
);
930 pm_runtime_put_noidle(ddata
->dev
);
935 error
= sysc_reset(ddata
);
937 dev_err(ddata
->dev
, "Reset failed with %d\n", error
);
938 pm_runtime_put_sync(ddata
->dev
);
943 ddata
->revision
= sysc_read_revision(ddata
);
944 pm_runtime_put_sync(ddata
->dev
);
947 sysc_init_revision_quirks(ddata
);
952 static int sysc_init_sysc_mask(struct sysc
*ddata
)
954 struct device_node
*np
= ddata
->dev
->of_node
;
958 error
= of_property_read_u32(np
, "ti,sysc-mask", &val
);
963 ddata
->cfg
.sysc_val
= val
& ddata
->cap
->sysc_mask
;
965 ddata
->cfg
.sysc_val
= ddata
->cap
->sysc_mask
;
970 static int sysc_init_idlemode(struct sysc
*ddata
, u8
*idlemodes
,
973 struct device_node
*np
= ddata
->dev
->of_node
;
974 struct property
*prop
;
978 of_property_for_each_u32(np
, name
, prop
, p
, val
) {
979 if (val
>= SYSC_NR_IDLEMODES
) {
980 dev_err(ddata
->dev
, "invalid idlemode: %i\n", val
);
983 *idlemodes
|= (1 << val
);
989 static int sysc_init_idlemodes(struct sysc
*ddata
)
993 error
= sysc_init_idlemode(ddata
, &ddata
->cfg
.midlemodes
,
998 error
= sysc_init_idlemode(ddata
, &ddata
->cfg
.sidlemodes
,
1007 * Only some devices on omap4 and later have SYSCONFIG reset done
1008 * bit. We can detect this if there is no SYSSTATUS at all, or the
1009 * SYSTATUS bit 0 is not used. Note that some SYSSTATUS registers
1010 * have multiple bits for the child devices like OHCI and EHCI.
1011 * Depends on SYSC being parsed first.
1013 static int sysc_init_syss_mask(struct sysc
*ddata
)
1015 struct device_node
*np
= ddata
->dev
->of_node
;
1019 error
= of_property_read_u32(np
, "ti,syss-mask", &val
);
1021 if ((ddata
->cap
->type
== TI_SYSC_OMAP4
||
1022 ddata
->cap
->type
== TI_SYSC_OMAP4_TIMER
) &&
1023 (ddata
->cfg
.sysc_val
& SYSC_OMAP4_SOFTRESET
))
1024 ddata
->cfg
.quirks
|= SYSC_QUIRK_RESET_STATUS
;
1029 if (!(val
& 1) && (ddata
->cfg
.sysc_val
& SYSC_OMAP4_SOFTRESET
))
1030 ddata
->cfg
.quirks
|= SYSC_QUIRK_RESET_STATUS
;
1032 ddata
->cfg
.syss_mask
= val
;
1038 * Many child device drivers need to have fck and opt clocks available
1039 * to get the clock rate for device internal configuration etc.
1041 static int sysc_child_add_named_clock(struct sysc
*ddata
,
1042 struct device
*child
,
1046 struct clk_lookup
*l
;
1052 clk
= clk_get(child
, name
);
1059 clk
= clk_get(ddata
->dev
, name
);
1063 l
= clkdev_create(clk
, name
, dev_name(child
));
1072 static int sysc_child_add_clocks(struct sysc
*ddata
,
1073 struct device
*child
)
1077 for (i
= 0; i
< ddata
->nr_clocks
; i
++) {
1078 error
= sysc_child_add_named_clock(ddata
,
1080 ddata
->clock_roles
[i
]);
1081 if (error
&& error
!= -EEXIST
) {
1082 dev_err(ddata
->dev
, "could not add child clock %s: %i\n",
1083 ddata
->clock_roles
[i
], error
);
1092 static struct device_type sysc_device_type
= {
1095 static struct sysc
*sysc_child_to_parent(struct device
*dev
)
1097 struct device
*parent
= dev
->parent
;
1099 if (!parent
|| parent
->type
!= &sysc_device_type
)
1102 return dev_get_drvdata(parent
);
1105 static int __maybe_unused
sysc_child_runtime_suspend(struct device
*dev
)
1110 ddata
= sysc_child_to_parent(dev
);
1112 error
= pm_generic_runtime_suspend(dev
);
1116 if (!ddata
->enabled
)
1119 return sysc_runtime_suspend(ddata
->dev
);
1122 static int __maybe_unused
sysc_child_runtime_resume(struct device
*dev
)
1127 ddata
= sysc_child_to_parent(dev
);
1129 if (!ddata
->enabled
) {
1130 error
= sysc_runtime_resume(ddata
->dev
);
1133 "%s error: %i\n", __func__
, error
);
1136 return pm_generic_runtime_resume(dev
);
1139 #ifdef CONFIG_PM_SLEEP
1140 static int sysc_child_suspend_noirq(struct device
*dev
)
1145 ddata
= sysc_child_to_parent(dev
);
1147 dev_dbg(ddata
->dev
, "%s %s\n", __func__
,
1148 ddata
->name
? ddata
->name
: "");
1150 error
= pm_generic_suspend_noirq(dev
);
1152 dev_err(dev
, "%s error at %i: %i\n",
1153 __func__
, __LINE__
, error
);
1158 if (!pm_runtime_status_suspended(dev
)) {
1159 error
= pm_generic_runtime_suspend(dev
);
1161 dev_dbg(dev
, "%s busy at %i: %i\n",
1162 __func__
, __LINE__
, error
);
1167 error
= sysc_runtime_suspend(ddata
->dev
);
1169 dev_err(dev
, "%s error at %i: %i\n",
1170 __func__
, __LINE__
, error
);
1175 ddata
->child_needs_resume
= true;
1181 static int sysc_child_resume_noirq(struct device
*dev
)
1186 ddata
= sysc_child_to_parent(dev
);
1188 dev_dbg(ddata
->dev
, "%s %s\n", __func__
,
1189 ddata
->name
? ddata
->name
: "");
1191 if (ddata
->child_needs_resume
) {
1192 ddata
->child_needs_resume
= false;
1194 error
= sysc_runtime_resume(ddata
->dev
);
1197 "%s runtime resume error: %i\n",
1200 error
= pm_generic_runtime_resume(dev
);
1203 "%s generic runtime resume: %i\n",
1207 return pm_generic_resume_noirq(dev
);
1211 struct dev_pm_domain sysc_child_pm_domain
= {
1213 SET_RUNTIME_PM_OPS(sysc_child_runtime_suspend
,
1214 sysc_child_runtime_resume
,
1216 USE_PLATFORM_PM_SLEEP_OPS
1217 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_child_suspend_noirq
,
1218 sysc_child_resume_noirq
)
1223 * sysc_legacy_idle_quirk - handle children in omap_device compatible way
1224 * @ddata: device driver data
1225 * @child: child device driver
1227 * Allow idle for child devices as done with _od_runtime_suspend().
1228 * Otherwise many child devices will not idle because of the permanent
1229 * parent usecount set in pm_runtime_irq_safe().
1231 * Note that the long term solution is to just modify the child device
1232 * drivers to not set pm_runtime_irq_safe() and then this can be just
1235 static void sysc_legacy_idle_quirk(struct sysc
*ddata
, struct device
*child
)
1237 if (!ddata
->legacy_mode
)
1240 if (ddata
->cfg
.quirks
& SYSC_QUIRK_LEGACY_IDLE
)
1241 dev_pm_domain_set(child
, &sysc_child_pm_domain
);
1244 static int sysc_notifier_call(struct notifier_block
*nb
,
1245 unsigned long event
, void *device
)
1247 struct device
*dev
= device
;
1251 ddata
= sysc_child_to_parent(dev
);
1256 case BUS_NOTIFY_ADD_DEVICE
:
1257 error
= sysc_child_add_clocks(ddata
, dev
);
1260 sysc_legacy_idle_quirk(ddata
, dev
);
1269 static struct notifier_block sysc_nb
= {
1270 .notifier_call
= sysc_notifier_call
,
1273 /* Device tree configured quirks */
1274 struct sysc_dts_quirk
{
1279 static const struct sysc_dts_quirk sysc_dts_quirks
[] = {
1280 { .name
= "ti,no-idle-on-init",
1281 .mask
= SYSC_QUIRK_NO_IDLE_ON_INIT
, },
1282 { .name
= "ti,no-reset-on-init",
1283 .mask
= SYSC_QUIRK_NO_RESET_ON_INIT
, },
1286 static void sysc_parse_dts_quirks(struct sysc
*ddata
, struct device_node
*np
,
1289 const struct property
*prop
;
1292 for (i
= 0; i
< ARRAY_SIZE(sysc_dts_quirks
); i
++) {
1293 const char *name
= sysc_dts_quirks
[i
].name
;
1295 prop
= of_get_property(np
, name
, &len
);
1299 ddata
->cfg
.quirks
|= sysc_dts_quirks
[i
].mask
;
1301 dev_warn(ddata
->dev
,
1302 "dts flag should be at module level for %s\n",
1308 static int sysc_init_dts_quirks(struct sysc
*ddata
)
1310 struct device_node
*np
= ddata
->dev
->of_node
;
1314 ddata
->legacy_mode
= of_get_property(np
, "ti,hwmods", NULL
);
1316 sysc_parse_dts_quirks(ddata
, np
, false);
1317 error
= of_property_read_u32(np
, "ti,sysc-delay-us", &val
);
1320 dev_warn(ddata
->dev
, "bad ti,sysc-delay-us: %i\n",
1324 ddata
->cfg
.srst_udelay
= (u8
)val
;
1330 static void sysc_unprepare(struct sysc
*ddata
)
1334 for (i
= 0; i
< SYSC_MAX_CLOCKS
; i
++) {
1335 if (!IS_ERR_OR_NULL(ddata
->clocks
[i
]))
1336 clk_unprepare(ddata
->clocks
[i
]);
1341 * Common sysc register bits found on omap2, also known as type1
1343 static const struct sysc_regbits sysc_regbits_omap2
= {
1344 .dmadisable_shift
= -ENODEV
,
1351 .autoidle_shift
= 0,
1354 static const struct sysc_capabilities sysc_omap2
= {
1355 .type
= TI_SYSC_OMAP2
,
1356 .sysc_mask
= SYSC_OMAP2_CLOCKACTIVITY
| SYSC_OMAP2_EMUFREE
|
1357 SYSC_OMAP2_ENAWAKEUP
| SYSC_OMAP2_SOFTRESET
|
1358 SYSC_OMAP2_AUTOIDLE
,
1359 .regbits
= &sysc_regbits_omap2
,
1362 /* All omap2 and 3 timers, and timers 1, 2 & 10 on omap 4 and 5 */
1363 static const struct sysc_capabilities sysc_omap2_timer
= {
1364 .type
= TI_SYSC_OMAP2_TIMER
,
1365 .sysc_mask
= SYSC_OMAP2_CLOCKACTIVITY
| SYSC_OMAP2_EMUFREE
|
1366 SYSC_OMAP2_ENAWAKEUP
| SYSC_OMAP2_SOFTRESET
|
1367 SYSC_OMAP2_AUTOIDLE
,
1368 .regbits
= &sysc_regbits_omap2
,
1369 .mod_quirks
= SYSC_QUIRK_USE_CLOCKACT
,
1373 * SHAM2 (SHA1/MD5) sysc found on omap3, a variant of sysc_regbits_omap2
1374 * with different sidle position
1376 static const struct sysc_regbits sysc_regbits_omap3_sham
= {
1377 .dmadisable_shift
= -ENODEV
,
1378 .midle_shift
= -ENODEV
,
1380 .clkact_shift
= -ENODEV
,
1381 .enwkup_shift
= -ENODEV
,
1383 .autoidle_shift
= 0,
1384 .emufree_shift
= -ENODEV
,
1387 static const struct sysc_capabilities sysc_omap3_sham
= {
1388 .type
= TI_SYSC_OMAP3_SHAM
,
1389 .sysc_mask
= SYSC_OMAP2_SOFTRESET
| SYSC_OMAP2_AUTOIDLE
,
1390 .regbits
= &sysc_regbits_omap3_sham
,
1394 * AES register bits found on omap3 and later, a variant of
1395 * sysc_regbits_omap2 with different sidle position
1397 static const struct sysc_regbits sysc_regbits_omap3_aes
= {
1398 .dmadisable_shift
= -ENODEV
,
1399 .midle_shift
= -ENODEV
,
1401 .clkact_shift
= -ENODEV
,
1402 .enwkup_shift
= -ENODEV
,
1404 .autoidle_shift
= 0,
1405 .emufree_shift
= -ENODEV
,
1408 static const struct sysc_capabilities sysc_omap3_aes
= {
1409 .type
= TI_SYSC_OMAP3_AES
,
1410 .sysc_mask
= SYSC_OMAP2_SOFTRESET
| SYSC_OMAP2_AUTOIDLE
,
1411 .regbits
= &sysc_regbits_omap3_aes
,
1415 * Common sysc register bits found on omap4, also known as type2
1417 static const struct sysc_regbits sysc_regbits_omap4
= {
1418 .dmadisable_shift
= 16,
1421 .clkact_shift
= -ENODEV
,
1422 .enwkup_shift
= -ENODEV
,
1425 .autoidle_shift
= -ENODEV
,
1428 static const struct sysc_capabilities sysc_omap4
= {
1429 .type
= TI_SYSC_OMAP4
,
1430 .sysc_mask
= SYSC_OMAP4_DMADISABLE
| SYSC_OMAP4_FREEEMU
|
1431 SYSC_OMAP4_SOFTRESET
,
1432 .regbits
= &sysc_regbits_omap4
,
1435 static const struct sysc_capabilities sysc_omap4_timer
= {
1436 .type
= TI_SYSC_OMAP4_TIMER
,
1437 .sysc_mask
= SYSC_OMAP4_DMADISABLE
| SYSC_OMAP4_FREEEMU
|
1438 SYSC_OMAP4_SOFTRESET
,
1439 .regbits
= &sysc_regbits_omap4
,
1443 * Common sysc register bits found on omap4, also known as type3
1445 static const struct sysc_regbits sysc_regbits_omap4_simple
= {
1446 .dmadisable_shift
= -ENODEV
,
1449 .clkact_shift
= -ENODEV
,
1450 .enwkup_shift
= -ENODEV
,
1451 .srst_shift
= -ENODEV
,
1452 .emufree_shift
= -ENODEV
,
1453 .autoidle_shift
= -ENODEV
,
1456 static const struct sysc_capabilities sysc_omap4_simple
= {
1457 .type
= TI_SYSC_OMAP4_SIMPLE
,
1458 .regbits
= &sysc_regbits_omap4_simple
,
1462 * SmartReflex sysc found on omap34xx
1464 static const struct sysc_regbits sysc_regbits_omap34xx_sr
= {
1465 .dmadisable_shift
= -ENODEV
,
1466 .midle_shift
= -ENODEV
,
1467 .sidle_shift
= -ENODEV
,
1469 .enwkup_shift
= -ENODEV
,
1470 .srst_shift
= -ENODEV
,
1471 .emufree_shift
= -ENODEV
,
1472 .autoidle_shift
= -ENODEV
,
1475 static const struct sysc_capabilities sysc_34xx_sr
= {
1476 .type
= TI_SYSC_OMAP34XX_SR
,
1477 .sysc_mask
= SYSC_OMAP2_CLOCKACTIVITY
,
1478 .regbits
= &sysc_regbits_omap34xx_sr
,
1479 .mod_quirks
= SYSC_QUIRK_USE_CLOCKACT
| SYSC_QUIRK_UNCACHED
|
1480 SYSC_QUIRK_LEGACY_IDLE
,
1484 * SmartReflex sysc found on omap36xx and later
1486 static const struct sysc_regbits sysc_regbits_omap36xx_sr
= {
1487 .dmadisable_shift
= -ENODEV
,
1488 .midle_shift
= -ENODEV
,
1490 .clkact_shift
= -ENODEV
,
1492 .srst_shift
= -ENODEV
,
1493 .emufree_shift
= -ENODEV
,
1494 .autoidle_shift
= -ENODEV
,
1497 static const struct sysc_capabilities sysc_36xx_sr
= {
1498 .type
= TI_SYSC_OMAP36XX_SR
,
1499 .sysc_mask
= SYSC_OMAP3_SR_ENAWAKEUP
,
1500 .regbits
= &sysc_regbits_omap36xx_sr
,
1501 .mod_quirks
= SYSC_QUIRK_UNCACHED
| SYSC_QUIRK_LEGACY_IDLE
,
1504 static const struct sysc_capabilities sysc_omap4_sr
= {
1505 .type
= TI_SYSC_OMAP4_SR
,
1506 .regbits
= &sysc_regbits_omap36xx_sr
,
1507 .mod_quirks
= SYSC_QUIRK_LEGACY_IDLE
,
1511 * McASP register bits found on omap4 and later
1513 static const struct sysc_regbits sysc_regbits_omap4_mcasp
= {
1514 .dmadisable_shift
= -ENODEV
,
1515 .midle_shift
= -ENODEV
,
1517 .clkact_shift
= -ENODEV
,
1518 .enwkup_shift
= -ENODEV
,
1519 .srst_shift
= -ENODEV
,
1520 .emufree_shift
= -ENODEV
,
1521 .autoidle_shift
= -ENODEV
,
1524 static const struct sysc_capabilities sysc_omap4_mcasp
= {
1525 .type
= TI_SYSC_OMAP4_MCASP
,
1526 .regbits
= &sysc_regbits_omap4_mcasp
,
1527 .mod_quirks
= SYSC_QUIRK_OPT_CLKS_NEEDED
,
1531 * McASP found on dra7 and later
1533 static const struct sysc_capabilities sysc_dra7_mcasp
= {
1534 .type
= TI_SYSC_OMAP4_SIMPLE
,
1535 .regbits
= &sysc_regbits_omap4_simple
,
1536 .mod_quirks
= SYSC_QUIRK_OPT_CLKS_NEEDED
,
1540 * FS USB host found on omap4 and later
1542 static const struct sysc_regbits sysc_regbits_omap4_usb_host_fs
= {
1543 .dmadisable_shift
= -ENODEV
,
1544 .midle_shift
= -ENODEV
,
1546 .clkact_shift
= -ENODEV
,
1548 .srst_shift
= -ENODEV
,
1549 .emufree_shift
= -ENODEV
,
1550 .autoidle_shift
= -ENODEV
,
1553 static const struct sysc_capabilities sysc_omap4_usb_host_fs
= {
1554 .type
= TI_SYSC_OMAP4_USB_HOST_FS
,
1555 .sysc_mask
= SYSC_OMAP2_ENAWAKEUP
,
1556 .regbits
= &sysc_regbits_omap4_usb_host_fs
,
1559 static const struct sysc_regbits sysc_regbits_dra7_mcan
= {
1560 .dmadisable_shift
= -ENODEV
,
1561 .midle_shift
= -ENODEV
,
1562 .sidle_shift
= -ENODEV
,
1563 .clkact_shift
= -ENODEV
,
1566 .emufree_shift
= -ENODEV
,
1567 .autoidle_shift
= -ENODEV
,
1570 static const struct sysc_capabilities sysc_dra7_mcan
= {
1571 .type
= TI_SYSC_DRA7_MCAN
,
1572 .sysc_mask
= SYSC_DRA7_MCAN_ENAWAKEUP
| SYSC_OMAP4_SOFTRESET
,
1573 .regbits
= &sysc_regbits_dra7_mcan
,
1576 static int sysc_init_pdata(struct sysc
*ddata
)
1578 struct ti_sysc_platform_data
*pdata
= dev_get_platdata(ddata
->dev
);
1579 struct ti_sysc_module_data mdata
;
1582 if (!pdata
|| !ddata
->legacy_mode
)
1585 mdata
.name
= ddata
->legacy_mode
;
1586 mdata
.module_pa
= ddata
->module_pa
;
1587 mdata
.module_size
= ddata
->module_size
;
1588 mdata
.offsets
= ddata
->offsets
;
1589 mdata
.nr_offsets
= SYSC_MAX_REGS
;
1590 mdata
.cap
= ddata
->cap
;
1591 mdata
.cfg
= &ddata
->cfg
;
1593 if (!pdata
->init_module
)
1596 error
= pdata
->init_module(ddata
->dev
, &mdata
, &ddata
->cookie
);
1597 if (error
== -EEXIST
)
1603 static int sysc_init_match(struct sysc
*ddata
)
1605 const struct sysc_capabilities
*cap
;
1607 cap
= of_device_get_match_data(ddata
->dev
);
1613 ddata
->cfg
.quirks
|= ddata
->cap
->mod_quirks
;
1618 static void ti_sysc_idle(struct work_struct
*work
)
1622 ddata
= container_of(work
, struct sysc
, idle_work
.work
);
1624 if (pm_runtime_active(ddata
->dev
))
1625 pm_runtime_put_sync(ddata
->dev
);
1628 static const struct of_device_id sysc_match_table
[] = {
1629 { .compatible
= "simple-bus", },
1633 static int sysc_probe(struct platform_device
*pdev
)
1635 struct ti_sysc_platform_data
*pdata
= dev_get_platdata(&pdev
->dev
);
1639 ddata
= devm_kzalloc(&pdev
->dev
, sizeof(*ddata
), GFP_KERNEL
);
1643 ddata
->dev
= &pdev
->dev
;
1644 platform_set_drvdata(pdev
, ddata
);
1646 error
= sysc_init_match(ddata
);
1650 error
= sysc_init_dts_quirks(ddata
);
1654 error
= sysc_get_clocks(ddata
);
1658 error
= sysc_map_and_check_registers(ddata
);
1662 error
= sysc_init_sysc_mask(ddata
);
1666 error
= sysc_init_idlemodes(ddata
);
1670 error
= sysc_init_syss_mask(ddata
);
1674 error
= sysc_init_pdata(ddata
);
1678 error
= sysc_init_resets(ddata
);
1682 pm_runtime_enable(ddata
->dev
);
1683 error
= sysc_init_module(ddata
);
1687 error
= pm_runtime_get_sync(ddata
->dev
);
1689 pm_runtime_put_noidle(ddata
->dev
);
1690 pm_runtime_disable(ddata
->dev
);
1694 sysc_show_registers(ddata
);
1696 ddata
->dev
->type
= &sysc_device_type
;
1697 error
= of_platform_populate(ddata
->dev
->of_node
, sysc_match_table
,
1698 pdata
? pdata
->auxdata
: NULL
,
1703 INIT_DELAYED_WORK(&ddata
->idle_work
, ti_sysc_idle
);
1705 /* At least earlycon won't survive without deferred idle */
1706 if (ddata
->cfg
.quirks
& (SYSC_QUIRK_NO_IDLE_ON_INIT
|
1707 SYSC_QUIRK_NO_RESET_ON_INIT
)) {
1708 schedule_delayed_work(&ddata
->idle_work
, 3000);
1710 pm_runtime_put(&pdev
->dev
);
1713 if (!of_get_available_child_count(ddata
->dev
->of_node
))
1714 reset_control_assert(ddata
->rsts
);
1719 pm_runtime_put_sync(&pdev
->dev
);
1720 pm_runtime_disable(&pdev
->dev
);
1722 sysc_unprepare(ddata
);
1727 static int sysc_remove(struct platform_device
*pdev
)
1729 struct sysc
*ddata
= platform_get_drvdata(pdev
);
1732 cancel_delayed_work_sync(&ddata
->idle_work
);
1734 error
= pm_runtime_get_sync(ddata
->dev
);
1736 pm_runtime_put_noidle(ddata
->dev
);
1737 pm_runtime_disable(ddata
->dev
);
1741 of_platform_depopulate(&pdev
->dev
);
1743 pm_runtime_put_sync(&pdev
->dev
);
1744 pm_runtime_disable(&pdev
->dev
);
1745 reset_control_assert(ddata
->rsts
);
1748 sysc_unprepare(ddata
);
1753 static const struct of_device_id sysc_match
[] = {
1754 { .compatible
= "ti,sysc-omap2", .data
= &sysc_omap2
, },
1755 { .compatible
= "ti,sysc-omap2-timer", .data
= &sysc_omap2_timer
, },
1756 { .compatible
= "ti,sysc-omap4", .data
= &sysc_omap4
, },
1757 { .compatible
= "ti,sysc-omap4-timer", .data
= &sysc_omap4_timer
, },
1758 { .compatible
= "ti,sysc-omap4-simple", .data
= &sysc_omap4_simple
, },
1759 { .compatible
= "ti,sysc-omap3430-sr", .data
= &sysc_34xx_sr
, },
1760 { .compatible
= "ti,sysc-omap3630-sr", .data
= &sysc_36xx_sr
, },
1761 { .compatible
= "ti,sysc-omap4-sr", .data
= &sysc_omap4_sr
, },
1762 { .compatible
= "ti,sysc-omap3-sham", .data
= &sysc_omap3_sham
, },
1763 { .compatible
= "ti,sysc-omap-aes", .data
= &sysc_omap3_aes
, },
1764 { .compatible
= "ti,sysc-mcasp", .data
= &sysc_omap4_mcasp
, },
1765 { .compatible
= "ti,sysc-dra7-mcasp", .data
= &sysc_dra7_mcasp
, },
1766 { .compatible
= "ti,sysc-usb-host-fs",
1767 .data
= &sysc_omap4_usb_host_fs
, },
1768 { .compatible
= "ti,sysc-dra7-mcan", .data
= &sysc_dra7_mcan
, },
1771 MODULE_DEVICE_TABLE(of
, sysc_match
);
1773 static struct platform_driver sysc_driver
= {
1774 .probe
= sysc_probe
,
1775 .remove
= sysc_remove
,
1778 .of_match_table
= sysc_match
,
1783 static int __init
sysc_init(void)
1785 bus_register_notifier(&platform_bus_type
, &sysc_nb
);
1787 return platform_driver_register(&sysc_driver
);
1789 module_init(sysc_init
);
1791 static void __exit
sysc_exit(void)
1793 bus_unregister_notifier(&platform_bus_type
, &sysc_nb
);
1794 platform_driver_unregister(&sysc_driver
);
1796 module_exit(sysc_exit
);
1798 MODULE_DESCRIPTION("TI sysc interconnect target driver");
1799 MODULE_LICENSE("GPL v2");