History

Merge tag 'drivers-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM SoC driver updates from Arnd Bergmann: "There are cleanups and minor bugfixes across several SoC specific drivers, for Qualcomm, Samsung, NXP i.MX, AT91, Tegra, Keystone, Renesas, ZynqMP Noteworthy new features are: - The op-tee firmware driver gains support for asynchronous notifications from secure-world firmware. - Qualcomm platforms gain support for new SoC types in various drivers: power domain, cache controller, RPM sleep, soc-info - Samsung SoC drivers gain support for new SoCs in ChipID and PMU, as well as a new USIv2 driver that handles various types of serial communiction (uart, i2c, spi) - Renesas adds support for R-Car S4-8 (R8A779F0) in multiple drivers, as well as memory controller support for RZ/G2L (R9A07G044). - Apple M1 gains support for the PMGR power management driver" * tag 'drivers-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (94 commits) soc: qcom: rpmh-rsc: Fix typo in a comment soc: qcom: socinfo: Add SM6350 and SM7225 dt-bindings: arm: msm: Don't mark LLCC interrupt as required dt-bindings: firmware: scm: Add SM6350 compatible dt-bindings: arm: msm: Add LLCC for SM6350 soc: qcom: rpmhpd: Sort power-domain definitions and lists soc: qcom: rpmhpd: Remove mx/cx relationship on sc7280 soc: qcom: rpmhpd: Rename rpmhpd struct names soc: qcom: rpmhpd: sm8450: Add the missing .peer for sm8450_cx_ao soc: qcom: socinfo: add SM8450 ID soc: qcom: rpmhpd: Add SM8450 power domains dt-bindings: power: rpmpd: Add SM8450 to rpmpd binding soc: qcom: smem: Update max processor count dt-bindings: arm: qcom: Document SM8450 SoC and boards dt-bindings: firmware: scm: Add SM8450 compatible dt-bindings: arm: cpus: Add kryo780 compatible soc: qcom: rpmpd: Add support for sm6125 dt-bindings: qcom-rpmpd: Add sm6125 power domains soc: qcom: aoss: constify static struct thermal_cooling_device_ops PM: AVS: qcom-cpr: Use div64_ul instead of do_div ...

Linus Torvalds committed 4 years ago

Commit e85195d2 parents 0dca3c5 13ee75c90 files · +3402 −918Browse files

Unified · Split

90 files
  1. Documentation/devicetree/bindings/arm/cpus.yaml +1 −0
  2. Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.yaml +8 −0
  3. Documentation/devicetree/bindings/arm/msm/qcom,llcc.yaml +1 −1
  4. Documentation/devicetree/bindings/arm/qcom.yaml +6 −0
  5. Documentation/devicetree/bindings/firmware/qcom,scm.txt +2 −0
  6. Documentation/devicetree/bindings/memory-controllers/renesas,rpc-if.yaml +40 −14
  7. Documentation/devicetree/bindings/power/qcom,rpmpd.yaml +3 −0
  8. Documentation/devicetree/bindings/soc/qcom/qcom-stats.yaml +5 −0
  9. Documentation/devicetree/bindings/soc/samsung/exynos-chipid.yaml +1 −1
  10. Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml +3 −1
  11. Documentation/devicetree/bindings/soc/samsung/exynos-usi.yaml +159 −0
  12. Documentation/staging/tee.rst +30 −0
  13. MAINTAINERS +1 −0
  14. arch/arm/mach-at91/pm.c +2 −0
  15. drivers/bus/imx-weim.c +16 −2
  16. drivers/bus/tegra-gmi.c +44 −6
  17. drivers/firmware/ti_sci.c +1 −1
  18. drivers/firmware/xilinx/zynqmp.c +4 −1
  19. drivers/memory/renesas-rpc-if.c +69 −40
  20. drivers/mmc/host/sdhci-tegra.c +65 −16
  21. drivers/mtd/hyperbus/rpc-if.c +3 −1
  22. drivers/mtd/nand/raw/tegra_nand.c +50 −8
  23. drivers/pwm/pwm-tegra.c +64 −18
  24. drivers/soc/Kconfig +1 −0
  25. drivers/soc/Makefile +1 −0
  26. drivers/soc/apple/Kconfig +22 −0
  27. drivers/soc/apple/Makefile +2 −0
  28. drivers/soc/apple/apple-pmgr-pwrstate.c +324 −0
  29. drivers/soc/imx/gpcv2.c +28 −1
  30. drivers/soc/imx/imx8m-blk-ctrl.c +76 −1
  31. drivers/soc/qcom/cpr.c +1 −1
  32. drivers/soc/qcom/llcc-qcom.c +28 −0
  33. drivers/soc/qcom/qcom_aoss.c +1 −1
  34. drivers/soc/qcom/qcom_stats.c +13 −0
  35. drivers/soc/qcom/qmi_interface.c +1 −1
  36. drivers/soc/qcom/rpmh-rsc.c +1 −1
  37. drivers/soc/qcom/rpmhpd.c +191 −135
  38. drivers/soc/qcom/rpmpd.c +41 −1
  39. drivers/soc/qcom/smem.c +1 −1
  40. drivers/soc/qcom/socinfo.c +3 −0
  41. drivers/soc/renesas/Kconfig +15 −0
  42. drivers/soc/renesas/Makefile +2 −0
  43. drivers/soc/renesas/r8a779a0-sysc.c +3 −377
  44. drivers/soc/renesas/r8a779f0-sysc.c +47 −0
  45. drivers/soc/renesas/rcar-gen4-sysc.c +376 −0
  46. drivers/soc/renesas/rcar-gen4-sysc.h +43 −0
  47. drivers/soc/renesas/rcar-rst.c +44 −6
  48. drivers/soc/renesas/renesas-soc.c +68 −59
  49. drivers/soc/samsung/Kconfig +14 −0
  50. drivers/soc/samsung/Makefile +2 −0
  51. drivers/soc/samsung/exynos-chipid.c +3 −0
  52. drivers/soc/samsung/exynos-pmu.c +2 −0
  53. drivers/soc/samsung/exynos-usi.c +285 −0
  54. drivers/soc/tegra/common.c +26 −3
  55. drivers/soc/tegra/fuse/fuse-tegra.c +40 −11
  56. drivers/soc/tegra/fuse/fuse-tegra20.c +30 −3
  57. drivers/soc/tegra/fuse/fuse.h +1 −0
  58. drivers/soc/tegra/pmc.c +33 −8
  59. drivers/soc/tegra/regulators-tegra20.c +99 −0
  60. drivers/soc/tegra/regulators-tegra30.c +122 −0
  61. drivers/soc/ti/k3-socinfo.c +2 −1
  62. drivers/soc/ti/knav_dma.c +10 −10
  63. drivers/soc/ti/pruss.c +1 −1
  64. drivers/soc/xilinx/zynqmp_pm_domains.c +51 −40
  65. drivers/soc/xilinx/zynqmp_power.c +0 −1
  66. drivers/spi/spi-rpc-if.c +3 −1
  67. drivers/spi/spi-tegra20-slink.c +8 −1
  68. drivers/staging/media/tegra-vde/vde.c +52 −11
  69. drivers/tee/optee/Makefile +1 −0
  70. drivers/tee/optee/core.c +1 −1
  71. drivers/tee/optee/ffa_abi.c +5 −1
  72. drivers/tee/optee/notif.c +125 −0
  73. drivers/tee/optee/optee_msg.h +9 −0
  74. drivers/tee/optee/optee_private.h +20 −8
  75. drivers/tee/optee/optee_rpc_cmd.h +17 −14
  76. drivers/tee/optee/optee_smc.h +73 −2
  77. drivers/tee/optee/rpc.c +7 −64
  78. drivers/tee/optee/smc_abi.c +206 −31
  79. drivers/tee/tee_core.c +7 −3
  80. drivers/usb/chipidea/ci_hdrc_tegra.c +46 −7
  81. include/dt-bindings/clock/r8a779f0-cpg-mssr.h +64 −0
  82. include/dt-bindings/power/imx8mn-power.h +5 −0
  83. include/dt-bindings/power/qcom-rpmpd.h +33 −0
  84. include/dt-bindings/power/r8a779f0-sysc.h +30 −0
  85. include/dt-bindings/soc/samsung,exynos-usi.h +17 −0
  86. include/linux/soc/qcom/llcc-qcom.h +3 −0
  87. include/linux/soc/renesas/rcar-rst.h +2 −0
  88. include/linux/tee_drv.h +14 −0
  89. include/memory/renesas-rpc-if.h +7 −1
  90. include/soc/tegra/common.h +15 −0
