Lines Matching refs:data
116 /* Used to tell uGuru what to read and to read the actual data */
175 /* For the Abit uGuru, we need to keep some data in memory.
180 struct mutex update_lock; /* protect access to data and uGuru */
198 /* Bank 1 data */
210 /* Bank 2 data, ABIT_UGURU_MAX_BANK2_SENSORS entries for bank2 */
224 static int abituguru_wait(struct abituguru_data *data, u8 state)
228 while (inb_p(data->addr + ABIT_UGURU_DATA) != state) {
241 static int abituguru_ready(struct abituguru_data *data)
245 if (data->uguru_ready)
249 outb(0x00, data->addr + ABIT_UGURU_DATA);
252 if (abituguru_wait(data, ABIT_UGURU_STATUS_READY)) {
259 while (inb_p(data->addr + ABIT_UGURU_CMD) != 0xAC) {
272 while (inb_p(data->addr + ABIT_UGURU_DATA) != ABIT_UGURU_STATUS_INPUT) {
282 data->uguru_ready = 1;
290 static int abituguru_send_address(struct abituguru_data *data,
300 if (abituguru_ready(data) != 0)
302 outb(bank_addr, data->addr + ABIT_UGURU_DATA);
303 data->uguru_ready = 0;
307 if (abituguru_wait(data, ABIT_UGURU_STATUS_INPUT)) {
323 outb(sensor_addr, data->addr + ABIT_UGURU_CMD);
330 static int abituguru_read(struct abituguru_data *data,
336 i = abituguru_send_address(data, bank_addr, sensor_addr, retries);
340 /* And read the data */
342 if (abituguru_wait(data, ABIT_UGURU_STATUS_READ)) {
349 buf[i] = inb(data->addr + ABIT_UGURU_CMD);
353 abituguru_ready(data);
360 static int abituguru_write(struct abituguru_data *data,
368 i = abituguru_send_address(data, bank_addr, sensor_addr,
373 /* And write the data */
375 if (abituguru_wait(data, ABIT_UGURU_STATUS_WRITE)) {
381 outb(buf[i], data->addr + ABIT_UGURU_CMD);
387 if (abituguru_wait(data, ABIT_UGURU_STATUS_READ)) {
395 while (inb_p(data->addr + ABIT_UGURU_CMD) != 0xAC) {
407 abituguru_ready(data);
419 abituguru_detect_bank1_sensor_type(struct abituguru_data *data,
435 if (abituguru_read(data, ABIT_UGURU_SENSOR_BANK1, sensor_addr, &val,
467 if (abituguru_write(data, ABIT_UGURU_SENSOR_BANK1 + 2, sensor_addr,
475 if (abituguru_read(data, ABIT_UGURU_ALARM_BANK, 0, buf, 3,
479 if (abituguru_read(data, ABIT_UGURU_SENSOR_BANK1 + 1,
500 if (abituguru_write(data, ABIT_UGURU_SENSOR_BANK1 + 2, sensor_addr,
508 if (abituguru_read(data, ABIT_UGURU_ALARM_BANK, 0, buf, 3,
512 if (abituguru_read(data, ABIT_UGURU_SENSOR_BANK1 + 1,
533 if (abituguru_write(data, ABIT_UGURU_SENSOR_BANK1 + 2,
534 sensor_addr, data->bank1_settings[sensor_addr],
565 abituguru_detect_no_bank2_sensors(struct abituguru_data *data)
570 data->bank2_sensors = fan_sensors;
573 (int)data->bank2_sensors);
585 if (data->bank2_settings[i][0] & ~0xC9) {
588 i, (unsigned int)data->bank2_settings[i][0]);
593 if (data->bank2_settings[i][1] <
598 (int)data->bank2_settings[i][1],
602 if (data->bank2_settings[i][1] >
607 (int)data->bank2_settings[i][1],
613 data->bank2_sensors = i;
615 (int)data->bank2_sensors);
619 abituguru_detect_no_pwms(struct abituguru_data *data)
624 data->pwms = pwms;
626 "\"pwms\" module param\n", (int)data->pwms);
635 if (data->pwm_settings[i][0] & ~0x8F) {
638 i, (unsigned int)data->pwm_settings[i][0]);
644 for (j = 0; j < data->bank1_sensors[ABIT_UGURU_TEMP_SENSOR];
646 if (data->bank1_address[ABIT_UGURU_TEMP_SENSOR][j] ==
647 (data->pwm_settings[i][0] & 0x0F))
650 if (j == data->bank1_sensors[ABIT_UGURU_TEMP_SENSOR]) {
654 data->pwm_settings[i][0] & 0x0F);
666 if (data->pwm_settings[i][j] < min) {
671 (int)data->pwm_settings[i][j],
675 if (data->pwm_settings[i][j] > abituguru_pwm_max[j]) {
680 (int)data->pwm_settings[i][j],
687 if (data->pwm_settings[i][1] >= data->pwm_settings[i][2]) {
691 (int)data->pwm_settings[i][1],
692 (int)data->pwm_settings[i][2]);
695 if (data->pwm_settings[i][3] >= data->pwm_settings[i][4]) {
699 (int)data->pwm_settings[i][3],
700 (int)data->pwm_settings[i][4]);
706 data->pwms = i;
707 ABIT_UGURU_DEBUG(2, " found: %d PWM outputs\n", (int)data->pwms);
719 struct abituguru_data *data = abituguru_update_device(dev);
720 if (!data)
722 return sprintf(buf, "%d\n", (data->bank1_value[attr->index] *
723 data->bank1_max_value[attr->index] + 128) / 255);
730 struct abituguru_data *data = dev_get_drvdata(dev);
732 (data->bank1_settings[attr->index][attr->nr] *
733 data->bank1_max_value[attr->index] + 128) / 255);
740 struct abituguru_data *data = abituguru_update_device(dev);
741 if (!data)
743 return sprintf(buf, "%d\n", (data->bank2_value[attr->index] *
751 struct abituguru_data *data = dev_get_drvdata(dev);
753 (data->bank2_settings[attr->index][attr->nr] *
761 struct abituguru_data *data = dev_get_drvdata(dev);
763 data->bank1_max_value[attr->index]/2) /
764 data->bank1_max_value[attr->index];
767 mutex_lock(&data->update_lock);
768 if (data->bank1_settings[attr->index][attr->nr] != val) {
769 u8 orig_val = data->bank1_settings[attr->index][attr->nr];
770 data->bank1_settings[attr->index][attr->nr] = val;
771 if (abituguru_write(data, ABIT_UGURU_SENSOR_BANK1 + 2,
772 attr->index, data->bank1_settings[attr->index],
774 data->bank1_settings[attr->index][attr->nr] = orig_val;
778 mutex_unlock(&data->update_lock);
786 struct abituguru_data *data = dev_get_drvdata(dev);
796 mutex_lock(&data->update_lock);
797 if (data->bank2_settings[attr->index][attr->nr] != val) {
798 u8 orig_val = data->bank2_settings[attr->index][attr->nr];
799 data->bank2_settings[attr->index][attr->nr] = val;
800 if (abituguru_write(data, ABIT_UGURU_SENSOR_BANK2 + 2,
801 attr->index, data->bank2_settings[attr->index],
803 data->bank2_settings[attr->index][attr->nr] = orig_val;
807 mutex_unlock(&data->update_lock);
815 struct abituguru_data *data = abituguru_update_device(dev);
816 if (!data)
823 if ((data->alarms[attr->index / 8] & (0x01 << (attr->index % 8))) &&
824 (data->bank1_settings[attr->index][0] & attr->nr))
834 struct abituguru_data *data = abituguru_update_device(dev);
835 if (!data)
837 if (data->alarms[2] & (0x01 << attr->index))
847 struct abituguru_data *data = dev_get_drvdata(dev);
848 if (data->bank1_settings[attr->index][0] & attr->nr)
858 struct abituguru_data *data = dev_get_drvdata(dev);
859 if (data->bank2_settings[attr->index][0] & attr->nr)
869 struct abituguru_data *data = dev_get_drvdata(dev);
874 mutex_lock(&data->update_lock);
875 orig_val = data->bank1_settings[attr->index][0];
878 data->bank1_settings[attr->index][0] |= attr->nr;
880 data->bank1_settings[attr->index][0] &= ~attr->nr;
882 if ((data->bank1_settings[attr->index][0] != orig_val) &&
883 (abituguru_write(data,
885 data->bank1_settings[attr->index], 3) < 1)) {
886 data->bank1_settings[attr->index][0] = orig_val;
889 mutex_unlock(&data->update_lock);
897 struct abituguru_data *data = dev_get_drvdata(dev);
902 mutex_lock(&data->update_lock);
903 orig_val = data->bank2_settings[attr->index][0];
906 data->bank2_settings[attr->index][0] |= attr->nr;
908 data->bank2_settings[attr->index][0] &= ~attr->nr;
910 if ((data->bank2_settings[attr->index][0] != orig_val) &&
911 (abituguru_write(data,
913 data->bank2_settings[attr->index], 2) < 1)) {
914 data->bank2_settings[attr->index][0] = orig_val;
917 mutex_unlock(&data->update_lock);
926 struct abituguru_data *data = dev_get_drvdata(dev);
927 return sprintf(buf, "%d\n", data->pwm_settings[attr->index][attr->nr] *
935 struct abituguru_data *data = dev_get_drvdata(dev);
951 mutex_lock(&data->update_lock);
954 (val >= data->pwm_settings[attr->index][attr->nr + 1]))
957 (val <= data->pwm_settings[attr->index][attr->nr - 1]))
959 else if (data->pwm_settings[attr->index][attr->nr] != val) {
960 u8 orig_val = data->pwm_settings[attr->index][attr->nr];
961 data->pwm_settings[attr->index][attr->nr] = val;
962 if (abituguru_write(data, ABIT_UGURU_FAN_PWM + 1,
963 attr->index, data->pwm_settings[attr->index],
965 data->pwm_settings[attr->index][attr->nr] =
970 mutex_unlock(&data->update_lock);
978 struct abituguru_data *data = dev_get_drvdata(dev);
982 for (i = 0; i < data->bank1_sensors[ABIT_UGURU_TEMP_SENSOR]; i++)
983 if (data->bank1_address[ABIT_UGURU_TEMP_SENSOR][i] ==
984 (data->pwm_settings[attr->index][0] & 0x0F))
994 struct abituguru_data *data = dev_get_drvdata(dev);
998 mutex_lock(&data->update_lock);
999 if (val < data->bank1_sensors[ABIT_UGURU_TEMP_SENSOR]) {
1000 u8 orig_val = data->pwm_settings[attr->index][0];
1001 u8 address = data->bank1_address[ABIT_UGURU_TEMP_SENSOR][val];
1002 data->pwm_settings[attr->index][0] &= 0xF0;
1003 data->pwm_settings[attr->index][0] |= address;
1004 if (data->pwm_settings[attr->index][0] != orig_val) {
1005 if (abituguru_write(data, ABIT_UGURU_FAN_PWM + 1,
1007 data->pwm_settings[attr->index],
1009 data->pwm_settings[attr->index][0] = orig_val;
1016 mutex_unlock(&data->update_lock);
1024 struct abituguru_data *data = dev_get_drvdata(dev);
1026 if (data->pwm_settings[attr->index][0] & ABIT_UGURU_FAN_PWM_ENABLE)
1035 struct abituguru_data *data = dev_get_drvdata(dev);
1039 mutex_lock(&data->update_lock);
1040 orig_val = data->pwm_settings[attr->index][0];
1043 data->pwm_settings[attr->index][0] &=
1047 data->pwm_settings[attr->index][0] |=
1053 if ((data->pwm_settings[attr->index][0] != orig_val) &&
1054 (abituguru_write(data, ABIT_UGURU_FAN_PWM + 1,
1055 attr->index, data->pwm_settings[attr->index],
1057 data->pwm_settings[attr->index][0] = orig_val;
1060 mutex_unlock(&data->update_lock);
1142 struct abituguru_data *data;
1152 if (!(data = kzalloc(sizeof(struct abituguru_data), GFP_KERNEL)))
1155 data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
1156 mutex_init(&data->update_lock);
1157 platform_set_drvdata(pdev, data);
1160 if (inb_p(data->addr + ABIT_UGURU_DATA) == ABIT_UGURU_STATUS_INPUT)
1161 data->uguru_ready = 1;
1166 if (abituguru_read(data, ABIT_UGURU_ALARM_BANK, 0,
1167 data->alarms, 3, ABIT_UGURU_MAX_RETRIES) != 3)
1171 if (abituguru_read(data, ABIT_UGURU_SENSOR_BANK1, i,
1172 &data->bank1_value[i], 1,
1175 if (abituguru_read(data, ABIT_UGURU_SENSOR_BANK1+1, i,
1176 data->bank1_settings[i], 3,
1186 if (abituguru_read(data, ABIT_UGURU_SENSOR_BANK2, i,
1187 &data->bank2_value[i], 1,
1190 if (abituguru_read(data, ABIT_UGURU_SENSOR_BANK2+1, i,
1191 data->bank2_settings[i], 2,
1196 if (abituguru_read(data, ABIT_UGURU_FAN_PWM, i,
1197 data->pwm_settings[i], 5,
1201 data->last_updated = jiffies;
1205 sysfs_filename = data->sysfs_names;
1208 res = abituguru_detect_bank1_sensor_type(data, probe_order[i]);
1218 attr.name, data->bank1_sensors[res] + res)
1220 data->sysfs_attr[sysfs_attr_i] =
1222 data->sysfs_attr[sysfs_attr_i].dev_attr.attr.name =
1224 data->sysfs_attr[sysfs_attr_i].index = probe_order[i];
1229 data->bank1_max_value[probe_order[i]] =
1231 data->bank1_address[res][data->bank1_sensors[res]] =
1233 data->bank1_sensors[res]++;
1236 abituguru_detect_no_bank2_sensors(data);
1237 for (i = 0; i < data->bank2_sensors; i++) {
1242 data->sysfs_attr[sysfs_attr_i] =
1244 data->sysfs_attr[sysfs_attr_i].dev_attr.attr.name =
1246 data->sysfs_attr[sysfs_attr_i].index = i;
1253 abituguru_detect_no_pwms(data);
1254 for (i = 0; i < data->pwms; i++) {
1259 data->sysfs_attr[sysfs_attr_i] =
1261 data->sysfs_attr[sysfs_attr_i].dev_attr.attr.name =
1263 data->sysfs_attr[sysfs_attr_i].index = i;
1283 &data->sysfs_attr[i].dev_attr))
1290 data->hwmon_dev = hwmon_device_register(&pdev->dev);
1291 if (!IS_ERR(data->hwmon_dev))
1294 res = PTR_ERR(data->hwmon_dev);
1296 for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++)
1297 device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr);
1302 kfree(data);
1309 struct abituguru_data *data = platform_get_drvdata(pdev);
1311 hwmon_device_unregister(data->hwmon_dev);
1312 for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++)
1313 device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr);
1318 kfree(data);
1326 struct abituguru_data *data = dev_get_drvdata(dev);
1330 mutex_lock(&data->update_lock);
1331 if (time_after(jiffies, data->last_updated + HZ)) {
1333 if ((err = abituguru_read(data, ABIT_UGURU_ALARM_BANK, 0,
1334 data->alarms, 3, 0)) != 3)
1337 if ((err = abituguru_read(data,
1339 &data->bank1_value[i], 1, 0)) != 1)
1341 if ((err = abituguru_read(data,
1343 data->bank1_settings[i], 3, 0)) != 3)
1346 for (i = 0; i < data->bank2_sensors; i++)
1347 if ((err = abituguru_read(data,
1349 &data->bank2_value[i], 1, 0)) != 1)
1353 data->update_timeouts = 0;
1358 if (data->update_timeouts < 255u)
1359 data->update_timeouts++;
1360 if (data->update_timeouts <= ABIT_UGURU_MAX_TIMEOUTS) {
1368 (int)data->update_timeouts);
1372 data->last_updated = jiffies;
1374 mutex_unlock(&data->update_lock);
1377 return data;
1385 struct abituguru_data *data = platform_get_drvdata(pdev);
1388 mutex_lock(&data->update_lock);
1394 struct abituguru_data *data = platform_get_drvdata(pdev);
1396 if (inb_p(data->addr + ABIT_UGURU_DATA) != ABIT_UGURU_STATUS_INPUT)
1397 data->uguru_ready = 0;
1398 mutex_unlock(&data->update_lock);
1431 ABIT_UGURU_DEBUG(2, "no Abit uGuru found, data = 0x%02X, cmd = "