Merge branch 'master' of gitorious.org:linux-on-wince-htc/linux-on-wince-htc

This commit is contained in:
LeTama 2010-09-04 20:48:40 +02:00
commit 751a8d238f
6 changed files with 592 additions and 4 deletions

View File

@ -1075,4 +1075,9 @@ config VERY_EARLY_CONSOLE
effect, the driver must support this and the consoles should
be initialized in the board file as soon as possible.
config HTCLEO_ENABLE_MULTI_TOUCH
bool "Support for multitouch"
default y
depends on MACH_HTCLEO
help
Add multitouch support for touchscreen

View File

@ -0,0 +1,104 @@
/* linux/arch/arm/mach-msm/board-htcleo-bkl.c
*
* Copyright (c) 2010 Cotulla
*
* 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/clk.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/wakelock.h>
#include <linux/leds.h>
#include <asm/io.h>
#include <asm/mach-types.h>
#include <mach/msm_fb.h>
#include <linux/gpio.h>
#include <mach/msm_iomap.h>
//#define DEBUG_LCM
#ifdef DEBUG_LCM
#define LCMDBG(fmt, arg...) printk(fmt, ## arg)
#else
#define LCMDBG(fmt, arg...) {}
#endif
extern int microp_set_bkl(uint8_t value);
extern int micorp_onoff_bkl(int enable);
static struct led_trigger *htcleo_lcd_backlight;
void htcleo_brightness_set(struct led_classdev *led_cdev, enum led_brightness val)
{
led_cdev->brightness = val;
// set brigtness level via MicroP
LCMDBG("htcleo_brightness_set: %d\n", val);
if (val > 255) val = 255;
if (val < 30)
{
micorp_onoff_bkl(0);
}
else
{
micorp_onoff_bkl(1);
microp_set_bkl((val - 30) / 23);
}
}
static struct led_classdev htcleo_backlight_led =
{
.name = "lcd-backlight",
.brightness = LED_FULL,
.brightness_set = htcleo_brightness_set,
};
static int htcleo_backlight_probe(struct platform_device *pdev)
{
int rc;
led_trigger_register_simple("lcd-backlight-gate", &htcleo_lcd_backlight);
rc = led_classdev_register(&pdev->dev, &htcleo_backlight_led);
if (rc)
LCMDBG("backlight: failure on register led_classdev\n");
return 0;
}
static struct platform_driver htcleo_backlight_driver =
{
.probe = htcleo_backlight_probe,
.driver =
{
.name = "htcleo-backlight",
.owner = THIS_MODULE,
},
};
static int __init htcleo_backlight_init(void)
{
return platform_driver_register(&htcleo_backlight_driver);
}
module_init(htcleo_backlight_init);
// END OF FILE

View File

@ -0,0 +1,319 @@
/* arch/arm/mach-msm/board-htcleo-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.
*/
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/leds.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/earlysuspend.h>
#include <asm/mach-types.h>
#include <mach/board-htcleo-microp.h>
#include <linux/capella_cm3602.h>
#include <linux/input.h>
#include <linux/uaccess.h>
#include <linux/miscdevice.h>
#include <mach/vreg.h>
#include <linux/wakelock.h>
#include <linux/workqueue.h>
#include "board-htcleo.h"
#define INT_PSENSOR (1<<4)
#define GPO_PROXIMITY 0x3
static int misc_opened;
static void p_sensor_do_work(struct work_struct *w);
static DECLARE_WORK(p_sensor_work, p_sensor_do_work);
struct wake_lock proximity_wake_lock;
static struct capella_cm3602_data {
struct input_dev *input_dev;
struct capella_cm3602_platform_data *pdata;
int enabled;
struct workqueue_struct *p_sensor_wq;
} the_data;
static int report_psensor_data(void)
{
int ret, ps_data = 0;
uint8_t data[3] = {0, 0, 0};
pr_info("%s\n", __func__);
ret = microp_i2c_read(MICROP_I2C_RCMD_GPIO_STATUS, data, 3);
if (ret < 0)
pr_err("%s: read data failed\n", __func__);
else {
ps_data = (data[1] & 0x1) ? 1 : 0;
pr_info("proximity %s\n", ps_data ? "FAR" : "NEAR");
/* 0 is close, 1 is far */
input_report_abs(the_data.input_dev, ABS_DISTANCE, ps_data);
input_sync(the_data.input_dev);
wake_lock_timeout(&proximity_wake_lock, 2*HZ);
}
return ret;
}
static int capella_cm3602_enable(struct capella_cm3602_data *data)
{
int rc;
pr_info("%s\n", __func__);
if (data->enabled) {
pr_info("%s: already enabled\n", __func__);
return 0;
}
/* dummy report */
input_report_abs(data->input_dev, ABS_DISTANCE, -1);
input_sync(data->input_dev);
rc = microp_gpo_enable(GPO_PROXIMITY);
if (rc < 0)
return -EIO;
data->enabled = 1;
report_psensor_data();
return rc;
}
static int capella_cm3602_disable(struct capella_cm3602_data *data)
{
int rc = -EIO;
pr_info("%s\n", __func__);
if (!data->enabled) {
pr_info("%s: already disabled\n", __func__);
return 0;
}
rc = microp_gpo_disable(GPO_PROXIMITY);
if (rc < 0)
return -EIO;
data->enabled = 0;
return rc;
}
static ssize_t capella_cm3602_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int ret;
ret = sprintf(buf, "proximity enabled = %d\n", the_data.enabled);
return ret;
}
static ssize_t capella_cm3602_store(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count
)
{
ssize_t val;
val = -1;
sscanf(buf, "%u", &val);
if (val < 0 || val > 1)
return -EINVAL;
/* Enable capella_cm3602*/
if (val == 1)
capella_cm3602_enable(&the_data);
/* Disable capella_cm3602*/
if (val == 0)
capella_cm3602_disable(&the_data);
return count;
}
static DEVICE_ATTR(proximity, 0644, capella_cm3602_show, capella_cm3602_store);
static int capella_cm3602_open(struct inode *inode, struct file *file)
{
pr_info("%s\n", __func__);
if (misc_opened)
return -EBUSY;
misc_opened = 1;
return 0;
}
static int capella_cm3602_release(struct inode *inode, struct file *file)
{
pr_info("%s\n", __func__);
misc_opened = 0;
return capella_cm3602_disable(&the_data);
}
static long capella_cm3602_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
int val;
pr_info("%s cmd %d\n", __func__, _IOC_NR(cmd));
switch (cmd) {
case CAPELLA_CM3602_IOCTL_ENABLE:
if (get_user(val, (unsigned long __user *)arg))
return -EFAULT;
if (val)
return capella_cm3602_enable(&the_data);
else
return capella_cm3602_disable(&the_data);
break;
case CAPELLA_CM3602_IOCTL_GET_ENABLED:
return put_user(the_data.enabled, (unsigned long __user *)arg);
break;
default:
pr_err("%s: invalid cmd %d\n", __func__, _IOC_NR(cmd));
return -EINVAL;
}
}
static void p_sensor_do_work(struct work_struct *w)
{
report_psensor_data();
}
void p_sensor_irq_handler(void)
{
pr_info("%s\n", __func__);
queue_work(the_data.p_sensor_wq, &p_sensor_work);
}
static struct file_operations capella_cm3602_fops = {
.owner = THIS_MODULE,
.open = capella_cm3602_open,
.release = capella_cm3602_release,
.unlocked_ioctl = capella_cm3602_ioctl
};
static struct miscdevice capella_cm3602_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = "cm3602",
.fops = &capella_cm3602_fops
};
static int capella_cm3602_probe(struct platform_device *pdev)
{
int rc = -1;
struct input_dev *input_dev;
struct capella_cm3602_data *ip;
struct capella_cm3602_platform_data *pdata;
struct class *proximity_attr_class;
struct device *proximity_attr_dev;
pr_info("%s: probe\n", __func__);
pdata = dev_get_platdata(&pdev->dev);
ip = &the_data;
platform_set_drvdata(pdev, ip);
input_dev = input_allocate_device();
if (!input_dev) {
pr_err("%s: could not allocate input device\n", __func__);
rc = -ENOMEM;
goto done;
}
ip->input_dev = input_dev;
ip->pdata = pdata;
input_set_drvdata(input_dev, ip);
input_dev->name = "proximity";
set_bit(EV_ABS, input_dev->evbit);
input_set_abs_params(input_dev, ABS_DISTANCE, 0, 1, 0, 0);
rc = input_register_device(input_dev);
if (rc < 0) {
pr_err("%s: could not register input device\n", __func__);
goto err_free_input_device;
}
rc = misc_register(&capella_cm3602_misc);
if (rc < 0) {
pr_err("%s: could not register misc device\n", __func__);
goto err_unregister_input_device;
}
wake_lock_init(&proximity_wake_lock, WAKE_LOCK_SUSPEND, "proximity");
proximity_attr_class = class_create(THIS_MODULE, "sensors");
if (IS_ERR(proximity_attr_class)) {
pr_err("%s: class_create failed\n", __func__);
rc = PTR_ERR(proximity_attr_class);
proximity_attr_class = NULL;
goto err_create_class;
}
proximity_attr_dev = device_create(proximity_attr_class,
NULL, 0, "%s", "proximity_sensor");
if (unlikely(IS_ERR(proximity_attr_dev))) {
pr_err("%s: device create failed\n", __func__);
rc = PTR_ERR(proximity_attr_dev);
proximity_attr_dev = NULL;
goto err_create_proximity_attr_device;
}
rc = device_create_file(proximity_attr_dev, &dev_attr_proximity);
if (rc) {
pr_err("%s: device_create_file failed\n", __func__);
goto err_create_proximity_device_file;
}
ip->p_sensor_wq = create_workqueue("p-sensor_microp_wq");
if (ip->p_sensor_wq == NULL) {
pr_err("%s: create_workqueue failed\n", __func__);
goto err_create_workqueue;
}
goto done;
err_create_workqueue:
device_remove_file(proximity_attr_dev, &dev_attr_proximity);
err_create_proximity_device_file:
device_unregister(proximity_attr_dev);
err_create_proximity_attr_device:
class_destroy(proximity_attr_class);
err_create_class:
misc_deregister(&capella_cm3602_misc);
err_unregister_input_device:
input_unregister_device(input_dev);
err_free_input_device:
input_free_device(input_dev);
done:
return rc;
}
static struct platform_driver capella_cm3602_driver = {
.probe = capella_cm3602_probe,
.driver = {
.name = "htcleo-proximity",
.owner = THIS_MODULE
},
};
static int __init htcleo_capella_cm3602_init(void)
{
return platform_driver_register(&capella_cm3602_driver);
}
device_initcall(htcleo_capella_cm3602_init);

