aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-08-16 16:59:59 -0400
committerStephen Warren <swarren@nvidia.com>2012-09-14 13:31:37 -0400
commit3cc404de243f5cc3cfe8036c6e84232c1401137b (patch)
treec982b99e0653a57c9180dbec921fa5a8748516d9 /arch/arm/mach-tegra
parentbb25af8167d357e3ce3774e85e0b43dc2e931289 (diff)
ARM: dt: tegra: harmony: add regulators
Harmony uses a TPS6586x regulator. Instantiate this, and hook up a couple of fixed GPIO-controlled regulators too. Based on Ventana regulator patch by Stephen Warren <swarren@nvidia.com> and converted to Harmony. swarren made the following changes: * Added ldo0 regulator configuration to device tree, and updated board-harmony-pcie.c for the new regulator name. * Fixed vdd_1v05's voltage from 10.5V to 1.05V. * Modified board-harmony-pcie.c to obtain the en_vdd_1v05 GPIO number at run-time from device tree instead of hard-coding it. * Removed board-harmony{-power.c,.h} now that they're unused. * Disabled vdd_1v05 regulator; the code in board-harmony-pcie.c hijacks this GPIO for now. This will be fixed when the PCIe driver is re- written as a driver. The code can't regulator_get("vdd_1v05") right now, because the vdd_1v05 regulator's probe gets deferred due to its supply being the PMIC, which gets probed after the regulator the first time around, and this dependency is only resolved by repeated probing, which happens when deferred_probe_initcall() is called, which happens in a late initcall, whose runtime order relative to harmony_pcie_init() is undefined, since that's also called from a late initcall. * Removed unused harmony_pcie_initcall(). Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra')
-rw-r--r--arch/arm/mach-tegra/Makefile1
-rw-r--r--arch/arm/mach-tegra/board-dt-tegra20.c9
-rw-r--r--arch/arm/mach-tegra/board-harmony-pcie.c49
-rw-r--r--arch/arm/mach-tegra/board-harmony-power.c152
-rw-r--r--arch/arm/mach-tegra/board-harmony.h28
5 files changed, 31 insertions, 208 deletions
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 6273853f9557..56065acbd816 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -27,6 +27,5 @@ obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-dt-tegra20.o
27obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o 27obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o
28 28
29obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-harmony-pcie.o 29obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-harmony-pcie.o
30obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-harmony-power.o
31 30
32obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-paz00.o 31obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-paz00.o
diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c b/arch/arm/mach-tegra/board-dt-tegra20.c
index f336cdbc8971..37007d60bc37 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -42,7 +42,6 @@
42#include <mach/irqs.h> 42#include <mach/irqs.h>
43 43
44#include "board.h" 44#include "board.h"
45#include "board-harmony.h"
46#include "clock.h" 45#include "clock.h"
47#include "devices.h" 46#include "devices.h"
48 47
@@ -108,15 +107,9 @@ static void __init trimslice_init(void)
108 107
109static void __init harmony_init(void) 108static void __init harmony_init(void)
110{ 109{
110#ifdef CONFIG_TEGRA_PCI
111 int ret; 111 int ret;
112 112
113 ret = harmony_regulator_init();
114 if (ret) {
115 pr_err("harmony_regulator_init() failed: %d\n", ret);
116 return;
117 }
118
119#ifdef CONFIG_TEGRA_PCI
120 ret = harmony_pcie_init(); 113 ret = harmony_pcie_init();
121 if (ret) 114 if (ret)
122 pr_err("harmony_pcie_init() failed: %d\n", ret); 115 pr_err("harmony_pcie_init() failed: %d\n", ret);
diff --git a/arch/arm/mach-tegra/board-harmony-pcie.c b/arch/arm/mach-tegra/board-harmony-pcie.c
index e8c3fda9bec2..3cdc1bb8254c 100644
--- a/arch/arm/mach-tegra/board-harmony-pcie.c
+++ b/arch/arm/mach-tegra/board-harmony-pcie.c
@@ -18,35 +18,57 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/gpio.h> 19#include <linux/gpio.h>
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/of_gpio.h>
21#include <linux/regulator/consumer.h> 22#include <linux/regulator/consumer.h>
22 23
23#include <asm/mach-types.h> 24#include <asm/mach-types.h>
24 25
25#include "board.h" 26#include "board.h"
26#include "board-harmony.h"
27 27
28#ifdef CONFIG_TEGRA_PCI 28#ifdef CONFIG_TEGRA_PCI
29 29
30int __init harmony_pcie_init(void) 30int __init harmony_pcie_init(void)
31{ 31{
32 struct device_node *np;
33 int en_vdd_1v05;
32 struct regulator *regulator = NULL; 34 struct regulator *regulator = NULL;
33 int err; 35 int err;
34 36
35 err = gpio_request(TEGRA_GPIO_EN_VDD_1V05_GPIO, "EN_VDD_1V05"); 37 np = of_find_node_by_path("/regulators/regulator@3");
36 if (err) 38 if (!np) {
39 pr_err("%s: of_find_node_by_path failed\n", __func__);
40 return -ENODEV;
41 }
42
43 en_vdd_1v05 = of_get_named_gpio(np, "gpio", 0);
44 if (en_vdd_1v05 < 0) {
45 pr_err("%s: of_get_named_gpio failed: %d\n", __func__,
46 en_vdd_1v05);
47 return en_vdd_1v05;
48 }
49
50 err = gpio_request(en_vdd_1v05, "EN_VDD_1V05");
51 if (err) {
52 pr_err("%s: gpio_request failed: %d\n", __func__, err);
37 return err; 53 return err;
54 }
38 55
39 gpio_direction_output(TEGRA_GPIO_EN_VDD_1V05_GPIO, 1); 56 gpio_direction_output(en_vdd_1v05, 1);
40 57
41 regulator = regulator_get(NULL, "pex_clk"); 58 regulator = regulator_get(NULL, "vdd_ldo0,vddio_pex_clk");
42 if (IS_ERR_OR_NULL(regulator)) 59 if (IS_ERR_OR_NULL(regulator)) {
60 pr_err("%s: regulator_get failed: %d\n", __func__,
61 (int)PTR_ERR(regulator));
43 goto err_reg; 62 goto err_reg;
63 }
44 64
45 regulator_enable(regulator); 65 regulator_enable(regulator);
46 66
47 err = tegra_pcie_init(true, true); 67 err = tegra_pcie_init(true, true);
48 if (err) 68 if (err) {
69 pr_err("%s: tegra_pcie_init failed: %d\n", __func__, err);
49 goto err_pcie; 70 goto err_pcie;
71 }
50 72
51 return 0; 73 return 0;
52 74
@@ -54,20 +76,9 @@ err_pcie:
54 regulator_disable(regulator); 76 regulator_disable(regulator);
55 regulator_put(regulator); 77 regulator_put(regulator);
56err_reg: 78err_reg:
57 gpio_free(TEGRA_GPIO_EN_VDD_1V05_GPIO); 79 gpio_free(en_vdd_1v05);
58 80
59 return err; 81 return err;
60} 82}
61 83
62static int __init harmony_pcie_initcall(void)
63{
64 if (!machine_is_harmony())
65 return 0;
66
67 return harmony_pcie_init();
68}
69
70/* PCI should be initialized after I2C, mfd and regulators */
71subsys_initcall_sync(harmony_pcie_initcall);
72
73#endif 84#endif
diff --git a/arch/arm/mach-tegra/board-harmony-power.c b/arch/arm/mach-tegra/board-harmony-power.c
deleted file mode 100644
index fddfb8213d2c..000000000000
--- a/arch/arm/mach-tegra/board-harmony-power.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/*
2 * Copyright (C) 2010 NVIDIA, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
16 * 02111-1307, USA
17 */
18#include <linux/i2c.h>
19#include <linux/platform_device.h>
20#include <linux/gpio.h>
21#include <linux/regulator/machine.h>
22#include <linux/regulator/fixed.h>
23#include <linux/mfd/tps6586x.h>
24#include <linux/of.h>
25#include <linux/of_i2c.h>
26
27#include <asm/mach-types.h>
28
29#include <mach/irqs.h>
30
31#include "board-harmony.h"
32
33static struct regulator_consumer_supply tps658621_ldo0_supply[] = {
34 REGULATOR_SUPPLY("pex_clk", NULL),
35};
36
37static struct regulator_init_data ldo0_data = {
38 .supply_regulator = "vdd_sm2",
39 .constraints = {
40 .name = "vdd_ldo0",
41 .min_uV = 3300 * 1000,
42 .max_uV = 3300 * 1000,
43 .valid_modes_mask = (REGULATOR_MODE_NORMAL |
44 REGULATOR_MODE_STANDBY),
45 .valid_ops_mask = (REGULATOR_CHANGE_MODE |
46 REGULATOR_CHANGE_STATUS |
47 REGULATOR_CHANGE_VOLTAGE),
48 .apply_uV = 1,
49 },
50 .num_consumer_supplies = ARRAY_SIZE(tps658621_ldo0_supply),
51 .consumer_supplies = tps658621_ldo0_supply,
52};
53
54#define HARMONY_REGULATOR_INIT(_id, _name, _supply, _minmv, _maxmv, _on)\
55 static struct regulator_init_data _id##_data = { \
56 .supply_regulator = _supply, \
57 .constraints = { \
58 .name = _name, \
59 .min_uV = (_minmv)*1000, \
60 .max_uV = (_maxmv)*1000, \
61 .valid_modes_mask = (REGULATOR_MODE_NORMAL | \
62 REGULATOR_MODE_STANDBY), \
63 .valid_ops_mask = (REGULATOR_CHANGE_MODE | \
64 REGULATOR_CHANGE_STATUS | \
65 REGULATOR_CHANGE_VOLTAGE), \
66 .always_on = _on, \
67 }, \
68 }
69
70static struct regulator_init_data sys_data = {
71 .supply_regulator = "vdd_5v0",
72 .constraints = {
73 .name = "vdd_sys",
74 },
75};
76
77HARMONY_REGULATOR_INIT(sm0, "vdd_sm0", "vdd_sys", 725, 1500, 1);
78HARMONY_REGULATOR_INIT(sm1, "vdd_sm1", "vdd_sys", 725, 1500, 1);
79HARMONY_REGULATOR_INIT(sm2, "vdd_sm2", "vdd_sys", 3000, 4550, 1);
80HARMONY_REGULATOR_INIT(ldo1, "vdd_ldo1", "vdd_sm2", 725, 1500, 1);
81HARMONY_REGULATOR_INIT(ldo2, "vdd_ldo2", "vdd_sm2", 725, 1500, 0);
82HARMONY_REGULATOR_INIT(ldo3, "vdd_ldo3", "vdd_sm2", 1250, 3300, 1);
83HARMONY_REGULATOR_INIT(ldo4, "vdd_ldo4", "vdd_sm2", 1700, 2475, 1);
84HARMONY_REGULATOR_INIT(ldo5, "vdd_ldo5", "vdd_sys", 1250, 3300, 1);
85HARMONY_REGULATOR_INIT(ldo6, "vdd_ldo6", "vdd_sm2", 1250, 3300, 0);
86HARMONY_REGULATOR_INIT(ldo7, "vdd_ldo7", "vdd_sm2", 1250, 3300, 0);
87HARMONY_REGULATOR_INIT(ldo8, "vdd_ldo8", "vdd_sm2", 1250, 3300, 0);
88HARMONY_REGULATOR_INIT(ldo9, "vdd_ldo9", "vdd_sm2", 1250, 3300, 1);
89
90#define TPS_REG(_id, _data) \
91 { \
92 .id = TPS6586X_ID_##_id, \
93 .name = "tps6586x-regulator", \
94 .platform_data = _data, \
95 }
96
97static struct tps6586x_subdev_info tps_devs[] = {
98 TPS_REG(SYS, &sys_data),
99 TPS_REG(SM_0, &sm0_data),
100 TPS_REG(SM_1, &sm1_data),
101 TPS_REG(SM_2, &sm2_data),
102 TPS_REG(LDO_0, &ldo0_data),
103 TPS_REG(LDO_1, &ldo1_data),
104 TPS_REG(LDO_2, &ldo2_data),
105 TPS_REG(LDO_3, &ldo3_data),
106 TPS_REG(LDO_4, &ldo4_data),
107 TPS_REG(LDO_5, &ldo5_data),
108 TPS_REG(LDO_6, &ldo6_data),
109 TPS_REG(LDO_7, &ldo7_data),
110 TPS_REG(LDO_8, &ldo8_data),
111 TPS_REG(LDO_9, &ldo9_data),
112};
113
114static struct tps6586x_platform_data tps_platform = {
115 .irq_base = TEGRA_NR_IRQS,
116 .num_subdevs = ARRAY_SIZE(tps_devs),
117 .subdevs = tps_devs,
118 .gpio_base = HARMONY_GPIO_TPS6586X(0),
119};
120
121static struct i2c_board_info __initdata harmony_regulators[] = {
122 {
123 I2C_BOARD_INFO("tps6586x", 0x34),
124 .irq = INT_EXTERNAL_PMU,
125 .platform_data = &tps_platform,
126 },
127};
128
129int __init harmony_regulator_init(void)
130{
131 struct device_node *np;
132 struct i2c_adapter *adapter;
133
134 regulator_register_always_on(0, "vdd_5v0",
135 NULL, 0, 5000000);
136
137 np = of_find_node_by_path("/i2c@7000d000");
138 if (np == NULL) {
139 pr_err("Could not find device_node for DVC I2C\n");
140 return -ENODEV;
141 }
142
143 adapter = of_find_i2c_adapter_by_node(np);
144 if (!adapter) {
145 pr_err("Could not find i2c_adapter for DVC I2C\n");
146 return -ENODEV;
147 }
148
149 i2c_new_device(adapter, harmony_regulators);
150
151 return 0;
152}
diff --git a/arch/arm/mach-tegra/board-harmony.h b/arch/arm/mach-tegra/board-harmony.h
deleted file mode 100644
index 7ae87088acf8..000000000000
--- a/arch/arm/mach-tegra/board-harmony.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * arch/arm/mach-tegra/board-harmony.h
3 *
4 * Copyright (C) 2010 Google, Inc.
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#ifndef _MACH_TEGRA_BOARD_HARMONY_H
18#define _MACH_TEGRA_BOARD_HARMONY_H
19
20#include <mach/gpio-tegra.h>
21
22#define HARMONY_GPIO_TPS6586X(_x_) (TEGRA_NR_GPIOS + (_x_))
23
24#define TEGRA_GPIO_EN_VDD_1V05_GPIO HARMONY_GPIO_TPS6586X(2)
25
26int harmony_regulator_init(void);
27
28#endif