22
22
#include <linux/platform_device.h>
23
23
#include <linux/resource.h>
24
24
#include <linux/regulator/machine.h>
25
- #include <linux/regulator/gpio-switch-regulator .h>
25
+ #include <linux/regulator/fixed .h>
26
26
#include <linux/mfd/tps80031.h>
27
27
#include <linux/regulator/tps80031-regulator.h>
28
28
#include <linux/tps80031-charger.h>
49
49
#define PMC_DPD_PADS_ORIDE 0x01c
50
50
#define PMC_DPD_PADS_ORIDE_BLINK (1 << 20)
51
51
52
+ static bool is_enterprise_machine = false;
53
+
52
54
/************************ TPS80031 based regulator ****************/
53
55
static struct regulator_consumer_supply tps80031_vio_supply [] = {
54
56
REGULATOR_SUPPLY ("vio_1v8" , NULL ),
@@ -329,43 +331,37 @@ static struct i2c_board_info __initdata enterprise_regulators[] = {
329
331
},
330
332
};
331
333
332
- /************************ GPIO based switch regulator ****************/
333
-
334
+ /************************ GPIO based fixed regulator ****************/
334
335
/* 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 [] = {
336
337
REGULATOR_SUPPLY ("vdd_5v15" , NULL ),
337
338
};
338
- static int gpio_switch_pmu_5v15_en_voltages [] = {5000 };
339
339
340
340
/* 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 [] = {
342
342
REGULATOR_SUPPLY ("avdd_usb_hdmi_3v3" , NULL ),
343
343
REGULATOR_SUPPLY ("avdd_usb" , NULL ),
344
344
REGULATOR_SUPPLY ("avdd_hdmi" , NULL ),
345
345
REGULATOR_SUPPLY ("vdd" , "4-004c" ),
346
346
};
347
- static int gpio_switch_pmu_3v3_en_voltages [] = {3300 };
348
347
349
348
/* 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 [] = {
351
350
REGULATOR_SUPPLY ("hdmi_5v0" , NULL ),
352
351
};
353
- static int gpio_switch_pmu_hdmi_5v0_en_voltages [] = {5000 };
354
352
355
353
/* 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 [] = {
357
355
REGULATOR_SUPPLY ("vdd_fuse" , NULL ),
358
356
};
359
- static int gpio_switch_vdd_fuse_en_voltages [] = {3300 };
360
357
361
358
/* 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 [] = {
363
360
REGULATOR_SUPPLY ("vddio_sdmmc3_2v85_1v8" , NULL ),
364
361
REGULATOR_SUPPLY ("sdmmc3_compu_pu" , NULL ),
365
362
REGULATOR_SUPPLY ("vddio_sdmmc3" , NULL ),
366
363
REGULATOR_SUPPLY ("vsys_3v7" , NULL ),
367
364
};
368
- static int gpio_switch_sdmmc3_vdd_sel_voltages [] = {2850 };
369
365
370
366
/* LCD-D23 (GPIO M7) from T30*/
371
367
/* 2-0036 is dev_name of ar0832 in Enterprise A01*/
@@ -374,7 +370,7 @@ static int gpio_switch_sdmmc3_vdd_sel_voltages[] = {2850};
374
370
/* 2-0070 is dev_name of PCA9546 in Enterprise A02*/
375
371
/* 6-0036 is dev_name of ar0832 in Enterprise A02 */
376
372
/* 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 [] = {
378
374
REGULATOR_SUPPLY ("vaa" , "2-0036" ),
379
375
REGULATOR_SUPPLY ("vaa" , "2-0032" ),
380
376
REGULATOR_SUPPLY ("avdd" , "2-0010" ),
@@ -383,7 +379,6 @@ static struct regulator_consumer_supply gpio_switch_cam_ldo_2v8_en_supply[] = {
383
379
REGULATOR_SUPPLY ("vaa" , "6-0036" ),
384
380
REGULATOR_SUPPLY ("vaa" , "7-0036" ),
385
381
};
386
- static int gpio_switch_cam_ldo_2v8_en_voltages [] = {2800 };
387
382
388
383
/* LCD-D9 (GPIO F1) from T30*/
389
384
/* 2-0036 is dev_name of ar0832 in Enterprise A01*/
@@ -393,7 +388,7 @@ static int gpio_switch_cam_ldo_2v8_en_voltages[] = {2800};
393
388
/* 2-0070 is dev_name of PCA9546 in Enterprise A02*/
394
389
/* 6-0036 is dev_name of ar0832 in Enterprise A02 */
395
390
/* 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 [] = {
397
392
REGULATOR_SUPPLY ("vdd" , "2-0036" ),
398
393
REGULATOR_SUPPLY ("vdd" , "2-0032" ),
399
394
REGULATOR_SUPPLY ("dovdd" , "2-0010" ),
@@ -403,80 +398,83 @@ static struct regulator_consumer_supply gpio_switch_cam_ldo_1v8_en_supply[] = {
403
398
REGULATOR_SUPPLY ("vdd" , "6-0036" ),
404
399
REGULATOR_SUPPLY ("vdd" , "7-0036" ),
405
400
};
406
- static int gpio_switch_cam_ldo_1v8_en_voltages [] = {1800 };
407
401
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 = \
412
406
{ \
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, \
422
408
.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, \
425
411
.constraints = { \
426
412
.valid_modes_mask = (REGULATOR_MODE_NORMAL | \
427
413
REGULATOR_MODE_STANDBY), \
428
414
.valid_ops_mask = (REGULATOR_CHANGE_MODE | \
429
415
REGULATOR_CHANGE_STATUS | \
430
416
REGULATOR_CHANGE_VOLTAGE), \
431
417
}, \
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
+ }, \
434
434
}
435
435
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 )
470
463
{
471
464
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 );
477
473
}
478
- return platform_device_register (& gswitch_regulator_pdata );
474
+ return platform_add_devices (fixed_regs_devices ,
475
+ ARRAY_SIZE (fixed_regs_devices ));
479
476
}
477
+ subsys_initcall_sync (enterprise_fixed_regulator_init );
480
478
481
479
static void enterprise_power_off (void )
482
480
{
@@ -516,8 +514,8 @@ int __init enterprise_regulator_init(void)
516
514
}
517
515
518
516
i2c_register_board_info (4 , enterprise_regulators , 1 );
519
- enterprise_gpio_switch_regulator_init ();
520
517
pm_power_off = enterprise_power_off ;
518
+ is_enterprise_machine = true;
521
519
522
520
return 0 ;
523
521
}
0 commit comments