Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ properties:
- apple,j473-macaudio
- apple,j493-macaudio
- apple,j575c-macaudio
- apple,j775c-macaudio
- apple,j775d-macaudio
- apple,j575c-macaudio-jack
- apple,j604-macaudio
Expand Down
70 changes: 6 additions & 64 deletions arch/arm64/boot/dts/apple/t6050-j775d.dts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/dts-v1/;

#include "t6050-ultra.dtsi"
#include "t6050-studio-audio.dtsi"

/ {
compatible = "apple,j775d", "apple,t6050", "apple,arm-platform";
Expand Down Expand Up @@ -48,42 +49,6 @@
ranges;
};

/*
* The jack (CS42L84) and the speaker (SN012776) through the AOP's audio services. The card waits
* for its CPU component, the AOP audio node, which exists only after Aura's AOP handoff.
*/
sound {
compatible = "apple,j775d-macaudio", "apple,macaudio";
model = "Mac Studio J775D";
#address-cells = <1>;
#size-cells = <0>;

dai-link@0 {
reg = <0>;
link-name = "Headphone Jack";

cpu {
sound-dai = <&aop_audio 0>;
};

codec {
sound-dai = <&jack_codec>;
};
};

dai-link@1 {
reg = <1>;
link-name = "Speaker";

cpu {
sound-dai = <&aop_audio 3>;
};

codec {
sound-dai = <&speaker_amp>;
};
};
};
};

/*
Expand All @@ -93,6 +58,11 @@
* Port 0 carries the N1 (Wi-Fi and Bluetooth), described disabled until the boot loader trains
* it (pci@0,0 below).
*/
&sound {
compatible = "apple,j775d-macaudio", "apple,macaudio";
model = "Mac Studio J775D";
};

&pcie0 {
reg = <0x1c 0xb0000000 0x0 0x10000000>,
<0x4 0x14000000 0x0 0x4000>,
Expand Down Expand Up @@ -239,34 +209,6 @@
gpio-reserved-ranges = <0 80>, <81 25>, <108 26>, <135 4>, <140 81>;
};

&i2c1 {
/*
* ADT speaker-config: playback slot 0, amp gain 20, V sense in slot 0 and I sense
* in slot 2. The firmware's speaker frame is 250 BCLKs of 12 MHz (ADT
* iop-audio-controller/audio-speaker), which the amp's ratio detection rejects.
*/
speaker_amp: codec@38 {
compatible = "ti,sn012776", "ti,tas2764";
reg = <0x38>;
shutdown-gpios = <&pinctrl_ap 107 GPIO_ACTIVE_HIGH>;
interrupts-extended = <&pinctrl_ap 106 IRQ_TYPE_LEVEL_LOW>;
#sound-dai-cells = <0>;
ti,imon-slot-no = <2>;
ti,vmon-slot-no = <0>;
};
};

&i2c2 {
jack_codec: codec@4b {
compatible = "cirrus,cs42l84";
reg = <0x4b>;
reset-gpios = <&pinctrl_ap 139 GPIO_ACTIVE_HIGH>;
interrupts-extended = <&pinctrl_ap 134 IRQ_TYPE_LEVEL_LOW>;
#sound-dai-cells = <0>;
sound-name-prefix = "Jack";
};
};

/*
* The console is on the USB debug link, which drains only while a host reads
* it; the machine also boots with nothing attached there.
Expand Down
80 changes: 80 additions & 0 deletions arch/arm64/boot/dts/apple/t6050-studio-audio.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: GPL-2.0+ OR MIT
/*
* The audio of the M5 Mac Studio (J775c, J775d): the headphone jack (a
* CS42L84) and the built-in speaker (one SN012776), both reached through the
* AOP's audio services. The card waits for its CPU component, the AOP audio
* node, which exists only after the boot loader's AOP handoff.
*
* The speaker has no protection model: no voltage or current sense from it
* has been seen to reach the AP on these machines, so nothing could govern it.
* macaudio keeps it at or below the -20 dB safe level in every state instead
* (spk_fixed_ceiling), and no protection daemon takes it.
*
* The board sets the card's compatible and model.
*
* Copyright The Asahi Linux Contributors
*/

/ {
sound: sound {
#address-cells = <1>;
#size-cells = <0>;

dai-link@0 {
reg = <0>;
link-name = "Headphone Jack";

cpu {
sound-dai = <&aop_audio 0>;
};

codec {
sound-dai = <&jack_codec>;
};
};

dai-link@1 {
reg = <1>;
link-name = "Speaker";

cpu {
sound-dai = <&aop_audio 3>;
};

codec {
sound-dai = <&speaker_amp>;
};
};
};
};

