[ARM] tegra: stingray: Add gyroscope board file data
authorDan Murphy <wldm10@motorola.com>
Fri, 28 May 2010 13:56:43 +0000 (08:56 -0500)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:33:01 +0000 (16:33 -0700)
Adding the gyroscope board file data

Change-Id: I54f076f6e3f3331755a204454c9539ba6f031156
Signed-off-by: Dan Murphy <wldm10@motorola.com>
arch/arm/mach-tegra/board-stingray-pinmux.c
arch/arm/mach-tegra/board-stingray-sensors.c

index b0b28aa9e3c3a5c9b0fef4724ded78ece494ff21..16fca4503439f4a687995c91c41f6af7a503bf10 100644 (file)
@@ -43,7 +43,7 @@ static __initdata struct tegra_pingroup_config stingray_pinmux[] = {
        {TEGRA_PINGROUP_DTC,   TEGRA_MUX_VI,            TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
        {TEGRA_PINGROUP_DTD,   TEGRA_MUX_VI,            TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
        {TEGRA_PINGROUP_DTE,   TEGRA_MUX_VI,            TEGRA_PUPD_NORMAL,    TEGRA_TRI_TRISTATE},
-       {TEGRA_PINGROUP_DTF,   TEGRA_MUX_I2C3,          TEGRA_PUPD_PULL_UP,   TEGRA_TRI_TRISTATE},
+       {TEGRA_PINGROUP_DTF,   TEGRA_MUX_I2C3,          TEGRA_PUPD_PULL_UP,   TEGRA_TRI_NORMAL},
        {TEGRA_PINGROUP_GMA,   TEGRA_MUX_SDIO4,         TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
        {TEGRA_PINGROUP_GMB,   TEGRA_MUX_GMI,           TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
        {TEGRA_PINGROUP_GMC,   TEGRA_MUX_UARTD,         TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
index b0235486ffed907bfbe212c36563e33ef9dc94a3..e3c04a7cdf200cf6ec83af530730df19d186aa75 100755 (executable)
@@ -23,6 +23,7 @@
 #include <linux/input.h>
 #include <linux/kernel.h>
 #include <linux/kxtf9.h>
+#include <linux/l3g4200d.h>
 #include <linux/max9635.h>
 #include <linux/platform_device.h>
 
@@ -35,6 +36,7 @@
 #define KXTF9_IRQ_GPIO         TEGRA_GPIO_PV3
 #define MAX9635_IRQ_GPIO       TEGRA_GPIO_PV1
 #define BMP085_IRQ_GPIO                TEGRA_GPIO_PW0
+#define L3G4200D_IRQ_GPIO      TEGRA_GPIO_PH2
 
 static struct regulator *stingray_bmp085_regulator;
 static int stingray_bmp085_init(void)
@@ -231,6 +233,77 @@ static int stingray_max9635_init(void)
        return 0;
 }
 
+static struct regulator *stingray_l3g4200d_regulator;
+static int stingray_l3g4200d_init(void)
+{
+       tegra_gpio_enable(L3G4200D_IRQ_GPIO);
+       gpio_request(L3G4200D_IRQ_GPIO, "l3g4200d_irq");
+       gpio_direction_input(L3G4200D_IRQ_GPIO);
+
+       /* TO DO: Add regulator init code here as well
+       struct regulator *reg;
+       reg = regulator_get(NULL, "vhvio");
+       if (IS_ERR(reg))
+               return PTR_ERR(reg);
+       stingray_max9635_regulator = reg;
+*/
+       stingray_l3g4200d_regulator = NULL;
+       return 0;
+}
+
+static void stingray_l3g4200d_exit(void)
+{
+       if (stingray_l3g4200d_regulator)
+               regulator_put(stingray_l3g4200d_regulator);
+
+       gpio_free(L3G4200D_IRQ_GPIO);
+}
+static int stingray_l3g4200d_power_on(void)
+{
+       if (stingray_l3g4200d_regulator)
+               return regulator_enable(stingray_l3g4200d_regulator);
+       return 0;
+}
+static int stingray_l3g4200d_power_off(void)
+{
+       if (stingray_l3g4200d_regulator)
+               return regulator_disable(stingray_l3g4200d_regulator);
+       return 0;
+}
+struct l3g4200d_platform_data stingray_gyro_pdata = {
+       .poll_interval = 200,
+       .min_interval = 0,
+
+       .g_range = 0,
+
+       .ctrl_reg_1 = 0xbf,
+       .ctrl_reg_2 = 0x00,
+       .ctrl_reg_3 = 0x00,
+       .ctrl_reg_4 = 0x00,
+       .ctrl_reg_5 = 0x00,
+       .int_config = 0x00,
+       .int_source = 0x00,
+       .int_th_x_h = 0x00,
+       .int_th_x_l = 0x00,
+       .int_th_y_h = 0x00,
+       .int_th_y_l = 0x00,
+       .int_th_z_h = 0x00,
+       .int_th_z_l = 0x00,
+       .int_duration = 0x00,
+
+       .axis_map_x = 0,
+       .axis_map_y = 0,
+       .axis_map_z = 0,
+
+       .negate_x = 0,
+       .negate_y = 0,
+       .negate_z = 0,
+
+       .exit = stingray_l3g4200d_exit,
+       .power_on = stingray_l3g4200d_power_on,
+       .power_off = stingray_l3g4200d_power_off,
+
+};
 static struct i2c_board_info __initdata stingray_i2c_bus4_sensor_info[] = {
        {
                I2C_BOARD_INFO("kxtf9", 0x0F),
@@ -251,14 +324,25 @@ static struct i2c_board_info __initdata stingray_i2c_bus1_sensor_info[] = {
                .irq = TEGRA_GPIO_TO_IRQ(MAX9635_IRQ_GPIO),
         },
 };
+static struct i2c_board_info __initdata stingray_i2c_bus3_sensor_info[] = {
+        {
+               I2C_BOARD_INFO(L3G4200D_NAME, 0x68),
+               .platform_data = &stingray_gyro_pdata,
+               .irq = TEGRA_GPIO_TO_IRQ(L3G4200D_IRQ_GPIO),
+        },
+};
 
 int __init stingray_sensors_init(void)
 {
        stingray_bmp085_init();
        stingray_kxtf9_init();
        stingray_max9635_init();
+       stingray_l3g4200d_init();
+
        i2c_register_board_info(3, stingray_i2c_bus4_sensor_info,
                ARRAY_SIZE(stingray_i2c_bus4_sensor_info));
+       i2c_register_board_info(2, stingray_i2c_bus3_sensor_info,
+               ARRAY_SIZE(stingray_i2c_bus3_sensor_info));
        return i2c_register_board_info(0, stingray_i2c_bus1_sensor_info,
                ARRAY_SIZE(stingray_i2c_bus1_sensor_info));
 }