1a5b79d62Sstigge@antcom.de /* 2a5b79d62Sstigge@antcom.de * max6639.c - Support for Maxim MAX6639 3a5b79d62Sstigge@antcom.de * 4a5b79d62Sstigge@antcom.de * 2-Channel Temperature Monitor with Dual PWM Fan-Speed Controller 5a5b79d62Sstigge@antcom.de * 6a5b79d62Sstigge@antcom.de * Copyright (C) 2010, 2011 Roland Stigge <stigge@antcom.de> 7a5b79d62Sstigge@antcom.de * 8a5b79d62Sstigge@antcom.de * based on the initial MAX6639 support from semptian.net 9a5b79d62Sstigge@antcom.de * by He Changqing <hechangqing@semptian.com> 10a5b79d62Sstigge@antcom.de * 11a5b79d62Sstigge@antcom.de * This program is free software; you can redistribute it and/or modify 12a5b79d62Sstigge@antcom.de * it under the terms of the GNU General Public License as published by 13a5b79d62Sstigge@antcom.de * the Free Software Foundation; either version 2 of the License, or 14a5b79d62Sstigge@antcom.de * (at your option) any later version. 15a5b79d62Sstigge@antcom.de * 16a5b79d62Sstigge@antcom.de * This program is distributed in the hope that it will be useful, 17a5b79d62Sstigge@antcom.de * but WITHOUT ANY WARRANTY; without even the implied warranty of 18a5b79d62Sstigge@antcom.de * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19a5b79d62Sstigge@antcom.de * GNU General Public License for more details. 20a5b79d62Sstigge@antcom.de * 21a5b79d62Sstigge@antcom.de * You should have received a copy of the GNU General Public License 22a5b79d62Sstigge@antcom.de * along with this program; if not, write to the Free Software 23a5b79d62Sstigge@antcom.de * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24a5b79d62Sstigge@antcom.de */ 25a5b79d62Sstigge@antcom.de 26a5b79d62Sstigge@antcom.de #include <linux/module.h> 27a5b79d62Sstigge@antcom.de #include <linux/init.h> 28a5b79d62Sstigge@antcom.de #include <linux/slab.h> 29a5b79d62Sstigge@antcom.de #include <linux/jiffies.h> 30a5b79d62Sstigge@antcom.de #include <linux/i2c.h> 31a5b79d62Sstigge@antcom.de #include <linux/hwmon.h> 32a5b79d62Sstigge@antcom.de #include <linux/hwmon-sysfs.h> 33a5b79d62Sstigge@antcom.de #include <linux/err.h> 34a5b79d62Sstigge@antcom.de #include <linux/mutex.h> 35*0c9fe161SWolfram Sang #include <linux/platform_data/max6639.h> 36a5b79d62Sstigge@antcom.de 37a5b79d62Sstigge@antcom.de /* Addresses to scan */ 387edc8cc1SAxel Lin static const unsigned short normal_i2c[] = { 0x2c, 0x2e, 0x2f, I2C_CLIENT_END }; 39a5b79d62Sstigge@antcom.de 40a5b79d62Sstigge@antcom.de /* The MAX6639 registers, valid channel numbers: 0, 1 */ 41a5b79d62Sstigge@antcom.de #define MAX6639_REG_TEMP(ch) (0x00 + (ch)) 42a5b79d62Sstigge@antcom.de #define MAX6639_REG_STATUS 0x02 43a5b79d62Sstigge@antcom.de #define MAX6639_REG_OUTPUT_MASK 0x03 44a5b79d62Sstigge@antcom.de #define MAX6639_REG_GCONFIG 0x04 45a5b79d62Sstigge@antcom.de #define MAX6639_REG_TEMP_EXT(ch) (0x05 + (ch)) 46a5b79d62Sstigge@antcom.de #define MAX6639_REG_ALERT_LIMIT(ch) (0x08 + (ch)) 47a5b79d62Sstigge@antcom.de #define MAX6639_REG_OT_LIMIT(ch) (0x0A + (ch)) 48a5b79d62Sstigge@antcom.de #define MAX6639_REG_THERM_LIMIT(ch) (0x0C + (ch)) 49a5b79d62Sstigge@antcom.de #define MAX6639_REG_FAN_CONFIG1(ch) (0x10 + (ch) * 4) 50a5b79d62Sstigge@antcom.de #define MAX6639_REG_FAN_CONFIG2a(ch) (0x11 + (ch) * 4) 51a5b79d62Sstigge@antcom.de #define MAX6639_REG_FAN_CONFIG2b(ch) (0x12 + (ch) * 4) 52a5b79d62Sstigge@antcom.de #define MAX6639_REG_FAN_CONFIG3(ch) (0x13 + (ch) * 4) 53a5b79d62Sstigge@antcom.de #define MAX6639_REG_FAN_CNT(ch) (0x20 + (ch)) 54a5b79d62Sstigge@antcom.de #define MAX6639_REG_TARGET_CNT(ch) (0x22 + (ch)) 55a5b79d62Sstigge@antcom.de #define MAX6639_REG_FAN_PPR(ch) (0x24 + (ch)) 56a5b79d62Sstigge@antcom.de #define MAX6639_REG_TARGTDUTY(ch) (0x26 + (ch)) 57a5b79d62Sstigge@antcom.de #define MAX6639_REG_FAN_START_TEMP(ch) (0x28 + (ch)) 58a5b79d62Sstigge@antcom.de #define MAX6639_REG_DEVID 0x3D 59a5b79d62Sstigge@antcom.de #define MAX6639_REG_MANUID 0x3E 60a5b79d62Sstigge@antcom.de #define MAX6639_REG_DEVREV 0x3F 61a5b79d62Sstigge@antcom.de 62a5b79d62Sstigge@antcom.de /* Register bits */ 63a5b79d62Sstigge@antcom.de #define MAX6639_GCONFIG_STANDBY 0x80 64a5b79d62Sstigge@antcom.de #define MAX6639_GCONFIG_POR 0x40 65a5b79d62Sstigge@antcom.de #define MAX6639_GCONFIG_DISABLE_TIMEOUT 0x20 66a5b79d62Sstigge@antcom.de #define MAX6639_GCONFIG_CH2_LOCAL 0x10 67177f3b92Sstigge@antcom.de #define MAX6639_GCONFIG_PWM_FREQ_HI 0x08 68a5b79d62Sstigge@antcom.de 69a5b79d62Sstigge@antcom.de #define MAX6639_FAN_CONFIG1_PWM 0x80 70a5b79d62Sstigge@antcom.de 71177f3b92Sstigge@antcom.de #define MAX6639_FAN_CONFIG3_THERM_FULL_SPEED 0x40 72177f3b92Sstigge@antcom.de 73a5b79d62Sstigge@antcom.de static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; 74a5b79d62Sstigge@antcom.de 75b63d97a3SChris D Schimp #define FAN_FROM_REG(val, rpm_range) ((val) == 0 || (val) == 255 ? \ 76b63d97a3SChris D Schimp 0 : (rpm_ranges[rpm_range] * 30) / (val)) 772a844c14SGuenter Roeck #define TEMP_LIMIT_TO_REG(val) clamp_val((val) / 1000, 0, 255) 78a5b79d62Sstigge@antcom.de 79a5b79d62Sstigge@antcom.de /* 80a5b79d62Sstigge@antcom.de * Client data (each client gets its own) 81a5b79d62Sstigge@antcom.de */ 82a5b79d62Sstigge@antcom.de struct max6639_data { 837981c584SGuenter Roeck struct i2c_client *client; 84a5b79d62Sstigge@antcom.de struct mutex update_lock; 85a5b79d62Sstigge@antcom.de char valid; /* !=0 if following fields are valid */ 86a5b79d62Sstigge@antcom.de unsigned long last_updated; /* In jiffies */ 87a5b79d62Sstigge@antcom.de 88a5b79d62Sstigge@antcom.de /* Register values sampled regularly */ 89a5b79d62Sstigge@antcom.de u16 temp[2]; /* Temperature, in 1/8 C, 0..255 C */ 90a5b79d62Sstigge@antcom.de bool temp_fault[2]; /* Detected temperature diode failure */ 91a5b79d62Sstigge@antcom.de u8 fan[2]; /* Register value: TACH count for fans >=30 */ 92a5b79d62Sstigge@antcom.de u8 status; /* Detected channel alarms and fan failures */ 93a5b79d62Sstigge@antcom.de 94a5b79d62Sstigge@antcom.de /* Register values only written to */ 95a5b79d62Sstigge@antcom.de u8 pwm[2]; /* Register value: Duty cycle 0..120 */ 96a5b79d62Sstigge@antcom.de u8 temp_therm[2]; /* THERM Temperature, 0..255 C (->_max) */ 97a5b79d62Sstigge@antcom.de u8 temp_alert[2]; /* ALERT Temperature, 0..255 C (->_crit) */ 98a5b79d62Sstigge@antcom.de u8 temp_ot[2]; /* OT Temperature, 0..255 C (->_emergency) */ 99a5b79d62Sstigge@antcom.de 100a5b79d62Sstigge@antcom.de /* Register values initialized only once */ 101a5b79d62Sstigge@antcom.de u8 ppr; /* Pulses per rotation 0..3 for 1..4 ppr */ 102a5b79d62Sstigge@antcom.de u8 rpm_range; /* Index in above rpm_ranges table */ 103a5b79d62Sstigge@antcom.de }; 104a5b79d62Sstigge@antcom.de 105a5b79d62Sstigge@antcom.de static struct max6639_data *max6639_update_device(struct device *dev) 106a5b79d62Sstigge@antcom.de { 1077981c584SGuenter Roeck struct max6639_data *data = dev_get_drvdata(dev); 1087981c584SGuenter Roeck struct i2c_client *client = data->client; 109a5b79d62Sstigge@antcom.de struct max6639_data *ret = data; 110a5b79d62Sstigge@antcom.de int i; 111a5b79d62Sstigge@antcom.de int status_reg; 112a5b79d62Sstigge@antcom.de 113a5b79d62Sstigge@antcom.de mutex_lock(&data->update_lock); 114a5b79d62Sstigge@antcom.de 115a5b79d62Sstigge@antcom.de if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 116a5b79d62Sstigge@antcom.de int res; 117a5b79d62Sstigge@antcom.de 118a5b79d62Sstigge@antcom.de dev_dbg(&client->dev, "Starting max6639 update\n"); 119a5b79d62Sstigge@antcom.de 120a5b79d62Sstigge@antcom.de status_reg = i2c_smbus_read_byte_data(client, 121a5b79d62Sstigge@antcom.de MAX6639_REG_STATUS); 122a5b79d62Sstigge@antcom.de if (status_reg < 0) { 123a5b79d62Sstigge@antcom.de ret = ERR_PTR(status_reg); 124a5b79d62Sstigge@antcom.de goto abort; 125a5b79d62Sstigge@antcom.de } 126a5b79d62Sstigge@antcom.de 127a5b79d62Sstigge@antcom.de data->status = status_reg; 128a5b79d62Sstigge@antcom.de 129a5b79d62Sstigge@antcom.de for (i = 0; i < 2; i++) { 130a5b79d62Sstigge@antcom.de res = i2c_smbus_read_byte_data(client, 131a5b79d62Sstigge@antcom.de MAX6639_REG_FAN_CNT(i)); 132a5b79d62Sstigge@antcom.de if (res < 0) { 133a5b79d62Sstigge@antcom.de ret = ERR_PTR(res); 134a5b79d62Sstigge@antcom.de goto abort; 135a5b79d62Sstigge@antcom.de } 136a5b79d62Sstigge@antcom.de data->fan[i] = res; 137a5b79d62Sstigge@antcom.de 138a5b79d62Sstigge@antcom.de res = i2c_smbus_read_byte_data(client, 139a5b79d62Sstigge@antcom.de MAX6639_REG_TEMP_EXT(i)); 140a5b79d62Sstigge@antcom.de if (res < 0) { 141a5b79d62Sstigge@antcom.de ret = ERR_PTR(res); 142a5b79d62Sstigge@antcom.de goto abort; 143a5b79d62Sstigge@antcom.de } 144a5b79d62Sstigge@antcom.de data->temp[i] = res >> 5; 145a5b79d62Sstigge@antcom.de data->temp_fault[i] = res & 0x01; 146a5b79d62Sstigge@antcom.de 147a5b79d62Sstigge@antcom.de res = i2c_smbus_read_byte_data(client, 148a5b79d62Sstigge@antcom.de MAX6639_REG_TEMP(i)); 149a5b79d62Sstigge@antcom.de if (res < 0) { 150a5b79d62Sstigge@antcom.de ret = ERR_PTR(res); 151a5b79d62Sstigge@antcom.de goto abort; 152a5b79d62Sstigge@antcom.de } 153a5b79d62Sstigge@antcom.de data->temp[i] |= res << 3; 154a5b79d62Sstigge@antcom.de } 155a5b79d62Sstigge@antcom.de 156a5b79d62Sstigge@antcom.de data->last_updated = jiffies; 157a5b79d62Sstigge@antcom.de data->valid = 1; 158a5b79d62Sstigge@antcom.de } 159a5b79d62Sstigge@antcom.de abort: 160a5b79d62Sstigge@antcom.de mutex_unlock(&data->update_lock); 161a5b79d62Sstigge@antcom.de 162a5b79d62Sstigge@antcom.de return ret; 163a5b79d62Sstigge@antcom.de } 164a5b79d62Sstigge@antcom.de 165a5b79d62Sstigge@antcom.de static ssize_t show_temp_input(struct device *dev, 166a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, char *buf) 167a5b79d62Sstigge@antcom.de { 168a5b79d62Sstigge@antcom.de long temp; 169a5b79d62Sstigge@antcom.de struct max6639_data *data = max6639_update_device(dev); 170a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 171a5b79d62Sstigge@antcom.de 172a5b79d62Sstigge@antcom.de if (IS_ERR(data)) 173a5b79d62Sstigge@antcom.de return PTR_ERR(data); 174a5b79d62Sstigge@antcom.de 175a5b79d62Sstigge@antcom.de temp = data->temp[attr->index] * 125; 176a5b79d62Sstigge@antcom.de return sprintf(buf, "%ld\n", temp); 177a5b79d62Sstigge@antcom.de } 178a5b79d62Sstigge@antcom.de 179a5b79d62Sstigge@antcom.de static ssize_t show_temp_fault(struct device *dev, 180a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, char *buf) 181a5b79d62Sstigge@antcom.de { 182a5b79d62Sstigge@antcom.de struct max6639_data *data = max6639_update_device(dev); 183a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 184a5b79d62Sstigge@antcom.de 185a5b79d62Sstigge@antcom.de if (IS_ERR(data)) 186a5b79d62Sstigge@antcom.de return PTR_ERR(data); 187a5b79d62Sstigge@antcom.de 188a5b79d62Sstigge@antcom.de return sprintf(buf, "%d\n", data->temp_fault[attr->index]); 189a5b79d62Sstigge@antcom.de } 190a5b79d62Sstigge@antcom.de 191a5b79d62Sstigge@antcom.de static ssize_t show_temp_max(struct device *dev, 192a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, char *buf) 193a5b79d62Sstigge@antcom.de { 194a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 1957981c584SGuenter Roeck struct max6639_data *data = dev_get_drvdata(dev); 196a5b79d62Sstigge@antcom.de 197a5b79d62Sstigge@antcom.de return sprintf(buf, "%d\n", (data->temp_therm[attr->index] * 1000)); 198a5b79d62Sstigge@antcom.de } 199a5b79d62Sstigge@antcom.de 200a5b79d62Sstigge@antcom.de static ssize_t set_temp_max(struct device *dev, 201a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, 202a5b79d62Sstigge@antcom.de const char *buf, size_t count) 203a5b79d62Sstigge@antcom.de { 204a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 2057981c584SGuenter Roeck struct max6639_data *data = dev_get_drvdata(dev); 2067981c584SGuenter Roeck struct i2c_client *client = data->client; 207a5b79d62Sstigge@antcom.de unsigned long val; 208a5b79d62Sstigge@antcom.de int res; 209a5b79d62Sstigge@antcom.de 210179c4fdbSFrans Meulenbroeks res = kstrtoul(buf, 10, &val); 211a5b79d62Sstigge@antcom.de if (res) 212a5b79d62Sstigge@antcom.de return res; 213a5b79d62Sstigge@antcom.de 214a5b79d62Sstigge@antcom.de mutex_lock(&data->update_lock); 215a5b79d62Sstigge@antcom.de data->temp_therm[attr->index] = TEMP_LIMIT_TO_REG(val); 216a5b79d62Sstigge@antcom.de i2c_smbus_write_byte_data(client, 217a5b79d62Sstigge@antcom.de MAX6639_REG_THERM_LIMIT(attr->index), 218a5b79d62Sstigge@antcom.de data->temp_therm[attr->index]); 219a5b79d62Sstigge@antcom.de mutex_unlock(&data->update_lock); 220a5b79d62Sstigge@antcom.de return count; 221a5b79d62Sstigge@antcom.de } 222a5b79d62Sstigge@antcom.de 223a5b79d62Sstigge@antcom.de static ssize_t show_temp_crit(struct device *dev, 224a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, char *buf) 225a5b79d62Sstigge@antcom.de { 226a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 2277981c584SGuenter Roeck struct max6639_data *data = dev_get_drvdata(dev); 228a5b79d62Sstigge@antcom.de 229a5b79d62Sstigge@antcom.de return sprintf(buf, "%d\n", (data->temp_alert[attr->index] * 1000)); 230a5b79d62Sstigge@antcom.de } 231a5b79d62Sstigge@antcom.de 232a5b79d62Sstigge@antcom.de static ssize_t set_temp_crit(struct device *dev, 233a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, 234a5b79d62Sstigge@antcom.de const char *buf, size_t count) 235a5b79d62Sstigge@antcom.de { 236a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 2377981c584SGuenter Roeck struct max6639_data *data = dev_get_drvdata(dev); 2387981c584SGuenter Roeck struct i2c_client *client = data->client; 239a5b79d62Sstigge@antcom.de unsigned long val; 240a5b79d62Sstigge@antcom.de int res; 241a5b79d62Sstigge@antcom.de 242179c4fdbSFrans Meulenbroeks res = kstrtoul(buf, 10, &val); 243a5b79d62Sstigge@antcom.de if (res) 244a5b79d62Sstigge@antcom.de return res; 245a5b79d62Sstigge@antcom.de 246a5b79d62Sstigge@antcom.de mutex_lock(&data->update_lock); 247a5b79d62Sstigge@antcom.de data->temp_alert[attr->index] = TEMP_LIMIT_TO_REG(val); 248a5b79d62Sstigge@antcom.de i2c_smbus_write_byte_data(client, 249a5b79d62Sstigge@antcom.de MAX6639_REG_ALERT_LIMIT(attr->index), 250a5b79d62Sstigge@antcom.de data->temp_alert[attr->index]); 251a5b79d62Sstigge@antcom.de mutex_unlock(&data->update_lock); 252a5b79d62Sstigge@antcom.de return count; 253a5b79d62Sstigge@antcom.de } 254a5b79d62Sstigge@antcom.de 255a5b79d62Sstigge@antcom.de static ssize_t show_temp_emergency(struct device *dev, 256a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, 257a5b79d62Sstigge@antcom.de char *buf) 258a5b79d62Sstigge@antcom.de { 259a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 2607981c584SGuenter Roeck struct max6639_data *data = dev_get_drvdata(dev); 261a5b79d62Sstigge@antcom.de 262a5b79d62Sstigge@antcom.de return sprintf(buf, "%d\n", (data->temp_ot[attr->index] * 1000)); 263a5b79d62Sstigge@antcom.de } 264a5b79d62Sstigge@antcom.de 265a5b79d62Sstigge@antcom.de static ssize_t set_temp_emergency(struct device *dev, 266a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, 267a5b79d62Sstigge@antcom.de const char *buf, size_t count) 268a5b79d62Sstigge@antcom.de { 269a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 2707981c584SGuenter Roeck struct max6639_data *data = dev_get_drvdata(dev); 2717981c584SGuenter Roeck struct i2c_client *client = data->client; 272a5b79d62Sstigge@antcom.de unsigned long val; 273a5b79d62Sstigge@antcom.de int res; 274a5b79d62Sstigge@antcom.de 275179c4fdbSFrans Meulenbroeks res = kstrtoul(buf, 10, &val); 276a5b79d62Sstigge@antcom.de if (res) 277a5b79d62Sstigge@antcom.de return res; 278a5b79d62Sstigge@antcom.de 279a5b79d62Sstigge@antcom.de mutex_lock(&data->update_lock); 280a5b79d62Sstigge@antcom.de data->temp_ot[attr->index] = TEMP_LIMIT_TO_REG(val); 281a5b79d62Sstigge@antcom.de i2c_smbus_write_byte_data(client, 282a5b79d62Sstigge@antcom.de MAX6639_REG_OT_LIMIT(attr->index), 283a5b79d62Sstigge@antcom.de data->temp_ot[attr->index]); 284a5b79d62Sstigge@antcom.de mutex_unlock(&data->update_lock); 285a5b79d62Sstigge@antcom.de return count; 286a5b79d62Sstigge@antcom.de } 287a5b79d62Sstigge@antcom.de 288a5b79d62Sstigge@antcom.de static ssize_t show_pwm(struct device *dev, 289a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, char *buf) 290a5b79d62Sstigge@antcom.de { 291a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 2927981c584SGuenter Roeck struct max6639_data *data = dev_get_drvdata(dev); 293a5b79d62Sstigge@antcom.de 294a5b79d62Sstigge@antcom.de return sprintf(buf, "%d\n", data->pwm[attr->index] * 255 / 120); 295a5b79d62Sstigge@antcom.de } 296a5b79d62Sstigge@antcom.de 297a5b79d62Sstigge@antcom.de static ssize_t set_pwm(struct device *dev, 298a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, 299a5b79d62Sstigge@antcom.de const char *buf, size_t count) 300a5b79d62Sstigge@antcom.de { 301a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 3027981c584SGuenter Roeck struct max6639_data *data = dev_get_drvdata(dev); 3037981c584SGuenter Roeck struct i2c_client *client = data->client; 304a5b79d62Sstigge@antcom.de unsigned long val; 305a5b79d62Sstigge@antcom.de int res; 306a5b79d62Sstigge@antcom.de 307179c4fdbSFrans Meulenbroeks res = kstrtoul(buf, 10, &val); 308a5b79d62Sstigge@antcom.de if (res) 309a5b79d62Sstigge@antcom.de return res; 310a5b79d62Sstigge@antcom.de 3112a844c14SGuenter Roeck val = clamp_val(val, 0, 255); 312a5b79d62Sstigge@antcom.de 313a5b79d62Sstigge@antcom.de mutex_lock(&data->update_lock); 314a5b79d62Sstigge@antcom.de data->pwm[attr->index] = (u8)(val * 120 / 255); 315a5b79d62Sstigge@antcom.de i2c_smbus_write_byte_data(client, 316a5b79d62Sstigge@antcom.de MAX6639_REG_TARGTDUTY(attr->index), 317a5b79d62Sstigge@antcom.de data->pwm[attr->index]); 318a5b79d62Sstigge@antcom.de mutex_unlock(&data->update_lock); 319a5b79d62Sstigge@antcom.de return count; 320a5b79d62Sstigge@antcom.de } 321a5b79d62Sstigge@antcom.de 322a5b79d62Sstigge@antcom.de static ssize_t show_fan_input(struct device *dev, 323a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, char *buf) 324a5b79d62Sstigge@antcom.de { 325a5b79d62Sstigge@antcom.de struct max6639_data *data = max6639_update_device(dev); 326a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 327a5b79d62Sstigge@antcom.de 328a5b79d62Sstigge@antcom.de if (IS_ERR(data)) 329a5b79d62Sstigge@antcom.de return PTR_ERR(data); 330a5b79d62Sstigge@antcom.de 331a5b79d62Sstigge@antcom.de return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], 332b63d97a3SChris D Schimp data->rpm_range)); 333a5b79d62Sstigge@antcom.de } 334a5b79d62Sstigge@antcom.de 335a5b79d62Sstigge@antcom.de static ssize_t show_alarm(struct device *dev, 336a5b79d62Sstigge@antcom.de struct device_attribute *dev_attr, char *buf) 337a5b79d62Sstigge@antcom.de { 338a5b79d62Sstigge@antcom.de struct max6639_data *data = max6639_update_device(dev); 339a5b79d62Sstigge@antcom.de struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 340a5b79d62Sstigge@antcom.de 341a5b79d62Sstigge@antcom.de if (IS_ERR(data)) 342a5b79d62Sstigge@antcom.de return PTR_ERR(data); 343a5b79d62Sstigge@antcom.de 344a5b79d62Sstigge@antcom.de return sprintf(buf, "%d\n", !!(data->status & (1 << attr->index))); 345a5b79d62Sstigge@antcom.de } 346a5b79d62Sstigge@antcom.de 347a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0); 348a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1); 349a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0); 350a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1); 351a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, 352a5b79d62Sstigge@antcom.de set_temp_max, 0); 353a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, 354a5b79d62Sstigge@antcom.de set_temp_max, 1); 355a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit, 356a5b79d62Sstigge@antcom.de set_temp_crit, 0); 357a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit, 358a5b79d62Sstigge@antcom.de set_temp_crit, 1); 359a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp1_emergency, S_IWUSR | S_IRUGO, 360a5b79d62Sstigge@antcom.de show_temp_emergency, set_temp_emergency, 0); 361a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp2_emergency, S_IWUSR | S_IRUGO, 362a5b79d62Sstigge@antcom.de show_temp_emergency, set_temp_emergency, 1); 363a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); 364a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); 365a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0); 366a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1); 367a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_alarm, NULL, 1); 368a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_alarm, NULL, 0); 369a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 3); 370a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 2); 371a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 7); 372a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 6); 373a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp1_emergency_alarm, S_IRUGO, show_alarm, NULL, 5); 374a5b79d62Sstigge@antcom.de static SENSOR_DEVICE_ATTR(temp2_emergency_alarm, S_IRUGO, show_alarm, NULL, 4); 375a5b79d62Sstigge@antcom.de 376a5b79d62Sstigge@antcom.de 3777981c584SGuenter Roeck static struct attribute *max6639_attrs[] = { 378a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp1_input.dev_attr.attr, 379a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp2_input.dev_attr.attr, 380a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp1_fault.dev_attr.attr, 381a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp2_fault.dev_attr.attr, 382a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp1_max.dev_attr.attr, 383a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp2_max.dev_attr.attr, 384a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp1_crit.dev_attr.attr, 385a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp2_crit.dev_attr.attr, 386a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp1_emergency.dev_attr.attr, 387a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp2_emergency.dev_attr.attr, 388a5b79d62Sstigge@antcom.de &sensor_dev_attr_pwm1.dev_attr.attr, 389a5b79d62Sstigge@antcom.de &sensor_dev_attr_pwm2.dev_attr.attr, 390a5b79d62Sstigge@antcom.de &sensor_dev_attr_fan1_input.dev_attr.attr, 391a5b79d62Sstigge@antcom.de &sensor_dev_attr_fan2_input.dev_attr.attr, 392a5b79d62Sstigge@antcom.de &sensor_dev_attr_fan1_fault.dev_attr.attr, 393a5b79d62Sstigge@antcom.de &sensor_dev_attr_fan2_fault.dev_attr.attr, 394a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, 395a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, 396a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, 397a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, 398a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp1_emergency_alarm.dev_attr.attr, 399a5b79d62Sstigge@antcom.de &sensor_dev_attr_temp2_emergency_alarm.dev_attr.attr, 400a5b79d62Sstigge@antcom.de NULL 401a5b79d62Sstigge@antcom.de }; 4027981c584SGuenter Roeck ATTRIBUTE_GROUPS(max6639); 403a5b79d62Sstigge@antcom.de 404a5b79d62Sstigge@antcom.de /* 405a5b79d62Sstigge@antcom.de * returns respective index in rpm_ranges table 406a5b79d62Sstigge@antcom.de * 1 by default on invalid range 407a5b79d62Sstigge@antcom.de */ 408a5b79d62Sstigge@antcom.de static int rpm_range_to_reg(int range) 409a5b79d62Sstigge@antcom.de { 410a5b79d62Sstigge@antcom.de int i; 411a5b79d62Sstigge@antcom.de 412a5b79d62Sstigge@antcom.de for (i = 0; i < ARRAY_SIZE(rpm_ranges); i++) { 413a5b79d62Sstigge@antcom.de if (rpm_ranges[i] == range) 414a5b79d62Sstigge@antcom.de return i; 415a5b79d62Sstigge@antcom.de } 416a5b79d62Sstigge@antcom.de 417a5b79d62Sstigge@antcom.de return 1; /* default: 4000 RPM */ 418a5b79d62Sstigge@antcom.de } 419a5b79d62Sstigge@antcom.de 4207981c584SGuenter Roeck static int max6639_init_client(struct i2c_client *client, 4217981c584SGuenter Roeck struct max6639_data *data) 422a5b79d62Sstigge@antcom.de { 423a5b79d62Sstigge@antcom.de struct max6639_platform_data *max6639_info = 424a8b3a3a5SJingoo Han dev_get_platdata(&client->dev); 4252f2da1acSChris D Schimp int i; 426a5b79d62Sstigge@antcom.de int rpm_range = 1; /* default: 4000 RPM */ 4272f2da1acSChris D Schimp int err; 428a5b79d62Sstigge@antcom.de 429177f3b92Sstigge@antcom.de /* Reset chip to default values, see below for GCONFIG setup */ 430a5b79d62Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG, 431a5b79d62Sstigge@antcom.de MAX6639_GCONFIG_POR); 432a5b79d62Sstigge@antcom.de if (err) 433a5b79d62Sstigge@antcom.de goto exit; 434a5b79d62Sstigge@antcom.de 435a5b79d62Sstigge@antcom.de /* Fans pulse per revolution is 2 by default */ 436a5b79d62Sstigge@antcom.de if (max6639_info && max6639_info->ppr > 0 && 437a5b79d62Sstigge@antcom.de max6639_info->ppr < 5) 438a5b79d62Sstigge@antcom.de data->ppr = max6639_info->ppr; 439a5b79d62Sstigge@antcom.de else 440a5b79d62Sstigge@antcom.de data->ppr = 2; 441a5b79d62Sstigge@antcom.de data->ppr -= 1; 442a5b79d62Sstigge@antcom.de 443a5b79d62Sstigge@antcom.de if (max6639_info) 444a5b79d62Sstigge@antcom.de rpm_range = rpm_range_to_reg(max6639_info->rpm_range); 445a5b79d62Sstigge@antcom.de data->rpm_range = rpm_range; 446a5b79d62Sstigge@antcom.de 447a5b79d62Sstigge@antcom.de for (i = 0; i < 2; i++) { 448a5b79d62Sstigge@antcom.de 4492f2da1acSChris D Schimp /* Set Fan pulse per revolution */ 4502f2da1acSChris D Schimp err = i2c_smbus_write_byte_data(client, 4512f2da1acSChris D Schimp MAX6639_REG_FAN_PPR(i), 4522f2da1acSChris D Schimp data->ppr << 6); 4532f2da1acSChris D Schimp if (err) 4542f2da1acSChris D Schimp goto exit; 4552f2da1acSChris D Schimp 456a5b79d62Sstigge@antcom.de /* Fans config PWM, RPM */ 457a5b79d62Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, 458a5b79d62Sstigge@antcom.de MAX6639_REG_FAN_CONFIG1(i), 459a5b79d62Sstigge@antcom.de MAX6639_FAN_CONFIG1_PWM | rpm_range); 460a5b79d62Sstigge@antcom.de if (err) 461a5b79d62Sstigge@antcom.de goto exit; 462a5b79d62Sstigge@antcom.de 463a5b79d62Sstigge@antcom.de /* Fans PWM polarity high by default */ 464a5b79d62Sstigge@antcom.de if (max6639_info && max6639_info->pwm_polarity == 0) 465a5b79d62Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, 466a5b79d62Sstigge@antcom.de MAX6639_REG_FAN_CONFIG2a(i), 0x00); 467a5b79d62Sstigge@antcom.de else 468a5b79d62Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, 469a5b79d62Sstigge@antcom.de MAX6639_REG_FAN_CONFIG2a(i), 0x02); 470a5b79d62Sstigge@antcom.de if (err) 471a5b79d62Sstigge@antcom.de goto exit; 472a5b79d62Sstigge@antcom.de 473177f3b92Sstigge@antcom.de /* 474177f3b92Sstigge@antcom.de * /THERM full speed enable, 475177f3b92Sstigge@antcom.de * PWM frequency 25kHz, see also GCONFIG below 476177f3b92Sstigge@antcom.de */ 477177f3b92Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, 478177f3b92Sstigge@antcom.de MAX6639_REG_FAN_CONFIG3(i), 479177f3b92Sstigge@antcom.de MAX6639_FAN_CONFIG3_THERM_FULL_SPEED | 0x03); 480177f3b92Sstigge@antcom.de if (err) 481177f3b92Sstigge@antcom.de goto exit; 482177f3b92Sstigge@antcom.de 483a5b79d62Sstigge@antcom.de /* Max. temp. 80C/90C/100C */ 484a5b79d62Sstigge@antcom.de data->temp_therm[i] = 80; 485a5b79d62Sstigge@antcom.de data->temp_alert[i] = 90; 486a5b79d62Sstigge@antcom.de data->temp_ot[i] = 100; 487a5b79d62Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, 488a5b79d62Sstigge@antcom.de MAX6639_REG_THERM_LIMIT(i), 489a5b79d62Sstigge@antcom.de data->temp_therm[i]); 490a5b79d62Sstigge@antcom.de if (err) 491a5b79d62Sstigge@antcom.de goto exit; 492a5b79d62Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, 493a5b79d62Sstigge@antcom.de MAX6639_REG_ALERT_LIMIT(i), 494a5b79d62Sstigge@antcom.de data->temp_alert[i]); 495a5b79d62Sstigge@antcom.de if (err) 496a5b79d62Sstigge@antcom.de goto exit; 497a5b79d62Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, 498a5b79d62Sstigge@antcom.de MAX6639_REG_OT_LIMIT(i), data->temp_ot[i]); 499a5b79d62Sstigge@antcom.de if (err) 500a5b79d62Sstigge@antcom.de goto exit; 501a5b79d62Sstigge@antcom.de 502a5b79d62Sstigge@antcom.de /* PWM 120/120 (i.e. 100%) */ 503a5b79d62Sstigge@antcom.de data->pwm[i] = 120; 504a5b79d62Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, 505a5b79d62Sstigge@antcom.de MAX6639_REG_TARGTDUTY(i), data->pwm[i]); 506a5b79d62Sstigge@antcom.de if (err) 507a5b79d62Sstigge@antcom.de goto exit; 508a5b79d62Sstigge@antcom.de } 509a5b79d62Sstigge@antcom.de /* Start monitoring */ 510a5b79d62Sstigge@antcom.de err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG, 511177f3b92Sstigge@antcom.de MAX6639_GCONFIG_DISABLE_TIMEOUT | MAX6639_GCONFIG_CH2_LOCAL | 512177f3b92Sstigge@antcom.de MAX6639_GCONFIG_PWM_FREQ_HI); 513a5b79d62Sstigge@antcom.de exit: 514a5b79d62Sstigge@antcom.de return err; 515a5b79d62Sstigge@antcom.de } 516a5b79d62Sstigge@antcom.de 517a5b79d62Sstigge@antcom.de /* Return 0 if detection is successful, -ENODEV otherwise */ 518a5b79d62Sstigge@antcom.de static int max6639_detect(struct i2c_client *client, 519a5b79d62Sstigge@antcom.de struct i2c_board_info *info) 520a5b79d62Sstigge@antcom.de { 521a5b79d62Sstigge@antcom.de struct i2c_adapter *adapter = client->adapter; 522a5b79d62Sstigge@antcom.de int dev_id, manu_id; 523a5b79d62Sstigge@antcom.de 524a5b79d62Sstigge@antcom.de if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 525a5b79d62Sstigge@antcom.de return -ENODEV; 526a5b79d62Sstigge@antcom.de 527a5b79d62Sstigge@antcom.de /* Actual detection via device and manufacturer ID */ 528a5b79d62Sstigge@antcom.de dev_id = i2c_smbus_read_byte_data(client, MAX6639_REG_DEVID); 529a5b79d62Sstigge@antcom.de manu_id = i2c_smbus_read_byte_data(client, MAX6639_REG_MANUID); 530a5b79d62Sstigge@antcom.de if (dev_id != 0x58 || manu_id != 0x4D) 531a5b79d62Sstigge@antcom.de return -ENODEV; 532a5b79d62Sstigge@antcom.de 533a5b79d62Sstigge@antcom.de strlcpy(info->type, "max6639", I2C_NAME_SIZE); 534a5b79d62Sstigge@antcom.de 535a5b79d62Sstigge@antcom.de return 0; 536a5b79d62Sstigge@antcom.de } 537a5b79d62Sstigge@antcom.de 538a5b79d62Sstigge@antcom.de static int max6639_probe(struct i2c_client *client, 539a5b79d62Sstigge@antcom.de const struct i2c_device_id *id) 540a5b79d62Sstigge@antcom.de { 541c1ea0a04SGuenter Roeck struct device *dev = &client->dev; 542a5b79d62Sstigge@antcom.de struct max6639_data *data; 5437981c584SGuenter Roeck struct device *hwmon_dev; 544a5b79d62Sstigge@antcom.de int err; 545a5b79d62Sstigge@antcom.de 546c1ea0a04SGuenter Roeck data = devm_kzalloc(dev, sizeof(struct max6639_data), GFP_KERNEL); 547b07405fbSGuenter Roeck if (!data) 548b07405fbSGuenter Roeck return -ENOMEM; 549a5b79d62Sstigge@antcom.de 5507981c584SGuenter Roeck data->client = client; 551a5b79d62Sstigge@antcom.de mutex_init(&data->update_lock); 552a5b79d62Sstigge@antcom.de 553a5b79d62Sstigge@antcom.de /* Initialize the max6639 chip */ 5547981c584SGuenter Roeck err = max6639_init_client(client, data); 555a5b79d62Sstigge@antcom.de if (err < 0) 556b07405fbSGuenter Roeck return err; 557a5b79d62Sstigge@antcom.de 5587981c584SGuenter Roeck hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, 5597981c584SGuenter Roeck data, 5607981c584SGuenter Roeck max6639_groups); 5617981c584SGuenter Roeck return PTR_ERR_OR_ZERO(hwmon_dev); 562a5b79d62Sstigge@antcom.de } 563a5b79d62Sstigge@antcom.de 56452f30f77SMark Brown #ifdef CONFIG_PM_SLEEP 56552f30f77SMark Brown static int max6639_suspend(struct device *dev) 566a5b79d62Sstigge@antcom.de { 56752f30f77SMark Brown struct i2c_client *client = to_i2c_client(dev); 568a5b79d62Sstigge@antcom.de int data = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG); 569a5b79d62Sstigge@antcom.de if (data < 0) 570a5b79d62Sstigge@antcom.de return data; 571a5b79d62Sstigge@antcom.de 572a5b79d62Sstigge@antcom.de return i2c_smbus_write_byte_data(client, 573a5b79d62Sstigge@antcom.de MAX6639_REG_GCONFIG, data | MAX6639_GCONFIG_STANDBY); 574a5b79d62Sstigge@antcom.de } 575a5b79d62Sstigge@antcom.de 57652f30f77SMark Brown static int max6639_resume(struct device *dev) 577a5b79d62Sstigge@antcom.de { 57852f30f77SMark Brown struct i2c_client *client = to_i2c_client(dev); 579a5b79d62Sstigge@antcom.de int data = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG); 580a5b79d62Sstigge@antcom.de if (data < 0) 581a5b79d62Sstigge@antcom.de return data; 582a5b79d62Sstigge@antcom.de 583a5b79d62Sstigge@antcom.de return i2c_smbus_write_byte_data(client, 584a5b79d62Sstigge@antcom.de MAX6639_REG_GCONFIG, data & ~MAX6639_GCONFIG_STANDBY); 585a5b79d62Sstigge@antcom.de } 58652f30f77SMark Brown #endif /* CONFIG_PM_SLEEP */ 587a5b79d62Sstigge@antcom.de 588a5b79d62Sstigge@antcom.de static const struct i2c_device_id max6639_id[] = { 589a5b79d62Sstigge@antcom.de {"max6639", 0}, 590a5b79d62Sstigge@antcom.de { } 591a5b79d62Sstigge@antcom.de }; 592a5b79d62Sstigge@antcom.de 593a5b79d62Sstigge@antcom.de MODULE_DEVICE_TABLE(i2c, max6639_id); 594a5b79d62Sstigge@antcom.de 595768821a3SJingoo Han static SIMPLE_DEV_PM_OPS(max6639_pm_ops, max6639_suspend, max6639_resume); 59652f30f77SMark Brown 597a5b79d62Sstigge@antcom.de static struct i2c_driver max6639_driver = { 598a5b79d62Sstigge@antcom.de .class = I2C_CLASS_HWMON, 599a5b79d62Sstigge@antcom.de .driver = { 600a5b79d62Sstigge@antcom.de .name = "max6639", 60152f30f77SMark Brown .pm = &max6639_pm_ops, 602a5b79d62Sstigge@antcom.de }, 603a5b79d62Sstigge@antcom.de .probe = max6639_probe, 604a5b79d62Sstigge@antcom.de .id_table = max6639_id, 605a5b79d62Sstigge@antcom.de .detect = max6639_detect, 606a5b79d62Sstigge@antcom.de .address_list = normal_i2c, 607a5b79d62Sstigge@antcom.de }; 608a5b79d62Sstigge@antcom.de 609f0967eeaSAxel Lin module_i2c_driver(max6639_driver); 610a5b79d62Sstigge@antcom.de 611a5b79d62Sstigge@antcom.de MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>"); 612a5b79d62Sstigge@antcom.de MODULE_DESCRIPTION("max6639 driver"); 613a5b79d62Sstigge@antcom.de MODULE_LICENSE("GPL"); 614