mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-11 05:17:10 +09:00
rollback gsensor mmaio num
This commit is contained in:
@@ -1,85 +0,0 @@
|
||||
/* --------------------------------------------------------------------------------------------------------
|
||||
* Copyright(C), 2010-2011, Fuzhou Rockchip Co., Ltd. All Rights Reserved.
|
||||
*
|
||||
* File: custom_log.h
|
||||
*
|
||||
* Desc: ChenZhen ƫ<>õ<EFBFBD> log <20><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>ʵ<EFBFBD><CAB5>.
|
||||
*
|
||||
* -----------------------------------------------------------------------------------
|
||||
* < ϰ<><CFB0> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> > :
|
||||
*
|
||||
* -----------------------------------------------------------------------------------
|
||||
*
|
||||
* Usage: <09><><EFBFBD>ñ<EFBFBD> log <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .c <20>ļ<EFBFBD>, <20><>Ҫʹ<D2AA><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> log <20><><EFBFBD><EFBFBD>,
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inclue <20><><EFBFBD>ļ<EFBFBD>֮ǰ, "#define ENABLE_DEBUG_LOG" <20><>.
|
||||
* Note:
|
||||
*
|
||||
* Author: ChenZhen
|
||||
*
|
||||
* --------------------------------------------------------------------------------------------------------
|
||||
* Version:
|
||||
* v1.0
|
||||
* --------------------------------------------------------------------------------------------------------
|
||||
* Log:
|
||||
----Fri Nov 19 15:20:28 2010 v1.0
|
||||
*
|
||||
* --------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __CUSTOM_LOG_H__
|
||||
#define __CUSTOM_LOG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Include Files
|
||||
* ---------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Macros Definition
|
||||
* ---------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_DEBUG_LOG
|
||||
#define D(fmt, args...) \
|
||||
{ printk("[File]:%s; [Line]:%d; [Func]:%s(); " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ## args); }
|
||||
#else
|
||||
#define D(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#define W(fmt, args...) \
|
||||
{ printk("WARNING :: [File]:%s; [Line]:%d; [Func]:%s() :: " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ## args); }
|
||||
|
||||
#define E(fmt, args...) \
|
||||
{ printk("ERROR :: [File]:%s; [Line]:%d; [Func]:%s() :: " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ## args); }
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Types and Structures Definition
|
||||
* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Global Functions' Prototype
|
||||
* ---------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------------
|
||||
* Inline Functions Implementation
|
||||
* ---------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CUSTOM_LOG_H__ */
|
||||
|
||||
@@ -33,20 +33,22 @@
|
||||
#include <linux/earlysuspend.h>
|
||||
#endif
|
||||
|
||||
// #define ENABLE_DEBUG_LOG
|
||||
#include <mach/custom_log.h>
|
||||
|
||||
#if 1
|
||||
#define mmaprintk(x...) D(x)
|
||||
#define mmaprintk(x...) printk(x)
|
||||
#else
|
||||
#define mmaprintk(x...)
|
||||
#endif
|
||||
|
||||
// #define ENABLE_VERBOSE_LOG
|
||||
#ifdef ENABLE_VERBOSE_LOG
|
||||
#define V(x...) D(x)
|
||||
#if 0
|
||||
#define mmaprintkd(x...) printk(x)
|
||||
#else
|
||||
#define V(x...)
|
||||
#define mmaprintkd(x...)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define mmaprintkf(x...) printk(x)
|
||||
#else
|
||||
#define mmaprintkf(x...)
|
||||
#endif
|
||||
|
||||
static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id *id);
|
||||
@@ -73,8 +75,6 @@ typedef char status_t;
|
||||
#define MMA8452_OPEN 1
|
||||
#define MMA8452_CLOSE 0
|
||||
|
||||
|
||||
// .! : <20>豸ʵ<E8B1B8><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
struct mma8452_data {
|
||||
status_t status;
|
||||
char curr_tate;
|
||||
@@ -83,19 +83,12 @@ struct mma8452_data {
|
||||
struct work_struct work;
|
||||
struct delayed_work delaywork; /*report second event*/
|
||||
|
||||
/** <20><><EFBFBD><EFBFBD> sensor <20><><EFBFBD><EFBFBD>. */
|
||||
struct mma8452_axis sense_data;
|
||||
/** <20><> "sense_data" <20>Ļ<EFBFBD><C4BB>Ᵽ<EFBFBD><E2B1A3>. */
|
||||
struct mutex sense_data_mutex;
|
||||
|
||||
/** <20><>ʶ "sense_data" <20>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ч. */
|
||||
atomic_t data_ready;
|
||||
/** <20><><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD> <20><><EFBFBD><EFBFBD> ready <20>ĵȴ<C4B5><C8B4><EFBFBD><EFBFBD><EFBFBD>ͷ. */
|
||||
wait_queue_head_t data_ready_wq;
|
||||
|
||||
/** <20><>ʶ <20>豸<EFBFBD><E8B1B8>Ҫ<EFBFBD><D2AA> START <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ݵĴ<DDB5><C4B4><EFBFBD>, <20><>Ӧ MMA_IOCTL_START <20><><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD>. */
|
||||
int start_count;
|
||||
/** <20><> 'start_count' <20><><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>Ᵽ<EFBFBD><E2B1A3>. */
|
||||
struct mutex operation_mutex;
|
||||
};
|
||||
|
||||
@@ -199,7 +192,7 @@ static int mma845x_active(struct i2c_client *client,int enable)
|
||||
tmp |=ACTIVE_MASK;
|
||||
else
|
||||
tmp &=~ACTIVE_MASK;
|
||||
mmaprintk("mma845x_active %s (0x%x)\n",enable?"active":"standby",tmp);
|
||||
mmaprintkd("mma845x_active %s (0x%x)\n",enable?"active":"standby",tmp);
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG1,tmp);
|
||||
return ret;
|
||||
}
|
||||
@@ -209,39 +202,39 @@ static int mma8452_start_test(struct i2c_client *client)
|
||||
int ret = 0;
|
||||
int tmp;
|
||||
|
||||
mmaprintk("-------------------------mma8452 start test------------------------\n");
|
||||
mmaprintkf("-------------------------mma8452 start test------------------------\n");
|
||||
|
||||
/* standby */
|
||||
mma845x_active(client,0);
|
||||
mmaprintk("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mmaprintkd("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
|
||||
/* disable FIFO FMODE = 0*/
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_F_SETUP,0);
|
||||
mmaprintk("mma8452 MMA8452_REG_F_SETUP:%x\n",mma845x_read_reg(client,MMA8452_REG_F_SETUP));
|
||||
mmaprintkd("mma8452 MMA8452_REG_F_SETUP:%x\n",mma845x_read_reg(client,MMA8452_REG_F_SETUP));
|
||||
|
||||
/* set full scale range to 2g */
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_XYZ_DATA_CFG,0);
|
||||
mmaprintk("mma8452 MMA8452_REG_XYZ_DATA_CFG:%x\n",mma845x_read_reg(client,MMA8452_REG_XYZ_DATA_CFG));
|
||||
mmaprintkd("mma8452 MMA8452_REG_XYZ_DATA_CFG:%x\n",mma845x_read_reg(client,MMA8452_REG_XYZ_DATA_CFG));
|
||||
|
||||
/* set bus 8bit/14bit(FREAD = 1,FMODE = 0) ,data rate*/
|
||||
tmp = (MMA8452_RATE_12P5<< MMA8452_RATE_SHIFT) | FREAD_MASK;
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG1,tmp);
|
||||
mmaprintk("mma8452 MMA8452_REG_CTRL_REG1:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG1));
|
||||
mmaprintkd("mma8452 MMA8452_REG_CTRL_REG1:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG1));
|
||||
|
||||
mmaprintk("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mmaprintkd("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG3,5);
|
||||
mmaprintk("mma8452 MMA8452_REG_CTRL_REG3:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG3));
|
||||
mmaprintkd("mma8452 MMA8452_REG_CTRL_REG3:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG3));
|
||||
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG4,1);
|
||||
mmaprintk("mma8452 MMA8452_REG_CTRL_REG4:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG4));
|
||||
mmaprintkd("mma8452 MMA8452_REG_CTRL_REG4:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG4));
|
||||
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG5,1);
|
||||
mmaprintk("mma8452 MMA8452_REG_CTRL_REG5:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG5));
|
||||
mmaprintkd("mma8452 MMA8452_REG_CTRL_REG5:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG5));
|
||||
|
||||
mmaprintk("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mmaprintkd("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mma845x_active(client,1);
|
||||
mmaprintk("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mmaprintkd("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
|
||||
enable_irq(client->irq);
|
||||
msleep(50);
|
||||
@@ -255,39 +248,39 @@ static int mma8452_start_dev(struct i2c_client *client, char rate)
|
||||
int tmp;
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client); // mma8452_data <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mma8452.h <20><>.
|
||||
|
||||
mmaprintk("-------------------------mma8452 start ------------------------\n");
|
||||
mmaprintkf("-------------------------mma8452 start ------------------------\n");
|
||||
/* standby */
|
||||
mma845x_active(client,0);
|
||||
mmaprintk("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mmaprintkd("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
|
||||
/* disable FIFO FMODE = 0*/
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_F_SETUP,0);
|
||||
mmaprintk("mma8452 MMA8452_REG_F_SETUP:%x\n",mma845x_read_reg(client,MMA8452_REG_F_SETUP));
|
||||
mmaprintkd("mma8452 MMA8452_REG_F_SETUP:%x\n",mma845x_read_reg(client,MMA8452_REG_F_SETUP));
|
||||
|
||||
/* set full scale range to 2g */
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_XYZ_DATA_CFG,0);
|
||||
mmaprintk("mma8452 MMA8452_REG_XYZ_DATA_CFG:%x\n",mma845x_read_reg(client,MMA8452_REG_XYZ_DATA_CFG));
|
||||
mmaprintkd("mma8452 MMA8452_REG_XYZ_DATA_CFG:%x\n",mma845x_read_reg(client,MMA8452_REG_XYZ_DATA_CFG));
|
||||
|
||||
/* set bus 8bit/14bit(FREAD = 1,FMODE = 0) ,data rate*/
|
||||
tmp = (rate<< MMA8452_RATE_SHIFT) | FREAD_MASK;
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG1,tmp);
|
||||
mma8452->curr_tate = rate;
|
||||
mmaprintk("mma8452 MMA8452_REG_CTRL_REG1:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG1));
|
||||
mmaprintkd("mma8452 MMA8452_REG_CTRL_REG1:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG1));
|
||||
|
||||
mmaprintk("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mmaprintkd("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG3,5);
|
||||
mmaprintk("mma8452 MMA8452_REG_CTRL_REG3:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG3));
|
||||
mmaprintkd("mma8452 MMA8452_REG_CTRL_REG3:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG3));
|
||||
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG4,1);
|
||||
mmaprintk("mma8452 MMA8452_REG_CTRL_REG4:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG4));
|
||||
mmaprintkd("mma8452 MMA8452_REG_CTRL_REG4:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG4));
|
||||
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG5,1);
|
||||
mmaprintk("mma8452 MMA8452_REG_CTRL_REG5:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG5));
|
||||
mmaprintkd("mma8452 MMA8452_REG_CTRL_REG5:%x\n",mma845x_read_reg(client,MMA8452_REG_CTRL_REG5));
|
||||
|
||||
mmaprintk("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mmaprintkd("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mma845x_active(client,1);
|
||||
mmaprintk("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
mmaprintkd("mma8452 MMA8452_REG_SYSMOD:%x\n",mma845x_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
|
||||
enable_irq(client->irq);
|
||||
return ret;
|
||||
@@ -298,7 +291,7 @@ static int mma8452_start(struct i2c_client *client, char rate)
|
||||
{
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
|
||||
printk("%s::enter\n",__FUNCTION__);
|
||||
mmaprintkf("%s::enter\n",__FUNCTION__);
|
||||
if (mma8452->status == MMA8452_OPEN) {
|
||||
return 0;
|
||||
}
|
||||
@@ -315,7 +308,7 @@ static int mma8452_close_dev(struct i2c_client *client)
|
||||
static int mma8452_close(struct i2c_client *client)
|
||||
{
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
printk("%s::enter\n",__FUNCTION__);
|
||||
mmaprintkf("%s::enter\n",__FUNCTION__);
|
||||
mma8452->status = MMA8452_CLOSE;
|
||||
|
||||
return mma8452_close_dev(client);
|
||||
@@ -325,7 +318,7 @@ static int mma8452_reset_rate(struct i2c_client *client, char rate)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
mmaprintk("\n----------------------------mma8452_reset_rate------------------------\n");
|
||||
mmaprintkf("\n----------------------------mma8452_reset_rate------------------------\n");
|
||||
|
||||
ret = mma8452_close_dev(client);
|
||||
ret = mma8452_start_dev(client, rate);
|
||||
@@ -356,7 +349,7 @@ static void mma8452_report_value(struct i2c_client *client, struct mma8452_axis
|
||||
input_report_abs(mma8452->input_dev, ABS_Y, axis->y);
|
||||
input_report_abs(mma8452->input_dev, ABS_Z, axis->z);
|
||||
input_sync(mma8452->input_dev);
|
||||
V("Gsensor x==%d y==%d z==%d\n",axis->x,axis->y,axis->z);
|
||||
mmaprintkd("Gsensor x==%d y==%d z==%d\n",axis->x,axis->y,axis->z);
|
||||
}
|
||||
|
||||
/** <20><> <20>װ벿ִ<EBB2BF><D6B4>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ g sensor <20><><EFBFBD><EFBFBD>. */
|
||||
@@ -377,7 +370,7 @@ static int mma8452_get_data(struct i2c_client *client)
|
||||
return ret;
|
||||
} while (0);
|
||||
|
||||
V("0x%02x 0x%02x 0x%02x \n",buffer[0],buffer[1],buffer[2]);
|
||||
mmaprintkd("0x%02x 0x%02x 0x%02x \n",buffer[0],buffer[1],buffer[2]);
|
||||
|
||||
axis.x = mma8452_convert_to_int(buffer[0]);
|
||||
axis.y = mma8452_convert_to_int(buffer[1]);
|
||||
@@ -389,7 +382,7 @@ static int mma8452_get_data(struct i2c_client *client)
|
||||
swap(axis.x,axis.y);
|
||||
}
|
||||
|
||||
V( "%s: ------------------mma8452_GetData axis = %d %d %d--------------\n",
|
||||
mmaprintkd( "%s: ------------------mma8452_GetData axis = %d %d %d--------------\n",
|
||||
__func__, axis.x, axis.y, axis.z);
|
||||
|
||||
//memcpy(sense_data, &axis, sizeof(axis));
|
||||
@@ -425,34 +418,20 @@ static int mma8452_trans_buff(char *rbuf, int size)
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>Ѿ<EFBFBD> cache <20>˵<EFBFBD> sensor <20><><EFBFBD><EFBFBD>.
|
||||
* @param sense_data
|
||||
* ָ<><EFBFBD><F2B7B5BB><EFBFBD> buffer.
|
||||
* @param client
|
||||
* <20><>ǰ i2c client <20>豸ʵ<E8B1B8><CAB5><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ָ<EFBFBD><D6B8>.
|
||||
* @return
|
||||
* <20><><EFBFBD>ɹ<EFBFBD>, <20><><EFBFBD><EFBFBD> 0; <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
*/
|
||||
static int mma8452_get_cached_data(struct i2c_client* client, struct mma8452_axis* sense_data)
|
||||
{
|
||||
struct mma8452_data* this = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
|
||||
/* <20>г<EFBFBD>ʱ<EFBFBD><CAB1>, <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD> ready. */
|
||||
wait_event_interruptible_timeout(this->data_ready_wq,
|
||||
atomic_read(&(this->data_ready) ),
|
||||
msecs_to_jiffies(1000) );
|
||||
/* <20><><EFBFBD><EFBFBD>ʱ, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB> ready. */
|
||||
if ( 0 == atomic_read(&(this->data_ready) ) ) {
|
||||
E("waiting 'data_ready_wq' timed out.");
|
||||
/* <20><><EFBFBD><EFBFBD> error. */
|
||||
printk("waiting 'data_ready_wq' timed out.");
|
||||
return -1;
|
||||
}
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD> ready, <20><><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. */
|
||||
mutex_lock(&(this->sense_data_mutex) );
|
||||
*sense_data = this->sense_data;
|
||||
mutex_unlock(&(this->sense_data_mutex) );
|
||||
/* <20><><EFBFBD><EFBFBD>. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -489,44 +468,31 @@ static int mma8452_ioctl(struct inode *inode, struct file *file, unsigned int cm
|
||||
|
||||
switch (cmd) {
|
||||
case MMA_IOCTL_START:
|
||||
/* <20><><EFBFBD><EFBFBD>. */
|
||||
mutex_lock(&(this->operation_mutex) );
|
||||
D("to perform 'MMA_IOCTL_START', former 'start_count' is %d.", this->start_count);
|
||||
/* <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD>. */
|
||||
mmaprintkd("to perform 'MMA_IOCTL_START', former 'start_count' is %d.", this->start_count);
|
||||
(this->start_count)++;
|
||||
/* <20><><EFBFBD>dz<EFBFBD><C7B3><EFBFBD> start, <20><>... */
|
||||
if ( 1 == this->start_count ) {
|
||||
/* <20><>λ data_ready. */
|
||||
atomic_set(&(this->data_ready), 0);
|
||||
/* ִ<>о<EFBFBD><D0BE><EFBFBD><EFBFBD>Ķ<EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. */
|
||||
if ( (ret = mma8452_start(client, MMA8452_RATE_12P5) ) < 0 ) {
|
||||
mutex_unlock(&(this->operation_mutex) );
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
/* <20><><EFBFBD><EFBFBD>. */
|
||||
mutex_unlock(&(this->operation_mutex) );
|
||||
D("finish 'MMA_IOCTL_START', ret = %d.", ret);
|
||||
/* <20><><EFBFBD><EFBFBD>. */
|
||||
mmaprintkd("finish 'MMA_IOCTL_START', ret = %d.", ret);
|
||||
return 0;
|
||||
|
||||
case MMA_IOCTL_CLOSE:
|
||||
/* <20><><EFBFBD><EFBFBD>. */
|
||||
mutex_lock(&(this->operation_mutex) );
|
||||
D("to perform 'MMA_IOCTL_CLOSE', former 'start_count' is %d, PID : %d", this->start_count, get_current()->pid);
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD> 0, <20><>... */
|
||||
mmaprintkd("to perform 'MMA_IOCTL_CLOSE', former 'start_count' is %d, PID : %d", this->start_count, get_current()->pid);
|
||||
if ( 0 == (--(this->start_count) ) ) {
|
||||
/* <20><>λ data_ready. */
|
||||
atomic_set(&(this->data_ready), 0);
|
||||
/* ִ<>о<EFBFBD><D0BE><EFBFBD><EFBFBD>Ķ<EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD> stop <20><><EFBFBD><EFBFBD>. */
|
||||
if ( (ret = mma8452_close(client) ) < 0 ) {
|
||||
mutex_unlock(&(this->operation_mutex) );
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
/* <20><><EFBFBD><EFBFBD>. */
|
||||
mutex_unlock(&(this->operation_mutex) );
|
||||
/* <20><><EFBFBD><EFBFBD>. */
|
||||
return 0;
|
||||
|
||||
case MMA_IOCTL_APP_SET_RATE:
|
||||
@@ -537,7 +503,7 @@ static int mma8452_ioctl(struct inode *inode, struct file *file, unsigned int cm
|
||||
case MMA_IOCTL_GETDATA:
|
||||
// ret = mma8452_trans_buff(msg, RBUFF_SIZE);
|
||||
if ( (ret = mma8452_get_cached_data(client, &sense_data) ) < 0 ) {
|
||||
E("failed to get cached sense data, ret = %d.", ret);
|
||||
printk("failed to get cached sense data, ret = %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
@@ -552,7 +518,7 @@ static int mma8452_ioctl(struct inode *inode, struct file *file, unsigned int cm
|
||||
return -EFAULT;
|
||||
*/
|
||||
if ( copy_to_user(argp, &sense_data, sizeof(sense_data) ) ) {
|
||||
D("failed to copy sense data to user space.");
|
||||
printk("failed to copy sense data to user space.");
|
||||
return -EFAULT;
|
||||
}
|
||||
break;
|
||||
@@ -569,7 +535,7 @@ static void mma8452_work_func(struct work_struct *work)
|
||||
struct i2c_client *client = mma8452->client;
|
||||
|
||||
if (mma8452_get_data(client) < 0)
|
||||
mmaprintk(KERN_ERR "MMA8452 mma_work_func: Get data failed\n");
|
||||
mmaprintkd(KERN_ERR "MMA8452 mma_work_func: Get data failed\n");
|
||||
|
||||
enable_irq(client->irq);
|
||||
}
|
||||
@@ -581,8 +547,8 @@ static void mma8452_delaywork_func(struct work_struct *work)
|
||||
struct i2c_client *client = mma8452->client;
|
||||
|
||||
if (mma8452_get_data(client) < 0)
|
||||
E(KERN_ERR "MMA8452 mma_work_func: Get data failed\n");
|
||||
V("%s :int src:0x%02x\n",__FUNCTION__,mma845x_read_reg(mma8452->client,MMA8452_REG_INTSRC));
|
||||
printk(KERN_ERR "MMA8452 mma_work_func: Get data failed\n");
|
||||
mmaprintkd("%s :int src:0x%02x\n",__FUNCTION__,mma845x_read_reg(mma8452->client,MMA8452_REG_INTSRC));
|
||||
enable_irq(client->irq);
|
||||
}
|
||||
|
||||
@@ -591,9 +557,8 @@ static irqreturn_t mma8452_interrupt(int irq, void *dev_id)
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)dev_id;
|
||||
|
||||
disable_irq_nosync(irq);
|
||||
/* .! : <20>ӳٵ<D3B3><D9B5><EFBFBD> <20>װ벿 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>). */
|
||||
schedule_delayed_work(&mma8452->delaywork, msecs_to_jiffies(30));
|
||||
V("%s :enter\n",__FUNCTION__);
|
||||
mmaprintkf("%s :enter\n",__FUNCTION__);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@@ -604,7 +569,6 @@ static struct file_operations mma8452_fops = {
|
||||
.ioctl = mma8452_ioctl,
|
||||
};
|
||||
|
||||
/** <20><><EFBFBD><EFBFBD><EFBFBD>豸. */
|
||||
static struct miscdevice mma8452_device = {
|
||||
.minor = MISC_DYNAMIC_MINOR,
|
||||
.name = "mma8452_daemon",//"mma8452_daemon",
|
||||
@@ -632,7 +596,7 @@ static void mma8452_suspend(struct early_suspend *h)
|
||||
{
|
||||
struct i2c_client *client = container_of(mma8452_device.parent, struct i2c_client, dev);
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
mmaprintk("Gsensor mma7760 enter suspend mma8452->status %d\n",mma8452->status);
|
||||
mmaprintkd("Gsensor mma7760 enter suspend mma8452->status %d\n",mma8452->status);
|
||||
// if(mma8452->status == MMA8452_OPEN)
|
||||
// {
|
||||
//mma8452->status = MMA8452_SUSPEND;
|
||||
@@ -644,7 +608,7 @@ static void mma8452_resume(struct early_suspend *h)
|
||||
{
|
||||
struct i2c_client *client = container_of(mma8452_device.parent, struct i2c_client, dev);
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
mmaprintk("Gsensor mma7760 resume!! mma8452->status %d\n",mma8452->status);
|
||||
mmaprintkd("Gsensor mma7760 resume!! mma8452->status %d\n",mma8452->status);
|
||||
//if((mma8452->status == MMA8452_SUSPEND) && (mma8452->status != MMA8452_OPEN))
|
||||
// if (mma8452->status == MMA8452_OPEN)
|
||||
// mma8452_start_dev(client,mma8452->curr_tate);
|
||||
@@ -653,7 +617,7 @@ static void mma8452_resume(struct early_suspend *h)
|
||||
static int mma8452_suspend(struct i2c_client *client, pm_message_t mesg)
|
||||
{
|
||||
int ret;
|
||||
mmaprintk("Gsensor mma7760 enter 2 level suspend mma8452->status %d\n",mma8452->status);
|
||||
mmaprintkd("Gsensor mma7760 enter 2 level suspend mma8452->status %d\n",mma8452->status);
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
// if(mma8452->status == MMA8452_OPEN)
|
||||
// {
|
||||
@@ -666,7 +630,7 @@ static int mma8452_resume(struct i2c_client *client)
|
||||
{
|
||||
int ret;
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
mmaprintk("Gsensor mma7760 2 level resume!! mma8452->status %d\n",mma8452->status);
|
||||
mmaprintkd("Gsensor mma7760 2 level resume!! mma8452->status %d\n",mma8452->status);
|
||||
// if((mma8452->status == MMA8452_SUSPEND) && (mma8452->status != MMA8452_OPEN))
|
||||
//if (mma8452->status == MMA8452_OPEN)
|
||||
// ret = mma8452_start_dev(client, mma8452->curr_tate);
|
||||
@@ -679,16 +643,12 @@ static const struct i2c_device_id mma8452_id[] = {
|
||||
{ }
|
||||
};
|
||||
|
||||
/** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>. */
|
||||
static struct i2c_driver mma8452_driver = {
|
||||
.driver = {
|
||||
.name = "gs_mma8452",
|
||||
},
|
||||
.id_table = mma8452_id,
|
||||
.probe = mma8452_probe, // .!! : <20><> probe() <20>ĵ<EFBFBD><C4B5><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ע<><D7A2><EFBFBD>豸<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>μ<EFBFBD> board-rk29sdk.c <20>е<EFBFBD> board_i2c0_devices.
|
||||
// <20><> board_i2c0_devices <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "gs_mma8452" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> I2C <20>豸.
|
||||
// ͬʱҲ<CAB1><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> I2C <20><>ַ <20><> <20>ն˺ŵ<CBBA><C5B5><EFBFBD>Ϣ.
|
||||
.probe = mma8452_probe,
|
||||
.remove = __devexit_p(mma8452_remove),
|
||||
#ifndef CONFIG_HAS_EARLYSUSPEND
|
||||
.suspend = &mma8452_suspend,
|
||||
@@ -741,7 +701,7 @@ static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id
|
||||
int err;
|
||||
char devid;
|
||||
|
||||
mmaprintk("%s enter\n",__FUNCTION__);
|
||||
mmaprintkf("%s enter\n",__FUNCTION__);
|
||||
|
||||
mma8452 = kzalloc(sizeof(struct mma8452_data), GFP_KERNEL);
|
||||
if (!mma8452) {
|
||||
|
||||
@@ -54,8 +54,7 @@
|
||||
#define MMA8452_REG_OFF_Y 0x30 //RW
|
||||
#define MMA8452_REG_OFF_Z 0x31 //RW
|
||||
|
||||
//#define MMAIO 0xA1
|
||||
#define MMAIO 'm'
|
||||
#define MMAIO 0xA1
|
||||
|
||||
/* IOCTLs for MMA8452 library */
|
||||
#define MMA_IOCTL_INIT _IO(MMAIO, 0x01)
|
||||
|
||||
Reference in New Issue
Block a user