Skip to contentSkip to conversation

Introduce Embedded Controller driver for Acer A500

PATCH Superseded Dmitry Osipenko 4 participants 15 messages Aug 30, 2020 – Sep 8, 2020

Subsystems (8)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover Introduce Embedded Controller driver for Acer A500

Hello!

This series adds support for the Embedded Controller which is found on Acer Iconia Tab A500 (Android tablet device).

The Embedded Controller is ENE KB930 and it's running firmware customized for the A500. The firmware interface may be reused by some other sibling Acer tablets, although none of those tablets are supported in upstream yet. Please review and apply, thanks in advance!

Changelog:

v2: - Factored out KB930 device-tree binding into a separate file, like it
was suggested by Lubomir Rintel.

- Switched to use regmap API like it was suggested by Lubomir Rintel.

- Added patch "regmap: Use flexible sleep" which allows not to hog CPU while LED is switching state.

- Corrected MODULE_LICENSE to use "GPL" in all patches.

- Corrected MFD driver Kconfig entry like it was suggested by Lubomir Rintel, it now depends on I2C.

- Switched to use I2C probe_new() in the MFD driver.

- Renamed the global pm_off variable, like it was suggested by Lubomir Rintel and Lee Jones.

- Dropped serial number from the battery driver because I realized that it's not a battery serial, but a device serial.

- Battery driver now uses dev_err_probe(), like it was suggested by Sebastian Reichel.

- Dropped legacy LED_ON usage from the LED driver and renamed the LEDs, like it was suggested by Pavel Machek. I also checked whether LED-name customization via device-tree could be needed by other potentially compatible devices and it shouldn't be needed, anyways it won't be difficult to extend the code even if I'm wrong.

Dmitry Osipenko (6):
dt-bindings: mfd: Add ENE KB930 Embedded Controller binding
regmap: Use flexible sleep
mfd: Add driver for Embedded Controller found on Acer Iconia Tab A500
power: supply: Add battery gauge driver for Acer Iconia Tab A500
leds: Add driver for Acer Iconia Tab A500
ARM: tegra: acer-a500: Add Embedded Controller

 .../devicetree/bindings/mfd/ene-kb930.yaml    |  66 ++++
 .../boot/dts/tegra20-acer-a500-picasso.dts    |  17 +
 drivers/base/regmap/regmap.c                  |   4 +-
 drivers/leds/Kconfig                          |   7 +
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-acer-a500.c                 | 130 ++++++++
 drivers/mfd/Kconfig                           |  12 +
 drivers/mfd/Makefile                          |   1 +
 drivers/mfd/acer-ec-a500.c                    | 203 ++++++++++++
 drivers/power/supply/Kconfig                  |   6 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/acer_a500_battery.c      | 297 ++++++++++++++++++
 12 files changed, 743 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/ene-kb930.yaml
 create mode 100644 drivers/leds/leds-acer-a500.c
 create mode 100644 drivers/mfd/acer-ec-a500.c
 create mode 100644 drivers/power/supply/acer_a500_battery.c
Signature · 1 line
2.27.0
#1 lore raw

PATCH v2 1/6 dt-bindings: mfd: Add ENE KB930 Embedded Controller binding

Add binding document for the ENE KB930 Embedded Controller.

---
 .../devicetree/bindings/mfd/ene-kb930.yaml    | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ene-kb930.yaml
Documentation/devicetree/bindings/mfd/ene-kb930.yaml new file +66 -0
new file mode 100644
index 000000000000..635c8966ca22
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/ene-kb930.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ENE KB930 Embedded Controller bindings
+
+description: |
+  This binding describes the ENE KB930 Embedded Controller attached to an
+  I2C bus.
+
+maintainers:
+  - Dmitry Osipenko <[email protected]>
+
+properties:
+  compatible:
+    items:
+      - enum:
+        - acer,a500-iconia-ec # Acer A500 Iconia tablet device
+      - enum:
+        - ene,kb930
+  reg:
+    maxItems: 1
+
+  monitored-battery: true
+  power-supplies: true
+  system-power-controller: true
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    battery: battery-cell {
+      compatible = "simple-battery";
+      charge-full-design-microamp-hours = <3260000>;
+      energy-full-design-microwatt-hours = <24000000>;
+      operating-range-celsius = <0 40>;
+    };
+
+    mains: ac-adapter {
+      compatible = "gpio-charger";
+      charger-type = "mains";
+      gpios = <&gpio 125 0>;
+    };
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      embedded-controller@58 {
+        compatible = "acer,a500-iconia-ec", "ene,kb930";
+        reg = <0x58>;
+
+        system-power-controller;
+
+        monitored-battery = <&battery>;
+        power-supplies = <&mains>;
+      };
+    };
+
+...
Signature · 1 line
2.27.0
maintainer
#2 lore raw

