Lines Matching +full:bank +full:- +full:number
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2007-2008, 2011 Texas Instruments, Inc.
6 * Copyright (C) 2007-2011 Nokia Corporation
72 if (!strcmp(name, temp_pwrdm->name)) { in _pwrdm_lookup()
82 * _pwrdm_register - register a powerdomain
86 * -EINVAL if given a null pointer, -EEXIST if a powerdomain is
94 if (!pwrdm || !pwrdm->name) in _pwrdm_register()
95 return -EINVAL; in _pwrdm_register()
98 pwrdm->prcm_partition == OMAP4430_INVALID_PRCM_PARTITION) { in _pwrdm_register()
100 pwrdm->name); in _pwrdm_register()
101 return -EINVAL; in _pwrdm_register()
104 if (_pwrdm_lookup(pwrdm->name)) in _pwrdm_register()
105 return -EEXIST; in _pwrdm_register()
107 if (arch_pwrdm && arch_pwrdm->pwrdm_has_voltdm) in _pwrdm_register()
108 if (!arch_pwrdm->pwrdm_has_voltdm()) in _pwrdm_register()
111 voltdm = voltdm_lookup(pwrdm->voltdm.name); in _pwrdm_register()
114 pwrdm->name, pwrdm->voltdm.name); in _pwrdm_register()
115 return -EINVAL; in _pwrdm_register()
117 pwrdm->voltdm.ptr = voltdm; in _pwrdm_register()
118 INIT_LIST_HEAD(&pwrdm->voltdm_node); in _pwrdm_register()
120 spin_lock_init(&pwrdm->_lock); in _pwrdm_register()
122 list_add(&pwrdm->node, &pwrdm_list); in _pwrdm_register()
126 pwrdm->state_counter[i] = 0; in _pwrdm_register()
128 pwrdm->ret_logic_off_counter = 0; in _pwrdm_register()
129 for (i = 0; i < pwrdm->banks; i++) in _pwrdm_register()
130 pwrdm->ret_mem_off_counter[i] = 0; in _pwrdm_register()
132 if (arch_pwrdm && arch_pwrdm->pwrdm_wait_transition) in _pwrdm_register()
133 arch_pwrdm->pwrdm_wait_transition(pwrdm); in _pwrdm_register()
134 pwrdm->state = pwrdm_read_pwrst(pwrdm); in _pwrdm_register()
135 pwrdm->state_counter[pwrdm->state] = 1; in _pwrdm_register()
137 pr_debug("powerdomain: registered %s\n", pwrdm->name); in _pwrdm_register()
148 if ((pwrdm->pwrsts_logic_ret == PWRSTS_OFF_RET) && in _update_logic_membank_counters()
150 pwrdm->ret_logic_off_counter++; in _update_logic_membank_counters()
152 for (i = 0; i < pwrdm->banks; i++) { in _update_logic_membank_counters()
155 if ((pwrdm->pwrsts_mem_ret[i] == PWRSTS_OFF_RET) && in _update_logic_membank_counters()
157 pwrdm->ret_mem_off_counter[i]++; in _update_logic_membank_counters()
167 return -EINVAL; in _pwrdm_state_switch()
173 prev = pwrdm->state; in _pwrdm_state_switch()
177 if (prev >= 0 && pwrdm->state != prev) in _pwrdm_state_switch()
178 pwrdm->state_counter[prev]++; in _pwrdm_state_switch()
190 trace_power_domain_target(pwrdm->name, in _pwrdm_state_switch()
196 return -EINVAL; in _pwrdm_state_switch()
200 pwrdm->state_counter[state]++; in _pwrdm_state_switch()
204 pwrdm->state = state; in _pwrdm_state_switch()
223 * _pwrdm_save_clkdm_state_and_activate - prepare for power state change
232 * supports software-supervised wakeup mode - potentially a problem.
243 pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE && in _pwrdm_save_clkdm_state_and_activate()
244 arch_pwrdm->pwrdm_set_lowpwrstchange) { in _pwrdm_save_clkdm_state_and_activate()
247 clkdm_deny_idle_nolock(pwrdm->pwrdm_clkdms[0]); in _pwrdm_save_clkdm_state_and_activate()
258 * _pwrdm_restore_clkdm_state - restore the clkdm hwsup state after pwrst change
267 * hardware-supervised idle control in the register, or
268 * software-supervised sleep. No return value.
275 clkdm_allow_idle_nolock(pwrdm->pwrdm_clkdms[0]); in _pwrdm_restore_clkdm_state()
278 if (pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE && in _pwrdm_restore_clkdm_state()
279 arch_pwrdm->pwrdm_set_lowpwrstchange) in _pwrdm_restore_clkdm_state()
280 arch_pwrdm->pwrdm_set_lowpwrstchange(pwrdm); in _pwrdm_restore_clkdm_state()
289 * pwrdm_register_platform_funcs - register powerdomain implementation fns
294 * before any other pwrdm_register*() function. Returns -EINVAL if
295 * @po is null, -EEXIST if platform functions have already been
301 return -EINVAL; in pwrdm_register_platform_funcs()
304 return -EEXIST; in pwrdm_register_platform_funcs()
312 * pwrdm_register_pwrdms - register SoC powerdomains
317 * multiple times. Returns -EACCES if called before
318 * pwrdm_register_platform_funcs(); -EINVAL if the argument @ps is
326 return -EEXIST; in pwrdm_register_pwrdms()
329 return -EINVAL; in pwrdm_register_pwrdms()
354 * pwrdm_complete_init - set up the powerdomain layer
360 * with non-power-management-enabled kernels. Must be called after
361 * pwrdm_register_pwrdms(). Returns -EACCES if called before
370 return -EACCES; in pwrdm_complete_init()
375 /* Only AM43XX can lose pwrdm context during rtc-ddr suspend */ in pwrdm_complete_init()
385 * pwrdm_lock - acquire a Linux spinlock on a powerdomain
391 __acquires(&pwrdm->_lock) in pwrdm_lock()
393 spin_lock_irqsave(&pwrdm->_lock, pwrdm->_lock_flags); in pwrdm_lock()
397 * pwrdm_unlock - release a Linux spinlock on a powerdomain
403 __releases(&pwrdm->_lock) in pwrdm_unlock()
405 spin_unlock_irqrestore(&pwrdm->_lock, pwrdm->_lock_flags); in pwrdm_unlock()
409 * pwrdm_lookup - look up a powerdomain by name, return a pointer
428 * pwrdm_for_each - call function on each registered clockdomain
435 * to indicate failure; or -EINVAL if the function pointer is null.
444 return -EINVAL; in pwrdm_for_each()
456 * pwrdm_add_clkdm - add a clockdomain to a powerdomain
461 * enables the use of pwrdm_for_each_clkdm(). Returns -EINVAL if
462 * presented with invalid pointers; -ENOMEM if memory could not be allocated;
468 int ret = -EINVAL; in pwrdm_add_clkdm()
471 return -EINVAL; in pwrdm_add_clkdm()
474 pwrdm->name, clkdm->name); in pwrdm_add_clkdm()
477 if (!pwrdm->pwrdm_clkdms[i]) in pwrdm_add_clkdm()
480 if (pwrdm->pwrdm_clkdms[i] == clkdm) { in pwrdm_add_clkdm()
481 ret = -EINVAL; in pwrdm_add_clkdm()
489 pwrdm->name, clkdm->name); in pwrdm_add_clkdm()
491 ret = -ENOMEM; in pwrdm_add_clkdm()
495 pwrdm->pwrdm_clkdms[i] = clkdm; in pwrdm_add_clkdm()
504 * pwrdm_get_mem_bank_count - get number of memory banks in this powerdomain
507 * Return the number of controllable memory banks in powerdomain @pwrdm,
508 * starting with 1. Returns -EINVAL if the powerdomain pointer is null.
513 return -EINVAL; in pwrdm_get_mem_bank_count()
515 return pwrdm->banks; in pwrdm_get_mem_bank_count()
519 * pwrdm_set_next_pwrst - set next powerdomain power state
525 * have not been satisfied. Returns -EINVAL if the powerdomain pointer is
531 int ret = -EINVAL; in pwrdm_set_next_pwrst()
534 return -EINVAL; in pwrdm_set_next_pwrst()
536 if (!(pwrdm->pwrsts & (1 << pwrst))) in pwrdm_set_next_pwrst()
537 return -EINVAL; in pwrdm_set_next_pwrst()
540 pwrdm->name, pwrst); in pwrdm_set_next_pwrst()
542 if (arch_pwrdm && arch_pwrdm->pwrdm_set_next_pwrst) { in pwrdm_set_next_pwrst()
544 trace_power_domain_target(pwrdm->name, pwrst, in pwrdm_set_next_pwrst()
547 ret = arch_pwrdm->pwrdm_set_next_pwrst(pwrdm, pwrst); in pwrdm_set_next_pwrst()
554 * pwrdm_read_next_pwrst - get next powerdomain power state
557 * Return the powerdomain @pwrdm's next power state. Returns -EINVAL
563 int ret = -EINVAL; in pwrdm_read_next_pwrst()
566 return -EINVAL; in pwrdm_read_next_pwrst()
568 if (arch_pwrdm && arch_pwrdm->pwrdm_read_next_pwrst) in pwrdm_read_next_pwrst()
569 ret = arch_pwrdm->pwrdm_read_next_pwrst(pwrdm); in pwrdm_read_next_pwrst()
575 * pwrdm_read_pwrst - get current powerdomain power state
578 * Return the powerdomain @pwrdm's current power state. Returns -EINVAL
585 int ret = -EINVAL; in pwrdm_read_pwrst()
588 return -EINVAL; in pwrdm_read_pwrst()
590 if (pwrdm->pwrsts == PWRSTS_ON) in pwrdm_read_pwrst()
593 if (arch_pwrdm && arch_pwrdm->pwrdm_read_pwrst) in pwrdm_read_pwrst()
594 ret = arch_pwrdm->pwrdm_read_pwrst(pwrdm); in pwrdm_read_pwrst()
600 * pwrdm_read_prev_pwrst - get previous powerdomain power state
603 * Return the powerdomain @pwrdm's previous power state. Returns -EINVAL
609 int ret = -EINVAL; in pwrdm_read_prev_pwrst()
612 return -EINVAL; in pwrdm_read_prev_pwrst()
614 if (arch_pwrdm && arch_pwrdm->pwrdm_read_prev_pwrst) in pwrdm_read_prev_pwrst()
615 ret = arch_pwrdm->pwrdm_read_prev_pwrst(pwrdm); in pwrdm_read_prev_pwrst()
621 * pwrdm_set_logic_retst - set powerdomain logic power state upon retention
628 * -EINVAL if the powerdomain pointer is null or the target power
633 int ret = -EINVAL; in pwrdm_set_logic_retst()
636 return -EINVAL; in pwrdm_set_logic_retst()
638 if (!(pwrdm->pwrsts_logic_ret & (1 << pwrst))) in pwrdm_set_logic_retst()
639 return -EINVAL; in pwrdm_set_logic_retst()
642 pwrdm->name, pwrst); in pwrdm_set_logic_retst()
644 if (arch_pwrdm && arch_pwrdm->pwrdm_set_logic_retst) in pwrdm_set_logic_retst()
645 ret = arch_pwrdm->pwrdm_set_logic_retst(pwrdm, pwrst); in pwrdm_set_logic_retst()
651 * pwrdm_set_mem_onst - set memory power state while powerdomain ON
653 * @bank: memory bank number to set (0-3)
656 * Set the next power state @pwrst that memory bank @bank of the
658 * state. @bank will be a number from 0 to 3, and represents different
659 * types of memory, depending on the powerdomain. Returns -EINVAL if
661 * supported for this memory bank, -EEXIST if the target memory
662 * bank does not exist or is not controllable, or returns 0 upon
665 int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst) in pwrdm_set_mem_onst() argument
667 int ret = -EINVAL; in pwrdm_set_mem_onst()
670 return -EINVAL; in pwrdm_set_mem_onst()
672 if (pwrdm->banks < (bank + 1)) in pwrdm_set_mem_onst()
673 return -EEXIST; in pwrdm_set_mem_onst()
675 if (!(pwrdm->pwrsts_mem_on[bank] & (1 << pwrst))) in pwrdm_set_mem_onst()
676 return -EINVAL; in pwrdm_set_mem_onst()
678 pr_debug("powerdomain: %s: setting next memory powerstate for bank %0x while pwrdm-ON to %0x\n", in pwrdm_set_mem_onst()
679 pwrdm->name, bank, pwrst); in pwrdm_set_mem_onst()
681 if (arch_pwrdm && arch_pwrdm->pwrdm_set_mem_onst) in pwrdm_set_mem_onst()
682 ret = arch_pwrdm->pwrdm_set_mem_onst(pwrdm, bank, pwrst); in pwrdm_set_mem_onst()
688 * pwrdm_set_mem_retst - set memory power state while powerdomain in RET
690 * @bank: memory bank number to set (0-3)
693 * Set the next power state @pwrst that memory bank @bank of the
695 * RETENTION state. Bank will be a number from 0 to 3, and represents
697 * will be either RETENTION or OFF, if supported. Returns -EINVAL if
699 * supported for this memory bank, -EEXIST if the target memory
700 * bank does not exist or is not controllable, or returns 0 upon
703 int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst) in pwrdm_set_mem_retst() argument
705 int ret = -EINVAL; in pwrdm_set_mem_retst()
708 return -EINVAL; in pwrdm_set_mem_retst()
710 if (pwrdm->banks < (bank + 1)) in pwrdm_set_mem_retst()
711 return -EEXIST; in pwrdm_set_mem_retst()
713 if (!(pwrdm->pwrsts_mem_ret[bank] & (1 << pwrst))) in pwrdm_set_mem_retst()
714 return -EINVAL; in pwrdm_set_mem_retst()
716 pr_debug("powerdomain: %s: setting next memory powerstate for bank %0x while pwrdm-RET to %0x\n", in pwrdm_set_mem_retst()
717 pwrdm->name, bank, pwrst); in pwrdm_set_mem_retst()
719 if (arch_pwrdm && arch_pwrdm->pwrdm_set_mem_retst) in pwrdm_set_mem_retst()
720 ret = arch_pwrdm->pwrdm_set_mem_retst(pwrdm, bank, pwrst); in pwrdm_set_mem_retst()
726 * pwrdm_read_logic_pwrst - get current powerdomain logic retention power state
730 * will enter when the powerdomain enters retention. Returns -EINVAL
736 int ret = -EINVAL; in pwrdm_read_logic_pwrst()
739 return -EINVAL; in pwrdm_read_logic_pwrst()
741 if (arch_pwrdm && arch_pwrdm->pwrdm_read_logic_pwrst) in pwrdm_read_logic_pwrst()
742 ret = arch_pwrdm->pwrdm_read_logic_pwrst(pwrdm); in pwrdm_read_logic_pwrst()
748 * pwrdm_read_prev_logic_pwrst - get previous powerdomain logic power state
752 * -EINVAL if the powerdomain pointer is null or returns the previous
757 int ret = -EINVAL; in pwrdm_read_prev_logic_pwrst()
760 return -EINVAL; in pwrdm_read_prev_logic_pwrst()
762 if (arch_pwrdm && arch_pwrdm->pwrdm_read_prev_logic_pwrst) in pwrdm_read_prev_logic_pwrst()
763 ret = arch_pwrdm->pwrdm_read_prev_logic_pwrst(pwrdm); in pwrdm_read_prev_logic_pwrst()
769 * pwrdm_read_logic_retst - get next powerdomain logic power state
772 * Return the powerdomain pwrdm's logic power state. Returns -EINVAL
778 int ret = -EINVAL; in pwrdm_read_logic_retst()
781 return -EINVAL; in pwrdm_read_logic_retst()
783 if (arch_pwrdm && arch_pwrdm->pwrdm_read_logic_retst) in pwrdm_read_logic_retst()
784 ret = arch_pwrdm->pwrdm_read_logic_retst(pwrdm); in pwrdm_read_logic_retst()
790 * pwrdm_read_mem_pwrst - get current memory bank power state
791 * @pwrdm: struct powerdomain * to get current memory bank power state
792 * @bank: memory bank number (0-3)
794 * Return the powerdomain @pwrdm's current memory power state for bank
795 * @bank. Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
796 * the target memory bank does not exist or is not controllable, or
799 int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank) in pwrdm_read_mem_pwrst() argument
801 int ret = -EINVAL; in pwrdm_read_mem_pwrst()
806 if (pwrdm->banks < (bank + 1)) in pwrdm_read_mem_pwrst()
809 if (pwrdm->flags & PWRDM_HAS_MPU_QUIRK) in pwrdm_read_mem_pwrst()
810 bank = 1; in pwrdm_read_mem_pwrst()
812 if (arch_pwrdm && arch_pwrdm->pwrdm_read_mem_pwrst) in pwrdm_read_mem_pwrst()
813 ret = arch_pwrdm->pwrdm_read_mem_pwrst(pwrdm, bank); in pwrdm_read_mem_pwrst()
819 * pwrdm_read_prev_mem_pwrst - get previous memory bank power state
820 * @pwrdm: struct powerdomain * to get previous memory bank power state
821 * @bank: memory bank number (0-3)
824 * bank @bank. Returns -EINVAL if the powerdomain pointer is null,
825 * -EEXIST if the target memory bank does not exist or is not
829 int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank) in pwrdm_read_prev_mem_pwrst() argument
831 int ret = -EINVAL; in pwrdm_read_prev_mem_pwrst()
836 if (pwrdm->banks < (bank + 1)) in pwrdm_read_prev_mem_pwrst()
839 if (pwrdm->flags & PWRDM_HAS_MPU_QUIRK) in pwrdm_read_prev_mem_pwrst()
840 bank = 1; in pwrdm_read_prev_mem_pwrst()
842 if (arch_pwrdm && arch_pwrdm->pwrdm_read_prev_mem_pwrst) in pwrdm_read_prev_mem_pwrst()
843 ret = arch_pwrdm->pwrdm_read_prev_mem_pwrst(pwrdm, bank); in pwrdm_read_prev_mem_pwrst()
849 * pwrdm_read_mem_retst - get next memory bank power state
850 * @pwrdm: struct powerdomain * to get mext memory bank power state
851 * @bank: memory bank number (0-3)
853 * Return the powerdomain pwrdm's next memory power state for bank
854 * x. Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
855 * the target memory bank does not exist or is not controllable, or
858 int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank) in pwrdm_read_mem_retst() argument
860 int ret = -EINVAL; in pwrdm_read_mem_retst()
865 if (pwrdm->banks < (bank + 1)) in pwrdm_read_mem_retst()
868 if (arch_pwrdm && arch_pwrdm->pwrdm_read_mem_retst) in pwrdm_read_mem_retst()
869 ret = arch_pwrdm->pwrdm_read_mem_retst(pwrdm, bank); in pwrdm_read_mem_retst()
875 * pwrdm_clear_all_prev_pwrst - clear previous powerstate register for a pwrdm
879 * Clears the entire register, including logic and memory bank
880 * previous power states. Returns -EINVAL if the powerdomain pointer
885 int ret = -EINVAL; in pwrdm_clear_all_prev_pwrst()
896 pwrdm->name); in pwrdm_clear_all_prev_pwrst()
898 if (arch_pwrdm && arch_pwrdm->pwrdm_clear_all_prev_pwrst) in pwrdm_clear_all_prev_pwrst()
899 ret = arch_pwrdm->pwrdm_clear_all_prev_pwrst(pwrdm); in pwrdm_clear_all_prev_pwrst()
905 * pwrdm_enable_hdwr_sar - enable automatic hardware SAR for a pwrdm
908 * Enable automatic context save-and-restore upon power state change
911 * closely. Returns -EINVAL if the powerdomain pointer is null or if
912 * the powerdomain does not support automatic save-and-restore, or
917 int ret = -EINVAL; in pwrdm_enable_hdwr_sar()
922 if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR)) in pwrdm_enable_hdwr_sar()
925 pr_debug("powerdomain: %s: setting SAVEANDRESTORE bit\n", pwrdm->name); in pwrdm_enable_hdwr_sar()
927 if (arch_pwrdm && arch_pwrdm->pwrdm_enable_hdwr_sar) in pwrdm_enable_hdwr_sar()
928 ret = arch_pwrdm->pwrdm_enable_hdwr_sar(pwrdm); in pwrdm_enable_hdwr_sar()
934 * pwrdm_disable_hdwr_sar - disable automatic hardware SAR for a pwrdm
937 * Disable automatic context save-and-restore upon power state change
940 * closely. Returns -EINVAL if the powerdomain pointer is null or if
941 * the powerdomain does not support automatic save-and-restore, or
946 int ret = -EINVAL; in pwrdm_disable_hdwr_sar()
951 if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR)) in pwrdm_disable_hdwr_sar()
954 pr_debug("powerdomain: %s: clearing SAVEANDRESTORE bit\n", pwrdm->name); in pwrdm_disable_hdwr_sar()
956 if (arch_pwrdm && arch_pwrdm->pwrdm_disable_hdwr_sar) in pwrdm_disable_hdwr_sar()
957 ret = arch_pwrdm->pwrdm_disable_hdwr_sar(pwrdm); in pwrdm_disable_hdwr_sar()
963 * pwrdm_has_hdwr_sar - test whether powerdomain supports hardware SAR
966 * Returns 1 if powerdomain @pwrdm supports hardware save-and-restore
971 return (pwrdm && pwrdm->flags & PWRDM_HAS_HDWR_SAR) ? 1 : 0; in pwrdm_has_hdwr_sar()
979 return -EINVAL; in pwrdm_state_switch_nolock()
981 ret = arch_pwrdm->pwrdm_wait_transition(pwrdm); in pwrdm_state_switch_nolock()
1020 * pwrdm_get_valid_lp_state() - Find best match deep power state
1037 * a) find if we have an exact match to the request - no issues.
1045 u8 pwrdm_states = is_logic_state ? pwrdm->pwrsts_logic_ret : in pwrdm_get_valid_lp_state()
1046 pwrdm->pwrsts; in pwrdm_get_valid_lp_state()
1063 new_pwrst = req_state - 1; in pwrdm_get_valid_lp_state()
1071 new_pwrst--; in pwrdm_get_valid_lp_state()
1083 pwrdm->name); in pwrdm_get_valid_lp_state()
1096 * omap_set_pwrdm_state - change a powerdomain's current power state
1102 * Returns -EINVAL if @pwrdm is null or invalid or if the
1105 * lower-power state. XXX Should not return 0 if the @pwrdm does not
1106 * support @pwrst or any lower-power state: this should be an error.
1115 return -EINVAL; in omap_set_pwrdm_state()
1117 while (!(pwrdm->pwrsts & (1 << pwrst))) { in omap_set_pwrdm_state()
1120 pwrst--; in omap_set_pwrdm_state()
1127 ret = -EINVAL; in omap_set_pwrdm_state()
1141 __func__, pwrdm->name); in omap_set_pwrdm_state()
1152 * pwrdm_save_context - save powerdomain registers
1159 if (arch_pwrdm && arch_pwrdm->pwrdm_save_context) in pwrdm_save_context()
1160 arch_pwrdm->pwrdm_save_context(pwrdm); in pwrdm_save_context()
1165 * pwrdm_restore_context - restore powerdomain registers
1172 if (arch_pwrdm && arch_pwrdm->pwrdm_restore_context) in pwrdm_restore_context()
1173 arch_pwrdm->pwrdm_restore_context(pwrdm); in pwrdm_restore_context()