Documentation/devicetree/bindings/arm/cpus.yaml+1−0
@@ -174,6 +174,7 @@ properties: · 173 unmodified lines
174174 - qcom,kryo560
175175 - qcom,kryo570
176176 - qcom,kryo685
177+ - qcom,kryo780
177178 - qcom,scorpion
178179
179180 enable-method:
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.yaml+8−0
@@ -24,6 +24,12 @@ properties: · 23 unmodified lines
2424 compatible:
2525 const: linaro,optee-tz
2626
27+ interrupts:
28+ maxItems: 1
29+ description: |
30+ This interrupt which is used to signal an event by the secure world
31+ software is expected to be edge-triggered.
32+
2733 method:
2834 enum: [smc, hvc]
2935 description: |
@@ -42,10 +48,12 @@ additionalProperties: false · 12 unmodified lines
4248
4349 examples:
4450 - |
51+ #include <dt-bindings/interrupt-controller/arm-gic.h>
4552 firmware {
4653 optee {
4754 compatible = "linaro,optee-tz";
4855 method = "smc";
56+ interrupts = <GIC_SPI 187 IRQ_TYPE_EDGE_RISING>;
4957 };
5058 };
5159
Documentation/devicetree/bindings/arm/msm/qcom,llcc.yaml+1−1
@@ -24,6 +24,7 @@ properties: · 23 unmodified lines
2424 - qcom,sc7180-llcc
2525 - qcom,sc7280-llcc
2626 - qcom,sdm845-llcc
27+ - qcom,sm6350-llcc
2728 - qcom,sm8150-llcc
2829 - qcom,sm8250-llcc
2930
@@ -44,7 +45,6 @@ required: · 14 unmodified lines
4445 - compatible
4546 - reg
4647 - reg-names
47− - interrupts
4848
4949 additionalProperties: false
5050
Documentation/devicetree/bindings/arm/qcom.yaml+6−0
@@ -50,6 +50,7 @@ description: | · 49 unmodified lines
5050 sm8150
5151 sm8250
5252 sm8350
53+ sm8450
5354
5455 The 'board' element must be one of the following strings:
5556
@@ -257,6 +258,11 @@ properties: · 201 unmodified lines
257258 - qcom,sm8350-mtp
258259 - const: qcom,sm8350
259260
261+ - items:
262+ - enum:
263+ - qcom,sm8450-qrd
264+ - const: qcom,sm8450
265+
260266 additionalProperties: true
261267
262268 ...
Documentation/devicetree/bindings/firmware/qcom,scm.txt+2−0
@@ -26,9 +26,11 @@ Required properties: · 25 unmodified lines
2626 * "qcom,scm-sc7280"
2727 * "qcom,scm-sdm845"
2828 * "qcom,scm-sdx55"
29+ * "qcom,scm-sm6350"
2930 * "qcom,scm-sm8150"
3031 * "qcom,scm-sm8250"
3132 * "qcom,scm-sm8350"
33+ * "qcom,scm-sm8450"
3234 and:
3335 * "qcom,scm"
3436 - clocks: Specifies clocks needed by the SCM interface, if any:
Documentation/devicetree/bindings/memory-controllers/renesas,rpc-if.yaml+40−14
@@ -24,17 +24,23 @@ allOf: · 23 unmodified lines
2424
2525 properties:
2626 compatible:
27− items:
28− - enum:
29− - renesas,r8a774a1-rpc-if # RZ/G2M
30− - renesas,r8a774b1-rpc-if # RZ/G2N
31− - renesas,r8a774c0-rpc-if # RZ/G2E
32− - renesas,r8a774e1-rpc-if # RZ/G2H
33− - renesas,r8a77970-rpc-if # R-Car V3M
34− - renesas,r8a77980-rpc-if # R-Car V3H
35− - renesas,r8a77995-rpc-if # R-Car D3
36− - renesas,r8a779a0-rpc-if # R-Car V3U
37− - const: renesas,rcar-gen3-rpc-if # a generic R-Car gen3 or RZ/G2 device
27+ oneOf:
28+ - items:
29+ - enum:
30+ - renesas,r8a774a1-rpc-if # RZ/G2M
31+ - renesas,r8a774b1-rpc-if # RZ/G2N
32+ - renesas,r8a774c0-rpc-if # RZ/G2E
33+ - renesas,r8a774e1-rpc-if # RZ/G2H
34+ - renesas,r8a77970-rpc-if # R-Car V3M
35+ - renesas,r8a77980-rpc-if # R-Car V3H
36+ - renesas,r8a77995-rpc-if # R-Car D3
37+ - renesas,r8a779a0-rpc-if # R-Car V3U
38+ - const: renesas,rcar-gen3-rpc-if # a generic R-Car gen3 or RZ/G2{E,H,M,N} device
39+
40+ - items:
41+ - enum:
42+ - renesas,r9a07g044-rpc-if # RZ/G2{L,LC}
43+ - const: renesas,rzg2l-rpc-if # RZ/G2L family
3844
3945 reg:
4046 items:
@@ -48,7 +54,9 @@ properties: · 7 unmodified lines
4854 - const: dirmap
4955 - const: wbuf
5056
51− clocks:
57+ clocks: true
58+
59+ interrupts:
5260 maxItems: 1
5361
5462 power-domains:
@@ -67,8 +75,6 @@ patternProperties: · 12 unmodified lines
6775 - cfi-flash
6876 - jedec,spi-nor
6977
70−unevaluatedProperties: false
71−
7278 required:
7379 - compatible
7480 - reg
@@ -79,6 +85,26 @@ required: · 4 unmodified lines
7985 - '#address-cells'
8086 - '#size-cells'
8187
88+if:
89+ properties:
90+ compatible:
91+ contains:
92+ enum:
93+ - renesas,rzg2l-rpc-if
94+then:
95+ properties:
96+ clocks:
97+ items:
98+ - description: SPI Multi IO Register access clock (SPI_CLK2)
99+ - description: SPI Multi IO Main clock (SPI_CLK).
100+
101+else:
102+ properties:
103+ clocks:
104+ maxItems: 1
105+
106+unevaluatedProperties: false
107+
82108 examples:
83109 - |
84110 #include <dt-bindings/clock/renesas-cpg-mssr.h>
Documentation/devicetree/bindings/power/qcom,rpmpd.yaml+3−0
@@ -24,6 +24,7 @@ properties: · 23 unmodified lines
2424 - qcom,msm8994-rpmpd
2525 - qcom,msm8996-rpmpd
2626 - qcom,msm8998-rpmpd
27+ - qcom,qcm2290-rpmpd
2728 - qcom,qcs404-rpmpd
2829 - qcom,sdm660-rpmpd
2930 - qcom,sc7180-rpmhpd
@@ -32,10 +33,12 @@ properties: · 2 unmodified lines
3233 - qcom,sdm845-rpmhpd
3334 - qcom,sdx55-rpmhpd
3435 - qcom,sm6115-rpmpd
36+ - qcom,sm6125-rpmpd
3537 - qcom,sm6350-rpmhpd
3638 - qcom,sm8150-rpmhpd
3739 - qcom,sm8250-rpmhpd
3840 - qcom,sm8350-rpmhpd
41+ - qcom,sm8450-rpmhpd
3942
4043 '#power-domain-cells':
4144 const: 1
Documentation/devicetree/bindings/soc/qcom/qcom-stats.yaml+5−0
@@ -21,6 +21,11 @@ properties: · 20 unmodified lines
2121 enum:
2222 - qcom,rpmh-stats
2323 - qcom,rpm-stats
24+ # For older RPM firmware versions with fixed offset for the sleep stats
25+ - qcom,apq8084-rpm-stats
26+ - qcom,msm8226-rpm-stats
27+ - qcom,msm8916-rpm-stats
28+ - qcom,msm8974-rpm-stats
2429
2530 reg:
2631 maxItems: 1
Documentation/devicetree/bindings/soc/samsung/exynos-chipid.yamlrenamed from Documentation/devicetree/bindings/arm/samsung/exynos-chipid.yaml+1−1
@@ -1,7 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0
22 %YAML 1.2
33 ---
4−$id: http://devicetree.org/schemas/arm/samsung/exynos-chipid.yaml#
4+$id: http://devicetree.org/schemas/soc/samsung/exynos-chipid.yaml#
55 $schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Samsung Exynos SoC series Chipid driver
Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yamlrenamed from Documentation/devicetree/bindings/arm/samsung/pmu.yaml+3−1
@@ -1,7 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0
22 %YAML 1.2
33 ---
4−$id: http://devicetree.org/schemas/arm/samsung/pmu.yaml#
4+$id: http://devicetree.org/schemas/soc/samsung/exynos-pmu.yaml#
55 $schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Samsung Exynos SoC series Power Management Unit (PMU)
@@ -24,6 +24,7 @@ select: · 16 unmodified lines
2424 - samsung,exynos5420-pmu
2525 - samsung,exynos5433-pmu
2626 - samsung,exynos7-pmu
27+ - samsung,exynos850-pmu
2728 - samsung-s5pv210-pmu
2829 required:
2930 - compatible
@@ -41,6 +42,7 @@ properties: · 11 unmodified lines
4142 - samsung,exynos5420-pmu
4243 - samsung,exynos5433-pmu
4344 - samsung,exynos7-pmu
45+ - samsung,exynos850-pmu
4446 - samsung-s5pv210-pmu
4547 - const: syscon
4648
Documentation/devicetree/bindings/soc/samsung/exynos-usi.yaml+159−0
@@ -0,0 +1,159 @@
1+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+%YAML 1.2
3+---
4+$id: http://devicetree.org/schemas/soc/samsung/exynos-usi.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+title: Samsung's Exynos USI (Universal Serial Interface) binding
8+
9+maintainers:
10+ - Sam Protsenko <semen.protsenko@linaro.org>
11+ - Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
12+
13+description: |
14+ USI IP-core provides selectable serial protocol (UART, SPI or High-Speed I2C).
15+ USI shares almost all internal circuits within each protocol, so only one
16+ protocol can be chosen at a time. USI is modeled as a node with zero or more
17+ child nodes, each representing a serial sub-node device. The mode setting
18+ selects which particular function will be used.
19+
20+ Refer to next bindings documentation for information on protocol subnodes that
21+ can exist under USI node:
22+
23+ [1] Documentation/devicetree/bindings/serial/samsung_uart.yaml
24+ [2] Documentation/devicetree/bindings/i2c/i2c-exynos5.txt
25+ [3] Documentation/devicetree/bindings/spi/spi-samsung.txt
26+
27+properties:
28+ $nodename:
29+ pattern: "^usi@[0-9a-f]+$"
30+
31+ compatible:
32+ enum:
33+ - samsung,exynos850-usi # for USIv2 (Exynos850, ExynosAutoV9)
34+
35+ reg: true
36+
37+ clocks: true
38+
39+ clock-names: true
40+
41+ ranges: true
42+
43+ "#address-cells":
44+ const: 1
45+
46+ "#size-cells":
47+ const: 1
48+
49+ samsung,sysreg:
50+ $ref: /schemas/types.yaml#/definitions/phandle-array
51+ description:
52+ Should be phandle/offset pair. The phandle to System Register syscon node
53+ (for the same domain where this USI controller resides) and the offset
54+ of SW_CONF register for this USI controller.
55+
56+ samsung,mode:
57+ $ref: /schemas/types.yaml#/definitions/uint32
58+ description:
59+ Selects USI function (which serial protocol to use). Refer to
60+ <include/dt-bindings/soc/samsung,exynos-usi.h> for valid USI mode values.
61+
62+ samsung,clkreq-on:
63+ type: boolean
64+ description:
65+ Enable this property if underlying protocol requires the clock to be
66+ continuously provided without automatic gating. As suggested by SoC
67+ manual, it should be set in case of SPI/I2C slave, UART Rx and I2C
68+ multi-master mode. Usually this property is needed if USI mode is set
69+ to "UART".
70+
71+ This property is optional.
72+
73+patternProperties:
74+ # All other properties should be child nodes
75+ "^(serial|spi|i2c)@[0-9a-f]+$":
76+ type: object
77+ description: Child node describing underlying USI serial protocol
78+
79+required:
80+ - compatible
81+ - ranges
82+ - "#address-cells"
83+ - "#size-cells"
84+ - samsung,sysreg
85+ - samsung,mode
86+
87+if:
88+ properties:
89+ compatible:
90+ contains:
91+ enum:
92+ - samsung,exynos850-usi
93+
94+then:
95+ properties:
96+ reg:
97+ maxItems: 1
98+
99+ clocks:
100+ items:
101+ - description: Bus (APB) clock
102+ - description: Operating clock for UART/SPI/I2C protocol
103+
104+ clock-names:
105+ items:
106+ - const: pclk
107+ - const: ipclk
108+
109+ required:
110+ - reg
111+ - clocks
112+ - clock-names
113+
114+else:
115+ properties:
116+ reg: false
117+ clocks: false
118+ clock-names: false
119+ samsung,clkreq-on: false
120+
121+additionalProperties: false
122+
123+examples:
124+ - |
125+ #include <dt-bindings/interrupt-controller/arm-gic.h>
126+ #include <dt-bindings/soc/samsung,exynos-usi.h>
127+
128+ usi0: usi@138200c0 {
129+ compatible = "samsung,exynos850-usi";
130+ reg = <0x138200c0 0x20>;
131+ samsung,sysreg = <&sysreg_peri 0x1010>;
132+ samsung,mode = <USI_V2_UART>;
133+ samsung,clkreq-on; /* needed for UART mode */
134+ #address-cells = <1>;
135+ #size-cells = <1>;
136+ ranges;
137+ clocks = <&cmu_peri 32>, <&cmu_peri 31>;
138+ clock-names = "pclk", "ipclk";
139+
140+ serial_0: serial@13820000 {
141+ compatible = "samsung,exynos850-uart";
142+ reg = <0x13820000 0xc0>;
143+ interrupts = <GIC_SPI 227 IRQ_TYPE_LEVEL_HIGH>;
144+ clocks = <&cmu_peri 32>, <&cmu_peri 31>;
145+ clock-names = "uart", "clk_uart_baud0";
146+ status = "disabled";
147+ };
148+
149+ hsi2c_0: i2c@13820000 {
150+ compatible = "samsung,exynosautov9-hsi2c";
151+ reg = <0x13820000 0xc0>;
152+ interrupts = <GIC_SPI 227 IRQ_TYPE_LEVEL_HIGH>;
153+ #address-cells = <1>;
154+ #size-cells = <0>;
155+ clocks = <&cmu_peri 32>, <&cmu_peri 31>;
156+ clock-names = "hsi2c_pclk", "hsi2c";
157+ status = "disabled";
158+ };
159+ };
Documentation/staging/tee.rst+30−0
@@ -184,6 +184,36 @@ order to support device enumeration. In other words, OP-TEE driver invokes this · 183 unmodified lines
184184 application to retrieve a list of Trusted Applications which can be registered
185185 as devices on the TEE bus.
186186
187+OP-TEE notifications
188+--------------------
189+
190+There are two kinds of notifications that secure world can use to make
191+normal world aware of some event.
192+
193+1. Synchronous notifications delivered with ``OPTEE_RPC_CMD_NOTIFICATION``
194+ using the ``OPTEE_RPC_NOTIFICATION_SEND`` parameter.
195+2. Asynchronous notifications delivered with a combination of a non-secure
196+ edge-triggered interrupt and a fast call from the non-secure interrupt
197+ handler.
198+
199+Synchronous notifications are limited by depending on RPC for delivery,
200+this is only usable when secure world is entered with a yielding call via
201+``OPTEE_SMC_CALL_WITH_ARG``. This excludes such notifications from secure
202+world interrupt handlers.
203+
204+An asynchronous notification is delivered via a non-secure edge-triggered
205+interrupt to an interrupt handler registered in the OP-TEE driver. The
206+actual notification value are retrieved with the fast call
207+``OPTEE_SMC_GET_ASYNC_NOTIF_VALUE``. Note that one interrupt can represent
208+multiple notifications.
209+
210+One notification value ``OPTEE_SMC_ASYNC_NOTIF_VALUE_DO_BOTTOM_HALF`` has a
211+special meaning. When this value is received it means that normal world is
212+supposed to make a yielding call ``OPTEE_MSG_CMD_DO_BOTTOM_HALF``. This
213+call is done from the thread assisting the interrupt handler. This is a
214+building block for OP-TEE OS in secure world to implement the top half and
215+bottom half style of device drivers.
216+
187217 AMD-TEE driver
188218 ==============
189219
MAINTAINERS+1−0
@@ -2551,6 +2551,7 @@ Q: https://patchwork.kernel.org/project/linux-samsung-soc/list/ · 2550 unmodified lines
25512551 F: Documentation/arm/samsung/
25522552 F: Documentation/devicetree/bindings/arm/samsung/
25532553 F: Documentation/devicetree/bindings/power/pd-samsung.yaml
2554+F: Documentation/devicetree/bindings/soc/samsung/
25542555 F: arch/arm/boot/dts/exynos*
25552556 F: arch/arm/boot/dts/s3c*
25562557 F: arch/arm/boot/dts/s5p*
arch/arm/mach-at91/pm.c+2−0
@@ -645,6 +645,7 @@ static __init int at91_dt_ramc(bool phy_mandatory) · 644 unmodified lines
645645 if (!soc_pm.data.ramc[idx]) {
646646 pr_err("unable to map ramc[%d] cpu registers\n", idx);
647647 ret = -ENOMEM;
648+ of_node_put(np);
648649 goto unmap_ramc;
649650 }
650651
@@ -670,6 +671,7 @@ static __init int at91_dt_ramc(bool phy_mandatory) · 19 unmodified lines
670671 if (!soc_pm.data.ramc_phy) {
671672 pr_err("unable to map ramc phy cpu registers\n");
672673 ret = -ENOMEM;
674+ of_node_put(np);
673675 goto unmap_ramc;
674676 }
675677 }
drivers/bus/imx-weim.c+16−2
@@ -21,6 +21,7 @@ struct imx_weim_devtype { · 20 unmodified lines
2121 unsigned int cs_stride;
2222 unsigned int wcr_offset;
2323 unsigned int wcr_bcm;
24+ unsigned int wcr_cont_bclk;
2425 };
2526
2627 static const struct imx_weim_devtype imx1_weim_devtype = {
@@ -41,6 +42,7 @@ static const struct imx_weim_devtype imx50_weim_devtype = { · 14 unmodified lines
4142 .cs_stride = 0x18,
4243 .wcr_offset = 0x90,
4344 .wcr_bcm = BIT(0),
45+ .wcr_cont_bclk = BIT(3),
4446 };
4547
4648 static const struct imx_weim_devtype imx51_weim_devtype = {
@@ -206,8 +208,20 @@ static int weim_parse_dt(struct platform_device *pdev, void __iomem *base) · 159 unmodified lines
206208 if (of_property_read_bool(pdev->dev.of_node, "fsl,burst-clk-enable")) {
207209 if (devtype->wcr_bcm) {
208210 reg = readl(base + devtype->wcr_offset);
209− writel(reg | devtype->wcr_bcm,
210− base + devtype->wcr_offset);
211+ reg |= devtype->wcr_bcm;
212+
213+ if (of_property_read_bool(pdev->dev.of_node,
214+ "fsl,continuous-burst-clk")) {
215+ if (devtype->wcr_cont_bclk) {
216+ reg |= devtype->wcr_cont_bclk;
217+ } else {
218+ dev_err(&pdev->dev,
219+ "continuous burst clk not supported.\n");
220+ return -EINVAL;
221+ }
222+ }
223+
224+ writel(reg, base + devtype->wcr_offset);
211225 } else {
212226 dev_err(&pdev->dev, "burst clk mode not supported.\n");
213227 return -EINVAL;
drivers/bus/tegra-gmi.c+44−6
@@ -13,8 +13,11 @@ · 12 unmodified lines
1313 #include <linux/io.h>
1414 #include <linux/module.h>
1515 #include <linux/of_device.h>
16+#include <linux/pm_runtime.h>
1617 #include <linux/reset.h>
1718
19+#include <soc/tegra/common.h>
20+
1821 #define TEGRA_GMI_CONFIG 0x00
1922 #define TEGRA_GMI_CONFIG_GO BIT(31)
2023 #define TEGRA_GMI_BUS_WIDTH_32BIT BIT(30)
@@ -54,9 +57,10 @@ static int tegra_gmi_enable(struct tegra_gmi *gmi) · 33 unmodified lines
5457 {
5558 int err;
5659
57− err = clk_prepare_enable(gmi->clk);
58− if (err < 0) {
59− dev_err(gmi->dev, "failed to enable clock: %d\n", err);
60+ pm_runtime_enable(gmi->dev);
61+ err = pm_runtime_resume_and_get(gmi->dev);
62+ if (err) {
63+ pm_runtime_disable(gmi->dev);
6064 return err;
6165 }
6266
@@ -83,7 +87,9 @@ static void tegra_gmi_disable(struct tegra_gmi *gmi) · 20 unmodified lines
8387 writel(config, gmi->base + TEGRA_GMI_CONFIG);
8488
8589 reset_control_assert(gmi->rst);
86− clk_disable_unprepare(gmi->clk);
90+
91+ pm_runtime_put_sync_suspend(gmi->dev);
92+ pm_runtime_force_suspend(gmi->dev);
8793 }
8894
8995 static int tegra_gmi_parse_dt(struct tegra_gmi *gmi)
@@ -213,6 +219,7 @@ static int tegra_gmi_probe(struct platform_device *pdev) · 123 unmodified lines
213219 if (!gmi)
214220 return -ENOMEM;
215221
222+ platform_set_drvdata(pdev, gmi);
216223 gmi->dev = dev;
217224
218225 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -232,6 +239,10 @@ static int tegra_gmi_probe(struct platform_device *pdev) · 13 unmodified lines
232239 return PTR_ERR(gmi->rst);
233240 }
234241
242+ err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
243+ if (err)
244+ return err;
245+
235246 err = tegra_gmi_parse_dt(gmi);
236247 if (err)
237248 return err;
@@ -247,8 +258,6 @@ static int tegra_gmi_probe(struct platform_device *pdev) · 9 unmodified lines
247258 return err;
248259 }
249260
250− platform_set_drvdata(pdev, gmi);
251−
252261 return 0;
253262 }
254263
@@ -262,6 +271,34 @@ static int tegra_gmi_remove(struct platform_device *pdev) · 7 unmodified lines
262271 return 0;
263272 }
264273
274+static int __maybe_unused tegra_gmi_runtime_resume(struct device *dev)
275+{
276+ struct tegra_gmi *gmi = dev_get_drvdata(dev);
277+ int err;
278+
279+ err = clk_prepare_enable(gmi->clk);
280+ if (err < 0) {
281+ dev_err(gmi->dev, "failed to enable clock: %d\n", err);
282+ return err;
283+ }
284+
285+ return 0;
286+}
287+
288+static int __maybe_unused tegra_gmi_runtime_suspend(struct device *dev)
289+{
290+ struct tegra_gmi *gmi = dev_get_drvdata(dev);
291+
292+ clk_disable_unprepare(gmi->clk);
293+
294+ return 0;
295+}
296+
297+static const struct dev_pm_ops tegra_gmi_pm = {
298+ SET_RUNTIME_PM_OPS(tegra_gmi_runtime_suspend, tegra_gmi_runtime_resume,
299+ NULL)
300+};
301+
265302 static const struct of_device_id tegra_gmi_id_table[] = {
266303 { .compatible = "nvidia,tegra20-gmi", },
267304 { .compatible = "nvidia,tegra30-gmi", },
@@ -275,6 +312,7 @@ static struct platform_driver tegra_gmi_driver = { · 7 unmodified lines
275312 .driver = {
276313 .name = "tegra-gmi",
277314 .of_match_table = tegra_gmi_id_table,
315+ .pm = &tegra_gmi_pm,
278316 },
279317 };
280318 module_platform_driver(tegra_gmi_driver);
drivers/firmware/ti_sci.c+1−1
@@ -1759,7 +1759,7 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, · 1758 unmodified lines
17591759 desc->num = resp->range_num;
17601760 desc->start_sec = resp->range_start_sec;
17611761 desc->num_sec = resp->range_num_sec;
1762− };
1762+ }
17631763
17641764 fail:
17651765 ti_sci_put_one_xfer(&info->minfo, xfer);
drivers/firmware/xilinx/zynqmp.c+4−1
@@ -1434,7 +1434,10 @@ static int zynqmp_firmware_probe(struct platform_device *pdev) · 1433 unmodified lines
14341434 return ret;
14351435
14361436 /* Check PM API version number */
1437− zynqmp_pm_get_api_version(&pm_api_version);
1437+ ret = zynqmp_pm_get_api_version(&pm_api_version);
1438+ if (ret)
1439+ return ret;
1440+
14381441 if (pm_api_version < ZYNQMP_PM_VERSION) {
14391442 panic("%s Platform Management API version error. Expected: v%d.%d - Found: v%d.%d\n",
14401443 __func__,
drivers/memory/renesas-rpc-if.c+69−40
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/module.h>
1313 #include <linux/platform_device.h>
1414 #include <linux/of.h>
15+#include <linux/of_device.h>
1516 #include <linux/regmap.h>
1617 #include <linux/reset.h>
1718
@@ -19,19 +20,17 @@ · 1 unmodified line
1920
2021 #define RPCIF_CMNCR 0x0000 /* R/W */
2122 #define RPCIF_CMNCR_MD BIT(31)
22−#define RPCIF_CMNCR_SFDE BIT(24) /* undocumented but must be set */
2323 #define RPCIF_CMNCR_MOIIO3(val) (((val) & 0x3) << 22)
2424 #define RPCIF_CMNCR_MOIIO2(val) (((val) & 0x3) << 20)
2525 #define RPCIF_CMNCR_MOIIO1(val) (((val) & 0x3) << 18)
2626 #define RPCIF_CMNCR_MOIIO0(val) (((val) & 0x3) << 16)
27−#define RPCIF_CMNCR_MOIIO_HIZ (RPCIF_CMNCR_MOIIO0(3) | \
28− RPCIF_CMNCR_MOIIO1(3) | \
29− RPCIF_CMNCR_MOIIO2(3) | RPCIF_CMNCR_MOIIO3(3))
30−#define RPCIF_CMNCR_IO3FV(val) (((val) & 0x3) << 14) /* undocumented */
31−#define RPCIF_CMNCR_IO2FV(val) (((val) & 0x3) << 12) /* undocumented */
27+#define RPCIF_CMNCR_MOIIO(val) (RPCIF_CMNCR_MOIIO0(val) | RPCIF_CMNCR_MOIIO1(val) | \
28+ RPCIF_CMNCR_MOIIO2(val) | RPCIF_CMNCR_MOIIO3(val))
29+#define RPCIF_CMNCR_IO3FV(val) (((val) & 0x3) << 14) /* documented for RZ/G2L */
30+#define RPCIF_CMNCR_IO2FV(val) (((val) & 0x3) << 12) /* documented for RZ/G2L */
3231 #define RPCIF_CMNCR_IO0FV(val) (((val) & 0x3) << 8)
33−#define RPCIF_CMNCR_IOFV_HIZ (RPCIF_CMNCR_IO0FV(3) | RPCIF_CMNCR_IO2FV(3) | \
34− RPCIF_CMNCR_IO3FV(3))
32+#define RPCIF_CMNCR_IOFV(val) (RPCIF_CMNCR_IO0FV(val) | RPCIF_CMNCR_IO2FV(val) | \
33+ RPCIF_CMNCR_IO3FV(val))
3534 #define RPCIF_CMNCR_BSZ(val) (((val) & 0x3) << 0)
3635
3736 #define RPCIF_SSLDR 0x0004 /* R/W */
@@ -126,6 +125,9 @@ · 88 unmodified lines
126125 #define RPCIF_SMDRENR_OPDRE BIT(4)
127126 #define RPCIF_SMDRENR_SPIDRE BIT(0)
128127
128+#define RPCIF_PHYADD 0x0070 /* R/W available on R-Car E3/D3/V3M and RZ/G2{E,L} */
129+#define RPCIF_PHYWR 0x0074 /* R/W available on R-Car E3/D3/V3M and RZ/G2{E,L} */
130+
129131 #define RPCIF_PHYCNT 0x007C /* R/W */
130132 #define RPCIF_PHYCNT_CAL BIT(31)
131133 #define RPCIF_PHYCNT_OCTA(v) (((v) & 0x3) << 22)
@@ -133,10 +135,12 @@ · 1 unmodified line
133135 #define RPCIF_PHYCNT_OCT BIT(20)
134136 #define RPCIF_PHYCNT_DDRCAL BIT(19)
135137 #define RPCIF_PHYCNT_HS BIT(18)
136−#define RPCIF_PHYCNT_STRTIM(v) (((v) & 0x7) << 15)
138+#define RPCIF_PHYCNT_CKSEL(v) (((v) & 0x3) << 16) /* valid only for RZ/G2L */
139+#define RPCIF_PHYCNT_STRTIM(v) (((v) & 0x7) << 15) /* valid for R-Car and RZ/G2{E,H,M,N} */
137140 #define RPCIF_PHYCNT_WBUF2 BIT(4)
138141 #define RPCIF_PHYCNT_WBUF BIT(2)
139142 #define RPCIF_PHYCNT_PHYMEM(v) (((v) & 0x3) << 0)
143+#define RPCIF_PHYCNT_PHYMEM_MASK GENMASK(1, 0)
140144
141145 #define RPCIF_PHYOFFSET1 0x0080 /* R/W */
142146 #define RPCIF_PHYOFFSET1_DDRTMG(v) (((v) & 0x3) << 28)
@@ -147,8 +151,6 @@ · 4 unmodified lines
147151 #define RPCIF_PHYINT 0x0088 /* R/W */
148152 #define RPCIF_PHYINT_WPVAL BIT(1)
149153
150−#define RPCIF_DIRMAP_SIZE 0x4000000
151−
152154 static const struct regmap_range rpcif_volatile_ranges[] = {
153155 regmap_reg_range(RPCIF_SMRDR0, RPCIF_SMRDR1),
154156 regmap_reg_range(RPCIF_SMWDR0, RPCIF_SMWDR1),
@@ -243,50 +245,74 @@ int rpcif_sw_init(struct rpcif *rpc, struct device *dev) · 88 unmodified lines
243245 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dirmap");
244246 rpc->dirmap = devm_ioremap_resource(&pdev->dev, res);
245247 if (IS_ERR(rpc->dirmap))
246− rpc->dirmap = NULL;
248+ return PTR_ERR(rpc->dirmap);
247249 rpc->size = resource_size(res);
248250
251+ rpc->type = (uintptr_t)of_device_get_match_data(dev);
249252 rpc->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
250253
251254 return PTR_ERR_OR_ZERO(rpc->rstc);
252255 }
253256 EXPORT_SYMBOL(rpcif_sw_init);
254257
255−void rpcif_hw_init(struct rpcif *rpc, bool hyperflash)
258+static void rpcif_rzg2l_timing_adjust_sdr(struct rpcif *rpc)
259+{
260+ regmap_write(rpc->regmap, RPCIF_PHYWR, 0xa5390000);
261+ regmap_write(rpc->regmap, RPCIF_PHYADD, 0x80000000);
262+ regmap_write(rpc->regmap, RPCIF_PHYWR, 0x00008080);
263+ regmap_write(rpc->regmap, RPCIF_PHYADD, 0x80000022);
264+ regmap_write(rpc->regmap, RPCIF_PHYWR, 0x00008080);
265+ regmap_write(rpc->regmap, RPCIF_PHYADD, 0x80000024);
266+ regmap_update_bits(rpc->regmap, RPCIF_PHYCNT, RPCIF_PHYCNT_CKSEL(3),
267+ RPCIF_PHYCNT_CKSEL(3));
268+ regmap_write(rpc->regmap, RPCIF_PHYWR, 0x00000030);
269+ regmap_write(rpc->regmap, RPCIF_PHYADD, 0x80000032);
270+}
271+
272+int rpcif_hw_init(struct rpcif *rpc, bool hyperflash)
256273 {
257274 u32 dummy;
258275
259276 pm_runtime_get_sync(rpc->dev);
260277
261− /*
262− * NOTE: The 0x260 are undocumented bits, but they must be set.
263− * RPCIF_PHYCNT_STRTIM is strobe timing adjustment bits,
264− * 0x0 : the delay is biggest,
265− * 0x1 : the delay is 2nd biggest,
266− * On H3 ES1.x, the value should be 0, while on others,
267− * the value should be 7.
268− */
269− regmap_write(rpc->regmap, RPCIF_PHYCNT, RPCIF_PHYCNT_STRTIM(7) |
270− RPCIF_PHYCNT_PHYMEM(hyperflash ? 3 : 0) | 0x260);
271−
272− /*
273− * NOTE: The 0x1511144 are undocumented bits, but they must be set
274− * for RPCIF_PHYOFFSET1.
275− * The 0x31 are undocumented bits, but they must be set
276− * for RPCIF_PHYOFFSET2.
277− */
278− regmap_write(rpc->regmap, RPCIF_PHYOFFSET1, 0x1511144 |
279− RPCIF_PHYOFFSET1_DDRTMG(3));
280− regmap_write(rpc->regmap, RPCIF_PHYOFFSET2, 0x31 |
281− RPCIF_PHYOFFSET2_OCTTMG(4));
278+ if (rpc->type == RPCIF_RZ_G2L) {
279+ int ret;
280+
281+ ret = reset_control_reset(rpc->rstc);
282+ if (ret)
283+ return ret;
284+ usleep_range(200, 300);
285+ rpcif_rzg2l_timing_adjust_sdr(rpc);
286+ }
287+
288+ regmap_update_bits(rpc->regmap, RPCIF_PHYCNT, RPCIF_PHYCNT_PHYMEM_MASK,
289+ RPCIF_PHYCNT_PHYMEM(hyperflash ? 3 : 0));
290+
291+ if (rpc->type == RPCIF_RCAR_GEN3)
292+ regmap_update_bits(rpc->regmap, RPCIF_PHYCNT,
293+ RPCIF_PHYCNT_STRTIM(7), RPCIF_PHYCNT_STRTIM(7));
294+
295+ regmap_update_bits(rpc->regmap, RPCIF_PHYOFFSET1, RPCIF_PHYOFFSET1_DDRTMG(3),
296+ RPCIF_PHYOFFSET1_DDRTMG(3));
297+ regmap_update_bits(rpc->regmap, RPCIF_PHYOFFSET2, RPCIF_PHYOFFSET2_OCTTMG(7),
298+ RPCIF_PHYOFFSET2_OCTTMG(4));
282299
283300 if (hyperflash)
284301 regmap_update_bits(rpc->regmap, RPCIF_PHYINT,
285302 RPCIF_PHYINT_WPVAL, 0);
286303
287− regmap_write(rpc->regmap, RPCIF_CMNCR, RPCIF_CMNCR_SFDE |
288− RPCIF_CMNCR_MOIIO_HIZ | RPCIF_CMNCR_IOFV_HIZ |
289− RPCIF_CMNCR_BSZ(hyperflash ? 1 : 0));
304+ if (rpc->type == RPCIF_RCAR_GEN3)
305+ regmap_update_bits(rpc->regmap, RPCIF_CMNCR,
306+ RPCIF_CMNCR_MOIIO(3) | RPCIF_CMNCR_BSZ(3),
307+ RPCIF_CMNCR_MOIIO(3) |
308+ RPCIF_CMNCR_BSZ(hyperflash ? 1 : 0));
309+ else
310+ regmap_update_bits(rpc->regmap, RPCIF_CMNCR,
311+ RPCIF_CMNCR_MOIIO(3) | RPCIF_CMNCR_IOFV(3) |
312+ RPCIF_CMNCR_BSZ(3),
313+ RPCIF_CMNCR_MOIIO(1) | RPCIF_CMNCR_IOFV(2) |
314+ RPCIF_CMNCR_BSZ(hyperflash ? 1 : 0));
315+
290316 /* Set RCF after BSZ update */
291317 regmap_write(rpc->regmap, RPCIF_DRCR, RPCIF_DRCR_RCF);
292318 /* Dummy read according to spec */
@@ -297,6 +323,8 @@ void rpcif_hw_init(struct rpcif *rpc, bool hyperflash) · 4 unmodified lines
297323 pm_runtime_put(rpc->dev);
298324
299325 rpc->bus_size = hyperflash ? 2 : 1;
326+
327+ return 0;
300328 }
301329 EXPORT_SYMBOL(rpcif_hw_init);
302330
@@ -588,8 +616,8 @@ static void memcpy_fromio_readw(void *to, · 285 unmodified lines
588616
589617 ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs, size_t len, void *buf)
590618 {
591− loff_t from = offs & (RPCIF_DIRMAP_SIZE - 1);
592− size_t size = RPCIF_DIRMAP_SIZE - from;
619+ loff_t from = offs & (rpc->size - 1);
620+ size_t size = rpc->size - from;
593621
594622 if (len > size)
595623 len = size;
@@ -659,7 +687,8 @@ static int rpcif_remove(struct platform_device *pdev) · 63 unmodified lines
659687 }
660688
661689 static const struct of_device_id rpcif_of_match[] = {
662− { .compatible = "renesas,rcar-gen3-rpc-if", },
690+ { .compatible = "renesas,rcar-gen3-rpc-if", .data = (void *)RPCIF_RCAR_GEN3 },
691+ { .compatible = "renesas,rzg2l-rpc-if", .data = (void *)RPCIF_RZ_G2L },
663692 {},
664693 };
665694 MODULE_DEVICE_TABLE(of, rpcif_of_match);
drivers/mmc/host/sdhci-tegra.c+65−16
@@ -15,6 +15,8 @@ · 14 unmodified lines
1515 #include <linux/of.h>
1616 #include <linux/of_device.h>
1717 #include <linux/pinctrl/consumer.h>
18+#include <linux/pm_opp.h>
19+#include <linux/pm_runtime.h>
1820 #include <linux/regulator/consumer.h>
1921 #include <linux/reset.h>
2022 #include <linux/mmc/card.h>
@@ -24,6 +26,8 @@ · 3 unmodified lines
2426 #include <linux/gpio/consumer.h>
2527 #include <linux/ktime.h>
2628
29+#include <soc/tegra/common.h>
30+
2731 #include "sdhci-pltfm.h"
2832 #include "cqhci.h"
2933
@@ -743,7 +747,9 @@ static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) · 713 unmodified lines
743747 {
744748 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
745749 struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
750+ struct device *dev = mmc_dev(host->mmc);
746751 unsigned long host_clk;
752+ int err;
747753
748754 if (!clock)
749755 return sdhci_set_clock(host, clock);
@@ -761,7 +767,12 @@ static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) · 11 unmodified lines
761767 * from clk_get_rate() is used.
762768 */
763769 host_clk = tegra_host->ddr_signaling ? clock * 2 : clock;
764− clk_set_rate(pltfm_host->clk, host_clk);
770+
771+ err = dev_pm_opp_set_rate(dev, host_clk);
772+ if (err)
773+ dev_err(dev, "failed to set clk rate to %luHz: %d\n",
774+ host_clk, err);
775+
765776 tegra_host->curr_clk_rate = host_clk;
766777 if (tegra_host->ddr_signaling)
767778 host->max_clk = host_clk;
@@ -1714,7 +1725,6 @@ static int sdhci_tegra_probe(struct platform_device *pdev) · 946 unmodified lines
17141725 "failed to get clock\n");
17151726 goto err_clk_get;
17161727 }
1717− clk_prepare_enable(clk);
17181728 pltfm_host->clk = clk;
17191729
17201730 tegra_host->rst = devm_reset_control_get_exclusive(&pdev->dev,
@@ -1725,15 +1735,24 @@ static int sdhci_tegra_probe(struct platform_device *pdev) · 4 unmodified lines
17251735 goto err_rst_get;
17261736 }
17271737
1728− rc = reset_control_assert(tegra_host->rst);
1738+ rc = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
17291739 if (rc)
17301740 goto err_rst_get;
17311741
1742+ pm_runtime_enable(&pdev->dev);
1743+ rc = pm_runtime_resume_and_get(&pdev->dev);
1744+ if (rc)
1745+ goto err_pm_get;
1746+
1747+ rc = reset_control_assert(tegra_host->rst);
1748+ if (rc)
1749+ goto err_rst_assert;
1750+
17321751 usleep_range(2000, 4000);
17331752
17341753 rc = reset_control_deassert(tegra_host->rst);
17351754 if (rc)
1736− goto err_rst_get;
1755+ goto err_rst_assert;
17371756
17381757 usleep_range(2000, 4000);
17391758
@@ -1745,8 +1764,11 @@ static int sdhci_tegra_probe(struct platform_device *pdev) · 5 unmodified lines
17451764
17461765 err_add_host:
17471766 reset_control_assert(tegra_host->rst);
1767+err_rst_assert:
1768+ pm_runtime_put_sync_suspend(&pdev->dev);
1769+err_pm_get:
1770+ pm_runtime_disable(&pdev->dev);
17481771 err_rst_get:
1749− clk_disable_unprepare(pltfm_host->clk);
17501772 err_clk_get:
17511773 clk_disable_unprepare(tegra_host->tmclk);
17521774 err_power_req:
@@ -1765,19 +1787,38 @@ static int sdhci_tegra_remove(struct platform_device *pdev) · 12 unmodified lines
17651787
17661788 reset_control_assert(tegra_host->rst);
17671789 usleep_range(2000, 4000);
1768− clk_disable_unprepare(pltfm_host->clk);
1769− clk_disable_unprepare(tegra_host->tmclk);
17701790
1791+ pm_runtime_put_sync_suspend(&pdev->dev);
1792+ pm_runtime_force_suspend(&pdev->dev);
1793+
1794+ clk_disable_unprepare(tegra_host->tmclk);
17711795 sdhci_pltfm_free(pdev);
17721796
17731797 return 0;
17741798 }
17751799
1776−#ifdef CONFIG_PM_SLEEP
1777−static int __maybe_unused sdhci_tegra_suspend(struct device *dev)
1800+static int __maybe_unused sdhci_tegra_runtime_suspend(struct device *dev)
17781801 {
17791802 struct sdhci_host *host = dev_get_drvdata(dev);
17801803 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1804+
1805+ clk_disable_unprepare(pltfm_host->clk);
1806+
1807+ return 0;
1808+}
1809+
1810+static int __maybe_unused sdhci_tegra_runtime_resume(struct device *dev)
1811+{
1812+ struct sdhci_host *host = dev_get_drvdata(dev);
1813+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1814+
1815+ return clk_prepare_enable(pltfm_host->clk);
1816+}
1817+
1818+#ifdef CONFIG_PM_SLEEP
1819+static int sdhci_tegra_suspend(struct device *dev)
1820+{
1821+ struct sdhci_host *host = dev_get_drvdata(dev);
17811822 int ret;
17821823
17831824 if (host->mmc->caps2 & MMC_CAP2_CQE) {
@@ -1792,17 +1833,22 @@ static int __maybe_unused sdhci_tegra_suspend(struct device *dev) · 8 unmodified lines
17921833 return ret;
17931834 }
17941835
1795− clk_disable_unprepare(pltfm_host->clk);
1836+ ret = pm_runtime_force_suspend(dev);
1837+ if (ret) {
1838+ sdhci_resume_host(host);
1839+ cqhci_resume(host->mmc);
1840+ return ret;
1841+ }
1842+
17961843 return 0;
17971844 }
17981845
1799−static int __maybe_unused sdhci_tegra_resume(struct device *dev)
1846+static int sdhci_tegra_resume(struct device *dev)
18001847 {
18011848 struct sdhci_host *host = dev_get_drvdata(dev);
1802− struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
18031849 int ret;
18041850
1805− ret = clk_prepare_enable(pltfm_host->clk);
1851+ ret = pm_runtime_force_resume(dev);
18061852 if (ret)
18071853 return ret;
18081854
@@ -1821,13 +1867,16 @@ static int __maybe_unused sdhci_tegra_resume(struct device *dev) · 12 unmodified lines
18211867 suspend_host:
18221868 sdhci_suspend_host(host);
18231869 disable_clk:
1824− clk_disable_unprepare(pltfm_host->clk);
1870+ pm_runtime_force_suspend(dev);
18251871 return ret;
18261872 }
18271873 #endif
18281874
1829−static SIMPLE_DEV_PM_OPS(sdhci_tegra_dev_pm_ops, sdhci_tegra_suspend,
1830− sdhci_tegra_resume);
1875+static const struct dev_pm_ops sdhci_tegra_dev_pm_ops = {
1876+ SET_RUNTIME_PM_OPS(sdhci_tegra_runtime_suspend, sdhci_tegra_runtime_resume,
1877+ NULL)
1878+ SET_SYSTEM_SLEEP_PM_OPS(sdhci_tegra_suspend, sdhci_tegra_resume)
1879+};
18311880
18321881 static struct platform_driver sdhci_tegra_driver = {
18331882 .driver = {
drivers/mtd/hyperbus/rpc-if.c+3−1
@@ -130,7 +130,9 @@ static int rpcif_hb_probe(struct platform_device *pdev) · 129 unmodified lines
130130
131131 rpcif_enable_rpm(&hyperbus->rpc);
132132
133− rpcif_hw_init(&hyperbus->rpc, true);
133+ error = rpcif_hw_init(&hyperbus->rpc, true);
134+ if (error)
135+ return error;
134136
135137 hyperbus->hbdev.map.size = hyperbus->rpc.size;
136138 hyperbus->hbdev.map.virt = hyperbus->rpc.dirmap;
drivers/mtd/nand/raw/tegra_nand.c+50−8
@@ -17,8 +17,11 @@ · 16 unmodified lines
1717 #include <linux/mtd/rawnand.h>
1818 #include <linux/of.h>
1919 #include <linux/platform_device.h>
20+#include <linux/pm_runtime.h>
2021 #include <linux/reset.h>
2122
23+#include <soc/tegra/common.h>
24+
2225 #define COMMAND 0x00
2326 #define COMMAND_GO BIT(31)
2427 #define COMMAND_CLE BIT(30)
@@ -1151,6 +1154,7 @@ static int tegra_nand_probe(struct platform_device *pdev) · 1126 unmodified lines
11511154 return -ENOMEM;
11521155
11531156 ctrl->dev = &pdev->dev;
1157+ platform_set_drvdata(pdev, ctrl);
11541158 nand_controller_init(&ctrl->controller);
11551159 ctrl->controller.ops = &tegra_nand_controller_ops;
11561160
@@ -1166,14 +1170,23 @@ static int tegra_nand_probe(struct platform_device *pdev) · 9 unmodified lines
11661170 if (IS_ERR(ctrl->clk))
11671171 return PTR_ERR(ctrl->clk);
11681172
1169− err = clk_prepare_enable(ctrl->clk);
1173+ err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
1174+ if (err)
1175+ return err;
1176+
1177+ /*
1178+ * This driver doesn't support active power management yet,
1179+ * so we will simply keep device resumed.
1180+ */
1181+ pm_runtime_enable(&pdev->dev);
1182+ err = pm_runtime_resume_and_get(&pdev->dev);
11701183 if (err)
11711184 return err;
11721185
11731186 err = reset_control_reset(rst);
11741187 if (err) {
11751188 dev_err(ctrl->dev, "Failed to reset HW: %d\n", err);
1176− goto err_disable_clk;
1189+ goto err_put_pm;
11771190 }
11781191
11791192 writel_relaxed(HWSTATUS_CMD_DEFAULT, ctrl->regs + HWSTATUS_CMD);
@@ -1188,21 +1201,20 @@ static int tegra_nand_probe(struct platform_device *pdev) · 8 unmodified lines
11881201 dev_name(&pdev->dev), ctrl);
11891202 if (err) {
11901203 dev_err(ctrl->dev, "Failed to get IRQ: %d\n", err);
1191− goto err_disable_clk;
1204+ goto err_put_pm;
11921205 }
11931206
11941207 writel_relaxed(DMA_MST_CTRL_IS_DONE, ctrl->regs + DMA_MST_CTRL);
11951208
11961209 err = tegra_nand_chips_init(ctrl->dev, ctrl);
11971210 if (err)
1198− goto err_disable_clk;
1199−
1200− platform_set_drvdata(pdev, ctrl);
1211+ goto err_put_pm;
12011212
12021213 return 0;
12031214
1204−err_disable_clk:
1205− clk_disable_unprepare(ctrl->clk);
1215+err_put_pm:
1216+ pm_runtime_put_sync_suspend(ctrl->dev);
1217+ pm_runtime_force_suspend(ctrl->dev);
12061218 return err;
12071219 }
12081220
@@ -1219,11 +1231,40 @@ static int tegra_nand_remove(struct platform_device *pdev) · 10 unmodified lines
12191231
12201232 nand_cleanup(chip);
12211233
1234+ pm_runtime_put_sync_suspend(ctrl->dev);
1235+ pm_runtime_force_suspend(ctrl->dev);
1236+
1237+ return 0;
1238+}
1239+
1240+static int __maybe_unused tegra_nand_runtime_resume(struct device *dev)
1241+{
1242+ struct tegra_nand_controller *ctrl = dev_get_drvdata(dev);
1243+ int err;
1244+
1245+ err = clk_prepare_enable(ctrl->clk);
1246+ if (err) {
1247+ dev_err(dev, "Failed to enable clock: %d\n", err);
1248+ return err;
1249+ }
1250+
1251+ return 0;
1252+}
1253+
1254+static int __maybe_unused tegra_nand_runtime_suspend(struct device *dev)
1255+{
1256+ struct tegra_nand_controller *ctrl = dev_get_drvdata(dev);
1257+
12221258 clk_disable_unprepare(ctrl->clk);
12231259
12241260 return 0;
12251261 }
12261262
1263+static const struct dev_pm_ops tegra_nand_pm = {
1264+ SET_RUNTIME_PM_OPS(tegra_nand_runtime_suspend, tegra_nand_runtime_resume,
1265+ NULL)
1266+};
1267+
12271268 static const struct of_device_id tegra_nand_of_match[] = {
12281269 { .compatible = "nvidia,tegra20-nand" },
12291270 { /* sentinel */ }
@@ -1234,6 +1275,7 @@ static struct platform_driver tegra_nand_driver = { · 4 unmodified lines
12341275 .driver = {
12351276 .name = "tegra-nand",
12361277 .of_match_table = tegra_nand_of_match,
1278+ .pm = &tegra_nand_pm,
12371279 },
12381280 .probe = tegra_nand_probe,
12391281 .remove = tegra_nand_remove,
drivers/pwm/pwm-tegra.c+64−18
@@ -42,12 +42,16 @@ · 41 unmodified lines
4242 #include <linux/module.h>
4343 #include <linux/of.h>
4444 #include <linux/of_device.h>
45+#include <linux/pm_opp.h>
4546 #include <linux/pwm.h>
4647 #include <linux/platform_device.h>
4748 #include <linux/pinctrl/consumer.h>
49+#include <linux/pm_runtime.h>
4850 #include <linux/slab.h>
4951 #include <linux/reset.h>
5052
53+#include <soc/tegra/common.h>
54+
5155 #define PWM_ENABLE (1 << 31)
5256 #define PWM_DUTY_WIDTH 8
5357 #define PWM_DUTY_SHIFT 16
@@ -145,7 +149,7 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, · 91 unmodified lines
145149 required_clk_rate =
146150 (NSEC_PER_SEC / period_ns) << PWM_DUTY_WIDTH;
147151
148− err = clk_set_rate(pc->clk, required_clk_rate);
152+ err = dev_pm_opp_set_rate(pc->dev, required_clk_rate);
149153 if (err < 0)
150154 return -EINVAL;
151155
@@ -181,8 +185,8 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, · 29 unmodified lines
181185 * before writing the register. Otherwise, keep it enabled.
182186 */
183187 if (!pwm_is_enabled(pwm)) {
184− err = clk_prepare_enable(pc->clk);
185− if (err < 0)
188+ err = pm_runtime_resume_and_get(pc->dev);
189+ if (err)
186190 return err;
187191 } else
188192 val |= PWM_ENABLE;
@@ -193,7 +197,7 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, · 4 unmodified lines
193197 * If the PWM is not enabled, turn the clock off again to save power.
194198 */
195199 if (!pwm_is_enabled(pwm))
196− clk_disable_unprepare(pc->clk);
200+ pm_runtime_put(pc->dev);
197201
198202 return 0;
199203 }
@@ -204,8 +208,8 @@ static int tegra_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) · 4 unmodified lines
204208 int rc = 0;
205209 u32 val;
206210
207− rc = clk_prepare_enable(pc->clk);
208− if (rc < 0)
211+ rc = pm_runtime_resume_and_get(pc->dev);
212+ if (rc)
209213 return rc;
210214
211215 val = pwm_readl(pc, pwm->hwpwm);
@@ -224,7 +228,7 @@ static void tegra_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) · 12 unmodified lines
224228 val &= ~PWM_ENABLE;
225229 pwm_writel(pc, pwm->hwpwm, val);
226230
227− clk_disable_unprepare(pc->clk);
231+ pm_runtime_put_sync(pc->dev);
228232 }
229233
230234 static const struct pwm_ops tegra_pwm_ops = {
@@ -256,11 +260,20 @@ static int tegra_pwm_probe(struct platform_device *pdev) · 25 unmodified lines
256260 if (IS_ERR(pwm->clk))
257261 return PTR_ERR(pwm->clk);
258262
263+ ret = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
264+ if (ret)
265+ return ret;
266+
267+ pm_runtime_enable(&pdev->dev);
268+ ret = pm_runtime_resume_and_get(&pdev->dev);
269+ if (ret)
270+ return ret;
271+
259272 /* Set maximum frequency of the IP */
260− ret = clk_set_rate(pwm->clk, pwm->soc->max_frequency);
273+ ret = dev_pm_opp_set_rate(pwm->dev, pwm->soc->max_frequency);
261274 if (ret < 0) {
262275 dev_err(&pdev->dev, "Failed to set max frequency: %d\n", ret);
263− return ret;
276+ goto put_pm;
264277 }
265278
266279 /*
@@ -278,7 +291,7 @@ static int tegra_pwm_probe(struct platform_device *pdev) · 11 unmodified lines
278291 if (IS_ERR(pwm->rst)) {
279292 ret = PTR_ERR(pwm->rst);
280293 dev_err(&pdev->dev, "Reset control is not found: %d\n", ret);
281− return ret;
294+ goto put_pm;
282295 }
283296
284297 reset_control_deassert(pwm->rst);
@@ -291,10 +304,16 @@ static int tegra_pwm_probe(struct platform_device *pdev) · 6 unmodified lines
291304 if (ret < 0) {
292305 dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
293306 reset_control_assert(pwm->rst);
294− return ret;
307+ goto put_pm;
295308 }
296309
310+ pm_runtime_put(&pdev->dev);
311+
297312 return 0;
313+put_pm:
314+ pm_runtime_put_sync_suspend(&pdev->dev);
315+ pm_runtime_force_suspend(&pdev->dev);
316+ return ret;
298317 }
299318
300319 static int tegra_pwm_remove(struct platform_device *pdev)
@@ -305,20 +324,44 @@ static int tegra_pwm_remove(struct platform_device *pdev) · 4 unmodified lines
305324
306325 reset_control_assert(pc->rst);
307326
327+ pm_runtime_force_suspend(&pdev->dev);
328+
308329 return 0;
309330 }
310331
311−#ifdef CONFIG_PM_SLEEP
312−static int tegra_pwm_suspend(struct device *dev)
332+static int __maybe_unused tegra_pwm_runtime_suspend(struct device *dev)
313333 {
314− return pinctrl_pm_select_sleep_state(dev);
334+ struct tegra_pwm_chip *pc = dev_get_drvdata(dev);
335+ int err;
336+
337+ clk_disable_unprepare(pc->clk);
338+
339+ err = pinctrl_pm_select_sleep_state(dev);
340+ if (err) {
341+ clk_prepare_enable(pc->clk);
342+ return err;
343+ }
344+
345+ return 0;
315346 }
316347
317−static int tegra_pwm_resume(struct device *dev)
348+static int __maybe_unused tegra_pwm_runtime_resume(struct device *dev)
318349 {
319− return pinctrl_pm_select_default_state(dev);
350+ struct tegra_pwm_chip *pc = dev_get_drvdata(dev);
351+ int err;
352+
353+ err = pinctrl_pm_select_default_state(dev);
354+ if (err)
355+ return err;
356+
357+ err = clk_prepare_enable(pc->clk);
358+ if (err) {
359+ pinctrl_pm_select_sleep_state(dev);
360+ return err;
361+ }
362+
363+ return 0;
320364 }
321−#endif
322365
323366 static const struct tegra_pwm_soc tegra20_pwm_soc = {
324367 .num_channels = 4,
@@ -344,7 +387,10 @@ static const struct of_device_id tegra_pwm_of_match[] = { · 19 unmodified lines
344387 MODULE_DEVICE_TABLE(of, tegra_pwm_of_match);
345388
346389 static const struct dev_pm_ops tegra_pwm_pm_ops = {
347− SET_SYSTEM_SLEEP_PM_OPS(tegra_pwm_suspend, tegra_pwm_resume)
390+ SET_RUNTIME_PM_OPS(tegra_pwm_runtime_suspend, tegra_pwm_runtime_resume,
391+ NULL)
392+ SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
393+ pm_runtime_force_resume)
348394 };
349395
350396 static struct platform_driver tegra_pwm_driver = {
drivers/soc/Kconfig+1−0
@@ -3,6 +3,7 @@ menu "SOC (System On Chip) specific Drivers" · 2 unmodified lines
33
44 source "drivers/soc/actions/Kconfig"
55 source "drivers/soc/amlogic/Kconfig"
6+source "drivers/soc/apple/Kconfig"
67 source "drivers/soc/aspeed/Kconfig"
78 source "drivers/soc/atmel/Kconfig"
89 source "drivers/soc/bcm/Kconfig"
drivers/soc/Makefile+1−0
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 #
55
66 obj-$(CONFIG_ARCH_ACTIONS) += actions/
7+obj-$(CONFIG_ARCH_APPLE) += apple/
78 obj-y += aspeed/
89 obj-$(CONFIG_ARCH_AT91) += atmel/
910 obj-y += bcm/
drivers/soc/apple/Kconfig+22−0
@@ -0,0 +1,22 @@
1+# SPDX-License-Identifier: GPL-2.0-only
2+
3+if ARCH_APPLE || COMPILE_TEST
4+
5+menu "Apple SoC drivers"
6+
7+config APPLE_PMGR_PWRSTATE
8+ bool "Apple SoC PMGR power state control"
9+ depends on PM
10+ select REGMAP
11+ select MFD_SYSCON
12+ select PM_GENERIC_DOMAINS
13+ select RESET_CONTROLLER
14+ default ARCH_APPLE
15+ help
16+ The PMGR block in Apple SoCs provides high-level power state
17+ controls for SoC devices. This driver manages them through the
18+ generic power domain framework, and also provides reset support.
19+
20+endmenu
21+
22+endif
drivers/soc/apple/Makefile+2−0
@@ -0,0 +1,2 @@
1+# SPDX-License-Identifier: GPL-2.0-only
2+obj-$(CONFIG_APPLE_PMGR_PWRSTATE) += apple-pmgr-pwrstate.o
drivers/soc/apple/apple-pmgr-pwrstate.c+324−0
@@ -0,0 +1,324 @@
1+// SPDX-License-Identifier: GPL-2.0-only OR MIT
2+/*
3+ * Apple SoC PMGR device power state driver
4+ *
5+ * Copyright The Asahi Linux Contributors
6+ */
7+
8+#include <linux/bitops.h>
9+#include <linux/bitfield.h>
10+#include <linux/err.h>
11+#include <linux/of.h>
12+#include <linux/of_address.h>
13+#include <linux/platform_device.h>
14+#include <linux/pm_domain.h>
15+#include <linux/regmap.h>
16+#include <linux/mfd/syscon.h>
17+#include <linux/reset-controller.h>
18+#include <linux/module.h>
19+
20+#define APPLE_PMGR_RESET BIT(31)
21+#define APPLE_PMGR_AUTO_ENABLE BIT(28)
22+#define APPLE_PMGR_PS_AUTO GENMASK(27, 24)
23+#define APPLE_PMGR_PS_MIN GENMASK(19, 16)
24+#define APPLE_PMGR_PARENT_OFF BIT(11)
25+#define APPLE_PMGR_DEV_DISABLE BIT(10)
26+#define APPLE_PMGR_WAS_CLKGATED BIT(9)
27+#define APPLE_PMGR_WAS_PWRGATED BIT(8)
28+#define APPLE_PMGR_PS_ACTUAL GENMASK(7, 4)
29+#define APPLE_PMGR_PS_TARGET GENMASK(3, 0)
30+
31+#define APPLE_PMGR_FLAGS (APPLE_PMGR_WAS_CLKGATED | APPLE_PMGR_WAS_PWRGATED)
32+
33+#define APPLE_PMGR_PS_ACTIVE 0xf
34+#define APPLE_PMGR_PS_CLKGATE 0x4
35+#define APPLE_PMGR_PS_PWRGATE 0x0
36+
37+#define APPLE_PMGR_PS_SET_TIMEOUT 100
38+#define APPLE_PMGR_RESET_TIME 1
39+
40+struct apple_pmgr_ps {
41+ struct device *dev;
42+ struct generic_pm_domain genpd;
43+ struct reset_controller_dev rcdev;
44+ struct regmap *regmap;
45+ u32 offset;
46+ u32 min_state;
47+};
48+
49+#define genpd_to_apple_pmgr_ps(_genpd) container_of(_genpd, struct apple_pmgr_ps, genpd)
50+#define rcdev_to_apple_pmgr_ps(_rcdev) container_of(_rcdev, struct apple_pmgr_ps, rcdev)
51+
52+static int apple_pmgr_ps_set(struct generic_pm_domain *genpd, u32 pstate, bool auto_enable)
53+{
54+ int ret;
55+ struct apple_pmgr_ps *ps = genpd_to_apple_pmgr_ps(genpd);
56+ u32 reg;
57+
58+ ret = regmap_read(ps->regmap, ps->offset, &reg);
59+ if (ret < 0)
60+ return ret;
61+
62+ /* Resets are synchronous, and only work if the device is powered and clocked. */
63+ if (reg & APPLE_PMGR_RESET && pstate != APPLE_PMGR_PS_ACTIVE)
64+ dev_err(ps->dev, "PS %s: powering off with RESET active\n",
65+ genpd->name);
66+
67+ reg &= ~(APPLE_PMGR_AUTO_ENABLE | APPLE_PMGR_FLAGS | APPLE_PMGR_PS_TARGET);
68+ reg |= FIELD_PREP(APPLE_PMGR_PS_TARGET, pstate);
69+
70+ dev_dbg(ps->dev, "PS %s: pwrstate = 0x%x: 0x%x\n", genpd->name, pstate, reg);
71+
72+ regmap_write(ps->regmap, ps->offset, reg);
73+
74+ ret = regmap_read_poll_timeout_atomic(
75+ ps->regmap, ps->offset, reg,
76+ (FIELD_GET(APPLE_PMGR_PS_ACTUAL, reg) == pstate), 1,
77+ APPLE_PMGR_PS_SET_TIMEOUT);
78+ if (ret < 0)
79+ dev_err(ps->dev, "PS %s: Failed to reach power state 0x%x (now: 0x%x)\n",
80+ genpd->name, pstate, reg);
81+
82+ if (auto_enable) {
83+ /* Not all devices implement this; this is a no-op where not implemented. */
84+ reg &= ~APPLE_PMGR_FLAGS;
85+ reg |= APPLE_PMGR_AUTO_ENABLE;
86+ regmap_write(ps->regmap, ps->offset, reg);
87+ }
88+
89+ return ret;
90+}
91+
92+static bool apple_pmgr_ps_is_active(struct apple_pmgr_ps *ps)
93+{
94+ u32 reg = 0;
95+
96+ regmap_read(ps->regmap, ps->offset, &reg);
97+ /*
98+ * We consider domains as active if they are actually on, or if they have auto-PM
99+ * enabled and the intended target is on.
100+ */
101+ return (FIELD_GET(APPLE_PMGR_PS_ACTUAL, reg) == APPLE_PMGR_PS_ACTIVE ||
102+ (FIELD_GET(APPLE_PMGR_PS_TARGET, reg) == APPLE_PMGR_PS_ACTIVE &&
103+ reg & APPLE_PMGR_AUTO_ENABLE));
104+}
105+
106+static int apple_pmgr_ps_power_on(struct generic_pm_domain *genpd)
107+{
108+ return apple_pmgr_ps_set(genpd, APPLE_PMGR_PS_ACTIVE, true);
109+}
110+
111+static int apple_pmgr_ps_power_off(struct generic_pm_domain *genpd)
112+{
113+ return apple_pmgr_ps_set(genpd, APPLE_PMGR_PS_PWRGATE, false);
114+}
115+
116+static int apple_pmgr_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
117+{
118+ struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev);
119+
120+ mutex_lock(&ps->genpd.mlock);
121+
122+ if (ps->genpd.status == GENPD_STATE_OFF)
123+ dev_err(ps->dev, "PS 0x%x: asserting RESET while powered down\n", ps->offset);
124+
125+ dev_dbg(ps->dev, "PS 0x%x: assert reset\n", ps->offset);
126+ /* Quiesce device before asserting reset */
127+ regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_DEV_DISABLE,
128+ APPLE_PMGR_DEV_DISABLE);
129+ regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_RESET,
130+ APPLE_PMGR_RESET);
131+
132+ mutex_unlock(&ps->genpd.mlock);
133+
134+ return 0;
135+}
136+
137+static int apple_pmgr_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
138+{
139+ struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev);
140+
141+ mutex_lock(&ps->genpd.mlock);
142+
143+ dev_dbg(ps->dev, "PS 0x%x: deassert reset\n", ps->offset);
144+ regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_RESET, 0);
145+ regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_DEV_DISABLE, 0);
146+
147+ if (ps->genpd.status == GENPD_STATE_OFF)
148+ dev_err(ps->dev, "PS 0x%x: RESET was deasserted while powered down\n", ps->offset);
149+
150+ mutex_unlock(&ps->genpd.mlock);
151+
152+ return 0;
153+}
154+
155+static int apple_pmgr_reset_reset(struct reset_controller_dev *rcdev, unsigned long id)
156+{
157+ int ret;
158+
159+ ret = apple_pmgr_reset_assert(rcdev, id);
160+ if (ret)
161+ return ret;
162+
163+ usleep_range(APPLE_PMGR_RESET_TIME, 2 * APPLE_PMGR_RESET_TIME);
164+
165+ return apple_pmgr_reset_deassert(rcdev, id);
166+}
167+
168+static int apple_pmgr_reset_status(struct reset_controller_dev *rcdev, unsigned long id)
169+{
170+ struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev);
171+ u32 reg = 0;
172+
173+ regmap_read(ps->regmap, ps->offset, &reg);
174+
175+ return !!(reg & APPLE_PMGR_RESET);
176+}
177+
178+const struct reset_control_ops apple_pmgr_reset_ops = {
179+ .assert = apple_pmgr_reset_assert,
180+ .deassert = apple_pmgr_reset_deassert,
181+ .reset = apple_pmgr_reset_reset,
182+ .status = apple_pmgr_reset_status,
183+};
184+
185+static int apple_pmgr_reset_xlate(struct reset_controller_dev *rcdev,
186+ const struct of_phandle_args *reset_spec)
187+{
188+ return 0;
189+}
190+
191+static int apple_pmgr_ps_probe(struct platform_device *pdev)
192+{
193+ struct device *dev = &pdev->dev;
194+ struct device_node *node = dev->of_node;
195+ struct apple_pmgr_ps *ps;
196+ struct regmap *regmap;
197+ struct of_phandle_iterator it;
198+ int ret;
199+ const char *name;
200+ bool active;
201+
202+ regmap = syscon_node_to_regmap(node->parent);
203+ if (IS_ERR(regmap))
204+ return PTR_ERR(regmap);
205+
206+ ps = devm_kzalloc(dev, sizeof(*ps), GFP_KERNEL);
207+ if (!ps)
208+ return -ENOMEM;
209+
210+ ps->dev = dev;
211+ ps->regmap = regmap;
212+
213+ ret = of_property_read_string(node, "label", &name);
214+ if (ret < 0) {
215+ dev_err(dev, "missing label property\n");
216+ return ret;
217+ }
218+
219+ ret = of_property_read_u32(node, "reg", &ps->offset);
220+ if (ret < 0) {
221+ dev_err(dev, "missing reg property\n");
222+ return ret;
223+ }
224+
225+ ps->genpd.name = name;
226+ ps->genpd.power_on = apple_pmgr_ps_power_on;
227+ ps->genpd.power_off = apple_pmgr_ps_power_off;
228+
229+ ret = of_property_read_u32(node, "apple,min-state", &ps->min_state);
230+ if (ret == 0 && ps->min_state <= APPLE_PMGR_PS_ACTIVE)
231+ regmap_update_bits(regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_PS_MIN,
232+ FIELD_PREP(APPLE_PMGR_PS_MIN, ps->min_state));
233+
234+ active = apple_pmgr_ps_is_active(ps);
235+ if (of_property_read_bool(node, "apple,always-on")) {
236+ ps->genpd.flags |= GENPD_FLAG_ALWAYS_ON;
237+ if (!active) {
238+ dev_warn(dev, "always-on domain %s is not on at boot\n", name);
239+ /* Turn it on so pm_genpd_init does not fail */
240+ active = apple_pmgr_ps_power_on(&ps->genpd) == 0;
241+ }
242+ }
243+
244+ /* Turn on auto-PM if the domain is already on */
245+ if (active)
246+ regmap_update_bits(regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_AUTO_ENABLE,
247+ APPLE_PMGR_AUTO_ENABLE);
248+
249+ ret = pm_genpd_init(&ps->genpd, NULL, !active);
250+ if (ret < 0) {
251+ dev_err(dev, "pm_genpd_init failed\n");
252+ return ret;
253+ }
254+
255+ ret = of_genpd_add_provider_simple(node, &ps->genpd);
256+ if (ret < 0) {
257+ dev_err(dev, "of_genpd_add_provider_simple failed\n");
258+ return ret;
259+ }
260+
261+ of_for_each_phandle(&it, ret, node, "power-domains", "#power-domain-cells", -1) {
262+ struct of_phandle_args parent, child;
263+
264+ parent.np = it.node;
265+ parent.args_count = of_phandle_iterator_args(&it, parent.args, MAX_PHANDLE_ARGS);
266+ child.np = node;
267+ child.args_count = 0;
268+ ret = of_genpd_add_subdomain(&parent, &child);
269+
270+ if (ret == -EPROBE_DEFER) {
271+ of_node_put(parent.np);
272+ goto err_remove;
273+ } else if (ret < 0) {
274+ dev_err(dev, "failed to add to parent domain: %d (%s -> %s)\n",
275+ ret, it.node->name, node->name);
276+ of_node_put(parent.np);
277+ goto err_remove;
278+ }
279+ }
280+
281+ /*
282+ * Do not participate in regular PM; parent power domains are handled via the
283+ * genpd hierarchy.
284+ */
285+ pm_genpd_remove_device(dev);
286+
287+ ps->rcdev.owner = THIS_MODULE;
288+ ps->rcdev.nr_resets = 1;
289+ ps->rcdev.ops = &apple_pmgr_reset_ops;
290+ ps->rcdev.of_node = dev->of_node;
291+ ps->rcdev.of_reset_n_cells = 0;
292+ ps->rcdev.of_xlate = apple_pmgr_reset_xlate;
293+
294+ ret = devm_reset_controller_register(dev, &ps->rcdev);
295+ if (ret < 0)
296+ goto err_remove;
297+
298+ return 0;
299+err_remove:
300+ of_genpd_del_provider(node);
301+ pm_genpd_remove(&ps->genpd);
302+ return ret;
303+}
304+
305+static const struct of_device_id apple_pmgr_ps_of_match[] = {
306+ { .compatible = "apple,pmgr-pwrstate" },
307+ {}
308+};
309+
310+MODULE_DEVICE_TABLE(of, apple_pmgr_ps_of_match);
311+
312+static struct platform_driver apple_pmgr_ps_driver = {
313+ .probe = apple_pmgr_ps_probe,
314+ .driver = {
315+ .name = "apple-pmgr-pwrstate",
316+ .of_match_table = apple_pmgr_ps_of_match,
317+ },
318+};
319+
320+MODULE_AUTHOR("Hector Martin <marcan@marcan.st>");
321+MODULE_DESCRIPTION("PMGR power state driver for Apple SoCs");
322+MODULE_LICENSE("GPL v2");
323+
324+module_platform_driver(apple_pmgr_ps_driver);
drivers/soc/imx/gpcv2.c+28−1
@@ -377,7 +377,7 @@ static int imx_pgc_power_down(struct generic_pm_domain *genpd) · 376 unmodified lines
377377 }
378378 }
379379
380− pm_runtime_put(domain->dev);
380+ pm_runtime_put_sync_suspend(domain->dev);
381381
382382 return 0;
383383
@@ -734,6 +734,7 @@ static const struct imx_pgc_domain imx8mm_pgc_domains[] = { · 350 unmodified lines
734734 .map = IMX8MM_VPUH1_A53_DOMAIN,
735735 },
736736 .pgc = BIT(IMX8MM_PGC_VPUH1),
737+ .keep_clocks = true,
737738 },
738739
739740 [IMX8MM_POWER_DOMAIN_DISPMIX] = {
@@ -840,6 +841,32 @@ static const struct imx_pgc_domain imx8mn_pgc_domains[] = { · 100 unmodified lines
840841 .hskack = IMX8MN_GPUMIX_HSK_PWRDNACKN,
841842 },
842843 .pgc = BIT(IMX8MN_PGC_GPUMIX),
844+ .keep_clocks = true,
845+ },
846+
847+ [IMX8MN_POWER_DOMAIN_DISPMIX] = {
848+ .genpd = {
849+ .name = "dispmix",
850+ },
851+ .bits = {
852+ .pxx = IMX8MN_DISPMIX_SW_Pxx_REQ,
853+ .map = IMX8MN_DISPMIX_A53_DOMAIN,
854+ .hskreq = IMX8MN_DISPMIX_HSK_PWRDNREQN,
855+ .hskack = IMX8MN_DISPMIX_HSK_PWRDNACKN,
856+ },
857+ .pgc = BIT(IMX8MN_PGC_DISPMIX),
858+ .keep_clocks = true,
859+ },
860+
861+ [IMX8MN_POWER_DOMAIN_MIPI] = {
862+ .genpd = {
863+ .name = "mipi",
864+ },
865+ .bits = {
866+ .pxx = IMX8MN_MIPI_SW_Pxx_REQ,
867+ .map = IMX8MN_MIPI_A53_DOMAIN,
868+ },
869+ .pgc = BIT(IMX8MN_PGC_MIPI),
843870 },
844871 };
845872
drivers/soc/imx/imx8m-blk-ctrl.c+76−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/clk.h>
1515
1616 #include <dt-bindings/power/imx8mm-power.h>
17+#include <dt-bindings/power/imx8mn-power.h>
1718
1819 #define BLK_SFT_RSTN 0x0
1920 #define BLK_CLK_EN 0x4
@@ -517,6 +518,77 @@ static const struct imx8m_blk_ctrl_data imx8mm_disp_blk_ctl_dev_data = { · 497 unmodified lines
517518 .num_domains = ARRAY_SIZE(imx8mm_disp_blk_ctl_domain_data),
518519 };
519520
521+
522+static int imx8mn_disp_power_notifier(struct notifier_block *nb,
523+ unsigned long action, void *data)
524+{
525+ struct imx8m_blk_ctrl *bc = container_of(nb, struct imx8m_blk_ctrl,
526+ power_nb);
527+
528+ if (action != GENPD_NOTIFY_ON && action != GENPD_NOTIFY_PRE_OFF)
529+ return NOTIFY_OK;
530+
531+ /* Enable bus clock and deassert bus reset */
532+ regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(8));
533+ regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(8));
534+
535+ /*
536+ * On power up we have no software backchannel to the GPC to
537+ * wait for the ADB handshake to happen, so we just delay for a
538+ * bit. On power down the GPC driver waits for the handshake.
539+ */
540+ if (action == GENPD_NOTIFY_ON)
541+ udelay(5);
542+
543+
544+ return NOTIFY_OK;
545+}
546+
547+static const struct imx8m_blk_ctrl_domain_data imx8mn_disp_blk_ctl_domain_data[] = {
548+ [IMX8MN_DISPBLK_PD_MIPI_DSI] = {
549+ .name = "dispblk-mipi-dsi",
550+ .clk_names = (const char *[]){ "dsi-pclk", "dsi-ref", },
551+ .num_clks = 2,
552+ .gpc_name = "mipi-dsi",
553+ .rst_mask = BIT(0) | BIT(1),
554+ .clk_mask = BIT(0) | BIT(1),
555+ .mipi_phy_rst_mask = BIT(17),
556+ },
557+ [IMX8MN_DISPBLK_PD_MIPI_CSI] = {
558+ .name = "dispblk-mipi-csi",
559+ .clk_names = (const char *[]){ "csi-aclk", "csi-pclk" },
560+ .num_clks = 2,
561+ .gpc_name = "mipi-csi",
562+ .rst_mask = BIT(2) | BIT(3),
563+ .clk_mask = BIT(2) | BIT(3),
564+ .mipi_phy_rst_mask = BIT(16),
565+ },
566+ [IMX8MN_DISPBLK_PD_LCDIF] = {
567+ .name = "dispblk-lcdif",
568+ .clk_names = (const char *[]){ "lcdif-axi", "lcdif-apb", "lcdif-pix", },
569+ .num_clks = 3,
570+ .gpc_name = "lcdif",
571+ .rst_mask = BIT(4) | BIT(5),
572+ .clk_mask = BIT(4) | BIT(5),
573+ },
574+ [IMX8MN_DISPBLK_PD_ISI] = {
575+ .name = "dispblk-isi",
576+ .clk_names = (const char *[]){ "disp_axi", "disp_apb", "disp_axi_root",
577+ "disp_apb_root"},
578+ .num_clks = 4,
579+ .gpc_name = "isi",
580+ .rst_mask = BIT(6) | BIT(7),
581+ .clk_mask = BIT(6) | BIT(7),
582+ },
583+};
584+
585+static const struct imx8m_blk_ctrl_data imx8mn_disp_blk_ctl_dev_data = {
586+ .max_reg = 0x84,
587+ .power_notifier_fn = imx8mn_disp_power_notifier,
588+ .domains = imx8mn_disp_blk_ctl_domain_data,
589+ .num_domains = ARRAY_SIZE(imx8mn_disp_blk_ctl_domain_data),
590+};
591+
520592 static const struct of_device_id imx8m_blk_ctrl_of_match[] = {
521593 {
522594 .compatible = "fsl,imx8mm-vpu-blk-ctrl",
@@ -524,7 +596,10 @@ static const struct of_device_id imx8m_blk_ctrl_of_match[] = { · 1 unmodified line
524596 }, {
525597 .compatible = "fsl,imx8mm-disp-blk-ctrl",
526598 .data = &imx8mm_disp_blk_ctl_dev_data
527− } ,{
599+ }, {
600+ .compatible = "fsl,imx8mn-disp-blk-ctrl",
601+ .data = &imx8mn_disp_blk_ctl_dev_data
602+ }, {
528603 /* Sentinel */
529604 }
530605 };
drivers/soc/qcom/cpr.c+1−1
@@ -1010,7 +1010,7 @@ static int cpr_interpolate(const struct corner *corner, int step_volt, · 1009 unmodified lines
10101010 return corner->uV;
10111011
10121012 temp = f_diff * (uV_high - uV_low);
1013− do_div(temp, f_high - f_low);
1013+ temp = div64_ul(temp, f_high - f_low);
10141014
10151015 /*
10161016 * max_volt_scale has units of uV/MHz while freq values
drivers/soc/qcom/llcc-qcom.c+28−0
@@ -195,6 +195,28 @@ static const struct llcc_slice_config sm8250_data[] = { · 194 unmodified lines
195195 { LLCC_WRCACHE, 31, 256, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
196196 };
197197
198+static const struct llcc_slice_config sm8350_data[] = {
199+ { LLCC_CPUSS, 1, 3072, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 1 },
200+ { LLCC_VIDSC0, 2, 512, 3, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
201+ { LLCC_AUDIO, 6, 1024, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 0, 0 },
202+ { LLCC_MDMHPGRW, 7, 1024, 3, 0, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
203+ { LLCC_MODHW, 9, 1024, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
204+ { LLCC_CMPT, 10, 3072, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
205+ { LLCC_GPUHTW, 11, 1024, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
206+ { LLCC_GPU, 12, 1024, 1, 0, 0xfff, 0x0, 0, 0, 0, 1, 1, 0 },
207+ { LLCC_MMUHWT, 13, 1024, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 0, 1 },
208+ { LLCC_DISP, 16, 3072, 2, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
209+ { LLCC_MDMPNG, 21, 1024, 0, 1, 0xf, 0x0, 0, 0, 0, 0, 1, 0 },
210+ { LLCC_AUDHW, 22, 1024, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
211+ { LLCC_CVP, 28, 512, 3, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
212+ { LLCC_MODPE, 29, 256, 1, 1, 0xf, 0x0, 0, 0, 0, 0, 1, 0 },
213+ { LLCC_APTCM, 30, 1024, 3, 1, 0x0, 0x1, 1, 0, 0, 0, 1, 0 },
214+ { LLCC_WRCACHE, 31, 512, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 0, 1 },
215+ { LLCC_CVPFW, 17, 512, 1, 0, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
216+ { LLCC_CPUSS1, 3, 1024, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 },
217+ { LLCC_CPUHWT, 5, 512, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 0, 1 },
218+};
219+
198220 static const struct qcom_llcc_config sc7180_cfg = {
199221 .sct_data = sc7180_data,
200222 .size = ARRAY_SIZE(sc7180_data),
@@ -228,6 +250,11 @@ static const struct qcom_llcc_config sm8250_cfg = { · 27 unmodified lines
228250 .size = ARRAY_SIZE(sm8250_data),
229251 };
230252
253+static const struct qcom_llcc_config sm8350_cfg = {
254+ .sct_data = sm8350_data,
255+ .size = ARRAY_SIZE(sm8350_data),
256+};
257+
231258 static struct llcc_drv_data *drv_data = (void *) -EPROBE_DEFER;
232259
233260 /**
@@ -644,6 +671,7 @@ static const struct of_device_id qcom_llcc_of_match[] = { · 410 unmodified lines
644671 { .compatible = "qcom,sm6350-llcc", .data = &sm6350_cfg },
645672 { .compatible = "qcom,sm8150-llcc", .data = &sm8150_cfg },
646673 { .compatible = "qcom,sm8250-llcc", .data = &sm8250_cfg },
674+ { .compatible = "qcom,sm8350-llcc", .data = &sm8350_cfg },
647675 { }
648676 };
649677
drivers/soc/qcom/qcom_aoss.c+1−1
@@ -352,7 +352,7 @@ static int qmp_cdev_set_cur_state(struct thermal_cooling_device *cdev, · 351 unmodified lines
352352 return ret;
353353 }
354354
355−static struct thermal_cooling_device_ops qmp_cooling_device_ops = {
355+static const struct thermal_cooling_device_ops qmp_cooling_device_ops = {
356356 .get_max_state = qmp_cdev_get_max_state,
357357 .get_cur_state = qmp_cdev_get_cur_state,
358358 .set_cur_state = qmp_cdev_set_cur_state,
drivers/soc/qcom/qcom_stats.c+13−0
@@ -237,6 +237,15 @@ static const struct stats_config rpm_data = { · 236 unmodified lines
237237 .subsystem_stats_in_smem = false,
238238 };
239239
240+/* Older RPM firmwares have the stats at a fixed offset instead */
241+static const struct stats_config rpm_data_dba0 = {
242+ .stats_offset = 0xdba0,
243+ .num_records = 2,
244+ .appended_stats_avail = true,
245+ .dynamic_offset = false,
246+ .subsystem_stats_in_smem = false,
247+};
248+
240249 static const struct stats_config rpmh_data = {
241250 .stats_offset = 0x48,
242251 .num_records = 3,
@@ -246,6 +255,10 @@ static const struct stats_config rpmh_data = { · 3 unmodified lines
246255 };
247256
248257 static const struct of_device_id qcom_stats_table[] = {
258+ { .compatible = "qcom,apq8084-rpm-stats", .data = &rpm_data_dba0 },
259+ { .compatible = "qcom,msm8226-rpm-stats", .data = &rpm_data_dba0 },
260+ { .compatible = "qcom,msm8916-rpm-stats", .data = &rpm_data_dba0 },
261+ { .compatible = "qcom,msm8974-rpm-stats", .data = &rpm_data_dba0 },
249262 { .compatible = "qcom,rpm-stats", .data = &rpm_data },
250263 { .compatible = "qcom,rpmh-stats", .data = &rpmh_data },
251264 { }
drivers/soc/qcom/qmi_interface.c+1−1
@@ -96,7 +96,7 @@ static void qmi_recv_del_server(struct qmi_handle *qmi, · 95 unmodified lines
9696 * @node: id of the dying node
9797 *
9898 * Signals the client that all previously registered services on this node are
99− * now gone and then calls the bye callback to allow the client client further
99+ * now gone and then calls the bye callback to allow the client further
100100 * cleaning up resources associated with this remote.
101101 */
102102 static void qmi_recv_bye(struct qmi_handle *qmi,
drivers/soc/qcom/rpmh-rsc.c+1−1
@@ -691,7 +691,7 @@ static int find_slots(struct tcs_group *tcs, const struct tcs_request *msg, · 690 unmodified lines
691691 * @drv: The controller.
692692 * @msg: The data to be written to the controller.
693693 *
694− * This should only be called for for sleep/wake state, never active-only
694+ * This should only be called for sleep/wake state, never active-only
695695 * state.
696696 *
697697 * The caller must ensure that no other RPMH actions are happening and the
drivers/soc/qcom/rpmhpd.c+191−135
@@ -63,73 +63,134 @@ struct rpmhpd_desc { · 62 unmodified lines
6363
6464 static DEFINE_MUTEX(rpmhpd_lock);
6565
66−/* SDM845 RPMH powerdomains */
66+/* RPMH powerdomains */
67+
68+static struct rpmhpd cx_ao;
69+static struct rpmhpd mx;
70+static struct rpmhpd mx_ao;
71+static struct rpmhpd cx = {
72+ .pd = { .name = "cx", },
73+ .peer = &cx_ao,
74+ .res_name = "cx.lvl",
75+};
76+
77+static struct rpmhpd cx_ao = {
78+ .pd = { .name = "cx_ao", },
79+ .active_only = true,
80+ .peer = &cx,
81+ .res_name = "cx.lvl",
82+};
6783
68−static struct rpmhpd sdm845_ebi = {
84+static struct rpmhpd cx_ao_w_mx_parent;
85+static struct rpmhpd cx_w_mx_parent = {
86+ .pd = { .name = "cx", },
87+ .peer = &cx_ao_w_mx_parent,
88+ .parent = &mx.pd,
89+ .res_name = "cx.lvl",
90+};
91+
92+static struct rpmhpd cx_ao_w_mx_parent = {
93+ .pd = { .name = "cx_ao", },
94+ .active_only = true,
95+ .peer = &cx_w_mx_parent,
96+ .parent = &mx_ao.pd,
97+ .res_name = "cx.lvl",
98+};
99+
100+static struct rpmhpd ebi = {
69101 .pd = { .name = "ebi", },
70102 .res_name = "ebi.lvl",
71103 };
72104
73−static struct rpmhpd sdm845_lmx = {
74− .pd = { .name = "lmx", },
75− .res_name = "lmx.lvl",
105+static struct rpmhpd gfx = {
106+ .pd = { .name = "gfx", },
107+ .res_name = "gfx.lvl",
76108 };
77109
78−static struct rpmhpd sdm845_lcx = {
110+static struct rpmhpd lcx = {
79111 .pd = { .name = "lcx", },
80112 .res_name = "lcx.lvl",
81113 };
82114
83−static struct rpmhpd sdm845_gfx = {
84− .pd = { .name = "gfx", },
85− .res_name = "gfx.lvl",
115+static struct rpmhpd lmx = {
116+ .pd = { .name = "lmx", },
117+ .res_name = "lmx.lvl",
86118 };
87119
88−static struct rpmhpd sdm845_mss = {
120+static struct rpmhpd mmcx_ao;
121+static struct rpmhpd mmcx = {
122+ .pd = { .name = "mmcx", },
123+ .peer = &mmcx_ao,
124+ .res_name = "mmcx.lvl",
125+};
126+
127+static struct rpmhpd mmcx_ao = {
128+ .pd = { .name = "mmcx_ao", },
129+ .active_only = true,
130+ .peer = &mmcx,
131+ .res_name = "mmcx.lvl",
132+};
133+
134+static struct rpmhpd mmcx_ao_w_cx_parent;
135+static struct rpmhpd mmcx_w_cx_parent = {
136+ .pd = { .name = "mmcx", },
137+ .peer = &mmcx_ao_w_cx_parent,
138+ .parent = &cx.pd,
139+ .res_name = "mmcx.lvl",
140+};
141+
142+static struct rpmhpd mmcx_ao_w_cx_parent = {
143+ .pd = { .name = "mmcx_ao", },
144+ .active_only = true,
145+ .peer = &mmcx_w_cx_parent,
146+ .parent = &cx_ao.pd,
147+ .res_name = "mmcx.lvl",
148+};
149+
150+static struct rpmhpd mss = {
89151 .pd = { .name = "mss", },
90152 .res_name = "mss.lvl",
91153 };
92154
93−static struct rpmhpd sdm845_mx_ao;
94−static struct rpmhpd sdm845_mx = {
155+static struct rpmhpd mx_ao;
156+static struct rpmhpd mx = {
95157 .pd = { .name = "mx", },
96− .peer = &sdm845_mx_ao,
158+ .peer = &mx_ao,
97159 .res_name = "mx.lvl",
98160 };
99161
100−static struct rpmhpd sdm845_mx_ao = {
162+static struct rpmhpd mx_ao = {
101163 .pd = { .name = "mx_ao", },
102164 .active_only = true,
103− .peer = &sdm845_mx,
165+ .peer = &mx,
104166 .res_name = "mx.lvl",
105167 };
106168
107−static struct rpmhpd sdm845_cx_ao;
108−static struct rpmhpd sdm845_cx = {
109− .pd = { .name = "cx", },
110− .peer = &sdm845_cx_ao,
111− .parent = &sdm845_mx.pd,
112− .res_name = "cx.lvl",
169+static struct rpmhpd mxc_ao;
170+static struct rpmhpd mxc = {
171+ .pd = { .name = "mxc", },
172+ .peer = &mxc_ao,
173+ .res_name = "mxc.lvl",
113174 };
114175
115−static struct rpmhpd sdm845_cx_ao = {
116− .pd = { .name = "cx_ao", },
176+static struct rpmhpd mxc_ao = {
177+ .pd = { .name = "mxc_ao", },
117178 .active_only = true,
118− .peer = &sdm845_cx,
119− .parent = &sdm845_mx_ao.pd,
120− .res_name = "cx.lvl",
179+ .peer = &mxc,
180+ .res_name = "mxc.lvl",
121181 };
122182
183+/* SDM845 RPMH powerdomains */
123184 static struct rpmhpd *sdm845_rpmhpds[] = {
124− [SDM845_EBI] = &sdm845_ebi,
125− [SDM845_MX] = &sdm845_mx,
126− [SDM845_MX_AO] = &sdm845_mx_ao,
127− [SDM845_CX] = &sdm845_cx,
128− [SDM845_CX_AO] = &sdm845_cx_ao,
129− [SDM845_LMX] = &sdm845_lmx,
130− [SDM845_LCX] = &sdm845_lcx,
131− [SDM845_GFX] = &sdm845_gfx,
132− [SDM845_MSS] = &sdm845_mss,
185+ [SDM845_CX] = &cx_w_mx_parent,
186+ [SDM845_CX_AO] = &cx_ao_w_mx_parent,
187+ [SDM845_EBI] = &ebi,
188+ [SDM845_GFX] = &gfx,
189+ [SDM845_LCX] = &lcx,
190+ [SDM845_LMX] = &lmx,
191+ [SDM845_MSS] = &mss,
192+ [SDM845_MX] = &mx,
193+ [SDM845_MX_AO] = &mx_ao,
133194 };
134195
135196 static const struct rpmhpd_desc sdm845_desc = {
@@ -139,9 +200,9 @@ static const struct rpmhpd_desc sdm845_desc = { · 3 unmodified lines
139200
140201 /* SDX55 RPMH powerdomains */
141202 static struct rpmhpd *sdx55_rpmhpds[] = {
142− [SDX55_MSS] = &sdm845_mss,
143− [SDX55_MX] = &sdm845_mx,
144− [SDX55_CX] = &sdm845_cx,
203+ [SDX55_CX] = &cx_w_mx_parent,
204+ [SDX55_MSS] = &mss,
205+ [SDX55_MX] = &mx,
145206 };
146207
147208 static const struct rpmhpd_desc sdx55_desc = {
@@ -151,12 +212,12 @@ static const struct rpmhpd_desc sdx55_desc = { · 3 unmodified lines
151212
152213 /* SM6350 RPMH powerdomains */
153214 static struct rpmhpd *sm6350_rpmhpds[] = {
154− [SM6350_CX] = &sdm845_cx,
155− [SM6350_GFX] = &sdm845_gfx,
156− [SM6350_LCX] = &sdm845_lcx,
157− [SM6350_LMX] = &sdm845_lmx,
158− [SM6350_MSS] = &sdm845_mss,
159− [SM6350_MX] = &sdm845_mx,
215+ [SM6350_CX] = &cx_w_mx_parent,
216+ [SM6350_GFX] = &gfx,
217+ [SM6350_LCX] = &lcx,
218+ [SM6350_LMX] = &lmx,
219+ [SM6350_MSS] = &mss,
220+ [SM6350_MX] = &mx,
160221 };
161222
162223 static const struct rpmhpd_desc sm6350_desc = {
@@ -165,33 +226,18 @@ static const struct rpmhpd_desc sm6350_desc = { · 2 unmodified lines
165226 };
166227
167228 /* SM8150 RPMH powerdomains */
168−
169−static struct rpmhpd sm8150_mmcx_ao;
170−static struct rpmhpd sm8150_mmcx = {
171− .pd = { .name = "mmcx", },
172− .peer = &sm8150_mmcx_ao,
173− .res_name = "mmcx.lvl",
174−};
175−
176−static struct rpmhpd sm8150_mmcx_ao = {
177− .pd = { .name = "mmcx_ao", },
178− .active_only = true,
179− .peer = &sm8150_mmcx,
180− .res_name = "mmcx.lvl",
181−};
182−
183229 static struct rpmhpd *sm8150_rpmhpds[] = {
184− [SM8150_MSS] = &sdm845_mss,
185− [SM8150_EBI] = &sdm845_ebi,
186− [SM8150_LMX] = &sdm845_lmx,
187− [SM8150_LCX] = &sdm845_lcx,
188− [SM8150_GFX] = &sdm845_gfx,
189− [SM8150_MX] = &sdm845_mx,
190− [SM8150_MX_AO] = &sdm845_mx_ao,
191− [SM8150_CX] = &sdm845_cx,
192− [SM8150_CX_AO] = &sdm845_cx_ao,
193− [SM8150_MMCX] = &sm8150_mmcx,
194− [SM8150_MMCX_AO] = &sm8150_mmcx_ao,
230+ [SM8150_CX] = &cx_w_mx_parent,
231+ [SM8150_CX_AO] = &cx_ao_w_mx_parent,
232+ [SM8150_EBI] = &ebi,
233+ [SM8150_GFX] = &gfx,
234+ [SM8150_LCX] = &lcx,
235+ [SM8150_LMX] = &lmx,
236+ [SM8150_MMCX] = &mmcx,
237+ [SM8150_MMCX_AO] = &mmcx_ao,
238+ [SM8150_MSS] = &mss,
239+ [SM8150_MX] = &mx,
240+ [SM8150_MX_AO] = &mx_ao,
195241 };
196242
197243 static const struct rpmhpd_desc sm8150_desc = {
@@ -199,17 +245,18 @@ static const struct rpmhpd_desc sm8150_desc = { · 1 unmodified line
199245 .num_pds = ARRAY_SIZE(sm8150_rpmhpds),
200246 };
201247
248+/* SM8250 RPMH powerdomains */
202249 static struct rpmhpd *sm8250_rpmhpds[] = {
203− [SM8250_CX] = &sdm845_cx,
204− [SM8250_CX_AO] = &sdm845_cx_ao,
205− [SM8250_EBI] = &sdm845_ebi,
206− [SM8250_GFX] = &sdm845_gfx,
207− [SM8250_LCX] = &sdm845_lcx,
208− [SM8250_LMX] = &sdm845_lmx,
209− [SM8250_MMCX] = &sm8150_mmcx,
210− [SM8250_MMCX_AO] = &sm8150_mmcx_ao,
211− [SM8250_MX] = &sdm845_mx,
212− [SM8250_MX_AO] = &sdm845_mx_ao,
250+ [SM8250_CX] = &cx_w_mx_parent,
251+ [SM8250_CX_AO] = &cx_ao_w_mx_parent,
252+ [SM8250_EBI] = &ebi,
253+ [SM8250_GFX] = &gfx,
254+ [SM8250_LCX] = &lcx,
255+ [SM8250_LMX] = &lmx,
256+ [SM8250_MMCX] = &mmcx,
257+ [SM8250_MMCX_AO] = &mmcx_ao,
258+ [SM8250_MX] = &mx,
259+ [SM8250_MX_AO] = &mx_ao,
213260 };
214261
215262 static const struct rpmhpd_desc sm8250_desc = {
@@ -218,34 +265,20 @@ static const struct rpmhpd_desc sm8250_desc = { · 2 unmodified lines
218265 };
219266
220267 /* SM8350 Power domains */
221−static struct rpmhpd sm8350_mxc_ao;
222−static struct rpmhpd sm8350_mxc = {
223− .pd = { .name = "mxc", },
224− .peer = &sm8350_mxc_ao,
225− .res_name = "mxc.lvl",
226−};
227−
228−static struct rpmhpd sm8350_mxc_ao = {
229− .pd = { .name = "mxc_ao", },
230− .active_only = true,
231− .peer = &sm8350_mxc,
232− .res_name = "mxc.lvl",
233−};
234−
235268 static struct rpmhpd *sm8350_rpmhpds[] = {
236− [SM8350_CX] = &sdm845_cx,
237− [SM8350_CX_AO] = &sdm845_cx_ao,
238− [SM8350_EBI] = &sdm845_ebi,
239− [SM8350_GFX] = &sdm845_gfx,
240− [SM8350_LCX] = &sdm845_lcx,
241− [SM8350_LMX] = &sdm845_lmx,
242− [SM8350_MMCX] = &sm8150_mmcx,
243− [SM8350_MMCX_AO] = &sm8150_mmcx_ao,
244− [SM8350_MX] = &sdm845_mx,
245− [SM8350_MX_AO] = &sdm845_mx_ao,
246− [SM8350_MXC] = &sm8350_mxc,
247− [SM8350_MXC_AO] = &sm8350_mxc_ao,
248− [SM8350_MSS] = &sdm845_mss,
269+ [SM8350_CX] = &cx_w_mx_parent,
270+ [SM8350_CX_AO] = &cx_ao_w_mx_parent,
271+ [SM8350_EBI] = &ebi,
272+ [SM8350_GFX] = &gfx,
273+ [SM8350_LCX] = &lcx,
274+ [SM8350_LMX] = &lmx,
275+ [SM8350_MMCX] = &mmcx,
276+ [SM8350_MMCX_AO] = &mmcx_ao,
277+ [SM8350_MSS] = &mss,
278+ [SM8350_MX] = &mx,
279+ [SM8350_MX_AO] = &mx_ao,
280+ [SM8350_MXC] = &mxc,
281+ [SM8350_MXC_AO] = &mxc_ao,
249282 };
250283
251284 static const struct rpmhpd_desc sm8350_desc = {
@@ -253,16 +286,38 @@ static const struct rpmhpd_desc sm8350_desc = { · 1 unmodified line
253286 .num_pds = ARRAY_SIZE(sm8350_rpmhpds),
254287 };
255288
289+/* SM8450 RPMH powerdomains */
290+static struct rpmhpd *sm8450_rpmhpds[] = {
291+ [SM8450_CX] = &cx,
292+ [SM8450_CX_AO] = &cx_ao,
293+ [SM8450_EBI] = &ebi,
294+ [SM8450_GFX] = &gfx,
295+ [SM8450_LCX] = &lcx,
296+ [SM8450_LMX] = &lmx,
297+ [SM8450_MMCX] = &mmcx_w_cx_parent,
298+ [SM8450_MMCX_AO] = &mmcx_ao_w_cx_parent,
299+ [SM8450_MSS] = &mss,
300+ [SM8450_MX] = &mx,
301+ [SM8450_MX_AO] = &mx_ao,
302+ [SM8450_MXC] = &mxc,
303+ [SM8450_MXC_AO] = &mxc_ao,
304+};
305+
306+static const struct rpmhpd_desc sm8450_desc = {
307+ .rpmhpds = sm8450_rpmhpds,
308+ .num_pds = ARRAY_SIZE(sm8450_rpmhpds),
309+};
310+
256311 /* SC7180 RPMH powerdomains */
257312 static struct rpmhpd *sc7180_rpmhpds[] = {
258− [SC7180_CX] = &sdm845_cx,
259− [SC7180_CX_AO] = &sdm845_cx_ao,
260− [SC7180_GFX] = &sdm845_gfx,
261− [SC7180_MX] = &sdm845_mx,
262− [SC7180_MX_AO] = &sdm845_mx_ao,
263− [SC7180_LMX] = &sdm845_lmx,
264− [SC7180_LCX] = &sdm845_lcx,
265− [SC7180_MSS] = &sdm845_mss,
313+ [SC7180_CX] = &cx_w_mx_parent,
314+ [SC7180_CX_AO] = &cx_ao_w_mx_parent,
315+ [SC7180_GFX] = &gfx,
316+ [SC7180_LCX] = &lcx,
317+ [SC7180_LMX] = &lmx,
318+ [SC7180_MSS] = &mss,
319+ [SC7180_MX] = &mx,
320+ [SC7180_MX_AO] = &mx_ao,
266321 };
267322
268323 static const struct rpmhpd_desc sc7180_desc = {
@@ -272,15 +327,15 @@ static const struct rpmhpd_desc sc7180_desc = { · 3 unmodified lines
272327
273328 /* SC7280 RPMH powerdomains */
274329 static struct rpmhpd *sc7280_rpmhpds[] = {
275− [SC7280_CX] = &sdm845_cx,
276− [SC7280_CX_AO] = &sdm845_cx_ao,
277− [SC7280_EBI] = &sdm845_ebi,
278− [SC7280_GFX] = &sdm845_gfx,
279− [SC7280_MX] = &sdm845_mx,
280− [SC7280_MX_AO] = &sdm845_mx_ao,
281− [SC7280_LMX] = &sdm845_lmx,
282− [SC7280_LCX] = &sdm845_lcx,
283− [SC7280_MSS] = &sdm845_mss,
330+ [SC7280_CX] = &cx,
331+ [SC7280_CX_AO] = &cx_ao,
332+ [SC7280_EBI] = &ebi,
333+ [SC7280_GFX] = &gfx,
334+ [SC7280_LCX] = &lcx,
335+ [SC7280_LMX] = &lmx,
336+ [SC7280_MSS] = &mss,
337+ [SC7280_MX] = &mx,
338+ [SC7280_MX_AO] = &mx_ao,
284339 };
285340
286341 static const struct rpmhpd_desc sc7280_desc = {
@@ -290,17 +345,17 @@ static const struct rpmhpd_desc sc7280_desc = { · 3 unmodified lines
290345
291346 /* SC8180x RPMH powerdomains */
292347 static struct rpmhpd *sc8180x_rpmhpds[] = {
293− [SC8180X_CX] = &sdm845_cx,
294− [SC8180X_CX_AO] = &sdm845_cx_ao,
295− [SC8180X_EBI] = &sdm845_ebi,
296− [SC8180X_GFX] = &sdm845_gfx,
297− [SC8180X_LCX] = &sdm845_lcx,
298− [SC8180X_LMX] = &sdm845_lmx,
299− [SC8180X_MMCX] = &sm8150_mmcx,
300− [SC8180X_MMCX_AO] = &sm8150_mmcx_ao,
301− [SC8180X_MSS] = &sdm845_mss,
302− [SC8180X_MX] = &sdm845_mx,
303− [SC8180X_MX_AO] = &sdm845_mx_ao,
348+ [SC8180X_CX] = &cx_w_mx_parent,
349+ [SC8180X_CX_AO] = &cx_ao_w_mx_parent,
350+ [SC8180X_EBI] = &ebi,
351+ [SC8180X_GFX] = &gfx,
352+ [SC8180X_LCX] = &lcx,
353+ [SC8180X_LMX] = &lmx,
354+ [SC8180X_MMCX] = &mmcx,
355+ [SC8180X_MMCX_AO] = &mmcx_ao,
356+ [SC8180X_MSS] = &mss,
357+ [SC8180X_MX] = &mx,
358+ [SC8180X_MX_AO] = &mx_ao,
304359 };
305360
306361 static const struct rpmhpd_desc sc8180x_desc = {
@@ -318,6 +373,7 @@ static const struct of_device_id rpmhpd_match_table[] = { · 11 unmodified lines
318373 { .compatible = "qcom,sm8150-rpmhpd", .data = &sm8150_desc },
319374 { .compatible = "qcom,sm8250-rpmhpd", .data = &sm8250_desc },
320375 { .compatible = "qcom,sm8350-rpmhpd", .data = &sm8350_desc },
376+ { .compatible = "qcom,sm8450-rpmhpd", .data = &sm8450_desc },
321377 { }
322378 };
323379 MODULE_DEVICE_TABLE(of, rpmhpd_match_table);
drivers/soc/qcom/rpmpd.c+41−1
@@ -102,7 +102,6 @@ struct rpmpd { · 101 unmodified lines
102102 const bool active_only;
103103 unsigned int corner;
104104 bool enabled;
105− const char *res_name;
106105 const int res_type;
107106 const int res_id;
108107 struct qcom_smd_rpm *rpm;
@@ -396,6 +395,45 @@ static const struct rpmpd_desc sm6115_desc = { · 287 unmodified lines
396395 .max_state = RPM_SMD_LEVEL_TURBO_NO_CPR,
397396 };
398397
398+/* sm6125 RPM Power domains */
399+DEFINE_RPMPD_PAIR(sm6125, vddcx, vddcx_ao, RWCX, LEVEL, 0);
400+DEFINE_RPMPD_VFL(sm6125, vddcx_vfl, RWCX, 0);
401+
402+DEFINE_RPMPD_PAIR(sm6125, vddmx, vddmx_ao, RWMX, LEVEL, 0);
403+DEFINE_RPMPD_VFL(sm6125, vddmx_vfl, RWMX, 0);
404+
405+static struct rpmpd *sm6125_rpmpds[] = {
406+ [SM6125_VDDCX] = &sm6125_vddcx,
407+ [SM6125_VDDCX_AO] = &sm6125_vddcx_ao,
408+ [SM6125_VDDCX_VFL] = &sm6125_vddcx_vfl,
409+ [SM6125_VDDMX] = &sm6125_vddmx,
410+ [SM6125_VDDMX_AO] = &sm6125_vddmx_ao,
411+ [SM6125_VDDMX_VFL] = &sm6125_vddmx_vfl,
412+};
413+
414+static const struct rpmpd_desc sm6125_desc = {
415+ .rpmpds = sm6125_rpmpds,
416+ .num_pds = ARRAY_SIZE(sm6125_rpmpds),
417+ .max_state = RPM_SMD_LEVEL_BINNING,
418+};
419+
420+static struct rpmpd *qcm2290_rpmpds[] = {
421+ [QCM2290_VDDCX] = &sm6115_vddcx,
422+ [QCM2290_VDDCX_AO] = &sm6115_vddcx_ao,
423+ [QCM2290_VDDCX_VFL] = &sm6115_vddcx_vfl,
424+ [QCM2290_VDDMX] = &sm6115_vddmx,
425+ [QCM2290_VDDMX_AO] = &sm6115_vddmx_ao,
426+ [QCM2290_VDDMX_VFL] = &sm6115_vddmx_vfl,
427+ [QCM2290_VDD_LPI_CX] = &sm6115_vdd_lpi_cx,
428+ [QCM2290_VDD_LPI_MX] = &sm6115_vdd_lpi_mx,
429+};
430+
431+static const struct rpmpd_desc qcm2290_desc = {
432+ .rpmpds = qcm2290_rpmpds,
433+ .num_pds = ARRAY_SIZE(qcm2290_rpmpds),
434+ .max_state = RPM_SMD_LEVEL_TURBO_NO_CPR,
435+};
436+
399437 static const struct of_device_id rpmpd_match_table[] = {
400438 { .compatible = "qcom,mdm9607-rpmpd", .data = &mdm9607_desc },
401439 { .compatible = "qcom,msm8916-rpmpd", .data = &msm8916_desc },
@@ -405,9 +443,11 @@ static const struct of_device_id rpmpd_match_table[] = { · 3 unmodified lines
405443 { .compatible = "qcom,msm8994-rpmpd", .data = &msm8994_desc },
406444 { .compatible = "qcom,msm8996-rpmpd", .data = &msm8996_desc },
407445 { .compatible = "qcom,msm8998-rpmpd", .data = &msm8998_desc },
446+ { .compatible = "qcom,qcm2290-rpmpd", .data = &qcm2290_desc },
408447 { .compatible = "qcom,qcs404-rpmpd", .data = &qcs404_desc },
409448 { .compatible = "qcom,sdm660-rpmpd", .data = &sdm660_desc },
410449 { .compatible = "qcom,sm6115-rpmpd", .data = &sm6115_desc },
450+ { .compatible = "qcom,sm6125-rpmpd", .data = &sm6125_desc },
411451 { }
412452 };
413453 MODULE_DEVICE_TABLE(of, rpmpd_match_table);
drivers/soc/qcom/smem.c+1−1
@@ -85,7 +85,7 @@ · 84 unmodified lines
8585 #define SMEM_GLOBAL_HOST 0xfffe
8686
8787 /* Max number of processors/hosts in a system */
88−#define SMEM_HOST_COUNT 14
88+#define SMEM_HOST_COUNT 15
8989
9090 /**
9191 * struct smem_proc_comm - proc_comm communication struct (legacy)
drivers/soc/qcom/socinfo.c+3−0
@@ -313,8 +313,11 @@ static const struct soc_id soc_id[] = { · 312 unmodified lines
313313 { 421, "IPQ6000" },
314314 { 422, "IPQ6010" },
315315 { 425, "SC7180" },
316+ { 434, "SM6350" },
316317 { 453, "IPQ6005" },
317318 { 455, "QRB5165" },
319+ { 457, "SM8450" },
320+ { 459, "SM7225" },
318321 };
319322
320323 static const char *socinfo_machine(struct device *dev, unsigned int id)
drivers/soc/renesas/Kconfig+15−0
@@ -235,6 +235,13 @@ config ARCH_R8A77961 · 234 unmodified lines
235235 This enables support for the Renesas R-Car M3-W+ SoC.
236236 This includes different gradings like R-Car M3e and M3e-2G.
237237
238+config ARCH_R8A779F0
239+ bool "ARM64 Platform support for R-Car S4-8"
240+ select ARCH_RCAR_GEN3
241+ select SYSC_R8A779F0
242+ help
243+ This enables support for the Renesas R-Car S4-8 SoC.
244+
238245 config ARCH_R8A77980
239246 bool "ARM64 Platform support for R-Car V3H"
240247 select ARCH_RCAR_GEN3
@@ -297,6 +304,9 @@ config RST_RCAR · 56 unmodified lines
297304 config SYSC_RCAR
298305 bool "System Controller support for R-Car" if COMPILE_TEST
299306
307+config SYSC_RCAR_GEN4
308+ bool "System Controller support for R-Car Gen4" if COMPILE_TEST
309+
300310 config SYSC_R8A77995
301311 bool "System Controller support for R-Car D3" if COMPILE_TEST
302312 select SYSC_RCAR
@@ -337,6 +347,10 @@ config SYSC_R8A77961 · 34 unmodified lines
337347 bool "System Controller support for R-Car M3-W+" if COMPILE_TEST
338348 select SYSC_RCAR
339349
350+config SYSC_R8A779F0
351+ bool "System Controller support for R-Car S4-8" if COMPILE_TEST
352+ select SYSC_RCAR_GEN4
353+
340354 config SYSC_R8A7792
341355 bool "System Controller support for R-Car V2H" if COMPILE_TEST
342356 select SYSC_RCAR
@@ -351,6 +365,7 @@ config SYSC_R8A77970 · 8 unmodified lines
351365
352366 config SYSC_R8A779A0
353367 bool "System Controller support for R-Car V3U" if COMPILE_TEST
368+ select SYSC_RCAR_GEN4
354369
355370 config SYSC_RMOBILE
356371 bool "System Controller support for R-Mobile" if COMPILE_TEST
drivers/soc/renesas/Makefile+2−0
@@ -25,6 +25,7 @@ obj-$(CONFIG_SYSC_R8A77980) += r8a77980-sysc.o · 24 unmodified lines
2525 obj-$(CONFIG_SYSC_R8A77990) += r8a77990-sysc.o
2626 obj-$(CONFIG_SYSC_R8A77995) += r8a77995-sysc.o
2727 obj-$(CONFIG_SYSC_R8A779A0) += r8a779a0-sysc.o
28+obj-$(CONFIG_SYSC_R8A779F0) += r8a779f0-sysc.o
2829 ifdef CONFIG_SMP
2930 obj-$(CONFIG_ARCH_R9A06G032) += r9a06g032-smp.o
3031 endif
@@ -32,4 +33,5 @@ endif · 1 unmodified line
3233 # Family
3334 obj-$(CONFIG_RST_RCAR) += rcar-rst.o
3435 obj-$(CONFIG_SYSC_RCAR) += rcar-sysc.o
36+obj-$(CONFIG_SYSC_RCAR_GEN4) += rcar-gen4-sysc.o
3537 obj-$(CONFIG_SYSC_RMOBILE) += rmobile-sysc.o
drivers/soc/renesas/r8a779a0-sysc.c+3−377
@@ -21,35 +21,9 @@ · 20 unmodified lines
2121
2222 #include <dt-bindings/power/r8a779a0-sysc.h>
2323
24−/*
25− * Power Domain flags
26− */
27−#define PD_CPU BIT(0) /* Area contains main CPU core */
28−#define PD_SCU BIT(1) /* Area contains SCU and L2 cache */
29−#define PD_NO_CR BIT(2) /* Area lacks PWR{ON,OFF}CR registers */
30−
31−#define PD_CPU_NOCR PD_CPU | PD_NO_CR /* CPU area lacks CR */
32−#define PD_ALWAYS_ON PD_NO_CR /* Always-on area */
33−
34−/*
35− * Description of a Power Area
36− */
37−struct r8a779a0_sysc_area {
38− const char *name;
39− u8 pdr; /* PDRn */
40− int parent; /* -1 if none */
41− unsigned int flags; /* See PD_* */
42−};
43−
44−/*
45− * SoC-specific Power Area Description
46− */
47−struct r8a779a0_sysc_info {
48− const struct r8a779a0_sysc_area *areas;
49− unsigned int num_areas;
50−};
24+#include "rcar-gen4-sysc.h"
5125
52−static struct r8a779a0_sysc_area r8a779a0_areas[] __initdata = {
26+static struct rcar_gen4_sysc_area r8a779a0_areas[] __initdata = {
5327 { "always-on", R8A779A0_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
5428 { "a3e0", R8A779A0_PD_A3E0, R8A779A0_PD_ALWAYS_ON, PD_SCU },
5529 { "a3e1", R8A779A0_PD_A3E1, R8A779A0_PD_ALWAYS_ON, PD_SCU },
@@ -96,355 +70,7 @@ static struct r8a779a0_sysc_area r8a779a0_areas[] __initdata = { · 40 unmodified lines
9670 { "a1dsp1", R8A779A0_PD_A1DSP1, R8A779A0_PD_A2CN1 },
9771 };
9872
99−static const struct r8a779a0_sysc_info r8a779a0_sysc_info __initconst = {
73+const struct rcar_gen4_sysc_info r8a779a0_sysc_info __initconst = {
10074 .areas = r8a779a0_areas,
10175 .num_areas = ARRAY_SIZE(r8a779a0_areas),
10276 };
103−
104−/* SYSC Common */
105−#define SYSCSR 0x000 /* SYSC Status Register */
106−#define SYSCPONSR(x) (0x800 + ((x) * 0x4)) /* Power-ON Status Register 0 */
107−#define SYSCPOFFSR(x) (0x808 + ((x) * 0x4)) /* Power-OFF Status Register */
108−#define SYSCISCR(x) (0x810 + ((x) * 0x4)) /* Interrupt Status/Clear Register */
109−#define SYSCIER(x) (0x820 + ((x) * 0x4)) /* Interrupt Enable Register */
110−#define SYSCIMR(x) (0x830 + ((x) * 0x4)) /* Interrupt Mask Register */
111−
112−/* Power Domain Registers */
113−#define PDRSR(n) (0x1000 + ((n) * 0x40))
114−#define PDRONCR(n) (0x1004 + ((n) * 0x40))
115−#define PDROFFCR(n) (0x1008 + ((n) * 0x40))
116−#define PDRESR(n) (0x100C + ((n) * 0x40))
117−
118−/* PWRON/PWROFF */
119−#define PWRON_PWROFF BIT(0) /* Power-ON/OFF request */
120−
121−/* PDRESR */
122−#define PDRESR_ERR BIT(0)
123−
124−/* PDRSR */
125−#define PDRSR_OFF BIT(0) /* Power-OFF state */
126−#define PDRSR_ON BIT(4) /* Power-ON state */
127−#define PDRSR_OFF_STATE BIT(8) /* Processing Power-OFF sequence */
128−#define PDRSR_ON_STATE BIT(12) /* Processing Power-ON sequence */
129−
130−#define SYSCSR_BUSY GENMASK(1, 0) /* All bit sets is not busy */
131−
132−#define SYSCSR_TIMEOUT 10000
133−#define SYSCSR_DELAY_US 10
134−
135−#define PDRESR_RETRIES 1000
136−#define PDRESR_DELAY_US 10
137−
138−#define SYSCISR_TIMEOUT 10000
139−#define SYSCISR_DELAY_US 10
140−
141−#define NUM_DOMAINS_EACH_REG BITS_PER_TYPE(u32)
142−
143−static void __iomem *r8a779a0_sysc_base;
144−static DEFINE_SPINLOCK(r8a779a0_sysc_lock); /* SMP CPUs + I/O devices */
145−
146−static int r8a779a0_sysc_pwr_on_off(u8 pdr, bool on)
147−{
148− unsigned int reg_offs;
149− u32 val;
150− int ret;
151−
152− if (on)
153− reg_offs = PDRONCR(pdr);
154− else
155− reg_offs = PDROFFCR(pdr);
156−
157− /* Wait until SYSC is ready to accept a power request */
158− ret = readl_poll_timeout_atomic(r8a779a0_sysc_base + SYSCSR, val,
159− (val & SYSCSR_BUSY) == SYSCSR_BUSY,
160− SYSCSR_DELAY_US, SYSCSR_TIMEOUT);
161− if (ret < 0)
162− return -EAGAIN;
163−
164− /* Submit power shutoff or power resume request */
165− iowrite32(PWRON_PWROFF, r8a779a0_sysc_base + reg_offs);
166−
167− return 0;
168−}
169−
170−static int clear_irq_flags(unsigned int reg_idx, unsigned int isr_mask)
171−{
172− u32 val;
173− int ret;
174−
175− iowrite32(isr_mask, r8a779a0_sysc_base + SYSCISCR(reg_idx));
176−
177− ret = readl_poll_timeout_atomic(r8a779a0_sysc_base + SYSCISCR(reg_idx),
178− val, !(val & isr_mask),
179− SYSCISR_DELAY_US, SYSCISR_TIMEOUT);
180− if (ret < 0) {
181− pr_err("\n %s : Can not clear IRQ flags in SYSCISCR", __func__);
182− return -EIO;
183− }
184−
185− return 0;
186−}
187−
188−static int r8a779a0_sysc_power(u8 pdr, bool on)
189−{
190− unsigned int isr_mask;
191− unsigned int reg_idx, bit_idx;
192− unsigned int status;
193− unsigned long flags;
194− int ret = 0;
195− u32 val;
196− int k;
197−
198− spin_lock_irqsave(&r8a779a0_sysc_lock, flags);
199−
200− reg_idx = pdr / NUM_DOMAINS_EACH_REG;
201− bit_idx = pdr % NUM_DOMAINS_EACH_REG;
202−
203− isr_mask = BIT(bit_idx);
204−
205− /*
206− * The interrupt source needs to be enabled, but masked, to prevent the
207− * CPU from receiving it.
208− */
209− iowrite32(ioread32(r8a779a0_sysc_base + SYSCIER(reg_idx)) | isr_mask,
210− r8a779a0_sysc_base + SYSCIER(reg_idx));
211− iowrite32(ioread32(r8a779a0_sysc_base + SYSCIMR(reg_idx)) | isr_mask,
212− r8a779a0_sysc_base + SYSCIMR(reg_idx));
213−
214− ret = clear_irq_flags(reg_idx, isr_mask);
215− if (ret)
216− goto out;
217−
218− /* Submit power shutoff or resume request until it was accepted */
219− for (k = 0; k < PDRESR_RETRIES; k++) {
220− ret = r8a779a0_sysc_pwr_on_off(pdr, on);
221− if (ret)
222− goto out;
223−
224− status = ioread32(r8a779a0_sysc_base + PDRESR(pdr));
225− if (!(status & PDRESR_ERR))
226− break;
227−
228− udelay(PDRESR_DELAY_US);
229− }
230−
231− if (k == PDRESR_RETRIES) {
232− ret = -EIO;
233− goto out;
234− }
235−
236− /* Wait until the power shutoff or resume request has completed * */
237− ret = readl_poll_timeout_atomic(r8a779a0_sysc_base + SYSCISCR(reg_idx),
238− val, (val & isr_mask),
239− SYSCISR_DELAY_US, SYSCISR_TIMEOUT);
240− if (ret < 0) {
241− ret = -EIO;
242− goto out;
243− }
244−
245− /* Clear interrupt flags */
246− ret = clear_irq_flags(reg_idx, isr_mask);
247− if (ret)
248− goto out;
249−
250− out:
251− spin_unlock_irqrestore(&r8a779a0_sysc_lock, flags);
252−
253− pr_debug("sysc power %s domain %d: %08x -> %d\n", on ? "on" : "off",
254− pdr, ioread32(r8a779a0_sysc_base + SYSCISCR(reg_idx)), ret);
255− return ret;
256−}
257−
258−static bool r8a779a0_sysc_power_is_off(u8 pdr)
259−{
260− unsigned int st;
261−
262− st = ioread32(r8a779a0_sysc_base + PDRSR(pdr));
263−
264− if (st & PDRSR_OFF)
265− return true;
266−
267− return false;
268−}
269−
270−struct r8a779a0_sysc_pd {
271− struct generic_pm_domain genpd;
272− u8 pdr;
273− unsigned int flags;
274− char name[];
275−};
276−
277−static inline struct r8a779a0_sysc_pd *to_r8a779a0_pd(struct generic_pm_domain *d)
278−{
279− return container_of(d, struct r8a779a0_sysc_pd, genpd);
280−}
281−
282−static int r8a779a0_sysc_pd_power_off(struct generic_pm_domain *genpd)
283−{
284− struct r8a779a0_sysc_pd *pd = to_r8a779a0_pd(genpd);
285−
286− pr_debug("%s: %s\n", __func__, genpd->name);
287− return r8a779a0_sysc_power(pd->pdr, false);
288−}
289−
290−static int r8a779a0_sysc_pd_power_on(struct generic_pm_domain *genpd)
291−{
292− struct r8a779a0_sysc_pd *pd = to_r8a779a0_pd(genpd);
293−
294− pr_debug("%s: %s\n", __func__, genpd->name);
295− return r8a779a0_sysc_power(pd->pdr, true);
296−}
297−
298−static int __init r8a779a0_sysc_pd_setup(struct r8a779a0_sysc_pd *pd)
299−{
300− struct generic_pm_domain *genpd = &pd->genpd;
301− const char *name = pd->genpd.name;
302− int error;
303−
304− if (pd->flags & PD_CPU) {
305− /*
306− * This domain contains a CPU core and therefore it should
307− * only be turned off if the CPU is not in use.
308− */
309− pr_debug("PM domain %s contains %s\n", name, "CPU");
310− genpd->flags |= GENPD_FLAG_ALWAYS_ON;
311− } else if (pd->flags & PD_SCU) {
312− /*
313− * This domain contains an SCU and cache-controller, and
314− * therefore it should only be turned off if the CPU cores are
315− * not in use.
316− */
317− pr_debug("PM domain %s contains %s\n", name, "SCU");
318− genpd->flags |= GENPD_FLAG_ALWAYS_ON;
319− } else if (pd->flags & PD_NO_CR) {
320− /*
321− * This domain cannot be turned off.
322− */
323− genpd->flags |= GENPD_FLAG_ALWAYS_ON;
324− }
325−
326− if (!(pd->flags & (PD_CPU | PD_SCU))) {
327− /* Enable Clock Domain for I/O devices */
328− genpd->flags |= GENPD_FLAG_PM_CLK | GENPD_FLAG_ACTIVE_WAKEUP;
329− genpd->attach_dev = cpg_mssr_attach_dev;
330− genpd->detach_dev = cpg_mssr_detach_dev;
331− }
332−
333− genpd->power_off = r8a779a0_sysc_pd_power_off;
334− genpd->power_on = r8a779a0_sysc_pd_power_on;
335−
336− if (pd->flags & (PD_CPU | PD_NO_CR)) {
337− /* Skip CPUs (handled by SMP code) and areas without control */
338− pr_debug("%s: Not touching %s\n", __func__, genpd->name);
339− goto finalize;
340− }
341−
342− if (!r8a779a0_sysc_power_is_off(pd->pdr)) {
343− pr_debug("%s: %s is already powered\n", __func__, genpd->name);
344− goto finalize;
345− }
346−
347− r8a779a0_sysc_power(pd->pdr, true);
348−
349−finalize:
350− error = pm_genpd_init(genpd, &simple_qos_governor, false);
351− if (error)
352− pr_err("Failed to init PM domain %s: %d\n", name, error);
353−
354− return error;
355−}
356−
357−static const struct of_device_id r8a779a0_sysc_matches[] __initconst = {
358− { .compatible = "renesas,r8a779a0-sysc", .data = &r8a779a0_sysc_info },
359− { /* sentinel */ }
360−};
361−
362−struct r8a779a0_pm_domains {
363− struct genpd_onecell_data onecell_data;
364− struct generic_pm_domain *domains[R8A779A0_PD_ALWAYS_ON + 1];
365−};
366−
367−static struct genpd_onecell_data *r8a779a0_sysc_onecell_data;
368−
369−static int __init r8a779a0_sysc_pd_init(void)
370−{
371− const struct r8a779a0_sysc_info *info;
372− const struct of_device_id *match;
373− struct r8a779a0_pm_domains *domains;
374− struct device_node *np;
375− void __iomem *base;
376− unsigned int i;
377− int error;
378−
379− np = of_find_matching_node_and_match(NULL, r8a779a0_sysc_matches, &match);
380− if (!np)
381− return -ENODEV;
382−
383− info = match->data;
384−
385− base = of_iomap(np, 0);
386− if (!base) {
387− pr_warn("%pOF: Cannot map regs\n", np);
388− error = -ENOMEM;
389− goto out_put;
390− }
391−
392− r8a779a0_sysc_base = base;
393−
394− domains = kzalloc(sizeof(*domains), GFP_KERNEL);
395− if (!domains) {
396− error = -ENOMEM;
397− goto out_put;
398− }
399−
400− domains->onecell_data.domains = domains->domains;
401− domains->onecell_data.num_domains = ARRAY_SIZE(domains->domains);
402− r8a779a0_sysc_onecell_data = &domains->onecell_data;
403−
404− for (i = 0; i < info->num_areas; i++) {
405− const struct r8a779a0_sysc_area *area = &info->areas[i];
406− struct r8a779a0_sysc_pd *pd;
407− size_t n;
408−
409− if (!area->name) {
410− /* Skip NULLified area */
411− continue;
412− }
413−
414− n = strlen(area->name) + 1;
415− pd = kzalloc(sizeof(*pd) + n, GFP_KERNEL);
416− if (!pd) {
417− error = -ENOMEM;
418− goto out_put;
419− }
420−
421− memcpy(pd->name, area->name, n);
422− pd->genpd.name = pd->name;
423− pd->pdr = area->pdr;
424− pd->flags = area->flags;
425−
426− error = r8a779a0_sysc_pd_setup(pd);
427− if (error)
428− goto out_put;
429−
430− domains->domains[area->pdr] = &pd->genpd;
431−
432− if (area->parent < 0)
433− continue;
434−
435− error = pm_genpd_add_subdomain(domains->domains[area->parent],
436− &pd->genpd);
437− if (error) {
438− pr_warn("Failed to add PM subdomain %s to parent %u\n",
439− area->name, area->parent);
440− goto out_put;
441− }
442− }
443−
444− error = of_genpd_add_provider_onecell(np, &domains->onecell_data);
445−
446−out_put:
447− of_node_put(np);
448− return error;
449−}
450−early_initcall(r8a779a0_sysc_pd_init);
drivers/soc/renesas/r8a779f0-sysc.c+47−0
@@ -0,0 +1,47 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Renesas R-Car S4-8 System Controller
4+ *
5+ * Copyright (C) 2021 Renesas Electronics Corp.
6+ */
7+
8+#include <linux/bits.h>
9+#include <linux/clk/renesas.h>
10+#include <linux/delay.h>
11+#include <linux/err.h>
12+#include <linux/io.h>
13+#include <linux/iopoll.h>
14+#include <linux/kernel.h>
15+#include <linux/mm.h>
16+#include <linux/of_address.h>
17+#include <linux/pm_domain.h>
18+#include <linux/slab.h>
19+#include <linux/spinlock.h>
20+#include <linux/types.h>
21+
22+#include <dt-bindings/power/r8a779f0-sysc.h>
23+
24+#include "rcar-gen4-sysc.h"
25+
26+static struct rcar_gen4_sysc_area r8a779f0_areas[] __initdata = {
27+ { "always-on", R8A779F0_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
28+ { "a3e0", R8A779F0_PD_A3E0, R8A779F0_PD_ALWAYS_ON, PD_SCU },
29+ { "a3e1", R8A779F0_PD_A3E1, R8A779F0_PD_ALWAYS_ON, PD_SCU },
30+ { "a2e0d0", R8A779F0_PD_A2E0D0, R8A779F0_PD_A3E0, PD_SCU },
31+ { "a2e0d1", R8A779F0_PD_A2E0D1, R8A779F0_PD_A3E0, PD_SCU },
32+ { "a2e1d0", R8A779F0_PD_A2E1D0, R8A779F0_PD_A3E1, PD_SCU },
33+ { "a2e1d1", R8A779F0_PD_A2E1D1, R8A779F0_PD_A3E1, PD_SCU },
34+ { "a1e0d0c0", R8A779F0_PD_A1E0D0C0, R8A779F0_PD_A2E0D0, PD_CPU_NOCR },
35+ { "a1e0d0c1", R8A779F0_PD_A1E0D0C1, R8A779F0_PD_A2E0D0, PD_CPU_NOCR },
36+ { "a1e0d1c0", R8A779F0_PD_A1E0D1C0, R8A779F0_PD_A2E0D1, PD_CPU_NOCR },
37+ { "a1e0d1c1", R8A779F0_PD_A1E0D1C1, R8A779F0_PD_A2E0D1, PD_CPU_NOCR },
38+ { "a1e1d0c0", R8A779F0_PD_A1E1D0C0, R8A779F0_PD_A2E1D0, PD_CPU_NOCR },
39+ { "a1e1d0c1", R8A779F0_PD_A1E1D0C1, R8A779F0_PD_A2E1D0, PD_CPU_NOCR },
40+ { "a1e1d1c0", R8A779F0_PD_A1E1D1C0, R8A779F0_PD_A2E1D1, PD_CPU_NOCR },
41+ { "a1e1d1c1", R8A779F0_PD_A1E1D1C1, R8A779F0_PD_A2E1D1, PD_CPU_NOCR },
42+};
43+
44+const struct rcar_gen4_sysc_info r8a779f0_sysc_info __initconst = {
45+ .areas = r8a779f0_areas,
46+ .num_areas = ARRAY_SIZE(r8a779f0_areas),
47+};
drivers/soc/renesas/rcar-gen4-sysc.c+376−0
@@ -0,0 +1,376 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * R-Car Gen4 SYSC Power management support
4+ *
5+ * Copyright (C) 2021 Renesas Electronics Corp.
6+ */
7+
8+#include <linux/bits.h>
9+#include <linux/clk/renesas.h>
10+#include <linux/delay.h>
11+#include <linux/err.h>
12+#include <linux/io.h>
13+#include <linux/iopoll.h>
14+#include <linux/kernel.h>
15+#include <linux/mm.h>
16+#include <linux/of_address.h>
17+#include <linux/pm_domain.h>
18+#include <linux/slab.h>
19+#include <linux/spinlock.h>
20+#include <linux/types.h>
21+
22+#include "rcar-gen4-sysc.h"
23+
24+/* SYSC Common */
25+#define SYSCSR 0x000 /* SYSC Status Register */
26+#define SYSCPONSR(x) (0x800 + ((x) * 0x4)) /* Power-ON Status Register 0 */
27+#define SYSCPOFFSR(x) (0x808 + ((x) * 0x4)) /* Power-OFF Status Register */
28+#define SYSCISCR(x) (0x810 + ((x) * 0x4)) /* Interrupt Status/Clear Register */
29+#define SYSCIER(x) (0x820 + ((x) * 0x4)) /* Interrupt Enable Register */
30+#define SYSCIMR(x) (0x830 + ((x) * 0x4)) /* Interrupt Mask Register */
31+
32+/* Power Domain Registers */
33+#define PDRSR(n) (0x1000 + ((n) * 0x40))
34+#define PDRONCR(n) (0x1004 + ((n) * 0x40))
35+#define PDROFFCR(n) (0x1008 + ((n) * 0x40))
36+#define PDRESR(n) (0x100C + ((n) * 0x40))
37+
38+/* PWRON/PWROFF */
39+#define PWRON_PWROFF BIT(0) /* Power-ON/OFF request */
40+
41+/* PDRESR */
42+#define PDRESR_ERR BIT(0)
43+
44+/* PDRSR */
45+#define PDRSR_OFF BIT(0) /* Power-OFF state */
46+#define PDRSR_ON BIT(4) /* Power-ON state */
47+#define PDRSR_OFF_STATE BIT(8) /* Processing Power-OFF sequence */
48+#define PDRSR_ON_STATE BIT(12) /* Processing Power-ON sequence */
49+
50+#define SYSCSR_BUSY GENMASK(1, 0) /* All bit sets is not busy */
51+
52+#define SYSCSR_TIMEOUT 10000
53+#define SYSCSR_DELAY_US 10
54+
55+#define PDRESR_RETRIES 1000
56+#define PDRESR_DELAY_US 10
57+
58+#define SYSCISR_TIMEOUT 10000
59+#define SYSCISR_DELAY_US 10
60+
61+#define RCAR_GEN4_PD_ALWAYS_ON 64
62+#define NUM_DOMAINS_EACH_REG BITS_PER_TYPE(u32)
63+
64+static void __iomem *rcar_gen4_sysc_base;
65+static DEFINE_SPINLOCK(rcar_gen4_sysc_lock); /* SMP CPUs + I/O devices */
66+
67+static int rcar_gen4_sysc_pwr_on_off(u8 pdr, bool on)
68+{
69+ unsigned int reg_offs;
70+ u32 val;
71+ int ret;
72+
73+ if (on)
74+ reg_offs = PDRONCR(pdr);
75+ else
76+ reg_offs = PDROFFCR(pdr);
77+
78+ /* Wait until SYSC is ready to accept a power request */
79+ ret = readl_poll_timeout_atomic(rcar_gen4_sysc_base + SYSCSR, val,
80+ (val & SYSCSR_BUSY) == SYSCSR_BUSY,
81+ SYSCSR_DELAY_US, SYSCSR_TIMEOUT);
82+ if (ret < 0)
83+ return -EAGAIN;
84+
85+ /* Submit power shutoff or power resume request */
86+ iowrite32(PWRON_PWROFF, rcar_gen4_sysc_base + reg_offs);
87+
88+ return 0;
89+}
90+
91+static int clear_irq_flags(unsigned int reg_idx, unsigned int isr_mask)
92+{
93+ u32 val;
94+ int ret;
95+
96+ iowrite32(isr_mask, rcar_gen4_sysc_base + SYSCISCR(reg_idx));
97+
98+ ret = readl_poll_timeout_atomic(rcar_gen4_sysc_base + SYSCISCR(reg_idx),
99+ val, !(val & isr_mask),
100+ SYSCISR_DELAY_US, SYSCISR_TIMEOUT);
101+ if (ret < 0) {
102+ pr_err("\n %s : Can not clear IRQ flags in SYSCISCR", __func__);
103+ return -EIO;
104+ }
105+
106+ return 0;
107+}
108+
109+static int rcar_gen4_sysc_power(u8 pdr, bool on)
110+{
111+ unsigned int isr_mask;
112+ unsigned int reg_idx, bit_idx;
113+ unsigned int status;
114+ unsigned long flags;
115+ int ret = 0;
116+ u32 val;
117+ int k;
118+
119+ spin_lock_irqsave(&rcar_gen4_sysc_lock, flags);
120+
121+ reg_idx = pdr / NUM_DOMAINS_EACH_REG;
122+ bit_idx = pdr % NUM_DOMAINS_EACH_REG;
123+
124+ isr_mask = BIT(bit_idx);
125+
126+ /*
127+ * The interrupt source needs to be enabled, but masked, to prevent the
128+ * CPU from receiving it.
129+ */
130+ iowrite32(ioread32(rcar_gen4_sysc_base + SYSCIER(reg_idx)) | isr_mask,
131+ rcar_gen4_sysc_base + SYSCIER(reg_idx));
132+ iowrite32(ioread32(rcar_gen4_sysc_base + SYSCIMR(reg_idx)) | isr_mask,
133+ rcar_gen4_sysc_base + SYSCIMR(reg_idx));
134+
135+ ret = clear_irq_flags(reg_idx, isr_mask);
136+ if (ret)
137+ goto out;
138+
139+ /* Submit power shutoff or resume request until it was accepted */
140+ for (k = 0; k < PDRESR_RETRIES; k++) {
141+ ret = rcar_gen4_sysc_pwr_on_off(pdr, on);
142+ if (ret)
143+ goto out;
144+
145+ status = ioread32(rcar_gen4_sysc_base + PDRESR(pdr));
146+ if (!(status & PDRESR_ERR))
147+ break;
148+
149+ udelay(PDRESR_DELAY_US);
150+ }
151+
152+ if (k == PDRESR_RETRIES) {
153+ ret = -EIO;
154+ goto out;
155+ }
156+
157+ /* Wait until the power shutoff or resume request has completed * */
158+ ret = readl_poll_timeout_atomic(rcar_gen4_sysc_base + SYSCISCR(reg_idx),
159+ val, (val & isr_mask),
160+ SYSCISR_DELAY_US, SYSCISR_TIMEOUT);
161+ if (ret < 0) {
162+ ret = -EIO;
163+ goto out;
164+ }
165+
166+ /* Clear interrupt flags */
167+ ret = clear_irq_flags(reg_idx, isr_mask);
168+ if (ret)
169+ goto out;
170+
171+ out:
172+ spin_unlock_irqrestore(&rcar_gen4_sysc_lock, flags);
173+
174+ pr_debug("sysc power %s domain %d: %08x -> %d\n", on ? "on" : "off",
175+ pdr, ioread32(rcar_gen4_sysc_base + SYSCISCR(reg_idx)), ret);
176+ return ret;
177+}
178+
179+static bool rcar_gen4_sysc_power_is_off(u8 pdr)
180+{
181+ unsigned int st;
182+
183+ st = ioread32(rcar_gen4_sysc_base + PDRSR(pdr));
184+
185+ if (st & PDRSR_OFF)
186+ return true;
187+
188+ return false;
189+}
190+
191+struct rcar_gen4_sysc_pd {
192+ struct generic_pm_domain genpd;
193+ u8 pdr;
194+ unsigned int flags;
195+ char name[];
196+};
197+
198+static inline struct rcar_gen4_sysc_pd *to_rcar_gen4_pd(struct generic_pm_domain *d)
199+{
200+ return container_of(d, struct rcar_gen4_sysc_pd, genpd);
201+}
202+
203+static int rcar_gen4_sysc_pd_power_off(struct generic_pm_domain *genpd)
204+{
205+ struct rcar_gen4_sysc_pd *pd = to_rcar_gen4_pd(genpd);
206+
207+ pr_debug("%s: %s\n", __func__, genpd->name);
208+ return rcar_gen4_sysc_power(pd->pdr, false);
209+}
210+
211+static int rcar_gen4_sysc_pd_power_on(struct generic_pm_domain *genpd)
212+{
213+ struct rcar_gen4_sysc_pd *pd = to_rcar_gen4_pd(genpd);
214+
215+ pr_debug("%s: %s\n", __func__, genpd->name);
216+ return rcar_gen4_sysc_power(pd->pdr, true);
217+}
218+
219+static int __init rcar_gen4_sysc_pd_setup(struct rcar_gen4_sysc_pd *pd)
220+{
221+ struct generic_pm_domain *genpd = &pd->genpd;
222+ const char *name = pd->genpd.name;
223+ int error;
224+
225+ if (pd->flags & PD_CPU) {
226+ /*
227+ * This domain contains a CPU core and therefore it should
228+ * only be turned off if the CPU is not in use.
229+ */
230+ pr_debug("PM domain %s contains %s\n", name, "CPU");
231+ genpd->flags |= GENPD_FLAG_ALWAYS_ON;
232+ } else if (pd->flags & PD_SCU) {
233+ /*
234+ * This domain contains an SCU and cache-controller, and
235+ * therefore it should only be turned off if the CPU cores are
236+ * not in use.
237+ */
238+ pr_debug("PM domain %s contains %s\n", name, "SCU");
239+ genpd->flags |= GENPD_FLAG_ALWAYS_ON;
240+ } else if (pd->flags & PD_NO_CR) {
241+ /*
242+ * This domain cannot be turned off.
243+ */
244+ genpd->flags |= GENPD_FLAG_ALWAYS_ON;
245+ }
246+
247+ if (!(pd->flags & (PD_CPU | PD_SCU))) {
248+ /* Enable Clock Domain for I/O devices */
249+ genpd->flags |= GENPD_FLAG_PM_CLK | GENPD_FLAG_ACTIVE_WAKEUP;
250+ genpd->attach_dev = cpg_mssr_attach_dev;
251+ genpd->detach_dev = cpg_mssr_detach_dev;
252+ }
253+
254+ genpd->power_off = rcar_gen4_sysc_pd_power_off;
255+ genpd->power_on = rcar_gen4_sysc_pd_power_on;
256+
257+ if (pd->flags & (PD_CPU | PD_NO_CR)) {
258+ /* Skip CPUs (handled by SMP code) and areas without control */
259+ pr_debug("%s: Not touching %s\n", __func__, genpd->name);
260+ goto finalize;
261+ }
262+
263+ if (!rcar_gen4_sysc_power_is_off(pd->pdr)) {
264+ pr_debug("%s: %s is already powered\n", __func__, genpd->name);
265+ goto finalize;
266+ }
267+
268+ rcar_gen4_sysc_power(pd->pdr, true);
269+
270+finalize:
271+ error = pm_genpd_init(genpd, &simple_qos_governor, false);
272+ if (error)
273+ pr_err("Failed to init PM domain %s: %d\n", name, error);
274+
275+ return error;
276+}
277+
278+static const struct of_device_id rcar_gen4_sysc_matches[] __initconst = {
279+#ifdef CONFIG_SYSC_R8A779A0
280+ { .compatible = "renesas,r8a779a0-sysc", .data = &r8a779a0_sysc_info },
281+#endif
282+#ifdef CONFIG_SYSC_R8A779F0
283+ { .compatible = "renesas,r8a779f0-sysc", .data = &r8a779f0_sysc_info },
284+#endif
285+ { /* sentinel */ }
286+};
287+
288+struct rcar_gen4_pm_domains {
289+ struct genpd_onecell_data onecell_data;
290+ struct generic_pm_domain *domains[RCAR_GEN4_PD_ALWAYS_ON + 1];
291+};
292+
293+static struct genpd_onecell_data *rcar_gen4_sysc_onecell_data;
294+
295+static int __init rcar_gen4_sysc_pd_init(void)
296+{
297+ const struct rcar_gen4_sysc_info *info;
298+ const struct of_device_id *match;
299+ struct rcar_gen4_pm_domains *domains;
300+ struct device_node *np;
301+ void __iomem *base;
302+ unsigned int i;
303+ int error;
304+
305+ np = of_find_matching_node_and_match(NULL, rcar_gen4_sysc_matches, &match);
306+ if (!np)
307+ return -ENODEV;
308+
309+ info = match->data;
310+
311+ base = of_iomap(np, 0);
312+ if (!base) {
313+ pr_warn("%pOF: Cannot map regs\n", np);
314+ error = -ENOMEM;
315+ goto out_put;
316+ }
317+
318+ rcar_gen4_sysc_base = base;
319+
320+ domains = kzalloc(sizeof(*domains), GFP_KERNEL);
321+ if (!domains) {
322+ error = -ENOMEM;
323+ goto out_put;
324+ }
325+
326+ domains->onecell_data.domains = domains->domains;
327+ domains->onecell_data.num_domains = ARRAY_SIZE(domains->domains);
328+ rcar_gen4_sysc_onecell_data = &domains->onecell_data;
329+
330+ for (i = 0; i < info->num_areas; i++) {
331+ const struct rcar_gen4_sysc_area *area = &info->areas[i];
332+ struct rcar_gen4_sysc_pd *pd;
333+ size_t n;
334+
335+ if (!area->name) {
336+ /* Skip NULLified area */
337+ continue;
338+ }
339+
340+ n = strlen(area->name) + 1;
341+ pd = kzalloc(sizeof(*pd) + n, GFP_KERNEL);
342+ if (!pd) {
343+ error = -ENOMEM;
344+ goto out_put;
345+ }
346+
347+ memcpy(pd->name, area->name, n);
348+ pd->genpd.name = pd->name;
349+ pd->pdr = area->pdr;
350+ pd->flags = area->flags;
351+
352+ error = rcar_gen4_sysc_pd_setup(pd);
353+ if (error)
354+ goto out_put;
355+
356+ domains->domains[area->pdr] = &pd->genpd;
357+
358+ if (area->parent < 0)
359+ continue;
360+
361+ error = pm_genpd_add_subdomain(domains->domains[area->parent],
362+ &pd->genpd);
363+ if (error) {
364+ pr_warn("Failed to add PM subdomain %s to parent %u\n",
365+ area->name, area->parent);
366+ goto out_put;
367+ }
368+ }
369+
370+ error = of_genpd_add_provider_onecell(np, &domains->onecell_data);
371+
372+out_put:
373+ of_node_put(np);
374+ return error;
375+}
376+early_initcall(rcar_gen4_sysc_pd_init);
drivers/soc/renesas/rcar-gen4-sysc.h+43−0
@@ -0,0 +1,43 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+/*
3+ * R-Car Gen4 System Controller
4+ *
5+ * Copyright (C) 2021 Renesas Electronics Corp.
6+ */
7+#ifndef __SOC_RENESAS_RCAR_GEN4_SYSC_H__
8+#define __SOC_RENESAS_RCAR_GEN4_SYSC_H__
9+
10+#include <linux/types.h>
11+
12+/*
13+ * Power Domain flags
14+ */
15+#define PD_CPU BIT(0) /* Area contains main CPU core */
16+#define PD_SCU BIT(1) /* Area contains SCU and L2 cache */
17+#define PD_NO_CR BIT(2) /* Area lacks PWR{ON,OFF}CR registers */
18+
19+#define PD_CPU_NOCR (PD_CPU | PD_NO_CR) /* CPU area lacks CR */
20+#define PD_ALWAYS_ON PD_NO_CR /* Always-on area */
21+
22+/*
23+ * Description of a Power Area
24+ */
25+struct rcar_gen4_sysc_area {
26+ const char *name;
27+ u8 pdr; /* PDRn */
28+ int parent; /* -1 if none */
29+ unsigned int flags; /* See PD_* */
30+};
31+
32+/*
33+ * SoC-specific Power Area Description
34+ */
35+struct rcar_gen4_sysc_info {
36+ const struct rcar_gen4_sysc_area *areas;
37+ unsigned int num_areas;
38+};
39+
40+extern const struct rcar_gen4_sysc_info r8a779a0_sysc_info;
41+extern const struct rcar_gen4_sysc_info r8a779f0_sysc_info;
42+
43+#endif /* __SOC_RENESAS_RCAR_GEN4_SYSC_H__ */
drivers/soc/renesas/rcar-rst.c+44−6
@@ -13,15 +13,43 @@ · 12 unmodified lines
1313 #define WDTRSTCR_RESET 0xA55A0002
1414 #define WDTRSTCR 0x0054
1515
16+#define CR7BAR 0x0070
17+#define CR7BAREN BIT(4)
18+#define CR7BAR_MASK 0xFFFC0000
19+
20+static void __iomem *rcar_rst_base;
21+static u32 saved_mode __initdata;
22+static int (*rcar_rst_set_rproc_boot_addr_func)(u64 boot_addr);
23+
1624 static int rcar_rst_enable_wdt_reset(void __iomem *base)
1725 {
1826 iowrite32(WDTRSTCR_RESET, base + WDTRSTCR);
1927 return 0;
2028 }
2129
30+/*
31+ * Most of the R-Car Gen3 SoCs have an ARM Realtime Core.
32+ * Firmware boot address has to be set in CR7BAR before
33+ * starting the realtime core.
34+ * Boot address must be aligned on a 256k boundary.
35+ */
36+static int rcar_rst_set_gen3_rproc_boot_addr(u64 boot_addr)
37+{
38+ if (boot_addr & ~(u64)CR7BAR_MASK) {
39+ pr_err("Invalid boot address got %llx\n", boot_addr);
40+ return -EINVAL;
41+ }
42+
43+ iowrite32(boot_addr, rcar_rst_base + CR7BAR);
44+ iowrite32(boot_addr | CR7BAREN, rcar_rst_base + CR7BAR);
45+
46+ return 0;
47+}
48+
2249 struct rst_config {
2350 unsigned int modemr; /* Mode Monitoring Register Offset */
2451 int (*configure)(void __iomem *base); /* Platform specific config */
52+ int (*set_rproc_boot_addr)(u64 boot_addr);
2553 };
2654
2755 static const struct rst_config rcar_rst_gen1 __initconst = {
@@ -35,9 +63,10 @@ static const struct rst_config rcar_rst_gen2 __initconst = { · 7 unmodified lines
3563
3664 static const struct rst_config rcar_rst_gen3 __initconst = {
3765 .modemr = 0x60,
66+ .set_rproc_boot_addr = rcar_rst_set_gen3_rproc_boot_addr,
3867 };
3968
40−static const struct rst_config rcar_rst_r8a779a0 __initconst = {
69+static const struct rst_config rcar_rst_gen4 __initconst = {
4170 .modemr = 0x00, /* MODEMR0 and it has CPG related bits */
4271 };
4372
@@ -71,14 +100,12 @@ static const struct of_device_id rcar_rst_matches[] __initconst = { · 27 unmodified lines
71100 { .compatible = "renesas,r8a77980-rst", .data = &rcar_rst_gen3 },
72101 { .compatible = "renesas,r8a77990-rst", .data = &rcar_rst_gen3 },
73102 { .compatible = "renesas,r8a77995-rst", .data = &rcar_rst_gen3 },
74− /* R-Car V3U */
75− { .compatible = "renesas,r8a779a0-rst", .data = &rcar_rst_r8a779a0 },
103+ /* R-Car Gen4 */
104+ { .compatible = "renesas,r8a779a0-rst", .data = &rcar_rst_gen4 },
105+ { .compatible = "renesas,r8a779f0-rst", .data = &rcar_rst_gen4 },
76106 { /* sentinel */ }
77107 };
78108
79−static void __iomem *rcar_rst_base __initdata;
80−static u32 saved_mode __initdata;
81−
82109 static int __init rcar_rst_init(void)
83110 {
84111 const struct of_device_id *match;
@@ -100,6 +127,8 @@ static int __init rcar_rst_init(void) · 15 unmodified lines
100127
101128 rcar_rst_base = base;
102129 cfg = match->data;
130+ rcar_rst_set_rproc_boot_addr_func = cfg->set_rproc_boot_addr;
131+
103132 saved_mode = ioread32(base + cfg->modemr);
104133 if (cfg->configure) {
105134 error = cfg->configure(base);
@@ -130,3 +159,12 @@ int __init rcar_rst_read_mode_pins(u32 *mode) · 24 unmodified lines
130159 *mode = saved_mode;
131160 return 0;
132161 }
162+
163+int rcar_rst_set_rproc_boot_addr(u64 boot_addr)
164+{
165+ if (!rcar_rst_set_rproc_boot_addr_func)
166+ return -EIO;
167+
168+ return rcar_rst_set_rproc_boot_addr_func(boot_addr);
169+}
170+EXPORT_SYMBOL_GPL(rcar_rst_set_rproc_boot_addr);
drivers/soc/renesas/renesas-soc.c+68−59
@@ -33,6 +33,10 @@ static const struct renesas_family fam_rcar_gen3 __initconst __maybe_unused = { · 32 unmodified lines
3333 .reg = 0xfff00044, /* PRR (Product Register) */
3434 };
3535
36+static const struct renesas_family fam_rcar_gen4 __initconst __maybe_unused = {
37+ .name = "R-Car Gen4",
38+};
39+
3640 static const struct renesas_family fam_rmobile __initconst __maybe_unused = {
3741 .name = "R-Mobile",
3842 .reg = 0xe600101c, /* CCCR (Common Chip Code Register) */
@@ -214,6 +218,11 @@ static const struct renesas_soc soc_rcar_v3u __initconst __maybe_unused = { · 175 unmodified lines
214218 .id = 0x59,
215219 };
216220
221+static const struct renesas_soc soc_rcar_s4 __initconst __maybe_unused = {
222+ .family = &fam_rcar_gen4,
223+ .id = 0x5a,
224+};
225+
217226 static const struct renesas_soc soc_shmobile_ag5 __initconst __maybe_unused = {
218227 .family = &fam_shmobile,
219228 .id = 0x37,
@@ -319,6 +328,9 @@ static const struct of_device_id renesas_socs[] __initconst = { · 99 unmodified lines
319328 #ifdef CONFIG_ARCH_R8A779A0
320329 { .compatible = "renesas,r8a779a0", .data = &soc_rcar_v3u },
321330 #endif
331+#ifdef CONFIG_ARCH_R8A779F0
332+ { .compatible = "renesas,r8a779f0", .data = &soc_rcar_s4 },
333+#endif
322334 #if defined(CONFIG_ARCH_R9A07G044)
323335 { .compatible = "renesas,r9a07g044", .data = &soc_rz_g2l },
324336 #endif
@@ -328,94 +340,92 @@ static const struct of_device_id renesas_socs[] __initconst = { · 3 unmodified lines
328340 { /* sentinel */ }
329341 };
330342
343+struct renesas_id {
344+ unsigned int offset;
345+ u32 mask;
346+};
347+
348+static const struct renesas_id id_bsid __initconst = {
349+ .offset = 0,
350+ .mask = 0xff0000,
351+ /*
352+ * TODO: Upper 4 bits of BSID are for chip version, but the format is
353+ * not known at this time so we don't know how to specify eshi and eslo
354+ */
355+};
356+
357+static const struct renesas_id id_rzg2l __initconst = {
358+ .offset = 0xa04,
359+ .mask = 0xfffffff,
360+};
361+
362+static const struct renesas_id id_prr __initconst = {
363+ .offset = 0,
364+ .mask = 0xff00,
365+};
366+
367+static const struct of_device_id renesas_ids[] __initconst = {
368+ { .compatible = "renesas,bsid", .data = &id_bsid },
369+ { .compatible = "renesas,r9a07g044-sysc", .data = &id_rzg2l },
370+ { .compatible = "renesas,prr", .data = &id_prr },
371+ { /* sentinel */ }
372+};
373+
331374 static int __init renesas_soc_init(void)
332375 {
333376 struct soc_device_attribute *soc_dev_attr;
377+ unsigned int product, eshi = 0, eslo;
334378 const struct renesas_family *family;
335379 const struct of_device_id *match;
336380 const struct renesas_soc *soc;
381+ const struct renesas_id *id;
337382 void __iomem *chipid = NULL;
338383 struct soc_device *soc_dev;
339384 struct device_node *np;
340− unsigned int product, eshi = 0, eslo;
385+ const char *soc_id;
341386
342387 match = of_match_node(renesas_socs, of_root);
343388 if (!match)
344389 return -ENODEV;
345390
391+ soc_id = strchr(match->compatible, ',') + 1;
346392 soc = match->data;
347393 family = soc->family;
348394
349− np = of_find_compatible_node(NULL, NULL, "renesas,bsid");
395+ np = of_find_matching_node_and_match(NULL, renesas_ids, &match);
350396 if (np) {
397+ id = match->data;
351398 chipid = of_iomap(np, 0);
352399 of_node_put(np);
353−
354− if (chipid) {
355− product = readl(chipid);
356− iounmap(chipid);
357−
358− if (soc->id && ((product >> 16) & 0xff) != soc->id) {
359− pr_warn("SoC mismatch (product = 0x%x)\n",
360− product);
361− return -ENODEV;
362− }
363− }
364−
365− /*
366− * TODO: Upper 4 bits of BSID are for chip version, but the
367− * format is not known at this time so we don't know how to
368− * specify eshi and eslo
369− */
370−
371− goto done;
400+ } else if (soc->id && family->reg) {
401+ /* Try hardcoded CCCR/PRR fallback */
402+ id = &id_prr;
403+ chipid = ioremap(family->reg, 4);
372404 }
373405
374− np = of_find_compatible_node(NULL, NULL, "renesas,r9a07g044-sysc");
375− if (np) {
376− chipid = of_iomap(np, 0);
377− of_node_put(np);
406+ if (chipid) {
407+ product = readl(chipid + id->offset);
408+ iounmap(chipid);
378409
379− if (chipid) {
380− product = readl(chipid + 0x0a04);
381− iounmap(chipid);
410+ if (id == &id_prr) {
411+ /* R-Car M3-W ES1.1 incorrectly identifies as ES2.0 */
412+ if ((product & 0x7fff) == 0x5210)
413+ product ^= 0x11;
414+ /* R-Car M3-W ES1.3 incorrectly identifies as ES2.1 */
415+ if ((product & 0x7fff) == 0x5211)
416+ product ^= 0x12;
382417
383− if (soc->id && (product & 0xfffffff) != soc->id) {
384− pr_warn("SoC mismatch (product = 0x%x)\n",
385− product);
386− return -ENODEV;
387− }
418+ eshi = ((product >> 4) & 0x0f) + 1;
419+ eslo = product & 0xf;
388420 }
389421
390− goto done;
391− }
392−
393− /* Try PRR first, then hardcoded fallback */
394− np = of_find_compatible_node(NULL, NULL, "renesas,prr");
395− if (np) {
396− chipid = of_iomap(np, 0);
397− of_node_put(np);
398− } else if (soc->id && family->reg) {
399− chipid = ioremap(family->reg, 4);
400− }
401− if (chipid) {
402− product = readl(chipid);
403− iounmap(chipid);
404− /* R-Car M3-W ES1.1 incorrectly identifies as ES2.0 */
405− if ((product & 0x7fff) == 0x5210)
406− product ^= 0x11;
407− /* R-Car M3-W ES1.3 incorrectly identifies as ES2.1 */
408− if ((product & 0x7fff) == 0x5211)
409− product ^= 0x12;
410− if (soc->id && ((product >> 8) & 0xff) != soc->id) {
422+ if (soc->id &&
423+ ((product & id->mask) >> __ffs(id->mask)) != soc->id) {
411424 pr_warn("SoC mismatch (product = 0x%x)\n", product);
412425 return -ENODEV;
413426 }
414− eshi = ((product >> 4) & 0x0f) + 1;
415− eslo = product & 0xf;
416427 }
417428
418−done:
419429 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
420430 if (!soc_dev_attr)
421431 return -ENOMEM;
@@ -425,8 +435,7 @@ done: · 3 unmodified lines
425435 of_node_put(np);
426436
427437 soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
428− soc_dev_attr->soc_id = kstrdup_const(strchr(match->compatible, ',') + 1,
429− GFP_KERNEL);
438+ soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL);
430439 if (eshi)
431440 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", eshi,
432441 eslo);
drivers/soc/samsung/Kconfig+14−0
@@ -23,6 +23,20 @@ config EXYNOS_CHIPID · 22 unmodified lines
2323 Support for Samsung Exynos SoC ChipID and Adaptive Supply Voltage.
2424 This driver can also be built as module (exynos_chipid).
2525
26+config EXYNOS_USI
27+ tristate "Exynos USI (Universal Serial Interface) driver"
28+ default ARCH_EXYNOS && ARM64
29+ depends on ARCH_EXYNOS || COMPILE_TEST
30+ select MFD_SYSCON
31+ help
32+ Enable support for USI block. USI (Universal Serial Interface) is an
33+ IP-core found in modern Samsung Exynos SoCs, like Exynos850 and
34+ ExynosAutoV0. USI block can be configured to provide one of the
35+ following serial protocols: UART, SPI or High Speed I2C.
36+
37+ This driver allows one to configure USI for desired protocol, which
38+ is usually done in USI node in Device Tree.
39+
2640 config EXYNOS_PMU
2741 bool "Exynos PMU controller driver" if COMPILE_TEST
2842 depends on ARCH_EXYNOS || ((ARM || ARM64) && COMPILE_TEST)
drivers/soc/samsung/Makefile+2−0
@@ -4,6 +4,8 @@ obj-$(CONFIG_EXYNOS_ASV_ARM) += exynos5422-asv.o · 3 unmodified lines
44 obj-$(CONFIG_EXYNOS_CHIPID) += exynos_chipid.o
55 exynos_chipid-y += exynos-chipid.o exynos-asv.o
66
7+obj-$(CONFIG_EXYNOS_USI) += exynos-usi.o
8+
79 obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o
810
911 obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \
drivers/soc/samsung/exynos-chipid.c+3−0
@@ -42,6 +42,7 @@ static const struct exynos_soc_id { · 41 unmodified lines
4242 unsigned int id;
4343 } soc_ids[] = {
4444 /* List ordered by SoC name */
45+ /* Compatible with: samsung,exynos4210-chipid */
4546 { "EXYNOS3250", 0xE3472000 },
4647 { "EXYNOS4210", 0x43200000 }, /* EVT0 revision */
4748 { "EXYNOS4210", 0x43210000 },
@@ -55,6 +56,8 @@ static const struct exynos_soc_id { · 7 unmodified lines
5556 { "EXYNOS5440", 0xE5440000 },
5657 { "EXYNOS5800", 0xE5422000 },
5758 { "EXYNOS7420", 0xE7420000 },
59+ /* Compatible with: samsung,exynos850-chipid */
60+ { "EXYNOS7885", 0xE7885000 },
5861 { "EXYNOS850", 0xE3830000 },
5962 { "EXYNOSAUTOV9", 0xAAA80000 },
6063 };
drivers/soc/samsung/exynos-pmu.c+2−0
@@ -94,6 +94,8 @@ static const struct of_device_id exynos_pmu_of_device_ids[] = { · 93 unmodified lines
9494 .compatible = "samsung,exynos5433-pmu",
9595 }, {
9696 .compatible = "samsung,exynos7-pmu",
97+ }, {
98+ .compatible = "samsung,exynos850-pmu",
9799 },
98100 { /*sentinel*/ },
99101 };
drivers/soc/samsung/exynos-usi.c+285−0
@@ -0,0 +1,285 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright (c) 2021 Linaro Ltd.
4+ * Author: Sam Protsenko <semen.protsenko@linaro.org>
5+ *
6+ * Samsung Exynos USI driver (Universal Serial Interface).
7+ */
8+
9+#include <linux/clk.h>
10+#include <linux/mfd/syscon.h>
11+#include <linux/module.h>
12+#include <linux/of.h>
13+#include <linux/of_platform.h>
14+#include <linux/platform_device.h>
15+#include <linux/regmap.h>
16+
17+#include <dt-bindings/soc/samsung,exynos-usi.h>
18+
19+/* USIv2: System Register: SW_CONF register bits */
20+#define USI_V2_SW_CONF_NONE 0x0
21+#define USI_V2_SW_CONF_UART BIT(0)
22+#define USI_V2_SW_CONF_SPI BIT(1)
23+#define USI_V2_SW_CONF_I2C BIT(2)
24+#define USI_V2_SW_CONF_MASK (USI_V2_SW_CONF_UART | USI_V2_SW_CONF_SPI | \
25+ USI_V2_SW_CONF_I2C)
26+
27+/* USIv2: USI register offsets */
28+#define USI_CON 0x04
29+#define USI_OPTION 0x08
30+
31+/* USIv2: USI register bits */
32+#define USI_CON_RESET BIT(0)
33+#define USI_OPTION_CLKREQ_ON BIT(1)
34+#define USI_OPTION_CLKSTOP_ON BIT(2)
35+
36+enum exynos_usi_ver {
37+ USI_VER2 = 2,
38+};
39+
40+struct exynos_usi_variant {
41+ enum exynos_usi_ver ver; /* USI IP-core version */
42+ unsigned int sw_conf_mask; /* SW_CONF mask for all protocols */
43+ size_t min_mode; /* first index in exynos_usi_modes[] */
44+ size_t max_mode; /* last index in exynos_usi_modes[] */
45+ size_t num_clks; /* number of clocks to assert */
46+ const char * const *clk_names; /* clock names to assert */
47+};
48+
49+struct exynos_usi {
50+ struct device *dev;
51+ void __iomem *regs; /* USI register map */
52+ struct clk_bulk_data *clks; /* USI clocks */
53+
54+ size_t mode; /* current USI SW_CONF mode index */
55+ bool clkreq_on; /* always provide clock to IP */
56+
57+ /* System Register */
58+ struct regmap *sysreg; /* System Register map */
59+ unsigned int sw_conf; /* SW_CONF register offset in sysreg */
60+
61+ const struct exynos_usi_variant *data;
62+};
63+
64+struct exynos_usi_mode {
65+ const char *name; /* mode name */
66+ unsigned int val; /* mode register value */
67+};
68+
69+static const struct exynos_usi_mode exynos_usi_modes[] = {
70+ [USI_V2_NONE] = { .name = "none", .val = USI_V2_SW_CONF_NONE },
71+ [USI_V2_UART] = { .name = "uart", .val = USI_V2_SW_CONF_UART },
72+ [USI_V2_SPI] = { .name = "spi", .val = USI_V2_SW_CONF_SPI },
73+ [USI_V2_I2C] = { .name = "i2c", .val = USI_V2_SW_CONF_I2C },
74+};
75+
76+static const char * const exynos850_usi_clk_names[] = { "pclk", "ipclk" };
77+static const struct exynos_usi_variant exynos850_usi_data = {
78+ .ver = USI_VER2,
79+ .sw_conf_mask = USI_V2_SW_CONF_MASK,
80+ .min_mode = USI_V2_NONE,
81+ .max_mode = USI_V2_I2C,
82+ .num_clks = ARRAY_SIZE(exynos850_usi_clk_names),
83+ .clk_names = exynos850_usi_clk_names,
84+};
85+
86+static const struct of_device_id exynos_usi_dt_match[] = {
87+ {
88+ .compatible = "samsung,exynos850-usi",
89+ .data = &exynos850_usi_data,
90+ },
91+ { } /* sentinel */
92+};
93+MODULE_DEVICE_TABLE(of, exynos_usi_dt_match);
94+
95+/**
96+ * exynos_usi_set_sw_conf - Set USI block configuration mode
97+ * @usi: USI driver object
98+ * @mode: Mode index
99+ *
100+ * Select underlying serial protocol (UART/SPI/I2C) in USI IP-core.
101+ *
102+ * Return: 0 on success, or negative error code on failure.
103+ */
104+static int exynos_usi_set_sw_conf(struct exynos_usi *usi, size_t mode)
105+{
106+ unsigned int val;
107+ int ret;
108+
109+ if (mode < usi->data->min_mode || mode > usi->data->max_mode)
110+ return -EINVAL;
111+
112+ val = exynos_usi_modes[mode].val;
113+ ret = regmap_update_bits(usi->sysreg, usi->sw_conf,
114+ usi->data->sw_conf_mask, val);
115+ if (ret)
116+ return ret;
117+
118+ usi->mode = mode;
119+ dev_dbg(usi->dev, "protocol: %s\n", exynos_usi_modes[usi->mode].name);
120+
121+ return 0;
122+}
123+
124+/**
125+ * exynos_usi_enable - Initialize USI block
126+ * @usi: USI driver object
127+ *
128+ * USI IP-core start state is "reset" (on startup and after CPU resume). This
129+ * routine enables the USI block by clearing the reset flag. It also configures
130+ * HWACG behavior (needed e.g. for UART Rx). It should be performed before
131+ * underlying protocol becomes functional.
132+ *
133+ * Return: 0 on success, or negative error code on failure.
134+ */
135+static int exynos_usi_enable(const struct exynos_usi *usi)
136+{
137+ u32 val;
138+ int ret;
139+
140+ ret = clk_bulk_prepare_enable(usi->data->num_clks, usi->clks);
141+ if (ret)
142+ return ret;
143+
144+ /* Enable USI block */
145+ val = readl(usi->regs + USI_CON);
146+ val &= ~USI_CON_RESET;
147+ writel(val, usi->regs + USI_CON);
148+ udelay(1);
149+
150+ /* Continuously provide the clock to USI IP w/o gating */
151+ if (usi->clkreq_on) {
152+ val = readl(usi->regs + USI_OPTION);
153+ val &= ~USI_OPTION_CLKSTOP_ON;
154+ val |= USI_OPTION_CLKREQ_ON;
155+ writel(val, usi->regs + USI_OPTION);
156+ }
157+
158+ clk_bulk_disable_unprepare(usi->data->num_clks, usi->clks);
159+
160+ return ret;
161+}
162+
163+static int exynos_usi_configure(struct exynos_usi *usi)
164+{
165+ int ret;
166+
167+ ret = exynos_usi_set_sw_conf(usi, usi->mode);
168+ if (ret)
169+ return ret;
170+
171+ if (usi->data->ver == USI_VER2)
172+ return exynos_usi_enable(usi);
173+
174+ return 0;
175+}
176+
177+static int exynos_usi_parse_dt(struct device_node *np, struct exynos_usi *usi)
178+{
179+ int ret;
180+ u32 mode;
181+
182+ ret = of_property_read_u32(np, "samsung,mode", &mode);
183+ if (ret)
184+ return ret;
185+ if (mode < usi->data->min_mode || mode > usi->data->max_mode)
186+ return -EINVAL;
187+ usi->mode = mode;
188+
189+ usi->sysreg = syscon_regmap_lookup_by_phandle(np, "samsung,sysreg");
190+ if (IS_ERR(usi->sysreg))
191+ return PTR_ERR(usi->sysreg);
192+
193+ ret = of_property_read_u32_index(np, "samsung,sysreg", 1,
194+ &usi->sw_conf);
195+ if (ret)
196+ return ret;
197+
198+ usi->clkreq_on = of_property_read_bool(np, "samsung,clkreq-on");
199+
200+ return 0;
201+}
202+
203+static int exynos_usi_get_clocks(struct exynos_usi *usi)
204+{
205+ const size_t num = usi->data->num_clks;
206+ struct device *dev = usi->dev;
207+ size_t i;
208+
209+ if (num == 0)
210+ return 0;
211+
212+ usi->clks = devm_kcalloc(dev, num, sizeof(*usi->clks), GFP_KERNEL);
213+ if (!usi->clks)
214+ return -ENOMEM;
215+
216+ for (i = 0; i < num; ++i)
217+ usi->clks[i].id = usi->data->clk_names[i];
218+
219+ return devm_clk_bulk_get(dev, num, usi->clks);
220+}
221+
222+static int exynos_usi_probe(struct platform_device *pdev)
223+{
224+ struct device *dev = &pdev->dev;
225+ struct device_node *np = dev->of_node;
226+ struct exynos_usi *usi;
227+ int ret;
228+
229+ usi = devm_kzalloc(dev, sizeof(*usi), GFP_KERNEL);
230+ if (!usi)
231+ return -ENOMEM;
232+
233+ usi->dev = dev;
234+ platform_set_drvdata(pdev, usi);
235+
236+ usi->data = of_device_get_match_data(dev);
237+ if (!usi->data)
238+ return -EINVAL;
239+
240+ ret = exynos_usi_parse_dt(np, usi);
241+ if (ret)
242+ return ret;
243+
244+ ret = exynos_usi_get_clocks(usi);
245+ if (ret)
246+ return ret;
247+
248+ if (usi->data->ver == USI_VER2) {
249+ usi->regs = devm_platform_ioremap_resource(pdev, 0);
250+ if (IS_ERR(usi->regs))
251+ return PTR_ERR(usi->regs);
252+ }
253+
254+ ret = exynos_usi_configure(usi);
255+ if (ret)
256+ return ret;
257+
258+ /* Make it possible to embed protocol nodes into USI np */
259+ return of_platform_populate(np, NULL, NULL, dev);
260+}
261+
262+static int __maybe_unused exynos_usi_resume_noirq(struct device *dev)
263+{
264+ struct exynos_usi *usi = dev_get_drvdata(dev);
265+
266+ return exynos_usi_configure(usi);
267+}
268+
269+static const struct dev_pm_ops exynos_usi_pm = {
270+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(NULL, exynos_usi_resume_noirq)
271+};
272+
273+static struct platform_driver exynos_usi_driver = {
274+ .driver = {
275+ .name = "exynos-usi",
276+ .pm = &exynos_usi_pm,
277+ .of_match_table = exynos_usi_dt_match,
278+ },
279+ .probe = exynos_usi_probe,
280+};
281+module_platform_driver(exynos_usi_driver);
282+
283+MODULE_DESCRIPTION("Samsung USI driver");
284+MODULE_AUTHOR("Sam Protsenko <semen.protsenko@linaro.org>");
285+MODULE_LICENSE("GPL");
drivers/soc/tegra/common.c+26−3
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 #include <linux/export.h>
1111 #include <linux/of.h>
1212 #include <linux/pm_opp.h>
13+#include <linux/pm_runtime.h>
1314
1415 #include <soc/tegra/common.h>
1516 #include <soc/tegra/fuse.h>
@@ -43,6 +44,7 @@ static int tegra_core_dev_init_opp_state(struct device *dev) · 27 unmodified lines
4344 {
4445 unsigned long rate;
4546 struct clk *clk;
47+ bool rpm_enabled;
4648 int err;
4749
4850 clk = devm_clk_get(dev, NULL);
@@ -57,8 +59,31 @@ static int tegra_core_dev_init_opp_state(struct device *dev) · 8 unmodified lines
5759 return -EINVAL;
5860 }
5961
62+ /*
63+ * Runtime PM of the device must be enabled in order to set up
64+ * GENPD's performance properly because GENPD core checks whether
65+ * device is suspended and this check doesn't work while RPM is
66+ * disabled. This makes sure the OPP vote below gets cached in
67+ * GENPD for the device. Instead, the vote is done the next time
68+ * the device gets runtime resumed.
69+ */
70+ rpm_enabled = pm_runtime_enabled(dev);
71+ if (!rpm_enabled)
72+ pm_runtime_enable(dev);
73+
74+ /* should never happen in practice */
75+ if (!pm_runtime_enabled(dev)) {
76+ dev_WARN(dev, "failed to enable runtime PM\n");
77+ pm_runtime_disable(dev);
78+ return -EINVAL;
79+ }
80+
6081 /* first dummy rate-setting initializes voltage vote */
6182 err = dev_pm_opp_set_rate(dev, rate);
83+
84+ if (!rpm_enabled)
85+ pm_runtime_disable(dev);
86+
6287 if (err) {
6388 dev_err(dev, "failed to initialize OPP clock: %d\n", err);
6489 return err;
@@ -111,9 +136,7 @@ int devm_tegra_core_dev_init_opp_table(struct device *dev, · 46 unmodified lines
111136 */
112137 err = devm_pm_opp_of_add_table(dev);
113138 if (err) {
114− if (err == -ENODEV)
115− dev_err_once(dev, "OPP table not found, please update device-tree\n");
116− else
139+ if (err != -ENODEV)
117140 dev_err(dev, "failed to add OPP table: %d\n", err);
118141
119142 return err;
drivers/soc/tegra/fuse/fuse-tegra.c+40−11
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/of_address.h>
1515 #include <linux/platform_device.h>
1616 #include <linux/pm_runtime.h>
17+#include <linux/reset.h>
1718 #include <linux/slab.h>
1819 #include <linux/sys_soc.h>
1920
@@ -181,6 +182,12 @@ static const struct nvmem_cell_info tegra_fuse_cells[] = { · 161 unmodified lines
181182 },
182183 };
183184
185+static void tegra_fuse_restore(void *base)
186+{
187+ fuse->clk = NULL;
188+ fuse->base = base;
189+}
190+
184191 static int tegra_fuse_probe(struct platform_device *pdev)
185192 {
186193 void __iomem *base = fuse->base;
@@ -188,13 +195,16 @@ static int tegra_fuse_probe(struct platform_device *pdev) · 1 unmodified line
188195 struct resource *res;
189196 int err;
190197
198+ err = devm_add_action(&pdev->dev, tegra_fuse_restore, base);
199+ if (err)
200+ return err;
201+
191202 /* take over the memory region from the early initialization */
192203 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
193204 fuse->phys = res->start;
194205 fuse->base = devm_ioremap_resource(&pdev->dev, res);
195206 if (IS_ERR(fuse->base)) {
196207 err = PTR_ERR(fuse->base);
197− fuse->base = base;
198208 return err;
199209 }
200210
@@ -204,19 +214,20 @@ static int tegra_fuse_probe(struct platform_device *pdev) · 3 unmodified lines
204214 dev_err(&pdev->dev, "failed to get FUSE clock: %ld",
205215 PTR_ERR(fuse->clk));
206216
207− fuse->base = base;
208217 return PTR_ERR(fuse->clk);
209218 }
210219
211220 platform_set_drvdata(pdev, fuse);
212221 fuse->dev = &pdev->dev;
213222
214− pm_runtime_enable(&pdev->dev);
223+ err = devm_pm_runtime_enable(&pdev->dev);
224+ if (err)
225+ return err;
215226
216227 if (fuse->soc->probe) {
217228 err = fuse->soc->probe(fuse);
218229 if (err < 0)
219− goto restore;
230+ return err;
220231 }
221232
222233 memset(&nvmem, 0, sizeof(nvmem));
@@ -240,19 +251,37 @@ static int tegra_fuse_probe(struct platform_device *pdev) · 17 unmodified lines
240251 err = PTR_ERR(fuse->nvmem);
241252 dev_err(&pdev->dev, "failed to register NVMEM device: %d\n",
242253 err);
243− goto restore;
254+ return err;
255+ }
256+
257+ fuse->rst = devm_reset_control_get_optional(&pdev->dev, "fuse");
258+ if (IS_ERR(fuse->rst)) {
259+ err = PTR_ERR(fuse->rst);
260+ dev_err(&pdev->dev, "failed to get FUSE reset: %pe\n",
261+ fuse->rst);
262+ return err;
263+ }
264+
265+ /*
266+ * FUSE clock is enabled at a boot time, hence this resume/suspend
267+ * disables the clock besides the h/w resetting.
268+ */
269+ err = pm_runtime_resume_and_get(&pdev->dev);
270+ if (err)
271+ return err;
272+
273+ err = reset_control_reset(fuse->rst);
274+ pm_runtime_put(&pdev->dev);
275+
276+ if (err < 0) {
277+ dev_err(&pdev->dev, "failed to reset FUSE: %d\n", err);
278+ return err;
244279 }
245280
246281 /* release the early I/O memory mapping */
247282 iounmap(base);
248283
249284 return 0;
250−
251−restore:
252− fuse->clk = NULL;
253− fuse->base = base;
254− pm_runtime_disable(&pdev->dev);
255− return err;
256285 }
257286
258287 static int __maybe_unused tegra_fuse_runtime_resume(struct device *dev)
drivers/soc/tegra/fuse/fuse-tegra20.c+30−3
@@ -94,9 +94,28 @@ static bool dma_filter(struct dma_chan *chan, void *filter_param) · 93 unmodified lines
9494 return of_device_is_compatible(np, "nvidia,tegra20-apbdma");
9595 }
9696
97+static void tegra20_fuse_release_channel(void *data)
98+{
99+ struct tegra_fuse *fuse = data;
100+
101+ dma_release_channel(fuse->apbdma.chan);
102+ fuse->apbdma.chan = NULL;
103+}
104+
105+static void tegra20_fuse_free_coherent(void *data)
106+{
107+ struct tegra_fuse *fuse = data;
108+
109+ dma_free_coherent(fuse->dev, sizeof(u32), fuse->apbdma.virt,
110+ fuse->apbdma.phys);
111+ fuse->apbdma.virt = NULL;
112+ fuse->apbdma.phys = 0x0;
113+}
114+
97115 static int tegra20_fuse_probe(struct tegra_fuse *fuse)
98116 {
99117 dma_cap_mask_t mask;
118+ int err;
100119
101120 dma_cap_zero(mask);
102121 dma_cap_set(DMA_SLAVE, mask);
@@ -105,13 +124,21 @@ static int tegra20_fuse_probe(struct tegra_fuse *fuse) · 2 unmodified lines
105124 if (!fuse->apbdma.chan)
106125 return -EPROBE_DEFER;
107126
127+ err = devm_add_action_or_reset(fuse->dev, tegra20_fuse_release_channel,
128+ fuse);
129+ if (err)
130+ return err;
131+
108132 fuse->apbdma.virt = dma_alloc_coherent(fuse->dev, sizeof(u32),
109133 &fuse->apbdma.phys,
110134 GFP_KERNEL);
111− if (!fuse->apbdma.virt) {
112− dma_release_channel(fuse->apbdma.chan);
135+ if (!fuse->apbdma.virt)
113136 return -ENOMEM;
114− }
137+
138+ err = devm_add_action_or_reset(fuse->dev, tegra20_fuse_free_coherent,
139+ fuse);
140+ if (err)
141+ return err;
115142
116143 fuse->apbdma.config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
117144 fuse->apbdma.config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
drivers/soc/tegra/fuse/fuse.h+1−0
@@ -43,6 +43,7 @@ struct tegra_fuse { · 42 unmodified lines
4343 void __iomem *base;
4444 phys_addr_t phys;
4545 struct clk *clk;
46+ struct reset_control *rst;
4647
4748 u32 (*read_early)(struct tegra_fuse *fuse, unsigned int offset);
4849 u32 (*read)(struct tegra_fuse *fuse, unsigned int offset);
drivers/soc/tegra/pmc.c+33−8
@@ -1064,10 +1064,8 @@ int tegra_pmc_cpu_remove_clamping(unsigned int cpuid) · 1063 unmodified lines
10641064 return tegra_powergate_remove_clamping(id);
10651065 }
10661066
1067−static int tegra_pmc_restart_notify(struct notifier_block *this,
1068− unsigned long action, void *data)
1067+static void tegra_pmc_program_reboot_reason(const char *cmd)
10691068 {
1070− const char *cmd = data;
10711069 u32 value;
10721070
10731071 value = tegra_pmc_scratch_readl(pmc, pmc->soc->regs->scratch0);
@@ -1085,6 +1083,25 @@ static int tegra_pmc_restart_notify(struct notifier_block *this, · 11 unmodified lines
10851083 }
10861084
10871085 tegra_pmc_scratch_writel(pmc, value, pmc->soc->regs->scratch0);
1086+}
1087+
1088+static int tegra_pmc_reboot_notify(struct notifier_block *this,
1089+ unsigned long action, void *data)
1090+{
1091+ if (action == SYS_RESTART)
1092+ tegra_pmc_program_reboot_reason(data);
1093+
1094+ return NOTIFY_DONE;
1095+}
1096+
1097+static struct notifier_block tegra_pmc_reboot_notifier = {
1098+ .notifier_call = tegra_pmc_reboot_notify,
1099+};
1100+
1101+static int tegra_pmc_restart_notify(struct notifier_block *this,
1102+ unsigned long action, void *data)
1103+{
1104+ u32 value;
10881105
10891106 /* reset everything but PMC_SCRATCH0 and PMC_RST_STATUS */
10901107 value = tegra_pmc_readl(pmc, PMC_CNTRL);
@@ -1353,7 +1370,7 @@ static int tegra_pmc_core_pd_add(struct tegra_pmc *pmc, struct device_node *np) · 262 unmodified lines
13531370 if (!genpd)
13541371 return -ENOMEM;
13551372
1356− genpd->name = np->name;
1373+ genpd->name = "core";
13571374 genpd->set_performance_state = tegra_pmc_core_pd_set_performance_state;
13581375 genpd->opp_to_performance_state = tegra_pmc_core_pd_opp_to_performance_state;
13591376
@@ -2890,6 +2907,14 @@ static int tegra_pmc_probe(struct platform_device *pdev) · 1530 unmodified lines
28902907 goto cleanup_sysfs;
28912908 }
28922909
2910+ err = devm_register_reboot_notifier(&pdev->dev,
2911+ &tegra_pmc_reboot_notifier);
2912+ if (err) {
2913+ dev_err(&pdev->dev, "unable to register reboot notifier, %d\n",
2914+ err);
2915+ goto cleanup_debugfs;
2916+ }
2917+
28932918 err = register_restart_handler(&tegra_pmc_restart_handler);
28942919 if (err) {
28952920 dev_err(&pdev->dev, "unable to register restart handler, %d\n",
@@ -2963,7 +2988,7 @@ static SIMPLE_DEV_PM_OPS(tegra_pmc_pm_ops, tegra_pmc_suspend, tegra_pmc_resume); · 67 unmodified lines
29632988
29642989 static const char * const tegra20_powergates[] = {
29652990 [TEGRA_POWERGATE_CPU] = "cpu",
2966− [TEGRA_POWERGATE_3D] = "3d",
2991+ [TEGRA_POWERGATE_3D] = "td",
29672992 [TEGRA_POWERGATE_VENC] = "venc",
29682993 [TEGRA_POWERGATE_VDEC] = "vdec",
29692994 [TEGRA_POWERGATE_PCIE] = "pcie",
@@ -3071,7 +3096,7 @@ static const struct tegra_pmc_soc tegra20_pmc_soc = { · 101 unmodified lines
30713096
30723097 static const char * const tegra30_powergates[] = {
30733098 [TEGRA_POWERGATE_CPU] = "cpu0",
3074− [TEGRA_POWERGATE_3D] = "3d0",
3099+ [TEGRA_POWERGATE_3D] = "td",
30753100 [TEGRA_POWERGATE_VENC] = "venc",
30763101 [TEGRA_POWERGATE_VDEC] = "vdec",
30773102 [TEGRA_POWERGATE_PCIE] = "pcie",
@@ -3083,7 +3108,7 @@ static const char * const tegra30_powergates[] = { · 5 unmodified lines
30833108 [TEGRA_POWERGATE_CPU2] = "cpu2",
30843109 [TEGRA_POWERGATE_CPU3] = "cpu3",
30853110 [TEGRA_POWERGATE_CELP] = "celp",
3086− [TEGRA_POWERGATE_3D1] = "3d1",
3111+ [TEGRA_POWERGATE_3D1] = "td2",
30873112 };
30883113
30893114 static const u8 tegra30_cpu_powergates[] = {
@@ -3132,7 +3157,7 @@ static const struct tegra_pmc_soc tegra30_pmc_soc = { · 42 unmodified lines
31323157
31333158 static const char * const tegra114_powergates[] = {
31343159 [TEGRA_POWERGATE_CPU] = "crail",
3135− [TEGRA_POWERGATE_3D] = "3d",
3160+ [TEGRA_POWERGATE_3D] = "td",
31363161 [TEGRA_POWERGATE_VENC] = "venc",
31373162 [TEGRA_POWERGATE_VDEC] = "vdec",
31383163 [TEGRA_POWERGATE_MPE] = "mpe",
drivers/soc/tegra/regulators-tegra20.c+99−0
@@ -16,7 +16,9 @@ · 15 unmodified lines
1616 #include <linux/regulator/coupler.h>
1717 #include <linux/regulator/driver.h>
1818 #include <linux/regulator/machine.h>
19+#include <linux/suspend.h>
1920
21+#include <soc/tegra/fuse.h>
2022 #include <soc/tegra/pmc.h>
2123
2224 struct tegra_regulator_coupler {
@@ -25,9 +27,12 @@ struct tegra_regulator_coupler { · 2 unmodified lines
2527 struct regulator_dev *cpu_rdev;
2628 struct regulator_dev *rtc_rdev;
2729 struct notifier_block reboot_notifier;
30+ struct notifier_block suspend_notifier;
2831 int core_min_uV, cpu_min_uV;
2932 bool sys_reboot_mode_req;
3033 bool sys_reboot_mode;
34+ bool sys_suspend_mode_req;
35+ bool sys_suspend_mode;
3136 };
3237
3338 static inline struct tegra_regulator_coupler *
@@ -105,6 +110,28 @@ static int tegra20_core_rtc_max_spread(struct regulator_dev *core_rdev, · 71 unmodified lines
105110 return 150000;
106111 }
107112
113+static int tegra20_cpu_nominal_uV(void)
114+{
115+ switch (tegra_sku_info.soc_speedo_id) {
116+ case 0:
117+ return 1100000;
118+ case 1:
119+ return 1025000;
120+ default:
121+ return 1125000;
122+ }
123+}
124+
125+static int tegra20_core_nominal_uV(void)
126+{
127+ switch (tegra_sku_info.soc_speedo_id) {
128+ default:
129+ return 1225000;
130+ case 2:
131+ return 1300000;
132+ }
133+}
134+
108135 static int tegra20_core_rtc_update(struct tegra_regulator_coupler *tegra,
109136 struct regulator_dev *core_rdev,
110137 struct regulator_dev *rtc_rdev,
@@ -144,6 +171,11 @@ static int tegra20_core_rtc_update(struct tegra_regulator_coupler *tegra, · 33 unmodified lines
144171 if (err)
145172 return err;
146173
174+ /* prepare voltage level for suspend */
175+ if (tegra->sys_suspend_mode)
176+ core_min_uV = clamp(tegra20_core_nominal_uV(),
177+ core_min_uV, core_max_uV);
178+
147179 core_uV = regulator_get_voltage_rdev(core_rdev);
148180 if (core_uV < 0)
149181 return core_uV;
@@ -279,6 +311,11 @@ static int tegra20_cpu_voltage_update(struct tegra_regulator_coupler *tegra, · 129 unmodified lines
279311 if (tegra->sys_reboot_mode)
280312 cpu_min_uV = max(cpu_min_uV, tegra->cpu_min_uV);
281313
314+ /* prepare voltage level for suspend */
315+ if (tegra->sys_suspend_mode)
316+ cpu_min_uV = clamp(tegra20_cpu_nominal_uV(),
317+ cpu_min_uV, cpu_max_uV);
318+
282319 if (cpu_min_uV > cpu_uV) {
283320 err = tegra20_core_rtc_update(tegra, core_rdev, rtc_rdev,
284321 cpu_uV, cpu_min_uV);
@@ -320,6 +357,7 @@ static int tegra20_regulator_balance_voltage(struct regulator_coupler *coupler, · 35 unmodified lines
320357 }
321358
322359 tegra->sys_reboot_mode = READ_ONCE(tegra->sys_reboot_mode_req);
360+ tegra->sys_suspend_mode = READ_ONCE(tegra->sys_suspend_mode_req);
323361
324362 if (rdev == cpu_rdev)
325363 return tegra20_cpu_voltage_update(tegra, cpu_rdev,
@@ -334,6 +372,63 @@ static int tegra20_regulator_balance_voltage(struct regulator_coupler *coupler, · 8 unmodified lines
334372 return -EPERM;
335373 }
336374
375+static int tegra20_regulator_prepare_suspend(struct tegra_regulator_coupler *tegra,
376+ bool sys_suspend_mode)
377+{
378+ int err;
379+
380+ if (!tegra->core_rdev || !tegra->rtc_rdev || !tegra->cpu_rdev)
381+ return 0;
382+
383+ /*
384+ * All power domains are enabled early during resume from suspend
385+ * by GENPD core. Domains like VENC may require a higher voltage
386+ * when enabled during resume from suspend. This also prepares
387+ * hardware for resuming from LP0.
388+ */
389+
390+ WRITE_ONCE(tegra->sys_suspend_mode_req, sys_suspend_mode);
391+
392+ err = regulator_sync_voltage_rdev(tegra->cpu_rdev);
393+ if (err)
394+ return err;
395+
396+ err = regulator_sync_voltage_rdev(tegra->core_rdev);
397+ if (err)
398+ return err;
399+
400+ return 0;
401+}
402+
403+static int tegra20_regulator_suspend(struct notifier_block *notifier,
404+ unsigned long mode, void *arg)
405+{
406+ struct tegra_regulator_coupler *tegra;
407+ int ret = 0;
408+
409+ tegra = container_of(notifier, struct tegra_regulator_coupler,
410+ suspend_notifier);
411+
412+ switch (mode) {
413+ case PM_HIBERNATION_PREPARE:
414+ case PM_RESTORE_PREPARE:
415+ case PM_SUSPEND_PREPARE:
416+ ret = tegra20_regulator_prepare_suspend(tegra, true);
417+ break;
418+
419+ case PM_POST_HIBERNATION:
420+ case PM_POST_RESTORE:
421+ case PM_POST_SUSPEND:
422+ ret = tegra20_regulator_prepare_suspend(tegra, false);
423+ break;
424+ }
425+
426+ if (ret)
427+ pr_err("failed to prepare regulators: %d\n", ret);
428+
429+ return notifier_from_errno(ret);
430+}
431+
337432 static int tegra20_regulator_prepare_reboot(struct tegra_regulator_coupler *tegra,
338433 bool sys_reboot_mode)
339434 {
@@ -444,6 +539,7 @@ static struct tegra_regulator_coupler tegra20_coupler = { · 104 unmodified lines
444539 .balance_voltage = tegra20_regulator_balance_voltage,
445540 },
446541 .reboot_notifier.notifier_call = tegra20_regulator_reboot,
542+ .suspend_notifier.notifier_call = tegra20_regulator_suspend,
447543 };
448544
449545 static int __init tegra_regulator_coupler_init(void)
@@ -456,6 +552,9 @@ static int __init tegra_regulator_coupler_init(void) · 6 unmodified lines
456552 err = register_reboot_notifier(&tegra20_coupler.reboot_notifier);
457553 WARN_ON(err);
458554
555+ err = register_pm_notifier(&tegra20_coupler.suspend_notifier);
556+ WARN_ON(err);
557+
459558 return regulator_coupler_register(&tegra20_coupler.coupler);
460559 }
461560 arch_initcall(tegra_regulator_coupler_init);
drivers/soc/tegra/regulators-tegra30.c+122−0
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <linux/regulator/coupler.h>
1717 #include <linux/regulator/driver.h>
1818 #include <linux/regulator/machine.h>
19+#include <linux/suspend.h>
1920
2021 #include <soc/tegra/fuse.h>
2122 #include <soc/tegra/pmc.h>
@@ -25,9 +26,12 @@ struct tegra_regulator_coupler { · 3 unmodified lines
2526 struct regulator_dev *core_rdev;
2627 struct regulator_dev *cpu_rdev;
2728 struct notifier_block reboot_notifier;
29+ struct notifier_block suspend_notifier;
2830 int core_min_uV, cpu_min_uV;
2931 bool sys_reboot_mode_req;
3032 bool sys_reboot_mode;
33+ bool sys_suspend_mode_req;
34+ bool sys_suspend_mode;
3135 };
3236
3337 static inline struct tegra_regulator_coupler *
@@ -113,6 +117,52 @@ static int tegra30_core_cpu_limit(int cpu_uV) · 79 unmodified lines
113117 return -EINVAL;
114118 }
115119
120+static int tegra30_cpu_nominal_uV(void)
121+{
122+ switch (tegra_sku_info.cpu_speedo_id) {
123+ case 10 ... 11:
124+ return 850000;
125+
126+ case 9:
127+ return 912000;
128+
129+ case 1 ... 3:
130+ case 7 ... 8:
131+ return 1050000;
132+
133+ default:
134+ return 1125000;
135+
136+ case 4 ... 6:
137+ case 12 ... 13:
138+ return 1237000;
139+ }
140+}
141+
142+static int tegra30_core_nominal_uV(void)
143+{
144+ switch (tegra_sku_info.soc_speedo_id) {
145+ case 0:
146+ return 1200000;
147+
148+ case 1:
149+ if (tegra_sku_info.cpu_speedo_id != 7 &&
150+ tegra_sku_info.cpu_speedo_id != 8)
151+ return 1200000;
152+
153+ fallthrough;
154+
155+ case 2:
156+ if (tegra_sku_info.cpu_speedo_id != 13)
157+ return 1300000;
158+
159+ return 1350000;
160+
161+ default:
162+ return 1250000;
163+ }
164+}
165+
116166 static int tegra30_voltage_update(struct tegra_regulator_coupler *tegra,
117167 struct regulator_dev *cpu_rdev,
118168 struct regulator_dev *core_rdev)
@@ -168,6 +218,11 @@ static int tegra30_voltage_update(struct tegra_regulator_coupler *tegra, · 49 unmodified lines
168218 if (err)
169219 return err;
170220
221+ /* prepare voltage level for suspend */
222+ if (tegra->sys_suspend_mode)
223+ core_min_uV = clamp(tegra30_core_nominal_uV(),
224+ core_min_uV, core_max_uV);
225+
171226 core_uV = regulator_get_voltage_rdev(core_rdev);
172227 if (core_uV < 0)
173228 return core_uV;
@@ -223,6 +278,11 @@ static int tegra30_voltage_update(struct tegra_regulator_coupler *tegra, · 49 unmodified lines
223278 if (tegra->sys_reboot_mode)
224279 cpu_min_uV = max(cpu_min_uV, tegra->cpu_min_uV);
225280
281+ /* prepare voltage level for suspend */
282+ if (tegra->sys_suspend_mode)
283+ cpu_min_uV = clamp(tegra30_cpu_nominal_uV(),
284+ cpu_min_uV, cpu_max_uV);
285+
226286 if (core_min_limited_uV > core_uV) {
227287 pr_err("core voltage constraint violated: %d %d %d\n",
228288 core_uV, core_min_limited_uV, cpu_uV);
@@ -292,10 +352,68 @@ static int tegra30_regulator_balance_voltage(struct regulator_coupler *coupler, · 63 unmodified lines
292352 }
293353
294354 tegra->sys_reboot_mode = READ_ONCE(tegra->sys_reboot_mode_req);
355+ tegra->sys_suspend_mode = READ_ONCE(tegra->sys_suspend_mode_req);
295356
296357 return tegra30_voltage_update(tegra, cpu_rdev, core_rdev);
297358 }
298359
360+static int tegra30_regulator_prepare_suspend(struct tegra_regulator_coupler *tegra,
361+ bool sys_suspend_mode)
362+{
363+ int err;
364+
365+ if (!tegra->core_rdev || !tegra->cpu_rdev)
366+ return 0;
367+
368+ /*
369+ * All power domains are enabled early during resume from suspend
370+ * by GENPD core. Domains like VENC may require a higher voltage
371+ * when enabled during resume from suspend. This also prepares
372+ * hardware for resuming from LP0.
373+ */
374+
375+ WRITE_ONCE(tegra->sys_suspend_mode_req, sys_suspend_mode);
376+
377+ err = regulator_sync_voltage_rdev(tegra->cpu_rdev);
378+ if (err)
379+ return err;
380+
381+ err = regulator_sync_voltage_rdev(tegra->core_rdev);
382+ if (err)
383+ return err;
384+
385+ return 0;
386+}
387+
388+static int tegra30_regulator_suspend(struct notifier_block *notifier,
389+ unsigned long mode, void *arg)
390+{
391+ struct tegra_regulator_coupler *tegra;
392+ int ret = 0;
393+
394+ tegra = container_of(notifier, struct tegra_regulator_coupler,
395+ suspend_notifier);
396+
397+ switch (mode) {
398+ case PM_HIBERNATION_PREPARE:
399+ case PM_RESTORE_PREPARE:
400+ case PM_SUSPEND_PREPARE:
401+ ret = tegra30_regulator_prepare_suspend(tegra, true);
402+ break;
403+
404+ case PM_POST_HIBERNATION:
405+ case PM_POST_RESTORE:
406+ case PM_POST_SUSPEND:
407+ ret = tegra30_regulator_prepare_suspend(tegra, false);
408+ break;
409+ }
410+
411+ if (ret)
412+ pr_err("failed to prepare regulators: %d\n", ret);
413+
414+ return notifier_from_errno(ret);
415+}
416+
299417 static int tegra30_regulator_prepare_reboot(struct tegra_regulator_coupler *tegra,
300418 bool sys_reboot_mode)
301419 {
@@ -395,6 +513,7 @@ static struct tegra_regulator_coupler tegra30_coupler = { · 93 unmodified lines
395513 .balance_voltage = tegra30_regulator_balance_voltage,
396514 },
397515 .reboot_notifier.notifier_call = tegra30_regulator_reboot,
516+ .suspend_notifier.notifier_call = tegra30_regulator_suspend,
398517 };
399518
400519 static int __init tegra_regulator_coupler_init(void)
@@ -407,6 +526,9 @@ static int __init tegra_regulator_coupler_init(void) · 6 unmodified lines
407526 err = register_reboot_notifier(&tegra30_coupler.reboot_notifier);
408527 WARN_ON(err);
409528
529+ err = register_pm_notifier(&tegra30_coupler.suspend_notifier);
530+ WARN_ON(err);
531+
410532 return regulator_coupler_register(&tegra30_coupler.coupler);
411533 }
412534 arch_initcall(tegra_regulator_coupler_init);
drivers/soc/ti/k3-socinfo.c+2−1
@@ -40,7 +40,8 @@ static const struct k3_soc_id { · 39 unmodified lines
4040 { 0xBB5A, "AM65X" },
4141 { 0xBB64, "J721E" },
4242 { 0xBB6D, "J7200" },
43− { 0xBB38, "AM64X" }
43+ { 0xBB38, "AM64X" },
44+ { 0xBB75, "J721S2"},
4445 };
4546
4647 static int
drivers/soc/ti/knav_dma.c+10−10
@@ -646,31 +646,31 @@ static int dma_init(struct device_node *cloud, struct device_node *dma_node) · 645 unmodified lines
646646 }
647647
648648 dma->reg_global = pktdma_get_regs(dma, node, 0, &size);
649− if (!dma->reg_global)
650− return -ENODEV;
649+ if (IS_ERR(dma->reg_global))
650+ return PTR_ERR(dma->reg_global);
651651 if (size < sizeof(struct reg_global)) {
652652 dev_err(kdev->dev, "bad size %pa for global regs\n", &size);
653653 return -ENODEV;
654654 }
655655
656656 dma->reg_tx_chan = pktdma_get_regs(dma, node, 1, &size);
657− if (!dma->reg_tx_chan)
658− return -ENODEV;
657+ if (IS_ERR(dma->reg_tx_chan))
658+ return PTR_ERR(dma->reg_tx_chan);
659659
660660 max_tx_chan = size / sizeof(struct reg_chan);
661661 dma->reg_rx_chan = pktdma_get_regs(dma, node, 2, &size);
662− if (!dma->reg_rx_chan)
663− return -ENODEV;
662+ if (IS_ERR(dma->reg_rx_chan))
663+ return PTR_ERR(dma->reg_rx_chan);
664664
665665 max_rx_chan = size / sizeof(struct reg_chan);
666666 dma->reg_tx_sched = pktdma_get_regs(dma, node, 3, &size);
667− if (!dma->reg_tx_sched)
668− return -ENODEV;
667+ if (IS_ERR(dma->reg_tx_sched))
668+ return PTR_ERR(dma->reg_tx_sched);
669669
670670 max_tx_sched = size / sizeof(struct reg_tx_sched);
671671 dma->reg_rx_flow = pktdma_get_regs(dma, node, 4, &size);
672− if (!dma->reg_rx_flow)
673− return -ENODEV;
672+ if (IS_ERR(dma->reg_rx_flow))
673+ return PTR_ERR(dma->reg_rx_flow);
674674
675675 max_rx_flow = size / sizeof(struct reg_rx_flow);
676676 dma->rx_priority = DMA_PRIO_DEFAULT;
drivers/soc/ti/pruss.c+1−1
@@ -129,7 +129,7 @@ static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node) · 128 unmodified lines
129129
130130 clks_np = of_get_child_by_name(cfg_node, "clocks");
131131 if (!clks_np) {
132− dev_err(dev, "%pOF is missing its 'clocks' node\n", clks_np);
132+ dev_err(dev, "%pOF is missing its 'clocks' node\n", cfg_node);
133133 return -ENODEV;
134134 }
135135
drivers/soc/xilinx/zynqmp_pm_domains.c+51−40
@@ -20,8 +20,6 @@ · 19 unmodified lines
2020 #include <linux/firmware/xlnx-zynqmp.h>
2121
2222 #define ZYNQMP_NUM_DOMAINS (100)
23−/* Flag stating if PM nodes mapped to the PM domain has been requested */
24−#define ZYNQMP_PM_DOMAIN_REQUESTED BIT(0)
2523
2624 static int min_capability;
2725
@@ -29,14 +27,17 @@ static int min_capability; · 1 unmodified line
2927 * struct zynqmp_pm_domain - Wrapper around struct generic_pm_domain
3028 * @gpd: Generic power domain
3129 * @node_id: PM node ID corresponding to device inside PM domain
32− * @flags: ZynqMP PM domain flags
30+ * @requested: The PM node mapped to the PM domain has been requested
3331 */
3432 struct zynqmp_pm_domain {
3533 struct generic_pm_domain gpd;
3634 u32 node_id;
37− u8 flags;
35+ bool requested;
3836 };
3937
38+#define to_zynqmp_pm_domain(pm_domain) \
39+ container_of(pm_domain, struct zynqmp_pm_domain, gpd)
40+
4041 /**
4142 * zynqmp_gpd_is_active_wakeup_path() - Check if device is in wakeup source
4243 * path
@@ -71,21 +72,23 @@ static int zynqmp_gpd_is_active_wakeup_path(struct device *dev, void *not_used) · 28 unmodified lines
7172 */
7273 static int zynqmp_gpd_power_on(struct generic_pm_domain *domain)
7374 {
75+ struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain);
7476 int ret;
75− struct zynqmp_pm_domain *pd;
7677
77− pd = container_of(domain, struct zynqmp_pm_domain, gpd);
7878 ret = zynqmp_pm_set_requirement(pd->node_id,
7979 ZYNQMP_PM_CAPABILITY_ACCESS,
8080 ZYNQMP_PM_MAX_QOS,
8181 ZYNQMP_PM_REQUEST_ACK_BLOCKING);
8282 if (ret) {
83− pr_err("%s() %s set requirement for node %d failed: %d\n",
84− __func__, domain->name, pd->node_id, ret);
83+ dev_err(&domain->dev,
84+ "failed to set requirement to 0x%x for PM node id %d: %d\n",
85+ ZYNQMP_PM_CAPABILITY_ACCESS, pd->node_id, ret);
8586 return ret;
8687 }
8788
88− pr_debug("%s() Powered on %s domain\n", __func__, domain->name);
89+ dev_dbg(&domain->dev, "set requirement to 0x%x for PM node id %d\n",
90+ ZYNQMP_PM_CAPABILITY_ACCESS, pd->node_id);
91+
8992 return 0;
9093 }
9194
@@ -100,18 +103,16 @@ static int zynqmp_gpd_power_on(struct generic_pm_domain *domain) · 8 unmodified lines
100103 */
101104 static int zynqmp_gpd_power_off(struct generic_pm_domain *domain)
102105 {
106+ struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain);
103107 int ret;
104108 struct pm_domain_data *pdd, *tmp;
105− struct zynqmp_pm_domain *pd;
106109 u32 capabilities = min_capability;
107110 bool may_wakeup;
108111
109− pd = container_of(domain, struct zynqmp_pm_domain, gpd);
110−
111112 /* If domain is already released there is nothing to be done */
112− if (!(pd->flags & ZYNQMP_PM_DOMAIN_REQUESTED)) {
113− pr_debug("%s() %s domain is already released\n",
114− __func__, domain->name);
113+ if (!pd->requested) {
114+ dev_dbg(&domain->dev, "PM node id %d is already released\n",
115+ pd->node_id);
115116 return 0;
116117 }
117118
@@ -128,17 +129,16 @@ static int zynqmp_gpd_power_off(struct generic_pm_domain *domain) · 10 unmodified lines
128129
129130 ret = zynqmp_pm_set_requirement(pd->node_id, capabilities, 0,
130131 ZYNQMP_PM_REQUEST_ACK_NO);
131− /**
132− * If powering down of any node inside this domain fails,
133− * report and return the error
134− */
135132 if (ret) {
136− pr_err("%s() %s set requirement for node %d failed: %d\n",
137− __func__, domain->name, pd->node_id, ret);
133+ dev_err(&domain->dev,
134+ "failed to set requirement to 0x%x for PM node id %d: %d\n",
135+ capabilities, pd->node_id, ret);
138136 return ret;
139137 }
140138
141− pr_debug("%s() Powered off %s domain\n", __func__, domain->name);
139+ dev_dbg(&domain->dev, "set requirement to 0x%x for PM node id %d\n",
140+ capabilities, pd->node_id);
141+
142142 return 0;
143143 }
144144
@@ -152,10 +152,14 @@ static int zynqmp_gpd_power_off(struct generic_pm_domain *domain) · 7 unmodified lines
152152 static int zynqmp_gpd_attach_dev(struct generic_pm_domain *domain,
153153 struct device *dev)
154154 {
155+ struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain);
156+ struct device_link *link;
155157 int ret;
156− struct zynqmp_pm_domain *pd;
157158
158− pd = container_of(domain, struct zynqmp_pm_domain, gpd);
159+ link = device_link_add(dev, &domain->dev, DL_FLAG_SYNC_STATE_ONLY);
160+ if (!link)
161+ dev_dbg(&domain->dev, "failed to create device link for %s\n",
162+ dev_name(dev));
159163
160164 /* If this is not the first device to attach there is nothing to do */
161165 if (domain->device_count)
@@ -163,17 +167,17 @@ static int zynqmp_gpd_attach_dev(struct generic_pm_domain *domain, · 1 unmodified line
163167
164168 ret = zynqmp_pm_request_node(pd->node_id, 0, 0,
165169 ZYNQMP_PM_REQUEST_ACK_BLOCKING);
166− /* If requesting a node fails print and return the error */
167170 if (ret) {
168− pr_err("%s() %s request failed for node %d: %d\n",
169− __func__, domain->name, pd->node_id, ret);
171+ dev_err(&domain->dev, "%s request failed for node %d: %d\n",
172+ domain->name, pd->node_id, ret);
170173 return ret;
171174 }
172175
173− pd->flags |= ZYNQMP_PM_DOMAIN_REQUESTED;
176+ pd->requested = true;
177+
178+ dev_dbg(&domain->dev, "%s requested PM node id %d\n",
179+ dev_name(dev), pd->node_id);
174180
175− pr_debug("%s() %s attached to %s domain\n", __func__,
176− dev_name(dev), domain->name);
177181 return 0;
178182 }
179183
@@ -185,27 +189,24 @@ static int zynqmp_gpd_attach_dev(struct generic_pm_domain *domain, · 5 unmodified lines
185189 static void zynqmp_gpd_detach_dev(struct generic_pm_domain *domain,
186190 struct device *dev)
187191 {
192+ struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain);
188193 int ret;
189− struct zynqmp_pm_domain *pd;
190−
191− pd = container_of(domain, struct zynqmp_pm_domain, gpd);
192194
193195 /* If this is not the last device to detach there is nothing to do */
194196 if (domain->device_count)
195197 return;
196198
197199 ret = zynqmp_pm_release_node(pd->node_id);
198− /* If releasing a node fails print the error and return */
199200 if (ret) {
200− pr_err("%s() %s release failed for node %d: %d\n",
201− __func__, domain->name, pd->node_id, ret);
201+ dev_err(&domain->dev, "failed to release PM node id %d: %d\n",
202+ pd->node_id, ret);
202203 return;
203204 }
204205
205− pd->flags &= ~ZYNQMP_PM_DOMAIN_REQUESTED;
206+ pd->requested = false;
206207
207− pr_debug("%s() %s detached from %s domain\n", __func__,
208− dev_name(dev), domain->name);
208+ dev_dbg(&domain->dev, "%s released PM node id %d\n",
209+ dev_name(dev), pd->node_id);
209210 }
210211
211212 static struct generic_pm_domain *zynqmp_gpd_xlate
@@ -215,7 +216,7 @@ static struct generic_pm_domain *zynqmp_gpd_xlate · 3 unmodified lines
215216 unsigned int i, idx = genpdspec->args[0];
216217 struct zynqmp_pm_domain *pd;
217218
218− pd = container_of(genpd_data->domains[0], struct zynqmp_pm_domain, gpd);
219+ pd = to_zynqmp_pm_domain(genpd_data->domains[0]);
219220
220221 if (genpdspec->args_count != 1)
221222 return ERR_PTR(-EINVAL);
@@ -299,9 +300,19 @@ static int zynqmp_gpd_remove(struct platform_device *pdev) · 77 unmodified lines
299300 return 0;
300301 }
301302
303+static void zynqmp_gpd_sync_state(struct device *dev)
304+{
305+ int ret;
306+
307+ ret = zynqmp_pm_init_finalize();
308+ if (ret)
309+ dev_warn(dev, "failed to release power management to firmware\n");
310+}
311+
302312 static struct platform_driver zynqmp_power_domain_driver = {
303313 .driver = {
304314 .name = "zynqmp_power_controller",
315+ .sync_state = zynqmp_gpd_sync_state,
305316 },
306317 .probe = zynqmp_gpd_probe,
307318 .remove = zynqmp_gpd_remove,
drivers/soc/xilinx/zynqmp_power.c+0−1
@@ -178,7 +178,6 @@ static int zynqmp_pm_probe(struct platform_device *pdev) · 177 unmodified lines
178178 u32 pm_api_version;
179179 struct mbox_client *client;
180180
181− zynqmp_pm_init_finalize();
182181 zynqmp_pm_get_api_version(&pm_api_version);
183182
184183 /* Check PM API version number */
drivers/spi/spi-rpc-if.c+3−1
@@ -156,7 +156,9 @@ static int rpcif_spi_probe(struct platform_device *pdev) · 155 unmodified lines
156156 ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_TX_QUAD | SPI_RX_QUAD;
157157 ctlr->flags = SPI_CONTROLLER_HALF_DUPLEX;
158158
159− rpcif_hw_init(rpc, false);
159+ error = rpcif_hw_init(rpc, false);
160+ if (error)
161+ return error;
160162
161163 error = spi_register_controller(ctlr);
162164 if (error) {
drivers/spi/spi-tegra20-slink.c+8−1
@@ -18,12 +18,15 @@ · 17 unmodified lines
1818 #include <linux/kthread.h>
1919 #include <linux/module.h>
2020 #include <linux/platform_device.h>
21+#include <linux/pm_opp.h>
2122 #include <linux/pm_runtime.h>
2223 #include <linux/of.h>
2324 #include <linux/of_device.h>
2425 #include <linux/reset.h>
2526 #include <linux/spi/spi.h>
2627
28+#include <soc/tegra/common.h>
29+
2730 #define SLINK_COMMAND 0x000
2831 #define SLINK_BIT_LENGTH(x) (((x) & 0x1f) << 0)
2932 #define SLINK_WORD_SIZE(x) (((x) & 0x1f) << 5)
@@ -680,7 +683,7 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi, · 650 unmodified lines
680683 bits_per_word = t->bits_per_word;
681684 speed = t->speed_hz;
682685 if (speed != tspi->cur_speed) {
683− clk_set_rate(tspi->clk, speed * 4);
686+ dev_pm_opp_set_rate(tspi->dev, speed * 4);
684687 tspi->cur_speed = speed;
685688 }
686689
@@ -1066,6 +1069,10 @@ static int tegra_slink_probe(struct platform_device *pdev) · 379 unmodified lines
10661069 goto exit_free_master;
10671070 }
10681071
1072+ ret = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
1073+ if (ret)
1074+ goto exit_free_master;
1075+
10691076 tspi->max_buf_size = SLINK_FIFO_DEPTH << 2;
10701077 tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN;
10711078
drivers/staging/media/tegra-vde/vde.c+52−11
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 #include <linux/slab.h>
2121 #include <linux/uaccess.h>
2222
23+#include <soc/tegra/common.h>
2324 #include <soc/tegra/pmc.h>
2425
2526 #include "uapi.h"
@@ -920,13 +921,17 @@ static __maybe_unused int tegra_vde_runtime_suspend(struct device *dev) · 894 unmodified lines
920921 struct tegra_vde *vde = dev_get_drvdata(dev);
921922 int err;
922923
923− err = tegra_powergate_power_off(TEGRA_POWERGATE_VDEC);
924− if (err) {
925− dev_err(dev, "Failed to power down HW: %d\n", err);
926− return err;
924+ if (!dev->pm_domain) {
925+ err = tegra_powergate_power_off(TEGRA_POWERGATE_VDEC);
926+ if (err) {
927+ dev_err(dev, "Failed to power down HW: %d\n", err);
928+ return err;
929+ }
927930 }
928931
929932 clk_disable_unprepare(vde->clk);
933+ reset_control_release(vde->rst);
934+ reset_control_release(vde->rst_mc);
930935
931936 return 0;
932937 }
@@ -936,14 +941,45 @@ static __maybe_unused int tegra_vde_runtime_resume(struct device *dev) · 3 unmodified lines
936941 struct tegra_vde *vde = dev_get_drvdata(dev);
937942 int err;
938943
939− err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_VDEC,
940− vde->clk, vde->rst);
944+ err = reset_control_acquire(vde->rst_mc);
941945 if (err) {
942− dev_err(dev, "Failed to power up HW : %d\n", err);
946+ dev_err(dev, "Failed to acquire mc reset: %d\n", err);
943947 return err;
944948 }
945949
950+ err = reset_control_acquire(vde->rst);
951+ if (err) {
952+ dev_err(dev, "Failed to acquire reset: %d\n", err);
953+ goto release_mc_reset;
954+ }
955+
956+ if (!dev->pm_domain) {
957+ err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_VDEC,
958+ vde->clk, vde->rst);
959+ if (err) {
960+ dev_err(dev, "Failed to power up HW : %d\n", err);
961+ goto release_reset;
962+ }
963+ } else {
964+ /*
965+ * tegra_powergate_sequence_power_up() leaves clocks enabled,
966+ * while GENPD not.
967+ */
968+ err = clk_prepare_enable(vde->clk);
969+ if (err) {
970+ dev_err(dev, "Failed to enable clock: %d\n", err);
971+ goto release_reset;
972+ }
973+ }
974+
946975 return 0;
976+
977+release_reset:
978+ reset_control_release(vde->rst);
979+release_mc_reset:
980+ reset_control_release(vde->rst_mc);
981+
982+ return err;
947983 }
948984
949985 static int tegra_vde_probe(struct platform_device *pdev)
@@ -1001,14 +1037,14 @@ static int tegra_vde_probe(struct platform_device *pdev) · 51 unmodified lines
10011037 return err;
10021038 }
10031039
1004− vde->rst = devm_reset_control_get(dev, NULL);
1040+ vde->rst = devm_reset_control_get_exclusive_released(dev, NULL);
10051041 if (IS_ERR(vde->rst)) {
10061042 err = PTR_ERR(vde->rst);
10071043 dev_err(dev, "Could not get VDE reset %d\n", err);
10081044 return err;
10091045 }
10101046
1011− vde->rst_mc = devm_reset_control_get_optional(dev, "mc");
1047+ vde->rst_mc = devm_reset_control_get_optional_exclusive_released(dev, "mc");
10121048 if (IS_ERR(vde->rst_mc)) {
10131049 err = PTR_ERR(vde->rst_mc);
10141050 dev_err(dev, "Could not get MC reset %d\n", err);
@@ -1026,6 +1062,12 @@ static int tegra_vde_probe(struct platform_device *pdev) · 11 unmodified lines
10261062 return err;
10271063 }
10281064
1065+ err = devm_tegra_core_dev_init_opp_table_common(dev);
1066+ if (err) {
1067+ dev_err(dev, "Could initialize OPP table %d\n", err);
1068+ return err;
1069+ }
1070+
10291071 vde->iram_pool = of_gen_pool_get(dev->of_node, "iram", 0);
10301072 if (!vde->iram_pool) {
10311073 dev_err(dev, "Could not get IRAM pool\n");
@@ -1133,8 +1175,7 @@ static void tegra_vde_shutdown(struct platform_device *pdev) · 101 unmodified lines
11331175 * On some devices bootloader isn't ready to a power-gated VDE on
11341176 * a warm-reboot, machine will hang in that case.
11351177 */
1136− if (pm_runtime_status_suspended(&pdev->dev))
1137− tegra_vde_runtime_resume(&pdev->dev);
1178+ pm_runtime_get_sync(&pdev->dev);
11381179 }
11391180
11401181 static __maybe_unused int tegra_vde_pm_suspend(struct device *dev)
drivers/tee/optee/Makefile+1−0
@@ -2,6 +2,7 @@ · 1 unmodified line
22 obj-$(CONFIG_OPTEE) += optee.o
33 optee-objs += core.o
44 optee-objs += call.o
5+optee-objs += notif.o
56 optee-objs += rpc.o
67 optee-objs += supp.o
78 optee-objs += device.o
drivers/tee/optee/core.c+1−1
@@ -157,6 +157,7 @@ void optee_remove_common(struct optee *optee) · 156 unmodified lines
157157 /* Unregister OP-TEE specific client devices on TEE bus */
158158 optee_unregister_devices();
159159
160+ optee_notif_uninit(optee);
160161 /*
161162 * The two devices have to be unregistered before we can free the
162163 * other resources.
@@ -165,7 +166,6 @@ void optee_remove_common(struct optee *optee) · 2 unmodified lines
165166 tee_device_unregister(optee->teedev);
166167
167168 tee_shm_pool_free(optee->pool);
168− optee_wait_queue_exit(&optee->wait_queue);
169169 optee_supp_uninit(&optee->supp);
170170 mutex_destroy(&optee->call_queue.mutex);
171171 }
drivers/tee/optee/ffa_abi.c+5−1
@@ -855,9 +855,13 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev) · 854 unmodified lines
855855 mutex_init(&optee->ffa.mutex);
856856 mutex_init(&optee->call_queue.mutex);
857857 INIT_LIST_HEAD(&optee->call_queue.waiters);
858− optee_wait_queue_init(&optee->wait_queue);
859858 optee_supp_init(&optee->supp);
860859 ffa_dev_set_drvdata(ffa_dev, optee);
860+ rc = optee_notif_init(optee, OPTEE_DEFAULT_MAX_NOTIF_VALUE);
861+ if (rc) {
862+ optee_ffa_remove(ffa_dev);
863+ return rc;
864+ }
861865
862866 rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES);
863867 if (rc) {
drivers/tee/optee/notif.c+125−0
@@ -0,0 +1,125 @@
1+// SPDX-License-Identifier: GPL-2.0-only
2+/*
3+ * Copyright (c) 2015-2021, Linaro Limited
4+ */
5+
6+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7+
8+#include <linux/arm-smccc.h>
9+#include <linux/errno.h>
10+#include <linux/slab.h>
11+#include <linux/spinlock.h>
12+#include <linux/tee_drv.h>
13+#include "optee_private.h"
14+
15+struct notif_entry {
16+ struct list_head link;
17+ struct completion c;
18+ u_int key;
19+};
20+
21+static bool have_key(struct optee *optee, u_int key)
22+{
23+ struct notif_entry *entry;
24+
25+ list_for_each_entry(entry, &optee->notif.db, link)
26+ if (entry->key == key)
27+ return true;
28+
29+ return false;
30+}
31+
32+int optee_notif_wait(struct optee *optee, u_int key)
33+{
34+ unsigned long flags;
35+ struct notif_entry *entry;
36+ int rc = 0;
37+
38+ if (key > optee->notif.max_key)
39+ return -EINVAL;
40+
41+ entry = kmalloc(sizeof(*entry), GFP_KERNEL);
42+ if (!entry)
43+ return -ENOMEM;
44+ init_completion(&entry->c);
45+ entry->key = key;
46+
47+ spin_lock_irqsave(&optee->notif.lock, flags);
48+
49+ /*
50+ * If the bit is already set it means that the key has already
51+ * been posted and we must not wait.
52+ */
53+ if (test_bit(key, optee->notif.bitmap)) {
54+ clear_bit(key, optee->notif.bitmap);
55+ goto out;
56+ }
57+
58+ /*
59+ * Check if someone is already waiting for this key. If there is
60+ * it's a programming error.
61+ */
62+ if (have_key(optee, key)) {
63+ rc = -EBUSY;
64+ goto out;
65+ }
66+
67+ list_add_tail(&entry->link, &optee->notif.db);
68+
69+ /*
70+ * Unlock temporarily and wait for completion.
71+ */
72+ spin_unlock_irqrestore(&optee->notif.lock, flags);
73+ wait_for_completion(&entry->c);
74+ spin_lock_irqsave(&optee->notif.lock, flags);
75+
76+ list_del(&entry->link);
77+out:
78+ spin_unlock_irqrestore(&optee->notif.lock, flags);
79+
80+ kfree(entry);
81+
82+ return rc;
83+}
84+
85+int optee_notif_send(struct optee *optee, u_int key)
86+{
87+ unsigned long flags;
88+ struct notif_entry *entry;
89+
90+ if (key > optee->notif.max_key)
91+ return -EINVAL;
92+
93+ spin_lock_irqsave(&optee->notif.lock, flags);
94+
95+ list_for_each_entry(entry, &optee->notif.db, link)
96+ if (entry->key == key) {
97+ complete(&entry->c);
98+ goto out;
99+ }
100+
101+ /* Only set the bit in case there where nobody waiting */
102+ set_bit(key, optee->notif.bitmap);
103+out:
104+ spin_unlock_irqrestore(&optee->notif.lock, flags);
105+
106+ return 0;
107+}
108+
109+int optee_notif_init(struct optee *optee, u_int max_key)
110+{
111+ spin_lock_init(&optee->notif.lock);
112+ INIT_LIST_HEAD(&optee->notif.db);
113+ optee->notif.bitmap = bitmap_zalloc(max_key, GFP_KERNEL);
114+ if (!optee->notif.bitmap)
115+ return -ENOMEM;
116+
117+ optee->notif.max_key = max_key;
118+
119+ return 0;
120+}
121+
122+void optee_notif_uninit(struct optee *optee)
123+{
124+ kfree(optee->notif.bitmap);
125+}
drivers/tee/optee/optee_msg.h+9−0
@@ -318,6 +318,13 @@ struct optee_msg_arg { · 317 unmodified lines
318318 * [in] param[0].u.rmem.shm_ref holds shared memory reference
319319 * [in] param[0].u.rmem.offs 0
320320 * [in] param[0].u.rmem.size 0
321+ *
322+ * OPTEE_MSG_CMD_DO_BOTTOM_HALF does the scheduled bottom half processing
323+ * of a driver.
324+ *
325+ * OPTEE_MSG_CMD_STOP_ASYNC_NOTIF informs secure world that from now is
326+ * normal world unable to process asynchronous notifications. Typically
327+ * used when the driver is shut down.
321328 */
322329 #define OPTEE_MSG_CMD_OPEN_SESSION 0
323330 #define OPTEE_MSG_CMD_INVOKE_COMMAND 1
@@ -325,6 +332,8 @@ struct optee_msg_arg { · 1 unmodified line
325332 #define OPTEE_MSG_CMD_CANCEL 3
326333 #define OPTEE_MSG_CMD_REGISTER_SHM 4
327334 #define OPTEE_MSG_CMD_UNREGISTER_SHM 5
335+#define OPTEE_MSG_CMD_DO_BOTTOM_HALF 6
336+#define OPTEE_MSG_CMD_STOP_ASYNC_NOTIF 7
328337 #define OPTEE_MSG_FUNCID_CALL_WITH_ARG 0x0004
329338
330339 #endif /* _OPTEE_MSG_H */
drivers/tee/optee/optee_private.h+20−8
@@ -28,6 +28,13 @@ · 27 unmodified lines
2828
2929 #define TEEC_ORIGIN_COMMS 0x00000002
3030
31+/*
32+ * This value should be larger than the number threads in secure world to
33+ * meet the need from secure world. The number of threads in secure world
34+ * are usually not even close to 255 so we should be safe for now.
35+ */
36+#define OPTEE_DEFAULT_MAX_NOTIF_VALUE 255
37+
3138 typedef void (optee_invoke_fn)(unsigned long, unsigned long, unsigned long,
3239 unsigned long, unsigned long, unsigned long,
3340 unsigned long, unsigned long,
@@ -44,10 +51,13 @@ struct optee_call_queue { · 10 unmodified lines
4451 struct list_head waiters;
4552 };
4653
47−struct optee_wait_queue {
48− /* Serializes access to this struct */
49− struct mutex mu;
54+struct optee_notif {
55+ u_int max_key;
56+ struct tee_context *ctx;
57+ /* Serializes access to the elements below in this struct */
58+ spinlock_t lock;
5059 struct list_head db;
60+ u_long *bitmap;
5161 };
5262
5363 /**
@@ -79,6 +89,7 @@ struct optee_smc { · 25 unmodified lines
7989 optee_invoke_fn *invoke_fn;
8090 void *memremaped_shm;
8191 u32 sec_caps;
92+ unsigned int notif_irq;
8293 };
8394
8495 /**
@@ -129,8 +140,7 @@ struct optee_ops { · 44 unmodified lines
129140 * @smc: specific to SMC ABI
130141 * @ffa: specific to FF-A ABI
131142 * @call_queue: queue of threads waiting to call @invoke_fn
132− * @wait_queue: queue of threads from secure world waiting for a
133− * secure world sync object
143+ * @notif: notification synchronization struct
134144 * @supp: supplicant synchronization struct for RPC to supplicant
135145 * @pool: shared memory pool
136146 * @rpc_arg_count: If > 0 number of RPC parameters to make room for
@@ -147,7 +157,7 @@ struct optee { · 10 unmodified lines
147157 struct optee_ffa ffa;
148158 };
149159 struct optee_call_queue call_queue;
150− struct optee_wait_queue wait_queue;
160+ struct optee_notif notif;
151161 struct optee_supp supp;
152162 struct tee_shm_pool *pool;
153163 unsigned int rpc_arg_count;
@@ -185,8 +195,10 @@ struct optee_call_ctx { · 31 unmodified lines
185195 size_t num_entries;
186196 };
187197
188−void optee_wait_queue_init(struct optee_wait_queue *wq);
189−void optee_wait_queue_exit(struct optee_wait_queue *wq);
198+int optee_notif_init(struct optee *optee, u_int max_key);
199+void optee_notif_uninit(struct optee *optee);
200+int optee_notif_wait(struct optee *optee, u_int key);
201+int optee_notif_send(struct optee *optee, u_int key);
190202
191203 u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
192204 struct tee_param *param);
drivers/tee/optee/optee_rpc_cmd.h+17−14
@@ -28,24 +28,27 @@ · 27 unmodified lines
2828 #define OPTEE_RPC_CMD_GET_TIME 3
2929
3030 /*
31− * Wait queue primitive, helper for secure world to implement a wait queue.
31+ * Notification from/to secure world.
3232 *
33− * If secure world needs to wait for a secure world mutex it issues a sleep
34− * request instead of spinning in secure world. Conversely is a wakeup
35− * request issued when a secure world mutex with a thread waiting thread is
36− * unlocked.
33+ * If secure world needs to wait for something, for instance a mutex, it
34+ * does a notification wait request instead of spinning in secure world.
35+ * Conversely can a synchronous notification can be sent when a secure
36+ * world mutex with a thread waiting thread is unlocked.
3737 *
38− * Waiting on a key
39− * [in] value[0].a OPTEE_RPC_WAIT_QUEUE_SLEEP
40− * [in] value[0].b Wait key
38+ * This interface can also be used to wait for a asynchronous notification
39+ * which instead is sent via a non-secure interrupt.
4140 *
42− * Waking up a key
43− * [in] value[0].a OPTEE_RPC_WAIT_QUEUE_WAKEUP
44− * [in] value[0].b Wakeup key
41+ * Waiting on notification
42+ * [in] value[0].a OPTEE_RPC_NOTIFICATION_WAIT
43+ * [in] value[0].b notification value
44+ *
45+ * Sending a synchronous notification
46+ * [in] value[0].a OPTEE_RPC_NOTIFICATION_SEND
47+ * [in] value[0].b notification value
4548 */
46−#define OPTEE_RPC_CMD_WAIT_QUEUE 4
47−#define OPTEE_RPC_WAIT_QUEUE_SLEEP 0
48−#define OPTEE_RPC_WAIT_QUEUE_WAKEUP 1
49+#define OPTEE_RPC_CMD_NOTIFICATION 4
50+#define OPTEE_RPC_NOTIFICATION_WAIT 0
51+#define OPTEE_RPC_NOTIFICATION_SEND 1
4952
5053 /*
5154 * Suspend execution
drivers/tee/optee/optee_smc.h+73−2
@@ -107,6 +107,12 @@ struct optee_smc_call_get_os_revision_result { · 106 unmodified lines
107107 /*
108108 * Call with struct optee_msg_arg as argument
109109 *
110+ * When calling this function normal world has a few responsibilities:
111+ * 1. It must be able to handle eventual RPCs
112+ * 2. Non-secure interrupts should not be masked
113+ * 3. If asynchronous notifications has been negotiated successfully, then
114+ * asynchronous notifications should be unmasked during this call.
115+ *
110116 * Call register usage:
111117 * a0 SMC Function ID, OPTEE_SMC*CALL_WITH_ARG
112118 * a1 Upper 32 bits of a 64-bit physical pointer to a struct optee_msg_arg
@@ -195,7 +201,8 @@ struct optee_smc_get_shm_config_result { · 82 unmodified lines
195201 * Normal return register usage:
196202 * a0 OPTEE_SMC_RETURN_OK
197203 * a1 bitfield of secure world capabilities OPTEE_SMC_SEC_CAP_*
198− * a2-7 Preserved
204+ * a2 The maximum secure world notification number
205+ * a3-7 Preserved
199206 *
200207 * Error return register usage:
201208 * a0 OPTEE_SMC_RETURN_ENOTAVAIL, can't use the capabilities from normal world
@@ -218,6 +225,8 @@ struct optee_smc_get_shm_config_result { · 16 unmodified lines
218225 #define OPTEE_SMC_SEC_CAP_VIRTUALIZATION BIT(3)
219226 /* Secure world supports Shared Memory with a NULL reference */
220227 #define OPTEE_SMC_SEC_CAP_MEMREF_NULL BIT(4)
228+/* Secure world supports asynchronous notification of normal world */
229+#define OPTEE_SMC_SEC_CAP_ASYNC_NOTIF BIT(5)
221230
222231 #define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9
223232 #define OPTEE_SMC_EXCHANGE_CAPABILITIES \
@@ -226,8 +235,8 @@ struct optee_smc_get_shm_config_result { · 2 unmodified lines
226235 struct optee_smc_exchange_capabilities_result {
227236 unsigned long status;
228237 unsigned long capabilities;
238+ unsigned long max_notif_value;
229239 unsigned long reserved0;
230− unsigned long reserved1;
231240 };
232241
233242 /*
@@ -319,6 +328,68 @@ struct optee_smc_disable_shm_cache_result { · 85 unmodified lines
319328 #define OPTEE_SMC_GET_THREAD_COUNT \
320329 OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_THREAD_COUNT)
321330
331+/*
332+ * Inform OP-TEE that normal world is able to receive asynchronous
333+ * notifications.
334+ *
335+ * Call requests usage:
336+ * a0 SMC Function ID, OPTEE_SMC_ENABLE_ASYNC_NOTIF
337+ * a1-6 Not used
338+ * a7 Hypervisor Client ID register
339+ *
340+ * Normal return register usage:
341+ * a0 OPTEE_SMC_RETURN_OK
342+ * a1-7 Preserved
343+ *
344+ * Not supported return register usage:
345+ * a0 OPTEE_SMC_RETURN_ENOTAVAIL
346+ * a1-7 Preserved
347+ */
348+#define OPTEE_SMC_FUNCID_ENABLE_ASYNC_NOTIF 16
349+#define OPTEE_SMC_ENABLE_ASYNC_NOTIF \
350+ OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_ENABLE_ASYNC_NOTIF)
351+
352+/*
353+ * Retrieve a value of notifications pending since the last call of this
354+ * function.
355+ *
356+ * OP-TEE keeps a record of all posted values. When an interrupt is
357+ * received which indicates that there are posted values this function
358+ * should be called until all pended values have been retrieved. When a
359+ * value is retrieved, it's cleared from the record in secure world.
360+ *
361+ * Call requests usage:
362+ * a0 SMC Function ID, OPTEE_SMC_GET_ASYNC_NOTIF_VALUE
363+ * a1-6 Not used
364+ * a7 Hypervisor Client ID register
365+ *
366+ * Normal return register usage:
367+ * a0 OPTEE_SMC_RETURN_OK
368+ * a1 value
369+ * a2 Bit[0]: OPTEE_SMC_ASYNC_NOTIF_VALUE_VALID if the value in a1 is
370+ * valid, else 0 if no values where pending
371+ * a2 Bit[1]: OPTEE_SMC_ASYNC_NOTIF_VALUE_PENDING if another value is
372+ * pending, else 0.
373+ * Bit[31:2]: MBZ
374+ * a3-7 Preserved
375+ *
376+ * Not supported return register usage:
377+ * a0 OPTEE_SMC_RETURN_ENOTAVAIL
378+ * a1-7 Preserved
379+ */
380+#define OPTEE_SMC_ASYNC_NOTIF_VALUE_VALID BIT(0)
381+#define OPTEE_SMC_ASYNC_NOTIF_VALUE_PENDING BIT(1)
382+
383+/*
384+ * Notification that OP-TEE expects a yielding call to do some bottom half
385+ * work in a driver.
386+ */
387+#define OPTEE_SMC_ASYNC_NOTIF_VALUE_DO_BOTTOM_HALF 0
388+
389+#define OPTEE_SMC_FUNCID_GET_ASYNC_NOTIF_VALUE 17
390+#define OPTEE_SMC_GET_ASYNC_NOTIF_VALUE \
391+ OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_ASYNC_NOTIF_VALUE)
392+
322393 /*
323394 * Resume from RPC (for example after processing a foreign interrupt)
324395 *
drivers/tee/optee/rpc.c+7−64
@@ -12,23 +12,6 @@ · 11 unmodified lines
1212 #include "optee_private.h"
1313 #include "optee_rpc_cmd.h"
1414
15−struct wq_entry {
16− struct list_head link;
17− struct completion c;
18− u32 key;
19−};
20−
21−void optee_wait_queue_init(struct optee_wait_queue *priv)
22−{
23− mutex_init(&priv->mu);
24− INIT_LIST_HEAD(&priv->db);
25−}
26−
27−void optee_wait_queue_exit(struct optee_wait_queue *priv)
28−{
29− mutex_destroy(&priv->mu);
30−}
31−
3215 static void handle_rpc_func_cmd_get_time(struct optee_msg_arg *arg)
3316 {
3417 struct timespec64 ts;
@@ -144,48 +127,6 @@ static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx, · 109 unmodified lines
144127 }
145128 #endif
146129
147−static struct wq_entry *wq_entry_get(struct optee_wait_queue *wq, u32 key)
148−{
149− struct wq_entry *w;
150−
151− mutex_lock(&wq->mu);
152−
153− list_for_each_entry(w, &wq->db, link)
154− if (w->key == key)
155− goto out;
156−
157− w = kmalloc(sizeof(*w), GFP_KERNEL);
158− if (w) {
159− init_completion(&w->c);
160− w->key = key;
161− list_add_tail(&w->link, &wq->db);
162− }
163−out:
164− mutex_unlock(&wq->mu);
165− return w;
166−}
167−
168−static void wq_sleep(struct optee_wait_queue *wq, u32 key)
169−{
170− struct wq_entry *w = wq_entry_get(wq, key);
171−
172− if (w) {
173− wait_for_completion(&w->c);
174− mutex_lock(&wq->mu);
175− list_del(&w->link);
176− mutex_unlock(&wq->mu);
177− kfree(w);
178− }
179−}
180−
181−static void wq_wakeup(struct optee_wait_queue *wq, u32 key)
182−{
183− struct wq_entry *w = wq_entry_get(wq, key);
184−
185− if (w)
186− complete(&w->c);
187−}
188−
189130 static void handle_rpc_func_cmd_wq(struct optee *optee,
190131 struct optee_msg_arg *arg)
191132 {
@@ -197,11 +138,13 @@ static void handle_rpc_func_cmd_wq(struct optee *optee, · 5 unmodified lines
197138 goto bad;
198139
199140 switch (arg->params[0].u.value.a) {
200− case OPTEE_RPC_WAIT_QUEUE_SLEEP:
201− wq_sleep(&optee->wait_queue, arg->params[0].u.value.b);
141+ case OPTEE_RPC_NOTIFICATION_WAIT:
142+ if (optee_notif_wait(optee, arg->params[0].u.value.b))
143+ goto bad;
202144 break;
203− case OPTEE_RPC_WAIT_QUEUE_WAKEUP:
204− wq_wakeup(&optee->wait_queue, arg->params[0].u.value.b);
145+ case OPTEE_RPC_NOTIFICATION_SEND:
146+ if (optee_notif_send(optee, arg->params[0].u.value.b))
147+ goto bad;
205148 break;
206149 default:
207150 goto bad;
@@ -319,7 +262,7 @@ void optee_rpc_cmd(struct tee_context *ctx, struct optee *optee, · 111 unmodified lines
319262 case OPTEE_RPC_CMD_GET_TIME:
320263 handle_rpc_func_cmd_get_time(arg);
321264 break;
322− case OPTEE_RPC_CMD_WAIT_QUEUE:
265+ case OPTEE_RPC_CMD_NOTIFICATION:
323266 handle_rpc_func_cmd_wq(optee, arg);
324267 break;
325268 case OPTEE_RPC_CMD_SUSPEND:
drivers/tee/optee/smc_abi.c+206−31
@@ -8,13 +8,16 @@ · 7 unmodified lines
88
99 #include <linux/arm-smccc.h>
1010 #include <linux/errno.h>
11+#include <linux/interrupt.h>
1112 #include <linux/io.h>
12−#include <linux/sched.h>
13+#include <linux/irqdomain.h>
1314 #include <linux/mm.h>
1415 #include <linux/module.h>
1516 #include <linux/of.h>
17+#include <linux/of_irq.h>
1618 #include <linux/of_platform.h>
1719 #include <linux/platform_device.h>
20+#include <linux/sched.h>
1821 #include <linux/slab.h>
1922 #include <linux/string.h>
2023 #include <linux/tee_drv.h>
@@ -35,7 +38,8 @@ · 14 unmodified lines
3538 * 2. Low level support functions to register shared memory in secure world
3639 * 3. Dynamic shared memory pool based on alloc_pages()
3740 * 4. Do a normal scheduled call into secure world
38− * 5. Driver initialization.
41+ * 5. Asynchronous notification
42+ * 6. Driver initialization.
3943 */
4044
4145 #define OPTEE_SHM_NUM_PRIV_PAGES CONFIG_OPTEE_SHM_NUM_PRIV_PAGES
@@ -877,10 +881,137 @@ static int optee_smc_do_call_with_arg(struct tee_context *ctx, · 835 unmodified lines
877881 return rc;
878882 }
879883
884+static int simple_call_with_arg(struct tee_context *ctx, u32 cmd)
885+{
886+ struct optee_msg_arg *msg_arg;
887+ struct tee_shm *shm;
888+
889+ shm = optee_get_msg_arg(ctx, 0, &msg_arg);
890+ if (IS_ERR(shm))
891+ return PTR_ERR(shm);
892+
893+ msg_arg->cmd = cmd;
894+ optee_smc_do_call_with_arg(ctx, shm);
895+
896+ tee_shm_free(shm);
897+ return 0;
898+}
899+
900+static int optee_smc_do_bottom_half(struct tee_context *ctx)
901+{
902+ return simple_call_with_arg(ctx, OPTEE_MSG_CMD_DO_BOTTOM_HALF);
903+}
904+
905+static int optee_smc_stop_async_notif(struct tee_context *ctx)
906+{
907+ return simple_call_with_arg(ctx, OPTEE_MSG_CMD_STOP_ASYNC_NOTIF);
908+}
909+
880910 /*
881− * 5. Driver initialization
911+ * 5. Asynchronous notification
912+ */
913+
914+static u32 get_async_notif_value(optee_invoke_fn *invoke_fn, bool *value_valid,
915+ bool *value_pending)
916+{
917+ struct arm_smccc_res res;
918+
919+ invoke_fn(OPTEE_SMC_GET_ASYNC_NOTIF_VALUE, 0, 0, 0, 0, 0, 0, 0, &res);
920+
921+ if (res.a0)
922+ return 0;
923+ *value_valid = (res.a2 & OPTEE_SMC_ASYNC_NOTIF_VALUE_VALID);
924+ *value_pending = (res.a2 & OPTEE_SMC_ASYNC_NOTIF_VALUE_PENDING);
925+ return res.a1;
926+}
927+
928+static irqreturn_t notif_irq_handler(int irq, void *dev_id)
929+{
930+ struct optee *optee = dev_id;
931+ bool do_bottom_half = false;
932+ bool value_valid;
933+ bool value_pending;
934+ u32 value;
935+
936+ do {
937+ value = get_async_notif_value(optee->smc.invoke_fn,
938+ &value_valid, &value_pending);
939+ if (!value_valid)
940+ break;
941+
942+ if (value == OPTEE_SMC_ASYNC_NOTIF_VALUE_DO_BOTTOM_HALF)
943+ do_bottom_half = true;
944+ else
945+ optee_notif_send(optee, value);
946+ } while (value_pending);
947+
948+ if (do_bottom_half)
949+ return IRQ_WAKE_THREAD;
950+ return IRQ_HANDLED;
951+}
952+
953+static irqreturn_t notif_irq_thread_fn(int irq, void *dev_id)
954+{
955+ struct optee *optee = dev_id;
956+
957+ optee_smc_do_bottom_half(optee->notif.ctx);
958+
959+ return IRQ_HANDLED;
960+}
961+
962+static int optee_smc_notif_init_irq(struct optee *optee, u_int irq)
963+{
964+ struct tee_context *ctx;
965+ int rc;
966+
967+ ctx = teedev_open(optee->teedev);
968+ if (IS_ERR(ctx))
969+ return PTR_ERR(ctx);
970+
971+ optee->notif.ctx = ctx;
972+ rc = request_threaded_irq(irq, notif_irq_handler,
973+ notif_irq_thread_fn,
974+ 0, "optee_notification", optee);
975+ if (rc)
976+ goto err_close_ctx;
977+
978+ optee->smc.notif_irq = irq;
979+
980+ return 0;
981+
982+err_close_ctx:
983+ teedev_close_context(optee->notif.ctx);
984+ optee->notif.ctx = NULL;
985+
986+ return rc;
987+}
988+
989+static void optee_smc_notif_uninit_irq(struct optee *optee)
990+{
991+ if (optee->notif.ctx) {
992+ optee_smc_stop_async_notif(optee->notif.ctx);
993+ if (optee->smc.notif_irq) {
994+ free_irq(optee->smc.notif_irq, optee);
995+ irq_dispose_mapping(optee->smc.notif_irq);
996+ }
997+
998+ /*
999+ * The thread normally working with optee->notif.ctx was
1000+ * stopped with free_irq() above.
1001+ *
1002+ * Note we're not using teedev_close_context() or
1003+ * tee_client_close_context() since we have already called
1004+ * tee_device_put() while initializing to avoid a circular
1005+ * reference counting.
1006+ */
1007+ teedev_close_context(optee->notif.ctx);
1008+ }
1009+}
1010+
1011+/*
1012+ * 6. Driver initialization
8821013 *
883− * During driver inititialization is secure world probed to find out which
1014+ * During driver initialization is secure world probed to find out which
8841015 * features it supports so the driver can be initialized with a matching
8851016 * configuration. This involves for instance support for dynamic shared
8861017 * memory instead of a static memory carvout.
@@ -952,6 +1083,17 @@ static const struct optee_ops optee_ops = { · 65 unmodified lines
9521083 .from_msg_param = optee_from_msg_param,
9531084 };
9541085
1086+static int enable_async_notif(optee_invoke_fn *invoke_fn)
1087+{
1088+ struct arm_smccc_res res;
1089+
1090+ invoke_fn(OPTEE_SMC_ENABLE_ASYNC_NOTIF, 0, 0, 0, 0, 0, 0, 0, &res);
1091+
1092+ if (res.a0)
1093+ return -EINVAL;
1094+ return 0;
1095+}
1096+
9551097 static bool optee_msg_api_uid_is_optee_api(optee_invoke_fn *invoke_fn)
9561098 {
9571099 struct arm_smccc_res res;
@@ -1001,7 +1143,7 @@ static bool optee_msg_api_revision_is_compatible(optee_invoke_fn *invoke_fn) · 43 unmodified lines
10011143 }
10021144
10031145 static bool optee_msg_exchange_capabilities(optee_invoke_fn *invoke_fn,
1004− u32 *sec_caps)
1146+ u32 *sec_caps, u32 *max_notif_value)
10051147 {
10061148 union {
10071149 struct arm_smccc_res smccc;
@@ -1024,6 +1166,11 @@ static bool optee_msg_exchange_capabilities(optee_invoke_fn *invoke_fn, · 16 unmodified lines
10241166 return false;
10251167
10261168 *sec_caps = res.result.capabilities;
1169+ if (*sec_caps & OPTEE_SMC_SEC_CAP_ASYNC_NOTIF)
1170+ *max_notif_value = res.result.max_notif_value;
1171+ else
1172+ *max_notif_value = OPTEE_DEFAULT_MAX_NOTIF_VALUE;
1173+
10271174 return true;
10281175 }
10291176
@@ -1188,6 +1335,8 @@ static int optee_smc_remove(struct platform_device *pdev) · 158 unmodified lines
11881335 */
11891336 optee_disable_shm_cache(optee);
11901337
1338+ optee_smc_notif_uninit_irq(optee);
1339+
11911340 optee_remove_common(optee);
11921341
11931342 if (optee->smc.memremaped_shm)
@@ -1217,6 +1366,7 @@ static int optee_probe(struct platform_device *pdev) · 23 unmodified lines
12171366 struct optee *optee = NULL;
12181367 void *memremaped_shm = NULL;
12191368 struct tee_device *teedev;
1369+ u32 max_notif_value;
12201370 u32 sec_caps;
12211371 int rc;
12221372
@@ -1236,7 +1386,8 @@ static int optee_probe(struct platform_device *pdev) · 13 unmodified lines
12361386 return -EINVAL;
12371387 }
12381388
1239− if (!optee_msg_exchange_capabilities(invoke_fn, &sec_caps)) {
1389+ if (!optee_msg_exchange_capabilities(invoke_fn, &sec_caps,
1390+ &max_notif_value)) {
12401391 pr_warn("capabilities mismatch\n");
12411392 return -EINVAL;
12421393 }
@@ -1259,7 +1410,7 @@ static int optee_probe(struct platform_device *pdev) · 16 unmodified lines
12591410 optee = kzalloc(sizeof(*optee), GFP_KERNEL);
12601411 if (!optee) {
12611412 rc = -ENOMEM;
1262− goto err;
1413+ goto err_free_pool;
12631414 }
12641415
12651416 optee->ops = &optee_ops;
@@ -1269,32 +1420,55 @@ static int optee_probe(struct platform_device *pdev) · 3 unmodified lines
12691420 teedev = tee_device_alloc(&optee_clnt_desc, NULL, pool, optee);
12701421 if (IS_ERR(teedev)) {
12711422 rc = PTR_ERR(teedev);
1272− goto err;
1423+ goto err_free_optee;
12731424 }
12741425 optee->teedev = teedev;
12751426
12761427 teedev = tee_device_alloc(&optee_supp_desc, NULL, pool, optee);
12771428 if (IS_ERR(teedev)) {
12781429 rc = PTR_ERR(teedev);
1279− goto err;
1430+ goto err_unreg_teedev;
12801431 }
12811432 optee->supp_teedev = teedev;
12821433
12831434 rc = tee_device_register(optee->teedev);
12841435 if (rc)
1285− goto err;
1436+ goto err_unreg_supp_teedev;
12861437
12871438 rc = tee_device_register(optee->supp_teedev);
12881439 if (rc)
1289− goto err;
1440+ goto err_unreg_supp_teedev;
12901441
12911442 mutex_init(&optee->call_queue.mutex);
12921443 INIT_LIST_HEAD(&optee->call_queue.waiters);
1293− optee_wait_queue_init(&optee->wait_queue);
12941444 optee_supp_init(&optee->supp);
12951445 optee->smc.memremaped_shm = memremaped_shm;
12961446 optee->pool = pool;
12971447
1448+ platform_set_drvdata(pdev, optee);
1449+ rc = optee_notif_init(optee, max_notif_value);
1450+ if (rc)
1451+ goto err_supp_uninit;
1452+
1453+ if (sec_caps & OPTEE_SMC_SEC_CAP_ASYNC_NOTIF) {
1454+ unsigned int irq;
1455+
1456+ rc = platform_get_irq(pdev, 0);
1457+ if (rc < 0) {
1458+ pr_err("platform_get_irq: ret %d\n", rc);
1459+ goto err_notif_uninit;
1460+ }
1461+ irq = rc;
1462+
1463+ rc = optee_smc_notif_init_irq(optee, irq);
1464+ if (rc) {
1465+ irq_dispose_mapping(irq);
1466+ goto err_notif_uninit;
1467+ }
1468+ enable_async_notif(optee->smc.invoke_fn);
1469+ pr_info("Asynchronous notifications enabled\n");
1470+ }
1471+
12981472 /*
12991473 * Ensure that there are no pre-existing shm objects before enabling
13001474 * the shm cache so that there's no chance of receiving an invalid
@@ -1309,29 +1483,30 @@ static int optee_probe(struct platform_device *pdev) · 8 unmodified lines
13091483 if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM)
13101484 pr_info("dynamic shared memory is enabled\n");
13111485
1312− platform_set_drvdata(pdev, optee);
1313−
13141486 rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES);
1315− if (rc) {
1316− optee_smc_remove(pdev);
1317− return rc;
1318− }
1487+ if (rc)
1488+ goto err_disable_shm_cache;
13191489
13201490 pr_info("initialized driver\n");
13211491 return 0;
1322−err:
1323− if (optee) {
1324− /*
1325− * tee_device_unregister() is safe to call even if the
1326− * devices hasn't been registered with
1327− * tee_device_register() yet.
1328− */
1329− tee_device_unregister(optee->supp_teedev);
1330− tee_device_unregister(optee->teedev);
1331− kfree(optee);
1332− }
1333− if (pool)
1334− tee_shm_pool_free(pool);
1492+
1493+err_disable_shm_cache:
1494+ optee_disable_shm_cache(optee);
1495+ optee_smc_notif_uninit_irq(optee);
1496+ optee_unregister_devices();
1497+err_notif_uninit:
1498+ optee_notif_uninit(optee);
1499+err_supp_uninit:
1500+ optee_supp_uninit(&optee->supp);
1501+ mutex_destroy(&optee->call_queue.mutex);
1502+err_unreg_supp_teedev:
1503+ tee_device_unregister(optee->supp_teedev);
1504+err_unreg_teedev:
1505+ tee_device_unregister(optee->teedev);
1506+err_free_optee:
1507+ kfree(optee);
1508+err_free_pool:
1509+ tee_shm_pool_free(pool);
13351510 if (memremaped_shm)
13361511 memunmap(memremaped_shm);
13371512 return rc;
drivers/tee/tee_core.c+7−3
@@ -43,7 +43,7 @@ static DEFINE_SPINLOCK(driver_lock); · 42 unmodified lines
4343 static struct class *tee_class;
4444 static dev_t tee_devt;
4545
46−static struct tee_context *teedev_open(struct tee_device *teedev)
46+struct tee_context *teedev_open(struct tee_device *teedev)
4747 {
4848 int rc;
4949 struct tee_context *ctx;
@@ -70,6 +70,7 @@ err: · 20 unmodified lines
7070 return ERR_PTR(rc);
7171
7272 }
73+EXPORT_SYMBOL_GPL(teedev_open);
7374
7475 void teedev_ctx_get(struct tee_context *ctx)
7576 {
@@ -96,11 +97,14 @@ void teedev_ctx_put(struct tee_context *ctx) · 20 unmodified lines
9697 kref_put(&ctx->refcount, teedev_ctx_release);
9798 }
9899
99−static void teedev_close_context(struct tee_context *ctx)
100+void teedev_close_context(struct tee_context *ctx)
100101 {
101− tee_device_put(ctx->teedev);
102+ struct tee_device *teedev = ctx->teedev;
103+
102104 teedev_ctx_put(ctx);
105+ tee_device_put(teedev);
103106 }
107+EXPORT_SYMBOL_GPL(teedev_close_context);
104108
105109 static int tee_open(struct inode *inode, struct file *filp)
106110 {
drivers/usb/chipidea/ci_hdrc_tegra.c+46−7
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 #include <linux/io.h>
88 #include <linux/module.h>
99 #include <linux/of_device.h>
10+#include <linux/pm_runtime.h>
1011 #include <linux/reset.h>
1112
1213 #include <linux/usb.h>
@@ -15,6 +16,8 @@ · 2 unmodified lines
1516 #include <linux/usb/of.h>
1617 #include <linux/usb/phy.h>
1718
19+#include <soc/tegra/common.h>
20+
1821 #include "../host/ehci.h"
1922
2023 #include "ci.h"
@@ -278,6 +281,8 @@ static int tegra_usb_probe(struct platform_device *pdev) · 257 unmodified lines
278281 if (!usb)
279282 return -ENOMEM;
280283
284+ platform_set_drvdata(pdev, usb);
285+
281286 soc = of_device_get_match_data(&pdev->dev);
282287 if (!soc) {
283288 dev_err(&pdev->dev, "failed to match OF data\n");
@@ -296,11 +301,14 @@ static int tegra_usb_probe(struct platform_device *pdev) · 12 unmodified lines
296301 return err;
297302 }
298303
299− err = clk_prepare_enable(usb->clk);
300− if (err < 0) {
301− dev_err(&pdev->dev, "failed to enable clock: %d\n", err);
304+ err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
305+ if (err)
306+ return err;
307+
308+ pm_runtime_enable(&pdev->dev);
309+ err = pm_runtime_resume_and_get(&pdev->dev);
310+ if (err)
302311 return err;
303− }
304312
305313 if (device_property_present(&pdev->dev, "nvidia,needs-double-reset"))
306314 usb->needs_double_reset = true;
@@ -320,8 +328,6 @@ static int tegra_usb_probe(struct platform_device *pdev) · 13 unmodified lines
320328 if (err)
321329 goto fail_power_off;
322330
323− platform_set_drvdata(pdev, usb);
324−
325331 /* setup and register ChipIdea HDRC device */
326332 usb->soc = soc;
327333 usb->data.name = "tegra-usb";
@@ -350,7 +356,9 @@ static int tegra_usb_probe(struct platform_device *pdev) · 22 unmodified lines
350356 phy_shutdown:
351357 usb_phy_shutdown(usb->phy);
352358 fail_power_off:
353− clk_disable_unprepare(usb->clk);
359+ pm_runtime_put_sync_suspend(&pdev->dev);
360+ pm_runtime_force_suspend(&pdev->dev);
361+
354362 return err;
355363 }
356364
@@ -360,15 +368,46 @@ static int tegra_usb_remove(struct platform_device *pdev) · 3 unmodified lines
360368
361369 ci_hdrc_remove_device(usb->dev);
362370 usb_phy_shutdown(usb->phy);
371+
372+ pm_runtime_put_sync_suspend(&pdev->dev);
373+ pm_runtime_force_suspend(&pdev->dev);
374+
375+ return 0;
376+}
377+
378+static int __maybe_unused tegra_usb_runtime_resume(struct device *dev)
379+{
380+ struct tegra_usb *usb = dev_get_drvdata(dev);
381+ int err;
382+
383+ err = clk_prepare_enable(usb->clk);
384+ if (err < 0) {
385+ dev_err(dev, "failed to enable clock: %d\n", err);
386+ return err;
387+ }
388+
389+ return 0;
390+}
391+
392+static int __maybe_unused tegra_usb_runtime_suspend(struct device *dev)
393+{
394+ struct tegra_usb *usb = dev_get_drvdata(dev);
395+
363396 clk_disable_unprepare(usb->clk);
364397
365398 return 0;
366399 }
367400
401+static const struct dev_pm_ops tegra_usb_pm = {
402+ SET_RUNTIME_PM_OPS(tegra_usb_runtime_suspend, tegra_usb_runtime_resume,
403+ NULL)
404+};
405+
368406 static struct platform_driver tegra_usb_driver = {
369407 .driver = {
370408 .name = "tegra-usb",
371409 .of_match_table = tegra_usb_of_match,
410+ .pm = &tegra_usb_pm,
372411 },
373412 .probe = tegra_usb_probe,
374413 .remove = tegra_usb_remove,
include/dt-bindings/clock/r8a779f0-cpg-mssr.h+64−0
@@ -0,0 +1,64 @@
1+/* SPDX-License-Identifier: (GPL-2.0 or MIT) */
2+/*
3+ * Copyright (C) 2021 Renesas Electronics Corp.
4+ */
5+#ifndef __DT_BINDINGS_CLOCK_R8A779F0_CPG_MSSR_H__
6+#define __DT_BINDINGS_CLOCK_R8A779F0_CPG_MSSR_H__
7+
8+#include <dt-bindings/clock/renesas-cpg-mssr.h>
9+
10+/* r8a779f0 CPG Core Clocks */
11+
12+#define R8A779F0_CLK_ZX 0
13+#define R8A779F0_CLK_ZS 1
14+#define R8A779F0_CLK_ZT 2
15+#define R8A779F0_CLK_ZTR 3
16+#define R8A779F0_CLK_S0D2 4
17+#define R8A779F0_CLK_S0D3 5
18+#define R8A779F0_CLK_S0D4 6
19+#define R8A779F0_CLK_S0D2_MM 7
20+#define R8A779F0_CLK_S0D3_MM 8
21+#define R8A779F0_CLK_S0D4_MM 9
22+#define R8A779F0_CLK_S0D2_RT 10
23+#define R8A779F0_CLK_S0D3_RT 11
24+#define R8A779F0_CLK_S0D4_RT 12
25+#define R8A779F0_CLK_S0D6_RT 13
26+#define R8A779F0_CLK_S0D3_PER 14
27+#define R8A779F0_CLK_S0D6_PER 15
28+#define R8A779F0_CLK_S0D12_PER 16
29+#define R8A779F0_CLK_S0D24_PER 17
30+#define R8A779F0_CLK_S0D2_HSC 18
31+#define R8A779F0_CLK_S0D3_HSC 19
32+#define R8A779F0_CLK_S0D4_HSC 20
33+#define R8A779F0_CLK_S0D6_HSC 21
34+#define R8A779F0_CLK_S0D12_HSC 22
35+#define R8A779F0_CLK_S0D2_CC 23
36+#define R8A779F0_CLK_CL 24
37+#define R8A779F0_CLK_CL16M 25
38+#define R8A779F0_CLK_CL16M_MM 26
39+#define R8A779F0_CLK_CL16M_RT 27
40+#define R8A779F0_CLK_CL16M_PER 28
41+#define R8A779F0_CLK_CL16M_HSC 29
42+#define R8A779F0_CLK_Z0 30
43+#define R8A779F0_CLK_Z1 31
44+#define R8A779F0_CLK_ZB3 32
45+#define R8A779F0_CLK_ZB3D2 33
46+#define R8A779F0_CLK_ZB3D4 34
47+#define R8A779F0_CLK_SD0H 35
48+#define R8A779F0_CLK_SD0 36
49+#define R8A779F0_CLK_RPC 37
50+#define R8A779F0_CLK_RPCD2 38
51+#define R8A779F0_CLK_MSO 39
52+#define R8A779F0_CLK_SASYNCRT 40
53+#define R8A779F0_CLK_SASYNCPERD1 41
54+#define R8A779F0_CLK_SASYNCPERD2 42
55+#define R8A779F0_CLK_SASYNCPERD4 43
56+#define R8A779F0_CLK_DBGSOC_HSC 44
57+#define R8A779F0_CLK_RSW2 45
58+#define R8A779F0_CLK_OSC 46
59+#define R8A779F0_CLK_ZR 47
60+#define R8A779F0_CLK_CPEX 48
61+#define R8A779F0_CLK_CBFUSA 49
62+#define R8A779F0_CLK_R 50
63+
64+#endif /* __DT_BINDINGS_CLOCK_R8A779F0_CPG_MSSR_H__ */
include/dt-bindings/power/imx8mn-power.h+5−0
@@ -12,4 +12,9 @@ · 11 unmodified lines
1212 #define IMX8MN_POWER_DOMAIN_DISPMIX 3
1313 #define IMX8MN_POWER_DOMAIN_MIPI 4
1414
15+#define IMX8MN_DISPBLK_PD_MIPI_DSI 0
16+#define IMX8MN_DISPBLK_PD_MIPI_CSI 1
17+#define IMX8MN_DISPBLK_PD_LCDIF 2
18+#define IMX8MN_DISPBLK_PD_ISI 3
19+
1520 #endif
include/dt-bindings/power/qcom-rpmpd.h+33−0
@@ -68,6 +68,21 @@ · 67 unmodified lines
6868 #define SM8350_MXC_AO 11
6969 #define SM8350_MSS 12
7070
71+/* SM8450 Power Domain Indexes */
72+#define SM8450_CX 0
73+#define SM8450_CX_AO 1
74+#define SM8450_EBI 2
75+#define SM8450_GFX 3
76+#define SM8450_LCX 4
77+#define SM8450_LMX 5
78+#define SM8450_MMCX 6
79+#define SM8450_MMCX_AO 7
80+#define SM8450_MX 8
81+#define SM8450_MX_AO 9
82+#define SM8450_MXC 10
83+#define SM8450_MXC_AO 11
84+#define SM8450_MSS 12
85+
7186 /* SC7180 Power Domain Indexes */
7287 #define SC7180_CX 0
7388 #define SC7180_CX_AO 1
@@ -219,6 +234,24 @@ · 145 unmodified lines
219234 #define SM6115_VDD_LPI_CX 6
220235 #define SM6115_VDD_LPI_MX 7
221236
237+/* SM6125 Power Domains */
238+#define SM6125_VDDCX 0
239+#define SM6125_VDDCX_AO 1
240+#define SM6125_VDDCX_VFL 2
241+#define SM6125_VDDMX 3
242+#define SM6125_VDDMX_AO 4
243+#define SM6125_VDDMX_VFL 5
244+
245+/* QCM2290 Power Domains */
246+#define QCM2290_VDDCX 0
247+#define QCM2290_VDDCX_AO 1
248+#define QCM2290_VDDCX_VFL 2
249+#define QCM2290_VDDMX 3
250+#define QCM2290_VDDMX_AO 4
251+#define QCM2290_VDDMX_VFL 5
252+#define QCM2290_VDD_LPI_CX 6
253+#define QCM2290_VDD_LPI_MX 7
254+
222255 /* RPM SMD Power Domain performance levels */
223256 #define RPM_SMD_LEVEL_RETENTION 16
224257 #define RPM_SMD_LEVEL_RETENTION_PLUS 32
include/dt-bindings/power/r8a779f0-sysc.h+30−0
@@ -0,0 +1,30 @@
1+/* SPDX-License-Identifier: (GPL-2.0 or MIT) */
2+/*
3+ * Copyright (C) 2021 Renesas Electronics Corp.
4+ */
5+#ifndef __DT_BINDINGS_POWER_R8A779F0_SYSC_H__
6+#define __DT_BINDINGS_POWER_R8A779F0_SYSC_H__
7+
8+/*
9+ * These power domain indices match the Power Domain Register Numbers (PDR)
10+ */
11+
12+#define R8A779F0_PD_A1E0D0C0 0
13+#define R8A779F0_PD_A1E0D0C1 1
14+#define R8A779F0_PD_A1E0D1C0 2
15+#define R8A779F0_PD_A1E0D1C1 3
16+#define R8A779F0_PD_A1E1D0C0 4
17+#define R8A779F0_PD_A1E1D0C1 5
18+#define R8A779F0_PD_A1E1D1C0 6
19+#define R8A779F0_PD_A1E1D1C1 7
20+#define R8A779F0_PD_A2E0D0 16
21+#define R8A779F0_PD_A2E0D1 17
22+#define R8A779F0_PD_A2E1D0 18
23+#define R8A779F0_PD_A2E1D1 19
24+#define R8A779F0_PD_A3E0 20
25+#define R8A779F0_PD_A3E1 21
26+
27+/* Always-on power area */
28+#define R8A779F0_PD_ALWAYS_ON 64
29+
30+#endif /* __DT_BINDINGS_POWER_R8A779A0_SYSC_H__*/
include/dt-bindings/soc/samsung,exynos-usi.h+17−0
@@ -0,0 +1,17 @@
1+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2+/*
3+ * Copyright (c) 2021 Linaro Ltd.
4+ * Author: Sam Protsenko <semen.protsenko@linaro.org>
5+ *
6+ * Device Tree bindings for Samsung Exynos USI (Universal Serial Interface).
7+ */
8+
9+#ifndef __DT_BINDINGS_SAMSUNG_EXYNOS_USI_H
10+#define __DT_BINDINGS_SAMSUNG_EXYNOS_USI_H
11+
12+#define USI_V2_NONE 0
13+#define USI_V2_UART 1
14+#define USI_V2_SPI 2
15+#define USI_V2_I2C 3
16+
17+#endif /* __DT_BINDINGS_SAMSUNG_EXYNOS_USI_H */
include/linux/soc/qcom/llcc-qcom.h+3−0
@@ -33,6 +33,9 @@ · 32 unmodified lines
3333 #define LLCC_MODPE 29
3434 #define LLCC_APTCM 30
3535 #define LLCC_WRCACHE 31
36+#define LLCC_CVPFW 32
37+#define LLCC_CPUSS1 33
38+#define LLCC_CPUHWT 36
3639
3740 /**
3841 * struct llcc_slice_desc - Cache slice descriptor
include/linux/soc/renesas/rcar-rst.h+2−0
@@ -4,8 +4,10 @@ · 3 unmodified lines
44
55 #ifdef CONFIG_RST_RCAR
66 int rcar_rst_read_mode_pins(u32 *mode);
7+int rcar_rst_set_rproc_boot_addr(u64 boot_addr);
78 #else
89 static inline int rcar_rst_read_mode_pins(u32 *mode) { return -ENODEV; }
10+static inline int rcar_rst_set_rproc_boot_addr(u64 boot_addr) { return -ENODEV; }
911 #endif
1012
1113 #endif /* __LINUX_SOC_RENESAS_RCAR_RST_H__ */
include/linux/tee_drv.h+14−0
@@ -587,4 +587,18 @@ struct tee_client_driver { · 586 unmodified lines
587587 #define to_tee_client_driver(d) \
588588 container_of(d, struct tee_client_driver, driver)
589589
590+/**
591+ * teedev_open() - Open a struct tee_device
592+ * @teedev: Device to open
593+ *
594+ * @return a pointer to struct tee_context on success or an ERR_PTR on failure.
595+ */
596+struct tee_context *teedev_open(struct tee_device *teedev);
597+
598+/**
599+ * teedev_close_context() - closes a struct tee_context
600+ * @ctx: The struct tee_context to close
601+ */
602+void teedev_close_context(struct tee_context *ctx);
603+
590604 #endif /*__TEE_DRV_H*/
include/memory/renesas-rpc-if.h+7−1
@@ -57,6 +57,11 @@ struct rpcif_op { · 56 unmodified lines
5757 } data;
5858 };
5959
60+enum rpcif_type {
61+ RPCIF_RCAR_GEN3,
62+ RPCIF_RZ_G2L,
63+};
64+
6065 struct rpcif {
6166 struct device *dev;
6267 void __iomem *base;
@@ -64,6 +69,7 @@ struct rpcif { · 1 unmodified line
6469 struct regmap *regmap;
6570 struct reset_control *rstc;
6671 size_t size;
72+ enum rpcif_type type;
6773 enum rpcif_data_dir dir;
6874 u8 bus_size;
6975 void *buffer;
@@ -78,7 +84,7 @@ struct rpcif { · 8 unmodified lines
7884 };
7985
8086 int rpcif_sw_init(struct rpcif *rpc, struct device *dev);
81−void rpcif_hw_init(struct rpcif *rpc, bool hyperflash);
87+int rpcif_hw_init(struct rpcif *rpc, bool hyperflash);
8288 void rpcif_prepare(struct rpcif *rpc, const struct rpcif_op *op, u64 *offs,
8389 size_t *len);
8490 int rpcif_manual_xfer(struct rpcif *rpc);
include/soc/tegra/common.h+15−0
@@ -39,4 +39,19 @@ devm_tegra_core_dev_init_opp_table(struct device *dev, · 38 unmodified lines
3939 }
4040 #endif
4141
42+static inline int
43+devm_tegra_core_dev_init_opp_table_common(struct device *dev)
44+{
45+ struct tegra_core_opp_params opp_params = {};
46+ int err;
47+
48+ opp_params.init_state = true;
49+
50+ err = devm_tegra_core_dev_init_opp_table(dev, &opp_params);
51+ if (err != -ENODEV)
52+ return err;
53+
54+ return 0;
55+}
56+
4257 #endif /* __SOC_TEGRA_COMMON_H__ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t