Skip to content

Commit 4b793fa

Browse files
ldewanganRohan Somvanshi
authored andcommitted
arm: tegra: enterprise: Use fixed regulator
Using fixed regulator in place of gpio-switch regulator Fixed regulator is very similar to gpio-switch regulator and it is available by default in linux kernel. bug 923713 Signed-off-by: Laxman Dewangan <[email protected]> Change-Id: Ib51874e4ba90750234d8c80735e9230669a0dee8 Reviewed-on: http://git-master/r/74249 Reviewed-by: Simone Willett <[email protected]> Tested-by: Simone Willett <[email protected]> Reviewed-on: http://git-master/r/75545 Reviewed-by: Rohan Somvanshi <[email protected]> Tested-by: Rohan Somvanshi <[email protected]>
1 parent 0ed0002 commit 4b793fa

File tree

1 file changed

+73
-75
lines changed

1 file changed

+73
-75
lines changed

arch/arm/mach-tegra/board-enterprise-power.c

Lines changed: 73 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <linux/platform_device.h>
2323
#include <linux/resource.h>
2424
#include <linux/regulator/machine.h>
25-
#include <linux/regulator/gpio-switch-regulator.h>
25+
#include <linux/regulator/fixed.h>
2626
#include <linux/mfd/tps80031.h>
2727
#include <linux/regulator/tps80031-regulator.h>
2828
#include <linux/tps80031-charger.h>
@@ -49,6 +49,8 @@
4949
#define PMC_DPD_PADS_ORIDE 0x01c
5050
#define PMC_DPD_PADS_ORIDE_BLINK (1 << 20)
5151

52+
static bool is_enterprise_machine = false;
53+
5254
/************************ TPS80031 based regulator ****************/
5355
static struct regulator_consumer_supply tps80031_vio_supply[] = {
5456
REGULATOR_SUPPLY("vio_1v8", NULL),
@@ -329,43 +331,37 @@ static struct i2c_board_info __initdata enterprise_regulators[] = {
329331
},
330332
};
331333

