Lines Matching +full:data +full:- +full:addr

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2010-2012 Hans de Goede <hdegoede@redhat.com> *
20 #include "sch56xx-common.h"
29 #define SIO_UNLOCK_KEY 0x55 /* Key to enable Super-I/O */
30 #define SIO_LOCK_KEY 0xAA /* Key to disable Super-I/O */
53 u16 addr; member
76 return -EBUSY; in superio_enter()
96 static int sch56xx_send_cmd(u16 addr, u8 cmd, u16 reg, u8 v) in sch56xx_send_cmd() argument
103 * responds within 15-32 reads, so we first busy poll, and if in sch56xx_send_cmd()
110 /* (Optional) Write-Clear the EC to Host Mailbox Register */ in sch56xx_send_cmd()
111 val = inb(addr + 1); in sch56xx_send_cmd()
112 outb(val, addr + 1); in sch56xx_send_cmd()
115 outb(0x00, addr + 2); in sch56xx_send_cmd()
116 outb(0x80, addr + 3); in sch56xx_send_cmd()
119 outb(cmd, addr + 4); /* VREG Access Type read:0x02 write:0x03 */ in sch56xx_send_cmd()
120 outb(0x01, addr + 5); /* # of Entries: 1 Byte (8-bit) */ in sch56xx_send_cmd()
121 outb(0x04, addr + 2); /* Mailbox AP to first data entry loc. */ in sch56xx_send_cmd()
125 outb(v, addr + 4); in sch56xx_send_cmd()
128 outb(reg & 0xff, addr + 6); in sch56xx_send_cmd()
129 outb(reg >> 8, addr + 7); in sch56xx_send_cmd()
132 outb(0x01, addr); /* Write 01h to the Host-to-EC register */ in sch56xx_send_cmd()
139 val = inb(addr + 8); in sch56xx_send_cmd()
142 outb(val, addr + 8); in sch56xx_send_cmd()
150 return -EIO; in sch56xx_send_cmd()
158 /* Read EC-to-Host Register */ in sch56xx_send_cmd()
159 val = inb(addr + 1); in sch56xx_send_cmd()
171 return -EIO; in sch56xx_send_cmd()
178 * outb(0x00, addr + 2); in sch56xx_send_cmd()
179 * outb(0x80, addr + 3); in sch56xx_send_cmd()
186 return inb(addr + 4); in sch56xx_send_cmd()
191 int sch56xx_read_virtual_reg(u16 addr, u16 reg) in sch56xx_read_virtual_reg() argument
193 return sch56xx_send_cmd(addr, SCH56XX_CMD_READ, reg, 0); in sch56xx_read_virtual_reg()
197 int sch56xx_write_virtual_reg(u16 addr, u16 reg, u8 val) in sch56xx_write_virtual_reg() argument
199 return sch56xx_send_cmd(addr, SCH56XX_CMD_WRITE, reg, val); in sch56xx_write_virtual_reg()
203 int sch56xx_read_virtual_reg16(u16 addr, u16 reg) in sch56xx_read_virtual_reg16() argument
208 lsb = sch56xx_read_virtual_reg(addr, reg); in sch56xx_read_virtual_reg16()
212 msb = sch56xx_read_virtual_reg(addr, reg + 1); in sch56xx_read_virtual_reg16()
220 int sch56xx_read_virtual_reg12(u16 addr, u16 msb_reg, u16 lsn_reg, in sch56xx_read_virtual_reg12() argument
226 msb = sch56xx_read_virtual_reg(addr, msb_reg); in sch56xx_read_virtual_reg12()
230 lsn = sch56xx_read_virtual_reg(addr, lsn_reg); in sch56xx_read_virtual_reg12()
248 struct sch56xx_watchdog_data *data = watchdog_get_drvdata(wddev); in watchdog_set_timeout() local
260 return -EINVAL; in watchdog_set_timeout()
263 control = data->watchdog_control | SCH56XX_WDOG_TIME_BASE_SEC; in watchdog_set_timeout()
265 control = data->watchdog_control & ~SCH56XX_WDOG_TIME_BASE_SEC; in watchdog_set_timeout()
267 if (data->watchdog_control != control) { in watchdog_set_timeout()
268 mutex_lock(data->io_lock); in watchdog_set_timeout()
269 ret = sch56xx_write_virtual_reg(data->addr, in watchdog_set_timeout()
272 mutex_unlock(data->io_lock); in watchdog_set_timeout()
276 data->watchdog_control = control; in watchdog_set_timeout()
283 data->watchdog_preset = DIV_ROUND_UP(timeout, resolution); in watchdog_set_timeout()
284 wddev->timeout = data->watchdog_preset * resolution; in watchdog_set_timeout()
291 struct sch56xx_watchdog_data *data = watchdog_get_drvdata(wddev); in watchdog_start() local
301 * of the second interrupt source register (at base-address + 9), in watchdog_start()
304 * This will only cause a system reset if the 0-1 flank happens when in watchdog_start()
314 mutex_lock(data->io_lock); in watchdog_start()
317 ret = sch56xx_write_virtual_reg(data->addr, SCH56XX_REG_WDOG_PRESET, in watchdog_start()
318 data->watchdog_preset); in watchdog_start()
323 val = data->watchdog_output_enable | SCH56XX_WDOG_OUTPUT_ENABLE; in watchdog_start()
324 ret = sch56xx_write_virtual_reg(data->addr, in watchdog_start()
329 data->watchdog_output_enable = val; in watchdog_start()
332 val = inb(data->addr + 9); in watchdog_start()
334 outb(0x01, data->addr + 9); in watchdog_start()
337 mutex_unlock(data->io_lock); in watchdog_start()
343 struct sch56xx_watchdog_data *data = watchdog_get_drvdata(wddev); in watchdog_trigger() local
347 mutex_lock(data->io_lock); in watchdog_trigger()
348 ret = sch56xx_write_virtual_reg(data->addr, SCH56XX_REG_WDOG_PRESET, in watchdog_trigger()
349 data->watchdog_preset); in watchdog_trigger()
350 mutex_unlock(data->io_lock); in watchdog_trigger()
357 struct sch56xx_watchdog_data *data = watchdog_get_drvdata(wddev); in watchdog_stop() local
361 val = data->watchdog_output_enable & ~SCH56XX_WDOG_OUTPUT_ENABLE; in watchdog_stop()
362 mutex_lock(data->io_lock); in watchdog_stop()
363 ret = sch56xx_write_virtual_reg(data->addr, in watchdog_stop()
365 mutex_unlock(data->io_lock); in watchdog_stop()
369 data->watchdog_output_enable = val; in watchdog_stop()
382 u16 addr, u32 revision, struct mutex *io_lock, int check_enabled) in sch56xx_watchdog_register() argument
384 struct sch56xx_watchdog_data *data; in sch56xx_watchdog_register() local
390 sch56xx_read_virtual_reg(addr, SCH56XX_REG_WDOG_CONTROL); in sch56xx_watchdog_register()
392 sch56xx_read_virtual_reg(addr, SCH56XX_REG_WDOG_OUTPUT_ENABLE); in sch56xx_watchdog_register()
404 data = kzalloc(sizeof(struct sch56xx_watchdog_data), GFP_KERNEL); in sch56xx_watchdog_register()
405 if (!data) in sch56xx_watchdog_register()
408 data->addr = addr; in sch56xx_watchdog_register()
409 data->io_lock = io_lock; in sch56xx_watchdog_register()
411 strlcpy(data->wdinfo.identity, "sch56xx watchdog", in sch56xx_watchdog_register()
412 sizeof(data->wdinfo.identity)); in sch56xx_watchdog_register()
413 data->wdinfo.firmware_version = revision; in sch56xx_watchdog_register()
414 data->wdinfo.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT; in sch56xx_watchdog_register()
416 data->wdinfo.options |= WDIOF_MAGICCLOSE; in sch56xx_watchdog_register()
418 data->wddev.info = &data->wdinfo; in sch56xx_watchdog_register()
419 data->wddev.ops = &watchdog_ops; in sch56xx_watchdog_register()
420 data->wddev.parent = parent; in sch56xx_watchdog_register()
421 data->wddev.timeout = 60; in sch56xx_watchdog_register()
422 data->wddev.min_timeout = 1; in sch56xx_watchdog_register()
423 data->wddev.max_timeout = 255 * 60; in sch56xx_watchdog_register()
425 set_bit(WDOG_NO_WAY_OUT, &data->wddev.status); in sch56xx_watchdog_register()
427 set_bit(WDOG_ACTIVE, &data->wddev.status); in sch56xx_watchdog_register()
430 the BIOS set timeout from (if any was set at all) -> in sch56xx_watchdog_register()
433 data->watchdog_preset = 60; /* seconds */ in sch56xx_watchdog_register()
435 data->watchdog_preset = 1; /* minute */ in sch56xx_watchdog_register()
437 data->watchdog_control = control; in sch56xx_watchdog_register()
438 data->watchdog_output_enable = output_enable; in sch56xx_watchdog_register()
440 watchdog_set_drvdata(&data->wddev, data); in sch56xx_watchdog_register()
441 err = watchdog_register_device(&data->wddev); in sch56xx_watchdog_register()
444 kfree(data); in sch56xx_watchdog_register()
448 return data; in sch56xx_watchdog_register()
452 void sch56xx_watchdog_unregister(struct sch56xx_watchdog_data *data) in sch56xx_watchdog_unregister() argument
454 watchdog_unregister_device(&data->wddev); in sch56xx_watchdog_unregister()
455 kfree(data); in sch56xx_watchdog_unregister()
484 err = -ENODEV; in sch56xx_find()
492 err = -ENODEV; in sch56xx_find()
504 err = -ENODEV; in sch56xx_find()
518 .end = address + REGION_LENGTH - 1, in sch56xx_device_add()
525 return -ENOMEM; in sch56xx_device_add()
527 res.name = sch56xx_pdev->name; in sch56xx_device_add()