View File

@ -0,0 +1,156 @@
/*
* Definitions for BMA150 G-sensor chip.
*/
#ifndef HTCLEO_MICROP_H
#define HTCLEO_MICROP_H
#include <linux/ioctl.h>
static struct wake_lock microp_i2c_wakelock;
static struct i2c_client *private_microp_client;
struct microp_i2c_platform_data {
struct platform_device *microp_devices;
int num_devices;
uint32_t gpio_reset;
void *dev_id;
uint8_t microp_mic_status;
uint8_t function_node[20];
uint32_t cmd_diff;
};
struct microp_int_pin {
uint16_t int_gsensor;
uint16_t int_lsensor;
uint16_t int_reset;
uint16_t int_simcard;
uint16_t int_hpin;
uint16_t int_remotekey;
};
struct microp_led_data {
int type;
struct led_classdev ldev;
struct mutex led_data_mutex;
struct work_struct brightness_work;
spinlock_t brightness_lock;
enum led_brightness brightness;
uint8_t mode;
uint8_t blink;
};
struct microp_i2c_work {
struct work_struct work;
struct i2c_client *client;
int (*intr_debounce)(uint8_t *pin_status);
void (*intr_function)(uint8_t *pin_status);
};
enum led_type {
GREEN_LED,
AMBER_LED,
NUM_LEDS,
};
struct microp_i2c_client_data {
struct mutex microp_i2c_rw_mutex;
struct mutex proximity_api_lock;
struct microp_led_data leds[NUM_LEDS];
uint8_t gpio_reset;
uint16_t version;
struct microp_i2c_work work;
struct delayed_work hpin_debounce_work;
struct early_suspend early_suspend;
uint8_t enable_early_suspend;
uint8_t enable_reset_button;
int microp_is_suspend;
int auto_backlight_enabled;
uint8_t proximity_sensor_enabled;
uint8_t button_led_value;
int headset_is_in;
int is_hpin_pin_stable;
struct input_dev *pr_input_dev;
struct input_dev *ls_input_dev;
uint32_t microp_als_kadc;
};
#define MICROP_I2C_NAME "htcleo-microp"
#define MICROP_LSENSOR_ADC_CHAN 6
#define MICROP_REMOTE_KEY_ADC_CHAN 7
#define MICROP_I2C_WCMD_MISC 0x20
#define MICROP_I2C_WCMD_SPI_EN 0x21
#define MICROP_I2C_WCMD_LCM_BL_MANU_CTL 0x22
#define MICROP_I2C_WCMD_AUTO_BL_CTL 0x23
#define MICROP_I2C_RCMD_SPI_BL_STATUS 0x24
#define MICROP_I2C_WCMD_LED_PWM 0x25
#define MICROP_I2C_WCMD_BL_EN 0x26
#define MICROP_I2C_RCMD_VERSION 0x30
#define MICROP_I2C_WCMD_ADC_TABLE 0x42
#define MICROP_I2C_WCMD_LED_CTRL 0x51
#define MICROP_I2C_WCMD_LED_MODE 0x53
#define MICROP_I2C_RCMD_GREEN_LED_REMAIN_TIME 0x54
#define MICROP_I2C_RCMD_AMBER_LED_REMAIN_TIME 0x55
#define MICROP_I2C_RCMD_LED_REMAIN_TIME 0x56
#define MICROP_I2C_RCMD_BLUE_LED_REMAIN_TIME 0x57
#define MICROP_I2C_RCMD_LED_STATUS 0x58
#define MICROP_I2C_WCMD_JOGBALL_LED_MODE 0x5A
#define MICROP_I2C_WCMD_JOGBALL_LED_PWM_SET 0x5C
#define MICROP_I2C_WCMD_READ_ADC_VALUE_REQ 0x60
#define MICROP_I2C_RCMD_ADC_VALUE 0x62
#define MICROP_I2C_WCMD_REMOTEKEY_TABLE 0x63
#define MICROP_I2C_WCMD_ADC_REQ 0x64
#define MICROP_I2C_WCMD_LCM_BURST 0x6A
#define MICROP_I2C_WCMD_LCM_BURST_EN 0x6B
#define MICROP_I2C_WCMD_LCM_REGISTER 0x70
#define MICROP_I2C_WCMD_GSENSOR_REG 0x73
#define MICROP_I2C_WCMD_GSENSOR_REG_DATA_REQ 0x74
#define MICROP_I2C_RCMD_GSENSOR_REG_DATA 0x75
#define MICROP_I2C_WCMD_GSENSOR_DATA_REQ 0x76
#define MICROP_I2C_RCMD_GSENSOR_X_DATA 0x77
#define MICROP_I2C_RCMD_GSENSOR_Y_DATA 0x78
#define MICROP_I2C_RCMD_GSENSOR_Z_DATA 0x79
#define MICROP_I2C_RCMD_GSENSOR_DATA 0x7A
#define MICROP_I2C_WCMD_OJ_REG 0x7B
#define MICROP_I2C_WCMD_OJ_REG_DATA_REQ 0x7C
#define MICROP_I2C_RCMD_OJ_REG_DATA 0x7D
#define MICROP_I2C_WCMD_OJ_POS_DATA_REQ 0x7E
#define MICROP_I2C_RCMD_OJ_POS_DATA 0x7F
#define MICROP_I2C_WCMD_GPI_INT_CTL_EN 0x80
#define MICROP_I2C_WCMD_GPI_INT_CTL_DIS 0x81
#define MICROP_I2C_RCMD_GPI_INT_STATUS 0x82
#define MICROP_I2C_RCMD_GPIO_STATUS 0x83
#define MICROP_I2C_WCMD_GPI_INT_STATUS_CLR 0x84
#define MICROP_I2C_RCMD_GPI_INT_SETTING 0x85
#define MICROP_I2C_RCMD_REMOTE_KEYCODE 0x87
#define MICROP_I2C_WCMD_REMOTE_KEY_DEBN_TIME 0x88
#define MICROP_I2C_WCMD_REMOTE_PLUG_DEBN_TIME 0x89
#define MICROP_I2C_WCMD_SIMCARD_DEBN_TIME 0x8A
#define MICROP_I2C_WCMD_GPO_LED_STATUS_EN 0x90
#define MICROP_I2C_WCMD_GPO_LED_STATUS_DIS 0x91
#define MICROP_I2C_RCMD_GPO_LED_STATUS 0x92
#define MICROP_I2C_WCMD_OJ_INT_STATUS 0xA8
#define MICROP_I2C_RCMD_MOBEAM_STATUS 0xB1
#define MICROP_I2C_WCMD_MOBEAM_DL 0xB2
#define MICROP_I2C_WCMD_MOBEAM_SEND 0xB3
#define IRQ_GSENSOR (1<<10)
#define IRQ_LSENSOR (1<<9)
#define IRQ_REMOTEKEY (1<<7)
#define IRQ_HEADSETIN (1<<2)
#define IRQ_PROXIMITY (1<<1)
#define IRQ_SDCARD (1<<0)
#define READ_GPI_STATE_HPIN (1<<2)
#define READ_GPI_STATE_SDCARD (1<<0)
#define GPO_PROXIMITY 0x3
int microp_i2c_read(uint8_t addr, uint8_t *data, int length);
int microp_i2c_write(uint8_t addr, uint8_t *data, int length);
int microp_gpo_enable(uint16_t interrupt_mask);
int microp_gpo_disable(uint16_t interrupt_mask);
#endif

