Michael Bohan | 037a0f5 | 2012-02-29 19:13:09 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 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 and |
| 6 | * only version 2 as 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 | |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/regulator/stub-regulator.h> |
| 16 | |
| 17 | #define VREG_CONSUMERS(_name) \ |
| 18 | static struct regulator_consumer_supply vreg_consumers_##_name[] |
| 19 | |
| 20 | /* |
| 21 | * Consumer specific regulator names: |
| 22 | * regulator name consumer dev_name |
| 23 | */ |
Michael Bohan | 518a7d3 | 2012-03-20 15:43:35 -0700 | [diff] [blame] | 24 | VREG_CONSUMERS(K0) = { |
| 25 | REGULATOR_SUPPLY("krait0", NULL), |
| 26 | }; |
| 27 | VREG_CONSUMERS(K1) = { |
| 28 | REGULATOR_SUPPLY("krait1", NULL), |
| 29 | }; |
| 30 | VREG_CONSUMERS(K2) = { |
| 31 | REGULATOR_SUPPLY("krait2", NULL), |
| 32 | }; |
| 33 | VREG_CONSUMERS(K3) = { |
| 34 | REGULATOR_SUPPLY("krait3", NULL), |
| 35 | }; |
Michael Bohan | 037a0f5 | 2012-02-29 19:13:09 -0800 | [diff] [blame] | 36 | |
| 37 | #define PM8X41_VREG_INIT(_id, _name, _min_uV, _max_uV, _modes, _ops, \ |
| 38 | _always_on, _supply_regulator, _hpm_min, _system_uA) \ |
| 39 | struct stub_regulator_pdata vreg_dev_##_id##_pdata __devinitdata = { \ |
| 40 | .init_data = { \ |
| 41 | .constraints = { \ |
| 42 | .valid_modes_mask = _modes, \ |
| 43 | .valid_ops_mask = _ops, \ |
| 44 | .min_uV = _min_uV, \ |
| 45 | .max_uV = _max_uV, \ |
| 46 | .input_uV = _max_uV, \ |
| 47 | .apply_uV = 0, \ |
| 48 | .always_on = _always_on, \ |
| 49 | .name = _name, \ |
| 50 | }, \ |
| 51 | .num_consumer_supplies = \ |
| 52 | ARRAY_SIZE(vreg_consumers_##_id), \ |
| 53 | .consumer_supplies = vreg_consumers_##_id, \ |
| 54 | .supply_regulator = _supply_regulator, \ |
| 55 | }, \ |
| 56 | .hpm_min_load = _hpm_min, \ |
| 57 | .system_uA = _system_uA, \ |
| 58 | } |
| 59 | |
Michael Bohan | 518a7d3 | 2012-03-20 15:43:35 -0700 | [diff] [blame] | 60 | #define KRAIT_PWR(_id, _name, _always_on, _min_uV, _max_uV, \ |
| 61 | _supply_regulator, _hpm_min, _system_uA) \ |
| 62 | PM8X41_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \ |
| 63 | | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \ |
| 64 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \ |
| 65 | REGULATOR_CHANGE_DRMS, _always_on, \ |
| 66 | _supply_regulator, _hpm_min, _system_uA) |
| 67 | |
Michael Bohan | 518a7d3 | 2012-03-20 15:43:35 -0700 | [diff] [blame] | 68 | /* ID name a_on min_uV max_uV supply hpm_min sys_uA */ |
| 69 | KRAIT_PWR(K0, "krait0", 0, 850000, 1100000, NULL, 100000, 0); |
| 70 | KRAIT_PWR(K1, "krait1", 0, 850000, 1100000, NULL, 100000, 0); |
| 71 | KRAIT_PWR(K2, "krait2", 0, 850000, 1100000, NULL, 100000, 0); |
| 72 | KRAIT_PWR(K3, "krait3", 0, 850000, 1100000, NULL, 100000, 0); |
| 73 | |
Michael Bohan | 037a0f5 | 2012-02-29 19:13:09 -0800 | [diff] [blame] | 74 | #define VREG_DEVICE(_name, _devid) \ |
| 75 | vreg_device_##_name __devinitdata = \ |
| 76 | { \ |
| 77 | .name = STUB_REGULATOR_DRIVER_NAME, \ |
| 78 | .id = _devid, \ |
| 79 | .dev = { .platform_data = &vreg_dev_##_name##_pdata }, \ |
| 80 | } |
| 81 | |
Michael Bohan | 2668fb0 | 2012-03-27 16:01:42 -0700 | [diff] [blame] | 82 | static struct platform_device VREG_DEVICE(K0, 0); |
| 83 | static struct platform_device VREG_DEVICE(K1, 1); |
| 84 | static struct platform_device VREG_DEVICE(K2, 2); |
| 85 | static struct platform_device VREG_DEVICE(K3, 3); |
Michael Bohan | 037a0f5 | 2012-02-29 19:13:09 -0800 | [diff] [blame] | 86 | |
| 87 | struct platform_device *msm_copper_stub_regulator_devices[] __devinitdata = { |
Michael Bohan | 518a7d3 | 2012-03-20 15:43:35 -0700 | [diff] [blame] | 88 | &vreg_device_K0, |
| 89 | &vreg_device_K1, |
| 90 | &vreg_device_K2, |
| 91 | &vreg_device_K3, |
Michael Bohan | 037a0f5 | 2012-02-29 19:13:09 -0800 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | int msm_copper_stub_regulator_devices_len __devinitdata = |
| 95 | ARRAY_SIZE(msm_copper_stub_regulator_devices); |