Skip to contentSkip to conversation

Add speaker and headset jack support for Apple Silicon Macs

PATCH Superseded James Calligeros 4 participants 31 messages Oct 18 – Oct 21

Subsystems (8)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add speaker and headset jack support for Apple Silicon Macs

Hi folks,

This series adds the machine driver and related bindings for the primary audio subsystem on Apple Silicon Macs. The macaudio machine driver is based on an RFC sent many years ago by Martin Povišer[1].

The driver uses the DPCM model to dynamically
glue a backend DAI (combination of MCA ports and codecs) to a frontend PCM. While this theoretically allows us to route any backend to any frontend, this is not used in practice; the "Primary" frontend is always used for the headset codec and the "Secondary" is always used for the speakers.

The audio subsystem on Apple Silicon Macs is rather complicated and the speaker arrangement is highly variable; some machines have a single mono woofer while others pull together multiple woofers and tweeters into a single stereo pair. Every machine also includes a headset jack, and some also have their own builtin microphones which are handled by a separate coprocessor with its own driver.

Many functions which are handled by firmware on other platforms must be handled by the kernel or by userspace. Most notably, speaker protection is handled by speakersafetyd[2], a userspace daemon. Speaker protection is handled in userspace due to the expensive floating point calculations and amount of per-machine configuration data required.

The machine driver facilitates this by exposing a capture PCM from which the voltage and current across each speaker's voice coil can be read. Given that there are absolutely no hardware or firmware level failsafes preventing permanent damage to the fragile speakers found on these machines, the driver also implements a failsafe that will significantly attenuate and lock the gains of every connected speaker unless speakersafetyd is running.

Version 2 of this series drops numerous fixes and semi-related patches that are not strictly necessary for the machine driver to function correctly. These will be resubmitted at a later date.

Adding the required Devicetree updates for M3 series devices would have bloated this series to an unreasonable size as they are still missing most prerequisite hardware nodes. They will be added in a future series.

Regards,
James

[1] https://lore.kernel.org/asahi/[email protected]/
[2] https://github.com/AsahiLinux/speakersafetyd

---
Changes in v3:
- Add TAS5770L compatible to TAS2770 driver to match binding
- Fix incorrect Right Tweeter prefix on J415
- Make reference to dai-common.yaml in cs42l{42,84} bindings for common properties
- Fix Devicetree binding formatting in macaudio binding
- Sort macaudio compatible list by fallback compatible
- Add references to fixed regulators for machines with CS42L83
- Fix iMac model compatibles (they are compatible with each other)
- Fix Mac Mini J474 name
- Rework kctl activate/deactivate to be a more pure wrapper of snd_ctl_activate_id
- Check for kctl->put before iterating in soc_set_enum_kctl
- Allocate structs on heap in soc_set_enum_kctl
- Rework snd_soc_set_enum_kctl to be neater
- Refactor snd_soc_set_enum_kctl to eliminate ret assignment
- Set evalue.id and info.id in soc_set_enum_kctl
- Guard against pointer arithmetic errors/null pointer deref in volume limiter
- Replace stored snd_soc_card with static struct
- Mark speaker BEs/FEs as nonatomic
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Drop patches that are only tangentially related (will be submitted later)
- Drop wildcard-matching API for kctls
- Relabel J473 sound model to Mac mini
- Align Devicetree changes with upstream bindings
- Relax Cirrus CS42L42 required properties to keep DT style checker happy
- Define missing properties in CS42L{42,84} bindings
- Fix mistyped DT properties
- Improve macaudio DT binding description
- Drop generic fallback compatible for apple,macaudio
- Drop now-redundant descriptions from other compatibles
- Constrain DAI link link-name property with an enum of valid values
- Drop MCA node from macaudio binding example
- Fix heading comment style in macaudio
- Drop obsolete module parameter
- Replace string functions with safer variants
- Replace dropped wildcard API with searching for full kctl name
- Rework idle props parsing to better surface errors/invalid Devicetree entries
- Add additional locking to backend setup
- Take controls_rwsem when safety functions are called from workqueues
- Replace all mutex{,un}lock calls with guard/scoped_guard
- Fix incorrect amp gain value for j37x config struct
- static const-ify all config structs
- Cancel control lock update workqueue on teardown
- Drop unused DAPM widget
- Fix commented-out safe volume calculations
- Drop speaker lock kcontrol ownership checks and related core API extension
- Link to v1: https://patch.msgid.link/[email protected]

To: David Rhodes <[email protected]>
To: Richard Fitzgerald <[email protected]>
To: Martin Povišer <[email protected]>
To: Liam Girdwood <[email protected]>
To: Mark Brown <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: James Calligeros <[email protected]>
To: Jaroslav Kysela <[email protected]>
To: Takashi Iwai <[email protected]>
To: Matthias Brugger <[email protected]>
To: AngeloGioacchino Del Regno <[email protected]>
To: Shenghao Ding <[email protected]>
To: Kevin Lu <[email protected]>
To: Baojun Xu <[email protected]>
To: Sen Wang <[email protected]>
To: Sven Peter <[email protected]>
To: Janne Grunau <[email protected]>
To: Neal Gompa <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
James Calligeros (16):
ASoC: dt-bindings: cs42l84: Document sound-name-prefix property
ASoC: dt-bindings: cs42l42: Document additional dai-common properties
ASoC: tas2770: Add compatible for TAS5770L
arm64: dts: apple: t8103-jxxx: Add regulators for CS42L83 power supply
arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes
arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes
arm64: dts: apple: t8103-j293: Add speaker/headset jack nodes
arm64: dts: apple: t8103-j45x: Add headset jack nodes
arm64: dts: apple: t8112-j413: Add speaker/headset jack nodes
arm64: dts: apple: t8112-j415: Add speaker/headset jack nodes
arm64: dts: apple: t8112-j473: Add speaker/headset jack nodes
arm64: dts: apple: t8112-j493: Add speaker/headset jack nodes
arm64: dts: apple: t600x-j31x: Add speaker/headset jack nodes
arm64: dts: apple: t600x-j375: Add speaker/headset jack nodes
arm64: dts: apple: t602x-j41x: Add speaker/headset jack nodes
arm64: dts: apple: t602x-j47x: Add speaker/headset jack nodes

Martin Povišer (5):
ASoC: dt-bindings: Add binding for Apple Silicon Mac audio
ASoC: ops: Introduce 'snd_soc_ctl_activate'
ASoC: ops: Introduce 'soc_set_enum_kctl'
ASoC: card: Let 'fixup_controls' return errors
ASoC: apple: Add macaudio machine driver

 .../bindings/sound/apple,macaudio.yaml   |  212 +++
 .../bindings/sound/cirrus,cs42l42.yaml   |    7 +
 .../bindings/sound/cirrus,cs42l84.yaml   |    5 +
 .../arm64/boot/dts/apple/t6000-j314s.dts |    5 +
 .../arm64/boot/dts/apple/t6000-j316s.dts |    5 +
 .../arm64/boot/dts/apple/t6001-j314c.dts |    5 +
 .../arm64/boot/dts/apple/t6001-j316c.dts |    5 +
 .../arm64/boot/dts/apple/t6001-j375c.dts |    5 +
 .../arm64/boot/dts/apple/t6002-j375d.dts |    5 +
 .../boot/dts/apple/t600x-j314-j316.dtsi  |  135 ++
 .../arm64/boot/dts/apple/t600x-j375.dtsi |   65 +
 .../arm64/boot/dts/apple/t6020-j414s.dts |    5 +
 .../arm64/boot/dts/apple/t6020-j416s.dts |    5 +
 .../arm64/boot/dts/apple/t6020-j474s.dts |    5 +
 .../arm64/boot/dts/apple/t6021-j414c.dts |    5 +
 .../arm64/boot/dts/apple/t6021-j416c.dts |    5 +
 .../arm64/boot/dts/apple/t6021-j475c.dts |    5 +
 .../arm64/boot/dts/apple/t6022-j475d.dts |    5 +
 .../boot/dts/apple/t602x-j414-j416.dtsi  |   35 +
 .../boot/dts/apple/t602x-j474-j475.dtsi  |   10 +
 arch/arm64/boot/dts/apple/t8103-j274.dts |   72 ++
 arch/arm64/boot/dts/apple/t8103-j293.dts |  116 ++
 arch/arm64/boot/dts/apple/t8103-j313.dts |   87 ++
 arch/arm64/boot/dts/apple/t8103-j456.dts |   43 +
 arch/arm64/boot/dts/apple/t8103-j457.dts |   43 +
 .../arm64/boot/dts/apple/t8103-jxxx.dtsi |   32 +
 arch/arm64/boot/dts/apple/t8112-j413.dts |  108 ++
 arch/arm64/boot/dts/apple/t8112-j415.dts |  132 ++
 arch/arm64/boot/dts/apple/t8112-j473.dts |   62 +
 arch/arm64/boot/dts/apple/t8112-j493.dts |  108 ++
 include/sound/soc-card.h                 |    2 +-
 include/sound/soc.h                      |    6 +-
 sound/soc/apple/Kconfig                  |   18 +
 sound/soc/apple/Makefile                 |    4 +
 sound/soc/apple/macaudio.c               | 1715 +++++++++++++++++++++++++
 sound/soc/codecs/tas2770.c               |    1 +
 .../soc/mediatek/mt8188/mt8188-mt6359.c  |    4 +-
 sound/soc/soc-card.c                     |   12 +-
 sound/soc/soc-core.c                     |    5 +-
 sound/soc/soc-ops.c                      |   99 ++
 40 files changed, 3196 insertions(+), 7 deletions(-)

---
base-commit: 74612d0b448fe745e80cda87fe49ac3c102ccc1f
change-id: 20260915-macaudio-33c1c4f304da

Best regards,

Signature · 1 line
James Calligeros <[email protected]>
#1 lore raw

PATCH v3 1/21 ASoC: dt-bindings: cs42l84: Document sound-name-prefix property

Some consumers may wish to prepend the codec's name with a known value to identify a specific codec among many. Enable this with the common sound-name-prefix property.

---
 .../bindings/sound/cirrus,cs42l84.yaml   | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +5 -0
index 94062c1d9d45..ca137aa57461 100644
@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L84 audio CODEC
 maintainers:
   - Martin Povišer <[email protected]>
 
+allOf:
+  - $ref: dai-common.yaml#
+
 description: |
   The CS42L84 is a headphone jack codec made by Cirrus Logic and embedded
   in personal computers sold by Apple. It was first seen in 2021 Macbook
@@ -32,6 +35,8 @@ properties:
   '#sound-dai-cells':
     const: 0
 
+  sound-name-prefix: true
+
 required:
   - compatible
   - reg
Signature · 1 line
2.56.0
#2 lore raw

Re: [PATCH v3 01/21] ASoC: dt-bindings: cs42l84: Document sound-name-prefix property

Quoted 24 lines · James Calligeros

Some consumers may wish to prepend the codec's name with a known value to identify a specific codec among many. Enable this with the common sound-name-prefix property.

---
 .../bindings/sound/cirrus,cs42l84.yaml   | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +3 -0
index 94062c1d9d45..ca137aa57461 100644
@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L84 audio CODEC
 maintainers:
   - Martin Povišer <[email protected]>
 
+allOf:
+  - $ref: dai-common.yaml#
+
 description: |
   The CS42L84 is a headphone jack codec made by Cirrus Logic and embedded
   in personal computers sold by Apple. It was first seen in 2021 Macbook

Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml properties: · line 38

Quoted 4 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +1 -0
@@ -32,6 +35,8 @@ properties:
   '#sound-dai-cells':
     const: 0
 
+  sound-name-prefix: true

Drop. Repeating myself from v2: just use the same code as others, e.g. cirrus,cs42l51 or other codecs. You only need ref and unevaluatedProps.

Best regards,
Krzysztof

#3 lore raw

PATCH v3 2/21 ASoC: dt-bindings: cs42l42: Document additional dai-common properties

In reply to James Calligeros

We may need to define both #sound-dai-cells and sound-name-prefix on some machines where this codec is part of a simple DAI. Document them with reference to dai-common to keep the style checker happy.

---
 .../bindings/sound/cirrus,cs42l42.yaml   | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +7 -0
index ab4c7d22dc0e..aba2121ac64a 100644
@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L42 audio CODEC
 maintainers:
   - [email protected]
 
+allOf:
+  - $ref: dai-common.yaml#
+
 description:
   The CS42L42 is a low-power audio codec designed for portable applications.
   It provides a high-dynamic range, stereo DAC for audio playback and a mono
@@ -26,6 +29,10 @@ properties:
       The I2C address of the CS42L42.
     maxItems: 1
 
+  '#sound-dai-cells': true
+
+  sound-name-prefix: true
+
   VP-supply:
     description:
       VP power supply.
Signature · 1 line
2.56.0
#4 lore raw

Re: [PATCH v3 02/21] ASoC: dt-bindings: cs42l42: Document additional dai-common properties

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] ASoC: dt-bindings: cs42l42: unconstrained #sound-dai-cells property --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] ASoC: dt-bindings: cs42l42: unconstrained #sound-dai-cells property --

commit 41e0b44d1b55811c2f6af66b07ffb649188a35d3
Author: James Calligeros <[email protected]>

ASoC: dt-bindings: cs42l42: Document additional dai-common properties

This patch references dai-common.yaml# and documents #sound-dai-cells and sound-name-prefix in the cirrus,cs42l42.yaml device tree binding.

Quoted 15 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +3 -0
index ab4c7d22dc0eb..aba2121ac64a7 100644
@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L42 audio CODEC
 maintainers:
   - [email protected]
 
+allOf:
+  - $ref: dai-common.yaml#
+
 description:
   The CS42L42 is a low-power audio codec designed for portable applications.
   It provides a high-dynamic range, stereo DAC for audio playback and a mono

Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml properties: · line 35

Quoted 7 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +4 -0
@@ -26,6 +29,10 @@ properties:
       The I2C address of the CS42L42.
     maxItems: 1
 
+  '#sound-dai-cells': true
+
+  sound-name-prefix: true
+

