From f4ef35e2a726e688db784df4d1b1c59e37c4218d Mon Sep 17 00:00:00 2001 From: Svyatoslav Ryhel Date: Tue, 13 Jul 2021 08:42:12 +0300 Subject: [PATCH] asus-ec: partially revert battery changes Signed-off-by: Svyatoslav Ryhel --- .../devicetree/bindings/mfd/asus-ec.yaml | 9 ++- arch/arm/boot/dts/tegra20-asus-tf101.dts | 2 +- .../dts/tegra30-asus-transformer-common.dtsi | 4 +- drivers/mfd/asus-ec.c | 58 ++++--------------- drivers/power/supply/asus-ec-battery.c | 5 +- include/linux/mfd/asus-ec.h | 6 -- 6 files changed, 23 insertions(+), 61 deletions(-) diff --git a/Documentation/devicetree/bindings/mfd/asus-ec.yaml b/Documentation/devicetree/bindings/mfd/asus-ec.yaml index 5ab35db90daf3..bfb76fa88a063 100644 --- a/Documentation/devicetree/bindings/mfd/asus-ec.yaml +++ b/Documentation/devicetree/bindings/mfd/asus-ec.yaml @@ -17,8 +17,11 @@ maintainers: properties: compatible: - const: asus,ec - + items: + - enum: + - asus,pad-ec # Pad part of Asus Transformer + - asus,dock-ec # Dock part of Asus Transformer + - const: asus,ec reg: maxItems: 1 @@ -87,7 +90,7 @@ examples: #size-cells = <0>; embedded-controller@15 { - compatible = "asus,ec"; + compatible = "asus,pad-ec", "asus,ec"; reg = <0x15>; interrupt-parent = <&gpio>; diff --git a/arch/arm/boot/dts/tegra20-asus-tf101.dts b/arch/arm/boot/dts/tegra20-asus-tf101.dts index 9fe6a2b6a02fa..08a811852524f 100644 --- a/arch/arm/boot/dts/tegra20-asus-tf101.dts +++ b/arch/arm/boot/dts/tegra20-asus-tf101.dts @@ -580,7 +580,7 @@ i2c-parent = <&lvds_ddc>; embedded-controller@19 { - compatible = "asus,ec"; + compatible = "asus,dock-ec", "asus,ec"; reg = <0x19>; interrupt-parent = <&gpio>; diff --git a/arch/arm/boot/dts/tegra30-asus-transformer-common.dtsi b/arch/arm/boot/dts/tegra30-asus-transformer-common.dtsi index 8f6b33d7a6017..ca44a8ecdff2e 100644 --- a/arch/arm/boot/dts/tegra30-asus-transformer-common.dtsi +++ b/arch/arm/boot/dts/tegra30-asus-transformer-common.dtsi @@ -1059,7 +1059,7 @@ /* Nuvoton NPCE795LA0BX embedded controller */ embedded-controller@15 { - compatible = "asus,ec"; + compatible = "asus,pad-ec", "asus,ec"; reg = <0x15>; interrupt-parent = <&gpio>; @@ -1091,7 +1091,7 @@ i2c-parent = <&i2c2>; embedded-controller@19 { - compatible = "asus,ec"; + compatible = "asus,dock-ec", "asus,ec"; reg = <0x19>; interrupt-parent = <&gpio>; diff --git a/drivers/mfd/asus-ec.c b/drivers/mfd/asus-ec.c index 654ab79db3998..f50e693e750c4 100644 --- a/drivers/mfd/asus-ec.c +++ b/drivers/mfd/asus-ec.c @@ -45,13 +45,10 @@ struct asus_ec_data { enum asus_ec_subdev_id { ID_EC_PART_BATTERY, -#define EC_PART_PAD_BATTERY BIT(ID_EC_PART_BATTERY) +#define EC_PART_BATTERY BIT(ID_EC_PART_BATTERY) - ID_EC_PART_DOCK_BATTERY, -#define EC_PART_DOCK_BATTERY BIT(ID_EC_PART_DOCK_BATTERY) - - ID_EC_PART_DOCK_BATTERY_TF701T, -#define EC_PART_DOCK_BATTERY_TF701T BIT(ID_EC_PART_DOCK_BATTERY_TF701T) + ID_EC_PART_CHARGER, +#define EC_PART_CHARGER BIT(ID_EC_PART_CHARGER) ID_EC_PART_CHARGE_LED, #define EC_PART_CHARGE_LED BIT(ID_EC_PART_CHARGE_LED) @@ -61,9 +58,6 @@ enum asus_ec_subdev_id { ID_EC_PART_EXT_KEYS, #define EC_PART_EXT_KEYS BIT(ID_EC_PART_EXT_KEYS) - - ID_EC_PART_CHARGER, -#define EC_PART_CHARGER BIT(ID_EC_PART_CHARGER) }; enum asus_ec_flag { @@ -78,36 +72,12 @@ struct asus_ec_initdata { unsigned int flags; }; -static struct asusec_pdata pad_battery_pdata = { - .is_pad = true, - .ec_addr = 0x14, -}; - -static struct asusec_pdata dock_battery_pdata = { - .is_pad = false, - .ec_addr = 0x14, -}; - -static struct asusec_pdata dock_battery_tf701t_pdata = { - .is_pad = false, - .ec_addr = 0x24, -}; - static const struct mfd_cell asus_ec_subdev[] = { [ID_EC_PART_BATTERY] = { .name = "asusec-battery", - .platform_data = &pad_battery_pdata, - .pdata_size = sizeof(pad_battery_pdata), - }, - [ID_EC_PART_DOCK_BATTERY] = { - .name = "asusec-battery", - .platform_data = &dock_battery_pdata, - .pdata_size = sizeof(dock_battery_pdata), }, - [ID_EC_PART_DOCK_BATTERY_TF701T] = { - .name = "asusec-battery", - .platform_data = &dock_battery_tf701t_pdata, - .pdata_size = sizeof(dock_battery_tf701t_pdata), + [ID_EC_PART_CHARGER] = { + .name = "asusec-charger", }, [ID_EC_PART_CHARGE_LED] = { .name = "asusec-led", @@ -118,45 +88,40 @@ static const struct mfd_cell asus_ec_subdev[] = { [ID_EC_PART_EXT_KEYS] = { .name = "asusec-keys", }, - [ID_EC_PART_CHARGER] = { - .name = "asusec-charger", - }, }; static const struct asus_ec_initdata asus_ec_model_info[] = { { /* Asus T20 Mobile Dock */ .model = "ASUS-EP101-DOCK", .name = "dock", - .components = EC_PART_DOCK_BATTERY | EC_PART_CHARGE_LED | + .components = EC_PART_BATTERY | EC_PART_CHARGE_LED | EC_PART_I8042 | EC_PART_EXT_KEYS | EC_PART_CHARGER, }, { /* Asus T30 Transformer Pad */ .model = "ASUS-TF201-PAD", .name = "pad", - .components = EC_PART_PAD_BATTERY | EC_PART_CHARGE_LED, + .components = EC_PART_BATTERY | EC_PART_CHARGE_LED, .flags = EC_FLAG_SET_MODE, }, { /* Asus T30 Mobile Dock */ .model = "ASUS-TF201-DOCK", .name = "dock", - .components = EC_PART_DOCK_BATTERY | EC_PART_CHARGE_LED | + .components = EC_PART_BATTERY | EC_PART_CHARGE_LED | EC_PART_I8042 | EC_PART_EXT_KEYS | EC_PART_CHARGER, }, { /* Asus TF500T/TF700T Mobile Dock */ .model = "ASUS-DOCK-EC21N", .name = "dock", - .components = EC_PART_DOCK_BATTERY | EC_PART_CHARGE_LED | + .components = EC_PART_BATTERY | EC_PART_CHARGE_LED | EC_PART_I8042 | EC_PART_EXT_KEYS | EC_PART_CHARGER, }, - { /* Asus T114 Transformer combined Pad/Dock */ + { /* Asus T114 Transformer Pad */ .model = "ASUS-TF701T-PAD", .name = "pad", - .components = EC_PART_PAD_BATTERY | - /* EC_PART_DOCK_BATTERY_TF701T | */ - EC_PART_CHARGE_LED, + .components = EC_PART_BATTERY | EC_PART_CHARGE_LED, .flags = EC_FLAG_SET_MODE, }, }; @@ -515,6 +480,7 @@ static int asus_ec_remove(struct i2c_client *client) struct asus_ec_data *priv = i2c_get_clientdata(client); mfd_remove_devices(&priv->self->dev); + sysfs_remove_link(&client->dev.kobj, "dockram"); sysfs_remove_group(&client->dev.kobj, &asus_ec_attr_group); diff --git a/drivers/power/supply/asus-ec-battery.c b/drivers/power/supply/asus-ec-battery.c index d39ba5634843f..6898b8fc019b7 100644 --- a/drivers/power/supply/asus-ec-battery.c +++ b/drivers/power/supply/asus-ec-battery.c @@ -222,7 +222,6 @@ static const struct power_supply_desc dock_battery_desc = { static int asusec_battery_probe(struct platform_device *pdev) { - const struct asusec_pdata *pdata = dev_get_platdata(&pdev->dev); const struct asusec_info *ec = asusec_cell_to_ec(pdev); const struct power_supply_desc *psd; struct asusec_battery_data *priv; @@ -237,14 +236,14 @@ static int asusec_battery_probe(struct platform_device *pdev) mutex_init(&priv->battery_lock); priv->ec = ec; - priv->ec_addr = pdata->ec_addr; + priv->ec_addr = 0x14; priv->batt_data_ts = jiffies - 1; priv->last_state = POWER_SUPPLY_STATUS_UNKNOWN; cfg.of_node = pdev->dev.parent->of_node; cfg.drv_data = priv; - if (pdata->is_pad) + if (!of_property_match_string(cfg.of_node, "compatible", "asus,pad-ec")) psd = &pad_battery_desc; else psd = &dock_battery_desc; diff --git a/include/linux/mfd/asus-ec.h b/include/linux/mfd/asus-ec.h index b1f81dc2c960f..bee9749a8d3c1 100644 --- a/include/linux/mfd/asus-ec.h +++ b/include/linux/mfd/asus-ec.h @@ -4,7 +4,6 @@ #include #include -#include struct i2c_client; struct workqueue_struct; @@ -22,11 +21,6 @@ struct i2c_client *devm_asus_dockram_get(struct device *parent); /* EC public API */ -struct asusec_pdata { - bool is_pad; - unsigned int ec_addr; -}; - struct asusec_info { const char *name; const char *model;