Bug #145 » inno_for_sb35_rity-kirkstone-v23.0-v001.patch
src/meta-mediatek-bsp/classes/image_type_aiotflash.bbclass 2023-06-06 14:42:15.379971818 +0800 → src/meta-mediatek-bsp/classes/image_type_aiotflash.bbclass 2023-06-06 11:40:50.464905651 +0800 | ||
---|---|---|
44 | 44 |
cp -a ${DEPLOY_DIR_IMAGE}/rity.json ${tmp_pack_dir} |
45 | 45 |
cp -a ${DEPLOY_DIR_IMAGE}/partitions.json ${tmp_pack_dir} |
46 | 46 |
cp -a ${DEPLOY_DIR_IMAGE}/lk.bin ${tmp_pack_dir} |
47 |
cp -a ${DEPLOY_DIR_IMAGE}/devicetree ${tmp_pack_dir} |
|
47 | 48 | |
48 | 49 |
if [ "${@oe.utils.conditional('BL2_SIGN_ENABLE', '1', '1', '', d)}" = "1" ]; then |
49 | 50 |
cp -a ${DEPLOY_DIR_IMAGE}/efuse.cfg ${tmp_pack_dir} |
src/meta-mediatek-bsp/conf/machine/mt8365-sb35.conf 2023-06-06 14:42:15.383971808 +0800 → src/meta-mediatek-bsp/conf/machine/mt8365-sb35.conf 2023-06-06 11:40:50.464905651 +0800 | ||
---|---|---|
5 | 5 |
KERNEL_DEVICETREE = "mediatek/mt8365-sb35.dtb" |
6 | 6 | |
7 | 7 |
# U-Boot |
8 |
UBOOT_MACHINE = "mt8365_pumpkin_defconfig"
|
|
8 |
UBOOT_MACHINE = "mt8365_sb35_defconfig"
|
|
9 | 9 | |
10 | 10 |
# libdram |
11 | 11 |
LIBDRAM_BOARD_NAME = "mt8365-sb35" |
12 | 12 | |
13 |
MACHINE_FEATURES:append = " alsa usbgadget usbhost wifi" |
|
13 |
MACHINE_FEATURES:append = " alsa usbgadget usbhost wifi screen"
|
|
14 | 14 | |
15 | 15 |
MACHINEOVERRIDES =. "mt8365-sb35:i350-sb35:genio-350-sb35:" |
src/meta-mediatek-bsp/recipes-bsp/alsa-state/mt8365-sb35/asound.conf 2023-06-06 14:42:15.387971797 +0800 → src/meta-mediatek-bsp/recipes-bsp/alsa-state/mt8365-sb35/asound.conf 2023-06-06 11:40:50.468905742 +0800 | ||
---|---|---|
22 | 22 |
} |
23 | 23 |
} |
24 | 24 | |
25 |
pcm.speaker { |
|
26 |
type plug |
|
27 |
slave { |
|
28 |
pcm "hw:mtsndcard,1,0" |
|
29 |
channels 2 |
|
30 |
} |
|
31 |
} |
|
32 | ||
25 | 33 |
pcm.line { |
26 | 34 |
type asym |
27 | 35 |
playback.pcm "jack_speaker" |
src/meta-mediatek-bsp/recipes-bsp/alsa-state/mt8365-sb35/asound.state 2023-06-06 14:42:15.387971797 +0800 → src/meta-mediatek-bsp/recipes-bsp/alsa-state/mt8365-sb35/asound.state 2023-06-06 11:40:50.468905742 +0800 | ||
---|---|---|
12 | 12 |
control.2 { |
13 | 13 |
iface MIXER |
14 | 14 |
name 'O00 I07 Switch' |
15 |
value false
|
|
15 |
value true
|
|
16 | 16 |
comment { |
17 | 17 |
access 'read write' |
18 | 18 |
type BOOLEAN |
... | ... | |
32 | 32 |
control.4 { |
33 | 33 |
iface MIXER |
34 | 34 |
name 'O01 I08 Switch' |
35 |
value false
|
|
35 |
value true
|
|
36 | 36 |
comment { |
37 | 37 |
access 'read write' |
38 | 38 |
type BOOLEAN |
src/meta-mediatek-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-mtk_2.6.inc 2023-06-06 14:42:15.391971786 +0800 → src/meta-mediatek-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-mtk_2.6.inc 2023-06-06 11:40:50.472905833 +0800 | ||
---|---|---|
5 | 5 |
" |
6 | 6 | |
7 | 7 |
SRC_URI = "${AIOT_BSP_URI}/trusted-firmware-a.git;name=tfa;branch=mtk-v2.6;protocol=ssh" |
8 |
SRCREV_tfa = "739772abf2fea0ffa8ea68613a9ea4ebe7c1af47"
|
|
8 |
SRCREV_tfa = "31d4d84a48551686f5ae1916c8fb6416ca16a83b"
|
|
9 | 9 | |
10 | 10 |
SRC_URI += "file://rot_key.pem" |
src/meta-mediatek-bsp/recipes-bsp/u-boot/files/0001-Add-dedicated-sb35-defconfig-and-dts-files.patch 1970-01-01 08:00:00.000000000 +0800 → src/meta-mediatek-bsp/recipes-bsp/u-boot/files/0001-Add-dedicated-sb35-defconfig-and-dts-files.patch 2023-06-06 11:40:50.472905833 +0800 | ||
---|---|---|
1 |
From 05bb8f47e4d376d05f30ef95b170ac51aaac6478 Mon Sep 17 00:00:00 2001 |
|
2 |
From: Rockefeller Lin <rockefeller.lin@innocomm.com> |
|
3 |
Date: Wed, 24 May 2023 12:18:47 +0800 |
|
4 |
Subject: [PATCH 1/1] Add dedicated sb35 defconfig and dts files |
|
5 | ||
6 |
The defconfig and dts files are copied from mt8365-pumpkin. |
|
7 |
--- |
|
8 |
arch/arm/dts/Makefile | 1 + |
|
9 |
arch/arm/dts/mt8365-sb35.dts | 164 ++++++++++++++++++++++++++++++++++ |
|
10 |
configs/mt8365_sb35_defconfig | 97 ++++++++++++++++++++ |
|
11 |
3 files changed, 262 insertions(+) |
|
12 |
create mode 100644 arch/arm/dts/mt8365-sb35.dts |
|
13 |
create mode 100644 configs/mt8365_sb35_defconfig |
|
14 | ||
15 |
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile |
|
16 |
index 7b216bf62a..ac852fab60 100644 |
|
17 |
--- a/arch/arm/dts/Makefile |
|
18 |
+++ b/arch/arm/dts/Makefile |
|
19 |
@@ -1237,6 +1237,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ |
|
20 |
mt8195-demo.dtb \ |
|
21 |
mt8195-evb-ufs.dtb \ |
|
22 |
mt8365-pumpkin.dtb \ |
|
23 |
+ mt8365-sb35.dtb \ |
|
24 |
mt8512-bm1-emmc.dtb \ |
|
25 |
mt8516-pumpkin.dtb \ |
|
26 |
mt8518-ap1-emmc.dtb \ |
|
27 |
diff --git a/arch/arm/dts/mt8365-sb35.dts b/arch/arm/dts/mt8365-sb35.dts |
|
28 |
new file mode 100644 |
|
29 |
index 0000000000..5f57657026 |
|
30 |
--- /dev/null |
|
31 |
+++ b/arch/arm/dts/mt8365-sb35.dts |
|
32 |
@@ -0,0 +1,164 @@ |
|
33 |
+// SPDX-License-Identifier: GPL-2.0 OR MIT |
|
34 |
+/* |
|
35 |
+ * Copyright (C) 2021 BayLibre SAS. |
|
36 |
+ * Author: Fabien Parent <fparent@baylibre.com> |
|
37 |
+ */ |
|
38 |
+ |
|
39 |
+/dts-v1/; |
|
40 |
+ |
|
41 |
+#include <config.h> |
|
42 |
+#include "mt8365.dtsi" |
|
43 |
+#include "mt6357.dtsi" |
|
44 |
+ |
|
45 |
+/ { |
|
46 |
+ model = "MT8365 SB35 board"; |
|
47 |
+ compatible = "mediatek,mt8365-sb35", "mediatek,mt8365"; |
|
48 |
+ |
|
49 |
+ memory@40000000 { |
|
50 |
+ device_type = "memory"; |
|
51 |
+ reg = <0 0x40000000 0 0x40000000>; |
|
52 |
+ }; |
|
53 |
+ |
|
54 |
+ firmware: firmware { |
|
55 |
+ optee { |
|
56 |
+ compatible = "linaro,optee-tz"; |
|
57 |
+ method = "smc"; |
|
58 |
+ }; |
|
59 |
+ }; |
|
60 |
+ |
|
61 |
+ reserved-memory { |
|
62 |
+ #address-cells = <2>; |
|
63 |
+ #size-cells = <2>; |
|
64 |
+ ranges; |
|
65 |
+ |
|
66 |
+ /* 192 KiB reserved for ARM Trusted Firmware (BL31) */ |
|
67 |
+ bl31_secmon_reserved: secmon@43000000 { |
|
68 |
+ no-map; |
|
69 |
+ reg = <0 0x43000000 0 0x30000>; |
|
70 |
+ }; |
|
71 |
+ |
|
72 |
+ /* 12 MiB reserved for OP-TEE (BL32) |
|
73 |
+ * +-----------------------+ 0x43e0_0000 |
|
74 |
+ * | SHMEM 2MiB | |
|
75 |
+ * +-----------------------+ 0x43c0_0000 |
|
76 |
+ * | | TA_RAM 8MiB | |
|
77 |
+ * + TZDRAM +--------------+ 0x4340_0000 |
|
78 |
+ * | | TEE_RAM 2MiB | |
|
79 |
+ * +-----------------------+ 0x4320_0000 |
|
80 |
+ */ |
|
81 |
+ optee_reserved: optee@43200000 { |
|
82 |
+ no-map; |
|
83 |
+ reg = <0 0x43200000 0 0x00c00000>; |
|
84 |
+ }; |
|
85 |
+ }; |
|
86 |
+ |
|
87 |
+ chosen { |
|
88 |
+ stdout-path = &uart0; |
|
89 |
+ }; |
|
90 |
+}; |
|
91 |
+ |
|
92 |
+&uart0 { |
|
93 |
+ status = "okay"; |
|
94 |
+}; |
|
95 |
+ |
|
96 |
+&mmc0 { |
|
97 |
+ bus-width = <4>; |
|
98 |
+ max-frequency = <200000000>; |
|
99 |
+ cap-mmc-highspeed; |
|
100 |
+ mmc-hs200-1_8v; |
|
101 |
+ cap-mmc-hw-reset; |
|
102 |
+ vmmc-supply = <&mt6357_vemc_reg>; |
|
103 |
+ vqmmc-supply = <&mt6357_vio18_reg>; |
|
104 |
+ non-removable; |
|
105 |
+ status = "okay"; |
|
106 |
+}; |
|
107 |
+ |
|
108 |
+&usb { |
|
109 |
+ status = "okay"; |
|
110 |
+}; |
|
111 |
+ |
|
112 |
+&ssusb { |
|
113 |
+ mediatek,force-vbus; |
|
114 |
+ maximum-speed = "high-speed"; |
|
115 |
+ dr_mode = "peripheral"; |
|
116 |
+ status = "okay"; |
|
117 |
+}; |
|
118 |
+ |
|
119 |
+&dpi0 { |
|
120 |
+ dpi_dual_edge; |
|
121 |
+ pinctrl-names = "default", "sleep"; |
|
122 |
+ pinctrl-0 = <&dpi_pin_func>; |
|
123 |
+ pinctrl-1 = <&dpi_pin_gpio>; |
|
124 |
+ status = "okay"; |
|
125 |
+}; |
|
126 |
+ |
|
127 |
+&i2c0 { |
|
128 |
+ pinctrl-names = "default"; |
|
129 |
+ pinctrl-0 = <&i2c0_pins_default>; |
|
130 |
+ clock-frequency = <100000>; |
|
131 |
+ status = "okay"; |
|
132 |
+}; |
|
133 |
+ |
|
134 |
+&i2c1 { |
|
135 |
+ pinctrl-names = "default"; |
|
136 |
+ pinctrl-0 = <&i2c1_pins_default>; |
|
137 |
+ clock-frequency = <100000>; |
|
138 |
+ status = "okay"; |
|
139 |
+ |
|
140 |
+ it66121hdmitx { |
|
141 |
+ compatible = "ite,it66121"; |
|
142 |
+ reg = <0x4c>; |
|
143 |
+ pinctrl-names = "default"; |
|
144 |
+ pinctrl-0 = <&ite_pins_default>; |
|
145 |
+ vcn33-supply = <&mt6357_vcn33_bt_reg>; |
|
146 |
+ vcn18-supply = <&mt6357_vcn18_reg>; |
|
147 |
+ vrf12-supply = <&mt6357_vrf12_reg>; |
|
148 |
+ reset-gpios = <&gpio 69 GPIO_ACTIVE_LOW>; |
|
149 |
+ }; |
|
150 |
+}; |
|
151 |
+ |
|
152 |
+&i2c2 { |
|
153 |
+ pinctrl-names = "default"; |
|
154 |
+ pinctrl-0 = <&i2c2_pins_default>; |
|
155 |
+ clock-frequency = <100000>; |
|
156 |
+ status = "okay"; |
|
157 |
+}; |
|
158 |
+ |
|
159 |
+&pio { |
|
160 |
+ dpi_pin_func: dpi_pin_func { |
|
161 |
+ function = "dpi"; |
|
162 |
+ groups = "dpi_enable"; |
|
163 |
+ }; |
|
164 |
+ |
|
165 |
+ dpi_pin_gpio: dpi_pin_gpio { |
|
166 |
+ function = "dpi"; |
|
167 |
+ groups = "dpi_sleep"; |
|
168 |
+ }; |
|
169 |
+ |
|
170 |
+ i2c0_pins_default: i2c0_pins_default { |
|
171 |
+ function = "i2c"; |
|
172 |
+ groups = "i2c0"; |
|
173 |
+ }; |
|
174 |
+ |
|
175 |
+ i2c1_pins_default: i2c1_pins_default { |
|
176 |
+ function = "i2c"; |
|
177 |
+ groups = "i2c1"; |
|
178 |
+ }; |
|
179 |
+ |
|
180 |
+ i2c2_pins_default: i2c2_pins_default { |
|
181 |
+ function = "i2c"; |
|
182 |
+ groups = "i2c2"; |
|
183 |
+ }; |
|
184 |
+ |
|
185 |
+ ite_pins_default: ite_pins_default { |
|
186 |
+ pins_rst_ite { |
|
187 |
+ pinmux = <MT8365_PIN_69_CMDAT1__FUNC_GPIO69>; |
|
188 |
+ output-high; |
|
189 |
+ }; |
|
190 |
+ |
|
191 |
+ pins_irq_ite { |
|
192 |
+ pinmux = <MT8365_PIN_68_CMDAT0__FUNC_GPIO68>; |
|
193 |
+ input-enable; |
|
194 |
+ }; |
|
195 |
+ }; |
|
196 |
+}; |
|
197 |
diff --git a/configs/mt8365_sb35_defconfig b/configs/mt8365_sb35_defconfig |
|
198 |
new file mode 100644 |
|
199 |
index 0000000000..3c25705aab |
|
200 |
--- /dev/null |
|
201 |
+++ b/configs/mt8365_sb35_defconfig |
|
202 |
@@ -0,0 +1,97 @@ |
|
203 |
+CONFIG_ARM=y |
|
204 |
+CONFIG_COUNTER_FREQUENCY=13000000 |
|
205 |
+CONFIG_POSITION_INDEPENDENT=y |
|
206 |
+CONFIG_ARCH_MEDIATEK=y |
|
207 |
+CONFIG_SYS_TEXT_BASE=0x4c000000 |
|
208 |
+CONFIG_SYS_MALLOC_F_LEN=0x4000 |
|
209 |
+CONFIG_NR_DRAM_BANKS=1 |
|
210 |
+CONFIG_ENV_SIZE=0x1000 |
|
211 |
+CONFIG_ENV_OFFSET=0x0 |
|
212 |
+CONFIG_DM_GPIO=y |
|
213 |
+CONFIG_DEFAULT_DEVICE_TREE="mt8365-sb35" |
|
214 |
+CONFIG_TARGET_MT8365=y |
|
215 |
+CONFIG_DEBUG_UART_BASE=0x11002000 |
|
216 |
+CONFIG_DEBUG_UART_CLOCK=26000000 |
|
217 |
+CONFIG_SYS_LOAD_ADDR=0x4c000000 |
|
218 |
+CONFIG_DEBUG_UART=y |
|
219 |
+CONFIG_ENV_VARS_UBOOT_CONFIG=y |
|
220 |
+# CONFIG_ANDROID_BOOT_IMAGE is not set |
|
221 |
+CONFIG_FIT=y |
|
222 |
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set |
|
223 |
+CONFIG_USE_BOOTCOMMAND=y |
|
224 |
+CONFIG_BOOTCOMMAND="run distro_bootcmd" |
|
225 |
+CONFIG_DEFAULT_FDT_FILE="mt8365-sb35" |
|
226 |
+# CONFIG_DISPLAY_BOARDINFO is not set |
|
227 |
+CONFIG_HUSH_PARSER=y |
|
228 |
+# CONFIG_CMD_CONSOLE is not set |
|
229 |
+# CONFIG_CMD_BOOTD is not set |
|
230 |
+# CONFIG_CMD_ELF is not set |
|
231 |
+# CONFIG_CMD_GO is not set |
|
232 |
+# CONFIG_CMD_IMI is not set |
|
233 |
+# CONFIG_CMD_XIMG is not set |
|
234 |
+# CONFIG_CMD_CRC32 is not set |
|
235 |
+CONFIG_CMD_CLK=y |
|
236 |
+CONFIG_CMD_DFU=y |
|
237 |
+CONFIG_CMD_DM=y |
|
238 |
+CONFIG_CMD_GPT=y |
|
239 |
+# CONFIG_RANDOM_UUID is not set |
|
240 |
+CONFIG_CMD_I2C=y |
|
241 |
+# CONFIG_CMD_LOADB is not set |
|
242 |
+# CONFIG_CMD_LOADS is not set |
|
243 |
+CONFIG_CMD_MMC=y |
|
244 |
+CONFIG_CMD_PART=y |
|
245 |
+CONFIG_CMD_USB=y |
|
246 |
+CONFIG_CMD_USB_MASS_STORAGE=y |
|
247 |
+# CONFIG_CMD_ITEST is not set |
|
248 |
+CONFIG_CMD_DHCP=y |
|
249 |
+# CONFIG_CMD_BLOCK_CACHE is not set |
|
250 |
+CONFIG_CMD_SYSBOOT=y |
|
251 |
+CONFIG_CMD_EXT4=y |
|
252 |
+CONFIG_CMD_FAT=y |
|
253 |
+CONFIG_CMD_FS_GENERIC=y |
|
254 |
+CONFIG_ISO_PARTITION=y |
|
255 |
+CONFIG_ENV_IS_IN_MMC=y |
|
256 |
+CONFIG_SYS_MMC_ENV_PART=2 |
|
257 |
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y |
|
258 |
+CONFIG_ENV_IMPORT_FDT=y |
|
259 |
+CONFIG_DEVRES=y |
|
260 |
+CONFIG_CLK=y |
|
261 |
+CONFIG_DFU_MMC=y |
|
262 |
+CONFIG_USB_FUNCTION_FASTBOOT=y |
|
263 |
+CONFIG_FASTBOOT_BUF_ADDR=0x4d000000 |
|
264 |
+CONFIG_FASTBOOT_BUF_SIZE=0x8000000 |
|
265 |
+CONFIG_FASTBOOT_FLASH=y |
|
266 |
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0 |
|
267 |
+CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y |
|
268 |
+CONFIG_DM_I2C=y |
|
269 |
+CONFIG_SYS_I2C_MTK=y |
|
270 |
+# CONFIG_INPUT is not set |
|
271 |
+# CONFIG_MMC_QUIRKS is not set |
|
272 |
+CONFIG_MMC_MTK=y |
|
273 |
+CONFIG_PHY=y |
|
274 |
+CONFIG_PHY_MTK_TPHY=y |
|
275 |
+CONFIG_PINCTRL=y |
|
276 |
+CONFIG_PINCONF=y |
|
277 |
+CONFIG_PINCTRL_MT8365=y |
|
278 |
+CONFIG_DM_RTC=y |
|
279 |
+CONFIG_RTC_EMULATION=y |
|
280 |
+CONFIG_BAUDRATE=921600 |
|
281 |
+CONFIG_DM_SERIAL=y |
|
282 |
+CONFIG_DEBUG_UART_ANNOUNCE=y |
|
283 |
+CONFIG_MTK_SERIAL=y |
|
284 |
+CONFIG_USB=y |
|
285 |
+CONFIG_DM_USB_GADGET=y |
|
286 |
+CONFIG_USB_XHCI_HCD=y |
|
287 |
+CONFIG_USB_XHCI_MTK=y |
|
288 |
+CONFIG_USB_MTU3=y |
|
289 |
+CONFIG_USB_STORAGE=y |
|
290 |
+CONFIG_USB_KEYBOARD=y |
|
291 |
+CONFIG_USB_HOST_ETHER=y |
|
292 |
+CONFIG_USB_GADGET=y |
|
293 |
+CONFIG_USB_GADGET_VENDOR_NUM=0x0e8d |
|
294 |
+CONFIG_USB_GADGET_PRODUCT_NUM=0x201c |
|
295 |
+CONFIG_USB_ETHER=y |
|
296 |
+CONFIG_WDT=y |
|
297 |
+CONFIG_WDT_MTK=y |
|
298 |
+CONFIG_OF_LIBFDT_OVERLAY=y |
|
299 |
+CONFIG_LMB_MAX_REGIONS=16 |
|
300 |
-- |
|
301 |
2.25.1 |
|
302 |
src/meta-mediatek-bsp/recipes-bsp/u-boot/files/0001-Set-bootdelay-to-0-to-save-3secs-of-booting-time.patch 1970-01-01 08:00:00.000000000 +0800 → src/meta-mediatek-bsp/recipes-bsp/u-boot/files/0001-Set-bootdelay-to-0-to-save-3secs-of-booting-time.patch 2023-06-06 11:40:50.472905833 +0800 | ||
---|---|---|
1 |
From 6061bcfb8f1dfc47714beae179be4bc4e4223062 Mon Sep 17 00:00:00 2001 |
|
2 |
From: Rockefeller Lin <rockefeller.lin@innocomm.com> |
|
3 |
Date: Fri, 7 Apr 2023 03:29:44 +0000 |
|
4 |
Subject: [PATCH] Set bootdelay to 0 to save ~3secs of booting time |
|
5 | ||
6 |
Set bootdelay to 0 to save ~3secs of booting time |
|
7 |
--- |
|
8 |
configs/mt8365_sb35_defconfig | 1 + |
|
9 |
1 files changed, 1 insertions(+) |
|
10 | ||
11 |
diff --git a/configs/mt8365_sb35_defconfig b/configs/mt8365_sb35_defconfig |
|
12 |
index 204b97244b..ccf8c26892 100644 |
|
13 |
--- a/configs/mt8365_sb35_defconfig |
|
14 |
+++ b/configs/mt8365_sb35_defconfig |
|
15 |
@@ -96,3 +96,4 @@ CONFIG_WDT=y |
|
16 |
CONFIG_WDT_MTK=y |
|
17 |
CONFIG_OF_LIBFDT_OVERLAY=y |
|
18 |
CONFIG_LMB_MAX_REGIONS=16 |
|
19 |
+CONFIG_BOOTDELAY=0 |
|
20 |
-- |
|
21 |
2.25.1 |
|
22 |
src/meta-mediatek-bsp/recipes-bsp/u-boot/files/0002-Remove-DPI-and-it66121-from-sb35-dts.patch 1970-01-01 08:00:00.000000000 +0800 → src/meta-mediatek-bsp/recipes-bsp/u-boot/files/0002-Remove-DPI-and-it66121-from-sb35-dts.patch 2023-06-06 11:40:50.472905833 +0800 | ||
---|---|---|
1 |
From 29ec664a6ac95151a2967527c1a9d04603aa62c3 Mon Sep 17 00:00:00 2001 |
|
2 |
From: Rockefeller Lin <rockefeller.lin@innocomm.com> |
|
3 |
Date: Wed, 24 May 2023 12:57:31 +0800 |
|
4 |
Subject: [PATCH 1/1] Remove DPI and it66121 from sb35 dts |
|
5 | ||
6 |
The HDMI bridge on SB35 EVK is lt9611 and interface is DSI, so remove |
|
7 |
DPI and it66121 nodes. |
|
8 | ||
9 |
The lt9611 node is added but disable it because MTK DSI is still not supported yet. |
|
10 |
--- |
|
11 |
arch/arm/dts/mt8365-sb35.dts | 66 +++++++++++++++++++----------------- |
|
12 |
1 file changed, 35 insertions(+), 31 deletions(-) |
|
13 | ||
14 |
diff --git a/arch/arm/dts/mt8365-sb35.dts b/arch/arm/dts/mt8365-sb35.dts |
|
15 |
index 5f57657026..b645d276a6 100644 |
|
16 |
--- a/arch/arm/dts/mt8365-sb35.dts |
|
17 |
+++ b/arch/arm/dts/mt8365-sb35.dts |
|
18 |
@@ -84,14 +84,6 @@ |
|
19 |
status = "okay"; |
|
20 |
}; |
|
21 |
|
|
22 |
-&dpi0 { |
|
23 |
- dpi_dual_edge; |
|
24 |
- pinctrl-names = "default", "sleep"; |
|
25 |
- pinctrl-0 = <&dpi_pin_func>; |
|
26 |
- pinctrl-1 = <&dpi_pin_gpio>; |
|
27 |
- status = "okay"; |
|
28 |
-}; |
|
29 |
- |
|
30 |
&i2c0 { |
|
31 |
pinctrl-names = "default"; |
|
32 |
pinctrl-0 = <&i2c0_pins_default>; |
|
33 |
@@ -105,16 +97,15 @@ |
|
34 |
clock-frequency = <100000>; |
|
35 |
status = "okay"; |
|
36 |
|
|
37 |
- it66121hdmitx { |
|
38 |
- compatible = "ite,it66121"; |
|
39 |
+#if 0 |
|
40 |
+ lt9611hdmitx { |
|
41 |
+ compatible = "lontium,lt9611"; |
|
42 |
reg = <0x4c>; |
|
43 |
pinctrl-names = "default"; |
|
44 |
- pinctrl-0 = <&ite_pins_default>; |
|
45 |
- vcn33-supply = <&mt6357_vcn33_bt_reg>; |
|
46 |
- vcn18-supply = <&mt6357_vcn18_reg>; |
|
47 |
- vrf12-supply = <&mt6357_vrf12_reg>; |
|
48 |
- reset-gpios = <&gpio 69 GPIO_ACTIVE_LOW>; |
|
49 |
+ pinctrl-0 = <&hdmi_pins_default>; |
|
50 |
+ reset-gpios = <&gpio 20 GPIO_ACTIVE_LOW>; |
|
51 |
}; |
|
52 |
+#endif |
|
53 |
}; |
|
54 |
|
|
55 |
&i2c2 { |
|
56 |
@@ -125,16 +116,6 @@ |
|
57 |
}; |
|
58 |
|
|
59 |
&pio { |
|
60 |
- dpi_pin_func: dpi_pin_func { |
|
61 |
- function = "dpi"; |
|
62 |
- groups = "dpi_enable"; |
|
63 |
- }; |
|
64 |
- |
|
65 |
- dpi_pin_gpio: dpi_pin_gpio { |
|
66 |
- function = "dpi"; |
|
67 |
- groups = "dpi_sleep"; |
|
68 |
- }; |
|
69 |
- |
|
70 |
i2c0_pins_default: i2c0_pins_default { |
|
71 |
function = "i2c"; |
|
72 |
groups = "i2c0"; |
|
73 |
@@ -150,15 +131,38 @@ |
|
74 |
groups = "i2c2"; |
|
75 |
}; |
|
76 |
|
|
77 |
- ite_pins_default: ite_pins_default { |
|
78 |
- pins_rst_ite { |
|
79 |
- pinmux = <MT8365_PIN_69_CMDAT1__FUNC_GPIO69>; |
|
80 |
- output-high; |
|
81 |
+#if 0 |
|
82 |
+ hdmi_pins_default: hdmi_pins_default { |
|
83 |
+ pin_pwr_en { |
|
84 |
+ pinmux = <MT8365_PIN_4_GPIO4__FUNC_GPIO4>; |
|
85 |
+ output-low; |
|
86 |
}; |
|
87 |
|
|
88 |
- pins_irq_ite { |
|
89 |
- pinmux = <MT8365_PIN_68_CMDAT0__FUNC_GPIO68>; |
|
90 |
+ pin_lt9611_1v8_en { |
|
91 |
+ pinmux = <MT8365_PIN_19_DISP_PWM__FUNC_GPIO19>; |
|
92 |
+ output-low; |
|
93 |
+ }; |
|
94 |
+ |
|
95 |
+ pin_lt9611_rst { |
|
96 |
+ pinmux = <MT8365_PIN_20_LCM_RST__FUNC_GPIO20>; |
|
97 |
+ output-low; |
|
98 |
+ }; |
|
99 |
+ |
|
100 |
+ pin_lt9611_3v3_en { |
|
101 |
+ pinmux = <MT8365_PIN_21_DSI_TE__FUNC_GPIO21>; |
|
102 |
+ output-low; |
|
103 |
+ }; |
|
104 |
+ |
|
105 |
+ pin_lt9611_intr { |
|
106 |
+ pinmux = <MT8365_PIN_125_DMIC2_DAT1__FUNC_GPIO125>; |
|
107 |
input-enable; |
|
108 |
+ bias-pull-up; |
|
109 |
+ }; |
|
110 |
+ |
|
111 |
+ pin_dsi_sel { |
|
112 |
+ pinmux = <MT8365_PIN_2_GPIO2__FUNC_GPIO2>; |
|
113 |
+ output-low; |
|
114 |
}; |
|
115 |
}; |
|
116 |
+#endif |
|
117 |
}; |
|
118 |
-- |
|
119 |
2.25.1 |
|
120 |
src/meta-mediatek-bsp/recipes-bsp/u-boot/u-boot_git.bb 2023-06-06 14:42:15.391971786 +0800 → src/meta-mediatek-bsp/recipes-bsp/u-boot/u-boot_git.bb 2023-06-06 11:40:50.472905833 +0800 | ||
---|---|---|
4 | 4 |
SRC_URI += " \ |
5 | 5 |
file://0001-Revert-cmd-pxe_utils-Check-fdtcontroladdr-in-label_b.patch \ |
6 | 6 |
file://fw_env.config \ |
7 |
file://0001-Add-dedicated-sb35-defconfig-and-dts-files.patch \ |
|
8 |
file://0002-Remove-DPI-and-it66121-from-sb35-dts.patch \ |
|
9 |
file://0001-Set-bootdelay-to-0-to-save-3secs-of-booting-time.patch \ |
|
7 | 10 |
" |
src/meta-mediatek-bsp/recipes-kernel/dtbo/dtbo.bb 2023-06-06 14:42:15.391971786 +0800 → src/meta-mediatek-bsp/recipes-kernel/dtbo/dtbo.bb 2023-06-06 11:40:50.472905833 +0800 | ||
---|---|---|
99 | 99 | |
100 | 100 |
SRC_URI:append:mt8365-sb35 = " \ |
101 | 101 |
file://panel-raspberrypi.dts \ |
102 |
file://rs232.dts \ |
|
103 |
file://spidev.dts \ |
|
102 | 104 |
" |
103 | 105 | |
104 | 106 |
SRC_URI:append:mt8516-pumpkin = " \ |
src/meta-mediatek-bsp/recipes-kernel/dtbo/mt8365-sb35/rs232.dts 1970-01-01 08:00:00.000000000 +0800 → src/meta-mediatek-bsp/recipes-kernel/dtbo/mt8365-sb35/rs232.dts 2023-06-06 11:40:50.476905923 +0800 | ||
---|---|---|
1 |
/dts-v1/; |
|
2 |
/plugin/; |
|
3 | ||
4 |
#include <dt-bindings/gpio/gpio.h> |
|
5 |
#include <dt-bindings/pinctrl/mt8365-pinfunc.h> |
|
6 | ||
7 |
/ { |
|
8 |
fragment@0 { |
|
9 |
target = <&pio>; |
|
10 |
__overlay__ { |
|
11 |
rs232_pins: rs232-pins { |
|
12 |
pins_rx { |
|
13 |
pinmux = <MT8365_PIN_37_URXD1__FUNC_URXD1>; |
|
14 |
input-enable; |
|
15 |
bias-pull-up; |
|
16 |
}; |
|
17 |
pins_tx_cts_rts { |
|
18 |
pinmux = <MT8365_PIN_38_UTXD1__FUNC_UTXD1>, |
|
19 |
<MT8365_PIN_39_URXD2__FUNC_UCTS1>, |
|
20 |
<MT8365_PIN_40_UTXD2__FUNC_URTS1>; |
|
21 |
}; |
|
22 |
pins_rs232_shdn { |
|
23 |
pinmux = <MT8365_PIN_10_GPIO10__FUNC_GPIO10>; |
|
24 |
output-high; |
|
25 |
}; |
|
26 |
pins_rs232_en { |
|
27 |
pinmux = <MT8365_PIN_8_GPIO8__FUNC_GPIO8>; |
|
28 |
output-high; |
|
29 |
}; |
|
30 |
}; |
|
31 |
}; |
|
32 |
}; |
|
33 | ||
34 |
fragment@1 { |
|
35 |
target = <&uart1>; |
|
36 |
__overlay__ { |
|
37 |
pinctrl-0 = <&rs232_pins>; |
|
38 |
pinctrl-names = "default"; |
|
39 |
status = "okay"; |
|
40 |
}; |
|
41 |
}; |
|
42 |
}; |
src/meta-mediatek-bsp/recipes-kernel/dtbo/mt8365-sb35/spidev.dts 1970-01-01 08:00:00.000000000 +0800 → src/meta-mediatek-bsp/recipes-kernel/dtbo/mt8365-sb35/spidev.dts 2023-06-06 11:40:50.476905923 +0800 | ||
---|---|---|
1 |
/dts-v1/; |
|
2 |
/plugin/; |
|
3 | ||
4 |
#include <dt-bindings/gpio/gpio.h> |
|
5 |
#include <dt-bindings/pinctrl/mt8365-pinfunc.h> |
|
6 | ||
7 |
/ { |
|
8 |
fragment@0 { |
|
9 |
target = <&pio>; |
|
10 |
__overlay__ { |
|
11 |
spi_pins: spi-pins { |
|
12 |
pins { |
|
13 |
pinmux = <MT8365_PIN_8_GPIO8__FUNC_SPI_CLK>, |
|
14 |
<MT8365_PIN_9_GPIO9__FUNC_SPI_CSB>, |
|
15 |
<MT8365_PIN_10_GPIO10__FUNC_SPI_MI>, |
|
16 |
<MT8365_PIN_11_GPIO11__FUNC_SPI_MO>; |
|
17 |
bias-disable; |
|
18 |
}; |
|
19 |
}; |
|
20 |
}; |
|
21 |
}; |
|
22 | ||
23 |
fragment@1 { |
|
24 |
target = <&spi>; |
|
25 |
__overlay__ { |
|
26 |
pinctrl-0 = <&spi_pins>; |
|
27 |
pinctrl-names = "default"; |
|
28 |
mediatek,pad-select = <0>; |
|
29 |
status = "okay"; |
|
30 | ||
31 |
spidev@0 { |
|
32 |
compatible = "mediatek,aiot-board"; |
|
33 |
spi-max-frequency = <5000000>; |
|
34 |
reg = <0>; |
|
35 |
}; |
|
36 |
}; |
|
37 |
}; |
|
38 |
}; |
src/meta-mediatek-bsp/recipes-kernel/linux/linux-mtk/0001-Add-stereo-mode-support.patch 1970-01-01 08:00:00.000000000 +0800 → src/meta-mediatek-bsp/recipes-kernel/linux/linux-mtk/0001-Add-stereo-mode-support.patch 2023-06-06 11:40:50.480906014 +0800 | ||
---|---|---|
1 |
From f0a65dcb3dbd37388aa40250611fb07037eb3e97 Mon Sep 17 00:00:00 2001 |
|
2 |
From: Roy Chen <roy.chen@innocomm.com> |
|
3 |
Date: Fri, 26 May 2023 15:33:28 +0800 |
|
4 |
Subject: [PATCH] Add stereo mode support |
|
5 | ||
6 |
--- |
|
7 |
arch/arm64/boot/dts/mediatek/mt8365-sb35.dts | 23 ++++--- |
|
8 |
sound/soc/codecs/rt5509.c | 66 ++++++++++++++------ |
|
9 |
sound/soc/codecs/rt5509.h | 7 +++ |
|
10 |
sound/soc/mediatek/mt8365/mt8365-sb35.c | 14 ++++- |
|
11 |
4 files changed, 80 insertions(+), 30 deletions(-) |
|
12 | ||
13 |
diff --git a/arch/arm64/boot/dts/mediatek/mt8365-sb35.dts b/arch/arm64/boot/dts/mediatek/mt8365-sb35.dts |
|
14 |
index bae04d1ab18d..aa57f3444ea2 100644 |
|
15 |
--- a/arch/arm64/boot/dts/mediatek/mt8365-sb35.dts |
|
16 |
+++ b/arch/arm64/boot/dts/mediatek/mt8365-sb35.dts |
|
17 |
@@ -75,14 +75,19 @@ sound: sound { |
|
18 |
pinctrl-5 = <&aud_pins_dmic>; |
|
19 |
status = "okay"; |
|
20 |
|
|
21 |
- dai-link { |
|
22 |
- sound-dai = <&afe>; |
|
23 |
+ dai-link@0 { |
|
24 |
dai-link-name = "2ND I2S BE"; |
|
25 |
- |
|
26 |
- codec-0 { |
|
27 |
+ codec { |
|
28 |
sound-dai = <&speaker_amp_left>; |
|
29 |
}; |
|
30 |
}; |
|
31 |
+ |
|
32 |
+ dai-link@1 { |
|
33 |
+ dai-link-name = "2ND I2S BE 2"; |
|
34 |
+ codec { |
|
35 |
+ sound-dai = <&speaker_amp_right>; |
|
36 |
+ }; |
|
37 |
+ }; |
|
38 |
}; |
|
39 |
|
|
40 |
reserved-memory { |
|
41 |
@@ -321,17 +326,15 @@ speaker_amp_left:speaker_amp@34 { |
|
42 |
reg = <0x34>; |
|
43 |
status = "okay"; |
|
44 |
#sound-dai-cells = <0>; |
|
45 |
- rt5509,boost-mode = <1>; |
|
46 |
- rt5509,reg-settings = <0x1f 0x0352>; |
|
47 |
+ rt5509,lrs = "left"; |
|
48 |
}; |
|
49 |
|
|
50 |
speaker_amp_right:speaker_amp@35 { |
|
51 |
compatible = "richtek,rt5509"; |
|
52 |
reg = <0x35>; |
|
53 |
- status = "okay"; |
|
54 |
- #sound-dai-cells = <0>; |
|
55 |
- rt5509,boost-mode = <1>; |
|
56 |
- rt5509,reg-settings = <0x1f 0x0352>; |
|
57 |
+ status = "okay"; |
|
58 |
+ #sound-dai-cells = <0>; |
|
59 |
+ rt5509,lrs = "right"; |
|
60 |
}; |
|
61 |
|
|
62 |
hdmi-bridge@3b { |
|
63 |
diff --git a/sound/soc/codecs/rt5509.c b/sound/soc/codecs/rt5509.c |
|
64 |
index a641797e407e..a43e9d67cd64 100644 |
|
65 |
--- a/sound/soc/codecs/rt5509.c |
|
66 |
+++ b/sound/soc/codecs/rt5509.c |
|
67 |
@@ -2705,8 +2705,6 @@ static const struct snd_kcontrol_new rt5509_component_snd_controls[] = { |
|
68 |
rt5509_recv_model_put), |
|
69 |
SOC_SINGLE_EXT("Calib_Start", SND_SOC_NOPM, 0, 0, 0, |
|
70 |
rt5509_get_calib_flag, rt5509_put_calib_start), |
|
71 |
- |
|
72 |
- |
|
73 |
}; |
|
74 |
|
|
75 |
static const struct snd_kcontrol_new rt5509_component_snd2_controls[] = { |
|
76 |
@@ -2753,7 +2751,6 @@ static const struct snd_kcontrol_new rt5509_component_snd2_controls[] = { |
|
77 |
rt5509_recv_model_put), |
|
78 |
SOC_SINGLE_EXT("Ch2 Calib_Start", SND_SOC_NOPM, 0, 0, 0, |
|
79 |
rt5509_get_calib_flag, rt5509_put_calib_start), |
|
80 |
- |
|
81 |
}; |
|
82 |
|
|
83 |
static int rt5509_component_setting(struct snd_soc_component *component) |
|
84 |
@@ -3259,9 +3256,24 @@ static inline int rt5509_parse_dt(struct device *dev, |
|
85 |
struct device_node *param_np = NULL; |
|
86 |
struct property *prop = NULL; |
|
87 |
struct rt5509_proprietary_param *p_param = NULL; |
|
88 |
+ const char *left_right_sel; |
|
89 |
u32 len = 0; |
|
90 |
int i = 0; |
|
91 |
+ int ret = 0; |
|
92 |
|
|
93 |
+ ret = device_property_read_string(dev, "rt5509,lrs", &left_right_sel); |
|
94 |
+ if (ret >= 0) { |
|
95 |
+ if (strcmp(left_right_sel, "left") == 0) { |
|
96 |
+ pdata->left_right_sel = RT5509_LEFT_CHANNEL; |
|
97 |
+ } else if (strcmp(left_right_sel, "right") == 0) { |
|
98 |
+ pdata->left_right_sel = RT5509_RIGHT_CHANNEL; |
|
99 |
+ } else { |
|
100 |
+ pdata->left_right_sel = RT5509_LEFT_RIGHT_CHANNEL_MIXED; |
|
101 |
+ } |
|
102 |
+ } else { |
|
103 |
+ pdata->left_right_sel = RT5509_LEFT_RIGHT_CHANNEL_MIXED; |
|
104 |
+ } |
|
105 |
+ |
|
106 |
param_np = of_find_node_by_name(dev->of_node, "proprietary_param"); |
|
107 |
if (!param_np) |
|
108 |
goto OUT_PARSE_DT; |
|
109 |
@@ -3296,24 +3308,42 @@ static inline int rt5509_parse_dt(struct device *dev, |
|
110 |
} |
|
111 |
#endif /* #ifdef CONFIG_OF */ |
|
112 |
|
|
113 |
+static int rt5509_set_stereo_mode(const struct rt5509_chip *chip) { |
|
114 |
+ int ret = 0; |
|
115 |
+ u8 data = 0; |
|
116 |
+ |
|
117 |
+ if (chip->pdata->left_right_sel == RT5509_LEFT_CHANNEL) { |
|
118 |
+ data = 0x00; |
|
119 |
+ } else if (chip->pdata->left_right_sel == RT5509_RIGHT_CHANNEL) { |
|
120 |
+ data = 0x08; |
|
121 |
+ } else { |
|
122 |
+ // RT5509_LEFT_RIGHT_CHANNEL_MIXED |
|
123 |
+ data = 0x04; |
|
124 |
+ } |
|
125 |
+ |
|
126 |
+ ret = rt5509_block_write(chip->i2c, RT5509_REG_I2SSEL, 1, &data); |
|
127 |
+ if (ret < 0) { |
|
128 |
+ dev_err(chip->dev, "channel selection failed ret=%d\n", ret); |
|
129 |
+ } else { |
|
130 |
+ dev_info(chip->dev, "channel selection = %d\n", chip->pdata->left_right_sel); |
|
131 |
+ } |
|
132 |
+ |
|
133 |
+ return ret; |
|
134 |
+} |
|
135 |
|
|
136 |
static inline int rt5509_component_register(struct rt5509_chip *chip) |
|
137 |
{ |
|
138 |
- |
|
139 |
- if (chip->dev_cnt) |
|
140 |
- { |
|
141 |
- return devm_snd_soc_register_component(chip->dev, |
|
142 |
- &rt5509_component_driver2, |
|
143 |
- rt5509_ch2_i2s_dais, |
|
144 |
- ARRAY_SIZE(rt5509_ch2_i2s_dais)); |
|
145 |
- }else |
|
146 |
- { |
|
147 |
- return devm_snd_soc_register_component(chip->dev, |
|
148 |
- &rt5509_component_driver, |
|
149 |
- rt5509_i2s_dais, |
|
150 |
- ARRAY_SIZE(rt5509_i2s_dais)); |
|
151 |
+ if (chip->dev_cnt) { |
|
152 |
+ return devm_snd_soc_register_component(chip->dev, |
|
153 |
+ &rt5509_component_driver2, |
|
154 |
+ rt5509_ch2_i2s_dais, |
|
155 |
+ ARRAY_SIZE(rt5509_ch2_i2s_dais)); |
|
156 |
+ } else { |
|
157 |
+ return devm_snd_soc_register_component(chip->dev, |
|
158 |
+ &rt5509_component_driver, |
|
159 |
+ rt5509_i2s_dais, |
|
160 |
+ ARRAY_SIZE(rt5509_i2s_dais)); |
|
161 |
} |
|
162 |
- |
|
163 |
} |
|
164 |
|
|
165 |
static struct regmap_config rt5509_regmap_config = { |
|
166 |
@@ -3413,7 +3443,7 @@ int rt5509_i2c_probe(struct i2c_client *client, |
|
167 |
if(chip->dev_cnt==0) |
|
168 |
rt5509_cal_init(); |
|
169 |
|
|
170 |
- dev_info(chip->dev, "%s done\n", __func__); |
|
171 |
+ rt5509_set_stereo_mode(chip); |
|
172 |
return ret; |
|
173 |
|
|
174 |
probe_fail: |
|
175 |
diff --git a/sound/soc/codecs/rt5509.h b/sound/soc/codecs/rt5509.h |
|
176 |
index 203b8b2ceefc..1e0b63ae3599 100644 |
|
177 |
--- a/sound/soc/codecs/rt5509.h |
|
178 |
+++ b/sound/soc/codecs/rt5509.h |
|
179 |
@@ -36,6 +36,12 @@ enum { |
|
180 |
RT5509_CHIP_REVD, |
|
181 |
}; |
|
182 |
|
|
183 |
+enum { |
|
184 |
+ RT5509_LEFT_RIGHT_CHANNEL_MIXED, |
|
185 |
+ RT5509_LEFT_CHANNEL, |
|
186 |
+ RT5509_RIGHT_CHANNEL, |
|
187 |
+}; |
|
188 |
+ |
|
189 |
enum { |
|
190 |
RT5509_CFG_GENERAL, |
|
191 |
RT5509_CFG_BOOSTCONV, |
|
192 |
@@ -56,6 +62,7 @@ struct rt5509_proprietary_param { |
|
193 |
|
|
194 |
struct rt5509_pdata { |
|
195 |
struct rt5509_proprietary_param *p_param; |
|
196 |
+ int left_right_sel; |
|
197 |
}; |
|
198 |
|
|
199 |
struct rt5509_calib_classdev { |
|
200 |
diff --git a/sound/soc/mediatek/mt8365/mt8365-sb35.c b/sound/soc/mediatek/mt8365/mt8365-sb35.c |
|
201 |
index 27acef137e74..defdcf474fd5 100644 |
|
202 |
--- a/sound/soc/mediatek/mt8365/mt8365-sb35.c |
|
203 |
+++ b/sound/soc/mediatek/mt8365/mt8365-sb35.c |
|
204 |
@@ -67,6 +67,7 @@ enum { |
|
205 |
DAI_LINK_VUL_CAPTURE, |
|
206 |
/* BE */ |
|
207 |
DAI_LINK_2ND_I2S_INTF, |
|
208 |
+ DAI_LINK_2ND_I2S_INTF2, |
|
209 |
DAI_LINK_DMIC, |
|
210 |
DAI_LINK_INT_ADDA, |
|
211 |
DAI_LINK_NUM |
|
212 |
@@ -75,13 +76,11 @@ enum { |
|
213 |
static const struct snd_soc_dapm_widget mt8365_sb35_widgets[] = { |
|
214 |
SND_SOC_DAPM_MIC("PMIC MIC", NULL), |
|
215 |
SND_SOC_DAPM_HP("Headphone", NULL), |
|
216 |
- SND_SOC_DAPM_OUTPUT("HDMI Out"), |
|
217 |
}; |
|
218 |
|
|
219 |
static const struct snd_soc_dapm_route mt8365_sb35_routes[] = { |
|
220 |
{"Headphone", NULL, "MT6357 Playback"}, |
|
221 |
{"MT6357 Capture", NULL, "PMIC MIC"}, |
|
222 |
- {"HDMI Out", NULL, "2ND I2S Playback"}, |
|
223 |
}; |
|
224 |
|
|
225 |
static int mt8365_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
|
226 |
@@ -294,6 +293,17 @@ static struct snd_soc_dai_link mt8365_sb35_dais[] = { |
|
227 |
.dpcm_capture = 1, |
|
228 |
SND_SOC_DAILINK_REG(i2s3), |
|
229 |
}, |
|
230 |
+ [DAI_LINK_2ND_I2S_INTF2] = { |
|
231 |
+ .name = "2ND I2S BE 2", |
|
232 |
+ .no_pcm = 1, |
|
233 |
+ .id = DAI_LINK_2ND_I2S_INTF2, |
|
234 |
+ .dai_fmt = SND_SOC_DAIFMT_I2S | |
|
235 |
+ SND_SOC_DAIFMT_NB_NF | |
|
236 |
+ SND_SOC_DAIFMT_CBS_CFS, |
|
237 |
+ .dpcm_playback = 1, |
|
238 |
+ .dpcm_capture = 1, |
|
239 |
+ SND_SOC_DAILINK_REG(i2s3), |
|
240 |
+ }, |
|
241 |
[DAI_LINK_DMIC] = { |
|
242 |
.name = "DMIC BE", |
|
243 |
.no_pcm = 1, |
|
244 |
-- |
|
245 |
2.39.2 |
|
246 |
src/meta-mediatek-bsp/recipes-kernel/linux/linux-mtk/0001-Audio-RT5509-driver-porting.patch 1970-01-01 08:00:00.000000000 +0800 → src/meta-mediatek-bsp/recipes-kernel/linux/linux-mtk/0001-Audio-RT5509-driver-porting.patch 2023-06-06 11:40:50.480906014 +0800 | ||
---|---|---|
1 |
From 3d835508c8f0ba77af87f35cf976adfcdd6a81d4 Mon Sep 17 00:00:00 2001 |
|
2 |
From: Roy Chen <roy.chen@innocomm.com> |
|
3 |
Date: Tue, 23 May 2023 09:46:04 +0800 |
|
4 |
Subject: [PATCH] Audio RT5509 driver porting |
|
5 | ||
6 |
--- |
|
7 |
arch/arm64/boot/dts/mediatek/mt8365-sb35.dts | 25 +- |
|
8 |
sound/soc/codecs/Kconfig | 5 + |
|
9 |
sound/soc/codecs/Makefile | 3 + |
|
10 |
sound/soc/codecs/rt5509.c | 3483 ++++++++++++++++++ |
|
11 |
sound/soc/codecs/rt5509.h | 481 +++ |
|
12 |
sound/soc/mediatek/mt8365/mt8365-sb35.c | 33 +- |
|
13 |
6 files changed, 4024 insertions(+), 6 deletions(-) |
|
14 |
create mode 100644 sound/soc/codecs/rt5509.c |
|
15 |
create mode 100644 sound/soc/codecs/rt5509.h |
|
16 | ||
17 |
diff --git a/arch/arm64/boot/dts/mediatek/mt8365-sb35.dts b/arch/arm64/boot/dts/mediatek/mt8365-sb35.dts |
|
18 |
index e8260faaab55..bae04d1ab18d 100644 |
|
19 |
--- a/arch/arm64/boot/dts/mediatek/mt8365-sb35.dts |
|
20 |
+++ b/arch/arm64/boot/dts/mediatek/mt8365-sb35.dts |
|
21 |
@@ -74,6 +74,15 @@ sound: sound { |
|
22 |
pinctrl-4 = <&aud_pins_default>; |
|
23 |
pinctrl-5 = <&aud_pins_dmic>; |
|
24 |
status = "okay"; |
|
25 |
+ |
|
26 |
+ dai-link { |
|
27 |
+ sound-dai = <&afe>; |
|
28 |
+ dai-link-name = "2ND I2S BE"; |
|
29 |
+ |
|
30 |
+ codec-0 { |
|
31 |
+ sound-dai = <&speaker_amp_left>; |
|
32 |
+ }; |
|
33 |
+ }; |
|
34 |
}; |
|
35 |
|
|
36 |
reserved-memory { |
|
37 |
@@ -307,14 +316,22 @@ &i2c1 { |
|
38 |
clock-frequency = <100000>; |
|
39 |
status = "okay"; |
|
40 |
|
|
41 |
- rt5509_left: codec@34 { |
|
42 |
- compatible = "realtek,rt5514"; |
|
43 |
+ speaker_amp_left:speaker_amp@34 { |
|
44 |
+ compatible = "richtek,rt5509"; |
|
45 |
reg = <0x34>; |
|
46 |
+ status = "okay"; |
|
47 |
+ #sound-dai-cells = <0>; |
|
48 |
+ rt5509,boost-mode = <1>; |
|
49 |
+ rt5509,reg-settings = <0x1f 0x0352>; |
|
50 |
}; |
|
51 |
|
|
52 |
- rt5509_right: codec@35 { |
|
53 |
- compatible = "realtek,rt5514"; |
|
54 |
+ speaker_amp_right:speaker_amp@35 { |
|
55 |
+ compatible = "richtek,rt5509"; |
|
56 |
reg = <0x35>; |
|
57 |
+ status = "okay"; |
|
58 |
+ #sound-dai-cells = <0>; |
|
59 |
+ rt5509,boost-mode = <1>; |
|
60 |
+ rt5509,reg-settings = <0x1f 0x0352>; |
|
61 |
}; |
|
62 |
|
|
63 |
hdmi-bridge@3b { |
|
64 |
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig |
|
65 |
index a2fb0031b342..3977d89674d1 100644 |
|
66 |
--- a/sound/soc/codecs/Kconfig |
|
67 |
+++ b/sound/soc/codecs/Kconfig |
|
68 |
@@ -226,6 +226,7 @@ config SND_SOC_ALL_CODECS |
|
69 |
imply SND_SOC_TLV320AIC3X_I2C |
|
70 |
imply SND_SOC_TLV320AIC3X_SPI |
|
71 |
imply SND_SOC_TPA6130A2 |
|
72 |
+ imply SND_SOC_RT5509 |
|
73 |
imply SND_SOC_TLV320DAC33 |
|
74 |
imply SND_SOC_TSCS42XX |
|
75 |
imply SND_SOC_TSCS454 |
|
76 |
@@ -1963,4 +1964,8 @@ config SND_SOC_LPASS_TX_MACRO |
|
77 |
select REGMAP_MMIO |
|
78 |
tristate "Qualcomm TX Macro in LPASS(Low Power Audio SubSystem)" |
|
79 |
|
|
80 |
+config SND_SOC_RT5509 |
|
81 |
+ tristate "Richtek RT5509 Smart AMP" |
|
82 |
+ depends on I2C |
|
83 |
+ |
|
84 |
endmenu |
|
85 |
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile |
|
86 |
index 67423b98f96d..84bf12e93ca9 100644 |
|
87 |
--- a/sound/soc/codecs/Makefile |
|
88 |
+++ b/sound/soc/codecs/Makefile |
|
89 |
@@ -320,6 +320,8 @@ snd-soc-wm9713-objs := wm9713.o |
|
90 |
snd-soc-wm-hubs-objs := wm_hubs.o |
|
91 |
snd-soc-wsa881x-objs := wsa881x.o |
|
92 |
snd-soc-zl38060-objs := zl38060.o |
|
93 |
+snd-soc-rt5509-objs := rt5509.o |
|
94 |
+ |
|
95 |
# Amp |
|
96 |
snd-soc-max9877-objs := max9877.o |
|
97 |
snd-soc-max98504-objs := max98504.o |
|
98 |
@@ -664,6 +666,7 @@ obj-$(CONFIG_SND_SOC_LPASS_WSA_MACRO) += snd-soc-lpass-wsa-macro.o |
|
99 |
obj-$(CONFIG_SND_SOC_LPASS_VA_MACRO) += snd-soc-lpass-va-macro.o |
|
100 |
obj-$(CONFIG_SND_SOC_LPASS_RX_MACRO) += snd-soc-lpass-rx-macro.o |
|
101 |
obj-$(CONFIG_SND_SOC_LPASS_TX_MACRO) += snd-soc-lpass-tx-macro.o |
|
102 |
+obj-$(CONFIG_SND_SOC_RT5509) += snd-soc-rt5509.o |
|
103 |
|
|
104 |
# Mux |
|
105 |
obj-$(CONFIG_SND_SOC_SIMPLE_MUX) += snd-soc-simple-mux.o |
|
106 |
diff --git a/sound/soc/codecs/rt5509.c b/sound/soc/codecs/rt5509.c |
|
107 |
new file mode 100644 |
|
108 |
index 000000000000..a641797e407e |
|
109 |
--- /dev/null |
|
110 |
+++ b/sound/soc/codecs/rt5509.c |
|
111 |
@@ -0,0 +1,3483 @@ |
|
112 |
+/* |
|
113 |
+ * Copyright (C) 2019 MediaTek Inc. |
|
114 |
+ * |
|
115 |
+ * This program is free software; you can redistribute it and/or modify |
|
116 |
+ * it under the terms of the GNU General Public License version 2 as |
|
117 |
+ * published by the Free Software Foundation. |
|
118 |
+ * |
|
119 |
+ * This program is distributed in the hope that it will be useful, |
|
120 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
121 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
122 |
+ * See http://www.gnu.org/licenses/gpl-2.0.html for more details. |
|
123 |
+ */ |
|
124 |
+ |
|
125 |
+#include <linux/module.h> |
|
126 |
+#include <linux/kernel.h> |
|
127 |
+#include <linux/version.h> |
|
128 |
+#include <linux/err.h> |
|
129 |
+#include <linux/i2c.h> |
|
130 |
+#include <linux/delay.h> |
|
131 |
+#include <sound/soc.h> |
|
132 |
+#include <sound/tlv.h> |
|
133 |
+#include <sound/pcm_params.h> |
|
134 |
+#include <linux/debugfs.h> |
|
135 |
+#include <linux/of.h> |
|
136 |
+#include <linux/gpio.h> |
|
137 |
+#include <linux/of_gpio.h> |
|
138 |
+#include <linux/pm_runtime.h> |
|
139 |
+ |
|
140 |
+#include "rt5509.h" |
|
141 |
+ |
|
142 |
+#if IS_ENABLED(CONFIG_SND_SOC_MTK_AUDIO_DSP) |
|
143 |
+#include "richtek_spm_cls.h" |
|
144 |
+#endif |
|
145 |
+ |
|
146 |
+/*---------------------------------------------------*/ |
|
147 |
+ |
|
148 |
+#include <linux/fs.h> |
|
149 |
+#include <linux/uaccess.h> |
|
150 |
+#include <linux/buffer_head.h> |
|
151 |
+/* alsa sound header */ |
|
152 |
+#include <sound/soc.h> |
|
153 |
+/* 64bit integer */ |
|
154 |
+#include <linux/math64.h> |
|
155 |
+#include <sound/soc.h> |
|
156 |
+ |
|
157 |
+#define RT5509_CALIB_MAGIC (5526789) |
|
158 |
+ |
|
159 |
+static struct class *rt5509_cal_class; |
|
160 |
+static int calib_status; |
|
161 |
+ |
|
162 |
+enum { |
|
163 |
+ RT5509_CALIB_CTRL_START = 0, |
|
164 |
+ RT5509_CALIB_CTRL_DCROFFSET, |
|
165 |
+ RT5509_CALIB_CTRL_N20DB, |
|
166 |
+ RT5509_CALIB_CTRL_N15DB, |
|
167 |
+ RT5509_CALIB_CTRL_N10DB, |
|
168 |
+ RT5509_CALIB_CTRL_READOTP, |
|
169 |
+ RT5509_CALIB_CTRL_READRAPP, |
|
170 |
+ RT5509_CALIB_CTRL_WRITEOTP, |
|
171 |
+ RT5509_CALIB_CTRL_WRITEFILE, |
|
172 |
+ RT5509_CALIB_CTRL_END, |
|
173 |
+ RT5509_CALIB_CTRL_ALLINONE, |
|
174 |
+ RT5509_CALIB_CTRL_MAX, |
|
175 |
+}; |
|
176 |
+ |
|
177 |
+static int rt5509_calib_get_dcroffset(struct rt5509_chip *chip) |
|
178 |
+{ |
|
179 |
+ |
|
180 |
+ uint32_t delta_v = 0, vtemp = 0; |
|
181 |
+ int ret = 0; |
|
182 |
+ |
|
183 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_VTEMP_TRIM); |
|
184 |
+ if (ret < 0) |
|
185 |
+ return ret; |
|
186 |
+ vtemp = ret & 0xffff; |
|
187 |
+ |
|
188 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_VTHRMDATA); |
|
189 |
+ if (ret < 0) |
|
190 |
+ return ret; |
|
191 |
+ ret &= 0xffff; |
|
192 |
+ delta_v = (2730 - 400) * (ret - vtemp) / vtemp; |
|
193 |
+ return delta_v; |
|
194 |
+} |
|
195 |
+ |
|
196 |
+static int rt5509_calib_chosen_db(struct rt5509_chip *chip, int choose) |
|
197 |
+{ |
|
198 |
+ u32 data = 0; |
|
199 |
+ uint8_t mode_store = 0; |
|
200 |
+ int i = 0, ret = 0; |
|
201 |
+ |
|
202 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_BST_MODE); |
|
203 |
+ if (ret < 0) |
|
204 |
+ return ret; |
|
205 |
+ mode_store = ret; |
|
206 |
+ |
|
207 |
+ data = 0x0080; |
|
208 |
+ |
|
209 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_CALIB_REQ, data); |
|
210 |
+ if (ret < 0) |
|
211 |
+ return ret; |
|
212 |
+ switch (choose) { |
|
213 |
+ case RT5509_CALIB_CTRL_N20DB: |
|
214 |
+ data = 0x0ccc; |
|
215 |
+ break; |
|
216 |
+ case RT5509_CALIB_CTRL_N15DB: |
|
217 |
+ data = 0x16c3; |
|
218 |
+ break; |
|
219 |
+ case RT5509_CALIB_CTRL_N10DB: |
|
220 |
+ data = 0x287a; |
|
221 |
+ break; |
|
222 |
+ default: |
|
223 |
+ return -EINVAL; |
|
224 |
+ } |
|
225 |
+ |
|
226 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_CALIB_GAIN, data); |
|
227 |
+ if (ret < 0) |
|
228 |
+ return ret; |
|
229 |
+ |
|
230 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_CALIB_CTRL); |
|
231 |
+ if (ret < 0) |
|
232 |
+ return ret; |
|
233 |
+ data = ret; |
|
234 |
+ data |= 0x80; |
|
235 |
+ |
|
236 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_CALIB_CTRL, data); |
|
237 |
+ if (ret < 0) |
|
238 |
+ return ret; |
|
239 |
+ mdelay(120); |
|
240 |
+ while (i++ < 3) { |
|
241 |
+ |
|
242 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_CALIB_CTRL); |
|
243 |
+ if (ret < 0) |
|
244 |
+ return ret; |
|
245 |
+ if (ret & 0x01) |
|
246 |
+ break; |
|
247 |
+ mdelay(20); |
|
248 |
+ } |
|
249 |
+ data &= ~(0x80); |
|
250 |
+ |
|
251 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_CALIB_CTRL, data); |
|
252 |
+ if (ret < 0) |
|
253 |
+ return ret; |
|
254 |
+ |
|
255 |
+ ret = snd_soc_component_update_bits(chip->component, RT5509_REG_BST_MODE, 0x03, mode_store); |
|
256 |
+ |
|
257 |
+ if (ret < 0) |
|
258 |
+ return ret; |
|
259 |
+ |
|
260 |
+ if (i > 3) { |
|
261 |
+ dev_err(chip->dev, "over ready count\n"); |
|
262 |
+ return -EINVAL; |
|
263 |
+ } |
|
264 |
+ return snd_soc_component_read(chip->component, RT5509_REG_CALIB_OUT0); |
|
265 |
+} |
|
266 |
+ |
|
267 |
+static int rt5509_calib_read_otp(struct rt5509_chip *chip) |
|
268 |
+{ |
|
269 |
+ |
|
270 |
+ int ret = 0; |
|
271 |
+ |
|
272 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_ISENSEGAIN); |
|
273 |
+ if (ret < 0) |
|
274 |
+ return ret; |
|
275 |
+ ret &= 0xffffff; |
|
276 |
+ return ret; |
|
277 |
+} |
|
278 |
+ |
|
279 |
+static int rt5509_calib_write_otp(struct rt5509_chip *chip) |
|
280 |
+{ |
|
281 |
+ uint8_t mode_store = 0; |
|
282 |
+ uint32_t param = chip->calib_dev.rspk; |
|
283 |
+ uint32_t param_store = 0; |
|
284 |
+ uint32_t bst_th = 0; |
|
285 |
+ int ret = 0; |
|
286 |
+ |
|
287 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_BST_TH1); |
|
288 |
+ if (ret < 0) |
|
289 |
+ return ret; |
|
290 |
+ bst_th = ret; |
|
291 |
+ |
|
292 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_BST_MODE); |
|
293 |
+ if (ret < 0) |
|
294 |
+ return ret; |
|
295 |
+ mode_store = ret; |
|
296 |
+ |
|
297 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_BST_TH1, 0x029b); |
|
298 |
+ if (ret < 0) |
|
299 |
+ return ret; |
|
300 |
+ |
|
301 |
+ ret = snd_soc_component_update_bits(chip->component, RT5509_REG_BST_MODE, 0x03, 0x02); |
|
302 |
+ if (ret < 0) |
|
303 |
+ return ret; |
|
304 |
+ |
|
305 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_CALIB_DCR, param); |
|
306 |
+ if (ret < 0) |
|
307 |
+ return ret; |
|
308 |
+ |
|
309 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_OTPDIN); |
|
310 |
+ ret &= 0x00ffff; |
|
311 |
+ ret |= 0xc50000; |
|
312 |
+ |
|
313 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_OTPDIN, ret); |
|
314 |
+ if (ret < 0) |
|
315 |
+ return ret; |
|
316 |
+ |
|
317 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_OTPDIN, 0x81); |
|
318 |
+ if (ret < 0) |
|
319 |
+ return ret; |
|
320 |
+ msleep(100); |
|
321 |
+ |
|
322 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_OTPCONF, 0x00); |
|
323 |
+ if (ret < 0) |
|
324 |
+ return ret; |
|
325 |
+ |
|
326 |
+ ret = snd_soc_component_update_bits(chip->component, RT5509_REG_BST_MODE,0x03, mode_store); |
|
327 |
+ if (ret < 0) |
|
328 |
+ return ret; |
|
329 |
+ |
|
330 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_BST_TH1, bst_th); |
|
331 |
+ if (ret < 0) |
|
332 |
+ return ret; |
|
333 |
+ |
|
334 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_CALIB_DCR, 0x00); |
|
335 |
+ if (ret < 0) |
|
336 |
+ return ret; |
|
337 |
+ |
|
338 |
+ if (ret < 0) |
|
339 |
+ return ret; |
|
340 |
+ |
|
341 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_OTPCONF, 0x82); |
|
342 |
+ if (ret < 0) |
|
343 |
+ return ret; |
|
344 |
+ |
|
345 |
+ ret = snd_soc_component_write(chip->component, RT5509_REG_OTPCONF, 0x00); |
|
346 |
+ if (ret < 0) |
|
347 |
+ return ret; |
|
348 |
+ |
|
349 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_CALIB_DCR); |
|
350 |
+ param_store = ret & 0xffffff; |
|
351 |
+ dev_info(chip->dev, "store %08x, put %08x\n", param_store, |
|
352 |
+ param); |
|
353 |
+ if (param_store != param) |
|
354 |
+ return -EINVAL; |
|
355 |
+ |
|
356 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_OTPDIN); |
|
357 |
+ dev_info(chip->dev, "otp_din = 0x%08x\n", ret); |
|
358 |
+ if ((ret & 0xff0000) != 0xc50000) |
|
359 |
+ return -EINVAL; |
|
360 |
+ chip->calibrated = 1; |
|
361 |
+ return 0; |
|
362 |
+} |
|
363 |
+ |
|
364 |
+static int rt5509_calib_rwotp(struct rt5509_chip *chip, int choose) |
|
365 |
+{ |
|
366 |
+ int ret = 0; |
|
367 |
+ |
|
368 |
+ dev_info(chip->dev, "%s\n", __func__); |
|
369 |
+ switch (choose) { |
|
370 |
+ case RT5509_CALIB_CTRL_READOTP: |
|
371 |
+ ret = rt5509_calib_read_otp(chip); |
|
372 |
+ break; |
|
373 |
+ case RT5509_CALIB_CTRL_WRITEOTP: |
|
374 |
+ ret = rt5509_calib_write_otp(chip); |
|
375 |
+ break; |
|
376 |
+ default: |
|
377 |
+ return -EINVAL; |
|
378 |
+ } |
|
379 |
+ return ret; |
|
380 |
+} |
|
381 |
+ |
|
382 |
+static int rt5509_calib_read_rapp(struct rt5509_chip *chip) |
|
383 |
+{ |
|
384 |
+ int ret = 0; |
|
385 |
+ |
|
386 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_RAPP); |
|
387 |
+ if (ret < 0) |
|
388 |
+ return ret; |
|
389 |
+ ret &= 0xffffff; |
|
390 |
+ return ret; |
|
391 |
+} |
|
392 |
+ |
|
393 |
+static int rt5509_calib_write_file(struct rt5509_chip *chip) |
|
394 |
+{ |
|
395 |
+ return 0; |
|
396 |
+} |
|
397 |
+ |
|
398 |
+static int rt5509_calib_start_process(struct rt5509_chip *chip) |
|
399 |
+{ |
|
400 |
+ int ret = 0; |
|
401 |
+ |
|
402 |
+ dev_info(chip->dev, "%s\n", __func__); |
|
403 |
+ |
|
404 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_CHIPEN); |
|
405 |
+ if (ret < 0) |
|
406 |
+ return ret; |
|
407 |
+ if (!(ret & RT5509_SPKAMP_ENMASK)) { |
|
408 |
+ dev_err(chip->dev, "class D not turn on\n"); |
|
409 |
+ return -EINVAL; |
|
410 |
+ } |
|
411 |
+ |
|
412 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_I2CBCKLRCKCONF); |
|
413 |
+ if (ret < 0) |
|
414 |
+ return ret; |
|
415 |
+ if (ret & 0x08) { |
|
416 |
+ dev_err(chip->dev, "BCK loss\n"); |
|
417 |
+ return -EINVAL; |
|
418 |
+ } |
|
419 |
+ |
|
420 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_CALIB_REQ); |
|
421 |
+ if (ret < 0) |
|
422 |
+ return ret; |
|
423 |
+ chip->pilot_freq = ret & 0xffff; |
|
424 |
+ return 0; |
|
425 |
+} |
|
426 |
+ |
|
427 |
+static int rt5509_calib_end_process(struct rt5509_chip *chip) |
|
428 |
+{ |
|
429 |
+ dev_info(chip->dev, "%s\n", __func__); |
|
430 |
+ return snd_soc_component_write(chip->component, RT5509_REG_CALIB_REQ,chip->pilot_freq); |
|
431 |
+} |
|
432 |
+ |
|
433 |
+static int rt5509_calib_trigger_read(struct rt5509_calib_classdev *cdev) |
|
434 |
+{ |
|
435 |
+ struct rt5509_chip *chip = container_of(cdev, |
|
436 |
+ struct rt5509_chip, calib_dev); |
|
437 |
+ int ret = 0; |
|
438 |
+ |
|
439 |
+ dev_dbg(chip->dev, "%s\n", __func__); |
|
440 |
+ ret = rt5509_calib_start_process(chip); |
|
441 |
+ if (ret < 0) { |
|
442 |
+ dev_err(chip->dev, "start fail\n"); |
|
443 |
+ dev_err(chip->dev, "bck not valid or amp not turn on\n"); |
|
444 |
+ goto out_trigger_read; |
|
445 |
+ } |
|
446 |
+ ret = rt5509_calib_get_dcroffset(chip); |
|
447 |
+ if (ret < 0) { |
|
448 |
+ cdev->dcr_offset = 0xffffffff; |
|
449 |
+ goto out_trigger_read; |
|
450 |
+ } |
|
451 |
+ cdev->dcr_offset = ret; |
|
452 |
+ dev_dbg(chip->dev, "dcr_offset -> %d\n", cdev->dcr_offset); |
|
453 |
+ ret = rt5509_calib_chosen_db(chip, RT5509_CALIB_CTRL_N15DB); |
|
454 |
+ if (ret < 0) { |
|
455 |
+ cdev->n15db = 0xffffffff; |
|
456 |
+ goto out_trigger_read; |
|
457 |
+ } |
|
458 |
+ cdev->n15db = ret; |
|
459 |
+ dev_dbg(chip->dev, "n15db -> 0x%08x\n", cdev->n15db); |
|
460 |
+ ret = rt5509_calib_rwotp(chip, RT5509_CALIB_CTRL_READOTP); |
|
461 |
+ if (ret < 0) { |
|
462 |
+ cdev->gsense_otp = 0xffffffff; |
|
463 |
+ goto out_trigger_read; |
|
464 |
+ } |
|
465 |
+ cdev->gsense_otp = ret; |
|
466 |
+ dev_dbg(chip->dev, "gsense_otp -> 0x%08x\n", cdev->gsense_otp); |
|
467 |
+ ret = rt5509_calib_read_rapp(chip); |
|
468 |
+ if (ret < 0) { |
|
469 |
+ cdev->rapp = 0xffffffff; |
|
470 |
+ goto out_trigger_read; |
|
471 |
+ } |
|
472 |
+ cdev->rapp = ret; |
|
473 |
+ dev_dbg(chip->dev, "rapp -> 0x%08x\n", cdev->rapp); |
|
474 |
+ return 0; |
|
475 |
+out_trigger_read: |
|
476 |
+ return ret; |
|
477 |
+} |
|
478 |
+ |
|
479 |
+static int rt5509_calib_trigger_write(struct rt5509_calib_classdev *cdev) |
|
480 |
+{ |
|
481 |
+ struct rt5509_chip *chip = container_of(cdev, |
|
482 |
+ struct rt5509_chip, calib_dev); |
|
483 |
+ int ret = 0; |
|
484 |
+ |
|
485 |
+ dev_dbg(chip->dev, "%s\n", __func__); |
|
486 |
+ ret = rt5509_calib_rwotp(chip, RT5509_CALIB_CTRL_WRITEOTP); |
|
487 |
+ if (ret < 0) |
|
488 |
+ goto out_trigger_write; |
|
489 |
+ ret = rt5509_calib_write_file(chip); |
|
490 |
+ if (ret < 0) |
|
491 |
+ goto out_trigger_write; |
|
492 |
+ ret = rt5509_calib_end_process(chip); |
|
493 |
+ if (ret < 0) |
|
494 |
+ goto out_trigger_write; |
|
495 |
+ return 0; |
|
496 |
+out_trigger_write: |
|
497 |
+ return ret; |
|
498 |
+} |
|
499 |
+ |
|
500 |
+static int64_t rt5509_integer_dcr_calculation(int index, uint32_t n_db) |
|
501 |
+{ |
|
502 |
+ int64_t a = 0, x = 0; |
|
503 |
+ int64_t coeffi = 0; |
|
504 |
+ int i = 0; |
|
505 |
+ int64_t ret = 0; |
|
506 |
+ |
|
507 |
+ switch (index) { |
|
508 |
+ case RT5509_CALIB_CTRL_N20DB: |
|
509 |
+ coeffi = 81051042; |
|
510 |
+ break; |
|
511 |
+ case RT5509_CALIB_CTRL_N15DB: |
|
512 |
+ coeffi = 25630590; |
|
513 |
+ break; |
|
514 |
+ case RT5509_CALIB_CTRL_N10DB: |
|
515 |
+ coeffi = 8105104; |
|
516 |
+ break; |
|
517 |
+ default: |
|
518 |
+ return -1; |
|
519 |
+ } |
|
520 |
+ a = n_db * coeffi; |
|
521 |
+ x = 1 << 24; |
|
522 |
+ for (i = 0; i < 10; i++) |
|
523 |
+ x = div_s64(((x * x + a) >> 1), x); |
|
524 |
+ ret = 1; |
|
525 |
+ ret <<= 32; |
|
526 |
+ ret *= 10000000; |
|
527 |
+ return div_s64(ret, x); |
|
528 |
+} |
|
529 |
+ |
|
530 |
+#define RefT (-40) |
|
531 |
+#define alpha_r (265) |
|
532 |
+static int rt5509_calib_trigger_calculation(struct rt5509_calib_classdev *cdev) |
|
533 |
+{ |
|
534 |
+ struct rt5509_chip *chip = container_of(cdev, |
|
535 |
+ struct rt5509_chip, calib_dev); |
|
536 |
+ int64_t dcr_n15i = 0, dcr_i = 0; |
|
537 |
+ int64_t alpha_rappi = 0, rappi = 0; |
|
538 |
+ int64_t rspki = 0; |
|
539 |
+ int64_t rspk_mini = 0, rspk_maxi = 0; |
|
540 |
+ |
|
541 |
+ dev_info(chip->dev, "dcr_offset = 0x%08x\n", cdev->dcr_offset); |
|
542 |
+ dev_info(chip->dev, "n15db reg = 0x%08x\n", cdev->n15db); |
|
543 |
+ dev_info(chip->dev, "gsense_otp reg = 0x%08x\n", cdev->gsense_otp); |
|
544 |
+ dcr_n15i = rt5509_integer_dcr_calculation(RT5509_CALIB_CTRL_N15DB, |
|
545 |
+ cdev->n15db); |
|
546 |
+ if (dcr_n15i < 0) |
|
547 |
+ return -EINVAL; |
|
548 |
+ dcr_i = dcr_n15i; |
|
549 |
+ alpha_rappi = cdev->alphaspk; |
|
550 |
+ rappi = cdev->rapp; |
|
551 |
+ rappi <<= 9; |
|
552 |
+ dev_info(chip->dev, "rappi = %llx\n", rappi); |
|
553 |
+ rspki = div_s64((dcr_i * cdev->gsense_otp), 8); |
|
554 |
+ rspki *= (cdev->alphaspk + 25); |
|
555 |
+ rspki = div_s64(rspki, (alpha_r + RefT)); |
|
556 |
+ rspki = div_s64(rspki, 1048576); |
|
557 |
+ dev_info(chip->dev, "pre rspki = %llx\n", rspki); |
|
558 |
+ rspki -= (div_s64((rappi * (alpha_rappi + 25)), (alpha_rappi + 50))); |
|
559 |
+ dev_info(chip->dev, "post rspki = %llx\n", rspki); |
|
560 |
+ rspk_mini = cdev->rspkmin; |
|
561 |
+ rspk_mini <<= 32; |
|
562 |
+ rspk_maxi = cdev->rspkmax; |
|
563 |
+ rspk_maxi <<= 32; |
|
564 |
+ if ((rspki * 80) < rspk_mini || (rspki * 80) > rspk_maxi) { |
|
565 |
+ dev_err(chip->dev, "rspki over range\n"); |
|
566 |
+ return -EINVAL; |
|
567 |
+ } |
|
568 |
+ rspki >>= 9; |
|
569 |
+ cdev->rspk = (uint32_t)rspki; |
|
570 |
+ cdev->rspk &= 0xffffff; |
|
571 |
+ dev_info(chip->dev, "rspk = 0x%08x\n", cdev->rspk); |
|
572 |
+ return 0; |
|
573 |
+} |
|
574 |
+ |
|
575 |
+void rt5509_calib_destroy(struct rt5509_chip *chip) |
|
576 |
+{ |
|
577 |
+ dev_dbg(chip->dev, "%s\n", __func__); |
|
578 |
+ device_unregister(chip->calib_dev.dev); |
|
579 |
+} |
|
580 |
+EXPORT_SYMBOL_GPL(rt5509_calib_destroy); |
|
581 |
+ |
|
582 |
+int rt5509_calib_create(struct rt5509_chip *chip) |
|
583 |
+{ |
|
584 |
+ struct rt5509_calib_classdev *pcalib_dev = &chip->calib_dev; |
|
585 |
+ int ret = 0; |
|
586 |
+ |
|
587 |
+ dev_dbg(chip->dev, "%s\n", __func__); |
|
588 |
+ |
|
589 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_OTPDIN); |
|
590 |
+ ret &= 0xff0000; |
|
591 |
+ |
|
592 |
+ if (ret == 0xc50000) |
|
593 |
+ chip->calibrated = 1; |
|
594 |
+ |
|
595 |
+ ret = snd_soc_component_read(chip->component, RT5509_REG_CALIB_DCR); |
|
596 |
+ ret &= 0xffffff; |
|
597 |
+ pcalib_dev->rspk = ret; |
|
598 |
+ /* default rspk min,max,alphspk */ |
|
599 |
+ pcalib_dev->rspkmin = 10; |
|
600 |
+ pcalib_dev->rspkmax = 160; |
|
601 |
+ pcalib_dev->alphaspk = 265; |
|
602 |
+ pcalib_dev->trigger_read = rt5509_calib_trigger_read; |