| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <ec/google/chromeec/ec.h> |
| 5 |
#include <baseboard/variants.h> |
| 6 |
#include <variant/sku.h> |
| 7 |
#include <string.h> |
| 8 |
#include <drivers/i2c/hid/chip.h> |
| 9 |
|
| 10 |
#define RT58_I2C_ADDRESS 0x1a |
| 11 |
|
| 12 |
extern struct chip_operations drivers_i2c_generic_ops; |
| 13 |
extern struct chip_operations drivers_i2c_da7219_ops; |
| 14 |
|
| 15 |
void variant_devtree_update(void) |
| 16 |
{ |
| 17 |
struct device *mmio_dev = NULL, *child = NULL; |
| 18 |
struct device *alc_dev = NULL, *da7219_dev = NULL; |
| 19 |
|
| 20 |
do { |
| 21 |
mmio_dev = dev_find_path(mmio_dev, DEVICE_PATH_MMIO); |
| 22 |
if (!mmio_dev) { |
| 23 |
printk(BIOS_INFO, "Checking audio codec\n"); |
| 24 |
return; |
| 25 |
} |
| 26 |
} while (mmio_dev->path.mmio.addr != APU_I2C0_BASE); |
| 27 |
|
| 28 |
while ((child = dev_bus_each_child(mmio_dev->downstream, child)) != NULL) { |
| 29 |
if (child->path.type != DEVICE_PATH_I2C) |
| 30 |
continue; |
| 31 |
if (child->path.i2c.device != RT58_I2C_ADDRESS) |
| 32 |
continue; |
| 33 |
if (child->chip_ops == &drivers_i2c_generic_ops) { |
| 34 |
struct drivers_i2c_generic_config *config = child->chip_info; |
| 35 |
if (!strcmp(config->hid, "10EC5682")) |
| 36 |
alc_dev = child; |
| 37 |
} else if (child->chip_ops == &drivers_i2c_da7219_ops) { |
| 38 |
da7219_dev = child; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
switch (google_chromeec_get_sku_id()) { |
| 43 |
case SKU_TREEYA_ALC5682_AE: |
| 44 |
case SKU_TREEYA_ALC5682_AF: |
| 45 |
|
| 46 |
if (da7219_dev) |
| 47 |
da7219_dev->enabled = 0; |
| 48 |
if (alc_dev) |
| 49 |
alc_dev->enabled = 1; |
| 50 |
break; |
| 51 |
default: |
| 52 |
|
| 53 |
if (da7219_dev) |
| 54 |
da7219_dev->enabled = 1; |
| 55 |
if (alc_dev) |
| 56 |
alc_dev->enabled = 0; |
| 57 |
break; |
| 58 |
} |
| 59 |
} |