[ARM] tegra: stingray: Initial sensor board file for stingray
authorDan Murphy <wldm10@motorola.com>
Thu, 20 May 2010 20:41:05 +0000 (15:41 -0500)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:32:55 +0000 (16:32 -0700)
Initial submission of the sensor board file with barometer intialization.

Change-Id: I04316eb26f53bbdc0306bb3a8a74f6d17e03ae88
Signed-off-by: Dan Murphy <wldm10@motorola.com>
arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/board-stingray-sensors.c [new file with mode: 0755]
arch/arm/mach-tegra/board-stingray.c
arch/arm/mach-tegra/board-stingray.h

index b3d839ffcdb38e64abd135fc61187cd3b00a6dd6..2e877af71c56367ebd6e9453271e6f74e3434ad3 100644 (file)
@@ -57,3 +57,4 @@ obj-${CONFIG_MACH_STINGRAY}             += board-stingray-panel.o
 obj-${CONFIG_MACH_STINGRAY}             += board-stingray-i2c.o
 obj-${CONFIG_MACH_STINGRAY}             += board-stingray-keypad.o
 obj-${CONFIG_MACH_STINGRAY}             += board-stingray-wifi.o
+obj-${CONFIG_MACH_STINGRAY}             += board-stingray-sensors.o
diff --git a/arch/arm/mach-tegra/board-stingray-sensors.c b/arch/arm/mach-tegra/board-stingray-sensors.c
new file mode 100755 (executable)
index 0000000..7585617
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2010, Motorola, All Rights Reserved.
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <linux/bmp085.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+
+#include <linux/regulator/consumer.h>
+
+#include <mach/gpio.h>
+
+#include "gpio-names.h"
+
+static struct regulator *stingray_bmp085_regulator;
+
+static int stingray_bmp085_init(void)
+{
+       /*struct regulator *reg;*/
+
+       tegra_gpio_enable(TEGRA_GPIO_PW0);
+       gpio_request(TEGRA_GPIO_PW0, "bmp085_irq");
+       gpio_direction_input(TEGRA_GPIO_PW0);
+/*
+       reg = regulator_get(NULL, "vhvio");
+       if (IS_ERR(reg))
+               return PTR_ERR(reg);*/
+       stingray_bmp085_regulator = NULL;/*reg;*/
+
+       return 0;
+}
+
+static void stingray_bmp085_exit(void)
+{
+       if (stingray_bmp085_regulator)
+               regulator_put(stingray_bmp085_regulator);
+       return;
+}
+static int stingray_bmp085_power_on(void)
+{
+       if (stingray_bmp085_regulator)
+               return regulator_enable(stingray_bmp085_regulator);
+       return 0;
+}
+static int stingray_bmp085_power_off(void)
+{
+       if (stingray_bmp085_regulator)
+               return regulator_disable(stingray_bmp085_regulator);
+       return 0;
+}
+struct bmp085_platform_data stingray_barom_pdata = {
+       .poll_interval = 200,
+       .min_interval = 20,
+
+       .init = stingray_bmp085_init,
+       .exit = stingray_bmp085_exit,
+       .power_on = stingray_bmp085_power_on,
+       .power_off = stingray_bmp085_power_off,
+
+};
+
+static struct i2c_board_info __initdata stingray_i2c_bus1_sensor_info[] = {
+       {
+        I2C_BOARD_INFO(BMP085_NAME, 0x77),
+        .platform_data = &stingray_barom_pdata,
+        .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PW0),
+        },
+};
+
+int __init stingray_sensors_init(void)
+{
+       stingray_bmp085_init();
+       return i2c_register_board_info(0, stingray_i2c_bus1_sensor_info,
+               ARRAY_SIZE(stingray_i2c_bus1_sensor_info));
+}
index 69cf93363060bc6c047f9a9da68b25d6d8871f28..1cc4bf62d24cd19bd2c4a8985f71b447617c1513 100644 (file)
@@ -286,6 +286,7 @@ static void __init tegra_stingray_init(void)
        stingray_i2c_init();
        stingray_panel_init();
        stingray_sdhci_init();
+       stingray_sensors_init();
        stingray_wlan_init();
 }
 
index 8e84cacc3fd4447574ddb0032d33db44fe751052..ff27feb6298d4c31e6fd6ee464ead2e31455826e 100644 (file)
@@ -22,5 +22,6 @@ int stingray_panel_init(void);
 int stingray_keypad_init(void);
 int stingray_i2c_init(void);
 int stingray_wlan_init(void);
+int stingray_sensors_init(void);
 
 #endif