Пример #1
0
				void *hcpu)
{
	struct ina230_data *data = container_of(nb, struct ina230_data,
						nb);
	struct i2c_client *client = data->client;

	if (event == CPU_ONLINE || event == CPU_DEAD)
		evaluate_state(client);

	return 0;
}



static struct sensor_device_attribute ina230[] = {
	SENSOR_ATTR(rail_name, S_IRUGO, show_rail_name, NULL, 0),
	SENSOR_ATTR(current_threshold, S_IWUSR | S_IRUGO,
		    show_current_threshold, set_current_threshold, 0),
	SENSOR_ATTR(shuntvolt1_input, S_IRUGO, show_shunt_voltage, NULL, 0),
	SENSOR_ATTR(curr1_input, S_IRUGO, show_current, NULL, 0),
#if MEASURE_BUS_VOLT
	SENSOR_ATTR(in1_input, S_IRUGO, show_bus_voltage, NULL, 0),
#endif
	SENSOR_ATTR(power1_input, S_IRUGO, show_power, NULL, 0),
};


static int __devinit ina230_probe(struct i2c_client *client,
				const struct i2c_device_id *id)
{
	struct ina230_data *data;
    struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
    struct qpnp_iadc_chip *iadc = dev_get_drvdata(dev);
    struct qpnp_iadc_result result;
    int rc = -1;

    rc = qpnp_iadc_read(iadc, attr->index, &result);

    if (rc)
        return 0;

    return snprintf(buf, QPNP_ADC_HWMON_NAME_LENGTH,
                    "Result:%d\n", result.result_ua);
}

static struct sensor_device_attribute qpnp_adc_attr =
    SENSOR_ATTR(NULL, S_IRUGO, qpnp_iadc_show, NULL, 0);

static int32_t qpnp_iadc_init_hwmon(struct qpnp_iadc_chip *iadc,
                                    struct spmi_device *spmi)
{
    struct device_node *child;
    struct device_node *node = spmi->dev.of_node;
    int rc = 0, i = 0, channel;

    for_each_child_of_node(node, child) {
        channel = iadc->adc->adc_channels[i].channel_num;
        qpnp_adc_attr.index = iadc->adc->adc_channels[i].channel_num;
        qpnp_adc_attr.dev_attr.attr.name =
            iadc->adc->adc_channels[i].name;
        memcpy(&iadc->sens_attr[i], &qpnp_adc_attr,
               sizeof(qpnp_adc_attr));
Пример #3
0
	if (kstrtol(buf, 10, &val))
		return -EINVAL;

	if (val != 1) {
		dev_err(dev, "temp_reset_history value %ld not"
			" supported. Use 1 to reset the history!\n", val);
		return -EINVAL;
	}
	i2c_smbus_write_byte_data(to_i2c_client(dev),
		TMP411_TEMP_LOWEST_MSB[0], val);

	return count;
}

static struct sensor_device_attribute tmp401_attr[] = {
	SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_value, NULL, 0),
	SENSOR_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min,
		    store_temp_min, 0),
	SENSOR_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max,
		    store_temp_max, 0),
	SENSOR_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit,
		    store_temp_crit, 0),
	SENSOR_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_crit_hyst,
		    store_temp_crit_hyst, 0),
	SENSOR_ATTR(temp1_min_alarm, S_IRUGO, show_status, NULL,
		    TMP401_STATUS_LOCAL_LOW),
	SENSOR_ATTR(temp1_max_alarm, S_IRUGO, show_status, NULL,
		    TMP401_STATUS_LOCAL_HIGH),
	SENSOR_ATTR(temp1_crit_alarm, S_IRUGO, show_status, NULL,
		    TMP401_STATUS_LOCAL_CRIT),
	SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_value, NULL, 1),
Пример #4
0
			}
			data->mode = TRIGGERED;
		}
		mutex_unlock(&data->mutex);
		return 0;
	} else
		return 0;

error:
	mutex_unlock(&data->mutex);
	dev_err(&client->dev, "INA can't be turned off/on: 0x%x\n", ret);
	return 0;
}

