Lines Matching +full:cpu +full:- +full:idle +full:- +full:states
1 // SPDX-License-Identifier: GPL-2.0-only
3 * DT idle states parsing code.
9 #define pr_fmt(fmt) "DT idle-states: " fmt
30 * pointer of the passed in struct of_device_id array to the idle in init_state_node()
33 idle_state->enter = match_id->data; in init_state_node()
39 idle_state->enter_s2idle = match_id->data; in init_state_node()
41 err = of_property_read_u32(state_node, "wakeup-latency-us", in init_state_node()
42 &idle_state->exit_latency); in init_state_node()
46 err = of_property_read_u32(state_node, "entry-latency-us", in init_state_node()
49 pr_debug(" * %pOF missing entry-latency-us property\n", in init_state_node()
51 return -EINVAL; in init_state_node()
54 err = of_property_read_u32(state_node, "exit-latency-us", in init_state_node()
57 pr_debug(" * %pOF missing exit-latency-us property\n", in init_state_node()
59 return -EINVAL; in init_state_node()
62 * If wakeup-latency-us is missing, default to entry+exit in init_state_node()
63 * latencies as defined in idle states bindings in init_state_node()
65 idle_state->exit_latency = entry_latency + exit_latency; in init_state_node()
68 err = of_property_read_u32(state_node, "min-residency-us", in init_state_node()
69 &idle_state->target_residency); in init_state_node()
71 pr_debug(" * %pOF missing min-residency-us property\n", in init_state_node()
73 return -EINVAL; in init_state_node()
76 err = of_property_read_string(state_node, "idle-state-name", &desc); in init_state_node()
78 desc = state_node->name; in init_state_node()
80 idle_state->flags = 0; in init_state_node()
81 if (of_property_read_bool(state_node, "local-timer-stop")) in init_state_node()
82 idle_state->flags |= CPUIDLE_FLAG_TIMER_STOP; in init_state_node()
88 strncpy(idle_state->name, state_node->name, CPUIDLE_NAME_LEN - 1); in init_state_node()
89 strncpy(idle_state->desc, desc, CPUIDLE_DESC_LEN - 1); in init_state_node()
94 * Check that the idle state is uniform across all CPUs in the CPUidle driver
100 int cpu; in idle_state_valid() local
105 * Compare idle state phandles for index idx on all CPUs in the in idle_state_valid()
106 * CPUidle driver cpumask. Start from next logical cpu following in idle_state_valid()
107 * cpumask_first(cpumask) since that's the CPU state_node was in idle_state_valid()
111 for (cpu = cpumask_next(cpumask_first(cpumask), cpumask); in idle_state_valid()
112 cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpumask)) { in idle_state_valid()
113 cpu_node = of_cpu_device_node_get(cpu); in idle_state_valid()
128 * dt_init_idle_driver() - Parse the DT idle states and initialize the
129 * idle driver states array
130 * @drv: Pointer to CPU idle driver to be initialized
132 * compatible idle state nodes. The data pointer for each valid
141 * @start_idx: First idle state index to be initialized
143 * If DT idle states are detected and are valid the state count and states
147 * Return: number of valid DT idle states parsed, <0 on failure
161 return -EINVAL; in dt_init_idle_driver()
163 * We get the idle states for the first logical cpu in the in dt_init_idle_driver()
168 cpumask = drv->cpumask ? : cpu_possible_mask; in dt_init_idle_driver()
178 err = -ENODEV; in dt_init_idle_driver()
188 pr_warn("%pOF idle state not valid, bailing out\n", in dt_init_idle_driver()
190 err = -EINVAL; in dt_init_idle_driver()
195 pr_warn("State index reached static CPU idle driver states array size\n"); in dt_init_idle_driver()
199 idle_state = &drv->states[state_idx++]; in dt_init_idle_driver()
202 pr_err("Parsing idle state node %pOF failed with err %d\n", in dt_init_idle_driver()
204 err = -EINVAL; in dt_init_idle_driver()
215 * Update the driver state count only if some valid DT idle states in dt_init_idle_driver()
219 drv->state_count = state_idx; in dt_init_idle_driver()
222 * Return the number of present and valid DT idle states, which can in dt_init_idle_driver()
223 * also be 0 on platforms with missing DT idle states or legacy DT in dt_init_idle_driver()
224 * configuration predating the DT idle states bindings. in dt_init_idle_driver()