1 #include <linux/regulator/machine.h>
2 #include <linux/i2c/twl.h>
6 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
7 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
9 #define CRU_CLKGATE5_CON_ADDR 0x00e4
10 #define GRF_GPIO6L_DIR_ADDR 0x0030
11 #define GRF_GPIO6L_DO_ADDR 0x0068
12 #define GRF_GPIO6L_EN_ADDR 0x00a0
13 #define GPIO6_PB3_DIR_OUT 0x08000800
14 #define GPIO6_PB3_DO_LOW 0x08000000
15 #define GPIO6_PB3_DO_HIGH 0x08000800
16 #define GPIO6_PB3_EN_MASK 0x08000800
17 #define GPIO6_PB3_UNEN_MASK 0x08000000
18 #define GPIO6_PB1_DIR_OUT 0x02000200
19 #define GPIO6_PB1_DO_LOW 0x02000000
20 #define GPIO6_PB1_DO_HIGH 0x02000200
21 #define GPIO6_PB1_EN_MASK 0x02000200
22 #define GPIO6_PB1_UNEN_MASK 0x02000000
24 #define TWL60xx_IRQ_BASE IRQ_BOARD_BASE
25 #ifdef CONFIG_TWL4030_CORE
26 #define TWL60xx_BASE_NR_IRQS 24
28 #define TWL60xx_BASE_NR_IRQS 0
30 #define TWL60xx_IRQ_END (TWL60xx_IRQ_BASE + TWL60xx_BASE_NR_IRQS)
32 #ifdef CONFIG_TWL4030_CORE
34 static inline int twl_reg_read(unsigned base, unsigned slave_subgp)
38 status = twl_i2c_read_u8(slave_subgp,&value, base);
39 return (status < 0) ? status : value;
43 static inline int twl_reg_write(unsigned base, unsigned slave_subgp,
46 return twl_i2c_write_u8(slave_subgp,value, base);
49 #define PMU_POWER_SLEEP RK30_PIN6_PB3
50 #define PMU_CHRG_DET_N RK30_PIN0_PC7
51 int tps80032_pre_init(void){
53 printk("%s\n", __func__);
55 gpio_request(PMU_POWER_SLEEP, "NULL");
56 gpio_direction_output(PMU_POWER_SLEEP, GPIO_LOW);
58 gpio_request(PMU_CHRG_DET_N, "NULL");
59 gpio_direction_output(PMU_CHRG_DET_N, GPIO_HIGH);
61 twl_reg_write(0x0e,TWL_MODULE_PM_MASTER,0x5f);
62 twl_reg_write(PREQ1_RES_ASS_A,TWL_MODULE_PM_SLAVE_RES,0x2b);
63 twl_reg_write(PREQ1_RES_ASS_B,TWL_MODULE_PM_SLAVE_RES,0x50);
64 twl_reg_write(PREQ1_RES_ASS_C,TWL_MODULE_PM_SLAVE_RES,0x27);
65 twl_reg_write(PHOENIX_MSK_TRANSITION,TWL_MODULE_PM_MASTER,0x00);
66 twl_reg_write(PHOENIX_SENS_TRANSITION,TWL_MODULE_PM_MASTER,0xc0); //set pmu enter sleep on a preq1 rising edge
68 twl_reg_write(SMPS1_CFG_STATE,TWL_MODULE_PM_RECEIVER,0x01); //set state
69 twl_reg_write(SMPS2_CFG_STATE,TWL_MODULE_PM_RECEIVER,0x01);
70 twl_reg_write(LDO7_CFG_STATE,TWL_MODULE_PM_RECEIVER,0x01);
72 twl_reg_write(CLK32KG_CFG_STATE,TWL_MODULE_PM_SLAVE_RES,0x01); //set clk32kg on when we use
73 twl_reg_write(CLK32KAUDIO_CFG_STATE,TWL_MODULE_PM_SLAVE_RES,0x01); //set clk32kaudio on when we use
75 twl_reg_write(CHARGERUSB_CTRLLIMIT2,TWL6030_MODULE_CHARGER, 0x0f);
76 twl_reg_write(CHARGERUSB_CTRLLIMIT2,TWL6030_MODULE_CHARGER, 0x1f);
78 twl_reg_write(0x05,TWL_MODULE_PM_MASTER,0x1d); //set vlow wakeup voltage 3.45v
80 twl_reg_write(LDO5_CFG_TRANS,TWL_MODULE_PM_RECEIVER,0x03); //set ldo5 is disabled when in sleep mode
81 twl_reg_write(LDO7_CFG_TRANS,TWL_MODULE_PM_RECEIVER,0x03); //set ldo7 is disabled when in sleep mode
82 twl_reg_write(LDOUSB_CFG_TRANS,TWL_MODULE_PM_RECEIVER,0x03);
86 int tps80032_set_init(void)
88 struct regulator *dcdc;
89 struct regulator *ldo;
90 printk("%s\n", __func__);
92 ldo = regulator_get(NULL, "ldo1"); //vcca_33
93 regulator_set_voltage(ldo, 3300000, 3300000);
94 regulator_enable(ldo);
95 // printk("%s set ldo1 vcca_33=%dmV end\n", __func__, regulator_get_voltage(ldo));
99 ldo = regulator_get(NULL, "ldo4"); // vdd_11
100 regulator_set_voltage(ldo, 1100000, 1100000);
101 regulator_enable(ldo);
102 // printk("%s set ldo4 vdd_11=%dmV end\n", __func__, regulator_get_voltage(ldo));
106 dcdc = regulator_get(NULL, "vcc_io");
107 regulator_set_voltage(dcdc,3000000,3000000);
108 regulator_enable(dcdc);
109 // printk("%s set dcdc4 vcc_io=%dmV end\n", __func__, regulator_get_voltage(dcdc));
113 ldo = regulator_get(NULL, "ldo2"); // vdd_usb11
114 regulator_set_voltage(ldo, 1100000, 1100000);
115 regulator_enable(ldo);
116 // printk("%s set ldo2 vdd_usb11=%dmV end\n", __func__, regulator_get_voltage(ldo));
120 ldo = regulator_get(NULL, "ldo5"); // vcc_25
121 regulator_set_voltage(ldo, 2500000, 2500000);
122 regulator_enable(ldo);
123 // printk("%s set ldo5 vcc_25=%dmV end\n", __func__, regulator_get_voltage(ldo));
127 ldo = regulator_get(NULL, "ldousb"); // vcc_usb33
128 regulator_set_voltage(ldo, 3300000, 3300000);
129 regulator_enable(ldo);
130 // printk("%s set ldousb vcc_usb33=%dmV end\n", __func__, regulator_get_voltage(ldo));
134 dcdc = regulator_get(NULL, "vdd_cpu"); // vdd_arm
135 regulator_set_voltage(dcdc,1100000,1100000);
136 regulator_enable(dcdc);
137 printk("%s set dcdc1 vdd_cpu=%dmV end\n", __func__, regulator_get_voltage(dcdc));
141 dcdc = regulator_get(NULL, "vdd_core"); //vdd_log
142 regulator_set_voltage(dcdc,1100000,1100000);
143 regulator_enable(dcdc);
144 printk("%s set dcdc2 vdd_core=%dmV end\n", __func__, regulator_get_voltage(dcdc));
148 dcdc = regulator_get(NULL, "vcc_lpddr2_1v8"); //vcc_lpddr2_1v8
149 regulator_set_voltage(dcdc,DC3_VCC_DDR_VOL,DC3_VCC_DDR_VOL);
150 regulator_enable(dcdc);
151 // printk("%s set dcdc3 vcc_lpddr2_1v8=%dmV end\n", __func__, regulator_get_voltage(dcdc));
155 dcdc = regulator_get(NULL, "vcc_lpddr2_1v2"); //vcc_lpddr2_1v2
156 regulator_set_voltage(dcdc,DC5_VCC_DDR_VOL,DC5_VCC_DDR_VOL);
157 regulator_enable(dcdc);
158 // printk("%s set dcdc5 vcc_lpddr2_1v2=%dmV end\n", __func__, regulator_get_voltage(dcdc));
162 ldo = regulator_get(NULL, "ldo3"); //vcc_nandflash
163 regulator_set_voltage(ldo, 3300000, 3300000);
164 regulator_enable(ldo);
165 // printk("%s set ldo3 vcc_nandflash=%dmV end\n", __func__, regulator_get_voltage(ldo));
169 ldo = regulator_get(NULL, "ldo6"); //codecvdd_1v8
170 regulator_set_voltage(ldo, 1800000, 1800000);
171 regulator_enable(ldo);
172 // printk("%s set ldo6 codecvdd_1v8=%dmV end\n", __func__, regulator_get_voltage(ldo));
176 ldo = regulator_get(NULL, "ldo7"); //vcc_lcd
177 regulator_set_voltage(ldo, 3000000, 3000000);
178 regulator_enable(ldo);
179 // printk("%s set ldo7 vcc_lcd=%dmV end\n", __func__, regulator_get_voltage(ldo));
184 ldo = regulator_get(NULL, "ldoln"); //vcccodec_io
185 regulator_set_voltage(ldo, 3300000, 3300000);
186 regulator_enable(ldo);
187 // printk("%s set ldoln vcccodec_io=%dmV end\n", __func__, regulator_get_voltage(ldo));
192 ldo = regulator_get(NULL, "vana"); //vana_out
193 regulator_set_voltage(ldo, 2500000, 2500000);
194 // regulator_set_suspend_voltage(ldo, 2500000);
195 regulator_enable(ldo);
196 printk("%s set vana vana_out=%dmV end\n", __func__, regulator_get_voltage(ldo));
201 printk("tps80032_set_init end.\n");
206 static struct regulator_consumer_supply tps80032_smps1_supply[] = {
214 static struct regulator_consumer_supply tps80032_smps2_supply[] = {
219 .supply = "vdd_core",
222 static struct regulator_consumer_supply tps80032_smps3_supply[] = {
227 .supply = "vcc_lpddr2_1v8",
230 .supply = "vcc_ddr3",
233 static struct regulator_consumer_supply tps80032_smps4_supply[] = {
241 static struct regulator_consumer_supply tps80032_smps5_supply[] = {
246 .supply = "vcc_lpddr2_1v2",
249 static struct regulator_consumer_supply tps80032_ldo1_supply[] = {
254 static struct regulator_consumer_supply tps80032_ldo2_supply[] = {
260 static struct regulator_consumer_supply tps80032_ldo3_supply[] = {
265 static struct regulator_consumer_supply tps80032_ldo4_supply[] = {
270 static struct regulator_consumer_supply tps80032_ldo5_supply[] = {
275 static struct regulator_consumer_supply tps80032_ldo6_supply[] = {
280 static struct regulator_consumer_supply tps80032_ldo7_supply[] = {
286 static struct regulator_consumer_supply tps80032_ldoln_supply[] = {
291 static struct regulator_consumer_supply tps80032_ldousb_supply[] = {
296 static struct regulator_consumer_supply tps80032_ldovana_supply[] = {
302 static struct regulator_init_data tps80032_smps1 = {
309 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
310 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
313 .num_consumer_supplies = ARRAY_SIZE(tps80032_smps1_supply),
314 .consumer_supplies = tps80032_smps1_supply,
318 static struct regulator_init_data tps80032_smps2 = {
325 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
326 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
329 .num_consumer_supplies = ARRAY_SIZE(tps80032_smps2_supply),
330 .consumer_supplies = tps80032_smps2_supply,
336 static struct regulator_init_data tps80032_smps3 = {
343 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
344 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
347 .num_consumer_supplies = ARRAY_SIZE(tps80032_smps3_supply),
348 .consumer_supplies = tps80032_smps3_supply,
353 static struct regulator_init_data tps80032_smps4 = {
360 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
361 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
364 .num_consumer_supplies = ARRAY_SIZE(tps80032_smps4_supply),
365 .consumer_supplies = tps80032_smps4_supply,
368 static struct regulator_init_data tps80032_smps5 = {
375 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
376 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
379 .num_consumer_supplies = ARRAY_SIZE(tps80032_smps5_supply),
380 .consumer_supplies = tps80032_smps5_supply,
382 static struct regulator_init_data tps80032_ldo1 = {
389 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
390 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
393 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldo1_supply),
394 .consumer_supplies = tps80032_ldo1_supply,
398 static struct regulator_init_data tps80032_ldo2 = {
405 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
406 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
409 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldo2_supply),
410 .consumer_supplies = tps80032_ldo2_supply,
414 static struct regulator_init_data tps80032_ldo3 = {
421 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
422 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
425 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldo3_supply),
426 .consumer_supplies = tps80032_ldo3_supply,
430 static struct regulator_init_data tps80032_ldo4 = {
437 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
438 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
441 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldo4_supply),
442 .consumer_supplies = tps80032_ldo4_supply,
446 static struct regulator_init_data tps80032_ldo5 = {
453 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
454 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
457 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldo5_supply),
458 .consumer_supplies = tps80032_ldo5_supply,
462 static struct regulator_init_data tps80032_ldo6 = {
469 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
470 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
473 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldo6_supply),
474 .consumer_supplies = tps80032_ldo6_supply,
478 static struct regulator_init_data tps80032_ldo7 = {
485 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
486 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
489 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldo7_supply),
490 .consumer_supplies = tps80032_ldo7_supply,
494 static struct regulator_init_data tps80032_ldoln = {
501 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
502 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
505 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldoln_supply),
506 .consumer_supplies = tps80032_ldoln_supply,
510 static struct regulator_init_data tps80032_ldousb = {
517 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
518 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
521 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldousb_supply),
522 .consumer_supplies = tps80032_ldousb_supply,
526 static struct regulator_init_data tps80032_ldovana = {
533 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
534 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
537 .num_consumer_supplies = ARRAY_SIZE(tps80032_ldovana_supply),
538 .consumer_supplies = tps80032_ldovana_supply,
541 static struct twl4030_madc_platform_data tps80032_madc_data = {
544 static int tps_batt_table[] = {
546 3400,3420,3440,3475,3505,3525,
547 3540,3557,3570,3580,3610,
548 3630,3640,3652,3662,3672,
549 3680,3687,3693,3699,3705,
550 3710,3714,3718,3722,3726,
551 3730,3734,3738,3742,3746,
552 3750,3756,3764,3774,3786,
553 3800,3808,3817,3827,3845,
554 3950,3964,3982,4002,4026,
555 4030,4034,4055,4070,4085,4120
557 static struct twl4030_bci_platform_data tps80032_bci_data = {
558 .battery_tmp_tbl = tps_batt_table,
559 .tblsize = ARRAY_SIZE(tps_batt_table),
562 static int rk30_phy_init(struct device *dev){
565 static int rk30_phy_exit(struct device *dev){
568 static int rk30_phy_power(struct device *dev, int ID, int on){
571 static int rk30_phy_set_clk(struct device *dev, int on){
574 static int rk30_phy_suspend(struct device *dev, int suspend){
577 static struct twl4030_usb_data tps80032_usbphy_data = {
578 .phy_init = rk30_phy_init,
579 .phy_exit = rk30_phy_exit,
580 .phy_power = rk30_phy_power,
581 .phy_set_clock = rk30_phy_set_clk,
582 .phy_suspend = rk30_phy_suspend,
585 static struct twl4030_ins sleep_on_seq[] __initdata = {
587 * Turn off everything
589 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
592 static struct twl4030_script sleep_on_script __initdata = {
593 .script = sleep_on_seq,
594 .size = ARRAY_SIZE(sleep_on_seq),
595 .flags = TWL4030_SLEEP_SCRIPT,
598 static struct twl4030_ins wakeup_seq[] __initdata = {
600 * Reenable everything
602 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
605 static struct twl4030_script wakeup_script __initdata = {
606 .script = wakeup_seq,
607 .size = ARRAY_SIZE(wakeup_seq),
608 .flags = TWL4030_WAKEUP12_SCRIPT,
611 static struct twl4030_ins wakeup_p3_seq[] __initdata = {
613 * Reenable everything
615 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
618 static struct twl4030_script wakeup_p3_script __initdata = {
619 .script = wakeup_p3_seq,
620 .size = ARRAY_SIZE(wakeup_p3_seq),
621 .flags = TWL4030_WAKEUP3_SCRIPT,
623 static struct twl4030_ins wrst_seq[] __initdata = {
626 * Reset VDD1 regulator.
627 * Reset VDD2 regulator.
628 * Reset VPLL1 regulator.
629 * Enable sysclk output.
632 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
633 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
635 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
636 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
637 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
638 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
639 {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
640 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
642 static struct twl4030_script wrst_script __initdata = {
644 .size = ARRAY_SIZE(wrst_seq),
645 .flags = TWL4030_WRST_SCRIPT,
648 static struct twl4030_script *twl4030_scripts[] __initdata = {
649 /* wakeup12 script should be loaded before sleep script, otherwise a
650 board might hit retention before loading of wakeup script is
651 completed. This can cause boot failures depending on timing issues.
658 static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
659 { .resource = RES_VDD1, .devgroup = -1,
660 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
661 .remap_sleep = RES_STATE_OFF
663 { .resource = RES_VDD2, .devgroup = -1,
664 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
665 .remap_sleep = RES_STATE_OFF
667 { .resource = RES_VPLL1, .devgroup = -1,
668 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
669 .remap_sleep = RES_STATE_OFF
671 { .resource = RES_VPLL2, .devgroup = -1,
672 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
674 { .resource = RES_VAUX1, .devgroup = -1,
675 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
677 { .resource = RES_VAUX2, .devgroup = -1,
678 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
680 { .resource = RES_VAUX3, .devgroup = -1,
681 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
683 { .resource = RES_VAUX4, .devgroup = -1,
684 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
686 { .resource = RES_VMMC1, .devgroup = -1,
687 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
689 { .resource = RES_VMMC2, .devgroup = -1,
690 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
692 { .resource = RES_VDAC, .devgroup = -1,
693 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
695 { .resource = RES_VSIM, .devgroup = -1,
696 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
698 { .resource = RES_VINTANA1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
699 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
701 { .resource = RES_VINTANA2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
702 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
704 { .resource = RES_VINTDIG, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
705 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
707 { .resource = RES_VIO, .devgroup = DEV_GRP_P3,
708 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
710 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
711 .type = 1, .type2 = -1 , .remap_off = -1, .remap_sleep = -1
713 { .resource = RES_REGEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
714 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
716 { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
717 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
719 { .resource = RES_SYSEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
720 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
722 { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
723 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
725 { .resource = RES_32KCLKOUT, .devgroup = -1,
726 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
728 { .resource = RES_RESET, .devgroup = -1,
729 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
731 { .resource = RES_MAIN_REF, .devgroup = -1,
732 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
736 static struct twl4030_power_data tps80032_scripts_data __initdata = {
737 .scripts = twl4030_scripts,
738 .num = ARRAY_SIZE(twl4030_scripts),
739 .resource_config = twl4030_rconfig,
742 #ifdef CONFIG_HAS_EARLYSUSPEND
743 void twl60xx_pmu_early_suspend(struct regulator_dev *rdev)
745 printk("%s\n", __func__);
747 ret = twl_reg_read(REG_INT_MSK_STS_A,TWL_MODULE_PIH);
748 twl_reg_write(REG_INT_MSK_STS_A,TWL_MODULE_PIH, ret & (~(1 << 2))); //open vlow interrupt
750 void twl60xx_pmu_early_resume(struct regulator_dev *rdev)
752 printk("%s\n", __func__);
754 ret = twl_reg_read(REG_INT_MSK_STS_A,TWL_MODULE_PIH);
755 twl_reg_write(REG_INT_MSK_STS_A,TWL_MODULE_PIH, ret |(1 << 2)); //close vlow interrupt
758 void twl60xx_pmu_early_suspend(struct regulator_dev *rdev)
761 void twl60xx_pmu_early_resume(struct regulator_dev *rdev)
766 void __sramfunc board_pmu_suspend(void)
768 #ifdef CONFIG_CLK_SWITCH_TO_32K //switch clk to 32k
769 grf_writel(GPIO6_PB1_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
770 grf_writel(GPIO6_PB1_DO_HIGH, GRF_GPIO6L_DO_ADDR); //set gpio6_b1 output low
771 grf_writel(GPIO6_PB1_EN_MASK, GRF_GPIO6L_EN_ADDR);
774 grf_writel(GPIO6_PB3_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
775 grf_writel(GPIO6_PB3_DO_HIGH, GRF_GPIO6L_DO_ADDR); //set gpio6_b3 output low
776 grf_writel(GPIO6_PB3_EN_MASK, GRF_GPIO6L_EN_ADDR);
779 void __sramfunc board_pmu_resume(void)
781 grf_writel(GPIO6_PB3_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
782 grf_writel(GPIO6_PB3_DO_LOW, GRF_GPIO6L_DO_ADDR); //set gpio6_b3 output high
783 grf_writel(GPIO6_PB3_EN_MASK, GRF_GPIO6L_EN_ADDR);
785 #ifdef CONFIG_CLK_SWITCH_TO_32K //switch clk to 24M
786 grf_writel(GPIO6_PB1_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
787 grf_writel(GPIO6_PB1_DO_LOW, GRF_GPIO6L_DO_ADDR); //set gpio6_b1 output low
788 grf_writel(GPIO6_PB1_EN_MASK, GRF_GPIO6L_EN_ADDR);
789 sram_32k_udelay(10000);
795 static struct twl4030_platform_data tps80032_data = {
796 .irq_base = TWL60xx_IRQ_BASE,
797 .irq_end = TWL60xx_IRQ_END,
798 //.irq = RK29_PIN0_PA1,
799 .pre_init = tps80032_pre_init,
800 .set_init = tps80032_set_init,
802 .madc = &tps80032_madc_data,
803 .bci = &tps80032_bci_data,
804 .usb = &tps80032_usbphy_data,
805 // .power = &tps80032_scripts_data,
807 .ldo1 = &tps80032_ldo1,
808 .ldo2 = &tps80032_ldo2,
809 .ldo3 = &tps80032_ldo3,
810 .ldo4 = &tps80032_ldo4,
811 .ldo5 = &tps80032_ldo5,
812 .ldo6 = &tps80032_ldo6,
813 .ldo7 = &tps80032_ldo7,
814 .ldoln = &tps80032_ldoln,
815 .ldousb =&tps80032_ldousb,
816 .vana = &tps80032_ldovana,
818 .smps1 = &tps80032_smps1,
819 .smps2= &tps80032_smps2,
820 .smps3 = &tps80032_smps3,
821 .smps4 = &tps80032_smps4,
822 .smps5 = &tps80032_smps5,