Blame view

drivers/cpuidle/cpuidle-calxeda.c 1.63 KB
9952f6918   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-only
be6a98d3f   Rob Herring   cpuidle: add Calx...
2
3
4
  /*
   * Copyright 2012 Calxeda, Inc.
   *
a8e39c35b   Daniel Lezcano   cpuidle: add main...
5
   * Based on arch/arm/plat-mxc/cpuidle.c: #v3.7
be6a98d3f   Rob Herring   cpuidle: add Calx...
6
7
8
   * Copyright 2012 Freescale Semiconductor, Inc.
   * Copyright 2012 Linaro Ltd.
   *
a8e39c35b   Daniel Lezcano   cpuidle: add main...
9
   * Maintainer: Rob Herring <rob.herring@calxeda.com>
be6a98d3f   Rob Herring   cpuidle: add Calx...
10
11
12
   */
  
  #include <linux/cpuidle.h>
34a5eeb20   Rob Herring   cpuidle: calxeda:...
13
  #include <linux/cpu_pm.h>
be6a98d3f   Rob Herring   cpuidle: add Calx...
14
  #include <linux/init.h>
a410146c3   Rob Herring   cpuidle: calxeda:...
15
  #include <linux/mm.h>
60a66e370   Daniel Lezcano   ARM: highbank: cp...
16
  #include <linux/platform_device.h>
be120397e   Mark Rutland   ARM: migrate to c...
17
  #include <linux/psci.h>
be6a98d3f   Rob Herring   cpuidle: add Calx...
18
  #include <asm/cpuidle.h>
be6a98d3f   Rob Herring   cpuidle: add Calx...
19
  #include <asm/suspend.h>
be120397e   Mark Rutland   ARM: migrate to c...
20
21
22
23
24
25
26
  
  #include <uapi/linux/psci.h>
  
  #define CALXEDA_IDLE_PARAM \
  	((0 << PSCI_0_2_POWER_STATE_ID_SHIFT) | \
  	 (0 << PSCI_0_2_POWER_STATE_AFFL_SHIFT) | \
  	 (PSCI_POWER_STATE_TYPE_POWER_DOWN << PSCI_0_2_POWER_STATE_TYPE_SHIFT))
be6a98d3f   Rob Herring   cpuidle: add Calx...
27
28
29
  
  static int calxeda_idle_finish(unsigned long val)
  {
be120397e   Mark Rutland   ARM: migrate to c...
30
  	return psci_ops.cpu_suspend(CALXEDA_IDLE_PARAM, __pa(cpu_resume));
be6a98d3f   Rob Herring   cpuidle: add Calx...
31
32
33
34
35
36
  }
  
  static int calxeda_pwrdown_idle(struct cpuidle_device *dev,
  				struct cpuidle_driver *drv,
  				int index)
  {
34a5eeb20   Rob Herring   cpuidle: calxeda:...
37
  	cpu_pm_enter();
be6a98d3f   Rob Herring   cpuidle: add Calx...
38
  	cpu_suspend(0, calxeda_idle_finish);
34a5eeb20   Rob Herring   cpuidle: calxeda:...
39
  	cpu_pm_exit();
be6a98d3f   Rob Herring   cpuidle: add Calx...
40
41
  	return index;
  }
be6a98d3f   Rob Herring   cpuidle: add Calx...
42
43
  static struct cpuidle_driver calxeda_idle_driver = {
  	.name = "calxeda_idle",
be6a98d3f   Rob Herring   cpuidle: add Calx...
44
45
46
47
48
  	.states = {
  		ARM_CPUIDLE_WFI_STATE,
  		{
  			.name = "PG",
  			.desc = "Power Gate",
be6a98d3f   Rob Herring   cpuidle: add Calx...
49
50
51
52
53
54
55
56
  			.exit_latency = 30,
  			.power_usage = 50,
  			.target_residency = 200,
  			.enter = calxeda_pwrdown_idle,
  		},
  	},
  	.state_count = 2,
  };
5781532eb   Andre Przywara   ARM/cpuidle: remo...
57
  static int calxeda_cpuidle_probe(struct platform_device *pdev)
be6a98d3f   Rob Herring   cpuidle: add Calx...
58
  {
0b210d96a   Daniel Lezcano   ARM: calxeda: cpu...
59
  	return cpuidle_register(&calxeda_idle_driver, NULL);
be6a98d3f   Rob Herring   cpuidle: add Calx...
60
  }
60a66e370   Daniel Lezcano   ARM: highbank: cp...
61
62
63
64
  
  static struct platform_driver calxeda_cpuidle_plat_driver = {
          .driver = {
                  .name = "cpuidle-calxeda",
60a66e370   Daniel Lezcano   ARM: highbank: cp...
65
66
67
          },
          .probe = calxeda_cpuidle_probe,
  };
090d1cf10   Paul Gortmaker   drivers/cpuidle: ...
68
  builtin_platform_driver(calxeda_cpuidle_plat_driver);