Lines Matching +full:no +full:- +full:idle +full:- +full:on +full:- +full:init
1 // SPDX-License-Identifier: GPL-2.0-only
3 * RISC-V SBI CPU idle driver.
9 #define pr_fmt(fmt) "cpuidle-riscv-sbi: " fmt
52 data->available = true;
53 data->state = state;
60 return data->state;
67 data->available = false;
74 return data->available;
115 u32 *states = data->states;
116 struct device *pd_dev = data->dev;
122 return -1;
137 ret = sbi_suspend(state) ? -1 : idx;
148 /* Clear the domain state to start fresh when back from idle. */
205 { .compatible = "riscv,idle-state",
223 int err = of_property_read_u32(np, "riscv,sbi-suspend-param", state);
226 pr_warn("%pOF missing riscv,sbi-suspend-param property\n", np);
232 return -EINVAL;
246 data->dev = dt_idle_attach_cpu(cpu, "sbi");
247 if (IS_ERR_OR_NULL(data->dev))
248 return PTR_ERR_OR_ZERO(data->dev);
255 drv->states[state_count - 1].flags |= CPUIDLE_FLAG_RCU_IDLE;
256 drv->states[state_count - 1].enter = sbi_enter_domain_idle_state;
257 drv->states[state_count - 1].enter_s2idle =
276 return -ENODEV;
280 return -ENOMEM;
284 state_node = of_get_cpu_state_node(cpu_node, i - 1);
294 pr_debug("sbi-state %#x index %d\n", states[i], i);
297 return -ENODEV;
304 /* Store states in the per-cpu struct. */
305 data->states = states;
314 dt_idle_detach_cpu(data->dev);
326 return -ENOMEM;
328 drv->name = "sbi_cpuidle";
329 drv->owner = THIS_MODULE;
330 drv->cpumask = (struct cpumask *)cpumask_of(cpu);
332 /* RISC-V architectural WFI to be represented as state index 0. */
333 drv->states[0].enter = sbi_cpuidle_enter_state;
334 drv->states[0].exit_latency = 1;
335 drv->states[0].target_residency = 1;
336 drv->states[0].power_usage = UINT_MAX;
337 strcpy(drv->states[0].name, "WFI");
338 strcpy(drv->states[0].desc, "RISC-V WFI");
341 * If no DT idle states are detected (ret == 0) let the driver
342 * initialization fail accordingly since there is no reason to
343 * initialize the idle driver if only wfi is supported, the
344 * default archictectural back-end already executes wfi
345 * on idle entry.
349 pr_debug("HART%ld: failed to parse DT idle states\n",
351 return ret ? : -ENODEV;
355 /* Initialize idle states from DT. */
358 pr_err("HART%ld: failed to init idle states\n",
388 struct genpd_power_state *state = &pd->states[pd->state_idx];
391 if (!state->data)
395 return -EBUSY;
398 pd_state = state->data;
416 int ret = -ENOMEM;
426 pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN;
430 pd->power_off = sbi_cpuidle_pd_power_off;
432 pd->flags |= GENPD_FLAG_ALWAYS_ON;
435 pd_gov = pd->states ? &pm_domain_cpu_gov : NULL;
445 pd_provider->node = of_node_get(np);
446 list_add(&pd_provider->link, &sbi_pd_providers);
448 pr_debug("init PM domain %s\n", pd->name);
458 pr_err("failed to init PM domain ret=%d %pOF\n", ret, np);
468 of_genpd_del_provider(pd_provider->node);
470 genpd = of_genpd_remove_last(pd_provider->node);
474 of_node_put(pd_provider->node);
475 list_del(&pd_provider->link);
486 return -ENODEV;
489 * Parse child nodes for the "#power-domain-cells" property and
490 * initialize a genpd/genpd-of-provider pair when it's found.
493 if (!of_property_present(node, "#power-domain-cells"))
539 /* Detect OSI support based on CPU DT nodes */
544 of_property_present(np, "power-domains") &&
545 of_property_present(np, "power-domain-names")) {
554 pds_node = of_find_node_by_path("/cpus/power-domains");
562 /* Initialize CPU idle driver for each CPU */
564 ret = sbi_cpuidle_init_cpu(&pdev->dev, cpu);
566 pr_debug("HART%ld: idle driver init failed\n",
575 pr_info("idle driver registered for all CPUs\n");
580 while (--cpu >= 0) {
593 .name = "sbi-cpuidle",
618 pdev = platform_device_register_simple("sbi-cpuidle",
619 -1, NULL, 0);