Lines Matching +full:adc +full:- +full:res +full:- +full:names
1 // SPDX-License-Identifier: GPL-2.0
3 * ti-sysc.c - Texas Instruments sysc interconnect target driver
8 * Copyright (C) 2017-2024 Texas Instruments Incorporated - https://www.ti.com/
13 * Copyright (C) 2009-2011 Nokia Corporation
14 * Copyright (C) 2011-2021 Texas Instruments Incorporated - https://www.ti.com/
35 #include <linux/platform_data/ti-sysc.h>
37 #include <dt-bindings/bus/ti-sysc.h>
107 * struct sysc - TI sysc interconnect target module registers and capabilities
113 * @mdata: ti-sysc to hwmod translation data for a module
115 * @clock_roles: clock role names for the found clocks
130 * @pre_reset_quirk: module specific pre-reset quirk
131 * @post_reset_quirk: module specific post-reset quirk
176 if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { in sysc_write()
177 writew_relaxed(value & 0xffff, ddata->module_va + offset); in sysc_write()
180 if (ddata->offsets[SYSC_REVISION] >= 0 && in sysc_write()
181 offset == ddata->offsets[SYSC_REVISION]) { in sysc_write()
184 writew_relaxed(hi, ddata->module_va + offset + 4); in sysc_write()
190 writel_relaxed(value, ddata->module_va + offset); in sysc_write()
195 if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { in sysc_read()
198 val = readw_relaxed(ddata->module_va + offset); in sysc_read()
201 if (ddata->offsets[SYSC_REVISION] >= 0 && in sysc_read()
202 offset == ddata->offsets[SYSC_REVISION]) { in sysc_read()
203 u16 tmp = readw_relaxed(ddata->module_va + offset + 4); in sysc_read()
211 return readl_relaxed(ddata->module_va + offset); in sysc_read()
216 return !!(ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_NEEDED); in sysc_opt_clks_needed()
221 int offset = ddata->offsets[SYSC_REVISION]; in sysc_read_revision()
231 int offset = ddata->offsets[SYSC_SYSCONFIG]; in sysc_read_sysconfig()
241 int offset = ddata->offsets[SYSC_SYSSTATUS]; in sysc_read_sysstatus()
254 if (ddata->cfg.quirks & SYSS_QUIRK_RESETDONE_INVERTED) in sysc_poll_reset_sysstatus()
257 syss_done = ddata->cfg.syss_mask; in sysc_poll_reset_sysstatus()
261 rstval, (rstval & ddata->cfg.syss_mask) == in sysc_poll_reset_sysstatus()
265 while (retries--) { in sysc_poll_reset_sysstatus()
267 if ((rstval & ddata->cfg.syss_mask) == syss_done) in sysc_poll_reset_sysstatus()
271 error = -ETIMEDOUT; in sysc_poll_reset_sysstatus()
282 sysc_mask = BIT(ddata->cap->regbits->srst_shift); in sysc_poll_reset_sysconfig()
290 while (retries--) { in sysc_poll_reset_sysconfig()
296 error = -ETIMEDOUT; in sysc_poll_reset_sysconfig()
307 if (ddata->cap->regbits->srst_shift < 0) in sysc_wait_softreset()
310 syss_offset = ddata->offsets[SYSC_SYSSTATUS]; in sysc_wait_softreset()
314 else if (ddata->cfg.quirks & SYSC_QUIRK_RESET_STATUS) in sysc_wait_softreset()
324 struct device_node *np = ddata->dev->of_node; in sysc_add_named_clock_from_child()
345 return -ENODEV; in sysc_add_named_clock_from_child()
347 clock = devm_get_clk_from_child(ddata->dev, child, name); in sysc_add_named_clock_from_child()
358 return -ENOMEM; in sysc_add_named_clock_from_child()
360 cl->con_id = n; in sysc_add_named_clock_from_child()
361 cl->dev_id = dev_name(ddata->dev); in sysc_add_named_clock_from_child()
362 cl->clk = clock; in sysc_add_named_clock_from_child()
375 if (ddata->nr_clocks < SYSC_OPTFCK0) in sysc_init_ext_opt_clock()
378 index = ddata->nr_clocks; in sysc_init_ext_opt_clock()
389 ddata->clock_roles[index] = optfck_name; in sysc_init_ext_opt_clock()
390 ddata->nr_clocks++; in sysc_init_ext_opt_clock()
397 int error, i, index = -ENODEV; in sysc_get_one_clock()
406 if (!ddata->clocks[i]) { in sysc_get_one_clock()
414 dev_err(ddata->dev, "clock %s not added\n", name); in sysc_get_one_clock()
418 ddata->clocks[index] = devm_clk_get(ddata->dev, name); in sysc_get_one_clock()
419 if (IS_ERR(ddata->clocks[index])) { in sysc_get_one_clock()
420 dev_err(ddata->dev, "clock get error for %s: %li\n", in sysc_get_one_clock()
421 name, PTR_ERR(ddata->clocks[index])); in sysc_get_one_clock()
423 return PTR_ERR(ddata->clocks[index]); in sysc_get_one_clock()
426 error = clk_prepare(ddata->clocks[index]); in sysc_get_one_clock()
428 dev_err(ddata->dev, "clock prepare error for %s: %i\n", in sysc_get_one_clock()
439 struct device_node *np = ddata->dev->of_node; in sysc_get_clocks()
444 ddata->clock_roles = devm_kcalloc(ddata->dev, in sysc_get_clocks()
446 sizeof(*ddata->clock_roles), in sysc_get_clocks()
448 if (!ddata->clock_roles) in sysc_get_clocks()
449 return -ENOMEM; in sysc_get_clocks()
451 of_property_for_each_string(np, "clock-names", prop, name) { in sysc_get_clocks()
456 ddata->clock_roles[ddata->nr_clocks] = name; in sysc_get_clocks()
457 ddata->nr_clocks++; in sysc_get_clocks()
460 if (ddata->nr_clocks < 1) in sysc_get_clocks()
463 if ((ddata->cfg.quirks & SYSC_QUIRK_EXT_OPT_CLOCK)) { in sysc_get_clocks()
469 if (ddata->nr_clocks > SYSC_MAX_CLOCKS) { in sysc_get_clocks()
470 dev_err(ddata->dev, "too many clocks for %pOF\n", np); in sysc_get_clocks()
472 return -EINVAL; in sysc_get_clocks()
476 dev_err(ddata->dev, "max one fck and ick for %pOF\n", np); in sysc_get_clocks()
478 return -EINVAL; in sysc_get_clocks()
483 ddata->nr_clocks++; in sysc_get_clocks()
485 ddata->nr_clocks++; in sysc_get_clocks()
487 ddata->clocks = devm_kcalloc(ddata->dev, in sysc_get_clocks()
488 ddata->nr_clocks, sizeof(*ddata->clocks), in sysc_get_clocks()
490 if (!ddata->clocks) in sysc_get_clocks()
491 return -ENOMEM; in sysc_get_clocks()
494 const char *name = ddata->clock_roles[i]; in sysc_get_clocks()
512 if (!ddata->clocks) in sysc_enable_main_clocks()
516 clock = ddata->clocks[i]; in sysc_enable_main_clocks()
530 for (i--; i >= 0; i--) { in sysc_enable_main_clocks()
531 clock = ddata->clocks[i]; in sysc_enable_main_clocks()
548 if (!ddata->clocks) in sysc_disable_main_clocks()
552 clock = ddata->clocks[i]; in sysc_disable_main_clocks()
565 if (!ddata->clocks || ddata->nr_clocks < SYSC_OPTFCK0 + 1) in sysc_enable_opt_clocks()
569 clock = ddata->clocks[i]; in sysc_enable_opt_clocks()
583 for (i--; i >= 0; i--) { in sysc_enable_opt_clocks()
584 clock = ddata->clocks[i]; in sysc_enable_opt_clocks()
599 if (!ddata->clocks || ddata->nr_clocks < SYSC_OPTFCK0 + 1) in sysc_disable_opt_clocks()
603 clock = ddata->clocks[i]; in sysc_disable_opt_clocks()
617 if (ddata->legacy_mode || (ddata->cfg.quirks & SYSC_QUIRK_CLKDM_NOAUTO)) in sysc_clkdm_deny_idle()
620 pdata = dev_get_platdata(ddata->dev); in sysc_clkdm_deny_idle()
621 if (pdata && pdata->clkdm_deny_idle) in sysc_clkdm_deny_idle()
622 pdata->clkdm_deny_idle(ddata->dev, &ddata->cookie); in sysc_clkdm_deny_idle()
629 if (ddata->legacy_mode || (ddata->cfg.quirks & SYSC_QUIRK_CLKDM_NOAUTO)) in sysc_clkdm_allow_idle()
632 pdata = dev_get_platdata(ddata->dev); in sysc_clkdm_allow_idle()
633 if (pdata && pdata->clkdm_allow_idle) in sysc_clkdm_allow_idle()
634 pdata->clkdm_allow_idle(ddata->dev, &ddata->cookie); in sysc_clkdm_allow_idle()
638 * sysc_init_resets - init rstctrl reset line if configured
645 ddata->rsts = in sysc_init_resets()
646 devm_reset_control_get_optional_shared(ddata->dev, "rstctrl"); in sysc_init_resets()
648 return PTR_ERR_OR_ZERO(ddata->rsts); in sysc_init_resets()
652 * sysc_parse_and_check_child_range - parses module IO region from ranges
662 struct device_node *np = ddata->dev->of_node; in sysc_parse_and_check_child_range()
672 ddata->module_pa = range.cpu_addr; in sysc_parse_and_check_child_range()
673 ddata->module_size = range.size; in sysc_parse_and_check_child_range()
695 * sysc_defer_non_critical - defer non_critical interconnect probing
704 struct resource *res; in sysc_defer_non_critical() local
711 res = &early_bus_ranges[i]; in sysc_defer_non_critical()
712 if (ddata->module_pa >= res->start && in sysc_defer_non_critical()
713 ddata->module_pa <= res->end) { in sysc_defer_non_critical()
722 return -EPROBE_DEFER; in sysc_defer_non_critical()
742 uart = of_get_property(np, "stdout-path", NULL); in sysc_init_stdout_path()
755 stdout_path = ERR_PTR(-ENODEV); in sysc_init_stdout_path()
765 ddata->cfg.quirks |= SYSC_QUIRK_NO_IDLE_ON_INIT | in sysc_check_quirk_stdout()
770 * sysc_check_one_child - check child configuration
785 dev_warn(ddata->dev, "really a child ti,hwmods property?"); in sysc_check_one_child()
795 for_each_child_of_node(ddata->dev->of_node, child) in sysc_check_children()
800 * So far only I2C uses 16-bit read access with clockactivity with revision
805 static void sysc_check_quirk_16bit(struct sysc *ddata, struct resource *res) in sysc_check_quirk_16bit() argument
807 if (resource_size(res) == 8) in sysc_check_quirk_16bit()
808 ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT; in sysc_check_quirk_16bit()
812 * sysc_parse_one - parses the interconnect target module registers
818 struct resource *res; in sysc_parse_one() local
828 return -EINVAL; in sysc_parse_one()
831 res = platform_get_resource_byname(to_platform_device(ddata->dev), in sysc_parse_one()
833 if (!res) { in sysc_parse_one()
834 ddata->offsets[reg] = -ENODEV; in sysc_parse_one()
839 ddata->offsets[reg] = res->start - ddata->module_pa; in sysc_parse_one()
841 sysc_check_quirk_16bit(ddata, res); in sysc_parse_one()
860 * sysc_check_registers - check for misconfigured register overlaps
868 if (ddata->offsets[i] < 0) in sysc_check_registers()
871 if (ddata->offsets[i] > (ddata->module_size - 4)) { in sysc_check_registers()
872 dev_err(ddata->dev, "register outside module range"); in sysc_check_registers()
874 return -EINVAL; in sysc_check_registers()
878 if (ddata->offsets[j] < 0) in sysc_check_registers()
881 if (ddata->offsets[i] == ddata->offsets[j]) in sysc_check_registers()
888 dev_err(ddata->dev, "overlapping registers: (%i/%i)", in sysc_check_registers()
891 return -EINVAL; in sysc_check_registers()
898 * sysc_ioremap - ioremap register space for the interconnect target module
912 if (ddata->offsets[SYSC_REVISION] < 0 && in sysc_ioremap()
913 ddata->offsets[SYSC_SYSCONFIG] < 0 && in sysc_ioremap()
914 ddata->offsets[SYSC_SYSSTATUS] < 0) { in sysc_ioremap()
915 size = ddata->module_size; in sysc_ioremap()
917 size = max3(ddata->offsets[SYSC_REVISION], in sysc_ioremap()
918 ddata->offsets[SYSC_SYSCONFIG], in sysc_ioremap()
919 ddata->offsets[SYSC_SYSSTATUS]); in sysc_ioremap()
924 if ((size + sizeof(u32)) > ddata->module_size) in sysc_ioremap()
925 size = ddata->module_size; in sysc_ioremap()
928 ddata->module_va = devm_ioremap(ddata->dev, in sysc_ioremap()
929 ddata->module_pa, in sysc_ioremap()
931 if (!ddata->module_va) in sysc_ioremap()
932 return -EIO; in sysc_ioremap()
938 * sysc_map_and_check_registers - ioremap and check device registers
943 struct device_node *np = ddata->dev->of_node; in sysc_map_and_check_registers()
975 * sysc_show_rev - read and show interconnect target module revision
983 if (ddata->offsets[SYSC_REVISION] < 0) in sysc_show_rev()
986 len = sprintf(bufp, ":%08x", ddata->revision); in sysc_show_rev()
994 if (ddata->offsets[reg] < 0) in sysc_show_reg()
997 return sprintf(bufp, ":%x", ddata->offsets[reg]); in sysc_show_reg()
1002 if (!ddata->name) in sysc_show_name()
1005 return sprintf(bufp, ":%s", ddata->name); in sysc_show_name()
1009 * sysc_show_registers - show information about interconnect target module
1024 dev_dbg(ddata->dev, "%llx:%x%s\n", in sysc_show_registers()
1025 ddata->module_pa, ddata->module_size, in sysc_show_registers()
1030 * sysc_write_sysconfig - handle sysconfig quirks for register write
1036 if (ddata->module_unlock_quirk) in sysc_write_sysconfig()
1037 ddata->module_unlock_quirk(ddata); in sysc_write_sysconfig()
1039 sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], value); in sysc_write_sysconfig()
1041 if (ddata->module_lock_quirk) in sysc_write_sysconfig()
1042 ddata->module_lock_quirk(ddata); in sysc_write_sysconfig()
1045 #define SYSC_IDLE_MASK (SYSC_NR_IDLEMODES - 1)
1062 if (ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_IN_RESET) { in sysc_enable_module()
1065 dev_err(ddata->dev, in sysc_enable_module()
1075 if (!(ddata->cfg.quirks & SYSC_MODULE_QUIRK_ENA_RESETDONE)) { in sysc_enable_module()
1078 dev_warn(ddata->dev, "OCP softreset timed out\n"); in sysc_enable_module()
1080 if (ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_IN_RESET) in sysc_enable_module()
1088 if (ddata->offsets[SYSC_SYSCONFIG] == -ENODEV) in sysc_enable_module()
1091 regbits = ddata->cap->regbits; in sysc_enable_module()
1092 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_enable_module()
1099 if (regbits->clkact_shift >= 0 && in sysc_enable_module()
1100 (ddata->cfg.quirks & SYSC_QUIRK_USE_CLOCKACT)) in sysc_enable_module()
1101 reg |= SYSC_CLOCACT_ICK << regbits->clkact_shift; in sysc_enable_module()
1104 idlemodes = ddata->cfg.sidlemodes; in sysc_enable_module()
1105 if (!idlemodes || regbits->sidle_shift < 0) in sysc_enable_module()
1108 if (ddata->cfg.quirks & (SYSC_QUIRK_SWSUP_SIDLE | in sysc_enable_module()
1113 if (regbits->enwkup_shift >= 0 && in sysc_enable_module()
1114 ddata->cfg.sysc_val & BIT(regbits->enwkup_shift)) in sysc_enable_module()
1115 reg &= ~BIT(regbits->enwkup_shift); 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 error = -EINVAL; in sysc_enable_module()
1146 if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_MSTANDBY) in sysc_enable_module()
1149 reg &= ~(SYSC_IDLE_MASK << regbits->midle_shift); in sysc_enable_module()
1150 reg |= best_mode << regbits->midle_shift; in sysc_enable_module()
1155 if (regbits->autoidle_shift >= 0 && in sysc_enable_module()
1156 ddata->cfg.sysc_val & BIT(regbits->autoidle_shift)) { in sysc_enable_module()
1157 reg |= 1 << regbits->autoidle_shift; in sysc_enable_module()
1165 ddata->sysconfig = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_enable_module()
1167 if (ddata->module_enable_quirk) in sysc_enable_module()
1168 ddata->module_enable_quirk(ddata); in sysc_enable_module()
1182 return -EINVAL; in sysc_best_idle_mode()
1196 if (ddata->offsets[SYSC_SYSCONFIG] == -ENODEV) in sysc_disable_module()
1199 if (ddata->module_disable_quirk) in sysc_disable_module()
1200 ddata->module_disable_quirk(ddata); in sysc_disable_module()
1202 regbits = ddata->cap->regbits; in sysc_disable_module()
1203 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_disable_module()
1206 idlemodes = ddata->cfg.midlemodes; in sysc_disable_module()
1207 if (!idlemodes || regbits->midle_shift < 0) in sysc_disable_module()
1216 if (ddata->cfg.quirks & (SYSC_QUIRK_SWSUP_MSTANDBY) || in sysc_disable_module()
1217 ddata->cfg.quirks & (SYSC_QUIRK_FORCE_MSTANDBY)) in sysc_disable_module()
1220 reg &= ~(SYSC_IDLE_MASK << regbits->midle_shift); in sysc_disable_module()
1221 reg |= best_mode << regbits->midle_shift; in sysc_disable_module()
1226 idlemodes = ddata->cfg.sidlemodes; in sysc_disable_module()
1227 if (!idlemodes || regbits->sidle_shift < 0) { in sysc_disable_module()
1232 if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_SIDLE) { in sysc_disable_module()
1238 ret = -EINVAL; in sysc_disable_module()
1243 if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_SIDLE_ACT) { in sysc_disable_module()
1245 if (regbits->enwkup_shift >= 0 && in sysc_disable_module()
1246 ddata->cfg.sysc_val & BIT(regbits->enwkup_shift)) in sysc_disable_module()
1247 reg |= BIT(regbits->enwkup_shift); in sysc_disable_module()
1250 reg &= ~(SYSC_IDLE_MASK << regbits->sidle_shift); in sysc_disable_module()
1251 reg |= best_mode << regbits->sidle_shift; in sysc_disable_module()
1252 if (regbits->autoidle_shift >= 0 && in sysc_disable_module()
1253 ddata->cfg.sysc_val & BIT(regbits->autoidle_shift)) in sysc_disable_module()
1254 reg |= 1 << regbits->autoidle_shift; in sysc_disable_module()
1261 ddata->sysconfig = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_disable_module()
1272 pdata = dev_get_platdata(ddata->dev); in sysc_runtime_suspend_legacy()
1276 if (!pdata->idle_module) in sysc_runtime_suspend_legacy()
1277 return -ENODEV; in sysc_runtime_suspend_legacy()
1279 error = pdata->idle_module(dev, &ddata->cookie); in sysc_runtime_suspend_legacy()
1284 reset_control_assert(ddata->rsts); in sysc_runtime_suspend_legacy()
1295 pdata = dev_get_platdata(ddata->dev); in sysc_runtime_resume_legacy()
1299 if (!pdata->enable_module) in sysc_runtime_resume_legacy()
1300 return -ENODEV; in sysc_runtime_resume_legacy()
1302 error = pdata->enable_module(dev, &ddata->cookie); in sysc_runtime_resume_legacy()
1307 reset_control_deassert(ddata->rsts); in sysc_runtime_resume_legacy()
1319 if (!ddata->enabled) in sysc_runtime_suspend()
1324 if (ddata->legacy_mode) { in sysc_runtime_suspend()
1339 ddata->enabled = false; in sysc_runtime_suspend()
1344 reset_control_assert(ddata->rsts); in sysc_runtime_suspend()
1356 if (ddata->enabled) in sysc_runtime_resume()
1372 reset_control_deassert(ddata->rsts); in sysc_runtime_resume()
1374 if (ddata->legacy_mode) { in sysc_runtime_resume()
1384 ddata->enabled = true; in sysc_runtime_resume()
1413 if (!ddata->enabled) in sysc_check_context()
1414 return -ENODATA; in sysc_check_context()
1416 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_check_context()
1417 if (reg == ddata->sysconfig) in sysc_check_context()
1420 return -EACCES; in sysc_check_context()
1425 struct device *dev = ddata->dev; in sysc_reinit_module()
1428 if (ddata->enabled) { in sysc_reinit_module()
1446 if (ddata->cfg.quirks & SYSC_QUIRK_RESET_ON_CTX_LOST) { in sysc_reinit_module()
1451 sysc_write_sysconfig(ddata, ddata->sysconfig); in sysc_reinit_module()
1471 if (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE) in sysc_noirq_suspend()
1474 if (!ddata->enabled) in sysc_noirq_suspend()
1477 ddata->needs_resume = 1; in sysc_noirq_suspend()
1489 if (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE) in sysc_noirq_resume()
1492 if (ddata->cfg.quirks & SYSC_QUIRK_REINIT_ON_RESUME) { in sysc_noirq_resume()
1493 error = sysc_reinit_module(ddata, ddata->needs_resume); in sysc_noirq_resume()
1496 } else if (ddata->needs_resume) { in sysc_noirq_resume()
1502 ddata->needs_resume = 0; in sysc_noirq_resume()
1541 SYSC_QUIRK("mcpdm", 0x40132000, 0, 0x10, -ENODEV, 0x50000800, 0xffffffff,
1546 SYSC_QUIRK("aess", 0, 0, 0x10, -ENODEV, 0x40000000, 0xffffffff,
1549 SYSC_QUIRK("dcan", 0x4ae3c000, 0x20, -ENODEV, -ENODEV, 0xa3170504, 0xffffffff,
1551 SYSC_QUIRK("dcan", 0x48480000, 0x20, -ENODEV, -ENODEV, 0xa3170504, 0xffffffff,
1555 SYSC_QUIRK("dss", 0x58000000, 0, -ENODEV, 0x14, 0x00000040, 0xffffffff,
1557 SYSC_QUIRK("dss", 0x58000000, 0, -ENODEV, 0x14, 0x00000061, 0xffffffff,
1559 SYSC_QUIRK("dwc3", 0x48880000, 0, 0x10, -ENODEV, 0x500a0200, 0xffffffff,
1561 SYSC_QUIRK("dwc3", 0x488c0000, 0, 0x10, -ENODEV, 0x500a0200, 0xffffffff,
1568 SYSC_QUIRK("hdmi", 0, 0, 0x10, -ENODEV, 0x50030200, 0xffffffff,
1582 SYSC_QUIRK("gpu", 0x50000000, 0x14, -ENODEV, -ENODEV, 0x00010201, 0xffffffff, 0),
1583 SYSC_QUIRK("gpu", 0x50000000, 0xfe00, 0xfe10, -ENODEV, 0x40000000 , 0xffffffff,
1585 SYSC_QUIRK("lcdc", 0, 0, 0x54, -ENODEV, 0x4f201000, 0xffffffff,
1587 SYSC_QUIRK("mcasp", 0, 0, 0x4, -ENODEV, 0x44306302, 0xffffffff,
1589 SYSC_QUIRK("rtc", 0, 0x74, 0x78, -ENODEV, 0x4eb01908, 0xffff00f0,
1591 SYSC_QUIRK("tptc", 0, 0, 0x10, -ENODEV, 0x40006c00, 0xffffefff,
1593 SYSC_QUIRK("tptc", 0, 0, -ENODEV, -ENODEV, 0x40007c00, 0xffffffff,
1595 SYSC_QUIRK("sata", 0, 0xfc, 0x1100, -ENODEV, 0x5e412000, 0xffffffff,
1610 SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -ENODEV, 0x50700101, 0xffffffff,
1621 SYSC_QUIRK("usb_otg_hs", 0, 0, 0x10, -ENODEV, 0x4ea2080d, 0xffffffff,
1627 SYSC_QUIRK("pruss", 0, 0x26000, 0x26004, -ENODEV, 0x47000000, 0xff000000,
1634 SYSC_QUIRK("adc", 0, 0, 0x10, -ENODEV, 0x47300001, 0xffffffff, 0),
1635 SYSC_QUIRK("atl", 0, 0, -ENODEV, -ENODEV, 0x0a070100, 0xffffffff, 0),
1636 SYSC_QUIRK("cm", 0, 0, -ENODEV, -ENODEV, 0x40000301, 0xffffffff, 0),
1637 SYSC_QUIRK("control", 0, 0, 0x10, -ENODEV, 0x40000900, 0xffffffff, 0),
1640 SYSC_QUIRK("dcan", 0, 0x20, -ENODEV, -ENODEV, 0xa3170504, 0xffffffff, 0),
1641 SYSC_QUIRK("dcan", 0, 0x20, -ENODEV, -ENODEV, 0x4edb1902, 0xffffffff, 0),
1645 SYSC_QUIRK("dmic", 0, 0, 0x10, -ENODEV, 0x50010000, 0xffffffff, 0),
1650 SYSC_QUIRK("dwc3", 0, 0, 0x10, -ENODEV, 0x500a0200, 0xffffffff, 0),
1654 SYSC_QUIRK("emif", 0, 0, -ENODEV, -ENODEV, 0x40441403, 0xffff0fff, 0),
1655 SYSC_QUIRK("emif", 0, 0, -ENODEV, -ENODEV, 0x50440500, 0xffffffff, 0),
1656 SYSC_QUIRK("epwmss", 0, 0, 0x4, -ENODEV, 0x47400001, 0xffffffff, 0),
1657 SYSC_QUIRK("gpu", 0, 0x1fc00, 0x1fc10, -ENODEV, 0, 0, 0),
1658 SYSC_QUIRK("gpu", 0, 0xfe00, 0xfe10, -ENODEV, 0x40000000 , 0xffffffff, 0),
1659 SYSC_QUIRK("hdmi", 0, 0, 0x10, -ENODEV, 0x50031d00, 0xffffffff, 0),
1661 SYSC_QUIRK("iss", 0, 0, 0x10, -ENODEV, 0x40000101, 0xffffffff, 0),
1663 SYSC_QUIRK("mcasp", 0, 0, 0x4, -ENODEV, 0x44307b02, 0xffffffff, 0),
1664 SYSC_QUIRK("mcbsp", 0, -ENODEV, 0x8c, -ENODEV, 0, 0, 0),
1665 SYSC_QUIRK("mcspi", 0, 0, 0x10, -ENODEV, 0x40300a0b, 0xffff00ff, 0),
1667 SYSC_QUIRK("mailbox", 0, 0, 0x10, -ENODEV, 0x00000400, 0xffffffff, 0),
1668 SYSC_QUIRK("m3", 0, 0, -ENODEV, -ENODEV, 0x5f580105, 0x0fff0f00, 0),
1670 SYSC_QUIRK("ocp2scp", 0, 0, -ENODEV, -ENODEV, 0x50060007, 0xffffffff, 0),
1671 SYSC_QUIRK("padconf", 0, 0, 0x10, -ENODEV, 0x4fff0800, 0xffffffff, 0),
1672 SYSC_QUIRK("padconf", 0, 0, -ENODEV, -ENODEV, 0x40001100, 0xffffffff, 0),
1673 SYSC_QUIRK("pcie", 0x51000000, -ENODEV, -ENODEV, -ENODEV, 0, 0, 0),
1674 SYSC_QUIRK("pcie", 0x51800000, -ENODEV, -ENODEV, -ENODEV, 0, 0, 0),
1675 SYSC_QUIRK("prcm", 0, 0, -ENODEV, -ENODEV, 0x40000100, 0xffffffff, 0),
1676 SYSC_QUIRK("prcm", 0, 0, -ENODEV, -ENODEV, 0x00004102, 0xffffffff, 0),
1677 SYSC_QUIRK("prcm", 0, 0, -ENODEV, -ENODEV, 0x40000400, 0xffffffff, 0),
1680 SYSC_QUIRK("scm", 0, 0, 0x10, -ENODEV, 0x40000900, 0xffffffff, 0),
1681 SYSC_QUIRK("scm", 0, 0, -ENODEV, -ENODEV, 0x4e8b0100, 0xffffffff, 0),
1682 SYSC_QUIRK("scm", 0, 0, -ENODEV, -ENODEV, 0x4f000100, 0xffffffff, 0),
1683 SYSC_QUIRK("scm", 0, 0, -ENODEV, -ENODEV, 0x40000900, 0xffffffff, 0),
1684 SYSC_QUIRK("scrm", 0, 0, -ENODEV, -ENODEV, 0x00000010, 0xffffffff, 0),
1685 SYSC_QUIRK("sdio", 0, 0, 0x10, -ENODEV, 0x40202301, 0xffff0ff0, 0),
1689 SYSC_QUIRK("slimbus", 0, 0, 0x10, -ENODEV, 0x40000902, 0xffffffff, 0),
1690 SYSC_QUIRK("slimbus", 0, 0, 0x10, -ENODEV, 0x40002903, 0xffffffff, 0),
1691 SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x24, -ENODEV, 0x00000000, 0xffffffff, 0),
1692 SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x38, -ENODEV, 0x00000000, 0xffffffff, 0),
1693 SYSC_QUIRK("spinlock", 0, 0, 0x10, -ENODEV, 0x50020000, 0xffffffff, 0),
1694 SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -ENODEV, 0x00000020, 0xffffffff, 0),
1698 SYSC_QUIRK("timer", 0, 0, 0x10, -ENODEV, 0x50002100, 0xffffffff, 0),
1699 SYSC_QUIRK("timer", 0, 0, 0x10, -ENODEV, 0x4fff1301, 0xffff00ff, 0),
1700 SYSC_QUIRK("timer32k", 0, 0, 0x4, -ENODEV, 0x00000040, 0xffffffff, 0),
1701 SYSC_QUIRK("timer32k", 0, 0, 0x4, -ENODEV, 0x00000011, 0xffffffff, 0),
1702 SYSC_QUIRK("timer32k", 0, 0, 0x4, -ENODEV, 0x00000060, 0xffffffff, 0),
1703 SYSC_QUIRK("tpcc", 0, 0, -ENODEV, -ENODEV, 0x40014c00, 0xffffffff, 0),
1706 SYSC_QUIRK("venc", 0x58003000, 0, -ENODEV, -ENODEV, 0x00000002, 0xffffffff, 0),
1707 SYSC_QUIRK("vfpe", 0, 0, 0x104, -ENODEV, 0x4d001200, 0xffffffff, 0),
1723 if (!q->base) in sysc_init_early_quirks()
1726 if (q->base != ddata->module_pa) in sysc_init_early_quirks()
1729 if (q->rev_offset != ddata->offsets[SYSC_REVISION]) in sysc_init_early_quirks()
1732 if (q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG]) in sysc_init_early_quirks()
1735 if (q->syss_offset != ddata->offsets[SYSC_SYSSTATUS]) in sysc_init_early_quirks()
1738 ddata->name = q->name; in sysc_init_early_quirks()
1739 ddata->cfg.quirks |= q->quirks; in sysc_init_early_quirks()
1752 if (q->base && q->base != ddata->module_pa) in sysc_init_revision_quirks()
1755 if (q->rev_offset != ddata->offsets[SYSC_REVISION]) in sysc_init_revision_quirks()
1758 if (q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG]) in sysc_init_revision_quirks()
1761 if (q->syss_offset != ddata->offsets[SYSC_SYSSTATUS]) in sysc_init_revision_quirks()
1764 if (q->revision == ddata->revision || in sysc_init_revision_quirks()
1765 (q->revision & q->revision_mask) == in sysc_init_revision_quirks()
1766 (ddata->revision & q->revision_mask)) { in sysc_init_revision_quirks()
1767 ddata->name = q->name; in sysc_init_revision_quirks()
1768 ddata->cfg.quirks |= q->quirks; in sysc_init_revision_quirks()
1776 * dispc init rather than top-level DSS init.
1787 switch (sysc_soc->soc) { in sysc_quirk_dispc()
1809 devm_iounmap(ddata->dev, ddata->module_va); in sysc_quirk_dispc()
1810 ddata->module_va = devm_ioremap(ddata->dev, in sysc_quirk_dispc()
1811 ddata->module_pa, in sysc_quirk_dispc()
1812 ddata->module_size); in sysc_quirk_dispc()
1813 if (!ddata->module_va) in sysc_quirk_dispc()
1814 return -EIO; in sysc_quirk_dispc()
1878 error = readl_poll_timeout(ddata->module_va + dispc_offset + 0x18, in sysc_pre_reset_quirk_dss()
1881 dev_warn(ddata->dev, "%s: timed out %08x !+ %08x\n", in sysc_pre_reset_quirk_dss()
1884 if (sysc_soc->soc == SOC_3430 || sysc_soc->soc == SOC_AM35) { in sysc_pre_reset_quirk_dss()
1896 /* 1-wire needs module's internal clocks enabled for reset */
1922 if ((ddata->revision & 0xffffff00) == 0x001f0000) in sysc_clk_quirk_i2c()
1960 error = readl_poll_timeout_atomic(ddata->module_va + 0x44, val, in sysc_quirk_rtc()
1963 dev_warn(ddata->dev, "rtc busy timeout\n"); in sysc_quirk_rtc()
2015 error = readl_poll_timeout(ddata->module_va + wps, val, in sysc_reset_done_quirk_wdt()
2019 dev_warn(ddata->dev, "wdt disable step1 failed\n"); in sysc_reset_done_quirk_wdt()
2022 error = readl_poll_timeout(ddata->module_va + wps, val, in sysc_reset_done_quirk_wdt()
2026 dev_warn(ddata->dev, "wdt disable step2 failed\n"); in sysc_reset_done_quirk_wdt()
2034 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_module_disable_quirk_pruss()
2036 sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); in sysc_module_disable_quirk_pruss()
2041 if (ddata->legacy_mode || !ddata->name) in sysc_init_module_quirks()
2044 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_HDQ1W) { in sysc_init_module_quirks()
2045 ddata->pre_reset_quirk = sysc_pre_reset_quirk_hdq1w; in sysc_init_module_quirks()
2051 if (ddata->cfg.quirks & SYSC_QUIRK_GPMC_DEBUG) { in sysc_init_module_quirks()
2052 ddata->cfg.quirks |= SYSC_QUIRK_NO_RESET_ON_INIT; in sysc_init_module_quirks()
2058 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_I2C) { in sysc_init_module_quirks()
2059 ddata->pre_reset_quirk = sysc_pre_reset_quirk_i2c; in sysc_init_module_quirks()
2060 ddata->post_reset_quirk = sysc_post_reset_quirk_i2c; in sysc_init_module_quirks()
2065 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_AESS) in sysc_init_module_quirks()
2066 ddata->module_enable_quirk = sysc_module_enable_quirk_aess; in sysc_init_module_quirks()
2068 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_DSS_RESET) in sysc_init_module_quirks()
2069 ddata->pre_reset_quirk = sysc_pre_reset_quirk_dss; in sysc_init_module_quirks()
2071 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_RTC_UNLOCK) { in sysc_init_module_quirks()
2072 ddata->module_unlock_quirk = sysc_module_unlock_quirk_rtc; in sysc_init_module_quirks()
2073 ddata->module_lock_quirk = sysc_module_lock_quirk_rtc; in sysc_init_module_quirks()
2078 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_OTG) { in sysc_init_module_quirks()
2079 ddata->module_enable_quirk = sysc_module_enable_quirk_otg; in sysc_init_module_quirks()
2080 ddata->module_disable_quirk = sysc_module_disable_quirk_otg; in sysc_init_module_quirks()
2083 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_SGX) in sysc_init_module_quirks()
2084 ddata->module_enable_quirk = sysc_module_enable_quirk_sgx; in sysc_init_module_quirks()
2086 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_WDT) { in sysc_init_module_quirks()
2087 ddata->reset_done_quirk = sysc_reset_done_quirk_wdt; in sysc_init_module_quirks()
2088 ddata->module_disable_quirk = sysc_reset_done_quirk_wdt; in sysc_init_module_quirks()
2091 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_PRUSS) in sysc_init_module_quirks()
2092 ddata->module_disable_quirk = sysc_module_disable_quirk_pruss; in sysc_init_module_quirks()
2097 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); in sysc_clockdomain_init()
2101 if (!pdata || !pdata->init_clockdomain) in sysc_clockdomain_init()
2104 switch (ddata->nr_clocks) { in sysc_clockdomain_init()
2106 ick = ddata->clocks[SYSC_ICK]; in sysc_clockdomain_init()
2109 fck = ddata->clocks[SYSC_FCK]; in sysc_clockdomain_init()
2115 error = pdata->init_clockdomain(ddata->dev, fck, ick, &ddata->cookie); in sysc_clockdomain_init()
2116 if (!error || error == -ENODEV) in sysc_clockdomain_init()
2123 * Note that pdata->init_module() typically does a reset first. After
2124 * pdata->init_module() is done, PM runtime can be used for the interconnect
2129 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); in sysc_legacy_init()
2132 if (!pdata || !pdata->init_module) in sysc_legacy_init()
2135 error = pdata->init_module(ddata->dev, ddata->mdata, &ddata->cookie); in sysc_legacy_init()
2136 if (error == -EEXIST) in sysc_legacy_init()
2151 sysc_offset = ddata->offsets[SYSC_SYSCONFIG]; in sysc_reset()
2153 if (ddata->legacy_mode || in sysc_reset()
2154 ddata->cap->regbits->srst_shift < 0) in sysc_reset()
2157 sysc_mask = BIT(ddata->cap->regbits->srst_shift); in sysc_reset()
2159 if (ddata->pre_reset_quirk) in sysc_reset()
2160 ddata->pre_reset_quirk(ddata); in sysc_reset()
2172 if (ddata->cfg.srst_udelay) in sysc_reset()
2173 fsleep(ddata->cfg.srst_udelay); in sysc_reset()
2183 if (ddata->post_reset_quirk) in sysc_reset()
2184 ddata->post_reset_quirk(ddata); in sysc_reset()
2188 dev_warn(ddata->dev, "OCP softreset timed out\n"); in sysc_reset()
2190 if (ddata->reset_done_quirk) in sysc_reset()
2191 ddata->reset_done_quirk(ddata); in sysc_reset()
2225 if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) { in sysc_init_module()
2226 error = reset_control_deassert(ddata->rsts); in sysc_init_module()
2232 ddata->revision = sysc_read_revision(ddata); in sysc_init_module()
2236 if (ddata->legacy_mode) { in sysc_init_module()
2242 if (!ddata->legacy_mode) { in sysc_init_module()
2243 error = sysc_enable_module(ddata->dev); in sysc_init_module()
2248 if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) { in sysc_init_module()
2251 dev_err(ddata->dev, "Reset failed with %d\n", error); in sysc_init_module()
2253 if (error && !ddata->legacy_mode) in sysc_init_module()
2254 sysc_disable_module(ddata->dev); in sysc_init_module()
2261 /* No re-enable of clockdomain autoidle to prevent module autoidle */ in sysc_init_module()
2268 !(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) in sysc_init_module()
2269 reset_control_assert(ddata->rsts); in sysc_init_module()
2276 struct device_node *np = ddata->dev->of_node; in sysc_init_sysc_mask()
2280 error = of_property_read_u32(np, "ti,sysc-mask", &val); in sysc_init_sysc_mask()
2284 ddata->cfg.sysc_val = val & ddata->cap->sysc_mask; in sysc_init_sysc_mask()
2292 struct device_node *np = ddata->dev->of_node; in sysc_init_idlemode()
2297 dev_err(ddata->dev, "invalid idlemode: %i\n", val); in sysc_init_idlemode()
2298 return -EINVAL; in sysc_init_idlemode()
2310 error = sysc_init_idlemode(ddata, &ddata->cfg.midlemodes, in sysc_init_idlemodes()
2311 "ti,sysc-midle"); in sysc_init_idlemodes()
2315 error = sysc_init_idlemode(ddata, &ddata->cfg.sidlemodes, in sysc_init_idlemodes()
2316 "ti,sysc-sidle"); in sysc_init_idlemodes()
2332 struct device_node *np = ddata->dev->of_node; in sysc_init_syss_mask()
2336 error = of_property_read_u32(np, "ti,syss-mask", &val); in sysc_init_syss_mask()
2338 if ((ddata->cap->type == TI_SYSC_OMAP4 || in sysc_init_syss_mask()
2339 ddata->cap->type == TI_SYSC_OMAP4_TIMER) && in sysc_init_syss_mask()
2340 (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) in sysc_init_syss_mask()
2341 ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; in sysc_init_syss_mask()
2346 if (!(val & 1) && (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) in sysc_init_syss_mask()
2347 ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; in sysc_init_syss_mask()
2349 ddata->cfg.syss_mask = val; in sysc_init_syss_mask()
2371 error = -EEXIST; in sysc_child_add_named_clock()
2375 clk = clk_get(ddata->dev, name); in sysc_child_add_named_clock()
2377 return -ENODEV; in sysc_child_add_named_clock()
2381 error = -ENOMEM; in sysc_child_add_named_clock()
2393 for (i = 0; i < ddata->nr_clocks; i++) { in sysc_child_add_clocks()
2396 ddata->clock_roles[i]); in sysc_child_add_clocks()
2397 if (error && error != -EEXIST) { in sysc_child_add_clocks()
2398 dev_err(ddata->dev, "could not add child clock %s: %i\n", in sysc_child_add_clocks()
2399 ddata->clock_roles[i], error); in sysc_child_add_clocks()
2413 struct device *parent = dev->parent; in sysc_child_to_parent()
2415 if (!parent || parent->type != &sysc_device_type) in sysc_child_to_parent()
2432 if (!ddata->enabled) in sysc_child_runtime_suspend()
2435 return sysc_runtime_suspend(ddata->dev); in sysc_child_runtime_suspend()
2445 if (!ddata->enabled) { in sysc_child_runtime_resume()
2446 error = sysc_runtime_resume(ddata->dev); in sysc_child_runtime_resume()
2448 dev_err(ddata->dev, in sysc_child_runtime_resume()
2461 list_for_each_entry(module, &sysc_soc->restored_modules, node) { in sysc_reinit_modules()
2462 ddata = module->ddata; in sysc_reinit_modules()
2463 sysc_reinit_module(ddata, ddata->enabled); in sysc_reinit_modules()
2468 * sysc_context_notifier - optionally reset and restore module after idle
2498 * sysc_add_restored - optionally add reset and restore quirk hanlling
2509 restored_module->ddata = ddata; in sysc_add_restored()
2511 mutex_lock(&sysc_soc->list_lock); in sysc_add_restored()
2513 list_add(&restored_module->node, &sysc_soc->restored_modules); in sysc_add_restored()
2515 if (sysc_soc->nb.notifier_call) in sysc_add_restored()
2518 sysc_soc->nb.notifier_call = sysc_context_notifier; in sysc_add_restored()
2519 cpu_pm_register_notifier(&sysc_soc->nb); in sysc_add_restored()
2522 mutex_unlock(&sysc_soc->list_lock); in sysc_add_restored()
2560 { .name = "ti,no-idle-on-init",
2562 { .name = "ti,no-reset-on-init",
2564 { .name = "ti,no-idle",
2579 ddata->cfg.quirks |= sysc_dts_quirks[i].mask; in sysc_parse_dts_quirks()
2581 dev_warn(ddata->dev, in sysc_parse_dts_quirks()
2590 struct device_node *np = ddata->dev->of_node; in sysc_init_dts_quirks()
2594 ddata->legacy_mode = of_get_property(np, "ti,hwmods", NULL); in sysc_init_dts_quirks()
2597 error = of_property_read_u32(np, "ti,sysc-delay-us", &val); in sysc_init_dts_quirks()
2600 dev_warn(ddata->dev, "bad ti,sysc-delay-us: %i\n", in sysc_init_dts_quirks()
2604 ddata->cfg.srst_udelay = (u8)val; in sysc_init_dts_quirks()
2614 if (!ddata->clocks) in sysc_unprepare()
2618 if (!IS_ERR_OR_NULL(ddata->clocks[i])) in sysc_unprepare()
2619 clk_unprepare(ddata->clocks[i]); in sysc_unprepare()
2627 .dmadisable_shift = -ENODEV,
2660 .dmadisable_shift = -ENODEV,
2661 .midle_shift = -ENODEV,
2663 .clkact_shift = -ENODEV,
2664 .enwkup_shift = -ENODEV,
2667 .emufree_shift = -ENODEV,
2681 .dmadisable_shift = -ENODEV,
2682 .midle_shift = -ENODEV,
2684 .clkact_shift = -ENODEV,
2685 .enwkup_shift = -ENODEV,
2688 .emufree_shift = -ENODEV,
2704 .clkact_shift = -ENODEV,
2705 .enwkup_shift = -ENODEV,
2708 .autoidle_shift = -ENODEV,
2729 .dmadisable_shift = -ENODEV,
2732 .clkact_shift = -ENODEV,
2733 .enwkup_shift = -ENODEV,
2734 .srst_shift = -ENODEV,
2735 .emufree_shift = -ENODEV,
2736 .autoidle_shift = -ENODEV,
2748 .dmadisable_shift = -ENODEV,
2749 .midle_shift = -ENODEV,
2750 .sidle_shift = -ENODEV,
2752 .enwkup_shift = -ENODEV,
2753 .srst_shift = -ENODEV,
2754 .emufree_shift = -ENODEV,
2755 .autoidle_shift = -ENODEV,
2769 .dmadisable_shift = -ENODEV,
2770 .midle_shift = -ENODEV,
2772 .clkact_shift = -ENODEV,
2774 .srst_shift = -ENODEV,
2775 .emufree_shift = -ENODEV,
2776 .autoidle_shift = -ENODEV,
2795 .dmadisable_shift = -ENODEV,
2796 .midle_shift = -ENODEV,
2798 .clkact_shift = -ENODEV,
2799 .enwkup_shift = -ENODEV,
2800 .srst_shift = -ENODEV,
2801 .emufree_shift = -ENODEV,
2802 .autoidle_shift = -ENODEV,
2824 .dmadisable_shift = -ENODEV,
2825 .midle_shift = -ENODEV,
2827 .clkact_shift = -ENODEV,
2829 .srst_shift = -ENODEV,
2830 .emufree_shift = -ENODEV,
2831 .autoidle_shift = -ENODEV,
2841 .dmadisable_shift = -ENODEV,
2842 .midle_shift = -ENODEV,
2843 .sidle_shift = -ENODEV,
2844 .clkact_shift = -ENODEV,
2847 .emufree_shift = -ENODEV,
2848 .autoidle_shift = -ENODEV,
2870 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); in sysc_init_pdata()
2876 mdata = devm_kzalloc(ddata->dev, sizeof(*mdata), GFP_KERNEL); in sysc_init_pdata()
2878 return -ENOMEM; in sysc_init_pdata()
2880 if (ddata->legacy_mode) { in sysc_init_pdata()
2881 mdata->name = ddata->legacy_mode; in sysc_init_pdata()
2882 mdata->module_pa = ddata->module_pa; in sysc_init_pdata()
2883 mdata->module_size = ddata->module_size; in sysc_init_pdata()
2884 mdata->offsets = ddata->offsets; in sysc_init_pdata()
2885 mdata->nr_offsets = SYSC_MAX_REGS; in sysc_init_pdata()
2886 mdata->cap = ddata->cap; in sysc_init_pdata()
2887 mdata->cfg = &ddata->cfg; in sysc_init_pdata()
2890 ddata->mdata = mdata; in sysc_init_pdata()
2899 cap = of_device_get_match_data(ddata->dev); in sysc_init_match()
2901 return -EINVAL; in sysc_init_match()
2903 ddata->cap = cap; in sysc_init_match()
2904 if (ddata->cap) in sysc_init_match()
2905 ddata->cfg.quirks |= ddata->cap->mod_quirks; in sysc_init_match()
2922 if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE | in ti_sysc_idle()
2930 if (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE) in ti_sysc_idle()
2937 if (pm_runtime_active(ddata->dev)) in ti_sysc_idle()
2938 pm_runtime_put_sync(ddata->dev); in ti_sysc_idle()
2989 return -ENOMEM; in sysc_add_disabled()
2991 disabled_module->base = base; in sysc_add_disabled()
2993 mutex_lock(&sysc_soc->list_lock); in sysc_add_disabled()
2994 list_add(&disabled_module->node, &sysc_soc->disabled_modules); in sysc_add_disabled()
2995 mutex_unlock(&sysc_soc->list_lock); in sysc_add_disabled()
3004 * Note that we initialize static data shared across all ti-sysc instances
3020 return -ENOMEM; in sysc_init_static_data()
3022 mutex_init(&sysc_soc->list_lock); in sysc_init_static_data()
3023 INIT_LIST_HEAD(&sysc_soc->disabled_modules); in sysc_init_static_data()
3024 INIT_LIST_HEAD(&sysc_soc->restored_modules); in sysc_init_static_data()
3025 sysc_soc->general_purpose = true; in sysc_init_static_data()
3027 pdata = dev_get_platdata(ddata->dev); in sysc_init_static_data()
3028 if (pdata && pdata->soc_type_gp) in sysc_init_static_data()
3029 sysc_soc->general_purpose = pdata->soc_type_gp(); in sysc_init_static_data()
3032 if (match && match->data) in sysc_init_static_data()
3033 sysc_soc->soc = (enum sysc_soc)(uintptr_t)match->data; in sysc_init_static_data()
3037 * simple-pm-bus instead of simple-bus in the dtb for genpd using SoCs. in sysc_init_static_data()
3039 switch (sysc_soc->soc) { in sysc_init_static_data()
3046 WARN_ONCE(np && of_device_is_compatible(np, "simple-bus"), in sysc_init_static_data()
3047 "ti-sysc: Incomplete old dtb, please update\n"); in sysc_init_static_data()
3054 if (!sysc_soc->general_purpose) { in sysc_init_static_data()
3055 switch (sysc_soc->soc) { in sysc_init_static_data()
3071 if (match->data) in sysc_init_static_data()
3072 features = (unsigned long)match->data; in sysc_init_static_data()
3098 if (sysc_soc->nb.notifier_call) in sysc_cleanup_static_data()
3099 cpu_pm_unregister_notifier(&sysc_soc->nb); in sysc_cleanup_static_data()
3101 mutex_lock(&sysc_soc->list_lock); in sysc_cleanup_static_data()
3102 list_for_each_safe(pos, tmp, &sysc_soc->restored_modules) { in sysc_cleanup_static_data()
3107 list_for_each_safe(pos, tmp, &sysc_soc->disabled_modules) { in sysc_cleanup_static_data()
3112 mutex_unlock(&sysc_soc->list_lock); in sysc_cleanup_static_data()
3120 mutex_lock(&sysc_soc->list_lock); in sysc_check_disabled_devices()
3121 list_for_each_entry(disabled_module, &sysc_soc->disabled_modules, node) { in sysc_check_disabled_devices()
3122 if (ddata->module_pa == disabled_module->base) { in sysc_check_disabled_devices()
3123 dev_dbg(ddata->dev, "module disabled for this SoC\n"); in sysc_check_disabled_devices()
3124 error = -ENODEV; in sysc_check_disabled_devices()
3128 mutex_unlock(&sysc_soc->list_lock); in sysc_check_disabled_devices()
3134 * Ignore timers tagged with no-reset and no-idle. These are likely in use,
3135 * for example by drivers/clocksource/timer-ti-dm-systimer.c. If more checks
3142 if (ddata->cap->type != TI_SYSC_OMAP2_TIMER && in sysc_check_active_timer()
3143 ddata->cap->type != TI_SYSC_OMAP4_TIMER) in sysc_check_active_timer()
3153 if (sysc_soc->soc == SOC_3430 || sysc_soc->soc == SOC_AM35) in sysc_check_active_timer()
3154 error = -ENXIO; in sysc_check_active_timer()
3156 error = -EBUSY; in sysc_check_active_timer()
3158 if ((ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) && in sysc_check_active_timer()
3159 (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE)) in sysc_check_active_timer()
3166 { .compatible = "simple-bus", },
3172 struct ti_sysc_platform_data *pdata = dev_get_platdata(&pdev->dev); in sysc_probe()
3176 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); in sysc_probe()
3178 return -ENOMEM; in sysc_probe()
3180 ddata->offsets[SYSC_REVISION] = -ENODEV; in sysc_probe()
3181 ddata->offsets[SYSC_SYSCONFIG] = -ENODEV; in sysc_probe()
3182 ddata->offsets[SYSC_SYSSTATUS] = -ENODEV; in sysc_probe()
3183 ddata->dev = &pdev->dev; in sysc_probe()
3225 if (error == -ENXIO) in sysc_probe()
3226 ddata->reserved = true; in sysc_probe()
3242 pm_runtime_enable(ddata->dev); in sysc_probe()
3243 error = pm_runtime_resume_and_get(ddata->dev); in sysc_probe()
3245 pm_runtime_disable(ddata->dev); in sysc_probe()
3250 if (!(ddata->cfg.quirks & in sysc_probe()
3257 if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) in sysc_probe()
3258 reset_control_assert(ddata->rsts); in sysc_probe()
3262 ddata->dev->type = &sysc_device_type; in sysc_probe()
3264 if (!ddata->reserved) { in sysc_probe()
3265 error = of_platform_populate(ddata->dev->of_node, in sysc_probe()
3267 pdata ? pdata->auxdata : NULL, in sysc_probe()
3268 ddata->dev); in sysc_probe()
3273 INIT_DELAYED_WORK(&ddata->idle_work, ti_sysc_idle); in sysc_probe()
3276 if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE | in sysc_probe()
3279 schedule_delayed_work(&ddata->idle_work, 3000); in sysc_probe()
3281 pm_runtime_put(&pdev->dev); in sysc_probe()
3284 if (ddata->cfg.quirks & SYSC_QUIRK_REINIT_ON_CTX_LOST) in sysc_probe()
3290 pm_runtime_put_sync(&pdev->dev); in sysc_probe()
3291 pm_runtime_disable(&pdev->dev); in sysc_probe()
3304 if (cancel_delayed_work_sync(&ddata->idle_work)) in sysc_remove()
3305 ti_sysc_idle(&ddata->idle_work.work); in sysc_remove()
3307 error = pm_runtime_resume_and_get(ddata->dev); in sysc_remove()
3309 pm_runtime_disable(ddata->dev); in sysc_remove()
3313 of_platform_depopulate(&pdev->dev); in sysc_remove()
3315 pm_runtime_put_sync(&pdev->dev); in sysc_remove()
3316 pm_runtime_disable(&pdev->dev); in sysc_remove()
3318 if (!reset_control_status(ddata->rsts)) in sysc_remove()
3319 reset_control_assert(ddata->rsts); in sysc_remove()
3326 { .compatible = "ti,sysc-omap2", .data = &sysc_omap2, },
3327 { .compatible = "ti,sysc-omap2-timer", .data = &sysc_omap2_timer, },
3328 { .compatible = "ti,sysc-omap4", .data = &sysc_omap4, },
3329 { .compatible = "ti,sysc-omap4-timer", .data = &sysc_omap4_timer, },
3330 { .compatible = "ti,sysc-omap4-simple", .data = &sysc_omap4_simple, },
3331 { .compatible = "ti,sysc-omap3430-sr", .data = &sysc_34xx_sr, },
3332 { .compatible = "ti,sysc-omap3630-sr", .data = &sysc_36xx_sr, },
3333 { .compatible = "ti,sysc-omap4-sr", .data = &sysc_omap4_sr, },
3334 { .compatible = "ti,sysc-omap3-sham", .data = &sysc_omap3_sham, },
3335 { .compatible = "ti,sysc-omap-aes", .data = &sysc_omap3_aes, },
3336 { .compatible = "ti,sysc-mcasp", .data = &sysc_omap4_mcasp, },
3337 { .compatible = "ti,sysc-dra7-mcasp", .data = &sysc_dra7_mcasp, },
3338 { .compatible = "ti,sysc-usb-host-fs",
3340 { .compatible = "ti,sysc-dra7-mcan", .data = &sysc_dra7_mcan, },
3341 { .compatible = "ti,sysc-pruss", .data = &sysc_pruss, },
3350 .name = "ti-sysc",