332-
/************************ GPIO based switch regulator ****************/
333-
334+
/************************ GPIO based fixed regulator ****************/
334335
/* REGEN1 from PMU*/
335-
static struct regulator_consumer_supply gpio_switch_pmu_5v15_en_supply[] = {
336+
static struct regulator_consumer_supply fixed_reg_pmu_5v15_en_supply[] = {
336337
REGULATOR_SUPPLY("vdd_5v15", NULL),
337338
};
338-
static int gpio_switch_pmu_5v15_en_voltages[] = {5000};
339339

340340
/* REGEN2 from PMU*/
341-
static struct regulator_consumer_supply gpio_switch_pmu_3v3_en_supply[] = {
341+
static struct regulator_consumer_supply fixed_reg_pmu_3v3_en_supply[] = {
342342
REGULATOR_SUPPLY("avdd_usb_hdmi_3v3", NULL),
343343
REGULATOR_SUPPLY("avdd_usb", NULL),
344344
REGULATOR_SUPPLY("avdd_hdmi", NULL),
345345
REGULATOR_SUPPLY("vdd", "4-004c"),
346346
};
347-
static int gpio_switch_pmu_3v3_en_voltages[] = {3300};
348347

349348
/* SYSEN from PMU*/
350-
static struct regulator_consumer_supply gpio_switch_pmu_hdmi_5v0_en_supply[] = {
349+
static struct regulator_consumer_supply fixed_reg_pmu_hdmi_5v0_en_supply[] = {
351350
REGULATOR_SUPPLY("hdmi_5v0", NULL),
352351
};
353-
static int gpio_switch_pmu_hdmi_5v0_en_voltages[] = {5000};
354352

355353
/* LCD-D16 (GPIO M0) from T30*/
356-
static struct regulator_consumer_supply gpio_switch_vdd_fuse_en_supply[] = {
354+
static struct regulator_consumer_supply fixed_reg_vdd_fuse_en_supply[] = {
357355
REGULATOR_SUPPLY("vdd_fuse", NULL),
358356
};
359-
static int gpio_switch_vdd_fuse_en_voltages[] = {3300};
360357

361358
/* LCD-D17 (GPIO M1) from T30*/
362-
static struct regulator_consumer_supply gpio_switch_sdmmc3_vdd_sel_supply[] = {
359+
static struct regulator_consumer_supply fixed_reg_sdmmc3_vdd_sel_supply[] = {
363360
REGULATOR_SUPPLY("vddio_sdmmc3_2v85_1v8", NULL),
364361
REGULATOR_SUPPLY("sdmmc3_compu_pu", NULL),
365362
REGULATOR_SUPPLY("vddio_sdmmc3", NULL),
366363
REGULATOR_SUPPLY("vsys_3v7", NULL),
367364
};
368-
static int gpio_switch_sdmmc3_vdd_sel_voltages[] = {2850};
369365

370366
/* LCD-D23 (GPIO M7) from T30*/
371367
/* 2-0036 is dev_name of ar0832 in Enterprise A01*/
@@ -374,7 +370,7 @@ static int gpio_switch_sdmmc3_vdd_sel_voltages[] = {2850};
374370
/* 2-0070 is dev_name of PCA9546 in Enterprise A02*/
375371
/* 6-0036 is dev_name of ar0832 in Enterprise A02 */
376372
/* 7-0036 is dev_name of ar0832 in Enterprise A02 */
377-
static struct regulator_consumer_supply gpio_switch_cam_ldo_2v8_en_supply[] = {
373+
static struct regulator_consumer_supply fixed_reg_cam_ldo_2v8_en_supply[] = {
378374
REGULATOR_SUPPLY("vaa", "2-0036"),
379375
REGULATOR_SUPPLY("vaa", "2-0032"),
380376
REGULATOR_SUPPLY("avdd", "2-0010"),
@@ -383,7 +379,6 @@ static struct regulator_consumer_supply gpio_switch_cam_ldo_2v8_en_supply[] = {
383379
REGULATOR_SUPPLY("vaa", "6-0036"),
384380
REGULATOR_SUPPLY("vaa", "7-0036"),
385381
};
386-
static int gpio_switch_cam_ldo_2v8_en_voltages[] = {2800};
387382

388383
/* LCD-D9 (GPIO F1) from T30*/
389384
/* 2-0036 is dev_name of ar0832 in Enterprise A01*/
@@ -393,7 +388,7 @@ static int gpio_switch_cam_ldo_2v8_en_voltages[] = {2800};
393388
/* 2-0070 is dev_name of PCA9546 in Enterprise A02*/
394389
/* 6-0036 is dev_name of ar0832 in Enterprise A02 */
395390
/* 7-0036 is dev_name of ar0832 in Enterprise A02 */
396-
static struct regulator_consumer_supply gpio_switch_cam_ldo_1v8_en_supply[] = {
391+
static struct regulator_consumer_supply fixed_reg_cam_ldo_1v8_en_supply[] = {
397392
REGULATOR_SUPPLY("vdd", "2-0036"),
398393
REGULATOR_SUPPLY("vdd", "2-0032"),
399394
REGULATOR_SUPPLY("dovdd", "2-0010"),
@@ -403,80 +398,83 @@ static struct regulator_consumer_supply gpio_switch_cam_ldo_1v8_en_supply[] = {
403398
REGULATOR_SUPPLY("vdd", "6-0036"),
404399
REGULATOR_SUPPLY("vdd", "7-0036"),
405400
};
406-
static int gpio_switch_cam_ldo_1v8_en_voltages[] = {1800};
407401

408-
/* Macro for defining gpio switch regulator sub device data */
409-
#define GREG_INIT(_id, _name, _input_supply, _gpio_nr, _active_low, \
410-
_init_state, _pg, _enable, _disable) \
411-
static struct gpio_switch_regulator_subdev_data gpio_pdata_##_name = \
402+
/* Macro for defining fixed regulator sub device data */
403+
#define FIXED_REG(_id, _name, _input_supply, _gpio_nr, _active_high, \
404+
_millivolts, _boot_state) \
405+
static struct regulator_init_data ri_data_##_name = \
412406
{ \
413-
.regulator_name = "gpio-switch-"#_name, \
414-
.input_supply = _input_supply, \
415-
.id = _id, \
416-
.gpio_nr = _gpio_nr, \
417-
.pin_group = _pg, \
418-
.active_low = _active_low, \
419-
.init_state = _init_state, \
420-
.voltages = gpio_switch_##_name##_voltages, \
421-
.n_voltages = ARRAY_SIZE(gpio_switch_##_name##_voltages), \
407+
.supply_regulator = _input_supply, \
422408
.num_consumer_supplies = \
423-
ARRAY_SIZE(gpio_switch_##_name##_supply), \
424-
.consumer_supplies = gpio_switch_##_name##_supply, \
409+
ARRAY_SIZE(fixed_reg_##_name##_supply), \
410+
.consumer_supplies = fixed_reg_##_name##_supply, \
425411
.constraints = { \
426412
.valid_modes_mask = (REGULATOR_MODE_NORMAL | \
427413
REGULATOR_MODE_STANDBY), \
428414
.valid_ops_mask = (REGULATOR_CHANGE_MODE | \
429415
REGULATOR_CHANGE_STATUS | \
430416
REGULATOR_CHANGE_VOLTAGE), \
431417
}, \
432-
.enable_rail = _enable, \
433-
.disable_rail = _disable, \
418+
}; \
419+
static struct fixed_voltage_config fixed_reg_##_name##_pdata = \
420+
{ \
421+
.supply_name = "fixed_reg_"#_name, \
422+
.microvolts = _millivolts * 1000, \
423+
.gpio = _gpio_nr, \
424+
.enable_high = _active_high, \
425+
.enabled_at_boot = _boot_state, \
426+
.init_data = &ri_data_##_name, \
427+
}; \
428+
static struct platform_device fixed_reg_##_name##_dev = { \
429+
.name = "reg-fixed-voltage", \
430+
.id = _id, \
431+
.dev = { \
432+
.platform_data = &fixed_reg_##_name##_pdata, \
433+
}, \
434434
}
435435

436-
GREG_INIT(0, pmu_5v15_en, NULL, ENT_TPS80031_GPIO_REGEN1, false, 0, 0, 0, 0);
437-
GREG_INIT(1, pmu_3v3_en, "vdd_5v15", ENT_TPS80031_GPIO_REGEN2, false, 0, 0, 0, 0);
438-
GREG_INIT(2, pmu_hdmi_5v0_en, "vdd_5v15", ENT_TPS80031_GPIO_SYSEN, false, 0, 0, 0, 0);
439-
440-
GREG_INIT(3, vdd_fuse_en, "avdd_usb_hdmi_3v3", TEGRA_GPIO_PM0, false, 0, 0, 0, 0);
441-
GREG_INIT(4, sdmmc3_vdd_sel, "vddio_sdmmc_2v85", TEGRA_GPIO_PM1, false, 0, 0, 0, 0);
442-
GREG_INIT(5, cam_ldo_2v8_en, NULL, TEGRA_GPIO_PM7, false, 0, 0, 0, 0);
443-
GREG_INIT(6, cam_ldo_1v8_en, NULL, TEGRA_GPIO_PF1, false, 0, 0, 0, 0);
444-
445-
#define ADD_GPIO_REG(_name) (&gpio_pdata_##_name)
446-
static struct gpio_switch_regulator_subdev_data *gswitch_subdevs[] = {
447-
ADD_GPIO_REG(pmu_5v15_en),
448-
ADD_GPIO_REG(pmu_3v3_en),
449-
ADD_GPIO_REG(pmu_hdmi_5v0_en),
450-
ADD_GPIO_REG(vdd_fuse_en),
451-
ADD_GPIO_REG(sdmmc3_vdd_sel),
452-
ADD_GPIO_REG(cam_ldo_2v8_en),
453-
ADD_GPIO_REG(cam_ldo_1v8_en),
454-
};
455-
456-
static struct gpio_switch_regulator_platform_data gswitch_pdata = {
457-
.num_subdevs = ARRAY_SIZE(gswitch_subdevs),
458-
.subdevs = gswitch_subdevs,
459-
};
460-
461-
static struct platform_device gswitch_regulator_pdata = {
462-
.name = "gpio-switch-regulator",
463-
.id = -1,
464-
.dev = {
465-
.platform_data = &gswitch_pdata,
466-
},
467-
};
468-
469-
static int __init enterprise_gpio_switch_regulator_init(void)
436+
FIXED_REG(0, pmu_5v15_en, NULL,
437+
ENT_TPS80031_GPIO_REGEN1, true, 5000, 0 );
438+
FIXED_REG(1, pmu_3v3_en, "fixed_reg_pmu_5v15_en",
439+
ENT_TPS80031_GPIO_REGEN2, true, 3300, 0);
440+
FIXED_REG(2, pmu_hdmi_5v0_en, "fixed_reg_pmu_5v15_en",
441+
ENT_TPS80031_GPIO_SYSEN, true, 5000, 0);
442+
FIXED_REG(3, vdd_fuse_en, "fixed_reg_pmu_3v3_en",
443+
TEGRA_GPIO_PM0, true, 3300, 0);
444+
FIXED_REG(4, sdmmc3_vdd_sel, tps80031_rails(SMPS4),
445+
TEGRA_GPIO_PM1, true, 2850, 0);
446+
FIXED_REG(5, cam_ldo_2v8_en, NULL,
447+
TEGRA_GPIO_PM7, true, 2800, 0);
448+
FIXED_REG(6, cam_ldo_1v8_en, NULL,
449+
TEGRA_GPIO_PF1, true, 1800, 0);
450+
451+
#define ADD_FIXED_REG(_name) (&fixed_reg_##_name##_dev)
452+
static struct platform_device *fixed_regs_devices[] = {
453+
ADD_FIXED_REG(pmu_5v15_en),
454+
ADD_FIXED_REG(pmu_3v3_en),
455+
ADD_FIXED_REG(pmu_hdmi_5v0_en),
456+
ADD_FIXED_REG(vdd_fuse_en),
457+
ADD_FIXED_REG(sdmmc3_vdd_sel),
458+
ADD_FIXED_REG(cam_ldo_2v8_en),
459+
ADD_FIXED_REG(cam_ldo_1v8_en),
460+
};
461+
462+
static int __init enterprise_fixed_regulator_init(void)
470463
{
471464
int i;
472-
for (i = 0; i < gswitch_pdata.num_subdevs; ++i) {
473-
struct gpio_switch_regulator_subdev_data *gswitch_data =
474-
gswitch_pdata.subdevs[i];
475-
if (gswitch_data->gpio_nr <= TEGRA_NR_GPIOS)
476-
tegra_gpio_enable(gswitch_data->gpio_nr);
465+
if (!is_enterprise_machine)
466+
return 0;
467+
468+
for (i = 0; i < ARRAY_SIZE(fixed_regs_devices); ++i) {
469+
struct fixed_voltage_config *fixed_reg_pdata =
470+
fixed_regs_devices[i]->dev.platform_data;
471+
if (fixed_reg_pdata->gpio < TEGRA_NR_GPIOS)
472+
tegra_gpio_enable(fixed_reg_pdata->gpio);
477473
}
478-
return platform_device_register(&gswitch_regulator_pdata);
474+
return platform_add_devices(fixed_regs_devices,
475+
ARRAY_SIZE(fixed_regs_devices));
479476
}
477+
subsys_initcall_sync(enterprise_fixed_regulator_init);
480478

481479
static void enterprise_power_off(void)
482480
{
@@ -516,8 +514,8 @@ int __init enterprise_regulator_init(void)
516514
}
517515

518516
i2c_register_board_info(4, enterprise_regulators, 1);
519-
enterprise_gpio_switch_regulator_init();
520517
pm_power_off = enterprise_power_off;
518+
is_enterprise_machine = true;
521519

522520
return 0;
523521
}

0 commit comments

Comments
 (0)