Lines Matching refs:oh
218 int (*reset)(struct omap_hwmod *oh);
231 void (*enable_module)(struct omap_hwmod *oh);
232 int (*disable_module)(struct omap_hwmod *oh);
233 int (*wait_target_ready)(struct omap_hwmod *oh);
234 int (*assert_hardreset)(struct omap_hwmod *oh,
236 int (*deassert_hardreset)(struct omap_hwmod *oh,
238 int (*is_hardreset_asserted)(struct omap_hwmod *oh,
240 int (*init_clkdm)(struct omap_hwmod *oh);
241 void (*update_context_lost)(struct omap_hwmod *oh);
242 int (*get_context_lost)(struct omap_hwmod *oh);
243 int (*disable_direct_prcm)(struct omap_hwmod *oh);
244 u32 (*xlate_clkctrl)(struct omap_hwmod *oh);
270 static int _update_sysc_cache(struct omap_hwmod *oh) in _update_sysc_cache() argument
272 if (!oh->class->sysc) { in _update_sysc_cache()
273 WARN(1, "omap_hwmod: %s: cannot read OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); in _update_sysc_cache()
279 oh->_sysc_cache = omap_hwmod_read(oh, oh->class->sysc->sysc_offs); in _update_sysc_cache()
281 if (!(oh->class->sysc->sysc_flags & SYSC_NO_CACHE)) in _update_sysc_cache()
282 oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED; in _update_sysc_cache()
295 static void _write_sysconfig(u32 v, struct omap_hwmod *oh) in _write_sysconfig() argument
297 if (!oh->class->sysc) { in _write_sysconfig()
298 WARN(1, "omap_hwmod: %s: cannot write OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); in _write_sysconfig()
305 oh->_sysc_cache = v; in _write_sysconfig()
313 if (oh->class->unlock) in _write_sysconfig()
314 oh->class->unlock(oh); in _write_sysconfig()
316 omap_hwmod_write(v, oh, oh->class->sysc->sysc_offs); in _write_sysconfig()
318 if (oh->class->lock) in _write_sysconfig()
319 oh->class->lock(oh); in _write_sysconfig()
332 static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, in _set_master_standbymode() argument
338 if (!oh->class->sysc || in _set_master_standbymode()
339 !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE)) in _set_master_standbymode()
342 if (!oh->class->sysc->sysc_fields) { in _set_master_standbymode()
343 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_master_standbymode()
347 mstandby_shift = oh->class->sysc->sysc_fields->midle_shift; in _set_master_standbymode()
366 static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) in _set_slave_idlemode() argument
371 if (!oh->class->sysc || in _set_slave_idlemode()
372 !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE)) in _set_slave_idlemode()
375 if (!oh->class->sysc->sysc_fields) { in _set_slave_idlemode()
376 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_slave_idlemode()
380 sidle_shift = oh->class->sysc->sysc_fields->sidle_shift; in _set_slave_idlemode()
400 static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) in _set_clockactivity() argument
405 if (!oh->class->sysc || in _set_clockactivity()
406 !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) in _set_clockactivity()
409 if (!oh->class->sysc->sysc_fields) { in _set_clockactivity()
410 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_clockactivity()
414 clkact_shift = oh->class->sysc->sysc_fields->clkact_shift; in _set_clockactivity()
431 static int _set_softreset(struct omap_hwmod *oh, u32 *v) in _set_softreset() argument
435 if (!oh->class->sysc || in _set_softreset()
436 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _set_softreset()
439 if (!oh->class->sysc->sysc_fields) { in _set_softreset()
440 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_softreset()
444 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _set_softreset()
459 static int _clear_softreset(struct omap_hwmod *oh, u32 *v) in _clear_softreset() argument
463 if (!oh->class->sysc || in _clear_softreset()
464 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _clear_softreset()
467 if (!oh->class->sysc->sysc_fields) { in _clear_softreset()
470 oh->name); in _clear_softreset()
474 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _clear_softreset()
491 static int _wait_softreset_complete(struct omap_hwmod *oh) in _wait_softreset_complete() argument
497 sysc = oh->class->sysc; in _wait_softreset_complete()
500 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs) in _wait_softreset_complete()
505 omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs) in _wait_softreset_complete()
525 static int _set_dmadisable(struct omap_hwmod *oh) in _set_dmadisable() argument
530 if (!oh->class->sysc || in _set_dmadisable()
531 !(oh->class->sysc->sysc_flags & SYSC_HAS_DMADISABLE)) in _set_dmadisable()
534 if (!oh->class->sysc->sysc_fields) { in _set_dmadisable()
535 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_dmadisable()
540 if (oh->_state != _HWMOD_STATE_ENABLED) { in _set_dmadisable()
541 pr_warn("omap_hwmod: %s: dma can be disabled only from enabled state\n", oh->name); in _set_dmadisable()
545 pr_debug("omap_hwmod: %s: setting DMADISABLE\n", oh->name); in _set_dmadisable()
547 v = oh->_sysc_cache; in _set_dmadisable()
549 (0x1 << oh->class->sysc->sysc_fields->dmadisable_shift); in _set_dmadisable()
551 _write_sysconfig(v, oh); in _set_dmadisable()
569 static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, in _set_module_autoidle() argument
575 if (!oh->class->sysc || in _set_module_autoidle()
576 !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE)) in _set_module_autoidle()
579 if (!oh->class->sysc->sysc_fields) { in _set_module_autoidle()
580 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _set_module_autoidle()
584 autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift; in _set_module_autoidle()
600 static int _enable_wakeup(struct omap_hwmod *oh, u32 *v) in _enable_wakeup() argument
602 if (!oh->class->sysc || in _enable_wakeup()
603 !((oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) || in _enable_wakeup()
604 (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) || in _enable_wakeup()
605 (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP))) in _enable_wakeup()
608 if (!oh->class->sysc->sysc_fields) { in _enable_wakeup()
609 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); in _enable_wakeup()
613 if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) in _enable_wakeup()
614 *v |= 0x1 << oh->class->sysc->sysc_fields->enwkup_shift; in _enable_wakeup()
616 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_wakeup()
617 _set_slave_idlemode(oh, HWMOD_IDLEMODE_SMART_WKUP, v); in _enable_wakeup()
618 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_wakeup()
619 _set_master_standbymode(oh, HWMOD_IDLEMODE_SMART_WKUP, v); in _enable_wakeup()
626 static struct clockdomain *_get_clkdm(struct omap_hwmod *oh) in _get_clkdm() argument
630 if (oh->clkdm) { in _get_clkdm()
631 return oh->clkdm; in _get_clkdm()
632 } else if (oh->_clk) { in _get_clkdm()
633 if (!omap2_clk_is_hw_omap(__clk_get_hw(oh->_clk))) in _get_clkdm()
635 clk = to_clk_hw_omap(__clk_get_hw(oh->_clk)); in _get_clkdm()
654 static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) in _add_initiator_dep() argument
658 clkdm = _get_clkdm(oh); in _add_initiator_dep()
683 static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) in _del_initiator_dep() argument
687 clkdm = _get_clkdm(oh); in _del_initiator_dep()
761 static u32 _omap4_xlate_clkctrl(struct omap_hwmod *oh) in _omap4_xlate_clkctrl() argument
763 if (!oh->prcm.omap4.modulemode) in _omap4_xlate_clkctrl()
766 return omap_cm_xlate_clkctrl(oh->clkdm->prcm_partition, in _omap4_xlate_clkctrl()
767 oh->clkdm->cm_inst, in _omap4_xlate_clkctrl()
768 oh->prcm.omap4.clkctrl_offs); in _omap4_xlate_clkctrl()
771 static struct clk *_lookup_clkctrl_clk(struct omap_hwmod *oh) in _lookup_clkctrl_clk() argument
780 addr = soc_ops.xlate_clkctrl(oh); in _lookup_clkctrl_clk()
784 pr_debug("%s: %s: addr=%x\n", __func__, oh->name, addr); in _lookup_clkctrl_clk()
802 __func__, oh->name, clk, in _lookup_clkctrl_clk()
821 static int _init_main_clk(struct omap_hwmod *oh) in _init_main_clk() argument
826 clk = _lookup_clkctrl_clk(oh); in _init_main_clk()
830 __clk_get_name(clk), oh->name); in _init_main_clk()
831 oh->main_clk = __clk_get_name(clk); in _init_main_clk()
832 oh->_clk = clk; in _init_main_clk()
833 soc_ops.disable_direct_prcm(oh); in _init_main_clk()
835 if (!oh->main_clk) in _init_main_clk()
838 oh->_clk = clk_get(NULL, oh->main_clk); in _init_main_clk()
841 if (IS_ERR(oh->_clk)) { in _init_main_clk()
843 oh->name, oh->main_clk); in _init_main_clk()
854 clk_prepare(oh->_clk); in _init_main_clk()
856 if (!_get_clkdm(oh)) in _init_main_clk()
858 oh->name, oh->main_clk); in _init_main_clk()
870 static int _init_interface_clks(struct omap_hwmod *oh) in _init_interface_clks() argument
876 list_for_each_entry(os, &oh->slave_ports, node) { in _init_interface_clks()
883 oh->name, os->clk); in _init_interface_clks()
909 static int _init_opt_clks(struct omap_hwmod *oh) in _init_opt_clks() argument
916 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) { in _init_opt_clks()
920 oh->name, oc->clk); in _init_opt_clks()
939 static void _enable_optional_clocks(struct omap_hwmod *oh) in _enable_optional_clocks() argument
944 pr_debug("omap_hwmod: %s: enabling optional clocks\n", oh->name); in _enable_optional_clocks()
946 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _enable_optional_clocks()
954 static void _disable_optional_clocks(struct omap_hwmod *oh) in _disable_optional_clocks() argument
959 pr_debug("omap_hwmod: %s: disabling optional clocks\n", oh->name); in _disable_optional_clocks()
961 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _disable_optional_clocks()
976 static int _enable_clocks(struct omap_hwmod *oh) in _enable_clocks() argument
980 pr_debug("omap_hwmod: %s: enabling clocks\n", oh->name); in _enable_clocks()
982 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _enable_clocks()
983 _enable_optional_clocks(oh); in _enable_clocks()
985 if (oh->_clk) in _enable_clocks()
986 clk_enable(oh->_clk); in _enable_clocks()
988 list_for_each_entry(os, &oh->slave_ports, node) { in _enable_clocks()
1004 static bool _omap4_clkctrl_managed_by_clkfwk(struct omap_hwmod *oh) in _omap4_clkctrl_managed_by_clkfwk() argument
1006 if (oh->prcm.omap4.flags & HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK) in _omap4_clkctrl_managed_by_clkfwk()
1016 static bool _omap4_has_clkctrl_clock(struct omap_hwmod *oh) in _omap4_has_clkctrl_clock() argument
1018 if (oh->prcm.omap4.clkctrl_offs) in _omap4_has_clkctrl_clock()
1021 if (!oh->prcm.omap4.clkctrl_offs && in _omap4_has_clkctrl_clock()
1022 oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET) in _omap4_has_clkctrl_clock()
1034 static int _disable_clocks(struct omap_hwmod *oh) in _disable_clocks() argument
1038 pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name); in _disable_clocks()
1040 if (oh->_clk) in _disable_clocks()
1041 clk_disable(oh->_clk); in _disable_clocks()
1043 list_for_each_entry(os, &oh->slave_ports, node) { in _disable_clocks()
1050 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _disable_clocks()
1051 _disable_optional_clocks(oh); in _disable_clocks()
1065 static void _omap4_enable_module(struct omap_hwmod *oh) in _omap4_enable_module() argument
1067 if (!oh->clkdm || !oh->prcm.omap4.modulemode || in _omap4_enable_module()
1068 _omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_enable_module()
1072 oh->name, __func__, oh->prcm.omap4.modulemode); in _omap4_enable_module()
1074 omap_cm_module_enable(oh->prcm.omap4.modulemode, in _omap4_enable_module()
1075 oh->clkdm->prcm_partition, in _omap4_enable_module()
1076 oh->clkdm->cm_inst, oh->prcm.omap4.clkctrl_offs); in _omap4_enable_module()
1088 static int _omap4_wait_target_disable(struct omap_hwmod *oh) in _omap4_wait_target_disable() argument
1090 if (!oh) in _omap4_wait_target_disable()
1093 if (oh->_int_flags & _HWMOD_NO_MPU_PORT || !oh->clkdm) in _omap4_wait_target_disable()
1096 if (oh->flags & HWMOD_NO_IDLEST) in _omap4_wait_target_disable()
1099 if (_omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_wait_target_disable()
1102 if (!_omap4_has_clkctrl_clock(oh)) in _omap4_wait_target_disable()
1105 return omap_cm_wait_module_idle(oh->clkdm->prcm_partition, in _omap4_wait_target_disable()
1106 oh->clkdm->cm_inst, in _omap4_wait_target_disable()
1107 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_disable()
1119 static void __init _save_mpu_port_index(struct omap_hwmod *oh) in _save_mpu_port_index() argument
1123 if (!oh) in _save_mpu_port_index()
1126 oh->_int_flags |= _HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1128 list_for_each_entry(os, &oh->slave_ports, node) { in _save_mpu_port_index()
1130 oh->_mpu_port = os; in _save_mpu_port_index()
1131 oh->_int_flags &= ~_HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1152 static struct omap_hwmod_ocp_if *_find_mpu_rt_port(struct omap_hwmod *oh) in _find_mpu_rt_port() argument
1154 if (!oh || oh->_int_flags & _HWMOD_NO_MPU_PORT || oh->slaves_cnt == 0) in _find_mpu_rt_port()
1157 return oh->_mpu_port; in _find_mpu_rt_port()
1171 static void _enable_sysc(struct omap_hwmod *oh) in _enable_sysc() argument
1178 if (!oh->class->sysc) in _enable_sysc()
1187 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1188 _enable_optional_clocks(oh); in _enable_sysc()
1189 _wait_softreset_complete(oh); in _enable_sysc()
1190 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1191 _disable_optional_clocks(oh); in _enable_sysc()
1193 v = oh->_sysc_cache; in _enable_sysc()
1194 sf = oh->class->sysc->sysc_flags; in _enable_sysc()
1196 clkdm = _get_clkdm(oh); in _enable_sysc()
1198 if (oh->flags & HWMOD_SWSUP_SIDLE || in _enable_sysc()
1199 oh->flags & HWMOD_SWSUP_SIDLE_ACT) { in _enable_sysc()
1203 _enable_wakeup(oh, &v); in _enable_sysc()
1204 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_sysc()
1215 if (clkdm_act && !(oh->class->sysc->idlemodes & in _enable_sysc()
1219 _set_slave_idlemode(oh, idlemode, &v); in _enable_sysc()
1223 if (oh->flags & HWMOD_FORCE_MSTANDBY) { in _enable_sysc()
1225 } else if (oh->flags & HWMOD_SWSUP_MSTANDBY) { in _enable_sysc()
1229 _enable_wakeup(oh, &v); in _enable_sysc()
1230 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_sysc()
1235 _set_master_standbymode(oh, idlemode, &v); in _enable_sysc()
1243 if ((oh->flags & HWMOD_SET_DEFAULT_CLOCKACT) && in _enable_sysc()
1245 _set_clockactivity(oh, CLOCKACT_TEST_ICLK, &v); in _enable_sysc()
1247 _write_sysconfig(v, oh); in _enable_sysc()
1254 idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? in _enable_sysc()
1256 _set_module_autoidle(oh, idlemode, &v); in _enable_sysc()
1257 _write_sysconfig(v, oh); in _enable_sysc()
1270 static void _idle_sysc(struct omap_hwmod *oh) in _idle_sysc() argument
1275 if (!oh->class->sysc) in _idle_sysc()
1278 v = oh->_sysc_cache; in _idle_sysc()
1279 sf = oh->class->sysc->sysc_flags; in _idle_sysc()
1282 if (oh->flags & HWMOD_SWSUP_SIDLE) { in _idle_sysc()
1286 _enable_wakeup(oh, &v); in _idle_sysc()
1287 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _idle_sysc()
1292 _set_slave_idlemode(oh, idlemode, &v); in _idle_sysc()
1296 if ((oh->flags & HWMOD_SWSUP_MSTANDBY) || in _idle_sysc()
1297 (oh->flags & HWMOD_FORCE_MSTANDBY)) { in _idle_sysc()
1301 _enable_wakeup(oh, &v); in _idle_sysc()
1302 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _idle_sysc()
1307 _set_master_standbymode(oh, idlemode, &v); in _idle_sysc()
1311 if (oh->_sysc_cache != v) in _idle_sysc()
1312 _write_sysconfig(v, oh); in _idle_sysc()
1322 static void _shutdown_sysc(struct omap_hwmod *oh) in _shutdown_sysc() argument
1327 if (!oh->class->sysc) in _shutdown_sysc()
1330 v = oh->_sysc_cache; in _shutdown_sysc()
1331 sf = oh->class->sysc->sysc_flags; in _shutdown_sysc()
1334 _set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v); in _shutdown_sysc()
1337 _set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v); in _shutdown_sysc()
1340 _set_module_autoidle(oh, 1, &v); in _shutdown_sysc()
1342 _write_sysconfig(v, oh); in _shutdown_sysc()
1353 struct omap_hwmod *oh, *temp_oh; in _lookup() local
1355 oh = NULL; in _lookup()
1359 oh = temp_oh; in _lookup()
1364 return oh; in _lookup()
1375 static int _init_clkdm(struct omap_hwmod *oh) in _init_clkdm() argument
1377 if (!oh->clkdm_name) { in _init_clkdm()
1378 pr_debug("omap_hwmod: %s: missing clockdomain\n", oh->name); in _init_clkdm()
1382 oh->clkdm = clkdm_lookup(oh->clkdm_name); in _init_clkdm()
1383 if (!oh->clkdm) { in _init_clkdm()
1385 oh->name, oh->clkdm_name); in _init_clkdm()
1390 oh->name, oh->clkdm_name); in _init_clkdm()
1405 static int _init_clocks(struct omap_hwmod *oh, struct device_node *np) in _init_clocks() argument
1409 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init_clocks()
1412 pr_debug("omap_hwmod: %s: looking up clocks\n", oh->name); in _init_clocks()
1415 ret |= soc_ops.init_clkdm(oh); in _init_clocks()
1417 ret |= _init_main_clk(oh); in _init_clocks()
1418 ret |= _init_interface_clks(oh); in _init_clocks()
1419 ret |= _init_opt_clks(oh); in _init_clocks()
1422 oh->_state = _HWMOD_STATE_CLKS_INITED; in _init_clocks()
1424 pr_warn("omap_hwmod: %s: cannot _init_clocks\n", oh->name); in _init_clocks()
1438 static int _lookup_hardreset(struct omap_hwmod *oh, const char *name, in _lookup_hardreset() argument
1443 for (i = 0; i < oh->rst_lines_cnt; i++) { in _lookup_hardreset()
1444 const char *rst_line = oh->rst_lines[i].name; in _lookup_hardreset()
1446 ohri->rst_shift = oh->rst_lines[i].rst_shift; in _lookup_hardreset()
1447 ohri->st_shift = oh->rst_lines[i].st_shift; in _lookup_hardreset()
1449 oh->name, __func__, rst_line, ohri->rst_shift, in _lookup_hardreset()
1472 static int _assert_hardreset(struct omap_hwmod *oh, const char *name) in _assert_hardreset() argument
1477 if (!oh) in _assert_hardreset()
1483 ret = _lookup_hardreset(oh, name, &ohri); in _assert_hardreset()
1487 ret = soc_ops.assert_hardreset(oh, &ohri); in _assert_hardreset()
1505 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name) in _deassert_hardreset() argument
1510 if (!oh) in _deassert_hardreset()
1516 ret = _lookup_hardreset(oh, name, &ohri); in _deassert_hardreset()
1520 if (oh->clkdm) { in _deassert_hardreset()
1526 clkdm_deny_idle(oh->clkdm); in _deassert_hardreset()
1527 ret = clkdm_hwmod_enable(oh->clkdm, oh); in _deassert_hardreset()
1530 oh->name, oh->clkdm->name, ret); in _deassert_hardreset()
1535 _enable_clocks(oh); in _deassert_hardreset()
1537 soc_ops.enable_module(oh); in _deassert_hardreset()
1539 ret = soc_ops.deassert_hardreset(oh, &ohri); in _deassert_hardreset()
1542 soc_ops.disable_module(oh); in _deassert_hardreset()
1543 _disable_clocks(oh); in _deassert_hardreset()
1546 pr_warn("omap_hwmod: %s: failed to hardreset\n", oh->name); in _deassert_hardreset()
1548 if (oh->clkdm) { in _deassert_hardreset()
1553 clkdm_allow_idle(oh->clkdm); in _deassert_hardreset()
1555 clkdm_hwmod_disable(oh->clkdm, oh); in _deassert_hardreset()
1573 static int _read_hardreset(struct omap_hwmod *oh, const char *name) in _read_hardreset() argument
1578 if (!oh) in _read_hardreset()
1584 ret = _lookup_hardreset(oh, name, &ohri); in _read_hardreset()
1588 return soc_ops.is_hardreset_asserted(oh, &ohri); in _read_hardreset()
1601 static bool _are_all_hardreset_lines_asserted(struct omap_hwmod *oh) in _are_all_hardreset_lines_asserted() argument
1605 if (oh->rst_lines_cnt == 0) in _are_all_hardreset_lines_asserted()
1608 for (i = 0; i < oh->rst_lines_cnt; i++) in _are_all_hardreset_lines_asserted()
1609 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_all_hardreset_lines_asserted()
1612 if (oh->rst_lines_cnt == rst_cnt) in _are_all_hardreset_lines_asserted()
1629 static bool _are_any_hardreset_lines_asserted(struct omap_hwmod *oh) in _are_any_hardreset_lines_asserted() argument
1634 for (i = 0; i < oh->rst_lines_cnt && rst_cnt == 0; i++) in _are_any_hardreset_lines_asserted()
1635 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_any_hardreset_lines_asserted()
1648 static int _omap4_disable_module(struct omap_hwmod *oh) in _omap4_disable_module() argument
1652 if (!oh->clkdm || !oh->prcm.omap4.modulemode || in _omap4_disable_module()
1653 _omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_disable_module()
1660 if (_are_any_hardreset_lines_asserted(oh)) in _omap4_disable_module()
1663 pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__); in _omap4_disable_module()
1665 omap_cm_module_disable(oh->clkdm->prcm_partition, oh->clkdm->cm_inst, in _omap4_disable_module()
1666 oh->prcm.omap4.clkctrl_offs); in _omap4_disable_module()
1668 v = _omap4_wait_target_disable(oh); in _omap4_disable_module()
1671 oh->name); in _omap4_disable_module()
1692 static int _ocp_softreset(struct omap_hwmod *oh) in _ocp_softreset() argument
1698 if (!oh->class->sysc || in _ocp_softreset()
1699 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _ocp_softreset()
1703 if (oh->_state != _HWMOD_STATE_ENABLED) { in _ocp_softreset()
1705 oh->name); in _ocp_softreset()
1710 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1711 _enable_optional_clocks(oh); in _ocp_softreset()
1713 pr_debug("omap_hwmod: %s: resetting via OCP SOFTRESET\n", oh->name); in _ocp_softreset()
1715 v = oh->_sysc_cache; in _ocp_softreset()
1716 ret = _set_softreset(oh, &v); in _ocp_softreset()
1720 _write_sysconfig(v, oh); in _ocp_softreset()
1722 if (oh->class->sysc->srst_udelay) in _ocp_softreset()
1723 udelay(oh->class->sysc->srst_udelay); in _ocp_softreset()
1725 c = _wait_softreset_complete(oh); in _ocp_softreset()
1728 oh->name, MAX_MODULE_SOFTRESET_WAIT); in _ocp_softreset()
1732 pr_debug("omap_hwmod: %s: softreset in %d usec\n", oh->name, c); in _ocp_softreset()
1735 ret = _clear_softreset(oh, &v); in _ocp_softreset()
1739 _write_sysconfig(v, oh); in _ocp_softreset()
1747 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1748 _disable_optional_clocks(oh); in _ocp_softreset()
1786 static int _reset(struct omap_hwmod *oh) in _reset() argument
1790 pr_debug("omap_hwmod: %s: resetting\n", oh->name); in _reset()
1792 if (oh->class->reset) { in _reset()
1793 r = oh->class->reset(oh); in _reset()
1795 if (oh->rst_lines_cnt > 0) { in _reset()
1796 for (i = 0; i < oh->rst_lines_cnt; i++) in _reset()
1797 _assert_hardreset(oh, oh->rst_lines[i].name); in _reset()
1800 r = _ocp_softreset(oh); in _reset()
1806 _set_dmadisable(oh); in _reset()
1813 if (oh->class->sysc) { in _reset()
1814 _update_sysc_cache(oh); in _reset()
1815 _enable_sysc(oh); in _reset()
1830 static void _omap4_update_context_lost(struct omap_hwmod *oh) in _omap4_update_context_lost() argument
1832 if (oh->prcm.omap4.flags & HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT) in _omap4_update_context_lost()
1835 if (!prm_was_any_context_lost_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
1836 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
1837 oh->prcm.omap4.context_offs)) in _omap4_update_context_lost()
1840 oh->prcm.omap4.context_lost_counter++; in _omap4_update_context_lost()
1841 prm_clear_context_loss_flags_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
1842 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
1843 oh->prcm.omap4.context_offs); in _omap4_update_context_lost()
1852 static int _omap4_get_context_lost(struct omap_hwmod *oh) in _omap4_get_context_lost() argument
1854 return oh->prcm.omap4.context_lost_counter; in _omap4_get_context_lost()
1865 static int _enable(struct omap_hwmod *oh) in _enable() argument
1869 pr_debug("omap_hwmod: %s: enabling\n", oh->name); in _enable()
1875 if (oh->_int_flags & _HWMOD_SKIP_ENABLE) { in _enable()
1876 oh->_int_flags &= ~_HWMOD_SKIP_ENABLE; in _enable()
1880 if (oh->_state != _HWMOD_STATE_INITIALIZED && in _enable()
1881 oh->_state != _HWMOD_STATE_IDLE && in _enable()
1882 oh->_state != _HWMOD_STATE_DISABLED) { in _enable()
1884 oh->name); in _enable()
1897 if (_are_all_hardreset_lines_asserted(oh)) in _enable()
1900 _add_initiator_dep(oh, mpu_oh); in _enable()
1902 if (oh->clkdm) { in _enable()
1908 clkdm_deny_idle(oh->clkdm); in _enable()
1909 r = clkdm_hwmod_enable(oh->clkdm, oh); in _enable()
1912 oh->name, oh->clkdm->name, r); in _enable()
1917 _enable_clocks(oh); in _enable()
1919 soc_ops.enable_module(oh); in _enable()
1920 if (oh->flags & HWMOD_BLOCK_WFI) in _enable()
1924 soc_ops.update_context_lost(oh); in _enable()
1926 r = (soc_ops.wait_target_ready) ? soc_ops.wait_target_ready(oh) : in _enable()
1928 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO)) in _enable()
1929 clkdm_allow_idle(oh->clkdm); in _enable()
1932 oh->_state = _HWMOD_STATE_ENABLED; in _enable()
1935 if (oh->class->sysc) { in _enable()
1936 if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) in _enable()
1937 _update_sysc_cache(oh); in _enable()
1938 _enable_sysc(oh); in _enable()
1942 soc_ops.disable_module(oh); in _enable()
1943 _disable_clocks(oh); in _enable()
1945 oh->name, r); in _enable()
1947 if (oh->clkdm) in _enable()
1948 clkdm_hwmod_disable(oh->clkdm, oh); in _enable()
1962 static int _idle(struct omap_hwmod *oh) in _idle() argument
1964 if (oh->flags & HWMOD_NO_IDLE) { in _idle()
1965 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _idle()
1969 pr_debug("omap_hwmod: %s: idling\n", oh->name); in _idle()
1971 if (_are_all_hardreset_lines_asserted(oh)) in _idle()
1974 if (oh->_state != _HWMOD_STATE_ENABLED) { in _idle()
1976 oh->name); in _idle()
1980 if (oh->class->sysc) in _idle()
1981 _idle_sysc(oh); in _idle()
1982 _del_initiator_dep(oh, mpu_oh); in _idle()
1989 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO)) in _idle()
1990 clkdm_deny_idle(oh->clkdm); in _idle()
1992 if (oh->flags & HWMOD_BLOCK_WFI) in _idle()
1995 soc_ops.disable_module(oh); in _idle()
2003 _disable_clocks(oh); in _idle()
2004 if (oh->clkdm) { in _idle()
2005 clkdm_allow_idle(oh->clkdm); in _idle()
2006 clkdm_hwmod_disable(oh->clkdm, oh); in _idle()
2009 oh->_state = _HWMOD_STATE_IDLE; in _idle()
2023 static int _shutdown(struct omap_hwmod *oh) in _shutdown() argument
2028 if (_are_all_hardreset_lines_asserted(oh)) in _shutdown()
2031 if (oh->_state != _HWMOD_STATE_IDLE && in _shutdown()
2032 oh->_state != _HWMOD_STATE_ENABLED) { in _shutdown()
2034 oh->name); in _shutdown()
2038 pr_debug("omap_hwmod: %s: disabling\n", oh->name); in _shutdown()
2040 if (oh->class->pre_shutdown) { in _shutdown()
2041 prev_state = oh->_state; in _shutdown()
2042 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2043 _enable(oh); in _shutdown()
2044 ret = oh->class->pre_shutdown(oh); in _shutdown()
2047 _idle(oh); in _shutdown()
2052 if (oh->class->sysc) { in _shutdown()
2053 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2054 _enable(oh); in _shutdown()
2055 _shutdown_sysc(oh); in _shutdown()
2059 if (oh->_state == _HWMOD_STATE_ENABLED) { in _shutdown()
2060 _del_initiator_dep(oh, mpu_oh); in _shutdown()
2062 if (oh->flags & HWMOD_BLOCK_WFI) in _shutdown()
2065 soc_ops.disable_module(oh); in _shutdown()
2066 _disable_clocks(oh); in _shutdown()
2067 if (oh->clkdm) in _shutdown()
2068 clkdm_hwmod_disable(oh->clkdm, oh); in _shutdown()
2072 for (i = 0; i < oh->rst_lines_cnt; i++) in _shutdown()
2073 _assert_hardreset(oh, oh->rst_lines[i].name); in _shutdown()
2075 oh->_state = _HWMOD_STATE_DISABLED; in _shutdown()
2081 struct omap_hwmod *oh) in of_dev_find_hwmod() argument
2095 if (!strcmp(p, oh->name)) { in of_dev_find_hwmod()
2097 np, i, oh->name); in of_dev_find_hwmod()
2117 struct omap_hwmod *oh, in of_dev_hwmod_lookup() argument
2124 res = of_dev_find_hwmod(np, oh); in of_dev_hwmod_lookup()
2135 res = of_dev_hwmod_lookup(np0, oh, &i, &fc); in of_dev_hwmod_lookup()
2163 static void omap_hwmod_fix_mpu_rt_idx(struct omap_hwmod *oh, in omap_hwmod_fix_mpu_rt_idx() argument
2174 error = of_address_to_resource(child, oh->mpu_rt_idx, res); in omap_hwmod_fix_mpu_rt_idx()
2191 int omap_hwmod_parse_module_range(struct omap_hwmod *oh, in omap_hwmod_parse_module_range() argument
2231 oh->name, np); in omap_hwmod_parse_module_range()
2240 oh->name, np, base, size); in omap_hwmod_parse_module_range()
2242 if (oh && oh->mpu_rt_idx) { in omap_hwmod_parse_module_range()
2243 omap_hwmod_fix_mpu_rt_idx(oh, np, res); in omap_hwmod_parse_module_range()
2272 static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, in _init_mpu_rt_base() argument
2279 if (!oh) in _init_mpu_rt_base()
2282 _save_mpu_port_index(oh); in _init_mpu_rt_base()
2285 if (!oh->class->sysc) in _init_mpu_rt_base()
2289 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in _init_mpu_rt_base()
2293 pr_err("omap_hwmod: %s: no dt node\n", oh->name); in _init_mpu_rt_base()
2298 error = omap_hwmod_parse_module_range(oh, np, &res); in _init_mpu_rt_base()
2304 va_start = of_iomap(np, index + oh->mpu_rt_idx); in _init_mpu_rt_base()
2307 oh->name, index, np); in _init_mpu_rt_base()
2312 oh->name, va_start); in _init_mpu_rt_base()
2314 oh->_mpu_rt_va = va_start; in _init_mpu_rt_base()
2318 static void __init parse_module_flags(struct omap_hwmod *oh, in parse_module_flags() argument
2322 oh->flags |= HWMOD_INIT_NO_RESET; in parse_module_flags()
2324 oh->flags |= HWMOD_INIT_NO_IDLE; in parse_module_flags()
2326 oh->flags |= HWMOD_NO_IDLE; in parse_module_flags()
2342 static int __init _init(struct omap_hwmod *oh, void *data) in _init() argument
2348 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init()
2355 r = of_dev_hwmod_lookup(bus, oh, &index, &np); in _init()
2357 pr_debug("omap_hwmod: %s missing dt data\n", oh->name); in _init()
2360 oh->name, np); in _init()
2362 r = _init_mpu_rt_base(oh, NULL, index, np); in _init()
2365 oh->name); in _init()
2369 r = _init_clocks(oh, np); in _init()
2371 WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name); in _init()
2378 parse_module_flags(oh, np); in _init()
2381 parse_module_flags(oh, child); in _init()
2384 oh->_state = _HWMOD_STATE_INITIALIZED; in _init()
2397 static void _setup_iclk_autoidle(struct omap_hwmod *oh) in _setup_iclk_autoidle() argument
2401 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_iclk_autoidle()
2404 list_for_each_entry(os, &oh->slave_ports, node) { in _setup_iclk_autoidle()
2432 static int _setup_reset(struct omap_hwmod *oh) in _setup_reset() argument
2436 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_reset()
2439 if (oh->flags & HWMOD_EXT_OPT_MAIN_CLK) in _setup_reset()
2442 if (oh->rst_lines_cnt == 0) { in _setup_reset()
2443 r = _enable(oh); in _setup_reset()
2446 oh->name, oh->_state); in _setup_reset()
2451 if (!(oh->flags & HWMOD_INIT_NO_RESET)) in _setup_reset()
2452 r = _reset(oh); in _setup_reset()
2493 static void _setup_postsetup(struct omap_hwmod *oh) in _setup_postsetup() argument
2497 if (oh->rst_lines_cnt > 0) in _setup_postsetup()
2500 postsetup_state = oh->_postsetup_state; in _setup_postsetup()
2508 if ((oh->flags & (HWMOD_INIT_NO_IDLE | HWMOD_NO_IDLE)) && in _setup_postsetup()
2510 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _setup_postsetup()
2515 _idle(oh); in _setup_postsetup()
2517 _shutdown(oh); in _setup_postsetup()
2520 oh->name, postsetup_state); in _setup_postsetup()
2541 static int _setup(struct omap_hwmod *oh, void *data) in _setup() argument
2543 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup()
2546 if (oh->parent_hwmod) { in _setup()
2549 r = _enable(oh->parent_hwmod); in _setup()
2551 oh->name, oh->parent_hwmod->name); in _setup()
2554 _setup_iclk_autoidle(oh); in _setup()
2556 if (!_setup_reset(oh)) in _setup()
2557 _setup_postsetup(oh); in _setup()
2559 if (oh->parent_hwmod) { in _setup()
2562 postsetup_state = oh->parent_hwmod->_postsetup_state; in _setup()
2565 _idle(oh->parent_hwmod); in _setup()
2567 _shutdown(oh->parent_hwmod); in _setup()
2570 oh->parent_hwmod->name, postsetup_state); in _setup()
2593 static int _register(struct omap_hwmod *oh) in _register() argument
2595 if (!oh || !oh->name || !oh->class || !oh->class->name || in _register()
2596 (oh->_state != _HWMOD_STATE_UNKNOWN)) in _register()
2599 pr_debug("omap_hwmod: %s: registering\n", oh->name); in _register()
2601 if (_lookup(oh->name)) in _register()
2604 list_add_tail(&oh->node, &omap_hwmod_list); in _register()
2606 INIT_LIST_HEAD(&oh->slave_ports); in _register()
2607 spin_lock_init(&oh->_lock); in _register()
2608 lockdep_set_class(&oh->_lock, &oh->hwmod_key); in _register()
2610 oh->_state = _HWMOD_STATE_REGISTERED; in _register()
2616 if (!strcmp(oh->name, MPU_INITIATOR_NAME)) in _register()
2617 mpu_oh = oh; in _register()
2695 static int _omap2xxx_3xxx_wait_target_ready(struct omap_hwmod *oh) in _omap2xxx_3xxx_wait_target_ready() argument
2697 if (!oh) in _omap2xxx_3xxx_wait_target_ready()
2700 if (oh->flags & HWMOD_NO_IDLEST) in _omap2xxx_3xxx_wait_target_ready()
2703 if (!_find_mpu_rt_port(oh)) in _omap2xxx_3xxx_wait_target_ready()
2708 return omap_cm_wait_module_ready(0, oh->prcm.omap2.module_offs, in _omap2xxx_3xxx_wait_target_ready()
2709 oh->prcm.omap2.idlest_reg_id, in _omap2xxx_3xxx_wait_target_ready()
2710 oh->prcm.omap2.idlest_idle_bit); in _omap2xxx_3xxx_wait_target_ready()
2722 static int _omap4_wait_target_ready(struct omap_hwmod *oh) in _omap4_wait_target_ready() argument
2724 if (!oh) in _omap4_wait_target_ready()
2727 if (oh->flags & HWMOD_NO_IDLEST || !oh->clkdm) in _omap4_wait_target_ready()
2730 if (!_find_mpu_rt_port(oh)) in _omap4_wait_target_ready()
2733 if (_omap4_clkctrl_managed_by_clkfwk(oh)) in _omap4_wait_target_ready()
2736 if (!_omap4_has_clkctrl_clock(oh)) in _omap4_wait_target_ready()
2741 return omap_cm_wait_module_ready(oh->clkdm->prcm_partition, in _omap4_wait_target_ready()
2742 oh->clkdm->cm_inst, in _omap4_wait_target_ready()
2743 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_ready()
2757 static int _omap2_assert_hardreset(struct omap_hwmod *oh, in _omap2_assert_hardreset() argument
2761 oh->prcm.omap2.module_offs, 0); in _omap2_assert_hardreset()
2775 static int _omap2_deassert_hardreset(struct omap_hwmod *oh, in _omap2_deassert_hardreset() argument
2779 oh->prcm.omap2.module_offs, 0, 0); in _omap2_deassert_hardreset()
2794 static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh, in _omap2_is_hardreset_asserted() argument
2798 oh->prcm.omap2.module_offs, 0); in _omap2_is_hardreset_asserted()
2813 static int _omap4_assert_hardreset(struct omap_hwmod *oh, in _omap4_assert_hardreset() argument
2816 if (!oh->clkdm) in _omap4_assert_hardreset()
2820 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_assert_hardreset()
2821 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_assert_hardreset()
2822 oh->prcm.omap4.rstctrl_offs); in _omap4_assert_hardreset()
2837 static int _omap4_deassert_hardreset(struct omap_hwmod *oh, in _omap4_deassert_hardreset() argument
2840 if (!oh->clkdm) in _omap4_deassert_hardreset()
2845 oh->name, ohri->name); in _omap4_deassert_hardreset()
2847 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_deassert_hardreset()
2848 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_deassert_hardreset()
2849 oh->prcm.omap4.rstctrl_offs, in _omap4_deassert_hardreset()
2850 oh->prcm.omap4.rstctrl_offs + in _omap4_deassert_hardreset()
2866 static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh, in _omap4_is_hardreset_asserted() argument
2869 if (!oh->clkdm) in _omap4_is_hardreset_asserted()
2873 oh->clkdm->pwrdm.ptr-> in _omap4_is_hardreset_asserted()
2875 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_is_hardreset_asserted()
2876 oh->prcm.omap4.rstctrl_offs); in _omap4_is_hardreset_asserted()
2887 static int _omap4_disable_direct_prcm(struct omap_hwmod *oh) in _omap4_disable_direct_prcm() argument
2889 if (!oh) in _omap4_disable_direct_prcm()
2892 oh->prcm.omap4.flags |= HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK; in _omap4_disable_direct_prcm()
2909 static int _am33xx_deassert_hardreset(struct omap_hwmod *oh, in _am33xx_deassert_hardreset() argument
2913 oh->clkdm->pwrdm.ptr->prcm_partition, in _am33xx_deassert_hardreset()
2914 oh->clkdm->pwrdm.ptr->prcm_offs, in _am33xx_deassert_hardreset()
2915 oh->prcm.omap4.rstctrl_offs, in _am33xx_deassert_hardreset()
2916 oh->prcm.omap4.rstst_offs); in _am33xx_deassert_hardreset()
2921 u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs) in omap_hwmod_read() argument
2923 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_read()
2924 return readw_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
2926 return readl_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
2929 void omap_hwmod_write(u32 v, struct omap_hwmod *oh, u16 reg_offs) in omap_hwmod_write() argument
2931 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_write()
2932 writew_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
2934 writel_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
2946 int omap_hwmod_softreset(struct omap_hwmod *oh) in omap_hwmod_softreset() argument
2951 if (!oh || !(oh->_sysc_cache)) in omap_hwmod_softreset()
2954 v = oh->_sysc_cache; in omap_hwmod_softreset()
2955 ret = _set_softreset(oh, &v); in omap_hwmod_softreset()
2958 _write_sysconfig(v, oh); in omap_hwmod_softreset()
2960 ret = _clear_softreset(oh, &v); in omap_hwmod_softreset()
2963 _write_sysconfig(v, oh); in omap_hwmod_softreset()
2978 struct omap_hwmod *oh; in omap_hwmod_lookup() local
2983 oh = _lookup(name); in omap_hwmod_lookup()
2985 return oh; in omap_hwmod_lookup()
3000 int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data), in omap_hwmod_for_each() argument
3063 static void __init _ensure_mpu_hwmod_is_setup(struct omap_hwmod *oh) in _ensure_mpu_hwmod_is_setup() argument
3068 else if (mpu_oh->_state == _HWMOD_STATE_REGISTERED && oh != mpu_oh) in _ensure_mpu_hwmod_is_setup()
3085 struct omap_hwmod *oh; in omap_hwmod_setup_one() local
3089 oh = _lookup(oh_name); in omap_hwmod_setup_one()
3090 if (!oh) { in omap_hwmod_setup_one()
3095 _ensure_mpu_hwmod_is_setup(oh); in omap_hwmod_setup_one()
3097 _init(oh, NULL); in omap_hwmod_setup_one()
3098 _setup(oh, NULL); in omap_hwmod_setup_one()
3157 static int omap_hwmod_init_regbits(struct device *dev, struct omap_hwmod *oh, in omap_hwmod_init_regbits() argument
3196 if (!oh->class->sysc->sysc_fields) in omap_hwmod_init_regbits()
3356 struct omap_hwmod *oh, in omap_hwmod_check_module() argument
3363 if (!oh->class->sysc) in omap_hwmod_check_module()
3366 if (oh->class->sysc->sysc_fields && in omap_hwmod_check_module()
3367 sysc_fields != oh->class->sysc->sysc_fields) in omap_hwmod_check_module()
3370 if (rev_offs != oh->class->sysc->rev_offs) in omap_hwmod_check_module()
3372 oh->class->sysc->rev_offs); in omap_hwmod_check_module()
3373 if (sysc_offs != oh->class->sysc->sysc_offs) in omap_hwmod_check_module()
3375 oh->class->sysc->sysc_offs); in omap_hwmod_check_module()
3376 if (syss_offs != oh->class->sysc->syss_offs) in omap_hwmod_check_module()
3378 oh->class->sysc->syss_offs); in omap_hwmod_check_module()
3380 if (sysc_flags != oh->class->sysc->sysc_flags) in omap_hwmod_check_module()
3382 oh->class->sysc->sysc_flags); in omap_hwmod_check_module()
3384 if (idlemodes != oh->class->sysc->idlemodes) in omap_hwmod_check_module()
3386 oh->class->sysc->idlemodes); in omap_hwmod_check_module()
3388 if (data->cfg->srst_udelay != oh->class->sysc->srst_udelay) in omap_hwmod_check_module()
3391 oh->class->sysc->srst_udelay); in omap_hwmod_check_module()
3410 static int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh, in omap_hwmod_allocate_module() argument
3436 if (!oh->_mpu_rt_va) { in omap_hwmod_allocate_module()
3447 if (oh->class->name && strcmp(oh->class->name, data->name)) { in omap_hwmod_allocate_module()
3448 class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL); in omap_hwmod_allocate_module()
3453 if (list_empty(&oh->slave_ports)) { in omap_hwmod_allocate_module()
3463 oi->slave = oh; in omap_hwmod_allocate_module()
3467 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_allocate_module()
3469 oh->_mpu_rt_va = regs; in omap_hwmod_allocate_module()
3471 oh->class = class; in omap_hwmod_allocate_module()
3472 oh->class->sysc = sysc; in omap_hwmod_allocate_module()
3476 oh->clkdm = clkdm; in omap_hwmod_allocate_module()
3477 oh->_state = _HWMOD_STATE_INITIALIZED; in omap_hwmod_allocate_module()
3478 oh->_postsetup_state = _HWMOD_STATE_DEFAULT; in omap_hwmod_allocate_module()
3479 _setup(oh, NULL); in omap_hwmod_allocate_module()
3480 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_allocate_module()
3509 omap_hwmod_init_reset_quirk(struct device *dev, struct omap_hwmod *oh, in omap_hwmod_init_reset_quirk() argument
3520 oh->class->reset = quirk->reset; in omap_hwmod_init_reset_quirk()
3528 omap_hwmod_init_reset_quirks(struct device *dev, struct omap_hwmod *oh, in omap_hwmod_init_reset_quirks() argument
3532 omap_hwmod_init_reset_quirk(dev, oh, data, in omap_hwmod_init_reset_quirks()
3537 omap_hwmod_init_reset_quirk(dev, oh, data, dra7_reset_quirks, in omap_hwmod_init_reset_quirks()
3540 omap_hwmod_init_reset_quirk(dev, oh, data, omap_reset_quirks, in omap_hwmod_init_reset_quirks()
3554 struct omap_hwmod *oh; in omap_hwmod_init_module() local
3563 oh = _lookup(data->name); in omap_hwmod_init_module()
3564 if (!oh) { in omap_hwmod_init_module()
3565 oh = kzalloc(sizeof(*oh), GFP_KERNEL); in omap_hwmod_init_module()
3566 if (!oh) in omap_hwmod_init_module()
3569 oh->name = data->name; in omap_hwmod_init_module()
3570 oh->_state = _HWMOD_STATE_UNKNOWN; in omap_hwmod_init_module()
3571 lockdep_register_key(&oh->hwmod_key); in omap_hwmod_init_module()
3574 oh->prcm.omap4.flags = HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT; in omap_hwmod_init_module()
3576 oh->class = kzalloc(sizeof(*oh->class), GFP_KERNEL); in omap_hwmod_init_module()
3577 if (!oh->class) { in omap_hwmod_init_module()
3578 kfree(oh); in omap_hwmod_init_module()
3582 omap_hwmod_init_reset_quirks(dev, oh, data); in omap_hwmod_init_module()
3584 oh->class->name = data->name; in omap_hwmod_init_module()
3586 error = _register(oh); in omap_hwmod_init_module()
3590 cookie->data = oh; in omap_hwmod_init_module()
3592 error = omap_hwmod_init_regbits(dev, oh, data, &sysc_fields); in omap_hwmod_init_module()
3610 oh->flags |= HWMOD_NO_IDLE; in omap_hwmod_init_module()
3612 oh->flags |= HWMOD_INIT_NO_IDLE; in omap_hwmod_init_module()
3614 oh->flags |= HWMOD_INIT_NO_RESET; in omap_hwmod_init_module()
3616 oh->flags |= HWMOD_SET_DEFAULT_CLOCKACT; in omap_hwmod_init_module()
3618 oh->flags |= HWMOD_SWSUP_SIDLE; in omap_hwmod_init_module()
3620 oh->flags |= HWMOD_SWSUP_SIDLE_ACT; in omap_hwmod_init_module()
3622 oh->flags |= HWMOD_SWSUP_MSTANDBY; in omap_hwmod_init_module()
3624 oh->flags |= HWMOD_CLKDM_NOAUTO; in omap_hwmod_init_module()
3626 error = omap_hwmod_check_module(dev, oh, data, sysc_fields, in omap_hwmod_init_module()
3632 return omap_hwmod_allocate_module(dev, oh, data, sysc_fields, in omap_hwmod_init_module()
3649 struct omap_hwmod *oh; in omap_hwmod_setup_earlycon_flags() local
3659 oh = omap_hwmod_lookup(uart); in omap_hwmod_setup_earlycon_flags()
3660 if (!oh) { in omap_hwmod_setup_earlycon_flags()
3664 oh = omap_hwmod_lookup(uart); in omap_hwmod_setup_earlycon_flags()
3666 if (oh) in omap_hwmod_setup_earlycon_flags()
3667 oh->flags |= DEBUG_OMAPUART_FLAGS; in omap_hwmod_setup_earlycon_flags()
3703 int omap_hwmod_enable(struct omap_hwmod *oh) in omap_hwmod_enable() argument
3708 if (!oh) in omap_hwmod_enable()
3711 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_enable()
3712 r = _enable(oh); in omap_hwmod_enable()
3713 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_enable()
3725 int omap_hwmod_idle(struct omap_hwmod *oh) in omap_hwmod_idle() argument
3730 if (!oh) in omap_hwmod_idle()
3733 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_idle()
3734 r = _idle(oh); in omap_hwmod_idle()
3735 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_idle()
3748 int omap_hwmod_shutdown(struct omap_hwmod *oh) in omap_hwmod_shutdown() argument
3753 if (!oh) in omap_hwmod_shutdown()
3756 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_shutdown()
3757 r = _shutdown(oh); in omap_hwmod_shutdown()
3758 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_shutdown()
3778 struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh) in omap_hwmod_get_pwrdm() argument
3786 if (!oh) in omap_hwmod_get_pwrdm()
3789 if (oh->clkdm) in omap_hwmod_get_pwrdm()
3790 return oh->clkdm->pwrdm.ptr; in omap_hwmod_get_pwrdm()
3792 if (oh->_clk) { in omap_hwmod_get_pwrdm()
3793 c = oh->_clk; in omap_hwmod_get_pwrdm()
3795 oi = _find_mpu_rt_port(oh); in omap_hwmod_get_pwrdm()
3825 void __iomem *omap_hwmod_get_mpu_rt_va(struct omap_hwmod *oh) in omap_hwmod_get_mpu_rt_va() argument
3827 if (!oh) in omap_hwmod_get_mpu_rt_va()
3830 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in omap_hwmod_get_mpu_rt_va()
3833 if (oh->_state == _HWMOD_STATE_UNKNOWN) in omap_hwmod_get_mpu_rt_va()
3836 return oh->_mpu_rt_va; in omap_hwmod_get_mpu_rt_va()
3856 int omap_hwmod_assert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_assert_hardreset() argument
3861 if (!oh) in omap_hwmod_assert_hardreset()
3864 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3865 ret = _assert_hardreset(oh, name); in omap_hwmod_assert_hardreset()
3866 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3883 int omap_hwmod_deassert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_deassert_hardreset() argument
3888 if (!oh) in omap_hwmod_deassert_hardreset()
3891 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3892 ret = _deassert_hardreset(oh, name); in omap_hwmod_deassert_hardreset()
3893 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3911 int (*fn)(struct omap_hwmod *oh, in omap_hwmod_for_each_by_class() argument
3952 int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state) in omap_hwmod_set_postsetup_state() argument
3957 if (!oh) in omap_hwmod_set_postsetup_state()
3965 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3967 if (oh->_state != _HWMOD_STATE_REGISTERED) { in omap_hwmod_set_postsetup_state()
3972 oh->_postsetup_state = state; in omap_hwmod_set_postsetup_state()
3976 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3992 int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh) in omap_hwmod_get_context_loss_count() argument
3998 return soc_ops.get_context_lost(oh); in omap_hwmod_get_context_loss_count()
4000 pwrdm = omap_hwmod_get_pwrdm(oh); in omap_hwmod_get_context_loss_count()
4066 const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh) in omap_hwmod_get_main_clk() argument
4068 if (!oh) in omap_hwmod_get_main_clk()
4071 return oh->main_clk; in omap_hwmod_get_main_clk()