static struct sensor_device_attribute ina3221[] = {
	SENSOR_ATTR(rail_name_0, S_IRUGO, show_rail_name, NULL, 0),
	SENSOR_ATTR(in1_input_0, S_IRUGO, show_voltage, NULL, 0),
	SENSOR_ATTR(curr1_input_0, S_IRUGO, show_current, NULL, 0),
	SENSOR_ATTR(power1_input_0, S_IRUGO, show_power, NULL, 0),
	SENSOR_ATTR(power2_input_0, S_IRUGO, show_power2, NULL, 0),
	SENSOR_ATTR(rail_name_1, S_IRUGO, show_rail_name, NULL, 1),
	SENSOR_ATTR(in1_input_1, S_IRUGO, show_voltage, NULL, 1),
	SENSOR_ATTR(curr1_input_1, S_IRUGO, show_current, NULL, 1),
	SENSOR_ATTR(power1_input_1, S_IRUGO, show_power, NULL, 1),
	SENSOR_ATTR(power2_input_1, S_IRUGO, show_power2, NULL, 1),
	SENSOR_ATTR(rail_name_2, S_IRUGO, show_rail_name, NULL, 2),
	SENSOR_ATTR(in1_input_2, S_IRUGO, show_voltage, NULL, 2),
	SENSOR_ATTR(curr1_input_2, S_IRUGO, show_current, NULL, 2),
	SENSOR_ATTR(power1_input_2, S_IRUGO, show_power, NULL, 2),
	SENSOR_ATTR(power2_input_2, S_IRUGO, show_power2, NULL, 2),
	SENSOR_ATTR(running_mode, S_IRUGO, show_mode, NULL, 0),
Пример #5
0
static ssize_t show_fan_alarm(struct device *dev, struct device_attribute
	*devattr, char *buf)
{
	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
	struct sch5636_data *data = sch5636_update_device(dev);
	int val;

	if (IS_ERR(data))
		return PTR_ERR(data);

	val = (data->fan_ctrl[attr->index] & SCH5636_FAN_ALARM) ? 1 : 0;
	return snprintf(buf, PAGE_SIZE, "%d\n", val);
}

static struct sensor_device_attribute sch5636_attr[] = {
	SENSOR_ATTR(name, 0444, show_name, NULL, 0),
	SENSOR_ATTR(in0_input, 0444, show_in_value, NULL, 0),
	SENSOR_ATTR(in0_label, 0444, show_in_label, NULL, 0),
	SENSOR_ATTR(in1_input, 0444, show_in_value, NULL, 1),
	SENSOR_ATTR(in1_label, 0444, show_in_label, NULL, 1),
	SENSOR_ATTR(in2_input, 0444, show_in_value, NULL, 2),
	SENSOR_ATTR(in2_label, 0444, show_in_label, NULL, 2),
	SENSOR_ATTR(in3_input, 0444, show_in_value, NULL, 3),
	SENSOR_ATTR(in3_label, 0444, show_in_label, NULL, 3),
	SENSOR_ATTR(in4_input, 0444, show_in_value, NULL, 4),
	SENSOR_ATTR(in4_label, 0444, show_in_label, NULL, 4),
};

static struct sensor_device_attribute sch5636_temp_attr[] = {
	SENSOR_ATTR(temp1_input, 0444, show_temp_value, NULL, 0),
	SENSOR_ATTR(temp1_fault, 0444, show_temp_fault, NULL, 0),
Пример #6
0
			struct device_attribute *da,
			const char *buf, size_t count)
{
	struct therm_estimator *est = dev_get_drvdata(dev);
	int tc2;

	if (kstrtoint(buf, 0, &tc2))
		return -EINVAL;

	est->tc2 = tc2;

	return count;
}

static struct sensor_device_attribute therm_est_nodes[] = {
	SENSOR_ATTR(coeff, S_IRUGO | S_IWUSR, show_coeff, set_coeff, 0),
	SENSOR_ATTR(offset, S_IRUGO | S_IWUSR, show_offset, set_offset, 0),
	SENSOR_ATTR(tc1, S_IRUGO | S_IWUSR, show_tc1, set_tc1, 0),
	SENSOR_ATTR(tc2, S_IRUGO | S_IWUSR, show_tc2, set_tc2, 0),
	SENSOR_ATTR(temps, S_IRUGO, show_temps, 0, 0),
};

static void therm_est_init_timer_trips(struct therm_estimator *est)
{
	int i;

	for (i = 0; i < est->num_timer_trips; i++)
		est->timer_trips[i].cur = TIMER_TRIP_INACTIVE;
}

static int therm_est_init_history(struct therm_estimator *est)
Пример #7
0
	return sprintf(buf, "%s\n", data->name);
}

