diff --git a/src/drivers/i2c/tas5825m/Kconfig b/src/drivers/i2c/tas5825m/Kconfig new file mode 100644 index 0000000000..0deca1742c --- /dev/null +++ b/src/drivers/i2c/tas5825m/Kconfig @@ -0,0 +1,5 @@ +config DRIVERS_I2C_TAS5825M + bool + default n + help + Enable support for TI TAS5825M Amplifier. diff --git a/src/drivers/i2c/tas5825m/Makefile.inc b/src/drivers/i2c/tas5825m/Makefile.inc new file mode 100644 index 0000000000..909ffdb85c --- /dev/null +++ b/src/drivers/i2c/tas5825m/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_DRIVERS_I2C_TAS5825M) += tas5825m.c diff --git a/src/drivers/i2c/tas5825m/chip.h b/src/drivers/i2c/tas5825m/chip.h new file mode 100644 index 0000000000..f283f005cc --- /dev/null +++ b/src/drivers/i2c/tas5825m/chip.h @@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +struct drivers_i2c_tas5825m_config { + //TODO +}; diff --git a/src/drivers/i2c/tas5825m/tas5825m.c b/src/drivers/i2c/tas5825m/tas5825m.c new file mode 100644 index 0000000000..76b051cec6 --- /dev/null +++ b/src/drivers/i2c/tas5825m/tas5825m.c @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include +#include +#include "chip.h" + +static int tas5825m_setup(struct device *dev) { + struct drivers_i2c_tas5825m_config *config = dev->chip_info; + + if (!config) { + printk(BIOS_ERR, "tas5825m: failed to find config\n"); + return -1; + } + + //TODO: handle errors + int res; + #define R(F, E) { \ + res = F; \ + if (res < 0) { \ + printk(BIOS_ERR, "tas5825m: %s\n", E); \ + return res; \ + } \ + } + + // Set page to 0 + R(smbus_write_byte(dev, 0x00, 0x00), "failed to set page"); + + // Set book to 0 + R(smbus_write_byte(dev, 0x7F, 0x00), "failed to set book"); + + // Get DIE_ID + R(smbus_read_byte(dev, 0x67), "failed to read die id"); + printk(BIOS_DEBUG, "tas5825m: DIE_ID=%02X\n", res); + + #undef R + return 0; +} + +static void tas5825m_init(struct device *dev) { + if (dev->enabled && dev->path.type == DEVICE_PATH_I2C && + ops_smbus_bus(get_pbus_smbus(dev))) { + printk(BIOS_DEBUG, "tas5825m at %s\n", dev_path(dev)); + int res = tas5825m_setup(dev); + if (res) { + printk(BIOS_ERR, "tas5825m init failed: %d\n", res); + } else { + printk(BIOS_DEBUG, "tas5825m init successful\n"); + } + } +} + +static struct device_operations tas5825m_operations = { + .read_resources = noop_read_resources, + .set_resources = noop_set_resources, + .init = tas5825m_init, +}; + +static void tas5825m_enable_dev(struct device *dev) { + dev->ops = &tas5825m_operations; +} + +struct chip_operations drivers_i2c_tas5825m_ops = { + CHIP_NAME("TI TAS5825M Amplifier") + .enable_dev = tas5825m_enable_dev, +}; diff --git a/src/mainboard/system76/oryp6/Kconfig b/src/mainboard/system76/oryp6/Kconfig index e4d80e3a3e..7d3e09b8b5 100644 --- a/src/mainboard/system76/oryp6/Kconfig +++ b/src/mainboard/system76/oryp6/Kconfig @@ -4,6 +4,7 @@ config BOARD_SPECIFIC_OPTIONS def_bool y select BOARD_ROMSIZE_KB_16384 select DRIVERS_I2C_HID + select DRIVERS_I2C_TAS5825M select DRIVERS_SYSTEM76_EC select EC_ACPI select HAVE_ACPI_RESUME diff --git a/src/mainboard/system76/oryp6/devicetree.cb b/src/mainboard/system76/oryp6/devicetree.cb index ea8e0b4093..512c10bbc5 100644 --- a/src/mainboard/system76/oryp6/devicetree.cb +++ b/src/mainboard/system76/oryp6/devicetree.cb @@ -322,7 +322,11 @@ chip soc/intel/cannonlake device pci 1f.1 off end # P2SB device pci 1f.2 off end # Power Management Controller device pci 1f.3 on end # Intel HDA - device pci 1f.4 on end # SMBus + device pci 1f.4 on + chip drivers/i2c/tas5825m + device i2c 4e on end # (8bit address: 0x9c) + end # tas5825m + end # SMBus device pci 1f.5 on end # PCH SPI device pci 1f.6 off end # GbE end