diff --git a/Documentation/devicetree/bindings/mailbox/google,gs201-aoc-mbox.yaml b/Documentation/devicetree/bindings/mailbox/google,gs201-aoc-mbox.yaml index df919aaa40..838c338dd2 100644 --- a/Documentation/devicetree/bindings/mailbox/google,gs201-aoc-mbox.yaml +++ b/Documentation/devicetree/bindings/mailbox/google,gs201-aoc-mbox.yaml @@ -17,7 +17,9 @@ description: properties: compatible: - const: google,gs201-aoc-mbox + enum: + - google,gs201-aoc-mbox + - google,zumapro-aoc-mbox reg: maxItems: 1 diff --git a/Documentation/devicetree/bindings/soc/google/google,gs201-aoc.yaml b/Documentation/devicetree/bindings/soc/google/google,gs201-aoc.yaml index f6b78d041f..c51328c19c 100644 --- a/Documentation/devicetree/bindings/soc/google/google,gs201-aoc.yaml +++ b/Documentation/devicetree/bindings/soc/google/google,gs201-aoc.yaml @@ -4,38 +4,48 @@ $id: http://devicetree.org/schemas/soc/google/google,gs201-aoc.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Google gs201 AoC (Always-on Compute) +title: Google Tensor AoC (Always-on Compute) maintainers: - Derek Ross description: - The AoC is the audio and sensor DSP of gs201. The AP loads its firmware - into a reserved carve-out, the GSA authenticates and starts it, and the - AoC reaches memory through its own System MMU. + The AoC is the audio and sensor DSP of Tensor SoCs. The AP loads its + firmware into a reserved carve-out and the GSA authenticates and starts + it. On gs201 the AoC reaches memory through its own System MMU, which + Linux sets up. On zumapro (Tensor G4) the authenticated firmware owns + the AoC's memory protection, so Linux touches neither its S2MPU nor its + System MMU. properties: compatible: - const: google,gs201-aoc + enum: + - google,gs201-aoc + - google,zumapro-aoc reg: - minItems: 3 - items: - - description: the AoC power request register (aoc_req) and its - acknowledge at +0x40 - - description: the AoC's stage-2 MPU - - description: the chip id block, read for the firmware's boot - parameters - - description: the AoC power control unit (A32 reset control and - revision), in the AoC block + minItems: 2 + maxItems: 4 reg-names: - minItems: 3 - items: - - const: aoc_req - - const: s2mpu - - const: chipid - - const: pcu + minItems: 2 + maxItems: 4 + + clocks: + description: the ACPM DVFS domains whose rates are read before each + firmware start + minItems: 1 + maxItems: 17 + + firmware-name: + maxItems: 1 + description: the signed AoC firmware image + + sensor-1v8-supply: + description: the sensors' 1.8 V, turned on before the 3.3 V + + sensor-3v3-supply: + description: the sensors' 3.3 V, turned off before the 1.8 V interrupts: maxItems: 1 @@ -69,16 +79,72 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 description: board revision passed to the firmware + google,gnss-type: + $ref: /schemas/types.yaml#/definitions/uint32 + description: the board's GNSS receiver, passed to the firmware + (kAOCGnssType) + required: - compatible - reg - reg-names - memory-region - google,gsa - - google,sysmmu - google,board-id - google,board-rev +allOf: + - if: + properties: + compatible: + const: google,zumapro-aoc + then: + properties: + reg: + items: + - description: the AoC power request register (aoc_req) and its + acknowledge at +0x40 + - description: the chip id block, read for the firmware's boot + parameters + reg-names: + items: + - const: aoc_req + - const: chipid + mboxes: + minItems: 48 + google,sysmmu: false + required: + - firmware-name + - interrupts + - interrupt-names + - mboxes + - sensor-1v8-supply + - sensor-3v3-supply + else: + properties: + reg: + minItems: 3 + items: + - description: the AoC power request register (aoc_req) and its + acknowledge at +0x40 + - description: the AoC's stage-2 MPU + - description: the chip id block, read for the firmware's boot + parameters + - description: the AoC power control unit (A32 reset control and + revision), in the AoC block + reg-names: + minItems: 3 + items: + - const: aoc_req + - const: s2mpu + - const: chipid + - const: pcu + clocks: false + sensor-1v8-supply: false + sensor-3v3-supply: false + required: + - google,sysmmu + additionalProperties: false examples: diff --git a/Documentation/devicetree/bindings/soc/google/google,gs201-gsa.yaml b/Documentation/devicetree/bindings/soc/google/google,gs201-gsa.yaml index 5868df472d..e2e2732241 100644 --- a/Documentation/devicetree/bindings/soc/google/google,gs201-gsa.yaml +++ b/Documentation/devicetree/bindings/soc/google/google,gs201-gsa.yaml @@ -17,7 +17,9 @@ description: properties: compatible: - const: google,gs201-gsa + enum: + - google,gs201-gsa + - google,zumapro-gsa reg: minItems: 1 @@ -42,6 +44,21 @@ required: - reg - interrupts +allOf: + - if: + properties: + compatible: + const: google,zumapro-gsa + then: + description: + On zumapro the GSA reads an image without Linux touching its + stage-2 MPU, so only the mailbox is described. + properties: + reg: + maxItems: 1 + reg-names: + maxItems: 1 + additionalProperties: false examples: diff --git a/Documentation/devicetree/bindings/sound/google,aoc-path.yaml b/Documentation/devicetree/bindings/sound/google,aoc-path.yaml new file mode 100644 index 0000000000..f4e1102bdd --- /dev/null +++ b/Documentation/devicetree/bindings/sound/google,aoc-path.yaml @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/google,aoc-path.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Google Tensor AoC audio path and PCM drivers + +maintainers: + - W4HO <87742609+W4HO-ham@users.noreply.github.com> + +description: + The pieces the AoC sound card (google,aoc-snd-card.yaml) is built from. + The path is the DAI component every DAI link runs on, one DAI per AoC + entry point and port. The others are the AoC drivers a DAI link's + platform names to serve its PCM, by the kind of stream. + +properties: + compatible: + enum: + - google-aoc-path + - google-aoc-snd-pcm + - google-aoc-snd-voice + - google-aoc-snd-compr + - google-aoc-snd-nohost + - google-aoc-snd-voip + - google-aoc-snd-incall + + "#sound-dai-cells": + const: 1 + +required: + - compatible + +allOf: + - if: + properties: + compatible: + const: google-aoc-path + then: + required: + - "#sound-dai-cells" + else: + properties: + "#sound-dai-cells": false + +additionalProperties: false + +examples: + - | + aoc_path { + compatible = "google-aoc-path"; + #sound-dai-cells = <1>; + }; + + aoc_pcm_drv { + compatible = "google-aoc-snd-pcm"; + }; diff --git a/Documentation/devicetree/bindings/sound/google,aoc-snd-card.yaml b/Documentation/devicetree/bindings/sound/google,aoc-snd-card.yaml new file mode 100644 index 0000000000..1d9e793c84 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/google,aoc-snd-card.yaml @@ -0,0 +1,237 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/google,aoc-snd-card.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Google Tensor AoC sound card + +maintainers: + - W4HO <87742609+W4HO-ham@users.noreply.github.com> + +description: + The sound card of the AoC, the audio and sensor DSP of Tensor SoCs. Its + front ends are the AoC's entry points (the PCM device number is the entry + point), and its back ends are the AoC's own ports to the amplifiers, + microphones, Bluetooth and USB. Each DAI link names the AoC path DAI it + runs on, the AoC driver that serves its PCM, and for a back end the + codecs and the format on the wire. The same card serves gs201 and + zumapro. + +properties: + compatible: + const: google-aoc-snd-card + + aoc-card-name: + $ref: /schemas/types.yaml#/definitions/string + description: + The ALSA card's long name, which UCM profiles and session rules match. + + codec_cfg: + type: object + description: Name prefixes for codecs that serve more than one back end. + additionalProperties: false + patternProperties: + "^[a-z0-9]+$": + type: object + additionalProperties: false + properties: + of_node: + $ref: /schemas/types.yaml#/definitions/phandle + description: The codec. + prefix: + $ref: /schemas/types.yaml#/definitions/string + description: The prefix of its controls and widgets. + required: + - of_node + - prefix + + clks: + type: object + description: + Clocks the AoC drives for codecs or DAIs, from its system clocks (sys) + or its PLLs (pll). + additionalProperties: false + patternProperties: + "^(sys|pll)$": + type: object + additionalProperties: false + patternProperties: + "^(sys|pll)@[a-z0-9_]+$": + type: object + additionalProperties: false + properties: + comp: + $ref: /schemas/types.yaml#/definitions/phandle + description: The component the clock feeds. + dai_id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: The DAI the clock feeds, when there is no component. + src: + enum: [MCLK, BCLK, PLL] + id: + $ref: /schemas/types.yaml#/definitions/uint32 + srcid: + $ref: /schemas/types.yaml#/definitions/uint32 + in_mul: + $ref: /schemas/types.yaml#/definitions/uint32 + out_mul: + $ref: /schemas/types.yaml#/definitions/uint32 + oneOf: + - required: [comp] + - required: [dai_id] + required: + - src + - id + - srcid + - in_mul + - out_mul + + dai_link: + type: object + description: The card's DAI links, front ends (fe_) and back ends (be_). + additionalProperties: false + patternProperties: + "^(fe|be)_[a-z0-9_]+$": + $ref: "#/$defs/link" + +$defs: + link: + type: object + additionalProperties: false + properties: + dai-name: + $ref: /schemas/types.yaml#/definitions/string + stream-name: + $ref: /schemas/types.yaml#/definitions/string + id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The link's ID. A front end's is its AoC entry point; a back end's + has bit 31 set and names the AoC port. + dynamic: + type: boolean + description: A DPCM front end. + no-pcm: + type: boolean + description: A DPCM back end, with no PCM device of its own. + playback: + type: boolean + capture: + type: boolean + useops: + type: boolean + description: The back end uses the AoC path's stream operations. + usefixup: + type: boolean + description: The back end's hardware parameters come from its AoC port. + cpu: + type: object + additionalProperties: false + properties: + sound-dai: + $ref: /schemas/types.yaml#/definitions/phandle-array + maxItems: 1 + description: The AoC path DAI and the link's ID. + required: + - sound-dai + codec: + type: object + additionalProperties: false + properties: + sound-dai: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 1 + required: + - sound-dai + platform: + type: object + additionalProperties: false + description: The AoC drivers that serve the link's PCM. + patternProperties: + "^(rx|tx|vorx|votx)[0-9]*$": + type: object + additionalProperties: false + properties: + of_drv: + $ref: /schemas/types.yaml#/definitions/phandle + required: + - of_drv + daifmt: + type: object + additionalProperties: false + properties: + dai-format: + enum: [i2s, dsp_a, dsp_b, left_j, right_j] + bitclock-inversion: + type: boolean + required: + - dai-format + required: + - dai-name + - stream-name + - id + - cpu + +required: + - compatible + - aoc-card-name + - dai_link + +additionalProperties: false + +examples: + - | + sound-aoc { + compatible = "google-aoc-snd-card"; + aoc-card-name = "google,tegu-aoc-snd-card"; + + codec_cfg { + top { + of_node = <1>; + prefix = "Top"; + }; + }; + + dai_link { + fe_ep1_rx { + dai-name = "audio_playback0"; + stream-name = "EP1 playback"; + id = <0x00>; + dynamic; + playback; + + cpu { + sound-dai = <2 0x00>; + }; + + platform { + rx1 { + of_drv = <3>; + }; + }; + }; + + be_tdm0_rx { + dai-name = "TDM_0_RX Playback"; + stream-name = "TDM_0_RX Playback"; + id = <0x80000006>; + playback; + no-pcm; + useops; + usefixup; + + codec { + sound-dai = <1>; + }; + + cpu { + sound-dai = <2 0x80000006>; + }; + + daifmt { + dai-format = "dsp_a"; + }; + }; + }; + }; diff --git a/Documentation/devicetree/bindings/sound/ti,tas2781.yaml b/Documentation/devicetree/bindings/sound/ti,tas2781.yaml index aa5a317b5a..50c7792b24 100644 --- a/Documentation/devicetree/bindings/sound/ti,tas2781.yaml +++ b/Documentation/devicetree/bindings/sound/ti,tas2781.yaml @@ -219,9 +219,7 @@ allOf: - if: properties: compatible: - contains: - enum: - - ti,tas2781 + const: ti,tas2781 then: properties: reg: diff --git a/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts b/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts index 76a95c1b05..a1fe22f20e 100644 --- a/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts +++ b/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts @@ -147,6 +147,998 @@ regulator-boot-on; regulator-always-on; }; + + /* + * The AoC sound card as stock's device tree describes it (Google's + * driver, so Google's compatibles): the + * entry-point PCMs, voice, compress, path, no-host, VoIP and in-call + * nodes and the stock DAI links, with the two TAS2572s on TDM 0. The + * haptics codec and the DisplayPort links are left out. + */ + aoc_pcm_ep: aoc_pcm_drv { + compatible = "google-aoc-snd-pcm"; + }; + + aoc_voice_ep: aoc_voice_drv { + compatible = "google-aoc-snd-voice"; + }; + + aoc_compr_ep: aoc_compr_drv { + compatible = "google-aoc-snd-compr"; + }; + + aud_aoc_path: aoc_path { + #sound-dai-cells = <0x01>; + compatible = "google-aoc-path"; + }; + + aoc_nohost_drv: aoc_nohost { + compatible = "google-aoc-snd-nohost"; + }; + + aoc_voip_ep: aoc_voip_drv { + compatible = "google-aoc-snd-voip"; + }; + + aoc_incall_ep: aoc_incall_drv { + compatible = "google-aoc-snd-incall"; + }; + + aoc_snd_card: sound-aoc { + compatible = "google-aoc-snd-card"; + /* + * Not "google,aoc-snd-card": the 7 Pro's UCM profile and + * WirePlumber rules match that name. + */ + aoc-card-name = "google,tegu-aoc-snd-card"; + + codec_cfg { + top { + of_node = <&tas2572_top>; + prefix = "Top"; + }; + + bottom { + of_node = <&tas2572_bottom>; + prefix = "Bottom"; + }; + }; + + dai_link { + fe_ep1_rx { + dai-name = "audio_playback0"; + stream-name = "EP1 playback"; + id = <0x00>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x00>; + }; + + platform { + rx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep2_rx { + dai-name = "audio_playback1"; + stream-name = "EP2 playback"; + id = <0x01>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x01>; + }; + + platform { + rx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep3_rx { + dai-name = "audio_playback2"; + stream-name = "EP3 playback"; + id = <0x02>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x02>; + }; + + platform { + rx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep4_rx { + dai-name = "audio_playback3"; + stream-name = "EP4 playback"; + id = <0x03>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x03>; + }; + + platform { + rx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep5_rx { + dai-name = "audio_playback4"; + stream-name = "EP5 playback"; + id = <0x04>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x04>; + }; + + platform { + vorx { + of_drv = <&aoc_voice_ep>; + }; + }; + }; + + fe_ep6_rx { + dai-name = "audio_playback5"; + stream-name = "EP6 playback"; + id = <0x05>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x05>; + }; + + platform { + rx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep7_rx { + dai-name = "audio_playback6"; + stream-name = "EP7 playback"; + id = <0x06>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x06>; + }; + + platform { + rx1 { + of_drv = <&aoc_compr_ep>; + }; + }; + }; + + fe_ep8_rx { + dai-name = "audio_haptics"; + stream-name = "EP8 playback"; + id = <0x07>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x07>; + }; + + platform { + rx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep1_tx { + dai-name = "audio_capture0"; + stream-name = "EP1 capture"; + id = <0x40000000>; + dynamic; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000000>; + }; + + platform { + tx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep2_tx { + dai-name = "audio_capture1"; + stream-name = "EP2 capture"; + id = <0x40000001>; + dynamic; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000001>; + }; + + platform { + tx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep3_tx { + dai-name = "audio_capture2"; + stream-name = "EP3 capture"; + id = <0x40000002>; + dynamic; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000002>; + }; + + platform { + tx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep4_tx { + dai-name = "audio_capture3"; + stream-name = "EP4 capture"; + id = <0x40000003>; + dynamic; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000003>; + }; + + platform { + votx { + of_drv = <&aoc_voice_ep>; + }; + }; + }; + + fe_ep5_tx { + dai-name = "ultrasonic_capture"; + stream-name = "EP5 capture"; + id = <0x40000004>; + dynamic; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000004>; + }; + + platform { + tx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_ep6_tx { + dai-name = "audio_capture5"; + stream-name = "EP6 capture"; + id = <0x40000005>; + dynamic; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000005>; + }; + + platform { + tx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_nohost1_rx { + dai-name = "nohost1 playback"; + stream-name = "nohost1 playback"; + id = <0x20000008>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x20000008>; + }; + + platform { + rx1 { + of_drv = <&aoc_nohost_drv>; + }; + }; + }; + + fe_nohost1_tx { + dai-name = "nohost1 capture"; + stream-name = "nohost1 capture"; + id = <0x60000008>; + dynamic; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x60000008>; + }; + + platform { + tx1 { + of_drv = <&aoc_nohost_drv>; + }; + }; + }; + + fe_voip_rx { + dai-name = "audio_voip_rx"; + stream-name = "audio_voip_rx"; + id = <0x0a>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x0a>; + }; + + platform { + rx1 { + of_drv = <&aoc_voip_ep>; + }; + }; + }; + + fe_voip_tx { + dai-name = "audio_voip_tx"; + stream-name = "audio_voip_tx"; + id = <0x4000000a>; + dynamic; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x4000000a>; + }; + + platform { + tx1 { + of_drv = <&aoc_voip_ep>; + }; + }; + }; + + fe_incall_pb0_rx { + dai-name = "audio_incall_pb_0"; + stream-name = "audio_incall_pb_0"; + id = <0x0b>; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x0b>; + }; + + platform { + rx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_incall_pb1_rx { + dai-name = "audio_incall_pb_1"; + stream-name = "audio_incall_pb_1"; + id = <0x0c>; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x0c>; + }; + + platform { + rx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_incall_cap0_tx { + dai-name = "audio_incall_cap_0"; + stream-name = "audio_incall_cap_0"; + id = <0x4000000d>; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x4000000d>; + }; + + platform { + tx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_incall_cap1_tx { + dai-name = "audio_incall_cap_1"; + stream-name = "audio_incall_cap_1"; + id = <0x4000000e>; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x4000000e>; + }; + + platform { + tx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_incall_cap2_tx { + dai-name = "audio_incall_cap_2"; + stream-name = "audio_incall_cap_2"; + id = <0x4000000f>; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x4000000f>; + }; + + platform { + tx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_raw_rx { + dai-name = "audio_raw"; + stream-name = "audio_raw"; + id = <0x09>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x09>; + }; + + platform { + rx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_haptic_nohost_rx { + dai-name = "haptic nohost playback"; + stream-name = "haptic nohost playback"; + id = <0x20000011>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x20000011>; + }; + + platform { + rx1 { + of_drv = <&aoc_nohost_drv>; + }; + }; + }; + + fe_hifi_rx { + dai-name = "audio_hifiout"; + stream-name = "audio_hifiout"; + id = <0x10>; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x10>; + }; + + platform { + rx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_hifi_tx { + dai-name = "audio_hifiin"; + stream-name = "audio_hifiin"; + id = <0x40000010>; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000010>; + }; + + platform { + tx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_android_aec_tx { + dai-name = "audio_android_aec"; + stream-name = "audio_android_aec"; + id = <0x40000012>; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000012>; + }; + + platform { + tx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_us_rx { + dai-name = "audio_ultrasonic"; + stream-name = "audio_ultrasonic"; + id = <0x13>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x13>; + }; + + platform { + rx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_incall_pb2_rx { + dai-name = "audio_incall_pb_2"; + stream-name = "audio_incall_pb_2"; + id = <0x14>; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x14>; + }; + + platform { + rx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_ims_rx { + dai-name = "audio_immersive"; + stream-name = "audio_immersive"; + id = <0x15>; + dynamic; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x15>; + }; + + platform { + rx1 { + of_drv = <&aoc_pcm_ep>; + }; + }; + }; + + fe_capture_inject_rx { + dai-name = "audio_capture_inject"; + stream-name = "audio_capture_inject"; + id = <0x16>; + playback; + + cpu { + sound-dai = <&aud_aoc_path 0x16>; + }; + + platform { + rx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + fe_hotword_tap_tx { + dai-name = "audio_hotword_tap"; + stream-name = "audio_hotword_tap"; + id = <0x40000017>; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000017>; + }; + + platform { + tx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + + be_i2s0_rx { + dai-name = "I2S_0_RX Playback"; + stream-name = "I2S_0_RX Playback"; + id = <0x80000000>; + playback; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0x80000000>; + }; + + daifmt { + dai-format = "i2s"; + }; + }; + + be_i2s0_tx { + dai-name = "I2S_0_TX Capture"; + stream-name = "I2S_0_TX Capture"; + id = <0xc0000001>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc0000001>; + }; + + daifmt { + dai-format = "i2s"; + }; + }; + + be_i2s1_rx { + dai-name = "I2S_1_RX Playback"; + stream-name = "I2S_1_RX Playback"; + id = <0x80000002>; + playback; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0x80000002>; + }; + + daifmt { + dai-format = "i2s"; + }; + }; + + be_i2s1_tx { + dai-name = "I2S_1_TX Capture"; + stream-name = "I2S_1_TX Capture"; + id = <0xc0000003>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc0000003>; + }; + + daifmt { + dai-format = "i2s"; + }; + }; + + be_i2s2_rx { + dai-name = "I2S_2_RX Playback"; + stream-name = "I2S_2_RX Playback"; + id = <0x80000004>; + playback; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0x80000004>; + }; + + daifmt { + dai-format = "i2s"; + bitclock-inversion; + }; + }; + + be_i2s2_tx { + dai-name = "I2S_2_TX Capture"; + stream-name = "I2S_2_TX Capture"; + id = <0xc0000005>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc0000005>; + }; + + daifmt { + dai-format = "i2s"; + }; + }; + + be_tdm0_rx { + dai-name = "TDM_0_RX Playback"; + stream-name = "TDM_0_RX Playback"; + id = <0x80000006>; + playback; + no-pcm; + useops; + usefixup; + + codec { + sound-dai = <&tas2572_top>, <&tas2572_bottom>; + }; + + cpu { + sound-dai = <&aud_aoc_path 0x80000006>; + }; + + daifmt { + dai-format = "dsp_a"; + }; + }; + + be_tdm0_tx { + dai-name = "TDM_0_TX Capture"; + stream-name = "TDM_0_TX Capture"; + id = <0xc0000007>; + capture; + no-pcm; + useops; + usefixup; + + codec { + sound-dai = <&tas2572_top>, <&tas2572_bottom>; + }; + + cpu { + sound-dai = <&aud_aoc_path 0xc0000007>; + }; + + daifmt { + dai-format = "dsp_a"; + }; + }; + + be_tdm1_rx { + dai-name = "TDM_1_RX Playback"; + stream-name = "TDM_1_RX Playback"; + id = <0x80000008>; + playback; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0x80000008>; + }; + + daifmt { + dai-format = "i2s"; + }; + }; + + be_tdm1_tx { + dai-name = "TDM_1_TX Capture"; + stream-name = "TDM_1_TX Capture"; + id = <0xc0000009>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc0000009>; + }; + + daifmt { + dai-format = "i2s"; + }; + }; + + be_internal_mic_tx { + dai-name = "INTERNAL_MIC_TX Capture"; + stream-name = "INTERNAL_MIC_TX Capture"; + id = <0xc000000a>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc000000a>; + }; + }; + + be_internal_mic_us_tx { + dai-name = "INTERNAL_MIC_US_TX Capture"; + stream-name = "INTERNAL_MIC_US_TX Capture"; + id = <0xc0000013>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc0000013>; + }; + }; + + be_bt_rx { + dai-name = "BT_RX Playback"; + stream-name = "BT_RX Playback"; + id = <0x8000000b>; + playback; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0x8000000b>; + }; + }; + + be_bt_tx { + dai-name = "BT_TX Capture"; + stream-name = "BT_TX Capture"; + id = <0xc000000c>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc000000c>; + }; + }; + + be_usb_rx { + dai-name = "USB_RX Playback"; + stream-name = "USB_RX Playback"; + id = <0x8000000d>; + playback; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0x8000000d>; + }; + }; + + be_usb_tx { + dai-name = "USB_TX Capture"; + stream-name = "USB_TX Capture"; + id = <0xc000000e>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc000000e>; + }; + }; + + be_incall_rx { + dai-name = "INCALL_RX Playback"; + stream-name = "INCALL_RX Playback"; + id = <0x8000000f>; + playback; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0x8000000f>; + }; + }; + + be_incall_tx { + dai-name = "INCALL_TX Capture"; + stream-name = "INCALL_TX Capture"; + id = <0xc0000010>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc0000010>; + }; + }; + + be_haptic_rx { + dai-name = "HAPTIC_RX Playback"; + stream-name = "HAPTIC_RX Playback"; + id = <0x80000011>; + playback; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0x80000011>; + }; + + daifmt { + dai-format = "dsp_a"; + }; + }; + + be_eraser_tx { + dai-name = "ERASER_TX Capture"; + stream-name = "ERASER_TX Capture"; + id = <0xc0000012>; + capture; + no-pcm; + useops; + usefixup; + + cpu { + sound-dai = <&aud_aoc_path 0xc0000012>; + }; + }; + + fe_incall_cap3_tx { + dai-name = "audio_incall_cap_3"; + stream-name = "audio_incall_cap_3"; + id = <0x40000019>; + capture; + + cpu { + sound-dai = <&aud_aoc_path 0x40000019>; + }; + + platform { + tx1 { + of_drv = <&aoc_incall_ep>; + }; + }; + }; + }; + }; }; &{/reserved-memory} { @@ -195,6 +1187,48 @@ }; }; }; + + pmic-2 { + compatible = "samsung,s2mpg15-pmic"; + + regulators { + sensor_3v3: ldo5s { + regulator-name = "sensor-3v3"; + }; + + sensor_1v8: ldo7s { + regulator-name = "sensor-1v8"; + }; + }; + }; +}; + +/* + * The AoC's firmware is the board's own signed image; the board id and + * revision are stock's for this board, and GNSS type 2 is the modem's + * integrated receiver. + */ +&aoc { + memory-region = <&aoc_reserved>; + firmware-name = "aoc-tegu.bin"; + google,board-id = <0x60b02>; + google,board-rev = <0x10000>; + google,gnss-type = <2>; + sensor-1v8-supply = <&sensor_1v8>; + sensor-3v3-supply = <&sensor_3v3>; + status = "okay"; +}; + +&aoc_mbox_a32 { + status = "okay"; +}; + +&aoc_mbox_f1 { + status = "okay"; +}; + +&aoc_mbox_p6 { + status = "okay"; }; &ap2apm_mailbox { @@ -363,6 +1397,34 @@ status = "okay"; }; +&gsa { + status = "okay"; +}; + +/* + * The speaker amplifiers, two TAS2572s: top at 0x48 (reset gpp6-3) and + * bottom at 0x49 (reset gph2-1). One node each, since the tas2781 driver + * takes one register profile per node and TI's TAS2572 profiles cover one + * device. The AoC sound card names them Top and Bottom. + */ +&hsi2c19 { + status = "okay"; + + tas2572_top: amplifier@48 { + compatible = "ti,tas2572", "ti,tas2781"; + reg = <0x48>; + reset-gpios = <&gpp6 3 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + }; + + tas2572_bottom: amplifier@49 { + compatible = "ti,tas2572", "ti,tas2781"; + reg = <0x49>; + reset-gpios = <&gph2 1 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + }; +}; + /* The torch: a TI LM3644 flash driver, both LED outputs on one white LED. */ &hsi2c4 { clock-frequency = <100000>; @@ -610,6 +1672,10 @@ status = "okay"; }; +&trusty { + status = "okay"; +}; + /* * Bluetooth: the BCM4383 on the APM's UART at 3 Mbaud, powered through * BT_REG_ON (gpn8-0) behind its latch (ble-dbo on gpp24-3), with device wake @@ -687,6 +1753,10 @@ status = "okay"; }; +&usi4_hsi0 { + status = "okay"; +}; + &usi6 { status = "okay"; }; diff --git a/arch/arm64/boot/dts/exynos/google/zumapro.dtsi b/arch/arm64/boot/dts/exynos/google/zumapro.dtsi index f8be1721dd..be17249e58 100644 --- a/arch/arm64/boot/dts/exynos/google/zumapro.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zumapro.dtsi @@ -594,6 +594,26 @@ }; }; + /* Trusty, the secure OS that runs from the bootloader's tzsw image. */ + trusty: trusty { + compatible = "android,trusty-smc-v1"; + status = "disabled"; + + irq { + compatible = "android,trusty-irq-v1"; + /* Trusty IPIs 8-15 are GIC SGIs 8-15 */ + ipi-range = <8 15 8>; + }; + + log { + compatible = "android,trusty-log-v1"; + }; + + virtio { + compatible = "android,trusty-virtio-v1"; + }; + }; + soc: soc { compatible = "simple-bus"; #address-cells = <2>; @@ -1099,6 +1119,34 @@ }; }; + usi4_hsi0: usi@111f00c0 { + compatible = "google,zumapro-usi", "samsung,exynos850-usi"; + reg = <0x0 0x111f00c0 0x20>; + clocks = <&cmu_hsi0 CLK_GOUT_HSI0_USI4_PCLK>, + <&cmu_hsi0 CLK_GOUT_HSI0_USI4_IP>; + clock-names = "pclk", "ipclk"; + samsung,sysreg = <&sysreg_hsi0 0x1024>; + samsung,mode = ; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x111f0000 0x0 0x111f0000 0x1000>; + status = "disabled"; + + hsi2c19: i2c@111f0000 { + compatible = "google,zumapro-hsi2c", + "samsung,exynosautov9-hsi2c"; + /* USI control starts at 0xc0; do not claim it twice. */ + reg = <0x111f0000 0xc0>; + interrupts = ; + clocks = <&cmu_hsi0 CLK_GOUT_HSI0_USI4_IP>, + <&cmu_hsi0 CLK_GOUT_HSI0_USI4_PCLK>; + clock-names = "hsi2c", "hsi2c_pclk"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + }; + usb: usb@11210000 { compatible = "snps,dwc3"; reg = <0x0 0x11210000 0x10000>; @@ -1322,6 +1370,30 @@ status = "disabled"; }; + aoc_mbox_a32: mailbox@15200000 { + compatible = "google,zumapro-aoc-mbox"; + reg = <0x0 0x15200000 0x1000>; + interrupts = ; + #mbox-cells = <1>; + status = "disabled"; + }; + + aoc_mbox_f1: mailbox@15220000 { + compatible = "google,zumapro-aoc-mbox"; + reg = <0x0 0x15220000 0x1000>; + interrupts = ; + #mbox-cells = <1>; + status = "disabled"; + }; + + aoc_mbox_p6: mailbox@15240000 { + compatible = "google,zumapro-aoc-mbox"; + reg = <0x0 0x15240000 0x1000>; + interrupts = ; + #mbox-cells = <1>; + status = "disabled"; + }; + cmu_apm: clock-controller@15400000 { compatible = "google,zumapro-cmu-apm"; reg = <0x0 0x15400000 0x8000>; @@ -1354,6 +1426,62 @@ }; }; + /* + * The audio and sensor DSP. Its authenticated firmware owns its + * memory protection: Linux touches neither its S2MPU nor its + * System MMU, so neither is described. + */ + aoc: aoc@154b0000 { + compatible = "google,zumapro-aoc"; + reg = <0x0 0x154b0000 0x1000>, <0x0 0x10000000 0x20>; + reg-names = "aoc_req", "chipid"; + interrupts = ; + interrupt-names = "watchdog"; + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_MIF>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_INT>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL0>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL1>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL2>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_DSU>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_BCI>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_G3D>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_G3DL2>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_TPU>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_INTCAM>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_TNR>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CAM>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_MFC>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_DISP>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_AOC>, + <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_BW>; + google,gsa = <&gsa>; + mboxes = <&aoc_mbox_a32 0>, <&aoc_mbox_a32 1>, + <&aoc_mbox_a32 2>, <&aoc_mbox_a32 3>, + <&aoc_mbox_a32 4>, <&aoc_mbox_a32 5>, + <&aoc_mbox_a32 6>, <&aoc_mbox_a32 7>, + <&aoc_mbox_a32 8>, <&aoc_mbox_a32 9>, + <&aoc_mbox_a32 10>, <&aoc_mbox_a32 11>, + <&aoc_mbox_a32 12>, <&aoc_mbox_a32 13>, + <&aoc_mbox_a32 14>, <&aoc_mbox_a32 15>, + <&aoc_mbox_f1 0>, <&aoc_mbox_f1 1>, + <&aoc_mbox_f1 2>, <&aoc_mbox_f1 3>, + <&aoc_mbox_f1 4>, <&aoc_mbox_f1 5>, + <&aoc_mbox_f1 6>, <&aoc_mbox_f1 7>, + <&aoc_mbox_f1 8>, <&aoc_mbox_f1 9>, + <&aoc_mbox_f1 10>, <&aoc_mbox_f1 11>, + <&aoc_mbox_f1 12>, <&aoc_mbox_f1 13>, + <&aoc_mbox_f1 14>, <&aoc_mbox_f1 15>, + <&aoc_mbox_p6 0>, <&aoc_mbox_p6 1>, + <&aoc_mbox_p6 2>, <&aoc_mbox_p6 3>, + <&aoc_mbox_p6 4>, <&aoc_mbox_p6 5>, + <&aoc_mbox_p6 6>, <&aoc_mbox_p6 7>, + <&aoc_mbox_p6 8>, <&aoc_mbox_p6 9>, + <&aoc_mbox_p6 10>, <&aoc_mbox_p6 11>, + <&aoc_mbox_p6 12>, <&aoc_mbox_p6 13>, + <&aoc_mbox_p6 14>, <&aoc_mbox_p6 15>; + status = "disabled"; + }; + pinctrl_alive: pinctrl@154d0000 { compatible = "google,zumapro-pinctrl"; reg = <0x0 0x154d0000 0x1000>; @@ -1485,6 +1613,14 @@ }; }; + gsa: gsa@16490000 { + compatible = "google,zumapro-gsa"; + reg = <0x0 0x16490000 0x1000>; + reg-names = "mbox"; + interrupts = ; + status = "disabled"; + }; + dsi0: dsi@19440000 { compatible = "google,zumapro-dsim", "google,gs201-dsim"; reg = <0x0 0x19440000 0x300>, diff --git a/drivers/clk/samsung/clk-zumapro.c b/drivers/clk/samsung/clk-zumapro.c index 4e47c45c12..d813b970b7 100644 --- a/drivers/clk/samsung/clk-zumapro.c +++ b/drivers/clk/samsung/clk-zumapro.c @@ -621,6 +621,7 @@ PNAME(mout_hsi0_noc_local_parents) = { "zumapro_mout_hsi0_noc_user", "zumapro_mo PNAME(mout_hsi0_peri_user_parents) = { "oscclk", "zumapro_dout_hsi0_peri" }; PNAME(mout_hsi0_usi2_local_parents) = { "zumapro_mout_hsi0_peri_user", "oscclk" }; PNAME(mout_hsi0_usi3_local_parents) = { "zumapro_mout_hsi0_peri_user", "oscclk" }; +PNAME(mout_hsi0_usi4_local_parents) = { "zumapro_mout_hsi0_peri_user", "oscclk" }; static const struct samsung_pll_clock hsi0_plls[] __initconst = { PLL(pll_0822x, CLK_FOUT_HSI0_USB, "zumapro_fout_hsi0_usb", "oscclk", @@ -645,6 +646,9 @@ static const struct samsung_mux_clock hsi0_muxes[] __initconst = { 0x101c, 0, 1, 0, CLK_MUX_READ_ONLY), nMUX(CLK_MOUT_HSI0_USI3_LOCAL, "zumapro_mout_hsi0_usi3_local", mout_hsi0_usi3_local_parents, 0x1020, 0, 1), + MUX_F(CLK_MOUT_HSI0_USI4_LOCAL, "zumapro_mout_hsi0_usi4_local", + mout_hsi0_usi4_local_parents, + 0x1024, 0, 1, 0, CLK_MUX_READ_ONLY), }; static const struct samsung_div_clock hsi0_dividers[] __initconst = { @@ -656,6 +660,8 @@ static const struct samsung_div_clock hsi0_dividers[] __initconst = { 0x181c, 0, 4, 0, 0), DIV_F(CLK_DOUT_HSI0_USI3, "zumapro_dout_hsi0_usi3", "zumapro_gout_hsi0_usi3_source", 0x1820, 0, 4, CLK_SET_RATE_PARENT, 0), + DIV_F(CLK_DOUT_HSI0_USI4, "zumapro_dout_hsi0_usi4", "zumapro_gout_hsi0_usi4_source", + 0x1824, 0, 4, 0, CLK_DIVIDER_READ_ONLY), }; static const struct samsung_gate_clock hsi0_gates[] __initconst = { @@ -681,6 +687,14 @@ static const struct samsung_gate_clock hsi0_gates[] __initconst = { * and power-off remain outside this firmware-on handoff. */ static const struct samsung_gate_clock hsi0_ro_gates[] __initconst = { + GATE(CLK_GOUT_HSI0_USI4_SOURCE, "zumapro_gout_hsi0_usi4_source", + "zumapro_mout_hsi0_usi4_local", + 0x2128, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_HSI0_USI4_IP, "zumapro_gout_hsi0_usi4_ip", "zumapro_dout_hsi0_usi4", + 0x210c, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_HSI0_USI4_PCLK, "zumapro_gout_hsi0_usi4_pclk", + "zumapro_mout_hsi0_noc_local", + 0x2110, 21, CLK_IGNORE_UNUSED, 0), GATE(CLK_GOUT_HSI0_ALT, "zumapro_gout_hsi0_alt", "hsi0-alt", 0x204c, 21, CLK_IGNORE_UNUSED, 0), GATE(CLK_GOUT_HSI0_EUSB_REF, "zumapro_gout_hsi0_eusb_ref", "zumapro_mout_hsi0_usb20_ref", @@ -717,7 +731,7 @@ static const struct samsung_cmu_info hsi0_cmu __initconst = { .nr_gate_clks = ARRAY_SIZE(hsi0_gates), .ro_gate_clks = hsi0_ro_gates, .nr_ro_gate_clks = ARRAY_SIZE(hsi0_ro_gates), - .nr_clk_ids = CLK_GOUT_HSI0_USI3_PCLK + 1, + .nr_clk_ids = CLK_GOUT_HSI0_USI4_PCLK + 1, .clk_regs = hsi0_regs, .nr_clk_regs = ARRAY_SIZE(hsi0_regs), .clk_name = "bus", diff --git a/drivers/soc/google/Kconfig b/drivers/soc/google/Kconfig index f4dd87cb8c..b865fd6915 100644 --- a/drivers/soc/google/Kconfig +++ b/drivers/soc/google/Kconfig @@ -74,7 +74,7 @@ config GS201_AOC Google's AoC core driver, ported: loads and authenticates the AoC firmware through the GSA, starts it, and exposes its services on the AoC bus. Firmware loading is triggered from sysfs (firmware), not at - probe. + probe. Supports gs201 and zumapro (Tensor G4). config GS201_AOC_CHAR tristate "gs201 AoC service character devices" diff --git a/drivers/soc/google/aoc/Makefile b/drivers/soc/google/aoc/Makefile index 064ecbf6c3..462602ac80 100644 --- a/drivers/soc/google/aoc/Makefile +++ b/drivers/soc/google/aoc/Makefile @@ -4,6 +4,7 @@ ccflags-y += -I$(src) obj-$(CONFIG_GS201_AOC_MBOX) += mailbox-wc.o obj-$(CONFIG_GS201_AOC) += aoc_core.o -aoc_core-y := aoc.o aoc_ipc_core.o aoc_firmware.o aoc_service_core.o aoc_v1.o +aoc_core-y := aoc.o aoc_ipc_core.o aoc_firmware.o aoc_service_core.o aoc_v1.o \ + aoc_sensor_power.o obj-$(CONFIG_GS201_AOC_CHAR) += aoc_char_dev.o aoc_channel_dev.o obj-y += alsa/ diff --git a/drivers/soc/google/aoc/aoc.c b/drivers/soc/google/aoc/aoc.c index 8fd393c084..366bdca832 100644 --- a/drivers/soc/google/aoc/aoc.c +++ b/drivers/soc/google/aoc/aoc.c @@ -22,9 +22,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -87,6 +89,7 @@ static struct platform_device sscd_dev = { .name = "aoc-sscd", static void *aoc_sram_virt_mapping; static void __iomem *aoc_chipid_virt; +static const struct aoc_soc_data *aoc_chipid_soc; /* gs-chipid.c, gs201 variant: product, type, revision for the firmware */ u32 gs_chipid_get_product_id(void) @@ -101,18 +104,22 @@ u32 gs_chipid_get_type(void) if (!aoc_chipid_virt) return 0; r0 = readl(aoc_chipid_virt); + if (!aoc_chipid_soc->merge_subrevision_into_type) + return r0 & 0xff; r10 = readl(aoc_chipid_virt + 0x10); return (r0 | ((r10 & 0x00f00000) >> 20)) & 0xff; } u32 gs_chipid_get_revision(void) { - u32 r10; + u32 r10, main; if (!aoc_chipid_virt) return 0; + main = readl(aoc_chipid_virt + aoc_chipid_soc->chipid_main_reg); r10 = readl(aoc_chipid_virt + 0x10); - return (((r10 >> 20) & 0xf) << 4) | ((r10 >> 16) & 0xf); + return (((main >> aoc_chipid_soc->chipid_main_shift) & 0xf) << 4) | + ((r10 >> 16) & 0xf); } static void *aoc_dram_virt_mapping; @@ -490,36 +497,65 @@ static u32 aoc_board_config_parse(struct device_node *node, u32 *board_id, u32 * } static int aoc_fw_authenticate(struct aoc_prvdata *prvdata, - const struct firmware *fw) { - - int rc; + const struct firmware *fw) +{ dma_addr_t header_dma_addr; void *header_vaddr; + int rc; - /* Allocate coherent memory for the image header */ - header_vaddr = dma_alloc_coherent(prvdata->gsa_dev, AOC_AUTH_HEADER_SIZE, - &header_dma_addr, GFP_KERNEL); - if (!header_vaddr) { - dev_err(prvdata->dev, "Failed to allocate coherent memory for header\n"); - rc = -ENOMEM; - goto err_alloc; + if (prvdata->soc->firmware_managed_mmu && prvdata->firmware_submitted) + return -EALREADY; + + /* The managed path keeps DMA storage alive even after a timeout. */ + if (prvdata->soc->firmware_managed_mmu) { + header_vaddr = prvdata->auth_header_virt; + if (!header_vaddr) { + header_vaddr = dmam_alloc_coherent(prvdata->gsa_dev, + AOC_AUTH_HEADER_SIZE, + &prvdata->auth_header_dma, + GFP_KERNEL); + prvdata->auth_header_virt = header_vaddr; + } + header_dma_addr = prvdata->auth_header_dma; + } else { + header_vaddr = dma_alloc_coherent(prvdata->gsa_dev, + AOC_AUTH_HEADER_SIZE, + &header_dma_addr, GFP_KERNEL); } + if (!header_vaddr) + return -ENOMEM; memcpy(header_vaddr, fw->data, AOC_AUTH_HEADER_SIZE); - + /* Publish the coherent authentication header before the mailbox request. */ + dma_wmb(); + prvdata->firmware_submitted = true; rc = gsa_load_aoc_fw_image(prvdata->gsa_dev, header_dma_addr, prvdata->dram_resource.start + AOC_BINARY_DRAM_OFFSET); - if (rc) { + if (rc) dev_err(prvdata->dev, "GSA authentication failed: %d\n", rc); - goto err_auth; - } -err_auth: -err_alloc: - dma_free_coherent(prvdata->gsa_dev, AOC_AUTH_HEADER_SIZE, header_vaddr, header_dma_addr); + if (!prvdata->soc->firmware_managed_mmu) + dma_free_coherent(prvdata->gsa_dev, AOC_AUTH_HEADER_SIZE, + header_vaddr, header_dma_addr); return rc; } +/* + * Ask ACPM for the current rate of each DVFS domain in "clocks" (ACPM + * clocks don't cache their rate). On zumapro the firmware faulted at every + * start until the AP had made this query once before it. + */ +static void aoc_read_dvfs_rates(struct aoc_prvdata *prvdata) +{ + unsigned long rate; + int i; + + for (i = 0; i < prvdata->num_dvfs_clks; i++) { + rate = clk_get_rate(prvdata->dvfs_clks[i].clk); + dev_dbg(prvdata->dev, "DVFS %d: %lu Hz\n", i, rate); + } +} + static void aoc_fw_callback(const struct firmware *fw, void *ctx) { static bool first_load_prevented = false; @@ -529,7 +565,9 @@ static void aoc_fw_callback(const struct firmware *fw, void *ctx) u32 carveout_base = prvdata->dram_resource.start; u32 carveout_size = prvdata->dram_size; u32 dt_force_vnom = dt_property(prvdata->dev->of_node, "force-vnom"); - u32 force_vnom = ((dt_force_vnom != 0) || (prvdata->force_voltage_nominal != 0)) ? 1 : 0; + u32 force_vnom = prvdata->force_voltage_nominal || + (dt_force_vnom == DT_PROPERTY_NOT_FOUND ? + prvdata->soc->force_vnom_default : dt_force_vnom != 0); u32 disable_mm = prvdata->disable_monitor_mode; u32 enable_uart = prvdata->enable_uart_tx; u32 force_speaker_ultrasonic = prvdata->force_speaker_ultrasonic; @@ -540,7 +578,7 @@ static void aoc_fw_callback(const struct firmware *fw, void *ctx) u32 chip_revision = gs_chipid_get_revision(); u32 chip_type = gs_chipid_get_type(); u32 chip_product_id = gs_chipid_get_product_id(); - u32 dt_gnss_type = dt_property(prvdata->dev->of_node, "gnss-type"); + u32 dt_gnss_type = dt_property(prvdata->dev->of_node, "google,gnss-type"); u32 gnss_type = dt_gnss_type == DT_PROPERTY_NOT_FOUND ? 0 : dt_gnss_type; u32 dt_wifi_chip = dt_property(prvdata->dev->of_node, "wifi-chip"); u32 wifi_chip = dt_wifi_chip == DT_PROPERTY_NOT_FOUND ? 0 : dt_wifi_chip; @@ -586,7 +624,11 @@ static void aoc_fw_callback(const struct firmware *fw, void *ctx) return; } - aoc_board_config_parse(prvdata->dev->of_node, &board_id, &board_rev); + if (aoc_board_config_parse(prvdata->dev->of_node, &board_id, &board_rev) && + prvdata->soc->firmware_managed_mmu) { + dev_err(dev, "no google,board-id or google,board-rev\n"); + goto free_fw; + } if (!fw) { dev_err(dev, "Failed to load AoC firmware image\n"); @@ -605,6 +647,7 @@ static void aoc_fw_callback(const struct firmware *fw, void *ctx) fw_data[i].value = board_rev; } + aoc_read_dvfs_rates(prvdata); request_aoc_on(prvdata, true); if (!fw->data) { @@ -660,10 +703,26 @@ static void aoc_fw_callback(const struct firmware *fw, void *ctx) aoc_control = aoc_dram_translate(prvdata, ipc_offset); + if (prvdata->soc->firmware_managed_mmu) { + int state = gsa_send_aoc_cmd(prvdata->gsa_dev, GSA_AOC_GET_STATE); + + if (state != GSA_AOC_STATE_INACTIVE || prvdata->firmware_submitted) { + dev_err(dev, "refusing firmware copy: secure state %d\n", state); + goto free_fw; + } + if (wait_for_aoc_status(prvdata, true)) { + dev_err(dev, "firmware-owned power request is not acknowledged\n"); + goto free_fw; + } + } + { bool commit_rc = _aoc_fw_commit(fw, aoc_dram_virt_mapping + AOC_BINARY_DRAM_OFFSET); if (!commit_rc) { dev_err(dev, "FW commit failed!\n"); + /* gs201 carries on to authentication, as before */ + if (prvdata->soc->firmware_managed_mmu) + goto free_fw; } } @@ -682,14 +741,17 @@ static void aoc_fw_callback(const struct firmware *fw, void *ctx) dev_err(dev, "no aoc_req acknowledge\n"); goto free_fw; } - dev_info(dev, "AoC S2MPU CTRL0 %#x, opening\n", - readl(prvdata->s2mpu_virt + AOC_S2MPU_CTRL0)); - writel(0, prvdata->s2mpu_virt + AOC_S2MPU_CTRL0); - rc = aoc_configure_iommu(prvdata, fw); - if (rc) { - dev_err(dev, "System MMU setup failed: %d\n", rc); - goto free_fw; + if (!prvdata->soc->firmware_managed_mmu) { + dev_info(dev, "AoC S2MPU CTRL0 %#x, opening\n", + readl(prvdata->s2mpu_virt + AOC_S2MPU_CTRL0)); + writel(0, prvdata->s2mpu_virt + AOC_S2MPU_CTRL0); + rc = aoc_configure_iommu(prvdata, fw); + if (rc) { + dev_err(dev, "System MMU setup failed: %d\n", rc); + goto free_fw; + } } + rc = aoc_fw_authenticate(prvdata, fw); if (rc) { dev_err(dev, "GSA: FW authentication failed: %d\n", rc); @@ -1119,6 +1181,18 @@ static ssize_t sensor_power_enable_store(struct device *dev, struct aoc_prvdata *prvdata = dev_get_drvdata(dev); int val; + if (prvdata->soc->ordered_sensor_supplies) { + int ret = kstrtoint(buf, 10, &val); + + if (ret) + return ret; + /* Once the firmware is submitted, only a reboot cycles the rails */ + if (prvdata->firmware_submitted) + return -EBUSY; + ret = aoc_sensor_power_set(&prvdata->sensor_power, !!val); + return ret ? ret : count; + } + if (kstrtoint(buf, 10, &val) == 0) { dev_info(prvdata->dev,"sensor_power_enable %d", val); configure_sensor_regulator(prvdata, !!val); @@ -1159,10 +1233,36 @@ static int aoc_platform_probe(struct platform_device *dev); static void aoc_platform_remove(struct platform_device *dev); static void aoc_platform_shutdown(struct platform_device *dev); +static const struct aoc_soc_data gs201_aoc_data = { + .merge_subrevision_into_type = true, + /* What a gs201 node without "force-vnom" has always passed */ + .force_vnom_default = true, + .chipid_main_reg = 0x10, + .chipid_main_shift = 20, + .pcu_base = 0xa00000, + .gpio_base = 0xd70000, + .pcu_db_set = 0xd004, + .pcu_db_clear = 0xd008, +}; + +static const struct aoc_soc_data zumapro_aoc_data = { + .ordered_sensor_supplies = true, + .firmware_managed_mmu = true, + .zero_heaps = true, + .chipid_main_reg = 0, + .chipid_main_shift = 0, + .pcu_base = 0x1400000, + .gpio_base = 0x1c00000, + .pcu_db_set = 0x1f004, + .pcu_db_clear = 0x1f008, +}; + static const struct of_device_id aoc_match[] = { { .compatible = "google,gs201-aoc", + .data = &gs201_aoc_data, }, + { .compatible = "google,zumapro-aoc", .data = &zumapro_aoc_data }, {}, }; MODULE_DEVICE_TABLE(of, aoc_match); @@ -1472,6 +1572,7 @@ static bool configure_sensor_regulator(struct aoc_prvdata *prvdata, bool enable) { bool check_enabled; int i; + if (enable) { check_enabled = true; for (i = 0; i < prvdata->sensor_power_count; i++) { @@ -1577,6 +1678,27 @@ void reset_sensor_power(struct aoc_prvdata *prvdata, bool is_init) int count; bool success; + if (prvdata->soc->ordered_sensor_supplies) { + int ret; + + if (prvdata->firmware_submitted) { + dev_err(prvdata->dev, "sensor rails stay on while the firmware runs\n"); + return; + } + if (!is_init) { + ret = aoc_sensor_power_set(&prvdata->sensor_power, false); + if (ret) { + dev_err(prvdata->dev, "sensor power off failed: %d\n", ret); + return; + } + msleep(150); + } + ret = aoc_sensor_power_set(&prvdata->sensor_power, true); + if (ret) + dev_err(prvdata->dev, "sensor power on failed: %d\n", ret); + return; + } + if (prvdata->sensor_power_count == 0) { return; } @@ -1790,8 +1912,7 @@ static void aoc_watchdog(struct work_struct *work) struct aoc_ramdump_header *ramdump_header = (struct aoc_ramdump_header *)((unsigned long)prvdata->dram_virt + RAMDUMP_HEADER_OFFSET); - struct wakeup_source *ws = - wakeup_source_register(prvdata->dev, dev_name(prvdata->dev)); + struct wakeup_source *ws; unsigned long ramdump_timeout; unsigned long carveout_paddr_from_aoc; unsigned long carveout_vaddr_from_aoc; @@ -1808,6 +1929,18 @@ static void aoc_watchdog(struct work_struct *work) bool ap_triggered_reset, valid_magic; struct aoc_section_header *crash_info_section; + /* Firmware-managed: no ramdump and no restart; a reboot recovers */ + if (prvdata->soc->firmware_managed_mmu) { + mutex_lock(&aoc_service_lock); + aoc_state = AOC_STATE_SSR; + mutex_unlock(&aoc_service_lock); + dev_err(prvdata->dev, + "DSP fault; ordinary reboot required (%s)\n", + prvdata->ap_triggered_reset ? "AP request" : "DSP watchdog"); + return; + } + ws = wakeup_source_register(prvdata->dev, dev_name(prvdata->dev)); + /* If we're already in SSR state, do nothing. */ mutex_lock(&aoc_service_lock); if (aoc_state == AOC_STATE_SSR) { @@ -2413,6 +2546,19 @@ bool aoc_create_dma_buf_heaps(struct aoc_prvdata *prvdata) base -= CAPTURE_HEAP_SIZE; prvdata->audio_capture_heap_base = base; + /* + * Android's heap constructors clear the three heaps at probe; on + * zumapro do the same before the firmware is ever authenticated. + */ + if (prvdata->soc->zero_heaps) { + memset_io((void __iomem *)prvdata->dram_virt + + (base - prvdata->dram_resource.start), 0, + CAPTURE_HEAP_SIZE + PLAYBACK_HEAP_SIZE + + SENSOR_DIRECT_HEAP_SIZE); + /* Before any later authentication and start */ + dma_wmb(); + } + return true; } @@ -2497,15 +2643,34 @@ long aoc_unlocked_ioctl_handle_ion_fd(unsigned int cmd, unsigned long arg) * pcu-db-set/clr-offset, cp-aperture-start/end-offset, clock-divider); * the mailbox channel count is that of the mboxes property. */ +static int aoc_read_firmware_name(struct aoc_prvdata *p, + struct device_node *node) +{ + const char *name; + int ret; + + ret = of_property_read_string(node, "firmware-name", &name); + if (ret) { + if (p->soc->firmware_managed_mmu) + return ret; + name = default_firmware; + } + if (!*name) + return -EINVAL; + if (strscpy(p->firmware_name, name, sizeof(p->firmware_name)) < 0) + return -E2BIG; + return 0; +} + static int platform_probe_parse_dt(struct device *dev, struct device_node *aoc_node) { struct aoc_prvdata *prvdata = platform_get_drvdata(aoc_platform_device); int n; - prvdata->aoc_pcu_base = 0xa00000; - prvdata->aoc_gpio_base = 0xd70000; - prvdata->aoc_pcu_db_set_offset = 0xd004; - prvdata->aoc_pcu_db_clr_offset = 0xd008; + prvdata->aoc_pcu_base = prvdata->soc->pcu_base; + prvdata->aoc_gpio_base = prvdata->soc->gpio_base; + prvdata->aoc_pcu_db_set_offset = prvdata->soc->pcu_db_set; + prvdata->aoc_pcu_db_clr_offset = prvdata->soc->pcu_db_clear; prvdata->aoc_cp_aperture_start_offset = 0x7fdf80; prvdata->aoc_cp_aperture_end_offset = 0x7fffff; prvdata->aoc_clock_divider = 1; @@ -2537,16 +2702,30 @@ static int aoc_platform_probe(struct platform_device *pdev) rc = -EEXIST; goto err_platform_not_null; } - aoc_platform_device = pdev; - aoc_node = dev->of_node; - mem_node = of_parse_phandle(aoc_node, "memory-region", 0); prvdata = devm_kzalloc(dev, sizeof(*prvdata), GFP_KERNEL); if (!prvdata) { rc = -ENOMEM; goto err_failed_prvdata_alloc; } + prvdata->soc = of_device_get_match_data(dev); + if (!prvdata->soc) { + rc = -ENODEV; + goto err_failed_prvdata_alloc; + } + prvdata->dev = dev; + if (prvdata->soc->ordered_sensor_supplies) { + rc = aoc_sensor_power_init(dev, &prvdata->sensor_power); + if (rc) + return rc; + } + rc = devm_clk_bulk_get_all(dev, &prvdata->dvfs_clks); + if (rc < 0) + return dev_err_probe(dev, rc, "failed to get the DVFS clocks\n"); + prvdata->num_dvfs_clks = rc; + aoc_platform_device = pdev; + mem_node = of_parse_phandle(aoc_node, "memory-region", 0); platform_set_drvdata(pdev, prvdata); if (platform_probe_parse_dt(dev, aoc_node) < 0) { @@ -2619,8 +2798,9 @@ static int aoc_platform_probe(struct platform_device *pdev) } - strscpy(prvdata->firmware_name, default_firmware, - sizeof(prvdata->firmware_name)); + rc = aoc_read_firmware_name(prvdata, aoc_node); + if (rc) + goto err_mem_resources; rc = allocate_mailbox_channels(prvdata); if (rc) { @@ -2635,28 +2815,37 @@ static int aoc_platform_probe(struct platform_device *pdev) if (ret < 0) goto err_watchdog_irq; - /* The System MMU's fault interrupts belong to gs201-aoc-sysmmu */ prvdata->iommu_nonsecure_irq = 0; prvdata->iommu_secure_irq = 0; - prvdata->mmu = aoc_sysmmu_get(dev); - if (IS_ERR(prvdata->mmu)) { - rc = PTR_ERR(prvdata->mmu); - goto err_watchdog_iommu_irq; + /* The System MMU's fault interrupts belong to gs201-aoc-sysmmu */ + if (!prvdata->soc->firmware_managed_mmu) { + prvdata->mmu = aoc_sysmmu_get(dev); + if (IS_ERR(prvdata->mmu)) { + rc = PTR_ERR(prvdata->mmu); + goto err_watchdog_iommu_irq; + } + ret = devm_add_action_or_reset(dev, release_sysmmu, prvdata->mmu); + if (ret) { + rc = ret; + goto err_watchdog_iommu_irq; + } } - ret = devm_add_action_or_reset(dev, release_sysmmu, prvdata->mmu); - if (ret) { - rc = ret; - goto err_watchdog_iommu_irq; + if (!prvdata->soc->firmware_managed_mmu) { + prvdata->s2mpu_virt = + devm_platform_ioremap_resource_byname(pdev, "s2mpu"); + if (IS_ERR(prvdata->s2mpu_virt)) { + rc = PTR_ERR(prvdata->s2mpu_virt); + goto err_watchdog_iommu_irq; + } } - - /* In BLK_AOC: only touched once aoc_req is acknowledged */ - prvdata->s2mpu_virt = devm_platform_ioremap_resource_byname(pdev, "s2mpu"); - prvdata->chipid_virt = devm_platform_ioremap_resource_byname(pdev, "chipid"); - if (IS_ERR(prvdata->s2mpu_virt) || IS_ERR(prvdata->chipid_virt)) { - rc = -ENOMEM; + prvdata->chipid_virt = + devm_platform_ioremap_resource_byname(pdev, "chipid"); + if (IS_ERR(prvdata->chipid_virt)) { + rc = PTR_ERR(prvdata->chipid_virt); goto err_watchdog_iommu_irq; } aoc_chipid_virt = prvdata->chipid_virt; + aoc_chipid_soc = prvdata->soc; pr_notice("found aoc with interrupt:%d dram:%pR\n", aoc_irq, &prvdata->dram_resource); @@ -2711,30 +2900,41 @@ static int aoc_platform_probe(struct platform_device *pdev) return -ENOMEM; } - prvdata->sensor_power_count = of_property_count_strings(aoc_node, "sensor_power_list"); - if (prvdata->sensor_power_count > MAX_SENSOR_POWER_NUM) { - pr_warn("sensor power count %i is larger than available number.", - prvdata->sensor_power_count); - prvdata->sensor_power_count = MAX_SENSOR_POWER_NUM; - } else if (prvdata->sensor_power_count < 0) { - pr_err("unsupported sensor power list, err = %i.", prvdata->sensor_power_count); - prvdata->sensor_power_count = 0; - } + if (prvdata->soc->ordered_sensor_supplies) { + rc = aoc_sensor_power_set(&prvdata->sensor_power, true); + if (rc) { + dev_err(dev, "failed to enable sensor supplies: %d\n", rc); + goto err_sram_dram_map; + } + } else { + prvdata->sensor_power_count = + of_property_count_strings(aoc_node, "sensor_power_list"); + if (prvdata->sensor_power_count > MAX_SENSOR_POWER_NUM) { + pr_warn("sensor power count %i is larger than available number.", + prvdata->sensor_power_count); + prvdata->sensor_power_count = MAX_SENSOR_POWER_NUM; + } else if (prvdata->sensor_power_count < 0) { + pr_err("unsupported sensor power list, err = %i.", + prvdata->sensor_power_count); + prvdata->sensor_power_count = 0; + } - ret = of_property_read_string_array(aoc_node, "sensor_power_list", - (const char**)&prvdata->sensor_power_list, - prvdata->sensor_power_count); + ret = of_property_read_string_array(aoc_node, "sensor_power_list", + (const char **)&prvdata->sensor_power_list, + prvdata->sensor_power_count); - for (i = 0; i < prvdata->sensor_power_count; i++) { - prvdata->sensor_regulator[i] = + for (i = 0; i < prvdata->sensor_power_count; i++) { + prvdata->sensor_regulator[i] = devm_regulator_get_exclusive(dev, prvdata->sensor_power_list[i]); - if (IS_ERR_OR_NULL(prvdata->sensor_regulator[i])) { - prvdata->sensor_regulator[i] = NULL; - pr_err("failed to get %s regulator.", prvdata->sensor_power_list[i]); + if (IS_ERR_OR_NULL(prvdata->sensor_regulator[i])) { + prvdata->sensor_regulator[i] = NULL; + pr_err("failed to get %s regulator.", + prvdata->sensor_power_list[i]); + } } - } - reset_sensor_power(prvdata, true); + reset_sensor_power(prvdata, true); + } aoc_parse_dmic_power(prvdata, aoc_node); configure_dmic_regulator(prvdata, true); diff --git a/drivers/soc/google/aoc/aoc.h b/drivers/soc/google/aoc/aoc.h index 8900499bff..f7468bea0d 100644 --- a/drivers/soc/google/aoc/aoc.h +++ b/drivers/soc/google/aoc/aoc.h @@ -20,6 +20,7 @@ #include #include "aoc-compat.h" #include "aoc_ipc_core.h" +#include "aoc_sensor_power.h" /* TODO: Remove internal calls, or promote to "public" */ #include "aoc_ipc_core_internal.h" @@ -90,7 +91,34 @@ struct aoc_service_dev { typedef int (*aoc_map_handler)(u32 handle, phys_addr_t p, size_t size, bool mapped, void *ctx); +/* + * What differs between Tensor generations: where the AoC's PCU and GPIO + * blocks sit in its address space, the chip id layout, the sensor supplies, + * whether Linux sets up the AoC's S2MPU and System MMU or the authenticated + * firmware owns its protection, and the forced-VNOM default. + */ +struct aoc_soc_data { + bool ordered_sensor_supplies; + bool firmware_managed_mmu; + bool merge_subrevision_into_type; + bool force_vnom_default; + bool zero_heaps; + u32 chipid_main_reg; + u32 chipid_main_shift; + u32 pcu_base; + u32 gpio_base; + u32 pcu_db_set; + u32 pcu_db_clear; +}; + struct aoc_prvdata { + struct aoc_sensor_power sensor_power; + const struct aoc_soc_data *soc; + bool firmware_submitted; + void *auth_header_virt; + dma_addr_t auth_header_dma; + struct clk_bulk_data *dvfs_clks; + int num_dvfs_clks; struct mbox_slot *mbox_channels; struct dentry *debugfs; struct aoc_service_dev **services; diff --git a/drivers/soc/google/aoc/aoc_sensor_power.c b/drivers/soc/google/aoc/aoc_sensor_power.c new file mode 100644 index 0000000000..02726dc530 --- /dev/null +++ b/drivers/soc/google/aoc/aoc_sensor_power.c @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Ordered ownership of the sensor supplies used by the Zumapro AoC. */ + +#include +#include +#include +#include +#include + +#include "aoc_sensor_power.h" + +static const char * const aoc_sensor_supply_names[AOC_SENSOR_SUPPLIES] = { + "sensor-1v8", "sensor-3v3", +}; + +/* Stop if a higher rail cannot be disabled: do not remove its lower rail. */ +static int aoc_sensor_power_disable(struct aoc_sensor_power *power, + unsigned long mask) +{ + int i, ret; + + for (i = AOC_SENSOR_SUPPLIES - 1; i >= 0; i--) { + if (!(power->enabled & mask & BIT(i))) + continue; + ret = regulator_disable(power->supplies[i]); + if (ret) + return ret; + power->enabled &= ~BIT(i); + } + + return 0; +} + +int aoc_sensor_power_set(struct aoc_sensor_power *power, bool enable) +{ + unsigned long added = 0; + int i, ret, rollback; + + mutex_lock(&power->lock); + if (!enable) { + ret = aoc_sensor_power_disable(power, GENMASK(AOC_SENSOR_SUPPLIES - 1, 0)); + goto out; + } + + /* Individual enables retain each provider's settling delay and order. */ + for (i = 0; i < AOC_SENSOR_SUPPLIES; i++) { + if (power->enabled & BIT(i)) { + ret = regulator_is_enabled(power->supplies[i]); + if (ret <= 0) { + if (!ret) + ret = -EIO; + goto undo; + } + continue; + } + ret = regulator_is_enabled(power->supplies[i]); + if (ret < 0) + goto undo; + /* Normal get starts with no consumer vote, even if hardware is on. */ + ret = regulator_enable(power->supplies[i]); + if (ret) + goto undo; + power->enabled |= BIT(i); + added |= BIT(i); + ret = regulator_is_enabled(power->supplies[i]); + if (ret <= 0) { + if (!ret) + ret = -EIO; + goto undo; + } + } + ret = 0; + goto out; + +undo: + rollback = aoc_sensor_power_disable(power, added); + if (rollback) + dev_err(power->dev, "sensor supply rollback failed: %d\n", rollback); +out: + mutex_unlock(&power->lock); + return ret; +} + +static void aoc_sensor_power_release(void *data) +{ + struct aoc_sensor_power *power = data; + int ret; + + ret = aoc_sensor_power_set(power, false); + if (ret) + dev_err(power->dev, "sensor supply release failed: %d\n", ret); +} + +int aoc_sensor_power_init(struct device *dev, struct aoc_sensor_power *power) +{ + int i; + + power->dev = dev; + mutex_init(&power->lock); + /* Both suppliers must exist before any AoC probe side effects. */ + if (!device_property_present(dev, "sensor-1v8-supply") || + !device_property_present(dev, "sensor-3v3-supply")) + return dev_err_probe(dev, -EINVAL, "both sensor supplies are required\n"); + + for (i = 0; i < AOC_SENSOR_SUPPLIES; i++) { + /* Optional-get rejects a missing supplier instead of using a dummy. */ + power->supplies[i] = + devm_regulator_get_optional(dev, aoc_sensor_supply_names[i]); + if (IS_ERR(power->supplies[i])) + return dev_err_probe(dev, PTR_ERR(power->supplies[i]), + "failed to get %s supply\n", + aoc_sensor_supply_names[i]); + } + + /* Registered last, so owned votes are dropped before the handles. */ + return devm_add_action_or_reset(dev, aoc_sensor_power_release, power); +} diff --git a/drivers/soc/google/aoc/aoc_sensor_power.h b/drivers/soc/google/aoc/aoc_sensor_power.h new file mode 100644 index 0000000000..c6015c5819 --- /dev/null +++ b/drivers/soc/google/aoc/aoc_sensor_power.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef AOC_SENSOR_POWER_H +#define AOC_SENSOR_POWER_H + +#include + +struct device; +struct regulator; + +#define AOC_SENSOR_SUPPLIES 2 + +struct aoc_sensor_power { + struct device *dev; + struct regulator *supplies[AOC_SENSOR_SUPPLIES]; + /* Serializes the consumer votes and their power sequence. */ + struct mutex lock; + unsigned long enabled; +}; + +int aoc_sensor_power_init(struct device *dev, struct aoc_sensor_power *power); +int aoc_sensor_power_set(struct aoc_sensor_power *power, bool enable); + +#endif diff --git a/drivers/soc/google/aoc/aoc_v1.c b/drivers/soc/google/aoc/aoc_v1.c index f45f91f4d6..c3470208e7 100644 --- a/drivers/soc/google/aoc/aoc_v1.c +++ b/drivers/soc/google/aoc/aoc_v1.c @@ -253,6 +253,18 @@ EXPORT_SYMBOL_GPL(trigger_aoc_ramdump); static irqreturn_t watchdog_int_handler(int irq, void *dev) { + struct aoc_prvdata *prvdata = dev_get_drvdata(dev); + + /* + * Firmware-managed AoCs (zumapro) are not restarted: keep the fault + * for the watchdog work and don't take the interrupt again. + */ + if (prvdata->soc->firmware_managed_mmu) { + disable_irq_nosync(irq); + dev_err(dev, "AoC watchdog interrupt\n"); + schedule_work(&prvdata->watchdog_work); + return IRQ_HANDLED; + } trigger_aoc_ssr(false, NULL); return IRQ_HANDLED; } diff --git a/drivers/soc/google/aoc/mailbox-wc.c b/drivers/soc/google/aoc/mailbox-wc.c index 3cae32624b..e74de0e34d 100644 --- a/drivers/soc/google/aoc/mailbox-wc.c +++ b/drivers/soc/google/aoc/mailbox-wc.c @@ -63,6 +63,9 @@ static const struct of_device_id wc_mbox_match[] = { { .compatible = "google,gs201-aoc-mbox", }, + { + .compatible = "google,zumapro-aoc-mbox", + }, {}, }; MODULE_DEVICE_TABLE(of, wc_mbox_match); diff --git a/drivers/soc/google/gsa.c b/drivers/soc/google/gsa.c index d3e37d182b..b491645d68 100644 --- a/drivers/soc/google/gsa.c +++ b/drivers/soc/google/gsa.c @@ -857,6 +857,7 @@ static void gsa_remove(struct platform_device *pdev) static const struct of_device_id gsa_of_match[] = { { .compatible = "google,gs201-gsa" }, + { .compatible = "google,zumapro-gsa" }, { } }; MODULE_DEVICE_TABLE(of, gsa_of_match); diff --git a/include/dt-bindings/clock/google,zumapro.h b/include/dt-bindings/clock/google,zumapro.h index e54d7a6f35..b46da728ad 100644 --- a/include/dt-bindings/clock/google,zumapro.h +++ b/include/dt-bindings/clock/google,zumapro.h @@ -103,6 +103,11 @@ #define CLK_DOUT_HSI0_USI3 25 #define CLK_GOUT_HSI0_USI3_IP 26 #define CLK_GOUT_HSI0_USI3_PCLK 27 +#define CLK_MOUT_HSI0_USI4_LOCAL 28 +#define CLK_GOUT_HSI0_USI4_SOURCE 29 +#define CLK_DOUT_HSI0_USI4 30 +#define CLK_GOUT_HSI0_USI4_IP 31 +#define CLK_GOUT_HSI0_USI4_PCLK 32 /* CMU_G3D. */ #define CLK_FOUT_G3D 1