Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Alexander Shiyan | 7c7f8f7 | 2014-03-22 09:44:35 +0400 | [diff] [blame] | 2 | /* |
| 3 | * CLPS711X CPU idle driver |
| 4 | * |
| 5 | * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru> |
Alexander Shiyan | 7c7f8f7 | 2014-03-22 09:44:35 +0400 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/cpuidle.h> |
| 9 | #include <linux/err.h> |
| 10 | #include <linux/io.h> |
Paul Gortmaker | 94e8057 | 2015-12-13 18:57:10 -0500 | [diff] [blame] | 11 | #include <linux/init.h> |
Alexander Shiyan | 7c7f8f7 | 2014-03-22 09:44:35 +0400 | [diff] [blame] | 12 | #include <linux/platform_device.h> |
| 13 | |
| 14 | #define CLPS711X_CPUIDLE_NAME "clps711x-cpuidle" |
| 15 | |
| 16 | static void __iomem *clps711x_halt; |
| 17 | |
| 18 | static 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 | |
| 26 | static 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 | |
| 38 | static int __init clps711x_cpuidle_probe(struct platform_device *pdev) |
| 39 | { |
Yangtao Li | 22c48a4 | 2019-12-15 13:02:05 +0000 | [diff] [blame] | 40 | clps711x_halt = devm_platform_ioremap_resource(pdev, 0); |
Alexander Shiyan | 7c7f8f7 | 2014-03-22 09:44:35 +0400 | [diff] [blame] | 41 | if (IS_ERR(clps711x_halt)) |
| 42 | return PTR_ERR(clps711x_halt); |
| 43 | |
| 44 | return cpuidle_register(&clps711x_idle_driver, NULL); |
| 45 | } |
| 46 | |
| 47 | static struct platform_driver clps711x_cpuidle_driver = { |
| 48 | .driver = { |
| 49 | .name = CLPS711X_CPUIDLE_NAME, |
Alexander Shiyan | 7c7f8f7 | 2014-03-22 09:44:35 +0400 | [diff] [blame] | 50 | }, |
| 51 | }; |
Paul Gortmaker | 94e8057 | 2015-12-13 18:57:10 -0500 | [diff] [blame] | 52 | builtin_platform_driver_probe(clps711x_cpuidle_driver, clps711x_cpuidle_probe); |