From 9cc3fa38f806968a2353c18088c1f565f3933ef4 Mon Sep 17 00:00:00 2001 From: Lu Date: Mon, 20 May 2024 09:20:56 +0800 Subject: [PATCH] lpi4a: add pocket4a & plastic4a initial support --- arch/riscv/boot/dts/thead/Makefile | 2 + .../boot/dts/thead/th1520-lpi4a-dsi0-hdmi.dts | 2 +- .../boot/dts/thead/th1520-lpi4a-dsi0.dts | 2 +- .../boot/dts/thead/th1520-lpi4a-laptop.dts | 8 + .../dts/thead/th1520-lpi4a-plastic-16g.dts | 17 ++ .../boot/dts/thead/th1520-lpi4a-plastic.dts | 80 +++++++ .../boot/dts/thead/th1520-lpi4a-pocket.dts | 219 ++++++++++++++++++ arch/riscv/boot/dts/thead/th1520-lpi4a.dtsi | 33 ++- arch/riscv/configs/revyos_defconfig | 8 +- drivers/gpu/drm/panel/panel-simple.c | 34 +++ 10 files changed, 400 insertions(+), 5 deletions(-) create mode 100644 arch/riscv/boot/dts/thead/th1520-lpi4a-plastic-16g.dts create mode 100644 arch/riscv/boot/dts/thead/th1520-lpi4a-plastic.dts create mode 100644 arch/riscv/boot/dts/thead/th1520-lpi4a-pocket.dts diff --git a/arch/riscv/boot/dts/thead/Makefile b/arch/riscv/boot/dts/thead/Makefile index 7d44139ba..9c8390e1c 100644 --- a/arch/riscv/boot/dts/thead/Makefile +++ b/arch/riscv/boot/dts/thead/Makefile @@ -56,7 +56,9 @@ dtb-$(CONFIG_SOC_THEAD_FIRE) += fire-emu-soc-base-sec.dtb dtb-$(CONFIG_SOC_THEAD) += th1520-beagle.dtb dtb-$(CONFIG_SOC_THEAD) += th1520-lpi4a-16gb.dtb dtb-$(CONFIG_SOC_THEAD) += th1520-lpi4a-laptop.dtb +dtb-$(CONFIG_SOC_THEAD) += th1520-lpi4a-pocket.dtb dtb-$(CONFIG_SOC_THEAD) += th1520-lpi4a-console.dtb th1520-lpi4a-console-16g.dtb +dtb-$(CONFIG_SOC_THEAD) += th1520-lpi4a-plastic.dtb th1520-lpi4a-plastic-16g.dtb dtb-$(CONFIG_SOC_THEAD) += th1520-lpi4a-cluster.dtb th1520-lpi4a-cluster-16gb.dtb dtb-$(CONFIG_SOC_THEAD) += th1520-lpi4a-z14inch-m0.dtb th1520-lpi4a-z14inch-m0-16g.dtb dtb-$(CONFIG_SOC_THEAD) += th1520-milkv-meles.dtb th1520-milkv-meles-4g.dtb th1520-milkv-meles-dsi0.dtb diff --git a/arch/riscv/boot/dts/thead/th1520-lpi4a-dsi0-hdmi.dts b/arch/riscv/boot/dts/thead/th1520-lpi4a-dsi0-hdmi.dts index b7dbee837..205ae77b5 100644 --- a/arch/riscv/boot/dts/thead/th1520-lpi4a-dsi0-hdmi.dts +++ b/arch/riscv/boot/dts/thead/th1520-lpi4a-dsi0-hdmi.dts @@ -32,7 +32,7 @@ }; &i2c3 { - touch@14 { + goodix_tp: touch@14 { #gpio-cells = <2>; compatible = "goodix,gt9271"; reg = <0x14>; diff --git a/arch/riscv/boot/dts/thead/th1520-lpi4a-dsi0.dts b/arch/riscv/boot/dts/thead/th1520-lpi4a-dsi0.dts index 72759f33d..8bc585959 100644 --- a/arch/riscv/boot/dts/thead/th1520-lpi4a-dsi0.dts +++ b/arch/riscv/boot/dts/thead/th1520-lpi4a-dsi0.dts @@ -11,7 +11,7 @@ }; &i2c3 { - touch@14 { + goodix_tp: touch@14 { touchscreen-size-x = <800>; touchscreen-size-y = <1200>; status = "okay"; diff --git a/arch/riscv/boot/dts/thead/th1520-lpi4a-laptop.dts b/arch/riscv/boot/dts/thead/th1520-lpi4a-laptop.dts index 4ba4884da..d2112006e 100644 --- a/arch/riscv/boot/dts/thead/th1520-lpi4a-laptop.dts +++ b/arch/riscv/boot/dts/thead/th1520-lpi4a-laptop.dts @@ -76,9 +76,17 @@ vin-supply = <®_sys_vcc_5v>; gpio = <&pcal6408ahk_c 1 1>; enable-active-high; + regulator-boot-on; regulator-always-on; }; + sata_pwr_switch: sata-pwr-switch { + status = "okay"; + compatible = "reg-userspace-consumer"; + regulator-name = "sata-pwr-consumer"; + vcc-supply = <®_sata_vcc_5v>; + }; + audio_amp: regulator-audio-amp-en { status = "okay"; compatible = "regulator-fixed"; diff --git a/arch/riscv/boot/dts/thead/th1520-lpi4a-plastic-16g.dts b/arch/riscv/boot/dts/thead/th1520-lpi4a-plastic-16g.dts new file mode 100644 index 000000000..12090f809 --- /dev/null +++ b/arch/riscv/boot/dts/thead/th1520-lpi4a-plastic-16g.dts @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Alibaba Group Holding Limited. + */ + +#include "th1520-lpi4a-plastic.dts" + +/ { + memory@0 { + device_type = "memory"; + reg = <0x0 0x200000 0x3 0xffe00000>; + }; +}; + +&cmamem { + alloc-ranges = <0x3 0xe4000000 0 0x14000000>; // [0x3E400_0000 ~ 0x3F800_0000] +}; diff --git a/arch/riscv/boot/dts/thead/th1520-lpi4a-plastic.dts b/arch/riscv/boot/dts/thead/th1520-lpi4a-plastic.dts new file mode 100644 index 000000000..8f40850c0 --- /dev/null +++ b/arch/riscv/boot/dts/thead/th1520-lpi4a-plastic.dts @@ -0,0 +1,80 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2024 Sipeed. + */ + +#include +#include "th1520-lpi4a-laptop.dts" + +/ { + model = "T-HEAD Light Lichee Pi 4A configuration for Plastic laptop"; +}; + +&dsi0_panel0 { + compatible = "cmn,5171_1920x1200_40Hz"; +}; + +&i2c2 { + touchpad: touchpad@2c { + compatible = "hid-over-i2c"; + reg = <0x2c>; + hid-descr-addr = <0x0020>; + interrupt-parent = <&gpio1_porta>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + }; +}; + +&cw2015 { + cellwise,battery-profile = /bits/ 8 < + 0x17 0x67 0x72 0x68 0x66 0x63 0x62 0x5A + 0x64 0x61 0x4D 0x57 0x5A 0x51 0x43 0x38 + 0x31 0x2A 0x24 0x22 0x29 0x31 0x3E 0x4C + 0x29 0x4D 0x0B 0x85 0x1C 0x38 0x47 0x57 + 0x5D 0x5E 0x5F 0x60 0x3F 0x1A 0x6F 0x41 + 0x0A 0x43 0x12 0x38 0x7B 0x95 0x9A 0x18 + 0x4B 0x6F 0x9E 0xD5 0x80 0x57 0x87 0xCB + 0x2F 0x00 0x64 0xA5 0xB5 0x13 0x54 0xB9 + >; +}; + +<8911 { + // CMN5171 + //lontium,pclk = <154000000>; // 60Hz + lontium,pclk = <127750000>; // 50Hz + //lontium,pclk = <757500000>; // 30Hz + lontium,hact = <1920>; + lontium,vact = <1200>; + lontium,hbp = <84>; + lontium,hfp = <46>; + lontium,vbp = <20>; + lontium,vfp = <10>; + lontium,hs = <30>; + lontium,vs = <6>; + lontium,mipi_lane = <2>; + lontium,lane_cnt = <2>; + lontium,color = <1>; //Color Depth 0:6bit 1:8bit + lontium,test = <0>; +}; + +&fan_config0 { + temperature = <40000>; +}; + +&fan_config1 { + temperature = <60000>; +}; + +&fan_config2 { + temperature = <80000>; +}; + +&fan { + pwms = <&pwm 1 100000 0>; + cooling-levels = <0x10 0x30 0x50 0xFF>; +}; + +&lcd0_backlight { + //pwms = <&pwm 0 50000>; + pwms = <&pwm 0 1000000>; + default-brightness-level = <40>; +}; diff --git a/arch/riscv/boot/dts/thead/th1520-lpi4a-pocket.dts b/arch/riscv/boot/dts/thead/th1520-lpi4a-pocket.dts new file mode 100644 index 000000000..fbd8a2356 --- /dev/null +++ b/arch/riscv/boot/dts/thead/th1520-lpi4a-pocket.dts @@ -0,0 +1,219 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2023 Sipeed. + */ + +#include "th1520-lpi4a-dsi0-hdmi.dts" + +/ { + model = "LicheePocket4A 8G"; + compatible = "thead,light", "sipeed,pocket4a"; + + charger: dc-charger { + compatible = "gpio-charger"; + charger-type = "mains"; + gpios = <&gpio1_porta 3 GPIO_ACTIVE_HIGH>; + }; +}; + +&uart1 { + status = "okay"; +}; + +&uart3 { + status = "okay"; +}; + +&lcd0_backlight { + pwms = <&pwm 0 10000>; // 100Khz + brightness-levels = <0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 + 36 37 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>; + default-brightness-level = <30>; +}; + +&fan { + pwms = <&pwm 1 10000000 0>; + //cooling-levels = <0 64 192 255>; + cooling-levels = <192 192 192 255>; +}; + +&i2c0 { + /delete-node/ gpio@18; + + cw2015: cw2015@62 { + compatible = "cellwise,cw2015"; + status = "disabled"; + reg = <0x62>; + cellwise,monitor-interval-ms = <5000>; + power-supplies = <&charger>; + cellwise,battery-profile = /bits/ 8 < + 0x17 0x67 0x80 0x73 0x6E 0x6C 0x6B 0x63 + 0x77 0x51 0x5C 0x58 0x50 0x4C 0x48 0x36 + 0x15 0x0C 0x0C 0x19 0x5B 0x7D 0x6F 0x69 + 0x69 0x5B 0x0C 0x29 0x20 0x40 0x52 0x59 + 0x57 0x56 0x54 0x4F 0x3B 0x1F 0x7F 0x17 + 0x06 0x1A 0x30 0x5A 0x85 0x93 0x96 0x2D + 0x48 0x77 0x9C 0xB3 0x80 0x52 0x94 0xCB + 0x2F 0x00 0x64 0xA5 0xB5 0x11 0xF0 0x11 + >; + }; +}; + +&i2c3 { + /delete-node/ gpio@18; +}; + +&goodix_tp { + #gpio-cells = <2>; + compatible = "goodix,gt9271"; + reg = <0x14>; + interrupt-parent = <&ao_gpio_porta>; + interrupts = <3 0>; + irq-gpios = <&ao_gpio_porta 3 0>; + reset-gpios = <&pcal6408ahk_c 0 0>; + touchscreen-size-x = <800>; + touchscreen-size-y = <1280>; + status = "okay"; +}; + +®_tp_pwr_en { + /delete-property/ gpio; +}; + +®_usb_hub_vdd1v2 { + /delete-property/ gpio; +}; + +&vvcam_sensor1 { + sensor_pdn = <&gpio1_porta 30 0>; + sensor_rst = <&pcal6408ahk_c 2 0>; + i2c_bus = /bits/ 8 <0>; +}; + +&key_volup { + gpios = <&gpio2_porta 16 0x1>; +}; + +®_usb_hub_vcc5v { + /delete-property/ gpio; +}; + +&soc_vdd33_lcd0_en_reg { + /delete-property/ gpio; +}; + +&soc_vdd18_lcd0_en_reg { + /delete-property/ gpio; +}; + +&soc_avdd28_rgb_reg { + /delete-property/ gpio; +}; + +&soc_dovdd18_rgb_reg { + /delete-property/ gpio; +}; + +&soc_dvdd12_rgb_reg { + /delete-property/ gpio; +}; + +&soc_avdd25_ir_reg { + /delete-property/ gpio; +}; + +&soc_dovdd18_ir_reg { + /delete-property/ gpio; +}; + +&soc_dvdd12_ir_reg { + /delete-property/ gpio; +}; + +&soc_cam2_avdd25_ir_reg { + /delete-property/ gpio; +}; + +&soc_cam2_dovdd18_ir_reg { + /delete-property/ gpio; +}; + +&soc_cam2_dvdd12_ir_reg { + /delete-property/ gpio; +}; + +&dsi0_panel0 { + compatible = "chongzhou,cz101b4001", "jadard,jd9365da-h3"; + backlight = <&lcd0_backlight>; + reset-gpio = <&pcal6408ahk_c 3 0>; /* active low */ + /delete-property/ hsvcc-supply; + /delete-property/ vspn3v3-supply; +}; + +&usb_1 { + /delete-property/ hubswitch-gpio; + /delete-property/ hub1v2-supply; + /delete-property/ hub5v-supply; +}; + +&cpus { + c910_0: cpu@0 { + operating-points = < + /* kHz uV */ + 300000 500000 + 800000 700000 + 1500000 800000 + >; + light,dvddm-operating-points = < + /* kHz uV */ + 300000 800000 + 800000 800000 + 1500000 800000 + >; + }; + c910_1: cpu@1 { + operating-points = < + /* kHz uV */ + 300000 500000 + 800000 700000 + 1500000 800000 + >; + light,dvddm-operating-points = < + /* kHz uV */ + 300000 800000 + 800000 800000 + 1500000 800000 + >; + }; + c910_2: cpu@2 { + + operating-points = < + /* kHz uV */ + 300000 500000 + 800000 700000 + 1500000 800000 + >; + light,dvddm-operating-points = < + /* kHz uV */ + 300000 800000 + 800000 800000 + 1500000 800000 + >; + }; + c910_3: cpu@3 { + + operating-points = < + /* kHz uV */ + 300000 500000 + 800000 700000 + 1500000 800000 + >; + light,dvddm-operating-points = < + /* kHz uV */ + 300000 800000 + 800000 800000 + 1500000 800000 + >; + }; +}; diff --git a/arch/riscv/boot/dts/thead/th1520-lpi4a.dtsi b/arch/riscv/boot/dts/thead/th1520-lpi4a.dtsi index 29e38c089..eb27dd6fe 100644 --- a/arch/riscv/boot/dts/thead/th1520-lpi4a.dtsi +++ b/arch/riscv/boot/dts/thead/th1520-lpi4a.dtsi @@ -295,7 +295,7 @@ debounce-interval = <1>; gpios = <&gpio1_porta 19 0x1>; }; - key-volumeup { + key_volup: key-volumeup { label = "Volume Up Key"; linux,code = ; debounce-interval = <1>; @@ -1174,7 +1174,6 @@ >; }; - pinctrl_uart3_tx_is_gpio: uart3txisgpiogrp { thead,pins = < FM_UART3_TXD 0x3 0x202 @@ -1184,6 +1183,7 @@ + pinctrl_wifi_wake: wifi_grp { thead,pins = < FM_GPIO0_27 0x0 0x202 @@ -1525,6 +1525,13 @@ channel0 { channel_id = <0>; status = "okay"; + sensor0 { + subdev_name = "vivcam"; + idx = <0>; + csi_idx = <0>; + mode_idx = <0>; + path_type = "SENSOR_VGA_RAW12_LINER"; + }; sensor1 { subdev_name = "vivcam"; idx = <3>; @@ -1550,6 +1557,13 @@ }; }; channel1 { + sensor0 { + subdev_name = "vivcam"; + idx = <0>; + csi_idx = <0>; + mode_idx = <0>; + path_type = "SENSOR_VGA_RAW12_LINER"; + }; sensor1 { subdev_name = "vivcam"; idx = <3>; @@ -1570,6 +1584,13 @@ }; }; channel2 { + sensor0 { + subdev_name = "vivcam"; + idx = <0>; + csi_idx = <0>; + mode_idx = <0>; + path_type = "SENSOR_VGA_RAW12_LINER"; + }; sensor1 { subdev_name = "vivcam"; idx = <3>; @@ -1595,6 +1616,14 @@ vi_mem_pool_region = <0>; // vi_mem: framebuffer, region[0] status = "okay"; channel0 { + sensor0 { + subdev_name = "vivcam"; + idx = <0>; + csi_idx = <0>; + mode_idx = <0>; + path_type = "SENSOR_VGA_RAW12_LINER"; + + }; sensor1 { subdev_name = "vivcam"; idx = <3>; diff --git a/arch/riscv/configs/revyos_defconfig b/arch/riscv/configs/revyos_defconfig index 235a29df9..1130665a7 100644 --- a/arch/riscv/configs/revyos_defconfig +++ b/arch/riscv/configs/revyos_defconfig @@ -239,6 +239,10 @@ CONFIG_LIGHT_PMIC_WATCHDOG=y CONFIG_ABX500_CORE=y CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_REGULATOR_VIRTUAL_CONSUMER=y +CONFIG_REGULATOR_USERSPACE_CONSUMER=y +CONFIG_REGULATOR_GPIO=y +CONFIG_REGULATOR_PWM=y CONFIG_MEDIA_SUPPORT=y # CONFIG_MEDIA_ANALOG_TV_SUPPORT is not set # CONFIG_MEDIA_DIGITAL_TV_SUPPORT is not set @@ -293,7 +297,7 @@ CONFIG_DRM_PANEL_HX8394=y CONFIG_DRM_PANEL_JADARD_JD9365DA_H3=y CONFIG_DRM_PANEL_MINGJUN_070BI30IA2=y CONFIG_DRM_PANEL_HX8279=y -CONFIG_DRM_LONTIUM_LT8911EXB=m +CONFIG_DRM_LONTIUM_LT8911EXB=y CONFIG_DRM_ETNAVIV=m CONFIG_DRM_VERISILICON=y CONFIG_DRM_POWERVR_ROGUE=m @@ -314,8 +318,10 @@ CONFIG_SND_SOC_ES8156=y CONFIG_SND_SOC_WM8960=y CONFIG_SND_SIMPLE_CARD=y CONFIG_SND_AUDIO_GRAPH_CARD=y +CONFIG_HIDRAW=m CONFIG_UHID=y CONFIG_HID_PID=y +CONFIG_HID_MULTITOUCH=m CONFIG_USB_HIDDEV=y CONFIG_I2C_HID=m CONFIG_USB=y diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 1edc874b7..c417aba87 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -4570,6 +4570,37 @@ static const struct panel_desc_dsi z14inch_2160x1440_40Hz = { }; +/* TODO: move timing into device tree */ +static const struct drm_display_mode cmn_5171_1920x1200_40Hz_mode = { + .clock = 127750, + .hdisplay = 1920, + .hsync_start = 1920 + 46, /* hact + hfp */ + .hsync_end = 1920 + 46 + 30, /* hact + hfp + hs */ + .htotal = 1920 + 46 + 30 + 84, /* hact + hfp + hs + hbp */ + .vdisplay = 1200, + .vsync_start = 1200 + 10, /* vact + vfp */ + .vsync_end = 1200 + 10 + 6, /* vact + vfp + vs */ + .vtotal = 1200 + 10 + 6 + 20, /* vact + vfp + vs + vbp */ + .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, +}; + +static const struct panel_desc_dsi cmn_5171_1920x1200_40Hz = { + .desc = { + .modes = &cmn_5171_1920x1200_40Hz_mode, + .num_modes = 1, + .bpc = 8, + .size = { + .width = 62, + .height = 110, + }, + .connector_type = DRM_MODE_CONNECTOR_DSI, + }, + .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_VIDEO_BURST, + .format = MIPI_DSI_FMT_RGB888, + .lanes = 4, +}; + + static const struct drm_display_mode lg_ld070wx3_sl01_mode = { .clock = 71000, .hdisplay = 800, @@ -4771,6 +4802,9 @@ static const struct of_device_id dsi_of_match[] = { }, { .compatible = "custom,z14inch_2160x1440_40Hz", .data = &z14inch_2160x1440_40Hz + }, { + .compatible = "cmn,5171_1920x1200_40Hz", + .data = &cmn_5171_1920x1200_40Hz }, { /* sentinel */ }