diff options
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/sch5627.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/drivers/hwmon/sch5627.c b/drivers/hwmon/sch5627.c index 9a51dcca9b0d..d785a2c5431f 100644 --- a/drivers/hwmon/sch5627.c +++ b/drivers/hwmon/sch5627.c | |||
@@ -52,6 +52,9 @@ | |||
52 | #define SCH5627_COMPANY_ID 0x5c | 52 | #define SCH5627_COMPANY_ID 0x5c |
53 | #define SCH5627_PRIMARY_ID 0xa0 | 53 | #define SCH5627_PRIMARY_ID 0xa0 |
54 | 54 | ||
55 | #define SCH5627_CMD_READ 0x02 | ||
56 | #define SCH5627_CMD_WRITE 0x03 | ||
57 | |||
55 | #define SCH5627_REG_BUILD_CODE 0x39 | 58 | #define SCH5627_REG_BUILD_CODE 0x39 |
56 | #define SCH5627_REG_BUILD_ID 0x3a | 59 | #define SCH5627_REG_BUILD_ID 0x3a |
57 | #define SCH5627_REG_HWMON_ID 0x3c | 60 | #define SCH5627_REG_HWMON_ID 0x3c |
@@ -140,7 +143,7 @@ static inline void superio_exit(int base) | |||
140 | release_region(base, 2); | 143 | release_region(base, 2); |
141 | } | 144 | } |
142 | 145 | ||
143 | static int sch5627_read_virtual_reg(struct sch5627_data *data, u16 reg) | 146 | static int sch5627_send_cmd(struct sch5627_data *data, u8 cmd, u16 reg, u8 v) |
144 | { | 147 | { |
145 | u8 val; | 148 | u8 val; |
146 | int i; | 149 | int i; |
@@ -163,10 +166,14 @@ static int sch5627_read_virtual_reg(struct sch5627_data *data, u16 reg) | |||
163 | outb(0x80, data->addr + 3); | 166 | outb(0x80, data->addr + 3); |
164 | 167 | ||
165 | /* Write Request Packet Header */ | 168 | /* Write Request Packet Header */ |
166 | outb(0x02, data->addr + 4); /* Access Type: VREG read */ | 169 | outb(cmd, data->addr + 4); /* VREG Access Type read:0x02 write:0x03 */ |
167 | outb(0x01, data->addr + 5); /* # of Entries: 1 Byte (8-bit) */ | 170 | outb(0x01, data->addr + 5); /* # of Entries: 1 Byte (8-bit) */ |
168 | outb(0x04, data->addr + 2); /* Mailbox AP to first data entry loc. */ | 171 | outb(0x04, data->addr + 2); /* Mailbox AP to first data entry loc. */ |
169 | 172 | ||
173 | /* Write Value field */ | ||
174 | if (cmd == SCH5627_CMD_WRITE) | ||
175 | outb(v, data->addr + 4); | ||
176 | |||
170 | /* Write Address field */ | 177 | /* Write Address field */ |
171 | outb(reg & 0xff, data->addr + 6); | 178 | outb(reg & 0xff, data->addr + 6); |
172 | outb(reg >> 8, data->addr + 7); | 179 | outb(reg >> 8, data->addr + 7); |
@@ -224,8 +231,16 @@ static int sch5627_read_virtual_reg(struct sch5627_data *data, u16 reg) | |||
224 | * But if we do that things don't work, so let's not. | 231 | * But if we do that things don't work, so let's not. |
225 | */ | 232 | */ |
226 | 233 | ||
227 | /* Read Data from Mailbox */ | 234 | /* Read Value field */ |
228 | return inb(data->addr + 4); | 235 | if (cmd == SCH5627_CMD_READ) |
236 | return inb(data->addr + 4); | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | static int sch5627_read_virtual_reg(struct sch5627_data *data, u16 reg) | ||
242 | { | ||
243 | return sch5627_send_cmd(data, SCH5627_CMD_READ, reg, 0); | ||
229 | } | 244 | } |
230 | 245 | ||
231 | static int sch5627_read_virtual_reg16(struct sch5627_data *data, u16 reg) | 246 | static int sch5627_read_virtual_reg16(struct sch5627_data *data, u16 reg) |