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> *
21 #include "sch56xx-common.h"
30 #define SIO_UNLOCK_KEY 0x55 /* Key to enable Super-I/O */
31 #define SIO_LOCK_KEY 0xAA /* Key to disable Super-I/O */
82 return -EBUSY; in superio_enter()
109 * responds within 15-32 reads, so we first busy poll, and if in sch56xx_send_cmd()
116 /* (Optional) Write-Clear the EC to Host Mailbox Register */ in sch56xx_send_cmd()
120 /* Set Mailbox Address Pointer to first location in Region 1 */ in sch56xx_send_cmd()
126 outb(0x01, addr + 5); /* # of Entries: 1 Byte (8-bit) */ in sch56xx_send_cmd()
127 outb(0x04, addr + 2); /* Mailbox AP to first data entry loc. */ in sch56xx_send_cmd()
138 outb(0x01, addr); /* Write 01h to the Host-to-EC register */ in sch56xx_send_cmd()
156 return -EIO; in sch56xx_send_cmd()
164 /* Read EC-to-Host Register */ in sch56xx_send_cmd()
177 return -EIO; in sch56xx_send_cmd()
183 * Set Mailbox Address Pointer to first location in Region 1 * in sch56xx_send_cmd()
211 int lsb, msb; in sch56xx_read_virtual_reg16() local
213 /* Read LSB first, this will cause the matching MSB to be latched */ in sch56xx_read_virtual_reg16()
214 lsb = sch56xx_read_virtual_reg(addr, reg); in sch56xx_read_virtual_reg16()
215 if (lsb < 0) in sch56xx_read_virtual_reg16()
216 return lsb; in sch56xx_read_virtual_reg16()
222 return lsb | (msb << 8); in sch56xx_read_virtual_reg16()
231 /* Read MSB first, this will cause the matching LSN to be latched */ in sch56xx_read_virtual_reg12()
253 int lsb, msb, ret; in sch56xx_regmap_read16() local
256 ret = regmap_read(map, reg, &lsb); in sch56xx_regmap_read16()
264 *val = lsb | (msb << 8); in sch56xx_regmap_read16()
287 mutex_lock(bus->lock); in sch56xx_reg_write()
288 ret = sch56xx_write_virtual_reg(bus->addr, (u16)reg, (u8)val); in sch56xx_reg_write()
289 mutex_unlock(bus->lock); in sch56xx_reg_write()
299 mutex_lock(bus->lock); in sch56xx_reg_read()
300 ret = sch56xx_read_virtual_reg(bus->addr, (u16)reg); in sch56xx_reg_read()
301 mutex_unlock(bus->lock); in sch56xx_reg_read()
330 if (config->reg_bits != 16 && config->val_bits != 8) in devm_regmap_init_sch56xx()
331 return ERR_PTR(-EOPNOTSUPP); in devm_regmap_init_sch56xx()
335 return ERR_PTR(-ENOMEM); in devm_regmap_init_sch56xx()
337 context->lock = lock; in devm_regmap_init_sch56xx()
338 context->addr = addr; in devm_regmap_init_sch56xx()
367 return -EINVAL; in watchdog_set_timeout()
370 control = data->watchdog_control | SCH56XX_WDOG_TIME_BASE_SEC; in watchdog_set_timeout()
372 control = data->watchdog_control & ~SCH56XX_WDOG_TIME_BASE_SEC; in watchdog_set_timeout()
374 if (data->watchdog_control != control) { in watchdog_set_timeout()
375 mutex_lock(data->io_lock); in watchdog_set_timeout()
376 ret = sch56xx_write_virtual_reg(data->addr, in watchdog_set_timeout()
379 mutex_unlock(data->io_lock); in watchdog_set_timeout()
383 data->watchdog_control = control; in watchdog_set_timeout()
390 data->watchdog_preset = DIV_ROUND_UP(timeout, resolution); in watchdog_set_timeout()
391 wddev->timeout = data->watchdog_preset * resolution; in watchdog_set_timeout()
408 * of the second interrupt source register (at base-address + 9), in watchdog_start()
411 * This will only cause a system reset if the 0-1 flank happens when in watchdog_start()
418 * first! in watchdog_start()
421 mutex_lock(data->io_lock); in watchdog_start()
424 ret = sch56xx_write_virtual_reg(data->addr, SCH56XX_REG_WDOG_PRESET, in watchdog_start()
425 data->watchdog_preset); in watchdog_start()
430 val = data->watchdog_output_enable | SCH56XX_WDOG_OUTPUT_ENABLE; in watchdog_start()
431 ret = sch56xx_write_virtual_reg(data->addr, in watchdog_start()
436 data->watchdog_output_enable = val; in watchdog_start()
439 val = inb(data->addr + 9); in watchdog_start()
441 outb(0x01, data->addr + 9); in watchdog_start()
444 mutex_unlock(data->io_lock); in watchdog_start()
454 mutex_lock(data->io_lock); in watchdog_trigger()
455 ret = sch56xx_write_virtual_reg(data->addr, SCH56XX_REG_WDOG_PRESET, in watchdog_trigger()
456 data->watchdog_preset); in watchdog_trigger()
457 mutex_unlock(data->io_lock); in watchdog_trigger()
468 val = data->watchdog_output_enable & ~SCH56XX_WDOG_OUTPUT_ENABLE; in watchdog_stop()
469 mutex_lock(data->io_lock); in watchdog_stop()
470 ret = sch56xx_write_virtual_reg(data->addr, in watchdog_stop()
472 mutex_unlock(data->io_lock); in watchdog_stop()
476 data->watchdog_output_enable = val; in watchdog_stop()
515 data->addr = addr; in sch56xx_watchdog_register()
516 data->io_lock = io_lock; in sch56xx_watchdog_register()
518 strscpy(data->wdinfo.identity, "sch56xx watchdog", sizeof(data->wdinfo.identity)); in sch56xx_watchdog_register()
519 data->wdinfo.firmware_version = revision; in sch56xx_watchdog_register()
520 data->wdinfo.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT; in sch56xx_watchdog_register()
522 data->wdinfo.options |= WDIOF_MAGICCLOSE; in sch56xx_watchdog_register()
524 data->wddev.info = &data->wdinfo; in sch56xx_watchdog_register()
525 data->wddev.ops = &watchdog_ops; in sch56xx_watchdog_register()
526 data->wddev.parent = parent; in sch56xx_watchdog_register()
527 data->wddev.timeout = 60; in sch56xx_watchdog_register()
528 data->wddev.min_timeout = 1; in sch56xx_watchdog_register()
529 data->wddev.max_timeout = 255 * 60; in sch56xx_watchdog_register()
530 watchdog_set_nowayout(&data->wddev, nowayout); in sch56xx_watchdog_register()
532 set_bit(WDOG_HW_RUNNING, &data->wddev.status); in sch56xx_watchdog_register()
535 the BIOS set timeout from (if any was set at all) -> in sch56xx_watchdog_register()
538 data->watchdog_preset = 60; /* seconds */ in sch56xx_watchdog_register()
540 data->watchdog_preset = 1; /* minute */ in sch56xx_watchdog_register()
542 data->watchdog_control = control; in sch56xx_watchdog_register()
543 data->watchdog_output_enable = output_enable; in sch56xx_watchdog_register()
545 watchdog_set_drvdata(&data->wddev, data); in sch56xx_watchdog_register()
546 err = devm_watchdog_register_device(parent, &data->wddev); in sch56xx_watchdog_register()
579 err = -ENODEV; in sch56xx_find()
587 err = -ENODEV; in sch56xx_find()
599 err = -ENODEV; in sch56xx_find()
613 .end = address + REGION_LENGTH - 1, in sch56xx_device_add()
623 sch56xx_pdev = platform_device_register_simple(name, -1, &res, 1); in sch56xx_device_add()