Advertisement
Guest User

Untitled

a guest
Nov 4th, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.06 KB | None | 0 0
  1. /*
  2. * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved.
  3. * Copyright 2006 Motorola, Inc.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12.  
  13. /*
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of the
  17. * License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful, but
  20. * WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22. * General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  27. * USA
  28. */
  29.  
  30. /*
  31. * Revision History:
  32. *
  33. * Date Author Comment
  34. * 10/04/2006 Motorola Added functions mxc_pm_dither_control,
  35. * mxc_pm_dither_setup, and mxc_pm_dither_report
  36. * to support PLL dithering.
  37. * 12/14/2006 Motorola Added structures for better operating point
  38. * control.
  39. */
  40.  
  41. /*!
  42. * @defgroup LPMD Low-Level Power Management Driver
  43. */
  44.  
  45. /*!
  46. * @file mxc_pm.h
  47. *
  48. * @brief This file contains the chip level configuration details and
  49. * public API declarations for CRM_AP module
  50. *
  51. * @ingroup LPMD
  52. */
  53.  
  54. #ifndef MXC_PM_H
  55.  
  56. #define MXC_PM_H
  57.  
  58. #define WAIT_MODE 111
  59. #define DOZE_MODE 112
  60. #define STOP_MODE 113
  61. #define DSM_MODE 114
  62. /*
  63. * MXC91231 Break-Point Frequency below which is low frequency and
  64. * above which is high frequency
  65. */
  66. #define BREAKPT_FREQ ((long)(400000000))
  67.  
  68. #define GATE_STOP_WAIT 9
  69. #define GATE_STOP 10
  70.  
  71. #ifdef CONFIG_MOT_FEAT_PM
  72. #define NUM_PLL 3
  73. /*!
  74. * Enumerations of operating points
  75. * We want the operating points to be used as indexes, so we use 0-n.
  76. *
  77. * This enum must be kept up to date with the dvfs_op_point_t.
  78. */
  79. typedef enum {
  80. INDX_INVAL = -1,
  81. INDX_FIRST = 0,
  82. INDX_133 = 0,
  83. INDX_266 = 1,
  84. INDX_399 = 2,
  85. INDX_532 = 3,
  86. NUM_DVFSOP_INDEXES = 4,
  87. } dvfs_op_point_index_t;
  88.  
  89. #endif
  90.  
  91. /*
  92. * Used for MHz conversion
  93. */
  94. #define MEGA_HERTZ 1000000
  95.  
  96. /*
  97. * If invalid frequency value other than the following
  98. * CORE_133 - ARM desired to run @133MHz, LoV (1.2V)
  99. * CORE_266 - ARM desired to run @266MHz, LoV (1.2V)
  100. * CORE_399 - ARM desired to run @399MHz, LoV (1.2V)
  101. * CORE_532 - ARM desired to run @133MHz, HiV (1.6V)
  102. * are passed then this error is returned,
  103. */
  104. #define ERR_FREQ_INVALID 1
  105.  
  106. /*
  107. * For MXC91231 Pass1, Integer DVFS greater than 133MHz is not allowed
  108. * due to the hardware issue
  109. */
  110. #define INTEGER_DVFS_NOT_ALLOW 1
  111.  
  112. /*
  113. * If PLL freq is less than desired ARM frequency during Integer
  114. * DVFS, then return this error
  115. */
  116. #define PLL_LESS_ARM_ERR 2
  117.  
  118. /*
  119. * Frequency change within the same-lo voltage is not approved.
  120. * Inorder to do Integer DFS, move to the high voltage range and
  121. * then set LFDF and move to the low voltage range
  122. */
  123. #define INT_DFS_LOW_NOT_ALLOW 3
  124.  
  125. /*
  126. * If the desired AHB or IPG exceeds 133MHz or 66.5MHz respectively,
  127. * then return this error
  128. */
  129. #define AHB_IPG_EXCEED_LIMIT 4
  130.  
  131. /*
  132. * If the desired ARM frequency is too low to get by PLL scaling
  133. * and the mxc_pm_pllscale API is called, return this error:
  134. */
  135. #define PLL_DVFS_FREQ_TOO_LOW 5
  136.  
  137. /*
  138. * Invalid frequencies requested
  139. */
  140. #define MXC_PM_INVALID_PARAM 6
  141.  
  142. #ifdef CONFIG_MOT_FEAT_PM
  143. /*
  144. * DVFS is currently disabled
  145. */
  146. #define MXC_PM_DVFS_DISABLED 7
  147. #endif
  148.  
  149. /*
  150. * If AHB and/or IPG frequencies are greater than maximum allowed
  151. */
  152. #define FREQ_OUT_OF_RANGE 2
  153.  
  154. /*
  155. * If AHB and/or IPG frequencies are other than 100 or 50Mhz
  156. */
  157. #define BUS_FREQ_INVALID 2
  158.  
  159. /*
  160. * If MAX_PDF is greater than max value (8) then return this error
  161. */
  162. #define AHB_MAX_DIV_ERR 3
  163.  
  164. /*
  165. * If IPG_PDF is greater than max value (2) then return this error
  166. */
  167. #define IPG_MAX_DIV_ERR 4
  168.  
  169. /*
  170. * If ARM freq is out of range i.e., less than 133 or greater than
  171. * 399 then return this error
  172. */
  173. #define INVALID_ARM_FREQ 5
  174.  
  175. /*
  176. * This file includes all API on ZATS. Some of the APIs are not
  177. * appicable to some platforms. So, this error is used to indicate
  178. * that a particular API is not available
  179. */
  180. #define MXC_PM_API_NOT_SUPPORTED 6
  181.  
  182. /*
  183. * Error when frequency scaling is attempted while switch between MPLL and
  184. * TPLL is in progress on MXC91321
  185. */
  186. #define ERR_DFSP_SWITCH 2
  187.  
  188. /*!
  189. * Additional define for stop mode
  190. */
  191. #define PM_SUSPEND_STOP ((__force suspend_state_t) 2)
  192.  
  193. /*!
  194. * CKOH pins configuration
  195. */
  196. #define CKOH_AP_SEL 1
  197. #define CKOH_AHB_SEL 2
  198. #define CKOH_IP_SEL 3
  199.  
  200. /*!
  201. * Defines for Stop and DSM mode acknowledgements
  202. */
  203. #define MXC_PM_LOWPWR_ACK_SDMA 0x01
  204. #define MXC_PM_LOWPWR_ACK_IPU 0x02
  205. #define MXC_PM_LOWPWR_ACK_MAX 0x04
  206. #define MXC_PM_LOWPWR_ACK_MQSPI 0x08
  207. #define MXC_PM_LOWPWR_ACK_USB 0x10
  208. #define MXC_PM_LOWPWR_ACK_RTIC 0x20
  209.  
  210. /*
  211. * PMIC configuration
  212. */
  213. #define MXC_PMIC_1_2_VOLT 0xC
  214. #define MXC_PMIC_1_6_VOLT 0x1C
  215. #define MXC_PMIC_1_0_VOLT 0x4
  216. #define MXC_PMIC_DVS_SPEED 0x3
  217.  
  218. /*!
  219. * Implementing Level 1 CRM Gate Control. Level 2 gate control
  220. * is provided at module level using LPMD registers
  221. *
  222. * @param group The desired clock gate control register bits.
  223. * Possible values are 0 through 6
  224. * @param opt The desired option requesting clock to run during stop
  225. * and wait modes or just during the stop mode. Possible
  226. * values are GATE_STOP_WAIT and GATE_STOP.
  227. *
  228. */
  229. void mxc_pm_clockgate(int group, int opt);
  230.  
  231. /*!
  232. * Implementing steps required to transition to low-power modes
  233. *
  234. * @param mode The desired low-power mode. Possible values are,
  235. * WAIT_MODE, STOP_MODE or DSM_MODE
  236. *
  237. */
  238. void mxc_pm_lowpower(int mode);
  239.  
  240. /*!
  241. * Enables acknowledgement from module when entering stop or DSM mode.
  242. *
  243. * @param ack The desired module acknowledgement to enable.
  244. *
  245. */
  246. void mxc_pm_lp_ack_enable(int ack);
  247.  
  248. /*!
  249. * Disables acknowledgement from module when entering stop or DSM mode.
  250. *
  251. * @param ack The desired module acknowledgement to disable.
  252. *
  253. */
  254. void mxc_pm_lp_ack_disable(int ack);
  255.  
  256. /*!
  257. * Implementing steps required to set Integer Scaling
  258. *
  259. * @param armfreq The desired ARM frequency. AHB and IP
  260. * frequency are changed depending on ARM
  261. * frequency and the divider values.
  262. * @param ahbfreq The desired AHB frequency
  263. * @param ipfreq The desired IP frequency
  264. *
  265. * @return Returns 0 on success or
  266. * Returns -PLL_LESS_ARM_ERR if pllfreq is less than
  267. * desired core freq
  268. */
  269. int mxc_pm_intscale(long armfreq, long ahbfreq, long ipfreq);
  270.  
  271. /*!
  272. * To calculate MFI, MFN, MFD values. Using this the output frequency
  273. * whose value is calculated using,
  274. * 2 * REF_FREQ * (MF / PDF), where
  275. * REF_FREQ is 26 Mhz
  276. * MF = MFI + (MFN + MFD)
  277. * PDF is assumed to be 1
  278. *
  279. * @param armfreq The desired ARM frequency
  280. * @param ahbfreq The desired AHB frequency
  281. * @param ipfreq The desired IP frequency
  282. *
  283. * @return Returns 0 on success or
  284. * Returns -1 on error
  285. */
  286. int mxc_pm_pllscale(long armfreq, long ahbfreq, long ipfreq);
  287.  
  288. /*!
  289. * To change AP core frequency and/or voltage suitably
  290. *
  291. * @param armfreq The desired ARM frequency
  292. * @param ahbfreq The desired AHB frequency
  293. * @param ipfreq The desired IP frequency
  294. *
  295. * @return Returns -ERR_FREQ_INVALID on failure
  296. * Returns -MXC_PM_DVFS_DISABLED when DVFS is disabled
  297. * Returns 0 on success
  298. */
  299. int mxc_pm_dvfs(unsigned long armfreq, long ahbfreq, long ipfreq);
  300.  
  301. #ifdef CONFIG_MOT_FEAT_PM
  302.  
  303. /*!
  304. * AP PLLs enum. SCM-A11 AP side has PLL0 (CORE_NORMAL) and PLL2 (USB)
  305. */
  306. typedef enum {
  307. AP_PLL_CORE_NORMAL = 0,
  308. AP_PLL_USB = 2,
  309. } ap_pll_number_t;
  310.  
  311. /*
  312. * This structure stores the MFN values related to a particular PLL.
  313. * These values are used to configure the PLLs when changing frequencies
  314. * and when enabling desense.
  315. */
  316. typedef struct {
  317. unsigned int ap_pll_dp_hfs_op; /* OP value (contains MFI) */
  318. unsigned int ap_pll_dp_hfs_mfn; /* MFN value (non dithered) */
  319. unsigned int ap_pll_dp_hfs_mfd; /* MFD value */
  320. int ap_pll_dp_hfs_mfnplus; /* MFN+ for HFS mode */
  321. int ap_pll_dp_hfs_mfnminus; /* MFN- for HFS mode */
  322. int ap_pll_ppm_value; /* Parts per million dithering value */
  323. unsigned int divider_ratio; /* ARM:AHB:IPG divider ratio */
  324. } ap_pll_mfn_values_t;
  325.  
  326. /*
  327. * De-sense feature: This structure contains values for all AP PLLs.
  328. */
  329. typedef struct {
  330. ap_pll_mfn_values_t ap_core_normal_pll[NUM_DVFSOP_INDEXES];
  331. ap_pll_mfn_values_t ap_core_turbo_pll;
  332. ap_pll_mfn_values_t ap_usb_pll;
  333. } ap_all_plls_mfn_values_t;
  334.  
  335.  
  336.  
  337. /*!
  338. * Dithering enable/disable of the AP and USB PLLs
  339. * SCM-A11: only ap_core_normal_pll_ppm and ap_usb_pll_ppm are concerned.
  340. * Must be called only if a non 0 ppm value has been setup via mxc_pm_dither_setup
  341. *
  342. * @param enable 0: disable, 1: enable
  343. * @param pll_number of the type ap_pll_number_t: PLL to enable/disable
  344. *
  345. * @return 0 OK, -1 wrong PLL number
  346. */
  347. int mxc_pm_dither_enable(int enable, ap_pll_number_t pll_number);
  348.  
  349.  
  350. /*!
  351. * Dithering setup: pass the PLLs ppm values. This function calculates
  352. * and stores the MFN+- values locally for the AP PLL,
  353. * sets up the USB PLL dithering, and enables the dithering.
  354. * SCM-A11: only ap_core_normal_pll_ppm and ap_usb_pll_ppm PLLs are used.
  355. *
  356. * @param ap_core_normal_pll_ppm ppm value of AP core PLL, normal mode
  357. * @param ap_core_turbo_pll_ppm ppm value of AP core PLL, turbo mode
  358. * @param ap_usb_pll_ppm ppm value of USB PLL
  359. *
  360. * @return Returns 0 on success, -1 on invalid ppm value(s)
  361. */
  362. int mxc_pm_dither_setup(u16 ap_core_normal_pll_ppm, u16 ap_core_turbo_pll_ppm, u16 ap_usb_pll_ppm);
  363.  
  364. /*!
  365. * Dithering report: return the PLLs ppm/MFN+- values.
  366. * SCM-A11: only ap_core_normal_pll_ppm and ap_usb_pll_ppm PLLs are used.
  367. *
  368. * @param pllvals ppm and MFN+- values for each AP PLL
  369. *
  370. * @return Returns 0 on success, -1 on failure.
  371. */
  372. void mxc_pm_dither_report(ap_all_plls_mfn_values_t *pllvals);
  373.  
  374. #endif /* CONFIG_MOT_FEAT_PM */
  375.  
  376. #endif
  377.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement