mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 21:07:02 +09:00
xxm update FIH 1: update mpu3050 2: delete no use file 3:update rk29_FIH_defconfig
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Linux kernel version: 2.6.32.27
|
||||
# Tue Mar 1 20:25:24 2011
|
||||
# Thu Mar 24 18:04:14 2011
|
||||
#
|
||||
CONFIG_ARM=y
|
||||
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
|
||||
CONFIG_HAVE_SCHED_CLOCK=y
|
||||
CONFIG_GENERIC_GPIO=y
|
||||
CONFIG_GENERIC_TIME=y
|
||||
CONFIG_GENERIC_CLOCKEVENTS=y
|
||||
@@ -202,6 +203,7 @@ CONFIG_MACH_RK29FIH=y
|
||||
# CONFIG_MACH_RK29_AIGO is not set
|
||||
# CONFIG_MACH_RK29_MALATA is not set
|
||||
# CONFIG_MACH_RK29_PHONESDK is not set
|
||||
# CONFIG_MACH_RK29_A22 is not set
|
||||
CONFIG_RK29_MEM_SIZE_M=512
|
||||
|
||||
#
|
||||
@@ -617,12 +619,12 @@ CONFIG_GPS_GNS7560=y
|
||||
# CONFIG_MPU_NONE is not set
|
||||
CONFIG_SENSORS_MPU3050=y
|
||||
# CONFIG_SENSORS_MPU6000 is not set
|
||||
CONFIG_SENSORS_ACCELEROMETER_NONE=y
|
||||
# CONFIG_SENSORS_ACCELEROMETER_NONE is not set
|
||||
# CONFIG_SENSORS_ADXL346 is not set
|
||||
# CONFIG_SENSORS_BMA150 is not set
|
||||
# CONFIG_SENSORS_BMA222 is not set
|
||||
# CONFIG_SENSORS_KXSD9 is not set
|
||||
# CONFIG_SENSORS_KXTF9 is not set
|
||||
CONFIG_SENSORS_KXTF9=y
|
||||
# CONFIG_SENSORS_LIS331DLH is not set
|
||||
# CONFIG_SENSORS_LSM303DLHA is not set
|
||||
# CONFIG_SENSORS_MMA8450 is not set
|
||||
@@ -809,11 +811,6 @@ CONFIG_KEYS_RK29=y
|
||||
# CONFIG_INPUT_JOYSTICK is not set
|
||||
# CONFIG_INPUT_TABLET is not set
|
||||
CONFIG_INPUT_TOUCHSCREEN=y
|
||||
CONFIG_TOUCHSCREEN_XPT2046_SPI_NOCHOOSE=y
|
||||
# CONFIG_TOUCHSCREEN_XPT2046_SPI is not set
|
||||
# CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI is not set
|
||||
# CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI is not set
|
||||
# CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI is not set
|
||||
# CONFIG_TOUCHSCREEN_IT7250 is not set
|
||||
# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
|
||||
# CONFIG_TOUCHSCREEN_AD7879 is not set
|
||||
@@ -842,10 +839,8 @@ CONFIG_MXT224_MAX_Y=4095
|
||||
# CONFIG_EETI_EGALAX is not set
|
||||
# CONFIG_TOUCHSCREEN_IT7260 is not set
|
||||
CONFIG_INPUT_MISC=y
|
||||
# CONFIG_INPUT_PSENSOR_ISL29028 is not set
|
||||
# CONFIG_INPUT_LPSENSOR_ISL29028 is not set
|
||||
# CONFIG_INPUT_LPSENSOR_CM3602 is not set
|
||||
CONFIG_INPUT_LSENSOR_CM3623=y
|
||||
# CONFIG_INPUT_MPU3050 is not set
|
||||
# CONFIG_INPUT_ATI_REMOTE is not set
|
||||
# CONFIG_INPUT_ATI_REMOTE2 is not set
|
||||
# CONFIG_INPUT_KEYCHORD is not set
|
||||
@@ -857,10 +852,7 @@ CONFIG_INPUT_LSENSOR_CM3623=y
|
||||
# CONFIG_INPUT_UINPUT is not set
|
||||
# CONFIG_INPUT_GPIO is not set
|
||||
# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
|
||||
CONFIG_G_SENSOR_DEVICE=y
|
||||
# CONFIG_GS_MMA7660 is not set
|
||||
# CONFIG_GS_MMA8452 is not set
|
||||
CONFIG_GS_FIH=y
|
||||
# CONFIG_G_SENSOR_DEVICE is not set
|
||||
# CONFIG_INPUT_JOGBALL is not set
|
||||
|
||||
#
|
||||
@@ -911,7 +903,7 @@ CONFIG_UNIX98_PTYS=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_BOARDINFO=y
|
||||
CONFIG_I2C_COMPAT=y
|
||||
# CONFIG_I2C_CHARDEV is not set
|
||||
CONFIG_I2C_CHARDEV=y
|
||||
CONFIG_I2C_HELPER_AUTO=y
|
||||
|
||||
#
|
||||
@@ -926,7 +918,7 @@ CONFIG_I2C0_RK29=y
|
||||
CONFIG_I2C1_RK29=y
|
||||
CONFIG_I2C2_RK29=y
|
||||
CONFIG_I2C3_RK29=y
|
||||
# CONFIG_I2C_DEV_RK29 is not set
|
||||
CONFIG_I2C_DEV_RK29=y
|
||||
|
||||
#
|
||||
# Miscellaneous I2C Chip support
|
||||
@@ -1023,6 +1015,7 @@ CONFIG_TPS65910_CORE=y
|
||||
# CONFIG_MFD_TC6387XB is not set
|
||||
# CONFIG_MFD_TC6393XB is not set
|
||||
# CONFIG_PMIC_DA903X is not set
|
||||
# CONFIG_MFD_WM8994 is not set
|
||||
# CONFIG_MFD_WM8400 is not set
|
||||
# CONFIG_MFD_WM831X_I2C is not set
|
||||
# CONFIG_MFD_WM8350_I2C is not set
|
||||
@@ -1226,13 +1219,14 @@ CONFIG_DISPLAY_SUPPORT=y
|
||||
# CONFIG_LCD_TJ048NC01CA is not set
|
||||
# CONFIG_LCD_HL070VM4AU is not set
|
||||
# CONFIG_LCD_HSD070IDW1 is not set
|
||||
CONFIG_LCD_HSD100PXN=y
|
||||
# CONFIG_LCD_HSD100PXN is not set
|
||||
# CONFIG_LCD_B101AW06 is not set
|
||||
# CONFIG_LCD_A060SE02 is not set
|
||||
# CONFIG_LCD_S1D13521 is not set
|
||||
# CONFIG_LCD_NT35582 is not set
|
||||
# CONFIG_LCD_NT35580 is not set
|
||||
# CONFIG_LCD_ANX7150_720P is not set
|
||||
CONFIG_LCD_AT070TNA2=y
|
||||
|
||||
#
|
||||
# HDMI support
|
||||
@@ -1297,6 +1291,7 @@ CONFIG_SND_RK29_SOC_I2S=y
|
||||
CONFIG_SND_RK29_SOC_I2S_8CH=y
|
||||
# CONFIG_SND_RK29_SOC_WM8988 is not set
|
||||
CONFIG_SND_RK29_SOC_WM8900=y
|
||||
# CONFIG_SND_RK29_SOC_WM8994 is not set
|
||||
# CONFIG_SND_RK29_CODEC_SOC_MASTER is not set
|
||||
CONFIG_SND_RK29_CODEC_SOC_SLAVE=y
|
||||
CONFIG_SND_SOC_I2C_AND_SPI=y
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <linux/usb/android_composite.h>
|
||||
#include <linux/i2c/tps65910.h>
|
||||
#include <linux/mpu.h>
|
||||
|
||||
#include <linux/mpu3050.h>
|
||||
#include <mach/hardware.h>
|
||||
#include <asm/setup.h>
|
||||
#include <asm/mach-types.h>
|
||||
@@ -43,7 +43,6 @@
|
||||
#include <mach/rk29_nand.h>
|
||||
#include <mach/rk29_camera.h> /* ddl@rock-chips.com : camera support */
|
||||
#include <media/soc_camera.h> /* ddl@rock-chips.com : camera support */
|
||||
#include <linux/leds-att1272.h> /* ddl@rock-chips.com: camera flash led support */
|
||||
#include <mach/vpu_mem.h>
|
||||
#include <mach/sram.h>
|
||||
|
||||
@@ -63,12 +62,12 @@
|
||||
#else
|
||||
#define SDRAM_SIZE SZ_512M
|
||||
#endif
|
||||
#define PMEM_GPU_SIZE SZ_64M
|
||||
#define PMEM_GPU_SIZE ( SZ_64M *3)
|
||||
#define PMEM_UI_SIZE SZ_32M
|
||||
#define PMEM_VPU_SIZE SZ_64M
|
||||
#define PMEM_CAM_SIZE 0x01300000
|
||||
#ifdef CONFIG_VIDEO_RK29_WORK_IPP
|
||||
#define MEM_CAMIPP_SIZE SZ_8M
|
||||
#define MEM_CAMIPP_SIZE SZ_4M
|
||||
#else
|
||||
#define MEM_CAMIPP_SIZE 0
|
||||
#endif
|
||||
@@ -404,34 +403,49 @@ static struct mma8452_platform_data mma8452_info = {
|
||||
|
||||
};
|
||||
#endif
|
||||
#if 1
|
||||
#if defined (CONFIG_SENSORS_MPU3050)
|
||||
/*mpu3050*/
|
||||
static struct mpu3050_platform_data mpu3050_data = {
|
||||
.int_config = 0x10,
|
||||
.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
|
||||
.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
|
||||
//{ 0, -1, 0 ,-1 , 0, 0, 0, 0, 1 },
|
||||
//{ 0, -1, 0 ,-1 , 0, 0, 0, 0, 1 },
|
||||
//{ 1, 0, 0,0, -1, 0,0, 0, 1 },//{ 0, 1, 0,1, 0, 0,0, 0, -1 },
|
||||
.level_shifter = 0,
|
||||
#if 0
|
||||
#if defined (CONFIG_SENSORS_KXTF9)
|
||||
.accel = {
|
||||
.get_slave_descr = bma150_get_slave_descr,
|
||||
.get_slave_descr = kxtf9_get_slave_descr ,
|
||||
.adapt_num = 0, // The i2c bus to which the mpu device is
|
||||
// connected
|
||||
.irq = RK29_PIN0_PA3,
|
||||
.bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
|
||||
.address = 0x38,
|
||||
.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
|
||||
.address = 0x0f,
|
||||
.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
|
||||
//{ 0, -1, 0 ,1 , 0, 0, 0, 0, 1 },
|
||||
//{ 0, -1, 0 ,1 , 0, 0, 0, 0, 1 },
|
||||
//{ 1, 0, 0,0, 1, 0,0, 0, 1 },//{ 0, 1, 0,1, 0, 0,0, 0, -1 },
|
||||
},
|
||||
#endif
|
||||
#if defined (CONFIG_SENSORS_AK8975)
|
||||
.compass = {
|
||||
.get_slave_descr = ak8975_get_slave_descr,/*ak5883_get_slave_descr,*/
|
||||
.adapt_num = 0, // The i2c bus to which the compass device is.
|
||||
// It can be difference with mpu
|
||||
// connected
|
||||
.irq = RK29_PIN0_PA4,
|
||||
.bus = EXT_SLAVE_BUS_PRIMARY,
|
||||
.address = 0x1E,
|
||||
.orientation = { 0, 1, 0,-1, 0, 0,0, 0, 1 },
|
||||
.address = 0x0d,
|
||||
.orientation = /*{ 0, 1, 0,
|
||||
-1, 0, 0,
|
||||
0, 0, 1 },*/
|
||||
{ -1, 0, 0,0, -1, 0,0, 0, 1 },
|
||||
//{ 0, 1, 0 , -1 , 0, 0, 0, 0, 1 },
|
||||
//{ -1, 0, 0 ,0 , -1, 0, 0, 0, 1 },
|
||||
//{ -1, 0, 0,0, -1, 0,0, 0, 1 },//{ 0, 1, 0,-1, 0, 0,0, 0, 1 },
|
||||
},
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if defined (CONFIG_BATTERY_BQ27510)
|
||||
|
||||
#define DC_CHECK_PIN RK29_PIN4_PA1
|
||||
@@ -527,7 +541,7 @@ static struct regulator_init_data rk29_regulator_vio = {
|
||||
/* VAUX1 */
|
||||
static struct regulator_consumer_supply rk29_vaux1_supplies[] = {
|
||||
{
|
||||
.supply = "vaux1",
|
||||
.supply = "vuax1",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -547,7 +561,7 @@ static struct regulator_init_data rk29_regulator_vaux1 = {
|
||||
/* VAUX2 */
|
||||
static struct regulator_consumer_supply rk29_vaux2_supplies[] = {
|
||||
{
|
||||
.supply = "vaux2",
|
||||
.supply = "vuax2",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -725,7 +739,7 @@ static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
|
||||
printk(KERN_ERR "Unable to write TPS65910_REG_VDD1 reg\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
||||
/* VDD2 */
|
||||
err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD2);
|
||||
if (err) {
|
||||
@@ -739,7 +753,7 @@ static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
|
||||
printk(KERN_ERR "Unable to write TPS65910_REG_VDD2 reg\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
||||
/* VIO */
|
||||
err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VIO);
|
||||
if (err) {
|
||||
@@ -753,7 +767,7 @@ static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
|
||||
printk(KERN_ERR "Unable to write TPS65910_REG_VIO reg\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
||||
/* Mask ALL interrupts */
|
||||
err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, 0xFF,
|
||||
TPS65910_REG_INT_MSK);
|
||||
@@ -778,27 +792,6 @@ static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
#if 0
|
||||
printk(KERN_INFO "TPS65910 Set default voltage.\n");
|
||||
/* VDD1 Set the default voltage: 1150 mV(47)*/
|
||||
val = 47;
|
||||
err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD1_OP);
|
||||
if (err) {
|
||||
printk(KERN_ERR "Unable to read TPS65910 Reg at offset 0x%x= \
|
||||
\n", TPS65910_REG_VDD1_OP);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* VDD2 Set the default voltage: 1087 * 1.25mV(41)*/
|
||||
val = 42;
|
||||
err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD2_OP);
|
||||
if (err) {
|
||||
printk(KERN_ERR "Unable to read TPS65910 Reg at offset 0x%x= \
|
||||
\n", TPS65910_REG_VDD2_OP);
|
||||
return -EIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* initilize all ISR work as NULL, specific driver will
|
||||
* assign function(s) later.
|
||||
*/
|
||||
@@ -827,14 +820,7 @@ struct tps65910_platform_data rk29_tps65910_data = {
|
||||
};
|
||||
#endif /* CONFIG_TPS65910_CORE */
|
||||
|
||||
/* ddl@rock-chips.com: camera flash led support */
|
||||
#if CONFIG_LEDS_ATT1272
|
||||
struct att1272_led_platform_data rk29_att1272_led_data = {
|
||||
.name = "camera_flash_led",
|
||||
.en_gpio = RK29_PIN1_PB0,
|
||||
.flen_gpio = RK29_PIN1_PB1,
|
||||
};
|
||||
#endif
|
||||
|
||||
/*****************************************************************************************
|
||||
* i2c devices
|
||||
* author: kfx@rock-chips.com
|
||||
@@ -965,7 +951,7 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
|
||||
.irq = RK29_PIN0_PA4,
|
||||
},
|
||||
#endif
|
||||
#if defined (CONFIG_SENSORS_AK8975)
|
||||
#if 0//defined (CONFIG_SENSORS_AK8975)
|
||||
{
|
||||
.type = "ak8975",
|
||||
.addr = 0x0d,
|
||||
@@ -973,8 +959,8 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
|
||||
.irq = RK29_PIN0_PA4,
|
||||
},
|
||||
#endif
|
||||
#if 1
|
||||
/*mpu3050*/
|
||||
#if defined (CONFIG_SENSORS_MPU3050)
|
||||
{
|
||||
.type = "mpu3050",
|
||||
.addr = 0x68,
|
||||
@@ -1012,15 +998,6 @@ static struct i2c_board_info __initdata board_i2c1_devices[] = {
|
||||
//.platform_data = &p1003_info,
|
||||
},
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_LEDS_ATT1272)
|
||||
{
|
||||
.type = "att1272",
|
||||
.addr = 0x37,
|
||||
.flags = 0,
|
||||
.platform_data = &rk29_att1272_led_data,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1067,7 +1044,7 @@ static struct i2c_board_info __initdata board_i2c3_devices[] = {
|
||||
*****************************************************************************************/
|
||||
#ifdef CONFIG_VIDEO_RK29
|
||||
#define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_MT9P111 /* back camera sensor */
|
||||
#define SENSOR_IIC_ADDR_0 0x78
|
||||
#define SENSOR_IIC_ADDR_0 0x00
|
||||
#define SENSOR_IIC_ADAPTER_ID_0 1
|
||||
#define SENSOR_POWER_PIN_0 RK29_PIN5_PD7
|
||||
#define SENSOR_RESET_PIN_0 INVALID_GPIO
|
||||
@@ -1079,7 +1056,7 @@ static struct i2c_board_info __initdata board_i2c3_devices[] = {
|
||||
#define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
|
||||
|
||||
#define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_S5K6AA /* front camera sensor */
|
||||
#define SENSOR_IIC_ADDR_1 0x00
|
||||
#define SENSOR_IIC_ADDR_1 0x78
|
||||
#define SENSOR_IIC_ADAPTER_ID_1 1
|
||||
#define SENSOR_POWER_PIN_1 INVALID_GPIO
|
||||
#define SENSOR_RESET_PIN_1 RK29_PIN1_PB3
|
||||
@@ -2111,8 +2088,7 @@ static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
|
||||
{
|
||||
.name = "spi0 cs0",
|
||||
.cs_gpio = RK29_PIN2_PC1,
|
||||
.cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
|
||||
.cs_iomux_mode = GPIO2H_SPI0_CSN0,
|
||||
.cs_iomux_name = NULL,
|
||||
},
|
||||
{
|
||||
.name = "spi0 cs1",
|
||||
@@ -2126,8 +2102,7 @@ static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
|
||||
{
|
||||
.name = "spi1 cs0",
|
||||
.cs_gpio = RK29_PIN2_PC5,
|
||||
.cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
|
||||
.cs_iomux_mode = GPIO2H_SPI1_CSN0,
|
||||
.cs_iomux_name = NULL,
|
||||
},
|
||||
{
|
||||
.name = "spi1 cs1",
|
||||
@@ -2140,20 +2115,40 @@ static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
|
||||
static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
|
||||
{
|
||||
#if 1
|
||||
int i;
|
||||
int i,j,ret;
|
||||
|
||||
//cs
|
||||
if (cs_gpios) {
|
||||
for (i=0; i<cs_num; i++) {
|
||||
rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
|
||||
ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
|
||||
if (ret) {
|
||||
for (j=0;j<i;j++) {
|
||||
gpio_free(cs_gpios[j].cs_gpio);
|
||||
//rk29_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
|
||||
}
|
||||
printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
gpio_direction_output(cs_gpios[i].cs_gpio, GPIO_HIGH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
|
||||
{
|
||||
#if 1
|
||||
int i;
|
||||
|
||||
if (cs_gpios) {
|
||||
for (i=0; i<cs_num; i++) {
|
||||
gpio_free(cs_gpios[i].cs_gpio);
|
||||
//rk29_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2306,9 +2301,11 @@ static void __init machine_rk29_board_init(void)
|
||||
gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
|
||||
pm_power_off = rk29_pm_power_off;
|
||||
|
||||
#ifdef CONFIG_WIFI_CONTROL_FUNC
|
||||
rk29sdk_wifi_bt_gpio_control_init();
|
||||
#endif
|
||||
|
||||
|
||||
platform_add_devices(devices, ARRAY_SIZE(devices));
|
||||
platform_add_devices(devices, ARRAY_SIZE(devices));
|
||||
#ifdef CONFIG_I2C0_RK29
|
||||
i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
|
||||
ARRAY_SIZE(board_i2c0_devices));
|
||||
@@ -2327,11 +2324,8 @@ static void __init machine_rk29_board_init(void)
|
||||
#endif
|
||||
|
||||
spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
|
||||
|
||||
#ifdef CONFIG_WIFI_CONTROL_FUNC
|
||||
rk29sdk_wifi_bt_gpio_control_init();
|
||||
rk29sdk_init_wifi_mem();
|
||||
#endif
|
||||
|
||||
rk29sdk_init_wifi_mem();
|
||||
}
|
||||
|
||||
static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
|
||||
|
||||
@@ -26,14 +26,4 @@ config GS_MMA8452
|
||||
help
|
||||
To have support for your specific gsesnor you will have to
|
||||
select the proper drivers which depend on this option.
|
||||
|
||||
config GS_FIH
|
||||
bool "gs_fih"
|
||||
depends on G_SENSOR_DEVICE
|
||||
default y
|
||||
help
|
||||
To have support for your specific gsesnor you will have to
|
||||
select the proper drivers which depend on this option.
|
||||
|
||||
|
||||
endif
|
||||
|
||||
@@ -2,4 +2,3 @@
|
||||
|
||||
obj-$(CONFIG_GS_MMA7660) += mma7660.o
|
||||
obj-$(CONFIG_GS_MMA8452) += mma8452.o
|
||||
obj-$(CONFIG_GS_FIH) += gs_fih.o
|
||||
|
||||
@@ -1,722 +0,0 @@
|
||||
/* drivers/i2c/chips/mma8452.c - mma8452 compass driver
|
||||
*
|
||||
* Copyright (C) 2007-2008 HTC Corporation.
|
||||
* Author: Hou-Kun Chen <houkun.chen@gmail.com>
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/freezer.h>
|
||||
#include <linux/mma8452.h>
|
||||
#include <mach/gpio.h>
|
||||
#include <mach/board.h>
|
||||
#ifdef CONFIG_HAS_EARLYSUSPEND
|
||||
#include <linux/earlysuspend.h>
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define mmaprintk(x...) printk(x)
|
||||
#else
|
||||
#define mmaprintk(x...)
|
||||
#endif
|
||||
static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id *id);
|
||||
|
||||
#define MMA8452_SPEED 200 * 1000
|
||||
#define MMA8452_DEVID 0x1a
|
||||
/* Addresses to scan -- protected by sense_data_mutex */
|
||||
//static char sense_data[RBUFF_SIZE + 1];
|
||||
static struct i2c_client *this_client;
|
||||
static struct miscdevice mma8452_device;
|
||||
|
||||
static DECLARE_WAIT_QUEUE_HEAD(data_ready_wq);
|
||||
|
||||
#ifdef CONFIG_HAS_EARLYSUSPEND
|
||||
static struct early_suspend mma8452_early_suspend;
|
||||
#endif
|
||||
static int revision = -1;
|
||||
/* AKM HW info */
|
||||
static ssize_t gsensor_vendor_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
|
||||
sprintf(buf, "%#x\n", revision);
|
||||
ret = strlen(buf) + 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(vendor, 0444, gsensor_vendor_show, NULL);
|
||||
|
||||
static struct kobject *android_gsensor_kobj;
|
||||
|
||||
static int gsensor_sysfs_init(void)
|
||||
{
|
||||
int ret ;
|
||||
|
||||
android_gsensor_kobj = kobject_create_and_add("android_gsensor", NULL);
|
||||
if (android_gsensor_kobj == NULL) {
|
||||
mmaprintk(KERN_ERR
|
||||
"MMA8452 gsensor_sysfs_init:"\
|
||||
"subsystem_register failed\n");
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = sysfs_create_file(android_gsensor_kobj, &dev_attr_vendor.attr);
|
||||
if (ret) {
|
||||
mmaprintk(KERN_ERR
|
||||
"MMA8452 gsensor_sysfs_init:"\
|
||||
"sysfs_create_group failed\n");
|
||||
goto err4;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
err4:
|
||||
kobject_del(android_gsensor_kobj);
|
||||
err:
|
||||
return ret ;
|
||||
}
|
||||
|
||||
static int mma8452_rx_data(struct i2c_client *client, char *rxData, int length)
|
||||
{
|
||||
int ret = 0;
|
||||
char reg = rxData[0];
|
||||
ret = i2c_master_reg8_recv(client, reg, rxData, length, MMA8452_SPEED);
|
||||
return (ret > 0)? 0 : ret;
|
||||
}
|
||||
|
||||
static int mma8452_tx_data(struct i2c_client *client, char *txData, int length)
|
||||
{
|
||||
int ret = 0;
|
||||
char reg = txData[0];
|
||||
ret = i2c_master_reg8_send(client, reg, &txData[1], length-1, MMA8452_SPEED);
|
||||
return (ret > 0)? 0 : ret;
|
||||
}
|
||||
|
||||
static char mma845x_read_reg(struct i2c_client *client,int addr)
|
||||
{
|
||||
char tmp;
|
||||
int ret = 0;
|
||||
|
||||
tmp = addr;
|
||||
// ret = mma8452_tx_data(client, &tmp, 1);
|
||||
ret = mma8452_rx_data(client, &tmp, 1);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static int mma845x_write_reg(struct i2c_client *client,int addr,int value)
|
||||
{
|
||||
char buffer[3];
|
||||
int ret = 0;
|
||||
|
||||
buffer[0] = addr;
|
||||
buffer[1] = value;
|
||||
ret = mma8452_tx_data(client, &buffer[0], 2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static char mma8452_get_devid(struct i2c_client *client)
|
||||
{
|
||||
printk("mma8452 devid:%x\n",mma845x_read_reg(client,MMA8452_REG_WHO_AM_I));
|
||||
return mma845x_read_reg(client,MMA8452_REG_WHO_AM_I);
|
||||
}
|
||||
|
||||
static int mma845x_active(struct i2c_client *client,int enable)
|
||||
{
|
||||
int tmp;
|
||||
int ret = 0;
|
||||
|
||||
tmp = mma845x_read_reg(client,MMA8452_REG_CTRL_REG1);
|
||||
if(enable)
|
||||
tmp |=ACTIVE_MASK;
|
||||
else
|
||||
tmp &=~ACTIVE_MASK;
|
||||
mmaprintk("mma845x_active %s (0x%x)\n",enable?"active":"standby",tmp);
|
||||
ret = mma845x_write_reg(client,MMA8452_REG_CTRL_REG1,tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mma8452_start_test(struct i2c_client *client)
|
||||
{
|
||||
int ret = 0;
|
||||
int tmp;
|
||||
|
||||
mmaprintk("-------------------------mma8452 start test------------------------\n");
|
||||
|
||||
/* standby */
|
||||
mma845x_active(client,0);
|
||||
mmaprintk("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));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* 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));
|
||||
|
||||
mmaprintk("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));
|
||||
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
mmaprintk("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));
|
||||
|
||||
enable_irq(client->irq);
|
||||
msleep(50);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mma8452_start_dev(struct i2c_client *client, char rate)
|
||||
{
|
||||
int ret = 0;
|
||||
int tmp;
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
|
||||
mmaprintk("-------------------------mma8452 start ------------------------\n");
|
||||
/* standby */
|
||||
mma845x_active(client,0);
|
||||
mmaprintk("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));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* 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));
|
||||
|
||||
mmaprintk("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));
|
||||
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
mmaprintk("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));
|
||||
|
||||
enable_irq(client->irq);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
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__);
|
||||
if (mma8452->status == MMA8452_OPEN) {
|
||||
return 0;
|
||||
}
|
||||
mma8452->status = MMA8452_OPEN;
|
||||
return mma8452_start_dev(client, rate);
|
||||
}
|
||||
|
||||
static int mma8452_close_dev(struct i2c_client *client)
|
||||
{
|
||||
disable_irq_nosync(client->irq);
|
||||
return mma845x_active(client,0);
|
||||
}
|
||||
|
||||
static int mma8452_close(struct i2c_client *client)
|
||||
{
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
printk("%s::enter\n",__FUNCTION__);
|
||||
mma8452->status = MMA8452_CLOSE;
|
||||
|
||||
return mma8452_close_dev(client);
|
||||
}
|
||||
|
||||
static int mma8452_reset_rate(struct i2c_client *client, char rate)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
mmaprintk("\n----------------------------mma8452_reset_rate------------------------\n");
|
||||
|
||||
ret = mma8452_close_dev(client);
|
||||
ret = mma8452_start_dev(client, rate);
|
||||
|
||||
return ret ;
|
||||
}
|
||||
|
||||
static inline int mma8452_convert_to_int(char value)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (value < MMA8452_BOUNDARY) {
|
||||
result = value * MMA8452_GRAVITY_STEP;
|
||||
} else {
|
||||
result = ~(((~value & 0x7f) + 1)* MMA8452_GRAVITY_STEP) + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void mma8452_report_value(struct i2c_client *client, struct mma8452_axis *axis)
|
||||
{
|
||||
struct mma8452_data *mma8452 = i2c_get_clientdata(client);
|
||||
//struct mma8452_axis *axis = (struct mma8452_axis *)rbuf;
|
||||
|
||||
/* Report acceleration sensor information */
|
||||
input_report_abs(mma8452->input_dev, ABS_X, axis->x);
|
||||
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);
|
||||
mmaprintk("Gsensor x==%d y==%d z==%d\n",axis->x,axis->y,axis->z);
|
||||
}
|
||||
|
||||
static int mma8452_get_data(struct i2c_client *client)
|
||||
{
|
||||
char buffer[6];
|
||||
int ret;
|
||||
struct mma8452_axis axis;
|
||||
struct mma8452_platform_data *pdata = pdata = client->dev.platform_data;
|
||||
|
||||
do {
|
||||
memset(buffer, 0, 3);
|
||||
buffer[0] = MMA8452_REG_X_OUT_MSB;
|
||||
ret = mma8452_tx_data(client, &buffer[0], 1);
|
||||
ret = mma8452_rx_data(client, &buffer[0], 3);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} while (0);
|
||||
|
||||
mmaprintk("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]);
|
||||
axis.z = mma8452_convert_to_int(buffer[2]);
|
||||
|
||||
if(pdata->swap_xy)
|
||||
{
|
||||
axis.y = -axis.y;
|
||||
swap(axis.x,axis.y);
|
||||
}
|
||||
#if defined(CONFIG_MACH_RK29_AIGO)
|
||||
axis.x = -axis.x;
|
||||
#endif
|
||||
|
||||
// mmaprintk( "%s: ------------------mma8452_GetData axis = %d %d %d--------------\n",
|
||||
// __func__, axis.x, axis.y, axis.z);
|
||||
|
||||
//memcpy(sense_data, &axis, sizeof(axis));
|
||||
mma8452_report_value(client, &axis);
|
||||
//atomic_set(&data_ready, 0);
|
||||
//wake_up(&data_ready_wq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
static int mma8452_trans_buff(char *rbuf, int size)
|
||||
{
|
||||
//wait_event_interruptible_timeout(data_ready_wq,
|
||||
// atomic_read(&data_ready), 1000);
|
||||
wait_event_interruptible(data_ready_wq,
|
||||
atomic_read(&data_ready));
|
||||
|
||||
atomic_set(&data_ready, 0);
|
||||
memcpy(rbuf, &sense_data[0], size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
static int mma8452_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return 0;//nonseekable_open(inode, file);
|
||||
}
|
||||
|
||||
static int mma8452_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mma8452_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
|
||||
void __user *argp = (void __user *)arg;
|
||||
char msg[RBUFF_SIZE + 1];
|
||||
int ret = -1;
|
||||
char rate;
|
||||
struct i2c_client *client = container_of(mma8452_device.parent, struct i2c_client, dev);
|
||||
|
||||
switch (cmd) {
|
||||
case ECS_IOCTL_APP_SET_RATE:
|
||||
if (copy_from_user(&rate, argp, sizeof(rate)))
|
||||
return -EFAULT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case ECS_IOCTL_START:
|
||||
ret = mma8452_start(client, MMA8452_RATE_12P5);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
break;
|
||||
case ECS_IOCTL_CLOSE:
|
||||
ret = mma8452_close(client);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
break;
|
||||
case ECS_IOCTL_APP_SET_RATE:
|
||||
ret = mma8452_reset_rate(client, rate);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
break;
|
||||
/*
|
||||
case ECS_IOCTL_GETDATA:
|
||||
ret = mma8452_trans_buff(msg, RBUFF_SIZE);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case ECS_IOCTL_GETDATA:
|
||||
if (copy_to_user(argp, &msg, sizeof(msg)))
|
||||
return -EFAULT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mma8452_work_func(struct work_struct *work)
|
||||
{
|
||||
struct mma8452_data *mma8452 = container_of(work, struct mma8452_data, work);
|
||||
struct i2c_client *client = mma8452->client;
|
||||
|
||||
if (mma8452_get_data(client) < 0)
|
||||
mmaprintk(KERN_ERR "MMA8452 mma_work_func: Get data failed\n");
|
||||
|
||||
enable_irq(client->irq);
|
||||
}
|
||||
|
||||
static void mma8452_delaywork_func(struct work_struct *work)
|
||||
{
|
||||
struct delayed_work *delaywork = container_of(work, struct delayed_work, work);
|
||||
struct mma8452_data *mma8452 = container_of(delaywork, struct mma8452_data, delaywork);
|
||||
struct i2c_client *client = mma8452->client;
|
||||
|
||||
if (mma8452_get_data(client) < 0)
|
||||
mmaprintk(KERN_ERR "MMA8452 mma_work_func: Get data failed\n");
|
||||
mmaprintk("%s :int src:0x%02x\n",__FUNCTION__,mma845x_read_reg(mma8452->client,MMA8452_REG_INTSRC));
|
||||
enable_irq(client->irq);
|
||||
}
|
||||
|
||||
static irqreturn_t mma8452_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)dev_id;
|
||||
|
||||
disable_irq_nosync(irq);
|
||||
schedule_delayed_work(&mma8452->delaywork, msecs_to_jiffies(30));
|
||||
mmaprintk("%s :enter\n",__FUNCTION__);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static struct file_operations mma8452_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = mma8452_open,
|
||||
.release = mma8452_release,
|
||||
.ioctl = mma8452_ioctl,
|
||||
};
|
||||
|
||||
static struct miscdevice mma8452_device = {
|
||||
.minor = MISC_DYNAMIC_MINOR,
|
||||
.name = "mma8452_daemon",//"mma8452_daemon",
|
||||
.fops = &mma8452_fops,
|
||||
};
|
||||
|
||||
static int mma8452_remove(struct i2c_client *client)
|
||||
{
|
||||
struct mma8452_data *mma8452 = i2c_get_clientdata(client);
|
||||
|
||||
misc_deregister(&mma8452_device);
|
||||
input_unregister_device(mma8452->input_dev);
|
||||
input_free_device(mma8452->input_dev);
|
||||
free_irq(client->irq, mma8452);
|
||||
kfree(mma8452);
|
||||
#ifdef CONFIG_HAS_EARLYSUSPEND
|
||||
unregister_early_suspend(&mma8452_early_suspend);
|
||||
#endif
|
||||
this_client = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HAS_EARLYSUSPEND
|
||||
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);
|
||||
// if(mma8452->status == MMA8452_OPEN)
|
||||
// {
|
||||
//mma8452->status = MMA8452_SUSPEND;
|
||||
// mma8452_close_dev(client);
|
||||
// }
|
||||
}
|
||||
|
||||
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);
|
||||
//if((mma8452->status == MMA8452_SUSPEND) && (mma8452->status != MMA8452_OPEN))
|
||||
// if (mma8452->status == MMA8452_OPEN)
|
||||
// mma8452_start_dev(client,mma8452->curr_tate);
|
||||
}
|
||||
#else
|
||||
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);
|
||||
struct mma8452_data *mma8452 = (struct mma8452_data *)i2c_get_clientdata(client);
|
||||
// if(mma8452->status == MMA8452_OPEN)
|
||||
// {
|
||||
// mma8452->status = MMA8452_SUSPEND;
|
||||
// ret = mma8452_close_dev(client);
|
||||
// }
|
||||
return ret;
|
||||
}
|
||||
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);
|
||||
// if((mma8452->status == MMA8452_SUSPEND) && (mma8452->status != MMA8452_OPEN))
|
||||
//if (mma8452->status == MMA8452_OPEN)
|
||||
// ret = mma8452_start_dev(client, mma8452->curr_tate);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct i2c_device_id mma8452_id[] = {
|
||||
{"gs_fih", 0},
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct i2c_driver mma8452_driver = {
|
||||
.driver = {
|
||||
.name = "gs_fih",
|
||||
},
|
||||
.id_table = mma8452_id,
|
||||
.probe = mma8452_probe,
|
||||
.remove = __devexit_p(mma8452_remove),
|
||||
#ifndef CONFIG_HAS_EARLYSUSPEND
|
||||
.suspend = &mma8452_suspend,
|
||||
.resume = &mma8452_resume,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
static int mma8452_init_client(struct i2c_client *client)
|
||||
{
|
||||
struct mma8452_data *mma8452;
|
||||
int ret;
|
||||
mma8452 = i2c_get_clientdata(client);
|
||||
mmaprintk("gpio_to_irq(%d) is %d\n",client->irq,gpio_to_irq(client->irq));
|
||||
if ( !gpio_is_valid(client->irq)) {
|
||||
mmaprintk("+++++++++++gpio_is_invalid\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
ret = gpio_request(client->irq, "mma8452_int");
|
||||
if (ret) {
|
||||
mmaprintk( "failed to request mma7990_trig GPIO%d\n",gpio_to_irq(client->irq));
|
||||
return ret;
|
||||
}
|
||||
ret = gpio_direction_input(client->irq);
|
||||
if (ret) {
|
||||
mmaprintk("failed to set mma7990_trig GPIO gpio input\n");
|
||||
return ret;
|
||||
}
|
||||
gpio_pull_updown(client->irq, GPIOPullUp);
|
||||
client->irq = gpio_to_irq(client->irq);
|
||||
ret = request_irq(client->irq, mma8452_interrupt, IRQF_TRIGGER_LOW, client->dev.driver->name, mma8452);
|
||||
mmaprintk("request irq is %d,ret is 0x%x\n",client->irq,ret);
|
||||
if (ret ) {
|
||||
mmaprintk(KERN_ERR "mma8452_init_client: request irq failed,ret is %d\n",ret);
|
||||
return ret;
|
||||
}
|
||||
disable_irq(client->irq);
|
||||
init_waitqueue_head(&data_ready_wq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct mma8452_data *mma8452;
|
||||
struct mma8452_platform_data *pdata = pdata = client->dev.platform_data;
|
||||
int err;
|
||||
|
||||
mmaprintk("%s enter\n",__FUNCTION__);
|
||||
|
||||
mma8452 = kzalloc(sizeof(struct mma8452_data), GFP_KERNEL);
|
||||
if (!mma8452) {
|
||||
mmaprintk("[mma8452]:alloc data failed.\n");
|
||||
err = -ENOMEM;
|
||||
goto exit_alloc_data_failed;
|
||||
}
|
||||
|
||||
INIT_WORK(&mma8452->work, mma8452_work_func);
|
||||
INIT_DELAYED_WORK(&mma8452->delaywork, mma8452_delaywork_func);
|
||||
|
||||
mma8452->client = client;
|
||||
i2c_set_clientdata(client, mma8452);
|
||||
|
||||
this_client = client;
|
||||
|
||||
err = mma8452_init_client(client);
|
||||
if (err < 0) {
|
||||
mmaprintk(KERN_ERR
|
||||
"mma8452_probe: mma8452_init_client failed\n");
|
||||
goto exit_request_gpio_irq_failed;
|
||||
}
|
||||
|
||||
mma8452->input_dev = input_allocate_device();
|
||||
if (!mma8452->input_dev) {
|
||||
err = -ENOMEM;
|
||||
mmaprintk(KERN_ERR
|
||||
"mma8452_probe: Failed to allocate input device\n");
|
||||
goto exit_input_allocate_device_failed;
|
||||
}
|
||||
|
||||
set_bit(EV_ABS, mma8452->input_dev->evbit);
|
||||
|
||||
/* x-axis acceleration */
|
||||
input_set_abs_params(mma8452->input_dev, ABS_X, -20000, 20000, 0, 0); //2g full scale range
|
||||
/* y-axis acceleration */
|
||||
input_set_abs_params(mma8452->input_dev, ABS_Y, -20000, 20000, 0, 0); //2g full scale range
|
||||
/* z-axis acceleration */
|
||||
input_set_abs_params(mma8452->input_dev, ABS_Z, -20000, 20000, 0, 0); //2g full scale range
|
||||
|
||||
mma8452->input_dev->name = "compass";
|
||||
mma8452->input_dev->dev.parent = &client->dev;
|
||||
|
||||
err = input_register_device(mma8452->input_dev);
|
||||
if (err < 0) {
|
||||
mmaprintk(KERN_ERR
|
||||
"mma8452_probe: Unable to register input device: %s\n",
|
||||
mma8452->input_dev->name);
|
||||
goto exit_input_register_device_failed;
|
||||
}
|
||||
|
||||
mma8452_device.parent = &client->dev;
|
||||
err = misc_register(&mma8452_device);
|
||||
if (err < 0) {
|
||||
mmaprintk(KERN_ERR
|
||||
"mma8452_probe: mmad_device register failed\n");
|
||||
goto exit_misc_device_register_mma8452_device_failed;
|
||||
}
|
||||
|
||||
err = gsensor_sysfs_init();
|
||||
if (err < 0) {
|
||||
mmaprintk(KERN_ERR
|
||||
"mma8452_probe: gsensor sysfs init failed\n");
|
||||
goto exit_gsensor_sysfs_init_failed;
|
||||
}
|
||||
|
||||
#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);
|
||||
#endif
|
||||
if(MMA8452_DEVID == mma8452_get_devid(this_client))
|
||||
printk(KERN_INFO "mma8452 probe ok\n");
|
||||
else
|
||||
goto exit_gsensor_sysfs_init_failed;
|
||||
|
||||
|
||||
mma8452->status = -1;
|
||||
#if 0
|
||||
// mma8452_start_test(this_client);
|
||||
mma8452_start(client, MMA8452_RATE_12P5);
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
exit_gsensor_sysfs_init_failed:
|
||||
misc_deregister(&mma8452_device);
|
||||
exit_misc_device_register_mma8452_device_failed:
|
||||
input_unregister_device(mma8452->input_dev);
|
||||
exit_input_register_device_failed:
|
||||
input_free_device(mma8452->input_dev);
|
||||
exit_input_allocate_device_failed:
|
||||
free_irq(client->irq, mma8452);
|
||||
exit_request_gpio_irq_failed:
|
||||
kfree(mma8452);
|
||||
exit_alloc_data_failed:
|
||||
;
|
||||
mmaprintk("%s error\n",__FUNCTION__);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static int __init mma8452_i2c_init(void)
|
||||
{
|
||||
return i2c_add_driver(&mma8452_driver);
|
||||
}
|
||||
|
||||
static void __exit mma8452_i2c_exit(void)
|
||||
{
|
||||
i2c_del_driver(&mma8452_driver);
|
||||
}
|
||||
|
||||
module_init(mma8452_i2c_init);
|
||||
module_exit(mma8452_i2c_exit);
|
||||
|
||||
@@ -18,13 +18,6 @@ config INPUT_LPSENSOR_ISL29028
|
||||
config INPUT_LPSENSOR_CM3602
|
||||
tristate "l/p sensor input support"
|
||||
|
||||
config INPUT_LSENSOR_CM3623
|
||||
tristate "CM3623 light sensor input support"
|
||||
|
||||
config INPUT_MPU3050
|
||||
tristate "MPU3050 motion proccess unit support"
|
||||
|
||||
|
||||
config INPUT_PCSPKR
|
||||
tristate "PC Speaker support"
|
||||
depends on PCSPKR_PLATFORM
|
||||
|
||||
@@ -35,5 +35,3 @@ obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o
|
||||
obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
|
||||
obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o
|
||||
obj-$(CONFIG_INPUT_YEALINK) += yealink.o
|
||||
obj-$(CONFIG_INPUT_LSENSOR_CM3623) += cm3623.o
|
||||
obj-$(CONFIG_INPUT_MPU3050) += mpu3050.o
|
||||
|
||||
@@ -1,475 +0,0 @@
|
||||
/*
|
||||
* isl29003.c - Linux kernel module for
|
||||
* Intersil ISL29003 ambient light sensor
|
||||
*
|
||||
* See file:Documentation/misc-devices/isl29003
|
||||
*
|
||||
* Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
|
||||
*
|
||||
* Based on code written by
|
||||
* Rodolfo Giometti <giometti@linux.it>
|
||||
* Eurotech S.p.A. <info@eurotech.it>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define ISL29003_DRV_NAME "isl29003"
|
||||
#define DRIVER_VERSION "1.0"
|
||||
|
||||
#define ISL29003_REG_COMMAND 0x00
|
||||
#define ISL29003_ADC_ENABLED (1 << 7)
|
||||
#define ISL29003_ADC_PD (1 << 6)
|
||||
#define ISL29003_TIMING_INT (1 << 5)
|
||||
#define ISL29003_MODE_SHIFT (2)
|
||||
#define ISL29003_MODE_MASK (0x3 << ISL29003_MODE_SHIFT)
|
||||
#define ISL29003_RES_SHIFT (0)
|
||||
#define ISL29003_RES_MASK (0x3 << ISL29003_RES_SHIFT)
|
||||
|
||||
#define ISL29003_REG_CONTROL 0x01
|
||||
#define ISL29003_INT_FLG (1 << 5)
|
||||
#define ISL29003_RANGE_SHIFT (2)
|
||||
#define ISL29003_RANGE_MASK (0x3 << ISL29003_RANGE_SHIFT)
|
||||
#define ISL29003_INT_PERSISTS_SHIFT (0)
|
||||
#define ISL29003_INT_PERSISTS_MASK (0xf << ISL29003_INT_PERSISTS_SHIFT)
|
||||
|
||||
#define ISL29003_REG_IRQ_THRESH_HI 0x02
|
||||
#define ISL29003_REG_IRQ_THRESH_LO 0x03
|
||||
#define ISL29003_REG_LSB_SENSOR 0x04
|
||||
#define ISL29003_REG_MSB_SENSOR 0x05
|
||||
#define ISL29003_REG_LSB_TIMER 0x06
|
||||
#define ISL29003_REG_MSB_TIMER 0x07
|
||||
|
||||
#define ISL29003_NUM_CACHABLE_REGS 4
|
||||
|
||||
struct isl29003_data {
|
||||
struct i2c_client *client;
|
||||
struct mutex lock;
|
||||
u8 reg_cache[ISL29003_NUM_CACHABLE_REGS];
|
||||
u8 power_state_before_suspend;
|
||||
};
|
||||
|
||||
static int gain_range[] = {
|
||||
1000, 4000, 16000, 64000
|
||||
};
|
||||
|
||||
/*
|
||||
* register access helpers
|
||||
*/
|
||||
|
||||
static int __isl29003_read_reg(struct i2c_client *client,
|
||||
u32 reg, u8 mask, u8 shift)
|
||||
{
|
||||
struct isl29003_data *data = i2c_get_clientdata(client);
|
||||
return (data->reg_cache[reg] & mask) >> shift;
|
||||
}
|
||||
|
||||
static int __isl29003_write_reg(struct i2c_client *client,
|
||||
u32 reg, u8 mask, u8 shift, u8 val)
|
||||
{
|
||||
struct isl29003_data *data = i2c_get_clientdata(client);
|
||||
int ret = 0;
|
||||
u8 tmp;
|
||||
|
||||
if (reg >= ISL29003_NUM_CACHABLE_REGS)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
|
||||
tmp = data->reg_cache[reg];
|
||||
tmp &= ~mask;
|
||||
tmp |= val << shift;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(client, reg, tmp);
|
||||
if (!ret)
|
||||
data->reg_cache[reg] = tmp;
|
||||
|
||||
mutex_unlock(&data->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* internally used functions
|
||||
*/
|
||||
|
||||
/* range */
|
||||
static int isl29003_get_range(struct i2c_client *client)
|
||||
{
|
||||
return __isl29003_read_reg(client, ISL29003_REG_CONTROL,
|
||||
ISL29003_RANGE_MASK, ISL29003_RANGE_SHIFT);
|
||||
}
|
||||
|
||||
static int isl29003_set_range(struct i2c_client *client, int range)
|
||||
{
|
||||
return __isl29003_write_reg(client, ISL29003_REG_CONTROL,
|
||||
ISL29003_RANGE_MASK, ISL29003_RANGE_SHIFT, range);
|
||||
}
|
||||
|
||||
/* resolution */
|
||||
static int isl29003_get_resolution(struct i2c_client *client)
|
||||
{
|
||||
return __isl29003_read_reg(client, ISL29003_REG_COMMAND,
|
||||
ISL29003_RES_MASK, ISL29003_RES_SHIFT);
|
||||
}
|
||||
|
||||
static int isl29003_set_resolution(struct i2c_client *client, int res)
|
||||
{
|
||||
return __isl29003_write_reg(client, ISL29003_REG_COMMAND,
|
||||
ISL29003_RES_MASK, ISL29003_RES_SHIFT, res);
|
||||
}
|
||||
|
||||
/* mode */
|
||||
static int isl29003_get_mode(struct i2c_client *client)
|
||||
{
|
||||
return __isl29003_read_reg(client, ISL29003_REG_COMMAND,
|
||||
ISL29003_RES_MASK, ISL29003_RES_SHIFT);
|
||||
}
|
||||
|
||||
static int isl29003_set_mode(struct i2c_client *client, int mode)
|
||||
{
|
||||
return __isl29003_write_reg(client, ISL29003_REG_COMMAND,
|
||||
ISL29003_RES_MASK, ISL29003_RES_SHIFT, mode);
|
||||
}
|
||||
|
||||
/* power_state */
|
||||
static int isl29003_set_power_state(struct i2c_client *client, int state)
|
||||
{
|
||||
return __isl29003_write_reg(client, ISL29003_REG_COMMAND,
|
||||
ISL29003_ADC_ENABLED | ISL29003_ADC_PD, 0,
|
||||
state ? ISL29003_ADC_ENABLED : ISL29003_ADC_PD);
|
||||
}
|
||||
|
||||
static int isl29003_get_power_state(struct i2c_client *client)
|
||||
{
|
||||
struct isl29003_data *data = i2c_get_clientdata(client);
|
||||
u8 cmdreg = data->reg_cache[ISL29003_REG_COMMAND];
|
||||
return ~cmdreg & ISL29003_ADC_PD;
|
||||
}
|
||||
|
||||
static int isl29003_get_adc_value(struct i2c_client *client)
|
||||
{
|
||||
struct isl29003_data *data = i2c_get_clientdata(client);
|
||||
int lsb, msb, range, bitdepth;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
lsb = i2c_smbus_read_byte_data(client, ISL29003_REG_LSB_SENSOR);
|
||||
|
||||
if (lsb < 0) {
|
||||
mutex_unlock(&data->lock);
|
||||
return lsb;
|
||||
}
|
||||
|
||||
msb = i2c_smbus_read_byte_data(client, ISL29003_REG_MSB_SENSOR);
|
||||
mutex_unlock(&data->lock);
|
||||
|
||||
if (msb < 0)
|
||||
return msb;
|
||||
|
||||
range = isl29003_get_range(client);
|
||||
bitdepth = (4 - isl29003_get_resolution(client)) * 4;
|
||||
return (((msb << 8) | lsb) * gain_range[range]) >> bitdepth;
|
||||
}
|
||||
|
||||
/*
|
||||
* sysfs layer
|
||||
*/
|
||||
|
||||
/* range */
|
||||
static ssize_t isl29003_show_range(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
return sprintf(buf, "%i\n", isl29003_get_range(client));
|
||||
}
|
||||
|
||||
static ssize_t isl29003_store_range(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
unsigned long val;
|
||||
int ret;
|
||||
|
||||
if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
|
||||
return -EINVAL;
|
||||
|
||||
ret = isl29003_set_range(client, val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(range, S_IWUSR | S_IRUGO,
|
||||
isl29003_show_range, isl29003_store_range);
|
||||
|
||||
|
||||
/* resolution */
|
||||
static ssize_t isl29003_show_resolution(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
return sprintf(buf, "%d\n", isl29003_get_resolution(client));
|
||||
}
|
||||
|
||||
static ssize_t isl29003_store_resolution(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
unsigned long val;
|
||||
int ret;
|
||||
|
||||
if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
|
||||
return -EINVAL;
|
||||
|
||||
ret = isl29003_set_resolution(client, val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(resolution, S_IWUSR | S_IRUGO,
|
||||
isl29003_show_resolution, isl29003_store_resolution);
|
||||
|
||||
/* mode */
|
||||
static ssize_t isl29003_show_mode(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
return sprintf(buf, "%d\n", isl29003_get_mode(client));
|
||||
}
|
||||
|
||||
static ssize_t isl29003_store_mode(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
unsigned long val;
|
||||
int ret;
|
||||
|
||||
if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2))
|
||||
return -EINVAL;
|
||||
|
||||
ret = isl29003_set_mode(client, val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(mode, S_IWUSR | S_IRUGO,
|
||||
isl29003_show_mode, isl29003_store_mode);
|
||||
|
||||
|
||||
/* power state */
|
||||
static ssize_t isl29003_show_power_state(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
return sprintf(buf, "%d\n", isl29003_get_power_state(client));
|
||||
}
|
||||
|
||||
static ssize_t isl29003_store_power_state(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
unsigned long val;
|
||||
int ret;
|
||||
|
||||
if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1))
|
||||
return -EINVAL;
|
||||
|
||||
ret = isl29003_set_power_state(client, val);
|
||||
return ret ? ret : count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO,
|
||||
isl29003_show_power_state, isl29003_store_power_state);
|
||||
|
||||
|
||||
/* lux */
|
||||
static ssize_t isl29003_show_lux(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
|
||||
/* No LUX data if not operational */
|
||||
if (!isl29003_get_power_state(client))
|
||||
return -EBUSY;
|
||||
|
||||
return sprintf(buf, "%d\n", isl29003_get_adc_value(client));
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(lux, S_IRUGO, isl29003_show_lux, NULL);
|
||||
|
||||
static struct attribute *isl29003_attributes[] = {
|
||||
&dev_attr_range.attr,
|
||||
&dev_attr_resolution.attr,
|
||||
&dev_attr_mode.attr,
|
||||
&dev_attr_power_state.attr,
|
||||
&dev_attr_lux.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct attribute_group isl29003_attr_group = {
|
||||
.attrs = isl29003_attributes,
|
||||
};
|
||||
|
||||
static int isl29003_init_client(struct i2c_client *client)
|
||||
{
|
||||
struct isl29003_data *data = i2c_get_clientdata(client);
|
||||
int i;
|
||||
|
||||
/* read all the registers once to fill the cache.
|
||||
* if one of the reads fails, we consider the init failed */
|
||||
for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++) {
|
||||
int v = i2c_smbus_read_byte_data(client, i);
|
||||
if (v < 0)
|
||||
return -ENODEV;
|
||||
|
||||
data->reg_cache[i] = v;
|
||||
}
|
||||
|
||||
/* set defaults */
|
||||
isl29003_set_range(client, 0);
|
||||
isl29003_set_resolution(client, 0);
|
||||
isl29003_set_mode(client, 0);
|
||||
isl29003_set_power_state(client, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* I2C layer
|
||||
*/
|
||||
|
||||
static int __devinit isl29003_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
|
||||
struct isl29003_data *data;
|
||||
int err = 0;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
|
||||
return -EIO;
|
||||
|
||||
data = kzalloc(sizeof(struct isl29003_data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
data->client = client;
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->lock);
|
||||
|
||||
/* initialize the ISL29003 chip */
|
||||
err = isl29003_init_client(client);
|
||||
if (err)
|
||||
goto exit_kfree;
|
||||
|
||||
/* register sysfs hooks */
|
||||
err = sysfs_create_group(&client->dev.kobj, &isl29003_attr_group);
|
||||
if (err)
|
||||
goto exit_kfree;
|
||||
|
||||
dev_info(&client->dev, "driver version %s enabled\n", DRIVER_VERSION);
|
||||
return 0;
|
||||
|
||||
exit_kfree:
|
||||
kfree(data);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int __devexit isl29003_remove(struct i2c_client *client)
|
||||
{
|
||||
sysfs_remove_group(&client->dev.kobj, &isl29003_attr_group);
|
||||
isl29003_set_power_state(client, 0);
|
||||
kfree(i2c_get_clientdata(client));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int isl29003_suspend(struct i2c_client *client, pm_message_t mesg)
|
||||
{
|
||||
struct isl29003_data *data = i2c_get_clientdata(client);
|
||||
|
||||
data->power_state_before_suspend = isl29003_get_power_state(client);
|
||||
return isl29003_set_power_state(client, 0);
|
||||
}
|
||||
|
||||
static int isl29003_resume(struct i2c_client *client)
|
||||
{
|
||||
int i;
|
||||
struct isl29003_data *data = i2c_get_clientdata(client);
|
||||
|
||||
/* restore registers from cache */
|
||||
for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++)
|
||||
if (i2c_smbus_write_byte_data(client, i, data->reg_cache[i]))
|
||||
return -EIO;
|
||||
|
||||
return isl29003_set_power_state(client,
|
||||
data->power_state_before_suspend);
|
||||
}
|
||||
|
||||
#else
|
||||
#define isl29003_suspend NULL
|
||||
#define isl29003_resume NULL
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
static const struct i2c_device_id isl29003_id[] = {
|
||||
{ "isl29003", 0 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, isl29003_id);
|
||||
|
||||
static struct i2c_driver isl29003_driver = {
|
||||
.driver = {
|
||||
.name = ISL29003_DRV_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.suspend = isl29003_suspend,
|
||||
.resume = isl29003_resume,
|
||||
.probe = isl29003_probe,
|
||||
.remove = __devexit_p(isl29003_remove),
|
||||
.id_table = isl29003_id,
|
||||
};
|
||||
|
||||
static int __init isl29003_init(void)
|
||||
{
|
||||
return i2c_add_driver(&isl29003_driver);
|
||||
}
|
||||
|
||||
static void __exit isl29003_exit(void)
|
||||
{
|
||||
i2c_del_driver(&isl29003_driver);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
|
||||
MODULE_DESCRIPTION("ISL29003 ambient light sensor driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_VERSION(DRIVER_VERSION);
|
||||
|
||||
module_init(isl29003_init);
|
||||
module_exit(isl29003_exit);
|
||||
|
||||
@@ -68,7 +68,23 @@ struct mpu_private_data {
|
||||
};
|
||||
|
||||
static int pid;
|
||||
|
||||
struct i2c_msg1 {
|
||||
__u16 addr; /* slave address */
|
||||
__u16 flags;
|
||||
#define I2C_M_TEN 0x0010 /* this is a ten bit chip address */
|
||||
#define I2C_M_RD 0x0001 /* read data, from slave to master */
|
||||
#define I2C_M_NOSTART 0x4000 /* if I2C_FUNC_PROTOCOL_MANGLING */
|
||||
#define I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */
|
||||
#define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */
|
||||
#define I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */
|
||||
#define I2C_M_RECV_LEN 0x0400 /* length will be first received byte */
|
||||
__u16 len; /* msg length */
|
||||
__u8 *buf; /* pointer to msg data */
|
||||
};
|
||||
struct i2c_rdwr_ioctl_data1 {
|
||||
struct i2c_msg1 __user *msgs; /* pointers to i2c_msgs */
|
||||
__u32 nmsgs; /* number of i2c_msgs */
|
||||
};
|
||||
static struct i2c_client *this_client;
|
||||
|
||||
static int mpu_open(struct inode *inode, struct file *file)
|
||||
@@ -130,13 +146,14 @@ static int mpu_release(struct inode *inode, struct file *file)
|
||||
static noinline int mpudev_ioctl_rdrw(struct i2c_client *client,
|
||||
unsigned long arg)
|
||||
{
|
||||
struct i2c_rdwr_ioctl_data rdwr_arg;
|
||||
struct i2c_msg *rdwr_pa;
|
||||
struct i2c_rdwr_ioctl_data1 rdwr_arg;
|
||||
struct i2c_msg1 *rdwr_pa;
|
||||
struct i2c_msg *msgs;
|
||||
u8 __user **data_ptrs;
|
||||
int i, res;
|
||||
|
||||
if (copy_from_user(&rdwr_arg,
|
||||
(struct i2c_rdwr_ioctl_data __user *) arg,
|
||||
(struct i2c_rdwr_ioctl_data1 __user *) arg,
|
||||
sizeof(rdwr_arg)))
|
||||
return -EFAULT;
|
||||
|
||||
@@ -144,14 +161,14 @@ static noinline int mpudev_ioctl_rdrw(struct i2c_client *client,
|
||||
* be sent at once */
|
||||
if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
|
||||
return -EINVAL;
|
||||
|
||||
rdwr_pa = (struct i2c_msg *)
|
||||
kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), GFP_KERNEL);
|
||||
msgs = (struct i2c_msg *)kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), GFP_KERNEL);
|
||||
rdwr_pa = (struct i2c_msg1 *)
|
||||
kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg1), GFP_KERNEL);
|
||||
if (!rdwr_pa)
|
||||
return -ENOMEM;
|
||||
|
||||
if (copy_from_user(rdwr_pa, rdwr_arg.msgs,
|
||||
rdwr_arg.nmsgs * sizeof(struct i2c_msg))) {
|
||||
rdwr_arg.nmsgs * sizeof(struct i2c_msg1))) {
|
||||
kfree(rdwr_pa);
|
||||
return -EFAULT;
|
||||
}
|
||||
@@ -184,6 +201,12 @@ static noinline int mpudev_ioctl_rdrw(struct i2c_client *client,
|
||||
res = -EFAULT;
|
||||
break;
|
||||
}
|
||||
msgs[i].buf = rdwr_pa[i].buf;
|
||||
msgs[i].len = rdwr_pa[i].len;
|
||||
msgs[i].flags = rdwr_pa[i].flags;
|
||||
msgs[i].addr = rdwr_pa[i].addr;
|
||||
|
||||
msgs[i].scl_rate = 400 * 1000;
|
||||
}
|
||||
if (res < 0) {
|
||||
int j;
|
||||
@@ -191,10 +214,11 @@ static noinline int mpudev_ioctl_rdrw(struct i2c_client *client,
|
||||
kfree(rdwr_pa[j].buf);
|
||||
kfree(data_ptrs);
|
||||
kfree(rdwr_pa);
|
||||
kfree(msgs);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = i2c_transfer(client->adapter, rdwr_pa, rdwr_arg.nmsgs);
|
||||
res = i2c_transfer(client->adapter, msgs,rdwr_arg.nmsgs);
|
||||
while (i-- > 0) {
|
||||
if (res >= 0 && (rdwr_pa[i].flags & I2C_M_RD)) {
|
||||
if (copy_to_user(data_ptrs[i], rdwr_pa[i].buf,
|
||||
@@ -205,6 +229,7 @@ static noinline int mpudev_ioctl_rdrw(struct i2c_client *client,
|
||||
}
|
||||
kfree(data_ptrs);
|
||||
kfree(rdwr_pa);
|
||||
kfree(msgs);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1195,15 +1220,17 @@ static struct i2c_driver mpu3050_driver = {
|
||||
|
||||
static int __init mpu_init(void)
|
||||
{
|
||||
printk("xxm -> enter mpu_init\n");
|
||||
int res = i2c_add_driver(&mpu3050_driver);
|
||||
pid = 0;
|
||||
printk(KERN_DEBUG "%s\n", __func__);
|
||||
if (res)
|
||||
dev_err(&this_client->adapter->dev, "%s failed\n",
|
||||
printk("xxm-> end mpu_init\n");
|
||||
if (res){
|
||||
dev_err(&this_client->adapter->dev, "%s\n",
|
||||
__func__);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
static void __exit mpu_exit(void)
|
||||
{
|
||||
printk(KERN_DEBUG "%s\n", __func__);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <linux/i2c.h>
|
||||
#include "mpu.h"
|
||||
|
||||
#define MPU_SPEED 400 * 1000
|
||||
int sensor_i2c_write(struct i2c_adapter *i2c_adap,
|
||||
unsigned char address,
|
||||
unsigned int len, unsigned char const *data)
|
||||
@@ -31,6 +32,7 @@ int sensor_i2c_write(struct i2c_adapter *i2c_adap,
|
||||
msgs[0].flags = 0; /* write */
|
||||
msgs[0].buf = (unsigned char *) data;
|
||||
msgs[0].len = len;
|
||||
msgs[0].scl_rate = MPU_SPEED;
|
||||
|
||||
res = i2c_transfer(i2c_adap, msgs, 1);
|
||||
if (res < 1)
|
||||
@@ -49,7 +51,6 @@ int sensor_i2c_write_register(struct i2c_adapter *i2c_adap,
|
||||
data[1] = value;
|
||||
return sensor_i2c_write(i2c_adap, address, 2, data);
|
||||
}
|
||||
|
||||
int sensor_i2c_read(struct i2c_adapter *i2c_adap,
|
||||
unsigned char address,
|
||||
unsigned char reg,
|
||||
@@ -65,11 +66,13 @@ int sensor_i2c_read(struct i2c_adapter *i2c_adap,
|
||||
msgs[0].flags = 0; /* write */
|
||||
msgs[0].buf = ®
|
||||
msgs[0].len = 1;
|
||||
msgs[0].scl_rate = MPU_SPEED;
|
||||
|
||||
msgs[1].addr = address;
|
||||
msgs[1].flags = I2C_M_RD;
|
||||
msgs[1].buf = data;
|
||||
msgs[1].len = len;
|
||||
msgs[1].scl_rate = MPU_SPEED;
|
||||
|
||||
res = i2c_transfer(i2c_adap, msgs, 2);
|
||||
if (res < 2)
|
||||
@@ -106,21 +109,25 @@ int mpu_memory_read(struct i2c_adapter *i2c_adap,
|
||||
msgs[0].flags = 0;
|
||||
msgs[0].buf = bank;
|
||||
msgs[0].len = sizeof(bank);
|
||||
msgs[0].scl_rate = MPU_SPEED;
|
||||
|
||||
msgs[1].addr = mpu_addr;
|
||||
msgs[1].flags = 0;
|
||||
msgs[1].buf = addr;
|
||||
msgs[1].len = sizeof(addr);
|
||||
msgs[1].scl_rate = MPU_SPEED;
|
||||
|
||||
msgs[2].addr = mpu_addr;
|
||||
msgs[2].flags = 0;
|
||||
msgs[2].buf = &buf;
|
||||
msgs[2].len = 1;
|
||||
msgs[2].scl_rate = MPU_SPEED;
|
||||
|
||||
msgs[3].addr = mpu_addr;
|
||||
msgs[3].flags = I2C_M_RD;
|
||||
msgs[3].buf = data;
|
||||
msgs[3].len = len;
|
||||
msgs[3].scl_rate = MPU_SPEED;
|
||||
|
||||
ret = i2c_transfer(i2c_adap, msgs, 4);
|
||||
if (ret != 4)
|
||||
@@ -160,17 +167,20 @@ int mpu_memory_write(struct i2c_adapter *i2c_adap,
|
||||
msgs[0].flags = 0;
|
||||
msgs[0].buf = bank;
|
||||
msgs[0].len = sizeof(bank);
|
||||
msgs[0].scl_rate = MPU_SPEED;
|
||||
|
||||
msgs[1].addr = mpu_addr;
|
||||
msgs[1].flags = 0;
|
||||
msgs[1].buf = addr;
|
||||
msgs[1].len = sizeof(addr);
|
||||
msgs[1].scl_rate = MPU_SPEED;
|
||||
|
||||
msgs[2].addr = mpu_addr;
|
||||
msgs[2].flags = 0;
|
||||
msgs[2].buf = (unsigned char *) buf;
|
||||
msgs[2].len = len + 1;
|
||||
|
||||
msgs[2].scl_rate = MPU_SPEED;
|
||||
|
||||
ret = i2c_transfer(i2c_adap, msgs, 3);
|
||||
if (ret != 3)
|
||||
return ret;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <linux/i2c-dev.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/poll.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <mach/gpio.h>
|
||||
|
||||
#include <linux/errno.h>
|
||||
#include <linux/fs.h>
|
||||
@@ -265,14 +267,28 @@ int mpuirq_init(struct i2c_client *mpu_client)
|
||||
flags = IRQF_TRIGGER_FALLING;
|
||||
else
|
||||
flags = IRQF_TRIGGER_RISING;
|
||||
|
||||
res =
|
||||
request_irq(mpuirq_dev_data.irq, mpuirq_handler, flags,
|
||||
interface, &mpuirq_dev_data.irq);
|
||||
/* mpu irq register xxm*/
|
||||
res = gpio_request(mpuirq_dev_data.irq, "mpu3050_int");
|
||||
if(res)
|
||||
{
|
||||
printk("failed to request mpu3050_int GPIO %d\n",
|
||||
gpio_to_irq(mpuirq_dev_data.irq));
|
||||
return res;
|
||||
}
|
||||
res = gpio_direction_input(mpuirq_dev_data.irq);
|
||||
if(res)
|
||||
{
|
||||
printk("failed to set mpu3050_int GPIO input\n");
|
||||
return res;
|
||||
}
|
||||
printk("gpio_to_irq(mpuirq_dev_data.irq) == %d \r\n",
|
||||
gpio_to_irq(mpuirq_dev_data.irq));
|
||||
res =request_irq(gpio_to_irq(mpuirq_dev_data.irq), mpuirq_handler, flags,
|
||||
interface,&mpuirq_dev_data.irq);
|
||||
if (res) {
|
||||
dev_err(&mpu_client->adapter->dev,
|
||||
"myirqtest: cannot register IRQ %d\n",
|
||||
mpuirq_dev_data.irq);
|
||||
"myirqtest: cannot register IRQ %d,return value is %d\n",
|
||||
gpio_to_irq(mpuirq_dev_data.irq),res);
|
||||
} else {
|
||||
res = misc_register(&mpuirq_device);
|
||||
if (res < 0) {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#include <linux/poll.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <mach/gpio.h>
|
||||
|
||||
#include <linux/errno.h>
|
||||
#include <linux/fs.h>
|
||||
@@ -29,7 +31,7 @@
|
||||
#include "mldl_cfg.h"
|
||||
#include "mpu-i2c.h"
|
||||
#include <linux/wait.h>
|
||||
|
||||
#include <linux/delay.h>
|
||||
/* function which gets slave data and sends it to SLAVE */
|
||||
|
||||
struct slaveirq_dev_data {
|
||||
@@ -211,8 +213,24 @@ int slaveirq_init(struct i2c_adapter *slave_adapter,
|
||||
data->data_ready = 0;
|
||||
data->timeout = 0;
|
||||
|
||||
res = request_irq(data->irq, slaveirq_handler, IRQF_TRIGGER_RISING,
|
||||
data->dev.name, data);
|
||||
/* mpu irq register xxm*/
|
||||
res = gpio_request(data->irq, name);
|
||||
if(res)
|
||||
{
|
||||
printk("failed to request %s GPIO %d\n",
|
||||
name,data->irq);
|
||||
return res;
|
||||
}
|
||||
res = gpio_direction_input(data->irq);
|
||||
if(res)
|
||||
{
|
||||
printk("failed to set %s GPIO input\n",name);
|
||||
return res;
|
||||
}
|
||||
printk("%s registing irq == %d \r\n",name,gpio_to_irq(data->irq));
|
||||
//gpio_pull_updown(data->irq, GPIOPullUp);
|
||||
//gpio_set_value(data->irq,GPIO_HIGH);
|
||||
res = request_irq(gpio_to_irq(data->irq), slaveirq_handler, IRQF_TRIGGER_FALLING,data->dev.name, data);
|
||||
|
||||
if (res) {
|
||||
dev_err(&slave_adapter->dev,
|
||||
|
||||
@@ -47,6 +47,8 @@ config LCD_ANX7150_720P
|
||||
bool "anx7150 720p for default panel"
|
||||
---help---
|
||||
if you want set anx7150(720p 50hz) for default panel, android UI size is 1280x720.
|
||||
config LCD_AT070TNA2
|
||||
bool "RGB AT070TNA2"
|
||||
endchoice
|
||||
|
||||
|
||||
|
||||
@@ -30,3 +30,4 @@ obj-$(CONFIG_LCD_RGB_TFT480800_25_E) += lcd_rgb_tft480800_25_e.o
|
||||
obj-$(CONFIG_LCD_LS035Y8DX02A) += lcd_ls035y8dx02a.o
|
||||
obj-$(CONFIG_LCD_IPS1P5680_V1_E) += lcd_ips1p5680_v1_e.o
|
||||
obj-$(CONFIG_LCD_MCU_TFT480800_25_E) += lcd_mcu_tft480800_25_e.o
|
||||
obj-$(CONFIG_LCD_AT070TNA2) += lcd_AT070TNA2.o
|
||||
|
||||
Reference in New Issue
Block a user