[Severity: Low]
Should '#sound-dai-cells' be constrained to const: 0 here instead of true?

In Documentation/devicetree/bindings/sound/dai-common.yaml, '#sound-dai-cells': true is a generic placeholder, and referencing codec schemas normally constrain the cell count to match the hardware.

In sound/soc/codecs/cs42l42.c, cs42l42_common_probe() registers a single DAI without a custom .of_xlate_dai_name callback:

    ret = devm_snd_soc_register_component(cs42l42->dev, component_drv, dai, 1);

Leaving '#sound-dai-cells' as true allows non-zero cell counts in device tree nodes to pass schema validation while failing at runtime during ASoC DAI phandle resolution.

Also, if additionalProperties: false at the bottom of Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml is changed to unevaluatedProperties: false when referencing dai-common.yaml# in allOf, would that avoid needing to list sound-name-prefix: true here?

Quoted 3 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +0 -0
   VP-supply:
     description:
       VP power supply.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#5 lore raw

Re: [PATCH v3 02/21] ASoC: dt-bindings: cs42l42: Document additional dai-common properties

In reply to James Calligeros
Quoted 24 lines · James Calligeros

We may need to define both #sound-dai-cells and sound-name-prefix on some machines where this codec is part of a simple DAI. Document them with reference to dai-common to keep the style checker happy.

---
 .../bindings/sound/cirrus,cs42l42.yaml   | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +3 -0
index ab4c7d22dc0e..aba2121ac64a 100644
@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L42 audio CODEC
 maintainers:
   - [email protected]
 
+allOf:
+  - $ref: dai-common.yaml#
+
 description:
   The CS42L42 is a low-power audio codec designed for portable applications.
   It provides a high-dynamic range, stereo DAC for audio playback and a mono

Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml properties: · line 32

Quoted 4 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +1 -0
@@ -26,6 +29,10 @@ properties:
       The I2C address of the CS42L42.
     maxItems: 1
 
+  '#sound-dai-cells': true

Instead const.

Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml properties: · line 34

Quoted 2 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +2 -0
+
+  sound-name-prefix: true

And drop this one.

Best regards,
Krzysztof

#6 lore raw

PATCH v3 3/21 ASoC: dt-bindings: Add binding for Apple Silicon Mac audio

In reply to James Calligeros

From: Martin Povišer <[email protected]>

Add a binding for the primary audio subsystem found on Apple Silicon Macs. This binding integrates the codecs and SoC I2S peripheral used for driving the headset jack and speaker arrays on all Apple Silicon Macs. The internal microphones on this platform are connected to a distinct coprocessor and are not part of this "main" audio subsystem.

---
 .../bindings/sound/apple,macaudio.yaml   | 212 +++++++++++++++++++++++++
 1 file changed, 212 insertions(+)
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +212 -0
new file mode 100644
index 000000000000..af8e9686ba7b
@@ -0,0 +1,212 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/apple,macaudio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sound peripheral integration for Apple Silicon Macs
+
+description:
+  The speakers and headphone jack on Apple Silicon Macs are
+  part of an integrated audio subsystem comprising of Apple's
+  I2S peripheral (MCA) and a series of codecs. The machines
+  have a wide variety of topologies ranging from a simple
+  mono speaker in the desktops to complex stereo arrays with
+  dual-opposed woofers and tweeters all driven by their own
+  mono amplifiers. This arrangement can be expressed as a
+  set of DAI links, where the MCA ports each codec is connected
+  to are represented by the CPU side of the link.
+
+maintainers:
+  - James Calligeros <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - apple,j180-macaudio
+              - apple,j274-macaudio
+              - apple,j293-macaudio
+              - apple,j313-macaudio
+              - apple,j314-macaudio
+              - apple,j316-macaudio
+              - apple,j375-macaudio
+              - apple,j413-macaudio
+              - apple,j415-macaudio
+              - apple,j456-macaudio
+              - apple,j473-macaudio
+      - items:
+          - enum:
+              - apple,j493-macaudio
+          - const: apple,j293-macaudio
+      - items:
+          - enum:
+              - apple,j414-macaudio
+              - apple,j504-macaudio
+              - apple,j514-macaudio
+          - const: apple,j314-macaudio
+      - items:
+          - enum:
+              - apple,j416-macaudio
+              - apple,j516-macaudio
+          - const: apple,j316-macaudio
+      - items:
+          - enum:
+              - apple,j475-macaudio
+              - apple,j575-macaudio
+          - const: apple,j375-macaudio
+      - items:
+          - enum:
+              - apple,j613-macaudio
+          - const: apple,j413-macaudio
+      - items:
+          - enum:
+              - apple,j615-macaudio
+          - const: apple,j415-macaudio
+      - items:
+          - enum:
+              - apple,j457-macaudio
+          - const: apple,j456-macaudio
+      - items:
+          - enum:
+              - apple,j474-macaudio
+          - const: apple,j473-macaudio
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  model:
+    description:
+      Model name for presentation to users
+    $ref: /schemas/types.yaml#/definitions/string
+
+patternProperties:
+  "^dai-link(@[0-9a-f]+)?$":
+    description: |
+      Node for each sound peripheral such as the speaker array, headphones jack,
+      or microphone.
+    type: object
+    $ref: tdm-slot.yaml#
+    additionalProperties: false
+
+    properties:
+      reg:
+        maxItems: 1
+
+      link-name:
+        description: Name for the peripheral
+        enum: [ Headphone Jack, Speaker, Speakers ]
+        $ref: /schemas/types.yaml#/definitions/string
+
+      codec:
+        type: object
+        additionalProperties: false
+
+        properties:
+          sound-dai:
+            minItems: 1
+            maxItems: 8
+            description: |
+              DAI list with the CODEC-side DAIs connected to the above CPU-side
+              DAIs and involved in this sound peripheral.
+
+              The list is in left/right order if applicable. If there are more
+              than one CPU-side DAIs (there can be two), the CODECs must be
+              listed first those connected to the first CPU, then those
+              connected to the second.
+
+              In addition, on some machines with many speaker codecs, the CODECs
+              are listed in this fixed order:
+
+              Four speakers: Left Front, Left Rear, Right Front, Right Rear
+              Six speakers: Left Woofer 1, Left Tweeter, Left Woofer 2,
+                            Right Woofer 1, Right Tweeter, Right Woofer 2
+
+        required:
+          - sound-dai
+
+      cpu:
+        type: object
+        additionalProperties: false
+
+        properties:
+          sound-dai:
+            minItems: 1
+            maxItems: 2
+            description: |
+              DAI list with CPU-side I2S ports involved in this peripheral.
+
+        required:
+          - sound-dai
+
+    patternProperties:
+      "^dai-tdm-idle-mode-[0-9]$":
+        $ref: tdm-slot.yaml#/properties/dai-tdm-idle-mode
+
+      "^dai-tdm-slot-tx-idle-mask-[0-9]$":
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: Idle slot mask. A bit being set to 1 indicates
+          that the corresponding TDM slot is inactive/idle.
+
+    required:
+      - reg
+      - codec
+      - cpu
+
+required:
+  - '#address-cells'
+  - '#size-cells'
+  - compatible
+  - model
+
+additionalProperties: false
+
+examples:
+  - |
+    sound {
+      compatible = "apple,j416-macaudio", "apple,j316-macaudio";
+      model = "MacBook Pro J416";
+
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      dai-link@0 {
+        reg = <0>;
+        link-name = "Speakers";
+
+        dai-tdm-idle-mode-0 = "zero";
+        dai-tdm-idle-mode-3 = "zero";
+        dai-tdm-slot-tx-idle-mask-0 = <0xf0f0f0>;
+        dai-tdm-slot-tx-idle-mask-3 = <0x0f0f0f>;
+
+        codec {
+          sound-dai = <&speaker_left_woof1>,
+                      <&speaker_left_tweet>,
+                      <&speaker_left_woof2>,
+                      <&speaker_right_woof1>,
+                      <&speaker_right_tweet>,
+                      <&speaker_right_woof2>;
+        };
+
+        cpu {
+          sound-dai = <&mca 0>, <&mca 1>;
+        };
+      };
+
+      dai-link@1 {
+        reg = <1>;
+        link-name = "Headphone Jack";
+
+        codec {
+          sound-dai = <&jack_codec>;
+        };
+
+        cpu {
+          sound-dai = <&mca 2>;
+        };
+      };
+    };
Signature · 1 line
2.56.0
#7 lore raw

Re: [PATCH v3 03/21] ASoC: dt-bindings: Add binding for Apple Silicon Mac audio

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] ASoC: dt-bindings: apple,macaudio: additionalProperties blocks tdm-slot $ref --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] ASoC: dt-bindings: apple,macaudio: additionalProperties blocks tdm-slot $ref --

commit 212ef47e302889aa8e011388085ecf8d026993bf
Author: Martin Povišer <[email protected]>

ASoC: dt-bindings: Add binding for Apple Silicon Mac audio

This commit adds a devicetree binding for the primary audio subsystem on Apple Silicon Macs, integrating the MCA I2S peripheral and codecs for driving the headphone jack and speaker arrays.

Quoted 6 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +0 -0
new file mode 100644
index 0000000000000..af8e9686ba7bb
@@ -0,0 +1,212 @@

[ ... ]

Documentation/devicetree/bindings/sound/apple,macaudio.yaml line 94

Quoted 8 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +8 -0
+patternProperties:
+  "^dai-link(@[0-9a-f]+)?$":
+    description: |
+      Node for each sound peripheral such as the speaker array, headphones jack,
+      or microphone.
+    type: object
+    $ref: tdm-slot.yaml#
+    additionalProperties: false

[Severity: Low]
Does setting additionalProperties: false alongside $ref: tdm-slot.yaml# in the ^dai-link(@[0-9a-f]+)?$ schema block all properties defined in tdm-slot.yaml?

In dtschema, additionalProperties: false only permits property names matched by the immediate schema object's properties and patternProperties keywords, ignoring properties defined in a sibling $ref unless they are also listed locally:

Documentation/devicetree/bindings/writing-schema.rst:
* additionalProperties: false
Most common case, where no additional schema is referenced or if this binding allows subset of properties from other referenced schemas.

* unevaluatedProperties: false
Used when this binding references other schema whose all properties should be allowed.

Because none of the properties from tdm-slot.yaml (such as dai-tdm-slot-num, dai-tdm-slot-width, dai-tdm-idle-mode, or the mask properties) are listed in the local properties or patternProperties of ^dai-link(@[0-9a-f]+)?$, any dai-link subnode using standard tdm-slot.yaml properties will fail dtbs_check validation.

Should this use unevaluatedProperties: false instead, or should the node-level $ref: tdm-slot.yaml# be dropped if only the locally defined ^dai-tdm-idle-mode-[0-9]$ and ^dai-tdm-slot-tx-idle-mask-[0-9]$ patternProperties are intended?

[ ... ]

Quoted 13 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +13 -0
+    patternProperties:
+      "^dai-tdm-idle-mode-[0-9]$":
+        $ref: tdm-slot.yaml#/properties/dai-tdm-idle-mode
+
+      "^dai-tdm-slot-tx-idle-mask-[0-9]$":
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: Idle slot mask. A bit being set to 1 indicates
+          that the corresponding TDM slot is inactive/idle.
+
+    required:
+      - reg
+      - codec
+      - cpu

[ ... ]

Quoted 4 lines
Signature · 2 lines
-- 
2.51.2
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
maintainer
#8 lore raw

Re: [PATCH v3 03/21] ASoC: dt-bindings: Add binding for Apple Silicon Mac audio

In reply to James Calligeros
Quoted 30 lines · James Calligeros

From: Martin Povišer <[email protected]>

Add a binding for the primary audio subsystem found on Apple Silicon Macs. This binding integrates the codecs and SoC I2S peripheral used for driving the headset jack and speaker arrays on all Apple Silicon Macs. The internal microphones on this platform are connected to a distinct coprocessor and are not part of this "main" audio subsystem.

---
 .../bindings/sound/apple,macaudio.yaml   | 212 +++++++++++++++++++++++++
 1 file changed, 212 insertions(+)
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +8 -0
new file mode 100644
index 000000000000..af8e9686ba7b
@@ -0,0 +1,212 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/apple,macaudio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sound peripheral integration for Apple Silicon Macs
+

Documentation/devicetree/bindings/sound/apple,macaudio.yaml line 18

Quoted 10 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +10 -0
+description:
+  The speakers and headphone jack on Apple Silicon Macs are
+  part of an integrated audio subsystem comprising of Apple's
+  I2S peripheral (MCA) and a series of codecs. The machines
+  have a wide variety of topologies ranging from a simple
+  mono speaker in the desktops to complex stereo arrays with
+  dual-opposed woofers and tweeters all driven by their own
+  mono amplifiers. This arrangement can be expressed as a
+  set of DAI links, where the MCA ports each codec is connected
+  to are represented by the CPU side of the link.

Wrap lines at 80 chars.

Quoted 61 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +61 -0
+
+maintainers:
+  - James Calligeros <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - apple,j180-macaudio
+              - apple,j274-macaudio
+              - apple,j293-macaudio
+              - apple,j313-macaudio
+              - apple,j314-macaudio
+              - apple,j316-macaudio
+              - apple,j375-macaudio
+              - apple,j413-macaudio
+              - apple,j415-macaudio
+              - apple,j456-macaudio
+              - apple,j473-macaudio
+      - items:
+          - enum:
+              - apple,j493-macaudio
+          - const: apple,j293-macaudio
+      - items:
+          - enum:
+              - apple,j414-macaudio
+              - apple,j504-macaudio
+              - apple,j514-macaudio
+          - const: apple,j314-macaudio
+      - items:
+          - enum:
+              - apple,j416-macaudio
+              - apple,j516-macaudio
+          - const: apple,j316-macaudio
+      - items:
+          - enum:
+              - apple,j475-macaudio
+              - apple,j575-macaudio
+          - const: apple,j375-macaudio
+      - items:
+          - enum:
+              - apple,j613-macaudio
+          - const: apple,j413-macaudio
+      - items:
+          - enum:
+              - apple,j615-macaudio
+          - const: apple,j415-macaudio
+      - items:
+          - enum:
+              - apple,j457-macaudio
+          - const: apple,j456-macaudio
+      - items:
+          - enum:
+              - apple,j474-macaudio
+          - const: apple,j473-macaudio
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":

