代码拉取完成,页面将自动刷新
From 73123c609e53bc66e05e408eb259a2db83343174 Mon Sep 17 00:00:00 2001
From: You Meng <36076779@qq.com>
Date: Thu, 23 May 2024 09:31:32 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A03.1=E8=A7=A6=E6=91=B8?=
=?UTF-8?q?=E5=B1=8F=E5=92=8CEC20=E7=94=B5=E6=BA=90=E6=8E=A7=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Change-Id: Iea5d0fdd9f654cf6533ec449684403c79bc34c10
---
.../dts/rockchip/tspi-rk3566-dsi-v10.dtsi | 1504 +++--------------
.../dts/rockchip/tspi-rk3566-user-v10.dts | 10 +-
arch/arm64/configs/tspi_defconfig | 6 +-
drivers/input/touchscreen/Kconfig | 1 +
drivers/input/touchscreen/Makefile | 1 +
.../input/touchscreen/cst128a_cust/Kconfig | 7 +
.../input/touchscreen/cst128a_cust/Makefile | 1 +
.../touchscreen/cst128a_cust/cst128a_ts.c | 288 ++++
drivers/power/supply/Kconfig | 2 +
drivers/power/supply/Makefile | 1 +
drivers/power/supply/ec20_power/Kconfig | 7 +
drivers/power/supply/ec20_power/Makefile | 1 +
drivers/power/supply/ec20_power/ec20_power.c | 250 +++
13 files changed, 808 insertions(+), 1271 deletions(-)
create mode 100644 drivers/input/touchscreen/cst128a_cust/Kconfig
create mode 100644 drivers/input/touchscreen/cst128a_cust/Makefile
create mode 100644 drivers/input/touchscreen/cst128a_cust/cst128a_ts.c
create mode 100644 drivers/power/supply/ec20_power/Kconfig
create mode 100644 drivers/power/supply/ec20_power/Makefile
create mode 100644 drivers/power/supply/ec20_power/ec20_power.c
diff --git a/arch/arm64/boot/dts/rockchip/tspi-rk3566-dsi-v10.dtsi b/arch/arm64/boot/dts/rockchip/tspi-rk3566-dsi-v10.dtsi
index f358292624b2..341b9dc7c957 100755
--- a/arch/arm64/boot/dts/rockchip/tspi-rk3566-dsi-v10.dtsi
+++ b/arch/arm64/boot/dts/rockchip/tspi-rk3566-dsi-v10.dtsi
@@ -1,1268 +1,236 @@
-// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
-/*
- * Copyright (c) 2020 Rockchip Electronics Co., Ltd.
- *
- */
-/*********************************************************************
- * 立创开发板不靠卖板赚钱,以培养中国工程师为己任
- * 泰山派软硬件资料与相关扩展板软硬件资料官网全部开源
- * 开发板官网:www.lckfb.com
- * 立创论坛:oshwhub.com/forum
- * 关注B站:【立创开发板】,掌握我们的最新动态!
- *********************************************************************
- * 文件名:tspi-rk3566-dsi-v10.dtsi
- * 描述:mipi 屏幕
- * 更新:
- * 时间 作者 联系 说明
- * 2023-07-21 吴才成 1378913492@qq.com v1.0.0
- *********************************************************************/
-/ {
- backlight: backlight {
- compatible = "pwm-backlight";
- pwms = <&pwm5 0 25000 0>;
- brightness-levels = <
- 0 20 20 21 21 22 22 23
- 23 24 24 25 25 26 26 27
- 27 28 28 29 29 30 30 31
- 31 32 32 33 33 34 34 35
- 35 36 36 37 37 38 38 39
- 40 41 42 43 44 45 46 47
- 48 49 50 51 52 53 54 55
- 56 57 58 59 60 61 62 63
- 64 65 66 67 68 69 70 71
- 72 73 74 75 76 77 78 79
- 80 81 82 83 84 85 86 87
- 88 89 90 91 92 93 94 95
- 96 97 98 99 100 101 102 103
- 104 105 106 107 108 109 110 111
- 112 113 114 115 116 117 118 119
- 120 121 122 123 124 125 126 127
- 128 129 130 131 132 133 134 135
- 136 137 138 139 140 141 142 143
- 144 145 146 147 148 149 150 151
- 152 153 154 155 156 157 158 159
- 160 161 162 163 164 165 166 167
- 168 169 170 171 172 173 174 175
- 176 177 178 179 180 181 182 183
- 184 185 186 187 188 189 190 191
- 192 193 194 195 196 197 198 199
- 200 201 202 203 204 205 206 207
- 208 209 210 211 212 213 214 215
- 216 217 218 219 220 221 222 223
- 224 225 226 227 228 229 230 231
- 232 233 234 235 236 237 238 239
- 240 241 242 243 244 245 246 247
- 248 249 250 251 252 253 254 255
- >;
- default-brightness-level = <255>;
- };
-};
-
-&pwm5 {
- status = "okay";
-};
-
-// &i2c1 {
-// status = "okay";
-// ts@5d {
-// compatible = "goodix,gt9xx";
-// reg = <0x5d>;
-// tp-size = <89>;
-// max-x = <1280>;
-// max-y = <800>;
-// touch-gpio = <&gpio1 RK_PA0 IRQ_TYPE_LEVEL_LOW>;
-// reset-gpio = <&gpio1 RK_PA1 IRQ_TYPE_LEVEL_LOW>;
-// };
-// };
-&i2c1 {
- status = "okay";
- ts@5d {
- pinctrl-0 = <&touch_gpio>;
- compatible = "goodix,gt9xx";
- reg = <0x5d>;
- tp-size = <970>;
- max-x = <1080>;
- max-y = <1920>;
- touch-gpio = <&gpio1 RK_PA0 IRQ_TYPE_LEVEL_LOW>;
- reset-gpio = <&gpio1 RK_PA1 GPIO_ACTIVE_HIGH>;
- };
-};
-
-&pinctrl {
- dsi1 {
- dsi1_rst_gpio: dsi1-rst-gpio {
- rockchip,pins = <3 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
- };
- touch_gpio: touch-gpio {
- rockchip,pins = <1 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>;
- };
- };
-};
-
-/*
- * video_phy1 needs to be enabled
- * when dsi1 is enabled
- */
-&dsi1 {
- status = "okay";
-};
-
-&dsi1_in_vp0 {
- status = "disabled";
-};
-
-&dsi1_in_vp1 {
- status = "okay";
-};
-
-&video_phy1 {
- status = "okay";
-};
-
-&route_dsi1 {
- status = "okay";//wucaicheng mipi okay
- connect = <&vp1_out_dsi1>;
-};
-
-/************************************************************************************************************************************************
-10寸晶尚
-默认 8寸800x1280
-************************************************************************************************************************************************/
-// &dsi1 {
-// status = "okay";
-// rockchip,lane-rate = <480>;
-// dsi1_panel: panel@0 {
-// status = "okay";
-// compatible = "simple-panel-dsi";
-// reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
-// pinctrl-names = "default";
-// pinctrl-0 = <&dsi1_rst_gpio>;
-// reg = <0>;
-// backlight = <&backlight>;
-// reset-delay-ms = <10>;
-// enable-delay-ms = <120>;
-// prepare-delay-ms = <20>;
-// unprepare-delay-ms = <20>;
-// disable-delay-ms = <50>;
-// dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
-// MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>;
-// dsi,format = <MIPI_DSI_FMT_RGB888>;
-// dsi,lanes = <4>;
-// panel-init-sequence = [
-// 15 00 02 E0 00
-// 15 00 02 E1 93
-// 15 00 02 E2 65
-// 15 00 02 E3 F8
-// 15 00 02 80 03
-// 15 00 02 E0 01
-// 15 00 02 00 00
-// 15 00 02 01 3C
-// 15 00 02 03 10
-// 15 00 02 04 38
-// 15 00 02 0C 74
-// 15 00 02 17 00
-// 15 00 02 18 E7
-// 15 00 02 19 01
-// 15 00 02 1A 00
-// 15 00 02 1B E7
-// 15 00 02 1C 01
-// 15 00 02 24 FE
-// 15 00 02 35 23
-// 15 00 02 37 09
-// 15 00 02 38 04
-// 15 00 02 39 00
-// 15 00 02 3A 01
-// 15 00 02 3C 70
-// 15 00 02 3D FF
-// 15 00 02 3E FF
-// 15 00 02 3F 7F
-// 15 00 02 40 06
-// 15 00 02 41 A0
-// 15 00 02 43 1E
-// 15 00 02 44 0B
-// 15 00 02 45 28
-// 15 00 02 55 02
-// 15 00 02 57 A9
-// 15 00 02 59 0A
-// 15 00 02 5A 2D
-// 15 00 02 5B 19
-// 15 00 02 5C 15
-// 15 00 02 5D 7F
-// 15 00 02 5E 6E
-// 15 00 02 5F 5F
-// 15 00 02 60 53
-// 15 00 02 61 50
-// 15 00 02 62 41
-// 15 00 02 63 44
-// 15 00 02 64 2C
-// 15 00 02 65 44
-// 15 00 02 66 42
-// 15 00 02 67 40
-// 15 00 02 68 5B
-// 15 00 02 69 45
-// 15 00 02 6A 48
-// 15 00 02 6B 38
-// 15 00 02 6C 32
-// 15 00 02 6D 25
-// 15 00 02 6E 14
-// 15 00 02 6F 08
-// 15 00 02 70 7F
-// 15 00 02 71 6E
-// 15 00 02 72 5F
-// 15 00 02 73 53
-// 15 00 02 74 50
-// 15 00 02 75 41
-// 15 00 02 76 44
-// 15 00 02 77 2C
-// 15 00 02 78 44
-// 15 00 02 79 42
-// 15 00 02 7A 40
-// 15 00 02 7B 5B
-// 15 00 02 7C 45
-// 15 00 02 7D 48
-// 15 00 02 7E 38
-// 15 00 02 7F 32
-// 15 00 02 80 25
-// 15 00 02 81 14
-// 15 00 02 82 08
-// 15 00 02 E0 02
-// 15 00 02 00 50
-// 15 00 02 01 5F
-// 15 00 02 02 5F
-// 15 00 02 03 52
-// 15 00 02 04 77
-// 15 00 02 05 57
-// 15 00 02 06 5F
-// 15 00 02 07 4E
-// 15 00 02 08 4C
-// 15 00 02 09 5F
-// 15 00 02 0A 4A
-// 15 00 02 0B 48
-// 15 00 02 0C 5F
-// 15 00 02 0D 46
-// 15 00 02 0E 44
-// 15 00 02 0F 40
-// 15 00 02 10 5F
-// 15 00 02 11 5F
-// 15 00 02 12 5F
-// 15 00 02 13 5F
-// 15 00 02 14 5F
-// 15 00 02 15 5F
-// 15 00 02 16 51
-// 15 00 02 17 5F
-// 15 00 02 18 5F
-// 15 00 02 19 53
-// 15 00 02 1A 77
-// 15 00 02 1B 57
-// 15 00 02 1C 5F
-// 15 00 02 1D 4F
-// 15 00 02 1E 4D
-// 15 00 02 1F 5F
-// 15 00 02 20 4B
-// 15 00 02 21 49
-// 15 00 02 22 5F
-// 15 00 02 23 47
-// 15 00 02 24 45
-// 15 00 02 25 41
-// 15 00 02 26 5F
-// 15 00 02 27 5F
-// 15 00 02 28 5F
-// 15 00 02 29 5F
-// 15 00 02 2A 5F
-// 15 00 02 2B 5F
-// 15 00 02 2C 01
-// 15 00 02 2D 1F
-// 15 00 02 2E 1F
-// 15 00 02 2F 13
-// 15 00 02 30 17
-// 15 00 02 31 17
-// 15 00 02 32 1F
-// 15 00 02 33 0D
-// 15 00 02 34 0F
-// 15 00 02 35 1F
-// 15 00 02 36 05
-// 15 00 02 37 07
-// 15 00 02 38 1F
-// 15 00 02 39 09
-// 15 00 02 3A 0B
-// 15 00 02 3B 11
-// 15 00 02 3C 1F
-// 15 00 02 3D 1F
-// 15 00 02 3E 1F
-// 15 00 02 3F 1F
-// 15 00 02 40 1F
-// 15 00 02 41 1F
-// 15 00 02 42 00
-// 15 00 02 43 1F
-// 15 00 02 44 1F
-// 15 00 02 45 12
-// 15 00 02 46 17
-// 15 00 02 47 17
-// 15 00 02 48 1F
-// 15 00 02 49 0C
-// 15 00 02 4A 0E
-// 15 00 02 4B 1F
-// 15 00 02 4C 04
-// 15 00 02 4D 06
-// 15 00 02 4E 1F
-// 15 00 02 4F 08
-// 15 00 02 50 0A
-// 15 00 02 51 10
-// 15 00 02 52 1F
-// 15 00 02 53 1F
-// 15 00 02 54 1F
-// 15 00 02 55 1F
-// 15 00 02 56 1F
-// 15 00 02 57 1F
-// 15 00 02 58 40
-// 15 00 02 5B 10
-// 15 00 02 5C 06
-// 15 00 02 5D 40
-// 15 00 02 5E 00
-// 15 00 02 5F 00
-// 15 00 02 60 40
-// 15 00 02 61 03
-// 15 00 02 62 04
-// 15 00 02 63 6C
-// 15 00 02 64 6C
-// 15 00 02 65 75
-// 15 00 02 66 08
-// 15 00 02 67 B4
-// 15 00 02 68 08
-// 15 00 02 69 6C
-// 15 00 02 6A 6C
-// 15 00 02 6B 0C
-// 15 00 02 6D 00
-// 15 00 02 6E 00
-// 15 00 02 6F 88
-// 15 00 02 75 BB
-// 15 00 02 76 00
-// 15 00 02 77 05
-// 15 00 02 78 2A
-// 15 00 02 E0 04
-// 15 00 02 00 0E
-// 15 00 02 02 B3
-// 15 00 02 09 60
-// 15 00 02 0E 48
-// 15 00 02 E0 00
-// 05 fa 01 11
-// 05 32 01 29
-// ];
-
-// panel-exit-sequence = [
-// 05 00 01 28
-// 05 00 01 10
-// ];
-
-// disp_timings1: display-timings {
-// native-mode = <&dsi1_timing0>;
-// dsi1_timing0: timing0 {
-// clock-frequency = <66000000>;
-// hactive = <800>;
-// vactive = <1280>;
-// hfront-porch = <18>;
-// hsync-len = <12>;
-// hback-porch = <18>;
-// vfront-porch = <24>;
-// vsync-len = <4>;
-// vback-porch = <12>;
-// hsync-active = <0>;
-// vsync-active = <0>;
-// de-active = <0>;
-// pixelclk-active = <1>;
-// };
-// };
-
-// ports {
-// #address-cells = <1>;
-// #size-cells = <0>;
-
-// port@0 {
-// reg = <0>;
-// panel_in_dsi1: endpoint {
-// remote-endpoint = <&dsi1_out_panel>;
-// };
-// };
-// };
-// };
-
-// ports {
-// #address-cells = <1>;
-// #size-cells = <0>;
-
-// port@1 {
-// reg = <1>;
-// dsi1_out_panel: endpoint {
-// remote-endpoint = <&panel_in_dsi1>;
-// };
-// };
-// };
-
-// };
-
-/************************************************************************************************************************************************
-10寸晶尚
-默认 10.1寸1200x1920
-************************************************************************************************************************************************/
-// &dsi1 {
-// status = "okay";
-// rockchip,lane-rate = <1000>;
-// dsi1_panel: panel@0 {
-// status = "okay";
-// compatible = "simple-panel-dsi";
-// reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
-// pinctrl-names = "default";
-// pinctrl-0 = <&dsi1_rst_gpio>;
-// reg = <0>;
-// backlight = <&backlight>;
-// reset-delay-ms = <100>;
-// enable-delay-ms = <120>;
-// prepare-delay-ms = <20>;
-// unprepare-delay-ms = <20>;
-// disable-delay-ms = <100>;
-// dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
-// MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>;
-// dsi,format = <MIPI_DSI_FMT_RGB888>;
-// dsi,lanes = <4>;
-// panel-init-sequence = [
-// 15 00 02 B0 01
-// 15 00 02 C3 4F
-// 15 00 02 C4 40
-// 15 00 02 C5 40
-// 15 00 02 C6 40
-// 15 00 02 C7 40
-// 15 00 02 C8 4D
-// 15 00 02 C9 52
-// 15 00 02 CA 51
-// 15 00 02 CD 5D
-// 15 00 02 CE 5B
-// 15 00 02 CF 4B
-// 15 00 02 D0 49
-// 15 00 02 D1 47
-// 15 00 02 D2 45
-// 15 00 02 D3 41
-// 15 00 02 D7 50
-// 15 00 02 D8 40
-// 15 00 02 D9 40
-// 15 00 02 DA 40
-// 15 00 02 DB 40
-// 15 00 02 DC 4E
-// 15 00 02 DD 52
-// 15 00 02 DE 51
-// 15 00 02 E1 5E
-// 15 00 02 E2 5C
-// 15 00 02 E3 4C
-// 15 00 02 E4 4A
-// 15 00 02 E5 48
-// 15 00 02 E6 46
-// 15 00 02 E7 42
-// 15 00 02 B0 03
-// 15 00 02 BE 03
-// 15 00 02 CC 44
-// 15 00 02 C8 07
-// 15 00 02 C9 05
-// 15 00 02 CA 42
-// 15 00 02 CD 3E
-// 15 00 02 CF 60
-// 15 00 02 D2 04
-// 15 00 02 D3 04
-// 15 00 02 D4 01
-// 15 00 02 D5 00
-// 15 00 02 D6 03
-// 15 00 02 D7 04
-// 15 00 02 D9 01
-// 15 00 02 DB 01
-// 15 00 02 E4 F0
-// 15 00 02 E5 0A
-// 15 00 02 B0 00
-// 15 00 02 B1 08
-// 15 00 02 BD 54
-// 15 00 02 C2 06
-// 15 00 02 C4 0B
-// 15 00 02 B0 02
-// 15 00 02 C0 00
-// 15 00 02 C1 0A
-// 15 00 02 C2 20
-// 15 00 02 C3 24
-// 15 00 02 C4 23
-// 15 00 02 C5 29
-// 15 00 02 C6 23
-// 15 00 02 C7 1C
-// 15 00 02 C8 19
-// 15 00 02 C9 17
-// 15 00 02 CA 17
-// 15 00 02 CB 18
-// 15 00 02 CC 1A
-// 15 00 02 CD 1E
-// 15 00 02 CE 20
-// 15 00 02 CF 23
-// 15 00 02 D0 07
-// 15 00 02 D1 00
-// 15 00 02 D2 00
-// 15 00 02 D3 0A
-// 15 00 02 D4 13
-// 15 00 02 D5 1C
-// 15 00 02 D6 1A
-// 15 00 02 D7 13
-// 15 00 02 D8 17
-// 15 00 02 D9 1C
-// 15 00 02 DA 19
-// 15 00 02 DB 17
-// 15 00 02 DC 17
-// 15 00 02 DD 18
-// 15 00 02 DE 1A
-// 15 00 02 DF 1E
-// 15 00 02 E0 20
-// 15 00 02 E1 23
-// 15 00 02 E2 07
-// 05 78 01 11
-// 05 14 01 29
-// ];
-
-// panel-exit-sequence = [
-// 05 00 01 28
-// 05 00 01 10
-// ];
-
-// disp_timings1: display-timings {
-// native-mode = <&dsi1_timing0>;
-// dsi1_timing0: timing0 {
-// clock-frequency = <156000000>;
-// hactive = <1200 >;
-// vactive = <1920>;
-// hfront-porch = <42>;
-// hsync-len = <10>;
-// hback-porch = <32>;
-// vfront-porch = <35>;
-// vsync-len = <4>;
-// vback-porch = <30>;
-// hsync-active = <0>;
-// vsync-active = <0>;
-// de-active = <0>;
-// pixelclk-active = <0>;
-// };
-// };
-
-// ports {
-// #address-cells = <1>;
-// #size-cells = <0>;
-
-// port@0 {
-// reg = <0>;
-// panel_in_dsi1: endpoint {
-// remote-endpoint = <&dsi1_out_panel>;
-// };
-// };
-// };
-// };
-
-// ports {
-// #address-cells = <1>;
-// #size-cells = <0>;
-
-// port@1 {
-// reg = <1>;
-// dsi1_out_panel: endpoint {
-// remote-endpoint = <&panel_in_dsi1>;
-// };
-// };
-// };
-
-// };
-
-// /************************************************************************************************************************************************
-// 10寸晶尚
-// 默认 8寸800x1280
-// ************************************************************************************************************************************************/
-// &dsi1 {
-// status = "okay";
-// rockchip,lane-rate = <500>;
-// dsi1_panel: panel@0 {
-// status = "okay";
-// compatible = "simple-panel-dsi";
-// reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
-// pinctrl-names = "default";
-// pinctrl-0 = <&dsi1_rst_gpio>;
-// reg = <0>;
-// backlight = <&backlight>;
-// reset-delay-ms = <30>;
-// enable-delay-ms = <100>;
-// prepare-delay-ms = <20>;
-// unprepare-delay-ms = <20>;
-// disable-delay-ms = <20>;
-// init-delay-ms = <10>;
-// dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
-// MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>;
-// dsi,format = <MIPI_DSI_FMT_RGB888>;
-// dsi,lanes = <4>;
-// panel-init-sequence = [
-// 39 00 04 FF 98 81 03
-// 15 00 02 01 00
-// 15 00 02 02 00
-// 15 00 02 03 53
-// 15 00 02 04 53
-// 15 00 02 05 13
-// 15 00 02 06 04
-// 15 00 02 07 02
-// 15 00 02 08 02
-// 15 00 02 09 00
-// 15 00 02 0a 00
-// 15 00 02 0b 00
-// 15 00 02 0c 00
-// 15 00 02 0d 00
-// 15 00 02 0e 00
-// 15 00 02 0f 00
-// 15 00 02 10 00
-// 15 00 02 11 00
-// 15 00 02 12 00
-// 15 00 02 13 00
-// 15 00 02 14 00
-// 15 00 02 15 00
-// 15 00 02 16 00
-// 15 00 02 17 00
-// 15 00 02 18 00
-// 15 00 02 19 00
-// 15 00 02 1a 00
-// 15 00 02 1b 00
-// 15 00 02 1c 00
-// 15 00 02 1d 00
-// 15 00 02 1e c0
-// 15 00 02 1f 00
-// 15 00 02 20 02
-// 15 00 02 21 09
-// 15 00 02 22 00
-// 15 00 02 23 00
-// 15 00 02 24 00
-// 15 00 02 25 00
-// 15 00 02 26 00
-// 15 00 02 27 00
-// 15 00 02 28 55
-// 15 00 02 29 03
-// 15 00 02 2a 00
-// 15 00 02 2b 00
-// 15 00 02 2c 00
-// 15 00 02 2d 00
-// 15 00 02 2e 00
-// 15 00 02 2f 00
-// 15 00 02 30 00
-// 15 00 02 31 00
-// 15 00 02 32 00
-// 15 00 02 33 00
-// 15 00 02 34 00
-// 15 00 02 35 00
-// 15 00 02 36 00
-// 15 00 02 37 00
-// 15 00 02 38 3C
-// 15 00 02 39 00
-// 15 00 02 3a 00
-// 15 00 02 3b 00
-// 15 00 02 3c 00
-// 15 00 02 3d 00
-// 15 00 02 3e 00
-// 15 00 02 3f 00
-// 15 00 02 40 00
-// 15 00 02 41 00
-// 15 00 02 42 00
-// 15 00 02 43 00
-// 15 00 02 44 00
-
-// 15 00 02 50 01
-// 15 00 02 51 23
-// 15 00 02 52 45
-// 15 00 02 53 67
-// 15 00 02 54 89
-// 15 00 02 55 ab
-// 15 00 02 56 01
-// 15 00 02 57 23
-// 15 00 02 58 45
-// 15 00 02 59 67
-// 15 00 02 5a 89
-// 15 00 02 5b ab
-// 15 00 02 5c cd
-// 15 00 02 5d ef
-
-// 15 00 02 5e 01
-// 15 00 02 5f 0A
-// 15 00 02 60 02
-// 15 00 02 61 02
-// 15 00 02 62 08
-// 15 00 02 63 15
-// 15 00 02 64 14
-// 15 00 02 65 02
-// 15 00 02 66 11
-// 15 00 02 67 10
-// 15 00 02 68 02
-// 15 00 02 69 0F
-// 15 00 02 6a 0E
-// 15 00 02 6b 02
-// 15 00 02 6c 0D
-// 15 00 02 6d 0C
-// 15 00 02 6e 06
-// 15 00 02 6f 02
-// 15 00 02 70 02
-// 15 00 02 71 02
-// 15 00 02 72 02
-// 15 00 02 73 02
-// 15 00 02 74 02
-
-// 15 00 02 75 0A
-// 15 00 02 76 02
-// 15 00 02 77 02
-// 15 00 02 78 06
-// 15 00 02 79 15
-// 15 00 02 7a 14
-// 15 00 02 7b 02
-// 15 00 02 7c 10
-// 15 00 02 7d 11
-// 15 00 02 7e 02
-// 15 00 02 7f 0C
-// 15 00 02 80 0D
-// 15 00 02 81 02
-// 15 00 02 82 0E
-// 15 00 02 83 0F
-// 15 00 02 84 08
-// 15 00 02 85 02
-// 15 00 02 86 02
-// 15 00 02 87 02
-// 15 00 02 88 02
-// 15 00 02 89 02
-// 15 00 02 8A 02
-
-
-// 39 00 04 FF 98 81 04
-// //15 00 02 00 00 //
-// // 15 00 02 2F 01 //bist 用户调试,屏幕会闪演示测试
-// 15 00 02 3B C0
-// 15 00 02 6C 15
-// 15 00 02 6E 30
-// 15 00 02 6F 55
-// 15 00 02 3A 24
-// 15 00 02 8D 1F
-// 15 00 02 87 BA
-// 15 00 02 26 76
-// 15 00 02 B2 D1
-// 15 00 02 B5 07
-// 15 00 02 35 1F
-// 15 00 02 88 0B
-// 15 00 02 21 09
-
-
-// 39 00 04 FF 98 81 01
-// 15 00 02 22 0A
-// 15 00 02 31 09
-// 15 00 02 40 33
-// 15 00 02 53 37
-// 15 00 02 55 38
-// 15 00 02 50 95
-// 15 00 02 51 95
-// 15 00 02 60 30
-
-// 15 00 02 A0 0F
-// 15 00 02 A1 17
-// 15 00 02 A2 22
-// 15 00 02 A3 19
-// 15 00 02 A4 15
-// 15 00 02 A5 28
-// 15 00 02 A6 1C
-// 15 00 02 A7 1C
-// 15 00 02 A8 78
-// 15 00 02 A9 1C
-// 15 00 02 AA 28
-// 15 00 02 AB 69
-// 15 00 02 AC 1A
-// 15 00 02 AD 19
-// 15 00 02 AE 4B
-// 15 00 02 AF 22
-// 15 00 02 B0 2A
-// 15 00 02 B1 4B
-// 15 00 02 B2 6B
-// 15 00 02 B3 3F
-
-// 15 00 02 C0 01
-// 15 00 02 C1 17
-// 15 00 02 C2 22
-// 15 00 02 C3 19
-// 15 00 02 C4 15
-// 15 00 02 C5 28
-// 15 00 02 C6 1C
-// 15 00 02 C7 1D
-// 15 00 02 C8 78
-// 15 00 02 C9 1C
-// 15 00 02 CA 28
-// 15 00 02 CB 69
-// 15 00 02 CC 1A
-// 15 00 02 CD 19
-// 15 00 02 CE 4B
-// 15 00 02 CF 22
-// 15 00 02 D0 2A
-// 15 00 02 D1 4B
-// 15 00 02 D2 6B
-// 15 00 02 D3 3F
-// 39 00 04 FF 98 81 00
-// 05 78 01 11
-// 05 14 01 29
-// ];
-
-// panel-exit-sequence = [
-// 05 00 01 28
-// 05 00 01 10
-// ];
-
-// disp_timings1: display-timings {
-// native-mode = <&dsi1_timing0>;
-// dsi1_timing0: timing0 {
-// clock-frequency = <71000000>;
-// hactive = <800>;
-// vactive = <1280>;
-// hfront-porch = <52>;
-// hsync-len = <8>;
-// hback-porch = <48>;
-// vfront-porch = <15>;
-// vsync-len = <6>;
-// vback-porch = <16>;
-// hsync-active = <0>;
-// vsync-active = <0>;
-// de-active = <0>;
-// pixelclk-active = <0>;
-// };
-// };
-
-// ports {
-// #address-cells = <1>;
-// #size-cells = <0>;
-
-// port@0 {
-// reg = <0>;
-// panel_in_dsi1: endpoint {
-// remote-endpoint = <&dsi1_out_panel>;
-// };
-// };
-// };
-// };
-
-// ports {
-// #address-cells = <1>;
-// #size-cells = <0>;
-
-// port@1 {
-// reg = <1>;
-// dsi1_out_panel: endpoint {
-// remote-endpoint = <&panel_in_dsi1>;
-// };
-// };
-// };
-
-// };
-
-// /************************************************************************************************************************************************
-// 贝力佳屏幕
-// 默认 8寸800x1280
-// ************************************************************************************************************************************************/
-// &dsi1 {
-// status = "okay";
-// rockchip,lane-rate = <500>;
-// dsi1_panel: panel@0 {
-// status = "okay";
-// compatible = "simple-panel-dsi";
-// reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
-// pinctrl-names = "default";
-// pinctrl-0 = <&dsi1_rst_gpio>;
-// reg = <0>;
-// backlight = <&backlight>;
-// reset-delay-ms = <30>;
-// enable-delay-ms = <100>;
-// prepare-delay-ms = <20>;
-// unprepare-delay-ms = <20>;
-// disable-delay-ms = <20>;
-// init-delay-ms = <10>;
-// dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
-// MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>;
-// dsi,format = <MIPI_DSI_FMT_RGB888>;
-// dsi,lanes = <4>;
-// panel-init-sequence = [
-// 39 00 04 FF 98 81 03
-// 15 00 02 01 00
-// 15 00 02 02 00
-// 15 00 02 03 53
-// 15 00 02 04 13
-// 15 00 02 05 00
-// 15 00 02 06 04
-// 15 00 02 07 00
-// 15 00 02 08 00
-// 15 00 02 09 22
-// 15 00 02 0a 22
-// 15 00 02 0b 00
-// 15 00 02 0c 01
-// 15 00 02 0d 00
-// 15 00 02 0e 00
-// 15 00 02 0f 25
-// 15 00 02 10 25
-// 15 00 02 11 00
-// 15 00 02 12 00
-// 15 00 02 13 00
-// 15 00 02 14 00
-// 15 00 02 15 00
-// 15 00 02 16 00
-// 15 00 02 17 00
-// 15 00 02 18 00
-// 15 00 02 19 00
-// 15 00 02 1a 00
-// 15 00 02 1b 00
-// 15 00 02 1c 00
-// 15 00 02 1d 00
-// 15 00 02 1e 44
-// 15 00 02 1f 80
-// 15 00 02 20 02
-// 15 00 02 21 03
-// 15 00 02 22 00
-// 15 00 02 23 00
-// 15 00 02 24 00
-// 15 00 02 25 00
-// 15 00 02 26 00
-// 15 00 02 27 00
-// 15 00 02 28 33
-// 15 00 02 29 03
-// 15 00 02 2a 00
-// 15 00 02 2b 00
-// 15 00 02 2c 00
-// 15 00 02 2d 00
-// 15 00 02 2e 00
-// 15 00 02 2f 00
-// 15 00 02 30 00
-// 15 00 02 31 00
-// 15 00 02 32 00
-// 15 00 02 33 00
-// 15 00 02 34 04
-// 15 00 02 35 00
-// 15 00 02 36 00
-// 15 00 02 37 00
-// 15 00 02 38 3C
-// 15 00 02 39 00
-// 15 00 02 3a 40
-// 15 00 02 3b 40
-// 15 00 02 3c 00
-// 15 00 02 3d 00
-// 15 00 02 3e 00
-// 15 00 02 3f 00
-// 15 00 02 40 00
-// 15 00 02 41 00
-// 15 00 02 42 00
-// 15 00 02 43 00
-// 15 00 02 44 00
-
-// 15 00 02 50 01
-// 15 00 02 51 23
-// 15 00 02 52 45
-// 15 00 02 53 67
-// 15 00 02 54 89
-// 15 00 02 55 ab
-// 15 00 02 56 01
-// 15 00 02 57 23
-// 15 00 02 58 45
-// 15 00 02 59 67
-// 15 00 02 5a 89
-// 15 00 02 5b ab
-// 15 00 02 5c cd
-// 15 00 02 5d ef
-
-// 15 00 02 5e 11
-
-// 15 00 02 5f 01
-// 15 00 02 60 00
-// 15 00 02 61 15
-// 15 00 02 62 14
-// 15 00 02 63 0C
-// 15 00 02 64 0D
-// 15 00 02 65 0E
-// 15 00 02 66 0F
-// 15 00 02 67 06
-// 15 00 02 68 02
-// 15 00 02 69 02
-// 15 00 02 6a 02
-// 15 00 02 6b 02
-// 15 00 02 6c 02
-// 15 00 02 6d 02
-// 15 00 02 6e 08
-// 15 00 02 6f 02
-// 15 00 02 70 02
-// 15 00 02 71 02
-// 15 00 02 72 02
-// 15 00 02 73 02
-// 15 00 02 74 02
-
-// 15 00 02 75 01
-// 15 00 02 76 00
-// 15 00 02 77 15
-// 15 00 02 78 14
-// 15 00 02 79 0C
-// 15 00 02 7a 0D
-// 15 00 02 7b 0E
-// 15 00 02 7c 0F
-// 15 00 02 7D 08
-// 15 00 02 7E 02
-// 15 00 02 7F 02
-// 15 00 02 80 02
-// 15 00 02 81 02
-// 15 00 02 82 02
-// 15 00 02 83 02
-// 15 00 02 84 06
-// 15 00 02 85 02
-// 15 00 02 86 02
-// 15 00 02 87 02
-// 15 00 02 88 02
-// 15 00 02 89 02
-// 15 00 02 8A 02
-
-// 39 00 04 FF 98 81 04
-// 15 00 02 6C 15
-// 15 00 02 6E 3B
-// 15 00 02 6F 55
-// // 15 00 02 3A 14
-// 15 00 02 8D 14
-// 15 00 02 87 BA
-// 15 00 02 26 76
-// 15 00 02 B2 D1
-// 15 00 02 3B 98
-// 15 00 02 35 1f
-// 15 00 02 3A 24
-// 15 00 02 B5 27
-// 15 00 02 31 75
-// 15 00 02 30 03
-// 15 00 02 33 14
-// 15 00 02 38 02
-// 15 00 02 39 00
-// 15 00 02 7A 10
-
-// // 15 00 02 2F 01 //开bist模式 检测gIP和ic有没有问题
-
-// 39 00 04 FF 98 81 01
-// 15 00 02 22 0A
-// 15 00 02 31 0A
-// 15 00 02 50 AE
-// 15 00 02 51 A9
-// 15 00 02 60 1F
-// 15 00 02 62 07
-// 15 00 02 63 00
-
-// 15 00 02 52 00
-// 15 00 02 53 56
-// 15 00 02 54 00
-// 15 00 02 55 59
-
-// 15 00 02 A0 08
-// 15 00 02 A1 20
-// 15 00 02 A2 2D
-// 15 00 02 A3 13
-// 15 00 02 A4 16
-// 15 00 02 A5 29
-// 15 00 02 A6 1D
-// 15 00 02 A7 1E
-// 15 00 02 A8 77
-// 15 00 02 A9 17
-// 15 00 02 AA 24
-// 15 00 02 AB 6A
-// 15 00 02 AC 22
-// 15 00 02 AD 24
-// 15 00 02 AE 5A
-// 15 00 02 AF 2B
-// 15 00 02 B0 2C
-// 15 00 02 B1 4D
-// 15 00 02 B2 6F
-// 15 00 02 B3 3F
-
-// 15 00 02 C0 08
-// 15 00 02 C1 1E
-// 15 00 02 C2 2B
-// 15 00 02 C3 13
-// 15 00 02 C4 16
-// 15 00 02 C5 28
-// 15 00 02 C6 1A
-// 15 00 02 C7 1D
-// 15 00 02 C8 75
-// 15 00 02 C9 18
-// 15 00 02 CA 25
-// 15 00 02 CB 71
-// 15 00 02 CC 23
-// 15 00 02 CD 28
-// 15 00 02 CE 59
-// 15 00 02 CF 2C
-// 15 00 02 D0 30
-// 15 00 02 D1 55
-// 15 00 02 D2 6B
-// 15 00 02 D3 3F
-
-// //CMD_Page 0
-// 39 00 04 FF 98 81 00
-// 15 00 02 35 00
-// 05 78 01 11
-// 05 14 01 29
-// ];
-
-// panel-exit-sequence = [
-// 05 00 01 28
-// 05 00 01 10
-// ];
-
-// disp_timings1: display-timings {
-// native-mode = <&dsi1_timing0>;
-// dsi1_timing0: timing0 {
-// clock-frequency = <71000000>;
-// hactive = <800>;
-// vactive = <1280>;
-// hfront-porch = <52>;
-// hsync-len = <8>;
-// hback-porch = <48>;
-// vfront-porch = <15>;
-// vsync-len = <6>;
-// vback-porch = <16>;
-// hsync-active = <0>;
-// vsync-active = <0>;
-// de-active = <0>;
-// pixelclk-active = <0>;
-// };
-// };
-
-// ports {
-// #address-cells = <1>;
-// #size-cells = <0>;
-
-// port@0 {
-// reg = <0>;
-// panel_in_dsi1: endpoint {
-// remote-endpoint = <&dsi1_out_panel>;
-// };
-// };
-// };
-// };
-
-// ports {
-// #address-cells = <1>;
-// #size-cells = <0>;
-
-// port@1 {
-// reg = <1>;
-// dsi1_out_panel: endpoint {
-// remote-endpoint = <&panel_in_dsi1>;
-// };
-// };
-// };
-
-// };
-
-
-/************************************************************************************************************************************************
-贝力佳屏幕
-默认 5寸
-************************************************************************************************************************************************/
-&dsi1 {
- status = "okay";
- rockchip,lane-rate = <1000>;
- dsi1_panel: panel@0 {
- status = "okay";
- compatible = "simple-panel-dsi";
- reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
- pinctrl-names = "default";
- pinctrl-0 = <&dsi1_rst_gpio>;
- reg = <0>;
- backlight = <&backlight>;
- reset-delay-ms = <30>;
- enable-delay-ms = <100>;
- prepare-delay-ms = <20>;
- unprepare-delay-ms = <20>;
- disable-delay-ms = <20>;
- init-delay-ms = <120>;
- dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
- MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>;
- dsi,format = <MIPI_DSI_FMT_RGB888>;
- dsi,lanes = <4>;
- panel-init-sequence = [
- // Set EXTC
- 39 00 04 B9 FF 83 99
- // Set Power
- 39 00 10 B1 02 04 6C 8C 01 32 33 11 11 53 48 01 73 02 02
- // Set Display
- 39 00 0C B2 00 80 80 AE 05 07 5A 11 00 10 10
- // Set CYC
- 39 00 2D B4 00 FF 00 AC 00 9C 00 00 08 00 00 02 00 26 02 07 09 21 03 00 00 04 A4 88 00 AC 00 9C 00 00 08 00 00 02 00 24 02 07 09 00 00 04 A4 12
- // Set GIP_0
- 39 00 22 D3 00 00 00 00 00 00 00 00 32 10 05 00 05 00 00 00 00 00 00 00 00 00 00 01 00 07 07 03 00 00 00 05 40
- // Set GIP_1
- 39 00 21 D5 00 00 00 01 02 03 00 00 00 00 19 00 18 00 20 21 00 18 00 00 00 00 00 00 00 00 31 31 30 30 2F 2F
- // Set GIP_2
- 39 00 21 D6 40 40 03 02 01 00 40 40 40 40 18 40 19 40 21 20 40 18 40 40 40 40 40 40 40 40 31 31 30 30 2F 2F
- // Set GIP_3_0
- 39 00 11 D8 28 02 00 2A 28 02 C0 2A 00 00 00 00 00 00 00 00
- // Set Bank
- 39 00 02 BD 01
- // Set GIP_3_1
- 39 00 11 D8 00 00 00 00 00 00 00 00 28 2A 00 2A 28 02 C0 2A
- // Set Bank
- 39 00 02 BD 02
- // Set GIP_3_2
- 39 00 09 D8 28 2A 00 2A 28 02 C0 2A
- // Set Bank
- 39 00 02 BD 00
- //Set VCOM
- 39 00 03 B6 7D 7D
- //Set VREF
- 39 00 02 D2 33
- // Set Panel
- 39 00 02 CC 08
- // Set GAMMA
- 39 00 37 E0 01 2E 38 31 6A 71 7B 76 78 7F 86 88 8E 90 98 9C 9D A7 A8 AB A7 A9 A8 59 52 5D 69 01 2E 38 31 6A 71 7B 76 78 7F 86 88 8E 90 98 9C 9D A7 A8 AB A7 A9 A8 59 52 5D 69
- // Checksum Enable
- 39 00 02 D0 39
- 05 78 01 11
- 05 14 01 29
- ];
-
- panel-exit-sequence = [
- 05 00 01 28
- 05 00 01 10
- ];
-
- disp_timings1: display-timings {
- native-mode = <&dsi1_timing0>;
- dsi1_timing0: timing0 {
- clock-frequency = <120000000>;
- hactive = <1080>; //与 LCDTiming.LCDH 对应
- vactive = <1920>; //与 LCDTiming.LCDV 对应
- hfront-porch = <32>; //与 LCDTiming.HFPD 对应
- hsync-len = <4>; //与 LCDTiming.HSPW 对应
- hback-porch = <32>; //与 LCDTiming.HBPD 对应
- vfront-porch = <9>; //与 LCDTiming.VEPD 对应
- vsync-len = <4>; //与 LCDTiming.VsPW 对应
- vback-porch = <3>; //与 LCDTiming.VBPD 对应
- hsync-active = <0>;
- vsync-active = <0>;
- de-active = <0>;
- pixelclk-active = <0>;
- };
- };
-
- ports {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port@0 {
- reg = <0>;
- panel_in_dsi1: endpoint {
- remote-endpoint = <&dsi1_out_panel>;
- };
- };
- };
- };
-
- ports {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port@1 {
- reg = <1>;
- dsi1_out_panel: endpoint {
- remote-endpoint = <&panel_in_dsi1>;
- };
- };
- };
-
-};
+/*********************************************************************
+ * 立创开发板不靠卖板赚钱,以培养中国工程师为己任
+ * 泰山派软硬件资料与相关扩展板软硬件资料官网全部开源
+ * 开发板官网:www.lckfb.com
+ * 立创论坛:oshwhub.com/forum
+ * 关注B站:【立创开发板】,掌握我们的最新动态!
+ *********************************************************************
+ * 文件名:tspi-rk3566-dsi-v10.dtsi
+ * 描述:mipi 屏幕
+ * 更新:
+ * 时间 作者 联系 说明
+ * 2023-09-13 吴才成 1378913492@qq.com v1.0.0
+ * 2024-01-19 风漠兮 578118086@qq.com Fit D310T9362V1
+ *********************************************************************/
+/ {
+ backlight: backlight {
+ compatible = "pwm-backlight";
+ pwms = <&pwm5 0 25000 0>;
+ brightness-levels = <
+ 0 20 20 20 20 20 20 20
+ 21 21 21 21 21 21 21 21
+ 22 22 22 22 22 22 22 22
+ 23 23 23 23 23 23 23 23
+ 24 24 24 24 24 24 24 24
+ 25 25 25 25 25 25 25 25
+ 26 26 26 26 26 26 26 26
+ 27 27 27 27 27 27 27 27
+ 28 28 28 28 28 28 28 28
+ 29 29 29 29 29 29 29 29
+ 30 30 30 30 30 30 30 30
+ 31 31 31 31 31 31 31 31
+ 32 32 32 32 32 32 32 32
+ 33 33 33 33 33 33 33 33
+ 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 35 35 35
+ 36 36 36 36 36 36 36 36
+ 37 37 37 37 37 37 37 37
+ 38 38 38 38 38 38 38 38
+ 39 39 39 39 39 39 39 39
+ 40 40 40 40 40 40 40 40
+ 41 41 41 41 41 41 41 41
+ 42 42 42 42 42 42 42 42
+ 43 43 43 43 43 43 43 43
+ 44 44 44 44 44 44 44 44
+ 45 45 45 45 45 45 45 45
+ 46 46 46 46 46 46 46 46
+ 47 47 47 47 47 47 47 47
+ 48 48 48 48 48 48 48 48
+ 49 49 49 49 49 49 49 49
+ 50 50 50 50 50 50 50 50
+ 51 51 51 51 51 51 51 51
+ 256
+ >;
+ default-brightness-level = <192>;
+ };
+};
+
+&pwm5 {
+ status = "okay";
+};
+
+&i2c1 {
+ status = "okay";
+ clock-frequency = <400000>;
+
+ tp@38 {
+ status = "okay";
+ pinctrl-0 = <&touch_gpio>;
+ compatible = "hyn,cst128a";
+ reg = <0x38>;
+ reset-gpios = <&gpio1 RK_PA1 GPIO_ACTIVE_LOW>;
+ irq-gpios = <&gpio1 RK_PA0 IRQ_TYPE_LEVEL_LOW>;
+ };
+};
+
+
+&pinctrl {
+ dsi1 {
+ dsi1_rst_gpio: dsi1-rst-gpio {
+ rockchip,pins = <3 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
+ };
+ touch_gpio: touch-gpio {
+ rockchip,pins = <1 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>;
+ };
+ };
+};
+
+/*
+ * video_phy1 needs to be enabled
+ * when dsi1 is enabled
+ */
+&dsi1 {
+ status = "okay";
+};
+
+&dsi1_in_vp0 {
+ status = "disabled";
+};
+
+&dsi1_in_vp1 {
+ status = "okay";
+};
+
+&video_phy1 {
+ status = "okay";
+};
+
+&route_dsi1 {
+ status = "okay";//wucaicheng mipi okay
+ connect = <&vp1_out_dsi1>;
+};
+
+// D310T9362V1
+&dsi1 {
+ status = "okay";
+ rockchip,lane-rate = <480>;//(480+50+60+10)*(800+20+34+2)*60*3*8/2,+100mhz
+ dsi1_panel: panel@0 {
+ status = "okay";
+ compatible = "simple-panel-dsi";
+ reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&dsi1_rst_gpio>;
+ reg = <0>;
+ backlight = <&backlight>;
+ reset-delay-ms = <200>;
+ enable-delay-ms = <100>;
+ prepare-delay-ms = <20>;
+ unprepare-delay-ms = <20>;
+ disable-delay-ms = <20>;
+ init-delay-ms = <120>;
+ dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
+ MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>;
+ dsi,format = <MIPI_DSI_FMT_RGB888>;
+ dsi,lanes = <2>;
+ panel-init-sequence = [
+ // init code
+ 05 78 01 01
+ 05 78 01 11
+ 39 0A 06 FF 77 01 00 00 11
+ 15 0A 02 D1 11
+ 15 0A 02 55 B0 // 80 90 b0
+ 39 0A 06 FF 77 01 00 00 10
+ 39 0A 03 C0 63 00
+ 39 0A 03 C1 09 02
+ 39 0A 03 C2 37 08
+ 15 0A 02 C7 00 // x-dir rotate 0:0x00,rotate 180:0x04
+ 15 0A 02 CC 38
+ 39 0A 11 B0 00 11 19 0C 10 06 07 0A 09 22 04 10 0E 28 30 1C
+ 39 6E 11 B1 00 12 19 0D 10 04 06 07 08 23 04 12 11 28 30 1C
+ 39 0A 06 FF 77 01 00 00 11 // enable bk fun of command 2 BK1
+ 15 0A 02 B0 4D
+ 15 0A 02 B1 60 // 0x56 0x4a 0x5b
+ 15 0A 02 B2 07
+ 15 6E 02 B3 80
+ 15 0A 02 B5 47
+ 15 0A 02 B7 8A
+ 15 0A 02 B8 21
+ 15 0A 02 C1 78
+ 15 0A 02 C2 78
+ 15 0A 02 D0 88
+ 39 0A 04 E0 00 00 02
+ 39 0A 0C E1 01 A0 03 A0 02 A0 04 A0 00 44 44
+ 39 0A 0D E2 00 00 00 00 00 00 00 00 00 00 00 00
+ 39 0A 05 E3 00 00 33 33
+ 39 0A 03 E4 44 44
+ 39 0A 11 E5 01 26 A0 A0 03 28 A0 A0 05 2A A0 A0 07 2C A0 A0
+ 39 0A 05 E6 00 00 33 33
+ 39 0A 03 E7 44 44
+ 39 0A 11 E8 02 26 A0 A0 04 28 A0 A0 06 2A A0 A0 08 2C A0 A0
+ 39 0A 08 EB 00 01 E4 E4 44 00 40
+ 39 0A 11 ED FF F7 65 4F 0B A1 CF FF FF FC 1A B0 F4 56 7F FF
+ 15 0A 02 EE 42 // missing?
+ 39 0A 06 FF 77 01 00 00 00
+ 15 0A 02 36 00 //U&D Y-DIR rotate 0:0x00,rotate 180:0x10
+ 15 0A 02 3A 55
+ 05 78 01 11
+ 05 14 01 29
+ ];
+
+ panel-exit-sequence = [
+ 05 00 01 28
+ 05 00 01 10
+ ];
+
+ disp_timings1: display-timings {
+ native-mode = <&dsi1_timing0>;
+ dsi1_timing0: timing0 {
+ clock-frequency = <30816000>;// (480+50+60+10)*(800+20+34+2)*60
+
+ hactive = <480>;
+ hfront-porch = <50>;
+ hback-porch = <60>;
+ hsync-len = <10>;
+
+ vactive = <800>;
+ vfront-porch = <20>;
+ vback-porch = <34>;
+ vsync-len = <2>;
+
+ hsync-active = <0>;
+ vsync-active = <0>;
+ de-active = <0>;
+ pixelclk-active = <0>;
+
+ swap-rb = <0>;
+ swap-rg = <0>;
+ swap-gb = <0>;
+ };
+ };
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+ panel_in_dsi1: endpoint {
+ remote-endpoint = <&dsi1_out_panel>;
+ };
+ };
+ };
+ };
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@1 {
+ reg = <1>;
+ dsi1_out_panel: endpoint {
+ remote-endpoint = <&panel_in_dsi1>;
+ };
+ };
+ };
+
+};
\ No newline at end of file
diff --git a/arch/arm64/boot/dts/rockchip/tspi-rk3566-user-v10.dts b/arch/arm64/boot/dts/rockchip/tspi-rk3566-user-v10.dts
index bb7e7f13678c..e3369ba87261 100755
--- a/arch/arm64/boot/dts/rockchip/tspi-rk3566-user-v10.dts
+++ b/arch/arm64/boot/dts/rockchip/tspi-rk3566-user-v10.dts
@@ -15,6 +15,7 @@
* 更新:
* 时间 作者 联系 说明
* 2023-07-21 吴才成 1378913492@qq.com v1.0.0
+ * 2024-05-13 千古长夜 36076779@qq.com v2.0.0 添加4g模块电源开关
*********************************************************************/
/dts-v1/;
@@ -32,7 +33,7 @@
// #include "tspi-rk3566-edp-v10.dtsi"
//【开/关】mipi 显示屏幕配置,用户可以基于此复制自己的屏幕,注意EDP与MIPI屏幕互斥,因为共用了VOP如果需要同显自行修改
-// #include "tspi-rk3566-dsi-v10.dtsi"
+#include "tspi-rk3566-dsi-v10.dtsi"
//【开/关】HDMI 显示屏幕配置,里面内容几乎可以不用动,如果不需要hdmi显示直接注释掉即可
#include "tspi-rk3566-hdmi-v10.dtsi"
@@ -48,6 +49,13 @@
model = "lckfb tspi V10 Board";
compatible = "lckfb,tspi-v10", "rockchip,rk3566";
+ // 控制移远4EC20 4G模块电源开关
+ ec20_power:ec20_power {
+ compatible = "ec20_power";
+ ec20power-gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;
+ status = "okay"; //“okay” 开启 “false” 关闭
+ };
+
rk_headset: rk-headset {
compatible = "rockchip_headset";
headset_gpio = <&gpio0 RK_PC5 GPIO_ACTIVE_HIGH>;
diff --git a/arch/arm64/configs/tspi_defconfig b/arch/arm64/configs/tspi_defconfig
index 6cd3c5e09934..b0c49e102a21 100755
--- a/arch/arm64/configs/tspi_defconfig
+++ b/arch/arm64/configs/tspi_defconfig
@@ -455,8 +455,9 @@ CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_GSLX6801=y
CONFIG_TOUCHSCREEN_GSLX680_PAD=y
CONFIG_TOUCHSCREEN_GSLX680_VR=y
-CONFIG_TOUCHSCREEN_GSL3673=y
-CONFIG_TOUCHSCREEN_GSL3673_800X1280=y
+; CONFIG_TOUCHSCREEN_GSL3673=y
+; CONFIG_TOUCHSCREEN_GSL3673_800X1280=y
+CONFIG_TOUCHSCREEN_CST128A_CUST=y
CONFIG_TOUCHSCREEN_GSL3676=y
CONFIG_TOUCHSCREEN_GT9XX=y
CONFIG_TOUCHSCREEN_HYN_CST2XX=y
@@ -541,6 +542,7 @@ CONFIG_BATTERY_RK817=y
CONFIG_CHARGER_RK817=y
CONFIG_BATTERY_RK818=y
CONFIG_CHARGER_RK818=y
+CONFIG_EC20_POWER=y
CONFIG_THERMAL=y
CONFIG_THERMAL_WRITABLE_TRIPS=y
CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR=y
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index ed7e7602924e..43b5bf224a53 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -1410,5 +1410,6 @@ config TOUCHSCREEN_FT5436
If unsure, say N.
source "drivers/input/touchscreen/cyttsp5/Kconfig"
+source "drivers/input/touchscreen/cst128a_cust/Kconfig"
endif
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index effe2cf060ad..f1d1f44e8976 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -128,3 +128,4 @@ obj-$(CONFIG_TOUCHSCREEN_HYN_CST2XX) += hyn_cst2xx/
obj-$(CONFIG_TOUCHSCREEN_FTS) += focaltech_touch/
obj-$(CONFIG_TOUCHSCREEN_FT5436) += focaltech_touch_ft5436/
obj-$(CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP5) += cyttsp5/
+obj-$(CONFIG_TOUCHSCREEN_CST128A_CUST) += cst128a_cust/
diff --git a/drivers/input/touchscreen/cst128a_cust/Kconfig b/drivers/input/touchscreen/cst128a_cust/Kconfig
new file mode 100644
index 000000000000..0d601df0c45c
--- /dev/null
+++ b/drivers/input/touchscreen/cst128a_cust/Kconfig
@@ -0,0 +1,7 @@
+config TOUCHSCREEN_CST128A_CUST
+ tristate "CST128A Touchscreen"
+ depends on I2C
+ default n
+ help
+ Say Y here if you have CST128A touch panel.
+ If unsure, say N.
\ No newline at end of file
diff --git a/drivers/input/touchscreen/cst128a_cust/Makefile b/drivers/input/touchscreen/cst128a_cust/Makefile
new file mode 100644
index 000000000000..1cb7a4386a2c
--- /dev/null
+++ b/drivers/input/touchscreen/cst128a_cust/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_TOUCHSCREEN_CST128A_CUST) += cst128a_ts.o
diff --git a/drivers/input/touchscreen/cst128a_cust/cst128a_ts.c b/drivers/input/touchscreen/cst128a_cust/cst128a_ts.c
new file mode 100644
index 000000000000..c26fb4886e11
--- /dev/null
+++ b/drivers/input/touchscreen/cst128a_cust/cst128a_ts.c
@@ -0,0 +1,288 @@
+/***************************************************************
+本驱动由正点原子的ft5426驱动修改而来
+ ***************************************************************/
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/input/mt.h>
+#include <linux/of_gpio.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+
+/* CST128寄存器相关宏定义 */
+#define CST128_DEVIDE_MODE_REG 0x00 // 模式寄存器
+#define CST128_TD_STATUS_REG 0x02 // 状态寄存器
+#define CST128_TOUCH_DATA_REG 0x03 // 触摸数据读取的起始寄存器
+#define CST128_ID_G_MODE_REG 0xA4 // 中断模式寄存器
+
+#define MAX_SUPPORT_POINTS 5 // cst128最大支持5点触摸
+
+#define TOUCH_EVENT_DOWN 0x00 // 按下
+#define TOUCH_EVENT_UP 0x01 // 抬起
+#define TOUCH_EVENT_ON 0x02 // 接触
+#define TOUCH_EVENT_RESERVED 0x03 // 保留
+
+
+struct hyn_cst128_dev {
+ struct i2c_client *client;
+ struct input_dev *input;
+ int reset_gpio;
+ int irq_gpio;
+};
+
+static int hyn_cst128_ts_write(struct hyn_cst128_dev *cst128,
+ u8 addr, u8 *buf, u16 len)
+{
+ struct i2c_client *client = cst128->client;
+ struct i2c_msg msg;
+ u8 send_buf[6] = {0};
+ int ret;
+
+ send_buf[0] = addr;
+ memcpy(&send_buf[1], buf, len);
+
+ msg.flags = 0; //i2c写
+ msg.addr = client->addr;
+ msg.buf = send_buf;
+ msg.len = len + 1;
+
+ ret = i2c_transfer(client->adapter, &msg, 1);
+ if (1 == ret)
+ return 0;
+ else {
+ dev_err(&client->dev, "%s: write error, addr=0x%x len=%d.\n",
+ __func__, addr, len);
+ return -1;
+ }
+}
+
+static int hyn_cst128_ts_read(struct hyn_cst128_dev *cst128,
+ u8 addr, u8 *buf, u16 len)
+{
+ struct i2c_client *client = cst128->client;
+ struct i2c_msg msg[2];
+ int ret;
+
+ msg[0].flags = 0; // i2c写
+ msg[0].addr = client->addr;
+ msg[0].buf = &addr;
+ msg[0].len = 1; // 1个字节
+
+ msg[1].flags = I2C_M_RD; //i2c读
+ msg[1].addr = client->addr;
+ msg[1].buf = buf;
+ msg[1].len = len;
+
+ ret = i2c_transfer(client->adapter, msg, 2);
+ if (2 == ret)
+ return 0;
+ else {
+ dev_err(&client->dev, "%s: read error, addr=0x%x len=%d.\n",
+ __func__, addr, len);
+ return -1;
+ }
+}
+
+static int hyn_cst128_ts_reset(struct hyn_cst128_dev *cst128)
+{
+ struct i2c_client *client = cst128->client;
+ int ret;
+
+ /* 从设备树中获取复位管脚 */
+ cst128->reset_gpio = of_get_named_gpio(client->dev.of_node, "reset-gpios", 0);
+ if (!gpio_is_valid(cst128->reset_gpio)) {
+ dev_err(&client->dev, "Failed to get ts reset gpio\n");
+ return cst128->reset_gpio;
+ }
+
+ /* 申请使用管脚 */
+ ret = devm_gpio_request_one(&client->dev, cst128->reset_gpio,
+ GPIOF_OUT_INIT_HIGH, "cst128 reset");
+ if (ret < 0)
+ return ret;
+
+ msleep(20);
+ gpio_set_value_cansleep(cst128->reset_gpio, 0); // 拉低复位引脚
+ msleep(5);
+ gpio_set_value_cansleep(cst128->reset_gpio, 1); // 拉高复位引脚,结束复位
+
+ return 0;
+}
+
+static irqreturn_t hyn_cst128_ts_isr(int irq, void *dev_id)
+{
+ struct hyn_cst128_dev *cst128 = dev_id;
+ u8 rdbuf[30] = {0};
+ int i, type, x, y, id;
+ bool down;
+ int ret;
+
+ /* 读取CST128触摸点坐标从0x02寄存器开始,连续读取29个寄存器 */
+ ret = hyn_cst128_ts_read(cst128, CST128_TD_STATUS_REG, rdbuf, 29);
+ if (ret)
+ goto out;
+
+ for (i = 0; i < MAX_SUPPORT_POINTS; i++) {
+
+ u8 *buf = &rdbuf[i * 6 + 1];
+
+ /* 以第一个触摸点为例,寄存器TOUCH1_XH(地址0x03),各bit位描述如下:
+ * bit7:6 Event flag 0:按下 1:释放 2:接触 3:没有事件
+ * bit5:4 保留
+ * bit3:0 X轴触摸点的11~8位
+ */
+ type = buf[0] >> 6; // 获取触摸点的Event Flag
+ if (type == TOUCH_EVENT_RESERVED)
+ continue;
+
+ y = ((buf[2] << 8) | buf[3]) & 0x0fff;
+ x = (((buf[0] << 8) | buf[1]) & 0x0fff);
+ x = 480 - x;
+
+ /* 以第一个触摸点为例,寄存器TOUCH1_YH(地址0x05),各bit位描述如下:
+ * bit7:4 Touch ID 触摸ID,表示是哪个触摸点
+ * bit3:0 Y轴触摸点的11~8位。
+ */
+ id = (buf[2] >> 4) & 0x0f;
+ down = type != TOUCH_EVENT_UP;
+
+ input_mt_slot(cst128->input, id);
+ input_mt_report_slot_state(cst128->input, MT_TOOL_FINGER, down);
+
+ if (!down)
+ continue;
+
+ input_report_abs(cst128->input, ABS_MT_POSITION_X, x);
+ input_report_abs(cst128->input, ABS_MT_POSITION_Y, y);
+ }
+
+ input_mt_report_pointer_emulation(cst128->input, true);
+ input_sync(cst128->input);
+
+out:
+ return IRQ_HANDLED;
+}
+
+static int hyn_cst128_ts_irq(struct hyn_cst128_dev *cst128)
+{
+ struct i2c_client *client = cst128->client;
+ int ret;
+
+ /* 从设备树中获取中断管脚 */
+ cst128->irq_gpio = of_get_named_gpio(client->dev.of_node, "irq-gpios", 0);
+ if (!gpio_is_valid(cst128->irq_gpio)) {
+ dev_err(&client->dev, "Failed to get ts interrupt gpio\n");
+ return cst128->irq_gpio;
+ }
+
+ /* 申请使用管脚 */
+ ret = devm_gpio_request_one(&client->dev, cst128->irq_gpio,
+ GPIOF_IN, "cst128 interrupt");
+ if (ret < 0)
+ return ret;
+
+ /* 注册中断服务函数 */
+ ret = devm_request_threaded_irq(&client->dev, gpio_to_irq(cst128->irq_gpio),
+ NULL, hyn_cst128_ts_isr, IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ client->name, cst128);
+ if (ret) {
+ dev_err(&client->dev, "Failed to request touchscreen IRQ.\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int hyn_cst128_ts_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct hyn_cst128_dev *cst128;
+ struct input_dev *input;
+ u8 data;
+ int ret;
+
+ /* 实例化一个struct hyn_cst128_dev对象 */
+ cst128 = devm_kzalloc(&client->dev, sizeof(struct hyn_cst128_dev), GFP_KERNEL);
+ if (!cst128) {
+ dev_err(&client->dev, "Failed to allocate cst128 driver data.\n");
+ return -ENOMEM;
+ }
+
+ cst128->client = client;
+
+ /* 复位CST128触摸芯片 */
+ ret = hyn_cst128_ts_reset(cst128);
+ if (ret)
+ return ret;
+
+ msleep(5);
+
+ /* 初始化CST128 */
+ data = 0;
+ hyn_cst128_ts_write(cst128, CST128_DEVIDE_MODE_REG, &data, 1);
+ data = 1;
+ hyn_cst128_ts_write(cst128, CST128_ID_G_MODE_REG, &data, 1);
+
+ /* 申请、注册中断服务函数 */
+ ret = hyn_cst128_ts_irq(cst128);
+ if (ret)
+ return ret;
+
+ /* 注册input设备 */
+ input = devm_input_allocate_device(&client->dev);
+ if (!input) {
+ dev_err(&client->dev, "Failed to allocate input device.\n");
+ return -ENOMEM;
+ }
+
+ cst128->input = input;
+ input->name = "CST128 TouchScreen";
+ input->id.bustype = BUS_I2C;
+
+ input_set_abs_params(input, ABS_MT_POSITION_X,
+ 0, 480, 0, 0);
+ input_set_abs_params(input, ABS_MT_POSITION_Y,
+ 0, 800, 0, 0);
+
+ ret = input_mt_init_slots(input, MAX_SUPPORT_POINTS, INPUT_MT_DIRECT);
+ if (ret) {
+ dev_err(&client->dev, "Failed to init MT slots.\n");
+ return ret;
+ }
+
+ ret = input_register_device(input);
+ if (ret)
+ return ret;
+
+ i2c_set_clientdata(client, cst128);
+ return 0;
+}
+
+static int hyn_cst128_ts_remove(struct i2c_client *client)
+{
+ struct hyn_cst128_dev *cst128 = i2c_get_clientdata(client);
+ input_unregister_device(cst128->input);
+ return 0;
+}
+
+static const struct of_device_id hyn_cst128_of_match[] = {
+ { .compatible = "hyn,cst128a", },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, hyn_cst128_of_match);
+
+static struct i2c_driver hyn_cst128_ts_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "hyn_cst128a",
+ .of_match_table = of_match_ptr(hyn_cst128_of_match),
+ },
+ .probe = hyn_cst128_ts_probe,
+ .remove = hyn_cst128_ts_remove,
+};
+
+module_i2c_driver(hyn_cst128_ts_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("leefei");
+MODULE_INFO(intree, "Y");
+
diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index ab9fdd0721bc..2dacadb793da 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -695,4 +695,6 @@ config CHARGER_RK818
If you say yes here you will get support for the charger of RK818 PMIC.
This driver can give support for Rk818 Charger Interface.
+source "drivers/power/supply/ec20_power/Kconfig"
+
endif # POWER_SUPPLY
diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile
index 4e8be4a2f1e0..1acf518a0b66 100644
--- a/drivers/power/supply/Makefile
+++ b/drivers/power/supply/Makefile
@@ -92,3 +92,4 @@ obj-$(CONFIG_BATTERY_RK817) += rk817_battery.o
obj-$(CONFIG_CHARGER_RK817) += rk817_charger.o
obj-$(CONFIG_BATTERY_RK818) += rk818_battery.o
obj-$(CONFIG_CHARGER_RK818) += rk818_charger.o
+obj-$(CONFIG_EC20_POWER) += ec20_power/
\ No newline at end of file
diff --git a/drivers/power/supply/ec20_power/Kconfig b/drivers/power/supply/ec20_power/Kconfig
new file mode 100644
index 000000000000..e24214d7bc2e
--- /dev/null
+++ b/drivers/power/supply/ec20_power/Kconfig
@@ -0,0 +1,7 @@
+config EC20_POWER
+ tristate "EC20 POWER"
+ depends on GPIOLIB
+ default n
+ help
+ Say Y here if you have EC20 module.
+ If unsure, say N.
\ No newline at end of file
diff --git a/drivers/power/supply/ec20_power/Makefile b/drivers/power/supply/ec20_power/Makefile
new file mode 100644
index 000000000000..6cd90188504f
--- /dev/null
+++ b/drivers/power/supply/ec20_power/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_EC20_POWER) += ec20_power.o
diff --git a/drivers/power/supply/ec20_power/ec20_power.c b/drivers/power/supply/ec20_power/ec20_power.c
new file mode 100644
index 000000000000..96627e0db44b
--- /dev/null
+++ b/drivers/power/supply/ec20_power/ec20_power.c
@@ -0,0 +1,250 @@
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/gpio.h>
+#include <linux/cdev.h>
+#include <linux/device.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_gpio.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+/***************************************************************
+文件名 : ec20_power.c
+作者 : 千古长夜
+版本 : V1.0
+描述 : EC20 4g模块电源控制。
+***************************************************************/
+#define EC20POWER_CNT 1 /* 设备号个数 */
+#define EC20POWER_NAME "ec20_power" /* 名字 */
+#define EC20POWEROFF 0 /* 关灯 */
+#define EC20POWERON 1 /* 开灯 */
+
+/* ec20_power设备结构体 */
+struct ec20_power_dev{
+ dev_t devid; /* 设备号 */
+ struct cdev cdev; /* cdev */
+ struct class *class; /* 类 */
+ struct device *device; /* 设备 */
+ int major; /* 主设备号 */
+ int minor; /* 次设备号 */
+ struct device_node *nd; /* 设备节点 */
+ int pwd_gpio; /* ec20power所使用的GPIO编号 */
+};
+
+struct ec20_power_dev ec20_power; /* ec20power设备 */
+
+/*
+ * @description : 打开设备
+ * @param – inode : 传递给驱动的inode
+ * @param - filp : 设备文件,file结构体有个叫做private_data的成员变量
+ * 一般在open的时候将private_data指向设备结构体。
+ * @return : 0 成功;其他 失败
+ */
+static int ec20power_open(struct inode *inode, struct file *filp)
+{
+ filp->private_data = &ec20_power; /* 设置私有数据 */
+ return 0;
+}
+
+/*
+ * @description : 从设备读取数据
+ * @param - filp : 要打开的设备文件(文件描述符)
+ * @param - buf : 返回给用户空间的数据缓冲区
+ * @param - cnt : 要读取的数据长度
+ * @param - offt : 相对于文件首地址的偏移
+ * @return : 读取的字节数,如果为负值,表示读取失败
+ */
+static ssize_t ec20power_read(struct file *filp, char __user *buf, size_t cnt, loff_t *offt)
+{
+ return 0;
+}
+
+/*
+ * @description : 向设备写数据
+ * @param - filp : 设备文件,表示打开的文件描述符
+ * @param - buf : 要写给设备写入的数据
+ * @param - cnt : 要写入的数据长度
+ * @param - offt : 相对于文件首地址的偏移
+ * @return : 写入的字节数,如果为负值,表示写入失败
+ */
+static ssize_t ec20power_write(struct file *filp, const char __user *buf,
+ size_t cnt, loff_t *offt)
+{
+ int retvalue;
+ unsigned char databuf[1];
+ unsigned char ec20powerstat;
+ struct ec20_power_dev *dev = filp->private_data;
+
+ retvalue = copy_from_user(databuf, buf, cnt);
+ if(retvalue < 0) {
+ printk("kernel write failed!\r\n");
+ return -EFAULT;
+ }
+
+ ec20powerstat = databuf[0]; /* 获取状态值 */
+
+ if(ec20powerstat == EC20POWERON) {
+ gpio_set_value(dev->pwd_gpio, 1); /* 打开EC20POWER */
+ } else if(ec20powerstat == EC20POWEROFF) {
+ gpio_set_value(dev->pwd_gpio, 0); /* 关闭EC20POWER */
+ }
+ return 0;
+}
+
+/*
+ * @description : 关闭/释放设备
+ * @param - filp : 要关闭的设备文件(文件描述符)
+ * @return : 0 成功;其他 失败
+ */
+static int ec20power_release(struct inode *inode, struct file *filp)
+{
+ return 0;
+}
+
+/* 设备操作函数 */
+static struct file_operations ec20_power_fops = {
+ .owner = THIS_MODULE,
+ .open = ec20power_open,
+ .read = ec20power_read,
+ .write = ec20power_write,
+ .release = ec20power_release,
+};
+
+/*
+ * @description : 驱动出口函数
+ * @param : 无
+ * @return : 无
+ */
+static int __init ec20power_init(void)
+{
+ int ret = 0;
+ const char *str;
+
+ /* 设置所使用的GPIO */
+ /* 1、获取设备节点:ec20_power */
+ ec20_power.nd = of_find_node_by_path("/ec20_power");
+ if(ec20_power.nd == NULL) {
+ printk("ec20_power node not find!\r\n");
+ return -EINVAL;
+ }
+
+ /* 2.读取status属性 */
+ ret = of_property_read_string(ec20_power.nd, "status", &str);
+ if(ret < 0)
+ return -EINVAL;
+
+ if (strcmp(str, "okay"))
+ return -EINVAL;
+
+ /* 3、获取compatible属性值并进行匹配 */
+ ret = of_property_read_string(ec20_power.nd, "compatible", &str);
+ if(ret < 0) {
+ printk("ec20_power: Failed to get compatible property\n");
+ return -EINVAL;
+ }
+
+ if (strcmp(str, "ec20_power")) {
+ printk("ec20_power: Compatible match failed\n");
+ return -EINVAL;
+ }
+
+ /* 4、 获取设备树中的gpio属性,得到所使用的编号 */
+ ec20_power.pwd_gpio = of_get_named_gpio(ec20_power.nd, "ec20power-gpio", 0);
+ if(ec20_power.pwd_gpio < 0) {
+ printk("can't get ec20power-gpio");
+ return -EINVAL;
+ }
+ printk("ec20power-gpio num = %d\r\n", ec20_power.pwd_gpio);
+
+ /* 5.向gpio子系统申请使用GPIO */
+ ret = gpio_request(ec20_power.pwd_gpio, "EC20POWER-GPIO");
+ if (ret) {
+ printk(KERN_ERR "ec20_power: Failed to request ec20power-gpio\n");
+ return ret;
+ }
+
+ /* 6、设置GPIO为输出,并且输出高电平,默认开启EC20 */
+ ret = gpio_direction_output(ec20_power.pwd_gpio, 1);
+ if(ret < 0) {
+ printk("can't set gpio!\r\n");
+ }
+
+ /* 注册字符设备驱动 */
+ /* 1、创建设备号 */
+ if (ec20_power.major) { /* 定义了设备号 */
+ ec20_power.devid = MKDEV(ec20_power.major, 0);
+ ret = register_chrdev_region(ec20_power.devid, EC20POWER_CNT, EC20POWER_NAME);
+ if(ret < 0) {
+ pr_err("cannot register %s char driver [ret=%d]\n", EC20POWER_NAME, EC20POWER_CNT);
+ goto free_gpio;
+ }
+ } else { /* 没有定义设备号 */
+ ret = alloc_chrdev_region(&ec20_power.devid, 0, EC20POWER_CNT, EC20POWER_NAME); /* 申请设备号 */
+ if(ret < 0) {
+ pr_err("%s Couldn't alloc_chrdev_region, ret=%d\r\n", EC20POWER_NAME, ret);
+ goto free_gpio;
+ }
+ ec20_power.major = MAJOR(ec20_power.devid); /* 获取分配号的主设备号 */
+ ec20_power.minor = MINOR(ec20_power.devid); /* 获取分配号的次设备号 */
+ }
+ printk("ec20_power major=%d,minor=%d\r\n",ec20_power.major, ec20_power.minor);
+
+ /* 2、初始化cdev */
+ ec20_power.cdev.owner = THIS_MODULE;
+ cdev_init(&ec20_power.cdev, &ec20_power_fops);
+
+ /* 3、添加一个cdev */
+ cdev_add(&ec20_power.cdev, ec20_power.devid, EC20POWER_CNT);
+ if(ret < 0)
+ goto del_unregister;
+
+ /* 4、创建类 */
+ ec20_power.class = class_create(THIS_MODULE, EC20POWER_NAME);
+ if (IS_ERR(ec20_power.class)) {
+ goto del_cdev;
+ }
+
+ /* 5、创建设备 */
+ ec20_power.device = device_create(ec20_power.class, NULL, ec20_power.devid, NULL, EC20POWER_NAME);
+ if (IS_ERR(ec20_power.device)) {
+ goto destroy_class;
+ }
+ return 0;
+
+destroy_class:
+ class_destroy(ec20_power.class);
+del_cdev:
+ cdev_del(&ec20_power.cdev);
+del_unregister:
+ unregister_chrdev_region(ec20_power.devid, EC20POWER_CNT);
+free_gpio:
+ gpio_free(ec20_power.pwd_gpio);
+ return -EIO;
+}
+
+/*
+ * @description : 驱动出口函数
+ * @param : 无
+ * @return : 无
+ */
+static void __exit ec20power_exit(void)
+{
+ /* 注销字符设备驱动 */
+ cdev_del(&ec20_power.cdev);/* 删除cdev */
+ unregister_chrdev_region(ec20_power.devid, EC20POWER_CNT);
+ device_destroy(ec20_power.class, ec20_power.devid);/* 注销设备 */
+ class_destroy(ec20_power.class);/* 注销类 */
+ gpio_free(ec20_power.pwd_gpio); /* 释放GPIO */
+}
+
+module_init(ec20power_init);
+module_exit(ec20power_exit);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("YOUMENG");
+MODULE_INFO(intree, "Y");
+
--
2.17.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。