Blame view

drivers/cpuidle/cpuidle-kirkwood.c 2.29 KB
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
1
  /*
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
2
3
4
5
6
7
8
9
10
11
   * CPU idle Marvell Kirkwood SoCs
   *
   * This file is licensed under the terms of the GNU General Public
   * License version 2.  This program is licensed "as is" without any
   * warranty of any kind, whether express or implied.
   *
   * The cpu idle uses wait-for-interrupt and DDR self refresh in order
   * to implement two idle states -
   * #1 wait-for-interrupt
   * #2 wait-for-interrupt and DDR self refresh
a8e39c35b   Daniel Lezcano   cpuidle: add main...
12
13
14
   *
   * Maintainer: Jason Cooper <jason@lakedaemon.net>
   * Maintainer: Andrew Lunn <andrew@lunn.ch>
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
15
16
17
   */
  
  #include <linux/kernel.h>
9cfc94eb0   Andrew Lunn   cpuidle: kirkwood...
18
  #include <linux/module.h>
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
19
20
21
22
  #include <linux/init.h>
  #include <linux/platform_device.h>
  #include <linux/cpuidle.h>
  #include <linux/io.h>
dc28094b9   Paul Gortmaker   arm: Add export.h...
23
  #include <linux/export.h>
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
24
  #include <asm/proc-fns.h>
b334648db   Robert Lee   ARM: kirkwood: Co...
25
  #include <asm/cpuidle.h>
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
26
27
  
  #define KIRKWOOD_MAX_STATES	2
9cfc94eb0   Andrew Lunn   cpuidle: kirkwood...
28
  static void __iomem *ddr_operation_base;
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
29
30
  /* Actual code that puts the SoC in different idle states */
  static int kirkwood_enter_idle(struct cpuidle_device *dev,
9cfc94eb0   Andrew Lunn   cpuidle: kirkwood...
31
  			       struct cpuidle_driver *drv,
e978aa7d7   Deepthi Dharwar   cpuidle: Move dev...
32
  			       int index)
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
33
  {
9cfc94eb0   Andrew Lunn   cpuidle: kirkwood...
34
  	writel(0x7, ddr_operation_base);
b334648db   Robert Lee   ARM: kirkwood: Co...
35
  	cpu_do_idle();
e978aa7d7   Deepthi Dharwar   cpuidle: Move dev...
36
37
  
  	return index;
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
38
  }
b334648db   Robert Lee   ARM: kirkwood: Co...
39
40
41
  static struct cpuidle_driver kirkwood_idle_driver = {
  	.name			= "kirkwood_idle",
  	.owner			= THIS_MODULE,
b334648db   Robert Lee   ARM: kirkwood: Co...
42
43
44
45
46
  	.states[0]		= ARM_CPUIDLE_WFI_STATE,
  	.states[1]		= {
  		.enter			= kirkwood_enter_idle,
  		.exit_latency		= 10,
  		.target_residency	= 100000,
b334648db   Robert Lee   ARM: kirkwood: Co...
47
48
49
50
51
  		.name			= "DDR SR",
  		.desc			= "WFI and DDR Self Refresh",
  	},
  	.state_count = KIRKWOOD_MAX_STATES,
  };
b334648db   Robert Lee   ARM: kirkwood: Co...
52

e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
53
  /* Initialize CPU idle by registering the idle states */
9cfc94eb0   Andrew Lunn   cpuidle: kirkwood...
54
  static int kirkwood_cpuidle_probe(struct platform_device *pdev)
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
55
  {
9cfc94eb0   Andrew Lunn   cpuidle: kirkwood...
56
57
58
  	struct resource *res;
  
  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
488540bf4   Silviu-Mihai Popescu   cpuidle: kirkwood...
59
60
61
  	ddr_operation_base = devm_ioremap_resource(&pdev->dev, res);
  	if (IS_ERR(ddr_operation_base))
  		return PTR_ERR(ddr_operation_base);
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
62

30dc72c6f   Daniel Lezcano   ARM: kirkwood: cp...
63
  	return cpuidle_register(&kirkwood_idle_driver, NULL);
e50b6befa   Rabeeh Khoury   [ARM] Kirkwood: C...
64
  }
75d6137da   Jingoo Han   cpuidle: kirkwood...
65
  static int kirkwood_cpuidle_remove(struct platform_device *pdev)
9cfc94eb0   Andrew Lunn   cpuidle: kirkwood...
66
  {
30dc72c6f   Daniel Lezcano   ARM: kirkwood: cp...
67
  	cpuidle_unregister(&kirkwood_idle_driver);
9cfc94eb0   Andrew Lunn   cpuidle: kirkwood...
68
69
70
71
72
73
74
75
  	return 0;
  }
  
  static struct platform_driver kirkwood_cpuidle_driver = {
  	.probe = kirkwood_cpuidle_probe,
  	.remove = kirkwood_cpuidle_remove,
  	.driver = {
  		   .name = "kirkwood_cpuidle",
9cfc94eb0   Andrew Lunn   cpuidle: kirkwood...
76
77
78
79
80
81
82
83
84
  		   },
  };
  
  module_platform_driver(kirkwood_cpuidle_driver);
  
  MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
  MODULE_DESCRIPTION("Kirkwood cpu idle driver");
  MODULE_LICENSE("GPL v2");
  MODULE_ALIAS("platform:kirkwood-cpuidle");