linux/drivers/mxc/pmic/mc13783/pmic_adc.c File Reference

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

Detailed Description

This is the main file of PMIC(mc13783) ADC driver.


Function Documentation

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  ) 
int mc13783_adc_init_monitor_param ( t_monitoring_param monitor  ) 
int mc13783_adc_init_param ( t_adc_param adc_param  ) 
PMIC_STATUS mc13783_adc_read_ts ( t_touch_screen ts_value,
int  wait_tsi 
)
int mc13783_adc_release ( int  adc_index  ) 

This function release an ADC.

Parameters:
adc_index index of ADC to be released.
Returns:
This function returns 0 if successful.

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.

Returns:
This function returns index of ADC to be used (0 or 1) if successful. return -1 if error.

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.

Parameters:
channel The channel to be sampled
Returns:
This function returns the requires read_mode

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.

Parameters:
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.
Returns:
This function returns PMIC_SUCCESS if successful.

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.

Parameters:
channel The channel to be sampled
result The pointer to the conversion result. The memory should be allocated by the caller of this function.
Returns:
This function returns PMIC_SUCCESS if successful.

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.

Parameters:
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.
Returns:
This function returns PMIC_SUCCESS if successful.

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.

Parameters:
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.
Returns:
This function returns PMIC_SUCCESS if successful.

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.

Returns:
This function returns PMIC_SUCCESS if successful.

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.

Returns:
This function returns PMIC_SUCCESS if successful.

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.

Parameters:
ts_curr Touch screen value
Returns:
This function returns 0 on success, -1 otherwise.

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.

Parameters:
inode pointer on the node
file pointer on the file
Returns:
This function returns 0.
PMIC_STATUS pmic_adc_get_battery_current ( t_conversion_mode  mode,
unsigned short *  result 
)

This function starts a Battery Current mode conversion.

Parameters:
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
Returns:
This function returns PMIC_SUCCESS if successful.

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.

Parameters:
touch_mode Pointer to the retrieved touch screen operation mode.
Returns:
This function returns PMIC_SUCCESS if successful.

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.

Parameters:
touch_sample Pointer to touch sample.
wait indicates whether this call must block or not.
Returns:
This function returns PMIC_SUCCESS if successful.

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.

Returns:
This function returns PMIC_SUCCESS if successful.

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.

Parameters:
inode pointer on the node
file pointer on the file
cmd the command
arg the parameter
Returns:
This function returns 0 if successful.

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.

Parameters:
inode pointer on the node
file pointer on the file
Returns:
This function returns 0.

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.

Parameters:
pdev the device
Returns:
This function returns 0 if successful.

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.

Parameters:
touch_mode Touch screen operation mode.
Returns:
This function returns PMIC_SUCCESS if successful.

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.

Parameters:
pdev the device
state the state
Returns:
This function returns 0 if successful.

References pmic_write_reg(), and suspend_flag.


Variable Documentation

int suspend_flag [static]
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().

footer
©  Freescale Semiconductor, Inc., 2007.  All rights reserved.
Freescale Confidential Proprietary
NDA Required
doxygen