platform/x86: x86-android-tablets: Add support for Vexia EDU ATLA 10 tablet
v2 cover platform/x86: x86-android-tablets: Add support for Vexia EDU ATLA 10 tablet
Hi All,
Here is v2 of my patch series to add support for the Vexia EDU ATLA 10 tablet.
Changes in v2:
- Add get_i2c_adap_by_handle() and get_i2c_adap_by_pci_parent() helpers as suggested by Andy
Regards,
Hans
Hans de Goede (3):
platform/x86: x86-android-tablets: Add get_i2c_adap_by_handle() helper platform/x86: x86-android-tablets: Add support for getting i2c_adapter
by PCI parent devname()
platform/x86: x86-android-tablets: Add support for Vexia EDU ATLA 10
tablet
.../platform/x86/x86-android-tablets/Kconfig | 1 + .../platform/x86/x86-android-tablets/core.c | 60 ++++++- .../platform/x86/x86-android-tablets/dmi.c | 20 +++ .../platform/x86/x86-android-tablets/other.c | 165 ++++++++++++++++++ .../x86-android-tablets/x86-android-tablets.h | 2 + 5 files changed, 239 insertions(+), 9 deletions(-)
Signature · 1 line
2.47.0
PATCH v2 1/3 platform/x86: x86-android-tablets: Add get_i2c_adap_by_handle() helper
Add get_i2c_adap_by_handle() helper function, this is a preparation patch for adding support for getting i2c_adapter-s by PCI parent devname().
---
Changes in v2:
- New patch in v2 of this series
--- .../platform/x86/x86-android-tablets/core.c | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/platform/x86/x86-android-tablets/core.c +16 -9
@@ -155,26 +155,33 @@ static struct gpiod_lookup_table * const *gpiod_lookup_tables;static const struct software_node *bat_swnode;static void (*exit_handler)(void ); +static struct i2c_adapter * +get_i2c_adap_by_handle (const struct x86_i2c_client_info *client_info) +{ +acpi_handle handle; +acpi_status status; + + status =acpi_get_handle (NULL , client_info->adapter_path, &handle); +if (ACPI_FAILURE (status)) { +pr_err ("Error could not get %s handle\n" , client_info->adapter_path); +return NULL ; + } + +return i2c_acpi_find_adapter_by_handle (handle); +} +static __init int x86_instantiate_i2c_client (const struct x86_dev_info *dev_info,int idx) {const struct x86_i2c_client_info *client_info = &dev_info->i2c_client_info[idx];struct i2c_board_info board_info = client_info->board_info;struct i2c_adapter *adap; -acpi_handle handle; -acpi_status status; board_info.irq =x86_acpi_irq_helper_get (&client_info->irq_data);if (board_info.irq <0 )return board_info.irq; - status =acpi_get_handle (NULL , client_info->adapter_path, &handle); -if (ACPI_FAILURE (status)) { -pr_err ("Error could not get %s handle\n" , client_info->adapter_path); -return -ENODEV ; - } - - adap =i2c_acpi_find_adapter_by_handle (handle); + adap =get_i2c_adap_by_handle (client_info);if (!adap) {pr_err ("error could not get %s adapter\n" , client_info->adapter_path);return -ENODEV ;
Signature · 1 line
2.47.0
Re: [PATCH v2 1/3] platform/x86: x86-android-tablets: Add get_i2c_adap_by_handle() helper
Quoted 3 lines · Hans de Goede
Add
get_i2c_adap_by_handle()helper function, this is a preparation patch for adding support for getting i2c_adapter-s by PCI parentdevname().
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 1/3] platform/x86: x86-android-tablets: Add get_i2c_adap_by_handle() helper
In reply to Hans de GoedeQuoted 49 lines · Hans de Goede
Add
get_i2c_adap_by_handle()helper function, this is a preparation patch for adding support for getting i2c_adapter-s by PCI parentdevname().Suggested-by Andy Shevchenko <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:
- New patch in v2 of this series--- .../platform/x86/x86-android-tablets/core.c | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-)drivers/platform/x86/x86-android-tablets/core.c +15
-3@@ -155,26 +155,33 @@ static struct gpiod_lookup_table * const *gpiod_lookup_tables;static const struct software_node *bat_swnode;static void (*exit_handler)(void ); +static struct i2c_adapter * +get_i2c_adap_by_handle (const struct x86_i2c_client_info *client_info) +{ +acpi_handle handle; +acpi_status status; + + status =acpi_get_handle (NULL , client_info->adapter_path, &handle); +if (ACPI_FAILURE (status)) { +pr_err ("Error could not get %s handle\n" , client_info->adapter_path); +return NULL ; + } + +return i2c_acpi_find_adapter_by_handle (handle); +} +static __init int x86_instantiate_i2c_client (const struct x86_dev_info *dev_info,int idx) {const struct x86_i2c_client_info *client_info = &dev_info->i2c_client_info[idx];struct i2c_board_info board_info = client_info->board_info;struct i2c_adapter *adap; -acpi_handle handle; -acpi_status status; board_info.irq =x86_acpi_irq_helper_get (&client_info->irq_data);if (board_info.irq <0 )return board_info.irq; - status =acpi_get_handle (NULL , client_info->adapter_path, &handle);
drivers/platform/x86/x86-android-tablets/core.c static struct gpiod_lookup_table * const *gpiod_lookup_tables; · line 187
Quoted 10 lines
drivers/platform/x86/x86-android-tablets/core.c +1
-6-if (ACPI_FAILURE (status)) { -pr_err ("Error could not get %s handle\n" , client_info->adapter_path); -return -ENODEV ; - } - - adap =i2c_acpi_find_adapter_by_handle (handle); + adap =get_i2c_adap_by_handle (client_info);if (!adap) {pr_err ("error could not get %s adapter\n" , client_info->adapter_path);return -ENODEV ;
Not a big deal, but you might want to consider if printing both error messages is fine or if the error printing should be somehow modified when that other print moves into the inner function.
Signature · 1 line
i.
Re: [PATCH v2 1/3] platform/x86: x86-android-tablets: Add get_i2c_adap_by_handle() helper
Hi Ilpo,
Quoted 64 lines · Ilpo Järvinen
Quoted 49 lines · Hans de Goede
Add
get_i2c_adap_by_handle()helper function, this is a preparation patch for adding support for getting i2c_adapter-s by PCI parentdevname().Suggested-by Andy Shevchenko <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:
- New patch in v2 of this series--- .../platform/x86/x86-android-tablets/core.c | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-)drivers/platform/x86/x86-android-tablets/core.c +15
-3@@ -155,26 +155,33 @@ static struct gpiod_lookup_table * const *gpiod_lookup_tables;static const struct software_node *bat_swnode;static void (*exit_handler)(void ); +static struct i2c_adapter * +get_i2c_adap_by_handle (const struct x86_i2c_client_info *client_info) +{ +acpi_handle handle; +acpi_status status; + + status =acpi_get_handle (NULL , client_info->adapter_path, &handle); +if (ACPI_FAILURE (status)) { +pr_err ("Error could not get %s handle\n" , client_info->adapter_path); +return NULL ; + } + +return i2c_acpi_find_adapter_by_handle (handle); +} +static __init int x86_instantiate_i2c_client (const struct x86_dev_info *dev_info,int idx) {const struct x86_i2c_client_info *client_info = &dev_info->i2c_client_info[idx];struct i2c_board_info board_info = client_info->board_info;struct i2c_adapter *adap; -acpi_handle handle; -acpi_status status; board_info.irq =x86_acpi_irq_helper_get (&client_info->irq_data);if (board_info.irq <0 )return board_info.irq; - status =acpi_get_handle (NULL , client_info->adapter_path, &handle);drivers/platform/x86/x86-android-tablets/core.c static struct gpiod_lookup_table * const *gpiod_lookup_tables; · line 187
Quoted 10 lines
drivers/platform/x86/x86-android-tablets/core.c +1
-6-if (ACPI_FAILURE (status)) { -pr_err ("Error could not get %s handle\n" , client_info->adapter_path); -return -ENODEV ; - } - - adap =i2c_acpi_find_adapter_by_handle (handle); + adap =get_i2c_adap_by_handle (client_info);if (!adap) {pr_err ("error could not get %s adapter\n" , client_info->adapter_path);return -ENODEV ;Reviewed-by Ilpo Järvinen <[email protected]>
Quoted 3 lines
Not a big deal, but you might want to consider if printing both error messages is fine or if the error printing should be somehow modified when that other print moves into the inner function.
I already considered this and since this should never happen printing both messages if it does happen is fine IMHO.
Basically the idea is if the acpi_get_handle() fails print both messages, if the i2c_acpi_find_adapter_by_handle() fails only print the latter message. This way one can tell one scenario from the other while keeping the logic simple.
The same applies to the get_i2c_adap_by_pci_parent() helper added in patch 2.
Regards,
Hans
PATCH v2 2/3 platform/x86: x86-android-tablets: Add support for getting i2c_adapter by PCI parent devname()
In reply to Hans de GoedeOn the Vexia EDU ATLA 10 tablet, which ships with Android + a custom Linux (guadalinex) using the custom Android kernel the I2C controllers are not enumerated as ACPI devices as they typically are.
Instead they are enumerated as PCI devices which do not have ACPI firmware nodes associated with them, so getting the i2c_adapter by the ACPI path of its firmware node does not work.
Add support for getting the i2c_adapter by the devname() of its PCI parent instead.
---
Changes in v2:
- Move "depends on PCI" Kconfig change to this patch
- Put the code to get the adapter in a get_i2c_adap_by_pci_parent() helper
--- .../platform/x86/x86-android-tablets/Kconfig | 4 +- .../platform/x86/x86-android-tablets/core.c | 39 ++++++++++++++++++- .../x86-android-tablets/x86-android-tablets.h | 1 + 3 files changed, 41 insertions(+), 3 deletions(-)
drivers/platform/x86/x86-android-tablets/Kconfig +3 -1
@@ -5,7 +5,9 @@ config X86_ANDROID_TABLETS tristate "X86 Android tablet support" - depends on I2C && SPI && SERIAL_DEV_BUS && ACPI && EFI && GPIOLIB && PMIC_OPREGION + depends on I2C && SPI && SERIAL_DEV_BUS + depends on GPIOLIB && PMIC_OPREGION + depends on ACPI && EFI && PCI select NEW_LEDS select LEDS_CLASS help
drivers/platform/x86/x86-android-tablets/core.c +37 -2
@@ -11,11 +11,13 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/acpi.h> +#include <linux/device.h> #include <linux/dmi.h> #include <linux/gpio/consumer.h> #include <linux/gpio/machine.h> #include <linux/irq.h> #include <linux/module.h> +#include <linux/pci.h> #include <linux/platform_device.h> #include <linux/serdev.h> #include <linux/string.h>
@@ -170,18 +172,51 @@ get_i2c_adap_by_handle(const struct x86_i2c_client_info *client_info)return i2c_acpi_find_adapter_by_handle (handle); } +static __init int match_parent (struct device *dev,const void *data) +{ +return dev->parent == data; +} + +static struct i2c_adapter * +get_i2c_adap_by_pci_parent (const struct x86_i2c_client_info *client_info) +{ +struct i2c_adapter *adap =NULL ; +struct device *pdev, *adap_dev; + + pdev =bus_find_device_by_name (&pci_bus_type,NULL , client_info->adapter_path); +if (!pdev) { +pr_err ("Error could not find %s PCI device\n" , client_info->adapter_path); +return NULL ; + } + + adap_dev =bus_find_device (&i2c_bus_type,NULL , pdev, match_parent); +if (adap_dev) { + adap =i2c_verify_adapter (adap_dev); +if (!adap) +put_device (adap_dev); + } + +put_device (pdev); + +return adap; +} +static __init int x86_instantiate_i2c_client (const struct x86_dev_info *dev_info,int idx) {const struct x86_i2c_client_info *client_info = &dev_info->i2c_client_info[idx];struct i2c_board_info board_info = client_info->board_info; -struct i2c_adapter *adap; +struct i2c_adapter *adap =NULL ; board_info.irq =x86_acpi_irq_helper_get (&client_info->irq_data);if (board_info.irq <0 )return board_info.irq; - adap =get_i2c_adap_by_handle (client_info); +if (dev_info->use_pci_devname) + adap =get_i2c_adap_by_pci_parent (client_info); +else + adap =get_i2c_adap_by_handle (client_info); +if (!adap) {pr_err ("error could not get %s adapter\n" , client_info->adapter_path);return -ENODEV ;
drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +1 -0
@@ -91,6 +91,7 @@ struct x86_dev_info {int gpio_button_count;int (*init)(struct device *dev);void (*exit)(void ); +bool use_pci_devname; }; int x86_android_tablet_get_gpiod(const char *chip, int pin, const char *con_id,
Signature · 1 line
2.47.0
Re: [PATCH v2 2/3] platform/x86: x86-android-tablets: Add support for getting i2c_adapter by PCI parent devname()
Quoted 11 lines · Hans de Goede
On the Vexia EDU ATLA 10 tablet, which ships with Android + a custom Linux (guadalinex) using the custom Android kernel the I2C controllers are not enumerated as ACPI devices as they typically are.
Instead they are enumerated as PCI devices which do not have ACPI firmware nodes associated with them, so getting the
i2c_adapterby the ACPI path of its firmware node does not work.Add support for getting the
i2c_adapterby thedevname()of its PCI parent instead.
...
drivers/platform/x86/x86-android-tablets/core.c get_i2c_adap_by_handle(const struct x86_i2c_client_info *client_info) · line 209
Quoted 3 lines
struct i2c_board_info board_info = client_info->board_info;drivers/platform/x86/x86-android-tablets/core.c +1
-1-struct i2c_adapter *adap; +struct i2c_adapter *adap =NULL ;
Unneeded change.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 2/3] platform/x86: x86-android-tablets: Add support for getting i2c_adapter by PCI parent devname()
Hi,
Quoted 15 lines · Andy Shevchenko
Quoted 11 lines · Hans de Goede
On the Vexia EDU ATLA 10 tablet, which ships with Android + a custom Linux (guadalinex) using the custom Android kernel the I2C controllers are not enumerated as ACPI devices as they typically are.
Instead they are enumerated as PCI devices which do not have ACPI firmware nodes associated with them, so getting the
i2c_adapterby the ACPI path of its firmware node does not work.Add support for getting the
i2c_adapterby thedevname()of its PCI parent instead.Reviewed-by Andy Shevchenko <[email protected]>
Quoted 7 lines
...
drivers/platform/x86/x86-android-tablets/core.c get_i2c_adap_by_handle(const struct x86_i2c_client_info *client_info) · line 209
Quoted 3 lines
struct i2c_board_info board_info = client_info->board_info;drivers/platform/x86/x86-android-tablets/core.c +1
-1-struct i2c_adapter *adap; +struct i2c_adapter *adap =NULL ;Unneeded change.
Ack I noticed this myself and I thought I had dropped this change, but apparently I did not.
Ilpo can you fix this up while merging or do you want a v3 series?
Regards,
Hans
Ilpo Järvinen
maintainerRe: [PATCH v2 2/3] platform/x86: x86-android-tablets: Add support for getting i2c_adapter by PCI parent devname()
Quoted 24 lines · Hans de Goede
Hi,
Quoted 21 lines · Andy Shevchenko
Quoted 11 lines · Hans de Goede
On the Vexia EDU ATLA 10 tablet, which ships with Android + a custom Linux (guadalinex) using the custom Android kernel the I2C controllers are not enumerated as ACPI devices as they typically are.
Instead they are enumerated as PCI devices which do not have ACPI firmware nodes associated with them, so getting the
i2c_adapterby the ACPI path of its firmware node does not work.Add support for getting the
i2c_adapterby thedevname()of its PCI parent instead.Reviewed-by Andy Shevchenko <[email protected]>...
Quoted 3 lines
struct i2c_board_info board_info = client_info->board_info;drivers/platform/x86/x86-android-tablets/core.c +1
-1-struct i2c_adapter *adap; +struct i2c_adapter *adap =NULL ;
Quoted 6 lines
Quoted 1 line
Unneeded change.
Ack I noticed this myself and I thought I had dropped this change, but apparently I did not.
Ilpo can you fix this up while merging or do you want a v3 series?
Thanks both.
I removed this change while applying. I also made minor adjustments to the braces in the patch 3 for stylish consistency.
Signature · 1 line
i.
Re: [PATCH v2 2/3] platform/x86: x86-android-tablets: Add support for getting i2c_adapter by PCI parent devname()
Hi,
Quoted 31 lines · Ilpo Järvinen
Quoted 29 lines · Hans de Goede
Hi,
Quoted 15 lines · Andy Shevchenko
Quoted 11 lines · Hans de Goede
On the Vexia EDU ATLA 10 tablet, which ships with Android + a custom Linux (guadalinex) using the custom Android kernel the I2C controllers are not enumerated as ACPI devices as they typically are.
Instead they are enumerated as PCI devices which do not have ACPI firmware nodes associated with them, so getting the
i2c_adapterby the ACPI path of its firmware node does not work.Add support for getting the
i2c_adapterby thedevname()of its PCI parent instead.Reviewed-by Andy Shevchenko <[email protected]>Quoted 7 lines
...
drivers/platform/x86/x86-android-tablets/core.c get_i2c_adap_by_handle(const struct x86_i2c_client_info *client_info) · line 209
Quoted 3 lines
struct i2c_board_info board_info = client_info->board_info;drivers/platform/x86/x86-android-tablets/core.c +1
-1-struct i2c_adapter *adap; +struct i2c_adapter *adap =NULL ;Unneeded change.
Ack I noticed this myself and I thought I had dropped this change, but apparently I did not.
Quoted 6 lines
Quoted 1 line
Ilpo can you fix this up while merging or do you want a v3 series?
Thanks both.
I removed this change while applying. I also made minor adjustments to the braces in the patch 3 for stylish consistency.
Great, Thank you for merging these.
Regards,
Hans
PATCH v2 3/3 platform/x86: x86-android-tablets: Add support for Vexia EDU ATLA 10 tablet
In reply to Hans de GoedeAdd support for the Vexia EDU ATLA 10 tablet, Android 4.2/4.4 + Guadalinex Ubuntu tablet distributed to schools in the Spanish Andalucía region.
Besides the usual broken DSDT issues this tablet is special because all its LPSS island peripherals are enumerated as PCI devices rather then as ACPI devices as they typically are.
At the same time there are disabled (_STA=0) ACPI devices for the peripherals and child ACPI devices for e.g. attached I2C/SDIO devices are children of these disabled ACPI devices and thus will not be used by Linux since the parent is disabled.
So besides the usual manual i2c-client instantiation for accel/touchscreen this tablet also requires manual i2c-client instantiation for the codec and for the PMIC.
Also it seems the mainboard was designed for Windows not Android, so it has an I2C attached embedded controller instead of allowing direct access to the charger + fuel-gauge chips as is usual with Android boards.
Normally when there is an embedded controller, there also is ACPI battery support, but since this shipped with Android that is missing and Linux needs to have a power_supply class driver talking directly to the EC.
---
Changes in v2:
- Use pci_get_domain_bus_and_slot()
- Move "depends on PCI" to patch adding get_i2c_adap_by_pci_parent() helper
--- .../platform/x86/x86-android-tablets/dmi.c | 10 ++ .../platform/x86/x86-android-tablets/other.c | 163 ++++++++++++++++++ .../x86-android-tablets/x86-android-tablets.h | 1 + 3 files changed, 174 insertions(+)
drivers/platform/x86/x86-android-tablets/dmi.c +10 -0
@@ -179,6 +179,16 @@ const struct dmi_system_id x86_android_tablet_ids[] __initconst = { }, .driver_data = (void *)&peaq_c1010_info, }, + { +/* Vexia Edu Atla 10 tablet 9V version */ + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"AMI Corporation" ), +DMI_MATCH (DMI_BOARD_NAME ,"Aptio CRB" ), +/* Above strings are too generic, also match on BIOS date */ + DMI_MATCH(DMI_BIOS_DATE, "08/25/2014"), + }, + .driver_data = (void *)&vexia_edu_atla10_info, + }, {/* Whitelabel (sold as various brands) TM800A550L */ .matches = {
drivers/platform/x86/x86-android-tablets/other.c +163 -0
175 lines not on this page · raw message
drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +1 -0
@@ -120,6 +120,7 @@ extern const struct x86_dev_info nextbook_ares8_info;extern const struct x86_dev_info nextbook_ares8a_info;extern const struct x86_dev_info peaq_c1010_info;extern const struct x86_dev_info whitelabel_tm800a550l_info; +extern const struct x86_dev_info vexia_edu_atla10_info;extern const struct x86_dev_info xiaomi_mipad2_info;extern const struct dmi_system_id x86_android_tablet_ids[];
Signature · 1 line
2.47.0
Quoted 17 lines · Hans de Goede
Add support for the Vexia EDU ATLA 10 tablet, Android 4.2/4.4 + Guadalinex Ubuntu tablet distributed to schools in the Spanish Andalucía region.
Besides the usual broken DSDT issues this tablet is special because all its LPSS island peripherals are enumerated as PCI devices rather then as ACPI devices as they typically are.
At the same time there are disabled (_STA=0) ACPI devices for the peripherals and child ACPI devices for e.g. attached I2C/SDIO devices are children of these disabled ACPI devices and thus will not be used by Linux since the parent is disabled.
So besides the usual manual i2c-client instantiation for accel/touchscreen this tablet also requires manual i2c-client instantiation for the codec and for the PMIC.
Quoted 7 lines
Also it seems the mainboard was designed for Windows not Android, so it has an I2C attached embedded controller instead of allowing direct access to the charger + fuel-gauge chips as is usual with Android boards.
Normally when there is an embedded controller, there also is ACPI battery support, but since this shipped with Android that is missing and Linux needs to have a
power_supplyclass driver talking directly to the EC.
...
Quoted 9 lines
drivers/platform/x86/x86-android-tablets/other.c +5
-0+ .adapter_path = "0000:00:18.1", + .adapter_path = "0000:00:18.2", + .adapter_path = "0000:00:18.5", + .adapter_path = "0000:00:18.6", + .adapter_path = "0000:00:18.7",
...
Quoted 1 line
+ .use_pci_devname = true,
Just realized that you may do something like this to the above and also use pci_get_...() instead of iterating over the I2C type of devices. But you can do it later.
Signature · 2 lines
With Best Regards, Andy Shevchenko