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 ...
Unified · Split
| @@ -174,6 +174,7 @@ properties: · 173 unmodified lines | |||
| 174 | - qcom,kryo560 | 174 | - qcom,kryo560 |
| 175 | - qcom,kryo570 | 175 | - qcom,kryo570 |
| 176 | - qcom,kryo685 | 176 | - qcom,kryo685 |
| 177 | - qcom,kryo780 | ||
| 177 | - qcom,scorpion | 178 | - qcom,scorpion |
| 178 | 179 | ||
| 179 | enable-method: | 180 | enable-method: |
| @@ -24,6 +24,12 @@ properties: · 23 unmodified lines | |||
| 24 | compatible: | 24 | compatible: |
| 25 | const: linaro,optee-tz | 25 | const: linaro,optee-tz |
| 26 | 26 | ||
| 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 | |||
| 27 | method: | 33 | method: |
| 28 | enum: [smc, hvc] | 34 | enum: [smc, hvc] |
| 29 | description: | | 35 | description: | |
| @@ -42,10 +48,12 @@ additionalProperties: false · 12 unmodified lines | |||
| 42 | 48 | ||
| 43 | examples: | 49 | examples: |
| 44 | - | | 50 | - | |
| 51 | #include <dt-bindings/interrupt-controller/arm-gic.h> | ||
| 45 | firmware { | 52 | firmware { |
| 46 | optee { | 53 | optee { |
| 47 | compatible = "linaro,optee-tz"; | 54 | compatible = "linaro,optee-tz"; |
| 48 | method = "smc"; | 55 | method = "smc"; |
| 56 | interrupts = <GIC_SPI 187 IRQ_TYPE_EDGE_RISING>; | ||
| 49 | }; | 57 | }; |
| 50 | }; | 58 | }; |
| 51 | 59 | ||
| @@ -24,6 +24,7 @@ properties: · 23 unmodified lines | |||
| 24 | - qcom,sc7180-llcc | 24 | - qcom,sc7180-llcc |
| 25 | - qcom,sc7280-llcc | 25 | - qcom,sc7280-llcc |
| 26 | - qcom,sdm845-llcc | 26 | - qcom,sdm845-llcc |
| 27 | - qcom,sm6350-llcc | ||
| 27 | - qcom,sm8150-llcc | 28 | - qcom,sm8150-llcc |
| 28 | - qcom,sm8250-llcc | 29 | - qcom,sm8250-llcc |
| 29 | 30 | ||
| @@ -44,7 +45,6 @@ required: · 14 unmodified lines | |||
| 44 | - compatible | 45 | - compatible |
| 45 | - reg | 46 | - reg |
| 46 | - reg-names | 47 | - reg-names |
| 47 | - interrupts | ||
| 48 | 48 | ||
| 49 | additionalProperties: false | 49 | additionalProperties: false |
| 50 | 50 | ||
| @@ -50,6 +50,7 @@ description: | · 49 unmodified lines | |||
| 50 | sm8150 | 50 | sm8150 |
| 51 | sm8250 | 51 | sm8250 |
| 52 | sm8350 | 52 | sm8350 |
| 53 | sm8450 | ||
| 53 | 54 | ||
| 54 | The 'board' element must be one of the following strings: | 55 | The 'board' element must be one of the following strings: |
| 55 | 56 | ||
| @@ -257,6 +258,11 @@ properties: · 201 unmodified lines | |||
| 257 | - qcom,sm8350-mtp | 258 | - qcom,sm8350-mtp |
| 258 | - const: qcom,sm8350 | 259 | - const: qcom,sm8350 |
| 259 | 260 | ||
| 261 | - items: | ||
| 262 | - enum: | ||
| 263 | - qcom,sm8450-qrd | ||
| 264 | - const: qcom,sm8450 | ||
| 265 | |||
| 260 | additionalProperties: true | 266 | additionalProperties: true |
| 261 | 267 | ||
| 262 | ... | 268 | ... |
| @@ -26,9 +26,11 @@ Required properties: · 25 unmodified lines | |||
| 26 | * "qcom,scm-sc7280" | 26 | * "qcom,scm-sc7280" |
| 27 | * "qcom,scm-sdm845" | 27 | * "qcom,scm-sdm845" |
| 28 | * "qcom,scm-sdx55" | 28 | * "qcom,scm-sdx55" |
| 29 | * "qcom,scm-sm6350" | ||
| 29 | * "qcom,scm-sm8150" | 30 | * "qcom,scm-sm8150" |
| 30 | * "qcom,scm-sm8250" | 31 | * "qcom,scm-sm8250" |
| 31 | * "qcom,scm-sm8350" | 32 | * "qcom,scm-sm8350" |
| 33 | * "qcom,scm-sm8450" | ||
| 32 | and: | 34 | and: |
| 33 | * "qcom,scm" | 35 | * "qcom,scm" |
| 34 | - clocks: Specifies clocks needed by the SCM interface, if any: | 36 | - clocks: Specifies clocks needed by the SCM interface, if any: |
| @@ -24,17 +24,23 @@ allOf: · 23 unmodified lines | |||
| 24 | 24 | ||
| 25 | properties: | 25 | properties: |
| 26 | compatible: | 26 | compatible: |
| 27 | items: | 27 | oneOf: |
| 28 | - enum: | 28 | - items: |
| 29 | - renesas,r8a774a1-rpc-if # RZ/G2M | 29 | - enum: |
| 30 | - renesas,r8a774b1-rpc-if # RZ/G2N | 30 | - renesas,r8a774a1-rpc-if # RZ/G2M |
| 31 | - renesas,r8a774c0-rpc-if # RZ/G2E | 31 | - renesas,r8a774b1-rpc-if # RZ/G2N |
| 32 | - renesas,r8a774e1-rpc-if # RZ/G2H | 32 | - renesas,r8a774c0-rpc-if # RZ/G2E |
| 33 | - renesas,r8a77970-rpc-if # R-Car V3M | 33 | - renesas,r8a774e1-rpc-if # RZ/G2H |
| 34 | - renesas,r8a77980-rpc-if # R-Car V3H | 34 | - renesas,r8a77970-rpc-if # R-Car V3M |
| 35 | - renesas,r8a77995-rpc-if # R-Car D3 | 35 | - renesas,r8a77980-rpc-if # R-Car V3H |
| 36 | - renesas,r8a779a0-rpc-if # R-Car V3U | 36 | - renesas,r8a77995-rpc-if # R-Car D3 |
| 37 | - const: renesas,rcar-gen3-rpc-if # a generic R-Car gen3 or RZ/G2 device | 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 | ||
| 38 | 44 | ||
| 39 | reg: | 45 | reg: |
| 40 | items: | 46 | items: |
| @@ -48,7 +54,9 @@ properties: · 7 unmodified lines | |||
| 48 | - const: dirmap | 54 | - const: dirmap |
| 49 | - const: wbuf | 55 | - const: wbuf |
| 50 | 56 | ||
| 51 | clocks: | 57 | clocks: true |
| 58 | |||
| 59 | interrupts: | ||
| 52 | maxItems: 1 | 60 | maxItems: 1 |
| 53 | 61 | ||
| 54 | power-domains: | 62 | power-domains: |
| @@ -67,8 +75,6 @@ patternProperties: · 12 unmodified lines | |||
| 67 | - cfi-flash | 75 | - cfi-flash |
| 68 | - jedec,spi-nor | 76 | - jedec,spi-nor |
| 69 | 77 | ||
| 70 | unevaluatedProperties: false | ||
| 71 | |||
| 72 | required: | 78 | required: |
| 73 | - compatible | 79 | - compatible |
| 74 | - reg | 80 | - reg |
| @@ -79,6 +85,26 @@ required: · 4 unmodified lines | |||
| 79 | - '#address-cells' | 85 | - '#address-cells' |
| 80 | - '#size-cells' | 86 | - '#size-cells' |
| 81 | 87 | ||
| 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 | |||
| 82 | examples: | 108 | examples: |
| 83 | - | | 109 | - | |
| 84 | #include <dt-bindings/clock/renesas-cpg-mssr.h> | 110 | #include <dt-bindings/clock/renesas-cpg-mssr.h> |
| @@ -24,6 +24,7 @@ properties: · 23 unmodified lines | |||
| 24 | - qcom,msm8994-rpmpd | 24 | - qcom,msm8994-rpmpd |
| 25 | - qcom,msm8996-rpmpd | 25 | - qcom,msm8996-rpmpd |
| 26 | - qcom,msm8998-rpmpd | 26 | - qcom,msm8998-rpmpd |
| 27 | - qcom,qcm2290-rpmpd | ||
| 27 | - qcom,qcs404-rpmpd | 28 | - qcom,qcs404-rpmpd |
| 28 | - qcom,sdm660-rpmpd | 29 | - qcom,sdm660-rpmpd |
| 29 | - qcom,sc7180-rpmhpd | 30 | - qcom,sc7180-rpmhpd |
| @@ -32,10 +33,12 @@ properties: · 2 unmodified lines | |||
| 32 | - qcom,sdm845-rpmhpd | 33 | - qcom,sdm845-rpmhpd |
| 33 | - qcom,sdx55-rpmhpd | 34 | - qcom,sdx55-rpmhpd |
| 34 | - qcom,sm6115-rpmpd | 35 | - qcom,sm6115-rpmpd |
| 36 | - qcom,sm6125-rpmpd | ||
| 35 | - qcom,sm6350-rpmhpd | 37 | - qcom,sm6350-rpmhpd |
| 36 | - qcom,sm8150-rpmhpd | 38 | - qcom,sm8150-rpmhpd |
| 37 | - qcom,sm8250-rpmhpd | 39 | - qcom,sm8250-rpmhpd |
| 38 | - qcom,sm8350-rpmhpd | 40 | - qcom,sm8350-rpmhpd |
| 41 | - qcom,sm8450-rpmhpd | ||
| 39 | 42 | ||
| 40 | '#power-domain-cells': | 43 | '#power-domain-cells': |
| 41 | const: 1 | 44 | const: 1 |
| @@ -21,6 +21,11 @@ properties: · 20 unmodified lines | |||
| 21 | enum: | 21 | enum: |
| 22 | - qcom,rpmh-stats | 22 | - qcom,rpmh-stats |
| 23 | - qcom,rpm-stats | 23 | - 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 | ||
| 24 | 29 | ||
| 25 | reg: | 30 | reg: |
| 26 | maxItems: 1 | 31 | maxItems: 1 |
| @@ -1,7 +1,7 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | %YAML 1.2 | 2 | %YAML 1.2 |
| 3 | --- | 3 | --- |
| 4 | $id: http://devicetree.org/schemas/arm/samsung/exynos-chipid.yaml# | 4 | $id: http://devicetree.org/schemas/soc/samsung/exynos-chipid.yaml# |
| 5 | $schema: http://devicetree.org/meta-schemas/core.yaml# | 5 | $schema: http://devicetree.org/meta-schemas/core.yaml# |
| 6 | 6 | ||
| 7 | title: Samsung Exynos SoC series Chipid driver | 7 | title: Samsung Exynos SoC series Chipid driver |
| @@ -1,7 +1,7 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | %YAML 1.2 | 2 | %YAML 1.2 |
| 3 | --- | 3 | --- |
| 4 | $id: http://devicetree.org/schemas/arm/samsung/pmu.yaml# | 4 | $id: http://devicetree.org/schemas/soc/samsung/exynos-pmu.yaml# |
| 5 | $schema: http://devicetree.org/meta-schemas/core.yaml# | 5 | $schema: http://devicetree.org/meta-schemas/core.yaml# |
| 6 | 6 | ||
| 7 | title: Samsung Exynos SoC series Power Management Unit (PMU) | 7 | title: Samsung Exynos SoC series Power Management Unit (PMU) |
| @@ -24,6 +24,7 @@ select: · 16 unmodified lines | |||
| 24 | - samsung,exynos5420-pmu | 24 | - samsung,exynos5420-pmu |
| 25 | - samsung,exynos5433-pmu | 25 | - samsung,exynos5433-pmu |
| 26 | - samsung,exynos7-pmu | 26 | - samsung,exynos7-pmu |
| 27 | - samsung,exynos850-pmu | ||
| 27 | - samsung-s5pv210-pmu | 28 | - samsung-s5pv210-pmu |
| 28 | required: | 29 | required: |
| 29 | - compatible | 30 | - compatible |
| @@ -41,6 +42,7 @@ properties: · 11 unmodified lines | |||
| 41 | - samsung,exynos5420-pmu | 42 | - samsung,exynos5420-pmu |
| 42 | - samsung,exynos5433-pmu | 43 | - samsung,exynos5433-pmu |
| 43 | - samsung,exynos7-pmu | 44 | - samsung,exynos7-pmu |
| 45 | - samsung,exynos850-pmu | ||
| 44 | - samsung-s5pv210-pmu | 46 | - samsung-s5pv210-pmu |
| 45 | - const: syscon | 47 | - const: syscon |
| 46 | 48 | ||
| @@ -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 | }; | ||
| @@ -184,6 +184,36 @@ order to support device enumeration. In other words, OP-TEE driver invokes this · 183 unmodified lines | |||
| 184 | application to retrieve a list of Trusted Applications which can be registered | 184 | application to retrieve a list of Trusted Applications which can be registered |
| 185 | as devices on the TEE bus. | 185 | as devices on the TEE bus. |
| 186 | 186 | ||
| 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 | |||
| 187 | AMD-TEE driver | 217 | AMD-TEE driver |
| 188 | ============== | 218 | ============== |
| 189 | 219 | ||
| @@ -2551,6 +2551,7 @@ Q: https://patchwork.kernel.org/project/linux-samsung-soc/list/ · 2550 unmodified lines | |||
| 2551 | F: Documentation/arm/samsung/ | 2551 | F: Documentation/arm/samsung/ |
| 2552 | F: Documentation/devicetree/bindings/arm/samsung/ | 2552 | F: Documentation/devicetree/bindings/arm/samsung/ |
| 2553 | F: Documentation/devicetree/bindings/power/pd-samsung.yaml | 2553 | F: Documentation/devicetree/bindings/power/pd-samsung.yaml |
| 2554 | F: Documentation/devicetree/bindings/soc/samsung/ | ||
| 2554 | F: arch/arm/boot/dts/exynos* | 2555 | F: arch/arm/boot/dts/exynos* |
| 2555 | F: arch/arm/boot/dts/s3c* | 2556 | F: arch/arm/boot/dts/s3c* |
| 2556 | F: arch/arm/boot/dts/s5p* | 2557 | F: arch/arm/boot/dts/s5p* |
| @@ -645,6 +645,7 @@ static __init int at91_dt_ramc(bool phy_mandatory) · 644 unmodified lines | |||
| 645 | if (!soc_pm.data.ramc[idx]) { | 645 | if (!soc_pm.data.ramc[idx]) { |
| 646 | pr_err("unable to map ramc[%d] cpu registers\n", idx); | 646 | pr_err("unable to map ramc[%d] cpu registers\n", idx); |
| 647 | ret = -ENOMEM; | 647 | ret = -ENOMEM; |
| 648 | of_node_put(np); | ||
| 648 | goto unmap_ramc; | 649 | goto unmap_ramc; |
| 649 | } | 650 | } |
| 650 | 651 | ||
| @@ -670,6 +671,7 @@ static __init int at91_dt_ramc(bool phy_mandatory) · 19 unmodified lines | |||
| 670 | if (!soc_pm.data.ramc_phy) { | 671 | if (!soc_pm.data.ramc_phy) { |
| 671 | pr_err("unable to map ramc phy cpu registers\n"); | 672 | pr_err("unable to map ramc phy cpu registers\n"); |
| 672 | ret = -ENOMEM; | 673 | ret = -ENOMEM; |
| 674 | of_node_put(np); | ||
| 673 | goto unmap_ramc; | 675 | goto unmap_ramc; |
| 674 | } | 676 | } |
| 675 | } | 677 | } |
| @@ -21,6 +21,7 @@ struct imx_weim_devtype { · 20 unmodified lines | |||
| 21 | unsigned int cs_stride; | 21 | unsigned int cs_stride; |
| 22 | unsigned int wcr_offset; | 22 | unsigned int wcr_offset; |
| 23 | unsigned int wcr_bcm; | 23 | unsigned int wcr_bcm; |
| 24 | unsigned int wcr_cont_bclk; | ||
| 24 | }; | 25 | }; |
| 25 | 26 | ||
| 26 | static const struct imx_weim_devtype imx1_weim_devtype = { | 27 | 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 | |||
| 41 | .cs_stride = 0x18, | 42 | .cs_stride = 0x18, |
| 42 | .wcr_offset = 0x90, | 43 | .wcr_offset = 0x90, |
| 43 | .wcr_bcm = BIT(0), | 44 | .wcr_bcm = BIT(0), |
| 45 | .wcr_cont_bclk = BIT(3), | ||
| 44 | }; | 46 | }; |
| 45 | 47 | ||
| 46 | static const struct imx_weim_devtype imx51_weim_devtype = { | 48 | 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 | |||
| 206 | if (of_property_read_bool(pdev->dev.of_node, "fsl,burst-clk-enable")) { | 208 | if (of_property_read_bool(pdev->dev.of_node, "fsl,burst-clk-enable")) { |
| 207 | if (devtype->wcr_bcm) { | 209 | if (devtype->wcr_bcm) { |
| 208 | reg = readl(base + devtype->wcr_offset); | 210 | reg = readl(base + devtype->wcr_offset); |
| 209 | writel(reg | devtype->wcr_bcm, | 211 | reg |= devtype->wcr_bcm; |
| 210 | base + devtype->wcr_offset); | 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); | ||
| 211 | } else { | 225 | } else { |
| 212 | dev_err(&pdev->dev, "burst clk mode not supported.\n"); | 226 | dev_err(&pdev->dev, "burst clk mode not supported.\n"); |
| 213 | return -EINVAL; | 227 | return -EINVAL; |
| @@ -13,8 +13,11 @@ · 12 unmodified lines | |||
| 13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
| 14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | #include <linux/of_device.h> | 15 | #include <linux/of_device.h> |
| 16 | #include <linux/pm_runtime.h> | ||
| 16 | #include <linux/reset.h> | 17 | #include <linux/reset.h> |
| 17 | 18 | ||
| 19 | #include <soc/tegra/common.h> | ||
| 20 | |||
| 18 | #define TEGRA_GMI_CONFIG 0x00 | 21 | #define TEGRA_GMI_CONFIG 0x00 |
| 19 | #define TEGRA_GMI_CONFIG_GO BIT(31) | 22 | #define TEGRA_GMI_CONFIG_GO BIT(31) |
| 20 | #define TEGRA_GMI_BUS_WIDTH_32BIT BIT(30) | 23 | #define TEGRA_GMI_BUS_WIDTH_32BIT BIT(30) |
| @@ -54,9 +57,10 @@ static int tegra_gmi_enable(struct tegra_gmi *gmi) · 33 unmodified lines | |||
| 54 | { | 57 | { |
| 55 | int err; | 58 | int err; |
| 56 | 59 | ||
| 57 | err = clk_prepare_enable(gmi->clk); | 60 | pm_runtime_enable(gmi->dev); |
| 58 | if (err < 0) { | 61 | err = pm_runtime_resume_and_get(gmi->dev); |
| 59 | dev_err(gmi->dev, "failed to enable clock: %d\n", err); | 62 | if (err) { |
| 63 | pm_runtime_disable(gmi->dev); | ||
| 60 | return err; | 64 | return err; |
| 61 | } | 65 | } |
| 62 | 66 | ||
| @@ -83,7 +87,9 @@ static void tegra_gmi_disable(struct tegra_gmi *gmi) · 20 unmodified lines | |||
| 83 | writel(config, gmi->base + TEGRA_GMI_CONFIG); | 87 | writel(config, gmi->base + TEGRA_GMI_CONFIG); |
| 84 | 88 | ||
| 85 | reset_control_assert(gmi->rst); | 89 | 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); | ||
| 87 | } | 93 | } |
| 88 | 94 | ||
| 89 | static int tegra_gmi_parse_dt(struct tegra_gmi *gmi) | 95 | 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 | |||
| 213 | if (!gmi) | 219 | if (!gmi) |
| 214 | return -ENOMEM; | 220 | return -ENOMEM; |
| 215 | 221 | ||
| 222 | platform_set_drvdata(pdev, gmi); | ||
| 216 | gmi->dev = dev; | 223 | gmi->dev = dev; |
| 217 | 224 | ||
| 218 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 225 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| @@ -232,6 +239,10 @@ static int tegra_gmi_probe(struct platform_device *pdev) · 13 unmodified lines | |||
| 232 | return PTR_ERR(gmi->rst); | 239 | return PTR_ERR(gmi->rst); |
| 233 | } | 240 | } |
| 234 | 241 | ||
| 242 | err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); | ||
| 243 | if (err) | ||
| 244 | return err; | ||
| 245 | |||
| 235 | err = tegra_gmi_parse_dt(gmi); | 246 | err = tegra_gmi_parse_dt(gmi); |
| 236 | if (err) | 247 | if (err) |
| 237 | return err; | 248 | return err; |
| @@ -247,8 +258,6 @@ static int tegra_gmi_probe(struct platform_device *pdev) · 9 unmodified lines | |||
| 247 | return err; | 258 | return err; |
| 248 | } | 259 | } |
| 249 | 260 | ||
| 250 | platform_set_drvdata(pdev, gmi); | ||
| 251 | |||
| 252 | return 0; | 261 | return 0; |
| 253 | } | 262 | } |
| 254 | 263 | ||
| @@ -262,6 +271,34 @@ static int tegra_gmi_remove(struct platform_device *pdev) · 7 unmodified lines | |||
| 262 | return 0; | 271 | return 0; |
| 263 | } | 272 | } |
| 264 | 273 | ||
| 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 | |||
| 265 | static const struct of_device_id tegra_gmi_id_table[] = { | 302 | static const struct of_device_id tegra_gmi_id_table[] = { |
| 266 | { .compatible = "nvidia,tegra20-gmi", }, | 303 | { .compatible = "nvidia,tegra20-gmi", }, |
| 267 | { .compatible = "nvidia,tegra30-gmi", }, | 304 | { .compatible = "nvidia,tegra30-gmi", }, |
| @@ -275,6 +312,7 @@ static struct platform_driver tegra_gmi_driver = { · 7 unmodified lines | |||
| 275 | .driver = { | 312 | .driver = { |
| 276 | .name = "tegra-gmi", | 313 | .name = "tegra-gmi", |
| 277 | .of_match_table = tegra_gmi_id_table, | 314 | .of_match_table = tegra_gmi_id_table, |
| 315 | .pm = &tegra_gmi_pm, | ||
| 278 | }, | 316 | }, |
| 279 | }; | 317 | }; |
| 280 | module_platform_driver(tegra_gmi_driver); | 318 | module_platform_driver(tegra_gmi_driver); |
| @@ -1759,7 +1759,7 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, · 1758 unmodified lines | |||
| 1759 | desc->num = resp->range_num; | 1759 | desc->num = resp->range_num; |
| 1760 | desc->start_sec = resp->range_start_sec; | 1760 | desc->start_sec = resp->range_start_sec; |
| 1761 | desc->num_sec = resp->range_num_sec; | 1761 | desc->num_sec = resp->range_num_sec; |
| 1762 | }; | 1762 | } |
| 1763 | 1763 | ||
| 1764 | fail: | 1764 | fail: |
| 1765 | ti_sci_put_one_xfer(&info->minfo, xfer); | 1765 | ti_sci_put_one_xfer(&info->minfo, xfer); |
| @@ -1434,7 +1434,10 @@ static int zynqmp_firmware_probe(struct platform_device *pdev) · 1433 unmodified lines | |||
| 1434 | return ret; | 1434 | return ret; |
| 1435 | 1435 | ||
| 1436 | /* Check PM API version number */ | 1436 | /* 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 | |||
| 1438 | if (pm_api_version < ZYNQMP_PM_VERSION) { | 1441 | if (pm_api_version < ZYNQMP_PM_VERSION) { |
| 1439 | panic("%s Platform Management API version error. Expected: v%d.%d - Found: v%d.%d\n", | 1442 | panic("%s Platform Management API version error. Expected: v%d.%d - Found: v%d.%d\n", |
| 1440 | __func__, | 1443 | __func__, |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | |||
| 12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
| 15 | #include <linux/of_device.h> | ||
| 15 | #include <linux/regmap.h> | 16 | #include <linux/regmap.h> |
| 16 | #include <linux/reset.h> | 17 | #include <linux/reset.h> |
| 17 | 18 | ||
| @@ -19,19 +20,17 @@ · 1 unmodified line | |||
| 19 | 20 | ||
| 20 | #define RPCIF_CMNCR 0x0000 /* R/W */ | 21 | #define RPCIF_CMNCR 0x0000 /* R/W */ |
| 21 | #define RPCIF_CMNCR_MD BIT(31) | 22 | #define RPCIF_CMNCR_MD BIT(31) |
| 22 | #define RPCIF_CMNCR_SFDE BIT(24) /* undocumented but must be set */ | ||
| 23 | #define RPCIF_CMNCR_MOIIO3(val) (((val) & 0x3) << 22) | 23 | #define RPCIF_CMNCR_MOIIO3(val) (((val) & 0x3) << 22) |
| 24 | #define RPCIF_CMNCR_MOIIO2(val) (((val) & 0x3) << 20) | 24 | #define RPCIF_CMNCR_MOIIO2(val) (((val) & 0x3) << 20) |
| 25 | #define RPCIF_CMNCR_MOIIO1(val) (((val) & 0x3) << 18) | 25 | #define RPCIF_CMNCR_MOIIO1(val) (((val) & 0x3) << 18) |
| 26 | #define RPCIF_CMNCR_MOIIO0(val) (((val) & 0x3) << 16) | 26 | #define RPCIF_CMNCR_MOIIO0(val) (((val) & 0x3) << 16) |
| 27 | #define RPCIF_CMNCR_MOIIO_HIZ (RPCIF_CMNCR_MOIIO0(3) | \ | 27 | #define RPCIF_CMNCR_MOIIO(val) (RPCIF_CMNCR_MOIIO0(val) | RPCIF_CMNCR_MOIIO1(val) | \ |
| 28 | RPCIF_CMNCR_MOIIO1(3) | \ | 28 | RPCIF_CMNCR_MOIIO2(val) | RPCIF_CMNCR_MOIIO3(val)) |
| 29 | RPCIF_CMNCR_MOIIO2(3) | RPCIF_CMNCR_MOIIO3(3)) | 29 | #define RPCIF_CMNCR_IO3FV(val) (((val) & 0x3) << 14) /* documented for RZ/G2L */ |
| 30 | #define RPCIF_CMNCR_IO3FV(val) (((val) & 0x3) << 14) /* undocumented */ | 30 | #define RPCIF_CMNCR_IO2FV(val) (((val) & 0x3) << 12) /* documented for RZ/G2L */ |
| 31 | #define RPCIF_CMNCR_IO2FV(val) (((val) & 0x3) << 12) /* undocumented */ | ||
| 32 | #define RPCIF_CMNCR_IO0FV(val) (((val) & 0x3) << 8) | 31 | #define RPCIF_CMNCR_IO0FV(val) (((val) & 0x3) << 8) |
| 33 | #define RPCIF_CMNCR_IOFV_HIZ (RPCIF_CMNCR_IO0FV(3) | RPCIF_CMNCR_IO2FV(3) | \ | 32 | #define RPCIF_CMNCR_IOFV(val) (RPCIF_CMNCR_IO0FV(val) | RPCIF_CMNCR_IO2FV(val) | \ |
| 34 | RPCIF_CMNCR_IO3FV(3)) | 33 | RPCIF_CMNCR_IO3FV(val)) |
| 35 | #define RPCIF_CMNCR_BSZ(val) (((val) & 0x3) << 0) | 34 | #define RPCIF_CMNCR_BSZ(val) (((val) & 0x3) << 0) |
| 36 | 35 | ||
| 37 | #define RPCIF_SSLDR 0x0004 /* R/W */ | 36 | #define RPCIF_SSLDR 0x0004 /* R/W */ |
| @@ -126,6 +125,9 @@ · 88 unmodified lines | |||
| 126 | #define RPCIF_SMDRENR_OPDRE BIT(4) | 125 | #define RPCIF_SMDRENR_OPDRE BIT(4) |
| 127 | #define RPCIF_SMDRENR_SPIDRE BIT(0) | 126 | #define RPCIF_SMDRENR_SPIDRE BIT(0) |
| 128 | 127 | ||
| 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 | |||
| 129 | #define RPCIF_PHYCNT 0x007C /* R/W */ | 131 | #define RPCIF_PHYCNT 0x007C /* R/W */ |
| 130 | #define RPCIF_PHYCNT_CAL BIT(31) | 132 | #define RPCIF_PHYCNT_CAL BIT(31) |
| 131 | #define RPCIF_PHYCNT_OCTA(v) (((v) & 0x3) << 22) | 133 | #define RPCIF_PHYCNT_OCTA(v) (((v) & 0x3) << 22) |
| @@ -133,10 +135,12 @@ · 1 unmodified line | |||
| 133 | #define RPCIF_PHYCNT_OCT BIT(20) | 135 | #define RPCIF_PHYCNT_OCT BIT(20) |
| 134 | #define RPCIF_PHYCNT_DDRCAL BIT(19) | 136 | #define RPCIF_PHYCNT_DDRCAL BIT(19) |
| 135 | #define RPCIF_PHYCNT_HS BIT(18) | 137 | #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} */ | ||
| 137 | #define RPCIF_PHYCNT_WBUF2 BIT(4) | 140 | #define RPCIF_PHYCNT_WBUF2 BIT(4) |
| 138 | #define RPCIF_PHYCNT_WBUF BIT(2) | 141 | #define RPCIF_PHYCNT_WBUF BIT(2) |
| 139 | #define RPCIF_PHYCNT_PHYMEM(v) (((v) & 0x3) << 0) | 142 | #define RPCIF_PHYCNT_PHYMEM(v) (((v) & 0x3) << 0) |
| 143 | #define RPCIF_PHYCNT_PHYMEM_MASK GENMASK(1, 0) | ||
| 140 | 144 | ||
| 141 | #define RPCIF_PHYOFFSET1 0x0080 /* R/W */ | 145 | #define RPCIF_PHYOFFSET1 0x0080 /* R/W */ |
| 142 | #define RPCIF_PHYOFFSET1_DDRTMG(v) (((v) & 0x3) << 28) | 146 | #define RPCIF_PHYOFFSET1_DDRTMG(v) (((v) & 0x3) << 28) |
| @@ -147,8 +151,6 @@ · 4 unmodified lines | |||
| 147 | #define RPCIF_PHYINT 0x0088 /* R/W */ | 151 | #define RPCIF_PHYINT 0x0088 /* R/W */ |
| 148 | #define RPCIF_PHYINT_WPVAL BIT(1) | 152 | #define RPCIF_PHYINT_WPVAL BIT(1) |
| 149 | 153 | ||
| 150 | #define RPCIF_DIRMAP_SIZE 0x4000000 | ||
| 151 | |||
| 152 | static const struct regmap_range rpcif_volatile_ranges[] = { | 154 | static const struct regmap_range rpcif_volatile_ranges[] = { |
| 153 | regmap_reg_range(RPCIF_SMRDR0, RPCIF_SMRDR1), | 155 | regmap_reg_range(RPCIF_SMRDR0, RPCIF_SMRDR1), |
| 154 | regmap_reg_range(RPCIF_SMWDR0, RPCIF_SMWDR1), | 156 | regmap_reg_range(RPCIF_SMWDR0, RPCIF_SMWDR1), |
| @@ -243,50 +245,74 @@ int rpcif_sw_init(struct rpcif *rpc, struct device *dev) · 88 unmodified lines | |||
| 243 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dirmap"); | 245 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dirmap"); |
| 244 | rpc->dirmap = devm_ioremap_resource(&pdev->dev, res); | 246 | rpc->dirmap = devm_ioremap_resource(&pdev->dev, res); |
| 245 | if (IS_ERR(rpc->dirmap)) | 247 | if (IS_ERR(rpc->dirmap)) |
| 246 | rpc->dirmap = NULL; | 248 | return PTR_ERR(rpc->dirmap); |
| 247 | rpc->size = resource_size(res); | 249 | rpc->size = resource_size(res); |
| 248 | 250 | ||
| 251 | rpc->type = (uintptr_t)of_device_get_match_data(dev); | ||
| 249 | rpc->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); | 252 | rpc->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); |
| 250 | 253 | ||
| 251 | return PTR_ERR_OR_ZERO(rpc->rstc); | 254 | return PTR_ERR_OR_ZERO(rpc->rstc); |
| 252 | } | 255 | } |
| 253 | EXPORT_SYMBOL(rpcif_sw_init); | 256 | EXPORT_SYMBOL(rpcif_sw_init); |
| 254 | 257 | ||
| 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) | ||
| 256 | { | 273 | { |
| 257 | u32 dummy; | 274 | u32 dummy; |
| 258 | 275 | ||
| 259 | pm_runtime_get_sync(rpc->dev); | 276 | pm_runtime_get_sync(rpc->dev); |
| 260 | 277 | ||
| 261 | /* | 278 | if (rpc->type == RPCIF_RZ_G2L) { |
| 262 | * NOTE: The 0x260 are undocumented bits, but they must be set. | 279 | int ret; |
| 263 | * RPCIF_PHYCNT_STRTIM is strobe timing adjustment bits, | 280 | |
| 264 | * 0x0 : the delay is biggest, | 281 | ret = reset_control_reset(rpc->rstc); |
| 265 | * 0x1 : the delay is 2nd biggest, | 282 | if (ret) |
| 266 | * On H3 ES1.x, the value should be 0, while on others, | 283 | return ret; |
| 267 | * the value should be 7. | 284 | usleep_range(200, 300); |
| 268 | */ | 285 | rpcif_rzg2l_timing_adjust_sdr(rpc); |
| 269 | regmap_write(rpc->regmap, RPCIF_PHYCNT, RPCIF_PHYCNT_STRTIM(7) | | 286 | } |
| 270 | RPCIF_PHYCNT_PHYMEM(hyperflash ? 3 : 0) | 0x260); | 287 | |
| 271 | 288 | regmap_update_bits(rpc->regmap, RPCIF_PHYCNT, RPCIF_PHYCNT_PHYMEM_MASK, | |
| 272 | /* | 289 | RPCIF_PHYCNT_PHYMEM(hyperflash ? 3 : 0)); |
| 273 | * NOTE: The 0x1511144 are undocumented bits, but they must be set | 290 | |
| 274 | * for RPCIF_PHYOFFSET1. | 291 | if (rpc->type == RPCIF_RCAR_GEN3) |
| 275 | * The 0x31 are undocumented bits, but they must be set | 292 | regmap_update_bits(rpc->regmap, RPCIF_PHYCNT, |
| 276 | * for RPCIF_PHYOFFSET2. | 293 | RPCIF_PHYCNT_STRTIM(7), RPCIF_PHYCNT_STRTIM(7)); |
| 277 | */ | 294 | |
| 278 | regmap_write(rpc->regmap, RPCIF_PHYOFFSET1, 0x1511144 | | 295 | regmap_update_bits(rpc->regmap, RPCIF_PHYOFFSET1, RPCIF_PHYOFFSET1_DDRTMG(3), |
| 279 | RPCIF_PHYOFFSET1_DDRTMG(3)); | 296 | RPCIF_PHYOFFSET1_DDRTMG(3)); |
| 280 | regmap_write(rpc->regmap, RPCIF_PHYOFFSET2, 0x31 | | 297 | regmap_update_bits(rpc->regmap, RPCIF_PHYOFFSET2, RPCIF_PHYOFFSET2_OCTTMG(7), |
| 281 | RPCIF_PHYOFFSET2_OCTTMG(4)); | 298 | RPCIF_PHYOFFSET2_OCTTMG(4)); |
| 282 | 299 | ||
| 283 | if (hyperflash) | 300 | if (hyperflash) |
| 284 | regmap_update_bits(rpc->regmap, RPCIF_PHYINT, | 301 | regmap_update_bits(rpc->regmap, RPCIF_PHYINT, |
| 285 | RPCIF_PHYINT_WPVAL, 0); | 302 | RPCIF_PHYINT_WPVAL, 0); |
| 286 | 303 | ||
| 287 | regmap_write(rpc->regmap, RPCIF_CMNCR, RPCIF_CMNCR_SFDE | | 304 | if (rpc->type == RPCIF_RCAR_GEN3) |
| 288 | RPCIF_CMNCR_MOIIO_HIZ | RPCIF_CMNCR_IOFV_HIZ | | 305 | regmap_update_bits(rpc->regmap, RPCIF_CMNCR, |
| 289 | RPCIF_CMNCR_BSZ(hyperflash ? 1 : 0)); | 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 | |||
| 290 | /* Set RCF after BSZ update */ | 316 | /* Set RCF after BSZ update */ |
| 291 | regmap_write(rpc->regmap, RPCIF_DRCR, RPCIF_DRCR_RCF); | 317 | regmap_write(rpc->regmap, RPCIF_DRCR, RPCIF_DRCR_RCF); |
| 292 | /* Dummy read according to spec */ | 318 | /* Dummy read according to spec */ |
| @@ -297,6 +323,8 @@ void rpcif_hw_init(struct rpcif *rpc, bool hyperflash) · 4 unmodified lines | |||
| 297 | pm_runtime_put(rpc->dev); | 323 | pm_runtime_put(rpc->dev); |
| 298 | 324 | ||
| 299 | rpc->bus_size = hyperflash ? 2 : 1; | 325 | rpc->bus_size = hyperflash ? 2 : 1; |
| 326 | |||
| 327 | return 0; | ||
| 300 | } | 328 | } |
| 301 | EXPORT_SYMBOL(rpcif_hw_init); | 329 | EXPORT_SYMBOL(rpcif_hw_init); |
| 302 | 330 | ||
| @@ -588,8 +616,8 @@ static void memcpy_fromio_readw(void *to, · 285 unmodified lines | |||
| 588 | 616 | ||
| 589 | ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs, size_t len, void *buf) | 617 | ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs, size_t len, void *buf) |
| 590 | { | 618 | { |
| 591 | loff_t from = offs & (RPCIF_DIRMAP_SIZE - 1); | 619 | loff_t from = offs & (rpc->size - 1); |
| 592 | size_t size = RPCIF_DIRMAP_SIZE - from; | 620 | size_t size = rpc->size - from; |
| 593 | 621 | ||
| 594 | if (len > size) | 622 | if (len > size) |
| 595 | len = size; | 623 | len = size; |
| @@ -659,7 +687,8 @@ static int rpcif_remove(struct platform_device *pdev) · 63 unmodified lines | |||
| 659 | } | 687 | } |
| 660 | 688 | ||
| 661 | static const struct of_device_id rpcif_of_match[] = { | 689 | 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 }, | ||
| 663 | {}, | 692 | {}, |
| 664 | }; | 693 | }; |
| 665 | MODULE_DEVICE_TABLE(of, rpcif_of_match); | 694 | MODULE_DEVICE_TABLE(of, rpcif_of_match); |
| @@ -15,6 +15,8 @@ · 14 unmodified lines | |||
| 15 | #include <linux/of.h> | 15 | #include <linux/of.h> |
| 16 | #include <linux/of_device.h> | 16 | #include <linux/of_device.h> |
| 17 | #include <linux/pinctrl/consumer.h> | 17 | #include <linux/pinctrl/consumer.h> |
| 18 | #include <linux/pm_opp.h> | ||
| 19 | #include <linux/pm_runtime.h> | ||
| 18 | #include <linux/regulator/consumer.h> | 20 | #include <linux/regulator/consumer.h> |
| 19 | #include <linux/reset.h> | 21 | #include <linux/reset.h> |
| 20 | #include <linux/mmc/card.h> | 22 | #include <linux/mmc/card.h> |
| @@ -24,6 +26,8 @@ · 3 unmodified lines | |||
| 24 | #include <linux/gpio/consumer.h> | 26 | #include <linux/gpio/consumer.h> |
| 25 | #include <linux/ktime.h> | 27 | #include <linux/ktime.h> |
| 26 | 28 | ||
| 29 | #include <soc/tegra/common.h> | ||
| 30 | |||
| 27 | #include "sdhci-pltfm.h" | 31 | #include "sdhci-pltfm.h" |
| 28 | #include "cqhci.h" | 32 | #include "cqhci.h" |
| 29 | 33 | ||
| @@ -743,7 +747,9 @@ static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) · 713 unmodified lines | |||
| 743 | { | 747 | { |
| 744 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 748 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 745 | struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host); | 749 | struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host); |
| 750 | struct device *dev = mmc_dev(host->mmc); | ||
| 746 | unsigned long host_clk; | 751 | unsigned long host_clk; |
| 752 | int err; | ||
| 747 | 753 | ||
| 748 | if (!clock) | 754 | if (!clock) |
| 749 | return sdhci_set_clock(host, clock); | 755 | 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 | |||
| 761 | * from clk_get_rate() is used. | 767 | * from clk_get_rate() is used. |
| 762 | */ | 768 | */ |
| 763 | host_clk = tegra_host->ddr_signaling ? clock * 2 : clock; | 769 | 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 | |||
| 765 | tegra_host->curr_clk_rate = host_clk; | 776 | tegra_host->curr_clk_rate = host_clk; |
| 766 | if (tegra_host->ddr_signaling) | 777 | if (tegra_host->ddr_signaling) |
| 767 | host->max_clk = host_clk; | 778 | host->max_clk = host_clk; |
| @@ -1714,7 +1725,6 @@ static int sdhci_tegra_probe(struct platform_device *pdev) · 946 unmodified lines | |||
| 1714 | "failed to get clock\n"); | 1725 | "failed to get clock\n"); |
| 1715 | goto err_clk_get; | 1726 | goto err_clk_get; |
| 1716 | } | 1727 | } |
| 1717 | clk_prepare_enable(clk); | ||
| 1718 | pltfm_host->clk = clk; | 1728 | pltfm_host->clk = clk; |
| 1719 | 1729 | ||
| 1720 | tegra_host->rst = devm_reset_control_get_exclusive(&pdev->dev, | 1730 | 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 | |||
| 1725 | goto err_rst_get; | 1735 | goto err_rst_get; |
| 1726 | } | 1736 | } |
| 1727 | 1737 | ||
| 1728 | rc = reset_control_assert(tegra_host->rst); | 1738 | rc = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); |
| 1729 | if (rc) | 1739 | if (rc) |
| 1730 | goto err_rst_get; | 1740 | goto err_rst_get; |
| 1731 | 1741 | ||
| 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 | |||
| 1732 | usleep_range(2000, 4000); | 1751 | usleep_range(2000, 4000); |
| 1733 | 1752 | ||
| 1734 | rc = reset_control_deassert(tegra_host->rst); | 1753 | rc = reset_control_deassert(tegra_host->rst); |
| 1735 | if (rc) | 1754 | if (rc) |
| 1736 | goto err_rst_get; | 1755 | goto err_rst_assert; |
| 1737 | 1756 | ||
| 1738 | usleep_range(2000, 4000); | 1757 | usleep_range(2000, 4000); |
| 1739 | 1758 | ||
| @@ -1745,8 +1764,11 @@ static int sdhci_tegra_probe(struct platform_device *pdev) · 5 unmodified lines | |||
| 1745 | 1764 | ||
| 1746 | err_add_host: | 1765 | err_add_host: |
| 1747 | reset_control_assert(tegra_host->rst); | 1766 | 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); | ||
| 1748 | err_rst_get: | 1771 | err_rst_get: |
| 1749 | clk_disable_unprepare(pltfm_host->clk); | ||
| 1750 | err_clk_get: | 1772 | err_clk_get: |
| 1751 | clk_disable_unprepare(tegra_host->tmclk); | 1773 | clk_disable_unprepare(tegra_host->tmclk); |
| 1752 | err_power_req: | 1774 | err_power_req: |
| @@ -1765,19 +1787,38 @@ static int sdhci_tegra_remove(struct platform_device *pdev) · 12 unmodified lines | |||
| 1765 | 1787 | ||
| 1766 | reset_control_assert(tegra_host->rst); | 1788 | reset_control_assert(tegra_host->rst); |
| 1767 | usleep_range(2000, 4000); | 1789 | usleep_range(2000, 4000); |
| 1768 | clk_disable_unprepare(pltfm_host->clk); | ||
| 1769 | clk_disable_unprepare(tegra_host->tmclk); | ||
| 1770 | 1790 | ||
| 1791 | pm_runtime_put_sync_suspend(&pdev->dev); | ||
| 1792 | pm_runtime_force_suspend(&pdev->dev); | ||
| 1793 | |||
| 1794 | clk_disable_unprepare(tegra_host->tmclk); | ||
| 1771 | sdhci_pltfm_free(pdev); | 1795 | sdhci_pltfm_free(pdev); |
| 1772 | 1796 | ||
| 1773 | return 0; | 1797 | return 0; |
| 1774 | } | 1798 | } |
| 1775 | 1799 | ||
| 1776 | #ifdef CONFIG_PM_SLEEP | 1800 | static int __maybe_unused sdhci_tegra_runtime_suspend(struct device *dev) |
| 1777 | static int __maybe_unused sdhci_tegra_suspend(struct device *dev) | ||
| 1778 | { | 1801 | { |
| 1779 | struct sdhci_host *host = dev_get_drvdata(dev); | 1802 | struct sdhci_host *host = dev_get_drvdata(dev); |
| 1780 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 1803 | 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); | ||
| 1781 | int ret; | 1822 | int ret; |
| 1782 | 1823 | ||
| 1783 | if (host->mmc->caps2 & MMC_CAP2_CQE) { | 1824 | if (host->mmc->caps2 & MMC_CAP2_CQE) { |
| @@ -1792,17 +1833,22 @@ static int __maybe_unused sdhci_tegra_suspend(struct device *dev) · 8 unmodified lines | |||
| 1792 | return ret; | 1833 | return ret; |
| 1793 | } | 1834 | } |
| 1794 | 1835 | ||
| 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 | |||
| 1796 | return 0; | 1843 | return 0; |
| 1797 | } | 1844 | } |
| 1798 | 1845 | ||
| 1799 | static int __maybe_unused sdhci_tegra_resume(struct device *dev) | 1846 | static int sdhci_tegra_resume(struct device *dev) |
| 1800 | { | 1847 | { |
| 1801 | struct sdhci_host *host = dev_get_drvdata(dev); | 1848 | struct sdhci_host *host = dev_get_drvdata(dev); |
| 1802 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | ||
| 1803 | int ret; | 1849 | int ret; |
| 1804 | 1850 | ||
| 1805 | ret = clk_prepare_enable(pltfm_host->clk); | 1851 | ret = pm_runtime_force_resume(dev); |
| 1806 | if (ret) | 1852 | if (ret) |
| 1807 | return ret; | 1853 | return ret; |
| 1808 | 1854 | ||
| @@ -1821,13 +1867,16 @@ static int __maybe_unused sdhci_tegra_resume(struct device *dev) · 12 unmodified lines | |||
| 1821 | suspend_host: | 1867 | suspend_host: |
| 1822 | sdhci_suspend_host(host); | 1868 | sdhci_suspend_host(host); |
| 1823 | disable_clk: | 1869 | disable_clk: |
| 1824 | clk_disable_unprepare(pltfm_host->clk); | 1870 | pm_runtime_force_suspend(dev); |
| 1825 | return ret; | 1871 | return ret; |
| 1826 | } | 1872 | } |
| 1827 | #endif | 1873 | #endif |
| 1828 | 1874 | ||
| 1829 | static SIMPLE_DEV_PM_OPS(sdhci_tegra_dev_pm_ops, sdhci_tegra_suspend, | 1875 | static const struct dev_pm_ops sdhci_tegra_dev_pm_ops = { |
| 1830 | sdhci_tegra_resume); | 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 | }; | ||
| 1831 | 1880 | ||
| 1832 | static struct platform_driver sdhci_tegra_driver = { | 1881 | static struct platform_driver sdhci_tegra_driver = { |
| 1833 | .driver = { | 1882 | .driver = { |
| @@ -130,7 +130,9 @@ static int rpcif_hb_probe(struct platform_device *pdev) · 129 unmodified lines | |||
| 130 | 130 | ||
| 131 | rpcif_enable_rpm(&hyperbus->rpc); | 131 | rpcif_enable_rpm(&hyperbus->rpc); |
| 132 | 132 | ||
| 133 | rpcif_hw_init(&hyperbus->rpc, true); | 133 | error = rpcif_hw_init(&hyperbus->rpc, true); |
| 134 | if (error) | ||
| 135 | return error; | ||
| 134 | 136 | ||
| 135 | hyperbus->hbdev.map.size = hyperbus->rpc.size; | 137 | hyperbus->hbdev.map.size = hyperbus->rpc.size; |
| 136 | hyperbus->hbdev.map.virt = hyperbus->rpc.dirmap; | 138 | hyperbus->hbdev.map.virt = hyperbus->rpc.dirmap; |
| @@ -17,8 +17,11 @@ · 16 unmodified lines | |||
| 17 | #include <linux/mtd/rawnand.h> | 17 | #include <linux/mtd/rawnand.h> |
| 18 | #include <linux/of.h> | 18 | #include <linux/of.h> |
| 19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/pm_runtime.h> | ||
| 20 | #include <linux/reset.h> | 21 | #include <linux/reset.h> |
| 21 | 22 | ||
| 23 | #include <soc/tegra/common.h> | ||
| 24 | |||
| 22 | #define COMMAND 0x00 | 25 | #define COMMAND 0x00 |
| 23 | #define COMMAND_GO BIT(31) | 26 | #define COMMAND_GO BIT(31) |
| 24 | #define COMMAND_CLE BIT(30) | 27 | #define COMMAND_CLE BIT(30) |
| @@ -1151,6 +1154,7 @@ static int tegra_nand_probe(struct platform_device *pdev) · 1126 unmodified lines | |||
| 1151 | return -ENOMEM; | 1154 | return -ENOMEM; |
| 1152 | 1155 | ||
| 1153 | ctrl->dev = &pdev->dev; | 1156 | ctrl->dev = &pdev->dev; |
| 1157 | platform_set_drvdata(pdev, ctrl); | ||
| 1154 | nand_controller_init(&ctrl->controller); | 1158 | nand_controller_init(&ctrl->controller); |
| 1155 | ctrl->controller.ops = &tegra_nand_controller_ops; | 1159 | ctrl->controller.ops = &tegra_nand_controller_ops; |
| 1156 | 1160 | ||
| @@ -1166,14 +1170,23 @@ static int tegra_nand_probe(struct platform_device *pdev) · 9 unmodified lines | |||
| 1166 | if (IS_ERR(ctrl->clk)) | 1170 | if (IS_ERR(ctrl->clk)) |
| 1167 | return PTR_ERR(ctrl->clk); | 1171 | return PTR_ERR(ctrl->clk); |
| 1168 | 1172 | ||
| 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); | ||
| 1170 | if (err) | 1183 | if (err) |
| 1171 | return err; | 1184 | return err; |
| 1172 | 1185 | ||
| 1173 | err = reset_control_reset(rst); | 1186 | err = reset_control_reset(rst); |
| 1174 | if (err) { | 1187 | if (err) { |
| 1175 | dev_err(ctrl->dev, "Failed to reset HW: %d\n", err); | 1188 | dev_err(ctrl->dev, "Failed to reset HW: %d\n", err); |
| 1176 | goto err_disable_clk; | 1189 | goto err_put_pm; |
| 1177 | } | 1190 | } |
| 1178 | 1191 | ||
| 1179 | writel_relaxed(HWSTATUS_CMD_DEFAULT, ctrl->regs + HWSTATUS_CMD); | 1192 | 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 | |||
| 1188 | dev_name(&pdev->dev), ctrl); | 1201 | dev_name(&pdev->dev), ctrl); |
| 1189 | if (err) { | 1202 | if (err) { |
| 1190 | dev_err(ctrl->dev, "Failed to get IRQ: %d\n", err); | 1203 | dev_err(ctrl->dev, "Failed to get IRQ: %d\n", err); |
| 1191 | goto err_disable_clk; | 1204 | goto err_put_pm; |
| 1192 | } | 1205 | } |
| 1193 | 1206 | ||
| 1194 | writel_relaxed(DMA_MST_CTRL_IS_DONE, ctrl->regs + DMA_MST_CTRL); | 1207 | writel_relaxed(DMA_MST_CTRL_IS_DONE, ctrl->regs + DMA_MST_CTRL); |
| 1195 | 1208 | ||
| 1196 | err = tegra_nand_chips_init(ctrl->dev, ctrl); | 1209 | err = tegra_nand_chips_init(ctrl->dev, ctrl); |
| 1197 | if (err) | 1210 | if (err) |
| 1198 | goto err_disable_clk; | 1211 | goto err_put_pm; |
| 1199 | |||
| 1200 | platform_set_drvdata(pdev, ctrl); | ||
| 1201 | 1212 | ||
| 1202 | return 0; | 1213 | return 0; |
| 1203 | 1214 | ||
| 1204 | err_disable_clk: | 1215 | err_put_pm: |
| 1205 | clk_disable_unprepare(ctrl->clk); | 1216 | pm_runtime_put_sync_suspend(ctrl->dev); |
| 1217 | pm_runtime_force_suspend(ctrl->dev); | ||
| 1206 | return err; | 1218 | return err; |
| 1207 | } | 1219 | } |
| 1208 | 1220 | ||
| @@ -1219,11 +1231,40 @@ static int tegra_nand_remove(struct platform_device *pdev) · 10 unmodified lines | |||
| 1219 | 1231 | ||
| 1220 | nand_cleanup(chip); | 1232 | nand_cleanup(chip); |
| 1221 | 1233 | ||
| 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 | |||
| 1222 | clk_disable_unprepare(ctrl->clk); | 1258 | clk_disable_unprepare(ctrl->clk); |
| 1223 | 1259 | ||
| 1224 | return 0; | 1260 | return 0; |
| 1225 | } | 1261 | } |
| 1226 | 1262 | ||
| 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 | |||
| 1227 | static const struct of_device_id tegra_nand_of_match[] = { | 1268 | static const struct of_device_id tegra_nand_of_match[] = { |
| 1228 | { .compatible = "nvidia,tegra20-nand" }, | 1269 | { .compatible = "nvidia,tegra20-nand" }, |
| 1229 | { /* sentinel */ } | 1270 | { /* sentinel */ } |
| @@ -1234,6 +1275,7 @@ static struct platform_driver tegra_nand_driver = { · 4 unmodified lines | |||
| 1234 | .driver = { | 1275 | .driver = { |
| 1235 | .name = "tegra-nand", | 1276 | .name = "tegra-nand", |
| 1236 | .of_match_table = tegra_nand_of_match, | 1277 | .of_match_table = tegra_nand_of_match, |
| 1278 | .pm = &tegra_nand_pm, | ||
| 1237 | }, | 1279 | }, |
| 1238 | .probe = tegra_nand_probe, | 1280 | .probe = tegra_nand_probe, |
| 1239 | .remove = tegra_nand_remove, | 1281 | .remove = tegra_nand_remove, |
| @@ -42,12 +42,16 @@ · 41 unmodified lines | |||
| 42 | #include <linux/module.h> | 42 | #include <linux/module.h> |
| 43 | #include <linux/of.h> | 43 | #include <linux/of.h> |
| 44 | #include <linux/of_device.h> | 44 | #include <linux/of_device.h> |
| 45 | #include <linux/pm_opp.h> | ||
| 45 | #include <linux/pwm.h> | 46 | #include <linux/pwm.h> |
| 46 | #include <linux/platform_device.h> | 47 | #include <linux/platform_device.h> |
| 47 | #include <linux/pinctrl/consumer.h> | 48 | #include <linux/pinctrl/consumer.h> |
| 49 | #include <linux/pm_runtime.h> | ||
| 48 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
| 49 | #include <linux/reset.h> | 51 | #include <linux/reset.h> |
| 50 | 52 | ||
| 53 | #include <soc/tegra/common.h> | ||
| 54 | |||
| 51 | #define PWM_ENABLE (1 << 31) | 55 | #define PWM_ENABLE (1 << 31) |
| 52 | #define PWM_DUTY_WIDTH 8 | 56 | #define PWM_DUTY_WIDTH 8 |
| 53 | #define PWM_DUTY_SHIFT 16 | 57 | #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 | |||
| 145 | required_clk_rate = | 149 | required_clk_rate = |
| 146 | (NSEC_PER_SEC / period_ns) << PWM_DUTY_WIDTH; | 150 | (NSEC_PER_SEC / period_ns) << PWM_DUTY_WIDTH; |
| 147 | 151 | ||
| 148 | err = clk_set_rate(pc->clk, required_clk_rate); | 152 | err = dev_pm_opp_set_rate(pc->dev, required_clk_rate); |
| 149 | if (err < 0) | 153 | if (err < 0) |
| 150 | return -EINVAL; | 154 | return -EINVAL; |
| 151 | 155 | ||
| @@ -181,8 +185,8 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, · 29 unmodified lines | |||
| 181 | * before writing the register. Otherwise, keep it enabled. | 185 | * before writing the register. Otherwise, keep it enabled. |
| 182 | */ | 186 | */ |
| 183 | if (!pwm_is_enabled(pwm)) { | 187 | if (!pwm_is_enabled(pwm)) { |
| 184 | err = clk_prepare_enable(pc->clk); | 188 | err = pm_runtime_resume_and_get(pc->dev); |
| 185 | if (err < 0) | 189 | if (err) |
| 186 | return err; | 190 | return err; |
| 187 | } else | 191 | } else |
| 188 | val |= PWM_ENABLE; | 192 | val |= PWM_ENABLE; |
| @@ -193,7 +197,7 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, · 4 unmodified lines | |||
| 193 | * If the PWM is not enabled, turn the clock off again to save power. | 197 | * If the PWM is not enabled, turn the clock off again to save power. |
| 194 | */ | 198 | */ |
| 195 | if (!pwm_is_enabled(pwm)) | 199 | if (!pwm_is_enabled(pwm)) |
| 196 | clk_disable_unprepare(pc->clk); | 200 | pm_runtime_put(pc->dev); |
| 197 | 201 | ||
| 198 | return 0; | 202 | return 0; |
| 199 | } | 203 | } |
| @@ -204,8 +208,8 @@ static int tegra_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) · 4 unmodified lines | |||
| 204 | int rc = 0; | 208 | int rc = 0; |
| 205 | u32 val; | 209 | u32 val; |
| 206 | 210 | ||
| 207 | rc = clk_prepare_enable(pc->clk); | 211 | rc = pm_runtime_resume_and_get(pc->dev); |
| 208 | if (rc < 0) | 212 | if (rc) |
| 209 | return rc; | 213 | return rc; |
| 210 | 214 | ||
| 211 | val = pwm_readl(pc, pwm->hwpwm); | 215 | 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 | |||
| 224 | val &= ~PWM_ENABLE; | 228 | val &= ~PWM_ENABLE; |
| 225 | pwm_writel(pc, pwm->hwpwm, val); | 229 | pwm_writel(pc, pwm->hwpwm, val); |
| 226 | 230 | ||
| 227 | clk_disable_unprepare(pc->clk); | 231 | pm_runtime_put_sync(pc->dev); |
| 228 | } | 232 | } |
| 229 | 233 | ||
| 230 | static const struct pwm_ops tegra_pwm_ops = { | 234 | static const struct pwm_ops tegra_pwm_ops = { |
| @@ -256,11 +260,20 @@ static int tegra_pwm_probe(struct platform_device *pdev) · 25 unmodified lines | |||
| 256 | if (IS_ERR(pwm->clk)) | 260 | if (IS_ERR(pwm->clk)) |
| 257 | return PTR_ERR(pwm->clk); | 261 | return PTR_ERR(pwm->clk); |
| 258 | 262 | ||
| 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 | |||
| 259 | /* Set maximum frequency of the IP */ | 272 | /* 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); |
| 261 | if (ret < 0) { | 274 | if (ret < 0) { |
| 262 | dev_err(&pdev->dev, "Failed to set max frequency: %d\n", ret); | 275 | dev_err(&pdev->dev, "Failed to set max frequency: %d\n", ret); |
| 263 | return ret; | 276 | goto put_pm; |
| 264 | } | 277 | } |
| 265 | 278 | ||
| 266 | /* | 279 | /* |
| @@ -278,7 +291,7 @@ static int tegra_pwm_probe(struct platform_device *pdev) · 11 unmodified lines | |||
| 278 | if (IS_ERR(pwm->rst)) { | 291 | if (IS_ERR(pwm->rst)) { |
| 279 | ret = PTR_ERR(pwm->rst); | 292 | ret = PTR_ERR(pwm->rst); |
| 280 | dev_err(&pdev->dev, "Reset control is not found: %d\n", ret); | 293 | dev_err(&pdev->dev, "Reset control is not found: %d\n", ret); |
| 281 | return ret; | 294 | goto put_pm; |
| 282 | } | 295 | } |
| 283 | 296 | ||
| 284 | reset_control_deassert(pwm->rst); | 297 | reset_control_deassert(pwm->rst); |
| @@ -291,10 +304,16 @@ static int tegra_pwm_probe(struct platform_device *pdev) · 6 unmodified lines | |||
| 291 | if (ret < 0) { | 304 | if (ret < 0) { |
| 292 | dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); | 305 | dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); |
| 293 | reset_control_assert(pwm->rst); | 306 | reset_control_assert(pwm->rst); |
| 294 | return ret; | 307 | goto put_pm; |
| 295 | } | 308 | } |
| 296 | 309 | ||
| 310 | pm_runtime_put(&pdev->dev); | ||
| 311 | |||
| 297 | return 0; | 312 | return 0; |
| 313 | put_pm: | ||
| 314 | pm_runtime_put_sync_suspend(&pdev->dev); | ||
| 315 | pm_runtime_force_suspend(&pdev->dev); | ||
| 316 | return ret; | ||
| 298 | } | 317 | } |
| 299 | 318 | ||
| 300 | static int tegra_pwm_remove(struct platform_device *pdev) | 319 | 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 | |||
| 305 | 324 | ||
| 306 | reset_control_assert(pc->rst); | 325 | reset_control_assert(pc->rst); |
| 307 | 326 | ||
| 327 | pm_runtime_force_suspend(&pdev->dev); | ||
| 328 | |||
| 308 | return 0; | 329 | return 0; |
| 309 | } | 330 | } |
| 310 | 331 | ||
| 311 | #ifdef CONFIG_PM_SLEEP | 332 | static int __maybe_unused tegra_pwm_runtime_suspend(struct device *dev) |
| 312 | static int tegra_pwm_suspend(struct device *dev) | ||
| 313 | { | 333 | { |
| 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; | ||
| 315 | } | 346 | } |
| 316 | 347 | ||
| 317 | static int tegra_pwm_resume(struct device *dev) | 348 | static int __maybe_unused tegra_pwm_runtime_resume(struct device *dev) |
| 318 | { | 349 | { |
| 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; | ||
| 320 | } | 364 | } |
| 321 | #endif | ||
| 322 | 365 | ||
| 323 | static const struct tegra_pwm_soc tegra20_pwm_soc = { | 366 | static const struct tegra_pwm_soc tegra20_pwm_soc = { |
| 324 | .num_channels = 4, | 367 | .num_channels = 4, |
| @@ -344,7 +387,10 @@ static const struct of_device_id tegra_pwm_of_match[] = { · 19 unmodified lines | |||
| 344 | MODULE_DEVICE_TABLE(of, tegra_pwm_of_match); | 387 | MODULE_DEVICE_TABLE(of, tegra_pwm_of_match); |
| 345 | 388 | ||
| 346 | static const struct dev_pm_ops tegra_pwm_pm_ops = { | 389 | 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) | ||
| 348 | }; | 394 | }; |
| 349 | 395 | ||
| 350 | static struct platform_driver tegra_pwm_driver = { | 396 | static struct platform_driver tegra_pwm_driver = { |
| @@ -3,6 +3,7 @@ menu "SOC (System On Chip) specific Drivers" · 2 unmodified lines | |||
| 3 | 3 | ||
| 4 | source "drivers/soc/actions/Kconfig" | 4 | source "drivers/soc/actions/Kconfig" |
| 5 | source "drivers/soc/amlogic/Kconfig" | 5 | source "drivers/soc/amlogic/Kconfig" |
| 6 | source "drivers/soc/apple/Kconfig" | ||
| 6 | source "drivers/soc/aspeed/Kconfig" | 7 | source "drivers/soc/aspeed/Kconfig" |
| 7 | source "drivers/soc/atmel/Kconfig" | 8 | source "drivers/soc/atmel/Kconfig" |
| 8 | source "drivers/soc/bcm/Kconfig" | 9 | source "drivers/soc/bcm/Kconfig" |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | |||
| 4 | # | 4 | # |
| 5 | 5 | ||
| 6 | obj-$(CONFIG_ARCH_ACTIONS) += actions/ | 6 | obj-$(CONFIG_ARCH_ACTIONS) += actions/ |
| 7 | obj-$(CONFIG_ARCH_APPLE) += apple/ | ||
| 7 | obj-y += aspeed/ | 8 | obj-y += aspeed/ |
| 8 | obj-$(CONFIG_ARCH_AT91) += atmel/ | 9 | obj-$(CONFIG_ARCH_AT91) += atmel/ |
| 9 | obj-y += bcm/ | 10 | obj-y += bcm/ |
| @@ -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 | ||
| @@ -0,0 +1,2 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 2 | obj-$(CONFIG_APPLE_PMGR_PWRSTATE) += apple-pmgr-pwrstate.o | ||
| @@ -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, ®); | ||
| 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, ®); | ||
| 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, ®); | ||
| 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); | ||
| @@ -377,7 +377,7 @@ static int imx_pgc_power_down(struct generic_pm_domain *genpd) · 376 unmodified lines | |||
| 377 | } | 377 | } |
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | pm_runtime_put(domain->dev); | 380 | pm_runtime_put_sync_suspend(domain->dev); |
| 381 | 381 | ||
| 382 | return 0; | 382 | return 0; |
| 383 | 383 | ||
| @@ -734,6 +734,7 @@ static const struct imx_pgc_domain imx8mm_pgc_domains[] = { · 350 unmodified lines | |||
| 734 | .map = IMX8MM_VPUH1_A53_DOMAIN, | 734 | .map = IMX8MM_VPUH1_A53_DOMAIN, |
| 735 | }, | 735 | }, |
| 736 | .pgc = BIT(IMX8MM_PGC_VPUH1), | 736 | .pgc = BIT(IMX8MM_PGC_VPUH1), |
| 737 | .keep_clocks = true, | ||
| 737 | }, | 738 | }, |
| 738 | 739 | ||
| 739 | [IMX8MM_POWER_DOMAIN_DISPMIX] = { | 740 | [IMX8MM_POWER_DOMAIN_DISPMIX] = { |
| @@ -840,6 +841,32 @@ static const struct imx_pgc_domain imx8mn_pgc_domains[] = { · 100 unmodified lines | |||
| 840 | .hskack = IMX8MN_GPUMIX_HSK_PWRDNACKN, | 841 | .hskack = IMX8MN_GPUMIX_HSK_PWRDNACKN, |
| 841 | }, | 842 | }, |
| 842 | .pgc = BIT(IMX8MN_PGC_GPUMIX), | 843 | .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), | ||
| 843 | }, | 870 | }, |
| 844 | }; | 871 | }; |
| 845 | 872 | ||
| @@ -14,6 +14,7 @@ · 13 unmodified lines | |||
| 14 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
| 15 | 15 | ||
| 16 | #include <dt-bindings/power/imx8mm-power.h> | 16 | #include <dt-bindings/power/imx8mm-power.h> |
| 17 | #include <dt-bindings/power/imx8mn-power.h> | ||
| 17 | 18 | ||
| 18 | #define BLK_SFT_RSTN 0x0 | 19 | #define BLK_SFT_RSTN 0x0 |
| 19 | #define BLK_CLK_EN 0x4 | 20 | #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 | |||
| 517 | .num_domains = ARRAY_SIZE(imx8mm_disp_blk_ctl_domain_data), | 518 | .num_domains = ARRAY_SIZE(imx8mm_disp_blk_ctl_domain_data), |
| 518 | }; | 519 | }; |
| 519 | 520 | ||
| 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 | |||
| 520 | static const struct of_device_id imx8m_blk_ctrl_of_match[] = { | 592 | static const struct of_device_id imx8m_blk_ctrl_of_match[] = { |
| 521 | { | 593 | { |
| 522 | .compatible = "fsl,imx8mm-vpu-blk-ctrl", | 594 | .compatible = "fsl,imx8mm-vpu-blk-ctrl", |
| @@ -524,7 +596,10 @@ static const struct of_device_id imx8m_blk_ctrl_of_match[] = { · 1 unmodified line | |||
| 524 | }, { | 596 | }, { |
| 525 | .compatible = "fsl,imx8mm-disp-blk-ctrl", | 597 | .compatible = "fsl,imx8mm-disp-blk-ctrl", |
| 526 | .data = &imx8mm_disp_blk_ctl_dev_data | 598 | .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 | }, { | ||
| 528 | /* Sentinel */ | 603 | /* Sentinel */ |
| 529 | } | 604 | } |
| 530 | }; | 605 | }; |
| @@ -1010,7 +1010,7 @@ static int cpr_interpolate(const struct corner *corner, int step_volt, · 1009 unmodified lines | |||
| 1010 | return corner->uV; | 1010 | return corner->uV; |
| 1011 | 1011 | ||
| 1012 | temp = f_diff * (uV_high - uV_low); | 1012 | temp = f_diff * (uV_high - uV_low); |
| 1013 | do_div(temp, f_high - f_low); | 1013 | temp = div64_ul(temp, f_high - f_low); |
| 1014 | 1014 | ||
| 1015 | /* | 1015 | /* |
| 1016 | * max_volt_scale has units of uV/MHz while freq values | 1016 | * max_volt_scale has units of uV/MHz while freq values |
| @@ -195,6 +195,28 @@ static const struct llcc_slice_config sm8250_data[] = { · 194 unmodified lines | |||
| 195 | { LLCC_WRCACHE, 31, 256, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 }, | 195 | { LLCC_WRCACHE, 31, 256, 1, 1, 0xfff, 0x0, 0, 0, 0, 0, 1, 0 }, |
| 196 | }; | 196 | }; |
| 197 | 197 | ||
| 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 | |||
| 198 | static const struct qcom_llcc_config sc7180_cfg = { | 220 | static const struct qcom_llcc_config sc7180_cfg = { |
| 199 | .sct_data = sc7180_data, | 221 | .sct_data = sc7180_data, |
| 200 | .size = ARRAY_SIZE(sc7180_data), | 222 | .size = ARRAY_SIZE(sc7180_data), |
| @@ -228,6 +250,11 @@ static const struct qcom_llcc_config sm8250_cfg = { · 27 unmodified lines | |||
| 228 | .size = ARRAY_SIZE(sm8250_data), | 250 | .size = ARRAY_SIZE(sm8250_data), |
| 229 | }; | 251 | }; |
| 230 | 252 | ||
| 253 | static const struct qcom_llcc_config sm8350_cfg = { | ||
| 254 | .sct_data = sm8350_data, | ||
| 255 | .size = ARRAY_SIZE(sm8350_data), | ||
| 256 | }; | ||
| 257 | |||
| 231 | static struct llcc_drv_data *drv_data = (void *) -EPROBE_DEFER; | 258 | static struct llcc_drv_data *drv_data = (void *) -EPROBE_DEFER; |
| 232 | 259 | ||
| 233 | /** | 260 | /** |
| @@ -644,6 +671,7 @@ static const struct of_device_id qcom_llcc_of_match[] = { · 410 unmodified lines | |||
| 644 | { .compatible = "qcom,sm6350-llcc", .data = &sm6350_cfg }, | 671 | { .compatible = "qcom,sm6350-llcc", .data = &sm6350_cfg }, |
| 645 | { .compatible = "qcom,sm8150-llcc", .data = &sm8150_cfg }, | 672 | { .compatible = "qcom,sm8150-llcc", .data = &sm8150_cfg }, |
| 646 | { .compatible = "qcom,sm8250-llcc", .data = &sm8250_cfg }, | 673 | { .compatible = "qcom,sm8250-llcc", .data = &sm8250_cfg }, |
| 674 | { .compatible = "qcom,sm8350-llcc", .data = &sm8350_cfg }, | ||
| 647 | { } | 675 | { } |
| 648 | }; | 676 | }; |
| 649 | 677 | ||
| @@ -352,7 +352,7 @@ static int qmp_cdev_set_cur_state(struct thermal_cooling_device *cdev, · 351 unmodified lines | |||
| 352 | return ret; | 352 | return ret; |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | static struct thermal_cooling_device_ops qmp_cooling_device_ops = { | 355 | static const struct thermal_cooling_device_ops qmp_cooling_device_ops = { |
| 356 | .get_max_state = qmp_cdev_get_max_state, | 356 | .get_max_state = qmp_cdev_get_max_state, |
| 357 | .get_cur_state = qmp_cdev_get_cur_state, | 357 | .get_cur_state = qmp_cdev_get_cur_state, |
| 358 | .set_cur_state = qmp_cdev_set_cur_state, | 358 | .set_cur_state = qmp_cdev_set_cur_state, |
| @@ -237,6 +237,15 @@ static const struct stats_config rpm_data = { · 236 unmodified lines | |||
| 237 | .subsystem_stats_in_smem = false, | 237 | .subsystem_stats_in_smem = false, |
| 238 | }; | 238 | }; |
| 239 | 239 | ||
| 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 | |||
| 240 | static const struct stats_config rpmh_data = { | 249 | static const struct stats_config rpmh_data = { |
| 241 | .stats_offset = 0x48, | 250 | .stats_offset = 0x48, |
| 242 | .num_records = 3, | 251 | .num_records = 3, |
| @@ -246,6 +255,10 @@ static const struct stats_config rpmh_data = { · 3 unmodified lines | |||
| 246 | }; | 255 | }; |
| 247 | 256 | ||
| 248 | static const struct of_device_id qcom_stats_table[] = { | 257 | 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 }, | ||
| 249 | { .compatible = "qcom,rpm-stats", .data = &rpm_data }, | 262 | { .compatible = "qcom,rpm-stats", .data = &rpm_data }, |
| 250 | { .compatible = "qcom,rpmh-stats", .data = &rpmh_data }, | 263 | { .compatible = "qcom,rpmh-stats", .data = &rpmh_data }, |
| 251 | { } | 264 | { } |
| @@ -96,7 +96,7 @@ static void qmi_recv_del_server(struct qmi_handle *qmi, · 95 unmodified lines | |||
| 96 | * @node: id of the dying node | 96 | * @node: id of the dying node |
| 97 | * | 97 | * |
| 98 | * Signals the client that all previously registered services on this node are | 98 | * 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 |
| 100 | * cleaning up resources associated with this remote. | 100 | * cleaning up resources associated with this remote. |
| 101 | */ | 101 | */ |
| 102 | static void qmi_recv_bye(struct qmi_handle *qmi, | 102 | static void qmi_recv_bye(struct qmi_handle *qmi, |
| @@ -691,7 +691,7 @@ static int find_slots(struct tcs_group *tcs, const struct tcs_request *msg, · 690 unmodified lines | |||
| 691 | * @drv: The controller. | 691 | * @drv: The controller. |
| 692 | * @msg: The data to be written to the controller. | 692 | * @msg: The data to be written to the controller. |
| 693 | * | 693 | * |
| 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 |
| 695 | * state. | 695 | * state. |
| 696 | * | 696 | * |
| 697 | * The caller must ensure that no other RPMH actions are happening and the | 697 | * The caller must ensure that no other RPMH actions are happening and the |
| @@ -63,73 +63,134 @@ struct rpmhpd_desc { · 62 unmodified lines | |||
| 63 | 63 | ||
| 64 | static DEFINE_MUTEX(rpmhpd_lock); | 64 | static DEFINE_MUTEX(rpmhpd_lock); |
| 65 | 65 | ||
| 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 | }; | ||
| 67 | 83 | ||
| 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 = { | ||
| 69 | .pd = { .name = "ebi", }, | 101 | .pd = { .name = "ebi", }, |
| 70 | .res_name = "ebi.lvl", | 102 | .res_name = "ebi.lvl", |
| 71 | }; | 103 | }; |
| 72 | 104 | ||
| 73 | static struct rpmhpd sdm845_lmx = { | 105 | static struct rpmhpd gfx = { |
| 74 | .pd = { .name = "lmx", }, | 106 | .pd = { .name = "gfx", }, |
| 75 | .res_name = "lmx.lvl", | 107 | .res_name = "gfx.lvl", |
| 76 | }; | 108 | }; |
| 77 | 109 | ||
| 78 | static struct rpmhpd sdm845_lcx = { | 110 | static struct rpmhpd lcx = { |
| 79 | .pd = { .name = "lcx", }, | 111 | .pd = { .name = "lcx", }, |
| 80 | .res_name = "lcx.lvl", | 112 | .res_name = "lcx.lvl", |
| 81 | }; | 113 | }; |
| 82 | 114 | ||
| 83 | static struct rpmhpd sdm845_gfx = { | 115 | static struct rpmhpd lmx = { |
| 84 | .pd = { .name = "gfx", }, | 116 | .pd = { .name = "lmx", }, |
| 85 | .res_name = "gfx.lvl", | 117 | .res_name = "lmx.lvl", |
| 86 | }; | 118 | }; |
| 87 | 119 | ||
| 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 = { | ||
| 89 | .pd = { .name = "mss", }, | 151 | .pd = { .name = "mss", }, |
| 90 | .res_name = "mss.lvl", | 152 | .res_name = "mss.lvl", |
| 91 | }; | 153 | }; |
| 92 | 154 | ||
| 93 | static struct rpmhpd sdm845_mx_ao; | 155 | static struct rpmhpd mx_ao; |
| 94 | static struct rpmhpd sdm845_mx = { | 156 | static struct rpmhpd mx = { |
| 95 | .pd = { .name = "mx", }, | 157 | .pd = { .name = "mx", }, |
| 96 | .peer = &sdm845_mx_ao, | 158 | .peer = &mx_ao, |
| 97 | .res_name = "mx.lvl", | 159 | .res_name = "mx.lvl", |
| 98 | }; | 160 | }; |
| 99 | 161 | ||
| 100 | static struct rpmhpd sdm845_mx_ao = { | 162 | static struct rpmhpd mx_ao = { |
| 101 | .pd = { .name = "mx_ao", }, | 163 | .pd = { .name = "mx_ao", }, |
| 102 | .active_only = true, | 164 | .active_only = true, |
| 103 | .peer = &sdm845_mx, | 165 | .peer = &mx, |
| 104 | .res_name = "mx.lvl", | 166 | .res_name = "mx.lvl", |
| 105 | }; | 167 | }; |
| 106 | 168 | ||
| 107 | static struct rpmhpd sdm845_cx_ao; | 169 | static struct rpmhpd mxc_ao; |
| 108 | static struct rpmhpd sdm845_cx = { | 170 | static struct rpmhpd mxc = { |
| 109 | .pd = { .name = "cx", }, | 171 | .pd = { .name = "mxc", }, |
| 110 | .peer = &sdm845_cx_ao, | 172 | .peer = &mxc_ao, |
| 111 | .parent = &sdm845_mx.pd, | 173 | .res_name = "mxc.lvl", |
| 112 | .res_name = "cx.lvl", | ||
| 113 | }; | 174 | }; |
| 114 | 175 | ||
| 115 | static struct rpmhpd sdm845_cx_ao = { | 176 | static struct rpmhpd mxc_ao = { |
| 116 | .pd = { .name = "cx_ao", }, | 177 | .pd = { .name = "mxc_ao", }, |
| 117 | .active_only = true, | 178 | .active_only = true, |
| 118 | .peer = &sdm845_cx, | 179 | .peer = &mxc, |
| 119 | .parent = &sdm845_mx_ao.pd, | 180 | .res_name = "mxc.lvl", |
| 120 | .res_name = "cx.lvl", | ||
| 121 | }; | 181 | }; |
| 122 | 182 | ||
| 183 | /* SDM845 RPMH powerdomains */ | ||
| 123 | static struct rpmhpd *sdm845_rpmhpds[] = { | 184 | static struct rpmhpd *sdm845_rpmhpds[] = { |
| 124 | [SDM845_EBI] = &sdm845_ebi, | 185 | [SDM845_CX] = &cx_w_mx_parent, |
| 125 | [SDM845_MX] = &sdm845_mx, | 186 | [SDM845_CX_AO] = &cx_ao_w_mx_parent, |
| 126 | [SDM845_MX_AO] = &sdm845_mx_ao, | 187 | [SDM845_EBI] = &ebi, |
| 127 | [SDM845_CX] = &sdm845_cx, | 188 | [SDM845_GFX] = &gfx, |
| 128 | [SDM845_CX_AO] = &sdm845_cx_ao, | 189 | [SDM845_LCX] = &lcx, |
| 129 | [SDM845_LMX] = &sdm845_lmx, | 190 | [SDM845_LMX] = &lmx, |
| 130 | [SDM845_LCX] = &sdm845_lcx, | 191 | [SDM845_MSS] = &mss, |
| 131 | [SDM845_GFX] = &sdm845_gfx, | 192 | [SDM845_MX] = &mx, |
| 132 | [SDM845_MSS] = &sdm845_mss, | 193 | [SDM845_MX_AO] = &mx_ao, |
| 133 | }; | 194 | }; |
| 134 | 195 | ||
| 135 | static const struct rpmhpd_desc sdm845_desc = { | 196 | static const struct rpmhpd_desc sdm845_desc = { |
| @@ -139,9 +200,9 @@ static const struct rpmhpd_desc sdm845_desc = { · 3 unmodified lines | |||
| 139 | 200 | ||
| 140 | /* SDX55 RPMH powerdomains */ | 201 | /* SDX55 RPMH powerdomains */ |
| 141 | static struct rpmhpd *sdx55_rpmhpds[] = { | 202 | static struct rpmhpd *sdx55_rpmhpds[] = { |
| 142 | [SDX55_MSS] = &sdm845_mss, | 203 | [SDX55_CX] = &cx_w_mx_parent, |
| 143 | [SDX55_MX] = &sdm845_mx, | 204 | [SDX55_MSS] = &mss, |
| 144 | [SDX55_CX] = &sdm845_cx, | 205 | [SDX55_MX] = &mx, |
| 145 | }; | 206 | }; |
| 146 | 207 | ||
| 147 | static const struct rpmhpd_desc sdx55_desc = { | 208 | static const struct rpmhpd_desc sdx55_desc = { |
| @@ -151,12 +212,12 @@ static const struct rpmhpd_desc sdx55_desc = { · 3 unmodified lines | |||
| 151 | 212 | ||
| 152 | /* SM6350 RPMH powerdomains */ | 213 | /* SM6350 RPMH powerdomains */ |
| 153 | static struct rpmhpd *sm6350_rpmhpds[] = { | 214 | static struct rpmhpd *sm6350_rpmhpds[] = { |
| 154 | [SM6350_CX] = &sdm845_cx, | 215 | [SM6350_CX] = &cx_w_mx_parent, |
| 155 | [SM6350_GFX] = &sdm845_gfx, | 216 | [SM6350_GFX] = &gfx, |
| 156 | [SM6350_LCX] = &sdm845_lcx, | 217 | [SM6350_LCX] = &lcx, |
| 157 | [SM6350_LMX] = &sdm845_lmx, | 218 | [SM6350_LMX] = &lmx, |
| 158 | [SM6350_MSS] = &sdm845_mss, | 219 | [SM6350_MSS] = &mss, |
| 159 | [SM6350_MX] = &sdm845_mx, | 220 | [SM6350_MX] = &mx, |
| 160 | }; | 221 | }; |
| 161 | 222 | ||
| 162 | static const struct rpmhpd_desc sm6350_desc = { | 223 | static const struct rpmhpd_desc sm6350_desc = { |
| @@ -165,33 +226,18 @@ static const struct rpmhpd_desc sm6350_desc = { · 2 unmodified lines | |||
| 165 | }; | 226 | }; |
| 166 | 227 | ||
| 167 | /* SM8150 RPMH powerdomains */ | 228 | /* 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 | |||
| 183 | static struct rpmhpd *sm8150_rpmhpds[] = { | 229 | static struct rpmhpd *sm8150_rpmhpds[] = { |
| 184 | [SM8150_MSS] = &sdm845_mss, | 230 | [SM8150_CX] = &cx_w_mx_parent, |
| 185 | [SM8150_EBI] = &sdm845_ebi, | 231 | [SM8150_CX_AO] = &cx_ao_w_mx_parent, |
| 186 | [SM8150_LMX] = &sdm845_lmx, | 232 | [SM8150_EBI] = &ebi, |
| 187 | [SM8150_LCX] = &sdm845_lcx, | 233 | [SM8150_GFX] = &gfx, |
| 188 | [SM8150_GFX] = &sdm845_gfx, | 234 | [SM8150_LCX] = &lcx, |
| 189 | [SM8150_MX] = &sdm845_mx, | 235 | [SM8150_LMX] = &lmx, |
| 190 | [SM8150_MX_AO] = &sdm845_mx_ao, | 236 | [SM8150_MMCX] = &mmcx, |
| 191 | [SM8150_CX] = &sdm845_cx, | 237 | [SM8150_MMCX_AO] = &mmcx_ao, |
| 192 | [SM8150_CX_AO] = &sdm845_cx_ao, | 238 | [SM8150_MSS] = &mss, |
| 193 | [SM8150_MMCX] = &sm8150_mmcx, | 239 | [SM8150_MX] = &mx, |
| 194 | [SM8150_MMCX_AO] = &sm8150_mmcx_ao, | 240 | [SM8150_MX_AO] = &mx_ao, |
| 195 | }; | 241 | }; |
| 196 | 242 | ||
| 197 | static const struct rpmhpd_desc sm8150_desc = { | 243 | static const struct rpmhpd_desc sm8150_desc = { |
| @@ -199,17 +245,18 @@ static const struct rpmhpd_desc sm8150_desc = { · 1 unmodified line | |||
| 199 | .num_pds = ARRAY_SIZE(sm8150_rpmhpds), | 245 | .num_pds = ARRAY_SIZE(sm8150_rpmhpds), |
| 200 | }; | 246 | }; |
| 201 | 247 | ||
| 248 | /* SM8250 RPMH powerdomains */ | ||
| 202 | static struct rpmhpd *sm8250_rpmhpds[] = { | 249 | static struct rpmhpd *sm8250_rpmhpds[] = { |
| 203 | [SM8250_CX] = &sdm845_cx, | 250 | [SM8250_CX] = &cx_w_mx_parent, |
| 204 | [SM8250_CX_AO] = &sdm845_cx_ao, | 251 | [SM8250_CX_AO] = &cx_ao_w_mx_parent, |
| 205 | [SM8250_EBI] = &sdm845_ebi, | 252 | [SM8250_EBI] = &ebi, |
| 206 | [SM8250_GFX] = &sdm845_gfx, | 253 | [SM8250_GFX] = &gfx, |
| 207 | [SM8250_LCX] = &sdm845_lcx, | 254 | [SM8250_LCX] = &lcx, |
| 208 | [SM8250_LMX] = &sdm845_lmx, | 255 | [SM8250_LMX] = &lmx, |
| 209 | [SM8250_MMCX] = &sm8150_mmcx, | 256 | [SM8250_MMCX] = &mmcx, |
| 210 | [SM8250_MMCX_AO] = &sm8150_mmcx_ao, | 257 | [SM8250_MMCX_AO] = &mmcx_ao, |
| 211 | [SM8250_MX] = &sdm845_mx, | 258 | [SM8250_MX] = &mx, |
| 212 | [SM8250_MX_AO] = &sdm845_mx_ao, | 259 | [SM8250_MX_AO] = &mx_ao, |
| 213 | }; | 260 | }; |
| 214 | 261 | ||
| 215 | static const struct rpmhpd_desc sm8250_desc = { | 262 | static const struct rpmhpd_desc sm8250_desc = { |
| @@ -218,34 +265,20 @@ static const struct rpmhpd_desc sm8250_desc = { · 2 unmodified lines | |||
| 218 | }; | 265 | }; |
| 219 | 266 | ||
| 220 | /* SM8350 Power domains */ | 267 | /* 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 | |||
| 235 | static struct rpmhpd *sm8350_rpmhpds[] = { | 268 | static struct rpmhpd *sm8350_rpmhpds[] = { |
| 236 | [SM8350_CX] = &sdm845_cx, | 269 | [SM8350_CX] = &cx_w_mx_parent, |
| 237 | [SM8350_CX_AO] = &sdm845_cx_ao, | 270 | [SM8350_CX_AO] = &cx_ao_w_mx_parent, |
| 238 | [SM8350_EBI] = &sdm845_ebi, | 271 | [SM8350_EBI] = &ebi, |
| 239 | [SM8350_GFX] = &sdm845_gfx, | 272 | [SM8350_GFX] = &gfx, |
| 240 | [SM8350_LCX] = &sdm845_lcx, | 273 | [SM8350_LCX] = &lcx, |
| 241 | [SM8350_LMX] = &sdm845_lmx, | 274 | [SM8350_LMX] = &lmx, |
| 242 | [SM8350_MMCX] = &sm8150_mmcx, | 275 | [SM8350_MMCX] = &mmcx, |
| 243 | [SM8350_MMCX_AO] = &sm8150_mmcx_ao, | 276 | [SM8350_MMCX_AO] = &mmcx_ao, |
| 244 | [SM8350_MX] = &sdm845_mx, | 277 | [SM8350_MSS] = &mss, |
| 245 | [SM8350_MX_AO] = &sdm845_mx_ao, | 278 | [SM8350_MX] = &mx, |
| 246 | [SM8350_MXC] = &sm8350_mxc, | 279 | [SM8350_MX_AO] = &mx_ao, |
| 247 | [SM8350_MXC_AO] = &sm8350_mxc_ao, | 280 | [SM8350_MXC] = &mxc, |
| 248 | [SM8350_MSS] = &sdm845_mss, | 281 | [SM8350_MXC_AO] = &mxc_ao, |
| 249 | }; | 282 | }; |
| 250 | 283 | ||
| 251 | static const struct rpmhpd_desc sm8350_desc = { | 284 | static const struct rpmhpd_desc sm8350_desc = { |
| @@ -253,16 +286,38 @@ static const struct rpmhpd_desc sm8350_desc = { · 1 unmodified line | |||
| 253 | .num_pds = ARRAY_SIZE(sm8350_rpmhpds), | 286 | .num_pds = ARRAY_SIZE(sm8350_rpmhpds), |
| 254 | }; | 287 | }; |
| 255 | 288 | ||
| 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 | |||
| 256 | /* SC7180 RPMH powerdomains */ | 311 | /* SC7180 RPMH powerdomains */ |
| 257 | static struct rpmhpd *sc7180_rpmhpds[] = { | 312 | static struct rpmhpd *sc7180_rpmhpds[] = { |
| 258 | [SC7180_CX] = &sdm845_cx, | 313 | [SC7180_CX] = &cx_w_mx_parent, |
| 259 | [SC7180_CX_AO] = &sdm845_cx_ao, | 314 | [SC7180_CX_AO] = &cx_ao_w_mx_parent, |
| 260 | [SC7180_GFX] = &sdm845_gfx, | 315 | [SC7180_GFX] = &gfx, |
| 261 | [SC7180_MX] = &sdm845_mx, | 316 | [SC7180_LCX] = &lcx, |
| 262 | [SC7180_MX_AO] = &sdm845_mx_ao, | 317 | [SC7180_LMX] = &lmx, |
| 263 | [SC7180_LMX] = &sdm845_lmx, | 318 | [SC7180_MSS] = &mss, |
| 264 | [SC7180_LCX] = &sdm845_lcx, | 319 | [SC7180_MX] = &mx, |
| 265 | [SC7180_MSS] = &sdm845_mss, | 320 | [SC7180_MX_AO] = &mx_ao, |
| 266 | }; | 321 | }; |
| 267 | 322 | ||
| 268 | static const struct rpmhpd_desc sc7180_desc = { | 323 | static const struct rpmhpd_desc sc7180_desc = { |
| @@ -272,15 +327,15 @@ static const struct rpmhpd_desc sc7180_desc = { · 3 unmodified lines | |||
| 272 | 327 | ||
| 273 | /* SC7280 RPMH powerdomains */ | 328 | /* SC7280 RPMH powerdomains */ |
| 274 | static struct rpmhpd *sc7280_rpmhpds[] = { | 329 | static struct rpmhpd *sc7280_rpmhpds[] = { |
| 275 | [SC7280_CX] = &sdm845_cx, | 330 | [SC7280_CX] = &cx, |
| 276 | [SC7280_CX_AO] = &sdm845_cx_ao, | 331 | [SC7280_CX_AO] = &cx_ao, |
| 277 | [SC7280_EBI] = &sdm845_ebi, | 332 | [SC7280_EBI] = &ebi, |
| 278 | [SC7280_GFX] = &sdm845_gfx, | 333 | [SC7280_GFX] = &gfx, |
| 279 | [SC7280_MX] = &sdm845_mx, | 334 | [SC7280_LCX] = &lcx, |
| 280 | [SC7280_MX_AO] = &sdm845_mx_ao, | 335 | [SC7280_LMX] = &lmx, |
| 281 | [SC7280_LMX] = &sdm845_lmx, | 336 | [SC7280_MSS] = &mss, |
| 282 | [SC7280_LCX] = &sdm845_lcx, | 337 | [SC7280_MX] = &mx, |
| 283 | [SC7280_MSS] = &sdm845_mss, | 338 | [SC7280_MX_AO] = &mx_ao, |
| 284 | }; | 339 | }; |
| 285 | 340 | ||
| 286 | static const struct rpmhpd_desc sc7280_desc = { | 341 | static const struct rpmhpd_desc sc7280_desc = { |
| @@ -290,17 +345,17 @@ static const struct rpmhpd_desc sc7280_desc = { · 3 unmodified lines | |||
| 290 | 345 | ||
| 291 | /* SC8180x RPMH powerdomains */ | 346 | /* SC8180x RPMH powerdomains */ |
| 292 | static struct rpmhpd *sc8180x_rpmhpds[] = { | 347 | static struct rpmhpd *sc8180x_rpmhpds[] = { |
| 293 | [SC8180X_CX] = &sdm845_cx, | 348 | [SC8180X_CX] = &cx_w_mx_parent, |
| 294 | [SC8180X_CX_AO] = &sdm845_cx_ao, | 349 | [SC8180X_CX_AO] = &cx_ao_w_mx_parent, |
| 295 | [SC8180X_EBI] = &sdm845_ebi, | 350 | [SC8180X_EBI] = &ebi, |
| 296 | [SC8180X_GFX] = &sdm845_gfx, | 351 | [SC8180X_GFX] = &gfx, |
| 297 | [SC8180X_LCX] = &sdm845_lcx, | 352 | [SC8180X_LCX] = &lcx, |
| 298 | [SC8180X_LMX] = &sdm845_lmx, | 353 | [SC8180X_LMX] = &lmx, |
| 299 | [SC8180X_MMCX] = &sm8150_mmcx, | 354 | [SC8180X_MMCX] = &mmcx, |
| 300 | [SC8180X_MMCX_AO] = &sm8150_mmcx_ao, | 355 | [SC8180X_MMCX_AO] = &mmcx_ao, |
| 301 | [SC8180X_MSS] = &sdm845_mss, | 356 | [SC8180X_MSS] = &mss, |
| 302 | [SC8180X_MX] = &sdm845_mx, | 357 | [SC8180X_MX] = &mx, |
| 303 | [SC8180X_MX_AO] = &sdm845_mx_ao, | 358 | [SC8180X_MX_AO] = &mx_ao, |
| 304 | }; | 359 | }; |
| 305 | 360 | ||
| 306 | static const struct rpmhpd_desc sc8180x_desc = { | 361 | static const struct rpmhpd_desc sc8180x_desc = { |
| @@ -318,6 +373,7 @@ static const struct of_device_id rpmhpd_match_table[] = { · 11 unmodified lines | |||
| 318 | { .compatible = "qcom,sm8150-rpmhpd", .data = &sm8150_desc }, | 373 | { .compatible = "qcom,sm8150-rpmhpd", .data = &sm8150_desc }, |
| 319 | { .compatible = "qcom,sm8250-rpmhpd", .data = &sm8250_desc }, | 374 | { .compatible = "qcom,sm8250-rpmhpd", .data = &sm8250_desc }, |
| 320 | { .compatible = "qcom,sm8350-rpmhpd", .data = &sm8350_desc }, | 375 | { .compatible = "qcom,sm8350-rpmhpd", .data = &sm8350_desc }, |
| 376 | { .compatible = "qcom,sm8450-rpmhpd", .data = &sm8450_desc }, | ||
| 321 | { } | 377 | { } |
| 322 | }; | 378 | }; |
| 323 | MODULE_DEVICE_TABLE(of, rpmhpd_match_table); | 379 | MODULE_DEVICE_TABLE(of, rpmhpd_match_table); |
| @@ -102,7 +102,6 @@ struct rpmpd { · 101 unmodified lines | |||
| 102 | const bool active_only; | 102 | const bool active_only; |
| 103 | unsigned int corner; | 103 | unsigned int corner; |
| 104 | bool enabled; | 104 | bool enabled; |
| 105 | const char *res_name; | ||
| 106 | const int res_type; | 105 | const int res_type; |
| 107 | const int res_id; | 106 | const int res_id; |
| 108 | struct qcom_smd_rpm *rpm; | 107 | struct qcom_smd_rpm *rpm; |
| @@ -396,6 +395,45 @@ static const struct rpmpd_desc sm6115_desc = { · 287 unmodified lines | |||
| 396 | .max_state = RPM_SMD_LEVEL_TURBO_NO_CPR, | 395 | .max_state = RPM_SMD_LEVEL_TURBO_NO_CPR, |
| 397 | }; | 396 | }; |
| 398 | 397 | ||
| 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 | |||
| 399 | static const struct of_device_id rpmpd_match_table[] = { | 437 | static const struct of_device_id rpmpd_match_table[] = { |
| 400 | { .compatible = "qcom,mdm9607-rpmpd", .data = &mdm9607_desc }, | 438 | { .compatible = "qcom,mdm9607-rpmpd", .data = &mdm9607_desc }, |
| 401 | { .compatible = "qcom,msm8916-rpmpd", .data = &msm8916_desc }, | 439 | { .compatible = "qcom,msm8916-rpmpd", .data = &msm8916_desc }, |
| @@ -405,9 +443,11 @@ static const struct of_device_id rpmpd_match_table[] = { · 3 unmodified lines | |||
| 405 | { .compatible = "qcom,msm8994-rpmpd", .data = &msm8994_desc }, | 443 | { .compatible = "qcom,msm8994-rpmpd", .data = &msm8994_desc }, |
| 406 | { .compatible = "qcom,msm8996-rpmpd", .data = &msm8996_desc }, | 444 | { .compatible = "qcom,msm8996-rpmpd", .data = &msm8996_desc }, |
| 407 | { .compatible = "qcom,msm8998-rpmpd", .data = &msm8998_desc }, | 445 | { .compatible = "qcom,msm8998-rpmpd", .data = &msm8998_desc }, |
| 446 | { .compatible = "qcom,qcm2290-rpmpd", .data = &qcm2290_desc }, | ||
| 408 | { .compatible = "qcom,qcs404-rpmpd", .data = &qcs404_desc }, | 447 | { .compatible = "qcom,qcs404-rpmpd", .data = &qcs404_desc }, |
| 409 | { .compatible = "qcom,sdm660-rpmpd", .data = &sdm660_desc }, | 448 | { .compatible = "qcom,sdm660-rpmpd", .data = &sdm660_desc }, |
| 410 | { .compatible = "qcom,sm6115-rpmpd", .data = &sm6115_desc }, | 449 | { .compatible = "qcom,sm6115-rpmpd", .data = &sm6115_desc }, |
| 450 | { .compatible = "qcom,sm6125-rpmpd", .data = &sm6125_desc }, | ||
| 411 | { } | 451 | { } |
| 412 | }; | 452 | }; |
| 413 | MODULE_DEVICE_TABLE(of, rpmpd_match_table); | 453 | MODULE_DEVICE_TABLE(of, rpmpd_match_table); |
| @@ -85,7 +85,7 @@ · 84 unmodified lines | |||
| 85 | #define SMEM_GLOBAL_HOST 0xfffe | 85 | #define SMEM_GLOBAL_HOST 0xfffe |
| 86 | 86 | ||
| 87 | /* Max number of processors/hosts in a system */ | 87 | /* Max number of processors/hosts in a system */ |
| 88 | #define SMEM_HOST_COUNT 14 | 88 | #define SMEM_HOST_COUNT 15 |
| 89 | 89 | ||
| 90 | /** | 90 | /** |
| 91 | * struct smem_proc_comm - proc_comm communication struct (legacy) | 91 | * struct smem_proc_comm - proc_comm communication struct (legacy) |
| @@ -313,8 +313,11 @@ static const struct soc_id soc_id[] = { · 312 unmodified lines | |||
| 313 | { 421, "IPQ6000" }, | 313 | { 421, "IPQ6000" }, |
| 314 | { 422, "IPQ6010" }, | 314 | { 422, "IPQ6010" }, |
| 315 | { 425, "SC7180" }, | 315 | { 425, "SC7180" }, |
| 316 | { 434, "SM6350" }, | ||
| 316 | { 453, "IPQ6005" }, | 317 | { 453, "IPQ6005" }, |
| 317 | { 455, "QRB5165" }, | 318 | { 455, "QRB5165" }, |
| 319 | { 457, "SM8450" }, | ||
| 320 | { 459, "SM7225" }, | ||
| 318 | }; | 321 | }; |
| 319 | 322 | ||
| 320 | static const char *socinfo_machine(struct device *dev, unsigned int id) | 323 | static const char *socinfo_machine(struct device *dev, unsigned int id) |
| @@ -235,6 +235,13 @@ config ARCH_R8A77961 · 234 unmodified lines | |||
| 235 | This enables support for the Renesas R-Car M3-W+ SoC. | 235 | This enables support for the Renesas R-Car M3-W+ SoC. |
| 236 | This includes different gradings like R-Car M3e and M3e-2G. | 236 | This includes different gradings like R-Car M3e and M3e-2G. |
| 237 | 237 | ||
| 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 | |||
| 238 | config ARCH_R8A77980 | 245 | config ARCH_R8A77980 |
| 239 | bool "ARM64 Platform support for R-Car V3H" | 246 | bool "ARM64 Platform support for R-Car V3H" |
| 240 | select ARCH_RCAR_GEN3 | 247 | select ARCH_RCAR_GEN3 |
| @@ -297,6 +304,9 @@ config RST_RCAR · 56 unmodified lines | |||
| 297 | config SYSC_RCAR | 304 | config SYSC_RCAR |
| 298 | bool "System Controller support for R-Car" if COMPILE_TEST | 305 | bool "System Controller support for R-Car" if COMPILE_TEST |
| 299 | 306 | ||
| 307 | config SYSC_RCAR_GEN4 | ||
| 308 | bool "System Controller support for R-Car Gen4" if COMPILE_TEST | ||
| 309 | |||
| 300 | config SYSC_R8A77995 | 310 | config SYSC_R8A77995 |
| 301 | bool "System Controller support for R-Car D3" if COMPILE_TEST | 311 | bool "System Controller support for R-Car D3" if COMPILE_TEST |
| 302 | select SYSC_RCAR | 312 | select SYSC_RCAR |
| @@ -337,6 +347,10 @@ config SYSC_R8A77961 · 34 unmodified lines | |||
| 337 | bool "System Controller support for R-Car M3-W+" if COMPILE_TEST | 347 | bool "System Controller support for R-Car M3-W+" if COMPILE_TEST |
| 338 | select SYSC_RCAR | 348 | select SYSC_RCAR |
| 339 | 349 | ||
| 350 | config SYSC_R8A779F0 | ||
| 351 | bool "System Controller support for R-Car S4-8" if COMPILE_TEST | ||
| 352 | select SYSC_RCAR_GEN4 | ||
| 353 | |||
| 340 | config SYSC_R8A7792 | 354 | config SYSC_R8A7792 |
| 341 | bool "System Controller support for R-Car V2H" if COMPILE_TEST | 355 | bool "System Controller support for R-Car V2H" if COMPILE_TEST |
| 342 | select SYSC_RCAR | 356 | select SYSC_RCAR |
| @@ -351,6 +365,7 @@ config SYSC_R8A77970 · 8 unmodified lines | |||
| 351 | 365 | ||
| 352 | config SYSC_R8A779A0 | 366 | config SYSC_R8A779A0 |
| 353 | bool "System Controller support for R-Car V3U" if COMPILE_TEST | 367 | bool "System Controller support for R-Car V3U" if COMPILE_TEST |
| 368 | select SYSC_RCAR_GEN4 | ||
| 354 | 369 | ||
| 355 | config SYSC_RMOBILE | 370 | config SYSC_RMOBILE |
| 356 | bool "System Controller support for R-Mobile" if COMPILE_TEST | 371 | bool "System Controller support for R-Mobile" if COMPILE_TEST |
| @@ -25,6 +25,7 @@ obj-$(CONFIG_SYSC_R8A77980) += r8a77980-sysc.o · 24 unmodified lines | |||
| 25 | obj-$(CONFIG_SYSC_R8A77990) += r8a77990-sysc.o | 25 | obj-$(CONFIG_SYSC_R8A77990) += r8a77990-sysc.o |
| 26 | obj-$(CONFIG_SYSC_R8A77995) += r8a77995-sysc.o | 26 | obj-$(CONFIG_SYSC_R8A77995) += r8a77995-sysc.o |
| 27 | obj-$(CONFIG_SYSC_R8A779A0) += r8a779a0-sysc.o | 27 | obj-$(CONFIG_SYSC_R8A779A0) += r8a779a0-sysc.o |
| 28 | obj-$(CONFIG_SYSC_R8A779F0) += r8a779f0-sysc.o | ||
| 28 | ifdef CONFIG_SMP | 29 | ifdef CONFIG_SMP |
| 29 | obj-$(CONFIG_ARCH_R9A06G032) += r9a06g032-smp.o | 30 | obj-$(CONFIG_ARCH_R9A06G032) += r9a06g032-smp.o |
| 30 | endif | 31 | endif |
| @@ -32,4 +33,5 @@ endif · 1 unmodified line | |||
| 32 | # Family | 33 | # Family |
| 33 | obj-$(CONFIG_RST_RCAR) += rcar-rst.o | 34 | obj-$(CONFIG_RST_RCAR) += rcar-rst.o |
| 34 | obj-$(CONFIG_SYSC_RCAR) += rcar-sysc.o | 35 | obj-$(CONFIG_SYSC_RCAR) += rcar-sysc.o |
| 36 | obj-$(CONFIG_SYSC_RCAR_GEN4) += rcar-gen4-sysc.o | ||
| 35 | obj-$(CONFIG_SYSC_RMOBILE) += rmobile-sysc.o | 37 | obj-$(CONFIG_SYSC_RMOBILE) += rmobile-sysc.o |
| @@ -21,35 +21,9 @@ · 20 unmodified lines | |||
| 21 | 21 | ||
| 22 | #include <dt-bindings/power/r8a779a0-sysc.h> | 22 | #include <dt-bindings/power/r8a779a0-sysc.h> |
| 23 | 23 | ||
| 24 | /* | 24 | #include "rcar-gen4-sysc.h" |
| 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 | }; | ||
| 51 | 25 | ||
| 52 | static struct r8a779a0_sysc_area r8a779a0_areas[] __initdata = { | 26 | static struct rcar_gen4_sysc_area r8a779a0_areas[] __initdata = { |
| 53 | { "always-on", R8A779A0_PD_ALWAYS_ON, -1, PD_ALWAYS_ON }, | 27 | { "always-on", R8A779A0_PD_ALWAYS_ON, -1, PD_ALWAYS_ON }, |
| 54 | { "a3e0", R8A779A0_PD_A3E0, R8A779A0_PD_ALWAYS_ON, PD_SCU }, | 28 | { "a3e0", R8A779A0_PD_A3E0, R8A779A0_PD_ALWAYS_ON, PD_SCU }, |
| 55 | { "a3e1", R8A779A0_PD_A3E1, R8A779A0_PD_ALWAYS_ON, PD_SCU }, | 29 | { "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 | |||
| 96 | { "a1dsp1", R8A779A0_PD_A1DSP1, R8A779A0_PD_A2CN1 }, | 70 | { "a1dsp1", R8A779A0_PD_A1DSP1, R8A779A0_PD_A2CN1 }, |
| 97 | }; | 71 | }; |
| 98 | 72 | ||
| 99 | static const struct r8a779a0_sysc_info r8a779a0_sysc_info __initconst = { | 73 | const struct rcar_gen4_sysc_info r8a779a0_sysc_info __initconst = { |
| 100 | .areas = r8a779a0_areas, | 74 | .areas = r8a779a0_areas, |
| 101 | .num_areas = ARRAY_SIZE(r8a779a0_areas), | 75 | .num_areas = ARRAY_SIZE(r8a779a0_areas), |
| 102 | }; | 76 | }; |
| 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); | ||
| @@ -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 | }; | ||
| @@ -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); | ||
| @@ -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__ */ | ||
| @@ -13,15 +13,43 @@ · 12 unmodified lines | |||
| 13 | #define WDTRSTCR_RESET 0xA55A0002 | 13 | #define WDTRSTCR_RESET 0xA55A0002 |
| 14 | #define WDTRSTCR 0x0054 | 14 | #define WDTRSTCR 0x0054 |
| 15 | 15 | ||
| 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 | |||
| 16 | static int rcar_rst_enable_wdt_reset(void __iomem *base) | 24 | static int rcar_rst_enable_wdt_reset(void __iomem *base) |
| 17 | { | 25 | { |
| 18 | iowrite32(WDTRSTCR_RESET, base + WDTRSTCR); | 26 | iowrite32(WDTRSTCR_RESET, base + WDTRSTCR); |
| 19 | return 0; | 27 | return 0; |
| 20 | } | 28 | } |
| 21 | 29 | ||
| 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 | |||
| 22 | struct rst_config { | 49 | struct rst_config { |
| 23 | unsigned int modemr; /* Mode Monitoring Register Offset */ | 50 | unsigned int modemr; /* Mode Monitoring Register Offset */ |
| 24 | int (*configure)(void __iomem *base); /* Platform specific config */ | 51 | int (*configure)(void __iomem *base); /* Platform specific config */ |
| 52 | int (*set_rproc_boot_addr)(u64 boot_addr); | ||
| 25 | }; | 53 | }; |
| 26 | 54 | ||
| 27 | static const struct rst_config rcar_rst_gen1 __initconst = { | 55 | 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 | |||
| 35 | 63 | ||
| 36 | static const struct rst_config rcar_rst_gen3 __initconst = { | 64 | static const struct rst_config rcar_rst_gen3 __initconst = { |
| 37 | .modemr = 0x60, | 65 | .modemr = 0x60, |
| 66 | .set_rproc_boot_addr = rcar_rst_set_gen3_rproc_boot_addr, | ||
| 38 | }; | 67 | }; |
| 39 | 68 | ||
| 40 | static const struct rst_config rcar_rst_r8a779a0 __initconst = { | 69 | static const struct rst_config rcar_rst_gen4 __initconst = { |
| 41 | .modemr = 0x00, /* MODEMR0 and it has CPG related bits */ | 70 | .modemr = 0x00, /* MODEMR0 and it has CPG related bits */ |
| 42 | }; | 71 | }; |
| 43 | 72 | ||
| @@ -71,14 +100,12 @@ static const struct of_device_id rcar_rst_matches[] __initconst = { · 27 unmodified lines | |||
| 71 | { .compatible = "renesas,r8a77980-rst", .data = &rcar_rst_gen3 }, | 100 | { .compatible = "renesas,r8a77980-rst", .data = &rcar_rst_gen3 }, |
| 72 | { .compatible = "renesas,r8a77990-rst", .data = &rcar_rst_gen3 }, | 101 | { .compatible = "renesas,r8a77990-rst", .data = &rcar_rst_gen3 }, |
| 73 | { .compatible = "renesas,r8a77995-rst", .data = &rcar_rst_gen3 }, | 102 | { .compatible = "renesas,r8a77995-rst", .data = &rcar_rst_gen3 }, |
| 74 | /* R-Car V3U */ | 103 | /* R-Car Gen4 */ |
| 75 | { .compatible = "renesas,r8a779a0-rst", .data = &rcar_rst_r8a779a0 }, | 104 | { .compatible = "renesas,r8a779a0-rst", .data = &rcar_rst_gen4 }, |
| 105 | { .compatible = "renesas,r8a779f0-rst", .data = &rcar_rst_gen4 }, | ||
| 76 | { /* sentinel */ } | 106 | { /* sentinel */ } |
| 77 | }; | 107 | }; |
| 78 | 108 | ||
| 79 | static void __iomem *rcar_rst_base __initdata; | ||
| 80 | static u32 saved_mode __initdata; | ||
| 81 | |||
| 82 | static int __init rcar_rst_init(void) | 109 | static int __init rcar_rst_init(void) |
| 83 | { | 110 | { |
| 84 | const struct of_device_id *match; | 111 | const struct of_device_id *match; |
| @@ -100,6 +127,8 @@ static int __init rcar_rst_init(void) · 15 unmodified lines | |||
| 100 | 127 | ||
| 101 | rcar_rst_base = base; | 128 | rcar_rst_base = base; |
| 102 | cfg = match->data; | 129 | cfg = match->data; |
| 130 | rcar_rst_set_rproc_boot_addr_func = cfg->set_rproc_boot_addr; | ||
| 131 | |||
| 103 | saved_mode = ioread32(base + cfg->modemr); | 132 | saved_mode = ioread32(base + cfg->modemr); |
| 104 | if (cfg->configure) { | 133 | if (cfg->configure) { |
| 105 | error = cfg->configure(base); | 134 | error = cfg->configure(base); |
| @@ -130,3 +159,12 @@ int __init rcar_rst_read_mode_pins(u32 *mode) · 24 unmodified lines | |||
| 130 | *mode = saved_mode; | 159 | *mode = saved_mode; |
| 131 | return 0; | 160 | return 0; |
| 132 | } | 161 | } |
| 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); | ||
| @@ -33,6 +33,10 @@ static const struct renesas_family fam_rcar_gen3 __initconst __maybe_unused = { · 32 unmodified lines | |||
| 33 | .reg = 0xfff00044, /* PRR (Product Register) */ | 33 | .reg = 0xfff00044, /* PRR (Product Register) */ |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | static const struct renesas_family fam_rcar_gen4 __initconst __maybe_unused = { | ||
| 37 | .name = "R-Car Gen4", | ||
| 38 | }; | ||
| 39 | |||
| 36 | static const struct renesas_family fam_rmobile __initconst __maybe_unused = { | 40 | static const struct renesas_family fam_rmobile __initconst __maybe_unused = { |
| 37 | .name = "R-Mobile", | 41 | .name = "R-Mobile", |
| 38 | .reg = 0xe600101c, /* CCCR (Common Chip Code Register) */ | 42 | .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 | |||
| 214 | .id = 0x59, | 218 | .id = 0x59, |
| 215 | }; | 219 | }; |
| 216 | 220 | ||
| 221 | static const struct renesas_soc soc_rcar_s4 __initconst __maybe_unused = { | ||
| 222 | .family = &fam_rcar_gen4, | ||
| 223 | .id = 0x5a, | ||
| 224 | }; | ||
| 225 | |||
| 217 | static const struct renesas_soc soc_shmobile_ag5 __initconst __maybe_unused = { | 226 | static const struct renesas_soc soc_shmobile_ag5 __initconst __maybe_unused = { |
| 218 | .family = &fam_shmobile, | 227 | .family = &fam_shmobile, |
| 219 | .id = 0x37, | 228 | .id = 0x37, |
| @@ -319,6 +328,9 @@ static const struct of_device_id renesas_socs[] __initconst = { · 99 unmodified lines | |||
| 319 | #ifdef CONFIG_ARCH_R8A779A0 | 328 | #ifdef CONFIG_ARCH_R8A779A0 |
| 320 | { .compatible = "renesas,r8a779a0", .data = &soc_rcar_v3u }, | 329 | { .compatible = "renesas,r8a779a0", .data = &soc_rcar_v3u }, |
| 321 | #endif | 330 | #endif |
| 331 | #ifdef CONFIG_ARCH_R8A779F0 | ||
| 332 | { .compatible = "renesas,r8a779f0", .data = &soc_rcar_s4 }, | ||
| 333 | #endif | ||
| 322 | #if defined(CONFIG_ARCH_R9A07G044) | 334 | #if defined(CONFIG_ARCH_R9A07G044) |
| 323 | { .compatible = "renesas,r9a07g044", .data = &soc_rz_g2l }, | 335 | { .compatible = "renesas,r9a07g044", .data = &soc_rz_g2l }, |
| 324 | #endif | 336 | #endif |
| @@ -328,94 +340,92 @@ static const struct of_device_id renesas_socs[] __initconst = { · 3 unmodified lines | |||
| 328 | { /* sentinel */ } | 340 | { /* sentinel */ } |
| 329 | }; | 341 | }; |
| 330 | 342 | ||
| 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 | |||
| 331 | static int __init renesas_soc_init(void) | 374 | static int __init renesas_soc_init(void) |
| 332 | { | 375 | { |
| 333 | struct soc_device_attribute *soc_dev_attr; | 376 | struct soc_device_attribute *soc_dev_attr; |
| 377 | unsigned int product, eshi = 0, eslo; | ||
| 334 | const struct renesas_family *family; | 378 | const struct renesas_family *family; |
| 335 | const struct of_device_id *match; | 379 | const struct of_device_id *match; |
| 336 | const struct renesas_soc *soc; | 380 | const struct renesas_soc *soc; |
| 381 | const struct renesas_id *id; | ||
| 337 | void __iomem *chipid = NULL; | 382 | void __iomem *chipid = NULL; |
| 338 | struct soc_device *soc_dev; | 383 | struct soc_device *soc_dev; |
| 339 | struct device_node *np; | 384 | struct device_node *np; |
| 340 | unsigned int product, eshi = 0, eslo; | 385 | const char *soc_id; |
| 341 | 386 | ||
| 342 | match = of_match_node(renesas_socs, of_root); | 387 | match = of_match_node(renesas_socs, of_root); |
| 343 | if (!match) | 388 | if (!match) |
| 344 | return -ENODEV; | 389 | return -ENODEV; |
| 345 | 390 | ||
| 391 | soc_id = strchr(match->compatible, ',') + 1; | ||
| 346 | soc = match->data; | 392 | soc = match->data; |
| 347 | family = soc->family; | 393 | family = soc->family; |
| 348 | 394 | ||
| 349 | np = of_find_compatible_node(NULL, NULL, "renesas,bsid"); | 395 | np = of_find_matching_node_and_match(NULL, renesas_ids, &match); |
| 350 | if (np) { | 396 | if (np) { |
| 397 | id = match->data; | ||
| 351 | chipid = of_iomap(np, 0); | 398 | chipid = of_iomap(np, 0); |
| 352 | of_node_put(np); | 399 | of_node_put(np); |
| 353 | 400 | } else if (soc->id && family->reg) { | |
| 354 | if (chipid) { | 401 | /* Try hardcoded CCCR/PRR fallback */ |
| 355 | product = readl(chipid); | 402 | id = &id_prr; |
| 356 | iounmap(chipid); | 403 | chipid = ioremap(family->reg, 4); |
| 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; | ||
| 372 | } | 404 | } |
| 373 | 405 | ||
| 374 | np = of_find_compatible_node(NULL, NULL, "renesas,r9a07g044-sysc"); | 406 | if (chipid) { |
| 375 | if (np) { | 407 | product = readl(chipid + id->offset); |
| 376 | chipid = of_iomap(np, 0); | 408 | iounmap(chipid); |
| 377 | of_node_put(np); | ||
| 378 | 409 | ||
| 379 | if (chipid) { | 410 | if (id == &id_prr) { |
| 380 | product = readl(chipid + 0x0a04); | 411 | /* R-Car M3-W ES1.1 incorrectly identifies as ES2.0 */ |
| 381 | iounmap(chipid); | 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; | ||
| 382 | 417 | ||
| 383 | if (soc->id && (product & 0xfffffff) != soc->id) { | 418 | eshi = ((product >> 4) & 0x0f) + 1; |
| 384 | pr_warn("SoC mismatch (product = 0x%x)\n", | 419 | eslo = product & 0xf; |
| 385 | product); | ||
| 386 | return -ENODEV; | ||
| 387 | } | ||
| 388 | } | 420 | } |
| 389 | 421 | ||
| 390 | goto done; | 422 | if (soc->id && |
| 391 | } | 423 | ((product & id->mask) >> __ffs(id->mask)) != soc->id) { |
| 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) { | ||
| 411 | pr_warn("SoC mismatch (product = 0x%x)\n", product); | 424 | pr_warn("SoC mismatch (product = 0x%x)\n", product); |
| 412 | return -ENODEV; | 425 | return -ENODEV; |
| 413 | } | 426 | } |
| 414 | eshi = ((product >> 4) & 0x0f) + 1; | ||
| 415 | eslo = product & 0xf; | ||
| 416 | } | 427 | } |
| 417 | 428 | ||
| 418 | done: | ||
| 419 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); | 429 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); |
| 420 | if (!soc_dev_attr) | 430 | if (!soc_dev_attr) |
| 421 | return -ENOMEM; | 431 | return -ENOMEM; |
| @@ -425,8 +435,7 @@ done: · 3 unmodified lines | |||
| 425 | of_node_put(np); | 435 | of_node_put(np); |
| 426 | 436 | ||
| 427 | soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL); | 437 | soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL); |
| 428 | soc_dev_attr->soc_id = kstrdup_const(strchr(match->compatible, ',') + 1, | 438 | soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL); |
| 429 | GFP_KERNEL); | ||
| 430 | if (eshi) | 439 | if (eshi) |
| 431 | soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", eshi, | 440 | soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", eshi, |
| 432 | eslo); | 441 | eslo); |
| @@ -23,6 +23,20 @@ config EXYNOS_CHIPID · 22 unmodified lines | |||
| 23 | Support for Samsung Exynos SoC ChipID and Adaptive Supply Voltage. | 23 | Support for Samsung Exynos SoC ChipID and Adaptive Supply Voltage. |
| 24 | This driver can also be built as module (exynos_chipid). | 24 | This driver can also be built as module (exynos_chipid). |
| 25 | 25 | ||
| 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 | |||
| 26 | config EXYNOS_PMU | 40 | config EXYNOS_PMU |
| 27 | bool "Exynos PMU controller driver" if COMPILE_TEST | 41 | bool "Exynos PMU controller driver" if COMPILE_TEST |
| 28 | depends on ARCH_EXYNOS || ((ARM || ARM64) && COMPILE_TEST) | 42 | depends on ARCH_EXYNOS || ((ARM || ARM64) && COMPILE_TEST) |
| @@ -4,6 +4,8 @@ obj-$(CONFIG_EXYNOS_ASV_ARM) += exynos5422-asv.o · 3 unmodified lines | |||
| 4 | obj-$(CONFIG_EXYNOS_CHIPID) += exynos_chipid.o | 4 | obj-$(CONFIG_EXYNOS_CHIPID) += exynos_chipid.o |
| 5 | exynos_chipid-y += exynos-chipid.o exynos-asv.o | 5 | exynos_chipid-y += exynos-chipid.o exynos-asv.o |
| 6 | 6 | ||
| 7 | obj-$(CONFIG_EXYNOS_USI) += exynos-usi.o | ||
| 8 | |||
| 7 | obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o | 9 | obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o |
| 8 | 10 | ||
| 9 | obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \ | 11 | obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \ |
| @@ -42,6 +42,7 @@ static const struct exynos_soc_id { · 41 unmodified lines | |||
| 42 | unsigned int id; | 42 | unsigned int id; |
| 43 | } soc_ids[] = { | 43 | } soc_ids[] = { |
| 44 | /* List ordered by SoC name */ | 44 | /* List ordered by SoC name */ |
| 45 | /* Compatible with: samsung,exynos4210-chipid */ | ||
| 45 | { "EXYNOS3250", 0xE3472000 }, | 46 | { "EXYNOS3250", 0xE3472000 }, |
| 46 | { "EXYNOS4210", 0x43200000 }, /* EVT0 revision */ | 47 | { "EXYNOS4210", 0x43200000 }, /* EVT0 revision */ |
| 47 | { "EXYNOS4210", 0x43210000 }, | 48 | { "EXYNOS4210", 0x43210000 }, |
| @@ -55,6 +56,8 @@ static const struct exynos_soc_id { · 7 unmodified lines | |||
| 55 | { "EXYNOS5440", 0xE5440000 }, | 56 | { "EXYNOS5440", 0xE5440000 }, |
| 56 | { "EXYNOS5800", 0xE5422000 }, | 57 | { "EXYNOS5800", 0xE5422000 }, |
| 57 | { "EXYNOS7420", 0xE7420000 }, | 58 | { "EXYNOS7420", 0xE7420000 }, |
| 59 | /* Compatible with: samsung,exynos850-chipid */ | ||
| 60 | { "EXYNOS7885", 0xE7885000 }, | ||
| 58 | { "EXYNOS850", 0xE3830000 }, | 61 | { "EXYNOS850", 0xE3830000 }, |
| 59 | { "EXYNOSAUTOV9", 0xAAA80000 }, | 62 | { "EXYNOSAUTOV9", 0xAAA80000 }, |
| 60 | }; | 63 | }; |
| @@ -94,6 +94,8 @@ static const struct of_device_id exynos_pmu_of_device_ids[] = { · 93 unmodified lines | |||
| 94 | .compatible = "samsung,exynos5433-pmu", | 94 | .compatible = "samsung,exynos5433-pmu", |
| 95 | }, { | 95 | }, { |
| 96 | .compatible = "samsung,exynos7-pmu", | 96 | .compatible = "samsung,exynos7-pmu", |
| 97 | }, { | ||
| 98 | .compatible = "samsung,exynos850-pmu", | ||
| 97 | }, | 99 | }, |
| 98 | { /*sentinel*/ }, | 100 | { /*sentinel*/ }, |
| 99 | }; | 101 | }; |
| @@ -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"); | ||
| @@ -10,6 +10,7 @@ · 9 unmodified lines | |||
| 10 | #include <linux/export.h> | 10 | #include <linux/export.h> |
| 11 | #include <linux/of.h> | 11 | #include <linux/of.h> |
| 12 | #include <linux/pm_opp.h> | 12 | #include <linux/pm_opp.h> |
| 13 | #include <linux/pm_runtime.h> | ||
| 13 | 14 | ||
| 14 | #include <soc/tegra/common.h> | 15 | #include <soc/tegra/common.h> |
| 15 | #include <soc/tegra/fuse.h> | 16 | #include <soc/tegra/fuse.h> |
| @@ -43,6 +44,7 @@ static int tegra_core_dev_init_opp_state(struct device *dev) · 27 unmodified lines | |||
| 43 | { | 44 | { |
| 44 | unsigned long rate; | 45 | unsigned long rate; |
| 45 | struct clk *clk; | 46 | struct clk *clk; |
| 47 | bool rpm_enabled; | ||
| 46 | int err; | 48 | int err; |
| 47 | 49 | ||
| 48 | clk = devm_clk_get(dev, NULL); | 50 | clk = devm_clk_get(dev, NULL); |
| @@ -57,8 +59,31 @@ static int tegra_core_dev_init_opp_state(struct device *dev) · 8 unmodified lines | |||
| 57 | return -EINVAL; | 59 | return -EINVAL; |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 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 | |||
| 60 | /* first dummy rate-setting initializes voltage vote */ | 81 | /* first dummy rate-setting initializes voltage vote */ |
| 61 | err = dev_pm_opp_set_rate(dev, rate); | 82 | err = dev_pm_opp_set_rate(dev, rate); |
| 83 | |||
| 84 | if (!rpm_enabled) | ||
| 85 | pm_runtime_disable(dev); | ||
| 86 | |||
| 62 | if (err) { | 87 | if (err) { |
| 63 | dev_err(dev, "failed to initialize OPP clock: %d\n", err); | 88 | dev_err(dev, "failed to initialize OPP clock: %d\n", err); |
| 64 | return err; | 89 | return err; |
| @@ -111,9 +136,7 @@ int devm_tegra_core_dev_init_opp_table(struct device *dev, · 46 unmodified lines | |||
| 111 | */ | 136 | */ |
| 112 | err = devm_pm_opp_of_add_table(dev); | 137 | err = devm_pm_opp_of_add_table(dev); |
| 113 | if (err) { | 138 | if (err) { |
| 114 | if (err == -ENODEV) | 139 | if (err != -ENODEV) |
| 115 | dev_err_once(dev, "OPP table not found, please update device-tree\n"); | ||
| 116 | else | ||
| 117 | dev_err(dev, "failed to add OPP table: %d\n", err); | 140 | dev_err(dev, "failed to add OPP table: %d\n", err); |
| 118 | 141 | ||
| 119 | return err; | 142 | return err; |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | |||
| 14 | #include <linux/of_address.h> | 14 | #include <linux/of_address.h> |
| 15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/pm_runtime.h> | 16 | #include <linux/pm_runtime.h> |
| 17 | #include <linux/reset.h> | ||
| 17 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 18 | #include <linux/sys_soc.h> | 19 | #include <linux/sys_soc.h> |
| 19 | 20 | ||
| @@ -181,6 +182,12 @@ static const struct nvmem_cell_info tegra_fuse_cells[] = { · 161 unmodified lines | |||
| 181 | }, | 182 | }, |
| 182 | }; | 183 | }; |
| 183 | 184 | ||
| 185 | static void tegra_fuse_restore(void *base) | ||
| 186 | { | ||
| 187 | fuse->clk = NULL; | ||
| 188 | fuse->base = base; | ||
| 189 | } | ||
| 190 | |||
| 184 | static int tegra_fuse_probe(struct platform_device *pdev) | 191 | static int tegra_fuse_probe(struct platform_device *pdev) |
| 185 | { | 192 | { |
| 186 | void __iomem *base = fuse->base; | 193 | void __iomem *base = fuse->base; |
| @@ -188,13 +195,16 @@ static int tegra_fuse_probe(struct platform_device *pdev) · 1 unmodified line | |||
| 188 | struct resource *res; | 195 | struct resource *res; |
| 189 | int err; | 196 | int err; |
| 190 | 197 | ||
| 198 | err = devm_add_action(&pdev->dev, tegra_fuse_restore, base); | ||
| 199 | if (err) | ||
| 200 | return err; | ||
| 201 | |||
| 191 | /* take over the memory region from the early initialization */ | 202 | /* take over the memory region from the early initialization */ |
| 192 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 203 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 193 | fuse->phys = res->start; | 204 | fuse->phys = res->start; |
| 194 | fuse->base = devm_ioremap_resource(&pdev->dev, res); | 205 | fuse->base = devm_ioremap_resource(&pdev->dev, res); |
| 195 | if (IS_ERR(fuse->base)) { | 206 | if (IS_ERR(fuse->base)) { |
| 196 | err = PTR_ERR(fuse->base); | 207 | err = PTR_ERR(fuse->base); |
| 197 | fuse->base = base; | ||
| 198 | return err; | 208 | return err; |
| 199 | } | 209 | } |
| 200 | 210 | ||
| @@ -204,19 +214,20 @@ static int tegra_fuse_probe(struct platform_device *pdev) · 3 unmodified lines | |||
| 204 | dev_err(&pdev->dev, "failed to get FUSE clock: %ld", | 214 | dev_err(&pdev->dev, "failed to get FUSE clock: %ld", |
| 205 | PTR_ERR(fuse->clk)); | 215 | PTR_ERR(fuse->clk)); |
| 206 | 216 | ||
| 207 | fuse->base = base; | ||
| 208 | return PTR_ERR(fuse->clk); | 217 | return PTR_ERR(fuse->clk); |
| 209 | } | 218 | } |
| 210 | 219 | ||
| 211 | platform_set_drvdata(pdev, fuse); | 220 | platform_set_drvdata(pdev, fuse); |
| 212 | fuse->dev = &pdev->dev; | 221 | fuse->dev = &pdev->dev; |
| 213 | 222 | ||
| 214 | pm_runtime_enable(&pdev->dev); | 223 | err = devm_pm_runtime_enable(&pdev->dev); |
| 224 | if (err) | ||
| 225 | return err; | ||
| 215 | 226 | ||
| 216 | if (fuse->soc->probe) { | 227 | if (fuse->soc->probe) { |
| 217 | err = fuse->soc->probe(fuse); | 228 | err = fuse->soc->probe(fuse); |
| 218 | if (err < 0) | 229 | if (err < 0) |
| 219 | goto restore; | 230 | return err; |
| 220 | } | 231 | } |
| 221 | 232 | ||
| 222 | memset(&nvmem, 0, sizeof(nvmem)); | 233 | memset(&nvmem, 0, sizeof(nvmem)); |
| @@ -240,19 +251,37 @@ static int tegra_fuse_probe(struct platform_device *pdev) · 17 unmodified lines | |||
| 240 | err = PTR_ERR(fuse->nvmem); | 251 | err = PTR_ERR(fuse->nvmem); |
| 241 | dev_err(&pdev->dev, "failed to register NVMEM device: %d\n", | 252 | dev_err(&pdev->dev, "failed to register NVMEM device: %d\n", |
| 242 | err); | 253 | 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; | ||
| 244 | } | 279 | } |
| 245 | 280 | ||
| 246 | /* release the early I/O memory mapping */ | 281 | /* release the early I/O memory mapping */ |
| 247 | iounmap(base); | 282 | iounmap(base); |
| 248 | 283 | ||
| 249 | return 0; | 284 | return 0; |
| 250 | |||
| 251 | restore: | ||
| 252 | fuse->clk = NULL; | ||
| 253 | fuse->base = base; | ||
| 254 | pm_runtime_disable(&pdev->dev); | ||
| 255 | return err; | ||
| 256 | } | 285 | } |
| 257 | 286 | ||
| 258 | static int __maybe_unused tegra_fuse_runtime_resume(struct device *dev) | 287 | static int __maybe_unused tegra_fuse_runtime_resume(struct device *dev) |
| @@ -94,9 +94,28 @@ static bool dma_filter(struct dma_chan *chan, void *filter_param) · 93 unmodified lines | |||
| 94 | return of_device_is_compatible(np, "nvidia,tegra20-apbdma"); | 94 | return of_device_is_compatible(np, "nvidia,tegra20-apbdma"); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 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 | |||
| 97 | static int tegra20_fuse_probe(struct tegra_fuse *fuse) | 115 | static int tegra20_fuse_probe(struct tegra_fuse *fuse) |
| 98 | { | 116 | { |
| 99 | dma_cap_mask_t mask; | 117 | dma_cap_mask_t mask; |
| 118 | int err; | ||
| 100 | 119 | ||
| 101 | dma_cap_zero(mask); | 120 | dma_cap_zero(mask); |
| 102 | dma_cap_set(DMA_SLAVE, mask); | 121 | dma_cap_set(DMA_SLAVE, mask); |
| @@ -105,13 +124,21 @@ static int tegra20_fuse_probe(struct tegra_fuse *fuse) · 2 unmodified lines | |||
| 105 | if (!fuse->apbdma.chan) | 124 | if (!fuse->apbdma.chan) |
| 106 | return -EPROBE_DEFER; | 125 | return -EPROBE_DEFER; |
| 107 | 126 | ||
| 127 | err = devm_add_action_or_reset(fuse->dev, tegra20_fuse_release_channel, | ||
| 128 | fuse); | ||
| 129 | if (err) | ||
| 130 | return err; | ||
| 131 | |||
| 108 | fuse->apbdma.virt = dma_alloc_coherent(fuse->dev, sizeof(u32), | 132 | fuse->apbdma.virt = dma_alloc_coherent(fuse->dev, sizeof(u32), |
| 109 | &fuse->apbdma.phys, | 133 | &fuse->apbdma.phys, |
| 110 | GFP_KERNEL); | 134 | GFP_KERNEL); |
| 111 | if (!fuse->apbdma.virt) { | 135 | if (!fuse->apbdma.virt) |
| 112 | dma_release_channel(fuse->apbdma.chan); | ||
| 113 | return -ENOMEM; | 136 | 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; | ||
| 115 | 142 | ||
| 116 | fuse->apbdma.config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | 143 | fuse->apbdma.config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 117 | fuse->apbdma.config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | 144 | fuse->apbdma.config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| @@ -43,6 +43,7 @@ struct tegra_fuse { · 42 unmodified lines | |||
| 43 | void __iomem *base; | 43 | void __iomem *base; |
| 44 | phys_addr_t phys; | 44 | phys_addr_t phys; |
| 45 | struct clk *clk; | 45 | struct clk *clk; |
| 46 | struct reset_control *rst; | ||
| 46 | 47 | ||
| 47 | u32 (*read_early)(struct tegra_fuse *fuse, unsigned int offset); | 48 | u32 (*read_early)(struct tegra_fuse *fuse, unsigned int offset); |
| 48 | u32 (*read)(struct tegra_fuse *fuse, unsigned int offset); | 49 | u32 (*read)(struct tegra_fuse *fuse, unsigned int offset); |
| @@ -1064,10 +1064,8 @@ int tegra_pmc_cpu_remove_clamping(unsigned int cpuid) · 1063 unmodified lines | |||
| 1064 | return tegra_powergate_remove_clamping(id); | 1064 | return tegra_powergate_remove_clamping(id); |
| 1065 | } | 1065 | } |
| 1066 | 1066 | ||
| 1067 | static int tegra_pmc_restart_notify(struct notifier_block *this, | 1067 | static void tegra_pmc_program_reboot_reason(const char *cmd) |
| 1068 | unsigned long action, void *data) | ||
| 1069 | { | 1068 | { |
| 1070 | const char *cmd = data; | ||
| 1071 | u32 value; | 1069 | u32 value; |
| 1072 | 1070 | ||
| 1073 | value = tegra_pmc_scratch_readl(pmc, pmc->soc->regs->scratch0); | 1071 | 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 | |||
| 1085 | } | 1083 | } |
| 1086 | 1084 | ||
| 1087 | tegra_pmc_scratch_writel(pmc, value, pmc->soc->regs->scratch0); | 1085 | 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; | ||
| 1088 | 1105 | ||
| 1089 | /* reset everything but PMC_SCRATCH0 and PMC_RST_STATUS */ | 1106 | /* reset everything but PMC_SCRATCH0 and PMC_RST_STATUS */ |
| 1090 | value = tegra_pmc_readl(pmc, PMC_CNTRL); | 1107 | 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 | |||
| 1353 | if (!genpd) | 1370 | if (!genpd) |
| 1354 | return -ENOMEM; | 1371 | return -ENOMEM; |
| 1355 | 1372 | ||
| 1356 | genpd->name = np->name; | 1373 | genpd->name = "core"; |
| 1357 | genpd->set_performance_state = tegra_pmc_core_pd_set_performance_state; | 1374 | genpd->set_performance_state = tegra_pmc_core_pd_set_performance_state; |
| 1358 | genpd->opp_to_performance_state = tegra_pmc_core_pd_opp_to_performance_state; | 1375 | genpd->opp_to_performance_state = tegra_pmc_core_pd_opp_to_performance_state; |
| 1359 | 1376 | ||
| @@ -2890,6 +2907,14 @@ static int tegra_pmc_probe(struct platform_device *pdev) · 1530 unmodified lines | |||
| 2890 | goto cleanup_sysfs; | 2907 | goto cleanup_sysfs; |
| 2891 | } | 2908 | } |
| 2892 | 2909 | ||
| 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 | |||
| 2893 | err = register_restart_handler(&tegra_pmc_restart_handler); | 2918 | err = register_restart_handler(&tegra_pmc_restart_handler); |
| 2894 | if (err) { | 2919 | if (err) { |
| 2895 | dev_err(&pdev->dev, "unable to register restart handler, %d\n", | 2920 | 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 | |||
| 2963 | 2988 | ||
| 2964 | static const char * const tegra20_powergates[] = { | 2989 | static const char * const tegra20_powergates[] = { |
| 2965 | [TEGRA_POWERGATE_CPU] = "cpu", | 2990 | [TEGRA_POWERGATE_CPU] = "cpu", |
| 2966 | [TEGRA_POWERGATE_3D] = "3d", | 2991 | [TEGRA_POWERGATE_3D] = "td", |
| 2967 | [TEGRA_POWERGATE_VENC] = "venc", | 2992 | [TEGRA_POWERGATE_VENC] = "venc", |
| 2968 | [TEGRA_POWERGATE_VDEC] = "vdec", | 2993 | [TEGRA_POWERGATE_VDEC] = "vdec", |
| 2969 | [TEGRA_POWERGATE_PCIE] = "pcie", | 2994 | [TEGRA_POWERGATE_PCIE] = "pcie", |
| @@ -3071,7 +3096,7 @@ static const struct tegra_pmc_soc tegra20_pmc_soc = { · 101 unmodified lines | |||
| 3071 | 3096 | ||
| 3072 | static const char * const tegra30_powergates[] = { | 3097 | static const char * const tegra30_powergates[] = { |
| 3073 | [TEGRA_POWERGATE_CPU] = "cpu0", | 3098 | [TEGRA_POWERGATE_CPU] = "cpu0", |
| 3074 | [TEGRA_POWERGATE_3D] = "3d0", | 3099 | [TEGRA_POWERGATE_3D] = "td", |
| 3075 | [TEGRA_POWERGATE_VENC] = "venc", | 3100 | [TEGRA_POWERGATE_VENC] = "venc", |
| 3076 | [TEGRA_POWERGATE_VDEC] = "vdec", | 3101 | [TEGRA_POWERGATE_VDEC] = "vdec", |
| 3077 | [TEGRA_POWERGATE_PCIE] = "pcie", | 3102 | [TEGRA_POWERGATE_PCIE] = "pcie", |
| @@ -3083,7 +3108,7 @@ static const char * const tegra30_powergates[] = { · 5 unmodified lines | |||
| 3083 | [TEGRA_POWERGATE_CPU2] = "cpu2", | 3108 | [TEGRA_POWERGATE_CPU2] = "cpu2", |
| 3084 | [TEGRA_POWERGATE_CPU3] = "cpu3", | 3109 | [TEGRA_POWERGATE_CPU3] = "cpu3", |
| 3085 | [TEGRA_POWERGATE_CELP] = "celp", | 3110 | [TEGRA_POWERGATE_CELP] = "celp", |
| 3086 | [TEGRA_POWERGATE_3D1] = "3d1", | 3111 | [TEGRA_POWERGATE_3D1] = "td2", |
| 3087 | }; | 3112 | }; |
| 3088 | 3113 | ||
| 3089 | static const u8 tegra30_cpu_powergates[] = { | 3114 | static const u8 tegra30_cpu_powergates[] = { |
| @@ -3132,7 +3157,7 @@ static const struct tegra_pmc_soc tegra30_pmc_soc = { · 42 unmodified lines | |||
| 3132 | 3157 | ||
| 3133 | static const char * const tegra114_powergates[] = { | 3158 | static const char * const tegra114_powergates[] = { |
| 3134 | [TEGRA_POWERGATE_CPU] = "crail", | 3159 | [TEGRA_POWERGATE_CPU] = "crail", |
| 3135 | [TEGRA_POWERGATE_3D] = "3d", | 3160 | [TEGRA_POWERGATE_3D] = "td", |
| 3136 | [TEGRA_POWERGATE_VENC] = "venc", | 3161 | [TEGRA_POWERGATE_VENC] = "venc", |
| 3137 | [TEGRA_POWERGATE_VDEC] = "vdec", | 3162 | [TEGRA_POWERGATE_VDEC] = "vdec", |
| 3138 | [TEGRA_POWERGATE_MPE] = "mpe", | 3163 | [TEGRA_POWERGATE_MPE] = "mpe", |
| @@ -16,7 +16,9 @@ · 15 unmodified lines | |||
| 16 | #include <linux/regulator/coupler.h> | 16 | #include <linux/regulator/coupler.h> |
| 17 | #include <linux/regulator/driver.h> | 17 | #include <linux/regulator/driver.h> |
| 18 | #include <linux/regulator/machine.h> | 18 | #include <linux/regulator/machine.h> |
| 19 | #include <linux/suspend.h> | ||
| 19 | 20 | ||
| 21 | #include <soc/tegra/fuse.h> | ||
| 20 | #include <soc/tegra/pmc.h> | 22 | #include <soc/tegra/pmc.h> |
| 21 | 23 | ||
| 22 | struct tegra_regulator_coupler { | 24 | struct tegra_regulator_coupler { |
| @@ -25,9 +27,12 @@ struct tegra_regulator_coupler { · 2 unmodified lines | |||
| 25 | struct regulator_dev *cpu_rdev; | 27 | struct regulator_dev *cpu_rdev; |
| 26 | struct regulator_dev *rtc_rdev; | 28 | struct regulator_dev *rtc_rdev; |
| 27 | struct notifier_block reboot_notifier; | 29 | struct notifier_block reboot_notifier; |
| 30 | struct notifier_block suspend_notifier; | ||
| 28 | int core_min_uV, cpu_min_uV; | 31 | int core_min_uV, cpu_min_uV; |
| 29 | bool sys_reboot_mode_req; | 32 | bool sys_reboot_mode_req; |
| 30 | bool sys_reboot_mode; | 33 | bool sys_reboot_mode; |
| 34 | bool sys_suspend_mode_req; | ||
| 35 | bool sys_suspend_mode; | ||
| 31 | }; | 36 | }; |
| 32 | 37 | ||
| 33 | static inline struct tegra_regulator_coupler * | 38 | 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 | |||
| 105 | return 150000; | 110 | return 150000; |
| 106 | } | 111 | } |
| 107 | 112 | ||
| 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 | |||
| 108 | static int tegra20_core_rtc_update(struct tegra_regulator_coupler *tegra, | 135 | static int tegra20_core_rtc_update(struct tegra_regulator_coupler *tegra, |
| 109 | struct regulator_dev *core_rdev, | 136 | struct regulator_dev *core_rdev, |
| 110 | struct regulator_dev *rtc_rdev, | 137 | struct regulator_dev *rtc_rdev, |
| @@ -144,6 +171,11 @@ static int tegra20_core_rtc_update(struct tegra_regulator_coupler *tegra, · 33 unmodified lines | |||
| 144 | if (err) | 171 | if (err) |
| 145 | return err; | 172 | return err; |
| 146 | 173 | ||
| 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 | |||
| 147 | core_uV = regulator_get_voltage_rdev(core_rdev); | 179 | core_uV = regulator_get_voltage_rdev(core_rdev); |
| 148 | if (core_uV < 0) | 180 | if (core_uV < 0) |
| 149 | return core_uV; | 181 | return core_uV; |
| @@ -279,6 +311,11 @@ static int tegra20_cpu_voltage_update(struct tegra_regulator_coupler *tegra, · 129 unmodified lines | |||
| 279 | if (tegra->sys_reboot_mode) | 311 | if (tegra->sys_reboot_mode) |
| 280 | cpu_min_uV = max(cpu_min_uV, tegra->cpu_min_uV); | 312 | cpu_min_uV = max(cpu_min_uV, tegra->cpu_min_uV); |
| 281 | 313 | ||
| 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 | |||
| 282 | if (cpu_min_uV > cpu_uV) { | 319 | if (cpu_min_uV > cpu_uV) { |
| 283 | err = tegra20_core_rtc_update(tegra, core_rdev, rtc_rdev, | 320 | err = tegra20_core_rtc_update(tegra, core_rdev, rtc_rdev, |
| 284 | cpu_uV, cpu_min_uV); | 321 | cpu_uV, cpu_min_uV); |
| @@ -320,6 +357,7 @@ static int tegra20_regulator_balance_voltage(struct regulator_coupler *coupler, · 35 unmodified lines | |||
| 320 | } | 357 | } |
| 321 | 358 | ||
| 322 | tegra->sys_reboot_mode = READ_ONCE(tegra->sys_reboot_mode_req); | 359 | tegra->sys_reboot_mode = READ_ONCE(tegra->sys_reboot_mode_req); |
| 360 | tegra->sys_suspend_mode = READ_ONCE(tegra->sys_suspend_mode_req); | ||
| 323 | 361 | ||
| 324 | if (rdev == cpu_rdev) | 362 | if (rdev == cpu_rdev) |
| 325 | return tegra20_cpu_voltage_update(tegra, cpu_rdev, | 363 | 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 | |||
| 334 | return -EPERM; | 372 | return -EPERM; |
| 335 | } | 373 | } |
| 336 | 374 | ||
| 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 | |||
| 337 | static int tegra20_regulator_prepare_reboot(struct tegra_regulator_coupler *tegra, | 432 | static int tegra20_regulator_prepare_reboot(struct tegra_regulator_coupler *tegra, |
| 338 | bool sys_reboot_mode) | 433 | bool sys_reboot_mode) |
| 339 | { | 434 | { |
| @@ -444,6 +539,7 @@ static struct tegra_regulator_coupler tegra20_coupler = { · 104 unmodified lines | |||
| 444 | .balance_voltage = tegra20_regulator_balance_voltage, | 539 | .balance_voltage = tegra20_regulator_balance_voltage, |
| 445 | }, | 540 | }, |
| 446 | .reboot_notifier.notifier_call = tegra20_regulator_reboot, | 541 | .reboot_notifier.notifier_call = tegra20_regulator_reboot, |
| 542 | .suspend_notifier.notifier_call = tegra20_regulator_suspend, | ||
| 447 | }; | 543 | }; |
| 448 | 544 | ||
| 449 | static int __init tegra_regulator_coupler_init(void) | 545 | static int __init tegra_regulator_coupler_init(void) |
| @@ -456,6 +552,9 @@ static int __init tegra_regulator_coupler_init(void) · 6 unmodified lines | |||
| 456 | err = register_reboot_notifier(&tegra20_coupler.reboot_notifier); | 552 | err = register_reboot_notifier(&tegra20_coupler.reboot_notifier); |
| 457 | WARN_ON(err); | 553 | WARN_ON(err); |
| 458 | 554 | ||
| 555 | err = register_pm_notifier(&tegra20_coupler.suspend_notifier); | ||
| 556 | WARN_ON(err); | ||
| 557 | |||
| 459 | return regulator_coupler_register(&tegra20_coupler.coupler); | 558 | return regulator_coupler_register(&tegra20_coupler.coupler); |
| 460 | } | 559 | } |
| 461 | arch_initcall(tegra_regulator_coupler_init); | 560 | arch_initcall(tegra_regulator_coupler_init); |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | |||
| 16 | #include <linux/regulator/coupler.h> | 16 | #include <linux/regulator/coupler.h> |
| 17 | #include <linux/regulator/driver.h> | 17 | #include <linux/regulator/driver.h> |
| 18 | #include <linux/regulator/machine.h> | 18 | #include <linux/regulator/machine.h> |
| 19 | #include <linux/suspend.h> | ||
| 19 | 20 | ||
| 20 | #include <soc/tegra/fuse.h> | 21 | #include <soc/tegra/fuse.h> |
| 21 | #include <soc/tegra/pmc.h> | 22 | #include <soc/tegra/pmc.h> |
| @@ -25,9 +26,12 @@ struct tegra_regulator_coupler { · 3 unmodified lines | |||
| 25 | struct regulator_dev *core_rdev; | 26 | struct regulator_dev *core_rdev; |
| 26 | struct regulator_dev *cpu_rdev; | 27 | struct regulator_dev *cpu_rdev; |
| 27 | struct notifier_block reboot_notifier; | 28 | struct notifier_block reboot_notifier; |
| 29 | struct notifier_block suspend_notifier; | ||
| 28 | int core_min_uV, cpu_min_uV; | 30 | int core_min_uV, cpu_min_uV; |
| 29 | bool sys_reboot_mode_req; | 31 | bool sys_reboot_mode_req; |
| 30 | bool sys_reboot_mode; | 32 | bool sys_reboot_mode; |
| 33 | bool sys_suspend_mode_req; | ||
| 34 | bool sys_suspend_mode; | ||
| 31 | }; | 35 | }; |
| 32 | 36 | ||
| 33 | static inline struct tegra_regulator_coupler * | 37 | static inline struct tegra_regulator_coupler * |
| @@ -113,6 +117,52 @@ static int tegra30_core_cpu_limit(int cpu_uV) · 79 unmodified lines | |||
| 113 | return -EINVAL; | 117 | return -EINVAL; |
| 114 | } | 118 | } |
| 115 | 119 | ||
| 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 | |||
| 116 | static int tegra30_voltage_update(struct tegra_regulator_coupler *tegra, | 166 | static int tegra30_voltage_update(struct tegra_regulator_coupler *tegra, |
| 117 | struct regulator_dev *cpu_rdev, | 167 | struct regulator_dev *cpu_rdev, |
| 118 | struct regulator_dev *core_rdev) | 168 | struct regulator_dev *core_rdev) |
| @@ -168,6 +218,11 @@ static int tegra30_voltage_update(struct tegra_regulator_coupler *tegra, · 49 unmodified lines | |||
| 168 | if (err) | 218 | if (err) |
| 169 | return err; | 219 | return err; |
| 170 | 220 | ||
| 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 | |||
| 171 | core_uV = regulator_get_voltage_rdev(core_rdev); | 226 | core_uV = regulator_get_voltage_rdev(core_rdev); |
| 172 | if (core_uV < 0) | 227 | if (core_uV < 0) |
| 173 | return core_uV; | 228 | return core_uV; |
| @@ -223,6 +278,11 @@ static int tegra30_voltage_update(struct tegra_regulator_coupler *tegra, · 49 unmodified lines | |||
| 223 | if (tegra->sys_reboot_mode) | 278 | if (tegra->sys_reboot_mode) |
| 224 | cpu_min_uV = max(cpu_min_uV, tegra->cpu_min_uV); | 279 | cpu_min_uV = max(cpu_min_uV, tegra->cpu_min_uV); |
| 225 | 280 | ||
| 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 | |||
| 226 | if (core_min_limited_uV > core_uV) { | 286 | if (core_min_limited_uV > core_uV) { |
| 227 | pr_err("core voltage constraint violated: %d %d %d\n", | 287 | pr_err("core voltage constraint violated: %d %d %d\n", |
| 228 | core_uV, core_min_limited_uV, cpu_uV); | 288 | 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 | |||
| 292 | } | 352 | } |
| 293 | 353 | ||
| 294 | tegra->sys_reboot_mode = READ_ONCE(tegra->sys_reboot_mode_req); | 354 | tegra->sys_reboot_mode = READ_ONCE(tegra->sys_reboot_mode_req); |
| 355 | tegra->sys_suspend_mode = READ_ONCE(tegra->sys_suspend_mode_req); | ||
| 295 | 356 | ||
| 296 | return tegra30_voltage_update(tegra, cpu_rdev, core_rdev); | 357 | return tegra30_voltage_update(tegra, cpu_rdev, core_rdev); |
| 297 | } | 358 | } |
| 298 | 359 | ||
| 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 | |||
| 299 | static int tegra30_regulator_prepare_reboot(struct tegra_regulator_coupler *tegra, | 417 | static int tegra30_regulator_prepare_reboot(struct tegra_regulator_coupler *tegra, |
| 300 | bool sys_reboot_mode) | 418 | bool sys_reboot_mode) |
| 301 | { | 419 | { |
| @@ -395,6 +513,7 @@ static struct tegra_regulator_coupler tegra30_coupler = { · 93 unmodified lines | |||
| 395 | .balance_voltage = tegra30_regulator_balance_voltage, | 513 | .balance_voltage = tegra30_regulator_balance_voltage, |
| 396 | }, | 514 | }, |
| 397 | .reboot_notifier.notifier_call = tegra30_regulator_reboot, | 515 | .reboot_notifier.notifier_call = tegra30_regulator_reboot, |
| 516 | .suspend_notifier.notifier_call = tegra30_regulator_suspend, | ||
| 398 | }; | 517 | }; |
| 399 | 518 | ||
| 400 | static int __init tegra_regulator_coupler_init(void) | 519 | static int __init tegra_regulator_coupler_init(void) |
| @@ -407,6 +526,9 @@ static int __init tegra_regulator_coupler_init(void) · 6 unmodified lines | |||
| 407 | err = register_reboot_notifier(&tegra30_coupler.reboot_notifier); | 526 | err = register_reboot_notifier(&tegra30_coupler.reboot_notifier); |
| 408 | WARN_ON(err); | 527 | WARN_ON(err); |
| 409 | 528 | ||
| 529 | err = register_pm_notifier(&tegra30_coupler.suspend_notifier); | ||
| 530 | WARN_ON(err); | ||
| 531 | |||
| 410 | return regulator_coupler_register(&tegra30_coupler.coupler); | 532 | return regulator_coupler_register(&tegra30_coupler.coupler); |
| 411 | } | 533 | } |
| 412 | arch_initcall(tegra_regulator_coupler_init); | 534 | arch_initcall(tegra_regulator_coupler_init); |
| @@ -40,7 +40,8 @@ static const struct k3_soc_id { · 39 unmodified lines | |||
| 40 | { 0xBB5A, "AM65X" }, | 40 | { 0xBB5A, "AM65X" }, |
| 41 | { 0xBB64, "J721E" }, | 41 | { 0xBB64, "J721E" }, |
| 42 | { 0xBB6D, "J7200" }, | 42 | { 0xBB6D, "J7200" }, |
| 43 | { 0xBB38, "AM64X" } | 43 | { 0xBB38, "AM64X" }, |
| 44 | { 0xBB75, "J721S2"}, | ||
| 44 | }; | 45 | }; |
| 45 | 46 | ||
| 46 | static int | 47 | static int |
| @@ -646,31 +646,31 @@ static int dma_init(struct device_node *cloud, struct device_node *dma_node) · 645 unmodified lines | |||
| 646 | } | 646 | } |
| 647 | 647 | ||
| 648 | dma->reg_global = pktdma_get_regs(dma, node, 0, &size); | 648 | dma->reg_global = pktdma_get_regs(dma, node, 0, &size); |
| 649 | if (!dma->reg_global) | 649 | if (IS_ERR(dma->reg_global)) |
| 650 | return -ENODEV; | 650 | return PTR_ERR(dma->reg_global); |
| 651 | if (size < sizeof(struct reg_global)) { | 651 | if (size < sizeof(struct reg_global)) { |
| 652 | dev_err(kdev->dev, "bad size %pa for global regs\n", &size); | 652 | dev_err(kdev->dev, "bad size %pa for global regs\n", &size); |
| 653 | return -ENODEV; | 653 | return -ENODEV; |
| 654 | } | 654 | } |
| 655 | 655 | ||
| 656 | dma->reg_tx_chan = pktdma_get_regs(dma, node, 1, &size); | 656 | dma->reg_tx_chan = pktdma_get_regs(dma, node, 1, &size); |
| 657 | if (!dma->reg_tx_chan) | 657 | if (IS_ERR(dma->reg_tx_chan)) |
| 658 | return -ENODEV; | 658 | return PTR_ERR(dma->reg_tx_chan); |
| 659 | 659 | ||
| 660 | max_tx_chan = size / sizeof(struct reg_chan); | 660 | max_tx_chan = size / sizeof(struct reg_chan); |
| 661 | dma->reg_rx_chan = pktdma_get_regs(dma, node, 2, &size); | 661 | dma->reg_rx_chan = pktdma_get_regs(dma, node, 2, &size); |
| 662 | if (!dma->reg_rx_chan) | 662 | if (IS_ERR(dma->reg_rx_chan)) |
| 663 | return -ENODEV; | 663 | return PTR_ERR(dma->reg_rx_chan); |
| 664 | 664 | ||
| 665 | max_rx_chan = size / sizeof(struct reg_chan); | 665 | max_rx_chan = size / sizeof(struct reg_chan); |
| 666 | dma->reg_tx_sched = pktdma_get_regs(dma, node, 3, &size); | 666 | dma->reg_tx_sched = pktdma_get_regs(dma, node, 3, &size); |
| 667 | if (!dma->reg_tx_sched) | 667 | if (IS_ERR(dma->reg_tx_sched)) |
| 668 | return -ENODEV; | 668 | return PTR_ERR(dma->reg_tx_sched); |
| 669 | 669 | ||
| 670 | max_tx_sched = size / sizeof(struct reg_tx_sched); | 670 | max_tx_sched = size / sizeof(struct reg_tx_sched); |
| 671 | dma->reg_rx_flow = pktdma_get_regs(dma, node, 4, &size); | 671 | dma->reg_rx_flow = pktdma_get_regs(dma, node, 4, &size); |
| 672 | if (!dma->reg_rx_flow) | 672 | if (IS_ERR(dma->reg_rx_flow)) |
| 673 | return -ENODEV; | 673 | return PTR_ERR(dma->reg_rx_flow); |
| 674 | 674 | ||
| 675 | max_rx_flow = size / sizeof(struct reg_rx_flow); | 675 | max_rx_flow = size / sizeof(struct reg_rx_flow); |
| 676 | dma->rx_priority = DMA_PRIO_DEFAULT; | 676 | dma->rx_priority = DMA_PRIO_DEFAULT; |
| @@ -129,7 +129,7 @@ static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node) · 128 unmodified lines | |||
| 129 | 129 | ||
| 130 | clks_np = of_get_child_by_name(cfg_node, "clocks"); | 130 | clks_np = of_get_child_by_name(cfg_node, "clocks"); |
| 131 | if (!clks_np) { | 131 | 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); |
| 133 | return -ENODEV; | 133 | return -ENODEV; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| @@ -20,8 +20,6 @@ · 19 unmodified lines | |||
| 20 | #include <linux/firmware/xlnx-zynqmp.h> | 20 | #include <linux/firmware/xlnx-zynqmp.h> |
| 21 | 21 | ||
| 22 | #define ZYNQMP_NUM_DOMAINS (100) | 22 | #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) | ||
| 25 | 23 | ||
| 26 | static int min_capability; | 24 | static int min_capability; |
| 27 | 25 | ||
| @@ -29,14 +27,17 @@ static int min_capability; · 1 unmodified line | |||
| 29 | * struct zynqmp_pm_domain - Wrapper around struct generic_pm_domain | 27 | * struct zynqmp_pm_domain - Wrapper around struct generic_pm_domain |
| 30 | * @gpd: Generic power domain | 28 | * @gpd: Generic power domain |
| 31 | * @node_id: PM node ID corresponding to device inside PM domain | 29 | * @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 |
| 33 | */ | 31 | */ |
| 34 | struct zynqmp_pm_domain { | 32 | struct zynqmp_pm_domain { |
| 35 | struct generic_pm_domain gpd; | 33 | struct generic_pm_domain gpd; |
| 36 | u32 node_id; | 34 | u32 node_id; |
| 37 | u8 flags; | 35 | bool requested; |
| 38 | }; | 36 | }; |
| 39 | 37 | ||
| 38 | #define to_zynqmp_pm_domain(pm_domain) \ | ||
| 39 | container_of(pm_domain, struct zynqmp_pm_domain, gpd) | ||
| 40 | |||
| 40 | /** | 41 | /** |
| 41 | * zynqmp_gpd_is_active_wakeup_path() - Check if device is in wakeup source | 42 | * zynqmp_gpd_is_active_wakeup_path() - Check if device is in wakeup source |
| 42 | * path | 43 | * path |
| @@ -71,21 +72,23 @@ static int zynqmp_gpd_is_active_wakeup_path(struct device *dev, void *not_used) · 28 unmodified lines | |||
| 71 | */ | 72 | */ |
| 72 | static int zynqmp_gpd_power_on(struct generic_pm_domain *domain) | 73 | static int zynqmp_gpd_power_on(struct generic_pm_domain *domain) |
| 73 | { | 74 | { |
| 75 | struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain); | ||
| 74 | int ret; | 76 | int ret; |
| 75 | struct zynqmp_pm_domain *pd; | ||
| 76 | 77 | ||
| 77 | pd = container_of(domain, struct zynqmp_pm_domain, gpd); | ||
| 78 | ret = zynqmp_pm_set_requirement(pd->node_id, | 78 | ret = zynqmp_pm_set_requirement(pd->node_id, |
| 79 | ZYNQMP_PM_CAPABILITY_ACCESS, | 79 | ZYNQMP_PM_CAPABILITY_ACCESS, |
| 80 | ZYNQMP_PM_MAX_QOS, | 80 | ZYNQMP_PM_MAX_QOS, |
| 81 | ZYNQMP_PM_REQUEST_ACK_BLOCKING); | 81 | ZYNQMP_PM_REQUEST_ACK_BLOCKING); |
| 82 | if (ret) { | 82 | if (ret) { |
| 83 | pr_err("%s() %s set requirement for node %d failed: %d\n", | 83 | dev_err(&domain->dev, |
| 84 | __func__, domain->name, pd->node_id, ret); | 84 | "failed to set requirement to 0x%x for PM node id %d: %d\n", |
| 85 | ZYNQMP_PM_CAPABILITY_ACCESS, pd->node_id, ret); | ||
| 85 | return ret; | 86 | return ret; |
| 86 | } | 87 | } |
| 87 | 88 | ||
| 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 | |||
| 89 | return 0; | 92 | return 0; |
| 90 | } | 93 | } |
| 91 | 94 | ||
| @@ -100,18 +103,16 @@ static int zynqmp_gpd_power_on(struct generic_pm_domain *domain) · 8 unmodified lines | |||
| 100 | */ | 103 | */ |
| 101 | static int zynqmp_gpd_power_off(struct generic_pm_domain *domain) | 104 | static int zynqmp_gpd_power_off(struct generic_pm_domain *domain) |
| 102 | { | 105 | { |
| 106 | struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain); | ||
| 103 | int ret; | 107 | int ret; |
| 104 | struct pm_domain_data *pdd, *tmp; | 108 | struct pm_domain_data *pdd, *tmp; |
| 105 | struct zynqmp_pm_domain *pd; | ||
| 106 | u32 capabilities = min_capability; | 109 | u32 capabilities = min_capability; |
| 107 | bool may_wakeup; | 110 | bool may_wakeup; |
| 108 | 111 | ||
| 109 | pd = container_of(domain, struct zynqmp_pm_domain, gpd); | ||
| 110 | |||
| 111 | /* If domain is already released there is nothing to be done */ | 112 | /* If domain is already released there is nothing to be done */ |
| 112 | if (!(pd->flags & ZYNQMP_PM_DOMAIN_REQUESTED)) { | 113 | if (!pd->requested) { |
| 113 | pr_debug("%s() %s domain is already released\n", | 114 | dev_dbg(&domain->dev, "PM node id %d is already released\n", |
| 114 | __func__, domain->name); | 115 | pd->node_id); |
| 115 | return 0; | 116 | return 0; |
| 116 | } | 117 | } |
| 117 | 118 | ||
| @@ -128,17 +129,16 @@ static int zynqmp_gpd_power_off(struct generic_pm_domain *domain) · 10 unmodified lines | |||
| 128 | 129 | ||
| 129 | ret = zynqmp_pm_set_requirement(pd->node_id, capabilities, 0, | 130 | ret = zynqmp_pm_set_requirement(pd->node_id, capabilities, 0, |
| 130 | ZYNQMP_PM_REQUEST_ACK_NO); | 131 | ZYNQMP_PM_REQUEST_ACK_NO); |
| 131 | /** | ||
| 132 | * If powering down of any node inside this domain fails, | ||
| 133 | * report and return the error | ||
| 134 | */ | ||
| 135 | if (ret) { | 132 | if (ret) { |
| 136 | pr_err("%s() %s set requirement for node %d failed: %d\n", | 133 | dev_err(&domain->dev, |
| 137 | __func__, domain->name, pd->node_id, ret); | 134 | "failed to set requirement to 0x%x for PM node id %d: %d\n", |
| 135 | capabilities, pd->node_id, ret); | ||
| 138 | return ret; | 136 | return ret; |
| 139 | } | 137 | } |
| 140 | 138 | ||
| 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 | |||
| 142 | return 0; | 142 | return 0; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| @@ -152,10 +152,14 @@ static int zynqmp_gpd_power_off(struct generic_pm_domain *domain) · 7 unmodified lines | |||
| 152 | static int zynqmp_gpd_attach_dev(struct generic_pm_domain *domain, | 152 | static int zynqmp_gpd_attach_dev(struct generic_pm_domain *domain, |
| 153 | struct device *dev) | 153 | struct device *dev) |
| 154 | { | 154 | { |
| 155 | struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain); | ||
| 156 | struct device_link *link; | ||
| 155 | int ret; | 157 | int ret; |
| 156 | struct zynqmp_pm_domain *pd; | ||
| 157 | 158 | ||
| 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)); | ||
| 159 | 163 | ||
| 160 | /* If this is not the first device to attach there is nothing to do */ | 164 | /* If this is not the first device to attach there is nothing to do */ |
| 161 | if (domain->device_count) | 165 | if (domain->device_count) |
| @@ -163,17 +167,17 @@ static int zynqmp_gpd_attach_dev(struct generic_pm_domain *domain, · 1 unmodified line | |||
| 163 | 167 | ||
| 164 | ret = zynqmp_pm_request_node(pd->node_id, 0, 0, | 168 | ret = zynqmp_pm_request_node(pd->node_id, 0, 0, |
| 165 | ZYNQMP_PM_REQUEST_ACK_BLOCKING); | 169 | ZYNQMP_PM_REQUEST_ACK_BLOCKING); |
| 166 | /* If requesting a node fails print and return the error */ | ||
| 167 | if (ret) { | 170 | if (ret) { |
| 168 | pr_err("%s() %s request failed for node %d: %d\n", | 171 | dev_err(&domain->dev, "%s request failed for node %d: %d\n", |
| 169 | __func__, domain->name, pd->node_id, ret); | 172 | domain->name, pd->node_id, ret); |
| 170 | return ret; | 173 | return ret; |
| 171 | } | 174 | } |
| 172 | 175 | ||
| 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); | ||
| 174 | 180 | ||
| 175 | pr_debug("%s() %s attached to %s domain\n", __func__, | ||
| 176 | dev_name(dev), domain->name); | ||
| 177 | return 0; | 181 | return 0; |
| 178 | } | 182 | } |
| 179 | 183 | ||
| @@ -185,27 +189,24 @@ static int zynqmp_gpd_attach_dev(struct generic_pm_domain *domain, · 5 unmodified lines | |||
| 185 | static void zynqmp_gpd_detach_dev(struct generic_pm_domain *domain, | 189 | static void zynqmp_gpd_detach_dev(struct generic_pm_domain *domain, |
| 186 | struct device *dev) | 190 | struct device *dev) |
| 187 | { | 191 | { |
| 192 | struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain); | ||
| 188 | int ret; | 193 | int ret; |
| 189 | struct zynqmp_pm_domain *pd; | ||
| 190 | |||
| 191 | pd = container_of(domain, struct zynqmp_pm_domain, gpd); | ||
| 192 | 194 | ||
| 193 | /* If this is not the last device to detach there is nothing to do */ | 195 | /* If this is not the last device to detach there is nothing to do */ |
| 194 | if (domain->device_count) | 196 | if (domain->device_count) |
| 195 | return; | 197 | return; |
| 196 | 198 | ||
| 197 | ret = zynqmp_pm_release_node(pd->node_id); | 199 | ret = zynqmp_pm_release_node(pd->node_id); |
| 198 | /* If releasing a node fails print the error and return */ | ||
| 199 | if (ret) { | 200 | if (ret) { |
| 200 | pr_err("%s() %s release failed for node %d: %d\n", | 201 | dev_err(&domain->dev, "failed to release PM node id %d: %d\n", |
| 201 | __func__, domain->name, pd->node_id, ret); | 202 | pd->node_id, ret); |
| 202 | return; | 203 | return; |
| 203 | } | 204 | } |
| 204 | 205 | ||
| 205 | pd->flags &= ~ZYNQMP_PM_DOMAIN_REQUESTED; | 206 | pd->requested = false; |
| 206 | 207 | ||
| 207 | pr_debug("%s() %s detached from %s domain\n", __func__, | 208 | dev_dbg(&domain->dev, "%s released PM node id %d\n", |
| 208 | dev_name(dev), domain->name); | 209 | dev_name(dev), pd->node_id); |
| 209 | } | 210 | } |
| 210 | 211 | ||
| 211 | static struct generic_pm_domain *zynqmp_gpd_xlate | 212 | static struct generic_pm_domain *zynqmp_gpd_xlate |
| @@ -215,7 +216,7 @@ static struct generic_pm_domain *zynqmp_gpd_xlate · 3 unmodified lines | |||
| 215 | unsigned int i, idx = genpdspec->args[0]; | 216 | unsigned int i, idx = genpdspec->args[0]; |
| 216 | struct zynqmp_pm_domain *pd; | 217 | struct zynqmp_pm_domain *pd; |
| 217 | 218 | ||
| 218 | pd = container_of(genpd_data->domains[0], struct zynqmp_pm_domain, gpd); | 219 | pd = to_zynqmp_pm_domain(genpd_data->domains[0]); |
| 219 | 220 | ||
| 220 | if (genpdspec->args_count != 1) | 221 | if (genpdspec->args_count != 1) |
| 221 | return ERR_PTR(-EINVAL); | 222 | return ERR_PTR(-EINVAL); |
| @@ -299,9 +300,19 @@ static int zynqmp_gpd_remove(struct platform_device *pdev) · 77 unmodified lines | |||
| 299 | return 0; | 300 | return 0; |
| 300 | } | 301 | } |
| 301 | 302 | ||
| 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 | |||
| 302 | static struct platform_driver zynqmp_power_domain_driver = { | 312 | static struct platform_driver zynqmp_power_domain_driver = { |
| 303 | .driver = { | 313 | .driver = { |
| 304 | .name = "zynqmp_power_controller", | 314 | .name = "zynqmp_power_controller", |
| 315 | .sync_state = zynqmp_gpd_sync_state, | ||
| 305 | }, | 316 | }, |
| 306 | .probe = zynqmp_gpd_probe, | 317 | .probe = zynqmp_gpd_probe, |
| 307 | .remove = zynqmp_gpd_remove, | 318 | .remove = zynqmp_gpd_remove, |
| @@ -178,7 +178,6 @@ static int zynqmp_pm_probe(struct platform_device *pdev) · 177 unmodified lines | |||
| 178 | u32 pm_api_version; | 178 | u32 pm_api_version; |
| 179 | struct mbox_client *client; | 179 | struct mbox_client *client; |
| 180 | 180 | ||
| 181 | zynqmp_pm_init_finalize(); | ||
| 182 | zynqmp_pm_get_api_version(&pm_api_version); | 181 | zynqmp_pm_get_api_version(&pm_api_version); |
| 183 | 182 | ||
| 184 | /* Check PM API version number */ | 183 | /* Check PM API version number */ |
| @@ -156,7 +156,9 @@ static int rpcif_spi_probe(struct platform_device *pdev) · 155 unmodified lines | |||
| 156 | ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_TX_QUAD | SPI_RX_QUAD; | 156 | ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_TX_QUAD | SPI_RX_QUAD; |
| 157 | ctlr->flags = SPI_CONTROLLER_HALF_DUPLEX; | 157 | ctlr->flags = SPI_CONTROLLER_HALF_DUPLEX; |
| 158 | 158 | ||
| 159 | rpcif_hw_init(rpc, false); | 159 | error = rpcif_hw_init(rpc, false); |
| 160 | if (error) | ||
| 161 | return error; | ||
| 160 | 162 | ||
| 161 | error = spi_register_controller(ctlr); | 163 | error = spi_register_controller(ctlr); |
| 162 | if (error) { | 164 | if (error) { |
| @@ -18,12 +18,15 @@ · 17 unmodified lines | |||
| 18 | #include <linux/kthread.h> | 18 | #include <linux/kthread.h> |
| 19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
| 20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/pm_opp.h> | ||
| 21 | #include <linux/pm_runtime.h> | 22 | #include <linux/pm_runtime.h> |
| 22 | #include <linux/of.h> | 23 | #include <linux/of.h> |
| 23 | #include <linux/of_device.h> | 24 | #include <linux/of_device.h> |
| 24 | #include <linux/reset.h> | 25 | #include <linux/reset.h> |
| 25 | #include <linux/spi/spi.h> | 26 | #include <linux/spi/spi.h> |
| 26 | 27 | ||
| 28 | #include <soc/tegra/common.h> | ||
| 29 | |||
| 27 | #define SLINK_COMMAND 0x000 | 30 | #define SLINK_COMMAND 0x000 |
| 28 | #define SLINK_BIT_LENGTH(x) (((x) & 0x1f) << 0) | 31 | #define SLINK_BIT_LENGTH(x) (((x) & 0x1f) << 0) |
| 29 | #define SLINK_WORD_SIZE(x) (((x) & 0x1f) << 5) | 32 | #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 | |||
| 680 | bits_per_word = t->bits_per_word; | 683 | bits_per_word = t->bits_per_word; |
| 681 | speed = t->speed_hz; | 684 | speed = t->speed_hz; |
| 682 | if (speed != tspi->cur_speed) { | 685 | if (speed != tspi->cur_speed) { |
| 683 | clk_set_rate(tspi->clk, speed * 4); | 686 | dev_pm_opp_set_rate(tspi->dev, speed * 4); |
| 684 | tspi->cur_speed = speed; | 687 | tspi->cur_speed = speed; |
| 685 | } | 688 | } |
| 686 | 689 | ||
| @@ -1066,6 +1069,10 @@ static int tegra_slink_probe(struct platform_device *pdev) · 379 unmodified lines | |||
| 1066 | goto exit_free_master; | 1069 | goto exit_free_master; |
| 1067 | } | 1070 | } |
| 1068 | 1071 | ||
| 1072 | ret = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); | ||
| 1073 | if (ret) | ||
| 1074 | goto exit_free_master; | ||
| 1075 | |||
| 1069 | tspi->max_buf_size = SLINK_FIFO_DEPTH << 2; | 1076 | tspi->max_buf_size = SLINK_FIFO_DEPTH << 2; |
| 1070 | tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN; | 1077 | tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN; |
| 1071 | 1078 | ||
| @@ -20,6 +20,7 @@ · 19 unmodified lines | |||
| 20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
| 21 | #include <linux/uaccess.h> | 21 | #include <linux/uaccess.h> |
| 22 | 22 | ||
| 23 | #include <soc/tegra/common.h> | ||
| 23 | #include <soc/tegra/pmc.h> | 24 | #include <soc/tegra/pmc.h> |
| 24 | 25 | ||
| 25 | #include "uapi.h" | 26 | #include "uapi.h" |
| @@ -920,13 +921,17 @@ static __maybe_unused int tegra_vde_runtime_suspend(struct device *dev) · 894 unmodified lines | |||
| 920 | struct tegra_vde *vde = dev_get_drvdata(dev); | 921 | struct tegra_vde *vde = dev_get_drvdata(dev); |
| 921 | int err; | 922 | int err; |
| 922 | 923 | ||
| 923 | err = tegra_powergate_power_off(TEGRA_POWERGATE_VDEC); | 924 | if (!dev->pm_domain) { |
| 924 | if (err) { | 925 | err = tegra_powergate_power_off(TEGRA_POWERGATE_VDEC); |
| 925 | dev_err(dev, "Failed to power down HW: %d\n", err); | 926 | if (err) { |
| 926 | return err; | 927 | dev_err(dev, "Failed to power down HW: %d\n", err); |
| 928 | return err; | ||
| 929 | } | ||
| 927 | } | 930 | } |
| 928 | 931 | ||
| 929 | clk_disable_unprepare(vde->clk); | 932 | clk_disable_unprepare(vde->clk); |
| 933 | reset_control_release(vde->rst); | ||
| 934 | reset_control_release(vde->rst_mc); | ||
| 930 | 935 | ||
| 931 | return 0; | 936 | return 0; |
| 932 | } | 937 | } |
| @@ -936,14 +941,45 @@ static __maybe_unused int tegra_vde_runtime_resume(struct device *dev) · 3 unmodified lines | |||
| 936 | struct tegra_vde *vde = dev_get_drvdata(dev); | 941 | struct tegra_vde *vde = dev_get_drvdata(dev); |
| 937 | int err; | 942 | int err; |
| 938 | 943 | ||
| 939 | err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_VDEC, | 944 | err = reset_control_acquire(vde->rst_mc); |
| 940 | vde->clk, vde->rst); | ||
| 941 | if (err) { | 945 | 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); |
| 943 | return err; | 947 | return err; |
| 944 | } | 948 | } |
| 945 | 949 | ||
| 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 | |||
| 946 | return 0; | 975 | 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; | ||
| 947 | } | 983 | } |
| 948 | 984 | ||
| 949 | static int tegra_vde_probe(struct platform_device *pdev) | 985 | 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 | |||
| 1001 | return err; | 1037 | return err; |
| 1002 | } | 1038 | } |
| 1003 | 1039 | ||
| 1004 | vde->rst = devm_reset_control_get(dev, NULL); | 1040 | vde->rst = devm_reset_control_get_exclusive_released(dev, NULL); |
| 1005 | if (IS_ERR(vde->rst)) { | 1041 | if (IS_ERR(vde->rst)) { |
| 1006 | err = PTR_ERR(vde->rst); | 1042 | err = PTR_ERR(vde->rst); |
| 1007 | dev_err(dev, "Could not get VDE reset %d\n", err); | 1043 | dev_err(dev, "Could not get VDE reset %d\n", err); |
| 1008 | return err; | 1044 | return err; |
| 1009 | } | 1045 | } |
| 1010 | 1046 | ||
| 1011 | vde->rst_mc = devm_reset_control_get_optional(dev, "mc"); | 1047 | vde->rst_mc = devm_reset_control_get_optional_exclusive_released(dev, "mc"); |
| 1012 | if (IS_ERR(vde->rst_mc)) { | 1048 | if (IS_ERR(vde->rst_mc)) { |
| 1013 | err = PTR_ERR(vde->rst_mc); | 1049 | err = PTR_ERR(vde->rst_mc); |
| 1014 | dev_err(dev, "Could not get MC reset %d\n", err); | 1050 | 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 | |||
| 1026 | return err; | 1062 | return err; |
| 1027 | } | 1063 | } |
| 1028 | 1064 | ||
| 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 | |||
| 1029 | vde->iram_pool = of_gen_pool_get(dev->of_node, "iram", 0); | 1071 | vde->iram_pool = of_gen_pool_get(dev->of_node, "iram", 0); |
| 1030 | if (!vde->iram_pool) { | 1072 | if (!vde->iram_pool) { |
| 1031 | dev_err(dev, "Could not get IRAM pool\n"); | 1073 | 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 | |||
| 1133 | * On some devices bootloader isn't ready to a power-gated VDE on | 1175 | * On some devices bootloader isn't ready to a power-gated VDE on |
| 1134 | * a warm-reboot, machine will hang in that case. | 1176 | * a warm-reboot, machine will hang in that case. |
| 1135 | */ | 1177 | */ |
| 1136 | if (pm_runtime_status_suspended(&pdev->dev)) | 1178 | pm_runtime_get_sync(&pdev->dev); |
| 1137 | tegra_vde_runtime_resume(&pdev->dev); | ||
| 1138 | } | 1179 | } |
| 1139 | 1180 | ||
| 1140 | static __maybe_unused int tegra_vde_pm_suspend(struct device *dev) | 1181 | static __maybe_unused int tegra_vde_pm_suspend(struct device *dev) |
| @@ -2,6 +2,7 @@ · 1 unmodified line | |||
| 2 | obj-$(CONFIG_OPTEE) += optee.o | 2 | obj-$(CONFIG_OPTEE) += optee.o |
| 3 | optee-objs += core.o | 3 | optee-objs += core.o |
| 4 | optee-objs += call.o | 4 | optee-objs += call.o |
| 5 | optee-objs += notif.o | ||
| 5 | optee-objs += rpc.o | 6 | optee-objs += rpc.o |
| 6 | optee-objs += supp.o | 7 | optee-objs += supp.o |
| 7 | optee-objs += device.o | 8 | optee-objs += device.o |
| @@ -157,6 +157,7 @@ void optee_remove_common(struct optee *optee) · 156 unmodified lines | |||
| 157 | /* Unregister OP-TEE specific client devices on TEE bus */ | 157 | /* Unregister OP-TEE specific client devices on TEE bus */ |
| 158 | optee_unregister_devices(); | 158 | optee_unregister_devices(); |
| 159 | 159 | ||
| 160 | optee_notif_uninit(optee); | ||
| 160 | /* | 161 | /* |
| 161 | * The two devices have to be unregistered before we can free the | 162 | * The two devices have to be unregistered before we can free the |
| 162 | * other resources. | 163 | * other resources. |
| @@ -165,7 +166,6 @@ void optee_remove_common(struct optee *optee) · 2 unmodified lines | |||
| 165 | tee_device_unregister(optee->teedev); | 166 | tee_device_unregister(optee->teedev); |
| 166 | 167 | ||
| 167 | tee_shm_pool_free(optee->pool); | 168 | tee_shm_pool_free(optee->pool); |
| 168 | optee_wait_queue_exit(&optee->wait_queue); | ||
| 169 | optee_supp_uninit(&optee->supp); | 169 | optee_supp_uninit(&optee->supp); |
| 170 | mutex_destroy(&optee->call_queue.mutex); | 170 | mutex_destroy(&optee->call_queue.mutex); |
| 171 | } | 171 | } |
| @@ -855,9 +855,13 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev) · 854 unmodified lines | |||
| 855 | mutex_init(&optee->ffa.mutex); | 855 | mutex_init(&optee->ffa.mutex); |
| 856 | mutex_init(&optee->call_queue.mutex); | 856 | mutex_init(&optee->call_queue.mutex); |
| 857 | INIT_LIST_HEAD(&optee->call_queue.waiters); | 857 | INIT_LIST_HEAD(&optee->call_queue.waiters); |
| 858 | optee_wait_queue_init(&optee->wait_queue); | ||
| 859 | optee_supp_init(&optee->supp); | 858 | optee_supp_init(&optee->supp); |
| 860 | ffa_dev_set_drvdata(ffa_dev, optee); | 859 | 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 | } | ||
| 861 | 865 | ||
| 862 | rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES); | 866 | rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES); |
| 863 | if (rc) { | 867 | if (rc) { |
| @@ -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 | } | ||
| @@ -318,6 +318,13 @@ struct optee_msg_arg { · 317 unmodified lines | |||
| 318 | * [in] param[0].u.rmem.shm_ref holds shared memory reference | 318 | * [in] param[0].u.rmem.shm_ref holds shared memory reference |
| 319 | * [in] param[0].u.rmem.offs 0 | 319 | * [in] param[0].u.rmem.offs 0 |
| 320 | * [in] param[0].u.rmem.size 0 | 320 | * [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. | ||
| 321 | */ | 328 | */ |
| 322 | #define OPTEE_MSG_CMD_OPEN_SESSION 0 | 329 | #define OPTEE_MSG_CMD_OPEN_SESSION 0 |
| 323 | #define OPTEE_MSG_CMD_INVOKE_COMMAND 1 | 330 | #define OPTEE_MSG_CMD_INVOKE_COMMAND 1 |
| @@ -325,6 +332,8 @@ struct optee_msg_arg { · 1 unmodified line | |||
| 325 | #define OPTEE_MSG_CMD_CANCEL 3 | 332 | #define OPTEE_MSG_CMD_CANCEL 3 |
| 326 | #define OPTEE_MSG_CMD_REGISTER_SHM 4 | 333 | #define OPTEE_MSG_CMD_REGISTER_SHM 4 |
| 327 | #define OPTEE_MSG_CMD_UNREGISTER_SHM 5 | 334 | #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 | ||
| 328 | #define OPTEE_MSG_FUNCID_CALL_WITH_ARG 0x0004 | 337 | #define OPTEE_MSG_FUNCID_CALL_WITH_ARG 0x0004 |
| 329 | 338 | ||
| 330 | #endif /* _OPTEE_MSG_H */ | 339 | #endif /* _OPTEE_MSG_H */ |
| @@ -28,6 +28,13 @@ · 27 unmodified lines | |||
| 28 | 28 | ||
| 29 | #define TEEC_ORIGIN_COMMS 0x00000002 | 29 | #define TEEC_ORIGIN_COMMS 0x00000002 |
| 30 | 30 | ||
| 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 | |||
| 31 | typedef void (optee_invoke_fn)(unsigned long, unsigned long, unsigned long, | 38 | typedef void (optee_invoke_fn)(unsigned long, unsigned long, unsigned long, |
| 32 | unsigned long, unsigned long, unsigned long, | 39 | unsigned long, unsigned long, unsigned long, |
| 33 | unsigned long, unsigned long, | 40 | unsigned long, unsigned long, |
| @@ -44,10 +51,13 @@ struct optee_call_queue { · 10 unmodified lines | |||
| 44 | struct list_head waiters; | 51 | struct list_head waiters; |
| 45 | }; | 52 | }; |
| 46 | 53 | ||
| 47 | struct optee_wait_queue { | 54 | struct optee_notif { |
| 48 | /* Serializes access to this struct */ | 55 | u_int max_key; |
| 49 | struct mutex mu; | 56 | struct tee_context *ctx; |
| 57 | /* Serializes access to the elements below in this struct */ | ||
| 58 | spinlock_t lock; | ||
| 50 | struct list_head db; | 59 | struct list_head db; |
| 60 | u_long *bitmap; | ||
| 51 | }; | 61 | }; |
| 52 | 62 | ||
| 53 | /** | 63 | /** |
| @@ -79,6 +89,7 @@ struct optee_smc { · 25 unmodified lines | |||
| 79 | optee_invoke_fn *invoke_fn; | 89 | optee_invoke_fn *invoke_fn; |
| 80 | void *memremaped_shm; | 90 | void *memremaped_shm; |
| 81 | u32 sec_caps; | 91 | u32 sec_caps; |
| 92 | unsigned int notif_irq; | ||
| 82 | }; | 93 | }; |
| 83 | 94 | ||
| 84 | /** | 95 | /** |
| @@ -129,8 +140,7 @@ struct optee_ops { · 44 unmodified lines | |||
| 129 | * @smc: specific to SMC ABI | 140 | * @smc: specific to SMC ABI |
| 130 | * @ffa: specific to FF-A ABI | 141 | * @ffa: specific to FF-A ABI |
| 131 | * @call_queue: queue of threads waiting to call @invoke_fn | 142 | * @call_queue: queue of threads waiting to call @invoke_fn |
| 132 | * @wait_queue: queue of threads from secure world waiting for a | 143 | * @notif: notification synchronization struct |
| 133 | * secure world sync object | ||
| 134 | * @supp: supplicant synchronization struct for RPC to supplicant | 144 | * @supp: supplicant synchronization struct for RPC to supplicant |
| 135 | * @pool: shared memory pool | 145 | * @pool: shared memory pool |
| 136 | * @rpc_arg_count: If > 0 number of RPC parameters to make room for | 146 | * @rpc_arg_count: If > 0 number of RPC parameters to make room for |
| @@ -147,7 +157,7 @@ struct optee { · 10 unmodified lines | |||
| 147 | struct optee_ffa ffa; | 157 | struct optee_ffa ffa; |
| 148 | }; | 158 | }; |
| 149 | struct optee_call_queue call_queue; | 159 | struct optee_call_queue call_queue; |
| 150 | struct optee_wait_queue wait_queue; | 160 | struct optee_notif notif; |
| 151 | struct optee_supp supp; | 161 | struct optee_supp supp; |
| 152 | struct tee_shm_pool *pool; | 162 | struct tee_shm_pool *pool; |
| 153 | unsigned int rpc_arg_count; | 163 | unsigned int rpc_arg_count; |
| @@ -185,8 +195,10 @@ struct optee_call_ctx { · 31 unmodified lines | |||
| 185 | size_t num_entries; | 195 | size_t num_entries; |
| 186 | }; | 196 | }; |
| 187 | 197 | ||
| 188 | void optee_wait_queue_init(struct optee_wait_queue *wq); | 198 | int optee_notif_init(struct optee *optee, u_int max_key); |
| 189 | void optee_wait_queue_exit(struct optee_wait_queue *wq); | 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); | ||
| 190 | 202 | ||
| 191 | u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params, | 203 | u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params, |
| 192 | struct tee_param *param); | 204 | struct tee_param *param); |
| @@ -28,24 +28,27 @@ · 27 unmodified lines | |||
| 28 | #define OPTEE_RPC_CMD_GET_TIME 3 | 28 | #define OPTEE_RPC_CMD_GET_TIME 3 |
| 29 | 29 | ||
| 30 | /* | 30 | /* |
| 31 | * Wait queue primitive, helper for secure world to implement a wait queue. | 31 | * Notification from/to secure world. |
| 32 | * | 32 | * |
| 33 | * If secure world needs to wait for a secure world mutex it issues a sleep | 33 | * If secure world needs to wait for something, for instance a mutex, it |
| 34 | * request instead of spinning in secure world. Conversely is a wakeup | 34 | * does a notification wait request instead of spinning in secure world. |
| 35 | * request issued when a secure world mutex with a thread waiting thread is | 35 | * Conversely can a synchronous notification can be sent when a secure |
| 36 | * unlocked. | 36 | * world mutex with a thread waiting thread is unlocked. |
| 37 | * | 37 | * |
| 38 | * Waiting on a key | 38 | * This interface can also be used to wait for a asynchronous notification |
| 39 | * [in] value[0].a OPTEE_RPC_WAIT_QUEUE_SLEEP | 39 | * which instead is sent via a non-secure interrupt. |
| 40 | * [in] value[0].b Wait key | ||
| 41 | * | 40 | * |
| 42 | * Waking up a key | 41 | * Waiting on notification |
| 43 | * [in] value[0].a OPTEE_RPC_WAIT_QUEUE_WAKEUP | 42 | * [in] value[0].a OPTEE_RPC_NOTIFICATION_WAIT |
| 44 | * [in] value[0].b Wakeup key | 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 | ||
| 45 | */ | 48 | */ |
| 46 | #define OPTEE_RPC_CMD_WAIT_QUEUE 4 | 49 | #define OPTEE_RPC_CMD_NOTIFICATION 4 |
| 47 | #define OPTEE_RPC_WAIT_QUEUE_SLEEP 0 | 50 | #define OPTEE_RPC_NOTIFICATION_WAIT 0 |
| 48 | #define OPTEE_RPC_WAIT_QUEUE_WAKEUP 1 | 51 | #define OPTEE_RPC_NOTIFICATION_SEND 1 |
| 49 | 52 | ||
| 50 | /* | 53 | /* |
| 51 | * Suspend execution | 54 | * Suspend execution |
| @@ -107,6 +107,12 @@ struct optee_smc_call_get_os_revision_result { · 106 unmodified lines | |||
| 107 | /* | 107 | /* |
| 108 | * Call with struct optee_msg_arg as argument | 108 | * Call with struct optee_msg_arg as argument |
| 109 | * | 109 | * |
| 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 | * | ||
| 110 | * Call register usage: | 116 | * Call register usage: |
| 111 | * a0 SMC Function ID, OPTEE_SMC*CALL_WITH_ARG | 117 | * a0 SMC Function ID, OPTEE_SMC*CALL_WITH_ARG |
| 112 | * a1 Upper 32 bits of a 64-bit physical pointer to a struct optee_msg_arg | 118 | * 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 | |||
| 195 | * Normal return register usage: | 201 | * Normal return register usage: |
| 196 | * a0 OPTEE_SMC_RETURN_OK | 202 | * a0 OPTEE_SMC_RETURN_OK |
| 197 | * a1 bitfield of secure world capabilities OPTEE_SMC_SEC_CAP_* | 203 | * 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 | ||
| 199 | * | 206 | * |
| 200 | * Error return register usage: | 207 | * Error return register usage: |
| 201 | * a0 OPTEE_SMC_RETURN_ENOTAVAIL, can't use the capabilities from normal world | 208 | * 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 | |||
| 218 | #define OPTEE_SMC_SEC_CAP_VIRTUALIZATION BIT(3) | 225 | #define OPTEE_SMC_SEC_CAP_VIRTUALIZATION BIT(3) |
| 219 | /* Secure world supports Shared Memory with a NULL reference */ | 226 | /* Secure world supports Shared Memory with a NULL reference */ |
| 220 | #define OPTEE_SMC_SEC_CAP_MEMREF_NULL BIT(4) | 227 | #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) | ||
| 221 | 230 | ||
| 222 | #define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9 | 231 | #define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9 |
| 223 | #define OPTEE_SMC_EXCHANGE_CAPABILITIES \ | 232 | #define OPTEE_SMC_EXCHANGE_CAPABILITIES \ |
| @@ -226,8 +235,8 @@ struct optee_smc_get_shm_config_result { · 2 unmodified lines | |||
| 226 | struct optee_smc_exchange_capabilities_result { | 235 | struct optee_smc_exchange_capabilities_result { |
| 227 | unsigned long status; | 236 | unsigned long status; |
| 228 | unsigned long capabilities; | 237 | unsigned long capabilities; |
| 238 | unsigned long max_notif_value; | ||
| 229 | unsigned long reserved0; | 239 | unsigned long reserved0; |
| 230 | unsigned long reserved1; | ||
| 231 | }; | 240 | }; |
| 232 | 241 | ||
| 233 | /* | 242 | /* |
| @@ -319,6 +328,68 @@ struct optee_smc_disable_shm_cache_result { · 85 unmodified lines | |||
| 319 | #define OPTEE_SMC_GET_THREAD_COUNT \ | 328 | #define OPTEE_SMC_GET_THREAD_COUNT \ |
| 320 | OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_THREAD_COUNT) | 329 | OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_GET_THREAD_COUNT) |
| 321 | 330 | ||
| 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 | |||
| 322 | /* | 393 | /* |
| 323 | * Resume from RPC (for example after processing a foreign interrupt) | 394 | * Resume from RPC (for example after processing a foreign interrupt) |
| 324 | * | 395 | * |
| @@ -12,23 +12,6 @@ · 11 unmodified lines | |||
| 12 | #include "optee_private.h" | 12 | #include "optee_private.h" |
| 13 | #include "optee_rpc_cmd.h" | 13 | #include "optee_rpc_cmd.h" |
| 14 | 14 | ||
| 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 | |||
| 32 | static void handle_rpc_func_cmd_get_time(struct optee_msg_arg *arg) | 15 | static void handle_rpc_func_cmd_get_time(struct optee_msg_arg *arg) |
| 33 | { | 16 | { |
| 34 | struct timespec64 ts; | 17 | struct timespec64 ts; |
| @@ -144,48 +127,6 @@ static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx, · 109 unmodified lines | |||
| 144 | } | 127 | } |
| 145 | #endif | 128 | #endif |
| 146 | 129 | ||
| 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 | |||
| 189 | static void handle_rpc_func_cmd_wq(struct optee *optee, | 130 | static void handle_rpc_func_cmd_wq(struct optee *optee, |
| 190 | struct optee_msg_arg *arg) | 131 | struct optee_msg_arg *arg) |
| 191 | { | 132 | { |
| @@ -197,11 +138,13 @@ static void handle_rpc_func_cmd_wq(struct optee *optee, · 5 unmodified lines | |||
| 197 | goto bad; | 138 | goto bad; |
| 198 | 139 | ||
| 199 | switch (arg->params[0].u.value.a) { | 140 | switch (arg->params[0].u.value.a) { |
| 200 | case OPTEE_RPC_WAIT_QUEUE_SLEEP: | 141 | case OPTEE_RPC_NOTIFICATION_WAIT: |
| 201 | wq_sleep(&optee->wait_queue, arg->params[0].u.value.b); | 142 | if (optee_notif_wait(optee, arg->params[0].u.value.b)) |
| 143 | goto bad; | ||
| 202 | break; | 144 | break; |
| 203 | case OPTEE_RPC_WAIT_QUEUE_WAKEUP: | 145 | case OPTEE_RPC_NOTIFICATION_SEND: |
| 204 | wq_wakeup(&optee->wait_queue, arg->params[0].u.value.b); | 146 | if (optee_notif_send(optee, arg->params[0].u.value.b)) |
| 147 | goto bad; | ||
| 205 | break; | 148 | break; |
| 206 | default: | 149 | default: |
| 207 | goto bad; | 150 | goto bad; |
| @@ -319,7 +262,7 @@ void optee_rpc_cmd(struct tee_context *ctx, struct optee *optee, · 111 unmodified lines | |||
| 319 | case OPTEE_RPC_CMD_GET_TIME: | 262 | case OPTEE_RPC_CMD_GET_TIME: |
| 320 | handle_rpc_func_cmd_get_time(arg); | 263 | handle_rpc_func_cmd_get_time(arg); |
| 321 | break; | 264 | break; |
| 322 | case OPTEE_RPC_CMD_WAIT_QUEUE: | 265 | case OPTEE_RPC_CMD_NOTIFICATION: |
| 323 | handle_rpc_func_cmd_wq(optee, arg); | 266 | handle_rpc_func_cmd_wq(optee, arg); |
| 324 | break; | 267 | break; |
| 325 | case OPTEE_RPC_CMD_SUSPEND: | 268 | case OPTEE_RPC_CMD_SUSPEND: |
| @@ -8,13 +8,16 @@ · 7 unmodified lines | |||
| 8 | 8 | ||
| 9 | #include <linux/arm-smccc.h> | 9 | #include <linux/arm-smccc.h> |
| 10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
| 11 | #include <linux/interrupt.h> | ||
| 11 | #include <linux/io.h> | 12 | #include <linux/io.h> |
| 12 | #include <linux/sched.h> | 13 | #include <linux/irqdomain.h> |
| 13 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
| 14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 15 | #include <linux/of.h> | 16 | #include <linux/of.h> |
| 17 | #include <linux/of_irq.h> | ||
| 16 | #include <linux/of_platform.h> | 18 | #include <linux/of_platform.h> |
| 17 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/sched.h> | ||
| 18 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
| 19 | #include <linux/string.h> | 22 | #include <linux/string.h> |
| 20 | #include <linux/tee_drv.h> | 23 | #include <linux/tee_drv.h> |
| @@ -35,7 +38,8 @@ · 14 unmodified lines | |||
| 35 | * 2. Low level support functions to register shared memory in secure world | 38 | * 2. Low level support functions to register shared memory in secure world |
| 36 | * 3. Dynamic shared memory pool based on alloc_pages() | 39 | * 3. Dynamic shared memory pool based on alloc_pages() |
| 37 | * 4. Do a normal scheduled call into secure world | 40 | * 4. Do a normal scheduled call into secure world |
| 38 | * 5. Driver initialization. | 41 | * 5. Asynchronous notification |
| 42 | * 6. Driver initialization. | ||
| 39 | */ | 43 | */ |
| 40 | 44 | ||
| 41 | #define OPTEE_SHM_NUM_PRIV_PAGES CONFIG_OPTEE_SHM_NUM_PRIV_PAGES | 45 | #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 | |||
| 877 | return rc; | 881 | return rc; |
| 878 | } | 882 | } |
| 879 | 883 | ||
| 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 | |||
| 880 | /* | 910 | /* |
| 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 | ||
| 882 | * | 1013 | * |
| 883 | * During driver inititialization is secure world probed to find out which | 1014 | * During driver initialization is secure world probed to find out which |
| 884 | * features it supports so the driver can be initialized with a matching | 1015 | * features it supports so the driver can be initialized with a matching |
| 885 | * configuration. This involves for instance support for dynamic shared | 1016 | * configuration. This involves for instance support for dynamic shared |
| 886 | * memory instead of a static memory carvout. | 1017 | * memory instead of a static memory carvout. |
| @@ -952,6 +1083,17 @@ static const struct optee_ops optee_ops = { · 65 unmodified lines | |||
| 952 | .from_msg_param = optee_from_msg_param, | 1083 | .from_msg_param = optee_from_msg_param, |
| 953 | }; | 1084 | }; |
| 954 | 1085 | ||
| 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 | |||
| 955 | static bool optee_msg_api_uid_is_optee_api(optee_invoke_fn *invoke_fn) | 1097 | static bool optee_msg_api_uid_is_optee_api(optee_invoke_fn *invoke_fn) |
| 956 | { | 1098 | { |
| 957 | struct arm_smccc_res res; | 1099 | 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 | |||
| 1001 | } | 1143 | } |
| 1002 | 1144 | ||
| 1003 | static bool optee_msg_exchange_capabilities(optee_invoke_fn *invoke_fn, | 1145 | static bool optee_msg_exchange_capabilities(optee_invoke_fn *invoke_fn, |
| 1004 | u32 *sec_caps) | 1146 | u32 *sec_caps, u32 *max_notif_value) |
| 1005 | { | 1147 | { |
| 1006 | union { | 1148 | union { |
| 1007 | struct arm_smccc_res smccc; | 1149 | struct arm_smccc_res smccc; |
| @@ -1024,6 +1166,11 @@ static bool optee_msg_exchange_capabilities(optee_invoke_fn *invoke_fn, · 16 unmodified lines | |||
| 1024 | return false; | 1166 | return false; |
| 1025 | 1167 | ||
| 1026 | *sec_caps = res.result.capabilities; | 1168 | *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 | |||
| 1027 | return true; | 1174 | return true; |
| 1028 | } | 1175 | } |
| 1029 | 1176 | ||
| @@ -1188,6 +1335,8 @@ static int optee_smc_remove(struct platform_device *pdev) · 158 unmodified lines | |||
| 1188 | */ | 1335 | */ |
| 1189 | optee_disable_shm_cache(optee); | 1336 | optee_disable_shm_cache(optee); |
| 1190 | 1337 | ||
| 1338 | optee_smc_notif_uninit_irq(optee); | ||
| 1339 | |||
| 1191 | optee_remove_common(optee); | 1340 | optee_remove_common(optee); |
| 1192 | 1341 | ||
| 1193 | if (optee->smc.memremaped_shm) | 1342 | if (optee->smc.memremaped_shm) |
| @@ -1217,6 +1366,7 @@ static int optee_probe(struct platform_device *pdev) · 23 unmodified lines | |||
| 1217 | struct optee *optee = NULL; | 1366 | struct optee *optee = NULL; |
| 1218 | void *memremaped_shm = NULL; | 1367 | void *memremaped_shm = NULL; |
| 1219 | struct tee_device *teedev; | 1368 | struct tee_device *teedev; |
| 1369 | u32 max_notif_value; | ||
| 1220 | u32 sec_caps; | 1370 | u32 sec_caps; |
| 1221 | int rc; | 1371 | int rc; |
| 1222 | 1372 | ||
| @@ -1236,7 +1386,8 @@ static int optee_probe(struct platform_device *pdev) · 13 unmodified lines | |||
| 1236 | return -EINVAL; | 1386 | return -EINVAL; |
| 1237 | } | 1387 | } |
| 1238 | 1388 | ||
| 1239 | if (!optee_msg_exchange_capabilities(invoke_fn, &sec_caps)) { | 1389 | if (!optee_msg_exchange_capabilities(invoke_fn, &sec_caps, |
| 1390 | &max_notif_value)) { | ||
| 1240 | pr_warn("capabilities mismatch\n"); | 1391 | pr_warn("capabilities mismatch\n"); |
| 1241 | return -EINVAL; | 1392 | return -EINVAL; |
| 1242 | } | 1393 | } |
| @@ -1259,7 +1410,7 @@ static int optee_probe(struct platform_device *pdev) · 16 unmodified lines | |||
| 1259 | optee = kzalloc(sizeof(*optee), GFP_KERNEL); | 1410 | optee = kzalloc(sizeof(*optee), GFP_KERNEL); |
| 1260 | if (!optee) { | 1411 | if (!optee) { |
| 1261 | rc = -ENOMEM; | 1412 | rc = -ENOMEM; |
| 1262 | goto err; | 1413 | goto err_free_pool; |
| 1263 | } | 1414 | } |
| 1264 | 1415 | ||
| 1265 | optee->ops = &optee_ops; | 1416 | optee->ops = &optee_ops; |
| @@ -1269,32 +1420,55 @@ static int optee_probe(struct platform_device *pdev) · 3 unmodified lines | |||
| 1269 | teedev = tee_device_alloc(&optee_clnt_desc, NULL, pool, optee); | 1420 | teedev = tee_device_alloc(&optee_clnt_desc, NULL, pool, optee); |
| 1270 | if (IS_ERR(teedev)) { | 1421 | if (IS_ERR(teedev)) { |
| 1271 | rc = PTR_ERR(teedev); | 1422 | rc = PTR_ERR(teedev); |
| 1272 | goto err; | 1423 | goto err_free_optee; |
| 1273 | } | 1424 | } |
| 1274 | optee->teedev = teedev; | 1425 | optee->teedev = teedev; |
| 1275 | 1426 | ||
| 1276 | teedev = tee_device_alloc(&optee_supp_desc, NULL, pool, optee); | 1427 | teedev = tee_device_alloc(&optee_supp_desc, NULL, pool, optee); |
| 1277 | if (IS_ERR(teedev)) { | 1428 | if (IS_ERR(teedev)) { |
| 1278 | rc = PTR_ERR(teedev); | 1429 | rc = PTR_ERR(teedev); |
| 1279 | goto err; | 1430 | goto err_unreg_teedev; |
| 1280 | } | 1431 | } |
| 1281 | optee->supp_teedev = teedev; | 1432 | optee->supp_teedev = teedev; |
| 1282 | 1433 | ||
| 1283 | rc = tee_device_register(optee->teedev); | 1434 | rc = tee_device_register(optee->teedev); |
| 1284 | if (rc) | 1435 | if (rc) |
| 1285 | goto err; | 1436 | goto err_unreg_supp_teedev; |
| 1286 | 1437 | ||
| 1287 | rc = tee_device_register(optee->supp_teedev); | 1438 | rc = tee_device_register(optee->supp_teedev); |
| 1288 | if (rc) | 1439 | if (rc) |
| 1289 | goto err; | 1440 | goto err_unreg_supp_teedev; |
| 1290 | 1441 | ||
| 1291 | mutex_init(&optee->call_queue.mutex); | 1442 | mutex_init(&optee->call_queue.mutex); |
| 1292 | INIT_LIST_HEAD(&optee->call_queue.waiters); | 1443 | INIT_LIST_HEAD(&optee->call_queue.waiters); |
| 1293 | optee_wait_queue_init(&optee->wait_queue); | ||
| 1294 | optee_supp_init(&optee->supp); | 1444 | optee_supp_init(&optee->supp); |
| 1295 | optee->smc.memremaped_shm = memremaped_shm; | 1445 | optee->smc.memremaped_shm = memremaped_shm; |
| 1296 | optee->pool = pool; | 1446 | optee->pool = pool; |
| 1297 | 1447 | ||
| 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 | |||
| 1298 | /* | 1472 | /* |
| 1299 | * Ensure that there are no pre-existing shm objects before enabling | 1473 | * Ensure that there are no pre-existing shm objects before enabling |
| 1300 | * the shm cache so that there's no chance of receiving an invalid | 1474 | * 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 | |||
| 1309 | if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM) | 1483 | if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM) |
| 1310 | pr_info("dynamic shared memory is enabled\n"); | 1484 | pr_info("dynamic shared memory is enabled\n"); |
| 1311 | 1485 | ||
| 1312 | platform_set_drvdata(pdev, optee); | ||
| 1313 | |||
| 1314 | rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES); | 1486 | rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES); |
| 1315 | if (rc) { | 1487 | if (rc) |
| 1316 | optee_smc_remove(pdev); | 1488 | goto err_disable_shm_cache; |
| 1317 | return rc; | ||
| 1318 | } | ||
| 1319 | 1489 | ||
| 1320 | pr_info("initialized driver\n"); | 1490 | pr_info("initialized driver\n"); |
| 1321 | return 0; | 1491 | return 0; |
| 1322 | err: | 1492 | |
| 1323 | if (optee) { | 1493 | err_disable_shm_cache: |
| 1324 | /* | 1494 | optee_disable_shm_cache(optee); |
| 1325 | * tee_device_unregister() is safe to call even if the | 1495 | optee_smc_notif_uninit_irq(optee); |
| 1326 | * devices hasn't been registered with | 1496 | optee_unregister_devices(); |
| 1327 | * tee_device_register() yet. | 1497 | err_notif_uninit: |
| 1328 | */ | 1498 | optee_notif_uninit(optee); |
| 1329 | tee_device_unregister(optee->supp_teedev); | 1499 | err_supp_uninit: |
| 1330 | tee_device_unregister(optee->teedev); | 1500 | optee_supp_uninit(&optee->supp); |
| 1331 | kfree(optee); | 1501 | mutex_destroy(&optee->call_queue.mutex); |
| 1332 | } | 1502 | err_unreg_supp_teedev: |
| 1333 | if (pool) | 1503 | tee_device_unregister(optee->supp_teedev); |
| 1334 | tee_shm_pool_free(pool); | 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); | ||
| 1335 | if (memremaped_shm) | 1510 | if (memremaped_shm) |
| 1336 | memunmap(memremaped_shm); | 1511 | memunmap(memremaped_shm); |
| 1337 | return rc; | 1512 | return rc; |
| @@ -43,7 +43,7 @@ static DEFINE_SPINLOCK(driver_lock); · 42 unmodified lines | |||
| 43 | static struct class *tee_class; | 43 | static struct class *tee_class; |
| 44 | static dev_t tee_devt; | 44 | static dev_t tee_devt; |
| 45 | 45 | ||
| 46 | static struct tee_context *teedev_open(struct tee_device *teedev) | 46 | struct tee_context *teedev_open(struct tee_device *teedev) |
| 47 | { | 47 | { |
| 48 | int rc; | 48 | int rc; |
| 49 | struct tee_context *ctx; | 49 | struct tee_context *ctx; |
| @@ -70,6 +70,7 @@ err: · 20 unmodified lines | |||
| 70 | return ERR_PTR(rc); | 70 | return ERR_PTR(rc); |
| 71 | 71 | ||
| 72 | } | 72 | } |
| 73 | EXPORT_SYMBOL_GPL(teedev_open); | ||
| 73 | 74 | ||
| 74 | void teedev_ctx_get(struct tee_context *ctx) | 75 | void teedev_ctx_get(struct tee_context *ctx) |
| 75 | { | 76 | { |
| @@ -96,11 +97,14 @@ void teedev_ctx_put(struct tee_context *ctx) · 20 unmodified lines | |||
| 96 | kref_put(&ctx->refcount, teedev_ctx_release); | 97 | kref_put(&ctx->refcount, teedev_ctx_release); |
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | static void teedev_close_context(struct tee_context *ctx) | 100 | void teedev_close_context(struct tee_context *ctx) |
| 100 | { | 101 | { |
| 101 | tee_device_put(ctx->teedev); | 102 | struct tee_device *teedev = ctx->teedev; |
| 103 | |||
| 102 | teedev_ctx_put(ctx); | 104 | teedev_ctx_put(ctx); |
| 105 | tee_device_put(teedev); | ||
| 103 | } | 106 | } |
| 107 | EXPORT_SYMBOL_GPL(teedev_close_context); | ||
| 104 | 108 | ||
| 105 | static int tee_open(struct inode *inode, struct file *filp) | 109 | static int tee_open(struct inode *inode, struct file *filp) |
| 106 | { | 110 | { |
| @@ -7,6 +7,7 @@ · 6 unmodified lines | |||
| 7 | #include <linux/io.h> | 7 | #include <linux/io.h> |
| 8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
| 9 | #include <linux/of_device.h> | 9 | #include <linux/of_device.h> |
| 10 | #include <linux/pm_runtime.h> | ||
| 10 | #include <linux/reset.h> | 11 | #include <linux/reset.h> |
| 11 | 12 | ||
| 12 | #include <linux/usb.h> | 13 | #include <linux/usb.h> |
| @@ -15,6 +16,8 @@ · 2 unmodified lines | |||
| 15 | #include <linux/usb/of.h> | 16 | #include <linux/usb/of.h> |
| 16 | #include <linux/usb/phy.h> | 17 | #include <linux/usb/phy.h> |
| 17 | 18 | ||
| 19 | #include <soc/tegra/common.h> | ||
| 20 | |||
| 18 | #include "../host/ehci.h" | 21 | #include "../host/ehci.h" |
| 19 | 22 | ||
| 20 | #include "ci.h" | 23 | #include "ci.h" |
| @@ -278,6 +281,8 @@ static int tegra_usb_probe(struct platform_device *pdev) · 257 unmodified lines | |||
| 278 | if (!usb) | 281 | if (!usb) |
| 279 | return -ENOMEM; | 282 | return -ENOMEM; |
| 280 | 283 | ||
| 284 | platform_set_drvdata(pdev, usb); | ||
| 285 | |||
| 281 | soc = of_device_get_match_data(&pdev->dev); | 286 | soc = of_device_get_match_data(&pdev->dev); |
| 282 | if (!soc) { | 287 | if (!soc) { |
| 283 | dev_err(&pdev->dev, "failed to match OF data\n"); | 288 | 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 | |||
| 296 | return err; | 301 | return err; |
| 297 | } | 302 | } |
| 298 | 303 | ||
| 299 | err = clk_prepare_enable(usb->clk); | 304 | err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); |
| 300 | if (err < 0) { | 305 | if (err) |
| 301 | dev_err(&pdev->dev, "failed to enable clock: %d\n", err); | 306 | return err; |
| 307 | |||
| 308 | pm_runtime_enable(&pdev->dev); | ||
| 309 | err = pm_runtime_resume_and_get(&pdev->dev); | ||
| 310 | if (err) | ||
| 302 | return err; | 311 | return err; |
| 303 | } | ||
| 304 | 312 | ||
| 305 | if (device_property_present(&pdev->dev, "nvidia,needs-double-reset")) | 313 | if (device_property_present(&pdev->dev, "nvidia,needs-double-reset")) |
| 306 | usb->needs_double_reset = true; | 314 | usb->needs_double_reset = true; |
| @@ -320,8 +328,6 @@ static int tegra_usb_probe(struct platform_device *pdev) · 13 unmodified lines | |||
| 320 | if (err) | 328 | if (err) |
| 321 | goto fail_power_off; | 329 | goto fail_power_off; |
| 322 | 330 | ||
| 323 | platform_set_drvdata(pdev, usb); | ||
| 324 | |||
| 325 | /* setup and register ChipIdea HDRC device */ | 331 | /* setup and register ChipIdea HDRC device */ |
| 326 | usb->soc = soc; | 332 | usb->soc = soc; |
| 327 | usb->data.name = "tegra-usb"; | 333 | usb->data.name = "tegra-usb"; |
| @@ -350,7 +356,9 @@ static int tegra_usb_probe(struct platform_device *pdev) · 22 unmodified lines | |||
| 350 | phy_shutdown: | 356 | phy_shutdown: |
| 351 | usb_phy_shutdown(usb->phy); | 357 | usb_phy_shutdown(usb->phy); |
| 352 | fail_power_off: | 358 | 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 | |||
| 354 | return err; | 362 | return err; |
| 355 | } | 363 | } |
| 356 | 364 | ||
| @@ -360,15 +368,46 @@ static int tegra_usb_remove(struct platform_device *pdev) · 3 unmodified lines | |||
| 360 | 368 | ||
| 361 | ci_hdrc_remove_device(usb->dev); | 369 | ci_hdrc_remove_device(usb->dev); |
| 362 | usb_phy_shutdown(usb->phy); | 370 | 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 | |||
| 363 | clk_disable_unprepare(usb->clk); | 396 | clk_disable_unprepare(usb->clk); |
| 364 | 397 | ||
| 365 | return 0; | 398 | return 0; |
| 366 | } | 399 | } |
| 367 | 400 | ||
| 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 | |||
| 368 | static struct platform_driver tegra_usb_driver = { | 406 | static struct platform_driver tegra_usb_driver = { |
| 369 | .driver = { | 407 | .driver = { |
| 370 | .name = "tegra-usb", | 408 | .name = "tegra-usb", |
| 371 | .of_match_table = tegra_usb_of_match, | 409 | .of_match_table = tegra_usb_of_match, |
| 410 | .pm = &tegra_usb_pm, | ||
| 372 | }, | 411 | }, |
| 373 | .probe = tegra_usb_probe, | 412 | .probe = tegra_usb_probe, |
| 374 | .remove = tegra_usb_remove, | 413 | .remove = tegra_usb_remove, |
| @@ -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__ */ | ||
| @@ -12,4 +12,9 @@ · 11 unmodified lines | |||
| 12 | #define IMX8MN_POWER_DOMAIN_DISPMIX 3 | 12 | #define IMX8MN_POWER_DOMAIN_DISPMIX 3 |
| 13 | #define IMX8MN_POWER_DOMAIN_MIPI 4 | 13 | #define IMX8MN_POWER_DOMAIN_MIPI 4 |
| 14 | 14 | ||
| 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 | |||
| 15 | #endif | 20 | #endif |
| @@ -68,6 +68,21 @@ · 67 unmodified lines | |||
| 68 | #define SM8350_MXC_AO 11 | 68 | #define SM8350_MXC_AO 11 |
| 69 | #define SM8350_MSS 12 | 69 | #define SM8350_MSS 12 |
| 70 | 70 | ||
| 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 | |||
| 71 | /* SC7180 Power Domain Indexes */ | 86 | /* SC7180 Power Domain Indexes */ |
| 72 | #define SC7180_CX 0 | 87 | #define SC7180_CX 0 |
| 73 | #define SC7180_CX_AO 1 | 88 | #define SC7180_CX_AO 1 |
| @@ -219,6 +234,24 @@ · 145 unmodified lines | |||
| 219 | #define SM6115_VDD_LPI_CX 6 | 234 | #define SM6115_VDD_LPI_CX 6 |
| 220 | #define SM6115_VDD_LPI_MX 7 | 235 | #define SM6115_VDD_LPI_MX 7 |
| 221 | 236 | ||
| 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 | |||
| 222 | /* RPM SMD Power Domain performance levels */ | 255 | /* RPM SMD Power Domain performance levels */ |
| 223 | #define RPM_SMD_LEVEL_RETENTION 16 | 256 | #define RPM_SMD_LEVEL_RETENTION 16 |
| 224 | #define RPM_SMD_LEVEL_RETENTION_PLUS 32 | 257 | #define RPM_SMD_LEVEL_RETENTION_PLUS 32 |
| @@ -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__*/ | ||
| @@ -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 */ | ||
| @@ -33,6 +33,9 @@ · 32 unmodified lines | |||
| 33 | #define LLCC_MODPE 29 | 33 | #define LLCC_MODPE 29 |
| 34 | #define LLCC_APTCM 30 | 34 | #define LLCC_APTCM 30 |
| 35 | #define LLCC_WRCACHE 31 | 35 | #define LLCC_WRCACHE 31 |
| 36 | #define LLCC_CVPFW 32 | ||
| 37 | #define LLCC_CPUSS1 33 | ||
| 38 | #define LLCC_CPUHWT 36 | ||
| 36 | 39 | ||
| 37 | /** | 40 | /** |
| 38 | * struct llcc_slice_desc - Cache slice descriptor | 41 | * struct llcc_slice_desc - Cache slice descriptor |
| @@ -4,8 +4,10 @@ · 3 unmodified lines | |||
| 4 | 4 | ||
| 5 | #ifdef CONFIG_RST_RCAR | 5 | #ifdef CONFIG_RST_RCAR |
| 6 | int rcar_rst_read_mode_pins(u32 *mode); | 6 | int rcar_rst_read_mode_pins(u32 *mode); |
| 7 | int rcar_rst_set_rproc_boot_addr(u64 boot_addr); | ||
| 7 | #else | 8 | #else |
| 8 | static inline int rcar_rst_read_mode_pins(u32 *mode) { return -ENODEV; } | 9 | 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; } | ||
| 9 | #endif | 11 | #endif |
| 10 | 12 | ||
| 11 | #endif /* __LINUX_SOC_RENESAS_RCAR_RST_H__ */ | 13 | #endif /* __LINUX_SOC_RENESAS_RCAR_RST_H__ */ |
| @@ -587,4 +587,18 @@ struct tee_client_driver { · 586 unmodified lines | |||
| 587 | #define to_tee_client_driver(d) \ | 587 | #define to_tee_client_driver(d) \ |
| 588 | container_of(d, struct tee_client_driver, driver) | 588 | container_of(d, struct tee_client_driver, driver) |
| 589 | 589 | ||
| 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 | |||
| 590 | #endif /*__TEE_DRV_H*/ | 604 | #endif /*__TEE_DRV_H*/ |
| @@ -57,6 +57,11 @@ struct rpcif_op { · 56 unmodified lines | |||
| 57 | } data; | 57 | } data; |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | enum rpcif_type { | ||
| 61 | RPCIF_RCAR_GEN3, | ||
| 62 | RPCIF_RZ_G2L, | ||
| 63 | }; | ||
| 64 | |||
| 60 | struct rpcif { | 65 | struct rpcif { |
| 61 | struct device *dev; | 66 | struct device *dev; |
| 62 | void __iomem *base; | 67 | void __iomem *base; |
| @@ -64,6 +69,7 @@ struct rpcif { · 1 unmodified line | |||
| 64 | struct regmap *regmap; | 69 | struct regmap *regmap; |
| 65 | struct reset_control *rstc; | 70 | struct reset_control *rstc; |
| 66 | size_t size; | 71 | size_t size; |
| 72 | enum rpcif_type type; | ||
| 67 | enum rpcif_data_dir dir; | 73 | enum rpcif_data_dir dir; |
| 68 | u8 bus_size; | 74 | u8 bus_size; |
| 69 | void *buffer; | 75 | void *buffer; |
| @@ -78,7 +84,7 @@ struct rpcif { · 8 unmodified lines | |||
| 78 | }; | 84 | }; |
| 79 | 85 | ||
| 80 | int rpcif_sw_init(struct rpcif *rpc, struct device *dev); | 86 | 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); |
| 82 | void rpcif_prepare(struct rpcif *rpc, const struct rpcif_op *op, u64 *offs, | 88 | void rpcif_prepare(struct rpcif *rpc, const struct rpcif_op *op, u64 *offs, |
| 83 | size_t *len); | 89 | size_t *len); |
| 84 | int rpcif_manual_xfer(struct rpcif *rpc); | 90 | int rpcif_manual_xfer(struct rpcif *rpc); |
| @@ -39,4 +39,19 @@ devm_tegra_core_dev_init_opp_table(struct device *dev, · 38 unmodified lines | |||
| 39 | } | 39 | } |
| 40 | #endif | 40 | #endif |
| 41 | 41 | ||
| 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 | |||
| 42 | #endif /* __SOC_TEGRA_COMMON_H__ */ | 57 | #endif /* __SOC_TEGRA_COMMON_H__ */ |