blob: 6e36740f5719ba0fff74aa713ab7728d9362bc8c [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Alexander Shiyan7c7f8f72014-03-22 09:44:35 +04002/*
3 * CLPS711X CPU idle driver
4 *
5 * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru>
Alexander Shiyan7c7f8f72014-03-22 09:44:35 +04006 */
7
8#include <linux/cpuidle.h>
9#include <linux/err.h>
10#include <linux/io.h>
Paul Gortmaker94e80572015-12-13 18:57:10 -050011#include <linux/init.h>
Alexander Shiyan7c7f8f72014-03-22 09:44:35 +040012#include <linux/platform_device.h>
13
14#define CLPS711X_CPUIDLE_NAME "clps711x-cpuidle"
15
16static void __iomem *clps711x_halt;
17
18static int clps711x_cpuidle_halt(struct cpuidle_device *dev,
19 struct cpuidle_driver *drv, int index)
20{
21 writel(0xaa, clps711x_halt);
22
23 return index;
24}
25
26static struct cpuidle_driver clps711x_idle_driver = {
27 .name = CLPS711X_CPUIDLE_NAME,
28 .owner = THIS_MODULE,
29 .states[0] = {
30 .name = "HALT",
31 .desc = "CLPS711X HALT",
32 .enter = clps711x_cpuidle_halt,
33 .exit_latency = 1,
34 },
35 .state_count = 1,
36};
37
38static int __init clps711x_cpuidle_probe(struct platform_device *pdev)
39{
40 struct resource *res;
41
42 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
43 clps711x_halt = devm_ioremap_resource(&pdev->dev, res);
44 if (IS_ERR(clps711x_halt))
45 return PTR_ERR(clps711x_halt);
46
47 return cpuidle_register(&clps711x_idle_driver, NULL);
48}
49
50static struct platform_driver clps711x_cpuidle_driver = {
51 .driver = {
52 .name = CLPS711X_CPUIDLE_NAME,
Alexander Shiyan7c7f8f72014-03-22 09:44:35 +040053 },
54};
Paul Gortmaker94e80572015-12-13 18:57:10 -050055builtin_platform_driver_probe(clps711x_cpuidle_driver, clps711x_cpuidle_probe);