Documentation/devicetree/bindings/sound/apple,macaudio.yaml line 89

Quoted 10 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +10 -0
+    const: 0
+
+  model:
+    description:
+      Model name for presentation to users
+    $ref: /schemas/types.yaml#/definitions/string
+
+patternProperties:
+  "^dai-link(@[0-9a-f]+)?$":
+    description: |

Don't need '|'.

Documentation/devicetree/bindings/sound/apple,macaudio.yaml line 94

Quoted 5 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +5 -0
+      Node for each sound peripheral such as the speaker array, headphones jack,
+      or microphone.
+    type: object
+    $ref: tdm-slot.yaml#
+    additionalProperties: false

Using tdm-slot.yaml properties, but then disallowing any of them?

Documentation/devicetree/bindings/sound/apple,macaudio.yaml line 98

Quoted 4 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +4 -0
+
+    properties:
+      reg:
+        maxItems: 1

Constraints on the reg values?

Quoted 40 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +40 -0
+
+      link-name:
+        description: Name for the peripheral
+        enum: [ Headphone Jack, Speaker, Speakers ]
+        $ref: /schemas/types.yaml#/definitions/string
+
+      codec:
+        type: object
+        additionalProperties: false
+
+        properties:
+          sound-dai:
+            minItems: 1
+            maxItems: 8
+            description: |
+              DAI list with the CODEC-side DAIs connected to the above CPU-side
+              DAIs and involved in this sound peripheral.
+
+              The list is in left/right order if applicable. If there are more
+              than one CPU-side DAIs (there can be two), the CODECs must be
+              listed first those connected to the first CPU, then those
+              connected to the second.
+
+              In addition, on some machines with many speaker codecs, the CODECs
+              are listed in this fixed order:
+
+              Four speakers: Left Front, Left Rear, Right Front, Right Rear
+              Six speakers: Left Woofer 1, Left Tweeter, Left Woofer 2,
+                            Right Woofer 1, Right Tweeter, Right Woofer 2
+
+        required:
+          - sound-dai
+
+      cpu:
+        type: object
+        additionalProperties: false
+
+        properties:
+          sound-dai:
+            minItems: 1

Documentation/devicetree/bindings/sound/apple,macaudio.yaml line 148

Quoted 10 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +10 -0
+            maxItems: 2
+            description: |
+              DAI list with CPU-side I2S ports involved in this peripheral.
+
+        required:
+          - sound-dai
+
+    patternProperties:
+      "^dai-tdm-idle-mode-[0-9]$":
+        $ref: tdm-slot.yaml#/properties/dai-tdm-idle-mode

Extend tdm-slot.yaml if it doesn't work for you instead of defining a new property using an existing property.

Documentation/devicetree/bindings/sound/apple,macaudio.yaml line 153

Quoted 5 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +5 -0
+
+      "^dai-tdm-slot-tx-idle-mask-[0-9]$":
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: Idle slot mask. A bit being set to 1 indicates
+          that the corresponding TDM slot is inactive/idle.

Extend tdm-slot.yaml...

Rob

#9 lore raw

PATCH v3 4/21 ASoC: ops: Introduce 'snd_soc_ctl_activate'

In reply to James Calligeros

From: Martin Povišer <[email protected]>

This function mirrors wraps the sound/core 'snd_ctl_activate_id' for ASoC. Machine drivers may call it to lock down kcontrols during fixup_controls.

---
 include/sound/soc.h |  2 ++
 sound/soc/soc-ops.c | 32 +++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
include/sound/soc.h +2 -0
index 553bb7e2be98..7509824a6b2e 100644
@@ -578,6 +578,8 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_value *ucontrol);
 int snd_soc_limit_volume(struct snd_soc_card *card,
 	const char *name, int max);
+int snd_soc_ctl_activate(struct snd_soc_card *card,
+	const char *name, int active);
 int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
 		       struct snd_ctl_elem_info *uinfo);
 int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
sound/soc/soc-ops.c +32 -0
index 142f407e3939..295056bcc081 100644
@@ -471,6 +471,38 @@ int snd_soc_limit_volume(struct snd_soc_card *card, const char *name, int max)
 }
 EXPORT_SYMBOL_GPL(snd_soc_limit_volume);
 
+/**
+ * snd_soc_ctl_activate - Activate/deactivate a control matching a name
+ *
+ * @card: where to look for the control
+ * @name: name
+ * @active: zero to deactivate, nonzero to activate
+ *
+ * Return: 0 if unchanged, 1 if changed, or a negative error code on failure.
+ */
+int snd_soc_ctl_activate(struct snd_soc_card *card,
+			 const char *name, int active)
+{
+	struct snd_kcontrol *kctl;
+	int ret = -EINVAL;
+
+	if (!name)
+		return ret;
+
+	kctl = snd_soc_card_get_kcontrol(card, name);
+
+	if (kctl) {
+		ret = snd_ctl_activate_id(card->snd_card, &kctl->id, active);
+		if (ret < 0)
+			return ret;
+	} else {
+		dev_dbg(card->dev, "Tried to de/activate unknown control '%s'\n", name);
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_ctl_activate);
+
 int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
 		       struct snd_ctl_elem_info *uinfo)
 {
Signature · 1 line
2.56.0
#10 lore raw

PATCH v3 5/21 ASoC: ops: Introduce 'soc_set_enum_kctl'

In reply to James Calligeros

From: Martin Povišer <[email protected]>

The new function is to be used to set enumerated controls to desired values. It is something a machine driver may call in fixup_controls.

---
 include/sound/soc.h |  2 +
 sound/soc/soc-ops.c | 67 +++++++++++++++++++++++++
 2 files changed, 69 insertions(+)
include/sound/soc.h +2 -0
index 7509824a6b2e..dcfd706a73ad 100644
@@ -580,6 +580,8 @@ int snd_soc_limit_volume(struct snd_soc_card *card,
 	const char *name, int max);
 int snd_soc_ctl_activate(struct snd_soc_card *card,
 	const char *name, int active);
+int snd_soc_set_enum_kctl(struct snd_soc_card *card,
+	const char *name, const char *strval);
 int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
 		       struct snd_ctl_elem_info *uinfo);
 int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
sound/soc/soc-ops.c +67 -0

73 lines not on this page · raw message

Signature · 1 line
2.56.0
#11 lore raw

PATCH v3 6/21 ASoC: card: Let 'fixup_controls' return errors

In reply to James Calligeros

From: Martin Povišer <[email protected]>

Let the 'fixup_controls' card method return error values which will roll back the half-done binding of the card.

---
 include/sound/soc-card.h                 |  2 +-
 include/sound/soc.h                      |  2 +-
 .../soc/mediatek/mt8188/mt8188-mt6359.c  |  4 +++-
 sound/soc/soc-card.c                     | 12 +++++++++---
 sound/soc/soc-core.c                     |  5 ++++-
 5 files changed, 18 insertions(+), 7 deletions(-)
include/sound/soc-card.h +1 -1
index 1f1e7d45f553..c392e6c4844b 100644
@@ -44,7 +44,7 @@ int snd_soc_card_resume_post(struct snd_soc_card *card);
 
 int snd_soc_card_probe(struct snd_soc_card *card);
 int snd_soc_card_late_probe(struct snd_soc_card *card);
-void snd_soc_card_fixup_controls(struct snd_soc_card *card);
+int snd_soc_card_fixup_controls(struct snd_soc_card *card);
 int snd_soc_card_remove(struct snd_soc_card *card);
 
 void snd_soc_card_set_topology_name(struct snd_soc_card *card, const char *preifx);
include/sound/soc.h +1 -1
index dcfd706a73ad..a3b9d2610514 100644
@@ -1005,7 +1005,7 @@ struct snd_soc_card {
 
 	int (*probe)(struct snd_soc_card *card);
 	int (*late_probe)(struct snd_soc_card *card);
-	void (*fixup_controls)(struct snd_soc_card *card);
+	int (*fixup_controls)(struct snd_soc_card *card);
 	int (*remove)(struct snd_soc_card *card);
 
 	/* the pre and post PM functions are used to do any PM work before and
sound/soc/mediatek/mt8188/mt8188-mt6359.c +3 -1
index 75c90d1d165f..14890af97706 100644
@@ -1280,7 +1280,7 @@ static struct snd_soc_dai_link mt8188_mt6359_dai_links[] = {
 	},
 };
 
-static void mt8188_fixup_controls(struct snd_soc_card *card)
+static int mt8188_fixup_controls(struct snd_soc_card *card)
 {
 	struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card);
 	struct mtk_platform_card_data *card_data = soc_card_data->card_data;
@@ -1302,6 +1302,8 @@ static void mt8188_fixup_controls(struct snd_soc_card *card)
 		else
 			dev_warn(card->dev, "Cannot find ctl : Headphone Switch\n");
 	}
+
+	return 0;
 }
 
 static struct snd_soc_card mt8188_mt6359_soc_card = {
sound/soc/soc-card.c +9 -3
index 282d666dae9e..e4d81329cde3 100644
@@ -184,10 +184,16 @@ int snd_soc_card_late_probe(struct snd_soc_card *card)
 	return 0;
 }
 
-void snd_soc_card_fixup_controls(struct snd_soc_card *card)
+int snd_soc_card_fixup_controls(struct snd_soc_card *card)
 {
-	if (card->fixup_controls)
-		card->fixup_controls(card);
+	if (card->fixup_controls) {
+		int ret = card->fixup_controls(card);
+
+		if (ret < 0)
+			return soc_card_ret(card, ret);
+	}
+
+	return 0;
 }
 
 int snd_soc_card_remove(struct snd_soc_card *card)
sound/soc/soc-core.c +4 -1
index 06167a198591..2092373698db 100644
@@ -2109,7 +2109,10 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
 		if (ret < 0)
 			goto probe_end;
 	}
-	snd_soc_card_fixup_controls(card);
+
+	ret = snd_soc_card_fixup_controls(card);
+	if (ret < 0)
+		goto probe_end;
 
 	ret = snd_card_register(card->snd_card);
 	if (ret < 0) {
Signature · 1 line
2.56.0
#12 lore raw

PATCH v3 7/21 ASoC: tas2770: Add compatible for TAS5770L

In reply to James Calligeros

TAS5770L is an Apple-specific variant of TAS2770 found in a number of first-generation Apple Silicon Macs. Add a compatible for it.

---
 sound/soc/codecs/tas2770.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/codecs/tas2770.c +1 -0
index 882e19857697..5dfddd3bd049 100644
@@ -978,6 +978,7 @@ MODULE_DEVICE_TABLE(i2c, tas2770_i2c_id);
 #if defined(CONFIG_OF)
 static const struct of_device_id tas2770_of_match[] = {
 	{ .compatible = "ti,tas2770" },
+	{ .compatible = "ti,tas5770l" }, /* Apple variant */
 	{},
 };
 MODULE_DEVICE_TABLE(of, tas2770_of_match);
Signature · 1 line
2.56.0
#13 lore raw

PATCH v3 8/21 ASoC: apple: Add macaudio machine driver

In reply to James Calligeros

From: Martin Povišer <[email protected]>

Apple Silicon Macs have a complex audio subsystem consisting of an I2S peripheral (MCA) and multiple codecs of various models and capabilities. Some machines have a basic mono speaker with hardware downmix, while others have a very intricate stereo system consisting of multiple codecs and drivers per L/R channel. Some machines report voice coil voltage and current information back to the SoC, and others do not. All machines have a headset jack.

Add an ASoC machine driver for this platform.

To express all of this sanely, we initialise the correct combinations of codecs/I2S ports as DAI backends and link them to a synthetic frontend. Each frontend is linked to a PCM, one for the headset codec and one for the speaker system on the target machine.

---
 sound/soc/apple/Kconfig    |   18 +
 sound/soc/apple/Makefile   |    4 +
 sound/soc/apple/macaudio.c | 1715 +++++++++++++++++++++++++
 3 files changed, 1737 insertions(+)
sound/soc/apple/Kconfig +18 -0
index f1d071a99fbf..549a5f4906c5 100644
@@ -9,4 +9,22 @@ config SND_SOC_APPLE_MCA
 	  This option enables an ASoC platform driver for MCA peripherals found
 	  on Apple Silicon SoCs.
 
+config SND_SOC_APPLE_MACAUDIO
+	tristate "Sound support for Apple Silicon Macs"
+	depends on ARCH_APPLE || COMPILE_TEST
+	select SND_SOC_APPLE_MCA
+	select APPLE_ADMAC if DMADEVICES
+	select COMMON_CLK_APPLE_NCO if COMMON_CLK
+	select SND_SOC_TAS2764 if I2C
+	select SND_SOC_TAS2770 if I2C
+	select SND_SOC_CS42L83 if I2C
+	select SND_SOC_CS42L84 if I2C
+	help
+	  This option enables an ASoC machine-level driver for Apple Silicon Macs
+	  and it also enables the required SoC and codec drivers for overall
+	  sound support on these machines. Say Y here if you have an Apple Silicon
+	  Mac.
+
+	  This driver can also be compiled as a module. If so, it will be called
+	  snd-soc-macaudio.
 endmenu
sound/soc/apple/Makefile +4 -0
index 252ba5fc18cb..90ad83adc588 100644
@@ -2,3 +2,7 @@
 snd-soc-apple-mca-y	:= mca.o
 
 obj-$(CONFIG_SND_SOC_APPLE_MCA)	+= snd-soc-apple-mca.o
+
+snd-soc-macaudio-y	:= macaudio.o
+
+obj-$(CONFIG_SND_SOC_APPLE_MACAUDIO)	+= snd-soc-macaudio.o
sound/soc/apple/macaudio.c new file +1715 -0

1,715 lines not on this page · raw message

Signature · 1 line
2.56.0
#14 lore raw

