From 610bdb2cc0a39a3b236a6bee8bc567e217ad66d1 Mon Sep 17 00:00:00 2001 From: Markinus Date: Sun, 29 Aug 2010 16:31:32 +0200 Subject: [PATCH] htcleo: add basic microp functions --- arch/arm/mach-msm/Makefile | 2 +- arch/arm/mach-msm/board-htcleo-microp.c | 79 +++++++++++++++++++++++++ arch/arm/mach-msm/board-htcleo.c | 47 +++++++++++++++ 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-msm/board-htcleo-microp.c diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile index 05bbc06e..695e68c8 100644 --- a/arch/arm/mach-msm/Makefile +++ b/arch/arm/mach-msm/Makefile @@ -108,7 +108,7 @@ obj-$(CONFIG_MACH_BRAVOC) += board-bravoc-microp.o clock.o obj-$(CONFIG_MACH_HTCLEO) += board-htcleo.o board-htcleo-spi.o board-htcleo-panel.o board-htcleo-keypad.o obj-$(CONFIG_MACH_HTCLEO) += board-htcleo-ts.o board-htcleo-mmc.o ieee754-df.o board-htcleo-power.o obj-$(CONFIG_MACH_HTCLEO) += board-htcleo-battery.o board-htcleo-log.o board-htcleo-acoustic.o board-htcleo-audio.o -obj-$(CONFIG_MACH_HTCLEO) += board-htcleo-bt.o +obj-$(CONFIG_MACH_HTCLEO) += board-htcleo-bt.o board-htcleo-microp.o obj-$(CONFIG_MACH_HTCLEO) += clock-wince.o # MSM7x30 boards diff --git a/arch/arm/mach-msm/board-htcleo-microp.c b/arch/arm/mach-msm/board-htcleo-microp.c new file mode 100644 index 00000000..1ce7c19c --- /dev/null +++ b/arch/arm/mach-msm/board-htcleo-microp.c @@ -0,0 +1,79 @@ +/* arch/arm/mach-msm/board-supersonic-microp.c + * Copyright (C) 2009 HTC Corporation. + * + * 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. +*/ +#ifdef CONFIG_MICROP_COMMON +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "board-htcleo.h" + +static int htcleo_microp_function_init(struct i2c_client *client) +{ + struct microp_i2c_platform_data *pdata; + struct microp_i2c_client_data *cdata; + uint8_t data[20]; + int i, j; + int ret; + + pdata = client->dev.platform_data; + cdata = i2c_get_clientdata(client); + + /* Headset remote key */ + ret = microp_function_check(client, MICROP_FUNCTION_REMOTEKEY); + if (ret >= 0) { + i = ret; + pdata->function_node[MICROP_FUNCTION_REMOTEKEY] = i; + cdata->int_pin.int_remotekey = + pdata->microp_function[i].int_pin; + + for (j = 0; j < 6; j++) { + data[j] = (uint8_t)(pdata->microp_function[i].levels[j] >> 8); + data[j + 6] = (uint8_t)(pdata->microp_function[i].levels[j]); + } + ret = microp_i2c_write(MICROP_I2C_WCMD_REMOTEKEY_TABLE, + data, 12); + if (ret) + goto exit; + } + + /* Reset button interrupt */ + ret = microp_write_interrupt(client, (1<<8), 1); + if (ret) + goto exit; + + + return 0; + +exit: + return ret; +} + +static struct microp_ops ops = { + .init_microp_func = htcleo_microp_function_init, +}; + +void __init htcleo_microp_init(void) +{ + microp_register_ops(&ops); +} +#endif diff --git a/arch/arm/mach-msm/board-htcleo.c b/arch/arm/mach-msm/board-htcleo.c index 1690dbbd..ba47243e 100644 --- a/arch/arm/mach-msm/board-htcleo.c +++ b/arch/arm/mach-msm/board-htcleo.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include <../../../drivers/staging/android/timed_gpio.h> @@ -51,6 +52,10 @@ #include "devices.h" #include "proc_comm.h" #include "dex_comm.h" +#ifdef CONFIG_MICROP_COMMON +#include +void __init htcleo_microp_init(void); +#endif extern int __init htcleo_init_mmc(unsigned debug_uart); extern void __init htcleo_audio_init(void); @@ -129,6 +134,38 @@ static struct akm8973_platform_data compass_platform_data = .intr = HTCLEO_GPIO_COMPASS_INT_N, }; +#ifdef CONFIG_MICROP_COMMON +// Microp +static struct microp_function_config microp_functions[] = { + { + .name = "reset-int", + .category = MICROP_FUNCTION_RESET_INT, + .int_pin = 1 << 8, + }, +}; + +static struct bma150_platform_data htcleo_g_sensor_pdata = { + .microp_new_cmd = 1, +}; + +static struct platform_device microp_devices[] = { + { + .name = BMA150_G_SENSOR_NAME, + .dev = { + .platform_data = &htcleo_g_sensor_pdata, + }, + }, +}; + +static struct microp_i2c_platform_data microp_data = { + .num_functions = ARRAY_SIZE(microp_functions), + .microp_function = microp_functions, + .num_devices = ARRAY_SIZE(microp_devices), + .microp_devices = microp_devices, + .gpio_reset = HTCLEO_GPIO_UP_RESET_N, + .spi_devices = SPI_GSENSOR, +}; +#endif static struct i2c_board_info base_i2c_devices[] = { { @@ -141,6 +178,13 @@ static struct i2c_board_info base_i2c_devices[] = I2C_BOARD_INFO("tps65023", 0x48), .platform_data = tps65023_data, }, +#ifdef CONFIG_MICROP_COMMON + { + I2C_BOARD_INFO(MICROP_I2C_NAME, 0xCC >> 1), + .platform_data = µp_data, + .irq = MSM_GPIO_TO_INT(HTCLEO_GPIO_UP_INT_N) + }, +#endif { I2C_BOARD_INFO(AKM8973_I2C_NAME, 0x1C), .platform_data = &compass_platform_data, @@ -538,6 +582,9 @@ static void __init htcleo_init(void) mdelay(100); htcleo_kgsl_power(true); +#ifdef CONFIG_MICROP_COMMON + htcleo_microp_init(); +#endif msm_device_i2c_init(); platform_add_devices(devices, ARRAY_SIZE(devices));