Lines Matching +full:lsb +full:- +full:first
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 */
76 return -EBUSY; in superio_enter()
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()
114 /* Set Mailbox Address Pointer to first location in Region 1 */ 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()
132 outb(0x01, addr); /* Write 01h to the Host-to-EC register */ in sch56xx_send_cmd()
150 return -EIO; in sch56xx_send_cmd()
158 /* Read EC-to-Host Register */ in sch56xx_send_cmd()
171 return -EIO; in sch56xx_send_cmd()
177 * Set Mailbox Address Pointer to first location in Region 1 * in sch56xx_send_cmd()
205 int lsb, msb; in sch56xx_read_virtual_reg16() local
207 /* Read LSB first, this will cause the matching MSB to be latched */ in sch56xx_read_virtual_reg16()
208 lsb = sch56xx_read_virtual_reg(addr, reg); in sch56xx_read_virtual_reg16()
209 if (lsb < 0) in sch56xx_read_virtual_reg16()
210 return lsb; in sch56xx_read_virtual_reg16()
216 return lsb | (msb << 8); in sch56xx_read_virtual_reg16()
225 /* Read MSB first, this will cause the matching LSN to be latched */ in sch56xx_read_virtual_reg12()
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()
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()
311 * first! 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()
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()
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()
408 data->addr = addr; in sch56xx_watchdog_register()
409 data->io_lock = io_lock; in sch56xx_watchdog_register()
411 strscpy(data->wdinfo.identity, "sch56xx watchdog", sizeof(data->wdinfo.identity)); in sch56xx_watchdog_register()
412 data->wdinfo.firmware_version = revision; in sch56xx_watchdog_register()
413 data->wdinfo.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT; in sch56xx_watchdog_register()
415 data->wdinfo.options |= WDIOF_MAGICCLOSE; in sch56xx_watchdog_register()
417 data->wddev.info = &data->wdinfo; in sch56xx_watchdog_register()
418 data->wddev.ops = &watchdog_ops; in sch56xx_watchdog_register()
419 data->wddev.parent = parent; in sch56xx_watchdog_register()
420 data->wddev.timeout = 60; in sch56xx_watchdog_register()
421 data->wddev.min_timeout = 1; in sch56xx_watchdog_register()
422 data->wddev.max_timeout = 255 * 60; in sch56xx_watchdog_register()
423 watchdog_set_nowayout(&data->wddev, nowayout); in sch56xx_watchdog_register()
425 set_bit(WDOG_HW_RUNNING, &data->wddev.status); in sch56xx_watchdog_register()
428 the BIOS set timeout from (if any was set at all) -> in sch56xx_watchdog_register()
431 data->watchdog_preset = 60; /* seconds */ in sch56xx_watchdog_register()
433 data->watchdog_preset = 1; /* minute */ in sch56xx_watchdog_register()
435 data->watchdog_control = control; in sch56xx_watchdog_register()
436 data->watchdog_output_enable = output_enable; in sch56xx_watchdog_register()
438 watchdog_set_drvdata(&data->wddev, data); in sch56xx_watchdog_register()
439 err = devm_watchdog_register_device(parent, &data->wddev); in sch56xx_watchdog_register()
472 err = -ENODEV; in sch56xx_find()
480 err = -ENODEV; in sch56xx_find()
492 err = -ENODEV; in sch56xx_find()
506 .end = address + REGION_LENGTH - 1, in sch56xx_device_add()
516 sch56xx_pdev = platform_device_register_simple(name, -1, &res, 1); in sch56xx_device_add()