1*7c7f8f7fSAlexander Shiyan /* 2*7c7f8f7fSAlexander Shiyan * CLPS711X CPU idle driver 3*7c7f8f7fSAlexander Shiyan * 4*7c7f8f7fSAlexander Shiyan * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru> 5*7c7f8f7fSAlexander Shiyan * 6*7c7f8f7fSAlexander Shiyan * This program is free software; you can redistribute it and/or modify 7*7c7f8f7fSAlexander Shiyan * it under the terms of the GNU General Public License as published by 8*7c7f8f7fSAlexander Shiyan * the Free Software Foundation; either version 2 of the License, or 9*7c7f8f7fSAlexander Shiyan * (at your option) any later version. 10*7c7f8f7fSAlexander Shiyan */ 11*7c7f8f7fSAlexander Shiyan 12*7c7f8f7fSAlexander Shiyan #include <linux/cpuidle.h> 13*7c7f8f7fSAlexander Shiyan #include <linux/err.h> 14*7c7f8f7fSAlexander Shiyan #include <linux/io.h> 15*7c7f8f7fSAlexander Shiyan #include <linux/module.h> 16*7c7f8f7fSAlexander Shiyan #include <linux/platform_device.h> 17*7c7f8f7fSAlexander Shiyan 18*7c7f8f7fSAlexander Shiyan #define CLPS711X_CPUIDLE_NAME "clps711x-cpuidle" 19*7c7f8f7fSAlexander Shiyan 20*7c7f8f7fSAlexander Shiyan static void __iomem *clps711x_halt; 21*7c7f8f7fSAlexander Shiyan 22*7c7f8f7fSAlexander Shiyan static int clps711x_cpuidle_halt(struct cpuidle_device *dev, 23*7c7f8f7fSAlexander Shiyan struct cpuidle_driver *drv, int index) 24*7c7f8f7fSAlexander Shiyan { 25*7c7f8f7fSAlexander Shiyan writel(0xaa, clps711x_halt); 26*7c7f8f7fSAlexander Shiyan 27*7c7f8f7fSAlexander Shiyan return index; 28*7c7f8f7fSAlexander Shiyan } 29*7c7f8f7fSAlexander Shiyan 30*7c7f8f7fSAlexander Shiyan static struct cpuidle_driver clps711x_idle_driver = { 31*7c7f8f7fSAlexander Shiyan .name = CLPS711X_CPUIDLE_NAME, 32*7c7f8f7fSAlexander Shiyan .owner = THIS_MODULE, 33*7c7f8f7fSAlexander Shiyan .states[0] = { 34*7c7f8f7fSAlexander Shiyan .name = "HALT", 35*7c7f8f7fSAlexander Shiyan .desc = "CLPS711X HALT", 36*7c7f8f7fSAlexander Shiyan .enter = clps711x_cpuidle_halt, 37*7c7f8f7fSAlexander Shiyan .exit_latency = 1, 38*7c7f8f7fSAlexander Shiyan }, 39*7c7f8f7fSAlexander Shiyan .state_count = 1, 40*7c7f8f7fSAlexander Shiyan }; 41*7c7f8f7fSAlexander Shiyan 42*7c7f8f7fSAlexander Shiyan static int __init clps711x_cpuidle_probe(struct platform_device *pdev) 43*7c7f8f7fSAlexander Shiyan { 44*7c7f8f7fSAlexander Shiyan struct resource *res; 45*7c7f8f7fSAlexander Shiyan 46*7c7f8f7fSAlexander Shiyan res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 47*7c7f8f7fSAlexander Shiyan clps711x_halt = devm_ioremap_resource(&pdev->dev, res); 48*7c7f8f7fSAlexander Shiyan if (IS_ERR(clps711x_halt)) 49*7c7f8f7fSAlexander Shiyan return PTR_ERR(clps711x_halt); 50*7c7f8f7fSAlexander Shiyan 51*7c7f8f7fSAlexander Shiyan return cpuidle_register(&clps711x_idle_driver, NULL); 52*7c7f8f7fSAlexander Shiyan } 53*7c7f8f7fSAlexander Shiyan 54*7c7f8f7fSAlexander Shiyan static struct platform_driver clps711x_cpuidle_driver = { 55*7c7f8f7fSAlexander Shiyan .driver = { 56*7c7f8f7fSAlexander Shiyan .name = CLPS711X_CPUIDLE_NAME, 57*7c7f8f7fSAlexander Shiyan .owner = THIS_MODULE, 58*7c7f8f7fSAlexander Shiyan }, 59*7c7f8f7fSAlexander Shiyan }; 60*7c7f8f7fSAlexander Shiyan module_platform_driver_probe(clps711x_cpuidle_driver, clps711x_cpuidle_probe); 61*7c7f8f7fSAlexander Shiyan 62*7c7f8f7fSAlexander Shiyan MODULE_AUTHOR("Alexander Shiyan <shc_work@mail.ru>"); 63*7c7f8f7fSAlexander Shiyan MODULE_DESCRIPTION("CLPS711X CPU idle driver"); 64*7c7f8f7fSAlexander Shiyan MODULE_LICENSE("GPL"); 65