diff options
Diffstat (limited to 'drivers/hwmon/nct6683.c')
| -rw-r--r-- | drivers/hwmon/nct6683.c | 70 |
1 files changed, 51 insertions, 19 deletions
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c index c0229152296f..6cda35388b24 100644 --- a/drivers/hwmon/nct6683.c +++ b/drivers/hwmon/nct6683.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* * nct6683 - Driver for the hardware monitoring functionality of - * Nuvoton NCT6683D eSIO + * Nuvoton NCT6683D/NCT6686D/NCT6687D eSIO * * Copyright (C) 2013 Guenter Roeck <linux@roeck-us.net> * @@ -12,6 +12,8 @@ * * Chip #vin #fan #pwm #temp chip ID * nct6683d 21(1) 16 8 32(1) 0xc730 + * nct6686d 21(1) 16 8 32(1) 0xd440 + * nct6687d 21(1) 16 8 32(1) 0xd590 * * Notes: * (1) Total number of vin and temp inputs is 32. @@ -32,7 +34,7 @@ #include <linux/platform_device.h> #include <linux/slab.h> -enum kinds { nct6683 }; +enum kinds { nct6683, nct6686, nct6687 }; static bool force; module_param(force, bool, 0); @@ -40,10 +42,14 @@ MODULE_PARM_DESC(force, "Set to one to enable support for unknown vendors"); static const char * const nct6683_device_names[] = { "nct6683", + "nct6686", + "nct6687", }; static const char * const nct6683_chip_names[] = { "NCT6683D", + "NCT6686D", + "NCT6687D", }; #define DRVNAME "nct6683" @@ -63,6 +69,8 @@ static const char * const nct6683_chip_names[] = { #define SIO_NCT6681_ID 0xb270 /* for later */ #define SIO_NCT6683_ID 0xc730 +#define SIO_NCT6686_ID 0xd440 +#define SIO_NCT6687_ID 0xd590 #define SIO_ID_MASK 0xFFF0 static inline void @@ -164,6 +172,15 @@ superio_exit(int ioreg) #define NCT6683_REG_CUSTOMER_ID 0x602 #define NCT6683_CUSTOMER_ID_INTEL 0x805 #define NCT6683_CUSTOMER_ID_MITAC 0xa0e +#define NCT6683_CUSTOMER_ID_MSI 0x201 +#define NCT6683_CUSTOMER_ID_MSI2 0x200 +#define NCT6683_CUSTOMER_ID_MSI3 0x207 +#define NCT6683_CUSTOMER_ID_MSI4 0x20d +#define NCT6683_CUSTOMER_ID_AMD 0x162b +#define NCT6683_CUSTOMER_ID_ASROCK 0xe2c +#define NCT6683_CUSTOMER_ID_ASROCK2 0xe1b +#define NCT6683_CUSTOMER_ID_ASROCK3 0x1631 +#define NCT6683_CUSTOMER_ID_ASROCK4 0x163e #define NCT6683_REG_BUILD_YEAR 0x604 #define NCT6683_REG_BUILD_MONTH 0x605 @@ -401,7 +418,7 @@ nct6683_create_attr_group(struct device *dev, struct sensor_device_attr_u *su; struct attribute_group *group; struct attribute **attrs; - int i, j, count; + int i, count; if (repeat <= 0) return ERR_PTR(-EINVAL); @@ -432,7 +449,7 @@ nct6683_create_attr_group(struct device *dev, for (i = 0; i < repeat; i++) { t = tg->templates; - for (j = 0; *t != NULL; j++) { + while (*t) { snprintf(su->name, sizeof(su->name), (*t)->dev_attr.attr.name, tg->base + i); if ((*t)->s2) { @@ -482,17 +499,6 @@ static inline long in_from_reg(u16 reg, u8 src) return reg * scale; } -static inline u16 in_to_reg(u32 val, u8 src) -{ - int scale = 16; - - if (src == MON_SRC_VCC || src == MON_SRC_VSB || src == MON_SRC_AVSB || - src == MON_SRC_VBAT) - scale <<= 1; - - return clamp_val(DIV_ROUND_CLOSEST(val, scale), 0, 127); -} - static u16 nct6683_read(struct nct6683_data *data, u16 reg) { int res; @@ -674,7 +680,7 @@ show_in_reg(struct device *dev, struct device_attribute *attr, char *buf) static umode_t nct6683_in_is_visible(struct kobject *kobj, struct attribute *attr, int index) { - struct device *dev = container_of(kobj, struct device, kobj); + struct device *dev = kobj_to_dev(kobj); struct nct6683_data *data = dev_get_drvdata(dev); int nr = index % 4; /* attribute */ @@ -739,7 +745,7 @@ show_fan_pulses(struct device *dev, struct device_attribute *attr, char *buf) static umode_t nct6683_fan_is_visible(struct kobject *kobj, struct attribute *attr, int index) { - struct device *dev = container_of(kobj, struct device, kobj); + struct device *dev = kobj_to_dev(kobj); struct nct6683_data *data = dev_get_drvdata(dev); int fan = index / 3; /* fan index */ int nr = index % 3; /* attribute index */ @@ -857,7 +863,7 @@ show_temp_type(struct device *dev, struct device_attribute *attr, char *buf) static umode_t nct6683_temp_is_visible(struct kobject *kobj, struct attribute *attr, int index) { - struct device *dev = container_of(kobj, struct device, kobj); + struct device *dev = kobj_to_dev(kobj); struct nct6683_data *data = dev_get_drvdata(dev); int temp = index / 7; /* temp index */ int nr = index % 7; /* attribute index */ @@ -944,7 +950,7 @@ SENSOR_TEMPLATE(pwm, "pwm%d", S_IRUGO, show_pwm, store_pwm, 0); static umode_t nct6683_pwm_is_visible(struct kobject *kobj, struct attribute *attr, int index) { - struct device *dev = container_of(kobj, struct device, kobj); + struct device *dev = kobj_to_dev(kobj); struct nct6683_data *data = dev_get_drvdata(dev); int pwm = index; /* pwm index */ @@ -1218,9 +1224,29 @@ static int nct6683_probe(struct platform_device *pdev) break; case NCT6683_CUSTOMER_ID_MITAC: break; + case NCT6683_CUSTOMER_ID_MSI: + break; + case NCT6683_CUSTOMER_ID_MSI2: + break; + case NCT6683_CUSTOMER_ID_MSI3: + break; + case NCT6683_CUSTOMER_ID_MSI4: + break; + case NCT6683_CUSTOMER_ID_AMD: + break; + case NCT6683_CUSTOMER_ID_ASROCK: + break; + case NCT6683_CUSTOMER_ID_ASROCK2: + break; + case NCT6683_CUSTOMER_ID_ASROCK3: + break; + case NCT6683_CUSTOMER_ID_ASROCK4: + break; default: if (!force) return -ENODEV; + dev_warn(dev, "Enabling support for unknown customer ID 0x%04x\n", data->customer_id); + break; } nct6683_init_device(data); @@ -1352,6 +1378,12 @@ static int __init nct6683_find(int sioaddr, struct nct6683_sio_data *sio_data) case SIO_NCT6683_ID: sio_data->kind = nct6683; break; + case SIO_NCT6686_ID: + sio_data->kind = nct6686; + break; + case SIO_NCT6687_ID: + sio_data->kind = nct6687; + break; default: if (val != 0xffff) pr_debug("unsupported chip ID: 0x%04x\n", val); |
