Lines Matching +full:pruss +full:- +full:cfg
1 // SPDX-License-Identifier: GPL-2.0
3 * ti-sysc.c - Texas Instruments sysc interconnect target driver
24 #include <linux/platform_data/ti-sysc.h>
26 #include <dt-bindings/bus/ti-sysc.h>
95 * struct sysc - TI sysc interconnect target module registers and capabilities
101 * @mdata: ti-sysc to hwmod translation data for a module
108 * @cfg: interconnect target module configuration
118 * @pre_reset_quirk: module specific pre-reset quirk
119 * @post_reset_quirk: module specific post-reset quirk
139 struct sysc_config cfg; member
162 if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { in sysc_write()
163 writew_relaxed(value & 0xffff, ddata->module_va + offset); in sysc_write()
166 if (ddata->offsets[SYSC_REVISION] >= 0 && in sysc_write()
167 offset == ddata->offsets[SYSC_REVISION]) { in sysc_write()
170 writew_relaxed(hi, ddata->module_va + offset + 4); in sysc_write()
176 writel_relaxed(value, ddata->module_va + offset); in sysc_write()
181 if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { in sysc_read()
184 val = readw_relaxed(ddata->module_va + offset); in sysc_read()
187 if (ddata->offsets[SYSC_REVISION] >= 0 && in sysc_read()
188 offset == ddata->offsets[SYSC_REVISION]) { in sysc_read()
189 u16 tmp = readw_relaxed(ddata->module_va + offset + 4); in sysc_read()
197 return readl_relaxed(ddata->module_va + offset); in sysc_read()
202 return !!(ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_NEEDED); in sysc_opt_clks_needed()
207 int offset = ddata->offsets[SYSC_REVISION]; in sysc_read_revision()
217 int offset = ddata->offsets[SYSC_SYSCONFIG]; in sysc_read_sysconfig()
227 int offset = ddata->offsets[SYSC_SYSSTATUS]; in sysc_read_sysstatus()
240 if (ddata->cfg.quirks & SYSS_QUIRK_RESETDONE_INVERTED) in sysc_poll_reset_sysstatus()
243 syss_done = ddata->cfg.syss_mask; in sysc_poll_reset_sysstatus()
247 rstval, (rstval & ddata->cfg.syss_mask) == in sysc_poll_reset_sysstatus()
251 while (retries--) { in sysc_poll_reset_sysstatus()
253 if ((rstval & ddata->cfg.syss_mask) == syss_done) in sysc_poll_reset_sysstatus()
257 error = -ETIMEDOUT; in sysc_poll_reset_sysstatus()
268 sysc_mask = BIT(ddata->cap->regbits->srst_shift); in sysc_poll_reset_sysconfig()
276 while (retries--) { in sysc_poll_reset_sysconfig()
282 error = -ETIMEDOUT; in sysc_poll_reset_sysconfig()
293 if (ddata->cap->regbits->srst_shift < 0) in sysc_wait_softreset()
296 syss_offset = ddata->offsets[SYSC_SYSSTATUS]; in sysc_wait_softreset()
300 else if (ddata->cfg.quirks & SYSC_QUIRK_RESET_STATUS) in sysc_wait_softreset()
310 struct device_node *np = ddata->dev->of_node; in sysc_add_named_clock_from_child()
331 return -ENODEV; in sysc_add_named_clock_from_child()
333 clock = devm_get_clk_from_child(ddata->dev, child, name); in sysc_add_named_clock_from_child()
344 return -ENOMEM; in sysc_add_named_clock_from_child()
346 cl->con_id = n; in sysc_add_named_clock_from_child()
347 cl->dev_id = dev_name(ddata->dev); in sysc_add_named_clock_from_child()
348 cl->clk = clock; in sysc_add_named_clock_from_child()
361 if (ddata->nr_clocks < SYSC_OPTFCK0) in sysc_init_ext_opt_clock()
364 index = ddata->nr_clocks; in sysc_init_ext_opt_clock()
375 ddata->clock_roles[index] = optfck_name; in sysc_init_ext_opt_clock()
376 ddata->nr_clocks++; in sysc_init_ext_opt_clock()
383 int error, i, index = -ENODEV; in sysc_get_one_clock()
392 if (!ddata->clocks[i]) { in sysc_get_one_clock()
400 dev_err(ddata->dev, "clock %s not added\n", name); in sysc_get_one_clock()
404 ddata->clocks[index] = devm_clk_get(ddata->dev, name); in sysc_get_one_clock()
405 if (IS_ERR(ddata->clocks[index])) { in sysc_get_one_clock()
406 dev_err(ddata->dev, "clock get error for %s: %li\n", in sysc_get_one_clock()
407 name, PTR_ERR(ddata->clocks[index])); in sysc_get_one_clock()
409 return PTR_ERR(ddata->clocks[index]); in sysc_get_one_clock()
412 error = clk_prepare(ddata->clocks[index]); in sysc_get_one_clock()
414 dev_err(ddata->dev, "clock prepare error for %s: %i\n", in sysc_get_one_clock()
425 struct device_node *np = ddata->dev->of_node; in sysc_get_clocks()
430 ddata->clock_roles = devm_kcalloc(ddata->dev, in sysc_get_clocks()
432 sizeof(*ddata->clock_roles), in sysc_get_clocks()
434 if (!ddata->clock_roles) in sysc_get_clocks()
435 return -ENOMEM; in sysc_get_clocks()
437 of_property_for_each_string(np, "clock-names", prop, name) { in sysc_get_clocks()
442 ddata->clock_roles[ddata->nr_clocks] = name; in sysc_get_clocks()
443 ddata->nr_clocks++; in sysc_get_clocks()
446 if (ddata->nr_clocks < 1) in sysc_get_clocks()
449 if ((ddata->cfg.quirks & SYSC_QUIRK_EXT_OPT_CLOCK)) { in sysc_get_clocks()
455 if (ddata->nr_clocks > SYSC_MAX_CLOCKS) { in sysc_get_clocks()
456 dev_err(ddata->dev, "too many clocks for %pOF\n", np); in sysc_get_clocks()
458 return -EINVAL; in sysc_get_clocks()
462 dev_err(ddata->dev, "max one fck and ick for %pOF\n", np); in sysc_get_clocks()
464 return -EINVAL; in sysc_get_clocks()
469 ddata->nr_clocks++; in sysc_get_clocks()
471 ddata->nr_clocks++; in sysc_get_clocks()
473 ddata->clocks = devm_kcalloc(ddata->dev, in sysc_get_clocks()
474 ddata->nr_clocks, sizeof(*ddata->clocks), in sysc_get_clocks()
476 if (!ddata->clocks) in sysc_get_clocks()
477 return -ENOMEM; in sysc_get_clocks()
480 const char *name = ddata->clock_roles[i]; in sysc_get_clocks()
498 if (!ddata->clocks) in sysc_enable_main_clocks()
502 clock = ddata->clocks[i]; in sysc_enable_main_clocks()
516 for (i--; i >= 0; i--) { in sysc_enable_main_clocks()
517 clock = ddata->clocks[i]; in sysc_enable_main_clocks()
534 if (!ddata->clocks) in sysc_disable_main_clocks()
538 clock = ddata->clocks[i]; in sysc_disable_main_clocks()
551 if (!ddata->clocks || ddata->nr_clocks < SYSC_OPTFCK0 + 1) in sysc_enable_opt_clocks()
555 clock = ddata->clocks[i]; in sysc_enable_opt_clocks()
569 for (i--; i >= 0; i--) { in sysc_enable_opt_clocks()
570 clock = ddata->clocks[i]; in sysc_enable_opt_clocks()
585 if (!ddata->clocks || ddata->nr_clocks < SYSC_OPTFCK0 + 1) in sysc_disable_opt_clocks()
589 clock = ddata->clocks[i]; in sysc_disable_opt_clocks()
603 if (ddata->legacy_mode || (ddata->cfg.quirks & SYSC_QUIRK_CLKDM_NOAUTO)) in sysc_clkdm_deny_idle()
606 pdata = dev_get_platdata(ddata->dev); in sysc_clkdm_deny_idle()
607 if (pdata && pdata->clkdm_deny_idle) in sysc_clkdm_deny_idle()
608 pdata->clkdm_deny_idle(ddata->dev, &ddata->cookie); in sysc_clkdm_deny_idle()
615 if (ddata->legacy_mode || (ddata->cfg.quirks & SYSC_QUIRK_CLKDM_NOAUTO)) in sysc_clkdm_allow_idle()
618 pdata = dev_get_platdata(ddata->dev); in sysc_clkdm_allow_idle()
619 if (pdata && pdata->clkdm_allow_idle) in sysc_clkdm_allow_idle()
620 pdata->clkdm_allow_idle(ddata->dev, &ddata->cookie); in sysc_clkdm_allow_idle()
624 * sysc_init_resets - init rstctrl reset line if configured
631 ddata->rsts = in sysc_init_resets()
632 devm_reset_control_get_optional_shared(ddata->dev, "rstctrl"); in sysc_init_resets()
634 return PTR_ERR_OR_ZERO(ddata->rsts); in sysc_init_resets()
638 * sysc_parse_and_check_child_range - parses module IO region from ranges
648 struct device_node *np = ddata->dev->of_node; in sysc_parse_and_check_child_range()
655 dev_err(ddata->dev, "missing ranges for %pOF\n", np); in sysc_parse_and_check_child_range()
657 return -ENOENT; in sysc_parse_and_check_child_range()
663 dev_err(ddata->dev, "incomplete ranges for %pOF\n", np); in sysc_parse_and_check_child_range()
665 return -EINVAL; in sysc_parse_and_check_child_range()
668 error = of_property_read_u32(np, "#address-cells", &nr_addr); in sysc_parse_and_check_child_range()
670 return -ENOENT; in sysc_parse_and_check_child_range()
672 error = of_property_read_u32(np, "#size-cells", &nr_size); in sysc_parse_and_check_child_range()
674 return -ENOENT; in sysc_parse_and_check_child_range()
677 dev_err(ddata->dev, "invalid ranges for %pOF\n", np); in sysc_parse_and_check_child_range()
679 return -EINVAL; in sysc_parse_and_check_child_range()
683 ddata->module_pa = of_translate_address(np, ranges++); in sysc_parse_and_check_child_range()
684 ddata->module_size = be32_to_cpup(ranges); in sysc_parse_and_check_child_range()
704 * sysc_defer_non_critical - defer non_critical interconnect probing
721 if (ddata->module_pa >= res->start && in sysc_defer_non_critical()
722 ddata->module_pa <= res->end) { in sysc_defer_non_critical()
731 return -EPROBE_DEFER; in sysc_defer_non_critical()
751 uart = of_get_property(np, "stdout-path", NULL); in sysc_init_stdout_path()
764 stdout_path = ERR_PTR(-ENODEV); in sysc_init_stdout_path()
774 ddata->cfg.quirks |= SYSC_QUIRK_NO_IDLE_ON_INIT | in sysc_check_quirk_stdout()
779 * sysc_check_one_child - check child configuration
794 dev_warn(ddata->dev, "really a child ti,hwmods property?"); in sysc_check_one_child()
804 for_each_child_of_node(ddata->dev->of_node, child) in sysc_check_children()
809 * So far only I2C uses 16-bit read access with clockactivity with revision
817 ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT; in sysc_check_quirk_16bit()
821 * sysc_parse_one - parses the interconnect target module registers
837 return -EINVAL; in sysc_parse_one()
840 res = platform_get_resource_byname(to_platform_device(ddata->dev), in sysc_parse_one()
843 ddata->offsets[reg] = -ENODEV; in sysc_parse_one()
848 ddata->offsets[reg] = res->start - ddata->module_pa; in sysc_parse_one()
869 * sysc_check_registers - check for misconfigured register overlaps
877 if (ddata->offsets[i] < 0) in sysc_check_registers()
880 if (ddata->offsets[i] > (ddata->module_size - 4)) { in sysc_check_registers()
881 dev_err(ddata->dev, "register outside module range"); in sysc_check_registers()
883 return -EINVAL; in sysc_check_registers()
887 if (ddata->offsets[j] < 0) in sysc_check_registers()
890 if (ddata->offsets[i] == ddata->offsets[j]) in sysc_check_registers()
897 dev_err(ddata->dev, "overlapping registers: (%i/%i)", in sysc_check_registers()
900 return -EINVAL; in sysc_check_registers()
907 * syc_ioremap - ioremap register space for the interconnect target module
921 if (ddata->offsets[SYSC_REVISION] < 0 && in sysc_ioremap()
922 ddata->offsets[SYSC_SYSCONFIG] < 0 && in sysc_ioremap()
923 ddata->offsets[SYSC_SYSSTATUS] < 0) { in sysc_ioremap()
924 size = ddata->module_size; in sysc_ioremap()
926 size = max3(ddata->offsets[SYSC_REVISION], in sysc_ioremap()
927 ddata->offsets[SYSC_SYSCONFIG], in sysc_ioremap()
928 ddata->offsets[SYSC_SYSSTATUS]); in sysc_ioremap()
933 if ((size + sizeof(u32)) > ddata->module_size) in sysc_ioremap()
934 size = ddata->module_size; in sysc_ioremap()
937 ddata->module_va = devm_ioremap(ddata->dev, in sysc_ioremap()
938 ddata->module_pa, in sysc_ioremap()
940 if (!ddata->module_va) in sysc_ioremap()
941 return -EIO; in sysc_ioremap()
947 * sysc_map_and_check_registers - ioremap and check device registers
980 * sysc_show_rev - read and show interconnect target module revision
988 if (ddata->offsets[SYSC_REVISION] < 0) in sysc_show_rev()
991 len = sprintf(bufp, ":%08x", ddata->revision); in sysc_show_rev()
999 if (ddata->offsets[reg] < 0) in sysc_show_reg()
1002 return sprintf(bufp, ":%x", ddata->offsets[reg]); in sysc_show_reg()
1007 if (!ddata->name) in sysc_show_name()
1010 return sprintf(bufp, ":%s", ddata->name); in sysc_show_name()
1014 * sysc_show_registers - show information about interconnect target module
1029 dev_dbg(ddata->dev, "%llx:%x%s\n", in sysc_show_registers()
1030 ddata->module_pa, ddata->module_size, in sysc_show_registers()
1035 * sysc_write_sysconfig - handle sysconfig quirks for register write
1041 if (ddata->module_unlock_quirk) in sysc_write_sysconfig()
1042 ddata->module_unlock_quirk(ddata); in sysc_write_sysconfig()
1044 sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], value); in sysc_write_sysconfig()
1046 if (ddata->module_lock_quirk) in sysc_write_sysconfig()
1047 ddata->module_lock_quirk(ddata); in sysc_write_sysconfig()
1050 #define SYSC_IDLE_MASK (SYSC_NR_IDLEMODES - 1)
1067 if (ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_IN_RESET) { in sysc_enable_module()
1070 dev_err(ddata->dev, in sysc_enable_module()
1080 if (!(ddata->cfg.quirks & SYSC_MODULE_QUIRK_ENA_RESETDONE)) { in sysc_enable_module()
1083 dev_warn(ddata->dev, "OCP softreset timed out\n"); in sysc_enable_module()
1085 if (ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_IN_RESET) in sysc_enable_module()
1093 if (ddata->offsets[SYSC_SYSCONFIG] == -ENODEV) in sysc_enable_module()
1096 regbits = ddata->cap->regbits; in sysc_enable_module()
1097 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_enable_module()
1104 if (regbits->clkact_shift >= 0 && in sysc_enable_module()
1105 (ddata->cfg.quirks & SYSC_QUIRK_USE_CLOCKACT)) in sysc_enable_module()
1106 reg |= SYSC_CLOCACT_ICK << regbits->clkact_shift; in sysc_enable_module()
1109 idlemodes = ddata->cfg.sidlemodes; in sysc_enable_module()
1110 if (!idlemodes || regbits->sidle_shift < 0) in sysc_enable_module()
1113 if (ddata->cfg.quirks & (SYSC_QUIRK_SWSUP_SIDLE | in sysc_enable_module()
1117 best_mode = fls(ddata->cfg.sidlemodes) - 1; in sysc_enable_module()
1120 return -EINVAL; in sysc_enable_module()
1124 if (regbits->enwkup_shift >= 0 && in sysc_enable_module()
1125 ddata->cfg.sysc_val & BIT(regbits->enwkup_shift)) in sysc_enable_module()
1126 reg |= BIT(regbits->enwkup_shift); in sysc_enable_module()
1129 reg &= ~(SYSC_IDLE_MASK << regbits->sidle_shift); in sysc_enable_module()
1130 reg |= best_mode << regbits->sidle_shift; in sysc_enable_module()
1135 idlemodes = ddata->cfg.midlemodes; in sysc_enable_module()
1136 if (!idlemodes || regbits->midle_shift < 0) in sysc_enable_module()
1139 best_mode = fls(ddata->cfg.midlemodes) - 1; in sysc_enable_module()
1142 return -EINVAL; in sysc_enable_module()
1145 if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_MSTANDBY) in sysc_enable_module()
1148 reg &= ~(SYSC_IDLE_MASK << regbits->midle_shift); in sysc_enable_module()
1149 reg |= best_mode << regbits->midle_shift; in sysc_enable_module()
1154 if (regbits->autoidle_shift >= 0 && in sysc_enable_module()
1155 ddata->cfg.sysc_val & BIT(regbits->autoidle_shift)) { in sysc_enable_module()
1156 reg |= 1 << regbits->autoidle_shift; in sysc_enable_module()
1161 sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_enable_module()
1163 if (ddata->module_enable_quirk) in sysc_enable_module()
1164 ddata->module_enable_quirk(ddata); in sysc_enable_module()
1178 return -EINVAL; in sysc_best_idle_mode()
1192 if (ddata->offsets[SYSC_SYSCONFIG] == -ENODEV) in sysc_disable_module()
1195 if (ddata->module_disable_quirk) in sysc_disable_module()
1196 ddata->module_disable_quirk(ddata); in sysc_disable_module()
1198 regbits = ddata->cap->regbits; in sysc_disable_module()
1199 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_disable_module()
1202 idlemodes = ddata->cfg.midlemodes; in sysc_disable_module()
1203 if (!idlemodes || regbits->midle_shift < 0) in sysc_disable_module()
1212 if (ddata->cfg.quirks & (SYSC_QUIRK_SWSUP_MSTANDBY) || in sysc_disable_module()
1213 ddata->cfg.quirks & (SYSC_QUIRK_FORCE_MSTANDBY)) in sysc_disable_module()
1216 reg &= ~(SYSC_IDLE_MASK << regbits->midle_shift); in sysc_disable_module()
1217 reg |= best_mode << regbits->midle_shift; in sysc_disable_module()
1222 idlemodes = ddata->cfg.sidlemodes; in sysc_disable_module()
1223 if (!idlemodes || regbits->sidle_shift < 0) in sysc_disable_module()
1226 if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_SIDLE) { in sysc_disable_module()
1236 reg &= ~(SYSC_IDLE_MASK << regbits->sidle_shift); in sysc_disable_module()
1237 reg |= best_mode << regbits->sidle_shift; in sysc_disable_module()
1238 if (regbits->autoidle_shift >= 0 && in sysc_disable_module()
1239 ddata->cfg.sysc_val & BIT(regbits->autoidle_shift)) in sysc_disable_module()
1240 reg |= 1 << regbits->autoidle_shift; in sysc_disable_module()
1244 sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_disable_module()
1255 pdata = dev_get_platdata(ddata->dev); in sysc_runtime_suspend_legacy()
1259 if (!pdata->idle_module) in sysc_runtime_suspend_legacy()
1260 return -ENODEV; in sysc_runtime_suspend_legacy()
1262 error = pdata->idle_module(dev, &ddata->cookie); in sysc_runtime_suspend_legacy()
1267 reset_control_assert(ddata->rsts); in sysc_runtime_suspend_legacy()
1278 pdata = dev_get_platdata(ddata->dev); in sysc_runtime_resume_legacy()
1282 if (!pdata->enable_module) in sysc_runtime_resume_legacy()
1283 return -ENODEV; in sysc_runtime_resume_legacy()
1285 error = pdata->enable_module(dev, &ddata->cookie); in sysc_runtime_resume_legacy()
1290 reset_control_deassert(ddata->rsts); in sysc_runtime_resume_legacy()
1302 if (!ddata->enabled) in sysc_runtime_suspend()
1307 if (ddata->legacy_mode) { in sysc_runtime_suspend()
1322 ddata->enabled = false; in sysc_runtime_suspend()
1325 reset_control_assert(ddata->rsts); in sysc_runtime_suspend()
1339 if (ddata->enabled) in sysc_runtime_resume()
1355 reset_control_deassert(ddata->rsts); in sysc_runtime_resume()
1357 if (ddata->legacy_mode) { in sysc_runtime_resume()
1367 ddata->enabled = true; in sysc_runtime_resume()
1386 struct device *dev = ddata->dev; in sysc_reinit_module()
1390 if (ddata->enabled) { in sysc_reinit_module()
1418 if (ddata->cfg.quirks & in sysc_noirq_suspend()
1422 if (!ddata->enabled) in sysc_noirq_suspend()
1425 ddata->needs_resume = 1; in sysc_noirq_suspend()
1437 if (ddata->cfg.quirks & in sysc_noirq_resume()
1441 if (ddata->cfg.quirks & SYSC_QUIRK_REINIT_ON_RESUME) { in sysc_noirq_resume()
1442 error = sysc_reinit_module(ddata, ddata->needs_resume); in sysc_noirq_resume()
1445 } else if (ddata->needs_resume) { in sysc_noirq_resume()
1451 ddata->needs_resume = 0; in sysc_noirq_resume()
1494 SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x24, -ENODEV, 0x00000000, 0xffffffff,
1496 SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x38, -ENODEV, 0x00000000, 0xffffffff,
1509 SYSC_QUIRK("mcpdm", 0x40132000, 0, 0x10, -ENODEV, 0x50000800, 0xffffffff,
1514 SYSC_QUIRK("aess", 0, 0, 0x10, -ENODEV, 0x40000000, 0xffffffff,
1517 SYSC_QUIRK("dcan", 0x4ae3c000, 0x20, -ENODEV, -ENODEV, 0xa3170504, 0xffffffff,
1519 SYSC_QUIRK("dcan", 0x48480000, 0x20, -ENODEV, -ENODEV, 0xa3170504, 0xffffffff,
1523 SYSC_QUIRK("dss", 0x58000000, 0, -ENODEV, 0x14, 0x00000040, 0xffffffff,
1525 SYSC_QUIRK("dss", 0x58000000, 0, -ENODEV, 0x14, 0x00000061, 0xffffffff,
1527 SYSC_QUIRK("dwc3", 0x48880000, 0, 0x10, -ENODEV, 0x500a0200, 0xffffffff,
1529 SYSC_QUIRK("dwc3", 0x488c0000, 0, 0x10, -ENODEV, 0x500a0200, 0xffffffff,
1533 SYSC_QUIRK("hdmi", 0, 0, 0x10, -ENODEV, 0x50030200, 0xffffffff,
1547 SYSC_QUIRK("gpu", 0x50000000, 0x14, -ENODEV, -ENODEV, 0x00010201, 0xffffffff, 0),
1548 SYSC_QUIRK("gpu", 0x50000000, 0xfe00, 0xfe10, -ENODEV, 0x40000000 , 0xffffffff,
1550 SYSC_QUIRK("lcdc", 0, 0, 0x54, -ENODEV, 0x4f201000, 0xffffffff,
1552 SYSC_QUIRK("rtc", 0, 0x74, 0x78, -ENODEV, 0x4eb01908, 0xffff00f0,
1554 SYSC_QUIRK("tptc", 0, 0, 0x10, -ENODEV, 0x40006c00, 0xffffefff,
1556 SYSC_QUIRK("tptc", 0, 0, -ENODEV, -ENODEV, 0x40007c00, 0xffffffff,
1560 SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -ENODEV, 0x50700101, 0xffffffff,
1564 SYSC_QUIRK("usb_otg_hs", 0, 0, 0x10, -ENODEV, 0x4ea2080d, 0xffffffff,
1569 /* PRUSS on am3, am4 and am5 */
1570 SYSC_QUIRK("pruss", 0, 0x26000, 0x26004, -ENODEV, 0x47000000, 0xff000000,
1577 SYSC_QUIRK("adc", 0, 0, 0x10, -ENODEV, 0x47300001, 0xffffffff, 0),
1578 SYSC_QUIRK("atl", 0, 0, -ENODEV, -ENODEV, 0x0a070100, 0xffffffff, 0),
1579 SYSC_QUIRK("cm", 0, 0, -ENODEV, -ENODEV, 0x40000301, 0xffffffff, 0),
1580 SYSC_QUIRK("control", 0, 0, 0x10, -ENODEV, 0x40000900, 0xffffffff, 0),
1583 SYSC_QUIRK("dcan", 0, 0x20, -ENODEV, -ENODEV, 0xa3170504, 0xffffffff, 0),
1584 SYSC_QUIRK("dcan", 0, 0x20, -ENODEV, -ENODEV, 0x4edb1902, 0xffffffff, 0),
1588 SYSC_QUIRK("dmic", 0, 0, 0x10, -ENODEV, 0x50010000, 0xffffffff, 0),
1593 SYSC_QUIRK("dwc3", 0, 0, 0x10, -ENODEV, 0x500a0200, 0xffffffff, 0),
1596 SYSC_QUIRK("epwmss", 0, 0, 0x4, -ENODEV, 0x47400001, 0xffffffff, 0),
1597 SYSC_QUIRK("gpu", 0, 0x1fc00, 0x1fc10, -ENODEV, 0, 0, 0),
1598 SYSC_QUIRK("gpu", 0, 0xfe00, 0xfe10, -ENODEV, 0x40000000 , 0xffffffff, 0),
1599 SYSC_QUIRK("hdmi", 0, 0, 0x10, -ENODEV, 0x50031d00, 0xffffffff, 0),
1601 SYSC_QUIRK("iss", 0, 0, 0x10, -ENODEV, 0x40000101, 0xffffffff, 0),
1602 SYSC_QUIRK("mcasp", 0, 0, 0x4, -ENODEV, 0x44306302, 0xffffffff, 0),
1603 SYSC_QUIRK("mcasp", 0, 0, 0x4, -ENODEV, 0x44307b02, 0xffffffff, 0),
1604 SYSC_QUIRK("mcbsp", 0, -ENODEV, 0x8c, -ENODEV, 0, 0, 0),
1605 SYSC_QUIRK("mcspi", 0, 0, 0x10, -ENODEV, 0x40300a0b, 0xffff00ff, 0),
1607 SYSC_QUIRK("mailbox", 0, 0, 0x10, -ENODEV, 0x00000400, 0xffffffff, 0),
1608 SYSC_QUIRK("m3", 0, 0, -ENODEV, -ENODEV, 0x5f580105, 0x0fff0f00, 0),
1610 SYSC_QUIRK("ocp2scp", 0, 0, -ENODEV, -ENODEV, 0x50060007, 0xffffffff, 0),
1611 SYSC_QUIRK("padconf", 0, 0, 0x10, -ENODEV, 0x4fff0800, 0xffffffff, 0),
1612 SYSC_QUIRK("padconf", 0, 0, -ENODEV, -ENODEV, 0x40001100, 0xffffffff, 0),
1613 SYSC_QUIRK("prcm", 0, 0, -ENODEV, -ENODEV, 0x40000100, 0xffffffff, 0),
1614 SYSC_QUIRK("prcm", 0, 0, -ENODEV, -ENODEV, 0x00004102, 0xffffffff, 0),
1615 SYSC_QUIRK("prcm", 0, 0, -ENODEV, -ENODEV, 0x40000400, 0xffffffff, 0),
1618 SYSC_QUIRK("scm", 0, 0, 0x10, -ENODEV, 0x40000900, 0xffffffff, 0),
1619 SYSC_QUIRK("scm", 0, 0, -ENODEV, -ENODEV, 0x4e8b0100, 0xffffffff, 0),
1620 SYSC_QUIRK("scm", 0, 0, -ENODEV, -ENODEV, 0x4f000100, 0xffffffff, 0),
1621 SYSC_QUIRK("scm", 0, 0, -ENODEV, -ENODEV, 0x40000900, 0xffffffff, 0),
1622 SYSC_QUIRK("scrm", 0, 0, -ENODEV, -ENODEV, 0x00000010, 0xffffffff, 0),
1623 SYSC_QUIRK("sdio", 0, 0, 0x10, -ENODEV, 0x40202301, 0xffff0ff0, 0),
1626 SYSC_QUIRK("slimbus", 0, 0, 0x10, -ENODEV, 0x40000902, 0xffffffff, 0),
1627 SYSC_QUIRK("slimbus", 0, 0, 0x10, -ENODEV, 0x40002903, 0xffffffff, 0),
1628 SYSC_QUIRK("spinlock", 0, 0, 0x10, -ENODEV, 0x50020000, 0xffffffff, 0),
1629 SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -ENODEV, 0x00000020, 0xffffffff, 0),
1633 SYSC_QUIRK("timer", 0, 0, 0x10, -ENODEV, 0x50002100, 0xffffffff, 0),
1634 SYSC_QUIRK("timer", 0, 0, 0x10, -ENODEV, 0x4fff1301, 0xffff00ff, 0),
1635 SYSC_QUIRK("timer32k", 0, 0, 0x4, -ENODEV, 0x00000040, 0xffffffff, 0),
1636 SYSC_QUIRK("timer32k", 0, 0, 0x4, -ENODEV, 0x00000011, 0xffffffff, 0),
1637 SYSC_QUIRK("timer32k", 0, 0, 0x4, -ENODEV, 0x00000060, 0xffffffff, 0),
1638 SYSC_QUIRK("tpcc", 0, 0, -ENODEV, -ENODEV, 0x40014c00, 0xffffffff, 0),
1641 SYSC_QUIRK("venc", 0x58003000, 0, -ENODEV, -ENODEV, 0x00000002, 0xffffffff, 0),
1642 SYSC_QUIRK("vfpe", 0, 0, 0x104, -ENODEV, 0x4d001200, 0xffffffff, 0),
1658 if (!q->base) in sysc_init_early_quirks()
1661 if (q->base != ddata->module_pa) in sysc_init_early_quirks()
1664 if (q->rev_offset != ddata->offsets[SYSC_REVISION]) in sysc_init_early_quirks()
1667 if (q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG]) in sysc_init_early_quirks()
1670 if (q->syss_offset != ddata->offsets[SYSC_SYSSTATUS]) in sysc_init_early_quirks()
1673 ddata->name = q->name; in sysc_init_early_quirks()
1674 ddata->cfg.quirks |= q->quirks; in sysc_init_early_quirks()
1687 if (q->base && q->base != ddata->module_pa) in sysc_init_revision_quirks()
1690 if (q->rev_offset != ddata->offsets[SYSC_REVISION]) in sysc_init_revision_quirks()
1693 if (q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG]) in sysc_init_revision_quirks()
1696 if (q->syss_offset != ddata->offsets[SYSC_SYSSTATUS]) in sysc_init_revision_quirks()
1699 if (q->revision == ddata->revision || in sysc_init_revision_quirks()
1700 (q->revision & q->revision_mask) == in sysc_init_revision_quirks()
1701 (ddata->revision & q->revision_mask)) { in sysc_init_revision_quirks()
1702 ddata->name = q->name; in sysc_init_revision_quirks()
1703 ddata->cfg.quirks |= q->quirks; in sysc_init_revision_quirks()
1711 * dispc init rather than top-level DSS init.
1722 switch (sysc_soc->soc) { in sysc_quirk_dispc()
1744 devm_iounmap(ddata->dev, ddata->module_va); in sysc_quirk_dispc()
1745 ddata->module_va = devm_ioremap(ddata->dev, in sysc_quirk_dispc()
1746 ddata->module_pa, in sysc_quirk_dispc()
1747 ddata->module_size); in sysc_quirk_dispc()
1748 if (!ddata->module_va) in sysc_quirk_dispc()
1749 return -EIO; in sysc_quirk_dispc()
1813 error = readl_poll_timeout(ddata->module_va + dispc_offset + 0x18, in sysc_pre_reset_quirk_dss()
1816 dev_warn(ddata->dev, "%s: timed out %08x !+ %08x\n", in sysc_pre_reset_quirk_dss()
1819 if (sysc_soc->soc == SOC_3430) { in sysc_pre_reset_quirk_dss()
1831 /* 1-wire needs module's internal clocks enabled for reset */
1857 if ((ddata->revision & 0xffffff00) == 0x001f0000) in sysc_clk_quirk_i2c()
1895 error = readl_poll_timeout_atomic(ddata->module_va + 0x44, val, in sysc_quirk_rtc()
1898 dev_warn(ddata->dev, "rtc busy timeout\n"); in sysc_quirk_rtc()
1934 error = readl_poll_timeout(ddata->module_va + wps, val, in sysc_reset_done_quirk_wdt()
1938 dev_warn(ddata->dev, "wdt disable step1 failed\n"); in sysc_reset_done_quirk_wdt()
1941 error = readl_poll_timeout(ddata->module_va + wps, val, in sysc_reset_done_quirk_wdt()
1945 dev_warn(ddata->dev, "wdt disable step2 failed\n"); in sysc_reset_done_quirk_wdt()
1948 /* PRUSS needs to set MSTANDBY_INIT inorder to idle properly */
1953 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_module_disable_quirk_pruss()
1955 sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); in sysc_module_disable_quirk_pruss()
1960 if (ddata->legacy_mode || !ddata->name) in sysc_init_module_quirks()
1963 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_HDQ1W) { in sysc_init_module_quirks()
1964 ddata->pre_reset_quirk = sysc_pre_reset_quirk_hdq1w; in sysc_init_module_quirks()
1970 if (ddata->cfg.quirks & SYSC_QUIRK_GPMC_DEBUG) { in sysc_init_module_quirks()
1971 ddata->cfg.quirks |= SYSC_QUIRK_NO_RESET_ON_INIT; in sysc_init_module_quirks()
1977 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_I2C) { in sysc_init_module_quirks()
1978 ddata->pre_reset_quirk = sysc_pre_reset_quirk_i2c; in sysc_init_module_quirks()
1979 ddata->post_reset_quirk = sysc_post_reset_quirk_i2c; in sysc_init_module_quirks()
1984 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_AESS) in sysc_init_module_quirks()
1985 ddata->module_enable_quirk = sysc_module_enable_quirk_aess; in sysc_init_module_quirks()
1987 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_DSS_RESET) in sysc_init_module_quirks()
1988 ddata->pre_reset_quirk = sysc_pre_reset_quirk_dss; in sysc_init_module_quirks()
1990 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_RTC_UNLOCK) { in sysc_init_module_quirks()
1991 ddata->module_unlock_quirk = sysc_module_unlock_quirk_rtc; in sysc_init_module_quirks()
1992 ddata->module_lock_quirk = sysc_module_lock_quirk_rtc; in sysc_init_module_quirks()
1997 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_SGX) in sysc_init_module_quirks()
1998 ddata->module_enable_quirk = sysc_module_enable_quirk_sgx; in sysc_init_module_quirks()
2000 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_WDT) { in sysc_init_module_quirks()
2001 ddata->reset_done_quirk = sysc_reset_done_quirk_wdt; in sysc_init_module_quirks()
2002 ddata->module_disable_quirk = sysc_reset_done_quirk_wdt; in sysc_init_module_quirks()
2005 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_PRUSS) in sysc_init_module_quirks()
2006 ddata->module_disable_quirk = sysc_module_disable_quirk_pruss; in sysc_init_module_quirks()
2011 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); in sysc_clockdomain_init()
2015 if (!pdata || !pdata->init_clockdomain) in sysc_clockdomain_init()
2018 switch (ddata->nr_clocks) { in sysc_clockdomain_init()
2020 ick = ddata->clocks[SYSC_ICK]; in sysc_clockdomain_init()
2023 fck = ddata->clocks[SYSC_FCK]; in sysc_clockdomain_init()
2029 error = pdata->init_clockdomain(ddata->dev, fck, ick, &ddata->cookie); in sysc_clockdomain_init()
2030 if (!error || error == -ENODEV) in sysc_clockdomain_init()
2037 * Note that pdata->init_module() typically does a reset first. After
2038 * pdata->init_module() is done, PM runtime can be used for the interconnect
2043 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); in sysc_legacy_init()
2046 if (!pdata || !pdata->init_module) in sysc_legacy_init()
2049 error = pdata->init_module(ddata->dev, ddata->mdata, &ddata->cookie); in sysc_legacy_init()
2050 if (error == -EEXIST) in sysc_legacy_init()
2065 sysc_offset = ddata->offsets[SYSC_SYSCONFIG]; in sysc_reset()
2067 if (ddata->legacy_mode || in sysc_reset()
2068 ddata->cap->regbits->srst_shift < 0 || in sysc_reset()
2069 ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) in sysc_reset()
2072 sysc_mask = BIT(ddata->cap->regbits->srst_shift); in sysc_reset()
2074 if (ddata->pre_reset_quirk) in sysc_reset()
2075 ddata->pre_reset_quirk(ddata); in sysc_reset()
2083 if (ddata->cfg.srst_udelay) in sysc_reset()
2084 usleep_range(ddata->cfg.srst_udelay, in sysc_reset()
2085 ddata->cfg.srst_udelay * 2); in sysc_reset()
2087 if (ddata->post_reset_quirk) in sysc_reset()
2088 ddata->post_reset_quirk(ddata); in sysc_reset()
2092 dev_warn(ddata->dev, "OCP softreset timed out\n"); in sysc_reset()
2094 if (ddata->reset_done_quirk) in sysc_reset()
2095 ddata->reset_done_quirk(ddata); in sysc_reset()
2128 if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) { in sysc_init_module()
2129 error = reset_control_deassert(ddata->rsts); in sysc_init_module()
2134 ddata->revision = sysc_read_revision(ddata); in sysc_init_module()
2138 if (ddata->legacy_mode) { in sysc_init_module()
2144 if (!ddata->legacy_mode) { in sysc_init_module()
2145 error = sysc_enable_module(ddata->dev); in sysc_init_module()
2152 dev_err(ddata->dev, "Reset failed with %d\n", error); in sysc_init_module()
2154 if (error && !ddata->legacy_mode) in sysc_init_module()
2155 sysc_disable_module(ddata->dev); in sysc_init_module()
2158 if (error && !(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) in sysc_init_module()
2159 reset_control_assert(ddata->rsts); in sysc_init_module()
2165 /* No re-enable of clockdomain autoidle to prevent module autoidle */ in sysc_init_module()
2176 struct device_node *np = ddata->dev->of_node; in sysc_init_sysc_mask()
2180 error = of_property_read_u32(np, "ti,sysc-mask", &val); in sysc_init_sysc_mask()
2184 ddata->cfg.sysc_val = val & ddata->cap->sysc_mask; in sysc_init_sysc_mask()
2192 struct device_node *np = ddata->dev->of_node; in sysc_init_idlemode()
2199 dev_err(ddata->dev, "invalid idlemode: %i\n", val); in sysc_init_idlemode()
2200 return -EINVAL; in sysc_init_idlemode()
2212 error = sysc_init_idlemode(ddata, &ddata->cfg.midlemodes, in sysc_init_idlemodes()
2213 "ti,sysc-midle"); in sysc_init_idlemodes()
2217 error = sysc_init_idlemode(ddata, &ddata->cfg.sidlemodes, in sysc_init_idlemodes()
2218 "ti,sysc-sidle"); in sysc_init_idlemodes()
2234 struct device_node *np = ddata->dev->of_node; in sysc_init_syss_mask()
2238 error = of_property_read_u32(np, "ti,syss-mask", &val); in sysc_init_syss_mask()
2240 if ((ddata->cap->type == TI_SYSC_OMAP4 || in sysc_init_syss_mask()
2241 ddata->cap->type == TI_SYSC_OMAP4_TIMER) && in sysc_init_syss_mask()
2242 (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) in sysc_init_syss_mask()
2243 ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; in sysc_init_syss_mask()
2248 if (!(val & 1) && (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) in sysc_init_syss_mask()
2249 ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; in sysc_init_syss_mask()
2251 ddata->cfg.syss_mask = val; in sysc_init_syss_mask()
2273 error = -EEXIST; in sysc_child_add_named_clock()
2277 clk = clk_get(ddata->dev, name); in sysc_child_add_named_clock()
2279 return -ENODEV; in sysc_child_add_named_clock()
2283 error = -ENOMEM; in sysc_child_add_named_clock()
2295 for (i = 0; i < ddata->nr_clocks; i++) { in sysc_child_add_clocks()
2298 ddata->clock_roles[i]); in sysc_child_add_clocks()
2299 if (error && error != -EEXIST) { in sysc_child_add_clocks()
2300 dev_err(ddata->dev, "could not add child clock %s: %i\n", in sysc_child_add_clocks()
2301 ddata->clock_roles[i], error); in sysc_child_add_clocks()
2315 struct device *parent = dev->parent; in sysc_child_to_parent()
2317 if (!parent || parent->type != &sysc_device_type) in sysc_child_to_parent()
2334 if (!ddata->enabled) in sysc_child_runtime_suspend()
2337 return sysc_runtime_suspend(ddata->dev); in sysc_child_runtime_suspend()
2347 if (!ddata->enabled) { in sysc_child_runtime_resume()
2348 error = sysc_runtime_resume(ddata->dev); in sysc_child_runtime_resume()
2350 dev_err(ddata->dev, in sysc_child_runtime_resume()
2365 dev_dbg(ddata->dev, "%s %s\n", __func__, in sysc_child_suspend_noirq()
2366 ddata->name ? ddata->name : ""); in sysc_child_suspend_noirq()
2385 error = sysc_runtime_suspend(ddata->dev); in sysc_child_suspend_noirq()
2393 ddata->child_needs_resume = true; in sysc_child_suspend_noirq()
2406 dev_dbg(ddata->dev, "%s %s\n", __func__, in sysc_child_resume_noirq()
2407 ddata->name ? ddata->name : ""); in sysc_child_resume_noirq()
2409 if (ddata->child_needs_resume) { in sysc_child_resume_noirq()
2410 ddata->child_needs_resume = false; in sysc_child_resume_noirq()
2412 error = sysc_runtime_resume(ddata->dev); in sysc_child_resume_noirq()
2414 dev_err(ddata->dev, in sysc_child_resume_noirq()
2420 dev_err(ddata->dev, in sysc_child_resume_noirq()
2447 list_for_each(pos, &sysc_soc->restored_modules) { in sysc_reinit_modules()
2449 ddata = module->ddata; in sysc_reinit_modules()
2450 sysc_reinit_module(ddata, ddata->enabled); in sysc_reinit_modules()
2455 * sysc_context_notifier - optionally reset and restore module after idle
2485 * sysc_add_restored - optionally add reset and restore quirk hanlling
2496 restored_module->ddata = ddata; in sysc_add_restored()
2498 mutex_lock(&sysc_soc->list_lock); in sysc_add_restored()
2500 list_add(&restored_module->node, &sysc_soc->restored_modules); in sysc_add_restored()
2502 if (sysc_soc->nb.notifier_call) in sysc_add_restored()
2505 sysc_soc->nb.notifier_call = sysc_context_notifier; in sysc_add_restored()
2506 cpu_pm_register_notifier(&sysc_soc->nb); in sysc_add_restored()
2509 mutex_unlock(&sysc_soc->list_lock); in sysc_add_restored()
2513 * sysc_legacy_idle_quirk - handle children in omap_device compatible way
2527 if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) in sysc_legacy_idle_quirk()
2567 { .name = "ti,no-idle-on-init",
2569 { .name = "ti,no-reset-on-init",
2571 { .name = "ti,no-idle",
2588 ddata->cfg.quirks |= sysc_dts_quirks[i].mask; in sysc_parse_dts_quirks()
2590 dev_warn(ddata->dev, in sysc_parse_dts_quirks()
2599 struct device_node *np = ddata->dev->of_node; in sysc_init_dts_quirks()
2603 ddata->legacy_mode = of_get_property(np, "ti,hwmods", NULL); in sysc_init_dts_quirks()
2606 error = of_property_read_u32(np, "ti,sysc-delay-us", &val); in sysc_init_dts_quirks()
2609 dev_warn(ddata->dev, "bad ti,sysc-delay-us: %i\n", in sysc_init_dts_quirks()
2613 ddata->cfg.srst_udelay = (u8)val; in sysc_init_dts_quirks()
2623 if (!ddata->clocks) in sysc_unprepare()
2627 if (!IS_ERR_OR_NULL(ddata->clocks[i])) in sysc_unprepare()
2628 clk_unprepare(ddata->clocks[i]); in sysc_unprepare()
2636 .dmadisable_shift = -ENODEV,
2669 .dmadisable_shift = -ENODEV,
2670 .midle_shift = -ENODEV,
2672 .clkact_shift = -ENODEV,
2673 .enwkup_shift = -ENODEV,
2676 .emufree_shift = -ENODEV,
2690 .dmadisable_shift = -ENODEV,
2691 .midle_shift = -ENODEV,
2693 .clkact_shift = -ENODEV,
2694 .enwkup_shift = -ENODEV,
2697 .emufree_shift = -ENODEV,
2713 .clkact_shift = -ENODEV,
2714 .enwkup_shift = -ENODEV,
2717 .autoidle_shift = -ENODEV,
2738 .dmadisable_shift = -ENODEV,
2741 .clkact_shift = -ENODEV,
2742 .enwkup_shift = -ENODEV,
2743 .srst_shift = -ENODEV,
2744 .emufree_shift = -ENODEV,
2745 .autoidle_shift = -ENODEV,
2757 .dmadisable_shift = -ENODEV,
2758 .midle_shift = -ENODEV,
2759 .sidle_shift = -ENODEV,
2761 .enwkup_shift = -ENODEV,
2762 .srst_shift = -ENODEV,
2763 .emufree_shift = -ENODEV,
2764 .autoidle_shift = -ENODEV,
2779 .dmadisable_shift = -ENODEV,
2780 .midle_shift = -ENODEV,
2782 .clkact_shift = -ENODEV,
2784 .srst_shift = -ENODEV,
2785 .emufree_shift = -ENODEV,
2786 .autoidle_shift = -ENODEV,
2806 .dmadisable_shift = -ENODEV,
2807 .midle_shift = -ENODEV,
2809 .clkact_shift = -ENODEV,
2810 .enwkup_shift = -ENODEV,
2811 .srst_shift = -ENODEV,
2812 .emufree_shift = -ENODEV,
2813 .autoidle_shift = -ENODEV,
2835 .dmadisable_shift = -ENODEV,
2836 .midle_shift = -ENODEV,
2838 .clkact_shift = -ENODEV,
2840 .srst_shift = -ENODEV,
2841 .emufree_shift = -ENODEV,
2842 .autoidle_shift = -ENODEV,
2852 .dmadisable_shift = -ENODEV,
2853 .midle_shift = -ENODEV,
2854 .sidle_shift = -ENODEV,
2855 .clkact_shift = -ENODEV,
2858 .emufree_shift = -ENODEV,
2859 .autoidle_shift = -ENODEV,
2870 * PRUSS found on some AM33xx, AM437x and AM57xx SoCs
2881 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); in sysc_init_pdata()
2887 mdata = devm_kzalloc(ddata->dev, sizeof(*mdata), GFP_KERNEL); in sysc_init_pdata()
2889 return -ENOMEM; in sysc_init_pdata()
2891 if (ddata->legacy_mode) { in sysc_init_pdata()
2892 mdata->name = ddata->legacy_mode; in sysc_init_pdata()
2893 mdata->module_pa = ddata->module_pa; in sysc_init_pdata()
2894 mdata->module_size = ddata->module_size; in sysc_init_pdata()
2895 mdata->offsets = ddata->offsets; in sysc_init_pdata()
2896 mdata->nr_offsets = SYSC_MAX_REGS; in sysc_init_pdata()
2897 mdata->cap = ddata->cap; in sysc_init_pdata()
2898 mdata->cfg = &ddata->cfg; in sysc_init_pdata()
2901 ddata->mdata = mdata; in sysc_init_pdata()
2910 cap = of_device_get_match_data(ddata->dev); in sysc_init_match()
2912 return -EINVAL; in sysc_init_match()
2914 ddata->cap = cap; in sysc_init_match()
2915 if (ddata->cap) in sysc_init_match()
2916 ddata->cfg.quirks |= ddata->cap->mod_quirks; in sysc_init_match()
2933 if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE | in ti_sysc_idle()
2941 if (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE) in ti_sysc_idle()
2948 if (pm_runtime_active(ddata->dev)) in ti_sysc_idle()
2949 pm_runtime_put_sync(ddata->dev); in ti_sysc_idle()
2999 return -ENOMEM; in sysc_add_disabled()
3001 disabled_module->base = base; in sysc_add_disabled()
3003 mutex_lock(&sysc_soc->list_lock); in sysc_add_disabled()
3004 list_add(&disabled_module->node, &sysc_soc->disabled_modules); in sysc_add_disabled()
3005 mutex_unlock(&sysc_soc->list_lock); in sysc_add_disabled()
3014 * Note that we initialize static data shared across all ti-sysc instances
3029 return -ENOMEM; in sysc_init_static_data()
3031 mutex_init(&sysc_soc->list_lock); in sysc_init_static_data()
3032 INIT_LIST_HEAD(&sysc_soc->disabled_modules); in sysc_init_static_data()
3033 INIT_LIST_HEAD(&sysc_soc->restored_modules); in sysc_init_static_data()
3034 sysc_soc->general_purpose = true; in sysc_init_static_data()
3036 pdata = dev_get_platdata(ddata->dev); in sysc_init_static_data()
3037 if (pdata && pdata->soc_type_gp) in sysc_init_static_data()
3038 sysc_soc->general_purpose = pdata->soc_type_gp(); in sysc_init_static_data()
3041 if (match && match->data) in sysc_init_static_data()
3042 sysc_soc->soc = (int)match->data; in sysc_init_static_data()
3045 if (!sysc_soc->general_purpose) { in sysc_init_static_data()
3046 switch (sysc_soc->soc) { in sysc_init_static_data()
3062 if (match->data) in sysc_init_static_data()
3063 features = (unsigned long)match->data; in sysc_init_static_data()
3089 if (sysc_soc->nb.notifier_call) in sysc_cleanup_static_data()
3090 cpu_pm_unregister_notifier(&sysc_soc->nb); in sysc_cleanup_static_data()
3092 mutex_lock(&sysc_soc->list_lock); in sysc_cleanup_static_data()
3093 list_for_each_safe(pos, tmp, &sysc_soc->restored_modules) { in sysc_cleanup_static_data()
3098 list_for_each_safe(pos, tmp, &sysc_soc->disabled_modules) { in sysc_cleanup_static_data()
3103 mutex_unlock(&sysc_soc->list_lock); in sysc_cleanup_static_data()
3112 mutex_lock(&sysc_soc->list_lock); in sysc_check_disabled_devices()
3113 list_for_each(pos, &sysc_soc->disabled_modules) { in sysc_check_disabled_devices()
3115 if (ddata->module_pa == disabled_module->base) { in sysc_check_disabled_devices()
3116 dev_dbg(ddata->dev, "module disabled for this SoC\n"); in sysc_check_disabled_devices()
3117 error = -ENODEV; in sysc_check_disabled_devices()
3121 mutex_unlock(&sysc_soc->list_lock); in sysc_check_disabled_devices()
3127 * Ignore timers tagged with no-reset and no-idle. These are likely in use,
3128 * for example by drivers/clocksource/timer-ti-dm-systimer.c. If more checks
3133 if (ddata->cap->type != TI_SYSC_OMAP2_TIMER && in sysc_check_active_timer()
3134 ddata->cap->type != TI_SYSC_OMAP4_TIMER) in sysc_check_active_timer()
3137 if ((ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) && in sysc_check_active_timer()
3138 (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE)) in sysc_check_active_timer()
3139 return -ENXIO; in sysc_check_active_timer()
3145 { .compatible = "simple-bus", },
3151 struct ti_sysc_platform_data *pdata = dev_get_platdata(&pdev->dev); in sysc_probe()
3155 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); in sysc_probe()
3157 return -ENOMEM; in sysc_probe()
3159 ddata->dev = &pdev->dev; in sysc_probe()
3201 if (error == -ENXIO) in sysc_probe()
3202 ddata->reserved = true; in sysc_probe()
3218 pm_runtime_enable(ddata->dev); in sysc_probe()
3219 error = pm_runtime_get_sync(ddata->dev); in sysc_probe()
3221 pm_runtime_put_noidle(ddata->dev); in sysc_probe()
3222 pm_runtime_disable(ddata->dev); in sysc_probe()
3227 if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) in sysc_probe()
3228 reset_control_assert(ddata->rsts); in sysc_probe()
3230 if (!(ddata->cfg.quirks & in sysc_probe()
3239 ddata->dev->type = &sysc_device_type; in sysc_probe()
3241 if (!ddata->reserved) { in sysc_probe()
3242 error = of_platform_populate(ddata->dev->of_node, in sysc_probe()
3244 pdata ? pdata->auxdata : NULL, in sysc_probe()
3245 ddata->dev); in sysc_probe()
3250 INIT_DELAYED_WORK(&ddata->idle_work, ti_sysc_idle); in sysc_probe()
3253 if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE | in sysc_probe()
3256 schedule_delayed_work(&ddata->idle_work, 3000); in sysc_probe()
3258 pm_runtime_put(&pdev->dev); in sysc_probe()
3261 if (ddata->cfg.quirks & SYSC_QUIRK_REINIT_ON_CTX_LOST) in sysc_probe()
3267 pm_runtime_put_sync(&pdev->dev); in sysc_probe()
3268 pm_runtime_disable(&pdev->dev); in sysc_probe()
3280 cancel_delayed_work_sync(&ddata->idle_work); in sysc_remove()
3282 error = pm_runtime_get_sync(ddata->dev); in sysc_remove()
3284 pm_runtime_put_noidle(ddata->dev); in sysc_remove()
3285 pm_runtime_disable(ddata->dev); in sysc_remove()
3289 of_platform_depopulate(&pdev->dev); in sysc_remove()
3291 pm_runtime_put_sync(&pdev->dev); in sysc_remove()
3292 pm_runtime_disable(&pdev->dev); in sysc_remove()
3294 if (!reset_control_status(ddata->rsts)) in sysc_remove()
3295 reset_control_assert(ddata->rsts); in sysc_remove()
3304 { .compatible = "ti,sysc-omap2", .data = &sysc_omap2, },
3305 { .compatible = "ti,sysc-omap2-timer", .data = &sysc_omap2_timer, },
3306 { .compatible = "ti,sysc-omap4", .data = &sysc_omap4, },
3307 { .compatible = "ti,sysc-omap4-timer", .data = &sysc_omap4_timer, },
3308 { .compatible = "ti,sysc-omap4-simple", .data = &sysc_omap4_simple, },
3309 { .compatible = "ti,sysc-omap3430-sr", .data = &sysc_34xx_sr, },
3310 { .compatible = "ti,sysc-omap3630-sr", .data = &sysc_36xx_sr, },
3311 { .compatible = "ti,sysc-omap4-sr", .data = &sysc_omap4_sr, },
3312 { .compatible = "ti,sysc-omap3-sham", .data = &sysc_omap3_sham, },
3313 { .compatible = "ti,sysc-omap-aes", .data = &sysc_omap3_aes, },
3314 { .compatible = "ti,sysc-mcasp", .data = &sysc_omap4_mcasp, },
3315 { .compatible = "ti,sysc-dra7-mcasp", .data = &sysc_dra7_mcasp, },
3316 { .compatible = "ti,sysc-usb-host-fs",
3318 { .compatible = "ti,sysc-dra7-mcan", .data = &sysc_dra7_mcan, },
3319 { .compatible = "ti,sysc-pruss", .data = &sysc_pruss, },
3328 .name = "ti-sysc",