[PATCH v2 2/3] input: misc: da9063_onkey: add mode change support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The pmic state machine behaviour upon a 'onkey press' event can be
configured using the ONKEY_PIN bit field. Most the time this is
configured correct by the OTP but sometimes we need to adjust the
behaviour so we need to add the support here.

Signed-off-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx>
---
v2:
- make use of da906x_chip_config
- rm unnecessary key_opmode

 drivers/input/misc/da9063_onkey.c | 16 ++++++++++++++++
 drivers/mfd/da9062-core.c         |  1 +
 2 files changed, 17 insertions(+)

diff --git a/drivers/input/misc/da9063_onkey.c b/drivers/input/misc/da9063_onkey.c
index 79851923ee57..3a3f06a33eda 100644
--- a/drivers/input/misc/da9063_onkey.c
+++ b/drivers/input/misc/da9063_onkey.c
@@ -19,6 +19,7 @@
 
 struct da906x_chip_config {
 	/* REGS */
+	int onkey_config;
 	int onkey_status;
 	int onkey_pwr_signalling;
 	int onkey_fault_log;
@@ -26,6 +27,7 @@ struct da906x_chip_config {
 	/* MASKS */
 	int onkey_nonkey_mask;
 	int onkey_nonkey_lock_mask;
+	int onkey_nonkey_pin_mask;
 	int onkey_key_reset_mask;
 	int onkey_shutdown_mask;
 	/* NAMES */
@@ -44,6 +46,7 @@ struct da9063_onkey {
 
 static const struct da906x_chip_config da9063_regs = {
 	/* REGS */
+	.onkey_config = DA9063_REG_CONFIG_I,
 	.onkey_status = DA9063_REG_STATUS_A,
 	.onkey_pwr_signalling = DA9063_REG_CONTROL_B,
 	.onkey_fault_log = DA9063_REG_FAULT_LOG,
@@ -51,6 +54,7 @@ static const struct da906x_chip_config da9063_regs = {
 	/* MASKS */
 	.onkey_nonkey_mask = DA9063_NONKEY,
 	.onkey_nonkey_lock_mask = DA9063_NONKEY_LOCK,
+	.onkey_nonkey_pin_mask = DA9063_NONKEY_PIN_MASK,
 	.onkey_key_reset_mask = DA9063_KEY_RESET,
 	.onkey_shutdown_mask = DA9063_SHUTDOWN,
 	/* NAMES */
@@ -59,6 +63,7 @@ static const struct da906x_chip_config da9063_regs = {
 
 static const struct da906x_chip_config da9062_regs = {
 	/* REGS */
+	.onkey_config = DA9062AA_CONFIG_I,
 	.onkey_status = DA9062AA_STATUS_A,
 	.onkey_pwr_signalling = DA9062AA_CONTROL_B,
 	.onkey_fault_log = DA9062AA_FAULT_LOG,
@@ -66,6 +71,7 @@ static const struct da906x_chip_config da9062_regs = {
 	/* MASKS */
 	.onkey_nonkey_mask = DA9062AA_NONKEY_MASK,
 	.onkey_nonkey_lock_mask = DA9062AA_NONKEY_LOCK_MASK,
+	.onkey_nonkey_pin_mask = DA9062AA_NONKEY_PIN_MASK,
 	.onkey_key_reset_mask = DA9062AA_KEY_RESET_MASK,
 	.onkey_shutdown_mask = DA9062AA_SHUTDOWN_MASK,
 	/* NAMES */
@@ -193,6 +199,7 @@ static int da9063_onkey_probe(struct platform_device *pdev)
 {
 	struct da9063_onkey *onkey;
 	const struct of_device_id *match;
+	unsigned int val;
 	int irq;
 	int error;
 
@@ -220,6 +227,15 @@ static int da9063_onkey_probe(struct platform_device *pdev)
 	onkey->key_power = !of_property_read_bool(pdev->dev.of_node,
 						  "dlg,disable-key-power");
 
+	if (!of_property_read_u32(pdev->dev.of_node, "dlg,key-opmode", &val)) {
+		error = regmap_update_bits(onkey->regmap,
+					   onkey->config->onkey_config,
+					   onkey->config->onkey_nonkey_pin_mask,
+					   val);
+		if (error)
+			return error;
+	}
+
 	onkey->input = devm_input_allocate_device(&pdev->dev);
 	if (!onkey->input) {
 		dev_err(&pdev->dev, "Failed to allocated input device.\n");
diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c
index e69626867c26..aaa1f1841bc3 100644
--- a/drivers/mfd/da9062-core.c
+++ b/drivers/mfd/da9062-core.c
@@ -510,6 +510,7 @@ static const struct regmap_range da9062_aa_writeable_ranges[] = {
 	regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B),
 	regmap_reg_range(DA9062AA_BBAT_CONT, DA9062AA_BBAT_CONT),
 	regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19),
+	regmap_reg_range(DA9062AA_CONFIG_I, DA9062AA_CONFIG_I),
 };
 
 static const struct regmap_range da9062_aa_volatile_ranges[] = {
-- 
2.20.1




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux