Blame view

arch/arm/mach-omap2/voltagedomains33xx_data.c 2.37 KB
5ed8f755b   Afzal Mohammed   arm:omap:am33xx: ...
1
2
3
4
5
6
7
8
9
10
11
  /*
   * AM33XX voltage domain data
   *
   * Copyright (C) 2011 Texas Instruments, Inc.
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  #include <linux/kernel.h>
  #include <linux/init.h>
fe9bf4373   Afzal Mohammed   arm:omap:am33xx: ...
12
  #include <linux/regulator/consumer.h>
5ed8f755b   Afzal Mohammed   arm:omap:am33xx: ...
13

536a4c8bb   Afzal Mohammed   arm: omap: am33x:...
14
  #include <plat/voltage.h>
fe9bf4373   Afzal Mohammed   arm:omap:am33xx: ...
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  #include <plat/omap_device.h>
  
  #include "omap_opp_data.h"
  
  #define TOLERANCE 12500 /* in uV */
  
  int am33x_mpu_voltdm_scale(struct voltagedomain *voltdm,
  				unsigned long target_volt)
  {
  	int ret = -EINVAL;
  
  
  	if (!voltdm->regulator)
  		return ret;
  
  
  	ret = regulator_set_voltage(voltdm->regulator, target_volt,
  		target_volt + TOLERANCE);
  
  	if (ret)
  		pr_debug("Voltage change failed, ret = %d
  ", ret);
  	else
  		pr_debug("Voltage scaled to %d
  ",
  			regulator_get_voltage(voltdm->regulator));
  
  	return ret;
  }
  
  struct omap_vdd_dep_info am33xx_vddmpu_dep_info[] = {
  	{.name = NULL, .dep_table = NULL, .nr_dep_entries = 0},
  };
  
  static struct omap_vdd_info am33xx_vdd1_info;
  
  int am33x_mpu_voltdm_init(struct voltagedomain *voltdm)
  {
  	struct regulator *mpu_regulator;
  	struct device *mpu_dev;
  
  	mpu_dev = omap_device_get_by_hwmod_name("mpu");
  	if (!mpu_dev) {
  		pr_warning("%s: unable to get the mpu device
  ", __func__);
  		return -EINVAL;
  	}
  
  	mpu_regulator = regulator_get(mpu_dev, voltdm->name);
  
  	if (IS_ERR(mpu_regulator)) {
  		pr_err("%s: Could not get regulator for %s
  ",
  			__func__, voltdm->name);
  		return -ENODEV;
  	} else {
  		voltdm->regulator = mpu_regulator;
  		voltdm->scale = &am33x_mpu_voltdm_scale;
  	}
  
  	return 0;
  }
5ed8f755b   Afzal Mohammed   arm:omap:am33xx: ...
77

188d98db3   Vaibhav Hiremath   arm:omap:am33xx: ...
78
79
  static struct voltagedomain am33xx_voltdm_mpu = {
  	.name = "mpu",
fe9bf4373   Afzal Mohammed   arm:omap:am33xx: ...
80
81
82
83
  	.scalable = true,
  	.use_regulator = 1,
  	.regulator_init = &am33x_mpu_voltdm_init,
  	.vdd	= &am33xx_vdd1_info,
188d98db3   Vaibhav Hiremath   arm:omap:am33xx: ...
84
  };
5ed8f755b   Afzal Mohammed   arm:omap:am33xx: ...
85
86
87
88
89
90
91
92
93
  static struct voltagedomain am33xx_voltdm_core = {
  	.name = "core",
  };
  
  static struct voltagedomain am33xx_voltdm_rtc = {
  	.name = "rtc",
  };
  
  static struct voltagedomain *voltagedomains_am33xx[] __initdata = {
188d98db3   Vaibhav Hiremath   arm:omap:am33xx: ...
94
  	&am33xx_voltdm_mpu,
5ed8f755b   Afzal Mohammed   arm:omap:am33xx: ...
95
96
97
98
  	&am33xx_voltdm_core,
  	&am33xx_voltdm_rtc,
  	NULL,
  };
fe9bf4373   Afzal Mohammed   arm:omap:am33xx: ...
99
  static const char *sys_clk_name __initdata = "sys_clkin_ck";
5ed8f755b   Afzal Mohammed   arm:omap:am33xx: ...
100
101
  void __init am33xx_voltagedomains_init(void)
  {
fe9bf4373   Afzal Mohammed   arm:omap:am33xx: ...
102
103
104
105
106
107
108
  	struct voltagedomain *voltdm;
  	int i;
  
  	am33xx_vdd1_info.dep_vdd_info = am33xx_vddmpu_dep_info;
  
  	for (i = 0; voltdm = voltagedomains_am33xx[i], voltdm; i++)
  		voltdm->sys_clk.name = sys_clk_name;
5ed8f755b   Afzal Mohammed   arm:omap:am33xx: ...
109
110
  	voltdm_init(voltagedomains_am33xx);
  }