Re: [PATCH v3 08/21] ASoC: apple: Add macaudio machine driver

Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider: - [Critical] ASoC: apple: macaudio: wrong drvdata and teardown order in remove() - [High] ASoC: apple…

Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [Critical] ASoC: apple: macaudio: wrong drvdata and teardown order in remove()
- [High] ASoC: apple: macaudio: ABBA deadlock in macaudio_vlimit_update()
- [High] ASoC: apple: macaudio: static macaudio_card mutated across probes
- [High] ASoC: apple: macaudio: atomic Primary FE fails with nonatomic speaker BE
- [Medium] ASoC: apple: macaudio: OF node reference leaks in macaudio_parse_of()
- [Medium] ASoC: apple: macaudio: TDM idle mode skipped in macaudio_be_assign_tdm()
- [Medium] ASoC: apple: macaudio: race with cancel_delayed_work() on timeout work --

commit 56eeabc9bf8ef8e9b2a3eb1ec213300f3ed1ab23
Author: Martin Povišer <[email protected]>

ASoC: apple: Add macaudio machine driver

This commit adds an ASoC machine driver for Apple Silicon Macs to manage DPCM routing between MCA I2S frontends/backends, speaker arrays, speaker sense capture, and headset jack codecs.

Quoted 6 lines
sound/soc/apple/macaudio.c new file +0 -0
new file mode 100644
index 0000000000000..b8e58c9a676f8
@@ -0,0 +1,1715 @@

[ ... ]

Quoted 13 lines
sound/soc/apple/macaudio.c new file +13 -0
+static struct snd_soc_dai_link macaudio_fe_links[] = {
+	{
+		.name = "Primary",
+		.stream_name = "Primary",
+		.dynamic = 1,
+		.dpcm_merged_rate = 1,
+		.dpcm_merged_chan = 1,
+		.dpcm_merged_format = 1,
+		.dai_fmt = MACAUDIO_DAI_FMT,
+		SND_SOC_DAILINK_REG(primary),
+	},
+	{
+		.name = "Secondary",

sound/soc/apple/macaudio.c line 182

Quoted 10 lines
sound/soc/apple/macaudio.c new file +10 -0
+		.stream_name = "Secondary",
+		.dynamic = 1,
+		.dpcm_merged_rate = 1,
+		.dpcm_merged_chan = 1,
+		.dpcm_merged_format = 1,
+		.dai_fmt = MACAUDIO_DAI_FMT,
+		.playback_only = 1,
+		.nonatomic = 1,
+		SND_SOC_DAILINK_REG(secondary),
+	},

[Severity: High]
Should the Primary frontend link in macaudio_fe_links[] (and the headphone backend links in macaudio_parse_of()) also set .nonatomic = 1?

In macaudio_dapm_routes[], both Primary and Secondary are routed to both Speaker Playback Mux (where Primary is the default selection at index 0) and Headphone Playback Mux. In macaudio_parse_of(), speaker backend links set link->nonatomic = 1, while headphone backend links have link->nonatomic = 0.

When Primary (atomic) is routed to a speaker backend (nonatomic), dpcm_be_connect() in sound/soc/soc-pcm.c rejects the connection with -EINVAL because an atomic frontend cannot connect to a nonatomic backend:

sound/soc/soc-pcm.c:dpcm_be_connect() {
	...
	if (be_substream->pcm->nonatomic && !fe_substream->pcm->nonatomic) {
		dev_err(be->dev, "FE is atomic but BE is nonatomic, invalid configuration\n");
		return -EINVAL;
	}
	if (!be_substream->pcm->nonatomic && fe_substream->pcm->nonatomic) {
		be_substream->pcm->nonatomic = 1;
	}
	...
}

Furthermore, if Secondary (nonatomic) is ever routed to Headphone Playback Mux, dpcm_be_connect() mutates the headphone backend PCM to nonatomic = 1, causing subsequent attempts to route Primary to headphones to also fail with -EINVAL.

[ ... ]

Quoted 13 lines
sound/soc/apple/macaudio.c new file +13 -0
+static void macaudio_vlimit_update(struct macaudio_snd_data *ma, bool take_rwsem)
+{
+	bool unlock = true;
+	const char *reason;
+
+	/* Do nothing if there is no safety configured */
+	if (!ma->has_safety)
+		return;
+
+	/* Check that the control has been pinged within the timeout */
+	if (ma->speaker_lock_remain <= 0) {
+		reason = "Lock timeout";
+		unlock = false;

sound/soc/apple/macaudio.c line 308

Quoted 10 lines
sound/soc/apple/macaudio.c new file +10 -0
+	}
+
+	/*
+	 * If this has been called from either of the safety interlock
+	 * workqueues, the core API has not taken controls_rwsem for us.
+	 * Take the write semaphore since macaudio_vlimit_unlock writes
+	 * to the kcontrols.
+	 */
+	if (take_rwsem)
+		down_write(&ma->card->snd_card->controls_rwsem);

[Severity: High]
Can taking controls_rwsem here while holding ma->volume_lock_mutex cause an AB-BA deadlock with macaudio_slk_put()?

When lock_update_work or lock_timeout_work runs, macaudio_vlimit_enable_timeout(), macaudio_vlimit_disable_timeout(), and macaudio_vlimit_timeout_work() first acquire ma->volume_lock_mutex via guard(mutex)(&ma->volume_lock_mutex) and then call macaudio_vlimit_update(ma, true), which calls down_write(&ma->card->snd_card->controls_rwsem):

volume_lock_mutex -> controls_rwsem

Conversely, when userspace writes to the Speaker Volume Unlock control, snd_ctl_elem_write() in sound/core/control.c acquires down_write(&card->controls_rwsem) before invoking macaudio_slk_put(), which then acquires guard(mutex)(&ma->volume_lock_mutex):

controls_rwsem -> volume_lock_mutex

If a userspace control write races with either work item, will the two threads deadlock against each other?

Quoted 66 lines
sound/soc/apple/macaudio.c new file +66 -0
+
+	if (unlock != ma->speaker_volume_unlocked) {
+		if (unlock) {
+			dev_info(ma->card->dev, "Speaker volumes unlocked\n");
+		} else  {
+			dev_info(ma->card->dev, "Speaker volumes locked: %s\n", reason);
+			ma->speaker_volume_was_locked = true;
+		}
+
+		macaudio_vlimit_unlock(ma, unlock);
+		ma->speaker_volume_unlocked = unlock;
+		snd_ctl_notify(ma->card->snd_card, SNDRV_CTL_EVENT_MASK_VALUE,
+			       &ma->speaker_lock_kctl->id);
+	}
+
+	if (take_rwsem)
+		up_write(&ma->card->snd_card->controls_rwsem);
+}
+
+static void macaudio_vlimit_enable_timeout(struct macaudio_snd_data *ma)
+{
+	guard(mutex)(&ma->volume_lock_mutex);
+
+	if (ma->speaker_lock_timeout_enabled) {
+		return;
+	}
+
+	if (ma->speaker_lock_remain > 0) {
+		ma->speaker_lock_timeout = ktime_add(ktime_get(), ma->speaker_lock_remain);
+		schedule_delayed_work(&ma->lock_timeout_work,
+				      usecs_to_jiffies(ktime_to_us(ma->speaker_lock_remain)));
+		dev_dbg(ma->card->dev, "Enabling volume limit timeout: %ld us left\n",
+			(long)ktime_to_us(ma->speaker_lock_remain));
+	}
+
+	macaudio_vlimit_update(ma, true);
+
+	ma->speaker_lock_timeout_enabled = true;
+}
+
+static void macaudio_vlimit_disable_timeout(struct macaudio_snd_data *ma)
+{
+	ktime_t now;
+
+	guard(mutex)(&ma->volume_lock_mutex);
+
+	if (!ma->speaker_lock_timeout_enabled) {
+		return;
+	}
+
+	now = ktime_get();
+
+	cancel_delayed_work(&ma->lock_timeout_work);
+
+	if (ktime_after(now, ma->speaker_lock_timeout))
+		ma->speaker_lock_remain = 0;
+	else if (ma->speaker_lock_remain > 0)
+		ma->speaker_lock_remain = ktime_sub(ma->speaker_lock_timeout, now);
+
+	dev_dbg(ma->card->dev, "Disabling volume limit timeout: %ld us left\n",
+		(long)ktime_to_us(ma->speaker_lock_remain));
+
+	macaudio_vlimit_update(ma, true);
+
+	ma->speaker_lock_timeout_enabled = false;
+}

sound/soc/apple/macaudio.c line 384

Quoted 10 lines
sound/soc/apple/macaudio.c new file +10 -0
+
+static void macaudio_vlimit_timeout_work(struct work_struct *wrk)
+{
+	struct macaudio_snd_data *ma = container_of(to_delayed_work(wrk),
+						    struct macaudio_snd_data, lock_timeout_work);
+
+	guard(mutex)(&ma->volume_lock_mutex);
+	ma->speaker_lock_remain = 0;
+	macaudio_vlimit_update(ma, true);
+}

[Severity: Medium]
What happens if lock_timeout_work fires and macaudio_vlimit_timeout_work() blocks on ma->volume_lock_mutex just after macaudio_slk_put() or macaudio_vlimit_disable_timeout() acquires ma->volume_lock_mutex?

Because macaudio_slk_put() and macaudio_vlimit_disable_timeout() use non-synchronous cancel_delayed_work(&ma->lock_timeout_work) while holding ma->volume_lock_mutex, cancel_delayed_work() cannot stop a macaudio_vlimit_timeout_work() instance that has already been dispatched and is waiting on ma->volume_lock_mutex.

Once macaudio_slk_put() refreshes ma->speaker_lock_remain to ms_to_ktime(SPEAKER_LOCK_TIMEOUT), reschedules lock_timeout_work, and releases ma->volume_lock_mutex (or macaudio_vlimit_disable_timeout() disables the timeout and releases the mutex), the waiting macaudio_vlimit_timeout_work() will acquire ma->volume_lock_mutex and unconditionally zero ma->speaker_lock_remain and lock the speaker volumes.

Should macaudio_vlimit_timeout_work() verify that ma->speaker_lock_timeout_enabled is still true and ktime_after(ktime_get(), ma->speaker_lock_timeout) before zeroing ma->speaker_lock_remain?

[ ... ]

Quoted 13 lines
sound/soc/apple/macaudio.c new file +13 -0
+static int macaudio_parse_of_component(struct device_node *node, int index,
+				struct snd_soc_dai_link_component *comp)
+{
+	struct of_phandle_args args;
+	int ret;
+
+	ret = of_parse_phandle_with_args(node, "sound-dai", "#sound-dai-cells",
+						index, &args);
+	if (ret)
+		return ret;
+	comp->of_node = args.np;
+	return snd_soc_get_dai_name(&args, &comp->dai_name);
+}

[ ... ]

Quoted 10 lines
sound/soc/apple/macaudio.c new file +10 -0
+static int macaudio_parse_of(struct macaudio_snd_data *ma, struct snd_soc_card *card)
+{
+	struct device_node *codec = NULL;
+	struct device_node *cpu = NULL;
+	struct device_node *np = NULL;
+	struct device_node *platform = NULL;
+	struct snd_soc_dai_link *link = NULL;
+	struct device *dev = card->dev;
+	struct macaudio_link_props *link_props;
+	int ret, num_links, i;

[ ... ]

Quoted 20 lines
sound/soc/apple/macaudio.c new file +20 -0
+		for (be_index = 0; be_index < num_bes; be_index++) {
+			/*
+			 * Set initial link name to be overwritten by a BE-specific
+			 * name later so that we can use at least use the provisional
+			 * name in error messages.
+			 */
+			link->name = link_name;
+
+			ret = macaudio_parse_of_be_dai_link(card, link, be_index,
+							    ncodecs_per_cpu, cpu, codec);
+			if (ret)
+				goto err_free;
+
+			link->nonatomic = link_props->is_speakers = speakers;
+			link_props->is_headphones = !speakers;
+
+			link_props->codecs = devm_kcalloc(dev, ncodecs_per_cpu,
+							  sizeof(struct ma_codec_idle), GFP_KERNEL);
+			if (!link_props->codecs)
+				return -ENOMEM;

[ ... ]

Quoted 12 lines
sound/soc/apple/macaudio.c new file +12 -0
+			/* Steal platform OF reference for use in FE links later */
+			platform = link->cpus->of_node;
+
+			link++; link_props++;
+		}
+
+		of_node_put(codec);
+		of_node_put(cpu);
+		cpu = codec = NULL;
+
+		num_links += num_bes;
+	}

[ ... ]

Quoted 9 lines
sound/soc/apple/macaudio.c new file +9 -0
+err_free:
+	of_node_put(codec);
+	of_node_put(cpu);
+	of_node_put(np);
+
+	if (!card->dai_link)
+		return ret;
+
+	for (i = 0; i < num_links; i++) {

sound/soc/apple/macaudio.c line 767

Quoted 10 lines
sound/soc/apple/macaudio.c new file +10 -0
+		/*
+		 * TODO: If we don't go through this path are the references
+		 * freed inside ASoC?
+		 */
+		snd_soc_of_put_dai_link_codecs(&card->dai_link[i]);
+		snd_soc_of_put_dai_link_cpus(&card->dai_link[i]);
+	}
+
+	return ret;
+}

[Severity: Medium]
Does macaudio_parse_of() leak device_node references in several paths?

1. If devm_kcalloc() for link_props->codecs fails, macaudio_parse_of() returns -ENOMEM directly from inside the for_each_available_child_of_node() loop instead of jumping to err_free, leaking np, cpu, codec, and all previously acquired DAI link component of_node references.

2. In macaudio_parse_of_component(), comp->of_node = args.np is assigned before calling snd_soc_get_dai_name(&args, &comp->dai_name). In macaudio_parse_of(), num_links is only incremented by num_bes after the entire inner for (be_index = 0; be_index < num_bes; be_index++) loop completes. If macaudio_parse_of_be_dai_link() fails (for example when snd_soc_get_dai_name() returns -EPROBE_DEFER), execution jumps to err_free, where the cleanup loop only iterates up to num_links and misses any comp->of_node references already populated in the current child node's BE links.

