Beispiel #1
0
static ssize_t rmi_f09_host_test_enable_store(struct device *dev,
					  struct device_attribute *attr,
					  const char *buf, size_t count)
{
	struct rmi_function_container *fc;
	struct rmi_fn_09_data *data;
	unsigned int new_value;
	int result;

	fc = to_rmi_function_container(dev);
	data = fc->data;
	if (sscanf(buf, "%u", &new_value) != 1) {
		dev_err(dev,
			"%s: Error - hostTestEnable has an invalid length.\n",
			__func__);
		return -EINVAL;
	}

	if (new_value < 0 || new_value > 1) {
		dev_err(dev, "%s: Invalid hostTestEnable bit %s.",
			__func__, buf);
		return -EINVAL;
	}
	data->query.host_test_enable = new_value;
	result = rmi_write(fc->rmi_dev, fc->fd.query_base_addr,
		data->query.host_test_enable);
	if (result < 0) {
		dev_err(dev, "%s: Could not write hostTestEnable to 0x%x\n",
				__func__, fc->fd.query_base_addr);
		return result;
	}

	return count;

}
Beispiel #2
0
static ssize_t rmi_f09_run_bist_store(struct device *dev,
				      struct device_attribute *attr,
					const char *buf, size_t count)
{
	struct rmi_function_container *fc;
	struct rmi_fn_09_data *data;
	unsigned int new_value;
	int result;

	fc = to_rmi_function_container(dev);
	data = fc->data;
	if (sscanf(buf, "%u", &new_value) != 1) {
		dev_err(dev,
		"%s: Error - run_bist_store has an "
		"invalid len.\n",
		__func__);
		return -EINVAL;
	}

	if (new_value < 0 || new_value > 1) {
		dev_err(dev, "%s: Invalid run_bist bit %s.", __func__, buf);
		return -EINVAL;
	}
	data->cmd.run_bist = new_value;
	result = rmi_write(fc->rmi_dev, fc->fd.command_base_addr,
		data->cmd.run_bist);
	if (result < 0) {
		dev_err(dev, "%s : Could not write run_bist_store to 0x%x\n",
				__func__, fc->fd.command_base_addr);
		return result;
	}

	return count;

}
Beispiel #3
0
static ssize_t f17_rezero_store(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf,
					 size_t count)
{
	struct rmi_function_container *fc;
	struct rmi_f17_device_data *data;
	unsigned int new_value;
	int len;

	fc = to_rmi_function_container(dev);
	data = fc->data;
	len = sscanf(buf, "%u", &new_value);
	if (new_value != 0 && new_value != 1) {
		dev_err(dev,
			"%s: Error - rezero is not a valid value 0x%x.\n",
			__func__, new_value);
		return -EINVAL;
	}
	data->commands.rezero = new_value;
	len = rmi_write(fc->rmi_dev, fc->fd.command_base_addr,
		data->commands.rezero);

	if (len < 0) {
		dev_err(dev, "%s : Could not write rezero to 0x%x\n",
				__func__, fc->fd.command_base_addr);
		return -EINVAL;
	}
	return count;
}
Beispiel #4
0
static ssize_t rmi_fn_21_rezero_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t count) {
	unsigned long val;
	int error, result;
	struct rmi_function_container *fc;
	struct rmi_fn_21_data *f21;
	struct rmi_driver *driver;
	u8 command;

	fc = to_rmi_function_container(dev);
	f21 = fc->data;
	driver = fc->rmi_dev->driver;

	/* need to convert the string data to an actual value */
	error = strict_strtoul(buf, 10, &val);
	if (error)
		return error;
	/* Do nothing if not set to 1. This prevents accidental commands. */
	if (val != 1)
		return count;

	command = (unsigned char)F21_REZERO_CMD;

	/* Write the command to the command register */
	result = rmi_write_block(fc->rmi_dev, fc->fd.command_base_addr,
						&command, 1);
	if (result < 0) {
		dev_err(dev, "%s : Could not write command to 0x%x\n",
				__func__, fc->fd.command_base_addr);
		return result;
	}
	return count;
}
Beispiel #5
0
static ssize_t  rmi_fn_05_no_auto_cal_store(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf, size_t count)
{
	struct f05_data *data = NULL;
	unsigned long new_value;
	int retval;
	struct rmi_function_container *fn_dev = to_rmi_function_container(dev);

	data = fn_dev->data;

	retval = strict_strtoul(buf, 10, &new_value);
	if (retval < 0 || new_value > 1) {
		dev_err(dev, "%s: Invalid no auto cal bit %s.", __func__, buf);
		return -EINVAL;
	}

	data->dev_control.no_auto_cal = new_value;
	retval = rmi_write_block(fn_dev->rmi_dev, fn_dev->fd.control_base_addr,
			(u8 *) &data->dev_control, sizeof(data->dev_control));
	if (retval >= 0)
		retval = count;
	else
		dev_err(dev, "Failed to write no auto cal bit, code: %d.\n",
			retval);
	return retval;
}
Beispiel #6
0
static ssize_t rmi_f09_control_test2_store(struct device *dev,
				      struct device_attribute *attr,
					const char *buf, size_t count)
{
	struct rmi_function_container *fc;
	struct rmi_fn_09_data *data;
	unsigned int new_low, new_high, new_diff;
	int result;

	fc = to_rmi_function_container(dev);
	data = fc->data;
	if (sscanf(buf, "%u %u %u", &new_low, &new_high, &new_diff) != 3) {
		dev_err(dev,
		"%s: Error - f09_control_test1_store has an "
		"invalid len.\n",
		__func__);
		return -EINVAL;
	}

	if (new_low < 0 || new_low > 1 || new_high < 0 || new_high > 1 ||
			new_diff < 0 || new_diff > 1) {
		dev_err(dev, "%s: Invalid f09_control_test2_diff bit %s.",
			__func__, buf);
		return -EINVAL;
	}
	data->control.test2_limit_low = new_low;
	data->control.test2_limit_high = new_high;
	data->control.test2_limit_diff = new_diff;
	result = rmi_write(fc->rmi_dev, fc->fd.control_base_addr,
		data->control.test2_limit_low);
	if (result < 0) {
		dev_err(dev, "%s : Could not write f09_control_test2_limit_low to 0x%x\n",
				__func__, fc->fd.control_base_addr);
		return result;
	}

	result = rmi_write(fc->rmi_dev, fc->fd.control_base_addr,
		data->control.test2_limit_high);
	if (result < 0) {
		dev_err(dev, "%s : Could not write f09_control_test2_limit_high to 0x%x\n",
				__func__, fc->fd.control_base_addr);
		return result;
	}

	result = rmi_write(fc->rmi_dev, fc->fd.control_base_addr,
		data->control.test2_limit_diff);
	if (result < 0) {
		dev_err(dev, "%s : Could not write f09_control_test2_limit_diff to 0x%x\n",
				__func__, fc->fd.control_base_addr);
		return result;
	}

	return count;

}
Beispiel #7
0
static ssize_t rmi_f09_overall_bist_result_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{
	struct rmi_function_container *fc;
	struct rmi_fn_09_data *data;

	fc = to_rmi_function_container(dev);
	data = fc->data;
	return snprintf(buf, PAGE_SIZE, "%u\n",
			data->data.overall_bist_result);
}
Beispiel #8
0
static ssize_t rmi_f09_internal_limits_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{
	struct rmi_function_container *fc;
	struct rmi_fn_09_data *data;

	fc = to_rmi_function_container(dev);
	data = fc->data;
	return snprintf(buf, PAGE_SIZE, "%u\n",
			data->query.internal_limits);
}
Beispiel #9
0
static ssize_t rmi_f09_test_number_control_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{
	struct rmi_function_container *fc;
	struct rmi_fn_09_data *data;

	fc = to_rmi_function_container(dev);
	data = fc->data;
	return snprintf(buf, PAGE_SIZE, "%u\n",
			data->data.test_number_control);
}
Beispiel #10
0
static ssize_t rmi_f09_status_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{
	struct rmi_function_container *fc;
	struct rmi_fn_09_data *instance_data;

	fc = to_rmi_function_container(dev);
	instance_data = fc->data;

	return snprintf(buf, PAGE_SIZE, "%d\n", instance_data->status);
}
Beispiel #11
0
static ssize_t  rmi_fn_05_no_auto_cal_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{
	struct f05_data *data = NULL;
	struct rmi_function_container *fn_dev = to_rmi_function_container(dev);

	data = fn_dev->data;

	return snprintf(buf, PAGE_SIZE,
			"%d\n", data->dev_control.no_auto_cal);
}
Beispiel #12
0
static ssize_t rmi_fn_05_image_window_size_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{
	struct f05_data *data = NULL;
	struct rmi_function_container *fn_dev = to_rmi_function_container(dev);

	data = fn_dev->data;

	return snprintf(buf, PAGE_SIZE, "%d\n",
		data->dev_query.size_f05_image_window);
}
Beispiel #13
0
static ssize_t rmi_fn_05_has_delta16_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{
	struct f05_data *data = NULL;
	struct rmi_function_container *fn_dev = to_rmi_function_container(dev);

	data = fn_dev->data;

	return snprintf(buf, PAGE_SIZE, "%d\n",
		data->dev_query.has16_bit_delta);
}
Beispiel #14
0
static ssize_t rmi_fn_05_num_of_tx_electrodes_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{
	struct f05_data *data = NULL;
	struct rmi_function_container *fn_dev = to_rmi_function_container(dev);

	data = fn_dev->data;

	return snprintf(buf, PAGE_SIZE, "0x%x\n",
		data->dev_query.num_of_tx_electrodes);
}
Beispiel #15
0
static ssize_t rmi_f09_control_test2_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{
	struct rmi_function_container *fc;
	struct rmi_fn_09_data *data;

	fc = to_rmi_function_container(dev);
	data = fc->data;
	return snprintf(buf, PAGE_SIZE, "%u %u %u\n",
			data->control.test2_limit_low,
			data->control.test2_limit_high,
			data->control.test2_limit_diff);
}
Beispiel #16
0
static ssize_t f17_rezero_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{
	struct rmi_function_container *fc;
	struct rmi_f17_device_data *f17;

	fc = to_rmi_function_container(dev);
	f17 = fc->data;

	return snprintf(buf, PAGE_SIZE, "%u\n",
			f17->commands.rezero);

}
Beispiel #17
0
static ssize_t rmi_f09_status_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	struct rmi_function_container *fc;
	struct rmi_fn_09_data *instance_data;

	fc = to_rmi_function_container(dev);
	instance_data = fc->data;

	/* any write to status resets 1 */
	instance_data->status = 0;

	return 0;
}
Beispiel #18
0
static __devinit int f05_probe(struct device *dev)
{
	struct rmi_function_container *fc;

	if (dev->type != &rmi_function_type) {
		dev_dbg(dev, "Not a function device.\n");
		return 1;
	}
	fc = to_rmi_function_container(dev);
	if (fc->fd.function_number != 0x05) {
		dev_dbg(dev, "Device is F%02X, not F%02X.\n",
			fc->fd.function_number, 0x05);
		return -ENXIO;
	}

	return rmi_f05_probe(fc);
}
Beispiel #19
0
/* Data */
static ssize_t rmi_fn_21_force_show(struct device *dev,
					struct device_attribute *attr,
					char *buf) {
	struct rmi_function_container *fc;
	struct FUNCTION_DATA *data;
	int reg_length;
	int result, size = 0;
	char *temp;
	int i;

	fc = to_rmi_function_container(dev);
	data = fc->data;

	/* Read current regtype values */
	reg_length = data->query.max_force_sensor_count;
	result = rmi_read_block(fc->rmi_dev, data->data.reg_0__1.address,
			data->data.reg_0__1.force_hi_lo,
			2 * reg_length * sizeof(u8));

	if (result < 0) {
		dev_err(dev, "Could not read regtype at %#06x. Data may be outdated.",
					data->data.reg_0__1.address);
	}
	temp = buf;
	for (i = 0; i < reg_length; i++) {
		result = snprintf(temp, PAGE_SIZE - size, "%d ",
			data->data.reg_0__1.force_hi_lo[i] * (2 << 3)
			+ data->data.reg_0__1.force_hi_lo[i + reg_length]);
		if (result < 0) {
			dev_err(dev, "%s : Could not write output.", __func__);
			return result;
		}
		size += result;
		temp += result;
	}
	result = snprintf(temp, PAGE_SIZE - size, "\n");
	if (result < 0) {
			dev_err(dev, "%s : Could not write output.", __func__);
			return result;
	}
	return size + result;
}
Beispiel #20
0
static int f05_remove_device(struct device *dev)
{
	struct rmi_function_container *fc = to_rmi_function_container(dev);

	return rmi_f05_remove(fc);
}