/* Amp IRQ 106 and shutdown 107; jack IRQ 134 and codec reset 139 (pinctrl_ap) */
&i2c1 {
/*
* ADT speaker-config: playback slot 0, V sense in slot 0 and I sense in
* slot 2. The firmware's speaker frame is 250 BCLKs of 12 MHz (ADT
* iop-audio-controller/audio-speaker), which the amp's ratio detection
* rejects, so the amp is told the ratio.
*/
speaker_amp: codec@38 {
compatible = "ti,sn012776", "ti,tas2764";
reg = <0x38>;
shutdown-gpios = <&pinctrl_ap 107 GPIO_ACTIVE_HIGH>;
interrupts-extended = <&pinctrl_ap 106 IRQ_TYPE_LEVEL_LOW>;
#sound-dai-cells = <0>;
ti,imon-slot-no = <2>;
ti,vmon-slot-no = <0>;
ti,bclk-ratio = <250>;
};
};

&i2c2 {
jack_codec: codec@4b {
compatible = "cirrus,cs42l84";
reg = <0x4b>;
reset-gpios = <&pinctrl_ap 139 GPIO_ACTIVE_HIGH>;
interrupts-extended = <&pinctrl_ap 134 IRQ_TYPE_LEVEL_LOW>;
#sound-dai-cells = <0>;
sound-name-prefix = "Jack";
};
};
2 changes: 2 additions & 0 deletions sound/soc/apple/macaudio-admission-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ static void macaudio_admission_needs_a_safe_level(struct kunit *test)
KUNIT_EXPECT_TRUE(test, macaudio_speakers_allowed(&macaudio_j714_cfg));
KUNIT_EXPECT_TRUE(test, macaudio_speakers_allowed(&macaudio_j813_cfg));
KUNIT_EXPECT_FALSE(test, macaudio_speakers_allowed(&macaudio_j873_cfg));
/* The Mac Studio M5: no sense, admitted only under its fixed ceiling */
KUNIT_EXPECT_TRUE(test, macaudio_speakers_allowed(&macaudio_j775_cfg));
cfg = macaudio_j413_cfg;
cfg.safe_vol = 0;
KUNIT_EXPECT_FALSE(test, macaudio_speakers_allowed(&cfg));
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/apple/macaudio-amp-level-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static void macaudio_level_no_table(struct kunit *test)
&macaudio_j493_cfg, &macaudio_j575c_j773_cfg, &macaudio_j604_cfg,
&macaudio_j614_cfg, &macaudio_j616_cfg, &macaudio_j713_cfg,
&macaudio_j714_cfg, &macaudio_j715_cfg, &macaudio_j813_cfg,
&macaudio_j873_cfg,
&macaudio_j775_cfg, &macaudio_j873_cfg,
};
unsigned int i;

Expand Down
30 changes: 23 additions & 7 deletions sound/soc/apple/macaudio-protection-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -1029,18 +1029,14 @@ static void macaudio_spk_j700_does_not_ramp(struct kunit *test)
}

/* A fixed ceiling: the grant runs the amps at it, the ramp starts below it */
static void macaudio_spk_fixed_ceiling(struct kunit *test)
static void macaudio_test_fixed_ceiling(struct kunit *test,
const struct macaudio_platform_cfg *cfg)
{
struct macaudio_platform_cfg *cfg = kunit_kzalloc(test, sizeof(*cfg), GFP_KERNEL);
const long ceiling = SN012776_DB(-15);
const long ceiling = SN012776_DB(cfg->safe_vol);
struct macaudio_test_vol *vol;
struct macaudio_test_spk t;
unsigned int i;

KUNIT_ASSERT_NOT_NULL(test, cfg);
*cfg = macaudio_j316_cfg;
cfg->safe_vol = -15;
cfg->spk_fixed_ceiling = true;
macaudio_test_spk_card(test, &t, cfg, SN012776_0DB);

/* The limit the lease leaves on the volumes (macaudio_spk_enter_lease()) */
Expand All @@ -1066,6 +1062,25 @@ static void macaudio_spk_fixed_ceiling(struct kunit *test)
macaudio_test_expect_vols(test, &t, 0);
}