3. Regarding the TODO comment in err_free: ASoC core does not release dai_link->codecs[].of_node or dai_link->cpus[].of_node. If devm_snd_soc_register_card() fails or when the driver is removed, those device_node references are never released.

[ ... ]

Quoted 41 lines
sound/soc/apple/macaudio.c new file +41 -0
+static int macaudio_be_assign_tdm(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_card *card = rtd->card;
+	struct macaudio_snd_data *ma = snd_soc_card_get_drvdata(card);
+	struct macaudio_link_props *props = &ma->link_props[rtd->dai_link->id];
+	struct snd_soc_dai *dai;
+	unsigned int mask;
+	int nslots, ret, i;
+
+	if (!props->tdm_mask)
+		return 0;
+
+	mask = props->tdm_mask;
+	nslots = __fls(mask) + 1;
+
+	if (rtd->dai_link->num_codecs == 1) {
+		ret = snd_soc_dai_set_tdm_slot(snd_soc_rtd_to_codec(rtd, 0), mask,
+					       0, nslots, MACAUDIO_SLOTWIDTH);
+
+		/*
+		 * Headphones get a pass on -ENOTSUPP (see the comment
+		 * around bclk_ratio value for primary FE).
+		 */
+		if (ret == -ENOTSUPP && props->is_headphones)
+			return 0;
+
+		return ret;
+	}
+
+	for_each_rtd_codec_dais(rtd, i, dai) {
+		int slot = __ffs(mask);
+
+		mask &= ~(1 << slot);
+		ret = snd_soc_dai_set_tdm_slot(dai, 1 << slot, 0, nslots,
+					       MACAUDIO_SLOTWIDTH);
+		if (ret)
+			return ret;
+
+		if (props->codecs[i].idle_mode) {
+			ret = snd_soc_dai_set_tdm_idle(dai, props->codecs[i].idle_mask,
+						       0, props->codecs[i].idle_mode, 0);

sound/soc/apple/macaudio.c line 1041

Quoted 10 lines
sound/soc/apple/macaudio.c new file +10 -0
+			if (ret) {
+				dev_err(card->dev, "Failed to set idle props for codec %d\n", i);
+				return ret;
+			}
+
+		}
+	}
+
+	return 0;
+}

[Severity: Medium]
When rtd->dai_link->num_codecs == 1, macaudio_be_assign_tdm() returns early after calling snd_soc_dai_set_tdm_slot() without checking props->codecs[0].idle_mode or calling snd_soc_dai_set_tdm_idle().

On machines where each speaker backend DAI link has a single codec (such as 2 speaker codecs split across 2 CPU BEs), won't this skip applying the dai-tdm-idle-mode-* and dai-tdm-slot-tx-idle-mask-* properties parsed by macaudio_get_codec_idle_props()?

[ ... ]

Quoted 15 lines
sound/soc/apple/macaudio.c new file +15 -0
+static struct snd_soc_card macaudio_card = {
+	.owner = THIS_MODULE,
+	.driver_name = "macaudio",
+	.dapm_widgets = macaudio_snd_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(macaudio_snd_widgets),
+	.dapm_routes = macaudio_dapm_routes,
+	.num_dapm_routes = ARRAY_SIZE(macaudio_dapm_routes),
+	.controls = macaudio_controls,
+	.num_controls = ARRAY_SIZE(macaudio_controls),
+	.probe = macaudio_probe,
+	.late_probe = macaudio_late_probe,
+	.component_chaining = true,
+	.fully_routed = true,
+	.fixup_controls = macaudio_fixup_controls,
+};

[ ... ]

Quoted 33 lines
sound/soc/apple/macaudio.c new file +33 -0
+static int macaudio_snd_platform_probe(struct platform_device *pdev)
+{
+	struct snd_soc_card *card;
+	struct macaudio_snd_data *data;
+	struct device *dev = &pdev->dev;
+	struct snd_soc_dai_link *link;
+	const struct of_device_id *of_id;
+	int ret;
+	int i;
+
+	of_id = of_match_device(macaudio_snd_device_id, dev);
+	if (!of_id)
+		return -EINVAL;
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+	card = &macaudio_card;
+	data->card = card;
+
+	snd_soc_card_set_drvdata(card, data);
+	dev_set_drvdata(&pdev->dev, data);
+	mutex_init(&data->volume_lock_mutex);
+	mutex_init(&data->be_link_mutex);
+
+	card->dev = dev;
+
+	if (of_id->data)
+		data->cfg = of_id->data;
+	else
+		data->cfg = &macaudio_fallback_cfg;
+
+	ret = macaudio_parse_of(data, card);

sound/soc/apple/macaudio.c line 1675

Quoted 10 lines
sound/soc/apple/macaudio.c new file +10 -0
+	if (ret)
+		return ret;
+
+	/* Remove useless controls */
+	if (!data->has_speakers) /* No speakers, remove both */
+		card->num_controls -= MACAUDIO_NUM_SPEAKER_CONTROLS;
+	else if (!data->cfg->safe_vol) /* No safety, remove unlock */
+		card->num_controls -= MACAUDIO_NUM_SPEAKER_LIMIT_CONTROLS;
+	else /* Speakers with safety, mark us as such */
+		data->has_safety = true;

[Severity: High]
Since macaudio_card is a static struct shared across probe attempts, what happens if devm_snd_soc_register_card() defers probe (-EPROBE_DEFER) or the device is unbound and re-probed?

In macaudio_snd_platform_probe(), card->num_controls is decremented in-place with -= without being reset to ARRAY_SIZE(macaudio_controls). Across repeated deferred probes, card->num_controls will be decremented multiple times, dropping valid controls or underflowing. For example, on a machine with speakers and !safe_vol, a second probe attempt will drop the Speaker Sample Rate control, causing snd_soc_card_get_kcontrol(card, "Speaker Sample Rate") in macaudio_late_probe() to return NULL and triggering a NULL pointer dereference when macaudio_dpcm_hw_params() or macaudio_be_hw_free() accesses &ma->speaker_sample_rate_kctl->id.

Similarly, macaudio_parse_of() assigns a devm-allocated array to macaudio_card.dai_link; if probe fails after that allocation, devres frees the array while leaving macaudio_card.dai_link pointing to freed memory if a subsequent probe jumps to err_free before reallocating card->dai_link. Embedding struct snd_soc_card inside struct macaudio_snd_data (and initializing it from a const template on probe) would avoid mutating global state across probes.

Quoted 15 lines
sound/soc/apple/macaudio.c new file +15 -0
+
+	for_each_card_prelinks(card, i, link) {
+		if (link->no_pcm) {
+			link->ops = &macaudio_be_ops;
+			link->init = macaudio_be_init;
+			link->exit = macaudio_be_exit;
+		} else {
+			link->ops = &macaudio_fe_ops;
+			link->init = macaudio_fe_init;
+		}
+	}
+
+	INIT_WORK(&data->lock_update_work, macaudio_vlimit_update_work);
+	INIT_DELAYED_WORK(&data->lock_timeout_work, macaudio_vlimit_timeout_work);
+

sound/soc/apple/macaudio.c line 1700

Quoted 10 lines
sound/soc/apple/macaudio.c new file +10 -0
+	return devm_snd_soc_register_card(dev, card);
+}
+
+static void macaudio_snd_platform_remove(struct platform_device *pdev)
+{
+	struct macaudio_snd_data *ma = dev_get_drvdata(&pdev->dev);
+
+	cancel_work_sync(&ma->lock_update_work);
+	cancel_delayed_work_sync(&ma->lock_timeout_work);
+}

[Severity: Critical]
Does macaudio_snd_platform_remove() retrieve the wrong pointer from dev_get_drvdata(&pdev->dev) and cancel the work items in the wrong order relative to card unregistration?

1. In macaudio_snd_platform_probe(), dev_set_drvdata(&pdev->dev, data) sets the platform device's drvdata to struct macaudio_snd_data *data, and then calls devm_snd_soc_register_card(dev, card). Inside snd_soc_register_card() in sound/soc/soc-core.c, ASoC unconditionally overwrites card->dev's drvdata with card:

sound/soc/soc-core.c:snd_soc_register_card() {
	...
	dev_set_drvdata(card->dev, card);
	...
}

When macaudio_snd_platform_remove() later calls dev_get_drvdata(&pdev->dev), it receives struct snd_soc_card * (instead of struct macaudio_snd_data *) and passes offsets inside macaudio_card to cancel_work_sync() and cancel_delayed_work_sync().

2. Because the card is registered with devm_snd_soc_register_card(), the devres release callback that unregisters the card runs after macaudio_snd_platform_remove() returns. While the card is still registered (and during PCM teardown in snd_soc_unregister_card()), macaudio_be_trigger() or macaudio_slk_put() can schedule lock_update_work and lock_timeout_work again after macaudio_snd_platform_remove() has completed, leading to use-after-free when devres frees struct macaudio_snd_data.

|}

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
#15 lore raw

PATCH v3 9/21 arm64: dts: apple: t8103-jxxx: Add regulators for CS42L83 power supply

In reply to James Calligeros

The CS42L83 codec found on M1 series Apple Silicon Macs gets its voltages from fixed regulators managed by the platform. Add these to the template Devicetree so that they can be referenced on the relevant devices.

We do not (officially) know how the power is delivered to the chip (voltage rail names, commoned pins, physical regulators, etc.) so the regulators expressed here are just stand-ins.

---
 .../arm64/boot/dts/apple/t8103-jxxx.dtsi | 32 +++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm64/boot/dts/apple/t8103-jxxx.dtsi +32 -0
index 686fb1dd215d..7483fc5cbd20 100644
@@ -38,6 +38,38 @@ memory@800000000 {
 		device_type = "memory";
 		reg = <0x8 0 0x2 0>; /* To be filled by loader */
 	};
+
+	/*
+	 * The CS42L83 found on all T8103 boards requires VA, VCP, VCP_FILT,
+	 * VL, VD and VP regulators. We don't (officially) know how power
+	 * gets to the codec, so these fixed regulators are stand-ins.
+	 */
+	jack_va_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-va";
+	};
+
+	/* CS42L83 VCP and VCP_FILT */
+	jack_vcp_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-vcp";
+	};
+
+	jack_vl_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-vl";
+	};
+
+	/* VD_FILT */
+	jack_vd_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-vd";
+	};
+
+	jack_vp_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-vp";
+	};
 };
 
 &serial0 {
Signature · 1 line
2.56.0
#16 lore raw

Re: [PATCH v3 09/21] arm64: dts: apple: t8103-jxxx: Add regulators for CS42L83 power supply

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] arm64: dts: apple: duplicate node names in t8103-jxxx.dtsi merge regulators --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] arm64: dts: apple: duplicate node names in t8103-jxxx.dtsi merge regulators --

commit d0005942339444378649a8aca2fe8ee2e51f9a6a
Author: James Calligeros <[email protected]>

arm64: dts: apple: t8103-jxxx: Add regulators for CS42L83 power supply

This commit adds five fixed-regulator nodes to the Apple T8103 template devicetree to serve as stand-in power supplies for the CS42L83 codec.

Quoted 30 lines
arch/arm64/boot/dts/apple/t8103-jxxx.dtsi +22 -0
index 686fb1dd215d2..7483fc5cbd204 100644
@@ -38,6 +38,38 @@ memory@800000000 {
 		device_type = "memory";
 		reg = <0x8 0 0x2 0>; /* To be filled by loader */
 	};
+
+	/*
+	 * The CS42L83 found on all T8103 boards requires VA, VCP, VCP_FILT,
+	 * VL, VD and VP regulators. We don't (officially) know how power
+	 * gets to the codec, so these fixed regulators are stand-ins.
+	 */
+	jack_va_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-va";
+	};
+
+	/* CS42L83 VCP and VCP_FILT */
+	jack_vcp_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-vcp";
+	};
+
+	jack_vl_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-vl";
+	};
+

arch/arm64/boot/dts/apple/t8103-jxxx.dtsi memory@800000000 { · line 72

Quoted 10 lines
arch/arm64/boot/dts/apple/t8103-jxxx.dtsi +10 -0
+	/* VD_FILT */
+	jack_vd_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-vd";
+	};
+
+	jack_vp_reg: regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "jack-vp";
+	};

[Severity: Medium]
Won't giving all five sibling nodes under / the identical node name "regulator" cause dtc to merge them into a single /regulator node?

When a T8103 board DTS includes t8103.dtsi (which defines /) followed by t8103-jxxx.dtsi (which re-opens /), dtc merges the two root nodes via merge_nodes() in scripts/dtc/livetree.c:

    for_each_child_withdel(old_node, old_child) {
        if (streq(old_child->name, new_child->name)) {
            merge_nodes(old_child, new_child);
            new_child = NULL;
            break;
        }
    }

    if (new_child)
        add_child(old_node, new_child);

The first child named "regulator" (jack_va_reg) is added to /, and the remaining four sibling nodes named "regulator" (jack_vcp_reg, jack_vl_reg, jack_vd_reg, and jack_vp_reg) match streq(old_child->name, new_child->name) and are merged into that single /regulator node. As a result, all five labels resolve to the same node and each definition overwrites regulator-name until only "jack-vp" remains.

Should each node be given a distinct name matching Documentation/devicetree/bindings/regulator/fixed-regulator.yaml, such as regulator-jack-va, regulator-jack-vcp, regulator-jack-vl, regulator-jack-vd, and regulator-jack-vp?