static struct device_attribute f71805f_dev_attr[] = {
	__ATTR(in0_input, S_IRUGO, show_in0, NULL),
	__ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max),
	__ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min),
	__ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL),
	__ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL),
	__ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL),
	__ATTR(name, S_IRUGO, show_name, NULL),
};

static struct sensor_device_attribute f71805f_sensor_attr[] = {
	SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1),
	SENSOR_ATTR(in1_max, S_IRUGO | S_IWUSR,
		    show_in_max, set_in_max, 1),
	SENSOR_ATTR(in1_min, S_IRUGO | S_IWUSR,
		    show_in_min, set_in_min, 1),
	SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2),
	SENSOR_ATTR(in2_max, S_IRUGO | S_IWUSR,
		    show_in_max, set_in_max, 2),
	SENSOR_ATTR(in2_min, S_IRUGO | S_IWUSR,
		    show_in_min, set_in_min, 2),
	SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3),
	SENSOR_ATTR(in3_max, S_IRUGO | S_IWUSR,
		    show_in_max, set_in_max, 3),
	SENSOR_ATTR(in3_min, S_IRUGO | S_IWUSR,
		    show_in_min, set_in_min, 3),
	SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4),
Пример #8
0
			const char *buf, size_t count)
{
	long val;
	int err;

	if (kstrtol(buf, 10, &val))
		return -EINVAL;

	err = tmon_write_high_limit(to_i2c_client(dev), val, REMOTE);
	if (err)
		return err;
	return count;
}

static struct sensor_device_attribute tmp411_attr[] = {
	SENSOR_ATTR(local_temp, S_IRUGO, show_temp_value, NULL, 0),

	SENSOR_ATTR(remote_temp, S_IRUGO, show_temp_value, NULL, 1),

	SENSOR_ATTR(remote_temp_low_limit, S_IWUSR | S_IRUGO,
			show_remote_low_limit, store_remote_low_limit, 1),

	SENSOR_ATTR(remote_temp_high_limit, S_IWUSR | S_IRUGO,
			show_remote_high_limit, store_remote_high_limit, 1),

	SENSOR_ATTR(remote_temp_alert, S_IRUGO, show_alert, NULL,
			STATUS_REMOTE_LOW | STATUS_REMOTE_HIGH),

	SENSOR_ATTR(remote_temp_alert_blocking, S_IWUSR | S_IRUGO,
				show_alert_blocking, store_alert_block_timeout,
				STATUS_REMOTE_LOW | STATUS_REMOTE_HIGH),
Пример #9
0
	s32 data = i2c_smbus_read_word_data(client, 0);
	if (0 > data) {
		pr_err("%s: error %d reading reg\n",
		       __FILE__, data);
	} else {
		data = swab16(data);
	}
	if (pdata && pdata->denominator) {
		data = (data * pdata->numerator)/pdata->denominator;
	} else
		pr_err("%s: invalid platform data\n", __FILE__);
	return (data < 0) ? data : sprintf(buf, "%d\n", data);
}

static const struct sensor_device_attribute ads1000_attr =
	SENSOR_ATTR(mv, S_IRUGO, show, NULL, 0);

/*
 * Driver interface
 */
static int ads1000_remove(struct i2c_client *client)
{
	device_remove_file(&client->dev, &ads1000_attr.dev_attr);
	return 0;
}

static int ads1000_probe
	(struct i2c_client *client,
	 const struct i2c_device_id *id)
{
	int err = device_create_file(&client->dev, &ads1000_attr.dev_attr);