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

Merge tag 'omap-for-v5.5/ti-sysc-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into arm/drivers

Changes for ti-sysc interconnect target module driver for v5.5

A series of changes from Tero Kristo for rpm reset control
driver to deal with the ordering requirements between clocks
and resets, and two changes to deal with quirks for musb otg
device.

* tag 'omap-for-v5.5/ti-sysc-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap:
bus: ti-sysc: Use swsup quirks also for am335x musb
bus: ti-sysc: Handle mstandby quirk and use it for musb
bus: ti-sysc: Fix watchdog quirk handling
bus: ti-sysc: avoid toggling power state of module during probe
bus: ti-sysc: drop the extra hardreset during init
bus: ti-sysc: re-order reset and main clock controls

Link: https://lore.kernel.org/r/pull-1571853258-16998@atomide.com-2
Signed-off-by: Olof Johansson <olof@lixom.net>

+47 -58
+47 -58
drivers/bus/ti-sysc.c
··· 74 74 * @clk_disable_quirk: module specific clock disable quirk 75 75 * @reset_done_quirk: module specific reset done quirk 76 76 * @module_enable_quirk: module specific enable quirk 77 + * @module_disable_quirk: module specific disable quirk 77 78 */ 78 79 struct sysc { 79 80 struct device *dev; ··· 101 100 void (*clk_disable_quirk)(struct sysc *sysc); 102 101 void (*reset_done_quirk)(struct sysc *sysc); 103 102 void (*module_enable_quirk)(struct sysc *sysc); 103 + void (*module_disable_quirk)(struct sysc *sysc); 104 104 }; 105 105 106 106 static void sysc_parse_dts_quirks(struct sysc *ddata, struct device_node *np, ··· 917 915 return -EINVAL; 918 916 } 919 917 918 + if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_MSTANDBY) 919 + best_mode = SYSC_IDLE_NO; 920 + 920 921 reg &= ~(SYSC_IDLE_MASK << regbits->midle_shift); 921 922 reg |= best_mode << regbits->midle_shift; 922 923 sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); ··· 964 959 if (ddata->offsets[SYSC_SYSCONFIG] == -ENODEV) 965 960 return 0; 966 961 962 + if (ddata->module_disable_quirk) 963 + ddata->module_disable_quirk(ddata); 964 + 967 965 regbits = ddata->cap->regbits; 968 966 reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); 969 967 ··· 980 972 dev_err(dev, "%s: invalid midlemode\n", __func__); 981 973 return ret; 982 974 } 975 + 976 + if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_MSTANDBY) 977 + best_mode = SYSC_IDLE_FORCE; 983 978 984 979 reg &= ~(SYSC_IDLE_MASK << regbits->midle_shift); 985 980 reg |= best_mode << regbits->midle_shift; ··· 1043 1032 struct ti_sysc_platform_data *pdata; 1044 1033 int error; 1045 1034 1046 - reset_control_deassert(ddata->rsts); 1047 - 1048 1035 pdata = dev_get_platdata(ddata->dev); 1049 1036 if (!pdata) 1050 1037 return 0; ··· 1054 1045 if (error) 1055 1046 dev_err(dev, "%s: could not enable: %i\n", 1056 1047 __func__, error); 1048 + 1049 + reset_control_deassert(ddata->rsts); 1057 1050 1058 1051 return 0; 1059 1052 } ··· 1110 1099 1111 1100 sysc_clkdm_deny_idle(ddata); 1112 1101 1113 - reset_control_deassert(ddata->rsts); 1114 - 1115 1102 if (sysc_opt_clks_needed(ddata)) { 1116 1103 error = sysc_enable_opt_clocks(ddata); 1117 1104 if (error) ··· 1119 1110 error = sysc_enable_main_clocks(ddata); 1120 1111 if (error) 1121 1112 goto err_opt_clocks; 1113 + 1114 + reset_control_deassert(ddata->rsts); 1122 1115 1123 1116 if (ddata->legacy_mode) { 1124 1117 error = sysc_runtime_resume_legacy(dev, ddata); ··· 1257 1246 SYSC_QUIRK("gpu", 0x50000000, 0x14, -1, -1, 0x00010201, 0xffffffff, 0), 1258 1247 SYSC_QUIRK("gpu", 0x50000000, 0xfe00, 0xfe10, -1, 0x40000000 , 0xffffffff, 1259 1248 SYSC_MODULE_QUIRK_SGX), 1249 + SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050, 1250 + 0xffffffff, SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY), 1251 + SYSC_QUIRK("usb_otg_hs", 0, 0, 0x10, -1, 0x4ea2080d, 0xffffffff, 1252 + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY), 1260 1253 SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xfffff0f0, 1261 1254 SYSC_MODULE_QUIRK_WDT), 1255 + /* Watchdog on am3 and am4 */ 1256 + SYSC_QUIRK("wdt", 0x44e35000, 0, 0x10, 0x14, 0x502a0500, 0xfffff0f0, 1257 + SYSC_MODULE_QUIRK_WDT | SYSC_QUIRK_SWSUP_SIDLE), 1262 1258 1263 1259 #ifdef DEBUG 1264 1260 SYSC_QUIRK("adc", 0, 0, 0x10, -1, 0x47300001, 0xffffffff, 0), ··· 1319 1301 SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000008, 0xffffffff, 0), 1320 1302 SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff, 0), 1321 1303 SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -1, 0x50700101, 0xffffffff, 0), 1322 - SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050, 1323 - 0xffffffff, 0), 1324 1304 SYSC_QUIRK("vfpe", 0, 0, 0x104, -1, 0x4d001200, 0xffffffff, 0), 1325 1305 #endif 1326 1306 }; ··· 1456 1440 !(val & 0x10), 100, 1457 1441 MAX_MODULE_SOFTRESET_WAIT); 1458 1442 if (error) 1459 - dev_warn(ddata->dev, "wdt disable spr failed\n"); 1443 + dev_warn(ddata->dev, "wdt disable step1 failed\n"); 1460 1444 1461 - sysc_write(ddata, wps, 0x5555); 1445 + sysc_write(ddata, spr, 0x5555); 1462 1446 error = readl_poll_timeout(ddata->module_va + wps, val, 1463 1447 !(val & 0x10), 100, 1464 1448 MAX_MODULE_SOFTRESET_WAIT); 1465 1449 if (error) 1466 - dev_warn(ddata->dev, "wdt disable wps failed\n"); 1450 + dev_warn(ddata->dev, "wdt disable step2 failed\n"); 1467 1451 } 1468 1452 1469 1453 static void sysc_init_module_quirks(struct sysc *ddata) ··· 1487 1471 if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_SGX) 1488 1472 ddata->module_enable_quirk = sysc_module_enable_quirk_sgx; 1489 1473 1490 - if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_WDT) 1474 + if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_WDT) { 1491 1475 ddata->reset_done_quirk = sysc_reset_done_quirk_wdt; 1476 + ddata->module_disable_quirk = sysc_reset_done_quirk_wdt; 1477 + } 1492 1478 } 1493 1479 1494 1480 static int sysc_clockdomain_init(struct sysc *ddata) ··· 1538 1520 error = 0; 1539 1521 1540 1522 return error; 1541 - } 1542 - 1543 - /** 1544 - * sysc_rstctrl_reset_deassert - deassert rstctrl reset 1545 - * @ddata: device driver data 1546 - * @reset: reset before deassert 1547 - * 1548 - * A module can have both OCP softreset control and external rstctrl. 1549 - * If more complicated rstctrl resets are needed, please handle these 1550 - * directly from the child device driver and map only the module reset 1551 - * for the parent interconnect target module device. 1552 - * 1553 - * Automatic reset of the module on init can be skipped with the 1554 - * "ti,no-reset-on-init" device tree property. 1555 - */ 1556 - static int sysc_rstctrl_reset_deassert(struct sysc *ddata, bool reset) 1557 - { 1558 - int error; 1559 - 1560 - if (!ddata->rsts) 1561 - return 0; 1562 - 1563 - if (reset) { 1564 - error = reset_control_assert(ddata->rsts); 1565 - if (error) 1566 - return error; 1567 - } 1568 - 1569 - reset_control_deassert(ddata->rsts); 1570 - 1571 - return 0; 1572 1523 } 1573 1524 1574 1525 /* ··· 1602 1615 static int sysc_init_module(struct sysc *ddata) 1603 1616 { 1604 1617 int error = 0; 1605 - bool manage_clocks = true; 1606 - 1607 - error = sysc_rstctrl_reset_deassert(ddata, false); 1608 - if (error) 1609 - return error; 1610 - 1611 - if (ddata->cfg.quirks & 1612 - (SYSC_QUIRK_NO_IDLE | SYSC_QUIRK_NO_IDLE_ON_INIT)) 1613 - manage_clocks = false; 1614 1618 1615 1619 error = sysc_clockdomain_init(ddata); 1616 1620 if (error) ··· 1622 1644 goto err_opt_clocks; 1623 1645 1624 1646 if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) { 1625 - error = sysc_rstctrl_reset_deassert(ddata, true); 1647 + error = reset_control_deassert(ddata->rsts); 1626 1648 if (error) 1627 1649 goto err_main_clocks; 1628 1650 } ··· 1634 1656 if (ddata->legacy_mode) { 1635 1657 error = sysc_legacy_init(ddata); 1636 1658 if (error) 1637 - goto err_main_clocks; 1659 + goto err_reset; 1638 1660 } 1639 1661 1640 1662 if (!ddata->legacy_mode) { 1641 1663 error = sysc_enable_module(ddata->dev); 1642 1664 if (error) 1643 - goto err_main_clocks; 1665 + goto err_reset; 1644 1666 } 1645 1667 1646 1668 error = sysc_reset(ddata); 1647 1669 if (error) 1648 1670 dev_err(ddata->dev, "Reset failed with %d\n", error); 1649 1671 1650 - if (!ddata->legacy_mode && manage_clocks) 1672 + if (error && !ddata->legacy_mode) 1651 1673 sysc_disable_module(ddata->dev); 1652 1674 1675 + err_reset: 1676 + if (error && !(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) 1677 + reset_control_assert(ddata->rsts); 1678 + 1653 1679 err_main_clocks: 1654 - if (manage_clocks) 1680 + if (error) 1655 1681 sysc_disable_main_clocks(ddata); 1656 1682 err_opt_clocks: 1657 1683 /* No re-enable of clockdomain autoidle to prevent module autoidle */ 1658 - if (manage_clocks) { 1684 + if (error) { 1659 1685 sysc_disable_opt_clocks(ddata); 1660 1686 sysc_clkdm_allow_idle(ddata); 1661 1687 } ··· 2432 2450 goto unprepare; 2433 2451 } 2434 2452 2435 - /* Balance reset counts */ 2436 - if (ddata->rsts) 2453 + /* Balance use counts as PM runtime should have enabled these all */ 2454 + if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) 2437 2455 reset_control_assert(ddata->rsts); 2456 + 2457 + if (!(ddata->cfg.quirks & 2458 + (SYSC_QUIRK_NO_IDLE | SYSC_QUIRK_NO_IDLE_ON_INIT))) { 2459 + sysc_disable_main_clocks(ddata); 2460 + sysc_disable_opt_clocks(ddata); 2461 + sysc_clkdm_allow_idle(ddata); 2462 + } 2438 2463 2439 2464 sysc_show_registers(ddata); 2440 2465