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);
264 * @oh: struct omap_hwmod *
270 static int _update_sysc_cache(struct omap_hwmod *oh)
272 if (!oh->class->sysc) {
273 WARN(1, "omap_hwmod: %s: cannot read OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name);
279 oh->_sysc_cache = omap_hwmod_read(oh, oh->class->sysc->sysc_offs);
281 if (!(oh->class->sysc->sysc_flags & SYSC_NO_CACHE))
282 oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED;
290 * @oh: struct omap_hwmod *
295 static void _write_sysconfig(u32 v, struct omap_hwmod *oh)
297 if (!oh->class->sysc) {
298 WARN(1, "omap_hwmod: %s: cannot write OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name);
305 oh->_sysc_cache = v;
313 if (oh->class->unlock)
314 oh->class->unlock(oh);
316 omap_hwmod_write(v, oh, oh->class->sysc->sysc_offs);
318 if (oh->class->lock)
319 oh->class->lock(oh);
324 * @oh: struct omap_hwmod *
329 * the @oh hwmod. Does not write to the hardware. Returns -EINVAL
332 static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode,
338 if (!oh->class->sysc ||
339 !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE))
342 if (!oh->class->sysc->sysc_fields) {
343 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);
347 mstandby_shift = oh->class->sysc->sysc_fields->midle_shift;
358 * @oh: struct omap_hwmod *
362 * Update the slave idle mode bits in @v to be @idlemode for the @oh
366 static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v)
371 if (!oh->class->sysc ||
372 !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE))
375 if (!oh->class->sysc->sysc_fields) {
376 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);
380 sidle_shift = oh->class->sysc->sysc_fields->sidle_shift;
391 * @oh: struct omap_hwmod *
396 * @oh hwmod. Used for additional powersaving on some modules. Does
400 static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
405 if (!oh->class->sysc ||
406 !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY))
409 if (!oh->class->sysc->sysc_fields) {
410 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);
414 clkact_shift = oh->class->sysc->sysc_fields->clkact_shift;
425 * @oh: struct omap_hwmod *
428 * Set the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon
431 static int _set_softreset(struct omap_hwmod *oh, u32 *v)
435 if (!oh->class->sysc ||
436 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET))
439 if (!oh->class->sysc->sysc_fields) {
440 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);
444 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
453 * @oh: struct omap_hwmod *
456 * Clear the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon
459 static int _clear_softreset(struct omap_hwmod *oh, u32 *v)
463 if (!oh->class->sysc ||
464 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET))
467 if (!oh->class->sysc->sysc_fields) {
470 oh->name);
474 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
483 * @oh: struct omap_hwmod * to wait on
485 * Wait until the IP block represented by @oh reports that its OCP
491 static int _wait_softreset_complete(struct omap_hwmod *oh)
497 sysc = oh->class->sysc;
500 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs)
505 omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs)
515 * @oh: struct omap_hwmod *
522 * Set the DMADISABLE bit in @v for hwmod @oh. Returns -EINVAL upon
525 static int _set_dmadisable(struct omap_hwmod *oh)
530 if (!oh->class->sysc ||
531 !(oh->class->sysc->sysc_flags & SYSC_HAS_DMADISABLE))
534 if (!oh->class->sysc->sysc_fields) {
535 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);
540 if (oh->_state != _HWMOD_STATE_ENABLED) {
541 pr_warn("omap_hwmod: %s: dma can be disabled only from enabled state\n", oh->name);
545 pr_debug("omap_hwmod: %s: setting DMADISABLE\n", oh->name);
547 v = oh->_sysc_cache;
549 (0x1 << oh->class->sysc->sysc_fields->dmadisable_shift);
551 _write_sysconfig(v, oh);
558 * @oh: struct omap_hwmod *
562 * Update the module autoidle bit in @v to be @autoidle for the @oh
569 static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle,
575 if (!oh->class->sysc ||
576 !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE))
579 if (!oh->class->sysc->sysc_fields) {
580 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);
584 autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift;
595 * @oh: struct omap_hwmod *
597 * Allow the hardware module @oh to send wakeups. Returns -EINVAL
600 static int _enable_wakeup(struct omap_hwmod *oh, u32 *v)
602 if (!oh->class->sysc ||
603 !((oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) ||
604 (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) ||
605 (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP)))
608 if (!oh->class->sysc->sysc_fields) {
609 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);
613 if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)
614 *v |= 0x1 << oh->class->sysc->sysc_fields->enwkup_shift;
616 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP)
617 _set_slave_idlemode(oh, HWMOD_IDLEMODE_SMART_WKUP, v);
618 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP)
619 _set_master_standbymode(oh, HWMOD_IDLEMODE_SMART_WKUP, v);
626 static struct clockdomain *_get_clkdm(struct omap_hwmod *oh)
630 if (oh->clkdm) {
631 return oh->clkdm;
632 } else if (oh->_clk) {
633 if (!omap2_clk_is_hw_omap(__clk_get_hw(oh->_clk)))
635 clk = to_clk_hw_omap(__clk_get_hw(oh->_clk));
642 * _add_initiator_dep: prevent @oh from smart-idling while @init_oh is active
643 * @oh: struct omap_hwmod *
645 * Prevent the hardware module @oh from entering idle while the
654 static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh)
658 clkdm = _get_clkdm(oh);
671 * _del_initiator_dep: allow @oh to smart-idle even if @init_oh is active
672 * @oh: struct omap_hwmod *
674 * Allow the hardware module @oh to enter idle while the hardare
683 static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh)
687 clkdm = _get_clkdm(oh);
761 static u32 _omap4_xlate_clkctrl(struct omap_hwmod *oh)
763 if (!oh->prcm.omap4.modulemode)
766 return omap_cm_xlate_clkctrl(oh->clkdm->prcm_partition,
767 oh->clkdm->cm_inst,
768 oh->prcm.omap4.clkctrl_offs);
771 static struct clk *_lookup_clkctrl_clk(struct omap_hwmod *oh)
780 addr = soc_ops.xlate_clkctrl(oh);
784 pr_debug("%s: %s: addr=%x\n", __func__, oh->name, addr);
802 __func__, oh->name, clk,
815 * @oh: struct omap_hwmod *
817 * Called from _init_clocks(). Populates the @oh _clk (main
821 static int _init_main_clk(struct omap_hwmod *oh)
826 clk = _lookup_clkctrl_clk(oh);
830 __clk_get_name(clk), oh->name);
831 oh->main_clk = __clk_get_name(clk);
832 oh->_clk = clk;
833 soc_ops.disable_direct_prcm(oh);
835 if (!oh->main_clk)
838 oh->_clk = clk_get(NULL, oh->main_clk);
841 if (IS_ERR(oh->_clk)) {
843 oh->name, oh->main_clk);
854 clk_prepare(oh->_clk);
856 if (!_get_clkdm(oh))
858 oh->name, oh->main_clk);
865 * @oh: struct omap_hwmod *
867 * Called from _init_clocks(). Populates the @oh OCP slave interface
870 static int _init_interface_clks(struct omap_hwmod *oh)
876 list_for_each_entry(os, &oh->slave_ports, node) {
883 oh->name, os->clk);
904 * @oh: struct omap_hwmod *
906 * Called from _init_clocks(). Populates the @oh omap_hwmod_opt_clk
909 static int _init_opt_clks(struct omap_hwmod *oh)
916 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) {
920 oh->name, oc->clk);
939 static void _enable_optional_clocks(struct omap_hwmod *oh)
944 pr_debug("omap_hwmod: %s: enabling optional clocks\n", oh->name);
946 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)
954 static void _disable_optional_clocks(struct omap_hwmod *oh)
959 pr_debug("omap_hwmod: %s: disabling optional clocks\n", oh->name);
961 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)
971 * @oh: struct omap_hwmod *
974 * on the hwmod @oh. Returns 0.
976 static int _enable_clocks(struct omap_hwmod *oh)
980 pr_debug("omap_hwmod: %s: enabling clocks\n", oh->name);
982 if (oh->flags & HWMOD_OPT_CLKS_NEEDED)
983 _enable_optional_clocks(oh);
985 if (oh->_clk)
986 clk_enable(oh->_clk);
988 list_for_each_entry(os, &oh->slave_ports, node) {
1002 * @oh: struct omap_hwmod *
1004 static bool _omap4_clkctrl_managed_by_clkfwk(struct omap_hwmod *oh)
1006 if (oh->prcm.omap4.flags & HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK)
1014 * @oh: struct omap_hwmod *
1016 static bool _omap4_has_clkctrl_clock(struct omap_hwmod *oh)
1018 if (oh->prcm.omap4.clkctrl_offs)
1021 if (!oh->prcm.omap4.clkctrl_offs &&
1022 oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET)
1030 * @oh: struct omap_hwmod *
1032 * Disables the hwmod @oh main functional and interface clocks. Returns 0.
1034 static int _disable_clocks(struct omap_hwmod *oh)
1038 pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
1040 if (oh->_clk)
1041 clk_disable(oh->_clk);
1043 list_for_each_entry(os, &oh->slave_ports, node) {
1050 if (oh->flags & HWMOD_OPT_CLKS_NEEDED)
1051 _disable_optional_clocks(oh);
1060 * @oh: struct omap_hwmod *
1062 * Enables the PRCM module mode related to the hwmod @oh.
1065 static void _omap4_enable_module(struct omap_hwmod *oh)
1067 if (!oh->clkdm || !oh->prcm.omap4.modulemode ||
1068 _omap4_clkctrl_managed_by_clkfwk(oh))
1072 oh->name, __func__, oh->prcm.omap4.modulemode);
1074 omap_cm_module_enable(oh->prcm.omap4.modulemode,
1075 oh->clkdm->prcm_partition,
1076 oh->clkdm->cm_inst, oh->prcm.omap4.clkctrl_offs);
1081 * @oh: struct omap_hwmod *
1083 * Wait for a module @oh to enter slave idle. Returns 0 if the module
1088 static int _omap4_wait_target_disable(struct omap_hwmod *oh)
1090 if (!oh)
1093 if (oh->_int_flags & _HWMOD_NO_MPU_PORT || !oh->clkdm)
1096 if (oh->flags & HWMOD_NO_IDLEST)
1099 if (_omap4_clkctrl_managed_by_clkfwk(oh))
1102 if (!_omap4_has_clkctrl_clock(oh))
1105 return omap_cm_wait_module_idle(oh->clkdm->prcm_partition,
1106 oh->clkdm->cm_inst,
1107 oh->prcm.omap4.clkctrl_offs, 0);
1111 * _save_mpu_port_index - find and save the index to @oh's MPU port
1112 * @oh: struct omap_hwmod *
1119 static void __init _save_mpu_port_index(struct omap_hwmod *oh)
1123 if (!oh)
1126 oh->_int_flags |= _HWMOD_NO_MPU_PORT;
1128 list_for_each_entry(os, &oh->slave_ports, node) {
1130 oh->_mpu_port = os;
1131 oh->_int_flags &= ~_HWMOD_NO_MPU_PORT;
1141 * @oh: struct omap_hwmod *
1143 * Given a pointer to a struct omap_hwmod record @oh, return a pointer
1147 * connected to the IP block represented by @oh. Returns a pointer
1152 static struct omap_hwmod_ocp_if *_find_mpu_rt_port(struct omap_hwmod *oh)
1154 if (!oh || oh->_int_flags & _HWMOD_NO_MPU_PORT || oh->slaves_cnt == 0)
1157 return oh->_mpu_port;
1162 * @oh: struct omap_hwmod *
1165 * by @oh is set to indicate to the PRCM that the IP block is active.
1171 static void _enable_sysc(struct omap_hwmod *oh)
1178 if (!oh->class->sysc)
1187 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1188 _enable_optional_clocks(oh);
1189 _wait_softreset_complete(oh);
1190 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1191 _disable_optional_clocks(oh);
1193 v = oh->_sysc_cache;
1194 sf = oh->class->sysc->sysc_flags;
1196 clkdm = _get_clkdm(oh);
1198 if (oh->flags & HWMOD_SWSUP_SIDLE ||
1199 oh->flags & HWMOD_SWSUP_SIDLE_ACT) {
1203 _enable_wakeup(oh, &v);
1204 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP)
1215 if (clkdm_act && !(oh->class->sysc->idlemodes &
1219 _set_slave_idlemode(oh, idlemode, &v);
1223 if (oh->flags & HWMOD_FORCE_MSTANDBY) {
1225 } else if (oh->flags & HWMOD_SWSUP_MSTANDBY) {
1229 _enable_wakeup(oh, &v);
1230 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP)
1235 _set_master_standbymode(oh, idlemode, &v);
1243 if ((oh->flags & HWMOD_SET_DEFAULT_CLOCKACT) &&
1245 _set_clockactivity(oh, CLOCKACT_TEST_ICLK, &v);
1247 _write_sysconfig(v, oh);
1254 idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ?
1256 _set_module_autoidle(oh, idlemode, &v);
1257 _write_sysconfig(v, oh);
1263 * @oh: struct omap_hwmod *
1270 static void _idle_sysc(struct omap_hwmod *oh)
1275 if (!oh->class->sysc)
1278 v = oh->_sysc_cache;
1279 sf = oh->class->sysc->sysc_flags;
1282 if (oh->flags & HWMOD_SWSUP_SIDLE) {
1286 _enable_wakeup(oh, &v);
1287 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP)
1292 _set_slave_idlemode(oh, idlemode, &v);
1296 if ((oh->flags & HWMOD_SWSUP_MSTANDBY) ||
1297 (oh->flags & HWMOD_FORCE_MSTANDBY)) {
1301 _enable_wakeup(oh, &v);
1302 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP)
1307 _set_master_standbymode(oh, idlemode, &v);
1311 if (oh->_sysc_cache != v)
1312 _write_sysconfig(v, oh);
1317 * @oh: struct omap_hwmod *
1322 static void _shutdown_sysc(struct omap_hwmod *oh)
1327 if (!oh->class->sysc)
1330 v = oh->_sysc_cache;
1331 sf = oh->class->sysc->sysc_flags;
1334 _set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v);
1337 _set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v);
1340 _set_module_autoidle(oh, 1, &v);
1342 _write_sysconfig(v, oh);
1353 struct omap_hwmod *oh, *temp_oh;
1355 oh = NULL;
1359 oh = temp_oh;
1364 return oh;
1369 * @oh: struct omap_hwmod *
1375 static int _init_clkdm(struct omap_hwmod *oh)
1377 if (!oh->clkdm_name) {
1378 pr_debug("omap_hwmod: %s: missing clockdomain\n", oh->name);
1382 oh->clkdm = clkdm_lookup(oh->clkdm_name);
1383 if (!oh->clkdm) {
1385 oh->name, oh->clkdm_name);
1390 oh->name, oh->clkdm_name);
1398 * @oh: struct omap_hwmod *
1405 static int _init_clocks(struct omap_hwmod *oh, struct device_node *np)
1409 if (oh->_state != _HWMOD_STATE_REGISTERED)
1412 pr_debug("omap_hwmod: %s: looking up clocks\n", oh->name);
1415 ret |= soc_ops.init_clkdm(oh);
1417 ret |= _init_main_clk(oh);
1418 ret |= _init_interface_clks(oh);
1419 ret |= _init_opt_clks(oh);
1422 oh->_state = _HWMOD_STATE_CLKS_INITED;
1424 pr_warn("omap_hwmod: %s: cannot _init_clocks\n", oh->name);
1431 * @oh: struct omap_hwmod *
1438 static int _lookup_hardreset(struct omap_hwmod *oh, const char *name,
1443 for (i = 0; i < oh->rst_lines_cnt; i++) {
1444 const char *rst_line = oh->rst_lines[i].name;
1446 ohri->rst_shift = oh->rst_lines[i].rst_shift;
1447 ohri->st_shift = oh->rst_lines[i].st_shift;
1449 oh->name, __func__, rst_line, ohri->rst_shift,
1462 * @oh: struct omap_hwmod *
1467 * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
1472 static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
1477 if (!oh)
1483 ret = _lookup_hardreset(oh, name, &ohri);
1487 ret = soc_ops.assert_hardreset(oh, &ohri);
1495 * @oh: struct omap_hwmod *
1500 * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
1505 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
1510 if (!oh)
1516 ret = _lookup_hardreset(oh, name, &ohri);
1520 if (oh->clkdm) {
1526 clkdm_deny_idle(oh->clkdm);
1527 ret = clkdm_hwmod_enable(oh->clkdm, oh);
1530 oh->name, oh->clkdm->name, ret);
1535 _enable_clocks(oh);
1537 soc_ops.enable_module(oh);
1539 ret = soc_ops.deassert_hardreset(oh, &ohri);
1542 soc_ops.disable_module(oh);
1543 _disable_clocks(oh);
1546 pr_warn("omap_hwmod: %s: failed to hardreset\n", oh->name);
1548 if (oh->clkdm) {
1553 clkdm_allow_idle(oh->clkdm);
1555 clkdm_hwmod_disable(oh->clkdm, oh);
1564 * @oh: struct omap_hwmod *
1567 * Return the state of the reset line. Returns -EINVAL if @oh is
1573 static int _read_hardreset(struct omap_hwmod *oh, const char *name)
1578 if (!oh)
1584 ret = _lookup_hardreset(oh, name, &ohri);
1588 return soc_ops.is_hardreset_asserted(oh, &ohri);
1592 * _are_all_hardreset_lines_asserted - return true if the @oh is hard-reset
1593 * @oh: struct omap_hwmod *
1595 * If all hardreset lines associated with @oh are asserted, then return true.
1596 * Otherwise, if part of @oh is out hardreset or if no hardreset lines
1597 * associated with @oh are asserted, then return false.
1601 static bool _are_all_hardreset_lines_asserted(struct omap_hwmod *oh)
1605 if (oh->rst_lines_cnt == 0)
1608 for (i = 0; i < oh->rst_lines_cnt; i++)
1609 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0)
1612 if (oh->rst_lines_cnt == rst_cnt)
1619 * _are_any_hardreset_lines_asserted - return true if any part of @oh is
1621 * @oh: struct omap_hwmod *
1623 * If any hardreset lines associated with @oh are asserted, then
1624 * return true. Otherwise, if no hardreset lines associated with @oh
1625 * are asserted, or if @oh has no hardreset lines, then return false.
1629 static bool _are_any_hardreset_lines_asserted(struct omap_hwmod *oh)
1634 for (i = 0; i < oh->rst_lines_cnt && rst_cnt == 0; i++)
1635 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0)
1643 * @oh: struct omap_hwmod *
1645 * Disable the PRCM module mode related to the hwmod @oh.
1648 static int _omap4_disable_module(struct omap_hwmod *oh)
1652 if (!oh->clkdm || !oh->prcm.omap4.modulemode ||
1653 _omap4_clkctrl_managed_by_clkfwk(oh))
1660 if (_are_any_hardreset_lines_asserted(oh))
1663 pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__);
1665 omap_cm_module_disable(oh->clkdm->prcm_partition, oh->clkdm->cm_inst,
1666 oh->prcm.omap4.clkctrl_offs);
1668 v = _omap4_wait_target_disable(oh);
1671 oh->name);
1678 * @oh: struct omap_hwmod *
1680 * Resets an omap_hwmod @oh via the OCP_SYSCONFIG bit. hwmod must be
1692 static int _ocp_softreset(struct omap_hwmod *oh)
1698 if (!oh->class->sysc ||
1699 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET))
1703 if (oh->_state != _HWMOD_STATE_ENABLED) {
1705 oh->name);
1710 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1711 _enable_optional_clocks(oh);
1713 pr_debug("omap_hwmod: %s: resetting via OCP SOFTRESET\n", oh->name);
1715 v = oh->_sysc_cache;
1716 ret = _set_softreset(oh, &v);
1720 _write_sysconfig(v, oh);
1722 if (oh->class->sysc->srst_udelay)
1723 udelay(oh->class->sysc->srst_udelay);
1725 c = _wait_softreset_complete(oh);
1728 oh->name, MAX_MODULE_SOFTRESET_WAIT);
1732 pr_debug("omap_hwmod: %s: softreset in %d usec\n", oh->name, c);
1735 ret = _clear_softreset(oh, &v);
1739 _write_sysconfig(v, oh);
1747 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1748 _disable_optional_clocks(oh);
1755 * @oh: struct omap_hwmod *
1757 * Resets an omap_hwmod @oh. If the module has a custom reset
1786 static int _reset(struct omap_hwmod *oh)
1790 pr_debug("omap_hwmod: %s: resetting\n", oh->name);
1792 if (oh->class->reset) {
1793 r = oh->class->reset(oh);
1795 if (oh->rst_lines_cnt > 0) {
1796 for (i = 0; i < oh->rst_lines_cnt; i++)
1797 _assert_hardreset(oh, oh->rst_lines[i].name);
1800 r = _ocp_softreset(oh);
1806 _set_dmadisable(oh);
1813 if (oh->class->sysc) {
1814 _update_sysc_cache(oh);
1815 _enable_sysc(oh);
1824 * @oh: hwmod to check for context loss
1826 * If the PRCM indicates that the hwmod @oh lost context, increment
1830 static void _omap4_update_context_lost(struct omap_hwmod *oh)
1832 if (oh->prcm.omap4.flags & HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT)
1835 if (!prm_was_any_context_lost_old(oh->clkdm->pwrdm.ptr->prcm_partition,
1836 oh->clkdm->pwrdm.ptr->prcm_offs,
1837 oh->prcm.omap4.context_offs))
1840 oh->prcm.omap4.context_lost_counter++;
1841 prm_clear_context_loss_flags_old(oh->clkdm->pwrdm.ptr->prcm_partition,
1842 oh->clkdm->pwrdm.ptr->prcm_offs,
1843 oh->prcm.omap4.context_offs);
1848 * @oh: hwmod to get context loss counter for
1852 static int _omap4_get_context_lost(struct omap_hwmod *oh)
1854 return oh->prcm.omap4.context_lost_counter;
1859 * @oh: struct omap_hwmod *
1861 * Enables an omap_hwmod @oh such that the MPU can access the hwmod's
1865 static int _enable(struct omap_hwmod *oh)
1869 pr_debug("omap_hwmod: %s: enabling\n", oh->name);
1875 if (oh->_int_flags & _HWMOD_SKIP_ENABLE) {
1876 oh->_int_flags &= ~_HWMOD_SKIP_ENABLE;
1880 if (oh->_state != _HWMOD_STATE_INITIALIZED &&
1881 oh->_state != _HWMOD_STATE_IDLE &&
1882 oh->_state != _HWMOD_STATE_DISABLED) {
1884 oh->name);
1897 if (_are_all_hardreset_lines_asserted(oh))
1900 _add_initiator_dep(oh, mpu_oh);
1902 if (oh->clkdm) {
1908 clkdm_deny_idle(oh->clkdm);
1909 r = clkdm_hwmod_enable(oh->clkdm, oh);
1912 oh->name, oh->clkdm->name, r);
1917 _enable_clocks(oh);
1919 soc_ops.enable_module(oh);
1920 if (oh->flags & HWMOD_BLOCK_WFI)
1924 soc_ops.update_context_lost(oh);
1926 r = (soc_ops.wait_target_ready) ? soc_ops.wait_target_ready(oh) :
1928 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO))
1929 clkdm_allow_idle(oh->clkdm);
1932 oh->_state = _HWMOD_STATE_ENABLED;
1935 if (oh->class->sysc) {
1936 if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED))
1937 _update_sysc_cache(oh);
1938 _enable_sysc(oh);
1942 soc_ops.disable_module(oh);
1943 _disable_clocks(oh);
1945 oh->name, r);
1947 if (oh->clkdm)
1948 clkdm_hwmod_disable(oh->clkdm, oh);
1956 * @oh: struct omap_hwmod *
1958 * Idles an omap_hwmod @oh. This should be called once the hwmod has
1962 static int _idle(struct omap_hwmod *oh)
1964 if (oh->flags & HWMOD_NO_IDLE) {
1965 oh->_int_flags |= _HWMOD_SKIP_ENABLE;
1969 pr_debug("omap_hwmod: %s: idling\n", oh->name);
1971 if (_are_all_hardreset_lines_asserted(oh))
1974 if (oh->_state != _HWMOD_STATE_ENABLED) {
1976 oh->name);
1980 if (oh->class->sysc)
1981 _idle_sysc(oh);
1982 _del_initiator_dep(oh, mpu_oh);
1989 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO))
1990 clkdm_deny_idle(oh->clkdm);
1992 if (oh->flags & HWMOD_BLOCK_WFI)
1995 soc_ops.disable_module(oh);
2003 _disable_clocks(oh);
2004 if (oh->clkdm) {
2005 clkdm_allow_idle(oh->clkdm);
2006 clkdm_hwmod_disable(oh->clkdm, oh);
2009 oh->_state = _HWMOD_STATE_IDLE;
2016 * @oh: struct omap_hwmod *
2018 * Shut down an omap_hwmod @oh. This should be called when the driver
2023 static int _shutdown(struct omap_hwmod *oh)
2028 if (_are_all_hardreset_lines_asserted(oh))
2031 if (oh->_state != _HWMOD_STATE_IDLE &&
2032 oh->_state != _HWMOD_STATE_ENABLED) {
2034 oh->name);
2038 pr_debug("omap_hwmod: %s: disabling\n", oh->name);
2040 if (oh->class->pre_shutdown) {
2041 prev_state = oh->_state;
2042 if (oh->_state == _HWMOD_STATE_IDLE)
2043 _enable(oh);
2044 ret = oh->class->pre_shutdown(oh);
2047 _idle(oh);
2052 if (oh->class->sysc) {
2053 if (oh->_state == _HWMOD_STATE_IDLE)
2054 _enable(oh);
2055 _shutdown_sysc(oh);
2059 if (oh->_state == _HWMOD_STATE_ENABLED) {
2060 _del_initiator_dep(oh, mpu_oh);
2062 if (oh->flags & HWMOD_BLOCK_WFI)
2065 soc_ops.disable_module(oh);
2066 _disable_clocks(oh);
2067 if (oh->clkdm)
2068 clkdm_hwmod_disable(oh->clkdm, oh);
2072 for (i = 0; i < oh->rst_lines_cnt; i++)
2073 _assert_hardreset(oh, oh->rst_lines[i].name);
2075 oh->_state = _HWMOD_STATE_DISABLED;
2081 struct omap_hwmod *oh)
2095 if (!strcmp(p, oh->name)) {
2097 np, i, oh->name);
2108 * @oh: struct omap_hwmod *
2117 struct omap_hwmod *oh,
2124 res = of_dev_find_hwmod(np, oh);
2135 res = of_dev_hwmod_lookup(np0, oh, &i, &fc);
2152 * @oh: struct omap_hwmod *
2163 static void omap_hwmod_fix_mpu_rt_idx(struct omap_hwmod *oh,
2174 error = of_address_to_resource(child, oh->mpu_rt_idx, res);
2182 * @oh: struct omap_hwmod *
2191 int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
2231 oh->name, np);
2240 oh->name, np, base, size);
2242 if (oh && oh->mpu_rt_idx) {
2243 omap_hwmod_fix_mpu_rt_idx(oh, np, res);
2257 * @oh: struct omap_hwmod * to locate the virtual address
2272 static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data,
2279 if (!oh)
2282 _save_mpu_port_index(oh);
2285 if (!oh->class->sysc)
2289 if (oh->_int_flags & _HWMOD_NO_MPU_PORT)
2293 pr_err("omap_hwmod: %s: no dt node\n", oh->name);
2298 error = omap_hwmod_parse_module_range(oh, np, &res);
2304 va_start = of_iomap(np, index + oh->mpu_rt_idx);
2307 oh->name, index, np);
2312 oh->name, va_start);
2314 oh->_mpu_rt_va = va_start;
2318 static void __init parse_module_flags(struct omap_hwmod *oh,
2322 oh->flags |= HWMOD_INIT_NO_RESET;
2324 oh->flags |= HWMOD_INIT_NO_IDLE;
2326 oh->flags |= HWMOD_NO_IDLE;
2330 * _init - initialize internal data for the hwmod @oh
2331 * @oh: struct omap_hwmod *
2335 * registers belonging to the hwmod @oh. @oh must already be
2342 static int __init _init(struct omap_hwmod *oh, void *data)
2348 if (oh->_state != _HWMOD_STATE_REGISTERED)
2355 r = of_dev_hwmod_lookup(bus, oh, &index, &np);
2357 pr_debug("omap_hwmod: %s missing dt data\n", oh->name);
2360 oh->name, np);
2362 r = _init_mpu_rt_base(oh, NULL, index, np);
2365 oh->name);
2369 r = _init_clocks(oh, np);
2371 WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name);
2378 parse_module_flags(oh, np);
2381 parse_module_flags(oh, child);
2384 oh->_state = _HWMOD_STATE_INITIALIZED;
2391 * @oh: struct omap_hwmod *
2397 static void _setup_iclk_autoidle(struct omap_hwmod *oh)
2401 if (oh->_state != _HWMOD_STATE_INITIALIZED)
2404 list_for_each_entry(os, &oh->slave_ports, node) {
2425 * @oh: struct omap_hwmod *
2427 * Reset the IP block corresponding to the hwmod @oh during the setup
2432 static int _setup_reset(struct omap_hwmod *oh)
2436 if (oh->_state != _HWMOD_STATE_INITIALIZED)
2439 if (oh->flags & HWMOD_EXT_OPT_MAIN_CLK)
2442 if (oh->rst_lines_cnt == 0) {
2443 r = _enable(oh);
2446 oh->name, oh->_state);
2451 if (!(oh->flags & HWMOD_INIT_NO_RESET))
2452 r = _reset(oh);
2459 * @oh: struct omap_hwmod *
2461 * Place an IP block represented by @oh into a "post-setup" state --
2493 static void _setup_postsetup(struct omap_hwmod *oh)
2497 if (oh->rst_lines_cnt > 0)
2500 postsetup_state = oh->_postsetup_state;
2508 if ((oh->flags & (HWMOD_INIT_NO_IDLE | HWMOD_NO_IDLE)) &&
2510 oh->_int_flags |= _HWMOD_SKIP_ENABLE;
2515 _idle(oh);
2517 _shutdown(oh);
2520 oh->name, postsetup_state);
2527 * @oh: struct omap_hwmod *
2530 * Configure the IP block represented by @oh. This may include
2541 static int _setup(struct omap_hwmod *oh, void *data)
2543 if (oh->_state != _HWMOD_STATE_INITIALIZED)
2546 if (oh->parent_hwmod) {
2549 r = _enable(oh->parent_hwmod);
2551 oh->name, oh->parent_hwmod->name);
2554 _setup_iclk_autoidle(oh);
2556 if (!_setup_reset(oh))
2557 _setup_postsetup(oh);
2559 if (oh->parent_hwmod) {
2562 postsetup_state = oh->parent_hwmod->_postsetup_state;
2565 _idle(oh->parent_hwmod);
2567 _shutdown(oh->parent_hwmod);
2570 oh->parent_hwmod->name, postsetup_state);
2578 * @oh: struct omap_hwmod *
2580 * Registers the omap_hwmod @oh. Returns -EEXIST if an omap_hwmod
2582 * omap_hwmod is in the wrong state, if @oh is NULL, if the
2593 static int _register(struct omap_hwmod *oh)
2595 if (!oh || !oh->name || !oh->class || !oh->class->name ||
2596 (oh->_state != _HWMOD_STATE_UNKNOWN))
2599 pr_debug("omap_hwmod: %s: registering\n", oh->name);
2601 if (_lookup(oh->name))
2604 list_add_tail(&oh->node, &omap_hwmod_list);
2606 INIT_LIST_HEAD(&oh->slave_ports);
2607 spin_lock_init(&oh->_lock);
2608 lockdep_set_class(&oh->_lock, &oh->hwmod_key);
2610 oh->_state = _HWMOD_STATE_REGISTERED;
2616 if (!strcmp(oh->name, MPU_INITIATOR_NAME))
2617 mpu_oh = oh;
2688 * @oh: struct omap_hwmod *
2690 * Wait for a module @oh to leave slave idle. Returns 0 if the module
2695 static int _omap2xxx_3xxx_wait_target_ready(struct omap_hwmod *oh)
2697 if (!oh)
2700 if (oh->flags & HWMOD_NO_IDLEST)
2703 if (!_find_mpu_rt_port(oh))
2708 return omap_cm_wait_module_ready(0, oh->prcm.omap2.module_offs,
2709 oh->prcm.omap2.idlest_reg_id,
2710 oh->prcm.omap2.idlest_idle_bit);
2715 * @oh: struct omap_hwmod *
2717 * Wait for a module @oh to leave slave idle. Returns 0 if the module
2722 static int _omap4_wait_target_ready(struct omap_hwmod *oh)
2724 if (!oh)
2727 if (oh->flags & HWMOD_NO_IDLEST || !oh->clkdm)
2730 if (!_find_mpu_rt_port(oh))
2733 if (_omap4_clkctrl_managed_by_clkfwk(oh))
2736 if (!_omap4_has_clkctrl_clock(oh))
2741 return omap_cm_wait_module_ready(oh->clkdm->prcm_partition,
2742 oh->clkdm->cm_inst,
2743 oh->prcm.omap4.clkctrl_offs, 0);
2748 * @oh: struct omap_hwmod * to assert hardreset
2752 * the hwmod @oh and the hardreset line data @ohri. Only intended for
2757 static int _omap2_assert_hardreset(struct omap_hwmod *oh,
2761 oh->prcm.omap2.module_offs, 0);
2766 * @oh: struct omap_hwmod * to deassert hardreset
2770 * the hwmod @oh and the hardreset line data @ohri. Only intended for
2775 static int _omap2_deassert_hardreset(struct omap_hwmod *oh,
2779 oh->prcm.omap2.module_offs, 0, 0);
2784 * @oh: struct omap_hwmod * to test hardreset
2788 * from the hwmod @oh and the hardreset line data @ohri. Only
2794 static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh,
2798 oh->prcm.omap2.module_offs, 0);
2803 * @oh: struct omap_hwmod * to assert hardreset
2807 * from the hwmod @oh and the hardreset line data @ohri. Only
2813 static int _omap4_assert_hardreset(struct omap_hwmod *oh,
2816 if (!oh->clkdm)
2820 oh->clkdm->pwrdm.ptr->prcm_partition,
2821 oh->clkdm->pwrdm.ptr->prcm_offs,
2822 oh->prcm.omap4.rstctrl_offs);
2827 * @oh: struct omap_hwmod * to deassert hardreset
2831 * from the hwmod @oh and the hardreset line data @ohri. Only
2837 static int _omap4_deassert_hardreset(struct omap_hwmod *oh,
2840 if (!oh->clkdm)
2845 oh->name, ohri->name);
2847 oh->clkdm->pwrdm.ptr->prcm_partition,
2848 oh->clkdm->pwrdm.ptr->prcm_offs,
2849 oh->prcm.omap4.rstctrl_offs,
2850 oh->prcm.omap4.rstctrl_offs +
2856 * @oh: struct omap_hwmod * to test hardreset
2860 * extracted from the hwmod @oh and the hardreset line data @ohri.
2866 static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh,
2869 if (!oh->clkdm)
2873 oh->clkdm->pwrdm.ptr->
2875 oh->clkdm->pwrdm.ptr->prcm_offs,
2876 oh->prcm.omap4.rstctrl_offs);
2881 * @oh: struct omap_hwmod * to disable control for
2887 static int _omap4_disable_direct_prcm(struct omap_hwmod *oh)
2889 if (!oh)
2892 oh->prcm.omap4.flags |= HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK;
2899 * @oh: struct omap_hwmod * to deassert hardreset
2903 * from the hwmod @oh and the hardreset line data @ohri. Only
2909 static int _am33xx_deassert_hardreset(struct omap_hwmod *oh,
2913 oh->clkdm->pwrdm.ptr->prcm_partition,
2914 oh->clkdm->pwrdm.ptr->prcm_offs,
2915 oh->prcm.omap4.rstctrl_offs,
2916 oh->prcm.omap4.rstst_offs);
2921 u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs)
2923 if (oh->flags & HWMOD_16BIT_REG)
2924 return readw_relaxed(oh->_mpu_rt_va + reg_offs);
2926 return readl_relaxed(oh->_mpu_rt_va + reg_offs);
2929 void omap_hwmod_write(u32 v, struct omap_hwmod *oh, u16 reg_offs)
2931 if (oh->flags & HWMOD_16BIT_REG)
2932 writew_relaxed(v, oh->_mpu_rt_va + reg_offs);
2934 writel_relaxed(v, oh->_mpu_rt_va + reg_offs);
2939 * @oh: struct omap_hwmod *
2946 int omap_hwmod_softreset(struct omap_hwmod *oh)
2951 if (!oh || !(oh->_sysc_cache))
2954 v = oh->_sysc_cache;
2955 ret = _set_softreset(oh, &v);
2958 _write_sysconfig(v, oh);
2960 ret = _clear_softreset(oh, &v);
2963 _write_sysconfig(v, oh);
2978 struct omap_hwmod *oh;
2983 oh = _lookup(name);
2985 return oh;
3000 int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data),
3055 * @oh: pointer to the hwmod currently being set up (usually not the MPU)
3063 static void __init _ensure_mpu_hwmod_is_setup(struct omap_hwmod *oh)
3068 else if (mpu_oh->_state == _HWMOD_STATE_REGISTERED && oh != mpu_oh)
3085 struct omap_hwmod *oh;
3089 oh = _lookup(oh_name);
3090 if (!oh) {
3095 _ensure_mpu_hwmod_is_setup(oh);
3097 _init(oh, NULL);
3098 _setup(oh, NULL);
3153 * @oh: module
3157 static int omap_hwmod_init_regbits(struct device *dev, struct omap_hwmod *oh,
3196 if (!oh->class->sysc->sysc_fields)
3346 * @oh: module
3356 struct omap_hwmod *oh,
3363 if (!oh->class->sysc)
3366 if (oh->class->sysc->sysc_fields &&
3367 sysc_fields != oh->class->sysc->sysc_fields)
3370 if (rev_offs != oh->class->sysc->rev_offs)
3372 oh->class->sysc->rev_offs);
3373 if (sysc_offs != oh->class->sysc->sysc_offs)
3375 oh->class->sysc->sysc_offs);
3376 if (syss_offs != oh->class->sysc->syss_offs)
3378 oh->class->sysc->syss_offs);
3380 if (sysc_flags != oh->class->sysc->sysc_flags)
3382 oh->class->sysc->sysc_flags);
3384 if (idlemodes != oh->class->sysc->idlemodes)
3386 oh->class->sysc->idlemodes);
3388 if (data->cfg->srst_udelay != oh->class->sysc->srst_udelay)
3391 oh->class->sysc->srst_udelay);
3399 * @oh: module
3410 static int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,
3436 if (!oh->_mpu_rt_va) {
3444 * We may need a new oh->class as the other devices in the same class
3447 if (oh->class->name && strcmp(oh->class->name, data->name)) {
3448 class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL);
3453 if (list_empty(&oh->slave_ports)) {
3463 oi->slave = oh;
3467 spin_lock_irqsave(&oh->_lock, flags);
3469 oh->_mpu_rt_va = regs;
3471 oh->class = class;
3472 oh->class->sysc = sysc;
3476 oh->clkdm = clkdm;
3477 oh->_state = _HWMOD_STATE_INITIALIZED;
3478 oh->_postsetup_state = _HWMOD_STATE_DEFAULT;
3479 _setup(oh, NULL);
3480 spin_unlock_irqrestore(&oh->_lock, flags);
3509 omap_hwmod_init_reset_quirk(struct device *dev, struct omap_hwmod *oh,
3520 oh->class->reset = quirk->reset;
3528 omap_hwmod_init_reset_quirks(struct device *dev, struct omap_hwmod *oh,
3532 omap_hwmod_init_reset_quirk(dev, oh, data,
3537 omap_hwmod_init_reset_quirk(dev, oh, data, dra7_reset_quirks,
3540 omap_hwmod_init_reset_quirk(dev, oh, data, omap_reset_quirks,
3554 struct omap_hwmod *oh;
3563 oh = _lookup(data->name);
3564 if (!oh) {
3565 oh = kzalloc(sizeof(*oh), GFP_KERNEL);
3566 if (!oh)
3569 oh->name = data->name;
3570 oh->_state = _HWMOD_STATE_UNKNOWN;
3571 lockdep_register_key(&oh->hwmod_key);
3574 oh->prcm.omap4.flags = HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT;
3576 oh->class = kzalloc(sizeof(*oh->class), GFP_KERNEL);
3577 if (!oh->class) {
3578 kfree(oh);
3582 omap_hwmod_init_reset_quirks(dev, oh, data);
3584 oh->class->name = data->name;
3586 error = _register(oh);
3590 cookie->data = oh;
3592 error = omap_hwmod_init_regbits(dev, oh, data, &sysc_fields);
3610 oh->flags |= HWMOD_NO_IDLE;
3612 oh->flags |= HWMOD_INIT_NO_IDLE;
3614 oh->flags |= HWMOD_INIT_NO_RESET;
3616 oh->flags |= HWMOD_SET_DEFAULT_CLOCKACT;
3618 oh->flags |= HWMOD_SWSUP_SIDLE;
3620 oh->flags |= HWMOD_SWSUP_SIDLE_ACT;
3622 oh->flags |= HWMOD_SWSUP_MSTANDBY;
3624 oh->flags |= HWMOD_CLKDM_NOAUTO;
3626 error = omap_hwmod_check_module(dev, oh, data, sysc_fields,
3632 return omap_hwmod_allocate_module(dev, oh, data, sysc_fields,
3649 struct omap_hwmod *oh;
3659 oh = omap_hwmod_lookup(uart);
3660 if (!oh) {
3664 oh = omap_hwmod_lookup(uart);
3666 if (oh)
3667 oh->flags |= DEBUG_OMAPUART_FLAGS;
3698 * @oh: struct omap_hwmod *
3700 * Enable an omap_hwmod @oh. Intended to be called by omap_device_enable().
3703 int omap_hwmod_enable(struct omap_hwmod *oh)
3708 if (!oh)
3711 spin_lock_irqsave(&oh->_lock, flags);
3712 r = _enable(oh);
3713 spin_unlock_irqrestore(&oh->_lock, flags);
3720 * @oh: struct omap_hwmod *
3722 * Idle an omap_hwmod @oh. Intended to be called by omap_device_idle().
3725 int omap_hwmod_idle(struct omap_hwmod *oh)
3730 if (!oh)
3733 spin_lock_irqsave(&oh->_lock, flags);
3734 r = _idle(oh);
3735 spin_unlock_irqrestore(&oh->_lock, flags);
3742 * @oh: struct omap_hwmod *
3744 * Shutdown an omap_hwmod @oh. Intended to be called by
3748 int omap_hwmod_shutdown(struct omap_hwmod *oh)
3753 if (!oh)
3756 spin_lock_irqsave(&oh->_lock, flags);
3757 r = _shutdown(oh);
3758 spin_unlock_irqrestore(&oh->_lock, flags);
3769 * @oh: struct omap_hwmod *
3772 * @oh's main clock. If @oh does not have a main clk, return the
3778 struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh)
3786 if (!oh)
3789 if (oh->clkdm)
3790 return oh->clkdm->pwrdm.ptr;
3792 if (oh->_clk) {
3793 c = oh->_clk;
3795 oi = _find_mpu_rt_port(oh);
3818 * @oh: struct omap_hwmod *
3825 void __iomem *omap_hwmod_get_mpu_rt_va(struct omap_hwmod *oh)
3827 if (!oh)
3830 if (oh->_int_flags & _HWMOD_NO_MPU_PORT)
3833 if (oh->_state == _HWMOD_STATE_UNKNOWN)
3836 return oh->_mpu_rt_va;
3847 * @oh: struct omap_hwmod *
3852 * the IP. Returns -EINVAL if @oh is null or if the operation is not
3856 int omap_hwmod_assert_hardreset(struct omap_hwmod *oh, const char *name)
3861 if (!oh)
3864 spin_lock_irqsave(&oh->_lock, flags);
3865 ret = _assert_hardreset(oh, name);
3866 spin_unlock_irqrestore(&oh->_lock, flags);
3874 * @oh: struct omap_hwmod *
3879 * the IP. Returns -EINVAL if @oh is null or if the operation is not
3883 int omap_hwmod_deassert_hardreset(struct omap_hwmod *oh, const char *name)
3888 if (!oh)
3891 spin_lock_irqsave(&oh->_lock, flags);
3892 ret = _deassert_hardreset(oh, name);
3893 spin_unlock_irqrestore(&oh->_lock, flags);
3911 int (*fn)(struct omap_hwmod *oh,
3943 * @oh: struct omap_hwmod *
3946 * Sets the hwmod state that @oh will enter at the end of _setup()
3952 int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state)
3957 if (!oh)
3965 spin_lock_irqsave(&oh->_lock, flags);
3967 if (oh->_state != _HWMOD_STATE_REGISTERED) {
3972 oh->_postsetup_state = state;
3976 spin_unlock_irqrestore(&oh->_lock, flags);
3983 * @oh: struct omap_hwmod *
3985 * Returns the context loss count of associated @oh
3992 int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
3998 return soc_ops.get_context_lost(oh);
4000 pwrdm = omap_hwmod_get_pwrdm(oh);
4061 * @oh: struct omap_hwmod *
4063 * Returns the main clock name assocated with @oh upon success,
4064 * or NULL if @oh is NULL.
4066 const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh)
4068 if (!oh)
4071 return oh->main_clk;