static void macaudio_spk_fixed_ceiling(struct kunit *test)
{
struct macaudio_platform_cfg *cfg = kunit_kzalloc(test, sizeof(*cfg), GFP_KERNEL);

KUNIT_ASSERT_NOT_NULL(test, cfg);
*cfg = macaudio_j316_cfg;
cfg->safe_vol = -15;
cfg->spk_fixed_ceiling = true;
macaudio_test_fixed_ceiling(test, cfg);
}

/* The Mac Studio M5 speaker, with no sense, never goes above -20 dB */
static void macaudio_j775_fixed_ceiling(struct kunit *test)
{
KUNIT_EXPECT_TRUE(test, macaudio_j775_cfg.spk_fixed_ceiling);
KUNIT_EXPECT_EQ(test, macaudio_j775_cfg.safe_vol, -20);
macaudio_test_fixed_ceiling(test, &macaudio_j775_cfg);
}

struct macaudio_test_unlock {
struct snd_kcontrol *spk;
struct completion done;
Expand Down Expand Up @@ -1355,6 +1370,7 @@ static struct kunit_case macaudio_protection_cases[] = {
KUNIT_CASE(macaudio_spk_hard_withdrawals_do_not_ramp),
KUNIT_CASE(macaudio_spk_j700_does_not_ramp),
KUNIT_CASE(macaudio_spk_fixed_ceiling),
KUNIT_CASE(macaudio_j775_fixed_ceiling),
KUNIT_CASE(macaudio_spk_floor_waits_for_the_resume),
KUNIT_CASE(macaudio_spk_grant_needs_d0),
{}
Expand Down
34 changes: 34 additions & 0 deletions sound/soc/apple/macaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -4073,6 +4073,36 @@ struct macaudio_platform_cfg macaudio_j873_cfg = {
.spk_secondary_only = true,
};

/*
* J775c and J775d (T6050, Mac Studio M5 Max and M5 Ultra): as on J714s, the
* AOP firmware owns the audio fabric and the CPU component is the AOP audio
* driver. The jack is a CS42L84 on "cout", the speaker one SN012776 on
* "spkr" in a frame of 250 BCLKs of 12 MHz.
*
* The amp's description in the ADT is the J575c's (M4 Max Mac Studio), but
* on these machines the speaker is fed through the AOP, and no voltage or
* current sense from it has been seen to reach the AP. With no sense there
* is no protection model to run, so the speaker has a fixed ceiling
* instead: its volume stays at or below the -20 dB safe level in every
* state (locked, unlocked or granted), the level every SN012776 Mac sits at
* before a protection daemon takes it, and there is no sense PCM for a
* daemon to take. If the sense turns out to reach the AP through the AOP,
* the J575 protection model can replace the ceiling.
*/
struct macaudio_platform_cfg macaudio_j775_cfg = {
.enable_speakers = true,
.amp = AMP_SN012776,
.speakers = SPKR_1W,
.stereo = false,
.safe_vol = -20,
.spk_fixed_ceiling = true,
.fe_dai_names = { "j873-pcm-0", "j873-pcm-1", "j873-pcm-2" },
.dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBC_CFC | SND_SOC_DAIFMT_IB_NF,
.spk_dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBC_CFC |
SND_SOC_DAIFMT_GATED | SND_SOC_DAIFMT_NB_IF,
.spk_secondary_only = true,
};

/*
* J813 (T8142, MacBook Air M5 13"): as on J873, the AOP firmware owns the
* audio fabric and the CPU component is the T8152-style AOP audio driver.
Expand Down Expand Up @@ -4445,6 +4475,10 @@ static const struct of_device_id macaudio_snd_device_id[] = {
{ .compatible = "apple,j773-macaudio-jack", .data = &macaudio_j616_jack_cfg },
/* j873 AID48 sn012776 15 1x 1W (AOP-fed, no protection) */
{ .compatible = "apple,j873-macaudio", .data = &macaudio_j873_cfg },
/* j775c - sn012776 - 1x 1W (AOP-fed, no sense: fixed -20 dB ceiling) */
{ .compatible = "apple,j775c-macaudio", .data = &macaudio_j775_cfg },
/* j775d - sn012776 - 1x 1W (AOP-fed, no sense: fixed -20 dB ceiling) */
{ .compatible = "apple,j775d-macaudio", .data = &macaudio_j775_cfg },
/* j813 AID? sn012776 15 2x 1W+1T (AOP-fed, V/I sense) */
{ .compatible = "apple,j813-macaudio", .data = &macaudio_j813_cfg },
/* j815 AID43 sn012776 15 2x 2W+1T (AOP-fed, V/I sense) */
Expand Down
Loading