diff options
Diffstat (limited to 'arch/arm/mach-exynos/midas-sensor.c')
-rw-r--r-- | arch/arm/mach-exynos/midas-sensor.c | 240 |
1 files changed, 211 insertions, 29 deletions
diff --git a/arch/arm/mach-exynos/midas-sensor.c b/arch/arm/mach-exynos/midas-sensor.c index 6c8385c..5bdbee7 100644 --- a/arch/arm/mach-exynos/midas-sensor.c +++ b/arch/arm/mach-exynos/midas-sensor.c @@ -2,7 +2,12 @@ #include <linux/gpio.h> #include <linux/i2c.h> #include <linux/sensor/sensors_core.h> +#ifdef CONFIG_SENSORS_AK8975C #include <linux/sensor/ak8975.h> +#endif +#ifdef CONFIG_SENSORS_AK8963C +#include <linux/sensor/ak8963.h> +#endif #include <linux/sensor/k3dh.h> #include <linux/sensor/gp2a.h> #include <linux/sensor/lsm330dlc_accel.h> @@ -11,18 +16,49 @@ #include <linux/sensor/cm36651.h> #include <linux/sensor/cm3663.h> #include <linux/sensor/bh1721.h> - +#include <linux/delay.h> #include <plat/gpio-cfg.h> #include <mach/regs-gpio.h> #include <mach/gpio.h> #include "midas.h" -static int accel_get_position(void); +#ifdef CONFIG_SENSORS_SSP +#include <linux/ssp_platformdata.h> +#endif + + +#if defined(CONFIG_SENSORS_LSM330DLC) ||\ + defined(CONFIG_SENSORS_K3DH) +static int stm_get_position(void); static struct accel_platform_data accel_pdata = { - .accel_get_position = accel_get_position, + .accel_get_position = stm_get_position, .axis_adjust = true, }; +#endif + +#ifdef CONFIG_SENSORS_LSM330DLC +static struct gyro_platform_data gyro_pdata = { + .gyro_get_position = stm_get_position, + .axis_adjust = true, +}; +#endif + +#ifdef CONFIG_SENSORS_SSP +static int wakeup_mcu(void); +static int check_mcu_busy(void); +static int check_mcu_ready(void); +static int set_mcu_reset(int on); +static int check_ap_rev(void); + +static struct ssp_platform_data ssp_pdata = { + .wakeup_mcu = wakeup_mcu, + .check_mcu_busy = check_mcu_busy, + .check_mcu_ready = check_mcu_ready, + .set_mcu_reset = set_mcu_reset, + .check_ap_rev = check_ap_rev, +}; +#endif static struct i2c_board_info i2c_devs1[] __initdata = { #ifdef CONFIG_SENSORS_LSM330DLC @@ -32,25 +68,94 @@ static struct i2c_board_info i2c_devs1[] __initdata = { }, { I2C_BOARD_INFO("lsm330dlc_gyro", (0xD6 >> 1)), + .platform_data = &gyro_pdata, }, #elif defined(CONFIG_SENSORS_K3DH) { I2C_BOARD_INFO("k3dh", 0x19), .platform_data = &accel_pdata, }, +#elif defined(CONFIG_SENSORS_SSP) + { + I2C_BOARD_INFO("ssp", 0x18), + .platform_data = &ssp_pdata, + .irq = GPIO_MCU_AP_INT, + }, #endif }; -static int accel_get_position(void) +#ifdef CONFIG_SENSORS_SSP +static int initialize_ssp_gpio(void) { - int position = 0; + int err; -#if defined(CONFIG_MACH_C1VZW) /* C1_SPR */ - if (system_rev == 1) - position = 3; /* top/lower-left */ + err = gpio_request(GPIO_AP_MCU_INT, "AP_MCU_INT_PIN"); + if (err) + printk(KERN_ERR "failed to request AP_MCU_INT for SSP\n"); + + s3c_gpio_cfgpin(GPIO_AP_MCU_INT, S3C_GPIO_OUTPUT); + s3c_gpio_setpull(GPIO_AP_MCU_INT, S3C_GPIO_PULL_NONE); + gpio_direction_output(GPIO_AP_MCU_INT, 1); + + err = gpio_request(GPIO_MCU_AP_INT_2, "MCU_AP_INT_PIN2"); + if (err) + printk(KERN_ERR "failed to request AP_MCU_INT for SSP\n"); + s3c_gpio_cfgpin(GPIO_MCU_AP_INT_2, S3C_GPIO_INPUT); + s3c_gpio_setpull(GPIO_MCU_AP_INT_2, S3C_GPIO_PULL_NONE); + + err = gpio_request(GPIO_MCU_NRST, "AP_MCU_RESET"); + if (err) + printk(KERN_ERR "failed to request AP_MCU_RESET for SSP\n"); + s3c_gpio_cfgpin(GPIO_MCU_NRST, S3C_GPIO_OUTPUT); + s3c_gpio_setpull(GPIO_MCU_NRST, S3C_GPIO_PULL_NONE); + gpio_direction_output(GPIO_MCU_NRST, 1); + + return 0; +} + +static int wakeup_mcu(void) +{ + gpio_set_value(GPIO_AP_MCU_INT, 0); + udelay(1); + gpio_set_value(GPIO_AP_MCU_INT, 1); + + return 0; +} + +static int set_mcu_reset(int on) +{ + if (on == 0) + gpio_set_value(GPIO_MCU_NRST, 0); else - position = 2; /* top/lower-right */ -#elif defined(CONFIG_MACH_C1CTC) + gpio_set_value(GPIO_MCU_NRST, 1); + + return 0; +} + +static int check_mcu_busy(void) +{ + return gpio_get_value(GPIO_MCU_AP_INT); +} + +static int check_mcu_ready(void) +{ + return gpio_get_value(GPIO_MCU_AP_INT_2); +} + +static int check_ap_rev(void) +{ + return system_rev; +} + +#endif + +#if defined(CONFIG_SENSORS_LSM330DLC) || \ + defined(CONFIG_SENSORS_K3DH) +static int stm_get_position(void) +{ + int position = 0; + +#if defined(CONFIG_MACH_M3) /* C2_SPR, M3 */ position = 2; /* top/lower-right */ #elif defined(CONFIG_MACH_M0_CMCC) if (system_rev == 2) @@ -69,8 +174,6 @@ static int accel_get_position(void) position = 4; /* bottom/upper-left */ else position = 3; /* top/lower-left */ -#elif defined(CONFIG_MACH_S2PLUS) - position = 3; /* top/lower-left */ #elif defined(CONFIG_MACH_P4NOTE) position = 4; /* bottom/upper-left */ #elif defined(CONFIG_MACH_M0) @@ -88,14 +191,21 @@ static int accel_get_position(void) position = 3; /* top/lower-left */ else position = 2; /* top/lower-right */ +#elif defined(CONFIG_MACH_GC1) + if (system_rev >= 6) + position = 6; /* bottom/lower-right */ + else if (system_rev == 2 || system_rev == 3) + position = 1; /* top/upper-right */ + else + position = 0; /* top/upper-left */ +#elif defined(CONFIG_MACH_BAFFIN) + position = 6; /* bottom/lower-right */ #else /* Common */ position = 2; /* top/lower-right */ #endif return position; } -#if defined(CONFIG_SENSORS_LSM330DLC) || \ - defined(CONFIG_SENSORS_K3DH) static int accel_gpio_init(void) { int ret = gpio_request(GPIO_ACC_INT, "accelerometer_irq"); @@ -103,7 +213,7 @@ static int accel_gpio_init(void) pr_info("%s\n", __func__); if (ret) { - pr_err("%s, Failed to request gpio lsm330dlc_accel_irq(%d)\n", + pr_err("%s, Failed to request gpio accelerometer_irq(%d)\n", __func__, ret); return ret; } @@ -201,22 +311,22 @@ static int optical_gpio_init(void) /* Depends window, threshold is needed to be set */ static u8 cm36651_get_threshold(void) { - u8 threshold = 17; + u8 threshold = 15; /* Add model config and threshold here. */ -#if defined(CONFIG_MACH_M0) - if (system_rev >= 12) - threshold = 15; +#if defined(CONFIG_MACH_M0_DUOSCTC) + threshold = 13; +#elif defined(CONFIG_MACH_M0) + threshold = 15; #elif defined(CONFIG_MACH_C1_KOR_SKT) || defined(CONFIG_MACH_C1_KOR_KT) ||\ defined(CONFIG_MACH_C1_KOR_LGT) if (system_rev >= 6) - threshold = 13; -#elif defined(CONFIG_MACH_C1VZW) - if (system_rev >= 11) - threshold = 13; + threshold = 15; +#elif defined(CONFIG_MACH_M3) + threshold = 14; #elif defined(CONFIG_MACH_C1) if (system_rev >= 7) - threshold = 13; + threshold = 15; #endif return threshold; @@ -255,22 +365,30 @@ static struct i2c_board_info i2c_devs9_emul[] __initdata = { { I2C_BOARD_INFO("gp2a", (0x72 >> 1)), }, -#elif defined(CONFIG_SENSORS_CM36651) +#endif +#if defined(CONFIG_SENSORS_CM36651) { I2C_BOARD_INFO("cm36651", (0x30 >> 1)), .platform_data = &cm36651_pdata, }, -#elif defined(CONFIG_SENSORS_CM3663) +#endif +#if defined(CONFIG_SENSORS_CM3663) { I2C_BOARD_INFO("cm3663", (0x20)), .irq = GPIO_PS_ALS_INT, .platform_data = &cm3663_pdata, }, -#elif defined(CONFIG_SENSORS_BH1721) +#endif +#if defined(CONFIG_SENSORS_BH1721) { I2C_BOARD_INFO("bh1721fvc", 0x23), }, #endif +#if defined(CONFIG_SENSORS_AL3201) + { + I2C_BOARD_INFO("AL3201", 0x1c), + }, +#endif }; #ifdef CONFIG_SENSORS_AK8975C @@ -305,6 +423,53 @@ static int ak8975c_gpio_init(void) } #endif +#ifdef CONFIG_SENSORS_AK8963C +static struct akm8963_platform_data akm8963_pdata = { + .gpio_data_ready_int = GPIO_MSENSOR_INT, + .layout = 1, + .outbit = 1, + .gpio_RST = GPIO_MSENSE_RST_N, +}; + +static struct i2c_board_info i2c_devs10_emul[] __initdata = { + { + I2C_BOARD_INFO("ak8963", 0x0C), + .platform_data = &akm8963_pdata, + }, +}; + +static int ak8963c_gpio_init(void) +{ + int ret; + + pr_info("%s\n", __func__); + + ret = gpio_request(GPIO_MSENSOR_INT, "gpio_akm_int"); + if (ret) { + pr_err("%s, Failed to request gpio akm_int.(%d)\n", + __func__, ret); + return ret; + } + s5p_register_gpio_interrupt(GPIO_MSENSOR_INT); + s3c_gpio_setpull(GPIO_MSENSOR_INT, S3C_GPIO_PULL_DOWN); + s3c_gpio_cfgpin(GPIO_MSENSOR_INT, S3C_GPIO_SFN(0xF)); + i2c_devs10_emul[0].irq = gpio_to_irq(GPIO_MSENSOR_INT); + + ret = gpio_request(GPIO_MSENSE_RST_N, "gpio_akm_rst"); + if (ret) { + pr_err("%s, Failed to request gpio akm_rst.(%d)\n", + __func__, ret); + return ret; + } + s3c_gpio_cfgpin(GPIO_MSENSE_RST_N, S3C_GPIO_OUTPUT); + s3c_gpio_setpull(GPIO_MSENSE_RST_N, S3C_GPIO_PULL_NONE); + gpio_direction_output(GPIO_MSENSE_RST_N, 1); + + return ret; +} +#endif + + #ifdef CONFIG_SENSORS_LPS331 static int lps331_gpio_init(void) { @@ -359,6 +524,8 @@ static int __init midas_sensor_init(void) pr_err("%s, accel_gpio_init fail(err=%d)\n", __func__, ret); return ret; } +#elif defined(CONFIG_SENSORS_SSP) + initialize_ssp_gpio(); #endif ret = i2c_add_devices(1, i2c_devs1, ARRAY_SIZE(i2c_devs1)); if (ret < 0) { @@ -379,7 +546,7 @@ static int __init midas_sensor_init(void) pr_err("%s, i2c9 adding i2c fail(err=%d)\n", __func__, ret); return ret; } -#elif defined(CONFIG_SENSORS_BH1721) +#elif defined(CONFIG_SENSORS_BH1721) || defined(CONFIG_SENSORS_AL3201) ret = i2c_add_devices(9, i2c_devs9_emul, ARRAY_SIZE(i2c_devs9_emul)); if (ret < 0) { pr_err("%s, i2c9 adding i2c fail(err=%d)\n", __func__, ret); @@ -409,12 +576,27 @@ static int __init midas_sensor_init(void) return ret; } #endif +#ifdef CONFIG_SENSORS_AK8963C + ret = ak8963c_gpio_init(); + if (ret < 0) { + pr_err("%s, ak8963c_gpio_init fail(err=%d)\n", + __func__, ret); + return ret; + } + ret = i2c_add_devices(10, i2c_devs10_emul, + ARRAY_SIZE(i2c_devs10_emul)); + if (ret < 0) { + pr_err("%s, i2c10 adding i2c fail(err=%d)\n", + __func__, ret); + return ret; + } +#endif /* Pressure Sensor */ #ifdef CONFIG_SENSORS_LPS331 ret = lps331_gpio_init(); if (ret < 0) { - pr_err("%s, ak8975c_gpio_init fail(err=%d)\n", __func__, ret); + pr_err("%s, lps331_gpio_init fail(err=%d)\n", __func__, ret); return ret; } ret = i2c_add_devices(11, i2c_devs11_emul, ARRAY_SIZE(i2c_devs11_emul)); |