Re: [PATCH v2 1/6] dt-bindings: mfd: Add ENE KB930 Embedded Controller binding

Quoted 8 lines · Dmitry Osipenko

Add binding document for the ENE KB930 Embedded Controller.

---
 .../devicetree/bindings/mfd/ene-kb930.yaml    | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ene-kb930.yaml

My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/ene-kb930.example.dt.yaml: battery-cell: 'operating-range-celsius' does not match any of the regexes: '^ocv-capacity-table-[0-9]+$', 'pinctrl-[0-9]+'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/battery.yaml

See https://patchwork.ozlabs.org/patch/1354004

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.

#3 lore raw

Re: [PATCH v2 1/6] dt-bindings: mfd: Add ENE KB930 Embedded Controller binding

03.09.2020 19:10, Rob Herring пишет:

Quoted 17 lines · Dmitry Osipenko
Quoted 8 lines

Add binding document for the ENE KB930 Embedded Controller.

---
 .../devicetree/bindings/mfd/ene-kb930.yaml    | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ene-kb930.yaml

My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/ene-kb930.example.dt.yaml: battery-cell: 'operating-range-celsius' does not match any of the regexes: '^ocv-capacity-table-[0-9]+$', 'pinctrl-[0-9]+'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/battery.yaml

Quoted 9 lines

See https://patchwork.ozlabs.org/patch/1354004

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.

Apparently bot uses outdated kernel.

maintainer
#4 lore raw

Re: [PATCH v2 1/6] dt-bindings: mfd: Add ENE KB930 Embedded Controller binding

Quoted 24 lines · Dmitry Osipenko

03.09.2020 19:10, Rob Herring пишет:

Quoted 22 lines · Dmitry Osipenko
Quoted 8 lines

Add binding document for the ENE KB930 Embedded Controller.

---
 .../devicetree/bindings/mfd/ene-kb930.yaml    | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ene-kb930.yaml

My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/ene-kb930.example.dt.yaml: battery-cell: 'operating-range-celsius' does not match any of the regexes: '^ocv-capacity-table-[0-9]+$', 'pinctrl-[0-9]+'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/battery.yaml

See https://patchwork.ozlabs.org/patch/1354004

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:

Quoted 6 lines
Quoted 4 lines

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.

Apparently bot uses outdated kernel.

It's on v5.9-rc2. The scripts don't know your base/dependencies and neither did I because you didn't mention anything here. I do review the errors before spamming people.

Rob

#5 lore raw

Re: [PATCH v2 1/6] dt-bindings: mfd: Add ENE KB930 Embedded Controller binding

04.09.2020 18:40, Rob Herring пишет:

Quoted 27 lines · Dmitry Osipenko
Quoted 26 lines

03.09.2020 19:10, Rob Herring пишет:

Quoted 24 lines · Dmitry Osipenko
Quoted 8 lines

Add binding document for the ENE KB930 Embedded Controller.

---
 .../devicetree/bindings/mfd/ene-kb930.yaml    | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ene-kb930.yaml

My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/ene-kb930.example.dt.yaml: battery-cell: 'operating-range-celsius' does not match any of the regexes: '^ocv-capacity-table-[0-9]+$', 'pinctrl-[0-9]+'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/battery.yaml

See https://patchwork.ozlabs.org/patch/1354004

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Please check and re-submit.

Apparently bot uses outdated kernel.

It's on v5.9-rc2. The scripts don't know your base/dependencies and neither did I because you didn't mention anything here. I do review the errors before spamming people.

The patches are based on the linux-next, hence nothing special here. My expectation is that the bot should use the linux-next as well in order to prevent such warnings. Is there any reason to why bot not using linux-next?

maintainer
#6 lore raw

Re: [PATCH v2 1/6] dt-bindings: mfd: Add ENE KB930 Embedded Controller binding

