2 * Copyright (C) 2010 NVIDIA, Inc.
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.
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.
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
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>
25 #include <linux/of_i2c.h>
27 #include <asm/mach-types.h>
29 #include <mach/irqs.h>
31 #include "board-harmony.h"
33 static struct regulator_consumer_supply tps658621_ldo0_supply
[] = {
34 REGULATOR_SUPPLY("pex_clk", NULL
),
37 static struct regulator_init_data ldo0_data
= {
38 .supply_regulator
= "vdd_sm2",
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
),
50 .num_consumer_supplies
= ARRAY_SIZE(tps658621_ldo0_supply
),
51 .consumer_supplies
= tps658621_ldo0_supply
,
54 #define HARMONY_REGULATOR_INIT(_id, _name, _supply, _minmv, _maxmv, _on)\
55 static struct regulator_init_data _id##_data = { \
56 .supply_regulator = _supply, \
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), \
70 HARMONY_REGULATOR_INIT(sm0
, "vdd_sm0", "vdd_sys", 725, 1500, 1);
71 HARMONY_REGULATOR_INIT(sm1
, "vdd_sm1", "vdd_sys", 725, 1500, 1);
72 HARMONY_REGULATOR_INIT(sm2
, "vdd_sm2", "vdd_sys", 3000, 4550, 1);
73 HARMONY_REGULATOR_INIT(ldo1
, "vdd_ldo1", "vdd_sm2", 725, 1500, 1);
74 HARMONY_REGULATOR_INIT(ldo2
, "vdd_ldo2", "vdd_sm2", 725, 1500, 0);
75 HARMONY_REGULATOR_INIT(ldo3
, "vdd_ldo3", "vdd_sm2", 1250, 3300, 1);
76 HARMONY_REGULATOR_INIT(ldo4
, "vdd_ldo4", "vdd_sm2", 1700, 2475, 1);
77 HARMONY_REGULATOR_INIT(ldo5
, "vdd_ldo5", NULL
, 1250, 3300, 1);
78 HARMONY_REGULATOR_INIT(ldo6
, "vdd_ldo6", "vdd_sm2", 1250, 3300, 0);
79 HARMONY_REGULATOR_INIT(ldo7
, "vdd_ldo7", "vdd_sm2", 1250, 3300, 0);
80 HARMONY_REGULATOR_INIT(ldo8
, "vdd_ldo8", "vdd_sm2", 1250, 3300, 0);
81 HARMONY_REGULATOR_INIT(ldo9
, "vdd_ldo9", "vdd_sm2", 1250, 3300, 1);
83 #define TPS_REG(_id, _data) \
85 .id = TPS6586X_ID_##_id, \
86 .name = "tps6586x-regulator", \
87 .platform_data = _data, \
90 static struct tps6586x_subdev_info tps_devs
[] = {
91 TPS_REG(SM_0
, &sm0_data
),
92 TPS_REG(SM_1
, &sm1_data
),
93 TPS_REG(SM_2
, &sm2_data
),
94 TPS_REG(LDO_0
, &ldo0_data
),
95 TPS_REG(LDO_1
, &ldo1_data
),
96 TPS_REG(LDO_2
, &ldo2_data
),
97 TPS_REG(LDO_3
, &ldo3_data
),
98 TPS_REG(LDO_4
, &ldo4_data
),
99 TPS_REG(LDO_5
, &ldo5_data
),
100 TPS_REG(LDO_6
, &ldo6_data
),
101 TPS_REG(LDO_7
, &ldo7_data
),
102 TPS_REG(LDO_8
, &ldo8_data
),
103 TPS_REG(LDO_9
, &ldo9_data
),
106 static struct tps6586x_platform_data tps_platform
= {
107 .irq_base
= TEGRA_NR_IRQS
,
108 .num_subdevs
= ARRAY_SIZE(tps_devs
),
110 .gpio_base
= HARMONY_GPIO_TPS6586X(0),
113 static struct i2c_board_info __initdata harmony_regulators
[] = {
115 I2C_BOARD_INFO("tps6586x", 0x34),
116 .irq
= INT_EXTERNAL_PMU
,
117 .platform_data
= &tps_platform
,
121 int __init
harmony_regulator_init(void)
123 regulator_register_always_on(0, "vdd_sys",
126 if (machine_is_harmony()) {
127 i2c_register_board_info(3, harmony_regulators
, 1);
128 } else { /* Harmony, booted using device tree */
129 struct device_node
*np
;
130 struct i2c_adapter
*adapter
;
132 np
= of_find_node_by_path("/i2c@7000d000");
134 pr_err("Could not find device_node for DVC I2C\n");
138 adapter
= of_find_i2c_adapter_by_node(np
);
140 pr_err("Could not find i2c_adapter for DVC I2C\n");
144 i2c_new_device(adapter
, harmony_regulators
);