Commit 57918dfa authored by Stephen Boyd's avatar Stephen Boyd Committed by Dmitry Torokhov

Input: pmic8xxx-pwrkey - migrate to DT

The driver is only supported on DT enabled platforms. Convert the
driver to DT so that it can probe properly.
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 86ea5e6b
Qualcomm PM8xxx PMIC Power Key
PROPERTIES
- compatible:
Usage: required
Value type: <string>
Definition: must be one of:
"qcom,pm8058-pwrkey"
"qcom,pm8921-pwrkey"
- reg:
Usage: required
Value type: <prop-encoded-array>
Definition: address of power key control register
- interrupts:
Usage: required
Value type: <prop-encoded-array>
Definition: the first interrupt specifies the key release interrupt
and the second interrupt specifies the key press interrupt.
The format of the specifier is defined by the binding
document describing the node's interrupt parent.
- debounce:
Usage: optional
Value type: <u32>
Definition: time in microseconds that key must be pressed or release
for state change interrupt to trigger.
- pull-up:
Usage: optional
Value type: <empty>
Definition: presence of this property indicates that the KPDPWR_N pin
should be configured for pull up.
EXAMPLE
pwrkey@1c {
compatible = "qcom,pm8921-pwrkey";
reg = <0x1c>;
interrupt-parent = <&pmicintc>;
interrupts = <50 1>, <51 1>;
debounce = <15625>;
pull-up;
};
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/of.h>
#include <linux/input/pmic8xxx-pwrkey.h>
#define PON_CNTL_1 0x1C #define PON_CNTL_1 0x1C
#define PON_CNTL_PULL_UP BIT(7) #define PON_CNTL_PULL_UP BIT(7)
...@@ -89,15 +88,15 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev) ...@@ -89,15 +88,15 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev)
unsigned int pon_cntl; unsigned int pon_cntl;
struct regmap *regmap; struct regmap *regmap;
struct pmic8xxx_pwrkey *pwrkey; struct pmic8xxx_pwrkey *pwrkey;
const struct pm8xxx_pwrkey_platform_data *pdata = u32 kpd_delay;
dev_get_platdata(&pdev->dev); bool pull_up;
if (!pdata) { if (of_property_read_u32(pdev->dev.of_node, "debounce", &kpd_delay))
dev_err(&pdev->dev, "power key platform data not supplied\n"); kpd_delay = 0;
return -EINVAL;
}
if (pdata->kpd_trigger_delay_us > 62500) { pull_up = of_property_read_bool(pdev->dev.of_node, "pull-up");
if (kpd_delay > 62500) {
dev_err(&pdev->dev, "invalid power key trigger delay\n"); dev_err(&pdev->dev, "invalid power key trigger delay\n");
return -EINVAL; return -EINVAL;
} }
...@@ -125,7 +124,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev) ...@@ -125,7 +124,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev)
pwr->name = "pmic8xxx_pwrkey"; pwr->name = "pmic8xxx_pwrkey";
pwr->phys = "pmic8xxx_pwrkey/input0"; pwr->phys = "pmic8xxx_pwrkey/input0";
delay = (pdata->kpd_trigger_delay_us << 10) / USEC_PER_SEC; delay = (kpd_delay << 10) / USEC_PER_SEC;
delay = 1 + ilog2(delay); delay = 1 + ilog2(delay);
err = regmap_read(regmap, PON_CNTL_1, &pon_cntl); err = regmap_read(regmap, PON_CNTL_1, &pon_cntl);
...@@ -136,7 +135,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev) ...@@ -136,7 +135,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev)
pon_cntl &= ~PON_CNTL_TRIG_DELAY_MASK; pon_cntl &= ~PON_CNTL_TRIG_DELAY_MASK;
pon_cntl |= (delay & PON_CNTL_TRIG_DELAY_MASK); pon_cntl |= (delay & PON_CNTL_TRIG_DELAY_MASK);
if (pdata->pull_up) if (pull_up)
pon_cntl |= PON_CNTL_PULL_UP; pon_cntl |= PON_CNTL_PULL_UP;
else else
pon_cntl &= ~PON_CNTL_PULL_UP; pon_cntl &= ~PON_CNTL_PULL_UP;
...@@ -172,7 +171,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev) ...@@ -172,7 +171,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev)
} }
platform_set_drvdata(pdev, pwrkey); platform_set_drvdata(pdev, pwrkey);
device_init_wakeup(&pdev->dev, pdata->wakeup); device_init_wakeup(&pdev->dev, 1);
return 0; return 0;
} }
...@@ -184,13 +183,21 @@ static int pmic8xxx_pwrkey_remove(struct platform_device *pdev) ...@@ -184,13 +183,21 @@ static int pmic8xxx_pwrkey_remove(struct platform_device *pdev)
return 0; return 0;
} }
static const struct of_device_id pm8xxx_pwr_key_id_table[] = {
{ .compatible = "qcom,pm8058-pwrkey" },
{ .compatible = "qcom,pm8921-pwrkey" },
{ }
};
MODULE_DEVICE_TABLE(of, pm8xxx_pwr_key_id_table);
static struct platform_driver pmic8xxx_pwrkey_driver = { static struct platform_driver pmic8xxx_pwrkey_driver = {
.probe = pmic8xxx_pwrkey_probe, .probe = pmic8xxx_pwrkey_probe,
.remove = pmic8xxx_pwrkey_remove, .remove = pmic8xxx_pwrkey_remove,
.driver = { .driver = {
.name = PM8XXX_PWRKEY_DEV_NAME, .name = "pm8xxx-pwrkey",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.pm = &pm8xxx_pwr_key_pm_ops, .pm = &pm8xxx_pwr_key_pm_ops,
.of_match_table = pm8xxx_pwr_key_id_table,
}, },
}; };
module_platform_driver(pmic8xxx_pwrkey_driver); module_platform_driver(pmic8xxx_pwrkey_driver);
......
/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __PMIC8XXX_PWRKEY_H__
#define __PMIC8XXX_PWRKEY_H__
#define PM8XXX_PWRKEY_DEV_NAME "pm8xxx-pwrkey"
/**
* struct pm8xxx_pwrkey_platform_data - platform data for pwrkey driver
* @pull up: power on register control for pull up/down configuration
* @kpd_trigger_delay_us: time delay for power key state change interrupt
* trigger.
* @wakeup: configure power key as wakeup source
*/
struct pm8xxx_pwrkey_platform_data {
bool pull_up;
u32 kpd_trigger_delay_us;
u32 wakeup;
};
#endif /* __PMIC8XXX_PWRKEY_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment