armbian-build/patch/kernel/archive/sunxi-5.19/patches.megous/input-pinephone-keyboard-Add-support-for-VBAT-regulator.patch
The-going 97c6e5e9dd
sunxi-5.19: Initial state for megous patches (#4048)
* sunxi-5.19: Initial state for megous patches

* Add the ability to do 5.19

* Move to 5.19

- tested both
- removed broken Opi Zero xradio driver https://armbian.atlassian.net/browse/AR-1280

* sunxi-5.19: fix tag for switch

* sunxi-5.19: Initial state for armbian patches

* sunxi-5.19: Add armbian patches to series.conf file

* sanxi-5.19: Add other 2 patches

* sunxi-5.19: Limit to use the 'wireless/xradio' module

Limit the kernel version to less than 5.19 to use
the 'wireless/xradio' module

Co-authored-by: Igor Pecovnik <igor.pecovnik@gmail.com>
2022-08-05 21:23:49 +03:00

79 lines
2.3 KiB
Diff

From 653325e5694e0c8e26bc4e6a7628d9b3ba9c42e3 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Sun, 3 Apr 2022 16:25:10 +0200
Subject: [PATCH 389/417] input: pinephone-keyboard: Add support for VBAT
regulator
This needs to be enabled for stable usage. If not, the keyboard
MCU may be browning out when phone's VBAT is low.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
drivers/input/keyboard/pinephone-keyboard.c | 22 +++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/input/keyboard/pinephone-keyboard.c b/drivers/input/keyboard/pinephone-keyboard.c
index 7d2e16e58..b1e951cbb 100644
--- a/drivers/input/keyboard/pinephone-keyboard.c
+++ b/drivers/input/keyboard/pinephone-keyboard.c
@@ -8,6 +8,7 @@
#include <linux/input/matrix_keypad.h>
#include <linux/interrupt.h>
#include <linux/module.h>
+#include <linux/regulator/consumer.h>
#define DRV_NAME "pinephone-keyboard"
@@ -139,6 +140,7 @@ static const struct matrix_keymap_data ppkb_default_keymap_data = {
struct pinephone_keyboard {
struct i2c_adapter adapter;
+ struct regulator *vbat_supply;
struct input_dev *input;
unsigned short *fn_keymap;
u8 crc_table[CRC8_TABLE_SIZE];
@@ -371,6 +373,11 @@ static int ppkb_probe(struct i2c_client *client)
i2c_set_clientdata(client, ppkb);
+ ppkb->vbat_supply = devm_regulator_get(dev, "vbat");
+ if (IS_ERR(ppkb->vbat_supply))
+ return dev_err_probe(dev, PTR_ERR(ppkb->vbat_supply),
+ "Failed to get vbat_supply\n");
+
i2c_bus = of_get_child_by_name(dev->of_node, "i2c-bus");
if (i2c_bus) {
ppkb->adapter.owner = THIS_MODULE;
@@ -426,6 +433,20 @@ static int ppkb_probe(struct i2c_client *client)
if (ret)
return dev_err_probe(dev, ret, "Failed to request IRQ\n");
+ ret = regulator_enable(ppkb->vbat_supply);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to enable keyboard vbat supply\n");
+
+ return 0;
+}
+
+static int ppkb_remove(struct i2c_client *client)
+{
+ struct pinephone_keyboard *ppkb = i2c_get_clientdata(client);
+
+ regulator_disable(ppkb->vbat_supply);
+
return 0;
}
@@ -437,6 +458,7 @@ MODULE_DEVICE_TABLE(of, ppkb_of_match);
static struct i2c_driver ppkb_driver = {
.probe_new = ppkb_probe,
+ .remove = ppkb_remove,
.driver = {
.name = DRV_NAME,
.of_match_table = ppkb_of_match,
--
2.35.3