ACPI EC SMBus driver

From: Armin Wolf
Date: Mon Apr 10 2023 - 17:18:34 EST


Hello,

i am currently trying to develop a full-featured i2c bus driver for ACPI EC SMBus controllers.
Currently, those are handled by the "sbshc" driver, which unfortunately does not register a i2c
bus driver. This would allow for replacing the outdated "sbs" and "sbshc" drivers with the standard
"sbs-battery", "sbs-manager", ... i2c drivers. Also, ACPI SMBus OpRegions for ACPI EC SMBus could
finally be supported.

While doing this, i stumbled upon a possible issue: the ACPI EC is accessed using ec_read(), which
could cause problems if multiple ACPI EC are present. This could be solved by somehow exposing
acpi_ec_read()/_write().

I am currently thinking of two options for doing this:
- expose them as-is and use dev->parent private drvdata (fragile)
- create a separate ec.h like this to hide internal driver details:

#ifndef __ACPI_EC_H
#define __ACPI_EC_H

void *acpi_get_parent_ec_cookie(struct acpi_device *adev);

int acpi_ec_read(void *cookie, u8 address, u8 *data);
int acpi_ec_write(void *cookie, u8 address, u8 data);

int acpi_ec_add_query_handler(void *cookie, u8 query, (void)(callback)(void *id), void *id);
void acpi_ec_remove_query_handler(void *cookie, u8 query, void *id);

#endif

Which one should i choose for developing the ACPI EC SMBus driver?

Thanks,
Armin Wolf