Karthikeyan Ramasubramanian | bf089d2a | 2020-10-07 12:42:44 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpi_device.h> |
| 4 | #include <acpi/acpigen.h> |
| 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
| 7 | #include <device/path.h> |
| 8 | #include <stdlib.h> |
| 9 | #include <string.h> |
| 10 | #include "chip.h" |
| 11 | |
| 12 | static const char *i2c_gpiomux_bus_acpi_name(const struct device *dev) |
| 13 | { |
| 14 | static char name[ACPI_NAME_BUFFER_SIZE]; |
| 15 | |
| 16 | snprintf(name, ACPI_NAME_BUFFER_SIZE, "MXA%01.1X", dev->path.generic.id); |
| 17 | return name; |
| 18 | } |
| 19 | |
| 20 | static void i2c_gpiomux_bus_fill_ssdt(const struct device *dev) |
| 21 | { |
| 22 | const char *scope = acpi_device_scope(dev); |
| 23 | const char *path = acpi_device_path(dev); |
| 24 | |
| 25 | if (!dev || !dev->enabled || !scope || !path) |
| 26 | return; |
| 27 | |
| 28 | /* Device */ |
| 29 | acpigen_write_scope(scope); |
| 30 | acpigen_write_device(acpi_device_name(dev)); |
| 31 | |
| 32 | acpigen_write_STA(acpi_device_status(dev)); |
| 33 | acpigen_write_ADR(dev->path.generic.id); |
| 34 | |
| 35 | acpigen_pop_len(); /* Device */ |
| 36 | acpigen_pop_len(); /* Scope */ |
| 37 | |
| 38 | printk(BIOS_INFO, "%s: %s at %s\n", path, dev->chip_ops->name, dev_path(dev)); |
| 39 | } |
| 40 | |
| 41 | static struct device_operations i2c_gpiomux_bus_ops = { |
| 42 | .read_resources = noop_read_resources, |
| 43 | .set_resources = noop_set_resources, |
| 44 | .scan_bus = scan_static_bus, |
| 45 | .acpi_name = i2c_gpiomux_bus_acpi_name, |
| 46 | .acpi_fill_ssdt = i2c_gpiomux_bus_fill_ssdt, |
| 47 | }; |
| 48 | |
| 49 | static void i2c_gpiomux_bus_enable(struct device *dev) |
| 50 | { |
| 51 | if (!dev) |
| 52 | return; |
| 53 | |
| 54 | dev->ops = &i2c_gpiomux_bus_ops; |
| 55 | } |
| 56 | |
| 57 | struct chip_operations drivers_i2c_gpiomux_bus_ops = { |
| 58 | CHIP_NAME("I2C GPIO MUX Bus Device") |
| 59 | .enable_dev = i2c_gpiomux_bus_enable |
| 60 | }; |