Mike Rapoport | 6f168f2 | 2011-03-09 16:31:18 +0200 | [diff] [blame] | 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> |
Stephen Warren | 9eb4b91 | 2011-09-21 16:10:40 -0600 | [diff] [blame] | 21 | #include <linux/io.h> |
Mike Rapoport | 6f168f2 | 2011-03-09 16:31:18 +0200 | [diff] [blame] | 22 | #include <linux/regulator/machine.h> |
| 23 | #include <linux/mfd/tps6586x.h> |
| 24 | |
Stephen Warren | 9eb4b91 | 2011-09-21 16:10:40 -0600 | [diff] [blame] | 25 | #include <mach/iomap.h> |
Mike Rapoport | 6f168f2 | 2011-03-09 16:31:18 +0200 | [diff] [blame] | 26 | #include <mach/irqs.h> |
| 27 | |
Stephen Warren | f2a4d8a | 2011-05-31 15:14:07 -0600 | [diff] [blame] | 28 | #include "board-harmony.h" |
| 29 | |
Mike Rapoport | 6f168f2 | 2011-03-09 16:31:18 +0200 | [diff] [blame] | 30 | #define PMC_CTRL 0x0 |
| 31 | #define PMC_CTRL_INTR_LOW (1 << 17) |
| 32 | |
| 33 | static struct regulator_consumer_supply tps658621_ldo0_supply[] = { |
| 34 | REGULATOR_SUPPLY("pex_clk", NULL), |
| 35 | }; |
| 36 | |
| 37 | static struct regulator_init_data ldo0_data = { |
| 38 | .constraints = { |
Thierry Reding | 1dbe1df | 2012-02-20 08:57:27 +0100 | [diff] [blame] | 39 | .min_uV = 3300 * 1000, |
Mike Rapoport | 6f168f2 | 2011-03-09 16:31:18 +0200 | [diff] [blame] | 40 | .max_uV = 3300 * 1000, |
| 41 | .valid_modes_mask = (REGULATOR_MODE_NORMAL | |
| 42 | REGULATOR_MODE_STANDBY), |
| 43 | .valid_ops_mask = (REGULATOR_CHANGE_MODE | |
| 44 | REGULATOR_CHANGE_STATUS | |
| 45 | REGULATOR_CHANGE_VOLTAGE), |
Thierry Reding | 1dbe1df | 2012-02-20 08:57:27 +0100 | [diff] [blame] | 46 | .apply_uV = 1, |
Mike Rapoport | 6f168f2 | 2011-03-09 16:31:18 +0200 | [diff] [blame] | 47 | }, |
| 48 | .num_consumer_supplies = ARRAY_SIZE(tps658621_ldo0_supply), |
| 49 | .consumer_supplies = tps658621_ldo0_supply, |
| 50 | }; |
| 51 | |
| 52 | #define HARMONY_REGULATOR_INIT(_id, _minmv, _maxmv) \ |
| 53 | static struct regulator_init_data _id##_data = { \ |
| 54 | .constraints = { \ |
| 55 | .min_uV = (_minmv)*1000, \ |
| 56 | .max_uV = (_maxmv)*1000, \ |
| 57 | .valid_modes_mask = (REGULATOR_MODE_NORMAL | \ |
| 58 | REGULATOR_MODE_STANDBY), \ |
| 59 | .valid_ops_mask = (REGULATOR_CHANGE_MODE | \ |
| 60 | REGULATOR_CHANGE_STATUS | \ |
| 61 | REGULATOR_CHANGE_VOLTAGE), \ |
| 62 | }, \ |
| 63 | } |
| 64 | |
| 65 | HARMONY_REGULATOR_INIT(sm0, 725, 1500); |
| 66 | HARMONY_REGULATOR_INIT(sm1, 725, 1500); |
| 67 | HARMONY_REGULATOR_INIT(sm2, 3000, 4550); |
| 68 | HARMONY_REGULATOR_INIT(ldo1, 725, 1500); |
| 69 | HARMONY_REGULATOR_INIT(ldo2, 725, 1500); |
| 70 | HARMONY_REGULATOR_INIT(ldo3, 1250, 3300); |
| 71 | HARMONY_REGULATOR_INIT(ldo4, 1700, 2475); |
| 72 | HARMONY_REGULATOR_INIT(ldo5, 1250, 3300); |
| 73 | HARMONY_REGULATOR_INIT(ldo6, 1250, 3300); |
| 74 | HARMONY_REGULATOR_INIT(ldo7, 1250, 3300); |
| 75 | HARMONY_REGULATOR_INIT(ldo8, 1250, 3300); |
| 76 | HARMONY_REGULATOR_INIT(ldo9, 1250, 3300); |
| 77 | |
| 78 | #define TPS_REG(_id, _data) \ |
| 79 | { \ |
| 80 | .id = TPS6586X_ID_##_id, \ |
| 81 | .name = "tps6586x-regulator", \ |
| 82 | .platform_data = _data, \ |
| 83 | } |
| 84 | |
| 85 | static struct tps6586x_subdev_info tps_devs[] = { |
| 86 | TPS_REG(SM_0, &sm0_data), |
| 87 | TPS_REG(SM_1, &sm1_data), |
| 88 | TPS_REG(SM_2, &sm2_data), |
| 89 | TPS_REG(LDO_0, &ldo0_data), |
| 90 | TPS_REG(LDO_1, &ldo1_data), |
| 91 | TPS_REG(LDO_2, &ldo2_data), |
| 92 | TPS_REG(LDO_3, &ldo3_data), |
| 93 | TPS_REG(LDO_4, &ldo4_data), |
| 94 | TPS_REG(LDO_5, &ldo5_data), |
| 95 | TPS_REG(LDO_6, &ldo6_data), |
| 96 | TPS_REG(LDO_7, &ldo7_data), |
| 97 | TPS_REG(LDO_8, &ldo8_data), |
| 98 | TPS_REG(LDO_9, &ldo9_data), |
| 99 | }; |
| 100 | |
| 101 | static struct tps6586x_platform_data tps_platform = { |
| 102 | .irq_base = TEGRA_NR_IRQS, |
| 103 | .num_subdevs = ARRAY_SIZE(tps_devs), |
| 104 | .subdevs = tps_devs, |
Stephen Warren | f2a4d8a | 2011-05-31 15:14:07 -0600 | [diff] [blame] | 105 | .gpio_base = HARMONY_GPIO_TPS6586X(0), |
Mike Rapoport | 6f168f2 | 2011-03-09 16:31:18 +0200 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | static struct i2c_board_info __initdata harmony_regulators[] = { |
| 109 | { |
| 110 | I2C_BOARD_INFO("tps6586x", 0x34), |
| 111 | .irq = INT_EXTERNAL_PMU, |
| 112 | .platform_data = &tps_platform, |
| 113 | }, |
| 114 | }; |
| 115 | |
| 116 | int __init harmony_regulator_init(void) |
| 117 | { |
Stephen Warren | 9eb4b91 | 2011-09-21 16:10:40 -0600 | [diff] [blame] | 118 | void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); |
| 119 | u32 pmc_ctrl; |
| 120 | |
| 121 | /* |
| 122 | * Configure the power management controller to trigger PMU |
| 123 | * interrupts when low |
| 124 | */ |
| 125 | pmc_ctrl = readl(pmc + PMC_CTRL); |
| 126 | writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL); |
| 127 | |
Mike Rapoport | 6f168f2 | 2011-03-09 16:31:18 +0200 | [diff] [blame] | 128 | i2c_register_board_info(3, harmony_regulators, 1); |
| 129 | |
| 130 | return 0; |
| 131 | } |