Lines Matching refs:ddata

57 	struct sysc *ddata;  member
158 static void sysc_parse_dts_quirks(struct sysc *ddata, struct device_node *np,
160 static int sysc_reset(struct sysc *ddata);
162 static void sysc_write(struct sysc *ddata, int offset, u32 value) in sysc_write() argument
164 if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { in sysc_write()
165 writew_relaxed(value & 0xffff, ddata->module_va + offset); in sysc_write()
168 if (ddata->offsets[SYSC_REVISION] >= 0 && in sysc_write()
169 offset == ddata->offsets[SYSC_REVISION]) { in sysc_write()
172 writew_relaxed(hi, ddata->module_va + offset + 4); in sysc_write()
178 writel_relaxed(value, ddata->module_va + offset); in sysc_write()
181 static u32 sysc_read(struct sysc *ddata, int offset) in sysc_read() argument
183 if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { in sysc_read()
186 val = readw_relaxed(ddata->module_va + offset); in sysc_read()
189 if (ddata->offsets[SYSC_REVISION] >= 0 && in sysc_read()
190 offset == ddata->offsets[SYSC_REVISION]) { in sysc_read()
191 u16 tmp = readw_relaxed(ddata->module_va + offset + 4); in sysc_read()
199 return readl_relaxed(ddata->module_va + offset); in sysc_read()
202 static bool sysc_opt_clks_needed(struct sysc *ddata) in sysc_opt_clks_needed() argument
204 return !!(ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_NEEDED); in sysc_opt_clks_needed()
207 static u32 sysc_read_revision(struct sysc *ddata) in sysc_read_revision() argument
209 int offset = ddata->offsets[SYSC_REVISION]; in sysc_read_revision()
214 return sysc_read(ddata, offset); in sysc_read_revision()
217 static u32 sysc_read_sysconfig(struct sysc *ddata) in sysc_read_sysconfig() argument
219 int offset = ddata->offsets[SYSC_SYSCONFIG]; in sysc_read_sysconfig()
224 return sysc_read(ddata, offset); in sysc_read_sysconfig()
227 static u32 sysc_read_sysstatus(struct sysc *ddata) in sysc_read_sysstatus() argument
229 int offset = ddata->offsets[SYSC_SYSSTATUS]; in sysc_read_sysstatus()
234 return sysc_read(ddata, offset); in sysc_read_sysstatus()
237 static int sysc_poll_reset_sysstatus(struct sysc *ddata) in sysc_poll_reset_sysstatus() argument
242 if (ddata->cfg.quirks & SYSS_QUIRK_RESETDONE_INVERTED) in sysc_poll_reset_sysstatus()
245 syss_done = ddata->cfg.syss_mask; in sysc_poll_reset_sysstatus()
248 error = readx_poll_timeout_atomic(sysc_read_sysstatus, ddata, in sysc_poll_reset_sysstatus()
249 rstval, (rstval & ddata->cfg.syss_mask) == in sysc_poll_reset_sysstatus()
254 rstval = sysc_read_sysstatus(ddata); in sysc_poll_reset_sysstatus()
255 if ((rstval & ddata->cfg.syss_mask) == syss_done) in sysc_poll_reset_sysstatus()
265 static int sysc_poll_reset_sysconfig(struct sysc *ddata) in sysc_poll_reset_sysconfig() argument
270 sysc_mask = BIT(ddata->cap->regbits->srst_shift); in sysc_poll_reset_sysconfig()
273 error = readx_poll_timeout_atomic(sysc_read_sysconfig, ddata, in sysc_poll_reset_sysconfig()
279 rstval = sysc_read_sysconfig(ddata); in sysc_poll_reset_sysconfig()
291 static int sysc_wait_softreset(struct sysc *ddata) in sysc_wait_softreset() argument
295 if (ddata->cap->regbits->srst_shift < 0) in sysc_wait_softreset()
298 syss_offset = ddata->offsets[SYSC_SYSSTATUS]; in sysc_wait_softreset()
301 error = sysc_poll_reset_sysstatus(ddata); in sysc_wait_softreset()
302 else if (ddata->cfg.quirks & SYSC_QUIRK_RESET_STATUS) in sysc_wait_softreset()
303 error = sysc_poll_reset_sysconfig(ddata); in sysc_wait_softreset()
308 static int sysc_add_named_clock_from_child(struct sysc *ddata, in sysc_add_named_clock_from_child() argument
312 struct device_node *np = ddata->dev->of_node; in sysc_add_named_clock_from_child()
335 clock = devm_get_clk_from_child(ddata->dev, child, name); in sysc_add_named_clock_from_child()
349 cl->dev_id = dev_name(ddata->dev); in sysc_add_named_clock_from_child()
358 static int sysc_init_ext_opt_clock(struct sysc *ddata, const char *name) in sysc_init_ext_opt_clock() argument
363 if (ddata->nr_clocks < SYSC_OPTFCK0) in sysc_init_ext_opt_clock()
366 index = ddata->nr_clocks; in sysc_init_ext_opt_clock()
373 error = sysc_add_named_clock_from_child(ddata, name, optfck_name); in sysc_init_ext_opt_clock()
377 ddata->clock_roles[index] = optfck_name; in sysc_init_ext_opt_clock()
378 ddata->nr_clocks++; in sysc_init_ext_opt_clock()
383 static int sysc_get_one_clock(struct sysc *ddata, const char *name) in sysc_get_one_clock() argument
394 if (!ddata->clocks[i]) { in sysc_get_one_clock()
402 dev_err(ddata->dev, "clock %s not added\n", name); in sysc_get_one_clock()
406 ddata->clocks[index] = devm_clk_get(ddata->dev, name); in sysc_get_one_clock()
407 if (IS_ERR(ddata->clocks[index])) { in sysc_get_one_clock()
408 dev_err(ddata->dev, "clock get error for %s: %li\n", in sysc_get_one_clock()
409 name, PTR_ERR(ddata->clocks[index])); in sysc_get_one_clock()
411 return PTR_ERR(ddata->clocks[index]); in sysc_get_one_clock()
414 error = clk_prepare(ddata->clocks[index]); in sysc_get_one_clock()
416 dev_err(ddata->dev, "clock prepare error for %s: %i\n", in sysc_get_one_clock()
425 static int sysc_get_clocks(struct sysc *ddata) in sysc_get_clocks() argument
427 struct device_node *np = ddata->dev->of_node; in sysc_get_clocks()
432 ddata->clock_roles = devm_kcalloc(ddata->dev, in sysc_get_clocks()
434 sizeof(*ddata->clock_roles), in sysc_get_clocks()
436 if (!ddata->clock_roles) in sysc_get_clocks()
444 ddata->clock_roles[ddata->nr_clocks] = name; in sysc_get_clocks()
445 ddata->nr_clocks++; in sysc_get_clocks()
448 if (ddata->nr_clocks < 1) in sysc_get_clocks()
451 if ((ddata->cfg.quirks & SYSC_QUIRK_EXT_OPT_CLOCK)) { in sysc_get_clocks()
452 error = sysc_init_ext_opt_clock(ddata, NULL); in sysc_get_clocks()
457 if (ddata->nr_clocks > SYSC_MAX_CLOCKS) { in sysc_get_clocks()
458 dev_err(ddata->dev, "too many clocks for %pOF\n", np); in sysc_get_clocks()
464 dev_err(ddata->dev, "max one fck and ick for %pOF\n", np); in sysc_get_clocks()
471 ddata->nr_clocks++; in sysc_get_clocks()
473 ddata->nr_clocks++; in sysc_get_clocks()
475 ddata->clocks = devm_kcalloc(ddata->dev, in sysc_get_clocks()
476 ddata->nr_clocks, sizeof(*ddata->clocks), in sysc_get_clocks()
478 if (!ddata->clocks) in sysc_get_clocks()
482 const char *name = ddata->clock_roles[i]; in sysc_get_clocks()
487 error = sysc_get_one_clock(ddata, name); in sysc_get_clocks()
495 static int sysc_enable_main_clocks(struct sysc *ddata) in sysc_enable_main_clocks() argument
500 if (!ddata->clocks) in sysc_enable_main_clocks()
504 clock = ddata->clocks[i]; in sysc_enable_main_clocks()
519 clock = ddata->clocks[i]; in sysc_enable_main_clocks()
531 static void sysc_disable_main_clocks(struct sysc *ddata) in sysc_disable_main_clocks() argument
536 if (!ddata->clocks) in sysc_disable_main_clocks()
540 clock = ddata->clocks[i]; in sysc_disable_main_clocks()
548 static int sysc_enable_opt_clocks(struct sysc *ddata) in sysc_enable_opt_clocks() argument
553 if (!ddata->clocks || ddata->nr_clocks < SYSC_OPTFCK0 + 1) in sysc_enable_opt_clocks()
557 clock = ddata->clocks[i]; in sysc_enable_opt_clocks()
572 clock = ddata->clocks[i]; in sysc_enable_opt_clocks()
582 static void sysc_disable_opt_clocks(struct sysc *ddata) in sysc_disable_opt_clocks() argument
587 if (!ddata->clocks || ddata->nr_clocks < SYSC_OPTFCK0 + 1) in sysc_disable_opt_clocks()
591 clock = ddata->clocks[i]; in sysc_disable_opt_clocks()
601 static void sysc_clkdm_deny_idle(struct sysc *ddata) in sysc_clkdm_deny_idle() argument
605 if (ddata->legacy_mode || (ddata->cfg.quirks & SYSC_QUIRK_CLKDM_NOAUTO)) in sysc_clkdm_deny_idle()
608 pdata = dev_get_platdata(ddata->dev); in sysc_clkdm_deny_idle()
610 pdata->clkdm_deny_idle(ddata->dev, &ddata->cookie); in sysc_clkdm_deny_idle()
613 static void sysc_clkdm_allow_idle(struct sysc *ddata) in sysc_clkdm_allow_idle() argument
617 if (ddata->legacy_mode || (ddata->cfg.quirks & SYSC_QUIRK_CLKDM_NOAUTO)) in sysc_clkdm_allow_idle()
620 pdata = dev_get_platdata(ddata->dev); in sysc_clkdm_allow_idle()
622 pdata->clkdm_allow_idle(ddata->dev, &ddata->cookie); in sysc_clkdm_allow_idle()
631 static int sysc_init_resets(struct sysc *ddata) in sysc_init_resets() argument
633 ddata->rsts = in sysc_init_resets()
634 devm_reset_control_get_optional_shared(ddata->dev, "rstctrl"); in sysc_init_resets()
636 return PTR_ERR_OR_ZERO(ddata->rsts); in sysc_init_resets()
648 static int sysc_parse_and_check_child_range(struct sysc *ddata) in sysc_parse_and_check_child_range() argument
650 struct device_node *np = ddata->dev->of_node; in sysc_parse_and_check_child_range()
657 dev_err(ddata->dev, "missing ranges for %pOF\n", np); in sysc_parse_and_check_child_range()
665 dev_err(ddata->dev, "incomplete ranges for %pOF\n", np); in sysc_parse_and_check_child_range()
679 dev_err(ddata->dev, "invalid ranges for %pOF\n", np); in sysc_parse_and_check_child_range()
685 ddata->module_pa = of_translate_address(np, ranges++); in sysc_parse_and_check_child_range()
686 ddata->module_size = be32_to_cpup(ranges); in sysc_parse_and_check_child_range()
713 static int sysc_defer_non_critical(struct sysc *ddata) in sysc_defer_non_critical() argument
723 if (ddata->module_pa >= res->start && in sysc_defer_non_critical()
724 ddata->module_pa <= res->end) { in sysc_defer_non_critical()
738 static void sysc_init_stdout_path(struct sysc *ddata) in sysc_init_stdout_path() argument
769 static void sysc_check_quirk_stdout(struct sysc *ddata, in sysc_check_quirk_stdout() argument
772 sysc_init_stdout_path(ddata); in sysc_check_quirk_stdout()
776 ddata->cfg.quirks |= SYSC_QUIRK_NO_IDLE_ON_INIT | in sysc_check_quirk_stdout()
789 static void sysc_check_one_child(struct sysc *ddata, in sysc_check_one_child() argument
796 dev_warn(ddata->dev, "really a child ti,hwmods property?"); in sysc_check_one_child()
798 sysc_check_quirk_stdout(ddata, np); in sysc_check_one_child()
799 sysc_parse_dts_quirks(ddata, np, true); in sysc_check_one_child()
802 static void sysc_check_children(struct sysc *ddata) in sysc_check_children() argument
806 for_each_child_of_node(ddata->dev->of_node, child) in sysc_check_children()
807 sysc_check_one_child(ddata, child); in sysc_check_children()
816 static void sysc_check_quirk_16bit(struct sysc *ddata, struct resource *res) in sysc_check_quirk_16bit() argument
819 ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT; in sysc_check_quirk_16bit()
827 static int sysc_parse_one(struct sysc *ddata, enum sysc_registers reg) in sysc_parse_one() argument
842 res = platform_get_resource_byname(to_platform_device(ddata->dev), in sysc_parse_one()
845 ddata->offsets[reg] = -ENODEV; in sysc_parse_one()
850 ddata->offsets[reg] = res->start - ddata->module_pa; in sysc_parse_one()
852 sysc_check_quirk_16bit(ddata, res); in sysc_parse_one()
857 static int sysc_parse_registers(struct sysc *ddata) in sysc_parse_registers() argument
862 error = sysc_parse_one(ddata, i); in sysc_parse_registers()
874 static int sysc_check_registers(struct sysc *ddata) in sysc_check_registers() argument
879 if (ddata->offsets[i] < 0) in sysc_check_registers()
882 if (ddata->offsets[i] > (ddata->module_size - 4)) { in sysc_check_registers()
883 dev_err(ddata->dev, "register outside module range"); in sysc_check_registers()
889 if (ddata->offsets[j] < 0) in sysc_check_registers()
892 if (ddata->offsets[i] == ddata->offsets[j]) in sysc_check_registers()
899 dev_err(ddata->dev, "overlapping registers: (%i/%i)", in sysc_check_registers()
919 static int sysc_ioremap(struct sysc *ddata) in sysc_ioremap() argument
923 if (ddata->offsets[SYSC_REVISION] < 0 && in sysc_ioremap()
924 ddata->offsets[SYSC_SYSCONFIG] < 0 && in sysc_ioremap()
925 ddata->offsets[SYSC_SYSSTATUS] < 0) { in sysc_ioremap()
926 size = ddata->module_size; in sysc_ioremap()
928 size = max3(ddata->offsets[SYSC_REVISION], in sysc_ioremap()
929 ddata->offsets[SYSC_SYSCONFIG], in sysc_ioremap()
930 ddata->offsets[SYSC_SYSSTATUS]); in sysc_ioremap()
935 if ((size + sizeof(u32)) > ddata->module_size) in sysc_ioremap()
936 size = ddata->module_size; in sysc_ioremap()
939 ddata->module_va = devm_ioremap(ddata->dev, in sysc_ioremap()
940 ddata->module_pa, in sysc_ioremap()
942 if (!ddata->module_va) in sysc_ioremap()
952 static int sysc_map_and_check_registers(struct sysc *ddata) in sysc_map_and_check_registers() argument
954 struct device_node *np = ddata->dev->of_node; in sysc_map_and_check_registers()
957 error = sysc_parse_and_check_child_range(ddata); in sysc_map_and_check_registers()
961 error = sysc_defer_non_critical(ddata); in sysc_map_and_check_registers()
965 sysc_check_children(ddata); in sysc_map_and_check_registers()
970 error = sysc_parse_registers(ddata); in sysc_map_and_check_registers()
974 error = sysc_ioremap(ddata); in sysc_map_and_check_registers()
978 error = sysc_check_registers(ddata); in sysc_map_and_check_registers()
990 static int sysc_show_rev(char *bufp, struct sysc *ddata) in sysc_show_rev() argument
994 if (ddata->offsets[SYSC_REVISION] < 0) in sysc_show_rev()
997 len = sprintf(bufp, ":%08x", ddata->revision); in sysc_show_rev()
1002 static int sysc_show_reg(struct sysc *ddata, in sysc_show_reg() argument
1005 if (ddata->offsets[reg] < 0) in sysc_show_reg()
1008 return sprintf(bufp, ":%x", ddata->offsets[reg]); in sysc_show_reg()
1011 static int sysc_show_name(char *bufp, struct sysc *ddata) in sysc_show_name() argument
1013 if (!ddata->name) in sysc_show_name()
1016 return sprintf(bufp, ":%s", ddata->name); in sysc_show_name()
1023 static void sysc_show_registers(struct sysc *ddata) in sysc_show_registers() argument
1030 bufp += sysc_show_reg(ddata, bufp, i); in sysc_show_registers()
1032 bufp += sysc_show_rev(bufp, ddata); in sysc_show_registers()
1033 bufp += sysc_show_name(bufp, ddata); in sysc_show_registers()
1035 dev_dbg(ddata->dev, "%llx:%x%s\n", in sysc_show_registers()
1036 ddata->module_pa, ddata->module_size, in sysc_show_registers()
1045 static void sysc_write_sysconfig(struct sysc *ddata, u32 value) in sysc_write_sysconfig() argument
1047 if (ddata->module_unlock_quirk) in sysc_write_sysconfig()
1048 ddata->module_unlock_quirk(ddata); in sysc_write_sysconfig()
1050 sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], value); in sysc_write_sysconfig()
1052 if (ddata->module_lock_quirk) in sysc_write_sysconfig()
1053 ddata->module_lock_quirk(ddata); in sysc_write_sysconfig()
1062 struct sysc *ddata; in sysc_enable_module() local
1067 ddata = dev_get_drvdata(dev); in sysc_enable_module()
1073 if (ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_IN_RESET) { in sysc_enable_module()
1074 error = sysc_enable_opt_clocks(ddata); in sysc_enable_module()
1076 dev_err(ddata->dev, in sysc_enable_module()
1086 if (!(ddata->cfg.quirks & SYSC_MODULE_QUIRK_ENA_RESETDONE)) { in sysc_enable_module()
1087 error = sysc_wait_softreset(ddata); in sysc_enable_module()
1089 dev_warn(ddata->dev, "OCP softreset timed out\n"); in sysc_enable_module()
1091 if (ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_IN_RESET) in sysc_enable_module()
1092 sysc_disable_opt_clocks(ddata); in sysc_enable_module()
1099 if (ddata->offsets[SYSC_SYSCONFIG] == -ENODEV) in sysc_enable_module()
1102 regbits = ddata->cap->regbits; in sysc_enable_module()
1103 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_enable_module()
1111 (ddata->cfg.quirks & SYSC_QUIRK_USE_CLOCKACT)) in sysc_enable_module()
1115 idlemodes = ddata->cfg.sidlemodes; in sysc_enable_module()
1119 if (ddata->cfg.quirks & (SYSC_QUIRK_SWSUP_SIDLE | in sysc_enable_module()
1123 best_mode = fls(ddata->cfg.sidlemodes) - 1; in sysc_enable_module()
1131 ddata->cfg.sysc_val & BIT(regbits->enwkup_shift)) in sysc_enable_module()
1137 sysc_write_sysconfig(ddata, reg); in sysc_enable_module()
1141 idlemodes = ddata->cfg.midlemodes; in sysc_enable_module()
1145 best_mode = fls(ddata->cfg.midlemodes) - 1; in sysc_enable_module()
1152 if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_MSTANDBY) in sysc_enable_module()
1157 sysc_write_sysconfig(ddata, reg); in sysc_enable_module()
1162 ddata->cfg.sysc_val & BIT(regbits->autoidle_shift)) { in sysc_enable_module()
1164 sysc_write_sysconfig(ddata, reg); in sysc_enable_module()
1171 ddata->sysconfig = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_enable_module()
1173 if (ddata->module_enable_quirk) in sysc_enable_module()
1174 ddata->module_enable_quirk(ddata); in sysc_enable_module()
1196 struct sysc *ddata; in sysc_disable_module() local
1201 ddata = dev_get_drvdata(dev); in sysc_disable_module()
1202 if (ddata->offsets[SYSC_SYSCONFIG] == -ENODEV) in sysc_disable_module()
1205 if (ddata->module_disable_quirk) in sysc_disable_module()
1206 ddata->module_disable_quirk(ddata); in sysc_disable_module()
1208 regbits = ddata->cap->regbits; in sysc_disable_module()
1209 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_disable_module()
1212 idlemodes = ddata->cfg.midlemodes; in sysc_disable_module()
1222 if (ddata->cfg.quirks & (SYSC_QUIRK_SWSUP_MSTANDBY) || in sysc_disable_module()
1223 ddata->cfg.quirks & (SYSC_QUIRK_FORCE_MSTANDBY)) in sysc_disable_module()
1228 sysc_write_sysconfig(ddata, reg); in sysc_disable_module()
1232 idlemodes = ddata->cfg.sidlemodes; in sysc_disable_module()
1238 if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_SIDLE) { in sysc_disable_module()
1252 ddata->cfg.sysc_val & BIT(regbits->autoidle_shift)) in sysc_disable_module()
1254 sysc_write_sysconfig(ddata, reg); in sysc_disable_module()
1260 ddata->sysconfig = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_disable_module()
1266 struct sysc *ddata) in sysc_runtime_suspend_legacy() argument
1271 pdata = dev_get_platdata(ddata->dev); in sysc_runtime_suspend_legacy()
1278 error = pdata->idle_module(dev, &ddata->cookie); in sysc_runtime_suspend_legacy()
1283 reset_control_assert(ddata->rsts); in sysc_runtime_suspend_legacy()
1289 struct sysc *ddata) in sysc_runtime_resume_legacy() argument
1294 pdata = dev_get_platdata(ddata->dev); in sysc_runtime_resume_legacy()
1301 error = pdata->enable_module(dev, &ddata->cookie); in sysc_runtime_resume_legacy()
1306 reset_control_deassert(ddata->rsts); in sysc_runtime_resume_legacy()
1313 struct sysc *ddata; in sysc_runtime_suspend() local
1316 ddata = dev_get_drvdata(dev); in sysc_runtime_suspend()
1318 if (!ddata->enabled) in sysc_runtime_suspend()
1321 sysc_clkdm_deny_idle(ddata); in sysc_runtime_suspend()
1323 if (ddata->legacy_mode) { in sysc_runtime_suspend()
1324 error = sysc_runtime_suspend_legacy(dev, ddata); in sysc_runtime_suspend()
1333 sysc_disable_main_clocks(ddata); in sysc_runtime_suspend()
1335 if (sysc_opt_clks_needed(ddata)) in sysc_runtime_suspend()
1336 sysc_disable_opt_clocks(ddata); in sysc_runtime_suspend()
1338 ddata->enabled = false; in sysc_runtime_suspend()
1341 sysc_clkdm_allow_idle(ddata); in sysc_runtime_suspend()
1343 reset_control_assert(ddata->rsts); in sysc_runtime_suspend()
1350 struct sysc *ddata; in sysc_runtime_resume() local
1353 ddata = dev_get_drvdata(dev); in sysc_runtime_resume()
1355 if (ddata->enabled) in sysc_runtime_resume()
1359 sysc_clkdm_deny_idle(ddata); in sysc_runtime_resume()
1361 if (sysc_opt_clks_needed(ddata)) { in sysc_runtime_resume()
1362 error = sysc_enable_opt_clocks(ddata); in sysc_runtime_resume()
1367 error = sysc_enable_main_clocks(ddata); in sysc_runtime_resume()
1371 reset_control_deassert(ddata->rsts); in sysc_runtime_resume()
1373 if (ddata->legacy_mode) { in sysc_runtime_resume()
1374 error = sysc_runtime_resume_legacy(dev, ddata); in sysc_runtime_resume()
1383 ddata->enabled = true; in sysc_runtime_resume()
1385 sysc_clkdm_allow_idle(ddata); in sysc_runtime_resume()
1390 sysc_disable_main_clocks(ddata); in sysc_runtime_resume()
1392 if (sysc_opt_clks_needed(ddata)) in sysc_runtime_resume()
1393 sysc_disable_opt_clocks(ddata); in sysc_runtime_resume()
1395 sysc_clkdm_allow_idle(ddata); in sysc_runtime_resume()
1408 static int sysc_check_context(struct sysc *ddata) in sysc_check_context() argument
1412 if (!ddata->enabled) in sysc_check_context()
1415 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_check_context()
1416 if (reg == ddata->sysconfig) in sysc_check_context()
1422 static int sysc_reinit_module(struct sysc *ddata, bool leave_enabled) in sysc_reinit_module() argument
1424 struct device *dev = ddata->dev; in sysc_reinit_module()
1427 if (ddata->enabled) { in sysc_reinit_module()
1429 error = sysc_check_context(ddata); in sysc_reinit_module()
1445 if (ddata->cfg.quirks & SYSC_QUIRK_RESET_ON_CTX_LOST) { in sysc_reinit_module()
1446 error = sysc_reset(ddata); in sysc_reinit_module()
1450 sysc_write_sysconfig(ddata, ddata->sysconfig); in sysc_reinit_module()
1466 struct sysc *ddata; in sysc_noirq_suspend() local
1468 ddata = dev_get_drvdata(dev); in sysc_noirq_suspend()
1470 if (ddata->cfg.quirks & in sysc_noirq_suspend()
1474 if (!ddata->enabled) in sysc_noirq_suspend()
1477 ddata->needs_resume = 1; in sysc_noirq_suspend()
1484 struct sysc *ddata; in sysc_noirq_resume() local
1487 ddata = dev_get_drvdata(dev); in sysc_noirq_resume()
1489 if (ddata->cfg.quirks & in sysc_noirq_resume()
1493 if (ddata->cfg.quirks & SYSC_QUIRK_REINIT_ON_RESUME) { in sysc_noirq_resume()
1494 error = sysc_reinit_module(ddata, ddata->needs_resume); in sysc_noirq_resume()
1497 } else if (ddata->needs_resume) { in sysc_noirq_resume()
1503 ddata->needs_resume = 0; in sysc_noirq_resume()
1710 static void sysc_init_early_quirks(struct sysc *ddata) in sysc_init_early_quirks() argument
1721 if (q->base != ddata->module_pa) in sysc_init_early_quirks()
1724 if (q->rev_offset != ddata->offsets[SYSC_REVISION]) in sysc_init_early_quirks()
1727 if (q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG]) in sysc_init_early_quirks()
1730 if (q->syss_offset != ddata->offsets[SYSC_SYSSTATUS]) in sysc_init_early_quirks()
1733 ddata->name = q->name; in sysc_init_early_quirks()
1734 ddata->cfg.quirks |= q->quirks; in sysc_init_early_quirks()
1739 static void sysc_init_revision_quirks(struct sysc *ddata) in sysc_init_revision_quirks() argument
1747 if (q->base && q->base != ddata->module_pa) in sysc_init_revision_quirks()
1750 if (q->rev_offset != ddata->offsets[SYSC_REVISION]) in sysc_init_revision_quirks()
1753 if (q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG]) in sysc_init_revision_quirks()
1756 if (q->syss_offset != ddata->offsets[SYSC_SYSSTATUS]) in sysc_init_revision_quirks()
1759 if (q->revision == ddata->revision || in sysc_init_revision_quirks()
1761 (ddata->revision & q->revision_mask)) { in sysc_init_revision_quirks()
1762 ddata->name = q->name; in sysc_init_revision_quirks()
1763 ddata->cfg.quirks |= q->quirks; in sysc_init_revision_quirks()
1773 static u32 sysc_quirk_dispc(struct sysc *ddata, int dispc_offset, in sysc_quirk_dispc() argument
1804 devm_iounmap(ddata->dev, ddata->module_va); in sysc_quirk_dispc()
1805 ddata->module_va = devm_ioremap(ddata->dev, in sysc_quirk_dispc()
1806 ddata->module_pa, in sysc_quirk_dispc()
1807 ddata->module_size); in sysc_quirk_dispc()
1808 if (!ddata->module_va) in sysc_quirk_dispc()
1812 val = sysc_read(ddata, dispc_offset + 0x40); in sysc_quirk_dispc()
1824 sysc_write(ddata, dispc_offset + 0x40, in sysc_quirk_dispc()
1831 val = sysc_read(ddata, dispc_offset + 0x238); in sysc_quirk_dispc()
1836 sysc_write(ddata, dispc_offset + 0x238, in sysc_quirk_dispc()
1843 val = sysc_read(ddata, dispc_offset + 0x848); in sysc_quirk_dispc()
1848 sysc_write(ddata, dispc_offset + 0x848, in sysc_quirk_dispc()
1855 static void sysc_pre_reset_quirk_dss(struct sysc *ddata) in sysc_pre_reset_quirk_dss() argument
1862 irq_mask = sysc_quirk_dispc(ddata, dispc_offset, false); in sysc_pre_reset_quirk_dss()
1867 sysc_write(ddata, dispc_offset + 0x18, irq_mask); in sysc_pre_reset_quirk_dss()
1870 val = sysc_quirk_dispc(ddata, dispc_offset, true); in sysc_pre_reset_quirk_dss()
1873 error = readl_poll_timeout(ddata->module_va + dispc_offset + 0x18, in sysc_pre_reset_quirk_dss()
1876 dev_warn(ddata->dev, "%s: timed out %08x !+ %08x\n", in sysc_pre_reset_quirk_dss()
1881 sysc_write(ddata, 0x44, 0); in sysc_pre_reset_quirk_dss()
1884 sysc_write(ddata, 0x48, 0); in sysc_pre_reset_quirk_dss()
1888 sysc_write(ddata, 0x40, 0); in sysc_pre_reset_quirk_dss()
1892 static void sysc_pre_reset_quirk_hdq1w(struct sysc *ddata) in sysc_pre_reset_quirk_hdq1w() argument
1897 val = sysc_read(ddata, offset); in sysc_pre_reset_quirk_hdq1w()
1899 sysc_write(ddata, offset, val); in sysc_pre_reset_quirk_hdq1w()
1903 static void sysc_module_enable_quirk_aess(struct sysc *ddata) in sysc_module_enable_quirk_aess() argument
1907 sysc_write(ddata, offset, 1); in sysc_module_enable_quirk_aess()
1911 static void sysc_clk_quirk_i2c(struct sysc *ddata, bool enable) in sysc_clk_quirk_i2c() argument
1917 if ((ddata->revision & 0xffffff00) == 0x001f0000) in sysc_clk_quirk_i2c()
1923 val = sysc_read(ddata, offset); in sysc_clk_quirk_i2c()
1928 sysc_write(ddata, offset, val); in sysc_clk_quirk_i2c()
1931 static void sysc_pre_reset_quirk_i2c(struct sysc *ddata) in sysc_pre_reset_quirk_i2c() argument
1933 sysc_clk_quirk_i2c(ddata, false); in sysc_pre_reset_quirk_i2c()
1936 static void sysc_post_reset_quirk_i2c(struct sysc *ddata) in sysc_post_reset_quirk_i2c() argument
1938 sysc_clk_quirk_i2c(ddata, true); in sysc_post_reset_quirk_i2c()
1942 static void sysc_quirk_rtc(struct sysc *ddata, bool lock) in sysc_quirk_rtc() argument
1955 error = readl_poll_timeout_atomic(ddata->module_va + 0x44, val, in sysc_quirk_rtc()
1958 dev_warn(ddata->dev, "rtc busy timeout\n"); in sysc_quirk_rtc()
1960 sysc_write(ddata, 0x6c, kick0_val); in sysc_quirk_rtc()
1961 sysc_write(ddata, 0x70, kick1_val); in sysc_quirk_rtc()
1965 static void sysc_module_unlock_quirk_rtc(struct sysc *ddata) in sysc_module_unlock_quirk_rtc() argument
1967 sysc_quirk_rtc(ddata, false); in sysc_module_unlock_quirk_rtc()
1970 static void sysc_module_lock_quirk_rtc(struct sysc *ddata) in sysc_module_lock_quirk_rtc() argument
1972 sysc_quirk_rtc(ddata, true); in sysc_module_lock_quirk_rtc()
1976 static void sysc_module_enable_quirk_otg(struct sysc *ddata) in sysc_module_enable_quirk_otg() argument
1980 sysc_write(ddata, offset, 0); in sysc_module_enable_quirk_otg()
1983 static void sysc_module_disable_quirk_otg(struct sysc *ddata) in sysc_module_disable_quirk_otg() argument
1988 sysc_write(ddata, offset, val); in sysc_module_disable_quirk_otg()
1992 static void sysc_module_enable_quirk_sgx(struct sysc *ddata) in sysc_module_enable_quirk_sgx() argument
1997 sysc_write(ddata, offset, val); in sysc_module_enable_quirk_sgx()
2001 static void sysc_reset_done_quirk_wdt(struct sysc *ddata) in sysc_reset_done_quirk_wdt() argument
2009 sysc_write(ddata, spr, 0xaaaa); in sysc_reset_done_quirk_wdt()
2010 error = readl_poll_timeout(ddata->module_va + wps, val, in sysc_reset_done_quirk_wdt()
2014 dev_warn(ddata->dev, "wdt disable step1 failed\n"); in sysc_reset_done_quirk_wdt()
2016 sysc_write(ddata, spr, 0x5555); in sysc_reset_done_quirk_wdt()
2017 error = readl_poll_timeout(ddata->module_va + wps, val, in sysc_reset_done_quirk_wdt()
2021 dev_warn(ddata->dev, "wdt disable step2 failed\n"); in sysc_reset_done_quirk_wdt()
2025 static void sysc_module_disable_quirk_pruss(struct sysc *ddata) in sysc_module_disable_quirk_pruss() argument
2029 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); in sysc_module_disable_quirk_pruss()
2031 sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); in sysc_module_disable_quirk_pruss()
2034 static void sysc_init_module_quirks(struct sysc *ddata) in sysc_init_module_quirks() argument
2036 if (ddata->legacy_mode || !ddata->name) in sysc_init_module_quirks()
2039 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_HDQ1W) { in sysc_init_module_quirks()
2040 ddata->pre_reset_quirk = sysc_pre_reset_quirk_hdq1w; in sysc_init_module_quirks()
2046 if (ddata->cfg.quirks & SYSC_QUIRK_GPMC_DEBUG) { in sysc_init_module_quirks()
2047 ddata->cfg.quirks |= SYSC_QUIRK_NO_RESET_ON_INIT; in sysc_init_module_quirks()
2053 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_I2C) { in sysc_init_module_quirks()
2054 ddata->pre_reset_quirk = sysc_pre_reset_quirk_i2c; in sysc_init_module_quirks()
2055 ddata->post_reset_quirk = sysc_post_reset_quirk_i2c; in sysc_init_module_quirks()
2060 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_AESS) in sysc_init_module_quirks()
2061 ddata->module_enable_quirk = sysc_module_enable_quirk_aess; in sysc_init_module_quirks()
2063 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_DSS_RESET) in sysc_init_module_quirks()
2064 ddata->pre_reset_quirk = sysc_pre_reset_quirk_dss; in sysc_init_module_quirks()
2066 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_RTC_UNLOCK) { in sysc_init_module_quirks()
2067 ddata->module_unlock_quirk = sysc_module_unlock_quirk_rtc; in sysc_init_module_quirks()
2068 ddata->module_lock_quirk = sysc_module_lock_quirk_rtc; in sysc_init_module_quirks()
2073 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_OTG) { in sysc_init_module_quirks()
2074 ddata->module_enable_quirk = sysc_module_enable_quirk_otg; in sysc_init_module_quirks()
2075 ddata->module_disable_quirk = sysc_module_disable_quirk_otg; in sysc_init_module_quirks()
2078 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_SGX) in sysc_init_module_quirks()
2079 ddata->module_enable_quirk = sysc_module_enable_quirk_sgx; in sysc_init_module_quirks()
2081 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_WDT) { in sysc_init_module_quirks()
2082 ddata->reset_done_quirk = sysc_reset_done_quirk_wdt; in sysc_init_module_quirks()
2083 ddata->module_disable_quirk = sysc_reset_done_quirk_wdt; in sysc_init_module_quirks()
2086 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_PRUSS) in sysc_init_module_quirks()
2087 ddata->module_disable_quirk = sysc_module_disable_quirk_pruss; in sysc_init_module_quirks()
2090 static int sysc_clockdomain_init(struct sysc *ddata) in sysc_clockdomain_init() argument
2092 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); in sysc_clockdomain_init()
2099 switch (ddata->nr_clocks) { in sysc_clockdomain_init()
2101 ick = ddata->clocks[SYSC_ICK]; in sysc_clockdomain_init()
2104 fck = ddata->clocks[SYSC_FCK]; in sysc_clockdomain_init()
2110 error = pdata->init_clockdomain(ddata->dev, fck, ick, &ddata->cookie); in sysc_clockdomain_init()
2122 static int sysc_legacy_init(struct sysc *ddata) in sysc_legacy_init() argument
2124 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); in sysc_legacy_init()
2130 error = pdata->init_module(ddata->dev, ddata->mdata, &ddata->cookie); in sysc_legacy_init()
2141 static int sysc_reset(struct sysc *ddata) in sysc_reset() argument
2146 sysc_offset = ddata->offsets[SYSC_SYSCONFIG]; in sysc_reset()
2148 if (ddata->legacy_mode || in sysc_reset()
2149 ddata->cap->regbits->srst_shift < 0 || in sysc_reset()
2150 ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) in sysc_reset()
2153 sysc_mask = BIT(ddata->cap->regbits->srst_shift); in sysc_reset()
2155 if (ddata->pre_reset_quirk) in sysc_reset()
2156 ddata->pre_reset_quirk(ddata); in sysc_reset()
2159 sysc_val = sysc_read_sysconfig(ddata); in sysc_reset()
2161 sysc_write(ddata, sysc_offset, sysc_val); in sysc_reset()
2164 if (ddata->cfg.srst_udelay) in sysc_reset()
2165 usleep_range(ddata->cfg.srst_udelay, in sysc_reset()
2166 ddata->cfg.srst_udelay * 2); in sysc_reset()
2168 if (ddata->post_reset_quirk) in sysc_reset()
2169 ddata->post_reset_quirk(ddata); in sysc_reset()
2171 error = sysc_wait_softreset(ddata); in sysc_reset()
2173 dev_warn(ddata->dev, "OCP softreset timed out\n"); in sysc_reset()
2175 if (ddata->reset_done_quirk) in sysc_reset()
2176 ddata->reset_done_quirk(ddata); in sysc_reset()
2187 static int sysc_init_module(struct sysc *ddata) in sysc_init_module() argument
2192 error = sysc_clockdomain_init(ddata); in sysc_init_module()
2196 sysc_clkdm_deny_idle(ddata); in sysc_init_module()
2202 error = sysc_enable_opt_clocks(ddata); in sysc_init_module()
2206 error = sysc_enable_main_clocks(ddata); in sysc_init_module()
2210 if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) { in sysc_init_module()
2211 error = reset_control_deassert(ddata->rsts); in sysc_init_module()
2217 ddata->revision = sysc_read_revision(ddata); in sysc_init_module()
2218 sysc_init_revision_quirks(ddata); in sysc_init_module()
2219 sysc_init_module_quirks(ddata); in sysc_init_module()
2221 if (ddata->legacy_mode) { in sysc_init_module()
2222 error = sysc_legacy_init(ddata); in sysc_init_module()
2227 if (!ddata->legacy_mode) { in sysc_init_module()
2228 error = sysc_enable_module(ddata->dev); in sysc_init_module()
2233 error = sysc_reset(ddata); in sysc_init_module()
2235 dev_err(ddata->dev, "Reset failed with %d\n", error); in sysc_init_module()
2237 if (error && !ddata->legacy_mode) in sysc_init_module()
2238 sysc_disable_module(ddata->dev); in sysc_init_module()
2242 sysc_disable_main_clocks(ddata); in sysc_init_module()
2246 sysc_disable_opt_clocks(ddata); in sysc_init_module()
2247 sysc_clkdm_allow_idle(ddata); in sysc_init_module()
2251 !(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) in sysc_init_module()
2252 reset_control_assert(ddata->rsts); in sysc_init_module()
2257 static int sysc_init_sysc_mask(struct sysc *ddata) in sysc_init_sysc_mask() argument
2259 struct device_node *np = ddata->dev->of_node; in sysc_init_sysc_mask()
2267 ddata->cfg.sysc_val = val & ddata->cap->sysc_mask; in sysc_init_sysc_mask()
2272 static int sysc_init_idlemode(struct sysc *ddata, u8 *idlemodes, in sysc_init_idlemode() argument
2275 struct device_node *np = ddata->dev->of_node; in sysc_init_idlemode()
2282 dev_err(ddata->dev, "invalid idlemode: %i\n", val); in sysc_init_idlemode()
2291 static int sysc_init_idlemodes(struct sysc *ddata) in sysc_init_idlemodes() argument
2295 error = sysc_init_idlemode(ddata, &ddata->cfg.midlemodes, in sysc_init_idlemodes()
2300 error = sysc_init_idlemode(ddata, &ddata->cfg.sidlemodes, in sysc_init_idlemodes()
2315 static int sysc_init_syss_mask(struct sysc *ddata) in sysc_init_syss_mask() argument
2317 struct device_node *np = ddata->dev->of_node; in sysc_init_syss_mask()
2323 if ((ddata->cap->type == TI_SYSC_OMAP4 || in sysc_init_syss_mask()
2324 ddata->cap->type == TI_SYSC_OMAP4_TIMER) && in sysc_init_syss_mask()
2325 (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) in sysc_init_syss_mask()
2326 ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; in sysc_init_syss_mask()
2331 if (!(val & 1) && (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) in sysc_init_syss_mask()
2332 ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; in sysc_init_syss_mask()
2334 ddata->cfg.syss_mask = val; in sysc_init_syss_mask()
2343 static int sysc_child_add_named_clock(struct sysc *ddata, in sysc_child_add_named_clock() argument
2360 clk = clk_get(ddata->dev, name); in sysc_child_add_named_clock()
2373 static int sysc_child_add_clocks(struct sysc *ddata, in sysc_child_add_clocks() argument
2378 for (i = 0; i < ddata->nr_clocks; i++) { in sysc_child_add_clocks()
2379 error = sysc_child_add_named_clock(ddata, in sysc_child_add_clocks()
2381 ddata->clock_roles[i]); in sysc_child_add_clocks()
2383 dev_err(ddata->dev, "could not add child clock %s: %i\n", in sysc_child_add_clocks()
2384 ddata->clock_roles[i], error); in sysc_child_add_clocks()
2408 struct sysc *ddata; in sysc_child_runtime_suspend() local
2411 ddata = sysc_child_to_parent(dev); in sysc_child_runtime_suspend()
2417 if (!ddata->enabled) in sysc_child_runtime_suspend()
2420 return sysc_runtime_suspend(ddata->dev); in sysc_child_runtime_suspend()
2425 struct sysc *ddata; in sysc_child_runtime_resume() local
2428 ddata = sysc_child_to_parent(dev); in sysc_child_runtime_resume()
2430 if (!ddata->enabled) { in sysc_child_runtime_resume()
2431 error = sysc_runtime_resume(ddata->dev); in sysc_child_runtime_resume()
2433 dev_err(ddata->dev, in sysc_child_runtime_resume()
2443 struct sysc *ddata; in sysc_child_suspend_noirq() local
2446 ddata = sysc_child_to_parent(dev); in sysc_child_suspend_noirq()
2448 dev_dbg(ddata->dev, "%s %s\n", __func__, in sysc_child_suspend_noirq()
2449 ddata->name ? ddata->name : ""); in sysc_child_suspend_noirq()
2468 error = sysc_runtime_suspend(ddata->dev); in sysc_child_suspend_noirq()
2476 ddata->child_needs_resume = true; in sysc_child_suspend_noirq()
2484 struct sysc *ddata; in sysc_child_resume_noirq() local
2487 ddata = sysc_child_to_parent(dev); in sysc_child_resume_noirq()
2489 dev_dbg(ddata->dev, "%s %s\n", __func__, in sysc_child_resume_noirq()
2490 ddata->name ? ddata->name : ""); in sysc_child_resume_noirq()
2492 if (ddata->child_needs_resume) { in sysc_child_resume_noirq()
2493 ddata->child_needs_resume = false; in sysc_child_resume_noirq()
2495 error = sysc_runtime_resume(ddata->dev); in sysc_child_resume_noirq()
2497 dev_err(ddata->dev, in sysc_child_resume_noirq()
2503 dev_err(ddata->dev, in sysc_child_resume_noirq()
2528 struct sysc *ddata; in sysc_reinit_modules() local
2532 ddata = module->ddata; in sysc_reinit_modules()
2533 sysc_reinit_module(ddata, ddata->enabled); in sysc_reinit_modules()
2571 static void sysc_add_restored(struct sysc *ddata) in sysc_add_restored() argument
2579 restored_module->ddata = ddata; in sysc_add_restored()
2608 static void sysc_legacy_idle_quirk(struct sysc *ddata, struct device *child) in sysc_legacy_idle_quirk() argument
2610 if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) in sysc_legacy_idle_quirk()
2618 struct sysc *ddata; in sysc_notifier_call() local
2621 ddata = sysc_child_to_parent(dev); in sysc_notifier_call()
2622 if (!ddata) in sysc_notifier_call()
2627 error = sysc_child_add_clocks(ddata, dev); in sysc_notifier_call()
2630 sysc_legacy_idle_quirk(ddata, dev); in sysc_notifier_call()
2658 static void sysc_parse_dts_quirks(struct sysc *ddata, struct device_node *np, in sysc_parse_dts_quirks() argument
2671 ddata->cfg.quirks |= sysc_dts_quirks[i].mask; in sysc_parse_dts_quirks()
2673 dev_warn(ddata->dev, in sysc_parse_dts_quirks()
2680 static int sysc_init_dts_quirks(struct sysc *ddata) in sysc_init_dts_quirks() argument
2682 struct device_node *np = ddata->dev->of_node; in sysc_init_dts_quirks()
2686 ddata->legacy_mode = of_get_property(np, "ti,hwmods", NULL); in sysc_init_dts_quirks()
2688 sysc_parse_dts_quirks(ddata, np, false); in sysc_init_dts_quirks()
2692 dev_warn(ddata->dev, "bad ti,sysc-delay-us: %i\n", in sysc_init_dts_quirks()
2696 ddata->cfg.srst_udelay = (u8)val; in sysc_init_dts_quirks()
2702 static void sysc_unprepare(struct sysc *ddata) in sysc_unprepare() argument
2706 if (!ddata->clocks) in sysc_unprepare()
2710 if (!IS_ERR_OR_NULL(ddata->clocks[i])) in sysc_unprepare()
2711 clk_unprepare(ddata->clocks[i]); in sysc_unprepare()
2962 static int sysc_init_pdata(struct sysc *ddata) in sysc_init_pdata() argument
2964 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); in sysc_init_pdata()
2970 mdata = devm_kzalloc(ddata->dev, sizeof(*mdata), GFP_KERNEL); in sysc_init_pdata()
2974 if (ddata->legacy_mode) { in sysc_init_pdata()
2975 mdata->name = ddata->legacy_mode; in sysc_init_pdata()
2976 mdata->module_pa = ddata->module_pa; in sysc_init_pdata()
2977 mdata->module_size = ddata->module_size; in sysc_init_pdata()
2978 mdata->offsets = ddata->offsets; in sysc_init_pdata()
2980 mdata->cap = ddata->cap; in sysc_init_pdata()
2981 mdata->cfg = &ddata->cfg; in sysc_init_pdata()
2984 ddata->mdata = mdata; in sysc_init_pdata()
2989 static int sysc_init_match(struct sysc *ddata) in sysc_init_match() argument
2993 cap = of_device_get_match_data(ddata->dev); in sysc_init_match()
2997 ddata->cap = cap; in sysc_init_match()
2998 if (ddata->cap) in sysc_init_match()
2999 ddata->cfg.quirks |= ddata->cap->mod_quirks; in sysc_init_match()
3006 struct sysc *ddata; in ti_sysc_idle() local
3008 ddata = container_of(work, struct sysc, idle_work.work); in ti_sysc_idle()
3016 if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE | in ti_sysc_idle()
3018 sysc_disable_main_clocks(ddata); in ti_sysc_idle()
3019 sysc_disable_opt_clocks(ddata); in ti_sysc_idle()
3020 sysc_clkdm_allow_idle(ddata); in ti_sysc_idle()
3024 if (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE) in ti_sysc_idle()
3031 if (pm_runtime_active(ddata->dev)) in ti_sysc_idle()
3032 pm_runtime_put_sync(ddata->dev); in ti_sysc_idle()
3101 static int sysc_init_static_data(struct sysc *ddata) in sysc_init_static_data() argument
3120 pdata = dev_get_platdata(ddata->dev); in sysc_init_static_data()
3208 static int sysc_check_disabled_devices(struct sysc *ddata) in sysc_check_disabled_devices() argument
3217 if (ddata->module_pa == disabled_module->base) { in sysc_check_disabled_devices()
3218 dev_dbg(ddata->dev, "module disabled for this SoC\n"); in sysc_check_disabled_devices()
3233 static int sysc_check_active_timer(struct sysc *ddata) in sysc_check_active_timer() argument
3237 if (ddata->cap->type != TI_SYSC_OMAP2_TIMER && in sysc_check_active_timer()
3238 ddata->cap->type != TI_SYSC_OMAP4_TIMER) in sysc_check_active_timer()
3253 if ((ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) && in sysc_check_active_timer()
3254 (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE)) in sysc_check_active_timer()
3268 struct sysc *ddata; in sysc_probe() local
3271 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); in sysc_probe()
3272 if (!ddata) in sysc_probe()
3275 ddata->offsets[SYSC_REVISION] = -ENODEV; in sysc_probe()
3276 ddata->offsets[SYSC_SYSCONFIG] = -ENODEV; in sysc_probe()
3277 ddata->offsets[SYSC_SYSSTATUS] = -ENODEV; in sysc_probe()
3278 ddata->dev = &pdev->dev; in sysc_probe()
3279 platform_set_drvdata(pdev, ddata); in sysc_probe()
3281 error = sysc_init_static_data(ddata); in sysc_probe()
3285 error = sysc_init_match(ddata); in sysc_probe()
3289 error = sysc_init_dts_quirks(ddata); in sysc_probe()
3293 error = sysc_map_and_check_registers(ddata); in sysc_probe()
3297 error = sysc_init_sysc_mask(ddata); in sysc_probe()
3301 error = sysc_init_idlemodes(ddata); in sysc_probe()
3305 error = sysc_init_syss_mask(ddata); in sysc_probe()
3309 error = sysc_init_pdata(ddata); in sysc_probe()
3313 sysc_init_early_quirks(ddata); in sysc_probe()
3315 error = sysc_check_disabled_devices(ddata); in sysc_probe()
3319 error = sysc_check_active_timer(ddata); in sysc_probe()
3321 ddata->reserved = true; in sysc_probe()
3325 error = sysc_get_clocks(ddata); in sysc_probe()
3329 error = sysc_init_resets(ddata); in sysc_probe()
3333 error = sysc_init_module(ddata); in sysc_probe()
3337 pm_runtime_enable(ddata->dev); in sysc_probe()
3338 error = pm_runtime_resume_and_get(ddata->dev); in sysc_probe()
3340 pm_runtime_disable(ddata->dev); in sysc_probe()
3345 if (!(ddata->cfg.quirks & in sysc_probe()
3347 sysc_disable_main_clocks(ddata); in sysc_probe()
3348 sysc_disable_opt_clocks(ddata); in sysc_probe()
3349 sysc_clkdm_allow_idle(ddata); in sysc_probe()
3352 if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) in sysc_probe()
3353 reset_control_assert(ddata->rsts); in sysc_probe()
3355 sysc_show_registers(ddata); in sysc_probe()
3357 ddata->dev->type = &sysc_device_type; in sysc_probe()
3359 if (!ddata->reserved) { in sysc_probe()
3360 error = of_platform_populate(ddata->dev->of_node, in sysc_probe()
3363 ddata->dev); in sysc_probe()
3368 INIT_DELAYED_WORK(&ddata->idle_work, ti_sysc_idle); in sysc_probe()
3371 if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE | in sysc_probe()
3374 schedule_delayed_work(&ddata->idle_work, 3000); in sysc_probe()
3379 if (ddata->cfg.quirks & SYSC_QUIRK_REINIT_ON_CTX_LOST) in sysc_probe()
3380 sysc_add_restored(ddata); in sysc_probe()
3388 sysc_unprepare(ddata); in sysc_probe()
3395 struct sysc *ddata = platform_get_drvdata(pdev); in sysc_remove() local
3399 if (cancel_delayed_work_sync(&ddata->idle_work)) in sysc_remove()
3400 ti_sysc_idle(&ddata->idle_work.work); in sysc_remove()
3402 error = pm_runtime_resume_and_get(ddata->dev); in sysc_remove()
3404 pm_runtime_disable(ddata->dev); in sysc_remove()
3413 if (!reset_control_status(ddata->rsts)) in sysc_remove()
3414 reset_control_assert(ddata->rsts); in sysc_remove()
3417 sysc_unprepare(ddata); in sysc_remove()