diff --git a/arch/arm64/boot/dts/rockchip/rk3588-cpcm5-notebook-v20.dts b/arch/arm64/boot/dts/rockchip/rk3588-cpcm5-notebook-v20.dts index 706fb0b86..3522f6435 100755 --- a/arch/arm64/boot/dts/rockchip/rk3588-cpcm5-notebook-v20.dts +++ b/arch/arm64/boot/dts/rockchip/rk3588-cpcm5-notebook-v20.dts @@ -145,16 +145,6 @@ default-brightness-level = <200>; }; - hdmi0_sound: hdmi0-sound { - status = "disabled"; - compatible = "rockchip,hdmi"; - rockchip,mclk-fs = <128>; - rockchip,card-name = "rockchip-hdmi0"; - rockchip,cpu = <&i2s5_8ch>; - rockchip,codec = <&hdmi0>; - rockchip,jack-det; - }; - fan: pwm-fan { compatible = "pwm-fan"; cooling-min-state = <0>; @@ -203,6 +193,17 @@ }; }; }; + + vendor_storage_rm: vendor-storage-rm@0 { + compatible = "rockchip,vendor-storage-rm"; + reg = <0x0 0x0 0x0 0x0>; + }; + + vendor_storage: vendor-storage { + compatible = "rockchip,ram-vendor-storage"; + memory-region = <&vendor_storage_rm>; + status = "okay"; + }; vcc3v3_lcd: vcc3v3-lcd { compatible = "regulator-fixed"; @@ -214,34 +215,41 @@ pinctrl-0 = <&lcdpwr_en>; }; - + es8316_sound: es8316-sound { status = "okay"; - compatible = "simple-audio-card"; - simple-audio-card,format = "i2s"; - simple-audio-card,mclk-fs = <256>; - simple-audio-card,name = "rockchip,es8316-codec"; - simple-audio-card,dai-link@0 { - format = "i2s"; - cpu { - sound-dai = <&i2s0_8ch>; - }; - codec { - sound-dai = <&es8316>; - }; - }; - }; - - rk_headset: rk-headset { - compatible = "rockchip_headset"; - headset_gpio = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>; + compatible = "rockchip,multicodecs-card"; + rockchip,card-name = "rk3588-es8316"; + hp-det-gpio = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>; + io-channels = <&saradc 3>; + io-channel-names = "adc-detect"; + keyup-threshold-microvolt = <1800000>; + poll-interval = <100>; + spk-con-gpio = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>; + rockchip,pre-power-on-delay-ms = <30>; + rockchip,post-power-down-delay-ms = <40>; + rockchip,format = "i2s"; + rockchip,mclk-fs = <256>; + rockchip,cpu = <&i2s0_8ch>; + rockchip,codec = <&es8316>; + rockchip,audio-routing = + "Headphone", "HPOL", + "Headphone", "HPOR", + "Speaker", "HPOL", + "Speaker", "HPOR", + "MIC1", "Main Mic", + "MIC2", "Headset Mic"; pinctrl-names = "default"; pinctrl-0 = <&hp_det>; - io-channels = <&saradc 3>; + play-pause-key { + label = "playpause"; + linux,code = ; + press-threshold-microvolt = <2000>; + }; }; dp0_sound: dp0-sound { - status = "disabled"; + status = "okay"; compatible = "rockchip,hdmi"; rockchip,card-name= "rockchip,dp0"; rockchip,mclk-fs = <512>; @@ -249,6 +257,16 @@ rockchip,codec = <&dp0 1>; rockchip,jack-det; }; + + hdmi0_sound: hdmi0-sound { + status = "okay"; + compatible = "rockchip,hdmi"; + rockchip,mclk-fs = <128>; + rockchip,card-name = "rockchip-hdmi0"; + rockchip,cpu = <&i2s5_8ch>; + rockchip,codec = <&hdmi0>; + rockchip,jack-det; + }; leds: leds { compatible = "gpio-leds"; @@ -421,8 +439,12 @@ mem-supply = <&vdd_cpu_big1_mem_s0>; }; +&dfi { + status = "okay"; +}; + &dmc { - auto-freq-en = <1>; + auto-freq-en = <0>; status = "okay"; }; @@ -785,10 +807,6 @@ status = "okay"; }; -&hdmi0_sound { - status = "okay"; -}; - &route_hdmi0 { status = "okay"; logo,uboot = "logo.bmp"; @@ -810,10 +828,6 @@ status = "okay"; }; -&dp0_sound{ - status = "okay"; -}; - &edp1 { force-hpd; status = "okay"; @@ -1112,8 +1126,7 @@ &i2c7 { status = "okay"; - pinctrl-names = "default"; - pinctrl-0 = <&i2c7m0_xfer>; + es8316: es8316@10 { status = "okay"; #sound-dai-cells = <0>; @@ -1121,17 +1134,16 @@ reg = <0x10>; clocks = <&mclkout_i2s0>; clock-names = "mclk"; - spk-con-gpio = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>; assigned-clocks = <&mclkout_i2s0>; assigned-clock-rates = <12288000>; pinctrl-names = "default"; pinctrl-0 = <&i2s0_mclk>; - extcon = <&rk_headset>; }; }; &i2s0_8ch { status = "okay"; + pinctrl-names = "default"; pinctrl-0 = <&i2s0_lrck &i2s0_sclk &i2s0_sdi0 diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index c4e4ab93f..86b34a493 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -360,6 +360,70 @@ static const struct snd_soc_dapm_route es8316_dapm_routes[] = { {"HPOR", NULL, "Headphone Out"}, }; +static int es8316_init_regs(struct snd_soc_component *component) +{ + snd_soc_component_write(component, ES8316_RESET, 0x3f); + usleep_range(5000, 5500); + snd_soc_component_write(component, ES8316_RESET, 0x00); + snd_soc_component_write(component, ES8316_SYS_VMIDSEL, 0xFF); + msleep(30); + snd_soc_component_write(component, ES8316_CLKMGR_CLKSEL, 0x08); + snd_soc_component_write(component, ES8316_CLKMGR_ADCOSR, 0x20); + snd_soc_component_write(component, ES8316_CLKMGR_ADCDIV1, 0x11); + snd_soc_component_write(component, ES8316_CLKMGR_ADCDIV2, 0x00); + snd_soc_component_write(component, ES8316_CLKMGR_DACDIV1, 0x11); + snd_soc_component_write(component, ES8316_CLKMGR_DACDIV2, 0x00); + snd_soc_component_write(component, ES8316_CLKMGR_CPDIV, 0x00); + snd_soc_component_write(component, ES8316_SERDATA1, 0x04); + snd_soc_component_write(component, ES8316_CLKMGR_CLKSW, 0x7F); + snd_soc_component_write(component, ES8316_CAL_TYPE, 0x0F); + snd_soc_component_write(component, ES8316_CAL_HPLIV, 0x90); + snd_soc_component_write(component, ES8316_CAL_HPRIV, 0x90); + snd_soc_component_write(component, ES8316_ADC_VOLUME, 0x00); + snd_soc_component_write(component, ES8316_ADC_PDN_LINSEL, 0xC0); + snd_soc_component_write(component, ES8316_ADC_D2SEPGA, 0x00); + snd_soc_component_write(component, ES8316_ADC_DMIC, 0x08); + snd_soc_component_write(component, ES8316_DAC_SET2, 0x20); + snd_soc_component_write(component, ES8316_DAC_SET3, 0x00); + snd_soc_component_write(component, ES8316_DAC_VOLL, 0x00); + snd_soc_component_write(component, ES8316_DAC_VOLR, 0x00); + snd_soc_component_write(component, ES8316_SERDATA_ADC, 0x00); + snd_soc_component_write(component, ES8316_SERDATA_DAC, 0x00); + snd_soc_component_write(component, ES8316_SYS_VMIDLOW, 0x11); + snd_soc_component_write(component, ES8316_SYS_VSEL, 0xFC); + snd_soc_component_write(component, ES8316_SYS_REF, 0x28); + snd_soc_component_write(component, ES8316_SYS_LP1, 0x04); + snd_soc_component_write(component, ES8316_SYS_LP2, 0x0C); + snd_soc_component_write(component, ES8316_DAC_PDN, 0x11); + snd_soc_component_write(component, ES8316_HPMIX_SEL, 0x00); + snd_soc_component_write(component, ES8316_HPMIX_SWITCH, 0x88); + snd_soc_component_write(component, ES8316_HPMIX_PDN, 0x00); + snd_soc_component_write(component, ES8316_HPMIX_VOL, 0xBB); + snd_soc_component_write(component, ES8316_CPHP_PDN2, 0x10); + snd_soc_component_write(component, ES8316_CPHP_LDOCTL, 0x30); + snd_soc_component_write(component, ES8316_CPHP_PDN1, 0x02); + snd_soc_component_write(component, ES8316_CPHP_ICAL_VOL, 0x00); + snd_soc_component_write(component, ES8316_GPIO_SEL, 0x00); + snd_soc_component_write(component, ES8316_GPIO_DEBOUNCE, 0x02); + snd_soc_component_write(component, ES8316_TESTMODE, 0xA0); + snd_soc_component_write(component, ES8316_TEST1, 0x00); + snd_soc_component_write(component, ES8316_TEST2, 0x00); + snd_soc_component_write(component, ES8316_SYS_PDN, 0x00); + snd_soc_component_write(component, ES8316_RESET, 0xC0); + msleep(50); + snd_soc_component_write(component, ES8316_ADC_PGAGAIN, 0xA0); + snd_soc_component_write(component, ES8316_ADC_D2SEPGA, 0x01); + /* adc ds mode, HPF enable */ + snd_soc_component_write(component, ES8316_ADC_DMIC, 0x08); + snd_soc_component_write(component, ES8316_ADC_ALC1, 0xcd); + snd_soc_component_write(component, ES8316_ADC_ALC2, 0x08); + snd_soc_component_write(component, ES8316_ADC_ALC3, 0xa0); + snd_soc_component_write(component, ES8316_ADC_ALC4, 0x05); + snd_soc_component_write(component, ES8316_ADC_ALC5, 0x06); + snd_soc_component_write(component, ES8316_ADC_ALC_NG, 0x61); + return 0; +} + static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { @@ -762,6 +826,21 @@ static int es8316_probe(struct snd_soc_component *component) */ snd_soc_component_write(component, ES8316_CLKMGR_ADCOSR, 0x32); + es8316_init_regs(component); + /* es8316_set_bias_level(codec, SND_SOC_BIAS_OFF); */ + snd_soc_component_write(component, ES8316_CPHP_OUTEN, 0x00); + snd_soc_component_write(component, ES8316_DAC_PDN, 0x11); + snd_soc_component_write(component, ES8316_CPHP_LDOCTL, 0x03); + snd_soc_component_write(component, ES8316_CPHP_PDN2, 0x22); + snd_soc_component_write(component, ES8316_CPHP_PDN1, 0x06); + snd_soc_component_write(component, ES8316_HPMIX_SWITCH, 0x00); + snd_soc_component_write(component, ES8316_HPMIX_PDN, 0x33); + snd_soc_component_write(component, ES8316_HPMIX_VOL, 0x00); + snd_soc_component_write(component, ES8316_SYS_LP1, 0xFF); + snd_soc_component_write(component, ES8316_SYS_LP2, 0xFF); + snd_soc_component_write(component, ES8316_CLKMGR_CLKSW, 0xF3); + snd_soc_component_write(component,ES8316_ADC_PDN_LINSEL, 0xC0); + return 0; } diff --git a/sound/soc/codecs/es8316.h b/sound/soc/codecs/es8316.h index c335138e2..2bd821256 100644 --- a/sound/soc/codecs/es8316.h +++ b/sound/soc/codecs/es8316.h @@ -129,4 +129,21 @@ #define ES8316_GPIO_FLAG_GM_NOT_SHORTED 0x02 #define ES8316_GPIO_FLAG_HP_NOT_INSERTED 0x04 +/* REGISTER 0X01 CLOCK MANAGER */ +#define ES8316_CLKMGR_MCLK_DIV_MASK (0X1<<7) +#define ES8316_CLKMGR_MCLK_DIV_NML (0X0<<7) +#define ES8316_CLKMGR_MCLK_DIV_1 (0X1<<7) +#define ES8316_CLKMGR_ADC_MCLK_MASK (0X1<<3) +#define ES8316_CLKMGR_ADC_MCLK_EN (0X1<<3) +#define ES8316_CLKMGR_ADC_MCLK_DIS (0X0<<3) +#define ES8316_CLKMGR_DAC_MCLK_MASK (0X1<<2) +#define ES8316_CLKMGR_DAC_MCLK_EN (0X1<<2) +#define ES8316_CLKMGR_DAC_MCLK_DIS (0X0<<2) +#define ES8316_CLKMGR_ADC_ANALOG_MASK (0X1<<1) +#define ES8316_CLKMGR_ADC_ANALOG_EN (0X1<<1) +#define ES8316_CLKMGR_ADC_ANALOG_DIS (0X0<<1) +#define ES8316_CLKMGR_DAC_ANALOG_MASK (0X1<<0) +#define ES8316_CLKMGR_DAC_ANALOG_EN (0X1<<0) +#define ES8316_CLKMGR_DAC_ANALOG_DIS (0X0<<0) + #endif