Quoted 34 lines · Dmitry Osipenko

04.09.2020 18:40, Rob Herring пишет:

Quoted 32 lines · Dmitry Osipenko
Quoted 30 lines

03.09.2020 19:10, Rob Herring пишет:

Quoted 17 lines · Dmitry Osipenko
Quoted 8 lines

Add binding document for the ENE KB930 Embedded Controller.

---
 .../devicetree/bindings/mfd/ene-kb930.yaml    | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ene-kb930.yaml

My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/ene-kb930.example.dt.yaml: battery-cell: 'operating-range-celsius' does not match any of the regexes: '^ocv-capacity-table-[0-9]+$', 'pinctrl-[0-9]+'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/battery.yaml

Quoted 9 lines

See https://patchwork.ozlabs.org/patch/1354004

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.

Apparently bot uses outdated kernel.

Quoted 8 lines
Quoted 3 lines

It's on v5.9-rc2. The scripts don't know your base/dependencies and neither did I because you didn't mention anything here. I do review the errors before spamming people.

The patches are based on the linux-next, hence nothing special here. My expectation is that the bot should use the linux-next as well in order to prevent such warnings. Is there any reason to why bot not using linux-next?

What the bot uses is not the issue. The issue is not stating what your dependencies are. linux-next is not a stable base. No patches to be applied should be based on linux-next because there's no maintainer that can take them if you consider anything in linux-next could be a dependency. Of course, you're probably just dependent on one maintainer's tree usually, but whose tree? Am I supposed to figure that out?

linux-next is frequently broken with respect to binding checks, so it really doesn't work for the bot. I need a known good base.

Rob

#7 lore raw

PATCH v2 2/6 regmap: Use flexible sleep

In reply to Dmitry Osipenko

The multi-reg write function uses udelay(), which is a busy-loop based delaying function that is not suitable for a long delays. Hence let's replace the udelay() with fsleep(), which is flexible sleep function that selects best delay function based on the delay-time.

---
 drivers/base/regmap/regmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/regmap/regmap.c +2 -2
index e93700af7e6e..a417cb1a11dc 100644
@@ -2231,7 +2231,7 @@ static int _regmap_range_multi_paged_reg_write(struct regmap *map,
 					return ret;
 
 				if (regs[i].delay_us)
-					udelay(regs[i].delay_us);
+					fsleep(regs[i].delay_us);
 
 				base += n;
 				n = 0;
@@ -2268,7 +2268,7 @@ static int _regmap_multi_reg_write(struct regmap *map,
 				return ret;
 
 			if (regs[i].delay_us)
-				udelay(regs[i].delay_us);
+				fsleep(regs[i].delay_us);
 		}
 		return 0;
 	}
Signature · 1 line
2.27.0
#8 lore raw

Re: [PATCH v2 2/6] regmap: Use flexible sleep

Hi Dmitry,

Quoted 6 lines · Dmitry Osipenko

The multi-reg write function uses udelay(), which is a busy-loop based delaying function that is not suitable for a long delays. Hence let's replace the udelay() with fsleep(), which is flexible sleep function that selects best delay function based on the delay-time.

This patch landed in today's linux-next (20200902) as commit 2b32d2f7ce0a. Sadly it breaks booting of ARM 64bit Amlogic S922X based Odroid N2 board. Here is the log:

BUG: scheduling while atomic: kworker/4:1/46/0x00000003
5 locks held by kworker/4:1/46:
  #0: ffff0000dfc06738 ((wq_completion)events){+.+.}-{0:0}, at: 
process_one_work+0x200/0x718
  #1: ffff80001320bdd0 (deferred_probe_work){+.+.}-{0:0}, at: 
process_one_work+0x200/0x718
  #2: ffff0000df4b6188 (&dev->mutex){....}-{3:3}, at: 
__device_attach+0x3c/0x150
  #3: ffff800012306e70 (enable_lock){+.+.}-{2:2}, at: 
clk_enable_lock+0x48/0x128
  #4: ffff0000de01c418 (syscon:110:(&syscon_config)->lock){+.+.}-{2:2}, 
