/arch/arm/mach-fsm/board-trout.c
C | 881 lines | 752 code | 101 blank | 28 comment | 18 complexity | 85504ef419dca79703d2018dfdcf69cd MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
- /* arch/arm/mach-msm/board-trout.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
- *
- * 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.
- *
- */
- #include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/platform_device.h>
- #include <linux/input.h>
- #include <linux/interrupt.h>
- #include <linux/i2c.h>
- #include <linux/irq.h>
- #include <linux/keyreset.h>
- #include <linux/leds.h>
- #include <linux/switch.h>
- #include <linux/../../../drivers/staging/android/timed_gpio.h>
- #include <linux/synaptics_i2c_rmi.h>
- #include <linux/akm8976.h>
- #include <linux/sysdev.h>
- #include <linux/android_pmem.h>
- #include <linux/delay.h>
- #include <asm/gpio.h>
- #include <mach/hardware.h>
- #include <asm/mach-types.h>
- #include <asm/mach/arch.h>
- #include <asm/mach/map.h>
- #include <asm/mach/flash.h>
- #include <asm/system.h>
- #include <mach/system.h>
- #include <mach/vreg.h>
- #include <asm/io.h>
- #include <asm/delay.h>
- #include <asm/setup.h>
- #include <linux/gpio_event.h>
- #include <linux/mtd/nand.h>
- #include <linux/mtd/partitions.h>
- #include <asm/mach/mmc.h>
- #include <linux/mmc/sdio_ids.h>
- #include <linux/msm_audio.h>
- #include "board-trout.h"
- #include "gpio_chip.h"
- #include "pm.h"
- #include <mach/board.h>
- #include <mach/board_htc.h>
- #include <mach/msm_serial_hs.h>
- #include <mach/htc_pwrsink.h>
- #ifdef CONFIG_HTC_HEADSET
- #include <mach/htc_headset.h>
- #endif
- #ifdef CONFIG_WIFI_CONTROL_FUNC
- #include <linux/wifi_tiwlan.h>
- #endif
- #include "proc_comm.h"
- #include "devices.h"
- void msm_init_irq(void);
- void msm_init_gpio(void);
- extern int trout_init_mmc(unsigned int);
- #ifdef CONFIG_WIFI_CONTROL_FUNC
- #ifdef CONFIG_WIFI_MEM_PREALLOC
- extern int trout_init_wifi_mem(void);
- #endif
- extern struct wifi_platform_data trout_wifi_control;
- #endif
- struct trout_axis_info {
- struct gpio_event_axis_info info;
- uint16_t in_state;
- uint16_t out_state;
- };
- static bool nav_just_on;
- static int nav_on_jiffies;
- uint16_t trout_axis_map(struct gpio_event_axis_info *info, uint16_t in)
- {
- struct trout_axis_info *ai = container_of(info, struct trout_axis_info, info);
- uint16_t out = ai->out_state;
- if (nav_just_on) {
- if (jiffies == nav_on_jiffies || jiffies == nav_on_jiffies + 1)
- goto ignore;
- nav_just_on = 0;
- }
- if((ai->in_state ^ in) & 1)
- out--;
- if((ai->in_state ^ in) & 2)
- out++;
- ai->out_state = out;
- ignore:
- ai->in_state = in;
- return out;
- }
- int trout_nav_power(const struct gpio_event_platform_data *pdata, bool on)
- {
- gpio_set_value(TROUT_GPIO_JOG_EN, on);
- if (on) {
- nav_just_on = 1;
- nav_on_jiffies = jiffies;
- }
- return 0;
- }
- static uint32_t trout_4_x_axis_gpios[] = {
- TROUT_4_BALL_LEFT_0, TROUT_4_BALL_RIGHT_0
- };
- static uint32_t trout_5_x_axis_gpios[] = {
- TROUT_5_BALL_LEFT_0, TROUT_5_BALL_RIGHT_0
- };
- static struct trout_axis_info trout_x_axis = {
- .info = {
- .info.func = gpio_event_axis_func,
- .count = ARRAY_SIZE(trout_5_x_axis_gpios),
- .type = EV_REL,
- .code = REL_X,
- .decoded_size = 1U << ARRAY_SIZE(trout_5_x_axis_gpios),
- .map = trout_axis_map,
- .gpio = trout_5_x_axis_gpios,
- .flags = GPIOEAF_PRINT_UNKNOWN_DIRECTION /*| GPIOEAF_PRINT_RAW | GPIOEAF_PRINT_EVENT */
- }
- };
- static uint32_t trout_4_y_axis_gpios[] = {
- TROUT_4_BALL_UP_0, TROUT_4_BALL_DOWN_0
- };
- static uint32_t trout_5_y_axis_gpios[] = {
- TROUT_5_BALL_UP_0, TROUT_5_BALL_DOWN_0
- };
- static struct trout_axis_info trout_y_axis = {
- .info = {
- .info.func = gpio_event_axis_func,
- .count = ARRAY_SIZE(trout_5_y_axis_gpios),
- .type = EV_REL,
- .code = REL_Y,
- .decoded_size = 1U << ARRAY_SIZE(trout_5_y_axis_gpios),
- .map = trout_axis_map,
- .gpio = trout_5_y_axis_gpios,
- .flags = GPIOEAF_PRINT_UNKNOWN_DIRECTION /*| GPIOEAF_PRINT_RAW | GPIOEAF_PRINT_EVENT */
- }
- };
- static struct gpio_event_direct_entry trout_nav_buttons[] = {
- { TROUT_GPIO_NAVI_ACT_N, BTN_MOUSE }
- };
- static struct gpio_event_input_info trout_nav_button_info = {
- .info.func = gpio_event_input_func,
- .flags = 0,
- .type = EV_KEY,
- .keymap = trout_nav_buttons,
- .keymap_size = ARRAY_SIZE(trout_nav_buttons)
- };
- static struct gpio_event_info *trout_nav_info[] = {
- &trout_x_axis.info.info,
- &trout_y_axis.info.info,
- &trout_nav_button_info.info
- };
- static struct gpio_event_platform_data trout_nav_data = {
- .name = "trout-nav",
- .info = trout_nav_info,
- .info_count = ARRAY_SIZE(trout_nav_info),
- .power = trout_nav_power,
- };
- static struct platform_device trout_nav_device = {
- .name = GPIO_EVENT_DEV_NAME,
- .id = 2,
- .dev = {
- .platform_data = &trout_nav_data,
- },
- };
- static int trout_reset_keys_up[] = {
- BTN_MOUSE,
- 0
- };
- static struct keyreset_platform_data trout_reset_keys_pdata = {
- .keys_up = trout_reset_keys_up,
- .keys_down = {
- KEY_SEND,
- KEY_MENU,
- KEY_END,
- 0
- },
- };
- struct platform_device trout_reset_keys_device = {
- .name = KEYRESET_NAME,
- .dev.platform_data = &trout_reset_keys_pdata,
- };
- static int trout_ts_power(int on)
- {
- int tp_ls_gpio = system_rev < 5 ? TROUT_4_TP_LS_EN : TROUT_5_TP_LS_EN;
- if (on) {
- gpio_set_value(TROUT_GPIO_TP_I2C_PULL, 1);
- gpio_set_value(TROUT_GPIO_TP_EN, 1);
- /* touchscreen must be powered before we enable i2c pullup */
- msleep(2);
- /* enable touch panel level shift */
- gpio_set_value(tp_ls_gpio, 1);
- msleep(2);
- }
- else {
- gpio_set_value(tp_ls_gpio, 0);
- udelay(50);
- gpio_set_value(TROUT_GPIO_TP_EN, 0);
- gpio_set_value(TROUT_GPIO_TP_I2C_PULL, 0);
- }
- return 0;
- }
- static struct synaptics_i2c_rmi_platform_data trout_ts_data[] = {
- {
- .version = 0x010c,
- .power = trout_ts_power,
- .flags = SYNAPTICS_FLIP_Y | SYNAPTICS_SNAP_TO_INACTIVE_EDGE,
- .inactive_left = -100 * 0x10000 / 4334,
- .inactive_right = -100 * 0x10000 / 4334,
- .inactive_top = -40 * 0x10000 / 6696,
- .inactive_bottom = -40 * 0x10000 / 6696,
-