Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) ST Ericsson SA 2011 |
| 3 | * |
| 4 | * License Terms: GNU General Public License v2 |
| 5 | * |
| 6 | * STE Ux500 PRCMU API |
| 7 | */ |
| 8 | #ifndef __MACH_PRCMU_H |
| 9 | #define __MACH_PRCMU_H |
| 10 | |
| 11 | #include <linux/interrupt.h> |
| 12 | #include <linux/notifier.h> |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 13 | #include <linux/err.h> |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 14 | |
| 15 | /* PRCMU Wakeup defines */ |
| 16 | enum prcmu_wakeup_index { |
| 17 | PRCMU_WAKEUP_INDEX_RTC, |
| 18 | PRCMU_WAKEUP_INDEX_RTT0, |
| 19 | PRCMU_WAKEUP_INDEX_RTT1, |
| 20 | PRCMU_WAKEUP_INDEX_HSI0, |
| 21 | PRCMU_WAKEUP_INDEX_HSI1, |
| 22 | PRCMU_WAKEUP_INDEX_USB, |
| 23 | PRCMU_WAKEUP_INDEX_ABB, |
| 24 | PRCMU_WAKEUP_INDEX_ABB_FIFO, |
| 25 | PRCMU_WAKEUP_INDEX_ARM, |
| 26 | PRCMU_WAKEUP_INDEX_CD_IRQ, |
| 27 | NUM_PRCMU_WAKEUP_INDICES |
| 28 | }; |
| 29 | #define PRCMU_WAKEUP(_name) (BIT(PRCMU_WAKEUP_INDEX_##_name)) |
| 30 | |
| 31 | /* EPOD (power domain) IDs */ |
| 32 | |
| 33 | /* |
| 34 | * DB8500 EPODs |
| 35 | * - EPOD_ID_SVAMMDSP: power domain for SVA MMDSP |
| 36 | * - EPOD_ID_SVAPIPE: power domain for SVA pipe |
| 37 | * - EPOD_ID_SIAMMDSP: power domain for SIA MMDSP |
| 38 | * - EPOD_ID_SIAPIPE: power domain for SIA pipe |
| 39 | * - EPOD_ID_SGA: power domain for SGA |
| 40 | * - EPOD_ID_B2R2_MCDE: power domain for B2R2 and MCDE |
| 41 | * - EPOD_ID_ESRAM12: power domain for ESRAM 1 and 2 |
| 42 | * - EPOD_ID_ESRAM34: power domain for ESRAM 3 and 4 |
| 43 | * - NUM_EPOD_ID: number of power domains |
| 44 | * |
| 45 | * TODO: These should be prefixed. |
| 46 | */ |
| 47 | #define EPOD_ID_SVAMMDSP 0 |
| 48 | #define EPOD_ID_SVAPIPE 1 |
| 49 | #define EPOD_ID_SIAMMDSP 2 |
| 50 | #define EPOD_ID_SIAPIPE 3 |
| 51 | #define EPOD_ID_SGA 4 |
| 52 | #define EPOD_ID_B2R2_MCDE 5 |
| 53 | #define EPOD_ID_ESRAM12 6 |
| 54 | #define EPOD_ID_ESRAM34 7 |
| 55 | #define NUM_EPOD_ID 8 |
| 56 | |
| 57 | /* |
| 58 | * DB5500 EPODs |
| 59 | */ |
| 60 | #define DB5500_EPOD_ID_BASE 0x0100 |
| 61 | #define DB5500_EPOD_ID_SGA (DB5500_EPOD_ID_BASE + 0) |
| 62 | #define DB5500_EPOD_ID_HVA (DB5500_EPOD_ID_BASE + 1) |
| 63 | #define DB5500_EPOD_ID_SIA (DB5500_EPOD_ID_BASE + 2) |
| 64 | #define DB5500_EPOD_ID_DISP (DB5500_EPOD_ID_BASE + 3) |
| 65 | #define DB5500_EPOD_ID_ESRAM12 (DB5500_EPOD_ID_BASE + 6) |
| 66 | #define DB5500_NUM_EPOD_ID 7 |
| 67 | |
| 68 | /* |
| 69 | * state definition for EPOD (power domain) |
| 70 | * - EPOD_STATE_NO_CHANGE: The EPOD should remain unchanged |
| 71 | * - EPOD_STATE_OFF: The EPOD is switched off |
| 72 | * - EPOD_STATE_RAMRET: The EPOD is switched off with its internal RAM in |
| 73 | * retention |
| 74 | * - EPOD_STATE_ON_CLK_OFF: The EPOD is switched on, clock is still off |
| 75 | * - EPOD_STATE_ON: Same as above, but with clock enabled |
| 76 | */ |
| 77 | #define EPOD_STATE_NO_CHANGE 0x00 |
| 78 | #define EPOD_STATE_OFF 0x01 |
| 79 | #define EPOD_STATE_RAMRET 0x02 |
| 80 | #define EPOD_STATE_ON_CLK_OFF 0x03 |
| 81 | #define EPOD_STATE_ON 0x04 |
| 82 | |
Mattias Nilsson | 6b6fae2 | 2012-01-13 16:20:28 +0100 | [diff] [blame] | 83 | /* DB5500 CLKOUT IDs */ |
| 84 | enum { |
| 85 | DB5500_CLKOUT0 = 0, |
| 86 | DB5500_CLKOUT1, |
| 87 | }; |
| 88 | |
| 89 | /* DB5500 CLKOUTx sources */ |
| 90 | enum { |
| 91 | DB5500_CLKOUT_REF_CLK_SEL0, |
| 92 | DB5500_CLKOUT_RTC_CLK0_SEL0, |
| 93 | DB5500_CLKOUT_ULP_CLK_SEL0, |
| 94 | DB5500_CLKOUT_STATIC0, |
| 95 | DB5500_CLKOUT_REFCLK, |
| 96 | DB5500_CLKOUT_ULPCLK, |
| 97 | DB5500_CLKOUT_ARMCLK, |
| 98 | DB5500_CLKOUT_SYSACC0CLK, |
| 99 | DB5500_CLKOUT_SOC0PLLCLK, |
| 100 | DB5500_CLKOUT_SOC1PLLCLK, |
| 101 | DB5500_CLKOUT_DDRPLLCLK, |
| 102 | DB5500_CLKOUT_TVCLK, |
| 103 | DB5500_CLKOUT_IRDACLK, |
| 104 | }; |
| 105 | |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 106 | /* |
| 107 | * CLKOUT sources |
| 108 | */ |
| 109 | #define PRCMU_CLKSRC_CLK38M 0x00 |
| 110 | #define PRCMU_CLKSRC_ACLK 0x01 |
| 111 | #define PRCMU_CLKSRC_SYSCLK 0x02 |
| 112 | #define PRCMU_CLKSRC_LCDCLK 0x03 |
| 113 | #define PRCMU_CLKSRC_SDMMCCLK 0x04 |
| 114 | #define PRCMU_CLKSRC_TVCLK 0x05 |
| 115 | #define PRCMU_CLKSRC_TIMCLK 0x06 |
| 116 | #define PRCMU_CLKSRC_CLK009 0x07 |
| 117 | /* These are only valid for CLKOUT1: */ |
| 118 | #define PRCMU_CLKSRC_SIAMMDSPCLK 0x40 |
| 119 | #define PRCMU_CLKSRC_I2CCLK 0x41 |
| 120 | #define PRCMU_CLKSRC_MSP02CLK 0x42 |
| 121 | #define PRCMU_CLKSRC_ARMPLL_OBSCLK 0x43 |
| 122 | #define PRCMU_CLKSRC_HSIRXCLK 0x44 |
| 123 | #define PRCMU_CLKSRC_HSITXCLK 0x45 |
| 124 | #define PRCMU_CLKSRC_ARMCLKFIX 0x46 |
| 125 | #define PRCMU_CLKSRC_HDMICLK 0x47 |
| 126 | |
| 127 | /* |
| 128 | * Clock identifiers. |
| 129 | */ |
| 130 | enum prcmu_clock { |
| 131 | PRCMU_SGACLK, |
| 132 | PRCMU_UARTCLK, |
| 133 | PRCMU_MSP02CLK, |
| 134 | PRCMU_MSP1CLK, |
| 135 | PRCMU_I2CCLK, |
| 136 | PRCMU_SDMMCCLK, |
Mattias Nilsson | 6b6fae2 | 2012-01-13 16:20:28 +0100 | [diff] [blame] | 137 | PRCMU_SPARE1CLK, |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 138 | PRCMU_SLIMCLK, |
| 139 | PRCMU_PER1CLK, |
| 140 | PRCMU_PER2CLK, |
| 141 | PRCMU_PER3CLK, |
| 142 | PRCMU_PER5CLK, |
| 143 | PRCMU_PER6CLK, |
| 144 | PRCMU_PER7CLK, |
| 145 | PRCMU_LCDCLK, |
| 146 | PRCMU_BMLCLK, |
| 147 | PRCMU_HSITXCLK, |
| 148 | PRCMU_HSIRXCLK, |
| 149 | PRCMU_HDMICLK, |
| 150 | PRCMU_APEATCLK, |
| 151 | PRCMU_APETRACECLK, |
| 152 | PRCMU_MCDECLK, |
| 153 | PRCMU_IPI2CCLK, |
| 154 | PRCMU_DSIALTCLK, |
| 155 | PRCMU_DMACLK, |
| 156 | PRCMU_B2R2CLK, |
| 157 | PRCMU_TVCLK, |
| 158 | PRCMU_SSPCLK, |
| 159 | PRCMU_RNGCLK, |
| 160 | PRCMU_UICCCLK, |
| 161 | PRCMU_PWMCLK, |
| 162 | PRCMU_IRDACLK, |
| 163 | PRCMU_IRRCCLK, |
| 164 | PRCMU_SIACLK, |
| 165 | PRCMU_SVACLK, |
Mattias Nilsson | 6b6fae2 | 2012-01-13 16:20:28 +0100 | [diff] [blame] | 166 | PRCMU_ACLK, |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 167 | PRCMU_NUM_REG_CLOCKS, |
| 168 | PRCMU_SYSCLK = PRCMU_NUM_REG_CLOCKS, |
Mattias Nilsson | 6b6fae2 | 2012-01-13 16:20:28 +0100 | [diff] [blame] | 169 | PRCMU_CDCLK, |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 170 | PRCMU_TIMCLK, |
| 171 | PRCMU_PLLSOC0, |
| 172 | PRCMU_PLLSOC1, |
| 173 | PRCMU_PLLDDR, |
Mattias Nilsson | 6b6fae2 | 2012-01-13 16:20:28 +0100 | [diff] [blame] | 174 | PRCMU_PLLDSI, |
| 175 | PRCMU_DSI0CLK, |
| 176 | PRCMU_DSI1CLK, |
| 177 | PRCMU_DSI0ESCCLK, |
| 178 | PRCMU_DSI1ESCCLK, |
| 179 | PRCMU_DSI2ESCCLK, |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | /** |
| 183 | * enum ape_opp - APE OPP states definition |
| 184 | * @APE_OPP_INIT: |
| 185 | * @APE_NO_CHANGE: The APE operating point is unchanged |
| 186 | * @APE_100_OPP: The new APE operating point is ape100opp |
| 187 | * @APE_50_OPP: 50% |
Mattias Nilsson | 4d64d2e | 2012-01-13 16:20:43 +0100 | [diff] [blame] | 188 | * @APE_50_PARTLY_25_OPP: 50%, except some clocks at 25%. |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 189 | */ |
| 190 | enum ape_opp { |
| 191 | APE_OPP_INIT = 0x00, |
| 192 | APE_NO_CHANGE = 0x01, |
| 193 | APE_100_OPP = 0x02, |
Mattias Nilsson | 4d64d2e | 2012-01-13 16:20:43 +0100 | [diff] [blame] | 194 | APE_50_OPP = 0x03, |
| 195 | APE_50_PARTLY_25_OPP = 0xFF, |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 196 | }; |
| 197 | |
| 198 | /** |
| 199 | * enum arm_opp - ARM OPP states definition |
| 200 | * @ARM_OPP_INIT: |
| 201 | * @ARM_NO_CHANGE: The ARM operating point is unchanged |
| 202 | * @ARM_100_OPP: The new ARM operating point is arm100opp |
| 203 | * @ARM_50_OPP: The new ARM operating point is arm50opp |
| 204 | * @ARM_MAX_OPP: Operating point is "max" (more than 100) |
| 205 | * @ARM_MAX_FREQ100OPP: Set max opp if available, else 100 |
| 206 | * @ARM_EXTCLK: The new ARM operating point is armExtClk |
| 207 | */ |
| 208 | enum arm_opp { |
| 209 | ARM_OPP_INIT = 0x00, |
| 210 | ARM_NO_CHANGE = 0x01, |
| 211 | ARM_100_OPP = 0x02, |
| 212 | ARM_50_OPP = 0x03, |
| 213 | ARM_MAX_OPP = 0x04, |
| 214 | ARM_MAX_FREQ100OPP = 0x05, |
| 215 | ARM_EXTCLK = 0x07 |
| 216 | }; |
| 217 | |
| 218 | /** |
| 219 | * enum ddr_opp - DDR OPP states definition |
| 220 | * @DDR_100_OPP: The new DDR operating point is ddr100opp |
| 221 | * @DDR_50_OPP: The new DDR operating point is ddr50opp |
| 222 | * @DDR_25_OPP: The new DDR operating point is ddr25opp |
| 223 | */ |
| 224 | enum ddr_opp { |
| 225 | DDR_100_OPP = 0x00, |
| 226 | DDR_50_OPP = 0x01, |
| 227 | DDR_25_OPP = 0x02, |
| 228 | }; |
| 229 | |
| 230 | /* |
| 231 | * Definitions for controlling ESRAM0 in deep sleep. |
| 232 | */ |
| 233 | #define ESRAM0_DEEP_SLEEP_STATE_OFF 1 |
| 234 | #define ESRAM0_DEEP_SLEEP_STATE_RET 2 |
| 235 | |
| 236 | /** |
| 237 | * enum ddr_pwrst - DDR power states definition |
| 238 | * @DDR_PWR_STATE_UNCHANGED: SDRAM and DDR controller state is unchanged |
| 239 | * @DDR_PWR_STATE_ON: |
| 240 | * @DDR_PWR_STATE_OFFLOWLAT: |
| 241 | * @DDR_PWR_STATE_OFFHIGHLAT: |
| 242 | */ |
| 243 | enum ddr_pwrst { |
| 244 | DDR_PWR_STATE_UNCHANGED = 0x00, |
| 245 | DDR_PWR_STATE_ON = 0x01, |
| 246 | DDR_PWR_STATE_OFFLOWLAT = 0x02, |
| 247 | DDR_PWR_STATE_OFFHIGHLAT = 0x03 |
| 248 | }; |
| 249 | |
| 250 | #include <linux/mfd/db8500-prcmu.h> |
| 251 | #include <linux/mfd/db5500-prcmu.h> |
| 252 | |
| 253 | #if defined(CONFIG_UX500_SOC_DB8500) || defined(CONFIG_UX500_SOC_DB5500) |
| 254 | |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 255 | #include <mach/id.h> |
| 256 | |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 257 | static inline void __init prcmu_early_init(void) |
| 258 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 259 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 260 | return db5500_prcmu_early_init(); |
| 261 | else |
| 262 | return db8500_prcmu_early_init(); |
| 263 | } |
| 264 | |
| 265 | static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk, |
| 266 | bool keep_ap_pll) |
| 267 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 268 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 269 | return db5500_prcmu_set_power_state(state, keep_ulp_clk, |
| 270 | keep_ap_pll); |
| 271 | else |
| 272 | return db8500_prcmu_set_power_state(state, keep_ulp_clk, |
| 273 | keep_ap_pll); |
| 274 | } |
| 275 | |
Mattias Nilsson | 4d64d2e | 2012-01-13 16:20:43 +0100 | [diff] [blame] | 276 | static inline u8 prcmu_get_power_state_result(void) |
| 277 | { |
| 278 | if (cpu_is_u5500()) |
| 279 | return -EINVAL; |
| 280 | else |
| 281 | return db8500_prcmu_get_power_state_result(); |
| 282 | } |
| 283 | |
Daniel Lezcano | 485540d | 2012-02-20 12:30:26 +0100 | [diff] [blame^] | 284 | static inline int prcmu_gic_decouple(void) |
| 285 | { |
| 286 | if (cpu_is_u5500()) |
| 287 | return -EINVAL; |
| 288 | else |
| 289 | return db8500_prcmu_gic_decouple(); |
| 290 | } |
| 291 | |
| 292 | static inline int prcmu_gic_recouple(void) |
| 293 | { |
| 294 | if (cpu_is_u5500()) |
| 295 | return -EINVAL; |
| 296 | else |
| 297 | return db8500_prcmu_gic_recouple(); |
| 298 | } |
| 299 | |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 300 | static inline int prcmu_set_epod(u16 epod_id, u8 epod_state) |
| 301 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 302 | if (cpu_is_u5500()) |
Mattias Nilsson | 73180f8 | 2011-08-12 10:28:10 +0200 | [diff] [blame] | 303 | return -EINVAL; |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 304 | else |
| 305 | return db8500_prcmu_set_epod(epod_id, epod_state); |
| 306 | } |
| 307 | |
| 308 | static inline void prcmu_enable_wakeups(u32 wakeups) |
| 309 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 310 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 311 | db5500_prcmu_enable_wakeups(wakeups); |
| 312 | else |
| 313 | db8500_prcmu_enable_wakeups(wakeups); |
| 314 | } |
| 315 | |
| 316 | static inline void prcmu_disable_wakeups(void) |
| 317 | { |
| 318 | prcmu_enable_wakeups(0); |
| 319 | } |
| 320 | |
| 321 | static inline void prcmu_config_abb_event_readout(u32 abb_events) |
| 322 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 323 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 324 | db5500_prcmu_config_abb_event_readout(abb_events); |
| 325 | else |
| 326 | db8500_prcmu_config_abb_event_readout(abb_events); |
| 327 | } |
| 328 | |
| 329 | static inline void prcmu_get_abb_event_buffer(void __iomem **buf) |
| 330 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 331 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 332 | db5500_prcmu_get_abb_event_buffer(buf); |
| 333 | else |
| 334 | db8500_prcmu_get_abb_event_buffer(buf); |
| 335 | } |
| 336 | |
| 337 | int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size); |
| 338 | int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size); |
| 339 | |
| 340 | int prcmu_config_clkout(u8 clkout, u8 source, u8 div); |
| 341 | |
| 342 | static inline int prcmu_request_clock(u8 clock, bool enable) |
| 343 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 344 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 345 | return db5500_prcmu_request_clock(clock, enable); |
| 346 | else |
| 347 | return db8500_prcmu_request_clock(clock, enable); |
| 348 | } |
| 349 | |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 350 | unsigned long prcmu_clock_rate(u8 clock); |
| 351 | long prcmu_round_clock_rate(u8 clock, unsigned long rate); |
| 352 | int prcmu_set_clock_rate(u8 clock, unsigned long rate); |
| 353 | |
| 354 | static inline int prcmu_set_ddr_opp(u8 opp) |
| 355 | { |
| 356 | if (cpu_is_u5500()) |
| 357 | return -EINVAL; |
| 358 | else |
| 359 | return db8500_prcmu_set_ddr_opp(opp); |
| 360 | } |
| 361 | static inline int prcmu_get_ddr_opp(void) |
| 362 | { |
| 363 | if (cpu_is_u5500()) |
| 364 | return -EINVAL; |
| 365 | else |
| 366 | return db8500_prcmu_get_ddr_opp(); |
| 367 | } |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 368 | |
| 369 | static inline int prcmu_set_arm_opp(u8 opp) |
| 370 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 371 | if (cpu_is_u5500()) |
Mattias Nilsson | 73180f8 | 2011-08-12 10:28:10 +0200 | [diff] [blame] | 372 | return -EINVAL; |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 373 | else |
| 374 | return db8500_prcmu_set_arm_opp(opp); |
| 375 | } |
| 376 | |
| 377 | static inline int prcmu_get_arm_opp(void) |
| 378 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 379 | if (cpu_is_u5500()) |
Mattias Nilsson | 73180f8 | 2011-08-12 10:28:10 +0200 | [diff] [blame] | 380 | return -EINVAL; |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 381 | else |
| 382 | return db8500_prcmu_get_arm_opp(); |
| 383 | } |
| 384 | |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 385 | static inline int prcmu_set_ape_opp(u8 opp) |
| 386 | { |
| 387 | if (cpu_is_u5500()) |
| 388 | return -EINVAL; |
| 389 | else |
| 390 | return db8500_prcmu_set_ape_opp(opp); |
| 391 | } |
| 392 | |
| 393 | static inline int prcmu_get_ape_opp(void) |
| 394 | { |
| 395 | if (cpu_is_u5500()) |
| 396 | return -EINVAL; |
| 397 | else |
| 398 | return db8500_prcmu_get_ape_opp(); |
| 399 | } |
| 400 | |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 401 | static inline void prcmu_system_reset(u16 reset_code) |
| 402 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 403 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 404 | return db5500_prcmu_system_reset(reset_code); |
| 405 | else |
| 406 | return db8500_prcmu_system_reset(reset_code); |
| 407 | } |
| 408 | |
| 409 | static inline u16 prcmu_get_reset_code(void) |
| 410 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 411 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 412 | return db5500_prcmu_get_reset_code(); |
| 413 | else |
| 414 | return db8500_prcmu_get_reset_code(); |
| 415 | } |
| 416 | |
| 417 | void prcmu_ac_wake_req(void); |
| 418 | void prcmu_ac_sleep_req(void); |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 419 | static inline void prcmu_modem_reset(void) |
| 420 | { |
| 421 | if (cpu_is_u5500()) |
| 422 | return; |
| 423 | else |
| 424 | return db8500_prcmu_modem_reset(); |
| 425 | } |
| 426 | |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 427 | static inline bool prcmu_is_ac_wake_requested(void) |
| 428 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 429 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 430 | return db5500_prcmu_is_ac_wake_requested(); |
| 431 | else |
| 432 | return db8500_prcmu_is_ac_wake_requested(); |
| 433 | } |
| 434 | |
| 435 | static inline int prcmu_set_display_clocks(void) |
| 436 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 437 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 438 | return db5500_prcmu_set_display_clocks(); |
| 439 | else |
| 440 | return db8500_prcmu_set_display_clocks(); |
| 441 | } |
| 442 | |
| 443 | static inline int prcmu_disable_dsipll(void) |
| 444 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 445 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 446 | return db5500_prcmu_disable_dsipll(); |
| 447 | else |
| 448 | return db8500_prcmu_disable_dsipll(); |
| 449 | } |
| 450 | |
| 451 | static inline int prcmu_enable_dsipll(void) |
| 452 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 453 | if (cpu_is_u5500()) |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 454 | return db5500_prcmu_enable_dsipll(); |
| 455 | else |
| 456 | return db8500_prcmu_enable_dsipll(); |
| 457 | } |
| 458 | |
| 459 | static inline int prcmu_config_esram0_deep_sleep(u8 state) |
| 460 | { |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 461 | if (cpu_is_u5500()) |
Mattias Nilsson | 73180f8 | 2011-08-12 10:28:10 +0200 | [diff] [blame] | 462 | return -EINVAL; |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 463 | else |
| 464 | return db8500_prcmu_config_esram0_deep_sleep(state); |
| 465 | } |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 466 | |
| 467 | static inline int prcmu_config_hotdog(u8 threshold) |
| 468 | { |
| 469 | if (cpu_is_u5500()) |
| 470 | return -EINVAL; |
| 471 | else |
| 472 | return db8500_prcmu_config_hotdog(threshold); |
| 473 | } |
| 474 | |
| 475 | static inline int prcmu_config_hotmon(u8 low, u8 high) |
| 476 | { |
| 477 | if (cpu_is_u5500()) |
| 478 | return -EINVAL; |
| 479 | else |
| 480 | return db8500_prcmu_config_hotmon(low, high); |
| 481 | } |
| 482 | |
| 483 | static inline int prcmu_start_temp_sense(u16 cycles32k) |
| 484 | { |
| 485 | if (cpu_is_u5500()) |
| 486 | return -EINVAL; |
| 487 | else |
| 488 | return db8500_prcmu_start_temp_sense(cycles32k); |
| 489 | } |
| 490 | |
| 491 | static inline int prcmu_stop_temp_sense(void) |
| 492 | { |
| 493 | if (cpu_is_u5500()) |
| 494 | return -EINVAL; |
| 495 | else |
| 496 | return db8500_prcmu_stop_temp_sense(); |
| 497 | } |
| 498 | |
Mattias Nilsson | b4a6dbd | 2012-01-13 16:21:00 +0100 | [diff] [blame] | 499 | static inline u32 prcmu_read(unsigned int reg) |
| 500 | { |
| 501 | if (cpu_is_u5500()) |
| 502 | return -EINVAL; |
| 503 | else |
| 504 | return db8500_prcmu_read(reg); |
| 505 | } |
| 506 | |
| 507 | static inline void prcmu_write(unsigned int reg, u32 value) |
| 508 | { |
| 509 | if (cpu_is_u5500()) |
| 510 | return; |
| 511 | else |
| 512 | db8500_prcmu_write(reg, value); |
| 513 | } |
| 514 | |
| 515 | static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) |
| 516 | { |
| 517 | if (cpu_is_u5500()) |
| 518 | return; |
| 519 | else |
| 520 | db8500_prcmu_write_masked(reg, mask, value); |
| 521 | } |
| 522 | |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 523 | static inline int prcmu_enable_a9wdog(u8 id) |
| 524 | { |
| 525 | if (cpu_is_u5500()) |
| 526 | return -EINVAL; |
| 527 | else |
| 528 | return db8500_prcmu_enable_a9wdog(id); |
| 529 | } |
| 530 | |
| 531 | static inline int prcmu_disable_a9wdog(u8 id) |
| 532 | { |
| 533 | if (cpu_is_u5500()) |
| 534 | return -EINVAL; |
| 535 | else |
| 536 | return db8500_prcmu_disable_a9wdog(id); |
| 537 | } |
| 538 | |
| 539 | static inline int prcmu_kick_a9wdog(u8 id) |
| 540 | { |
| 541 | if (cpu_is_u5500()) |
| 542 | return -EINVAL; |
| 543 | else |
| 544 | return db8500_prcmu_kick_a9wdog(id); |
| 545 | } |
| 546 | |
| 547 | static inline int prcmu_load_a9wdog(u8 id, u32 timeout) |
| 548 | { |
| 549 | if (cpu_is_u5500()) |
| 550 | return -EINVAL; |
| 551 | else |
| 552 | return db8500_prcmu_load_a9wdog(id, timeout); |
| 553 | } |
| 554 | |
| 555 | static inline int prcmu_config_a9wdog(u8 num, bool sleep_auto_off) |
| 556 | { |
| 557 | if (cpu_is_u5500()) |
| 558 | return -EINVAL; |
| 559 | else |
| 560 | return db8500_prcmu_config_a9wdog(num, sleep_auto_off); |
| 561 | } |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 562 | #else |
| 563 | |
| 564 | static inline void __init prcmu_early_init(void) {} |
| 565 | |
| 566 | static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk, |
| 567 | bool keep_ap_pll) |
| 568 | { |
| 569 | return 0; |
| 570 | } |
| 571 | |
| 572 | static inline int prcmu_set_epod(u16 epod_id, u8 epod_state) |
| 573 | { |
| 574 | return 0; |
| 575 | } |
| 576 | |
| 577 | static inline void prcmu_enable_wakeups(u32 wakeups) {} |
| 578 | |
| 579 | static inline void prcmu_disable_wakeups(void) {} |
| 580 | |
| 581 | static inline int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size) |
| 582 | { |
| 583 | return -ENOSYS; |
| 584 | } |
| 585 | |
| 586 | static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size) |
| 587 | { |
| 588 | return -ENOSYS; |
| 589 | } |
| 590 | |
| 591 | static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div) |
| 592 | { |
| 593 | return 0; |
| 594 | } |
| 595 | |
| 596 | static inline int prcmu_request_clock(u8 clock, bool enable) |
| 597 | { |
| 598 | return 0; |
| 599 | } |
| 600 | |
Mattias Nilsson | 6b6fae2 | 2012-01-13 16:20:28 +0100 | [diff] [blame] | 601 | static inline long prcmu_round_clock_rate(u8 clock, unsigned long rate) |
| 602 | { |
| 603 | return 0; |
| 604 | } |
| 605 | |
| 606 | static inline int prcmu_set_clock_rate(u8 clock, unsigned long rate) |
| 607 | { |
| 608 | return 0; |
| 609 | } |
| 610 | |
| 611 | static inline unsigned long prcmu_clock_rate(u8 clock) |
| 612 | { |
| 613 | return 0; |
| 614 | } |
| 615 | |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 616 | static inline int prcmu_set_ape_opp(u8 opp) |
| 617 | { |
| 618 | return 0; |
| 619 | } |
| 620 | |
| 621 | static inline int prcmu_get_ape_opp(void) |
| 622 | { |
| 623 | return APE_100_OPP; |
| 624 | } |
| 625 | |
| 626 | static inline int prcmu_set_arm_opp(u8 opp) |
| 627 | { |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | static inline int prcmu_get_arm_opp(void) |
| 632 | { |
| 633 | return ARM_100_OPP; |
| 634 | } |
| 635 | |
| 636 | static inline int prcmu_set_ddr_opp(u8 opp) |
| 637 | { |
| 638 | return 0; |
| 639 | } |
| 640 | |
| 641 | static inline int prcmu_get_ddr_opp(void) |
| 642 | { |
| 643 | return DDR_100_OPP; |
| 644 | } |
| 645 | |
| 646 | static inline void prcmu_system_reset(u16 reset_code) {} |
| 647 | |
| 648 | static inline u16 prcmu_get_reset_code(void) |
| 649 | { |
| 650 | return 0; |
| 651 | } |
| 652 | |
| 653 | static inline void prcmu_ac_wake_req(void) {} |
| 654 | |
| 655 | static inline void prcmu_ac_sleep_req(void) {} |
| 656 | |
| 657 | static inline void prcmu_modem_reset(void) {} |
| 658 | |
| 659 | static inline bool prcmu_is_ac_wake_requested(void) |
| 660 | { |
| 661 | return false; |
| 662 | } |
| 663 | |
| 664 | static inline int prcmu_set_display_clocks(void) |
| 665 | { |
| 666 | return 0; |
| 667 | } |
| 668 | |
| 669 | static inline int prcmu_disable_dsipll(void) |
| 670 | { |
| 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | static inline int prcmu_enable_dsipll(void) |
| 675 | { |
| 676 | return 0; |
| 677 | } |
| 678 | |
| 679 | static inline int prcmu_config_esram0_deep_sleep(u8 state) |
| 680 | { |
| 681 | return 0; |
| 682 | } |
| 683 | |
| 684 | static inline void prcmu_config_abb_event_readout(u32 abb_events) {} |
| 685 | |
| 686 | static inline void prcmu_get_abb_event_buffer(void __iomem **buf) |
| 687 | { |
| 688 | *buf = NULL; |
| 689 | } |
| 690 | |
Mattias Nilsson | 0508901 | 2012-01-13 16:20:20 +0100 | [diff] [blame] | 691 | static inline int prcmu_config_hotdog(u8 threshold) |
| 692 | { |
| 693 | return 0; |
| 694 | } |
| 695 | |
| 696 | static inline int prcmu_config_hotmon(u8 low, u8 high) |
| 697 | { |
| 698 | return 0; |
| 699 | } |
| 700 | |
| 701 | static inline int prcmu_start_temp_sense(u16 cycles32k) |
| 702 | { |
| 703 | return 0; |
| 704 | } |
| 705 | |
| 706 | static inline int prcmu_stop_temp_sense(void) |
| 707 | { |
| 708 | return 0; |
| 709 | } |
| 710 | |
Mattias Nilsson | b4a6dbd | 2012-01-13 16:21:00 +0100 | [diff] [blame] | 711 | static inline u32 prcmu_read(unsigned int reg) |
| 712 | { |
| 713 | return 0; |
| 714 | } |
| 715 | |
| 716 | static inline void prcmu_write(unsigned int reg, u32 value) {} |
| 717 | |
| 718 | static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) {} |
| 719 | |
| 720 | #endif |
| 721 | |
| 722 | static inline void prcmu_set(unsigned int reg, u32 bits) |
| 723 | { |
| 724 | prcmu_write_masked(reg, bits, bits); |
| 725 | } |
| 726 | |
| 727 | static inline void prcmu_clear(unsigned int reg, u32 bits) |
| 728 | { |
| 729 | prcmu_write_masked(reg, bits, 0); |
| 730 | } |
| 731 | |
| 732 | #if defined(CONFIG_UX500_SOC_DB8500) || defined(CONFIG_UX500_SOC_DB5500) |
| 733 | |
| 734 | /** |
| 735 | * prcmu_enable_spi2 - Enables pin muxing for SPI2 on OtherAlternateC1. |
| 736 | */ |
| 737 | static inline void prcmu_enable_spi2(void) |
| 738 | { |
| 739 | if (cpu_is_u8500()) |
| 740 | prcmu_set(DB8500_PRCM_GPIOCR, DB8500_PRCM_GPIOCR_SPI2_SELECT); |
| 741 | } |
| 742 | |
| 743 | /** |
| 744 | * prcmu_disable_spi2 - Disables pin muxing for SPI2 on OtherAlternateC1. |
| 745 | */ |
| 746 | static inline void prcmu_disable_spi2(void) |
| 747 | { |
| 748 | if (cpu_is_u8500()) |
| 749 | prcmu_clear(DB8500_PRCM_GPIOCR, DB8500_PRCM_GPIOCR_SPI2_SELECT); |
| 750 | } |
| 751 | |
| 752 | /** |
| 753 | * prcmu_enable_stm_mod_uart - Enables pin muxing for STMMOD |
| 754 | * and UARTMOD on OtherAlternateC3. |
| 755 | */ |
| 756 | static inline void prcmu_enable_stm_mod_uart(void) |
| 757 | { |
| 758 | if (cpu_is_u8500()) { |
| 759 | prcmu_set(DB8500_PRCM_GPIOCR, |
| 760 | (DB8500_PRCM_GPIOCR_DBG_STM_MOD_CMD1 | |
| 761 | DB8500_PRCM_GPIOCR_DBG_UARTMOD_CMD0)); |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | /** |
| 766 | * prcmu_disable_stm_mod_uart - Disables pin muxing for STMMOD |
| 767 | * and UARTMOD on OtherAlternateC3. |
| 768 | */ |
| 769 | static inline void prcmu_disable_stm_mod_uart(void) |
| 770 | { |
| 771 | if (cpu_is_u8500()) { |
| 772 | prcmu_clear(DB8500_PRCM_GPIOCR, |
| 773 | (DB8500_PRCM_GPIOCR_DBG_STM_MOD_CMD1 | |
| 774 | DB8500_PRCM_GPIOCR_DBG_UARTMOD_CMD0)); |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | /** |
| 779 | * prcmu_enable_stm_ape - Enables pin muxing for STM APE on OtherAlternateC1. |
| 780 | */ |
| 781 | static inline void prcmu_enable_stm_ape(void) |
| 782 | { |
| 783 | if (cpu_is_u8500()) { |
| 784 | prcmu_set(DB8500_PRCM_GPIOCR, |
| 785 | DB8500_PRCM_GPIOCR_DBG_STM_APE_CMD); |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | /** |
| 790 | * prcmu_disable_stm_ape - Disables pin muxing for STM APE on OtherAlternateC1. |
| 791 | */ |
| 792 | static inline void prcmu_disable_stm_ape(void) |
| 793 | { |
| 794 | if (cpu_is_u8500()) { |
| 795 | prcmu_clear(DB8500_PRCM_GPIOCR, |
| 796 | DB8500_PRCM_GPIOCR_DBG_STM_APE_CMD); |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | #else |
| 801 | |
| 802 | static inline void prcmu_enable_spi2(void) {} |
| 803 | static inline void prcmu_disable_spi2(void) {} |
| 804 | static inline void prcmu_enable_stm_mod_uart(void) {} |
| 805 | static inline void prcmu_disable_stm_mod_uart(void) {} |
| 806 | static inline void prcmu_enable_stm_ape(void) {} |
| 807 | static inline void prcmu_disable_stm_ape(void) {} |
| 808 | |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 809 | #endif |
| 810 | |
| 811 | /* PRCMU QoS APE OPP class */ |
| 812 | #define PRCMU_QOS_APE_OPP 1 |
| 813 | #define PRCMU_QOS_DDR_OPP 2 |
Mattias Nilsson | 4d64d2e | 2012-01-13 16:20:43 +0100 | [diff] [blame] | 814 | #define PRCMU_QOS_ARM_OPP 3 |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 815 | #define PRCMU_QOS_DEFAULT_VALUE -1 |
| 816 | |
Mattias Nilsson | 4d64d2e | 2012-01-13 16:20:43 +0100 | [diff] [blame] | 817 | #ifdef CONFIG_DBX500_PRCMU_QOS_POWER |
Mattias Nilsson | fea799e | 2011-08-12 10:28:02 +0200 | [diff] [blame] | 818 | |
| 819 | unsigned long prcmu_qos_get_cpufreq_opp_delay(void); |
| 820 | void prcmu_qos_set_cpufreq_opp_delay(unsigned long); |
| 821 | void prcmu_qos_force_opp(int, s32); |
| 822 | int prcmu_qos_requirement(int pm_qos_class); |
| 823 | int prcmu_qos_add_requirement(int pm_qos_class, char *name, s32 value); |
| 824 | int prcmu_qos_update_requirement(int pm_qos_class, char *name, s32 new_value); |
| 825 | void prcmu_qos_remove_requirement(int pm_qos_class, char *name); |
| 826 | int prcmu_qos_add_notifier(int prcmu_qos_class, |
| 827 | struct notifier_block *notifier); |
| 828 | int prcmu_qos_remove_notifier(int prcmu_qos_class, |
| 829 | struct notifier_block *notifier); |
| 830 | |
| 831 | #else |
| 832 | |
| 833 | static inline unsigned long prcmu_qos_get_cpufreq_opp_delay(void) |
| 834 | { |
| 835 | return 0; |
| 836 | } |
| 837 | |
| 838 | static inline void prcmu_qos_set_cpufreq_opp_delay(unsigned long n) {} |
| 839 | |
| 840 | static inline void prcmu_qos_force_opp(int prcmu_qos_class, s32 i) {} |
| 841 | |
| 842 | static inline int prcmu_qos_requirement(int prcmu_qos_class) |
| 843 | { |
| 844 | return 0; |
| 845 | } |
| 846 | |
| 847 | static inline int prcmu_qos_add_requirement(int prcmu_qos_class, |
| 848 | char *name, s32 value) |
| 849 | { |
| 850 | return 0; |
| 851 | } |
| 852 | |
| 853 | static inline int prcmu_qos_update_requirement(int prcmu_qos_class, |
| 854 | char *name, s32 new_value) |
| 855 | { |
| 856 | return 0; |
| 857 | } |
| 858 | |
| 859 | static inline void prcmu_qos_remove_requirement(int prcmu_qos_class, char *name) |
| 860 | { |
| 861 | } |
| 862 | |
| 863 | static inline int prcmu_qos_add_notifier(int prcmu_qos_class, |
| 864 | struct notifier_block *notifier) |
| 865 | { |
| 866 | return 0; |
| 867 | } |
| 868 | static inline int prcmu_qos_remove_notifier(int prcmu_qos_class, |
| 869 | struct notifier_block *notifier) |
| 870 | { |
| 871 | return 0; |
| 872 | } |
| 873 | |
| 874 | #endif |
| 875 | |
| 876 | #endif /* __MACH_PRCMU_H */ |