View File

@ -149,10 +149,10 @@ static int smd_tty_open(struct tty_struct *tty, struct file *f)
info = smd_tty + n;
mutex_lock(&smd_tty_lock);
wake_lock_init(&info->wake_lock, WAKE_LOCK_SUSPEND, name);
tty->driver_data = info;
if (info->open_count++ == 0) {
wake_lock_init(&info->wake_lock, WAKE_LOCK_SUSPEND, name);
info->tty = tty;
if (info->ch) {
smd_kick(info->ch);
@ -204,13 +204,16 @@ static int smd_tty_write(struct tty_struct *tty,
** never be able to write more data than there
** is currently space for
*/
#ifndef CONFIG_MACH_HTCLEO
mutex_lock(&smd_tty_lock);
#endif
avail = smd_write_avail(info->ch);
if (len > avail)
len = avail;
ret = smd_write(info->ch, buf, len);
#ifndef CONFIG_MACH_HTCLEO
mutex_unlock(&smd_tty_lock);
#endif
return ret;
}

View File

@ -264,6 +264,7 @@ static struct platform_driver msmrtc_driver = {
static int __init msmrtc_init(void)
{
pr_info("RTC: Init MSM RTC Clock");
rtcalarm_time = 0;
switch(__amss_version) {
case 6210:
@ -274,7 +275,7 @@ static int __init msmrtc_init(void)
msmrtc_driver.driver.name="rs30000048:0da5b528";
break;
case 1550:
msmrtc_driver.driver.name="rs30000048:00010002";
msmrtc_driver.driver.name="rs30000048:00010000";
break;
default:
msmrtc_driver.driver.name="rs30000048:00010001";