mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
add gsensor mma8452 code support for board-rk30-sdk
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
* author: hhb@rock-chips.com
|
||||
*****************************************************************************************/
|
||||
#if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
|
||||
#define XPT2046_GPIO_INT RK30_PIN6_PB7
|
||||
#define XPT2046_GPIO_INT RK30_PIN4_PC2
|
||||
#define DEBOUNCE_REPTIME 3
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ static struct xpt2046_platform_data xpt2046_info = {
|
||||
.debounce_rep = DEBOUNCE_REPTIME,
|
||||
.debounce_tol = 20,
|
||||
.gpio_pendown = XPT2046_GPIO_INT,
|
||||
.pendown_iomux_name = GPIO6B7_TESTCLOCKOUT_NAME,
|
||||
.pendown_iomux_mode = GPIO6B_GPIO6B7,
|
||||
.pendown_iomux_name = GPIO4C2_SMCDATA2_TRACEDATA2_NAME,
|
||||
.pendown_iomux_mode = GPIO4C_GPIO4C2,
|
||||
.touch_virtualkey_length = 60,
|
||||
.penirq_recheck_delay_usecs = 1,
|
||||
#if defined(CONFIG_TOUCHSCREEN_480X800)
|
||||
@@ -109,8 +109,8 @@ static struct xpt2046_platform_data xpt2046_info = {
|
||||
.debounce_rep = DEBOUNCE_REPTIME,
|
||||
.debounce_tol = 20,
|
||||
.gpio_pendown = XPT2046_GPIO_INT,
|
||||
.pendown_iomux_name = GPIO6B7_TESTCLOCKOUT_NAME,
|
||||
.pendown_iomux_mode = GPIO6B_GPIO6B7,
|
||||
.pendown_iomux_name = GPIO4C2_SMCDATA2_TRACEDATA2_NAME,
|
||||
.pendown_iomux_mode = GPIO4C_GPIO4C2,
|
||||
.touch_virtualkey_length = 60,
|
||||
.penirq_recheck_delay_usecs = 1,
|
||||
|
||||
@@ -155,7 +155,7 @@ static struct spi_board_info board_spi_devices[] = {
|
||||
{
|
||||
.modalias = "xpt2046_ts",
|
||||
.chip_select = 1,// 2,
|
||||
.max_speed_hz = 1 * 1000 * 1000,/* (max sample rate @ 3V) * (cmd + data + overhead) */
|
||||
.max_speed_hz = 1 * 1000 * 800,/* (max sample rate @ 3V) * (cmd + data + overhead) */
|
||||
.bus_num = 0,
|
||||
.irq = XPT2046_GPIO_INT,
|
||||
.platform_data = &xpt2046_info,
|
||||
@@ -263,7 +263,32 @@ struct platform_device rk29_device_backlight = {
|
||||
|
||||
#endif
|
||||
|
||||
/*MMA8452 gsensor*/
|
||||
#if defined (CONFIG_GS_MMA8452)
|
||||
#define MMA8452_INT_PIN RK30_PIN4_PC0
|
||||
|
||||
static int mma8452_init_platform_hw(void)
|
||||
{
|
||||
rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
|
||||
|
||||
if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
|
||||
gpio_free(MMA8452_INT_PIN);
|
||||
printk("mma8452_init_platform_hw gpio_request error\n");
|
||||
return -EIO;
|
||||
}
|
||||
gpio_pull_updown(MMA8452_INT_PIN, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static struct mma8452_platform_data mma8452_info = {
|
||||
.model= 8452,
|
||||
.swap_xy = 0,
|
||||
.swap_xyz = 1,
|
||||
.init_platform_hw= mma8452_init_platform_hw,
|
||||
.orientation = { -1, 0, 0, 0, 0, 1, 0, -1, 0},
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
static struct platform_device *devices[] __initdata = {
|
||||
@@ -276,6 +301,16 @@ static struct platform_device *devices[] __initdata = {
|
||||
// i2c
|
||||
#ifdef CONFIG_I2C0_RK30
|
||||
static struct i2c_board_info __initdata i2c0_info[] = {
|
||||
#if defined (CONFIG_GS_MMA8452)
|
||||
{
|
||||
.type = "gs_mma8452",
|
||||
.addr = 0x1c,
|
||||
.flags = 0,
|
||||
.irq = MMA8452_INT_PIN,
|
||||
.platform_data = &mma8452_info,
|
||||
},
|
||||
#endif
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
13
arch/arm/mach-rk30/include/mach/board.h
Normal file → Executable file
13
arch/arm/mach-rk30/include/mach/board.h
Normal file → Executable file
@@ -22,6 +22,19 @@ struct rk30_i2c_platform_data {
|
||||
int (*io_deinit)(void);
|
||||
};
|
||||
|
||||
struct mma8452_platform_data {
|
||||
u16 model;
|
||||
u16 swap_xy;
|
||||
u16 swap_xyz;
|
||||
signed char orientation[9];
|
||||
int (*get_pendown_state)(void);
|
||||
int (*init_platform_hw)(void);
|
||||
int (*mma8452_platform_sleep)(void);
|
||||
int (*mma8452_platform_wakeup)(void);
|
||||
void (*exit_platform_hw)(void);
|
||||
};
|
||||
|
||||
|
||||
void __init rk30_map_common_io(void);
|
||||
void __init rk30_init_irq(void);
|
||||
void __init rk30_map_io(void);
|
||||
|
||||
@@ -66,7 +66,7 @@ static DECLARE_WAIT_QUEUE_HEAD(data_ready_wq);
|
||||
#ifdef CONFIG_HAS_EARLYSUSPEND
|
||||
static struct early_suspend mma8452_early_suspend;
|
||||
#endif
|
||||
static int revision = -1;
|
||||
//static int revision = -1;
|
||||
static const char* vendor = "Freescale Semiconductor";
|
||||
|
||||
|
||||
@@ -197,6 +197,7 @@ static int mma845x_active(struct i2c_client *client,int enable)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int mma8452_start_test(struct i2c_client *client)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -241,6 +242,7 @@ static int mma8452_start_test(struct i2c_client *client)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int mma8452_start_dev(struct i2c_client *client, char rate)
|
||||
{
|
||||
@@ -627,9 +629,9 @@ static void mma8452_resume(struct early_suspend *h)
|
||||
#else
|
||||
static int mma8452_suspend(struct i2c_client *client, pm_message_t mesg)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0;
|
||||
//struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
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)
|
||||
// {
|
||||
// mma8452->status = MMA8452_SUSPEND;
|
||||
@@ -639,8 +641,8 @@ static int mma8452_suspend(struct i2c_client *client, pm_message_t mesg)
|
||||
}
|
||||
static int mma8452_resume(struct i2c_client *client)
|
||||
{
|
||||
int ret;
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
int ret = 0;
|
||||
//struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
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)
|
||||
@@ -782,7 +784,7 @@ static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id
|
||||
goto exit_input_register_device_failed;
|
||||
}
|
||||
|
||||
mma8452_device.parent = &client->dev;
|
||||
mma8452_device.parent = &client->dev;
|
||||
err = misc_register(&mma8452_device);
|
||||
if (err < 0) {
|
||||
mmaprintk(KERN_ERR
|
||||
@@ -798,10 +800,10 @@ static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HAS_EARLYSUSPEND
|
||||
mma8452_early_suspend.suspend = mma8452_suspend;
|
||||
mma8452_early_suspend.resume = mma8452_resume;
|
||||
mma8452_early_suspend.level = 0x2;
|
||||
register_early_suspend(&mma8452_early_suspend);
|
||||
mma8452_early_suspend.suspend = mma8452_suspend;
|
||||
mma8452_early_suspend.resume = mma8452_resume;
|
||||
mma8452_early_suspend.level = 0x2;
|
||||
register_early_suspend(&mma8452_early_suspend);
|
||||
#endif
|
||||
|
||||
printk(KERN_INFO "mma8452 probe ok\n");
|
||||
@@ -812,9 +814,9 @@ static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id
|
||||
return 0;
|
||||
|
||||
exit_gsensor_sysfs_init_failed:
|
||||
misc_deregister(&mma8452_device);
|
||||
misc_deregister(&mma8452_device);
|
||||
exit_misc_device_register_mma8452_device_failed:
|
||||
input_unregister_device(mma8452->input_dev);
|
||||
input_unregister_device(mma8452->input_dev);
|
||||
exit_input_register_device_failed:
|
||||
input_free_device(mma8452->input_dev);
|
||||
exit_input_allocate_device_failed:
|
||||
|
||||
Reference in New Issue
Block a user