Quoted 3 lines
arch/arm64/boot/dts/apple/t8103-jxxx.dtsi +0 -0
 };
 
 &serial0 {
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
#17 lore raw

PATCH v3 10/21 arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes

In reply to James Calligeros

The M1 Mac mini integrates Apple-specific variants of the TI TAS2770 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 arch/arm64/boot/dts/apple/t8103-j274.dts | 72 +++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
arch/arm64/boot/dts/apple/t8103-j274.dts +72 -0
index 1212852251e0..150d778565f0 100644
@@ -75,4 +75,76 @@ &i2c2 {
 	status = "okay";
 };
 
+/* Audio codecs */
+&i2c1 {
+	status = "okay";
+
+	speaker: codec@31 {
+		compatible = "ti,tas5770l";
+		reg = <0x31>;
+		interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		ti,imon-slot-no = <0>;
+		ti,vmon-slot-no = <2>;
+	};
+};
+
+&i2c2 {
+	status = "okay";
+
+	jack_codec: codec@48 {
+		compatible = "cirrus,cs42l83";
+		reg = <0x48>;
+		interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+		cirrus,ts-inv = <1>;
+		VA-supply = <&jack_va_reg>;
+		VP-supply = <&jack_vp_reg>;
+		VCP-supply = <&jack_vcp_reg>;
+		VD_FILT-supply = <&jack_vd_reg>;
+		VL-supply = <&jack_vl_reg>;
+	};
+};
+
+/ {
+	sound: sound {
+		compatible = "apple,j274-macaudio";
+		model = "Mac mini J274";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		dai-link@0 {
+			reg = <0>;
+
+			link-name = "Speaker";
+
+			codec {
+				sound-dai = <&speaker>;
+			};
+
+			cpu {
+				sound-dai = <&mca 0>;
+			};
+		};
+
+		dai-link@1 {
+			reg = <1>;
+
+			link-name = "Headphone Jack";
+
+			codec {
+				sound-dai = <&jack_codec>;
+			};
+
+			cpu {
+				sound-dai = <&mca 2>;
+			};
+		};
+	};
+};
+
 #include "hwmon-mini.dtsi"
Signature · 1 line
2.56.0
#18 lore raw

Re: [PATCH v3 10/21] arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] arm64: dts: apple: duplicate regulator node names merge into single node - [Low] arm64: dts…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] arm64: dts: apple: duplicate regulator node names merge into single node
- [Low] arm64: dts: apple: t8103-j274: duplicate &i2c2 node reference
--

commit 2140e74bb313811cd8c26e108fe31118f7e0ab3f
Author: James Calligeros <[email protected]>

arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes

This commit adds Device Tree nodes for the TI TAS5770L speaker codec on i2c1, the Cirrus CS42L83 headset jack codec on i2c2, and the top-level sound node for the M1 Mac mini (J274).

Quoted 15 lines
arch/arm64/boot/dts/apple/t8103-j274.dts +7 -0
index 1212852251e07..150d778565f0c 100644
@@ -75,4 +75,76 @@ &i2c2 {
 	status = "okay";
 };
 
+/* Audio codecs */
+&i2c1 {
+	status = "okay";
+
+	speaker: codec@31 {
+		compatible = "ti,tas5770l";
+		reg = <0x31>;

arch/arm64/boot/dts/apple/t8103-j274.dts &i2c2 { · line 94

Quoted 10 lines
arch/arm64/boot/dts/apple/t8103-j274.dts +10 -0
+		interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		ti,imon-slot-no = <0>;
+		ti,vmon-slot-no = <2>;
+	};
+};
+
+&i2c2 {
+	status = "okay";

[Severity: Low]
Does this duplicate the existing &i2c2 block right above? Since arch/arm64/boot/dts/apple/t8103-j274.dts already has an &i2c2 block setting status = "okay", could jack_codec be placed inside that existing block (or the earlier stub removed) to avoid referencing &i2c2 twice in the same file?

Quoted 6 lines
arch/arm64/boot/dts/apple/t8103-j274.dts +6 -0
+
+	jack_codec: codec@48 {
+		compatible = "cirrus,cs42l83";
+		reg = <0x48>;
+		interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>;

arch/arm64/boot/dts/apple/t8103-j274.dts &i2c2 { · line 110

Quoted 10 lines
arch/arm64/boot/dts/apple/t8103-j274.dts +10 -0
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+		cirrus,ts-inv = <1>;
+		VA-supply = <&jack_va_reg>;
+		VP-supply = <&jack_vp_reg>;
+		VCP-supply = <&jack_vcp_reg>;
+		VD_FILT-supply = <&jack_vd_reg>;
+		VL-supply = <&jack_vl_reg>;
+	};
+};

[Severity: Medium]
Do all five regulator supplies in jack_codec end up resolving to a single merged /regulator node in the compiled DTB?

In arch/arm64/boot/dts/apple/t8103-jxxx.dtsi (included by t8103-j274.dts after t8103.dtsi), all five fixed regulators under the root node / use the identical node name regulator:

	jack_va_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-va";
	};

	/* CS42L83 VCP and VCP_FILT */
	jack_vcp_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-vcp";
	};

	jack_vl_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-vl";
	};

	/* VD_FILT */
	jack_vd_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-vd";
	};

	jack_vp_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-vp";
	};

When dtc merges the root node / from t8103-jxxx.dtsi into the existing root node from t8103.dtsi via merge_nodes() in scripts/dtc/livetree.c, the first regulator child (jack_va_reg) is added to old_node->children, and each of the remaining four regulator children matches that node name and merges into it before check_duplicate_node_names() runs.

As a result, four of the five regulators (jack-va, jack-vcp, jack-vl, jack-vd) are overwritten, leaving a single /regulator node with regulator-name = "jack-vp" and all five labels pointing to the same phandle. Should the regulator nodes in t8103-jxxx.dtsi be given distinct node names such as regulator-jack-va, regulator-jack-vcp, regulator-jack-vl, regulator-jack-vd, and regulator-jack-vp?

[ ... ]

Quoted 4 lines
Signature · 2 lines
-- 
2.51.2

base-commit: 74612d0b448fe745e80cda87fe49ac3c102ccc1f

Signature · 4 lines
2.51.2

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
#19 lore raw

PATCH v3 11/21 arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes

In reply to James Calligeros

The M1 MacBook Air integrates Apple-specific variants of the TI TAS2770 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 arch/arm64/boot/dts/apple/t8103-j313.dts | 87 +++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
arch/arm64/boot/dts/apple/t8103-j313.dts +87 -0
index f8b2b1637b9d..ed0eb358809b 100644
@@ -55,4 +55,91 @@ &typec1 {
 	label = "USB-C Left-front";
 };
 
+/* Audio codecs */
+&i2c1 {
+	status = "okay";
+
+	speaker_left: codec@31 {
+		compatible = "ti,tas5770l";
+		reg = <0x31>;
+		interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left";
+		ti,imon-slot-no = <0>;
+		ti,vmon-slot-no = <2>;
+	};
+};
+
+&i2c3 {
+	status = "okay";
+
+	speaker_right: codec@34 {
+		compatible = "ti,tas5770l";
+		reg = <0x34>;
+		interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right";
+		ti,imon-slot-no = <4>;
+		ti,vmon-slot-no = <6>;
+	};
+
+	jack_codec: codec@48 {
+		compatible = "cirrus,cs42l83";
+		reg = <0x48>;
+		interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+		cirrus,ts-inv = <1>;
+		VA-supply = <&jack_va_reg>;
+		VP-supply = <&jack_vp_reg>;
+		VCP-supply = <&jack_vcp_reg>;
+		VD_FILT-supply = <&jack_vd_reg>;
+		VL-supply = <&jack_vl_reg>;
+	};
+};
+
+/ {
+	sound: sound {
+		compatible = "apple,j313-macaudio";
+		model = "MacBook Air J313";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		dai-link@0 {
+			reg = <0>;
+
+			dai-tdm-idle-mode-0 = "zero";
+			dai-tdm-idle-mode-1 = "zero";
+
+			link-name = "Speakers";
+
+			codec {
+				sound-dai = <&speaker_left>, <&speaker_right>;
+			};
+
+			cpu {
+				sound-dai = <&mca 0>, <&mca 1>;
+			};
+		};
+
+		dai-link@1 {
+			reg = <1>;
+
+			link-name = "Headphone Jack";
+
+			codec {
+				sound-dai = <&jack_codec>;
+			};
+
+			cpu {
+				sound-dai = <&mca 2>;
+			};
+		};
+	};
+};
+
 #include "hwmon-laptop.dtsi"
Signature · 1 line
2.56.0
#20 lore raw

Re: [PATCH v3 11/21] arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] ASoC: apple: macaudio: macaudio_be_assign_tdm() skips idle_mode for 1-codec BE - [Medium] arm64…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] ASoC: apple: macaudio: macaudio_be_assign_tdm() skips idle_mode for 1-codec BE
- [Medium] arm64: dts: apple: t8103-j313: jack_codec supplies merge into one /regulator
- [Medium] ASoC: apple: macaudio: unreleased OF node refs in macaudio_parse_of() --

commit 802339e5380e3a87c88c58c583fe94106f5d49a8
Author: James Calligeros <[email protected]>

arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes

This commit adds the TI TAS5770L speaker amplifier nodes and Cirrus CS42L83 headset jack codec node to the M1 MacBook Air (J313) device tree and wires them to the macaudio machine driver via the sound node.

Quoted 5 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +0 -0
index f8b2b1637b9dc..ed0eb358809b4 100644
@@ -55,4 +55,91 @@ &typec1 {

[ ... ]

Quoted 5 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +5 -0
+	jack_codec: codec@48 {
+		compatible = "cirrus,cs42l83";
+		reg = <0x48>;
+		interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>;

arch/arm64/boot/dts/apple/t8103-j313.dts &typec1 { · line 102

Quoted 10 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +10 -0
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+		cirrus,ts-inv = <1>;
+		VA-supply = <&jack_va_reg>;
+		VP-supply = <&jack_vp_reg>;
+		VCP-supply = <&jack_vcp_reg>;
+		VD_FILT-supply = <&jack_vd_reg>;
+		VL-supply = <&jack_vl_reg>;
+	};
+};

[Severity: Medium]
Do these five supply phandles on jack_codec resolve to five distinct regulators in the compiled DTB?

In arch/arm64/boot/dts/apple/t8103-jxxx.dtsi (included by t8103-j313.dts), all five fixed regulators are defined as direct children of / with the identical node name regulator:

arch/arm64/boot/dts/apple/t8103-jxxx.dtsi:

	jack_va_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-va";
	};

	/* CS42L83 VCP and VCP_FILT */
	jack_vcp_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-vcp";
	};

	jack_vl_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-vl";
	};

	/* VD_FILT */
	jack_vd_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-vd";
	};

	jack_vp_reg: regulator {
		compatible = "regulator-fixed";
		regulator-name = "jack-vp";
	};

Because they share the same /regulator path, dtc merges all five definitions into a single node, overwriting regulator-name to "jack-vp" and attaching all five labels to that single node, so VA-supply, VP-supply, VCP-supply, VD_FILT-supply, and VL-supply all point to the same regulator instance.

