12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 27c7f8f7fSAlexander Shiyan /* 37c7f8f7fSAlexander Shiyan * CLPS711X CPU idle driver 47c7f8f7fSAlexander Shiyan * 57c7f8f7fSAlexander Shiyan * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru> 67c7f8f7fSAlexander Shiyan */ 77c7f8f7fSAlexander Shiyan 87c7f8f7fSAlexander Shiyan #include <linux/cpuidle.h> 97c7f8f7fSAlexander Shiyan #include <linux/err.h> 107c7f8f7fSAlexander Shiyan #include <linux/io.h> 1194e8057bSPaul Gortmaker #include <linux/init.h> 127c7f8f7fSAlexander Shiyan #include <linux/platform_device.h> 137c7f8f7fSAlexander Shiyan 147c7f8f7fSAlexander Shiyan #define CLPS711X_CPUIDLE_NAME "clps711x-cpuidle" 157c7f8f7fSAlexander Shiyan 167c7f8f7fSAlexander Shiyan static void __iomem *clps711x_halt; 177c7f8f7fSAlexander Shiyan 187c7f8f7fSAlexander Shiyan static int clps711x_cpuidle_halt(struct cpuidle_device *dev, 197c7f8f7fSAlexander Shiyan struct cpuidle_driver *drv, int index) 207c7f8f7fSAlexander Shiyan { 217c7f8f7fSAlexander Shiyan writel(0xaa, clps711x_halt); 227c7f8f7fSAlexander Shiyan 237c7f8f7fSAlexander Shiyan return index; 247c7f8f7fSAlexander Shiyan } 257c7f8f7fSAlexander Shiyan 267c7f8f7fSAlexander Shiyan static struct cpuidle_driver clps711x_idle_driver = { 277c7f8f7fSAlexander Shiyan .name = CLPS711X_CPUIDLE_NAME, 287c7f8f7fSAlexander Shiyan .owner = THIS_MODULE, 297c7f8f7fSAlexander Shiyan .states[0] = { 307c7f8f7fSAlexander Shiyan .name = "HALT", 317c7f8f7fSAlexander Shiyan .desc = "CLPS711X HALT", 327c7f8f7fSAlexander Shiyan .enter = clps711x_cpuidle_halt, 337c7f8f7fSAlexander Shiyan .exit_latency = 1, 347c7f8f7fSAlexander Shiyan }, 357c7f8f7fSAlexander Shiyan .state_count = 1, 367c7f8f7fSAlexander Shiyan }; 377c7f8f7fSAlexander Shiyan 387c7f8f7fSAlexander Shiyan static int __init clps711x_cpuidle_probe(struct platform_device *pdev) 397c7f8f7fSAlexander Shiyan { 40*22c48a43SYangtao Li clps711x_halt = devm_platform_ioremap_resource(pdev, 0); 417c7f8f7fSAlexander Shiyan if (IS_ERR(clps711x_halt)) 427c7f8f7fSAlexander Shiyan return PTR_ERR(clps711x_halt); 437c7f8f7fSAlexander Shiyan 447c7f8f7fSAlexander Shiyan return cpuidle_register(&clps711x_idle_driver, NULL); 457c7f8f7fSAlexander Shiyan } 467c7f8f7fSAlexander Shiyan 477c7f8f7fSAlexander Shiyan static struct platform_driver clps711x_cpuidle_driver = { 487c7f8f7fSAlexander Shiyan .driver = { 497c7f8f7fSAlexander Shiyan .name = CLPS711X_CPUIDLE_NAME, 507c7f8f7fSAlexander Shiyan }, 517c7f8f7fSAlexander Shiyan }; 5294e8057bSPaul Gortmaker builtin_platform_driver_probe(clps711x_cpuidle_driver, clps711x_cpuidle_probe); 53