Advertisement
Guest User

Untitled

a guest
Mar 6th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 80.37 KB | None | 0 0
  1. /*
  2. * Copyright © 2004-2007, Motorola, All Rights Reserved.
  3. *
  4. * This program is licensed under a BSD license with the following terms:
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification, are permitted
  7. * provided that the following conditions are met:
  8. *
  9. * - Redistributions of source code must retain the above copyright notice, this list of conditions
  10. * and the following disclaimer.
  11. * - Redistributions in binary form must reproduce the above copyright notice, this list of
  12. * conditions and the following disclaimer in the documentation and/or other materials provided
  13. * with the distribution.
  14. * - Neither the name of Motorola nor the names of its contributors may be used to endorse or
  15. * promote products derived from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  18. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  19. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  20. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  24. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  25. * OF SUCH DAMAGE.
  26. *
  27. * Motorola 2007-Mar-23 - Remove Power Control 1 register from initialization.
  28. * Motorola 2007-Mar-20 - Update NUM_INIT_REGS
  29. * Motorola 2007-Mar-19 - Handle PowerCut
  30. * Motorola 2006-Dec-07 - Fix issue reported by klocwork
  31. * Motorola 2006-Nov-09 - Remove LED register initialization
  32. * Motorola 2006-Oct-11 - New Audio interfaces.
  33. * Motorola 2006-Oct-04 - Support audio output path for linear vibrator.
  34. * Motorola 2006-Sep-28 - Add charger connection status function
  35. * Motorola 2006-Aug-28 - Add Codec Clock and Stereo DAC Clock support.
  36. * Motorola 2006-Aug-04 - Support ambient light sensor
  37. * Motorola 2006-Aug-04 - Turn off transflash power when card not in use
  38. * Motorola 2006-Aug-03 - Mono Adder and Balance Control support
  39. * Motorola 2006-Jul-31 - Updated comments
  40. * Motorola 2006-Jul-26 - Added IOCTL for setting the lithium coin cell enable bit.
  41. * Motorola 2006-Jul-17 - Thermistor on/off for AtoD reading
  42. * Motorola 2006-Jul-17 - Added define for SPI init tables
  43. * Motorola 2006-Jun-22 - Added IOCTL for setting flash mode
  44. * Motorola 2006-May-31 - Added new interface functions to provide backlight status.
  45. * Motorola 2006-May-17 - USB State new functions
  46. * Motorola 2006-May-06 - Implement EMU Common Algorithm
  47. * Motorola 2006-Apr-26 - Removed timing ioctls.
  48. * Motorola 2006-Apr-17 - VAUDIO and BIASEN new function
  49. * Motorola 2006-Apr-12 - Added new interface functions to control backlight brightness.
  50. * Motorola 2006-Apr-11 - USB Charge State Addition
  51. * Motorola 2006-Feb-06 - battery rom interface
  52. * Motorola 2005-Sep-01 - Charger Overvoltage support
  53. * Motorola 2005-Mar-25 - Atlas support
  54. * Motorola 2005-Feb-28 - Addition of Charger Interface
  55. * Motorola 2004-Dec-17 - Initial Creation
  56. */
  57.  
  58. #ifndef __POWER_IC_H__
  59. #define __POWER_IC_H__
  60.  
  61. /*!
  62. * @mainpage Power IC driver
  63. *
  64. * @section intro Introduction
  65. *
  66. * @subsection intro_purpose Purpose
  67. *
  68. * The purpose of this documentation is to document the design and programming interface
  69. * of the power IC device driver for various Linux platforms.
  70. *
  71. * @subsection intro_target Target Audience
  72. *
  73. * This document is intended to be used by software developers.
  74. *
  75. * @subsection intro_problems Problem Reporting Instructions
  76. *
  77. * Problems or corrections to this document must be reported using DDTS.
  78. *
  79. * @section design Design Information
  80. *
  81. * The documentation is divided up on a per-module basis. Click on the
  82. * Modules link above for the detailed design information.
  83. *
  84. * @section api API Information
  85. *
  86. * For a description of the API for the driver, see the documentation for the
  87. * following files:
  88. *
  89. * - lights_backlight.h - Backlight control interface.
  90. * - lights_funlights.h - Interface for funlight control.
  91. * - moto_accy.h - Accessory-related interface.
  92. * - power_ic.h - Interface for the main functionality provided by the driver.
  93. */
  94.  
  95. /*!
  96. * @defgroup poweric_core Power IC core
  97. *
  98. * This module makes up the core of the low-level power IC driver. It implements
  99. * support for the reading and writing of registers and manages the interrupts from
  100. * the power IC. The module also provides the main interface to the remainder of
  101. * the power IC modules (e.g. RTC, A/D converter, etc.).
  102. */
  103.  
  104. /*!
  105. * @defgroup poweric_accy Power IC accessory driver
  106. *
  107. * This module provides the interface for accessory operations through /dev/accy.
  108. */
  109.  
  110. /*!
  111. * @defgroup poweric_atod Power IC AtoD converter driver
  112. *
  113. * This module provides the interface to the power IC for AtoD conversions.
  114. */
  115.  
  116. /*!
  117. * @defgroup poweric_audio Power IC audio driver
  118. *
  119. * This module controls the audio functions of the power IC.
  120. */
  121.  
  122. /*!
  123. * @defgroup poweric_charger Power IC charger driver
  124. *
  125. * This module provides the interface to control various charging functions.
  126. */
  127.  
  128. /*!
  129. * @defgroup poweric_debounce Power IC debounce
  130. *
  131. * This module debounces signals from the power IC, primarily keypresses.
  132. */
  133.  
  134. /*!
  135. * @defgroup poweric_debug Power IC debug
  136. *
  137. * This is a group of source code that is not compiled by default, but is
  138. * included with the driver for developer builds to aid debugging.
  139. */
  140.  
  141. /*!
  142. * @defgroup poweric_emu Power IC EMU driver
  143. *
  144. * This module handles the detection of all devices attached to the EMU bus.
  145. */
  146.  
  147. /*!
  148. * @defgroup poweric_lights Power IC lighting driver
  149. *
  150. * This module controls all of the lights (keypad, display, fun coloured stuff, etc)
  151. * on a phone.
  152. */
  153.  
  154. /*!
  155. * @defgroup poweric_periph Power IC peripheral driver
  156. *
  157. * This module makes up the interface to the power IC for peripherals. This includes
  158. * things like the vibrator, Bluetooth, and the flash card.
  159. */
  160.  
  161. /*!
  162. * @defgroup poweric_power_management Power IC power management driver
  163. *
  164. * This module provides interfaces for managing various power-related functions.
  165. */
  166.  
  167. /*!
  168. * @defgroup poweric_rtc Power IC RTC driver
  169. *
  170. * This module makes up the interface to the power IC for the real-time clock.
  171. */
  172.  
  173. /*!
  174. * @defgroup poweric_tcmd_ioctl Power IC TCMD ioctl support
  175. *
  176. * This module will contain all power-related ioctls that are required for TCMD
  177. * support unless the requirements can be met with ones that already exist for normal
  178. * operation.
  179. */
  180.  
  181. /*!
  182. * @defgroup poweric_brt Power IC BRT support
  183. *
  184. * This module will contain all battery rom data-related ioctls
  185. */
  186.  
  187. /*!
  188. * @file power_ic.h
  189. *
  190. * @ingroup poweric_core
  191. *
  192. * @brief Contains power IC driver interface information (types, enums, macros, functions, etc.)
  193. *
  194. * This file contains the following information:
  195. * - User-space interface
  196. * - @ref ioctl_core "Core ioctl commands"
  197. * - @ref ioctl_atod "AtoD converter ioctl commands"
  198. * - @ref ioctl_audio "Audio ioctl commands"
  199. * - @ref ioctl_charger "Charger ioctl commands"
  200. * - @ref ioctl_lights "Lighting ioctl commands"
  201. * - @ref ioctl_periph "Peripheral ioctl commands"
  202. * - @ref ioctl_pwr_mgmt "Power management ioctl commands"
  203. * - @ref ioctl_rtc "RTC ioctl commands"
  204. * - @ref ioctl_tcmd "Test Command ioctl commands"
  205. * - @ref ioctl_brt "BRT ioctl commands"
  206. * - @ref ioctl_types "Types used in ioctl calls"
  207. */
  208.  
  209. #include <linux/ioctl.h>
  210. #include <linux/lights_backlight.h>
  211. #include <linux/lights_funlights.h>
  212. #include <stdbool.h>
  213.  
  214. /* Including the kernel version of the time header from user-space is causing some
  215. * headaches. Until someone comes up with a better idea, use the kernel version for
  216. * kernel builds and the system's version for user-space. We only really care about
  217. * timeval anway...
  218. */
  219. #ifdef __KERNEL__
  220. #include <linux/time.h>
  221. #else
  222. #include <sys/time.h>
  223. #include <sys/types.h>
  224. #endif
  225.  
  226.  
  227. /*******************************************************************************************
  228. * Universal constants
  229. *
  230. * These are constants that are universal to use of the power IC driver from both kernel
  231. * and user space..
  232. ******************************************************************************************/
  233. /*! The major number of the power IC driver. */
  234. #define POWER_IC_MAJOR_NUM 220
  235.  
  236. /*! The name of the device in /dev. */
  237. #define POWER_IC_DEV_NAME "power_ic"
  238.  
  239. /*! The number of individual AtoD readings returned for the AtoD raw conversion request. */
  240. #define POWER_IC_ATOD_NUM_RAW_RESULTS 8
  241.  
  242. /******************************************************************************************
  243. * NOTE
  244. *
  245. * #ifdefs are not recognized outside of the kernel, so they cannot be used in this
  246. * global header.
  247. *
  248. * DO NOT USE THESE REGISTERS DIRECTLY!!!!
  249. *
  250. * BE WARNED:
  251. *
  252. * We need to be able to support multiple platforms and if you directly access these
  253. * registers, your stuff will break.
  254. ******************************************************************************************/
  255.  
  256. /*!@cond INTERNAL */
  257. /*! Number of registers in SPI Init tables */
  258. #define NUM_INIT_REGS 30
  259. /*!@endcond */
  260.  
  261. #define NUM_INIT_TABLE_COLUMNS 2
  262.  
  263. /*! Enumeration of all registers in the power IC(s) */
  264. typedef enum
  265. {
  266. /* Beginning of Atlas Registers */
  267. POWER_IC_REG_ATLAS_FIRST_REG,
  268.  
  269. POWER_IC_REG_ATLAS_INT_STAT_0 = POWER_IC_REG_ATLAS_FIRST_REG, /*!< Interrupt Status 0 */
  270. POWER_IC_REG_ATLAS_INT_MASK_0, /*!< Interrupt Mask 0 */
  271. POWER_IC_REG_ATLAS_INT_SENSE_0, /*!< Interrupt Sense 0 */
  272. POWER_IC_REG_ATLAS_INT_STAT_1, /*!< Interrupt Status 1 */
  273. POWER_IC_REG_ATLAS_INT_MASK_1, /*!< Interrupt Mask 1 */
  274. POWER_IC_REG_ATLAS_INT_SENSE_1, /*!< Interrupt Sense 1 */
  275. POWER_IC_REG_ATLAS_PWRUP_SENSE, /*!< Power Up Mode Sense */
  276. POWER_IC_REG_ATLAS_REVISION, /*!< Revision */
  277. POWER_IC_REG_ATLAS_SEMAPHORE, /*!< Semaphore */
  278. POWER_IC_REG_ATLAS_ARB_PERIPH_AUDIO, /*!< Arbitration Peripheral Audio */
  279. POWER_IC_REG_ATLAS_ARB_SWITCHERS, /*!< Arbitration Switchers */
  280. POWER_IC_REG_ATLAS_ARB_REG_0, /*!< Arbitration Regulators 0 */
  281. POWER_IC_REG_ATLAS_ARB_REG_1, /*!< Arbitration Regulators 1 */
  282. POWER_IC_REG_ATLAS_PWR_CONTROL_0, /*!< Power Control 0 */
  283. POWER_IC_REG_ATLAS_PWR_CONTROL_1, /*!< Power Control 1 */
  284. POWER_IC_REG_ATLAS_PWR_CONTROL_2, /*!< Power Control 2 */
  285. POWER_IC_REG_ATLAS_REGEN_ASSIGN, /*!< Regen Assignment */
  286. POWER_IC_REG_ATLAS_CONTROL_SPARE, /*!< Control Spare */
  287. POWER_IC_REG_ATLAS_MEMORY_A, /*!< Memory A */
  288. POWER_IC_REG_ATLAS_MEMORY_B, /*!< Memory B */
  289. POWER_IC_REG_ATLAS_RTC_TIME, /*!< RTC Time */
  290. POWER_IC_REG_ATLAS_RTC_ALARM, /*!< RTC Alarm */
  291. POWER_IC_REG_ATLAS_RTC_DAY, /*!< RTC Day */
  292. POWER_IC_REG_ATLAS_RTC_DAY_ALARM, /*!< RTC Day Alarm */
  293. POWER_IC_REG_ATLAS_SWITCHERS_0, /*!< Switchers 0 */
  294. POWER_IC_REG_ATLAS_SWITCHERS_1, /*!< Switchers 1 */
  295. POWER_IC_REG_ATLAS_SWITCHERS_2, /*!< Switchers 2 */
  296. POWER_IC_REG_ATLAS_SWITCHERS_3, /*!< Switchers 3 */
  297. POWER_IC_REG_ATLAS_SWITCHERS_4, /*!< Switchers 4 */
  298. POWER_IC_REG_ATLAS_SWITCHERS_5, /*!< Switchers 5 */
  299. POWER_IC_REG_ATLAS_REG_SET_0, /*!< Regulator Setting 0 */
  300. POWER_IC_REG_ATLAS_REG_SET_1, /*!< Regulator Setting 1 */
  301. POWER_IC_REG_ATLAS_REG_MODE_0, /*!< Regulator Mode 0 */
  302. POWER_IC_REG_ATLAS_REG_MODE_1, /*!< Regulator Mode 1 */
  303. POWER_IC_REG_ATLAS_PWR_MISC, /*!< Power Miscellaneous */
  304. POWER_IC_REG_ATLAS_PWR_SPARE, /*!< Power Spare */
  305. POWER_IC_REG_ATLAS_AUDIO_RX_0, /*!< Audio Rx 0 */
  306. POWER_IC_REG_ATLAS_AUDIO_RX_1, /*!< Audio Rx 1 */
  307. POWER_IC_REG_ATLAS_AUDIO_TX, /*!< Audio Tx */
  308. POWER_IC_REG_ATLAS_SSI_NETWORK, /*!< SSI Network */
  309. POWER_IC_REG_ATLAS_AUDIO_CODEC, /*!< Audio Codec */
  310. POWER_IC_REG_ATLAS_AUDIO_STEREO_DAC, /*!< Audio Stereo DAC */
  311. POWER_IC_REG_ATLAS_AUDIO_SPARE, /*!< Audio Spare */
  312. POWER_IC_REG_ATLAS_ADC_0, /*!< ADC 0 */
  313. POWER_IC_REG_ATLAS_ADC_1, /*!< ADC 1 */
  314. POWER_IC_REG_ATLAS_ADC_2, /*!< ADC 2 */
  315. POWER_IC_REG_ATLAS_ADC_3, /*!< ADC 3 */
  316. POWER_IC_REG_ATLAS_ADC_4, /*!< ADC 4 */
  317. POWER_IC_REG_ATLAS_CHARGER_0, /*!< Charger 0 */
  318. POWER_IC_REG_ATLAS_USB_0, /*!< USB 0 */
  319. POWER_IC_REG_ATLAS_CHARGE_USB_1, /*!< USB 1 */
  320. POWER_IC_REG_ATLAS_LED_CONTROL_0, /*!< LED Control 0 */
  321. POWER_IC_REG_ATLAS_LED_CONTROL_1, /*!< LED Control 1 */
  322. POWER_IC_REG_ATLAS_LED_CONTROL_2, /*!< LED Control 2 */
  323. POWER_IC_REG_ATLAS_LED_CONTROL_3, /*!< LED Control 3 */
  324. POWER_IC_REG_ATLAS_LED_CONTROL_4, /*!< LED Control 4 */
  325. POWER_IC_REG_ATLAS_LED_CONTROL_5, /*!< LED Control 5 */
  326. POWER_IC_REG_ATLAS_SPARE, /*!< Spare */
  327. POWER_IC_REG_ATLAS_TRIM_0, /*!< Trim 0 */
  328. POWER_IC_REG_ATLAS_TRIM_1, /*!< Trim 1 */
  329. POWER_IC_REG_ATLAS_TEST_0, /*!< Test 0 */
  330. POWER_IC_REG_ATLAS_TEST_1, /*!< Test 1*/
  331. POWER_IC_REG_ATLAS_TEST_2, /*!< Test 2 */
  332. POWER_IC_REG_ATLAS_TEST_3, /*!< Test 3 */
  333.  
  334. POWER_IC_REG_ATLAS_LAST_REG = POWER_IC_REG_ATLAS_TEST_3,
  335.  
  336. /* End of Atlas Registers */
  337.  
  338. POWER_IC_REG_NUM_REGS_ATLAS
  339. } POWER_IC_REGISTER_T;
  340.  
  341. /*! Enumeration of possible power IC events */
  342. typedef enum
  343. {
  344. POWER_IC_EVENT_ATLAS_FIRST_REG,
  345.  
  346. /* Interrupt Status 0 Register */
  347. POWER_IC_EVENT_ATLAS_ADCDONEI = POWER_IC_EVENT_ATLAS_FIRST_REG, /*!< AtoD Conversion complete interrupt */
  348. POWER_IC_EVENT_ATLAS_ADCBISDONEI, /*!< ADCBIS complete interrupt */
  349. POWER_IC_EVENT_ATLAS_TSI, /*!< Touchscreen interrupt */
  350. POWER_IC_EVENT_ATLAS_WHIGHI, /*!< ADC reading above high limit interrupt */
  351. POWER_IC_EVENT_ATLAS_WLOWI, /*!< ADC reading below low limit interrupt */
  352. POWER_IC_EVENT_ATLAS_RESERVED1, /*!< For future use */
  353. POWER_IC_EVENT_ATLAS_CHGDETI, /*!< Charger Attached interrupt */
  354. POWER_IC_EVENT_ATLAS_CHGOVI, /*!< Charger overvoltage detection interrupt */
  355. POWER_IC_EVENT_ATLAS_CHGREVI, /*!< Charger path reverse current interrupt */
  356. POWER_IC_EVENT_ATLAS_CHGSHORTI, /*!< Charger path short current interrupt */
  357. POWER_IC_EVENT_ATLAS_CCCVI, /*!< BP regulator V or I interrupt */
  358. POWER_IC_EVENT_ATLAS_CHGCURRI, /*!< Charge current below threshold warning interrupt */
  359. POWER_IC_EVENT_ATLAS_BPONI, /*!< BP turn on threshold interrupt */
  360. POWER_IC_EVENT_ATLAS_LOBATLI, /*!< Low battery low threshold warning interrupt */
  361. POWER_IC_EVENT_ATLAS_LOBATHI, /*!< Low battery high threshold warning interrupt */
  362. POWER_IC_EVENT_ATLAS_RESERVED2, /*!< For future use */
  363. POWER_IC_EVENT_ATLAS_USBI, /*!< USB VBUS detect interrupt */
  364. POWER_IC_EVENT_ATLAS_USB2V0S, /*!< USB2V0 sense bit, unused in mask interrupt */
  365. POWER_IC_EVENT_ATLAS_USB0V8S, /*!< USB0V8 sense bit, unused in mask interrupt */
  366. POWER_IC_EVENT_ATLAS_IDI, /*!< USB ID detect interrupt */
  367. POWER_IC_EVENT_ATLAS_ID_FLOAT = POWER_IC_EVENT_ATLAS_IDI,
  368. POWER_IC_EVENT_ATLAS_ID_GROUND, /*!< USB ID Ground sense bit (unused interrupt status/mask) */
  369. POWER_IC_EVENT_ATLAS_SE1I, /*!< Single ended 1 detect interrupt */
  370. POWER_IC_EVENT_ATLAS_CKDETI, /*!< Carkit detect interrupt */
  371. POWER_IC_EVENT_ATLAS_RESERVED3, /*!< For future use */
  372.  
  373. POWER_IC_EVENT_ATLAS_FIRST_REG_LAST = POWER_IC_EVENT_ATLAS_RESERVED3,
  374.  
  375. POWER_IC_EVENT_ATLAS_SECOND_REG,
  376.  
  377. /* Interrupt Status 1 Register */
  378. POWER_IC_EVENT_ATLAS_1HZI = POWER_IC_EVENT_ATLAS_SECOND_REG, /*!< 1 Hz timetick */
  379. POWER_IC_EVENT_ATLAS_TODAI, /*!< Time of day alarm interrupt */
  380. POWER_IC_EVENT_ATLAS_RESERVED4, /*!< For future use */
  381. POWER_IC_EVENT_ATLAS_ONOFD1I, /*!< ON1B event interrupt */
  382. POWER_IC_EVENT_ATLAS_ONOFD2I, /*!< ON2B event interrupt */
  383. POWER_IC_EVENT_ATLAS_ONOFD3I, /*!< ON3B event interrupt */
  384. POWER_IC_EVENT_ATLAS_SYSRSTI, /*!< System reset interrupt */
  385. POWER_IC_EVENT_ATLAS_RTCRSTI, /*!< RTC reset event interrupt */
  386. POWER_IC_EVENT_ATLAS_PCI, /*!< Power cut event interrupt */
  387. POWER_IC_EVENT_ATLAS_WARMI, /*!< Warm start event interrupt */
  388. POWER_IC_EVENT_ATLAS_MEMHLDI, /*!< Memory hold event interrupt */
  389. POWER_IC_EVENT_ATLAS_PWRRDYI, /*!< Power Gate and DVS power ready interrupt */
  390. POWER_IC_EVENT_ATLAS_THWARNLI, /*!< Thermal warning low threshold interrupt */
  391. POWER_IC_EVENT_ATLAS_THWARNHI, /*!< Thermal warning high threshold interrupt */
  392. POWER_IC_EVENT_ATLAS_CLKI, /*!< Clock source change interrupt */
  393. POWER_IC_EVENT_ATLAS_SEMAFI, /*!< Semaphore */
  394. POWER_IC_EVENT_ATLAS_RESERVED5, /*!< For future use */
  395. POWER_IC_EVENT_ATLAS_MC2BI, /*!< Microphone bias 2 detect interrupt */
  396. POWER_IC_EVENT_ATLAS_HSDETI, /*!< Headset attach interrupt */
  397. POWER_IC_EVENT_ATLAS_HSLI, /*!< Stereo headset detect interrupt */
  398. POWER_IC_EVENT_ATLAS_ALSPTHI, /*!< Thermal shutdown Alsp interrupt */
  399. POWER_IC_EVENT_ATLAS_AHSSHORTI, /*!< Short circuit on Ahs outputs interrupt */
  400. POWER_IC_EVENT_ATLAS_RESERVED6, /*!< For future use */
  401. POWER_IC_EVENT_ATLAS_RESERVED7, /*!< For future use */
  402.  
  403. POWER_IC_EVENT_ATLAS_SECOND_REG_LAST = POWER_IC_EVENT_ATLAS_RESERVED7,
  404.  
  405. POWER_IC_EVENT_NUM_EVENTS_ATLAS
  406. } POWER_IC_EVENT_T;
  407.  
  408. /*! Defines the possible settings for the state of a power IC peripheral */
  409. typedef enum
  410. {
  411. POWER_IC_PERIPH_OFF,
  412. POWER_IC_PERIPH_ON
  413. } POWER_IC_PERIPH_ONOFF_T;
  414.  
  415. /*! Sample rate for the ST Dac*/
  416. typedef enum
  417. {
  418. POWER_IC_ST_DAC_SR_8000,
  419. POWER_IC_ST_DAC_SR_11025,
  420. POWER_IC_ST_DAC_SR_12000,
  421. POWER_IC_ST_DAC_SR_16000,
  422. POWER_IC_ST_DAC_SR_22050,
  423. POWER_IC_ST_DAC_SR_24000,
  424. POWER_IC_ST_DAC_SR_32000,
  425. POWER_IC_ST_DAC_SR_44100,
  426. POWER_IC_ST_DAC_SR_48000
  427. } POWER_IC_ST_DAC_SR_T;
  428.  
  429. /*! Sample rate for the codec */
  430. typedef enum
  431. {
  432. POWER_IC_CODEC_SR_8000,
  433. POWER_IC_CODEC_SR_16000
  434. } POWER_IC_CODEC_SR_T;
  435.  
  436. /*! Settings for mono adder */
  437. typedef enum
  438. {
  439. POWER_IC_MONO_LEFT_RIGHT_IND,
  440. POWER_IC_MONO_STEREO_OPP,
  441. POWER_IC_MONO_STEREO_MONO_CONV,
  442. POWER_IC_MONO_MONO_OPP
  443. } POWER_IC_AUD_MONO_ADDER_T;
  444.  
  445. /*! Attenuation in dB for balance control */
  446. typedef enum
  447. {
  448. POWER_IC_BAL_CTRL_R_0,
  449. POWER_IC_BAL_CTRL_R_3,
  450. POWER_IC_BAL_CTRL_R_6,
  451. POWER_IC_BAL_CTRL_R_9,
  452. POWER_IC_BAL_CTRL_R_12,
  453. POWER_IC_BAL_CTRL_R_15,
  454. POWER_IC_BAL_CTRL_R_18,
  455. POWER_IC_BAL_CTRL_R_21,
  456. POWER_IC_BAL_CTRL_L_0,
  457. POWER_IC_BAL_CTRL_L_3,
  458. POWER_IC_BAL_CTRL_L_6,
  459. POWER_IC_BAL_CTRL_L_9,
  460. POWER_IC_BAL_CTRL_L_12,
  461. POWER_IC_BAL_CTRL_L_15,
  462. POWER_IC_BAL_CTRL_L_18,
  463. POWER_IC_BAL_CTRL_L_21
  464. } POWER_IC_AUD_BAL_CTRL_T;
  465.  
  466. /* Settings for Codec clock. */
  467. typedef enum
  468. {
  469. POWER_IC_AUD_CODEC_CLOCK_13_MHZ, /* CLI = 13.0 MHz */
  470. POWER_IC_AUD_CODEC_CLOCK_15_MHZ, /* CLI = 15.36 MHz */
  471. POWER_IC_AUD_CODEC_CLOCK_16_MHZ, /* CLI = 16.8 MHz */
  472. POWER_IC_AUD_CODEC_CLOCK_NA_1, /* This setting is unused. */
  473. POWER_IC_AUD_CODEC_CLOCK_26_MHZ, /* CLI = 26.0 MHz */
  474. POWER_IC_AUD_CODEC_CLOCK_NA_2, /* This setting is unused. */
  475. POWER_IC_AUD_CODEC_CLOCK_NA_3, /* This setting is unused. */
  476. POWER_IC_AUD_CODEC_CLOCK_33_MHZ /* CLI = 33.6 MHz */
  477. } POWER_IC_AUD_CODEC_CLOCK_T;
  478.  
  479. /* Settings for Stereo DAC clock. */
  480. typedef enum
  481. {
  482. POWER_IC_AUD_ST_DAC_CLOCK_13_MHZ, /* CLI = 13.0 MHz */
  483. POWER_IC_AUD_ST_DAC_CLOCK_15_MHZ, /* CLI = 15.36 MHz */
  484. POWER_IC_AUD_ST_DAC_CLOCK_16_MHZ, /* CLI = 16.8 MHz */
  485. POWER_IC_AUD_ST_DAC_CLOCK_NA, /* This setting is unused.*/
  486. POWER_IC_AUD_ST_DAC_CLOCK_26_MHZ, /* CLI = 26.0 MHz */
  487. POWER_IC_AUD_ST_DAC_CLOCK_12_MHZ, /* CLI = 12.0 MHz */
  488. POWER_IC_AUD_ST_DAC_CLOCK_3_MHZ, /* CLI = 3.6864 MHz */
  489. POWER_IC_AUD_ST_DAC_CLOCK_33_MHZ /* CLI = 33.6 MHz */
  490. } POWER_IC_AUD_ST_DAC_CLOCK_T;
  491.  
  492. /*! For the AtoD interface, these are the individual channels that can be requested. */
  493. typedef enum
  494. {
  495. POWER_IC_ATOD_CHANNEL_AD6,
  496. POWER_IC_ATOD_CHANNEL_BATT,
  497. POWER_IC_ATOD_CHANNEL_BATT_CURR,
  498. POWER_IC_ATOD_CHANNEL_BPLUS,
  499. POWER_IC_ATOD_CHANNEL_CHARGER_ID,
  500. POWER_IC_ATOD_CHANNEL_CHRG_CURR,
  501. POWER_IC_ATOD_CHANNEL_COIN_CELL,
  502. POWER_IC_ATOD_CHANNEL_MOBPORTB,
  503. POWER_IC_ATOD_CHANNEL_TEMPERATURE,
  504. POWER_IC_ATOD_CHANNEL_AMBIENT_LIGHT,
  505. } POWER_IC_ATOD_CHANNEL_T;
  506.  
  507. #define POWER_IC_ATOD_NUM_CHANNELS (POWER_IC_ATOD_CHANNEL_AMBIENT_LIGHT + 1)
  508.  
  509. /*! The timing requested for the battery/current conversion. */
  510. typedef enum
  511. {
  512. POWER_IC_ATOD_TIMING_IMMEDIATE,
  513. POWER_IC_ATOD_TIMING_IN_BURST,
  514. POWER_IC_ATOD_TIMING_OUT_OF_BURST
  515. } POWER_IC_ATOD_TIMING_T;
  516.  
  517. /*! Indication of whether a hardware-timed conversion completed or timed out. */
  518. typedef enum
  519. {
  520. POWER_IC_ATOD_CONVERSION_TIMEOUT,
  521. POWER_IC_ATOD_CONVERSION_COMPLETE
  522. } POWER_IC_ATOD_CONVERSION_TIMEOUT_T;
  523.  
  524. /*! The direction in which current will be measured for the battery/current conversion. */
  525. typedef enum
  526. {
  527. POWER_IC_ATOD_CURR_POLARITY_DISCHARGE,
  528. POWER_IC_ATOD_CURR_POLARITY_CHARGE,
  529. } POWER_IC_ATOD_CURR_POLARITY_T;
  530.  
  531. /*! Power-up reasons */
  532. typedef enum
  533. {
  534. POWER_IC_POWER_UP_REASON_NONE,
  535. POWER_IC_POWER_UP_REASON_FIRST_POWER_KEY_LONG, /*!< indicates sense bit still active */
  536. POWER_IC_POWER_UP_REASON_FIRST_POWER_KEY_SHORT, /*!< indicates only status bit active */
  537. POWER_IC_POWER_UP_REASON_SECOND_POWER_KEY_LONG, /*!< indicates sense bit still active */
  538. POWER_IC_POWER_UP_REASON_SECOND_POWER_KEY_SHORT, /*!< indicates only status bit active */
  539. POWER_IC_POWER_UP_REASON_THIRD_POWER_KEY_LONG, /*!< indicates sense bit still active */
  540. POWER_IC_POWER_UP_REASON_THIRD_POWER_KEY_SHORT, /*!< indicates only status bit active */
  541. POWER_IC_POWER_UP_REASON_CHARGER,
  542. POWER_IC_POWER_UP_REASON_POWER_CUT,
  543. POWER_IC_POWER_UP_REASON_ALARM,
  544. } POWER_IC_POWER_UP_REASON_T;
  545.  
  546.  
  547.  
  548. /*! Power paths that can be selected. */
  549. typedef enum
  550. {
  551. POWER_IC_CHARGER_POWER_DUAL_PATH, /*!< Dual-path mode under hardware control. */
  552. POWER_IC_CHARGER_POWER_CURRENT_SHARE, /*!< Current-share under hardware control. */
  553. POWER_IC_CHARGER_POWER_DUAL_PATH_SW_OVERRIDE, /*!< Dual-path mode forced under software control. */
  554. POWER_IC_CHARGER_POWER_CURRENT_SHARE_SW_OVERRIDE /*!< Current-share forced under software control. */
  555. } POWER_IC_CHARGER_POWER_PATH_T;
  556.  
  557. /*! USB Charge States that can be selected */
  558. typedef enum
  559. {
  560. POWER_IC_CHARGER_CHRG_STATE_CHARGE, /*!< High charge state (500mA) */
  561. POWER_IC_CHARGER_CHRG_STATE_SLOW_CHARGE, /*!< Low charge state (100mA) */
  562. POWER_IC_CHARGER_CHRG_STATE_SUSPEND, /*!< USB Suspend mode */
  563. POWER_IC_CHARGER_CHRG_STATE_FAIL_ENUM, /*!< USB Failed Enumeration */
  564. POWER_IC_CHARGER_CHRG_STATE_NOT_ALLOWED, /*!< USB state not allowed */
  565. POWER_IC_CHARGER_CHRG_STATE_NONE_CURR, /*!< No current available */
  566. POWER_IC_CHARGER_CHRG_STATE_INVALID, /*!< Invalid USB State */
  567. POWER_IC_CHARGER_CHRG_STATE_UNKNOWN = 0xFF /*!< Initial Unknown State */
  568. } POWER_IC_CHARGER_CHRG_STATE_T;
  569.  
  570. /*! SIM Voltages that can be selected. */
  571. typedef enum
  572. {
  573. POWER_IC_SIM_VOLT_18, /*!< indicates a 1.8 voltage setting for SIM */
  574. POWER_IC_SIM_VOLT_30 /*!< indicates a 3.0 voltage setting for SIM */
  575. } POWER_IC_SIM_VOLTAGE_T;
  576.  
  577. /*! Identifiers for bits that can be read/written to using the Backup Memory API. */
  578. typedef enum
  579. {
  580. POWER_IC_BACKUP_MEMORY_ID_MEMA, /*!< All of Memory Register A. */
  581. POWER_IC_BACKUP_MEMORY_ID_MEMB, /*!< All of Memory Register B. */
  582. POWER_IC_BACKUP_MEMORY_ID_ATLAS_BACKUP_FLASH_MODE, /*!< Signal MBM to go into flash mode after reboot. */
  583. POWER_IC_BACKUP_MEMORY_ID_ATLAS_BACKUP_PANIC, /*!< Signal MBM that a panic occurred. */
  584. POWER_IC_BACKUP_MEMORY_ID_ATLAS_BACKUP_FOTA_MODE, /*!< Signal MBM to go in FOTA mode after reboot. */
  585. POWER_IC_BACKUP_MEMORY_ID_NUM_ELEMENTS /*!< Number of ID elements defined. */
  586. } POWER_IC_BACKUP_MEMORY_ID_T;
  587.  
  588. /*! States to determine possible CONN modes, this table is tied to hardware */
  589. typedef enum
  590. {
  591. POWER_IC_EMU_CONN_MODE_USB, /*000*/
  592. POWER_IC_EMU_CONN_MODE_UART1, /*001*/
  593. POWER_IC_EMU_CONN_MODE_UART2, /*010*/
  594. POWER_IC_EMU_CONN_MODE_RESERVED, /*011*/
  595. POWER_IC_EMU_CONN_MODE_MONO_AUDIO, /*100*/
  596. POWER_IC_EMU_CONN_MODE_STEREO_AUDIO, /*101*/
  597. POWER_IC_EMU_CONN_MODE_LOOPBACK_RIGHT, /*110*/
  598. POWER_IC_EMU_CONN_MODE_LOOPBACK_LEFT, /*111*/
  599.  
  600. POWER_IC_EMU_CONN_MODE__NUM
  601. } POWER_IC_EMU_CONN_MODE_T;
  602.  
  603. /*! States to determine the transceiver states */
  604. typedef enum
  605. {
  606. EMU_XCVR_OFF,
  607. EMU_XCVR_PPD_DETECT,
  608. EMU_XCVR_SPD_DETECT,
  609. EMU_XCVR_PPD,
  610. EMU_XCVR_PPD_AUDIO,
  611. EMU_XCVR_SPD,
  612. EMU_XCVR_SPD_AUDIO,
  613. EMU_XCVR_USB_HOST,
  614. EMU_XCVR_FACTORY_MODE,
  615.  
  616. EMU_XCVR__NUM
  617. } EMU_XCVR_T;
  618.  
  619. /*! For battery rom interface */
  620. #define BRT_BYTE_SIZE 128
  621. #define BRT_UID_SIZE 8
  622.  
  623. typedef enum
  624. {
  625. BRT_NONE = 0,
  626. BRT_W_DATA,
  627. BRT_WO_DATA,
  628. BRT_INVALID
  629. } BRT_DATA_T;
  630.  
  631.  
  632.  
  633. #ifndef DOXYGEN_SHOULD_SKIP_THIS /* This stuff just clutters the documentation. Don't bother. */
  634. /*!
  635. * @name ioctl() command ranges
  636. *
  637. * These are the ranges of ioctl commands for the power IC driver. These cannot be used
  638. * directly from user-space, but are used to construct the request parameters used in ioctl()
  639. * calls to the driver.
  640. */
  641.  
  642. /* @{ */
  643.  
  644. /* Base of all the ioctl() commands that will be handled by the driver core. */
  645. #define POWER_IC_IOC_CMD_CORE_BASE 0x00
  646. /* Last of the range of ioctl() commands reserved for the driver core. */
  647. #define POWER_IC_IOC_CMD_CORE_LAST_CMD (POWER_IC_IOC_CMD_CORE_BASE + 0x0F)
  648.  
  649. /* Base of all the ioctl() commands that will be handled by the peripheral module. */
  650. #define POWER_IC_IOC_CMD_PERIPH_BASE (POWER_IC_IOC_CMD_CORE_LAST_CMD + 1)
  651. /* This is the last of the range of ioctl() commands reserved for the peripheral interface. */
  652. #define POWER_IC_IO_CMD_PERIPH_LAST_CMD (POWER_IC_IOC_CMD_PERIPH_BASE + 0x0F)
  653.  
  654. /* Base for the ioctl() commands for the RTC */
  655. #define POWER_IC_IOC_RTC_BASE (POWER_IC_IO_CMD_PERIPH_LAST_CMD + 1)
  656. /* Last ioctl() command reserved for the RTC. */
  657. #define POWER_IC_IOC_RTC_LAST_CMD (POWER_IC_IOC_RTC_BASE + 0x0F)
  658.  
  659. /*! Base for the ioctl() commands for AtoD requests */
  660. #define POWER_IC_IOC_ATOD_BASE (POWER_IC_IOC_RTC_LAST_CMD + 1)
  661. /*! Last ioctl() command reserved for AtoD. */
  662. #define POWER_IC_IOC_ATOD_LAST_CMD (POWER_IC_IOC_ATOD_BASE + 0x0F)
  663.  
  664. /*! Base for the ioctl() commands for the power management module. */
  665. #define POWER_IC_IOC_PMM_BASE (POWER_IC_IOC_ATOD_LAST_CMD + 1)
  666. /*! Last ioctl() command reserved for power management. */
  667. #define POWER_IC_IOC_PMM_LAST_CMD (POWER_IC_IOC_PMM_BASE + 0x0F)
  668.  
  669. /* Base of all the ioctl() commands that will be handled by the audio module. */
  670. #define POWER_IC_IOC_CMD_AUDIO_BASE (POWER_IC_IOC_PMM_LAST_CMD + 1)
  671. /* Last ioctl() command reserved for the audio interface. */
  672. #define POWER_IC_IOC_CMD_AUDIO_LAST_CMD (POWER_IC_IOC_CMD_AUDIO_BASE + 0x0F)
  673.  
  674. /* This is the base of all the ioctl() commands that will be handled by the lights module. */
  675. #define POWER_IC_IOC_LIGHTS_BASE (POWER_IC_IOC_CMD_AUDIO_LAST_CMD + 1)
  676. /* Last ioctl() command reserved for the lights interface. */
  677. #define POWER_IC_IOC_LIGHTS_LAST_CMD (POWER_IC_IOC_LIGHTS_BASE + 0x0F)
  678.  
  679. /* This is the base of all the ioctl() commands that will be handled by the charger module. */
  680. #define POWER_IC_IOC_CMD_CHARGER_BASE (POWER_IC_IOC_LIGHTS_LAST_CMD + 1)
  681. /* Last ioctl() command reserved for the charger interface. */
  682. #define POWER_IC_IOC_CHARGER_LAST_CMD (POWER_IC_IOC_CMD_CHARGER_BASE + 0x0F)
  683.  
  684. /* Base of all the ioctl() commands that will be handled by the tcmd_ioctl module. */
  685. #define POWER_IC_IOC_CMD_TCMD_BASE (POWER_IC_IOC_CHARGER_LAST_CMD + 1)
  686. /* Last ioctl() command reserved for the tcmd_ioctl module. */
  687. #define POWER_IC_IOC_CMD_TCMD_LAST_CMD (POWER_IC_IOC_CMD_TCMD_BASE + 0x0F)
  688.  
  689. /* Base of all the ioctl() commands that will be handled by the brt module. */
  690. #define POWER_IC_IOC_CMD_BRT_BASE (POWER_IC_IOC_CMD_TCMD_LAST_CMD + 1)
  691. /* Last ioctl() command reserved for the brt_ioctl module. */
  692. #define POWER_IC_IOC_CMD_BRT_LAST_CMD (POWER_IC_IOC_CMD_BRT_BASE + 0x0F)
  693.  
  694. /* @} End of ioctl range constants. -------------------------------------------------------------- */
  695.  
  696. /* Old IOC_CMD numbers that we have removed. These were clearly commented that they should
  697. * not be used in calls to ioctl(), but they got used anyway. These are here only to allow
  698. * the build to complete so we don't hold too much up right now.
  699. *
  700. * In case you missed it, DO NOT USE THESE. EVER.
  701. */
  702. #define POWER_IC_IOC_LIGHTS_BACKLIGHTS_SET (POWER_IC_IOC_LIGHTS_BASE + 0x00)
  703. #define POWER_IC_IOC_LIGHTS_FL_SET_CONTROL (POWER_IC_IOC_LIGHTS_BASE + 0x01)
  704. #define POWER_IC_IOC_LIGHTS_FL_UPDATE (POWER_IC_IOC_LIGHTS_BASE + 0x02)
  705.  
  706. #endif /* Doxygen skips over this... */
  707.  
  708. /*******************************************************************************************
  709. * Driver ioctls
  710. *
  711. * All of the ioctl commands supported by the driver are in this section.
  712. *
  713. * Note: when adding new ioctl commands, each should be fully documented in the format used
  714. * for the existing commands. This will be the only documentation available for each ioctl,
  715. * so it is in our best interest to provide useful and consistent information here.
  716. *
  717. * Typically, each ioctl command should have the following:
  718. *
  719. * A brief, one-sentence description prefixed with doxygen's brief tag.
  720. *
  721. * A paragraph with a more detailed description of the operation of the command.
  722. *
  723. * A paragraph describing inputs to the command.
  724. *
  725. * A paragraph describing outputs from the command.
  726. *
  727. * optionally, one or more notes about the command (prefxed by Doxygen's note tag).
  728. ******************************************************************************************/
  729.  
  730. /*!
  731. * @anchor ioctl_core
  732. * @name Core ioctl() commands
  733. *
  734. * These are the commands that can be passed to ioctl() to request low-level operations on the
  735. * power IC driver. In general. <b>the basic register access commands should not be used unless
  736. * absolutely necessary</b>. Instead, the abstracted interfaces should be used to read and write
  737. * values to registers as these are supported without any name changes between platforms.
  738. */
  739.  
  740. /* @{ */
  741.  
  742. /*!
  743. * @brief Reads a register.
  744. *
  745. * This command reads the entire contents of a single specified register and passes back its
  746. * contents.
  747. *
  748. * The register is specified in the reg field of the passed POWER_IC_REG_ACCESS_T.
  749. *
  750. * The value read is returned in the value field of the structure.
  751. */
  752. #define POWER_IC_IOCTL_READ_REG \
  753. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CORE_BASE + 0x00), POWER_IC_REG_ACCESS_T *)
  754.  
  755. /*!
  756. * @brief Writes a register.
  757. *
  758. * This command overwrites the entire contents of a single specified register.
  759. *
  760. * The register is specified in the reg field of the passed POWER_IC_REG_ACCESS_T and the
  761. * new value to be written is passed in the value field of the structure.
  762. *
  763. * The command has no output other than the returned error code for the ioctl() call.
  764. */
  765. #define POWER_IC_IOCTL_WRITE_REG \
  766. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CORE_BASE + 0x01), POWER_IC_REG_ACCESS_T *)
  767.  
  768. /*!
  769. * @brief Reads a subset of bits from a register.
  770. *
  771. * This command reads a contiguous set of bits from a single specified register. The
  772. * driver reads from the register specified and does the necessary masking and shifting so
  773. * that only the specified bits are passed back, shifted so that the first bit read is bit
  774. * zero of the value passed back.
  775. *
  776. * The register is specified in the reg field of the passed POWER_IC_REG_ACCESS_T, the
  777. * index of the first (least significant) bit is specified in the index field, and the
  778. * number of bits including the first bit is specified in the num_bits field.
  779. *
  780. * The value read starts from bit zero of the returned value, which is passed back in the
  781. * value field of the structure.
  782. */
  783. #define POWER_IC_IOCTL_READ_REG_BITS \
  784. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CORE_BASE + 0x02), POWER_IC_REG_ACCESS_T *)
  785.  
  786. /*!
  787. * @brief Writes a subset of bits from a register.
  788. *
  789. * This command overwrites a contiguous set of bits from a single specified register. The
  790. * driver takes the value and shifts it to the correct position in the register, overwriting
  791. * the subset of bits specified. The remaining bits are not changed.
  792. *
  793. * The register is specified in the reg field of the passed POWER_IC_REG_ACCESS_T, the index
  794. * of the first (least significant) bit is specified in the index field, the number of bits
  795. * (including the first bit) is specified in the num_bits field and the value to be shifted
  796. * and written is specified in the value field.
  797. *
  798. * The command has no output other than the returned error code for the ioctl() call.
  799. */
  800. #define POWER_IC_IOCTL_WRITE_REG_BITS \
  801. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CORE_BASE + 0x03), POWER_IC_REG_ACCESS_T *)
  802. /*!
  803. * @brief Writes a subset of bits from a register.
  804. *
  805. * This command overwrites a possibly non-contiguous set of bits from a single specified
  806. * register. This is similar to POWER_IC_IOCTL_WRITE_REG_BITS above, but instead the value
  807. * specified must be bit-exact compared to the register to be written (i.e. the bits you
  808. * want to set/clear in the register must be set the same way in the value passed in to
  809. * the command.
  810. *
  811. * The register is specified in the reg field of the passed POWER_IC_REG_ACCESS_T
  812. * and the bitmask describing which register bits to be changed is specified by the
  813. * num_bits field (each bit set will result in that bit in the register being overwritten)
  814. * and the bit-exact value to be written is passed in the value field of the structure.
  815. *
  816. * This command has no output other than the returned error code for the ioctl() call.
  817. */
  818. #define POWER_IC_IOCTL_WRITE_REG_MASK \
  819. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CORE_BASE + 0x04), POWER_IC_REG_ACCESS_T *)
  820.  
  821. /*!
  822. * @brief Gets the powerup reason.
  823. *
  824. * This command retrieves the reason the phone powered up from the driver. When the driver
  825. * starts, it checks for possible reasons for powering up and remembers the reason, which
  826. * is retrieved later via this command.
  827. *
  828. * The command has no inputs.
  829. *
  830. * The command passes back the powerup reason via the passed pointer to a
  831. * POWER_IC_POWER_UP_REASON_T.
  832. */
  833. #define POWER_IC_IOCTL_GET_POWER_UP_REASON \
  834. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CORE_BASE + 0x05), POWER_IC_POWER_UP_REASON_T *)
  835.  
  836. /*!
  837. * @brief Gets hardware information.
  838. *
  839. * This command fetches information about the hardware's type and any revision information
  840. * that might be available for the hardware.
  841. *
  842. * The command has no inputs.
  843. *
  844. * The command passes back the power IC hardware type and revision information in the
  845. * POWER_IC_HARDWARE_T structure, which is passed by pointer.
  846. *
  847. * @note Under most circumstances, a caller does not need to know whether the power IC is an
  848. * Atlas or something else. This is only intended for the few cases where more information
  849. * is needed about the hardware, e.g. to interpret the results of an AtoD conversion
  850. * or similar. <b>Please do not make unnecessary use of this command.</b>
  851. */
  852. #define POWER_IC_IOCTL_GET_HARDWARE_INFO \
  853. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CORE_BASE + 0x06), POWER_IC_HARDWARE_T *)
  854.  
  855. /*!
  856. * @brief Reads a Backup Memory register bit(s).
  857. *
  858. * This command reads part of either the Backup Memory A or Backup Memory B registers based on the
  859. * ID provided and the backup_memory_table located in external.c and passes back its value.
  860. *
  861. * The ID is specified in the reg field of the passed POWER_IC_REG_ACCESS_T.
  862. *
  863. * The value read is returned in the value field of the structure.
  864. */
  865. #define POWER_IC_IOCTL_READ_BACKUP_MEMORY \
  866. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CORE_BASE + 0x07), POWER_IC_REG_ACCESS_T *)
  867.  
  868. /*!
  869. * @brief Writes a Backup Memory register bit(s).
  870. *
  871. * This command overwrites part of either the Backup Memory A or Backup Memory B registers based on
  872. * the ID provided and the backup_memory_table located in external.c.
  873. *
  874. * The ID is specified in the reg field of the passed POWER_IC_REG_ACCESS_T and the
  875. * new value to be written is passed in the value field of the structure.
  876. *
  877. * The command has no output other than the returned error code for the ioctl() call.
  878. */
  879. #define POWER_IC_IOCTL_WRITE_BACKUP_MEMORY \
  880. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CORE_BASE + 0x08), POWER_IC_REG_ACCESS_T *)
  881. /* @} End of core ioctls. ------------------------------------------------------------------------*/
  882.  
  883. /*!
  884. * @anchor ioctl_periph
  885. * @name Peripheral ioctl() commands
  886. *
  887. * These are the commands that can be used through ioctl() to perform various peripheral
  888. * operations. The caller does not need to know which platform these commands are being
  889. * performed on.
  890. */
  891.  
  892. /* @{ */
  893. /*!
  894. * @brief Sets the vibrator level.
  895. *
  896. * This command sets the level at which the vibrator should spin when it is turned on.
  897. *
  898. * This command takes a single int, indicating the level at which the vibrator should turn.
  899. * The available range of levels is 0..3, with higher levels resulting in the vibrator
  900. * spinning faster.
  901. *
  902. * This command has no output other than the returned error code for the ioctl() call.
  903. */
  904. #define POWER_IC_IOCTL_PERIPH_SET_VIBRATOR_LEVEL \
  905. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_PERIPH_BASE + 0x00), int)
  906.  
  907. /*!
  908. * @brief Turns the vibrator on and off.
  909. *
  910. * This command is the on/off switch for the vibrator. When on, the vibrator will spin at the
  911. * level set by POWER_IC_IOCTL_PERIPH_SET_VIBRATOR_LEVEL.
  912. *
  913. * This command takes a single POWER_IC_PERIPH_ONOFF_T, indicating whether the vibrator should be
  914. * turned on or off.
  915. *
  916. * This command has no output other than the returned error code for the ioctl() call.
  917. */
  918. #define POWER_IC_IOCTL_PERIPH_SET_VIBRATOR_ON \
  919. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_PERIPH_BASE + 0x01), POWER_IC_PERIPH_ONOFF_T)
  920.  
  921. /*!
  922. * @brief Controls power to Camera.
  923. *
  924. * This command controls the regulator that powers the Camera hardware, allowing the
  925. * caller to turn the hardware on and off.
  926. *
  927. * The command takes a single POWER_IC_PERIPH_ONOFF_T, indicating whether the Camera should be
  928. * turned on or off.
  929. *
  930. * This command has no output other than the returned error code for the ioctl() call.
  931. */
  932. #define POWER_IC_IOCTL_PERIPH_SET_CAMERA_ON \
  933. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_PERIPH_BASE + 0x02), POWER_IC_PERIPH_ONOFF_T)
  934. /* @} End of power management ioctls. ------------------------------------------------------------*/
  935.  
  936.  
  937. /*!
  938. * @anchor ioctl_rtc
  939. * @name Real-time clock (RTC) ioctl() commands
  940. *
  941. * These are the commands that can be used through ioctl() to perform various operations on
  942. * the real-time clock. The caller does not need to know which platform these commands are being
  943. * performed on.
  944. */
  945.  
  946. /* @{ */
  947.  
  948. /*!
  949. * @brief Gets the current RTC time.
  950. *
  951. * This command reads the current time from the hardware.
  952. *
  953. * This command takes no inputs.
  954. *
  955. * The command passes back the current time in the passed timeval structure. The time
  956. * is expressed in the unix-standard number of seconds since January, 1 1970 00:00:00 UTC.
  957. */
  958. #define POWER_IC_IOCTL_GET_TIME \
  959. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_RTC_BASE + 0x00), struct timeval *)
  960.  
  961. /*!
  962. * @brief Sets the current RTC time.
  963. *
  964. * This command writes the passed time to the hardware RTC.
  965. *
  966. * The command takes the current time in the passed timeval structure. The time should be
  967. * expressed in the unix-standard number of seconds since January, 1 1970 00:00:00 UTC.
  968. *
  969. * The command has no output other than the returned error code for the ioctl() call.
  970. */
  971. #define POWER_IC_IOCTL_SET_TIME \
  972. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_RTC_BASE + 0x01), struct timeval *)
  973.  
  974. /*!
  975. * @brief Gets the currently set RTC alarm.
  976. *
  977. * This command reads the current programmed alarm from the hardware.
  978. *
  979. * This command takes no inputs.
  980. *
  981. * The command passes back the alarm time in the passed timeval structure. The time
  982. * is expressed in the unix-standard number of seconds since January, 1 1970 00:00:00 UTC.
  983. */
  984. #define POWER_IC_IOCTL_GET_ALARM_TIME \
  985. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_RTC_BASE + 0x02), struct timeval *)
  986.  
  987. /*!
  988. * @brief Programs the RTC alarm.
  989. *
  990. * This command writes the passed alarm time to the hardware RTC.
  991. *
  992. * The command takes the alarm time in the passed timeval structure. The time should be
  993. * expressed in the unix-standard number of seconds since January, 1 1970 00:00:00 UTC.
  994. *
  995. * The command has no output other than the returned error code for the ioctl() call.
  996. */
  997. #define POWER_IC_IOCTL_SET_ALARM_TIME \
  998. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_RTC_BASE + 0x03), struct timeval *)
  999. /* @} End of RTC ioctls. -------------------------------------------------------------------------*/
  1000.  
  1001. /*!
  1002. * @anchor ioctl_atod
  1003. * @name Analogue to Digital converter (AtoD) ioctl() commands
  1004. *
  1005. * These are the commands that can be used through ioctl() to perform various AtoD
  1006. * conversions. The caller does not need to know which platform these commands are
  1007. * being performed on in order to perform a conversion, but may need to know to
  1008. * interpret the measurements correctly.
  1009. */
  1010.  
  1011. /* @{ */
  1012.  
  1013. /*!
  1014. * @brief Converts a single channel.
  1015. *
  1016. * This command performs a conversion on a single AtoD channel. The results of the
  1017. * conversion are averaged and phasing is applied to the result (if available for
  1018. * the converted channel).
  1019. *
  1020. * The command takes the channel to be converted in the channel field of the passed
  1021. * POWER_IC_ATOD_REQUEST_SINGLE_CHANNEL_T structure.
  1022. *
  1023. * The averaged (and possibly phased) AtoD measurement is returned in the result field of the
  1024. * structure.
  1025. */
  1026. #define POWER_IC_IOCTL_ATOD_SINGLE_CHANNEL \
  1027. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x00), POWER_IC_ATOD_REQUEST_SINGLE_CHANNEL_T *)
  1028.  
  1029. /*!
  1030. * @brief Converts battery voltage and current.
  1031. *
  1032. * This command performs a conversion of the battery voltage and current. The results of the
  1033. * conversion are averaged and phasing is applied to the result (if available).
  1034. *
  1035. * The averaged (and possibly phased) AtoD measurements for the battery voltage and current are
  1036. * passed back in the batt_result and curr_result fields of the structure. The current value passed
  1037. * back has been converted to milliamps.
  1038. */
  1039. #define POWER_IC_IOCTL_ATOD_BATT_AND_CURR \
  1040. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x01), POWER_IC_ATOD_REQUEST_BATT_AND_CURR_T *)
  1041.  
  1042. /*!
  1043. * @brief Converts set of channels.
  1044. *
  1045. * This command performs a conversion of a set of AtoD channels, taking one sample for each
  1046. * channel converted. The measurements are phased where phasing is available.
  1047. *
  1048. * The command takes no inputs.
  1049. *
  1050. * The results for all of the converted channels are passed back to the caller in the
  1051. * POWER_IC_ATOD_RESULT_GENERAL_CONVERSION_T structure passed by pointer to the ioctl() call.
  1052. */
  1053. #define POWER_IC_IOCTL_ATOD_GENERAL \
  1054. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x02), POWER_IC_ATOD_RESULT_GENERAL_CONVERSION_T *)
  1055.  
  1056. /*!
  1057. * @brief Enables a hardware-timed conversion.
  1058. *
  1059. * This command is different from the other conversions in that no conversion is performed
  1060. * within the duration of the command. This command sets the hardware to perform a conversion
  1061. * of the battery voltage and current that is triggered relative to a transmit burst. Once
  1062. * set, this command returns and the hardware waits for the transmit burst to occur. If
  1063. * no transmit occurs, the conversion will never be performed. The conversion results can
  1064. * be polled by using the read() system call on the power IC driver.
  1065. *
  1066. * The timing of the conversion (in/out of burst) is specified in the timing field of the structure.
  1067. *
  1068. * The command has no output other than the returned error code for the ioctl() call. The
  1069. * status of the conversion and the results are retrieved via the read() system call on the
  1070. * power IC device.
  1071. */
  1072. #define POWER_IC_IOCTL_ATOD_BEGIN_CONVERSION \
  1073. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x05), POWER_IC_ATOD_REQUEST_BATT_AND_CURR_T *)
  1074.  
  1075. /*!
  1076. * @brief Cancels a hardware-timed conversion.
  1077. *
  1078. * This command disables a hardware-timed conversion previously set up by the
  1079. * POWER_IC_IOCTL_ATOD_BEGIN_CONVERSION command. If no conversion has been set up
  1080. * or a conversion has already been completed, the command will return an error.
  1081. *
  1082. * The command takes no inputs.
  1083. *
  1084. * The command has no output other than the returned error code for the ioctl() call.
  1085. */
  1086. #define POWER_IC_IOCTL_ATOD_CANCEL_CONVERSION \
  1087. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x06), int)
  1088.  
  1089. /*!
  1090. * @brief Programs the AtoD phasing.
  1091. *
  1092. * This command programs the phasing applied to various AtoD conversion results. The
  1093. * phasing applied is an array of 12 bytes in the same format as is used for all
  1094. * products' AtoD phasing.
  1095. *
  1096. * The command takes a pointer to an array of phasing bytes.
  1097. *
  1098. * The command has no output other than the returned error code for the ioctl() call.
  1099. *
  1100. * @note The driver will reject all phasing that is deemed to be unprogrammed. If
  1101. * any slope byte is seen as 0x00 or 0xFF, the phasing will be rejected and the
  1102. * driver will continue to use the previously programmed values.
  1103. */
  1104. #define POWER_IC_IOCTL_ATOD_SET_PHASING \
  1105. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x07), unsigned char *)
  1106.  
  1107. /*!
  1108. * @brief Turns the thermistor on and off.
  1109. *
  1110. * This command is the on/off switch for the thermistor GPO.
  1111. *
  1112. * This command takes a single int on/off, indicating whether the thermistor should be
  1113. * turned on or off.
  1114. *
  1115. * This command has no output other than the returned error code for the ioctl() call.
  1116. */
  1117. #define POWER_IC_IOCTL_ATOD_SET_THERM \
  1118. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x08), int)
  1119.  
  1120.  
  1121. /*!
  1122. * @brief Converts battery voltage and current for Phasing.
  1123. *
  1124. * This command performs a conversion of the battery voltage and current. The results of the
  1125. * conversion are averaged and phasing is applied to the result (if available).
  1126. *
  1127. * The averaged (and possibly phased) AtoD measurements for the battery voltage and current are
  1128. * passed back in the batt_result and curr_result fields of the structure. The current value passed
  1129. * back is in DAC values.
  1130. */
  1131. #define POWER_IC_IOCTL_ATOD_BATT_AND_CURR_PHASED \
  1132. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x09), POWER_IC_ATOD_REQUEST_BATT_AND_CURR_T *)
  1133.  
  1134. /*!
  1135. * @brief Sets the lithium coin cell enable bit.
  1136. *
  1137. * This command sets the lithium coin cell enable bit in order to read the RTCBatt AtoD
  1138. * voltage.
  1139. *
  1140. * The command takes an int containing the value for the lithium coin cell bit.
  1141. *
  1142. * The command has no output other than the returned error code for the ioctl() call.
  1143. *
  1144. */
  1145. #define POWER_IC_IOCTL_ATOD_SET_LITHIUM_COIN_CELL_EN \
  1146. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x0A), int)
  1147.  
  1148. /*!
  1149. * @brief Converts a single channel.
  1150. *
  1151. * This command performs a conversion on a single AtoD channel. However, unlike the
  1152. * POWER_IC_IOCTL_ATOD_SINGLE_CHANNEL the results are not averaged nor are they phased.
  1153. * Instead, all of the samples will be passed back to the caller.
  1154. *
  1155. * The command takes the channel to be converted in the channel field of the passed
  1156. * POWER_IC_ATOD_REQUEST_RAW_T structure.
  1157. *
  1158. * The command passes back all of the results in the results[] field of the passed structure
  1159. * and number of samples taken will be recorded in the num_results field.
  1160. *
  1161. * @note This is really only intended for testing purposes. Since the results are unphased and
  1162. * not averaged, making decisions on the results of this conversion is probably not a good idea.
  1163. */
  1164. #define POWER_IC_IOCTL_ATOD_RAW \
  1165. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_ATOD_BASE + 0x0F), POWER_IC_ATOD_REQUEST_RAW_T *)
  1166.  
  1167. /* @} End of AtoD ioctls ------------------------------------------------------------------------- */
  1168.  
  1169. /*!
  1170. * @name Audio ioctl() commands
  1171. * @anchor ioctl_audio
  1172. *
  1173. * These are the commands that can be used through ioctl() to perform various audio-related
  1174. * operations. The caller does not need to know which platform these commands are
  1175. * being performed on.
  1176. */
  1177.  
  1178. /* @{ */
  1179. /*!
  1180. * @brief Used to set the audio connection mode.
  1181. */
  1182. #define POWER_IC_IOCTL_AUDIO_CONN_MODE_SET \
  1183. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_AUDIO_BASE + 0x00), POWER_IC_EMU_CONN_MODE_T *)
  1184. /*!
  1185. * @brief Used to enable/disable the ceramic speaker
  1186. *
  1187. * This command is only supported for products that have a ceramic speaker.
  1188. */
  1189. #define POWER_IC_IOCTL_AUDIO_CERAMIC_SPEAKER_EN \
  1190. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_AUDIO_BASE + 0x01), bool)
  1191. /*!
  1192. * @brief Used to change Audio Rx 0 register
  1193. */
  1194. #define POWER_IC_IOCTL_AUDIO_SET_REG_MASK_AUDIO_RX_0 \
  1195. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_AUDIO_BASE + 0x02), POWER_IC_AUDIO_SET_REG_MASK_T *)
  1196. /*!
  1197. * @brief Used to change Audio Rx 1 register
  1198. */
  1199. #define POWER_IC_IOCTL_AUDIO_SET_REG_MASK_AUDIO_RX_1 \
  1200. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_AUDIO_BASE + 0x03), POWER_IC_AUDIO_SET_REG_MASK_T *)
  1201. /*!
  1202. * @brief Used to change Audio Tx register
  1203. */
  1204. #define POWER_IC_IOCTL_AUDIO_SET_REG_MASK_AUDIO_TX \
  1205. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_AUDIO_BASE + 0x04), POWER_IC_AUDIO_SET_REG_MASK_T *)
  1206. /*!
  1207. * @brief Used to change SSI Network register
  1208. */
  1209. #define POWER_IC_IOCTL_AUDIO_SET_REG_MASK_SSI_NETWORK \
  1210. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_AUDIO_BASE + 0x05), POWER_IC_AUDIO_SET_REG_MASK_T *)
  1211. /*!
  1212. * @brief Used to change Audio Codec register
  1213. */
  1214. #define POWER_IC_IOCTL_AUDIO_SET_REG_MASK_AUDIO_CODEC \
  1215. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_AUDIO_BASE + 0x06), POWER_IC_AUDIO_SET_REG_MASK_T *)
  1216. /*!
  1217. * @brief Used to change Audio Stereo DAC register
  1218. */
  1219. #define POWER_IC_IOCTL_AUDIO_SET_REG_MASK_AUDIO_STEREO_DAC \
  1220. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_AUDIO_BASE + 0x07), POWER_IC_AUDIO_SET_REG_MASK_T *)
  1221. /* @} End of Audio ioctls. -----------------------------------------------------------------------*/
  1222.  
  1223. /*!
  1224. * @name Lighting ioctl() commands
  1225. * @anchor ioctl_lights
  1226. *
  1227. * These are the commands that can be used through ioctl() to perform various operations.
  1228. * on the phone's backlights/funlights. The caller does not need to know which platform these
  1229. * commands are being performed on.
  1230. */
  1231.  
  1232. /* @{ */
  1233. /*!
  1234. * @brief Set the intensity of a backlight.
  1235. *
  1236. * Sets the intensity of the backlight requested to the percentage passed in. See
  1237. * LIGHTS_BACKLIGHT_IOCTL_T for more details.
  1238. */
  1239. #define POWER_IC_IOCTL_LIGHTS_BACKLIGHTS_SET \
  1240. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x00), LIGHTS_BACKLIGHT_IOCTL_T *)
  1241. /*!
  1242. * @brief Grants the control of a fun lights region to an app.
  1243. *
  1244. * Enables the regions specified in the region mask for control by the app which is passed in.
  1245. * When bits in the mask are clear access is returned to lower priority apps. Please note an app
  1246. * will only be granted access when a lower priority task currently has access. If a higher priority
  1247. * task currently has control the requesting app will be granted access once all higher priority
  1248. * tasks have released control. If a higher priority task has control the request for access
  1249. * will be queued, if this is not desired the function must be called again with the request bit
  1250. * cleared. See LIGHTS_FL_SET_T for more details on the parameters.
  1251. */
  1252. #define POWER_IC_IOCTL_LIGHTS_FL_SET_CONTROL \
  1253. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x01), LIGHTS_FL_SET_T *)
  1254. /*!
  1255. * @brief Sets the value of a fun lights region and updates the lights if the app has control.
  1256. *
  1257. * Assigns colors to regions for the app which is passed in. If the app is not currently active
  1258. * the color assignment is cached but will not be active. In the case the LED is not active
  1259. * the corresponding bit in the return mask will be clear. See LIGHTS_FL_UPDATE_T for more
  1260. * details on the parameters.
  1261. */
  1262. #define POWER_IC_IOCTL_LIGHTS_FL_UPDATE \
  1263. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x02), LIGHTS_FL_UPDATE_T *)
  1264.  
  1265. /*!
  1266. * @brief Set the intensity of a backlight.
  1267. *
  1268. * Sets the intensity of the backlight requested to the percentage passed in. See
  1269. * LIGHTS_BACKLIGHT_IOCTL_T for more details on the parameters.
  1270. */
  1271. #define POWER_IC_IOCTL_LIGHTS_BACKLIGHTS_STEP_SET \
  1272. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x03), LIGHTS_BACKLIGHT_IOCTL_T *)
  1273. /*!
  1274. * @brief Get the number of backlight steps supported by the hardware.
  1275. *
  1276. * Returns the number of brightness steps implemented in the hardware driver for a type of
  1277. * backlight. The number of steps will include the value for off.
  1278. */
  1279. #define POWER_IC_IOCTL_LIGHTS_BACKLIGHT_GET_STEPS \
  1280. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x04), LIGHTS_BACKLIGHT_IOCTL_T *)
  1281. /*!
  1282. * @brief Convert a step to a percentage based on the current hardware.
  1283. *
  1284. * Returns a percentage based on the step and backlight passed in. The return value is suitable
  1285. * for use by POWER_IC_IOCTL_LIGHTS_BACKLIGHTS_SET. See LIGHTS_BACKLIGHT_IOCTL_T for more details
  1286. * on the parameters.
  1287. */
  1288. #define POWER_IC_IOCTL_LIGHTS_BACKLIGHT_STEPS_TO_PERCENT \
  1289. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x05), LIGHTS_BACKLIGHT_IOCTL_T *)
  1290.  
  1291. /*!
  1292. * @brief Get the current backlight step value of the required region.
  1293. *
  1294. * Returns the step based on the region passed in. See LIGHTS_BACKLIGHT_IOCTL_T for more details
  1295. * on the parameters.
  1296. */
  1297. #define POWER_IC_IOCTL_LIGHTS_BACKLIGHT_GET_STEPS_VAL \
  1298. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x06), LIGHTS_BACKLIGHT_IOCTL_T *)
  1299.  
  1300. /*!
  1301. * @brief Get a percentage based on the step value of a particular region.
  1302. *
  1303. * Returns a percentage based on the step and backlight passed in.See LIGHTS_BACKLIGHT_IOCTL_T for more details
  1304. * on the parameters.
  1305. */
  1306. #define POWER_IC_IOCTL_LIGHTS_BACKLIGHT_GET_VAL \
  1307. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x07), LIGHTS_BACKLIGHT_IOCTL_T *)
  1308.  
  1309. /*!
  1310. * @brief Enable the ambient light sensor circuit.
  1311. *
  1312. * The procedure is like followings:
  1313. * 1. Enable the ambient light sensor using the POWER_IC_IOCTL_LIGHTS_LIGHT_SENSOR_START ioctl.
  1314. * 2. Wait the correct amount of time for the circuit to settle based on the hardware in use.
  1315. * 3. Read the ambient light sensor atod value using POWER_IC_IOCTL_LIGHTS_LIGHT_SENSOR_GET_LUMA.
  1316. * 4. Disable the ambient light sensor using the POWER_IC_IOCTL_LIGHTS_LIGHT_SENSOR_STOP ioctl.
  1317. *
  1318. * @note The sensor must be disabled after reading in order to maximize battery life.
  1319. */
  1320. #define POWER_IC_IOCTL_LIGHTS_LIGHT_SENSOR_START \
  1321. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x08),char)
  1322.  
  1323. /*!
  1324. * @brief Read ambient light sensor ATOD value.
  1325. *
  1326. * Read out Atod value of the ambient light sensor and return to the user.
  1327. */
  1328. #define POWER_IC_IOCTL_LIGHTS_LIGHT_SENSOR_GET_LUMA\
  1329. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x09),int)
  1330.  
  1331. /*!
  1332. * @brief Disable the ambient light sensor circuit
  1333. */
  1334. #define POWER_IC_IOCTL_LIGHTS_LIGHT_SENSOR_STOP\
  1335. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_LIGHTS_BASE + 0x0A),char)
  1336.  
  1337. /* @} End of lighting ioctls. -------------------------------------------------------------------- */
  1338.  
  1339. /*!
  1340. * @anchor ioctl_charger
  1341. * @name Charger ioctl() commands
  1342. *
  1343. * These are the commands that can be used through ioctl() to control the charging hardware.
  1344. */
  1345.  
  1346. /* @{ */
  1347.  
  1348. /*!
  1349. * @brief Sets the charge voltage.
  1350. *
  1351. * This command programs the maximum voltage that the battery will be charged up to.
  1352. * While it is expected that the main 4.2V level used will never change, there are
  1353. * potentially some differences in the other levels used depending on the hardware type
  1354. * and revision.
  1355. *
  1356. * The command takes an int, which is the requested setting for VCHRG as per the hardware
  1357. * specification.
  1358. *
  1359. * The command has no output other than the returned error code for the ioctl() call.
  1360. */
  1361. #define POWER_IC_IOCTL_CHARGER_SET_CHARGE_VOLTAGE \
  1362. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x00), int)
  1363.  
  1364. /*!
  1365. * @brief Sets the main charge current.
  1366. *
  1367. * This command programs the maximum current that will be fed into the battery while
  1368. * charging. This is only an upper limit - the charging hardware is free to charge
  1369. * at a limit lower than that set depending on the battery voltage and how much current
  1370. * an attached charger can supply.
  1371. *
  1372. * The command takes an int, which is the requested setting for ICHRG as per the hardware
  1373. * specification. For the most part this translates into 100's of milliamps of current,
  1374. * but there are discontinuities at the top end of the range.
  1375. *
  1376. * The command has no output other than the returned error code for the ioctl() call.
  1377. *
  1378. * @note The main charge current and trickle charge current settings are mutually exclusive.
  1379. * Setting this control will result in the trickle charge current being set to zero.
  1380. */
  1381. #define POWER_IC_IOCTL_CHARGER_SET_CHARGE_CURRENT \
  1382. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x01), int)
  1383.  
  1384. /*!
  1385. * @brief Sets the trickle charge current.
  1386. *
  1387. * This command programs the maximum trickle current that will be fed into the battery
  1388. * while charging. This is only an upper limit - the charging hardware is free to charge
  1389. * at a limit lower than that set depending on the battery voltage and how much current
  1390. * an attached charger can supply.
  1391. *
  1392. * The command takes an int, which is the requested setting for ICHRG_TR as per the hardware
  1393. * specification. This should translate to roughly 12 mA of current per count.
  1394. *
  1395. * The command has no output other than the returned error code for the ioctl() call.
  1396. *
  1397. * @note The trickle charge current and main charge current settings are mutually exclusive.
  1398. * Setting this control will result in the main charge current being set to zero.
  1399. */
  1400. #define POWER_IC_IOCTL_CHARGER_SET_TRICKLE_CURRENT \
  1401. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x02), int)
  1402.  
  1403. /*!
  1404. * @brief Sets the power path.
  1405. *
  1406. * This command sets the path that supplies power to the phone. The hardware can be set
  1407. * to either supply current from the battery (current share) or from the attached charger
  1408. * (dual-path).
  1409. *
  1410. * The command takes an POWER_IC_CHARGER_POWER_PATH_T, indicates whether the hardware should
  1411. * be set in current-share or dual-path mode.
  1412. *
  1413. * The command has no output other than the returned error code for the ioctl() call.
  1414. *
  1415. * @note Setting current-share mode when no battery is attached will result in an instant
  1416. * powerdown.
  1417. */
  1418. #define POWER_IC_IOCTL_CHARGER_SET_POWER_PATH \
  1419. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x03), POWER_IC_CHARGER_POWER_PATH_T)
  1420.  
  1421. /*!
  1422. * @brief Reads overvoltage state.
  1423. *
  1424. * This function reads the charger overvoltage sense bit from the hardware and returns it
  1425. * to the caller.
  1426. *
  1427. * The command expects a pointer to an int, where the command will store the read state of the
  1428. * overvoltage detect hardware. This will be zero if no overvoltage condition existsm and
  1429. * greater than zero if overvoltage has been detected.
  1430. *
  1431. * This command has no output other than the returned error code for the ioctl() call.
  1432. */
  1433. #define POWER_IC_IOCTL_CHARGER_GET_OVERVOLTAGE \
  1434. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x04), int *)
  1435.  
  1436. /*!
  1437. * @brief Resets the overvoltage hardware.
  1438. *
  1439. * This function is used to reset the overvoltage hardware after a problem is detected.
  1440. * once an overvoltage condition occurs, charging will be disabled in hardware until it is
  1441. * reset.
  1442. *
  1443. * This commend takes no inputs.
  1444. *
  1445. * This command has no output other than the returned error code for the ioctl() call.
  1446. */
  1447. #define POWER_IC_IOCTL_CHARGER_RESET_OVERVOLTAGE \
  1448. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x05), int)
  1449.  
  1450. /*!
  1451. * @brief Sets the USB Charger State.
  1452. *
  1453. * This command sets the the USB Charger State so that SBCM can determine the amount of current
  1454. * allowed to be pulled from the port.
  1455. *
  1456. * The command takes an POWER_IC_CHARGER_CHRG_STATE_T, indicates the state of the charger
  1457. *
  1458. * The command has no output other than the returned error code for the ioctl() call.
  1459. *
  1460. */
  1461. #define POWER_IC_IOCTL_CHARGER_SET_USB_STATE \
  1462. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x06), POWER_IC_CHARGER_CHRG_STATE_T)
  1463.  
  1464. /*!
  1465. * @brief Reads the USB Charger State.
  1466. *
  1467. * This function reads the state of the charger and returns it to the user.
  1468. *
  1469. * The command expects a pointer to POWER_IC_CHARGER_CHRG_STATE_T, where the command will
  1470. * store the read state of the charger.
  1471. *
  1472. * The command has no output other than the returned error code for the ioctl() call.
  1473. *
  1474. */
  1475. #define POWER_IC_IOCTL_CHARGER_GET_USB_STATE \
  1476. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x07), POWER_IC_CHARGER_CHRG_STATE_T *)
  1477.  
  1478. /*!
  1479. * @brief Sets the power cut.
  1480. *
  1481. * This command sets the power cut enable bit.
  1482. *
  1483. * The command takes an int, which is the requested setting for PCEN.
  1484. *
  1485. * The command has no output other than the returned error code for the ioctl() call.
  1486. */
  1487. #define POWER_IC_IOCTL_CHARGER_SET_POWER_CUT \
  1488. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x08), int)
  1489.  
  1490. /*!
  1491. * @brief Reads the power cut state.
  1492. *
  1493. * This function reads the state of power cut and returns it to the user.
  1494. *
  1495. * The command expects a pointer to int, where the command will store the read state of power cut.
  1496. *
  1497. * The command has no output other than the returned error code for the ioctl() call.
  1498. *
  1499. */
  1500. #define POWER_IC_IOCTL_CHARGER_GET_POWER_CUT \
  1501. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_CHARGER_BASE + 0x09), int *)
  1502.  
  1503. /* @} End of charger control ioctls. -------------------------------------------------------------*/
  1504.  
  1505. /*!
  1506. * @name Test ioctl() commands
  1507. * @anchor ioctl_tcmd
  1508. *
  1509. * These are the commands that are not normally used as part of the phone's normal
  1510. * operation, but are intended for use in test commands.
  1511. *
  1512. * @todo The tcmd ioctl commands need to be better documented.
  1513. */
  1514. /* @{ */
  1515.  
  1516. /*! Configures the transceiver to the requested state, if an out of range state is passed
  1517. * the off state is used. */
  1518. #define POWER_IC_IOCTL_CMD_TCMD_EMU_TRANS_STATE \
  1519. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x00), EMU_XCVR_T)
  1520. /*! Sets the MONO adder to the requested state, if an invalid state is requested nothing
  1521. * is done to hardware and -EFAULT is returned to user. */
  1522. #define POWER_IC_IOCTL_CMD_TCMD_MONO_ADDER_STATE \
  1523. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x01), POWER_IC_TCMD_MONO_ADDER_T)
  1524. /*! Returns the current value of the IDFLOATS bit */
  1525. #define POWER_IC_IOCTL_CMD_TCMD_IDFLOATS_READ \
  1526. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x02), unsigned int *)
  1527. /*! Returns the current value of the IDGNDS bit */
  1528. #define POWER_IC_IOCTL_CMD_TCMD_IDGNDS_READ \
  1529. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x03), unsigned int *)
  1530. /*! Returns the current value of the headset detect bit */
  1531. #define POWER_IC_IOCTL_CMD_TCMD_A1SNS_READ \
  1532. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x04), unsigned int *)
  1533. /*! Returns the current value of the mic bias MB2SNS bit */
  1534. #define POWER_IC_IOCTL_CMD_TCMD_MB2SNS_READ \
  1535. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x05), unsigned int *)
  1536. /*! Passing 1 sets the reverse mode to on passing 0 sets it to off */
  1537. #define POWER_IC_IOCTL_CMD_TCMD_REVERSE_MODE_STATE \
  1538. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x06), int)
  1539. /*! Returns the current value of the bits that determine the source of the VUSB input */
  1540. #define POWER_IC_IOCTL_CMD_TCMD_VUSBIN_READ \
  1541. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x07), unsigned int *)
  1542. /*! Set the bits that determine the source of the VUSB input */
  1543. #define POWER_IC_IOCTL_CMD_TCMD_VUSBIN_STATE \
  1544. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x08), int)
  1545. /*! Returns 1 if the external 32KHz oscillator is present and 0 if it is not */
  1546. #define POWER_IC_IOCTL_CMD_TCMD_CLKSTAT_READ \
  1547. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x09), unsigned int *)
  1548. /*! Passing 1 Enables the charging of the coincell passing 0 sets it to no charge */
  1549. #define POWER_IC_IOCTL_CMD_TCMD_COINCHEN_STATE \
  1550. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x0A), int)
  1551. /*! Sets the CONN mode to the requested state, if an invalid state is requested nothing
  1552. * is done to hardware and -EFAULT is returned to user. */
  1553. #define POWER_IC_IOCTL_CMD_TCMD_EMU_CONN_STATE \
  1554. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x0B), POWER_IC_EMU_CONN_MODE_T)
  1555. /*! Sets the Atlas external regulator voltage output(High - 3.1V Low- 0V) GPO4 */
  1556. #define POWER_IC_IOCTL_CMD_TCMD_GPO4_EXT_VOLTAGE_OUTPUT \
  1557. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x0C), int)
  1558. #define POWER_IC_IOCTL_CMD_TCMD_FLASH_MODE_WRITE \
  1559. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x0D), int)
  1560. /*! Sets the Atlas codec receive gain and stereo dac gain settings. */
  1561. #define POWER_IC_IOCTL_CMD_TCMD_WRITE_OGAIN \
  1562. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x0E), int)
  1563. /*! Returns the current value of the stereo dac gain setting. */
  1564. #define POWER_IC_IOCTL_CMD_TCMD_READ_OGAIN \
  1565. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_TCMD_BASE + 0x0F), int *)
  1566. /* @} End of tcmd ioctls -------------------------------------------------------------------------*/
  1567.  
  1568. /*!
  1569. * @name BRT ioctl() commands
  1570. * @anchor ioctl_brt
  1571. *
  1572. * These are the commands used to perform reading on battery rom data
  1573. *
  1574. * @todo The brt ioctl commands need to be better documented.
  1575. */
  1576. /* @{ */
  1577.  
  1578. /*! Returns the current battery rom data */
  1579. #define POWER_IC_IOCTL_CMD_BRT_DATA_READ \
  1580. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_BRT_BASE + 0x00), POWER_IC_BRT_DATA_REQUEST_T*)
  1581. /*! Returns the current value of the unique id in BRT */
  1582. #define POWER_IC_IOCTL_CMD_BRT_UID_READ \
  1583. _IOR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_BRT_BASE + 0x01), POWER_IC_BRT_UID_REQUEST_T*)
  1584. /* @} End of brt ioctls -------------------------------------------------------------------------*/
  1585.  
  1586.  
  1587.  
  1588. /*!
  1589. * @anchor ioctl_types
  1590. * @name ioctl() types
  1591. *
  1592. * These are the types of data passed in various ioctl() requests.
  1593. */
  1594.  
  1595. /* @{ */
  1596.  
  1597. /*!
  1598. * @brief Type of data used for power IC register access.
  1599. *
  1600. * This structure is passed as the final parameter to ioctl() when using the commands:
  1601. * POWER_IC_IOCTL_READ_REG, POWER_IC_IOCTL_WRITE_REG, POWER_IC_IOCTL_READ_REG_BITS,
  1602. * POWER_IC_IOCTL_WRITE_REG_BITS, or POWER_IC_IOCTL_WRITE_REG_MASK.
  1603. */
  1604. typedef struct
  1605. {
  1606. POWER_IC_REGISTER_T reg; /*!< Register to be read/written. */
  1607. int index; /*!< Index of first bit for read/write bits operations. */
  1608. int num_bits; /*!< Number of bits to be written for r/w bits, or bitmask for write mask. */
  1609. int value; /*!< Value written for writes, value read put here for reads. */
  1610. } POWER_IC_REG_ACCESS_T;
  1611.  
  1612. /*!
  1613. * @brief Type of data used for power IC backup memory access.
  1614. *
  1615. * This structure is passed as the final parameter to ioctl() when using the commands:
  1616. * POWER_IC_IOCTL_READ_BACKUP_MEMORY and POWER_IC_IOCTL_WRITE_BACKUP_MEMORY.
  1617. */
  1618. typedef struct
  1619. {
  1620. int value; /*!< Value written for writes, value read put here for reads. */
  1621. POWER_IC_BACKUP_MEMORY_ID_T id; /*!< ID of Backup Memory element to be read/written. */
  1622. } POWER_IC_BACKUP_MEM_ACCESS_T;
  1623.  
  1624. /*!
  1625. * @brief Chipsets reported by POWER_IC_IOCTL_GET_HARDWARE_INFO.
  1626. *
  1627. * This is the set of chipsets that can be reported in the POWER_IC_HARDWARE_T retrieved by the
  1628. * POWER_IC_IOCTL_GET_HARDWARE_INFO command. Under normal circumstances, POWER_IC_CHIPSET_UNKNOWN
  1629. * should never be reported.
  1630. */
  1631. typedef enum
  1632. {
  1633. POWER_IC_CHIPSET_ATLAS,
  1634.  
  1635. /* Add new chipsets above this line. */
  1636. POWER_IC_CHIPSET_UNKNOWN = 0xFF
  1637. } POWER_IC_CHIPSET_T;
  1638.  
  1639. /*!
  1640. * @brief Type returned by POWER_IC_IOCTL_GET_HARDWARE_INFO.
  1641. *
  1642. * This is all of the information retrieved by the POWER_IC_IOCTL_GET_HARDWARE_INFO command.
  1643. * For the two sets of revision history, revision1 will represent the main power IC (e.g.
  1644. * Atlas) and revision2 will represent other hardware alongside it.
  1645. *
  1646. * @note For some hardware types, revision information is not available for the hardware. In
  1647. * these cases, the corresponding revision will be set to POWER_IC_HARDWARE_NO_REV_INFO.
  1648. */
  1649. typedef struct
  1650. {
  1651. POWER_IC_CHIPSET_T chipset; /*!< Indicates type of hardware. */
  1652. int revision1; /*!< Revision info for primary IC. */
  1653. int revision2; /*!< Revision info for secondary IC. */
  1654. } POWER_IC_HARDWARE_T;
  1655.  
  1656. /*! Revision info in POWER_IC_HARDWARE_T will be set to this if no information is available. */
  1657. #define POWER_IC_HARDWARE_NO_REV_INFO 0xFFFFFFFF
  1658.  
  1659. /* The following types are used in the AtoD interface. */
  1660.  
  1661. /*!
  1662. * @brief General AtoD conversion results.
  1663. *
  1664. * This type is the set of AtoD conversions returned from a general conversion request.
  1665. * this is passed by address as the 3rd parameter to a POWER_IC_IOCTL_ATOD_GENERAL
  1666. * ioctl() request.
  1667. */
  1668. typedef struct
  1669. {
  1670. int coin_cell;
  1671. int battery;
  1672. int bplus;
  1673. int mobportb;
  1674. int charger_id;
  1675. int temperature;
  1676. } POWER_IC_ATOD_RESULT_GENERAL_CONVERSION_T;
  1677.  
  1678. /*!
  1679. * @brief Structure passed to ioctl() for a single channel request.
  1680. *
  1681. * This type is passed by pointer as the 3rd parameter of a
  1682. * POWER_IC_IOCTL_ATOD_SINGLE_CHANNEL ioctl() request.
  1683. */
  1684. typedef struct
  1685. {
  1686. POWER_IC_ATOD_CHANNEL_T channel; /*!< The channel that should be converted. */
  1687. int result; /*!< The result of the conversion, */
  1688. } POWER_IC_ATOD_REQUEST_SINGLE_CHANNEL_T;
  1689.  
  1690. /*!
  1691. * @brief Structure passed to ioctl() for a battery/current request.
  1692. *
  1693. * This type is passed by pointer as the 3rd parameter of a
  1694. * POWER_IC_IOCTL_ATOD_BATT_AND_CURR ioctl() request.
  1695. */
  1696. typedef struct
  1697. {
  1698. POWER_IC_ATOD_TIMING_T timing; /*!< The timing for the conversion. */
  1699. int timeout_secs; /*!< If a non-immediate conversion, timeout after this number of seconds.*/
  1700. POWER_IC_ATOD_CURR_POLARITY_T polarity; /*!< The direction in which current should be sampled. Ignored for ATLAS. */
  1701. int batt_result; /*!< The battery result from the conversion. */
  1702. int curr_result; /*!< The current result from the conversion. */
  1703. } POWER_IC_ATOD_REQUEST_BATT_AND_CURR_T;
  1704.  
  1705. /*!
  1706. * @brief Structure passed to ioctl() for a raw conversion request.
  1707. *
  1708. * This type is passed by pointer as the 3rd parameter of a
  1709. * POWER_IC_IOCTL_ATOD_RAW ioctl() request.
  1710. */
  1711. typedef struct
  1712. {
  1713. POWER_IC_ATOD_CHANNEL_T channel; /*!< The channel that should be converted. */
  1714. int results[POWER_IC_ATOD_NUM_RAW_RESULTS]; /*!< Results of conversion. */
  1715. int num_results; /*!< Number of the results being passed back. */
  1716. } POWER_IC_ATOD_REQUEST_RAW_T;
  1717.  
  1718. /*!
  1719. * @brief Structure passed to ioctl() for audio set_reg_mask requests.
  1720. *
  1721. * This type is passed by pointer as the 3rd parameter of any
  1722. * POWER_IC_IOCTL_AUDIO_SET_REG_MASK_* ioctl() request.
  1723. */
  1724. typedef struct
  1725. {
  1726. unsigned int mask; /* Mask of bits to be modified in the register being changed. */
  1727. unsigned int value; /* New values for the bits that are being modified. */
  1728. } POWER_IC_AUDIO_SET_REG_MASK_T;
  1729.  
  1730. /*!
  1731. * @brief Structure passed to ioctl() for battery data request.
  1732. *
  1733. * This type is passed by pointer as the 3rd parameter of a
  1734. * POWER_IC_IOCTL_CMD_BRT_DATA_READ ioctl() request.
  1735. */
  1736. typedef struct
  1737. {
  1738. BRT_DATA_T brt_type; /* the type of battery rom data. */
  1739. unsigned char brt_data[BRT_BYTE_SIZE]; /* Result of battery rom data read */
  1740. } POWER_IC_BRT_DATA_REQUEST_T;
  1741.  
  1742. /*!
  1743. * @brief Structure passed to ioctl() for battery unique id request.
  1744. *
  1745. * This type is passed by pointer as the 3rd parameter of a
  1746. * POWER_IC_IOCTL_CMD_BRT_DATA_READ ioctl() request.
  1747. */
  1748. typedef struct
  1749. {
  1750. BRT_DATA_T brt_type; /* the type of battery rom data. */
  1751. unsigned char brt_uid[BRT_UID_SIZE]; /* Result of battery unique id read */
  1752. } POWER_IC_BRT_UID_REQUEST_T;
  1753.  
  1754.  
  1755. /*! Defines the possible modes of the MONO adder, this table is tied to the
  1756. * hardware, this case supports Atlas. The Mono adder can be used
  1757. * to sum the left and right channels of the stereo DAC or signals supplied
  1758. * to the left and right PGA inputs. The Mono adder can then attenuate the
  1759. * summed signals by 0dB, 3dB or 6dB and an identical monophonic signal
  1760. * to the output amplifiers.
  1761. *
  1762. */
  1763.  
  1764. typedef enum
  1765. {
  1766. POWER_IC_TCMD_MONO_ADDER_STEREO, /*!< 00 - Right PGA and Left PGA Separated (Stereo) */
  1767. POWER_IC_TCMD_MONO_ADDER_R_L, /*!< 01 - Right PGA + Left PGA */
  1768. POWER_IC_TCMD_MONO_ADDER_R_L_3DB_LOSS, /*!< 10 - (Right PGA + Left PGA) -3 dB */
  1769. POWER_IC_TCMD_MONO_ADDER_R_L_6DB_LOSS, /*!< 11 - (Right PGA + Left PGA) -6 dB */
  1770.  
  1771. POWER_IC_TCMD_MONO_ADDER_NUM
  1772. } POWER_IC_TCMD_MONO_ADDER_T;
  1773.  
  1774.  
  1775. /*******************************************************************************************
  1776. * EMU proc Universal constants for SCMA-11 and BUTE platform
  1777. *
  1778. * These are constants that are universal to use of the EMU proc driver from both kernel
  1779. * and user space..
  1780. ******************************************************************************************/
  1781.  
  1782. /*! Define EMU proc event to be reported to User Space */
  1783. #define POWER_IC_EVENT_INT_VBUS 0x01
  1784. #define POWER_IC_EVENT_INT_ID 0x02
  1785. #define POWER_IC_EVENT_INT_SE1 0x04
  1786.  
  1787.  
  1788. /* Base of all the ioctl() commands that will be handled by the EMU proc . */
  1789. #define POWER_IC_IOC_CMD_EMU_GLUE_BASE 0x00
  1790. /* Last of the range of ioctl() commands reserved for the EMU proc*/
  1791. #define POWER_IC_IOC_CMD_EMU_GLUE_LAST_CMD (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x1F)
  1792.  
  1793. /*******************************************************************************************
  1794. * EMU proc ioctls
  1795. *
  1796. * All of the ioctl commands supported by the driver are in this section.
  1797. *
  1798. ******************************************************************************************/
  1799.  
  1800. /*!
  1801. * @name EMU_GLUE ioctl() commands
  1802. * @anchor ioctl_emu_glue
  1803. *
  1804. * These are the commands of the EMU proc ioctl for the Common Algortihm EMU glue
  1805. *
  1806. */
  1807. /* @{ */
  1808. /*! Returns the EMU state information */
  1809. #define POWER_IC_IOCTL_CMD_EMU_GLUE_READ_SENSE\
  1810. _IOWR(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x00), POWER_IC_EMU_GLUE_READ_SENSE_T*)
  1811. /*! Sets the EMU lockout changes */
  1812. #define POWER_IC_IOCTL_CMD_EMU_GLUE_LOCKOUT_CHANGES \
  1813. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x01), unsigned long)
  1814. /*! Sets the VBUS 5K pull down */
  1815. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_VBUS_5K_PD \
  1816. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x02), unsigned long)
  1817. /*! Sets the VBUS 70K pull down */
  1818. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_VBUS_70K_PD \
  1819. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x03), unsigned long)
  1820. /*! Sets the reverse mode */
  1821. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_REVERSE_MODE \
  1822. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x04), unsigned long)
  1823. /*! Sets the ID pull up */
  1824. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_ID_PU \
  1825. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x05), unsigned long)
  1826. /*! Sets the ID pull down */
  1827. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_ID_PD \
  1828. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x06), unsigned long)
  1829. /*! Sets the ID stereo pull down */
  1830. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_ID_STEREO_PU \
  1831. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x07), unsigned long)
  1832. /* Sets the conn mode */
  1833. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_CONN_MODE \
  1834. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x08), POWER_IC_EMU_CONN_MODE_T)
  1835. /* Sets the dplus 150K pull up */
  1836. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_DPLUS_150K_PU \
  1837. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x09), unsigned long)
  1838. /* Sets the dplus 1,5K pull up */
  1839. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_DPLUS_1_5K_PU \
  1840. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x0A), unsigned long)
  1841. /* Sets the low speed mode */
  1842. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_LOW_SPEED_MODE \
  1843. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x0B), unsigned long)
  1844. /* Sets the USB suspend */
  1845. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_USB_SUSPEND \
  1846. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x0C), unsigned long)
  1847. /* Sets the transceiver params */
  1848. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_TRANSCEIVER_PARAMS \
  1849. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x0D), POWER_IC_EMU_GLUE_TRANSCEIVER_PARAMS_T *)
  1850. /* Sets the USB suspend */
  1851. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_ID_INT_MASK \
  1852. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x0E), unsigned long)
  1853. /* Sets the USB suspend */
  1854. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_VBUS_INT_MASK \
  1855. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x0F), unsigned long)
  1856. /* Sets the USB suspend */
  1857. #define POWER_IC_IOCTL_CMD_EMU_GLUE_SET_SE1_INT_MASK \
  1858. _IOW(POWER_IC_MAJOR_NUM, (POWER_IC_IOC_CMD_EMU_GLUE_BASE + 0x10), unsigned long)
  1859. /* @} End of emu glue ioctls -------------------------------------------------------------------------*/
  1860.  
  1861. /*!
  1862. * @brief Structure passed to emu glue read sense ioctl().
  1863. *
  1864. * This type is passed by pointer as the 3rd parameter of a
  1865. * POWER_IC_IOCTL_CMD_EMU_GLUE_READ_SENSE ioctl() request.
  1866. */
  1867. typedef struct
  1868. {
  1869. unsigned long sense; /* Current state of the EMU state information */
  1870. unsigned char clear_int_flags; /* Specify if the EMU related interrupt should be cleared */
  1871. } POWER_IC_EMU_GLUE_READ_SENSE_T;
  1872.  
  1873. /*!
  1874. * @brief Used with the EMU_GLUE_set_transceiver_params function
  1875. *
  1876. */
  1877. typedef enum
  1878. {
  1879. POWER_IC_EMU_VUSB_IN_VINBUS, /*00*/
  1880. POWER_IC_EMU_VUSB_IN_VBUS, /*01*/
  1881. POWER_IC_EMU_VUSB_IN_BPLUS, /*10*/
  1882. POWER_IC_EMU_VUSB_IN_VBUS2, /*11*/
  1883.  
  1884. POWER_IC_EMU_VUSB_IN__NUM
  1885. } POWER_IC_EMU_VUSB_IN_T;
  1886.  
  1887. /*!
  1888. * @brief Structure passed to EMU ioctl() for emu glue set transceiver params .
  1889. *
  1890. * This type is passed by pointer as the 3rd parameter of a
  1891. * POWER_IC_IOCTL_CMD_EMU_GLUE_SET_TANSCEIVER_PARAMS ioctl() request.
  1892. */
  1893. typedef struct
  1894. {
  1895. unsigned long xcvr_en; /*!< transceiver enable */
  1896. unsigned long vusb_en; /*!< VUSB enable */
  1897. POWER_IC_EMU_VUSB_IN_T vusb_input_source; /*!< VUSB input source */
  1898. unsigned short vusb_voltage; /*!< VUSB voltage */
  1899. } POWER_IC_EMU_GLUE_TRANSCEIVER_PARAMS_T;
  1900.  
  1901. #endif /* __POWER_IC_H__ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement