Release develop 251023

This commit is contained in:
hongyi
2025-10-23 10:06:52 +08:00
parent e8e2710771
commit ac5bae38b9
12 changed files with 1554 additions and 200 deletions

View File

@@ -1,3 +1,3 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
dtb-$(CONFIG_ARCH_ZHIHE) += a210-emu.dtb a210-emu-d2d.dtb a210-evb.dtb a210-dev.dtb dtb-$(CONFIG_ARCH_ZHIHE) += a210-emu.dtb a210-emu-d2d.dtb a210-evb.dtb a210-dev.dtb a210-evb-d2d.dtb

View File

@@ -112,8 +112,8 @@
#size-cells = <0>; #size-cells = <0>;
status = "okay"; status = "okay";
SOUND_CARD_LINK(0, i2s, i2s0, 0, es8156_dac0, 0); /* I2S0 <-> es8156_dac0 */ SOUND_CARD_LINK(0, i2s, i2s1, 0, es8156_dac0, 0); /* I2S1 <-> es8156_dac0 */
SOUND_CARD_LINK(1, i2s, i2s0, 0, es7210_adc0, 0); /* I2S0 <-> es7210_adc0 */ SOUND_CARD_LINK(1, i2s, i2s1, 0, es7210_adc0, 0); /* I2S1 <-> es7210_adc0 */
}; };
Sound_Card@1 { Sound_Card@1 {
@@ -121,7 +121,7 @@
simple-audio-card,name = "Sound-Card-I2S1"; simple-audio-card,name = "Sound-Card-I2S1";
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
status = "okay"; status = "disabled";
simple-audio-card,widgets = "Speaker", "Speaker"; simple-audio-card,widgets = "Speaker", "Speaker";
simple-audio-card,routing = simple-audio-card,routing =
@@ -132,6 +132,23 @@
SOUND_CARD_LINK(1, i2s, i2s1, 0, es7210_adc1, 0); SOUND_CARD_LINK(1, i2s, i2s1, 0, es7210_adc1, 0);
}; };
wcn_wifi: wireless-wlan {
compatible = "wlan-platdata";
WIFI,poweren-gpios = <&aw9535_1 11 GPIO_ACTIVE_HIGH>,
<&aw9535_1 12 GPIO_ACTIVE_HIGH>,
<&gpio0_porta 14 GPIO_ACTIVE_HIGH>;
power_on_after_init;
power_on_when_resume;
status = "okay";
};
wcn_bt: wireless-bluetooth {
compatible = "bluetooth-platdata";
BT,power-gpios = <&ao_gpio1_porta 4 GPIO_ACTIVE_HIGH>,
<&aw9535_1 15 GPIO_ACTIVE_HIGH>;
status = "okay";
};
/* The bootargs in U-Boot will override the configuration set here. */ /* The bootargs in U-Boot will override the configuration set here. */
chosen { chosen {
stdout-path = "serial4"; stdout-path = "serial4";
@@ -206,16 +223,6 @@
slew-rate = <0>; slew-rate = <0>;
}; };
}; };
i2s0_pins: i2s0-1 {
i2s-pins {
pins = "GPIO0_28", "GPIO0_29", "GPIO0_30", "GPIO0_31", "GPIO1_0";
function = "i2s0";
bias-disable;
drive-strength = <13>;
input-schmitt-disable;
slew-rate = <0>;
};
};
qspi0_pins: qspi0-0 { qspi0_pins: qspi0-0 {
qspi-pins { qspi-pins {
pins = "GPIO0_18", "GPIO0_20", "GPIO0_21", "GPIO0_22", "GPIO0_23"; pins = "GPIO0_18", "GPIO0_20", "GPIO0_21", "GPIO0_22", "GPIO0_23";
@@ -321,6 +328,17 @@
slew-rate = <0>; slew-rate = <0>;
}; };
}; };
usb3_pins: usb3-1 {
usb3-pins {
pins = "GPIO0_27";
function = "gpio0";
bias-disable;
drive-strength = <13>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
};
}; };
&peri2_padctrl { &peri2_padctrl {
@@ -420,6 +438,17 @@
slew-rate = <0>; slew-rate = <0>;
}; };
}; };
pwm0_pins: pwm0-1 {
pwm0-pins {
pins = "GPIO0_30"; // PWM0_CH2
function = "pwm0";
bias-disable;
drive-strength = <13>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
};
pwm1_pins: pwm1-1 { pwm1_pins: pwm1-1 {
pwm1-pins { pwm1-pins {
pins = "GPIO2_12"; // PWM1_CH2 pins = "GPIO2_12"; // PWM1_CH2
@@ -548,7 +577,10 @@
#sound-dai-cells = <1>; #sound-dai-cells = <1>;
sound-name-prefix = "ES8156_DAC0"; sound-name-prefix = "ES8156_DAC0";
mclk-sclk-ratio = <4>; mclk-sclk-ratio = <4>;
status = "disabled"; audio-3v3-pwren-gpios = <&aw9535_1 1 GPIO_ACTIVE_HIGH>;
audio-1v8-pwren-gpios = <&aw9535_1 2 GPIO_ACTIVE_HIGH>;
audio-hp-ctl-gpios = <&aw9535_0 11 GPIO_ACTIVE_HIGH>;
status = "okay";
}; };
codec_es7210_adc0: es7210@40 { codec_es7210_adc0: es7210@40 {
@@ -559,7 +591,7 @@
channels-max = <2>; channels-max = <2>;
mclk-sclk-ratio = <4>; mclk-sclk-ratio = <4>;
sound-name-prefix = "ES7210_ADC0"; sound-name-prefix = "ES7210_ADC0";
status = "disabled"; status = "okay";
}; };
codec_es8156_dac1: es8156@9 { codec_es8156_dac1: es8156@9 {
@@ -568,7 +600,7 @@
#sound-dai-cells = <1>; #sound-dai-cells = <1>;
sound-name-prefix = "ES8156_DAC1"; sound-name-prefix = "ES8156_DAC1";
mclk-sclk-ratio = <4>; mclk-sclk-ratio = <4>;
status = "okay"; status = "disabled";
}; };
codec_es7210_adc1: es7210@41 { codec_es7210_adc1: es7210@41 {
@@ -579,7 +611,7 @@
channels-max = <2>; channels-max = <2>;
mclk-sclk-ratio = <4>; mclk-sclk-ratio = <4>;
sound-name-prefix = "ES7210_ADC1"; sound-name-prefix = "ES7210_ADC1";
status = "okay"; status = "disabled";
}; };
audio_aw87565_pa2: audio_pa2@5b { audio_aw87565_pa2: audio_pa2@5b {
@@ -587,7 +619,7 @@
reg = <0x5b>; reg = <0x5b>;
sound-name-prefix = "AW87565_PA2"; sound-name-prefix = "AW87565_PA2";
reset-gpios = <&aw9535_0 8 GPIO_ACTIVE_LOW>; reset-gpios = <&aw9535_0 8 GPIO_ACTIVE_LOW>;
status = "okay"; status = "disabled";
}; };
}; };
@@ -618,10 +650,10 @@
interrupt-parent = <&ao_gpio1>; interrupt-parent = <&ao_gpio1>;
interrupts = <2 IRQ_TYPE_LEVEL_LOW>; interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
gpio-line-names = gpio-line-names =
"CSI1_PWDN_IO0", "CSI1_RST_IO1", "CSI1_FSIN_IO2", "CSI0_PWDN_IO3", // index 0..3 "CSI1_PWDN_IO0", "CSI1_RST_IO1", "CSI1_FSIN_IO2", "CSI0_PWDN_IO3", // index 0..3
"CSI0_RST_IO4", "CSI0_FSIN_IO5", "PCIE_X1_PRSNT_L_IO6", "PCIE_X4_PRSNT_L_IO7", // index 4..7 "CSI0_RST_IO4", "CSI0_FSIN_IO5", "MINPCIE_1V5POWER_EN_I06", "MINPCIE_3V3_PWREN_I07",// index 4..7
"AUDIO1_PARST0_IO8", "AUDIO_ADC1_INT_IO9", "AUDIO_ADC0_INT_IO10", "HP_CTL_H_IO11", // index 8..11 "NULL_I08", "M2_SATA_EN_IO9", "AUDIO_ADC0_INT_IO10", "HP_CTL_H_IO11", // index 8..11
"SIT91211_SSC_EN_IO12","DISP_RST_IO13","SWITCH3_SEL_IO14","SWITCH1_SEL_IO15"; // index 12..15 "PI6C557_EN_IO12","DISP_RST_IO13","M2_SATA_3V3_PWREN_IO14","MINPCIE_PERST_IO15"; // index 12..15
}; };
aw9535_1: gpio@21 { aw9535_1: gpio@21 {
@@ -631,10 +663,10 @@
#gpio-cells = <2>; #gpio-cells = <2>;
ngpios = <16>; ngpios = <16>;
gpio-line-names = gpio-line-names =
"PCIE_BAT_EN_IO0", "AUDIO_3V3_PWREN_IO1", "AUDIO_1V8_PWREN_IO2", "MIPI_CSI0_PWREN_IO3", // index 0..3 "PCIE_ETH_PERSTB_IO0", "AUDIO_3V3_PWREN_IO1", "AUDIO_1V8_PWREN_IO2", "MIPI_CSI0_PWREN_IO3", // index 0..3
"MIPI_CSI1_PWREN_IO4", "MIPI_TP_PWREN_IO5", "PCIE_3V3_EN_IO6", "PCIE_12V_EN_IO7", // index 4..7 "MIPI_CSI1_PWREN_IO4", "MIPI_TP_PWREN_IO5", "PCIE_ETH_3V3_PWREN_IO6", "NULL_IO7", // index 4..7
"USBCON_PWREN_IO8", "USBCON1_PWREN_IO9", "PCIE_3V3_AUX_EN_IO10", "SDIO_3V3_PWREN_IO11", // index 8..11 "USBCON_PWREN_IO8", "USBCON1_PWREN_IO9", "NULL_IO10", "SDIO_3V3_PWREN_IO11", // index 8..11
"SDIO_1V8_PWREN_IO12","SIT91211_3V3_EN_IO13","MIPI_DSI_PWREN_IO14","BL_EN_IO15"; // index 12..15 "SDIO_1V8_PWREN_IO12","PI6C557_PWREN_IO13","MIPI_DSI_PWREN_IO14","BL_EN_IO15"; // index 12..15
}; };
}; };
@@ -663,11 +695,6 @@
pinctrl-0 = <&pcie_x4_pins>; pinctrl-0 = <&pcie_x4_pins>;
}; };
&audio_i2s0 {
pinctrl-names = "default";
pinctrl-0 = <&i2s0_pins>;
};
&audio_i2s1 { &audio_i2s1 {
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&i2s1_pins>; pinctrl-0 = <&i2s1_pins>;
@@ -680,6 +707,11 @@
resolution = <12>; resolution = <12>;
}; };
&pwm0 {
pinctrl-names = "default";
pinctrl-0 = <&pwm0_pins>;
};
&pwm1 { &pwm1 {
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&pwm1_pins>; pinctrl-0 = <&pwm1_pins>;
@@ -721,11 +753,23 @@
cap-sd-highspeed; cap-sd-highspeed;
bus-width = <4>; bus-width = <4>;
sd-uhs-sdr104; sd-uhs-sdr104;
no-sdio;
pull_up; pull_up;
no-sd;
no-mmc;
non-removable;
io_fixed_1v8;
post-power-on-delay-ms = <200>;
wprtn_ignore; wprtn_ignore;
wakeup-source;
}; };
&usb2_0 { &usb20_zhihe {
status = "disabled"; usb21-pwren-gpios = <&aw9535_1 8 GPIO_ACTIVE_HIGH>;
usb20-pwren-gpios = <&aw9535_1 9 GPIO_ACTIVE_HIGH>;
};
&usb3 {
pinctrl-names = "default";
pinctrl-0 = <&usb3_pins>;
typec-pwren-gpios = <&gpio0_porta 27 GPIO_ACTIVE_HIGH>;
}; };

View File

@@ -0,0 +1,457 @@
/dts-v1/;
#include "a210-soc-core.dtsi"
#include "a210-soc-core-die1.dtsi"
#include "a210-soc-peri.dtsi"
/ {
model = "A210 EVB D2D configuration";
aliases {
mmc0 = &emmc;
serial4 = &uart4;
};
/* The first 2M will be reserved in the Kernel, and the entire available range is set here */
memory@0 {
device_type = "memory";
reg = <0x00 0x80000000 0x01 0x00000000>; /* 4G - 64MB */
numa-node-id = <0>;
};
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
linux,cma {
compatible = "shared-dma-pool";
reusable;
size = <0x00 0x40000000>;
alloc-ranges = <0x00 0x90000000 0x00 0x40000000>;
linux,cma-default;
};
memory@1c000000 {
reg = <0x00 0x1c000000 0x00 0x2000000>;
no-map;
};
framebuffer: framebuffer@10000000 {
reg = <0x01 0x00 0x00 0x5000000>;
no-map;
};
// zh_videomem@100000000 {
// reg = <0x01 0x00 0x00 0x20000000>;
// no-map;
// };
npu_mmu_memory@130000000 {
reg = <0x01 0x30000000 0x00 0x04000000>;
no-map;
};
memblock-memory@17b800000 {
reg = <0x01 0x7b800000 0x00 0x04000000>;
no-map;
};
};
/* The bootargs in U-Boot will override the configuration set here. */
chosen {
stdout-path = "serial4";
};
};
&reset {
control-val = <0x3 0x0 0x3 0x0>;
};
&c908_1 {
status = "disable";
};
&c908_2 {
status = "disable";
};
&c908_3 {
status = "disable";
};
&c920_4 {
status = "disable";
};
&c920_5 {
status = "disable";
};
&c920_6 {
status = "disable";
};
&c920_7 {
status = "disable";
};
&c908_8 {
//status = "disable";
};
&c908_9 {
status = "disable";
};
&c908_10 {
status = "disable";
};
&c908_11 {
status = "disable";
};
&c920_12 {
status = "disable";
};
&c920_13 {
status = "disable";
};
&c920_14 {
status = "disable";
};
&c920_15 {
status = "disable";
};
&uart0 {
status = "disabled";
};
&uart1 {
status = "disabled";
};
&uart3 {
status = "disabled";
};
&uart4 {
current-speed = <115200>; /* OpenSBI */
};
&uart5 {
status = "disabled";
};
&uart6 {
status = "disabled";
};
&uart7 {
status = "disabled";
};
&uart8 {
status = "disabled";
};
&uart9 {
status = "disabled";
};
&spi0 {
status = "disabled";
};
&qspi0 {
status = "disabled";
};
&i2c1 {
status = "disabled";
};
&i2c2 {
status = "disabled";
};
&i2c3 {
status = "disabled";
};
&i2c5 {
status = "disabled";
};
&i2c6 {
status = "disabled";
};
&i2c7 {
status = "disabled";
};
&pwm0 {
status = "disabled";
};
&pwm2 {
status = "disabled";
};
&audio_i2s2 {
status = "disabled";
};
&audio_i2s_8ch_sd1 {
status = "disabled";
};
&audio_i2s_8ch_sd2 {
status = "disabled";
};
&audio_i2s_8ch_sd3 {
status = "disabled";
};
&peri3_padctrl {
status = "disabled";
};
&gpio4 {
status = "disabled";
};
&gmac1 {
status = "disabled";
};
/* FIXME: Disabled non-critical peripherals in the bringup phase */
&can0 {
status = "disabled";
};
&can1 {
status = "disabled";
};
&can2 {
status = "disabled";
};
&dmac1 {
status = "disabled";
};
&uart2 {
status = "disabled";
};
&timer0 {
status = "disabled";
};
&timer1 {
status = "disabled";
};
&timer3 {
status = "disabled";
};
&timer4 {
status = "disabled";
};
&timer5 {
status = "disabled";
};
&timer6 {
status = "disabled";
};
&timer7 {
status = "disabled";
};
&i2c4 {
status = "disabled";
};
&audio_i2s0 {
status = "disabled";
};
&dm3x4 {
status = "disabled";
};
&rp3x1 {
status = "disabled";
};
&usb31_zhihe {
status = "disabled";
};
&gmac0 {
status = "disabled";
};
&mdio0 {
status = "disabled";
};
&gmac1 {
status = "disabled";
};
&mdio1 {
status = "disabled";
};
&audio_i2s0 {
status = "disabled";
};
&spi0 {
status = "disabled";
};
&spi1 {
status = "disabled";
};
&rp3x1 {
status = "disabled";
};
&audio_i2s2 {
status = "disabled";
};
&audio_pdm0 { // Load the module using insmod
status = "disabled";
};
&pwm1 {
status = "disabled";
};
&sata {
status = "disabled";
};
&hdmi_tx {
status = "disabled";
};
&emmc {
max-frequency = <196608000>;
non-removable;
mmc-ddr-1_8v;
mmc-hs200-1_8v;
mmc-hs400-1_8v;
cap-mmc-highspeed;
io_fixed_1v8;
is_emmc;
no-sdio;
no-sd;
pull_up;
bus-width = <8>;
};
&sdhci0 {
status = "disabled";
};
&adc {
status = "disabled";
};
&vp_dfmu_iommu {
status = "disabled";
};
&vp_dfmu_mt {
status = "disabled";
};
&npu_dfmu_iommu {
status = "disabled";
};
&npu_dfmu_mt {
status = "disabled";
};
&vi_dfmu_iommu {
status = "disabled";
};
&vi_dfmu_mt {
status = "disabled";
};
&vo_dfmu_iommu {
status = "disabled";
};
&vo_dfmu_mt {
status = "disabled";
};
&peri1_dfmu_iommu {
status = "okay";
};
&peri1_dfmu_mt {
status = "disabled";
};
&pcie_dfmu_iommu {
status = "disabled";
};
&pcie_dfmu_mt {
status = "disabled";
};
&usb_dfmu_iommu {
status = "okay";
};
&usb_dfmu_mt {
status = "disabled";
};
&vidmem {
status = "disabled";
};
&usb2_0 {
status = "disabled";
};
&gpio0 {
status = "disabled";
};
&gpio1 {
status = "disabled";
};
&gpio2 {
status = "disabled";
};
&gpio3 {
status = "disabled";
};
&gpio4 {
status = "disabled";
};

View File

@@ -0,0 +1,735 @@
/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include "a210-soc-core.dtsi"
#include "a210-soc-peri.dtsi"
#include "a210-platform-dev.dtsi"
#define SOUND_CARD_LINK(REG, FMT, CPU, M, CODEC, N) \
simple-audio-card,dai-link@##REG { \
reg = <REG>; \
format = #FMT; \
cpu { \
sound-dai = <&audio_##CPU M>; \
}; \
codec { \
sound-dai = <&codec_##CODEC N>; \
}; \
}
/ {
model = "A210 DEV configuration";
aliases {
ethernet0 = &gmac0;
ethernet1 = &gmac1;
gpio0 = &gpio0;
gpio1 = &gpio1;
gpio2 = &gpio2;
gpio3 = &gpio3;
gpio4 = &gpio4;
i2c0 = &i2c0;
i2c1 = &i2c1;
i2c2 = &i2c2;
i2c3 = &i2c3;
i2c4 = &i2c4;
i2c5 = &i2c5;
i2c6 = &i2c6;
i2c7 = &i2c7;
aoi2c1 = &aoi2c1;
can0 = &can0;
can1 = &can1;
can2 = &can2;
mmc0 = &emmc;
mmc1 = &sdhci0;
serial0 = &uart0;
serial1 = &uart1;
serial2 = &uart2;
serial3 = &uart3;
serial4 = &uart4;
serial5 = &uart5;
serial6 = &uart6;
serial7 = &uart7;
serial8 = &uart8;
serial9 = &uart9;
spi0 = &qspi0;
spi1 = &qspi1;
spi2 = &spi0;
spi3 = &spi1;
pcie3x4 = &dm3x4;
pcie3x1 = &rp3x1;
};
/* The first 2M will be reserved in the Kernel, and the entire available range is set here */
memory@0 {
device_type = "memory";
reg = <0x00 0x80000000 0x01 0x00000000>; /* 4G - 64MB */
numa-node-id = <0>;
};
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
linux,cma {
compatible = "shared-dma-pool";
reusable;
size = <0x00 0x40000000>;
alloc-ranges = <0x00 0x90000000 0x00 0x40000000>;
linux,cma-default;
};
memory@1c000000 {
reg = <0x00 0x1c000000 0x00 0x2000000>;
no-map;
};
framebuffer: framebuffer@10000000 {
reg = <0x01 0x00 0x00 0x5000000>;
no-map;
};
npu_mmu_memory@130000000 {
reg = <0x01 0x30000000 0x00 0x04000000>;
no-map;
};
memblock-memory@17b800000 {
reg = <0x01 0x7b800000 0x00 0x04000000>;
no-map;
};
};
Sound_Card@0 {
compatible = "simple-audio-card";
simple-audio-card,name = "Sound-Card-I2S0";
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
SOUND_CARD_LINK(0, i2s, i2s0, 0, es8156_dac0, 0); /* I2S0 <-> es8156_dac0 */
SOUND_CARD_LINK(1, i2s, i2s0, 0, es7210_adc0, 0); /* I2S0 <-> es7210_adc0 */
};
Sound_Card@1 {
compatible = "simple-audio-card";
simple-audio-card,name = "Sound-Card-I2S1";
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
simple-audio-card,widgets = "Speaker", "Speaker";
simple-audio-card,routing =
"Speaker", "AW87565_PA2 VO",
"AW87565_PA2 IN", "ES8156_DAC1 LOUT";
simple-audio-card,aux-devs = <&audio_aw87565_pa2>;
SOUND_CARD_LINK(0, i2s, i2s1, 0, es8156_dac1, 0);
SOUND_CARD_LINK(1, i2s, i2s1, 0, es7210_adc1, 0);
};
/* The bootargs in U-Boot will override the configuration set here. */
chosen {
stdout-path = "serial4";
};
};
&aon_padctrl {
rtc_pins: rtc {
rtc-pins {
pins = "AOGPIO0_27";
function = "aogpio0";
bias-disable;
drive-strength = <13>;
input-enable;
input-schmitt-disable;
slew-rate = <0>;
};
};
aoi2c1_pins: aoi2c1-0 {
i2c-pins {
pins = "AOI2C1_SCL", "AOI2C1_SDA";
function = "aoi2c1";
bias-disable;
drive-strength = <7>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
};
&peri1_padctrl {
gmac0_pins: gmac0-0 {
txclk-pins {
pins = "GPIO0_0", /* GMAC0_TX_CLK */
"GPIO0_12"; /* GMAC0_MDC */
function = "gmac0";
bias-disable;
drive-strength = <13>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
tx-pins {
pins = "GPIO0_2", /* GMAC0_TXEN */
"GPIO0_3", /* GMAC0_TXD0 */
"GPIO0_4", /* GMAC0_TXD1 */
"GPIO0_5", /* GMAC0_TXD2 */
"GPIO0_6"; /* GMAC0_TXD3 */
function = "gmac0";
bias-disable;
drive-strength = <20>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
rx-pins {
pins = "GPIO0_1", /* GMAC0_RX_CLK */
"GPIO0_7", /* GMAC0_RXDV */
"GPIO0_8", /* GMAC0_RXD0 */
"GPIO0_9", /* GMAC0_RXD1 */
"GPIO0_10", /* GMAC0_RXD2 */
"GPIO0_11", /* GMAC0_RXD3 */
"GPIO0_13"; /* GMAC0_MDIO */
function = "gmac0";
bias-disable;
drive-strength = <13>;
input-enable;
input-schmitt-disable;
slew-rate = <0>;
};
};
i2s0_pins: i2s0-1 {
i2s-pins {
pins = "GPIO0_28", "GPIO0_29", "GPIO0_30", "GPIO0_31", "GPIO1_0";
function = "i2s0";
bias-disable;
drive-strength = <13>;
input-schmitt-disable;
slew-rate = <0>;
};
};
qspi0_pins: qspi0-0 {
qspi-pins {
pins = "GPIO0_18", "GPIO0_20", "GPIO0_21", "GPIO0_22", "GPIO0_23";
function = "qspi0";
bias-disable;
drive-strength = <13>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
can0_pins: can0-0 {
tx-pins {
pins = "GPIO0_25";
function = "can0";
bias-disable;
drive-strength = <5>;
input-disable;
input-schmitt-disable;
slew-rate = <1>;
};
rx-pins {
pins = "GPIO0_24";
function = "can0";
bias-disable;
drive-strength = <1>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
pcie_x1_pins: pcie_x1-1 {
pcie_x1-pins {
pins = "GPIO0_24", "GPIO0_25", "GPIO0_26", "GPIO0_27";
function = "pcie_x1";
bias-disable;
drive-strength = <7>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
pcie_x4_pins: pcie_x4-1 {
pcie_x4-pins {
pins = "GPIO0_28", "GPIO0_29", "GPIO0_31";
function = "pcie_x4";
bias-disable;
drive-strength = <7>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
gmac1_pins: gmac1-0 {
txclk-pins {
pins = "GPIO1_2", /* GMAC1_TX_CLK */
"GPIO1_14"; /* GMAC1_MDC */
function = "gmac1";
bias-disable;
drive-strength = <13>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
tx-pins {
pins = "GPIO1_4", /* GMAC1_TXEN */
"GPIO1_5", /* GMAC1_TXD0 */
"GPIO1_6", /* GMAC1_TXD1 */
"GPIO1_7", /* GMAC1_TXD2 */
"GPIO1_8"; /* GMAC1_TXD3 */
function = "gmac1";
bias-disable;
drive-strength = <20>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
rx-pins {
pins = "GPIO1_3", /* GMAC1_RX_CLK */
"GPIO1_9", /* GMAC1_RXDV */
"GPIO1_10", /* GMAC1_RXD0 */
"GPIO1_11", /* GMAC1_RXD1 */
"GPIO1_12", /* GMAC1_RXD2 */
"GPIO1_13", /* GMAC1_RXD3 */
"GPIO1_15"; /* GMAC1_MDIO */
function = "gmac1";
bias-disable;
drive-strength = <13>;
input-enable;
input-schmitt-disable;
slew-rate = <0>;
};
};
sdhci_pins: sdhci0-1 {
sd-pins {
pins = "GPIO1_1";
function = "sdio";
bias-disable;
drive-strength = <13>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
};
&peri2_padctrl {
uart4_pins: uart4-0 {
tx-pins {
pins = "GPIO2_0";
function = "uart4";
bias-disable;
drive-strength = <3>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
rx-pins {
pins = "GPIO2_1";
function = "uart4";
bias-disable;
drive-strength = <1>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
i2c5_pins: i2c5-1 {
i2c-pins {
pins = "GPIO2_28", "GPIO2_29";
function = "i2c5";
bias-disable;
drive-strength = <7>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
uart5_pins: uart5-1 {
tx-pins {
pins = "GPIO2_18", "GPIO3_10"; // TXD, RTSN
function = "uart5";
bias-disable;
drive-strength = <3>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
rx-pins {
pins = "GPIO2_19", "GPIO3_9"; // RXD, CTSN
function = "uart5";
bias-disable;
drive-strength = <1>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
i2c6_pins: i2c6-1 {
i2c-pins {
pins = "GPIO2_8", "GPIO2_9";
function = "i2c6";
bias-disable;
drive-strength = <7>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
i2s1_pins: i2s1-0 {
i2s-pins {
pins = "GPIO2_2", "GPIO2_3", "GPIO2_4", "GPIO2_5", "GPIO2_6";
function = "i2s1";
bias-disable;
drive-strength = <13>;
input-schmitt-disable;
slew-rate = <0>;
};
};
i2c7_pins: i2c7-0 {
i2c-pins {
pins = "GPIO2_10", "GPIO2_11";
function = "i2c7";
bias-disable;
drive-strength = <7>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
i2c4_pins: i2c4-2 {
i2c-pins {
pins = "GPIO2_26", "GPIO2_27";
function = "i2c4";
bias-disable;
drive-strength = <7>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
pwm1_pins: pwm1-1 {
pwm1-pins {
pins = "GPIO2_12"; // PWM1_CH2
function = "pwm1";
bias-disable;
drive-strength = <13>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
};
hdmi_pins: hdmi-0 {
hdmi-pins {
pins = "GPIO2_25", "GPIO2_30", "GPIO2_31";
function = "hdmi";
bias-disable;
drive-strength = <3>;
input-enable;
input-schmitt-disable;
slew-rate = <0>;
};
};
sen_vclk_pins: sen_vclk-1 {
sen_vclk-pins {
pins = "GPIO3_0", "GPIO3_1";
function = "sen_vclk";
bias-disable;
drive-strength = <7>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
uart8_pins: uart8-1 {
tx-pins {
pins = "GPIO3_2"; // TXD
function = "uart8";
bias-disable;
drive-strength = <3>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
rx-pins {
pins = "GPIO3_3"; // RXD
function = "uart8";
bias-disable;
drive-strength = <1>;
input-enable;
input-schmitt-enable;
slew-rate = <0>;
};
};
};
&gmac0 {
phy-mode = "rgmii-id";
pinctrl-names = "default";
pinctrl-0 = <&gmac0_pins>;
rx-clk-delay = <0x00>; /* for RGMII */
tx-clk-delay = <0x00>; /* for RGMII */
phy-handle = <&phy0>;
};
&mdio0 {
phy0: ethernet-phy@0 {
reg = <0x0>;
};
};
&gmac1 {
phy-mode = "rgmii-id";
pinctrl-names = "default";
pinctrl-0 = <&gmac1_pins>;
phy-handle = <&phy1>;
};
&mdio1 {
phy1: ethernet-phy@1 {
reg = <0x0>;
};
};
&qspi0 {
cs-gpios = <&gpio0_porta 19 0>;
rx-sample-dly = <2>;
spi-swap-data = <1>;
spi-max-frequency = <55000000>;
pinctrl-names = "default";
pinctrl-0 = <&qspi0_pins>;
spi_norflash@0 {
compatible = "jedec,spi-nor";
spi-max-frequency = <55000000>;
#address-cells = <1>;
#size-cells = <1>;
spi-tx-bus-width = <4>;
spi-rx-bus-width = <4>;
reg = <0>;
status = "okay";
};
};
&i2c4 {
pinctrl-names = "default";
pinctrl-0 = <&i2c4_pins>;
clock-frequency = <400000>;
pcf8563: rtc@51 {
pinctrl-names = "default";
pinctrl-0 = <&rtc_pins>;
compatible = "nxp,pcf8563";
reg = <0x51>;
};
};
&i2c5 {
pinctrl-names = "default";
pinctrl-0 = <&i2c5_pins>;
clock-frequency = <400000>;
codec_es8156_dac0: es8156@8 {
compatible = "everest,es8156";
reg = <0x8>;
#sound-dai-cells = <1>;
sound-name-prefix = "ES8156_DAC0";
mclk-sclk-ratio = <4>;
status = "disabled";
};
codec_es7210_adc0: es7210@40 {
compatible = "MicArray_0";
reg = <0x40>;
#sound-dai-cells = <1>;
work-mode = "ES7210_NORMAL_I2S";
channels-max = <2>;
mclk-sclk-ratio = <4>;
sound-name-prefix = "ES7210_ADC0";
status = "disabled";
};
codec_es8156_dac1: es8156@9 {
compatible = "everest,es8156";
reg = <0x9>;
#sound-dai-cells = <1>;
sound-name-prefix = "ES8156_DAC1";
mclk-sclk-ratio = <4>;
status = "okay";
};
codec_es7210_adc1: es7210@41 {
compatible = "MicArray_0";
reg = <0x41>;
#sound-dai-cells = <1>;
work-mode = "ES7210_NORMAL_I2S";
channels-max = <2>;
mclk-sclk-ratio = <4>;
sound-name-prefix = "ES7210_ADC1";
status = "okay";
};
audio_aw87565_pa2: audio_pa2@5b {
compatible = "awinic,aw87565_pa";
reg = <0x5b>;
sound-name-prefix = "AW87565_PA2";
reset-gpios = <&aw9535_0 8 GPIO_ACTIVE_LOW>;
status = "okay";
};
};
&i2c6 {
pinctrl-names = "default";
pinctrl-0 = <&i2c6_pins>;
clock-frequency = <400000>;
};
&i2c7 {
pinctrl-names = "default";
pinctrl-0 = <&i2c7_pins>;
clock-frequency = <400000>;
};
&aoi2c1 {
pinctrl-names = "default";
pinctrl-0 = <&aoi2c1_pins>;
clock-frequency = <400000>;
status = "okay";
aw9535_0: gpio@20 {
compatible = "awinic,aw9535";
reg = <0x20>;
gpio-controller;
#gpio-cells = <2>;
ngpios = <16>;
interrupt-parent = <&ao_gpio1>;
interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
gpio-line-names =
"CSI1_PWDN_IO0", "CSI1_RST_IO1", "CSI1_FSIN_IO2", "CSI0_PWDN_IO3", // index 0..3
"CSI0_RST_IO4", "CSI0_FSIN_IO5", "PCIE_X1_PRSNT_L_IO6", "PCIE_X4_PRSNT_L_IO7", // index 4..7
"AUDIO1_PARST0_IO8", "AUDIO_ADC1_INT_IO9", "AUDIO_ADC0_INT_IO10", "HP_CTL_H_IO11", // index 8..11
"SIT91211_SSC_EN_IO12","DISP_RST_IO13","SWITCH3_SEL_IO14","SWITCH1_SEL_IO15"; // index 12..15
};
aw9535_1: gpio@21 {
compatible = "awinic,aw9535";
reg = <0x21>;
gpio-controller;
#gpio-cells = <2>;
ngpios = <16>;
gpio-line-names =
"PCIE_BAT_EN_IO0", "AUDIO_3V3_PWREN_IO1", "AUDIO_1V8_PWREN_IO2", "MIPI_CSI0_PWREN_IO3", // index 0..3
"MIPI_CSI1_PWREN_IO4", "MIPI_TP_PWREN_IO5", "PCIE_3V3_EN_IO6", "PCIE_12V_EN_IO7", // index 4..7
"USBCON_PWREN_IO8", "USBCON1_PWREN_IO9", "PCIE_3V3_AUX_EN_IO10", "SDIO_3V3_PWREN_IO11", // index 8..11
"SDIO_1V8_PWREN_IO12","SIT91211_3V3_EN_IO13","MIPI_DSI_PWREN_IO14","BL_EN_IO15"; // index 12..15
};
};
&uart4 {
pinctrl-names = "default";
pinctrl-0 = <&uart4_pins>;
};
&uart5 {
pinctrl-names = "default";
pinctrl-0 = <&uart5_pins>;
};
&uart8 {
pinctrl-names = "default";
pinctrl-0 = <&uart8_pins>;
};
&rp3x1 {
pinctrl-names = "default";
pinctrl-0 = <&pcie_x1_pins>;
};
&dm3x4 {
pinctrl-names = "default";
pinctrl-0 = <&pcie_x4_pins>;
pcie-bat-en-gpio = <&aw9535_1 0 GPIO_ACTIVE_HIGH>;
pcie-3v3-en-gpio = <&aw9535_1 6 GPIO_ACTIVE_HIGH>;
pcie-12v-en-gpio = <&aw9535_1 7 GPIO_ACTIVE_HIGH>;
pcie-clk-en-gpio = <&aw9535_1 13 GPIO_ACTIVE_HIGH>;
};
&audio_i2s0 {
pinctrl-names = "default";
pinctrl-0 = <&i2s0_pins>;
};
&audio_i2s1 {
pinctrl-names = "default";
pinctrl-0 = <&i2s1_pins>;
};
&adc {
vref-supply = <&reg_vref_1v8>;
#io-channel-cells = <1>;
sampling-frequency = <1000000>;
resolution = <12>;
};
&pwm1 {
pinctrl-names = "default";
pinctrl-0 = <&pwm1_pins>;
};
&can0 {
pinctrl-names = "default";
pinctrl-0 = <&can0_pins>;
};
&hdmi_tx {
pinctrl-names = "default";
pinctrl-0 = <&hdmi_pins>;
};
&vidmem {
memory-region = <&framebuffer>;
};
&emmc {
max-frequency = <196608000>;
non-removable;
mmc-ddr-1_8v;
mmc-hs200-1_8v;
mmc-hs400-1_8v;
cap-mmc-highspeed;
io_fixed_1v8;
is_emmc;
no-sdio;
no-sd;
pull_up;
bus-width = <8>;
};
&sdhci0 {
pinctrl-names = "default";
pinctrl-0 = <&sdhci_pins>;
max-frequency = <196608000>;
cap-sd-highspeed;
bus-width = <4>;
sd-uhs-sdr104;
no-sdio;
pull_up;
wprtn_ignore;
};
&usb2_0 {
status = "disabled";
};

View File

@@ -70,8 +70,10 @@ CONFIG_DNS_RESOLVER=y
CONFIG_CAN=m CONFIG_CAN=m
CONFIG_CAN_J1939=m CONFIG_CAN_J1939=m
CONFIG_CAN_ISOTP=m CONFIG_CAN_ISOTP=m
CONFIG_CFG80211=m CONFIG_CFG80211=y
CONFIG_MAC80211=m CONFIG_CFG80211_WEXT=y
CONFIG_MAC80211=y
CONFIG_RFKILL=y
# CONFIG_ETHTOOL_NETLINK is not set # CONFIG_ETHTOOL_NETLINK is not set
CONFIG_PCI=y CONFIG_PCI=y
CONFIG_PCIE_ZH=m CONFIG_PCIE_ZH=m
@@ -150,6 +152,9 @@ CONFIG_REALTEK_PHY=y
CONFIG_CAN_FLEXCAN=m CONFIG_CAN_FLEXCAN=m
CONFIG_IWLWIFI=m CONFIG_IWLWIFI=m
CONFIG_IWLMVM=m CONFIG_IWLMVM=m
# CONFIG_RTL_CARDS is not set
CONFIG_RTW88=m
CONFIG_RTW88_8822CS=m
CONFIG_INPUT_EVDEV=m CONFIG_INPUT_EVDEV=m
# CONFIG_INPUT_KEYBOARD is not set # CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set # CONFIG_INPUT_MOUSE is not set

View File

@@ -18,6 +18,7 @@
#include <linux/resource.h> #include <linux/resource.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/gpio/consumer.h>
#include "pcie-designware.h" #include "pcie-designware.h"
@@ -70,6 +71,10 @@ struct p100_plat_pcie {
void __iomem *cpr_base; void __iomem *cpr_base;
struct reset_control *pcie_rst; struct reset_control *pcie_rst;
struct reset_control *pcie_prst; struct reset_control *pcie_prst;
struct gpio_desc *pcie_bat_en;
struct gpio_desc *pcie_3v3_en;
struct gpio_desc *pcie_12v_en;
struct gpio_desc *pcie_clk_en;
}; };
struct p100_plat_pcie_of_data { struct p100_plat_pcie_of_data {
@@ -338,11 +343,56 @@ static int p100_plat_pcie_probe(struct platform_device *pdev)
p100_pcie_ipctrl_init(p100_plat_pcie); p100_pcie_ipctrl_init(p100_plat_pcie);
p100_pcie_wait_linkup(pdev, p100_plat_pcie); p100_pcie_wait_linkup(pdev, p100_plat_pcie);
p100_plat_pcie->pci->dbi_base = p100_plat_pcie->apb_base;
platform_set_drvdata(pdev, p100_plat_pcie); platform_set_drvdata(pdev, p100_plat_pcie);
switch (p100_plat_pcie->mode) { switch (p100_plat_pcie->mode) {
case DW_PCIE_RC_TYPE: case DW_PCIE_RC_TYPE:
/* Get GPIO descriptors for PCIe power control */
p100_plat_pcie->pcie_bat_en = devm_gpiod_get_optional(&pdev->dev,
"pcie-bat-en",
GPIOD_OUT_LOW);
if (IS_ERR(p100_plat_pcie->pcie_bat_en)) {
dev_err(&pdev->dev, "Failed to get pcie-bat-en GPIO\n");
return PTR_ERR(p100_plat_pcie->pcie_bat_en);
}
p100_plat_pcie->pcie_3v3_en = devm_gpiod_get_optional(&pdev->dev,
"pcie-3v3-en",
GPIOD_OUT_LOW);
if (IS_ERR(p100_plat_pcie->pcie_3v3_en)) {
dev_err(&pdev->dev, "Failed to get pcie-3v3-en GPIO\n");
return PTR_ERR(p100_plat_pcie->pcie_3v3_en);
}
p100_plat_pcie->pcie_12v_en = devm_gpiod_get_optional(&pdev->dev,
"pcie-12v-en",
GPIOD_OUT_LOW);
if (IS_ERR(p100_plat_pcie->pcie_12v_en)) {
dev_err(&pdev->dev, "Failed to get pcie-12v-en GPIO\n");
return PTR_ERR(p100_plat_pcie->pcie_12v_en);
}
p100_plat_pcie->pcie_clk_en = devm_gpiod_get_optional(&pdev->dev,
"pcie-clk-en",
GPIOD_OUT_LOW);
if (IS_ERR(p100_plat_pcie->pcie_clk_en)) {
dev_err(&pdev->dev, "Failed to get pcie-clk-en GPIO\n");
return PTR_ERR(p100_plat_pcie->pcie_clk_en);
}
if (p100_plat_pcie->pcie_bat_en)
gpiod_set_value(p100_plat_pcie->pcie_bat_en, 1);
if (p100_plat_pcie->pcie_3v3_en)
gpiod_set_value(p100_plat_pcie->pcie_3v3_en, 1);
if (p100_plat_pcie->pcie_12v_en)
gpiod_set_value(p100_plat_pcie->pcie_12v_en, 1);
if (p100_plat_pcie->pcie_clk_en)
gpiod_set_value(p100_plat_pcie->pcie_clk_en, 1);
p100_plat_pcie->pci->dbi_base = p100_plat_pcie->apb_base;
ret = p100_plat_add_pcie_port(p100_plat_pcie, pdev); ret = p100_plat_add_pcie_port(p100_plat_pcie, pdev);
if (ret < 0) if (ret < 0)
return ret; return ret;

View File

@@ -14,6 +14,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/usb/of.h> #include <linux/usb/of.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/gpio/consumer.h>
#include "core.h" #include "core.h"
#include "hcd.h" #include "hcd.h"
@@ -42,6 +43,8 @@ struct dwc2_zhihe {
void __iomem *usb20_blk_sysreg; void __iomem *usb20_blk_sysreg;
struct reset_control *usb0_phy_rst; struct reset_control *usb0_phy_rst;
struct reset_control *usb1_phy_rst; struct reset_control *usb1_phy_rst;
struct gpio_desc *usb20_pwren;
struct gpio_desc *usb21_pwren;
}; };
static int dwc2_zhihe_probe(struct platform_device *pdev) static int dwc2_zhihe_probe(struct platform_device *pdev)
@@ -117,6 +120,28 @@ static int dwc2_zhihe_probe(struct platform_device *pdev)
return ret; return ret;
} }
zhihe->usb20_pwren = devm_gpiod_get_optional(&pdev->dev,
"usb20-pwren",
GPIOD_OUT_LOW);
if (IS_ERR(zhihe->usb20_pwren)) {
dev_err(&pdev->dev, "Failed to get usb20-pwren GPIO\n");
return PTR_ERR(zhihe->usb20_pwren);
}
zhihe->usb21_pwren = devm_gpiod_get_optional(&pdev->dev,
"usb21-pwren",
GPIOD_OUT_LOW);
if (IS_ERR(zhihe->usb21_pwren)) {
dev_err(&pdev->dev, "Failed to get usb21-pwren GPIO\n");
return PTR_ERR(zhihe->usb21_pwren);
}
if (zhihe->usb20_pwren)
gpiod_set_value(zhihe->usb20_pwren, 1);
if (zhihe->usb21_pwren)
gpiod_set_value(zhihe->usb21_pwren, 1);
dev_info(dev, "ZHIHE DWC2 glue layer initialized\n"); dev_info(dev, "ZHIHE DWC2 glue layer initialized\n");
return 0; return 0;
} }

View File

@@ -18,6 +18,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/gpio/consumer.h>
#include "core.h" #include "core.h"
@@ -48,6 +49,7 @@ struct dwc3_zhihe {
void __iomem *c10phy_tca; void __iomem *c10phy_tca;
void __iomem *c10phy_sysreg; void __iomem *c10phy_sysreg;
void __iomem *dwc3_ctrl; void __iomem *dwc3_ctrl;
struct gpio_desc *pwren;
}; };
static int dwc3_zhihe_probe(struct platform_device *pdev) static int dwc3_zhihe_probe(struct platform_device *pdev)
@@ -158,6 +160,14 @@ static int dwc3_zhihe_probe(struct platform_device *pdev)
return ret; return ret;
} }
zhihe->pwren = devm_gpiod_get_optional(&pdev->dev, "typec-pwren", GPIOD_OUT_LOW);
if (IS_ERR(zhihe->pwren))
zhihe->pwren = NULL;
else if (zhihe->pwren)
gpiod_set_value(zhihe->pwren, 1);
else
dev_info(dev, "Type-C power enable GPIO not defined in device tree\n");
/* Update TX deemphasis parameters used in compliance mode, pattern 14 */ /* Update TX deemphasis parameters used in compliance mode, pattern 14 */
writel(0x10540, zhihe->dwc3_ctrl + DWC3_LCSR_TX_DEEMPH_2); writel(0x10540, zhihe->dwc3_ctrl + DWC3_LCSR_TX_DEEMPH_2);
devm_release_region(dev, dwc3_res.start, resource_size(&dwc3_res)); devm_release_region(dev, dwc3_res.start, resource_size(&dwc3_res));

View File

@@ -36,21 +36,20 @@
#include "aw87565.h" #include "aw87565.h"
/******************************************************************************* /*******************************************************************************
* aw87565 marco * aw87565 marco
******************************************************************************/ ******************************************************************************/
#define AW87565_I2C_NAME "aw87565_pa" #define AW87565_I2C_NAME "aw87565_pa"
#define AW87565_DRIVER_VERSION "v1.0.0" #define AW87565_DRIVER_VERSION "v1.0.0"
/******************************************************************************* /*******************************************************************************
* aw87565 variable * aw87565 variable
******************************************************************************/ ******************************************************************************/
struct aw87565 *aw87565;
struct aw87565_container *aw87565_spk_cnt; struct aw87565_container *aw87565_spk_cnt;
struct aw87565_container *aw87565_rcv_cnt; struct aw87565_container *aw87565_rcv_cnt;
/***************************************************************************** /*******************************************************************************
* i2c write and read * i2c write and read
****************************************************************************/ ******************************************************************************/
static int aw87565_i2c_write(struct aw87565 *aw87565, static int aw87565_i2c_write(struct aw87565 *aw87565,
unsigned char reg_addr, unsigned char reg_data) unsigned char reg_addr, unsigned char reg_data)
{ {
@@ -95,9 +94,9 @@ static int aw87565_i2c_read(struct aw87565 *aw87565,
} }
/******************************************************************************* /*******************************************************************************
* aw87565 control interface * aw87565 control interface
******************************************************************************/ ******************************************************************************/
unsigned char aw87565_audio_receiver(void) static unsigned char aw87565_audio_receiver(struct aw87565 *aw87565)
{ {
unsigned int i; unsigned int i;
unsigned int length; unsigned int length;
@@ -123,7 +122,7 @@ unsigned char aw87565_audio_receiver(void)
return 0; return 0;
} }
unsigned char aw87565_audio_speaker(void) static unsigned char aw87565_audio_speaker(struct aw87565 *aw87565)
{ {
unsigned int i; unsigned int i;
unsigned int length; unsigned int length;
@@ -149,7 +148,7 @@ unsigned char aw87565_audio_speaker(void)
return 0; return 0;
} }
unsigned char aw87565_audio_off(void) static unsigned char aw87565_audio_off(struct aw87565 *aw87565)
{ {
if (aw87565 == NULL) if (aw87565 == NULL)
return 2; return 2;
@@ -165,10 +164,15 @@ unsigned char aw87565_audio_off(void)
static ssize_t aw87565_get_reg(struct device *dev, static ssize_t aw87565_get_reg(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct aw87565 *aw87565;
ssize_t len = 0; ssize_t len = 0;
unsigned int i = 0; unsigned int i = 0;
unsigned char reg_val = 0; unsigned char reg_val = 0;
aw87565 = dev_get_drvdata(dev);
if (!aw87565)
return -EINVAL;
for (i = 0; i < AW87565_REG_MAX; i++) { for (i = 0; i < AW87565_REG_MAX; i++) {
aw87565_i2c_read(aw87565, i, &reg_val); aw87565_i2c_read(aw87565, i, &reg_val);
len += snprintf(buf+len, PAGE_SIZE-len, "reg:0x%02x=0x%02x\n", len += snprintf(buf+len, PAGE_SIZE-len, "reg:0x%02x=0x%02x\n",
@@ -180,8 +184,13 @@ static ssize_t aw87565_get_reg(struct device *dev,
static ssize_t aw87565_set_reg(struct device *dev, static ssize_t aw87565_set_reg(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len) struct device_attribute *attr, const char *buf, size_t len)
{ {
struct aw87565 *aw87565;
unsigned int databuf[2] = {0, 0}; unsigned int databuf[2] = {0, 0};
aw87565 = dev_get_drvdata(dev);
if (!aw87565)
return -EINVAL;
if (sscanf(buf, "%x %x", &databuf[0], &databuf[1]) == 2) if (sscanf(buf, "%x %x", &databuf[0], &databuf[1]) == 2)
aw87565_i2c_write(aw87565, databuf[0], databuf[1]); aw87565_i2c_write(aw87565, databuf[0], databuf[1]);
return len; return len;
@@ -190,7 +199,13 @@ static ssize_t aw87565_set_reg(struct device *dev,
static ssize_t aw87565_get_hwen(struct device *dev, static ssize_t aw87565_get_hwen(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct aw87565 *aw87565;
ssize_t len = 0; ssize_t len = 0;
aw87565 = dev_get_drvdata(dev);
if (!aw87565)
return -EINVAL;
len += snprintf(buf+len, PAGE_SIZE-len, "hwen: %d\n", len += snprintf(buf+len, PAGE_SIZE-len, "hwen: %d\n",
aw87565->hwen_flag); aw87565->hwen_flag);
return len; return len;
@@ -199,9 +214,14 @@ static ssize_t aw87565_get_hwen(struct device *dev,
static ssize_t aw87565_set_hwen(struct device *dev, static ssize_t aw87565_set_hwen(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len) struct device_attribute *attr, const char *buf, size_t len)
{ {
struct aw87565 *aw87565;
ssize_t ret; ssize_t ret;
unsigned int state; unsigned int state;
aw87565 = dev_get_drvdata(dev);
if (!aw87565)
return -EINVAL;
ret = kstrtouint(buf, 10, &state); ret = kstrtouint(buf, 10, &state);
if (ret) { if (ret) {
dev_err(&aw87565->i2c_client->dev, "%s: fail to change str to int\n", dev_err(&aw87565->i2c_client->dev, "%s: fail to change str to int\n",
@@ -227,21 +247,26 @@ static ssize_t aw87565_get_mode(struct device *cd,
static ssize_t aw87565_set_mode(struct device *dev, static ssize_t aw87565_set_mode(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len) struct device_attribute *attr, const char *buf, size_t len)
{ {
struct aw87565 *aw87565;
ssize_t ret; ssize_t ret;
unsigned int state; unsigned int state;
aw87565 = dev_get_drvdata(dev);
if (!aw87565)
return -EINVAL;
ret = kstrtouint(buf, 10, &state); ret = kstrtouint(buf, 10, &state);
ret = kstrtouint(buf, 10, &state); ret = kstrtouint(buf, 10, &state);
if (ret) if (ret)
goto out_strtoint; goto out_strtoint;
if (state == 0) if (state == 0)
aw87565_audio_off(); aw87565_audio_off(aw87565);
else if (state == 1) else if (state == 1)
aw87565_audio_speaker(); aw87565_audio_speaker(aw87565);
else if (state == 2) else if (state == 2)
aw87565_audio_receiver(); aw87565_audio_receiver(aw87565);
else else
aw87565_audio_off(); aw87565_audio_off(aw87565);
if (ret < 0) if (ret < 0)
goto out; goto out;
@@ -335,10 +360,10 @@ static int aw87565_power_event(struct snd_soc_dapm_widget *w,
if (SND_SOC_DAPM_EVENT_ON(event)) { if (SND_SOC_DAPM_EVENT_ON(event)) {
aw87565_hw_reset(pa); aw87565_hw_reset(pa);
/* Before widget power up: turn chip on, sync registers */ /* Before widget power up: turn chip on, sync registers */
aw87565_audio_speaker(); aw87565_audio_speaker(pa);
} else { } else {
/* After widget power down: turn chip off */ /* After widget power down: turn chip off */
aw87565_audio_off(); aw87565_audio_off(pa);
} }
return 0; return 0;
@@ -401,19 +426,18 @@ static int aw87565_i2c_probe(struct i2c_client *client)
struct device_node *node; struct device_node *node;
struct device_node *aw9535_node = NULL; struct device_node *aw9535_node = NULL;
int reg_val; int reg_val;
struct aw87565 *aw87565;
int ret = -1; int ret = -1;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, "%s: i2c check failed\n", __func__); dev_err(&client->dev, "%s: i2c check failed\n", __func__);
ret = -ENODEV; return -ENODEV;
goto exit_check_functionality_failed;
} }
aw87565 = aw87565 = devm_kzalloc(&client->dev, sizeof(struct aw87565), GFP_KERNEL);
devm_kzalloc(&client->dev, sizeof(struct aw87565), GFP_KERNEL);
if (aw87565 == NULL) { if (aw87565 == NULL) {
ret = -ENOMEM; dev_err(&client->dev, "Failed to alloc priv data: %d\n", ret);
goto exit_devm_kzalloc_failed; return -ENOMEM;
} }
aw87565->regmap = devm_regmap_init_i2c(client, &aw87565_regmap_config); aw87565->regmap = devm_regmap_init_i2c(client, &aw87565_regmap_config);
@@ -438,7 +462,7 @@ static int aw87565_i2c_probe(struct i2c_client *client)
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "%s: aw87565_read_chipid failed %d\n", dev_err(&client->dev, "%s: aw87565_read_chipid failed %d\n",
__func__, ret); __func__, ret);
goto exit_i2c_check_id_failed; return ret;
} }
/* 创建sysfs属性文件 */ /* 创建sysfs属性文件 */
@@ -452,17 +476,12 @@ static int aw87565_i2c_probe(struct i2c_client *client)
aw87565->rcv_cfg_update_flag = 0; aw87565->rcv_cfg_update_flag = 0;
return devm_snd_soc_register_component(&client->dev, &aw87565_component_driver, NULL, 0); return devm_snd_soc_register_component(&client->dev, &aw87565_component_driver, NULL, 0);
exit_i2c_check_id_failed:
devm_kfree(&client->dev, aw87565);
aw87565 = NULL;
exit_devm_kzalloc_failed:
exit_check_functionality_failed:
return ret;
} }
static void aw87565_i2c_remove(struct i2c_client *client) static void aw87565_i2c_remove(struct i2c_client *client)
{ {
struct aw87565 *aw87565 = i2c_get_clientdata(client);
if (aw87565->audio_parst0_desc) if (aw87565->audio_parst0_desc)
gpiod_put(aw87565->audio_parst0_desc); gpiod_put(aw87565->audio_parst0_desc);
return; return;

View File

@@ -161,11 +161,4 @@ struct aw87565 {
struct gpio_desc *audio_parst0_desc; struct gpio_desc *audio_parst0_desc;
}; };
/*******************************************************************************
* aw87565 functions
******************************************************************************/
unsigned char aw87565_audio_receiver(void);
unsigned char aw87565_audio_speaker(void);
unsigned char aw87565_audio_off(void);
#endif #endif

View File

@@ -18,6 +18,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/of_platform.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
@@ -27,6 +28,7 @@
#include <sound/initval.h> #include <sound/initval.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/regmap.h> #include <linux/regmap.h>
@@ -36,6 +38,7 @@
#define INVALID_GPIO -1 #define INVALID_GPIO -1
#define GPIO_LOW 0 #define GPIO_LOW 0
#define GPIO_HIGH 1 #define GPIO_HIGH 1
#define GPIO_MAX 16
#define es8156_DEF_VOL 0xBF #define es8156_DEF_VOL 0xBF
#define ES8156_VOL_MAX 0xBF #define ES8156_VOL_MAX 0xBF
/* /*
@@ -46,6 +49,12 @@
static struct snd_soc_component *es8156_codec; static struct snd_soc_component *es8156_codec;
static const struct es8156_gpio es8156_gpio[] = {
{ ES8156_GPIO_3V3_PWREN, "audio-3v3-pwren" },
{ ES8156_GPIO_1V8_PWREN, "audio-1v8-pwren" },
{ ES8156_GPIO_HP_CTL, "audio-hp-ctl"},
};
static const struct reg_default es8156_reg_defaults[] = { static const struct reg_default es8156_reg_defaults[] = {
{0x00, 0x1c}, {0x01, 0x20}, {0x02, 0x00}, {0x03, 0x01}, {0x00, 0x1c}, {0x01, 0x20}, {0x02, 0x00}, {0x03, 0x01},
{0x04, 0x00}, {0x05, 0x04}, {0x06, 0x11}, {0x07, 0x00}, {0x04, 0x00}, {0x05, 0x04}, {0x06, 0x11}, {0x07, 0x00},
@@ -71,6 +80,7 @@ struct es8156_priv {
int debounce_time; int debounce_time;
int hp_det_invert; int hp_det_invert;
struct delayed_work work; struct delayed_work work;
struct gpio_desc *audio_pw_desc[GPIO_MAX];
int spk_ctl_gpio; int spk_ctl_gpio;
int hp_det_gpio; int hp_det_gpio;
@@ -80,6 +90,7 @@ struct es8156_priv {
int pwr_count; int pwr_count;
u32 mclk_sclk_ratio; u32 mclk_sclk_ratio;
u32 mclk_src;
u32 suspend_reg_00; u32 suspend_reg_00;
u32 suspend_reg_01; u32 suspend_reg_01;
@@ -155,8 +166,6 @@ static const struct snd_kcontrol_new es8156_snd_controls[] = {
SOC_SINGLE_TLV("Master Playback Volume", ES8156_VOLUME_CONTROL_REG14, 0, SOC_SINGLE_TLV("Master Playback Volume", ES8156_VOLUME_CONTROL_REG14, 0,
ES8156_VOL_MAX, 0, dac_vol_tlv), ES8156_VOL_MAX, 0, dac_vol_tlv),
SOC_SINGLE("HP Switch",ES8156_ANALOG_SYS3_REG22,3,1,0), SOC_SINGLE("HP Switch",ES8156_ANALOG_SYS3_REG22,3,1,0),
}; };
@@ -200,12 +209,11 @@ static const struct snd_soc_dapm_widget es8156_dapm_widgets[] = {
/**************************************************/ /**************************************************/
#define MSMode_MasterSelOn 0 // SlaveMode:0, MasterMode:1 #define MSMode_MasterSelOn 0 // SlaveMode:0, MasterMode:1
static unsigned int Ratio = 64; // Ratio = MCLK/LRCK on board #define Ratio 64 // Ratio = MCLK/LRCK on board
#define Format NORMAL_I2S #define Format NORMAL_I2S
#define Format_Len Format_Len16 // data format #define Format_Len Format_Len16 // data format
#define SCLK_DIV 8 // SCLK_DIV = MCLK/SCLK #define SCLK_DIV 8 // SCLK_DIV = MCLK/SCLK
#define SCLK_INV 0 #define SCLK_INV 0
static unsigned int MCLK_SOURCE; // select MCLK source, MCLK_PIN or SCLK_PIN
#define EQ7bandOn 0 #define EQ7bandOn 0
#define VDDA_VOLTAGE VDDA_3V3 #define VDDA_VOLTAGE VDDA_3V3
#define DAC_Volume 191 // DAC digital gain #define DAC_Volume 191 // DAC digital gain
@@ -215,114 +223,111 @@ static unsigned int MCLK_SOURCE; // select MCLK source, MCLK_PIN or SCLK
static int es8156_init_regs(struct snd_soc_component *codec) static int es8156_init_regs(struct snd_soc_component *codec)
{ {
//struct es8156_priv *priv = snd_soc_component_get_drvdata(codec); struct es8156_priv *priv = snd_soc_component_get_drvdata(codec);
pr_debug("%s\n", __func__); unsigned int ratio = priv->mclk_sclk_ratio * Ratio;
unsigned int config_val = (priv->mclk_src << 7) + (SCLK_INV << 4) +
(EQ7bandOn << 3) + 0x04 + MSMode_MasterSelOn;
snd_soc_component_write(codec,0x02,(MCLK_SOURCE<<7) + (SCLK_INV<<4) + (EQ7bandOn<<3) + 0x04 + MSMode_MasterSelOn); pr_debug("%s\n", __func__);
snd_soc_component_write(codec,0x19,0x20);
if(DACHPModeOn == 0) // output from PA snd_soc_component_write(codec, 0x02, config_val);
{ snd_soc_component_write(codec, 0x19, 0x20);
snd_soc_component_write(codec,0x20,0x2A);
snd_soc_component_write(codec,0x21,0x3C);
snd_soc_component_write(codec,0x22,0x02);
snd_soc_component_write(codec,0x24,0x07);
snd_soc_component_write(codec,0x23,0x40 + (0x30*VDDA_VOLTAGE));
}
if(DACHPModeOn == 1) // output from headphone
{
snd_soc_component_write(codec,0x20,0x16);
snd_soc_component_write(codec,0x21,0x3F);
snd_soc_component_write(codec,0x22,0x0A);
snd_soc_component_write(codec,0x24,0x01);
snd_soc_component_write(codec,0x23,0xCA + (0x30*VDDA_VOLTAGE));
}
snd_soc_component_write(codec,0x0A,0x01);
snd_soc_component_write(codec,0x0B,0x01);
//snd_soc_component_write(codec,0x11,NORMAL_I2S + (Format_Len<<4));
if(Ratio == 1536) // Ratio=MCLK/LRCK=1536; 12M288/8K; 24M576/16K if (DACHPModeOn == 0) { // output from PA
{ snd_soc_component_write(codec, 0x20, 0x2A);
snd_soc_component_write(codec,0x01,0x26 - (0x03*EQ7bandOn)); // 1536 Ratio(MCLK/LRCK) snd_soc_component_write(codec, 0x21, 0x3C);
snd_soc_component_write(codec,0x09,0x00); // 1536 Ratio(MCLK/LRCK) snd_soc_component_write(codec, 0x22, 0x02);
snd_soc_component_write(codec,0x03,0x06); // LRCK H snd_soc_component_write(codec, 0x24, 0x07);
snd_soc_component_write(codec,0x04,0x00); // LRCK=MCLK/1536 snd_soc_component_write(codec, 0x23, 0x40 + (0x30 * VDDA_VOLTAGE));
snd_soc_component_write(codec,0x05,SCLK_DIV); // BCLK=MCLK/4 } else if (DACHPModeOn == 1) { // output from headphone
} snd_soc_component_write(codec, 0x20, 0x16);
if(Ratio == 1024) // Ratio=MCLK/LRCK=1024; 12M288/12K; 24M576/24K snd_soc_component_write(codec, 0x21, 0x3F);
{ snd_soc_component_write(codec, 0x22, 0x0A);
snd_soc_component_write(codec,0x01,0x24 - (0x02*EQ7bandOn)); // 256 Ratio(MCLK/LRCK) snd_soc_component_write(codec, 0x24, 0x01);
snd_soc_component_write(codec,0x09,0x00); // 256 Ratio(MCLK/LRCK) snd_soc_component_write(codec, 0x23, 0xCA + (0x30 * VDDA_VOLTAGE));
snd_soc_component_write(codec,0x03,0x04); // LRCK H }
snd_soc_component_write(codec,0x04,0x00); // LRCK=MCLK/256 snd_soc_component_write(codec, 0x0A, 0x01);
snd_soc_component_write(codec,0x05,SCLK_DIV); // BCLK=MCLK/4 snd_soc_component_write(codec, 0x0B, 0x01);
} // snd_soc_component_write(codec, 0x11, NORMAL_I2S + (Format_Len << 4));
if(Ratio == 768) // Ratio=MCLK/LRCK=768; 12M288/16K; 24M576/32K
{
snd_soc_component_write(codec,0x01,0x23 + (0x40*EQ7bandOn)); // 768 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x09,0x00); // 768 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x03,0x03); // LRCK H
snd_soc_component_write(codec,0x04,0x00); // LRCK=MCLK/768
snd_soc_component_write(codec,0x05,SCLK_DIV); // BCLK=MCLK/4
}
if(Ratio == 512) // Ratio=MCLK/LRCK=512; 12M288/24K; 24M576/48K
{
snd_soc_component_write(codec,0x01,0xC0 + 0x22 - (0x01*EQ7bandOn)); // 512 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x09,0x00); // 512 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x03,0x02); // LRCK H
snd_soc_component_write(codec,0x04,0x00); // LRCK=MCLK/512
snd_soc_component_write(codec,0x05,SCLK_DIV); //BCLK=MCLK/4
}
if(Ratio == 400) // Ratio=MCLK/LRCK=400; 19M2/48K
{ // DVDD must be 3.3V
snd_soc_component_write(codec,0x01,0x21 + (0x40*EQ7bandOn)); // 384 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x09,0x00); // 400 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x10,0x64); // 400 OSR
snd_soc_component_write(codec,0x03,0x01); // LRCK H
snd_soc_component_write(codec,0x04,0x90); // LRCK=MCLK/400
snd_soc_component_write(codec,0x05,SCLK_DIV); // BCLK=MCLK/4
}
if(Ratio == 384) // Ratio=MCLK/LRCK=384; 12M288/32K; 6M144/16K
{
snd_soc_component_write(codec,0x01,0x63 + (0x40*EQ7bandOn)); // 384 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x09,0x00); // 384 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x03,0x01); // LRCK H
snd_soc_component_write(codec,0x04,0x80); // LRCK=MCLK/384
snd_soc_component_write(codec,0x05,SCLK_DIV); // BCLK=MCLK/4
}
if(Ratio == 256) // Ratio=MCLK/LRCK=256; 12M288/48K
{
snd_soc_component_write(codec,0x01,0x21 + (0x40*EQ7bandOn)); // 256 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x09,0x00); // 256 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x03,0x01); // LRCK H
snd_soc_component_write(codec,0x04,0x00); // LRCK=MCLK/256
snd_soc_component_write(codec,0x05,SCLK_DIV); // BCLK=MCLK/4
}
if(Ratio == 128) // Ratio=MCLK/LRCK=128; 6M144/48K
{
snd_soc_component_write(codec,0x01,0x61 + (0x40*EQ7bandOn)); // 128 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x09,0x00); // 128 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x03,0x00); // LRCK H
snd_soc_component_write(codec,0x04,0x80); // LRCK=MCLK/128
snd_soc_component_write(codec,0x05,SCLK_DIV); // BCLK=MCLK/4
}
if(Ratio == 64) // Ratio=MCLK/LRCK=64; 3M072/48K
{
snd_soc_component_write(codec,0x01,0xE1); // 64 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x09,0x02); // 64 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x03,0x00); // LRCK H
snd_soc_component_write(codec,0x04,0x40); // LRCK=MCLK/64
snd_soc_component_write(codec,0x05,SCLK_DIV); // BCLK=MCLK/2
}
snd_soc_component_write(codec,0x0D,0x14); switch (ratio) {
snd_soc_component_write(codec,0x18,0x00); case 1536: // Ratio=MCLK/LRCK=1536; 12M288/8K; 24M576/16K
snd_soc_component_write(codec,0x08,0x3F); snd_soc_component_write(codec, 0x01, 0x26 - (0x03 * EQ7bandOn)); // 1536 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x00,0x02); snd_soc_component_write(codec, 0x09, 0x00); // 1536 Ratio(MCLK/LRCK)
snd_soc_component_write(codec,0x00,0x03); snd_soc_component_write(codec, 0x03, 0x06); // LRCK H
snd_soc_component_write(codec,0x25,0x20); snd_soc_component_write(codec, 0x04, 0x00); // LRCK=MCLK/1536
snd_soc_component_write(codec, 0x05, SCLK_DIV); // BCLK=MCLK/4
break;
case 1024: // Ratio=MCLK/LRCK=1024; 12M288/12K; 24M576/24K
snd_soc_component_write(codec, 0x01, 0x24 - (0x02 * EQ7bandOn)); // 1024 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x09, 0x00); // 1024 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x03, 0x04); // LRCK H
snd_soc_component_write(codec, 0x04, 0x00); // LRCK=MCLK/1024
snd_soc_component_write(codec, 0x05, SCLK_DIV); // BCLK=MCLK/4
break;
case 768: // Ratio=MCLK/LRCK=768; 12M288/16K; 24M576/32K
snd_soc_component_write(codec, 0x01, 0x23 + (0x40 * EQ7bandOn)); // 768 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x09, 0x00); // 768 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x03, 0x03); // LRCK H
snd_soc_component_write(codec, 0x04, 0x00); // LRCK=MCLK/768
snd_soc_component_write(codec, 0x05, SCLK_DIV); // BCLK=MCLK/4
break;
case 512: // Ratio=MCLK/LRCK=512; 12M288/24K; 24M576/48K
snd_soc_component_write(codec, 0x01, 0xC0 + 0x22 - (0x01 * EQ7bandOn)); // 512 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x09, 0x00); // 512 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x03, 0x02); // LRCK H
snd_soc_component_write(codec, 0x04, 0x00); // LRCK=MCLK/512
snd_soc_component_write(codec, 0x05, SCLK_DIV); //BCLK=MCLK/4
break;
case 400: // Ratio=MCLK/LRCK=400; 19M2/48K
// DVDD must be 3.3V
snd_soc_component_write(codec, 0x01, 0x21 + (0x40 * EQ7bandOn)); // 384 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x09, 0x00); // 400 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x10, 0x64); // 400 OSR
snd_soc_component_write(codec, 0x03, 0x01); // LRCK H
snd_soc_component_write(codec, 0x04, 0x90); // LRCK=MCLK/400
snd_soc_component_write(codec, 0x05, SCLK_DIV); // BCLK=MCLK/4
break;
case 384: // Ratio=MCLK/LRCK=384; 12M288/32K; 6M144/16K
snd_soc_component_write(codec, 0x01, 0x63 + (0x40 * EQ7bandOn)); // 384 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x09, 0x00); // 384 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x03, 0x01); // LRCK H
snd_soc_component_write(codec, 0x04, 0x80); // LRCK=MCLK/384
snd_soc_component_write(codec, 0x05, SCLK_DIV); // BCLK=MCLK/4
break;
case 256: // Ratio=MCLK/LRCK=256; 12M288/48K
snd_soc_component_write(codec, 0x01, 0x21 + (0x40 * EQ7bandOn)); // 256 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x09, 0x00); // 256 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x03, 0x01); // LRCK H
snd_soc_component_write(codec, 0x04, 0x00); // LRCK=MCLK/256
snd_soc_component_write(codec, 0x05, SCLK_DIV); // BCLK=MCLK/4
break;
case 128: // Ratio=MCLK/LRCK=128; 6M144/48K
snd_soc_component_write(codec, 0x01, 0x61 + (0x40 * EQ7bandOn)); // 128 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x09, 0x00); // 128 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x03, 0x00); // LRCK H
snd_soc_component_write(codec, 0x04, 0x80); // LRCK=MCLK/128
snd_soc_component_write(codec, 0x05, SCLK_DIV); // BCLK=MCLK/4
break;
case 64: // Ratio=MCLK/LRCK=64; 3M072/48K
snd_soc_component_write(codec, 0x01, 0xE1); // 64 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x09, 0x02); // 64 Ratio(MCLK/LRCK)
snd_soc_component_write(codec, 0x03, 0x00); // LRCK H
snd_soc_component_write(codec, 0x04, 0x40); // LRCK=MCLK/64
snd_soc_component_write(codec, 0x05, SCLK_DIV); // BCLK=MCLK/2
break;
default:
break;
}
return 0; snd_soc_component_write(codec, 0x0D, 0x14);
snd_soc_component_write(codec, 0x18, 0x00);
snd_soc_component_write(codec, 0x08, 0x3F);
snd_soc_component_write(codec, 0x00, 0x02);
snd_soc_component_write(codec, 0x00, 0x03);
snd_soc_component_write(codec, 0x25, 0x20);
return 0;
} }
static int es8156_init_sequence(struct snd_soc_component *codec) static int es8156_init_sequence(struct snd_soc_component *codec)
@@ -345,9 +350,7 @@ static const struct snd_soc_dapm_route es8156_dapm_routes[] = {
{"DACL",NULL,"Channel Select Mux"}, {"DACL",NULL,"Channel Select Mux"},
{"DACR",NULL,"Channel Select Mux"}, {"DACR",NULL,"Channel Select Mux"},
{ "LOUT", NULL, "DACL" },
{ "LOUT", NULL, "DACL" },
{ "ROUT", NULL, "DACR" }, { "ROUT", NULL, "DACR" },
}; };
@@ -770,6 +773,7 @@ static int es8156_i2c_probe(struct i2c_client *i2c)
struct es8156_priv *es8156; struct es8156_priv *es8156;
int ret = -1; int ret = -1;
struct device_node *np = i2c->dev.of_node; struct device_node *np = i2c->dev.of_node;
int i;
#ifdef HP_DET_FUNTION #ifdef HP_DET_FUNTION
int hp_irq; int hp_irq;
enum of_gpio_flags flags; enum of_gpio_flags flags;
@@ -814,15 +818,20 @@ static int es8156_i2c_probe(struct i2c_client *i2c)
es8156->mclk_sclk_ratio = 1; es8156->mclk_sclk_ratio = 1;
} }
Ratio *= es8156->mclk_sclk_ratio; if (es8156->mclk_sclk_ratio == 1)
es8156->mclk_src = SCLK_PIN;
if (es8156->mclk_sclk_ratio == 1) { else
MCLK_SOURCE = SCLK_PIN; es8156->mclk_src = MCLK_PIN;
} else {
MCLK_SOURCE = MCLK_PIN;
}
i2c_set_clientdata(i2c, es8156); i2c_set_clientdata(i2c, es8156);
for (i = 0; i < ARRAY_SIZE(es8156_gpio); i++) {
es8156->audio_pw_desc[i] = devm_gpiod_get_optional(&i2c->dev,
es8156_gpio[i].name, GPIOD_OUT_HIGH);
if (es8156->audio_pw_desc[i])
gpiod_set_value_cansleep(es8156->audio_pw_desc[i], 1);
}
#ifdef HP_DET_FUNTION #ifdef HP_DET_FUNTION
es8156->spk_ctl_gpio = of_get_named_gpio_flags(np, es8156->spk_ctl_gpio = of_get_named_gpio_flags(np,
"spk-con-gpio", "spk-con-gpio",

View File

@@ -77,9 +77,16 @@ enum vmidlow {
VMIDLEVEL3, VMIDLEVEL3,
}; };
#define ES8156_3V3 0 enum es8156_gpio_id {
#define ES8156_1V8 1 ES8156_GPIO_3V3_PWREN = 0,
#define ES8156_DVDD ES8156_1V8 ES8156_GPIO_1V8_PWREN,
ES8156_GPIO_HP_CTL,
ES8156_GPIO_BUTTON = ES8156_GPIO_HP_CTL,
};
struct es8156_gpio {
int id;
const char *name;
};
#endif #endif