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> *
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 */
54 u16 addr; member
65 u16 addr; member
82 return -EBUSY; in superio_enter()
102 static int sch56xx_send_cmd(u16 addr, u8 cmd, u16 reg, u8 v) in sch56xx_send_cmd() argument
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()
117 val = inb(addr + 1); in sch56xx_send_cmd()
118 outb(val, addr + 1); in sch56xx_send_cmd()
121 outb(0x00, addr + 2); in sch56xx_send_cmd()
122 outb(0x80, addr + 3); in sch56xx_send_cmd()
125 outb(cmd, addr + 4); /* VREG Access Type read:0x02 write:0x03 */ 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()
131 outb(v, addr + 4); in sch56xx_send_cmd()
134 outb(reg & 0xff, addr + 6); in sch56xx_send_cmd()
135 outb(reg >> 8, addr + 7); in sch56xx_send_cmd()
138 outb(0x01, addr); /* Write 01h to the Host-to-EC register */ in sch56xx_send_cmd()
145 val = inb(addr + 8); in sch56xx_send_cmd()
148 outb(val, addr + 8); in sch56xx_send_cmd()
156 return -EIO; in sch56xx_send_cmd()
164 /* Read EC-to-Host Register */ in sch56xx_send_cmd()
165 val = inb(addr + 1); in sch56xx_send_cmd()
177 return -EIO; in sch56xx_send_cmd()
184 * outb(0x00, addr + 2); in sch56xx_send_cmd()
185 * outb(0x80, addr + 3); in sch56xx_send_cmd()
192 return inb(addr + 4); in sch56xx_send_cmd()
197 int sch56xx_read_virtual_reg(u16 addr, u16 reg) in sch56xx_read_virtual_reg() argument
199 return sch56xx_send_cmd(addr, SCH56XX_CMD_READ, reg, 0); in sch56xx_read_virtual_reg()
203 int sch56xx_write_virtual_reg(u16 addr, u16 reg, u8 val) in sch56xx_write_virtual_reg() argument
205 return sch56xx_send_cmd(addr, SCH56XX_CMD_WRITE, reg, val); in sch56xx_write_virtual_reg()
209 int sch56xx_read_virtual_reg16(u16 addr, u16 reg) in sch56xx_read_virtual_reg16() argument
214 lsb = sch56xx_read_virtual_reg(addr, reg); in sch56xx_read_virtual_reg16()
218 msb = sch56xx_read_virtual_reg(addr, reg + 1); in sch56xx_read_virtual_reg16()
226 int sch56xx_read_virtual_reg12(u16 addr, u16 msb_reg, u16 lsn_reg, in sch56xx_read_virtual_reg12() argument
232 msb = sch56xx_read_virtual_reg(addr, msb_reg); in sch56xx_read_virtual_reg12()
236 lsn = sch56xx_read_virtual_reg(addr, lsn_reg); in sch56xx_read_virtual_reg12()
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()
324 struct regmap *devm_regmap_init_sch56xx(struct device *dev, struct mutex *lock, u16 addr, in devm_regmap_init_sch56xx() argument
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()
355 struct sch56xx_watchdog_data *data = watchdog_get_drvdata(wddev); in watchdog_set_timeout() local
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()
398 struct sch56xx_watchdog_data *data = watchdog_get_drvdata(wddev); in watchdog_start() local
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()
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()
450 struct sch56xx_watchdog_data *data = watchdog_get_drvdata(wddev); in watchdog_trigger() local
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()
464 struct sch56xx_watchdog_data *data = watchdog_get_drvdata(wddev); in watchdog_stop() local
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()
488 void sch56xx_watchdog_register(struct device *parent, u16 addr, u32 revision, in sch56xx_watchdog_register() argument
491 struct sch56xx_watchdog_data *data; in sch56xx_watchdog_register() local
497 sch56xx_read_virtual_reg(addr, SCH56XX_REG_WDOG_CONTROL); in sch56xx_watchdog_register()
499 sch56xx_read_virtual_reg(addr, SCH56XX_REG_WDOG_OUTPUT_ENABLE); in sch56xx_watchdog_register()
511 data = devm_kzalloc(parent, sizeof(struct sch56xx_watchdog_data), GFP_KERNEL); in sch56xx_watchdog_register()
512 if (!data) in sch56xx_watchdog_register()
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()
549 devm_kfree(parent, data); 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()