This is the main file of PMIC(mc13783) ADC driver. More...
Functions | |
static void | callback_tsi (void *) |
static void | callback_adcdone (void *) |
static void | callback_adcbisdone (void *) |
static void | callback_adc_comp_high (void *) |
static int | pmic_adc_suspend (struct platform_device *pdev, pm_message_t state) |
static int | pmic_adc_resume (struct platform_device *pdev) |
static int | pmic_adc_filter (t_touch_screen *ts_curr) |
static int | pmic_adc_open (struct inode *inode, struct file *file) |
static int | pmic_adc_free (struct inode *inode, struct file *file) |
int | pmic_adc_init (void) |
PMIC_STATUS | pmic_adc_deinit (void) |
int | mc13783_adc_init_param (t_adc_param *adc_param) |
PMIC_STATUS | mc13783_adc_convert (t_adc_param *adc_param) |
t_reading_mode | mc13783_set_read_mode (t_channel channel) |
PMIC_STATUS | pmic_adc_convert (t_channel channel, unsigned short *result) |
PMIC_STATUS | pmic_adc_convert_8x (t_channel channel, unsigned short *result) |
PMIC_STATUS | pmic_adc_convert_multichnnel (t_channel channels, unsigned short *result) |
PMIC_STATUS | pmic_adc_set_touch_mode (t_touch_mode touch_mode) |
PMIC_STATUS | pmic_adc_get_touch_mode (t_touch_mode *touch_mode) |
PMIC_STATUS | pmic_adc_get_touch_sample (t_touch_screen *touch_sample, int wait) |
PMIC_STATUS | mc13783_adc_read_ts (t_touch_screen *ts_value, int wait_tsi) |
PMIC_STATUS | pmic_adc_get_battery_current (t_conversion_mode mode, unsigned short *result) |
int | mc13783_adc_request (bool read_ts) |
int | mc13783_adc_release (int adc_index) |
int | mc13783_adc_init_monitor_param (t_monitoring_param *monitor) |
PMIC_STATUS | pmic_adc_active_comparator (unsigned char low, unsigned char high, t_channel channel, t_comparator_cb callback) |
PMIC_STATUS | pmic_adc_deactive_comparator (void) |
static int | pmic_adc_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
Variables | |
static int | swait |
static int | suspend_flag |
static wait_queue_head_t | suspendq |
This is the main file of PMIC(mc13783) ADC driver.
static void callback_adc_comp_high | ( | void * | unused | ) | [static] |
This is the callback function called on mc13783 event.
References CHECK_HIGH, and CHECK_LOW_OR_HIGH.
Referenced by pmic_adc_init().
static void callback_adcbisdone | ( | void * | unused | ) | [static] |
This is the callback function called on ADCDone mc13783 event.
Referenced by pmic_adc_init().
static void callback_adcdone | ( | void * | unused | ) | [static] |
This is the callback function called on ADCDone mc13783 event.
Referenced by pmic_adc_init().
static void callback_tsi | ( | void * | unused | ) | [static] |
This is the callback function called on TSI mc13783 event, used in synchronous call.
References pmic_event_mask().
Referenced by pmic_adc_init().
PMIC_STATUS mc13783_adc_convert | ( | t_adc_param * | adc_param | ) |
This function starts the convert.
adc_param | contains all adc configuration and return value. |
References t_adc_param::channel_0, t_adc_param::channel_1, t_adc_param::chrgraw_devide_5, t_touch_screen::contact_resistance, t_adc_param::conv_delay, t_adc_param::delay, t_adc_param::group, mc13783_adc_release(), mc13783_adc_request(), pmic_event_unmask(), pmic_get_version(), pmic_read_reg(), pmic_write_reg(), t_adc_param::read_mode, t_adc_param::read_ts, pmic_version_t::revision, t_adc_param::single_channel, suspend_flag, t_adc_param::ts_value, t_adc_param::value, t_adc_param::wait_tsi, t_touch_screen::x_position, t_touch_screen::x_position1, t_touch_screen::x_position2, t_touch_screen::x_position3, t_touch_screen::y_position, t_touch_screen::y_position1, t_touch_screen::y_position2, and t_touch_screen::y_position3.
Referenced by mc13783_adc_read_ts(), pmic_adc_convert(), pmic_adc_convert_8x(), and pmic_adc_convert_multichnnel().
int mc13783_adc_init_monitor_param | ( | t_monitoring_param * | monitor | ) |
This function initializes monitoring structure.
monitor | Structure to be initialized. |
References t_monitoring_param::callback, t_monitoring_param::channel, CHECK_LOW_OR_HIGH, t_monitoring_param::check_mode, t_monitoring_param::comp_high, t_monitoring_param::comp_low, t_monitoring_param::conv_delay, t_monitoring_param::delay, t_monitoring_param::group, and t_monitoring_param::read_mode.
Referenced by pmic_adc_active_comparator().
int mc13783_adc_init_param | ( | t_adc_param * | adc_param | ) |
This function initializes adc_param structure.
adc_param | Structure to be initialized. |
References t_adc_param::channel_0, t_adc_param::channel_1, t_adc_param::chrgraw_devide_5, t_touch_screen::contact_resistance, t_adc_param::conv_delay, t_adc_param::delay, t_adc_param::group, t_adc_param::read_mode, t_adc_param::read_ts, t_adc_param::single_channel, suspend_flag, t_adc_param::ts_value, t_adc_param::value, t_adc_param::wait_tsi, t_touch_screen::x_position, and t_touch_screen::y_position.
Referenced by mc13783_adc_read_ts(), pmic_adc_convert(), pmic_adc_convert_8x(), and pmic_adc_convert_multichnnel().
PMIC_STATUS mc13783_adc_read_ts | ( | t_touch_screen * | ts_value, | |
int | wait_tsi | |||
) |
This function read the touch screen value.
ts_value | return value of touch screen | |
wait_tsi | if true, this function is synchronous (wait in TSI event). |
References t_touch_screen::contact_resistance, mc13783_adc_convert(), mc13783_adc_init_param(), t_adc_param::read_ts, suspend_flag, t_adc_param::ts_value, t_adc_param::wait_tsi, t_touch_screen::x_position, t_touch_screen::x_position1, t_touch_screen::x_position2, t_touch_screen::x_position3, t_touch_screen::y_position, t_touch_screen::y_position1, t_touch_screen::y_position2, and t_touch_screen::y_position3.
Referenced by pmic_adc_get_touch_sample().
int mc13783_adc_release | ( | int | adc_index | ) |
This function release an ADC.
adc_index | index of ADC to be released. |
References ADC_FREE, ADC_MONITORING, ADC_USED, suspend_flag, suspendq, and swait.
Referenced by mc13783_adc_convert(), and pmic_adc_deactive_comparator().
int mc13783_adc_request | ( | bool | read_ts | ) |
This function request a ADC.
References ADC_USED.
Referenced by mc13783_adc_convert(), and pmic_adc_active_comparator().
t_reading_mode mc13783_set_read_mode | ( | t_channel | channel | ) |
This function select the required read_mode for a specific channel.
channel | The channel to be sampled |
References M_BATTERY_CURRENT, M_CHARGE_CURRENT, M_DIE_TEMPERATURE, M_LITHIUM_CELL, M_THERMISTOR, and M_UID.
Referenced by pmic_adc_convert(), and pmic_adc_convert_8x().
PMIC_STATUS pmic_adc_active_comparator | ( | unsigned char | low, | |
unsigned char | high, | |||
t_channel | channel, | |||
t_comparator_cb | callback | |||
) |
This function actives the comparator. When comparator is active and ADC is enabled, the 8th converted value will be digitally compared against the window defined by WLOW and WHIGH registers.
low | Comparison window low threshold (WLOW). | |
high | Comparison window high threshold (WHIGH). | |
channel | The channel to be sampled | |
callback | Callback function to be called when the converted value is beyond the comparison window. The callback function will pass a parameter of type t_comp_expection to indicate the reason of comparator exception. |
References t_monitoring_param::callback, t_monitoring_param::channel, t_monitoring_param::check_mode, t_monitoring_param::comp_high, t_monitoring_param::comp_low, t_monitoring_param::conv_delay, t_monitoring_param::delay, t_monitoring_param::group, mc13783_adc_init_monitor_param(), mc13783_adc_request(), pmic_write_reg(), t_monitoring_param::read_mode, and suspend_flag.
Referenced by pmic_adc_ioctl().
PMIC_STATUS pmic_adc_convert | ( | t_channel | channel, | |
unsigned short * | result | |||
) |
This function triggers a conversion and returns one sampling result of one channel.
channel | The channel to be sampled | |
result | The pointer to the conversion result. The memory should be allocated by the caller of this function. |
References t_adc_param::channel_0, t_adc_param::group, mc13783_adc_convert(), mc13783_adc_init_param(), mc13783_set_read_mode(), t_adc_param::read_mode, t_adc_param::read_ts, t_adc_param::single_channel, suspend_flag, and t_adc_param::value.
Referenced by pmic_adc_get_battery_current(), pmic_adc_ioctl(), pmic_batt_get_batt_current(), pmic_batt_get_batt_temperature(), pmic_batt_get_batt_voltage(), pmic_batt_get_charge_current(), and pmic_batt_get_charge_voltage().
PMIC_STATUS pmic_adc_convert_8x | ( | t_channel | channel, | |
unsigned short * | result | |||
) |
This function triggers a conversion and returns eight sampling results of one channel.
channel | The channel to be sampled | |
result | The pointer to array to store eight sampling results. The memory should be allocated by the caller of this function. |
References t_adc_param::channel_0, t_adc_param::channel_1, t_adc_param::group, mc13783_adc_convert(), mc13783_adc_init_param(), mc13783_set_read_mode(), t_adc_param::read_mode, t_adc_param::read_ts, t_adc_param::single_channel, suspend_flag, and t_adc_param::value.
Referenced by pmic_adc_get_battery_current(), and pmic_adc_ioctl().
PMIC_STATUS pmic_adc_convert_multichnnel | ( | t_channel | channels, | |
unsigned short * | result | |||
) |
This function triggers a conversion and returns sampling results of each specified channel.
channels | This input parameter is bitmap to specify channels to be sampled. | |
result | The pointer to array to store sampling results. The memory should be allocated by the caller of this function. |
References t_adc_param::channel_0, t_adc_param::channel_1, t_adc_param::group, mc13783_adc_convert(), mc13783_adc_init_param(), t_adc_param::read_mode, t_adc_param::read_ts, t_adc_param::single_channel, suspend_flag, and t_adc_param::value.
Referenced by pmic_adc_ioctl().
PMIC_STATUS pmic_adc_deactive_comparator | ( | void | ) |
This function deactivates the comparator.
References mc13783_adc_release(), pmic_write_reg(), and suspend_flag.
Referenced by pmic_adc_ioctl().
PMIC_STATUS pmic_adc_deinit | ( | void | ) |
This function disables the ADC, de-registers the interrupt events.
References pmic_event_unsubscribe().
Referenced by pmic_adc_ioctl().
static int pmic_adc_filter | ( | t_touch_screen * | ts_curr | ) | [static] |
This function performs filtering and rejection of excessive noise prone samples.
ts_curr | Touch screen value |
References t_touch_screen::contact_resistance, t_touch_screen::x_position, t_touch_screen::x_position1, t_touch_screen::x_position2, t_touch_screen::x_position3, t_touch_screen::y_position, t_touch_screen::y_position1, t_touch_screen::y_position2, and t_touch_screen::y_position3.
Referenced by pmic_adc_get_touch_sample().
static int pmic_adc_free | ( | struct inode * | inode, | |
struct file * | file | |||
) | [static] |
This function implements the release method on a MC13783 ADC device.
inode | pointer on the node | |
file | pointer on the file |
PMIC_STATUS pmic_adc_get_battery_current | ( | t_conversion_mode | mode, | |
unsigned short * | result | |||
) |
This function starts a Battery Current mode conversion.
mode | Conversion mode. | |
result | Battery Current measurement result. if mode = ADC_8CHAN_1X, the result is result[0] = (BATTP - BATT_I) if mode = ADC_1CHAN_8X, the result is result[0] = BATTP result[1] = BATT_I result[2] = BATTP result[3] = BATT_I result[4] = BATTP result[5] = BATT_I result[6] = BATTP result[7] = BATT_I |
References pmic_adc_convert(), pmic_adc_convert_8x(), and suspend_flag.
Referenced by pmic_adc_ioctl().
PMIC_STATUS pmic_adc_get_touch_mode | ( | t_touch_mode * | touch_mode | ) |
This function retrieves the current touch screen operation mode.
touch_mode | Pointer to the retrieved touch screen operation mode. |
References pmic_read_reg(), and suspend_flag.
Referenced by pmic_adc_ioctl().
PMIC_STATUS pmic_adc_get_touch_sample | ( | t_touch_screen * | touch_sample, | |
int | wait | |||
) |
This function retrieves the current touch screen (X,Y) coordinates.
touch_sample | Pointer to touch sample. | |
wait | indicates whether this call must block or not. |
References mc13783_adc_read_ts(), and pmic_adc_filter().
Referenced by pmic_adc_ioctl().
int pmic_adc_init | ( | void | ) |
This function initializes all ADC registers with default values. This function also registers the interrupt events.
References ADC_FREE, callback_adc_comp_high(), callback_adcbisdone(), callback_adcdone(), callback_tsi(), CHECK_LOW, pmic_event_callback_t::func, pmic_event_callback_t::param, pmic_event_subscribe(), pmic_write_reg(), and suspend_flag.
Referenced by pmic_adc_ioctl().
static int pmic_adc_ioctl | ( | struct inode * | inode, | |
struct file * | file, | |||
unsigned int | cmd, | |||
unsigned long | arg | |||
) | [static] |
This function implements IOCTL controls on a MC13783 ADC device.
inode | pointer on the node | |
file | pointer on the file | |
cmd | the command | |
arg | the parameter |
References pmic_adc_active_comparator(), pmic_adc_convert(), pmic_adc_convert_8x(), pmic_adc_convert_multichnnel(), pmic_adc_deactive_comparator(), pmic_adc_deinit(), pmic_adc_get_battery_current(), pmic_adc_get_touch_mode(), pmic_adc_get_touch_sample(), pmic_adc_init(), pmic_adc_set_touch_mode(), t_adc_convert_param::result, suspend_flag, suspendq, swait, t_adc_comp_param::whigh, and t_adc_comp_param::wlow.
static int pmic_adc_open | ( | struct inode * | inode, | |
struct file * | file | |||
) | [static] |
This function implements the open method on a MC13783 ADC device.
inode | pointer on the node | |
file | pointer on the file |
References suspend_flag, suspendq, and swait.
static int pmic_adc_resume | ( | struct platform_device * | pdev | ) | [static] |
This is the resume of power management for the mc13783 adc API. It supports RESTORE state.
pdev | the device |
References pmic_write_reg(), suspend_flag, suspendq, and swait.
PMIC_STATUS pmic_adc_set_touch_mode | ( | t_touch_mode | touch_mode | ) |
This function sets touch screen operation mode.
touch_mode | Touch screen operation mode. |
References pmic_write_reg(), and suspend_flag.
Referenced by pmic_adc_ioctl().
static int pmic_adc_suspend | ( | struct platform_device * | pdev, | |
pm_message_t | state | |||
) | [static] |
This is the suspend of power management for the mc13783 ADC API. It supports SAVE and POWER_DOWN state.
pdev | the device | |
state | the state |
References pmic_write_reg(), and suspend_flag.
int suspend_flag [static] |
To indicate whether any of the adc devices are suspending
Referenced by mc13783_adc_convert(), mc13783_adc_init_param(), mc13783_adc_read_ts(), mc13783_adc_release(), pmic_adc_active_comparator(), pmic_adc_convert(), pmic_adc_convert_8x(), pmic_adc_convert_multichnnel(), pmic_adc_deactive_comparator(), pmic_adc_get_battery_current(), pmic_adc_get_touch_mode(), pmic_adc_init(), pmic_adc_ioctl(), pmic_adc_open(), pmic_adc_resume(), pmic_adc_set_touch_mode(), and pmic_adc_suspend().
wait_queue_head_t suspendq [static] |
The suspendq is used by blocking application calls
Referenced by mc13783_adc_release(), pmic_adc_ioctl(), pmic_adc_open(), and pmic_adc_resume().
int swait [static] |
Number of users waiting in suspendq
Referenced by mc13783_adc_release(), pmic_adc_ioctl(), pmic_adc_open(), and pmic_adc_resume().
© Freescale Semiconductor, Inc., 2007.
All rights reserved. Freescale Confidential Proprietary NDA Required |
![]() |