at: regmap_lock_spinlock+0x14/0x28
Modules linked in:
CPU: 4 PID: 46 Comm: kworker/4:1 Not tainted 5.9.0-rc2+ #1570
Hardware name: Hardkernel ODROID-N2 (DT)
Workqueue: events deferred_probe_work_func
Call trace:
  dump_backtrace+0x0/0x1d0
  show_stack+0x14/0x20
  dump_stack+0xec/0x16c
  __schedule_bug+0x64/0x98
  __schedule+0x7e0/0x8a0
  schedule+0x78/0x118
  schedule_hrtimeout_range_clock+0x84/0x108
  schedule_hrtimeout_range+0x10/0x18
  usleep_range+0x88/0xb8
  _regmap_multi_reg_write+0x188/0x4e0
  regmap_multi_reg_write+0x38/0x58
  meson_clk_pll_init+0x80/0xd8
  meson_clk_pcie_pll_enable+0x48/0xd8
  clk_core_enable+0xc8/0x2b0
  clk_core_enable+0xa8/0x2b0
  clk_core_enable+0xa8/0x2b0
  clk_core_enable+0xa8/0x2b0
  clk_core_enable_lock+0x20/0x40
  clk_enable+0x14/0x28
  phy_g12a_usb3_pcie_probe+0x130/0x210
  platform_drv_probe+0x50/0xa8
  really_probe+0x110/0x400
  driver_probe_device+0x54/0xb8
  __device_attach_driver+0x90/0xc0
  bus_for_each_drv+0x70/0xc8
  __device_attach+0xec/0x150
  device_initial_probe+0x10/0x18
  bus_probe_device+0x94/0xa0
  deferred_probe_work_func+0x70/0xa8
  process_one_work+0x2a8/0x718
  worker_thread+0x48/0x460
  kthread+0x134/0x160
  ret_from_fork+0x10/0x1c
BUG: sleeping function called from invalid context at mm/slab.h:498
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 46, name: kworker/4:1
3 locks held by kworker/4:1/46:
  #0: ffff0000dfc06738 ((wq_completion)events){+.+.}-{0:0}, at: 
process_one_work+0x200/0x718
  #1: ffff80001320bdd0 (deferred_probe_work){+.+.}-{0:0}, at: 
process_one_work+0x200/0x718
  #2: ffff0000df4b6188 (&dev->mutex){....}-{3:3}, at: 
__device_attach+0x3c/0x150
CPU: 4 PID: 46 Comm: kworker/4:1 Tainted: G        W 5.9.0-rc2+ #1570
Hardware name: Hardkernel ODROID-N2 (DT)
Workqueue: events deferred_probe_work_func
Call trace:
  dump_backtrace+0x0/0x1d0
  show_stack+0x14/0x20
  dump_stack+0xec/0x16c
  ___might_sleep+0x1d4/0x1f8
  __might_sleep+0x4c/0x88
  slab_pre_alloc_hook.constprop.96+0xf4/0x138
  __kmalloc_node_track_caller+0x6c/0x288
  devres_alloc_node+0x54/0xc0
  devm_reset_control_array_get+0x34/0xc0
  phy_g12a_usb3_pcie_probe+0x148/0x210
  platform_drv_probe+0x50/0xa8
  really_probe+0x110/0x400
  driver_probe_device+0x54/0xb8
  __device_attach_driver+0x90/0xc0
  bus_for_each_drv+0x70/0xc8
  __device_attach+0xec/0x150
  device_initial_probe+0x10/0x18
  bus_probe_device+0x94/0xa0
  deferred_probe_work_func+0x70/0xa8
  process_one_work+0x2a8/0x718
  worker_thread+0x48/0x460
  kthread+0x134/0x160
  ret_from_fork+0x10/0x1c
------------[ cut here ]------------
kernel BUG at mm/vmalloc.c:2066!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
Modules linked in:
CPU: 4 PID: 46 Comm: kworker/4:1 Tainted: G        W 5.9.0-rc2+ #1570
Hardware name: Hardkernel ODROID-N2 (DT)
Workqueue: events deferred_probe_work_func
pstate: 00000005 (nzcv daif -PAN -UAO BTYPE=--)
pc : __get_vm_area_node+0x190/0x198
lr : get_vm_area_caller+0x34/0x40

