hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/pinctrl/qcom/pinctrl-sdm845.c
....@@ -1,8 +1,9 @@
11 // SPDX-License-Identifier: GPL-2.0
22 /*
3
- * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
3
+ * Copyright (c) 2016-2019, 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>
....@@ -261,10 +262,10 @@
261262 PINCTRL_PIN(147, "GPIO_147"),
262263 PINCTRL_PIN(148, "GPIO_148"),
263264 PINCTRL_PIN(149, "GPIO_149"),
264
- PINCTRL_PIN(150, "SDC2_CLK"),
265
- PINCTRL_PIN(151, "SDC2_CMD"),
266
- PINCTRL_PIN(152, "SDC2_DATA"),
267
- PINCTRL_PIN(153, "UFS_RESET"),
265
+ PINCTRL_PIN(150, "UFS_RESET"),
266
+ PINCTRL_PIN(151, "SDC2_CLK"),
267
+ PINCTRL_PIN(152, "SDC2_CMD"),
268
+ PINCTRL_PIN(153, "SDC2_DATA"),
268269 };
269270
270271 #define DECLARE_MSM_GPIO_PINS(pin) \
....@@ -420,10 +421,10 @@
420421 DECLARE_MSM_GPIO_PINS(148);
421422 DECLARE_MSM_GPIO_PINS(149);
422423
423
-static const unsigned int sdc2_clk_pins[] = { 150 };
424
-static const unsigned int sdc2_cmd_pins[] = { 151 };
425
-static const unsigned int sdc2_data_pins[] = { 152 };
426
-static const unsigned int ufs_reset_pins[] = { 153 };
424
+static const unsigned int ufs_reset_pins[] = { 150 };
425
+static const unsigned int sdc2_clk_pins[] = { 151 };
426
+static const unsigned int sdc2_cmd_pins[] = { 152 };
427
+static const unsigned int sdc2_data_pins[] = { 153 };
427428
428429 enum sdm845_functions {
429430 msm_mux_gpio,
....@@ -1271,10 +1272,32 @@
12711272 PINGROUP(147, NORTH, _, _, _, _, _, _, _, _, _, _),
12721273 PINGROUP(148, NORTH, _, _, _, _, _, _, _, _, _, _),
12731274 PINGROUP(149, NORTH, _, _, _, _, _, _, _, _, _, _),
1275
+ UFS_RESET(ufs_reset, 0x99f000),
12741276 SDC_QDSD_PINGROUP(sdc2_clk, 0x99a000, 14, 6),
12751277 SDC_QDSD_PINGROUP(sdc2_cmd, 0x99a000, 11, 3),
12761278 SDC_QDSD_PINGROUP(sdc2_data, 0x99a000, 9, 0),
1277
- UFS_RESET(ufs_reset, 0x99f000),
1279
+};
1280
+
1281
+static const int sdm845_acpi_reserved_gpios[] = {
1282
+ 0, 1, 2, 3, 81, 82, 83, 84, -1
1283
+};
1284
+
1285
+static const struct msm_gpio_wakeirq_map sdm845_pdc_map[] = {
1286
+ { 1, 30 }, { 3, 31 }, { 5, 32 }, { 10, 33 }, { 11, 34 },
1287
+ { 20, 35 }, { 22, 36 }, { 24, 37 }, { 26, 38 }, { 30, 39 },
1288
+ { 31, 117 }, { 32, 41 }, { 34, 42 }, { 36, 43 }, { 37, 44 },
1289
+ { 38, 45 }, { 39, 46 }, { 40, 47 }, { 41, 115 }, { 43, 49 },
1290
+ { 44, 50 }, { 46, 51 }, { 48, 52 }, { 49, 118 }, { 52, 54 },
1291
+ { 53, 55 }, { 54, 56 }, { 56, 57 }, { 57, 58 }, { 58, 59 },
1292
+ { 59, 60 }, { 60, 61 }, { 61, 62 }, { 62, 63 }, { 63, 64 },
1293
+ { 64, 65 }, { 66, 66 }, { 68, 67 }, { 71, 68 }, { 73, 69 },
1294
+ { 77, 70 }, { 78, 71 }, { 79, 72 }, { 80, 73 }, { 84, 74 },
1295
+ { 85, 75 }, { 86, 76 }, { 88, 77 }, { 89, 116 }, { 91, 79 },
1296
+ { 92, 80 }, { 95, 81 }, { 96, 82 }, { 97, 83 }, { 101, 84 },
1297
+ { 103, 85 }, { 104, 86 }, { 115, 90 }, { 116, 91 }, { 117, 92 },
1298
+ { 118, 93 }, { 119, 94 }, { 120, 95 }, { 121, 96 }, { 122, 97 },
1299
+ { 123, 98 }, { 124, 99 }, { 125, 100 }, { 127, 102 }, { 128, 103 },
1300
+ { 129, 104 }, { 130, 105 }, { 132, 106 }, { 133, 107 }, { 145, 108 },
12781301 };
12791302
12801303 static const struct msm_pinctrl_soc_data sdm845_pinctrl = {
....@@ -1284,13 +1307,44 @@
12841307 .nfunctions = ARRAY_SIZE(sdm845_functions),
12851308 .groups = sdm845_groups,
12861309 .ngroups = ARRAY_SIZE(sdm845_groups),
1310
+ .ngpios = 151,
1311
+ .wakeirq_map = sdm845_pdc_map,
1312
+ .nwakeirq_map = ARRAY_SIZE(sdm845_pdc_map),
1313
+ .wakeirq_dual_edge_errata = true,
1314
+};
1315
+
1316
+static const struct msm_pinctrl_soc_data sdm845_acpi_pinctrl = {
1317
+ .pins = sdm845_pins,
1318
+ .npins = ARRAY_SIZE(sdm845_pins),
1319
+ .groups = sdm845_groups,
1320
+ .ngroups = ARRAY_SIZE(sdm845_groups),
1321
+ .reserved_gpios = sdm845_acpi_reserved_gpios,
12871322 .ngpios = 150,
12881323 };
12891324
12901325 static int sdm845_pinctrl_probe(struct platform_device *pdev)
12911326 {
1292
- return msm_pinctrl_probe(pdev, &sdm845_pinctrl);
1327
+ int ret;
1328
+
1329
+ if (pdev->dev.of_node) {
1330
+ ret = msm_pinctrl_probe(pdev, &sdm845_pinctrl);
1331
+ } else if (has_acpi_companion(&pdev->dev)) {
1332
+ ret = msm_pinctrl_probe(pdev, &sdm845_acpi_pinctrl);
1333
+ } else {
1334
+ dev_err(&pdev->dev, "DT and ACPI disabled\n");
1335
+ return -EINVAL;
1336
+ }
1337
+
1338
+ return ret;
12931339 }
1340
+
1341
+#ifdef CONFIG_ACPI
1342
+static const struct acpi_device_id sdm845_pinctrl_acpi_match[] = {
1343
+ { "QCOM0217"},
1344
+ { },
1345
+};
1346
+MODULE_DEVICE_TABLE(acpi, sdm845_pinctrl_acpi_match);
1347
+#endif
12941348
12951349 static const struct of_device_id sdm845_pinctrl_of_match[] = {
12961350 { .compatible = "qcom,sdm845-pinctrl", },
....@@ -1300,7 +1354,9 @@
13001354 static struct platform_driver sdm845_pinctrl_driver = {
13011355 .driver = {
13021356 .name = "sdm845-pinctrl",
1357
+ .pm = &msm_pinctrl_dev_pm_ops,
13031358 .of_match_table = sdm845_pinctrl_of_match,
1359
+ .acpi_match_table = ACPI_PTR(sdm845_pinctrl_acpi_match),
13041360 },
13051361 .probe = sdm845_pinctrl_probe,
13061362 .remove = msm_pinctrl_remove,