De-duplicate VIA 586B I2C update code
This commit is contained in:
22
src/acpi.c
22
src/acpi.c
@@ -649,6 +649,16 @@ acpi_reg_write_via_common(int size, uint16_t addr, uint8_t val, void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
acpi_i2c_set(acpi_t *dev)
|
||||||
|
{
|
||||||
|
if (dev->i2c) {
|
||||||
|
/* Check direction as well due to pull-ups. */
|
||||||
|
i2c_gpio_set(dev->i2c, !(dev->regs.gpio_dir & 0x02) || (dev->regs.gpio_val & 0x02), !(dev->regs.gpio_dir & 0x04) || (dev->regs.gpio_val & 0x04));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
acpi_reg_write_via(int size, uint16_t addr, uint8_t val, void *p)
|
acpi_reg_write_via(int size, uint16_t addr, uint8_t val, void *p)
|
||||||
{
|
{
|
||||||
@@ -664,22 +674,14 @@ acpi_reg_write_via(int size, uint16_t addr, uint8_t val, void *p)
|
|||||||
/* GPIO Direction Control */
|
/* GPIO Direction Control */
|
||||||
if (size == 1) {
|
if (size == 1) {
|
||||||
dev->regs.gpio_dir = val & 0x7f;
|
dev->regs.gpio_dir = val & 0x7f;
|
||||||
|
acpi_i2c_set(dev);
|
||||||
if (dev->i2c) {
|
|
||||||
/* Check direction as well due to pull-ups. */
|
|
||||||
i2c_gpio_set(dev->i2c, !(dev->regs.gpio_dir & 0x02) || (dev->regs.gpio_val & 0x02), !(dev->regs.gpio_dir & 0x04) || (dev->regs.gpio_val & 0x04));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x42:
|
case 0x42:
|
||||||
/* GPIO port Output Value */
|
/* GPIO port Output Value */
|
||||||
if (size == 1) {
|
if (size == 1) {
|
||||||
dev->regs.gpio_val = val & 0x1f;
|
dev->regs.gpio_val = val & 0x1f;
|
||||||
|
acpi_i2c_set(dev);
|
||||||
if (dev->i2c) {
|
|
||||||
/* Check direction as well due to pull-ups. */
|
|
||||||
i2c_gpio_set(dev->i2c, !(dev->regs.gpio_dir & 0x02) || (dev->regs.gpio_val & 0x02), !(dev->regs.gpio_dir & 0x04) || (dev->regs.gpio_val & 0x04));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x46: case 0x47:
|
case 0x46: case 0x47:
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ gl518sm_log(const char *fmt, ...)
|
|||||||
static void
|
static void
|
||||||
gl518sm_remap(gl518sm_t *dev, uint8_t addr)
|
gl518sm_remap(gl518sm_t *dev, uint8_t addr)
|
||||||
{
|
{
|
||||||
gl518sm_log("GL518SM: remapping to I2C %02Xh\n", addr);
|
gl518sm_log("GL518SM: remapping to SMBus %02Xh\n", addr);
|
||||||
|
|
||||||
i2c_removehandler(i2c_smbus, dev->i2c_addr, 1, gl518sm_i2c_start, gl518sm_i2c_read, gl518sm_i2c_write, NULL, dev);
|
i2c_removehandler(i2c_smbus, dev->i2c_addr, 1, gl518sm_i2c_start, gl518sm_i2c_read, gl518sm_i2c_write, NULL, dev);
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ gl518sm_init(const device_t *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* GL518SM on I2C address 2Ch */
|
/* GL518SM on SMBus address 2Ch */
|
||||||
const device_t gl518sm_2c_device = {
|
const device_t gl518sm_2c_device = {
|
||||||
"Genesys Logic GL518SM Hardware Monitor",
|
"Genesys Logic GL518SM Hardware Monitor",
|
||||||
DEVICE_ISA,
|
DEVICE_ISA,
|
||||||
@@ -294,7 +294,7 @@ const device_t gl518sm_2c_device = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* GL518SM on I2C address 2Dh */
|
/* GL518SM on SMBus address 2Dh */
|
||||||
const device_t gl518sm_2d_device = {
|
const device_t gl518sm_2d_device = {
|
||||||
"Genesys Logic GL518SM Hardware Monitor",
|
"Genesys Logic GL518SM Hardware Monitor",
|
||||||
DEVICE_ISA,
|
DEVICE_ISA,
|
||||||
|
|||||||
Reference in New Issue
Block a user