0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __MFD_DB8500_PRCMU_H
0011 #define __MFD_DB8500_PRCMU_H
0012
0013 #include <linux/interrupt.h>
0014 #include <linux/bitops.h>
0015
0016
0017
0018
0019 #define DB8500_PRCM_LINE_VALUE 0x170
0020 #define DB8500_PRCM_LINE_VALUE_HSI_CAWAKE0 BIT(3)
0021
0022 #define DB8500_PRCM_DSI_SW_RESET 0x324
0023 #define DB8500_PRCM_DSI_SW_RESET_DSI0_SW_RESETN BIT(0)
0024 #define DB8500_PRCM_DSI_SW_RESET_DSI1_SW_RESETN BIT(1)
0025 #define DB8500_PRCM_DSI_SW_RESET_DSI2_SW_RESETN BIT(2)
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 enum state {
0036 OFF = 0x0,
0037 ON = 0x1,
0038 };
0039
0040
0041
0042
0043
0044 enum ret_state {
0045 OFFST = 0,
0046 ONST = 1,
0047 RETST = 2
0048 };
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 enum clk_arm {
0059 A9_OFF,
0060 A9_BOOT,
0061 A9_OPPT1,
0062 A9_OPPT2,
0063 A9_EXTCLK
0064 };
0065
0066
0067
0068
0069
0070
0071
0072 enum clk_gen {
0073 GEN_OFF,
0074 GEN_BOOT,
0075 GEN_OPPT1,
0076 };
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 enum romcode_write {
0087 RDY_2_DS = 0x09,
0088 RDY_2_XP70_RST = 0x10
0089 };
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 enum romcode_read {
0107 INIT = 0x00,
0108 FS_2_DS = 0x0A,
0109 END_DS = 0x0B,
0110 DS_TO_FS = 0x0C,
0111 END_FS = 0x0D,
0112 SWR = 0x0E,
0113 END_SWR = 0x0F
0114 };
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126 enum ap_pwrst {
0127 NO_PWRST = 0x00,
0128 AP_BOOT = 0x01,
0129 AP_EXECUTE = 0x02,
0130 AP_DEEP_SLEEP = 0x03,
0131 AP_SLEEP = 0x04,
0132 AP_IDLE = 0x05,
0133 AP_RESET = 0x06
0134 };
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146 enum ap_pwrst_trans {
0147 PRCMU_AP_NO_CHANGE = 0x00,
0148 APEXECUTE_TO_APSLEEP = 0x01,
0149 APIDLE_TO_APSLEEP = 0x02,
0150 PRCMU_AP_SLEEP = 0x01,
0151 APBOOT_TO_APEXECUTE = 0x03,
0152 APEXECUTE_TO_APDEEPSLEEP = 0x04,
0153 PRCMU_AP_DEEP_SLEEP = 0x04,
0154 APEXECUTE_TO_APIDLE = 0x05,
0155 PRCMU_AP_IDLE = 0x05,
0156 PRCMU_AP_DEEP_IDLE = 0x07,
0157 };
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170 enum hw_acc_state {
0171 HW_NO_CHANGE = 0x00,
0172 HW_OFF = 0x01,
0173 HW_OFF_RAMRET = 0x02,
0174 HW_ON = 0x04
0175 };
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204 enum ap_pwrsttr_status {
0205 BOOT_TO_EXECUTEOK = 0xFF,
0206 DEEPSLEEPOK = 0xFE,
0207 SLEEPOK = 0xFD,
0208 IDLEOK = 0xFC,
0209 SOFTRESETOK = 0xFB,
0210 SOFTRESETGO = 0xFA,
0211 BOOT_TO_EXECUTE = 0xF9,
0212 EXECUTE_TO_DEEPSLEEP = 0xF8,
0213 DEEPSLEEP_TO_EXECUTE = 0xF7,
0214 DEEPSLEEP_TO_EXECUTEOK = 0xF6,
0215 EXECUTE_TO_SLEEP = 0xF5,
0216 SLEEP_TO_EXECUTE = 0xF4,
0217 SLEEP_TO_EXECUTEOK = 0xF3,
0218 EXECUTE_TO_IDLE = 0xF2,
0219 IDLE_TO_EXECUTE = 0xF1,
0220 IDLE_TO_EXECUTEOK = 0xF0,
0221 RDYTODS_RETURNTOEXE = 0xEF,
0222 NORDYTODS_RETURNTOEXE = 0xEE,
0223 EXETOSLEEP_RETURNTOEXE = 0xED,
0224 EXETOIDLE_RETURNTOEXE = 0xEC,
0225 INIT_STATUS = 0xEB,
0226
0227
0228 INITERROR = 0x00,
0229 PLLARMLOCKP_ER = 0x01,
0230 PLLDDRLOCKP_ER = 0x02,
0231 PLLSOCLOCKP_ER = 0x03,
0232 PLLSOCK1LOCKP_ER = 0x04,
0233 ARMWFI_ER = 0x05,
0234 SYSCLKOK_ER = 0x06,
0235 I2C_NACK_DATA_ER = 0x07,
0236 BOOT_ER = 0x08,
0237 I2C_STATUS_ALWAYS_1 = 0x0A,
0238 I2C_NACK_REG_ADDR_ER = 0x0B,
0239 I2C_NACK_DATA0123_ER = 0x1B,
0240 I2C_NACK_ADDR_ER = 0x1F,
0241 CURAPPWRSTISNOT_BOOT = 0x20,
0242 CURAPPWRSTISNOT_EXECUTE = 0x21,
0243 CURAPPWRSTISNOT_SLEEPMODE = 0x22,
0244 CURAPPWRSTISNOT_CORRECTFORIT10 = 0x23,
0245 FIFO4500WUISNOT_WUPEVENT = 0x24,
0246 PLL32KLOCKP_ER = 0x29,
0247 DDRDEEPSLEEPOK_ER = 0x2A,
0248 ROMCODEREADY_ER = 0x50,
0249 WUPBEFOREDS = 0x51,
0250 DDRCONFIG_ER = 0x52,
0251 WUPBEFORESLEEP = 0x53,
0252 WUPBEFOREIDLE = 0x54
0253 };
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265 enum dvfs_stat {
0266 DVFS_GO = 0xFF,
0267 DVFS_ARM100OPPOK = 0xFE,
0268 DVFS_ARM50OPPOK = 0xFD,
0269 DVFS_ARMEXTCLKOK = 0xFC,
0270 DVFS_NOCHGTCLKOK = 0xFB,
0271 DVFS_INITSTATUS = 0x00
0272 };
0273
0274
0275
0276
0277
0278
0279 enum sva_mmdsp_stat {
0280 SVA_MMDSP_GO = 0xFF,
0281 SVA_MMDSP_INIT = 0x00
0282 };
0283
0284
0285
0286
0287
0288
0289 enum sia_mmdsp_stat {
0290 SIA_MMDSP_GO = 0xFF,
0291 SIA_MMDSP_INIT = 0x00
0292 };
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351 enum mbox_to_arm_err {
0352 INIT_ERR = 0x00,
0353 PLLARMLOCKP_ERR = 0x01,
0354 PLLDDRLOCKP_ERR = 0x02,
0355 PLLSOC0LOCKP_ERR = 0x03,
0356 PLLSOC1LOCKP_ERR = 0x04,
0357 ARMWFI_ERR = 0x05,
0358 SYSCLKOK_ERR = 0x06,
0359 BOOT_ERR = 0x07,
0360 ROMCODESAVECONTEXT = 0x08,
0361 VARMHIGHSPEEDVALTO_ERR = 0x10,
0362 VARMHIGHSPEEDACCESS_ERR = 0x11,
0363 VARMLOWSPEEDVALTO_ERR = 0x12,
0364 VARMLOWSPEEDACCESS_ERR = 0x13,
0365 VARMRETENTIONVALTO_ERR = 0x14,
0366 VARMRETENTIONACCESS_ERR = 0x15,
0367 VAPEHIGHSPEEDVALTO_ERR = 0x16,
0368 VSAFEHPVALTO_ERR = 0x17,
0369 VMODSEL1VALTO_ERR = 0x18,
0370 VMODSEL2VALTO_ERR = 0x19,
0371 VARMOFFACCESS_ERR = 0x1A,
0372 VAPEOFFACCESS_ERR = 0x1B,
0373 VARMRETACCES_ERR = 0x1C,
0374 CURAPPWRSTISNOTBOOT = 0x20,
0375 CURAPPWRSTISNOTEXECUTE = 0x21,
0376 CURAPPWRSTISNOTSLEEPMODE = 0x22,
0377 CURAPPWRSTISNOTCORRECTDBG = 0x23,
0378 ARMREGU1VALTO_ERR = 0x24,
0379 ARMREGU2VALTO_ERR = 0x25,
0380 VAPEREGUVALTO_ERR = 0x26,
0381 VSMPS3REGUVALTO_ERR = 0x27,
0382 VMODREGUVALTO_ERR = 0x28
0383 };
0384
0385 enum hw_acc {
0386 SVAMMDSP = 0,
0387 SVAPIPE = 1,
0388 SIAMMDSP = 2,
0389 SIAPIPE = 3,
0390 SGA = 4,
0391 B2R2MCDE = 5,
0392 ESRAM12 = 6,
0393 ESRAM34 = 7,
0394 };
0395
0396 enum cs_pwrmgt {
0397 PWRDNCS0 = 0,
0398 WKUPCS0 = 1,
0399 PWRDNCS1 = 2,
0400 WKUPCS1 = 3
0401 };
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414 enum sia_sva_pwr_policy {
0415 NO_CHGT = 0x0,
0416 DSPOFF_HWPOFF = 0x1,
0417 DSPOFFRAMRET_HWPOFF = 0x2,
0418 DSPCLKOFF_HWPOFF = 0x3,
0419 DSPCLKOFF_HWPCLKOFF = 0x4,
0420 };
0421
0422
0423
0424
0425
0426
0427
0428 enum auto_enable {
0429 AUTO_OFF = 0x0,
0430 AUTO_ON = 0x1,
0431 };
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445 enum prcmu_power_status {
0446 PRCMU_SLEEP_OK = 0xf3,
0447 PRCMU_DEEP_SLEEP_OK = 0xf6,
0448 PRCMU_IDLE_OK = 0xf0,
0449 PRCMU_DEEPIDLE_OK = 0xe3,
0450 PRCMU_PRCMU2ARMPENDINGIT_ER = 0x91,
0451 PRCMU_ARMPENDINGIT_ER = 0x93,
0452 };
0453
0454
0455
0456
0457
0458 #define PRCMU_AUTO_PM_OFF 0
0459 #define PRCMU_AUTO_PM_ON 1
0460
0461 #define PRCMU_AUTO_PM_POWER_ON_HSEM BIT(0)
0462 #define PRCMU_AUTO_PM_POWER_ON_ABB_FIFO_IT BIT(1)
0463
0464 enum prcmu_auto_pm_policy {
0465 PRCMU_AUTO_PM_POLICY_NO_CHANGE,
0466 PRCMU_AUTO_PM_POLICY_DSP_OFF_HWP_OFF,
0467 PRCMU_AUTO_PM_POLICY_DSP_OFF_RAMRET_HWP_OFF,
0468 PRCMU_AUTO_PM_POLICY_DSP_CLK_OFF_HWP_OFF,
0469 PRCMU_AUTO_PM_POLICY_DSP_CLK_OFF_HWP_CLK_OFF,
0470 };
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481 struct prcmu_auto_pm_config {
0482 u8 sia_auto_pm_enable;
0483 u8 sia_power_on;
0484 u8 sia_policy;
0485 u8 sva_auto_pm_enable;
0486 u8 sva_power_on;
0487 u8 sva_policy;
0488 };
0489
0490 #ifdef CONFIG_MFD_DB8500_PRCMU
0491
0492 void db8500_prcmu_early_init(void);
0493 int prcmu_set_rc_a2p(enum romcode_write);
0494 enum romcode_read prcmu_get_rc_p2a(void);
0495 enum ap_pwrst prcmu_get_xp70_current_state(void);
0496 bool prcmu_has_arm_maxopp(void);
0497 struct prcmu_fw_version *prcmu_get_fw_version(void);
0498 int prcmu_release_usb_wakeup_state(void);
0499 void prcmu_configure_auto_pm(struct prcmu_auto_pm_config *sleep,
0500 struct prcmu_auto_pm_config *idle);
0501 bool prcmu_is_auto_pm_enabled(void);
0502
0503 int prcmu_config_clkout(u8 clkout, u8 source, u8 div);
0504 int prcmu_set_clock_divider(u8 clock, u8 divider);
0505 int db8500_prcmu_config_hotdog(u8 threshold);
0506 int db8500_prcmu_config_hotmon(u8 low, u8 high);
0507 int db8500_prcmu_start_temp_sense(u16 cycles32k);
0508 int db8500_prcmu_stop_temp_sense(void);
0509 int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
0510 int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
0511
0512 int prcmu_ac_wake_req(void);
0513 void prcmu_ac_sleep_req(void);
0514 void db8500_prcmu_modem_reset(void);
0515
0516 int db8500_prcmu_config_a9wdog(u8 num, bool sleep_auto_off);
0517 int db8500_prcmu_enable_a9wdog(u8 id);
0518 int db8500_prcmu_disable_a9wdog(u8 id);
0519 int db8500_prcmu_kick_a9wdog(u8 id);
0520 int db8500_prcmu_load_a9wdog(u8 id, u32 val);
0521
0522 void db8500_prcmu_system_reset(u16 reset_code);
0523 int db8500_prcmu_set_power_state(u8 state, bool keep_ulp_clk, bool keep_ap_pll);
0524 u8 db8500_prcmu_get_power_state_result(void);
0525 void db8500_prcmu_enable_wakeups(u32 wakeups);
0526 int db8500_prcmu_set_epod(u16 epod_id, u8 epod_state);
0527 int db8500_prcmu_request_clock(u8 clock, bool enable);
0528 void db8500_prcmu_config_abb_event_readout(u32 abb_events);
0529 void db8500_prcmu_get_abb_event_buffer(void __iomem **buf);
0530 int db8500_prcmu_config_esram0_deep_sleep(u8 state);
0531 u16 db8500_prcmu_get_reset_code(void);
0532 bool db8500_prcmu_is_ac_wake_requested(void);
0533 int db8500_prcmu_set_arm_opp(u8 opp);
0534 int db8500_prcmu_get_arm_opp(void);
0535 int db8500_prcmu_set_ape_opp(u8 opp);
0536 int db8500_prcmu_get_ape_opp(void);
0537 int db8500_prcmu_request_ape_opp_100_voltage(bool enable);
0538 int db8500_prcmu_get_ddr_opp(void);
0539
0540 u32 db8500_prcmu_read(unsigned int reg);
0541 void db8500_prcmu_write(unsigned int reg, u32 value);
0542 void db8500_prcmu_write_masked(unsigned int reg, u32 mask, u32 value);
0543
0544 #else
0545
0546 static inline void db8500_prcmu_early_init(void) {}
0547
0548 static inline int prcmu_set_rc_a2p(enum romcode_write code)
0549 {
0550 return 0;
0551 }
0552
0553 static inline enum romcode_read prcmu_get_rc_p2a(void)
0554 {
0555 return INIT;
0556 }
0557
0558 static inline enum ap_pwrst prcmu_get_xp70_current_state(void)
0559 {
0560 return AP_EXECUTE;
0561 }
0562
0563 static inline bool prcmu_has_arm_maxopp(void)
0564 {
0565 return false;
0566 }
0567
0568 static inline struct prcmu_fw_version *prcmu_get_fw_version(void)
0569 {
0570 return NULL;
0571 }
0572
0573 static inline int db8500_prcmu_set_ape_opp(u8 opp)
0574 {
0575 return 0;
0576 }
0577
0578 static inline int db8500_prcmu_get_ape_opp(void)
0579 {
0580 return APE_100_OPP;
0581 }
0582
0583 static inline int db8500_prcmu_request_ape_opp_100_voltage(bool enable)
0584 {
0585 return 0;
0586 }
0587
0588 static inline int prcmu_release_usb_wakeup_state(void)
0589 {
0590 return 0;
0591 }
0592
0593 static inline int db8500_prcmu_get_ddr_opp(void)
0594 {
0595 return DDR_100_OPP;
0596 }
0597
0598 static inline void prcmu_configure_auto_pm(struct prcmu_auto_pm_config *sleep,
0599 struct prcmu_auto_pm_config *idle)
0600 {
0601 }
0602
0603 static inline bool prcmu_is_auto_pm_enabled(void)
0604 {
0605 return false;
0606 }
0607
0608 static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div)
0609 {
0610 return 0;
0611 }
0612
0613 static inline int prcmu_set_clock_divider(u8 clock, u8 divider)
0614 {
0615 return 0;
0616 }
0617
0618 static inline int db8500_prcmu_config_hotdog(u8 threshold)
0619 {
0620 return 0;
0621 }
0622
0623 static inline int db8500_prcmu_config_hotmon(u8 low, u8 high)
0624 {
0625 return 0;
0626 }
0627
0628 static inline int db8500_prcmu_start_temp_sense(u16 cycles32k)
0629 {
0630 return 0;
0631 }
0632
0633 static inline int db8500_prcmu_stop_temp_sense(void)
0634 {
0635 return 0;
0636 }
0637
0638 static inline int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
0639 {
0640 return -ENOSYS;
0641 }
0642
0643 static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
0644 {
0645 return -ENOSYS;
0646 }
0647
0648 static inline int prcmu_ac_wake_req(void)
0649 {
0650 return 0;
0651 }
0652
0653 static inline void prcmu_ac_sleep_req(void) {}
0654
0655 static inline void db8500_prcmu_modem_reset(void) {}
0656
0657 static inline void db8500_prcmu_system_reset(u16 reset_code) {}
0658
0659 static inline int db8500_prcmu_set_power_state(u8 state, bool keep_ulp_clk,
0660 bool keep_ap_pll)
0661 {
0662 return 0;
0663 }
0664
0665 static inline u8 db8500_prcmu_get_power_state_result(void)
0666 {
0667 return 0;
0668 }
0669
0670 static inline void db8500_prcmu_enable_wakeups(u32 wakeups) {}
0671
0672 static inline int db8500_prcmu_set_epod(u16 epod_id, u8 epod_state)
0673 {
0674 return 0;
0675 }
0676
0677 static inline int db8500_prcmu_request_clock(u8 clock, bool enable)
0678 {
0679 return 0;
0680 }
0681
0682 static inline int db8500_prcmu_config_esram0_deep_sleep(u8 state)
0683 {
0684 return 0;
0685 }
0686
0687 static inline void db8500_prcmu_config_abb_event_readout(u32 abb_events) {}
0688
0689 static inline void db8500_prcmu_get_abb_event_buffer(void __iomem **buf) {}
0690
0691 static inline u16 db8500_prcmu_get_reset_code(void)
0692 {
0693 return 0;
0694 }
0695
0696 static inline int db8500_prcmu_config_a9wdog(u8 num, bool sleep_auto_off)
0697 {
0698 return 0;
0699 }
0700
0701 static inline int db8500_prcmu_enable_a9wdog(u8 id)
0702 {
0703 return 0;
0704 }
0705
0706 static inline int db8500_prcmu_disable_a9wdog(u8 id)
0707 {
0708 return 0;
0709 }
0710
0711 static inline int db8500_prcmu_kick_a9wdog(u8 id)
0712 {
0713 return 0;
0714 }
0715
0716 static inline int db8500_prcmu_load_a9wdog(u8 id, u32 val)
0717 {
0718 return 0;
0719 }
0720
0721 static inline bool db8500_prcmu_is_ac_wake_requested(void)
0722 {
0723 return false;
0724 }
0725
0726 static inline int db8500_prcmu_set_arm_opp(u8 opp)
0727 {
0728 return 0;
0729 }
0730
0731 static inline int db8500_prcmu_get_arm_opp(void)
0732 {
0733 return 0;
0734 }
0735
0736 static inline u32 db8500_prcmu_read(unsigned int reg)
0737 {
0738 return 0;
0739 }
0740
0741 static inline void db8500_prcmu_write(unsigned int reg, u32 value) {}
0742
0743 static inline void db8500_prcmu_write_masked(unsigned int reg, u32 mask,
0744 u32 value) {}
0745
0746 #endif
0747
0748 #endif