sp : ffff80001320b9f0
x29: ffff80001320b9f0 x28: ffff8000124bf68d
x27: ffff0000e47ce005 x26: ffff0000e484a6a8
x25: 0000000000000009 x24: ffff80001220f000
x23: 0068000000000707 x22: ffff800010531544
x21: 0000000000000000 x20: 00000000ffe09000
x19: 0000000000001000 x18: ffffffffffffffff
x17: 0000000089f66c61 x16: 00000000b502d7d1
x15: ffff80001220fa48 x14: ffff0000de6df18a
x13: ffff0000de6df189 x12: 0000000000000030
x11: 0000000000000003 x10: ffff8000124f8c58
x9 : 0000000000000000 x8 : 00000000fffffffe
x7 : ffff800010531544 x6 : 0000000000000cc0
x5 : 00000000ffffffff x4 : fffffdffbfff0000
x3 : ffff800010000000 x2 : 0000000000000001
x1 : 0000000000000001 x0 : 0000000000001000

Call trace:
  __get_vm_area_node+0x190/0x198
  __ioremap_caller+0x68/0xe0
  __ioremap+0x38/0x40
  __devm_ioremap+0x7c/0xf8
  __devm_ioremap_resource+0xa8/0x160
  devm_ioremap_resource+0x10/0x18
  devm_platform_get_and_ioremap_resource+0x70/0x78
  devm_platform_ioremap_resource+0x10/0x18
  dwc3_meson_g12a_probe+0x60/0x518
  platform_drv_probe+0x50/0xa8
  really_probe+0x110/0x400
  driver_probe_device+0x54/0xb8
  __device_attach_driver+0x90/0xc0
  bus_for_each_drv+0x70/0xc8
  __device_attach+0xec/0x150
  device_initial_probe+0x10/0x18
  bus_probe_device+0x94/0xa0
  deferred_probe_work_func+0x70/0xa8
  process_one_work+0x2a8/0x718
  worker_thread+0x48/0x460
  kthread+0x134/0x160
  ret_from_fork+0x10/0x1c
Code: cb010000 11000400 17ffffe8 d503201f (d4210000)
---[ end trace b621320ae7bce6b7 ]---
Kernel panic - not syncing: Aiee, killing interrupt handler!

SMP: stopping secondary CPUs
Kernel Offset: disabled
CPU features: 0x0240002,20082004
Memory Limit: none

---[ end Kernel panic - not syncing: Aiee, killing interrupt handler! ]---

Reverting this commit on top of current linux-next fixes board booting.

Quoted 18 lines
---
  drivers/base/regmap/regmap.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/regmap/regmap.c +1 -1
