static void microp_scan_key(struct microp_input_state *ds)
{
	const struct gpio_event_direct_entry *key_entry;
	uint8_t pressed = 0;
	uint8_t data[3];
	int i = 0;

	memset(data, 0x00, sizeof(uint8_t)*3);
	microp_i2c_read(MICROP_I2C_RCMD_GPIO_STATUS, data, 3);

	key_entry = ds->info->keymap;
	if (key_entry == NULL) {
		KEY_LOGE("%s, (key_entry == NULL) failed\n", __func__);
		return;
	}

	for (i = 0; i < ds->info->keymap_size; i++) {
		pressed = read_microp_gpio(data, key_entry[i].gpio);
		pr_info("microp_keys_scan_keys: key %d-%d, %d (%d) "
			"changed to %d\n", ds->info->type,
			key_entry[i].code, i, key_entry[i].gpio, pressed);
#ifdef CONFIG_OPTICALJOYSTICK_CRUCIAL
		if (ds->info->info.oj_btn && key_entry->code == BTN_MOUSE) {
			curcial_oj_send_key(BTN_MOUSE, pressed);
		} else {
#endif
			input_event(ds->input_devs->dev[key_entry[i].dev],
			ds->info->type, key_entry[i].code, pressed);
			input_sync(ds->input_devs->dev[key_entry->dev]);
#ifdef CONFIG_OPTICALJOYSTICK_CRUCIAL
		}
#endif
	}
}
Beispiel #2
0
static int curcial_oj_poweron(int	on)
{
	uint8_t data[2];
	struct vreg	*oj_power = vreg_get(0, "gp2");
	if (IS_ERR(oj_power)) {
		printk(KERN_ERR"%s:Error power domain\n",__func__);
		return 0;
	}


	if (on) {
		vreg_set_level(oj_power, 2750);
		vreg_enable(oj_power);
		printk(KERN_ERR "%s:OJ	power	enable(%d)\n", __func__, on);
	} else {
	/* for microp firmware(v04) setting*/
		microp_i2c_read(MICROP_I2C_RCMD_VERSION, data, 2);
		if (data[0] < 4) {
			printk("Microp firmware version:%d\n",data[0]);
			return 1;
		}
		vreg_disable(oj_power);
		printk(KERN_ERR "%s:OJ	power	enable(%d)\n", __func__, on);
		}
	return 1;
}
Beispiel #3
0
static void curcial_oj_burst_read(uint8_t *data)
{
	uint8_t cmd[2];

	cmd[0] = 0x01;
	microp_i2c_write(OJ_REGISTER_BURST_REQUEST, cmd, 1);
	microp_i2c_read(OJ_REGISTER_BURST_READ, data, BURST_DATA_SIZE);
}
Beispiel #4
0
static int curcial_oj_poweron(int on)
{
	uint8_t data[2];

#ifdef CONFIG_MACH_BRAVO
	struct vreg *oj_power = vreg_get(0, "gp2");
	if (IS_ERR(oj_power)) {
		pr_err("%s: Error power domain\n", __func__);
		return 0;
	}

	if (on) {
		vreg_set_level(oj_power, 2750);
		vreg_enable(oj_power);
	} else {
		/* for microp firmware(v04) setting*/
		microp_i2c_read(MICROP_I2C_RCMD_VERSION, data, 2);
		if (data[0] < 4) {
			printk("Microp firmware version: %d\n", data[0]);
			return 1;
		}
		vreg_disable(oj_power);
	}
	pr_err("%s: OJ power enable(%d)\n", __func__, on);
#else
	/* for microp firmware(v04) setting*/
	if (on == 0) {
		microp_i2c_read(MICROP_I2C_RCMD_VERSION, data, 2);
		if (data[0] < 4) {
			printk("Microp firmware version:%d\n",data[0]);
			return 1;
		}
	}

	gpio_set_value(CURCIAL_OJ_POWER, on);

	if (gpio_get_value(CURCIAL_OJ_POWER) != on) {
		printk(KERN_ERR "%s:OJ:power status fail \n", __func__);
		return 0;
	}
	printk(KERN_ERR "%s:OJ:power status ok \n", __func__);
#endif
	return 1;
}
Beispiel #5
0
static uint8_t curcial_oj_register_read(uint8_t reg)
{
	uint8_t cmd[2];

	cmd[0] = 0;
	cmd[1] = reg;
	microp_i2c_write(OJ_REGISTER_REQUEST, cmd, 2);
	microp_i2c_read(OJ_REGISTER_READ, cmd, 2);

	return cmd[1];
}
static void gpio_event_check_func(struct work_struct *work)
{
	struct microp_input_state *ds =
		container_of(work, struct microp_input_state, work);
	uint8_t data[3];

	memset(data, 0x00, sizeof(uint8_t)*3);
	microp_i2c_read(MICROP_I2C_RCMD_AP_KEY_CODE, data, 2);

	report_key_event(ds, data[1]);
	wake_unlock(&gpio_microp_wake_lock);
}
Beispiel #7
0
static int curcial_oj_init(void)
{
	uint8_t data[BURST_DATA_SIZE];
	uint8_t id;
	uint8_t version;
	uint8_t i;

	microp_i2c_read(MICROP_I2C_RCMD_VERSION, data, 2);
	version = my_oj->microp_version;


	if (data[0] < version) {
		printk("Microp firmware version:%d have to large than %d !\n\
						Stop OJ driver loading!\n", data[0], version);
		return 0;
	}
static int check_microp_info(uint8_t info)
{
	int err = 0;
	uint8_t data[2];

	memset(data, 0x00, sizeof(uint8_t)*2);
	err = microp_i2c_read(MICROP_I2C_RCMD_VERSION, data, 2);
	if (err)
		return err;
	pr_info("%s: rev=0x%x proj=0x%x\n", __func__, data[0], data[1]);

	if (data[0] <= 0)
		return -EINVAL;
	if (data[1] != info)
		return -EINVAL;
	return err;
}
int lightsensor_read_value(uint32_t *val)
{
	int ret;
	uint8_t data[2];

	if (!val)
		return -EIO;

	ret = microp_i2c_read(MICROP_I2C_RCMD_LSENSOR, data, 2);
	if (ret < 0) 
	{
		pr_err("%s: read ls fail\n", __func__);
		return -EIO;
	}

	*val = data[1] | (data[0] << 8);
	D("lsensor adc = %u\n", *val);
	return 0;
}
int microp_get_remote_adc(uint32_t *val)
{
	int ret;
	uint8_t data[4];

	if (!val)
		return -EIO; 

	ret = microp_i2c_read(MICROP_I2C_RCMD_ADC_VALUE, data, 2);
	if (ret < 0) 
	{
		pr_err("%s: request adc fail\n", __func__);
		return -EIO;
	}

//	printk("%x %x\n", data[0], data[1]);
	*val = data[1] | (data[0] << 8);
	printk("remote adc %d\n", *val);
	return 0;
}
static int report_psensor_data(void)
{
	int ret, ps_data = 0;
	uint8_t data[3] = {0, 0, 0};
	D("%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;
		D("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;
}