From f8ffb66d1ae6a3b55a2b9cca4c535d887d876209 Mon Sep 17 00:00:00 2001 From: Dan Murphy Date: Thu, 20 May 2010 15:41:05 -0500 Subject: [PATCH] [ARM] tegra: stingray: Initial sensor board file for stingray Initial submission of the sensor board file with barometer intialization. Change-Id: I04316eb26f53bbdc0306bb3a8a74f6d17e03ae88 Signed-off-by: Dan Murphy --- arch/arm/mach-tegra/Makefile | 1 + arch/arm/mach-tegra/board-stingray-sensors.c | 93 ++++++++++++++++++++ arch/arm/mach-tegra/board-stingray.c | 1 + arch/arm/mach-tegra/board-stingray.h | 1 + 4 files changed, 96 insertions(+) create mode 100755 arch/arm/mach-tegra/board-stingray-sensors.c diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile index b3d839ffcdb3..2e877af71c56 100644 --- a/arch/arm/mach-tegra/Makefile +++ b/arch/arm/mach-tegra/Makefile @@ -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 index 000000000000..758561795b28 --- /dev/null +++ b/arch/arm/mach-tegra/board-stingray-sensors.c @@ -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 . + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#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)); +} diff --git a/arch/arm/mach-tegra/board-stingray.c b/arch/arm/mach-tegra/board-stingray.c index 69cf93363060..1cc4bf62d24c 100644 --- a/arch/arm/mach-tegra/board-stingray.c +++ b/arch/arm/mach-tegra/board-stingray.c @@ -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(); } diff --git a/arch/arm/mach-tegra/board-stingray.h b/arch/arm/mach-tegra/board-stingray.h index 8e84cacc3fd4..ff27feb6298d 100644 --- a/arch/arm/mach-tegra/board-stingray.h +++ b/arch/arm/mach-tegra/board-stingray.h @@ -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 -- 2.34.1