index e93700af7e6e..a417cb1a11dc 100644
@@ -2231,7 +2231,7 @@ static int _regmap_range_multi_paged_reg_write(struct regmap *map,
  					return ret;
 
  				if (regs[i].delay_us)
-					udelay(regs[i].delay_us);
+					fsleep(regs[i].delay_us);
 
  				base += n;
  				n = 0;

drivers/base/regmap/regmap.c static int _regmap_multi_reg_write(struct regmap *map, · line 2274

Quoted 8 lines
drivers/base/regmap/regmap.c +1 -1
@@ -2268,7 +2268,7 @@ static int _regmap_multi_reg_write(struct regmap *map,
  				return ret;
 
  			if (regs[i].delay_us)
-				udelay(regs[i].delay_us);
+				fsleep(regs[i].delay_us);
  		}
  		return 0;
  	}

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#9 lore raw

Re: [PATCH v2 2/6] regmap: Use flexible sleep

02.09.2020 15:47, Marek Szyprowski пишет:

Quoted 8 lines

Hi Dmitry,

Quoted 5 lines · Dmitry Osipenko

The multi-reg write function uses udelay(), which is a busy-loop based delaying function that is not suitable for a long delays. Hence let's replace the udelay() with fsleep(), which is flexible sleep function that selects best delay function based on the delay-time.

Quoted 5 lines
Quoted 1 line

This patch landed in today's linux-next (20200902) as commit 2b32d2f7ce0a. Sadly it breaks booting of ARM 64bit Amlogic S922X based Odroid N2 board. Here is the log:

Hello, Marek! Thank you for the feedback! I missed that remap supports different types of locking, I'll make a another patch to fix this problem.

#10 lore raw

PATCH v2 3/6 mfd: Add driver for Embedded Controller found on Acer Iconia Tab A500

In reply to Dmitry Osipenko

Acer Iconia Tab A500 is an Android tablet device, it has ENE KB930 Embedded Controller which provides battery-gauge, LED, GPIO and some other functions. The EC uses firmware that is specifically customized for Acer A500. This patch adds MFD driver for the Embedded Controller which allows to power-off / reboot the A500 device, it also provides a common register read/write API that will be used by the sub-devices.

---
 drivers/mfd/Kconfig        |  12 +++
 drivers/mfd/Makefile       |   1 +
 drivers/mfd/acer-ec-a500.c | 203 +++++++++++++++++++++++++++++++++++++
 3 files changed, 216 insertions(+)
 create mode 100644 drivers/mfd/acer-ec-a500.c
drivers/mfd/Kconfig +12 -0
index ecd791ad5e8f..7a0f4952c76e 100644
@@ -2062,6 +2062,18 @@ config MFD_KHADAS_MCU
 	  additional drivers must be enabled in order to use the functionality
 	  of the device.
 
+config MFD_ACER_A500_EC
+	tristate "Embedded Controller driver for Acer Iconia Tab A500"
+	depends on I2C
+	depends on ARCH_TEGRA_2x_SOC || COMPILE_TEST
+	select MFD_CORE
+	select REGMAP
+	help
+	  Support for Acer Iconia Tab A500 Embedded Controller.
+
+	  The controller itself is ENE KB930, it is running firmware
+	  customized for the specific needs of the Acer A500 hardware.
+
 menu "Multimedia Capabilities Port drivers"
 	depends on ARCH_SA1100
 
drivers/mfd/Makefile +1 -0
index dd2cc7be7eaa..f6652fb33b7a 100644
@@ -262,6 +262,7 @@ obj-$(CONFIG_MFD_ROHM_BD71828)	+= rohm-bd71828.o
 obj-$(CONFIG_MFD_ROHM_BD718XX)	+= rohm-bd718x7.o
 obj-$(CONFIG_MFD_STMFX) 	+= stmfx.o
 obj-$(CONFIG_MFD_KHADAS_MCU) 	+= khadas-mcu.o
+obj-$(CONFIG_MFD_ACER_A500_EC)	+= acer-ec-a500.o
 
 obj-$(CONFIG_SGI_MFD_IOC3)	+= ioc3.o
 
drivers/mfd/acer-ec-a500.c new file +203 -0

203 lines not on this page · raw message

Signature · 1 line
2.27.0
#11 lore raw

PATCH v2 4/6 power: supply: Add battery gauge driver for Acer Iconia Tab A500

In reply to Dmitry Osipenko

This patch adds battery gauge driver for Acer Iconia Tab A500 device. The battery gauge function is provided via the Embedded Controller, which is found on the Acer A500.

---
 drivers/power/supply/Kconfig             |   6 +
 drivers/power/supply/Makefile            |   1 +
 drivers/power/supply/acer_a500_battery.c | 297 +++++++++++++++++++++++
 3 files changed, 304 insertions(+)
 create mode 100644 drivers/power/supply/acer_a500_battery.c
drivers/power/supply/Kconfig +6 -0
index d1ccf17df42e..3daf0e359964 100644
@@ -752,4 +752,10 @@ config CHARGER_WILCO
 	  information can be found in
 	  Documentation/ABI/testing/sysfs-class-power-wilco
 
+config BATTERY_ACER_A500
+	tristate "Acer Iconia Tab A500 battery driver"
+	depends on MFD_ACER_A500_EC
+	help
+	  Say Y to include support for Acer Iconia Tab A500 battery fuel gauge.
+
 endif # POWER_SUPPLY
drivers/power/supply/Makefile +1 -0
index b3c694a65114..08a5b49e2936 100644
@@ -96,3 +96,4 @@ obj-$(CONFIG_CHARGER_UCS1002)	+= ucs1002_power.o
 obj-$(CONFIG_CHARGER_BD70528)	+= bd70528-charger.o
 obj-$(CONFIG_CHARGER_BD99954)	+= bd99954-charger.o
 obj-$(CONFIG_CHARGER_WILCO)	+= wilco-charger.o
+obj-$(CONFIG_BATTERY_ACER_A500)	+= acer_a500_battery.o
drivers/power/supply/acer_a500_battery.c new file +297 -0

297 lines not on this page · raw message

Signature · 1 line
2.27.0
#12 lore raw

PATCH v2 5/6 leds: Add driver for Acer Iconia Tab A500

In reply to Dmitry Osipenko

Acer Iconia Tab A500 is an Android tablet device which has two LEDs embedded into the Power Button. Orange LED indicates "battery charging" status and white LED indicates "wake-up/charge-done" status. The new LED driver provides control over both LEDs to userspace.

---
 drivers/leds/Kconfig          |   7 ++
 drivers/leds/Makefile         |   1 +
 drivers/leds/leds-acer-a500.c | 130 ++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 drivers/leds/leds-acer-a500.c
drivers/leds/Kconfig +7 -0
index 4f6464a169d5..4c39b53bcf1f 100644
@@ -921,6 +921,13 @@ config LEDS_SGM3140
 	  This option enables support for the SGM3140 500mA Buck/Boost Charge
 	  Pump LED Driver.
 
+config LEDS_ACER_A500
+	tristate "Power button LED support for Acer Iconia Tab A500"
+	depends on LEDS_CLASS && MFD_ACER_A500_EC
+	help
+	  This option enables support for the Power Button LED of
+	  Acer Iconia Tab A500.
+
 comment "LED Triggers"
 source "drivers/leds/trigger/Kconfig"
 
drivers/leds/Makefile +1 -0
index 778cb4bb8c52..73e603e1727e 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 # LED Platform Drivers (keep this sorted, M-| sort)
 obj-$(CONFIG_LEDS_88PM860X)		+= leds-88pm860x.o
 obj-$(CONFIG_LEDS_AAT1290)		+= leds-aat1290.o
+obj-$(CONFIG_LEDS_ACER_A500)		+= leds-acer-a500.o
 obj-$(CONFIG_LEDS_ADP5520)		+= leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)		+= leds-an30259a.o
 obj-$(CONFIG_LEDS_APU)			+= leds-apu.o
