Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'intel-pinctrl-v5.12-1' of gitolite.kernel.org:pub/scm/linux/kernel/git/pinctrl/intel into devel

intel-pinctrl for v5.12-1

* Enable pin control on Intel Alder Lake-P
* Traverse through capabilities, convert them to features for the future use

The following is an automated git shortlog grouped by driver:

intel:
- Convert capability list to features
- Drop unnecessary check for predefined features
- Split intel_pinctrl_add_padgroups() for better maintenance

tigerlake:
- Add Alder Lake-P ACPI ID

+89 -35
+84 -35
drivers/pinctrl/intel/pinctrl-intel.c
··· 29 29 #define REVID_SHIFT 16 30 30 #define REVID_MASK GENMASK(31, 16) 31 31 32 + #define CAPLIST 0x004 33 + #define CAPLIST_ID_SHIFT 16 34 + #define CAPLIST_ID_MASK GENMASK(23, 16) 35 + #define CAPLIST_ID_GPIO_HW_INFO 1 36 + #define CAPLIST_ID_PWM 2 37 + #define CAPLIST_ID_BLINK 3 38 + #define CAPLIST_ID_EXP 4 39 + #define CAPLIST_NEXT_SHIFT 0 40 + #define CAPLIST_NEXT_MASK GENMASK(15, 0) 41 + 32 42 #define PADBAR 0x00c 33 43 34 44 #define PADOWN_BITS 4 ··· 1331 1321 return 0; 1332 1322 } 1333 1323 1334 - static int intel_pinctrl_add_padgroups(struct intel_pinctrl *pctrl, 1335 - struct intel_community *community) 1324 + static int intel_pinctrl_add_padgroups_by_gpps(struct intel_pinctrl *pctrl, 1325 + struct intel_community *community) 1336 1326 { 1337 1327 struct intel_padgroup *gpps; 1338 - unsigned int npins = community->npins; 1339 1328 unsigned int padown_num = 0; 1340 - size_t ngpps, i; 1341 - 1342 - if (community->gpps) 1343 - ngpps = community->ngpps; 1344 - else 1345 - ngpps = DIV_ROUND_UP(community->npins, community->gpp_size); 1329 + size_t i, ngpps = community->ngpps; 1346 1330 1347 1331 gpps = devm_kcalloc(pctrl->dev, ngpps, sizeof(*gpps), GFP_KERNEL); 1348 1332 if (!gpps) 1349 1333 return -ENOMEM; 1350 1334 1351 1335 for (i = 0; i < ngpps; i++) { 1352 - if (community->gpps) { 1353 - gpps[i] = community->gpps[i]; 1354 - } else { 1355 - unsigned int gpp_size = community->gpp_size; 1356 - 1357 - gpps[i].reg_num = i; 1358 - gpps[i].base = community->pin_base + i * gpp_size; 1359 - gpps[i].size = min(gpp_size, npins); 1360 - npins -= gpps[i].size; 1361 - } 1336 + gpps[i] = community->gpps[i]; 1362 1337 1363 1338 if (gpps[i].size > 32) 1364 1339 return -EINVAL; ··· 1360 1365 default: 1361 1366 break; 1362 1367 } 1368 + 1369 + gpps[i].padown_num = padown_num; 1370 + padown_num += DIV_ROUND_UP(gpps[i].size * 4, 32); 1371 + } 1372 + 1373 + community->gpps = gpps; 1374 + 1375 + return 0; 1376 + } 1377 + 1378 + static int intel_pinctrl_add_padgroups_by_size(struct intel_pinctrl *pctrl, 1379 + struct intel_community *community) 1380 + { 1381 + struct intel_padgroup *gpps; 1382 + unsigned int npins = community->npins; 1383 + unsigned int padown_num = 0; 1384 + size_t i, ngpps = DIV_ROUND_UP(npins, community->gpp_size); 1385 + 1386 + if (community->gpp_size > 32) 1387 + return -EINVAL; 1388 + 1389 + gpps = devm_kcalloc(pctrl->dev, ngpps, sizeof(*gpps), GFP_KERNEL); 1390 + if (!gpps) 1391 + return -ENOMEM; 1392 + 1393 + for (i = 0; i < ngpps; i++) { 1394 + unsigned int gpp_size = community->gpp_size; 1395 + 1396 + gpps[i].reg_num = i; 1397 + gpps[i].base = community->pin_base + i * gpp_size; 1398 + gpps[i].size = min(gpp_size, npins); 1399 + npins -= gpps[i].size; 1363 1400 1364 1401 gpps[i].padown_num = padown_num; 1365 1402 ··· 1482 1455 for (i = 0; i < pctrl->ncommunities; i++) { 1483 1456 struct intel_community *community = &pctrl->communities[i]; 1484 1457 void __iomem *regs; 1485 - u32 padbar; 1458 + u32 offset; 1459 + u32 value; 1486 1460 1487 1461 *community = pctrl->soc->communities[i]; 1488 1462 ··· 1491 1463 if (IS_ERR(regs)) 1492 1464 return PTR_ERR(regs); 1493 1465 1494 - /* 1495 - * Determine community features based on the revision if 1496 - * not specified already. 1497 - */ 1498 - if (!community->features) { 1499 - u32 rev; 1500 - 1501 - rev = (readl(regs + REVID) & REVID_MASK) >> REVID_SHIFT; 1502 - if (rev >= 0x94) { 1503 - community->features |= PINCTRL_FEATURE_DEBOUNCE; 1504 - community->features |= PINCTRL_FEATURE_1K_PD; 1505 - } 1466 + /* Determine community features based on the revision */ 1467 + value = readl(regs + REVID); 1468 + if (((value & REVID_MASK) >> REVID_SHIFT) >= 0x94) { 1469 + community->features |= PINCTRL_FEATURE_DEBOUNCE; 1470 + community->features |= PINCTRL_FEATURE_1K_PD; 1506 1471 } 1507 1472 1473 + /* Determine community features based on the capabilities */ 1474 + offset = CAPLIST; 1475 + do { 1476 + value = readl(regs + offset); 1477 + switch ((value & CAPLIST_ID_MASK) >> CAPLIST_ID_SHIFT) { 1478 + case CAPLIST_ID_GPIO_HW_INFO: 1479 + community->features |= PINCTRL_FEATURE_GPIO_HW_INFO; 1480 + break; 1481 + case CAPLIST_ID_PWM: 1482 + community->features |= PINCTRL_FEATURE_PWM; 1483 + break; 1484 + case CAPLIST_ID_BLINK: 1485 + community->features |= PINCTRL_FEATURE_BLINK; 1486 + break; 1487 + case CAPLIST_ID_EXP: 1488 + community->features |= PINCTRL_FEATURE_EXP; 1489 + break; 1490 + default: 1491 + break; 1492 + } 1493 + offset = (value & CAPLIST_NEXT_MASK) >> CAPLIST_NEXT_SHIFT; 1494 + } while (offset); 1495 + 1496 + dev_dbg(&pdev->dev, "Community%d features: %#08x\n", i, community->features); 1497 + 1508 1498 /* Read offset of the pad configuration registers */ 1509 - padbar = readl(regs + PADBAR); 1499 + offset = readl(regs + PADBAR); 1510 1500 1511 1501 community->regs = regs; 1512 - community->pad_regs = regs + padbar; 1502 + community->pad_regs = regs + offset; 1513 1503 1514 - ret = intel_pinctrl_add_padgroups(pctrl, community); 1504 + if (community->gpps) 1505 + ret = intel_pinctrl_add_padgroups_by_gpps(pctrl, community); 1506 + else 1507 + ret = intel_pinctrl_add_padgroups_by_size(pctrl, community); 1515 1508 if (ret) 1516 1509 return ret; 1517 1510 }
+4
drivers/pinctrl/intel/pinctrl-intel.h
··· 143 143 /* Additional features supported by the hardware */ 144 144 #define PINCTRL_FEATURE_DEBOUNCE BIT(0) 145 145 #define PINCTRL_FEATURE_1K_PD BIT(1) 146 + #define PINCTRL_FEATURE_GPIO_HW_INFO BIT(2) 147 + #define PINCTRL_FEATURE_PWM BIT(3) 148 + #define PINCTRL_FEATURE_BLINK BIT(4) 149 + #define PINCTRL_FEATURE_EXP BIT(5) 146 150 147 151 /** 148 152 * PIN_GROUP - Declare a pin group
+1
drivers/pinctrl/intel/pinctrl-tigerlake.c
··· 748 748 static const struct acpi_device_id tgl_pinctrl_acpi_match[] = { 749 749 { "INT34C5", (kernel_ulong_t)&tgllp_soc_data }, 750 750 { "INT34C6", (kernel_ulong_t)&tglh_soc_data }, 751 + { "INTC1055", (kernel_ulong_t)&tgllp_soc_data }, 751 752 { } 752 753 }; 753 754 MODULE_DEVICE_TABLE(acpi, tgl_pinctrl_acpi_match);