brintos

brintos / linux-shallow public Read only

0
0
Text · 2.0 KiB · 602c4df Raw
81 lines · c
1// SPDX-License-Identifier: GPL-2.0-only2/*3 * CPU idle Marvell Kirkwood SoCs4 *5 * The cpu idle uses wait-for-interrupt and DDR self refresh in order6 * to implement two idle states -7 * #1 wait-for-interrupt8 * #2 wait-for-interrupt and DDR self refresh9 *10 * Maintainer: Jason Cooper <jason@lakedaemon.net>11 * Maintainer: Andrew Lunn <andrew@lunn.ch>12 */13 14#include <linux/kernel.h>15#include <linux/module.h>16#include <linux/init.h>17#include <linux/platform_device.h>18#include <linux/cpuidle.h>19#include <linux/io.h>20#include <linux/export.h>21#include <asm/cpuidle.h>22 23#define KIRKWOOD_MAX_STATES	224 25static void __iomem *ddr_operation_base;26 27/* Actual code that puts the SoC in different idle states */28static int kirkwood_enter_idle(struct cpuidle_device *dev,29			       struct cpuidle_driver *drv,30			       int index)31{32	writel(0x7, ddr_operation_base);33	cpu_do_idle();34 35	return index;36}37 38static struct cpuidle_driver kirkwood_idle_driver = {39	.name			= "kirkwood_idle",40	.owner			= THIS_MODULE,41	.states[0]		= ARM_CPUIDLE_WFI_STATE,42	.states[1]		= {43		.enter			= kirkwood_enter_idle,44		.exit_latency		= 10,45		.target_residency	= 100000,46		.name			= "DDR SR",47		.desc			= "WFI and DDR Self Refresh",48	},49	.state_count = KIRKWOOD_MAX_STATES,50};51 52/* Initialize CPU idle by registering the idle states */53static int kirkwood_cpuidle_probe(struct platform_device *pdev)54{55	ddr_operation_base = devm_platform_ioremap_resource(pdev, 0);56	if (IS_ERR(ddr_operation_base))57		return PTR_ERR(ddr_operation_base);58 59	return cpuidle_register(&kirkwood_idle_driver, NULL);60}61 62static void kirkwood_cpuidle_remove(struct platform_device *pdev)63{64	cpuidle_unregister(&kirkwood_idle_driver);65}66 67static struct platform_driver kirkwood_cpuidle_driver = {68	.probe = kirkwood_cpuidle_probe,69	.remove_new = kirkwood_cpuidle_remove,70	.driver = {71		   .name = "kirkwood_cpuidle",72		   },73};74 75module_platform_driver(kirkwood_cpuidle_driver);76 77MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");78MODULE_DESCRIPTION("Kirkwood cpu idle driver");79MODULE_LICENSE("GPL v2");80MODULE_ALIAS("platform:kirkwood-cpuidle");81