Skip to content

Commit 8ac8904

Browse files
Anjelique Melendezdtor
authored andcommitted
Input: pm8941-pwrkey - add support for PON GEN3 base addresses
Currently, PON address is read from the "reg" property. For PON GEN3, which starts with PMK8350, the "reg" property will have both the PON HLOS and PON PBS addesses defined. Add support so that all PON generations can be configured. Reviewed-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com> Link: https://lore.kernel.org/r/20220422191239.6271-4-quic_amelende@quicinc.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 2e7cfec commit 8ac8904

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

drivers/input/misc/pm8941-pwrkey.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/log2.h>
1313
#include <linux/module.h>
1414
#include <linux/of.h>
15+
#include <linux/of_address.h>
1516
#include <linux/of_device.h>
1617
#include <linux/platform_device.h>
1718
#include <linux/reboot.h>
@@ -45,6 +46,7 @@ struct pm8941_data {
4546
unsigned int status_bit;
4647
bool supports_ps_hold_poff_config;
4748
bool supports_debounce_config;
49+
bool has_pon_pbs;
4850
const char *name;
4951
const char *phys;
5052
};
@@ -53,6 +55,7 @@ struct pm8941_pwrkey {
5355
struct device *dev;
5456
int irq;
5557
u32 baseaddr;
58+
u32 pon_pbs_baseaddr;
5659
struct regmap *regmap;
5760
struct input_dev *input;
5861

@@ -171,6 +174,8 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
171174
struct pm8941_pwrkey *pwrkey;
172175
bool pull_up;
173176
struct device *parent;
177+
struct device_node *regmap_node;
178+
const __be32 *addr;
174179
u32 req_delay;
175180
int error;
176181

@@ -192,8 +197,10 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
192197
pwrkey->data = of_device_get_match_data(&pdev->dev);
193198

194199
parent = pdev->dev.parent;
200+
regmap_node = pdev->dev.of_node;
195201
pwrkey->regmap = dev_get_regmap(parent, NULL);
196202
if (!pwrkey->regmap) {
203+
regmap_node = parent->of_node;
197204
/*
198205
* We failed to get regmap for parent. Let's see if we are
199206
* a child of pon node and read regmap and reg from its
@@ -204,15 +211,21 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
204211
dev_err(&pdev->dev, "failed to locate regmap\n");
205212
return -ENODEV;
206213
}
214+
}
207215

208-
error = of_property_read_u32(parent->of_node,
209-
"reg", &pwrkey->baseaddr);
210-
} else {
211-
error = of_property_read_u32(pdev->dev.of_node, "reg",
212-
&pwrkey->baseaddr);
216+
addr = of_get_address(regmap_node, 0, NULL, NULL);
217+
if (!addr) {
218+
dev_err(&pdev->dev, "reg property missing\n");
219+
return -EINVAL;
220+
}
221+
pwrkey->baseaddr = be32_to_cpup(addr);
222+
223+
if (pwrkey->data->has_pon_pbs) {
224+
/* PON_PBS base address is optional */
225+
addr = of_get_address(regmap_node, 1, NULL, NULL);
226+
if (addr)
227+
pwrkey->pon_pbs_baseaddr = be32_to_cpup(addr);
213228
}
214-
if (error)
215-
return error;
216229

217230
pwrkey->irq = platform_get_irq(pdev, 0);
218231
if (pwrkey->irq < 0)
@@ -320,6 +333,7 @@ static const struct pm8941_data pwrkey_data = {
320333
.phys = "pm8941_pwrkey/input0",
321334
.supports_ps_hold_poff_config = true,
322335
.supports_debounce_config = true,
336+
.has_pon_pbs = false,
323337
};
324338

325339
static const struct pm8941_data resin_data = {
@@ -329,6 +343,7 @@ static const struct pm8941_data resin_data = {
329343
.phys = "pm8941_resin/input0",
330344
.supports_ps_hold_poff_config = true,
331345
.supports_debounce_config = true,
346+
.has_pon_pbs = false,
332347
};
333348

334349
static const struct pm8941_data pon_gen3_pwrkey_data = {
@@ -337,6 +352,7 @@ static const struct pm8941_data pon_gen3_pwrkey_data = {
337352
.phys = "pmic_pwrkey/input0",
338353
.supports_ps_hold_poff_config = false,
339354
.supports_debounce_config = false,
355+
.has_pon_pbs = true,
340356
};
341357

342358
static const struct pm8941_data pon_gen3_resin_data = {
@@ -345,6 +361,7 @@ static const struct pm8941_data pon_gen3_resin_data = {
345361
.phys = "pmic_resin/input0",
346362
.supports_ps_hold_poff_config = false,
347363
.supports_debounce_config = false,
364+
.has_pon_pbs = true,
348365
};
349366

350367
static const struct of_device_id pm8941_pwr_key_id_table[] = {

0 commit comments

Comments
 (0)