Quoted 15 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +15 -0
+
+/ {
+	sound: sound {
+		compatible = "apple,j313-macaudio";
+		model = "MacBook Air J313";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		dai-link@0 {
+			reg = <0>;
+
+			dai-tdm-idle-mode-0 = "zero";
+			dai-tdm-idle-mode-1 = "zero";
+

arch/arm64/boot/dts/apple/t8103-j313.dts &typec1 { · line 127

Quoted 10 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +10 -0
+			link-name = "Speakers";
+
+			codec {
+				sound-dai = <&speaker_left>, <&speaker_right>;
+			};
+
+			cpu {
+				sound-dai = <&mca 0>, <&mca 1>;
+			};
+		};

[Severity: Medium]
Will dai-tdm-idle-mode-0 and dai-tdm-idle-mode-1 actually be applied to speaker_left and speaker_right here?

In dai-link@0, there are 2 codecs (<&speaker_left>, <&speaker_right>) and 2 CPU DAIs (<&mca 0>, <&mca 1>). When macaudio_snd_platform_probe() -> macaudio_parse_of() parses this node in sound/soc/apple/macaudio.c, ncodecs_per_cpu is num_codecs / num_bes = 2 / 2 = 1. Two backend DAI links are created with num_codecs = 1, and macaudio_get_codec_idle_props() stores dai-tdm-idle-mode-0 and dai-tdm-idle-mode-1 into each backend link's link_props->codecs[0].idle_mode.

However, when macaudio_be_init() -> macaudio_be_assign_tdm() runs, it takes the single-codec early return without configuring idle_mode:

sound/soc/apple/macaudio.c:macaudio_be_assign_tdm() {
	...
	if (rtd->dai_link->num_codecs == 1) {
		ret = snd_soc_dai_set_tdm_slot(snd_soc_rtd_to_codec(rtd, 0), mask,
					       0, nslots, MACAUDIO_SLOTWIDTH);

		/*
		 * Headphones get a pass on -ENOTSUPP (see the comment
		 * around bclk_ratio value for primary FE).
		 */
		if (ret == -ENOTSUPP && props->is_headphones)
			return 0;

		return ret;
	}
	...
}

Because macaudio_be_assign_tdm() returns before calling snd_soc_dai_set_tdm_idle(), tas2770_set_dai_tdm_idle() is never called for either speaker amplifier on J313, leaving the SDOUT TDM idle slots unconfigured while both codecs share the IV-sense capture TDM bus.

[Severity: Medium]
Also, can binding apple,j313-macaudio with this multi-BE dai-link@0 leak device_node references in macaudio_parse_of() when probing defers or fails, or on driver unbind?

First, in macaudio_parse_of_component(), of_parse_phandle_with_args() acquires a reference on args.np and assigns it to comp->of_node before calling snd_soc_get_dai_name():

sound/soc/apple/macaudio.c:macaudio_parse_of_component() {
	ret = of_parse_phandle_with_args(node, "sound-dai", "#sound-dai-cells",
						index, &args);
	if (ret)
		return ret;
	comp->of_node = args.np;
	return snd_soc_get_dai_name(&args, &comp->dai_name);
}

When speaker_left, speaker_right, jack_codec, or mca has not registered its ASoC component yet, snd_soc_get_dai_name() returns -EPROBE_DEFER while comp->of_node still holds the reference. In macaudio_parse_of(), the for (be_index = 0; be_index < num_bes; be_index++) loop populates card->dai_link[num_links + be_index], but num_links is only incremented by num_bes after the entire be_index loop finishes:

sound/soc/apple/macaudio.c:macaudio_parse_of() {
		for (be_index = 0; be_index < num_bes; be_index++) {
			...
			ret = macaudio_parse_of_be_dai_link(card, link, be_index,
							    ncodecs_per_cpu, cpu, codec);
			if (ret)
				goto err_free;
			...
			link_props->codecs = devm_kcalloc(dev, ncodecs_per_cpu,
							  sizeof(struct ma_codec_idle), GFP_KERNEL);
			if (!link_props->codecs)
				return -ENOMEM;
			...
		}
		...
		num_links += num_bes;
}

When macaudio_parse_of_be_dai_link() jumps to err_free, the cleanup loop only iterates up to num_links, missing the comp->of_node references acquired in card->dai_link[num_links .. num_links + be_index] during the failing iteration:

sound/soc/apple/macaudio.c:macaudio_parse_of() {
err_free:

	of_node_put(codec);
	of_node_put(cpu);
	of_node_put(np);

	if (!card->dai_link)
		return ret;

	for (i = 0; i < num_links; i++) {
		snd_soc_of_put_dai_link_codecs(&card->dai_link[i]);
		snd_soc_of_put_dai_link_cpus(&card->dai_link[i]);
	}
}

Second, if devm_kcalloc() for link_props->codecs fails inside for_each_available_child_of_node(dev->of_node, np), macaudio_parse_of() returns -ENOMEM directly instead of jumping to err_free, leaking np, cpu, codec, and all previously parsed DAI link component node references.

Finally, once macaudio_parse_of() succeeds, neither a failure in devm_snd_soc_register_card() in macaudio_snd_platform_probe() nor macaudio_snd_platform_remove() calls snd_soc_of_put_dai_link_codecs() and snd_soc_of_put_dai_link_cpus() on the backend DAI links.

[ ... ]

Quoted 2 lines
Signature · 1 line
2.43.0
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
#21 lore raw

PATCH v3 12/21 arm64: dts: apple: t8103-j293: Add speaker/headset jack nodes

In reply to James Calligeros

The M1 MacBook Pro integrates Apple-specific variants of the TI TAS2770 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 arch/arm64/boot/dts/apple/t8103-j293.dts | 116 +++++++++++++++++++++++++
 1 file changed, 116 insertions(+)
arch/arm64/boot/dts/apple/t8103-j293.dts +116 -0
index 1d074b9e6018..7d4907cefca9 100644
@@ -133,5 +133,121 @@ &displaydfr_dart {
 	status = "okay";
 };
 
+/* Audio codecs */
+&i2c1 {
+	status = "okay";
+
+	speaker_left_rear: codec@31 {
+		compatible = "ti,tas5770l";
+		reg = <0x31>;
+		interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left Rear";
+		ti,imon-slot-no = <8>;
+		ti,vmon-slot-no = <10>;
+	};
+
+	speaker_left_front: codec@32 {
+		compatible = "ti,tas5770l";
+		reg = <0x32>;
+		interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left Front";
+		ti,imon-slot-no = <0>;
+		ti,vmon-slot-no = <2>;
+	};
+};
+
+&i2c2 {
+	status = "okay";
+
+	jack_codec: codec@48 {
+		compatible = "cirrus,cs42l83";
+		reg = <0x48>;
+		interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+		cirrus,ts-inv = <1>;
+		VA-supply = <&jack_va_reg>;
+		VP-supply = <&jack_vp_reg>;
+		VCP-supply = <&jack_vcp_reg>;
+		VD_FILT-supply = <&jack_vd_reg>;
+		VL-supply = <&jack_vl_reg>;
+	};
+};
+
+&i2c3 {
+	status = "okay";
+
+	speaker_right_rear: codec@34 {
+		compatible = "ti,tas5770l";
+		reg = <0x34>;
+		interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right Rear";
+		ti,imon-slot-no = <12>;
+		ti,vmon-slot-no = <14>;
+	};
+
+	speaker_right_front: codec@35 {
+		compatible = "ti,tas5770l";
+		reg = <0x35>;
+		interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right Front";
+		ti,imon-slot-no = <4>;
+		ti,vmon-slot-no = <6>;
+	};
+};
+
+/ {
+	sound: sound {
+		compatible = "apple,j293-macaudio";
+		model = "MacBook Pro J293";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		dai-link@0 {
+			reg = <0>;
+
+			dai-tdm-idle-mode-0 = "pulldown";
+			dai-tdm-idle-mode-2 = "pulldown";
+
+			link-name = "Speakers";
+
+			codec {
+				sound-dai = <&speaker_left_front>,
+					    <&speaker_left_rear>,
+					    <&speaker_right_front>,
+					    <&speaker_right_rear>;
+			};
+
+			cpu {
+				sound-dai = <&mca 0>, <&mca 1>;
+			};
+		};
+
+		dai-link@1 {
+			reg = <1>;
+
+			link-name = "Headphone Jack";
+
+			codec {
+				sound-dai = <&jack_codec>;
+			};
+
+			cpu {
+				sound-dai = <&mca 2>;
+			};
+		};
+	};
+};
+
 #include "hwmon-laptop.dtsi"
 #include "hwmon-fan.dtsi"
Signature · 1 line
2.56.0
#22 lore raw

PATCH v3 13/21 arm64: dts: apple: t8103-j45x: Add headset jack nodes

In reply to James Calligeros

The M1 iMacs integrate Apple-specific variants of the TI TAS2770 and Cirrus CS42L42. Since it is not yet safe to expose the speakers on these machines, add the headset jack nodes and advertise them to the machine driver via the sound node.

---
 arch/arm64/boot/dts/apple/t8103-j456.dts | 43 +++++++++++++++++++++++++
 arch/arm64/boot/dts/apple/t8103-j457.dts | 43 +++++++++++++++++++++++++
 2 files changed, 86 insertions(+)
arch/arm64/boot/dts/apple/t8103-j456.dts +43 -0
index 090c97bb781b..91da90b37089 100644
@@ -88,3 +88,46 @@ &pcie0_dart_1 {
 &pcie0_dart_2 {
 	status = "okay";
 };
+
+&i2c1 {
+	status = "okay";
+
+	jack_codec: codec@48 {
+		compatible = "cirrus,cs42l83";
+		reg = <0x48>;
+		interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+		cirrus,ts-inv = <1>;
+		VA-supply = <&jack_va_reg>;
+		VP-supply = <&jack_vp_reg>;
+		VCP-supply = <&jack_vcp_reg>;
+		VD_FILT-supply = <&jack_vd_reg>;
+		VL-supply = <&jack_vl_reg>;
+	};
+};
+
+/ {
+	sound: sound {
+		compatible = "apple,j456-macaudio";
+		model = "iMac J456";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		dai-link@1 {
+			reg = <1>;
+
+			link-name = "Headphone Jack";
+
+			codec {
+				sound-dai = <&jack_codec>;
+			};
+
+			cpu {
+				sound-dai = <&mca 2>;
+			};
+		};
+	};
+};
arch/arm64/boot/dts/apple/t8103-j457.dts +43 -0

46 lines not on this page · raw message

Signature · 1 line
2.56.0
#23 lore raw

PATCH v3 14/21 arm64: dts: apple: t8112-j413: Add speaker/headset jack nodes

In reply to James Calligeros

The M2 MacBook Air integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 arch/arm64/boot/dts/apple/t8112-j413.dts | 108 +++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
arch/arm64/boot/dts/apple/t8112-j413.dts +108 -0
index 7ccfceb08093..5f8768832e1e 100644
@@ -92,4 +92,112 @@ &fpwm1 {
 	status = "okay";
 };
 
+/* Audio codecs */
+&i2c1 {
+	status = "okay";
+
+	speaker_left_woof: codec@38 {
+		compatible = "ti,sn012776";
+		reg = <0x38>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left Woofer";
+		ti,imon-slot-no = <0>;
+		ti,vmon-slot-no = <2>;
+	};
+
+	speaker_left_tweet: codec@39 {
+		compatible = "ti,sn012776";
+		reg = <0x39>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left Tweeter";
+		ti,imon-slot-no = <8>;
+		ti,vmon-slot-no = <10>;
+	};
+};
+
+&i2c3 {
+	status = "okay";
+
+	speaker_right_woof: codec@3b {
+		compatible = "ti,sn012776";
+		reg = <0x3b>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right Woofer";
+		ti,imon-slot-no = <4>;
+		ti,vmon-slot-no = <6>;
+	};
+
+	speaker_right_tweet: codec@3c {
+		compatible = "ti,sn012776";
+		reg = <0x3c>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right Tweeter";
+		ti,imon-slot-no = <12>;
+		ti,vmon-slot-no = <14>;
+	};
+
+	jack_codec: codec@4b {
+		compatible = "cirrus,cs42l84";
+		reg = <0x4b>;
+		interrupts-extended = <&pinctrl_ap 149 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 12 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+	};
+};
+
+/ {
+	sound: sound {
+		compatible = "apple,j413-macaudio";
+		model = "MacBook Air J413";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		dai-link@0 {
+			reg = <0>;
+
+			dai-tdm-idle-mode-0 = "zero";
+			dai-tdm-idle-mode-2 = "zero";
+			dai-tdm-slot-tx-idle-mask-0 = <0xf0f0>;
+			dai-tdm-slot-tx-idle-mask-2 = <0x0f0f>;
+
+			link-name = "Speakers";
+
+			codec {
+				sound-dai = <&speaker_left_woof>,
+					    <&speaker_left_tweet>,
+					    <&speaker_right_woof>,
+					    <&speaker_right_tweet>;
+			};
+
+			cpu {
+				sound-dai = <&mca 0>, <&mca 1>;
+			};
+		};
+
+		dai-link@1 {
+			reg = <1>;
+
+			link-name = "Headphone Jack";
+
+			codec {
+				sound-dai = <&jack_codec>;
+			};
+
+			cpu {
+				sound-dai = <&mca 2>;
+			};
+		};
+	};
+};
+
 #include "hwmon-laptop.dtsi"
Signature · 1 line
2.56.0
#24 lore raw

PATCH v3 15/21 arm64: dts: apple: t8112-j415: Add speaker/headset jack nodes

In reply to James Calligeros

The M2 MacBook Air integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 arch/arm64/boot/dts/apple/t8112-j415.dts | 132 +++++++++++++++++++++++++
 1 file changed, 132 insertions(+)
arch/arm64/boot/dts/apple/t8112-j415.dts +132 -0
index fdc3409d2e07..099b9837b633 100644
@@ -92,4 +92,136 @@ &fpwm1 {
 	status = "okay";
 };
 
+/* Audio codecs */
+&i2c1 {
+	status = "okay";
+
+	speaker_left_woof1: codec@38 {
+		compatible = "ti,sn012776";
+		reg = <0x38>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left Woofer 1";
+		ti,imon-slot-no = <0>;
+		ti,vmon-slot-no = <2>;
+	};
+
+	speaker_left_tweet: codec@39 {
+		compatible = "ti,sn012776";
+		reg = <0x39>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left Tweeter";
+		ti,imon-slot-no = <8>;
+		ti,vmon-slot-no = <10>;
+	};
+
+	speaker_left_woof2: codec@3a {
+		compatible = "ti,sn012776";
+		reg = <0x3a>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left Woofer 2";
+		ti,imon-slot-no = <16>;
+		ti,vmon-slot-no = <18>;
+	};
+};
+
+&i2c3 {
+	status = "okay";
+
+	speaker_right_woof1: codec@3b {
+		compatible = "ti,sn012776";
+		reg = <0x3b>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right Woofer 1";
+		ti,imon-slot-no = <4>;
+		ti,vmon-slot-no = <6>;
+	};
+
+	speaker_right_tweet: codec@3c {
+		compatible = "ti,sn012776";
+		reg = <0x3c>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right Tweeter";
+		ti,imon-slot-no = <12>;
+		ti,vmon-slot-no = <14>;
+	};
+
+	speaker_right_woof2: codec@3d {
+		compatible = "ti,sn012776";
+		reg = <0x3d>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right Woofer 2";
+		ti,imon-slot-no = <20>;
+		ti,vmon-slot-no = <22>;
+	};
+
+	jack_codec: codec@4b {
+		compatible = "cirrus,cs42l84";
+		reg = <0x4b>;
+		interrupts-extended = <&pinctrl_ap 149 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 12 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+	};
+};
+
+/ {
+	sound: sound {
+		compatible = "apple,j415-macaudio";
+		model = "MacBook Air J415";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		dai-link@0 {
+			reg = <0>;
+
+			dai-tdm-idle-mode-0 = "zero";
+			dai-tdm-idle-mode-3 = "zero";
+			dai-tdm-slot-tx-idle-mask-0 = <0xf0f0f0>;
+			dai-tdm-slot-tx-idle-mask-3 = <0x0f0f0f>;
+
+			link-name = "Speakers";
+
+			codec {
+				sound-dai = <&speaker_left_woof1>,
+					    <&speaker_left_tweet>,
+					    <&speaker_left_woof2>,
+					    <&speaker_right_woof1>,
+					    <&speaker_right_tweet>,
+					    <&speaker_right_woof2>;
+			};
+
+			cpu {
+				sound-dai = <&mca 0>, <&mca 1>;
+			};
+		};
+
+		dai-link@1 {
+			reg = <1>;
+
+			link-name = "Headphone Jack";
+
+			codec {
+				sound-dai = <&jack_codec>;
+			};
+
+			cpu {
+				sound-dai = <&mca 2>;
+			};
+		};
+	};
+};
+
 #include "hwmon-laptop.dtsi"
Signature · 1 line
2.56.0
#25 lore raw

PATCH v3 16/21 arm64: dts: apple: t8112-j473: Add speaker/headset jack nodes

In reply to James Calligeros

The M2 Mac mini integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 arch/arm64/boot/dts/apple/t8112-j473.dts | 62 +++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
arch/arm64/boot/dts/apple/t8112-j473.dts +62 -0
index 105a9d118980..36f06c6e385d 100644
@@ -85,4 +85,66 @@ &typec1 {
 	label = "USB-C Back-right";
 };
 
+/* Audio codecs */
+&i2c1 {
+	status = "okay";
+
+	speaker: codec@38 {
+		compatible = "ti,sn012776";
+		reg = <0x38>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		ti,imon-slot-no = <0>;
+		ti,vmon-slot-no = <2>;
+	};
+
+	jack_codec: codec@4b {
+		compatible = "cirrus,cs42l84";
+		reg = <0x4b>;
+		interrupts-extended = <&pinctrl_ap 149 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 12 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+	};
+};
+
+/ {
+	sound: sound {
+		compatible = "apple,j473-macaudio";
+		model = "Mac mini J473";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		dai-link@0 {
+			reg = <0>;
+
+			link-name = "Speakers";
+
+			codec {
+				sound-dai = <&speaker>;
+			};
+
+			cpu {
+				sound-dai = <&mca 0>;
+			};
+		};
+
+		dai-link@1 {
+			reg = <1>;
+
+			link-name = "Headphone Jack";
+
+			codec {
+				sound-dai = <&jack_codec>;
+			};
+
+			cpu {
+				sound-dai = <&mca 2>;
+			};
+		};
+	};
+};
+
 #include "hwmon-mini.dtsi"
Signature · 1 line
2.56.0
#26 lore raw

PATCH v3 17/21 arm64: dts: apple: t8112-j493: Add speaker/headset jack nodes

In reply to James Calligeros

The M2 MacBook Pro integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 arch/arm64/boot/dts/apple/t8112-j493.dts | 108 +++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
arch/arm64/boot/dts/apple/t8112-j493.dts +108 -0
index 7cea5c594810..8993775da9ab 100644
@@ -147,5 +147,113 @@ touchbar0: touchbar@0 {
 	};
 };
 
+/* Audio codecs */
+&i2c1 {
+	status = "okay";
+
+	speaker_left_rear: codec@38 {
+		compatible = "ti,sn012776";
+		reg = <0x38>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left Rear";
+		ti,imon-slot-no = <8>;
+		ti,vmon-slot-no = <10>;
+	};
+
+	speaker_left_front: codec@39 {
+		compatible = "ti,sn012776";
+		reg = <0x39>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Left Front";
+		ti,imon-slot-no = <0>;
+		ti,vmon-slot-no = <2>;
+	};
+};
+
+&i2c3 {
+	status = "okay";
+
+	speaker_right_rear: codec@3b {
+		compatible = "ti,sn012776";
+		reg = <0x3b>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right Rear";
+		ti,imon-slot-no = <12>;
+		ti,vmon-slot-no = <14>;
+	};
+
+	speaker_right_front: codec@3c {
+		compatible = "ti,sn012776";
+		reg = <0x3c>;
+		interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>;
+		shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Right Front";
+		ti,imon-slot-no = <4>;
+		ti,vmon-slot-no = <6>;
+	};
+
+	jack_codec: codec@4b {
+		compatible = "cirrus,cs42l84";
+		reg = <0x4b>;
+		interrupts-extended = <&pinctrl_ap 149 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pinctrl_nub 12 GPIO_ACTIVE_HIGH>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "Jack";
+	};
+};
+
+/ {
+	sound: sound {
+		compatible = "apple,j493-macaudio", "apple,j293-macaudio";
+		model = "MacBook Pro J493";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		dai-link@0 {
+			reg = <0>;
+
+			dai-tdm-idle-mode-0 = "zero";
+			dai-tdm-idle-mode-2 = "zero";
+			dai-tdm-slot-tx-idle-mask-0 = <0xf0f0>;
+			dai-tdm-slot-tx-idle-mask-2 = <0x0f0f>;
+
+			link-name = "Speakers";
+
+			codec {
+				sound-dai = <&speaker_left_front>,
+					    <&speaker_left_rear>,
+					    <&speaker_right_front>,
+					    <&speaker_right_rear>;
+			};
+
+			cpu {
+				sound-dai = <&mca 0>, <&mca 1>;
+			};
+		};
+
+		dai-link@1 {
+			reg = <1>;
+
+			link-name = "Headphone Jack";
+
+			codec {
+				sound-dai = <&jack_codec>;
+			};
+
+			cpu {
+				sound-dai = <&mca 2>;
+			};
+		};
+	};
+};
+
 #include "hwmon-laptop.dtsi"
 #include "hwmon-fan.dtsi"
Signature · 1 line
2.56.0
#27 lore raw

PATCH v3 18/21 arm64: dts: apple: t600x-j31x: Add speaker/headset jack nodes

In reply to James Calligeros

The M1 Pro/Max MacBooks integrate Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 .../arm64/boot/dts/apple/t6000-j314s.dts |   5 +
 .../arm64/boot/dts/apple/t6000-j316s.dts |   5 +
 .../arm64/boot/dts/apple/t6001-j314c.dts |   5 +
 .../arm64/boot/dts/apple/t6001-j316c.dts |   5 +
 .../boot/dts/apple/t600x-j314-j316.dtsi  | 135 +++++++++++++++++++++++++
 5 files changed, 155 insertions(+)
arch/arm64/boot/dts/apple/t6000-j314s.dts +5 -0
index 1430b91ff1b1..63ae47ea46e6 100644
@@ -24,3 +24,8 @@ &wifi0 {
 &bluetooth0 {
 	brcm,board-type = "apple,maldives";
 };
+
+&sound {
+	compatible = "apple,j314-macaudio";
+	model = "MacBook Pro J314";
+};
arch/arm64/boot/dts/apple/t6000-j316s.dts +5 -0
index da0cbe7d9673..c8428fbf9244 100644
@@ -24,3 +24,8 @@ &wifi0 {
 &bluetooth0 {
 	brcm,board-type = "apple,madagascar";
 };
+
+&sound {
+	compatible = "apple,j316-macaudio";
+	model = "MacBook Pro J316";
+};
arch/arm64/boot/dts/apple/t6001-j314c.dts +5 -0
index c37097dcfdb3..05066cbde96b 100644
@@ -24,3 +24,8 @@ &wifi0 {
 &bluetooth0 {
 	brcm,board-type = "apple,maldives";
 };
+
+&sound {
+	compatible = "apple,j314-macaudio";
+	model = "MacBook Pro J314";
+};
arch/arm64/boot/dts/apple/t6001-j316c.dts +5 -0
index 3bc6e0c3294c..ee0339b61713 100644
@@ -24,3 +24,8 @@ &wifi0 {
 &bluetooth0 {
 	brcm,board-type = "apple,madagascar";
 };
+
+&sound {
+	compatible = "apple,j316-macaudio";
+	model = "MacBook Pro J316";
+};
arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi +135 -0

147 lines not on this page · raw message

Signature · 1 line
2.56.0
#28 lore raw

PATCH v3 19/21 arm64: dts: apple: t600x-j375: Add speaker/headset jack nodes

In reply to James Calligeros

The M1 Max/Ultra Mac Studio integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 .../arm64/boot/dts/apple/t6001-j375c.dts |  5 ++
 .../arm64/boot/dts/apple/t6002-j375d.dts |  5 ++
 .../arm64/boot/dts/apple/t600x-j375.dtsi | 65 +++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
arch/arm64/boot/dts/apple/t6001-j375c.dts +5 -0
index 08276114c1d8..2e544f43b085 100644
@@ -25,4 +25,9 @@ &bluetooth0 {
 	brcm,board-type = "apple,okinawa";
 };
 
+&sound {
+	compatible = "apple,j375-macaudio";
+	model = "Mac Studio J375";
+};
+
 #include "hwmon-fan-dual.dtsi"
arch/arm64/boot/dts/apple/t6002-j375d.dts +5 -0
index e6eb6b6c386d..dfdf90fb1825 100644
@@ -184,6 +184,11 @@ atcphy5_usb3: endpoint {
 	};
 };
 
+&sound {
+	compatible = "apple,j375-macaudio";
+	model = "Mac Studio J375";
+};
+
 #include "hwmon-fan-dual.dtsi"
 
 /* delete unused USB nodes on die 1 */
arch/arm64/boot/dts/apple/t600x-j375.dtsi +65 -0

75 lines not on this page · raw message

Signature · 1 line
2.56.0
#29 lore raw

PATCH v3 20/21 arm64: dts: apple: t602x-j41x: Add speaker/headset jack nodes

In reply to James Calligeros

The M2 Pro/Max MacBooks integrate Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 .../arm64/boot/dts/apple/t6020-j414s.dts |  5 ++++
 .../arm64/boot/dts/apple/t6020-j416s.dts |  5 ++++
 .../arm64/boot/dts/apple/t6021-j414c.dts |  5 ++++
 .../arm64/boot/dts/apple/t6021-j416c.dts |  5 ++++
 .../boot/dts/apple/t602x-j414-j416.dtsi  | 35 +++++++++++++++++++++++++
 5 files changed, 55 insertions(+)
arch/arm64/boot/dts/apple/t6020-j414s.dts +5 -0
index 631c54c5f03d..2df6a39c719d 100644
@@ -24,3 +24,8 @@ &wifi0 {
 &bluetooth0 {
 	brcm,board-type = "apple,tokara";
 };
+
+&sound {
+	compatible = "apple,j414-macaudio", "apple,j314-macaudio";
+	model = "MacBook Pro J414";
+};
arch/arm64/boot/dts/apple/t6020-j416s.dts +5 -0
index c277ed5889a2..7f3f0d6eee87 100644
@@ -24,3 +24,8 @@ &wifi0 {
 &bluetooth0 {
 	brcm,board-type = "apple,amami";
 };
+
+&sound {
+	compatible = "apple,j416-macaudio", "apple,j316-macaudio";
+	model = "MacBook Pro J416";
+};
arch/arm64/boot/dts/apple/t6021-j414c.dts +5 -0
index cdcf0740714d..ec4050ec0ecf 100644
@@ -24,3 +24,8 @@ &wifi0 {
 &bluetooth0 {
 	brcm,board-type = "apple,tokara";
 };
+
+&sound {
+	compatible = "apple,j414-macaudio", "apple,j314-macaudio";
+	model = "MacBook Pro J414";
+};
arch/arm64/boot/dts/apple/t6021-j416c.dts +5 -0
index 6d8146b94170..0037346959a5 100644
@@ -24,3 +24,8 @@ &wifi0 {
 &bluetooth0 {
 	brcm,board-type = "apple,amami";
 };
+
+&sound {
+	compatible = "apple,j416-macaudio", "apple,j316-macaudio";
+	model = "MacBook Pro J416";
+};
arch/arm64/boot/dts/apple/t602x-j414-j416.dtsi +35 -0
index 0e806d8ddf81..852fbcd6277a 100644
@@ -43,3 +43,38 @@ &wifi0 {
 &bluetooth0 {
 	compatible = "pci14e4,5f72";
 };
+
+&speaker_left_tweet {
+	interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>;
+	shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>;
+};
+
+&speaker_left_woof1 {
+	interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>;
+	shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>;
+};
+
+&speaker_left_woof2 {
+	interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>;
+	shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>;
+};
+
+&speaker_right_tweet {
+	interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>;
+	shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>;
+};
+
+&speaker_right_woof1 {
+	interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>;
+	shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>;
+};
+
+&speaker_right_woof2 {
+	interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>;
+	shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>;
+};
+
+&jack_codec {
+	interrupts-extended = <&pinctrl_ap 59 IRQ_TYPE_LEVEL_LOW>;
+	reset-gpios = <&pinctrl_nub 8 GPIO_ACTIVE_HIGH>;
+};
Signature · 1 line
2.56.0
#30 lore raw

PATCH v3 21/21 arm64: dts: apple: t602x-j47x: Add speaker/headset jack nodes

In reply to James Calligeros

The M2 Pro/Max/Ultra Mac mini and Mac Studio integrate Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.

---
 .../arm64/boot/dts/apple/t6020-j474s.dts |  5 +++++
 .../arm64/boot/dts/apple/t6021-j475c.dts |  5 +++++
 .../arm64/boot/dts/apple/t6022-j475d.dts |  5 +++++
 .../boot/dts/apple/t602x-j474-j475.dtsi  | 10 ++++++++++
 4 files changed, 25 insertions(+)
arch/arm64/boot/dts/apple/t6020-j474s.dts +5 -0
index e3c2635d84fa..f39697490365 100644
@@ -46,4 +46,9 @@ &pcie0 {
 			<0x300 &pcie0_dart_3 1 1>;
 };
 
+&sound {
+	compatible = "apple,j474-macaudio", "apple,j473-macaudio";
+	model = "Mac mini J474";
+};
+
 #include "hwmon-mini.dtsi"
arch/arm64/boot/dts/apple/t6021-j475c.dts +5 -0
index 9fe17f1f7f59..f8f776f9eb1e 100644
@@ -36,4 +36,9 @@ &pcie0_dart_1 {
 	status = "okay";
 };
 
+&sound {
+	compatible = "apple,j475-macaudio", "apple,j375-macaudio";
+	model = "Mac Studio J475";
+};
+
 #include "hwmon-fan-dual.dtsi"
arch/arm64/boot/dts/apple/t6022-j475d.dts +5 -0
index 32938a3bf96a..153899f1569b 100644
@@ -73,3 +73,8 @@ &bluetooth0 {
 	compatible = "pci14e4,5f72";
 	brcm,board-type = "apple,canary";
 };
+
+&sound {
+	compatible = "apple,j475-macaudio", "apple,j375-macaudio";
+	model = "Mac Studio J475";
+};
arch/arm64/boot/dts/apple/t602x-j474-j475.dtsi +10 -0
index 926bb4ab77af..7f1faefcf9bb 100644
@@ -36,3 +36,13 @@ &hpm2 {
 &hpm3 {
 	interrupts = <44 IRQ_TYPE_LEVEL_LOW>;
 };
+
+&speaker {
+	interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>;
+	shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>;
+};
+
+&jack_codec {
+	interrupts-extended = <&pinctrl_ap 59 IRQ_TYPE_LEVEL_LOW>;
+	reset-gpios = <&pinctrl_nub 8 GPIO_ACTIVE_HIGH>;
+};
Signature · 1 line
2.56.0