drivers/leds/leds-acer-a500.c new file +130 -0

130 lines not on this page · raw message

Signature · 1 line
2.27.0
#13 lore raw

PATCH v2 6/6 ARM: tegra: acer-a500: Add Embedded Controller

In reply to Dmitry Osipenko

This patch adds device-tree node for the Embedded Controller which is found on the Picasso board. The Embedded Controller itself is ENE KB930, it provides functions like battery-gauge/LED/GPIO/etc and it uses firmware that is specifically customized for the Acer A500 device.

---
 arch/arm/boot/dts/tegra20-acer-a500-picasso.dts | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm/boot/dts/tegra20-acer-a500-picasso.dts +17 -0
index 2d683c9a1a5d..f92712e4bd34 100644
@@ -502,6 +502,16 @@ panel_ddc: i2c@1 {
 			reg = <1>;
 			#address-cells = <1>;
 			#size-cells = <0>;
+
+			embedded-controller@58 {
+				compatible = "acer,a500-iconia-ec", "ene,kb930";
+				reg = <0x58>;
+
+				system-power-controller;
+
+				monitored-battery = <&bat1010>;
+				power-supplies = <&mains>;
+			};
 		};
 	};
 
@@ -780,6 +790,13 @@ backlight: backlight {
 		default-brightness-level = <20>;
 	};
 
+	bat1010: battery-2s1p {
+		compatible = "simple-battery";
+		charge-full-design-microamp-hours = <3260000>;
+		energy-full-design-microwatt-hours = <24000000>;
+		operating-range-celsius = <0 40>;
+	};
+
 	/* PMIC has a built-in 32KHz oscillator which is used by PMC */
 	clk32k_in: clock@0 {
 		compatible = "fixed-clock";
Signature · 1 line
2.27.0
maintainer
#14 lore raw
In reply to Dmitry Osipenko
Quoted 9 lines · Dmitry Osipenko

This series adds support for the Embedded Controller which is found on Acer Iconia Tab A500 (Android tablet device).

The Embedded Controller is ENE KB930 and it's running firmware customized for the A500. The firmware interface may be reused by some other sibling Acer tablets, although none of those tablets are supported in upstream yet. Please review and apply, thanks in advance!

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: Use flexible sleep

      commit: 2b32d2f7ce0a54ce74a75f0d939b5ee063a05ec5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark