Skip to content

Commit a229105

Browse files
Lee Joneslinusw
authored andcommitted
pinctrl: qcom: sdm845: Provide ACPI support
This patch provides basic support for booting with ACPI instead of the currently supported Device Tree. When doing so there are a couple of differences which we need to taken into consideration. Firstly, the SDM850 ACPI tables omit information pertaining to the 4 reserved GPIOs on the platform. If Linux attempts to touch/ initialise any of these lines, the firmware will restart the platform. Secondly, when booting with ACPI, it is expected that the firmware will set-up things like; Regulators, Clocks, Pin Functions, etc in their ideal configuration. Thus, the possible Pin Functions available to this platform are not advertised when providing the higher GPIOD/Pinctrl APIs with pin information. Signed-off-by: Lee Jones <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 4c0efbf commit a229105

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

drivers/pinctrl/qcom/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ config PINCTRL_SDM660
168168

169169
config PINCTRL_SDM845
170170
tristate "Qualcomm Technologies Inc SDM845 pin controller driver"
171-
depends on GPIOLIB && OF
171+
depends on GPIOLIB && (OF || ACPI)
172172
select PINCTRL_MSM
173173
help
174174
This is the pinctrl, pinmux, pinconf and gpiolib driver for the

drivers/pinctrl/qcom/pinctrl-sdm845.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
44
*/
55

6+
#include <linux/acpi.h>
67
#include <linux/module.h>
78
#include <linux/of.h>
89
#include <linux/platform_device.h>
@@ -1277,6 +1278,10 @@ static const struct msm_pingroup sdm845_groups[] = {
12771278
UFS_RESET(ufs_reset, 0x99f000),
12781279
};
12791280

1281+
static const int sdm845_acpi_reserved_gpios[] = {
1282+
0, 1, 2, 3, 81, 82, 83, 84, -1
1283+
};
1284+
12801285
static const struct msm_pinctrl_soc_data sdm845_pinctrl = {
12811286
.pins = sdm845_pins,
12821287
.npins = ARRAY_SIZE(sdm845_pins),
@@ -1287,11 +1292,39 @@ static const struct msm_pinctrl_soc_data sdm845_pinctrl = {
12871292
.ngpios = 150,
12881293
};
12891294

1295+
static const struct msm_pinctrl_soc_data sdm845_acpi_pinctrl = {
1296+
.pins = sdm845_pins,
1297+
.npins = ARRAY_SIZE(sdm845_pins),
1298+
.groups = sdm845_groups,
1299+
.ngroups = ARRAY_SIZE(sdm845_groups),
1300+
.reserved_gpios = sdm845_acpi_reserved_gpios,
1301+
.ngpios = 150,
1302+
};
1303+
12901304
static int sdm845_pinctrl_probe(struct platform_device *pdev)
12911305
{
1292-
return msm_pinctrl_probe(pdev, &sdm845_pinctrl);
1306+
int ret;
1307+
1308+
if (pdev->dev.of_node) {
1309+
ret = msm_pinctrl_probe(pdev, &sdm845_pinctrl);
1310+
} else if (has_acpi_companion(&pdev->dev)) {
1311+
ret = msm_pinctrl_probe(pdev, &sdm845_acpi_pinctrl);
1312+
} else {
1313+
dev_err(&pdev->dev, "DT and ACPI disabled\n");
1314+
return -EINVAL;
1315+
}
1316+
1317+
return ret;
12931318
}
12941319

1320+
#if CONFIG_ACPI
1321+
static const struct acpi_device_id sdm845_pinctrl_acpi_match[] = {
1322+
{ "QCOM0217"},
1323+
{ },
1324+
};
1325+
MODULE_DEVICE_TABLE(acpi, sdm845_pinctrl_acpi_match);
1326+
#endif
1327+
12951328
static const struct of_device_id sdm845_pinctrl_of_match[] = {
12961329
{ .compatible = "qcom,sdm845-pinctrl", },
12971330
{ },
@@ -1302,6 +1335,7 @@ static struct platform_driver sdm845_pinctrl_driver = {
13021335
.name = "sdm845-pinctrl",
13031336
.pm = &msm_pinctrl_dev_pm_ops,
13041337
.of_match_table = sdm845_pinctrl_of_match,
1338+
.acpi_match_table = ACPI_PTR(sdm845_pinctrl_acpi_match),
13051339
},
13061340
.probe = sdm845_pinctrl_probe,
13071341
.remove = msm_pinctrl_remove,

0 commit comments

Comments
 (0)