moby: define the audio/amplifier
combined with an out-of-tree ucm file, the audio device can actually make noise. no setup needed -- just run speaker-test after boot this patch probably changes more than is strictly required: i can maybe reduce it over time
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
// [ALC5640]HPO_L -> HPOUTL -> NO2[UM4717] -> COM2[UM4717] -> HPO_L -> JA-3618-011 (jack, "EARPHONE")
|
// [ALC5640]HPO_L -> HPOUTL -> NO2[UM4717] -> COM2[UM4717] -> HPO_L -> JA-3618-011 (jack, "EARPHONE")
|
||||||
// +----> INN[AW8737SCSR] -> SPK+/SPK-
|
// +----> INN[AW8737SCSR] -> SPK+/SPK-
|
||||||
// so, the codec's HPO_L output is sent to the SW-6 MUX (user-exposed, controls whether jack is audio or serial)
|
// so, the codec's HPO_L output is sent to the SW-6 MUX (user-exposed, controls whether jack is audio or serial)
|
||||||
// AND it's send to AW8737SCSR which *may* send it to the speaker.
|
// AND it's sent to AW8737SCSR which *may* send it to the speaker.
|
||||||
// i think audio is *unconditionally* routed to the headphones, then.
|
// i think audio is *unconditionally* routed to the headphones, then.
|
||||||
// it's impossible to have headphones connected, and play *only* to the speaker.
|
// it's impossible to have headphones connected, and play *only* to the speaker.
|
||||||
// and it's up to the system to disable AW8737SCSR when the headphones are detected.
|
// and it's up to the system to disable AW8737SCSR when the headphones are detected.
|
||||||
@@ -29,6 +29,9 @@
|
|||||||
// [ALC5640]SPO_LP -> EAROUTP -> 1[J7202/earphone]
|
// [ALC5640]SPO_LP -> EAROUTP -> 1[J7202/earphone]
|
||||||
// [ALC5640]SPO_LN -> EAROUTN -> 2[J7202/earphone]
|
// [ALC5640]SPO_LN -> EAROUTN -> 2[J7202/earphone]
|
||||||
//
|
//
|
||||||
|
// ## amplifiers
|
||||||
|
// [RK3399]B3 -> SPK_CTL_H -> SHDN[AW8737SCSR]
|
||||||
|
//
|
||||||
// ## Headphone detection (RK3399)
|
// ## Headphone detection (RK3399)
|
||||||
// [RK3399]GPIO4_D4_d -> HP_DET_H -> HP_DET (circuit)
|
// [RK3399]GPIO4_D4_d -> HP_DET_H -> HP_DET (circuit)
|
||||||
// - HP_DET is pulled to 3V0 when jack is *unplugged*, pulled to HPO_L when jack is plugged.
|
// - HP_DET is pulled to 3V0 when jack is *unplugged*, pulled to HPO_L when jack is plugged.
|
||||||
@@ -68,6 +71,10 @@
|
|||||||
|
|
||||||
// for symbols like SCLK_I2S_8CH_OUT
|
// for symbols like SCLK_I2S_8CH_OUT
|
||||||
#include <dt-bindings/clock/rk3399-cru.h>
|
#include <dt-bindings/clock/rk3399-cru.h>
|
||||||
|
// for RK_PD4, other pins
|
||||||
|
#include <dt-bindings/pinctrl/rockchip.h>
|
||||||
|
// for GPIO_ACTIVE_LOW
|
||||||
|
#include <dt-bindings/gpio/gpio.h>
|
||||||
|
|
||||||
/dts-v1/;
|
/dts-v1/;
|
||||||
/plugin/;
|
/plugin/;
|
||||||
@@ -112,17 +119,30 @@
|
|||||||
// SPOLP/SPOLN -> earphone (with only passives in between)
|
// SPOLP/SPOLN -> earphone (with only passives in between)
|
||||||
//
|
//
|
||||||
// naming ("Internal Earpiece") is chosen to be consistent with OG pinephone
|
// naming ("Internal Earpiece") is chosen to be consistent with OG pinephone
|
||||||
|
// "Speaker Amp {INL,INR,OUTL,OUTR}" actually come from simple-audio-amplifier, i think.
|
||||||
|
// - the speaker_amp dt node specifies "Speaker Amp" as its name-prefix,
|
||||||
|
// and <sound/soc/codecs/simple-amplifier.c> (i.e. simple-audio-amplifier) uses the INL/OUTL naming
|
||||||
simple-audio-card,routing =
|
simple-audio-card,routing =
|
||||||
"Headphone Jack", "HPOL",
|
"Headphones", "HPOL",
|
||||||
"Headphone Jack", "HPOR",
|
"Headphones", "HPOR",
|
||||||
"Internal Earpiece", "SPOLP",
|
// "Internal Earpiece", "SPOLP",
|
||||||
"Internal Earpiece", "SPOLN";
|
// "Internal Earpiece", "SPOLN",
|
||||||
|
"Speaker Amp INL", "HPOL",
|
||||||
|
"Speaker Amp INR", "HPOR",
|
||||||
|
"Internal Speaker", "Speaker Amp OUTL",
|
||||||
|
"Internal Speaker", "Speaker Amp OUTR";
|
||||||
|
|
||||||
// user-facing controls. e.g. when user selects "Headphone", activate the "Headphone Jack" path.
|
// user-facing controls. e.g. when user selects "Headphone", activate the "Headphone Jack" path.
|
||||||
simple-audio-card,widgets =
|
simple-audio-card,widgets =
|
||||||
"Headphone", "Headphone Jack",
|
"Headphone", "Headphones",
|
||||||
"Speaker", "Internal Earpiece";
|
"Speaker", "Internal Speaker";
|
||||||
// TODO; once i add the internal speaker, that will be bridged to the Speaker user-facing control
|
// "Speaker", "Internal Earpiece";
|
||||||
|
// TODO; once i add the internal earpiece, that will be bridged to the Speaker user-facing control
|
||||||
|
|
||||||
|
simple-audio-card,hp-det-gpio = <&gpio4 RK_PD4 GPIO_ACTIVE_LOW>;
|
||||||
|
|
||||||
|
simple-audio-card,pin-switches = "Internal Speaker";
|
||||||
|
simple-audio-card,aux-devs = <&speaker_amp>;
|
||||||
|
|
||||||
simple-audio-card,cpu {
|
simple-audio-card,cpu {
|
||||||
sound-dai = <&i2s0>;
|
sound-dai = <&i2s0>;
|
||||||
@@ -131,9 +151,19 @@
|
|||||||
simple-audio-card,codec {
|
simple-audio-card,codec {
|
||||||
sound-dai = <&rt5640>;
|
sound-dai = <&rt5640>;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// TODO: speakers
|
// TODO: i haven't defined the 5v power rail for this amplifier.
|
||||||
// simple-audio-card,aux-devs = <&speaker_amp>;
|
// it's needed here because the PinePhonePro alsa-ucm files will
|
||||||
|
// fail if they can't find any control for the amplifier
|
||||||
|
speaker_amp: audio-amplifier {
|
||||||
|
compatible = "simple-audio-amplifier";
|
||||||
|
// TODO: why does it need both pinctrl *and* enable-gpios??
|
||||||
|
// i guess the pinctrl enables the physical pin to act as a gpio?
|
||||||
|
pinctrl-names = "default";
|
||||||
|
pinctrl-0 = <&spk_en>;
|
||||||
|
enable-gpios = <&gpio0 RK_PB3 GPIO_ACTIVE_HIGH>;
|
||||||
|
sound-name-prefix = "Speaker Amp";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,6 +188,7 @@
|
|||||||
// declared in rk3399-base.dtsi, as `i2c1: i2c@ff110000 { ... }`
|
// declared in rk3399-base.dtsi, as `i2c1: i2c@ff110000 { ... }`
|
||||||
&i2c1 {
|
&i2c1 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
|
clock-frequency = <400000>;
|
||||||
// from rk3399-firefly.dts
|
// from rk3399-firefly.dts
|
||||||
// note that i2c3 in pinephone-pro is defined as 450/15 rise/fall
|
// note that i2c3 in pinephone-pro is defined as 450/15 rise/fall
|
||||||
i2c-scl-rising-time-ns = <300>;
|
i2c-scl-rising-time-ns = <300>;
|
||||||
@@ -179,9 +210,10 @@
|
|||||||
clock-names = "mclk";
|
clock-names = "mclk";
|
||||||
// XXX: this differs from megi's kernel (which declares in3 as differential).
|
// XXX: this differs from megi's kernel (which declares in3 as differential).
|
||||||
// the schematics show `IN2P` / `IN2N` as being differential inputs though, with no mention of "in3"
|
// the schematics show `IN2P` / `IN2N` as being differential inputs though, with no mention of "in3"
|
||||||
realtek,in2-differential;
|
// realtek,in2-differential;
|
||||||
|
realtek,in3-differential;
|
||||||
// megi has lout-differential, but schematic shows LOUT{R,L} => 4G_IN_{R,L} i.e. stereo
|
// megi has lout-differential, but schematic shows LOUT{R,L} => 4G_IN_{R,L} i.e. stereo
|
||||||
// realtek,lout-differential;
|
realtek,lout-differential;
|
||||||
// codec has ldo1-en connected to 1.8V via pull-up, i.e. permanently enabled, no GPIO?
|
// codec has ldo1-en connected to 1.8V via pull-up, i.e. permanently enabled, no GPIO?
|
||||||
// realtek,ldo1-en-gpios = VCCA1V8_CODEC;
|
// realtek,ldo1-en-gpios = VCCA1V8_CODEC;
|
||||||
// PDM_SDI1_MIC -> IN1P/DMIC1_DAT
|
// PDM_SDI1_MIC -> IN1P/DMIC1_DAT
|
||||||
@@ -198,7 +230,15 @@
|
|||||||
// i think there's only one DAI on the board (the i2s DAI), and this is telling the driver the index of that DAI?
|
// i think there's only one DAI on the board (the i2s DAI), and this is telling the driver the index of that DAI?
|
||||||
#sound-dai-cells = <0>;
|
#sound-dai-cells = <0>;
|
||||||
|
|
||||||
// TODO: define pinctrl for the headphone connector? like rk3399-firefly.dts does
|
// TODO: i think all of these can be removed?
|
||||||
|
assigned-clocks = <&cru SCLK_I2S0_8CH>;
|
||||||
|
assigned-clock-rates = <11289599>; // 44100 * 256
|
||||||
|
// // rt5645 describes avdd-supply, cpvdd-supply, but rt5640 does not.
|
||||||
|
// // <Documentation/devicetree/bindings/sound/realtek,rt5645.yaml>
|
||||||
|
// avdd-supply = <&vcca3v0_codec>;
|
||||||
|
// cpvdd-supply = <&vcca3v0_codec>;
|
||||||
|
// // spkvdd-supply = <&vcc5v0_sys>; //< TODO
|
||||||
|
// dbvdd-supply = <&vcca1v8_codec>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -217,4 +257,13 @@
|
|||||||
status = "okay";
|
status = "okay";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
&pinctrl {
|
||||||
|
sound {
|
||||||
|
spk_en: spk-en {
|
||||||
|
rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// TODO: what are `io_domains`?
|
// TODO: what are `io_domains`?
|
||||||
|
// TODO: define headphone detector
|
||||||
|
Reference in New Issue
Block a user