29 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31 #include <linux/module.h>
32 #include <linux/slab.h>
44 static unsigned short force_id;
50 #define DRVNAME "smsc47b397"
57 static inline void superio_outb(
int reg,
int val)
63 static inline int superio_inb(
int reg)
72 superio_outb(0x07, ld);
75 static inline void superio_enter(
void)
80 static inline void superio_exit(
void)
85 #define SUPERIO_REG_DEVID 0x20
86 #define SUPERIO_REG_DEVREV 0x21
87 #define SUPERIO_REG_BASE_MSB 0x60
88 #define SUPERIO_REG_BASE_LSB 0x61
89 #define SUPERIO_REG_LD8 0x08
91 #define SMSC_EXTENT 0x02
94 static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80};
95 #define SMSC47B397_REG_TEMP(nr) (smsc47b397_reg_temp[(nr)])
98 #define SMSC47B397_REG_FAN_LSB(nr) (0x28 + 2 * (nr))
99 #define SMSC47B397_REG_FAN_MSB(nr) (0x29 + 2 * (nr))
135 dev_dbg(dev,
"starting device update...\n");
138 for (i = 0; i < 4; i++) {
139 data->
temp[
i] = smsc47b397_read_value(data,
143 data->
fan[
i] = smsc47b397_read_value(data,
145 data->
fan[
i] |= smsc47b397_read_value(data,
152 dev_dbg(dev,
"... device update complete\n");
164 static int temp_from_reg(
u8 reg)
166 return (
s8)reg * 1000;
186 static int fan_from_reg(
u16 reg)
188 if (reg == 0 || reg == 0xffff)
190 return 90000 * 60 /
reg;
213 static struct attribute *smsc47b397_attributes[] = {
214 &sensor_dev_attr_temp1_input.dev_attr.attr,
215 &sensor_dev_attr_temp2_input.dev_attr.attr,
216 &sensor_dev_attr_temp3_input.dev_attr.attr,
217 &sensor_dev_attr_temp4_input.dev_attr.attr,
218 &sensor_dev_attr_fan1_input.dev_attr.attr,
219 &sensor_dev_attr_fan2_input.dev_attr.attr,
220 &sensor_dev_attr_fan3_input.dev_attr.attr,
221 &sensor_dev_attr_fan4_input.dev_attr.attr,
228 .attrs = smsc47b397_attributes,
248 .probe = smsc47b397_probe,
261 smsc47b397_driver.
driver.name)) {
262 dev_err(dev,
"Region 0x%lx-0x%lx already in use!\n",
263 (
unsigned long)res->
start,
273 data->
name =
"smsc47b397";
276 platform_set_drvdata(pdev, data);
295 static int __init smsc47b397_device_add(
unsigned short address)
312 pr_err(
"Device allocation failed\n");
318 pr_err(
"Device resource addition failed (%d)\n", err);
319 goto exit_device_put;
324 pr_err(
"Device addition failed (%d)\n", err);
325 goto exit_device_put;
336 static int __init smsc47b397_find(
void)
350 name =
"LPC47B397-NC";
367 pr_info(
"found SMSC %s (base address 0x%04x, revision %u)\n",
374 static int __init smsc47b397_init(
void)
379 ret = smsc47b397_find();
389 ret = smsc47b397_device_add(address);
401 static void __exit smsc47b397_exit(
void)