Lines Matching +full:idle +full:- +full:state +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2009-2011 Nokia Corporation
6 * Copyright (C) 2011-2012 Texas Instruments, Inc.
15 * ------------
21 * TI's documentation, on-chip devices are referred to as "OMAP
26 * Most of the address and data flow between modules is via OCP-based
28 * interconnects that distribute the hardware clock tree, handle idle
32 * OMAP hwmod provides a consistent way to describe the on-chip
36 * to reset, enable, idle, and disable these hardware blocks. And
42 * -----------
54 * +-------------------------------+
57 * +-------------------------------+
61 * +-------------------------------+
62 * | OMAP core-driver integration |
63 * |(arch/arm/mach-omap2/devices.c)|
64 * +-------------------------------+
66 * | (../plat-omap/omap_device.c) |
67 * +-------------------------------+
68 * ----> | omap_hwmod code/data | <-----
69 * | (../mach-omap2/omap_hwmod*) |
70 * +-------------------------------+
73 * +-------------------------------+
75 * Device drivers should not contain any OMAP-specific code or data in
82 * The OMAP hwmod code also will attempt to reset and idle all on-chip
84 * completely self-reliant and independent from bootloaders. This is
90 * ---------------------------
92 * states. IP blocks start out in an UNKNOWN state, then once they
93 * are registered via the hwmod code, proceed to the REGISTERED state.
95 * enters the CLKS_INITED state; and finally, once the module has been
96 * reset and the integration registers programmed, the INITIALIZED state
98 * the IDLE state to save power, or in the case of a critical system
99 * module, the ENABLED state.
102 * directly to move the module between the IDLE, ENABLED, and DISABLED
103 * states, as needed. This is done during both the PM idle loop, and
108 * ----------
110 * - OMAP2420 Multimedia Processor Silicon Revision 2.1.1, 2.2 (SWPU064)
111 * - OMAP2430 Multimedia Device POP Silicon Revision 2.1 (SWPU090)
112 * - OMAP34xx Multimedia Device Silicon Revision 3.1 (SWPU108)
113 * - OMAP4430 Multimedia Device Silicon Revision 1.0 (SWPU140)
114 * - Open Core Protocol Specification 2.2
117 * - handle IO mapping
118 * - bus throughput & module latency measurement code
121 * in the appropriate state
131 #include <linux/clk-provider.h>
143 #include <linux/platform_data/ti-sysc.h>
145 #include <dt-bindings/bus/ti-sysc.h>
169 /* Name of the OMAP hwmod for the MPU */
174 * omap_hwmod_ocp_if record (master->slave and slave->master)
190 * struct clkctrl_provider - clkctrl provider mapping data
208 * struct omap_hwmod_reset - IP specific reset functions
209 * @match: string to match against the module name
222 * struct omap_hwmod_soc_ops - fn ptrs for some SoC-specific operations
247 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
263 * _update_sysc_cache - return the module OCP_SYSCONFIG register, keep copy
267 * struct omap_hwmod for later use. Returns -EINVAL if the hwmod has no
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()
274 return -EINVAL; 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()
288 * _write_sysconfig - write a value to the module's OCP_SYSCONFIG register
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()
329 * the @oh hwmod. Does not write to the hardware. Returns -EINVAL
338 if (!oh->class->sysc || in _set_master_standbymode()
339 !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE)) in _set_master_standbymode()
340 return -EINVAL; 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()
344 return -EINVAL; in _set_master_standbymode()
347 mstandby_shift = oh->class->sysc->sysc_fields->midle_shift; in _set_master_standbymode()
362 * Update the slave idle mode bits in @v to be @idlemode for the @oh
363 * hwmod. Does not write to the hardware. Returns -EINVAL upon error
371 if (!oh->class->sysc || in _set_slave_idlemode()
372 !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE)) in _set_slave_idlemode()
373 return -EINVAL; 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()
377 return -EINVAL; in _set_slave_idlemode()
380 sidle_shift = oh->class->sysc->sysc_fields->sidle_shift; in _set_slave_idlemode()
397 * not write to the hardware. Returns -EINVAL upon error or 0 upon
405 if (!oh->class->sysc || in _set_clockactivity()
406 !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) in _set_clockactivity()
407 return -EINVAL; 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()
411 return -EINVAL; in _set_clockactivity()
414 clkact_shift = oh->class->sysc->sysc_fields->clkact_shift; in _set_clockactivity()
428 * Set the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon
435 if (!oh->class->sysc || in _set_softreset()
436 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _set_softreset()
437 return -EINVAL; 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()
441 return -EINVAL; in _set_softreset()
444 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _set_softreset()
456 * Clear the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon
463 if (!oh->class->sysc || in _clear_softreset()
464 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _clear_softreset()
465 return -EINVAL; in _clear_softreset()
467 if (!oh->class->sysc->sysc_fields) { in _clear_softreset()
470 oh->name); in _clear_softreset()
471 return -EINVAL; in _clear_softreset()
474 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); in _clear_softreset()
482 * _wait_softreset_complete - wait for an OCP softreset to complete
487 * _ocp_softreset()) or by hardware upon returning from off-mode (one
497 sysc = oh->class->sysc; in _wait_softreset_complete()
499 if (sysc->sysc_flags & SYSS_HAS_RESET_STATUS && sysc->syss_offs > 0) in _wait_softreset_complete()
500 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs) in _wait_softreset_complete()
503 else if (sysc->sysc_flags & SYSC_HAS_RESET_STATUS) { in _wait_softreset_complete()
504 softrst_mask = (0x1 << sysc->sysc_fields->srst_shift); in _wait_softreset_complete()
505 omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs) in _wait_softreset_complete()
517 * The DMADISABLE bit is a semi-automatic bit present in sysconfig register
522 * Set the DMADISABLE bit in @v for hwmod @oh. Returns -EINVAL upon
530 if (!oh->class->sysc || in _set_dmadisable()
531 !(oh->class->sysc->sysc_flags & SYSC_HAS_DMADISABLE)) in _set_dmadisable()
532 return -EINVAL; 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()
536 return -EINVAL; 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()
542 return -EINVAL; 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()
565 * exact function of this bit varies on a per-module basis. This
566 * function does not write to the hardware. Returns -EINVAL upon
575 if (!oh->class->sysc || in _set_module_autoidle()
576 !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE)) in _set_module_autoidle()
577 return -EINVAL; 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()
581 return -EINVAL; in _set_module_autoidle()
584 autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift; in _set_module_autoidle()
597 * Allow the hardware module @oh to send wakeups. Returns -EINVAL
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()
606 return -EINVAL; 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()
610 return -EINVAL; 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()
618 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_wakeup()
633 if (oh->clkdm) { in _get_clkdm()
634 return oh->clkdm; in _get_clkdm()
635 } else if (oh->_clk) { in _get_clkdm()
636 if (!omap2_clk_is_hw_omap(__clk_get_hw(oh->_clk))) in _get_clkdm()
638 clk = to_clk_hw_omap(__clk_get_hw(oh->_clk)); in _get_clkdm()
639 return clk->clkdm; in _get_clkdm()
645 * _add_initiator_dep: prevent @oh from smart-idling while @init_oh is active
648 * Prevent the hardware module @oh from entering idle while the
652 * initiator and the module). Only applies to modules in smart-idle
654 * 0 without doing anything. Otherwise, returns -EINVAL upon error or
665 return -EINVAL; in _add_initiator_dep()
667 if (clkdm && clkdm->flags & CLKDM_NO_AUTODEPS) in _add_initiator_dep()
674 * _del_initiator_dep: allow @oh to smart-idle even if @init_oh is active
677 * Allow the hardware module @oh to enter idle while the hardare
681 * initiator and the module). Only applies to modules in smart-idle
683 * 0 without doing anything. Returns -EINVAL upon error or passes
694 return -EINVAL; in _del_initiator_dep()
696 if (clkdm && clkdm->flags & CLKDM_NO_AUTODEPS) in _del_initiator_dep()
716 return -ENOMEM; in _setup_clkctrl_provider()
718 provider->node = np; in _setup_clkctrl_provider()
720 provider->num_addrs = in _setup_clkctrl_provider()
723 provider->addr = in _setup_clkctrl_provider()
724 memblock_alloc(sizeof(void *) * provider->num_addrs, in _setup_clkctrl_provider()
726 if (!provider->addr) in _setup_clkctrl_provider()
727 return -ENOMEM; in _setup_clkctrl_provider()
729 provider->size = in _setup_clkctrl_provider()
730 memblock_alloc(sizeof(u32) * provider->num_addrs, in _setup_clkctrl_provider()
732 if (!provider->size) in _setup_clkctrl_provider()
733 return -ENOMEM; in _setup_clkctrl_provider()
735 for (i = 0; i < provider->num_addrs; i++) { in _setup_clkctrl_provider()
737 provider->addr[i] = (u32)of_translate_address(np, addrp); in _setup_clkctrl_provider()
738 provider->size[i] = size; in _setup_clkctrl_provider()
739 pr_debug("%s: %pOF: %x...%x\n", __func__, np, provider->addr[i], in _setup_clkctrl_provider()
740 provider->addr[i] + provider->size[i]); in _setup_clkctrl_provider()
743 list_add(&provider->link, &clkctrl_providers); in _setup_clkctrl_provider()
764 if (!oh->prcm.omap4.modulemode) in _omap4_xlate_clkctrl()
767 return omap_cm_xlate_clkctrl(oh->clkdm->prcm_partition, in _omap4_xlate_clkctrl()
768 oh->clkdm->cm_inst, in _omap4_xlate_clkctrl()
769 oh->prcm.omap4.clkctrl_offs); in _omap4_xlate_clkctrl()
785 pr_debug("%s: %s: addr=%x\n", __func__, oh->name, addr); in _lookup_clkctrl_clk()
790 for (i = 0; i < provider->num_addrs; i++) { in _lookup_clkctrl_clk()
791 if (provider->addr[i] <= addr && in _lookup_clkctrl_clk()
792 provider->addr[i] + provider->size[i] > addr) { in _lookup_clkctrl_clk()
795 clkspec.np = provider->node; in _lookup_clkctrl_clk()
797 clkspec.args[0] = addr - provider->addr[0]; in _lookup_clkctrl_clk()
803 __func__, oh->name, clk, in _lookup_clkctrl_clk()
804 clkspec.args[0], provider->node); in _lookup_clkctrl_clk()
815 * _init_main_clk - get a struct clk * for the the hwmod's main functional clk
819 * functional clock pointer) if a clock matching the hwmod name is found,
820 * or a main_clk is present. Returns 0 on success or -EINVAL on error.
831 __clk_get_name(clk), oh->name); in _init_main_clk()
832 oh->main_clk = __clk_get_name(clk); in _init_main_clk()
833 oh->_clk = clk; in _init_main_clk()
836 if (!oh->main_clk) in _init_main_clk()
839 oh->_clk = clk_get(NULL, oh->main_clk); in _init_main_clk()
842 if (IS_ERR(oh->_clk)) { in _init_main_clk()
844 oh->name, oh->main_clk); in _init_main_clk()
845 return -EINVAL; in _init_main_clk()
848 * HACK: This needs a re-visit once clk_prepare() is implemented in _init_main_clk()
849 * to do something meaningful. Today its just a no-op. in _init_main_clk()
855 clk_prepare(oh->_clk); in _init_main_clk()
859 oh->name, oh->main_clk); in _init_main_clk()
865 * _init_interface_clks - get a struct clk * for the the hwmod's interface clks
869 * clock pointers. Returns 0 on success or -EINVAL on error.
877 list_for_each_entry(os, &oh->slave_ports, node) { in _init_interface_clks()
878 if (!os->clk) in _init_interface_clks()
881 c = clk_get(NULL, os->clk); in _init_interface_clks()
884 oh->name, os->clk); in _init_interface_clks()
885 ret = -EINVAL; in _init_interface_clks()
888 os->_clk = c; in _init_interface_clks()
890 * HACK: This needs a re-visit once clk_prepare() is implemented in _init_interface_clks()
891 * to do something meaningful. Today its just a no-op. in _init_interface_clks()
897 clk_prepare(os->_clk); in _init_interface_clks()
904 * _init_opt_clk - get a struct clk * for the the hwmod's optional clocks
908 * clock pointers. Returns 0 on success or -EINVAL on error.
917 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) { in _init_opt_clks()
918 c = clk_get(NULL, oc->clk); in _init_opt_clks()
921 oh->name, oc->clk); in _init_opt_clks()
922 ret = -EINVAL; in _init_opt_clks()
925 oc->_clk = c; in _init_opt_clks()
927 * HACK: This needs a re-visit once clk_prepare() is implemented in _init_opt_clks()
928 * to do something meaningful. Today its just a no-op. in _init_opt_clks()
934 clk_prepare(oc->_clk); in _init_opt_clks()
945 pr_debug("omap_hwmod: %s: enabling optional clocks\n", oh->name); in _enable_optional_clocks()
947 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _enable_optional_clocks()
948 if (oc->_clk) { in _enable_optional_clocks()
949 pr_debug("omap_hwmod: enable %s:%s\n", oc->role, in _enable_optional_clocks()
950 __clk_get_name(oc->_clk)); in _enable_optional_clocks()
951 clk_enable(oc->_clk); in _enable_optional_clocks()
960 pr_debug("omap_hwmod: %s: disabling optional clocks\n", oh->name); in _disable_optional_clocks()
962 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) in _disable_optional_clocks()
963 if (oc->_clk) { in _disable_optional_clocks()
964 pr_debug("omap_hwmod: disable %s:%s\n", oc->role, in _disable_optional_clocks()
965 __clk_get_name(oc->_clk)); in _disable_optional_clocks()
966 clk_disable(oc->_clk); in _disable_optional_clocks()
971 * _enable_clocks - enable hwmod main clock and interface clocks
981 pr_debug("omap_hwmod: %s: enabling clocks\n", oh->name); in _enable_clocks()
983 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _enable_clocks()
986 if (oh->_clk) in _enable_clocks()
987 clk_enable(oh->_clk); in _enable_clocks()
989 list_for_each_entry(os, &oh->slave_ports, node) { in _enable_clocks()
990 if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE)) { in _enable_clocks()
991 omap2_clk_deny_idle(os->_clk); in _enable_clocks()
992 clk_enable(os->_clk); in _enable_clocks()
1002 * _omap4_clkctrl_managed_by_clkfwk - true if clkctrl managed by clock framework
1007 if (oh->prcm.omap4.flags & HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK) in _omap4_clkctrl_managed_by_clkfwk()
1014 * _omap4_has_clkctrl_clock - returns true if a module has clkctrl clock
1019 if (oh->prcm.omap4.clkctrl_offs) in _omap4_has_clkctrl_clock()
1022 if (!oh->prcm.omap4.clkctrl_offs && in _omap4_has_clkctrl_clock()
1023 oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET) in _omap4_has_clkctrl_clock()
1030 * _disable_clocks - disable hwmod main clock and interface clocks
1039 pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name); in _disable_clocks()
1041 if (oh->_clk) in _disable_clocks()
1042 clk_disable(oh->_clk); in _disable_clocks()
1044 list_for_each_entry(os, &oh->slave_ports, node) { in _disable_clocks()
1045 if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE)) { in _disable_clocks()
1046 clk_disable(os->_clk); in _disable_clocks()
1047 omap2_clk_allow_idle(os->_clk); in _disable_clocks()
1051 if (oh->flags & HWMOD_OPT_CLKS_NEEDED) in _disable_clocks()
1060 * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
1068 if (!oh->clkdm || !oh->prcm.omap4.modulemode || in _omap4_enable_module()
1073 oh->name, __func__, oh->prcm.omap4.modulemode); in _omap4_enable_module()
1075 omap_cm_module_enable(oh->prcm.omap4.modulemode, in _omap4_enable_module()
1076 oh->clkdm->prcm_partition, in _omap4_enable_module()
1077 oh->clkdm->cm_inst, oh->prcm.omap4.clkctrl_offs); in _omap4_enable_module()
1081 * _omap4_wait_target_disable - wait for a module to be disabled on OMAP4
1084 * Wait for a module @oh to enter slave idle. Returns 0 if the module
1086 * slave idle; otherwise, pass along the return value of the
1092 return -EINVAL; in _omap4_wait_target_disable()
1094 if (oh->_int_flags & _HWMOD_NO_MPU_PORT || !oh->clkdm) in _omap4_wait_target_disable()
1097 if (oh->flags & HWMOD_NO_IDLEST) in _omap4_wait_target_disable()
1106 return omap_cm_wait_module_idle(oh->clkdm->prcm_partition, in _omap4_wait_target_disable()
1107 oh->clkdm->cm_inst, in _omap4_wait_target_disable()
1108 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_disable()
1112 * _save_mpu_port_index - find and save the index to @oh's MPU port
1127 oh->_int_flags |= _HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1129 list_for_each_entry(os, &oh->slave_ports, node) { in _save_mpu_port_index()
1130 if (os->user & OCP_USER_MPU) { in _save_mpu_port_index()
1131 oh->_mpu_port = os; in _save_mpu_port_index()
1132 oh->_int_flags &= ~_HWMOD_NO_MPU_PORT; in _save_mpu_port_index()
1141 * _find_mpu_rt_port - return omap_hwmod_ocp_if accessible by the MPU
1155 if (!oh || oh->_int_flags & _HWMOD_NO_MPU_PORT || oh->slaves_cnt == 0) in _find_mpu_rt_port()
1158 return oh->_mpu_port; in _find_mpu_rt_port()
1162 * _enable_sysc - try to bring a module out of idle via OCP_SYSCONFIG
1167 * Usually this means placing the module into smart-idle mode and
1168 * smart-standby, but if there is a bug in the automatic idle handling
1169 * for the IP block, it may need to be placed into the force-idle or
1170 * no-idle variants of these modes. No return value.
1179 if (!oh->class->sysc) in _enable_sysc()
1185 * (off-mode for example), and the drivers require the in _enable_sysc()
1188 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1191 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _enable_sysc()
1194 v = oh->_sysc_cache; in _enable_sysc()
1195 sf = oh->class->sysc->sysc_flags; in _enable_sysc()
1199 if (oh->flags & HWMOD_SWSUP_SIDLE || in _enable_sysc()
1200 oh->flags & HWMOD_SWSUP_SIDLE_ACT) { in _enable_sysc()
1205 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _enable_sysc()
1213 * 32k sync timer. Force them to idle! in _enable_sysc()
1215 clkdm_act = (clkdm && clkdm->flags & CLKDM_ACTIVE_WITH_MPU); in _enable_sysc()
1216 if (clkdm_act && !(oh->class->sysc->idlemodes & in _enable_sysc()
1224 if (oh->flags & HWMOD_FORCE_MSTANDBY) { in _enable_sysc()
1226 } else if (oh->flags & HWMOD_SWSUP_MSTANDBY) { in _enable_sysc()
1231 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _enable_sysc()
1244 if ((oh->flags & HWMOD_SET_DEFAULT_CLOCKACT) && in _enable_sysc()
1255 idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? in _enable_sysc()
1263 * _idle_sysc - try to put a module into idle via OCP_SYSCONFIG
1267 * idle; otherwise, configure it for smart-idle. If module is marked
1269 * configure it for smart-standby. No return value.
1276 if (!oh->class->sysc) in _idle_sysc()
1279 v = oh->_sysc_cache; in _idle_sysc()
1280 sf = oh->class->sysc->sysc_flags; in _idle_sysc()
1283 if (oh->flags & HWMOD_SWSUP_SIDLE) { in _idle_sysc()
1288 if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) in _idle_sysc()
1297 if ((oh->flags & HWMOD_SWSUP_MSTANDBY) || in _idle_sysc()
1298 (oh->flags & HWMOD_FORCE_MSTANDBY)) { in _idle_sysc()
1303 if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP) in _idle_sysc()
1312 if (oh->_sysc_cache != v) in _idle_sysc()
1317 * _shutdown_sysc - force a module into idle via OCP_SYSCONFIG
1320 * Force the module into slave idle and master suspend. No return
1328 if (!oh->class->sysc) in _shutdown_sysc()
1331 v = oh->_sysc_cache; in _shutdown_sysc()
1332 sf = oh->class->sysc->sysc_flags; in _shutdown_sysc()
1347 * _lookup - find an omap_hwmod by name
1348 * @name: find an omap_hwmod by name
1350 * Return a pointer to an omap_hwmod by name, or NULL if not found.
1352 static struct omap_hwmod *_lookup(const char *name) in _lookup() argument
1359 if (!strcmp(name, temp_oh->name)) { in _lookup()
1369 * _init_clkdm - look up a clockdomain name, store pointer in omap_hwmod
1372 * Convert a clockdomain name stored in a struct omap_hwmod into a
1374 * Return -EINVAL if the clkdm_name lookup failed.
1378 if (!oh->clkdm_name) { in _init_clkdm()
1379 pr_debug("omap_hwmod: %s: missing clockdomain\n", oh->name); in _init_clkdm()
1383 oh->clkdm = clkdm_lookup(oh->clkdm_name); in _init_clkdm()
1384 if (!oh->clkdm) { in _init_clkdm()
1386 oh->name, oh->clkdm_name); in _init_clkdm()
1391 oh->name, oh->clkdm_name); in _init_clkdm()
1397 * _init_clocks - clk_get() all clocks associated with this hwmod. Retrieve as
1410 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init_clocks()
1413 pr_debug("omap_hwmod: %s: looking up clocks\n", oh->name); in _init_clocks()
1423 oh->_state = _HWMOD_STATE_CLKS_INITED; in _init_clocks()
1425 pr_warn("omap_hwmod: %s: cannot _init_clocks\n", oh->name); in _init_clocks()
1431 * _lookup_hardreset - fill register bit info for this hwmod/reset line
1433 * @name: name of the reset line in the context of this hwmod
1437 * input name. Return -ENOENT if not found.
1439 static int _lookup_hardreset(struct omap_hwmod *oh, const char *name, in _lookup_hardreset() argument
1444 for (i = 0; i < oh->rst_lines_cnt; i++) { in _lookup_hardreset()
1445 const char *rst_line = oh->rst_lines[i].name; in _lookup_hardreset()
1446 if (!strcmp(rst_line, name)) { in _lookup_hardreset()
1447 ohri->rst_shift = oh->rst_lines[i].rst_shift; in _lookup_hardreset()
1448 ohri->st_shift = oh->rst_lines[i].st_shift; in _lookup_hardreset()
1450 oh->name, __func__, rst_line, ohri->rst_shift, in _lookup_hardreset()
1451 ohri->st_shift); in _lookup_hardreset()
1457 return -ENOENT; in _lookup_hardreset()
1461 * _assert_hardreset - assert the HW reset line of submodules
1464 * @name: name of the reset line to lookup and assert
1468 * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
1469 * asserting the hardreset line on the currently-booted SoC, or passes
1473 static int _assert_hardreset(struct omap_hwmod *oh, const char *name) in _assert_hardreset() argument
1476 int ret = -EINVAL; in _assert_hardreset()
1479 return -EINVAL; in _assert_hardreset()
1482 return -ENOSYS; in _assert_hardreset()
1484 ret = _lookup_hardreset(oh, name, &ohri); in _assert_hardreset()
1494 * _deassert_hardreset - deassert the HW reset line of submodules contained
1497 * @name: name of the reset line to look up and deassert
1501 * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
1502 * deasserting the hardreset line on the currently-booted SoC, or passes
1506 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name) in _deassert_hardreset() argument
1509 int ret = -EINVAL; in _deassert_hardreset()
1512 return -EINVAL; in _deassert_hardreset()
1515 return -ENOSYS; in _deassert_hardreset()
1517 ret = _lookup_hardreset(oh, name, &ohri); in _deassert_hardreset()
1521 if (oh->clkdm) { in _deassert_hardreset()
1527 clkdm_deny_idle(oh->clkdm); in _deassert_hardreset()
1528 ret = clkdm_hwmod_enable(oh->clkdm, oh); in _deassert_hardreset()
1531 oh->name, oh->clkdm->name, ret); in _deassert_hardreset()
1546 if (ret == -EBUSY) in _deassert_hardreset()
1547 pr_warn("omap_hwmod: %s: failed to hardreset\n", oh->name); in _deassert_hardreset()
1549 if (oh->clkdm) { in _deassert_hardreset()
1552 * previous state was HW_AUTO. in _deassert_hardreset()
1554 clkdm_allow_idle(oh->clkdm); in _deassert_hardreset()
1556 clkdm_hwmod_disable(oh->clkdm, oh); in _deassert_hardreset()
1563 * _read_hardreset - read the HW reset line state of submodules
1566 * @name: name of the reset line to look up and read
1568 * Return the state of the reset line. Returns -EINVAL if @oh is
1569 * null, -ENOSYS if we have no way of reading the hardreset line
1570 * status on the currently-booted SoC, or passes along the return
1574 static int _read_hardreset(struct omap_hwmod *oh, const char *name) in _read_hardreset() argument
1577 int ret = -EINVAL; in _read_hardreset()
1580 return -EINVAL; in _read_hardreset()
1583 return -ENOSYS; in _read_hardreset()
1585 ret = _lookup_hardreset(oh, name, &ohri); in _read_hardreset()
1593 * _are_all_hardreset_lines_asserted - return true if the @oh is hard-reset
1606 if (oh->rst_lines_cnt == 0) in _are_all_hardreset_lines_asserted()
1609 for (i = 0; i < oh->rst_lines_cnt; i++) in _are_all_hardreset_lines_asserted()
1610 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_all_hardreset_lines_asserted()
1613 if (oh->rst_lines_cnt == rst_cnt) in _are_all_hardreset_lines_asserted()
1620 * _are_any_hardreset_lines_asserted - return true if any part of @oh is
1621 * hard-reset
1635 for (i = 0; i < oh->rst_lines_cnt && rst_cnt == 0; i++) in _are_any_hardreset_lines_asserted()
1636 if (_read_hardreset(oh, oh->rst_lines[i].name) > 0) in _are_any_hardreset_lines_asserted()
1643 * _omap4_disable_module - enable CLKCTRL modulemode on OMAP4
1653 if (!oh->clkdm || !oh->prcm.omap4.modulemode || in _omap4_disable_module()
1655 return -EINVAL; in _omap4_disable_module()
1664 pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__); in _omap4_disable_module()
1666 omap_cm_module_disable(oh->clkdm->prcm_partition, oh->clkdm->cm_inst, in _omap4_disable_module()
1667 oh->prcm.omap4.clkctrl_offs); in _omap4_disable_module()
1672 oh->name); in _omap4_disable_module()
1678 * _ocp_softreset - reset an omap_hwmod via the OCP_SYSCONFIG bit
1682 * enabled for this to work. Returns -ENOENT if the hwmod cannot be
1683 * reset this way, -EINVAL if the hwmod is in the wrong state,
1684 * -ETIMEDOUT if the module did not reset in time, or 0 upon success.
1699 if (!oh->class->sysc || in _ocp_softreset()
1700 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) in _ocp_softreset()
1701 return -ENOENT; in _ocp_softreset()
1704 if (oh->_state != _HWMOD_STATE_ENABLED) { in _ocp_softreset()
1705 pr_warn("omap_hwmod: %s: reset can only be entered from enabled state\n", in _ocp_softreset()
1706 oh->name); in _ocp_softreset()
1707 return -EINVAL; in _ocp_softreset()
1711 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1714 pr_debug("omap_hwmod: %s: resetting via OCP SOFTRESET\n", oh->name); in _ocp_softreset()
1716 v = oh->_sysc_cache; in _ocp_softreset()
1723 if (oh->class->sysc->srst_udelay) in _ocp_softreset()
1724 udelay(oh->class->sysc->srst_udelay); in _ocp_softreset()
1729 oh->name, MAX_MODULE_SOFTRESET_WAIT); in _ocp_softreset()
1730 ret = -ETIMEDOUT; in _ocp_softreset()
1733 pr_debug("omap_hwmod: %s: softreset in %d usec\n", oh->name, c); in _ocp_softreset()
1748 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET) in _ocp_softreset()
1755 * _reset - reset an omap_hwmod
1783 * custom reset function - these must return -EINVAL if the hwmod
1784 * cannot be reset this way or if the hwmod is in the wrong state,
1785 * -ETIMEDOUT if the module did not reset in time, or 0 upon success.
1791 pr_debug("omap_hwmod: %s: resetting\n", oh->name); in _reset()
1793 if (oh->class->reset) { in _reset()
1794 r = oh->class->reset(oh); in _reset()
1796 if (oh->rst_lines_cnt > 0) { in _reset()
1797 for (i = 0; i < oh->rst_lines_cnt; i++) in _reset()
1798 _assert_hardreset(oh, oh->rst_lines[i].name); in _reset()
1802 if (r == -ENOENT) in _reset()
1814 if (oh->class->sysc) { in _reset()
1823 * _omap4_update_context_lost - increment hwmod context loss counter if
1828 * our in-memory context loss counter, and clear the RM_*_CONTEXT
1833 if (oh->prcm.omap4.flags & HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT) in _omap4_update_context_lost()
1836 if (!prm_was_any_context_lost_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
1837 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
1838 oh->prcm.omap4.context_offs)) in _omap4_update_context_lost()
1841 oh->prcm.omap4.context_lost_counter++; in _omap4_update_context_lost()
1842 prm_clear_context_loss_flags_old(oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_update_context_lost()
1843 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_update_context_lost()
1844 oh->prcm.omap4.context_offs); in _omap4_update_context_lost()
1848 * _omap4_get_context_lost - get context loss counter for a hwmod
1851 * Returns the in-memory context loss counter for a hwmod.
1855 return oh->prcm.omap4.context_lost_counter; in _omap4_get_context_lost()
1859 * _enable - enable an omap_hwmod
1863 * register target. Returns -EINVAL if the hwmod is in the wrong
1864 * state or passes along the return value of _wait_target_ready().
1870 pr_debug("omap_hwmod: %s: enabling\n", oh->name); in _enable()
1874 * state at init. in _enable()
1876 if (oh->_int_flags & _HWMOD_SKIP_ENABLE) { in _enable()
1877 oh->_int_flags &= ~_HWMOD_SKIP_ENABLE; in _enable()
1881 if (oh->_state != _HWMOD_STATE_INITIALIZED && in _enable()
1882 oh->_state != _HWMOD_STATE_IDLE && in _enable()
1883 oh->_state != _HWMOD_STATE_DISABLED) { in _enable()
1884 …WARN(1, "omap_hwmod: %s: enabled state can only be entered from initialized, idle, or disabled sta… in _enable()
1885 oh->name); in _enable()
1886 return -EINVAL; in _enable()
1903 if (oh->clkdm) { in _enable()
1909 clkdm_deny_idle(oh->clkdm); in _enable()
1910 r = clkdm_hwmod_enable(oh->clkdm, oh); in _enable()
1913 oh->name, oh->clkdm->name, r); in _enable()
1921 if (oh->flags & HWMOD_BLOCK_WFI) in _enable()
1928 -EINVAL; in _enable()
1929 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO)) in _enable()
1930 clkdm_allow_idle(oh->clkdm); in _enable()
1933 oh->_state = _HWMOD_STATE_ENABLED; in _enable()
1936 if (oh->class->sysc) { in _enable()
1937 if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) in _enable()
1946 oh->name, r); in _enable()
1948 if (oh->clkdm) in _enable()
1949 clkdm_hwmod_disable(oh->clkdm, oh); in _enable()
1956 * _idle - idle an omap_hwmod
1960 * no further work. Returns -EINVAL if the hwmod is in the wrong
1961 * state or returns 0.
1965 if (oh->flags & HWMOD_NO_IDLE) { in _idle()
1966 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _idle()
1970 pr_debug("omap_hwmod: %s: idling\n", oh->name); in _idle()
1975 if (oh->_state != _HWMOD_STATE_ENABLED) { in _idle()
1976 WARN(1, "omap_hwmod: %s: idle state can only be entered from enabled state\n", in _idle()
1977 oh->name); in _idle()
1978 return -EINVAL; in _idle()
1981 if (oh->class->sysc) in _idle()
1987 * deny idle the clkdm again since idle was already denied in _idle()
1990 if (oh->clkdm && !(oh->flags & HWMOD_CLKDM_NOAUTO)) in _idle()
1991 clkdm_deny_idle(oh->clkdm); in _idle()
1993 if (oh->flags & HWMOD_BLOCK_WFI) in _idle()
1999 * The module must be in idle mode before disabling any parents in _idle()
2005 if (oh->clkdm) { in _idle()
2006 clkdm_allow_idle(oh->clkdm); in _idle()
2007 clkdm_hwmod_disable(oh->clkdm, oh); in _idle()
2010 oh->_state = _HWMOD_STATE_IDLE; in _idle()
2016 * _shutdown - shutdown an omap_hwmod
2021 * used by the system. Returns -EINVAL if the hwmod is in the wrong
2022 * state or returns 0.
2032 if (oh->_state != _HWMOD_STATE_IDLE && in _shutdown()
2033 oh->_state != _HWMOD_STATE_ENABLED) { in _shutdown()
2034 WARN(1, "omap_hwmod: %s: disabled state can only be entered from idle, or enabled state\n", in _shutdown()
2035 oh->name); in _shutdown()
2036 return -EINVAL; in _shutdown()
2039 pr_debug("omap_hwmod: %s: disabling\n", oh->name); in _shutdown()
2041 if (oh->class->pre_shutdown) { in _shutdown()
2042 prev_state = oh->_state; in _shutdown()
2043 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2045 ret = oh->class->pre_shutdown(oh); in _shutdown()
2053 if (oh->class->sysc) { in _shutdown()
2054 if (oh->_state == _HWMOD_STATE_IDLE) in _shutdown()
2059 /* clocks and deps are already disabled in idle */ in _shutdown()
2060 if (oh->_state == _HWMOD_STATE_ENABLED) { in _shutdown()
2063 if (oh->flags & HWMOD_BLOCK_WFI) in _shutdown()
2068 if (oh->clkdm) in _shutdown()
2069 clkdm_hwmod_disable(oh->clkdm, oh); in _shutdown()
2071 /* XXX Should this code also force-disable the optional clocks? */ in _shutdown()
2073 for (i = 0; i < oh->rst_lines_cnt; i++) in _shutdown()
2074 _assert_hardreset(oh, oh->rst_lines[i].name); in _shutdown()
2076 oh->_state = _HWMOD_STATE_DISABLED; in _shutdown()
2089 return -ENODEV; in of_dev_find_hwmod()
2096 if (!strcmp(p, oh->name)) { in of_dev_find_hwmod()
2098 np, i, oh->name); in of_dev_find_hwmod()
2103 return -ENODEV; in of_dev_find_hwmod()
2107 * of_dev_hwmod_lookup - look up needed hwmod from dt blob
2115 * Return: Returns 0 on success, -ENODEV when not found.
2148 return -ENODEV; in of_dev_hwmod_lookup()
2152 * omap_hwmod_fix_mpu_rt_idx - fix up mpu_rt_idx register offsets
2176 error = of_address_to_resource(child, oh->mpu_rt_idx, res); in omap_hwmod_fix_mpu_rt_idx()
2183 * omap_hwmod_parse_module_range - map module IO range from device tree
2199 const char *name; in omap_hwmod_parse_module_range() local
2205 return -EINVAL; in omap_hwmod_parse_module_range()
2209 return -ENOENT; in omap_hwmod_parse_module_range()
2214 return -EINVAL; in omap_hwmod_parse_module_range()
2216 of_property_for_each_string(np, "compatible", prop, name) in omap_hwmod_parse_module_range()
2217 if (!strncmp("ti,sysc-", name, 8)) in omap_hwmod_parse_module_range()
2220 if (!name) in omap_hwmod_parse_module_range()
2221 return -ENOENT; in omap_hwmod_parse_module_range()
2223 error = of_property_read_u32(np, "#address-cells", &nr_addr); in omap_hwmod_parse_module_range()
2225 return -ENOENT; in omap_hwmod_parse_module_range()
2227 error = of_property_read_u32(np, "#size-cells", &nr_size); in omap_hwmod_parse_module_range()
2229 return -ENOENT; in omap_hwmod_parse_module_range()
2232 pr_err("%s: invalid range for %s->%pOFn\n", __func__, in omap_hwmod_parse_module_range()
2233 oh->name, np); in omap_hwmod_parse_module_range()
2234 return -EINVAL; in omap_hwmod_parse_module_range()
2242 oh->name, np, base, size); in omap_hwmod_parse_module_range()
2244 if (oh && oh->mpu_rt_idx) { in omap_hwmod_parse_module_range()
2250 res->start = base; in omap_hwmod_parse_module_range()
2251 res->end = base + size - 1; in omap_hwmod_parse_module_range()
2252 res->flags = IORESOURCE_MEM; in omap_hwmod_parse_module_range()
2258 * _init_mpu_rt_base - populate the virtual address for a hwmod
2269 * and non-availability of MPU access is not treated as an error.
2271 * Returns 0 on success, -EINVAL if an invalid hwmod is passed, and
2272 * -ENXIO on absent or invalid register target address space.
2282 return -EINVAL; in _init_mpu_rt_base()
2287 if (!oh->class->sysc) in _init_mpu_rt_base()
2291 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in _init_mpu_rt_base()
2292 return -ENXIO; in _init_mpu_rt_base()
2295 pr_err("omap_hwmod: %s: no dt node\n", oh->name); in _init_mpu_rt_base()
2296 return -ENXIO; in _init_mpu_rt_base()
2306 va_start = of_iomap(np, index + oh->mpu_rt_idx); in _init_mpu_rt_base()
2309 oh->name, index, np); in _init_mpu_rt_base()
2310 return -ENXIO; in _init_mpu_rt_base()
2314 oh->name, va_start); in _init_mpu_rt_base()
2316 oh->_mpu_rt_va = va_start; in _init_mpu_rt_base()
2323 if (of_find_property(np, "ti,no-reset-on-init", NULL)) in parse_module_flags()
2324 oh->flags |= HWMOD_INIT_NO_RESET; in parse_module_flags()
2325 if (of_find_property(np, "ti,no-idle-on-init", NULL)) in parse_module_flags()
2326 oh->flags |= HWMOD_INIT_NO_IDLE; in parse_module_flags()
2327 if (of_find_property(np, "ti,no-idle", NULL)) in parse_module_flags()
2328 oh->flags |= HWMOD_NO_IDLE; in parse_module_flags()
2332 * _init - initialize internal data for the hwmod @oh
2342 * address space is not defined, or -EINVAL upon failure.
2350 if (oh->_state != _HWMOD_STATE_REGISTERED) in _init()
2355 return -ENODEV; in _init()
2359 pr_debug("omap_hwmod: %s missing dt data\n", oh->name); in _init()
2362 oh->name, np); in _init()
2367 oh->name); in _init()
2373 WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name); in _init()
2374 return -EINVAL; in _init()
2386 oh->_state = _HWMOD_STATE_INITIALIZED; in _init()
2392 * _setup_iclk_autoidle - configure an IP block's interface clocks
2403 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_iclk_autoidle()
2406 list_for_each_entry(os, &oh->slave_ports, node) { in _setup_iclk_autoidle()
2407 if (!os->_clk) in _setup_iclk_autoidle()
2410 if (os->flags & OCPIF_SWSUP_IDLE) { in _setup_iclk_autoidle()
2418 clk_enable(os->_clk); in _setup_iclk_autoidle()
2426 * _setup_reset - reset an IP block during the setup process
2438 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup_reset()
2439 return -EINVAL; in _setup_reset()
2441 if (oh->flags & HWMOD_EXT_OPT_MAIN_CLK) in _setup_reset()
2442 return -EPERM; in _setup_reset()
2444 if (oh->rst_lines_cnt == 0) { in _setup_reset()
2448 oh->name, oh->_state); in _setup_reset()
2449 return -EINVAL; in _setup_reset()
2453 if (!(oh->flags & HWMOD_INIT_NO_RESET)) in _setup_reset()
2460 * _setup_postsetup - transition to the appropriate state after _setup
2463 * Place an IP block represented by @oh into a "post-setup" state --
2464 * either IDLE, ENABLED, or DISABLED. ("post-setup" simply means that
2466 * state for an IP block can be changed by calling
2471 * The IP block stays in this state until a PM runtime-based driver is
2472 * loaded for that IP block. A post-setup state of IDLE is
2473 * appropriate for almost all IP blocks with runtime PM-enabled
2475 * post-setup state of ENABLED is appropriate for kernels with PM
2476 * runtime disabled. The DISABLED state is appropriate for unusual IP
2481 * This post-setup mechanism is deprecated. Once all of the OMAP
2499 if (oh->rst_lines_cnt > 0) in _setup_postsetup()
2502 postsetup_state = oh->_postsetup_state; in _setup_postsetup()
2507 * XXX HWMOD_INIT_NO_IDLE does not belong in hwmod data - in _setup_postsetup()
2510 if ((oh->flags & (HWMOD_INIT_NO_IDLE | HWMOD_NO_IDLE)) && in _setup_postsetup()
2512 oh->_int_flags |= _HWMOD_SKIP_ENABLE; in _setup_postsetup()
2521 WARN(1, "hwmod: %s: unknown postsetup state %d! defaulting to enabled\n", in _setup_postsetup()
2522 oh->name, postsetup_state); in _setup_postsetup()
2528 * _setup - prepare IP block hardware for use
2534 * post-setup state, depending on the type of IP block and applicable
2545 if (oh->_state != _HWMOD_STATE_INITIALIZED) in _setup()
2548 if (oh->parent_hwmod) { in _setup()
2551 r = _enable(oh->parent_hwmod); in _setup()
2553 oh->name, oh->parent_hwmod->name); in _setup()
2561 if (oh->parent_hwmod) { in _setup()
2564 postsetup_state = oh->parent_hwmod->_postsetup_state; in _setup()
2567 _idle(oh->parent_hwmod); in _setup()
2569 _shutdown(oh->parent_hwmod); in _setup()
2571 WARN(1, "hwmod: %s: unknown postsetup state %d! defaulting to enabled\n", in _setup()
2572 oh->parent_hwmod->name, postsetup_state); in _setup()
2579 * _register - register a struct omap_hwmod
2582 * Registers the omap_hwmod @oh. Returns -EEXIST if an omap_hwmod
2583 * already has been registered by the same name; -EINVAL if the
2584 * omap_hwmod is in the wrong state, if @oh is NULL, if the
2586 * name, or if the omap_hwmod's class is missing a name; or 0 upon
2591 * unneeded omap_hwmods to be freed on multi-OMAP configurations. Note
2597 if (!oh || !oh->name || !oh->class || !oh->class->name || in _register()
2598 (oh->_state != _HWMOD_STATE_UNKNOWN)) in _register()
2599 return -EINVAL; in _register()
2601 pr_debug("omap_hwmod: %s: registering\n", oh->name); in _register()
2603 if (_lookup(oh->name)) in _register()
2604 return -EEXIST; in _register()
2606 list_add_tail(&oh->node, &omap_hwmod_list); in _register()
2608 INIT_LIST_HEAD(&oh->slave_ports); in _register()
2609 spin_lock_init(&oh->_lock); in _register()
2610 lockdep_set_class(&oh->_lock, &oh->hwmod_key); in _register()
2612 oh->_state = _HWMOD_STATE_REGISTERED; in _register()
2618 if (!strcmp(oh->name, MPU_INITIATOR_NAME)) in _register()
2625 * _add_link - add an interconnect between two IP blocks
2629 * specified in @oi->slave to @oi. This code is assumed to run before
2636 pr_debug("omap_hwmod: %s -> %s: adding link\n", oi->master->name, in _add_link()
2637 oi->slave->name); in _add_link()
2639 list_add(&oi->node, &oi->slave->slave_ports); in _add_link()
2640 oi->slave->slaves_cnt++; in _add_link()
2646 * _register_link - register a struct omap_hwmod_ocp_if
2649 * Registers the omap_hwmod_ocp_if record @oi. Returns -EEXIST if it
2650 * has already been registered; -EINVAL if @oi is NULL or if the
2656 * unneeded omap_hwmods to be freed on multi-OMAP configurations.
2660 if (!oi || !oi->master || !oi->slave || !oi->user) in _register_link()
2661 return -EINVAL; in _register_link()
2663 if (oi->_int_flags & _OCPIF_INT_FLAGS_REGISTERED) in _register_link()
2664 return -EEXIST; in _register_link()
2667 oi->master->name, oi->slave->name); in _register_link()
2673 if (oi->master->_state != _HWMOD_STATE_REGISTERED) in _register_link()
2674 _register(oi->master); in _register_link()
2676 if (oi->slave->_state != _HWMOD_STATE_REGISTERED) in _register_link()
2677 _register(oi->slave); in _register_link()
2681 oi->_int_flags |= _OCPIF_INT_FLAGS_REGISTERED; in _register_link()
2689 * _omap2xxx_3xxx_wait_target_ready - wait for a module to leave slave idle
2692 * Wait for a module @oh to leave slave idle. Returns 0 if the module
2694 * slave idle; otherwise, pass along the return value of the
2700 return -EINVAL; in _omap2xxx_3xxx_wait_target_ready()
2702 if (oh->flags & HWMOD_NO_IDLEST) in _omap2xxx_3xxx_wait_target_ready()
2710 return omap_cm_wait_module_ready(0, oh->prcm.omap2.module_offs, in _omap2xxx_3xxx_wait_target_ready()
2711 oh->prcm.omap2.idlest_reg_id, in _omap2xxx_3xxx_wait_target_ready()
2712 oh->prcm.omap2.idlest_idle_bit); in _omap2xxx_3xxx_wait_target_ready()
2716 * _omap4_wait_target_ready - wait for a module to leave slave idle
2719 * Wait for a module @oh to leave slave idle. Returns 0 if the module
2721 * slave idle; otherwise, pass along the return value of the
2727 return -EINVAL; in _omap4_wait_target_ready()
2729 if (oh->flags & HWMOD_NO_IDLEST || !oh->clkdm) in _omap4_wait_target_ready()
2743 return omap_cm_wait_module_ready(oh->clkdm->prcm_partition, in _omap4_wait_target_ready()
2744 oh->clkdm->cm_inst, in _omap4_wait_target_ready()
2745 oh->prcm.omap4.clkctrl_offs, 0); in _omap4_wait_target_ready()
2749 * _omap2_assert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
2762 return omap_prm_assert_hardreset(ohri->rst_shift, 0, in _omap2_assert_hardreset()
2763 oh->prcm.omap2.module_offs, 0); in _omap2_assert_hardreset()
2767 * _omap2_deassert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
2780 return omap_prm_deassert_hardreset(ohri->rst_shift, ohri->st_shift, 0, in _omap2_deassert_hardreset()
2781 oh->prcm.omap2.module_offs, 0, 0); in _omap2_deassert_hardreset()
2785 * _omap2_is_hardreset_asserted - call OMAP2 PRM hardreset fn with hwmod args
2799 return omap_prm_is_hardreset_asserted(ohri->st_shift, 0, in _omap2_is_hardreset_asserted()
2800 oh->prcm.omap2.module_offs, 0); in _omap2_is_hardreset_asserted()
2804 * _omap4_assert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
2818 if (!oh->clkdm) in _omap4_assert_hardreset()
2819 return -EINVAL; in _omap4_assert_hardreset()
2821 return omap_prm_assert_hardreset(ohri->rst_shift, in _omap4_assert_hardreset()
2822 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_assert_hardreset()
2823 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_assert_hardreset()
2824 oh->prcm.omap4.rstctrl_offs); in _omap4_assert_hardreset()
2828 * _omap4_deassert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
2842 if (!oh->clkdm) in _omap4_deassert_hardreset()
2843 return -EINVAL; in _omap4_deassert_hardreset()
2845 if (ohri->st_shift) in _omap4_deassert_hardreset()
2847 oh->name, ohri->name); in _omap4_deassert_hardreset()
2848 return omap_prm_deassert_hardreset(ohri->rst_shift, ohri->rst_shift, in _omap4_deassert_hardreset()
2849 oh->clkdm->pwrdm.ptr->prcm_partition, in _omap4_deassert_hardreset()
2850 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_deassert_hardreset()
2851 oh->prcm.omap4.rstctrl_offs, in _omap4_deassert_hardreset()
2852 oh->prcm.omap4.rstctrl_offs + in _omap4_deassert_hardreset()
2857 * _omap4_is_hardreset_asserted - call OMAP4 PRM hardreset fn with hwmod args
2871 if (!oh->clkdm) in _omap4_is_hardreset_asserted()
2872 return -EINVAL; in _omap4_is_hardreset_asserted()
2874 return omap_prm_is_hardreset_asserted(ohri->rst_shift, in _omap4_is_hardreset_asserted()
2875 oh->clkdm->pwrdm.ptr-> in _omap4_is_hardreset_asserted()
2877 oh->clkdm->pwrdm.ptr->prcm_offs, in _omap4_is_hardreset_asserted()
2878 oh->prcm.omap4.rstctrl_offs); in _omap4_is_hardreset_asserted()
2882 * _omap4_disable_direct_prcm - disable direct PRCM control for hwmod
2892 return -EINVAL; in _omap4_disable_direct_prcm()
2894 oh->prcm.omap4.flags |= HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK; in _omap4_disable_direct_prcm()
2900 * _am33xx_deassert_hardreset - call AM33XX PRM hardreset fn with hwmod args
2914 return omap_prm_deassert_hardreset(ohri->rst_shift, ohri->st_shift, in _am33xx_deassert_hardreset()
2915 oh->clkdm->pwrdm.ptr->prcm_partition, in _am33xx_deassert_hardreset()
2916 oh->clkdm->pwrdm.ptr->prcm_offs, in _am33xx_deassert_hardreset()
2917 oh->prcm.omap4.rstctrl_offs, in _am33xx_deassert_hardreset()
2918 oh->prcm.omap4.rstst_offs); in _am33xx_deassert_hardreset()
2925 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_read()
2926 return readw_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
2928 return readl_relaxed(oh->_mpu_rt_va + reg_offs); in omap_hwmod_read()
2933 if (oh->flags & HWMOD_16BIT_REG) in omap_hwmod_write()
2934 writew_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
2936 writel_relaxed(v, oh->_mpu_rt_va + reg_offs); in omap_hwmod_write()
2940 * omap_hwmod_softreset - reset a module via SYSCONFIG.SOFTRESET bit
2953 if (!oh || !(oh->_sysc_cache)) in omap_hwmod_softreset()
2954 return -EINVAL; in omap_hwmod_softreset()
2956 v = oh->_sysc_cache; in omap_hwmod_softreset()
2972 * omap_hwmod_lookup - look up a registered omap_hwmod by name
2973 * @name: name of the omap_hwmod to look up
2975 * Given a @name of an omap_hwmod, return a pointer to the registered
2978 struct omap_hwmod *omap_hwmod_lookup(const char *name) in omap_hwmod_lookup() argument
2982 if (!name) in omap_hwmod_lookup()
2985 oh = _lookup(name); in omap_hwmod_lookup()
2991 * omap_hwmod_for_each - call function for each registered omap_hwmod
2997 * failure. If @fn returns non-zero, the iteration across omap_hwmods
2998 * will stop and the non-zero return value will be passed to the
3009 return -EINVAL; in omap_hwmod_for_each()
3021 * omap_hwmod_register_links - register an array of hwmod links
3026 * listed in @ois that are valid for this chip. Returns -EINVAL if
3028 * -ENOMEM if the link memory area can't be allocated, or 0 upon
3036 return -EINVAL; in omap_hwmod_register_links()
3047 WARN(r && r != -EEXIST, in omap_hwmod_register_links()
3048 "omap_hwmod: _register_link(%s -> %s) returned %d\n", in omap_hwmod_register_links()
3049 ois[i]->master->name, ois[i]->slave->name, r); in omap_hwmod_register_links()
3056 * _ensure_mpu_hwmod_is_setup - ensure the MPU SS hwmod is init'ed and set up
3067 if (!mpu_oh || mpu_oh->_state == _HWMOD_STATE_UNKNOWN) in _ensure_mpu_hwmod_is_setup()
3070 else if (mpu_oh->_state == _HWMOD_STATE_REGISTERED && oh != mpu_oh) in _ensure_mpu_hwmod_is_setup()
3075 * omap_hwmod_setup_one - set up a single hwmod
3076 * @oh_name: const char * name of the already-registered hwmod to set up
3083 * -EINVAL upon error or 0 upon success.
3094 return -EINVAL; in omap_hwmod_setup_one()
3106 const char *name, s8 v1, u8 v2) in omap_hwmod_check_one() argument
3112 dev_warn(dev, "%s %d != %d\n", name, v1, v2); in omap_hwmod_check_one()
3116 * omap_hwmod_check_sysc - check sysc against platform sysc
3125 const struct sysc_regbits *regbits = data->cap->regbits; in omap_hwmod_check_sysc()
3128 regbits->dmadisable_shift, in omap_hwmod_check_sysc()
3129 sysc_fields->dmadisable_shift); in omap_hwmod_check_sysc()
3131 regbits->midle_shift, in omap_hwmod_check_sysc()
3132 sysc_fields->midle_shift); in omap_hwmod_check_sysc()
3134 regbits->sidle_shift, in omap_hwmod_check_sysc()
3135 sysc_fields->sidle_shift); in omap_hwmod_check_sysc()
3137 regbits->clkact_shift, in omap_hwmod_check_sysc()
3138 sysc_fields->clkact_shift); in omap_hwmod_check_sysc()
3140 regbits->enwkup_shift, in omap_hwmod_check_sysc()
3141 sysc_fields->enwkup_shift); in omap_hwmod_check_sysc()
3143 regbits->srst_shift, in omap_hwmod_check_sysc()
3144 sysc_fields->srst_shift); in omap_hwmod_check_sysc()
3146 regbits->autoidle_shift, in omap_hwmod_check_sysc()
3147 sysc_fields->autoidle_shift); in omap_hwmod_check_sysc()
3153 * omap_hwmod_init_regbits - init sysconfig specific register bits
3163 switch (data->cap->type) { in omap_hwmod_init_regbits()
3198 if (!oh->class->sysc->sysc_fields) in omap_hwmod_init_regbits()
3203 return -EINVAL; in omap_hwmod_init_regbits()
3210 * omap_hwmod_init_reg_offs - initialize sysconfig register offsets
3222 *rev_offs = -ENODEV; in omap_hwmod_init_reg_offs()
3226 if (data->offsets[SYSC_REVISION] >= 0) in omap_hwmod_init_reg_offs()
3227 *rev_offs = data->offsets[SYSC_REVISION]; in omap_hwmod_init_reg_offs()
3229 if (data->offsets[SYSC_SYSCONFIG] >= 0) in omap_hwmod_init_reg_offs()
3230 *sysc_offs = data->offsets[SYSC_SYSCONFIG]; in omap_hwmod_init_reg_offs()
3232 if (data->offsets[SYSC_SYSSTATUS] >= 0) in omap_hwmod_init_reg_offs()
3233 *syss_offs = data->offsets[SYSC_SYSSTATUS]; in omap_hwmod_init_reg_offs()
3239 * omap_hwmod_init_sysc_flags - initialize sysconfig features
3250 switch (data->cap->type) { in omap_hwmod_init_sysc_flags()
3253 /* See SYSC_OMAP2_* in include/dt-bindings/bus/ti-sysc.h */ in omap_hwmod_init_sysc_flags()
3254 if (data->cfg->sysc_val & SYSC_OMAP2_CLOCKACTIVITY) in omap_hwmod_init_sysc_flags()
3256 if (data->cfg->sysc_val & SYSC_OMAP2_EMUFREE) in omap_hwmod_init_sysc_flags()
3258 if (data->cfg->sysc_val & SYSC_OMAP2_ENAWAKEUP) in omap_hwmod_init_sysc_flags()
3260 if (data->cfg->sysc_val & SYSC_OMAP2_SOFTRESET) in omap_hwmod_init_sysc_flags()
3262 if (data->cfg->sysc_val & SYSC_OMAP2_AUTOIDLE) in omap_hwmod_init_sysc_flags()
3267 /* See SYSC_OMAP4_* in include/dt-bindings/bus/ti-sysc.h */ in omap_hwmod_init_sysc_flags()
3268 if (data->cfg->sysc_val & SYSC_OMAP4_DMADISABLE) in omap_hwmod_init_sysc_flags()
3270 if (data->cfg->sysc_val & SYSC_OMAP4_FREEEMU) in omap_hwmod_init_sysc_flags()
3272 if (data->cfg->sysc_val & SYSC_OMAP4_SOFTRESET) in omap_hwmod_init_sysc_flags()
3277 /* See SYSC_OMAP3_SR_* in include/dt-bindings/bus/ti-sysc.h */ in omap_hwmod_init_sysc_flags()
3278 if (data->cfg->sysc_val & SYSC_OMAP3_SR_ENAWAKEUP) in omap_hwmod_init_sysc_flags()
3282 if (data->cap->regbits->emufree_shift >= 0) in omap_hwmod_init_sysc_flags()
3284 if (data->cap->regbits->enwkup_shift >= 0) in omap_hwmod_init_sysc_flags()
3286 if (data->cap->regbits->srst_shift >= 0) in omap_hwmod_init_sysc_flags()
3288 if (data->cap->regbits->autoidle_shift >= 0) in omap_hwmod_init_sysc_flags()
3293 if (data->cap->regbits->midle_shift >= 0 && in omap_hwmod_init_sysc_flags()
3294 data->cfg->midlemodes) in omap_hwmod_init_sysc_flags()
3297 if (data->cap->regbits->sidle_shift >= 0 && in omap_hwmod_init_sysc_flags()
3298 data->cfg->sidlemodes) in omap_hwmod_init_sysc_flags()
3301 if (data->cfg->quirks & SYSC_QUIRK_UNCACHED) in omap_hwmod_init_sysc_flags()
3303 if (data->cfg->quirks & SYSC_QUIRK_RESET_STATUS) in omap_hwmod_init_sysc_flags()
3306 if (data->cfg->syss_mask & 1) in omap_hwmod_init_sysc_flags()
3313 * omap_hwmod_init_idlemodes - initialize module idle modes
3316 * @idlemodes: module supported idle modes
3324 if (data->cfg->midlemodes & BIT(SYSC_IDLE_FORCE)) in omap_hwmod_init_idlemodes()
3326 if (data->cfg->midlemodes & BIT(SYSC_IDLE_NO)) in omap_hwmod_init_idlemodes()
3328 if (data->cfg->midlemodes & BIT(SYSC_IDLE_SMART)) in omap_hwmod_init_idlemodes()
3330 if (data->cfg->midlemodes & BIT(SYSC_IDLE_SMART_WKUP)) in omap_hwmod_init_idlemodes()
3333 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_FORCE)) in omap_hwmod_init_idlemodes()
3335 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_NO)) in omap_hwmod_init_idlemodes()
3337 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_SMART)) in omap_hwmod_init_idlemodes()
3339 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_SMART_WKUP)) in omap_hwmod_init_idlemodes()
3346 * omap_hwmod_check_module - check new module against platform data
3365 if (!oh->class->sysc) in omap_hwmod_check_module()
3366 return -ENODEV; in omap_hwmod_check_module()
3368 if (oh->class->sysc->sysc_fields && in omap_hwmod_check_module()
3369 sysc_fields != oh->class->sysc->sysc_fields) in omap_hwmod_check_module()
3372 if (rev_offs != oh->class->sysc->rev_offs) in omap_hwmod_check_module()
3374 oh->class->sysc->rev_offs); in omap_hwmod_check_module()
3375 if (sysc_offs != oh->class->sysc->sysc_offs) in omap_hwmod_check_module()
3377 oh->class->sysc->sysc_offs); in omap_hwmod_check_module()
3378 if (syss_offs != oh->class->sysc->syss_offs) in omap_hwmod_check_module()
3380 oh->class->sysc->syss_offs); in omap_hwmod_check_module()
3382 if (sysc_flags != oh->class->sysc->sysc_flags) in omap_hwmod_check_module()
3384 oh->class->sysc->sysc_flags); in omap_hwmod_check_module()
3386 if (idlemodes != oh->class->sysc->idlemodes) in omap_hwmod_check_module()
3388 oh->class->sysc->idlemodes); in omap_hwmod_check_module()
3390 if (data->cfg->srst_udelay != oh->class->sysc->srst_udelay) in omap_hwmod_check_module()
3392 data->cfg->srst_udelay, in omap_hwmod_check_module()
3393 oh->class->sysc->srst_udelay); in omap_hwmod_check_module()
3399 * omap_hwmod_allocate_module - allocate new module
3410 * Note that the allocations here cannot use devm as ti-sysc can rebind.
3428 return -ENOMEM; in omap_hwmod_allocate_module()
3430 sysc->sysc_fields = sysc_fields; in omap_hwmod_allocate_module()
3431 sysc->rev_offs = rev_offs; in omap_hwmod_allocate_module()
3432 sysc->sysc_offs = sysc_offs; in omap_hwmod_allocate_module()
3433 sysc->syss_offs = syss_offs; in omap_hwmod_allocate_module()
3434 sysc->sysc_flags = sysc_flags; in omap_hwmod_allocate_module()
3435 sysc->idlemodes = idlemodes; in omap_hwmod_allocate_module()
3436 sysc->srst_udelay = data->cfg->srst_udelay; in omap_hwmod_allocate_module()
3438 if (!oh->_mpu_rt_va) { in omap_hwmod_allocate_module()
3439 regs = ioremap(data->module_pa, in omap_hwmod_allocate_module()
3440 data->module_size); in omap_hwmod_allocate_module()
3446 * We may need a new oh->class as the other devices in the same class in omap_hwmod_allocate_module()
3449 if (oh->class->name && strcmp(oh->class->name, data->name)) { in omap_hwmod_allocate_module()
3450 class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL); in omap_hwmod_allocate_module()
3455 if (list_empty(&oh->slave_ports)) { in omap_hwmod_allocate_module()
3465 oi->slave = oh; in omap_hwmod_allocate_module()
3466 oi->user = OCP_USER_MPU | OCP_USER_SDMA; in omap_hwmod_allocate_module()
3469 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_allocate_module()
3471 oh->_mpu_rt_va = regs; in omap_hwmod_allocate_module()
3473 oh->class = class; in omap_hwmod_allocate_module()
3474 oh->class->sysc = sysc; in omap_hwmod_allocate_module()
3478 oh->clkdm = clkdm; in omap_hwmod_allocate_module()
3479 oh->_state = _HWMOD_STATE_INITIALIZED; in omap_hwmod_allocate_module()
3480 oh->_postsetup_state = _HWMOD_STATE_DEFAULT; in omap_hwmod_allocate_module()
3482 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_allocate_module()
3492 return -ENOMEM; in omap_hwmod_allocate_module()
3517 if (!strncmp(data->name, quirk->match, quirk->len)) { in omap_hwmod_init_reset_quirk()
3518 oh->class->reset = quirk->reset; in omap_hwmod_init_reset_quirk()
3539 * omap_hwmod_init_module - initialize new module
3554 if (!dev || !data || !data->name || !cookie) in omap_hwmod_init_module()
3555 return -EINVAL; in omap_hwmod_init_module()
3557 oh = _lookup(data->name); in omap_hwmod_init_module()
3561 return -ENOMEM; in omap_hwmod_init_module()
3563 oh->name = data->name; in omap_hwmod_init_module()
3564 oh->_state = _HWMOD_STATE_UNKNOWN; in omap_hwmod_init_module()
3565 lockdep_register_key(&oh->hwmod_key); in omap_hwmod_init_module()
3568 oh->prcm.omap4.flags = HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT; in omap_hwmod_init_module()
3570 oh->class = kzalloc(sizeof(*oh->class), GFP_KERNEL); in omap_hwmod_init_module()
3571 if (!oh->class) { in omap_hwmod_init_module()
3573 return -ENOMEM; in omap_hwmod_init_module()
3578 oh->class->name = data->name; in omap_hwmod_init_module()
3584 cookie->data = oh; in omap_hwmod_init_module()
3603 if (data->cfg->quirks & SYSC_QUIRK_NO_IDLE) in omap_hwmod_init_module()
3604 oh->flags |= HWMOD_NO_IDLE; in omap_hwmod_init_module()
3605 if (data->cfg->quirks & SYSC_QUIRK_NO_IDLE_ON_INIT) in omap_hwmod_init_module()
3606 oh->flags |= HWMOD_INIT_NO_IDLE; in omap_hwmod_init_module()
3607 if (data->cfg->quirks & SYSC_QUIRK_NO_RESET_ON_INIT) in omap_hwmod_init_module()
3608 oh->flags |= HWMOD_INIT_NO_RESET; in omap_hwmod_init_module()
3609 if (data->cfg->quirks & SYSC_QUIRK_USE_CLOCKACT) in omap_hwmod_init_module()
3610 oh->flags |= HWMOD_SET_DEFAULT_CLOCKACT; in omap_hwmod_init_module()
3611 if (data->cfg->quirks & SYSC_QUIRK_SWSUP_SIDLE) in omap_hwmod_init_module()
3612 oh->flags |= HWMOD_SWSUP_SIDLE; in omap_hwmod_init_module()
3613 if (data->cfg->quirks & SYSC_QUIRK_SWSUP_SIDLE_ACT) in omap_hwmod_init_module()
3614 oh->flags |= HWMOD_SWSUP_SIDLE_ACT; in omap_hwmod_init_module()
3615 if (data->cfg->quirks & SYSC_QUIRK_SWSUP_MSTANDBY) in omap_hwmod_init_module()
3616 oh->flags |= HWMOD_SWSUP_MSTANDBY; in omap_hwmod_init_module()
3617 if (data->cfg->quirks & SYSC_QUIRK_CLKDM_NOAUTO) in omap_hwmod_init_module()
3618 oh->flags |= HWMOD_CLKDM_NOAUTO; in omap_hwmod_init_module()
3627 cookie->clkdm, rev_offs, in omap_hwmod_init_module()
3633 * omap_hwmod_setup_earlycon_flags - set up flags for early console
3636 * early concole so that hwmod core doesn't reset and keep it in idle
3648 uart = of_get_property(np, "stdout-path", NULL); in omap_hwmod_setup_earlycon_flags()
3655 uart = of_get_property(np->parent, in omap_hwmod_setup_earlycon_flags()
3661 oh->flags |= DEBUG_OMAPUART_FLAGS; in omap_hwmod_setup_earlycon_flags()
3669 * omap_hwmod_setup_all - set up all registered IP blocks
3694 * omap_hwmod_enable - enable an omap_hwmod
3698 * Returns -EINVAL on error or passes along the return value from _enable().
3706 return -EINVAL; in omap_hwmod_enable()
3708 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_enable()
3710 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_enable()
3716 * omap_hwmod_idle - idle an omap_hwmod
3719 * Idle an omap_hwmod @oh. Intended to be called by omap_device_idle().
3720 * Returns -EINVAL on error or passes along the return value from _idle().
3728 return -EINVAL; in omap_hwmod_idle()
3730 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_idle()
3732 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_idle()
3738 * omap_hwmod_shutdown - shutdown an omap_hwmod
3742 * omap_device_shutdown(). Returns -EINVAL on error or passes along
3751 return -EINVAL; in omap_hwmod_shutdown()
3753 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_shutdown()
3755 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_shutdown()
3765 * omap_hwmod_get_pwrdm - return pointer to this module's main powerdomain
3786 if (oh->clkdm) in omap_hwmod_get_pwrdm()
3787 return oh->clkdm->pwrdm.ptr; in omap_hwmod_get_pwrdm()
3789 if (oh->_clk) { in omap_hwmod_get_pwrdm()
3790 c = oh->_clk; in omap_hwmod_get_pwrdm()
3795 c = oi->_clk; in omap_hwmod_get_pwrdm()
3806 clkdm = clk->clkdm; in omap_hwmod_get_pwrdm()
3810 return clkdm->pwrdm.ptr; in omap_hwmod_get_pwrdm()
3814 * omap_hwmod_get_mpu_rt_va - return the module's base address (for the MPU)
3827 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) in omap_hwmod_get_mpu_rt_va()
3830 if (oh->_state == _HWMOD_STATE_UNKNOWN) in omap_hwmod_get_mpu_rt_va()
3833 return oh->_mpu_rt_va; in omap_hwmod_get_mpu_rt_va()
3842 * omap_hwmod_assert_hardreset - assert the HW reset line of submodules
3845 * @name: name of the reset line to lookup and assert
3849 * the IP. Returns -EINVAL if @oh is null or if the operation is not
3853 int omap_hwmod_assert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_assert_hardreset() argument
3859 return -EINVAL; in omap_hwmod_assert_hardreset()
3861 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3862 ret = _assert_hardreset(oh, name); in omap_hwmod_assert_hardreset()
3863 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_assert_hardreset()
3869 * omap_hwmod_deassert_hardreset - deassert the HW reset line of submodules
3872 * @name: name of the reset line to look up and deassert
3876 * the IP. Returns -EINVAL if @oh is null or if the operation is not
3880 int omap_hwmod_deassert_hardreset(struct omap_hwmod *oh, const char *name) in omap_hwmod_deassert_hardreset() argument
3886 return -EINVAL; in omap_hwmod_deassert_hardreset()
3888 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3889 ret = _deassert_hardreset(oh, name); in omap_hwmod_deassert_hardreset()
3890 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_deassert_hardreset()
3896 * omap_hwmod_for_each_by_class - call @fn for each hwmod of class @classname
3897 * @classname: struct omap_hwmod_class name to search for
3904 * value is passed back to the caller. Returns 0 upon success, -EINVAL
3916 return -EINVAL; in omap_hwmod_for_each_by_class()
3922 if (!strcmp(temp_oh->class->name, classname)) { in omap_hwmod_for_each_by_class()
3924 __func__, temp_oh->name); in omap_hwmod_for_each_by_class()
3939 * omap_hwmod_set_postsetup_state - set the post-_setup() state for this hwmod
3941 * @state: state that _setup() should leave the hwmod in
3943 * Sets the hwmod state that @oh will enter at the end of _setup()
3946 * -EINVAL if there is a problem with the arguments or if the hwmod is
3947 * in the wrong state.
3949 int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state) in omap_hwmod_set_postsetup_state() argument
3955 return -EINVAL; in omap_hwmod_set_postsetup_state()
3957 if (state != _HWMOD_STATE_DISABLED && in omap_hwmod_set_postsetup_state()
3958 state != _HWMOD_STATE_ENABLED && in omap_hwmod_set_postsetup_state()
3959 state != _HWMOD_STATE_IDLE) in omap_hwmod_set_postsetup_state()
3960 return -EINVAL; in omap_hwmod_set_postsetup_state()
3962 spin_lock_irqsave(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3964 if (oh->_state != _HWMOD_STATE_REGISTERED) { in omap_hwmod_set_postsetup_state()
3965 ret = -EINVAL; in omap_hwmod_set_postsetup_state()
3969 oh->_postsetup_state = state; in omap_hwmod_set_postsetup_state()
3973 spin_unlock_irqrestore(&oh->_lock, flags); in omap_hwmod_set_postsetup_state()
3979 * omap_hwmod_get_context_loss_count - get lost context count
3985 * On OMAP4, this queries the per-hwmod context loss register,
4005 * omap_hwmod_init - initialize the hwmod code
4008 * currently-booted SoC. Intended to be called once during kernel init
4057 * omap_hwmod_get_main_clk - get pointer to main clock name
4060 * Returns the main clock name assocated with @oh upon success,
4068 return oh->main_clk; in omap_hwmod_get_main_clk()