1/*
2 * Copyright (c) 2024, Nicolas Goualard <nicolas.goualard@sfr.fr>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <freq.h>
8#include <zephyr/dt-bindings/display/panel.h>
9
10/ {
11	chosen {
12		zephyr,display = &gc9a01_xiao_round_display;
13		zephyr,touch = &chsc6x_xiao_round_display;
14	};
15
16	vbatt {
17		compatible = "voltage-divider";
18		io-channels = <&xiao_adc 0>;
19		output-ohms = <470000>;
20		full-ohms = <940000>;
21	};
22
23	lvgl_pointer {
24		compatible = "zephyr,lvgl-pointer-input";
25		input = <&chsc6x_xiao_round_display>;
26	};
27
28	aliases {
29		rtc = &pcf8563_xiao_round_display;
30	};
31
32	xiao_round_display_mipi_dbi {
33		compatible = "zephyr,mipi-dbi-spi";
34		spi-dev = <&xiao_spi>;
35		dc-gpios = <&xiao_d 3 GPIO_ACTIVE_HIGH>;
36		write-only;
37		#address-cells = <1>;
38		#size-cells = <0>;
39
40		gc9a01_xiao_round_display: gc9a01@0 {
41			status = "okay";
42			compatible = "galaxycore,gc9x01x";
43			reg = <0>;
44			mipi-max-frequency = <DT_FREQ_M(100)>;
45			pixel-format = <PANEL_PIXEL_FORMAT_RGB_565>;
46			width = <240>;
47			height = <240>;
48			display-inversion;
49		};
50	};
51};
52
53&xiao_adc {
54	status = "okay";
55};
56
57/*
58 * xiao_serial uses pins D6 and D7 of the Xiao, which are used respectively to
59 * control the screen backlight and as touch controller interrupt.
60 */
61&xiao_serial {
62	status = "disabled";
63};
64
65&xiao_i2c {
66	clock-frequency = < I2C_BITRATE_FAST >;
67
68	pcf8563_xiao_round_display: pcf8563@51 {
69		status = "okay";
70		compatible = "nxp,pcf8563";
71		reg = <0x51>;
72	};
73
74	chsc6x_xiao_round_display: chsc6x@2e {
75		status = "okay";
76		compatible = "chipsemi,chsc6x";
77		reg = <0x2e>;
78		irq-gpios = <&xiao_d 7 GPIO_ACTIVE_LOW>;
79	};
80};
81
82&xiao_spi {
83	status = "okay";
84	cs-gpios = <&xiao_d 1 GPIO_ACTIVE_LOW>, <&xiao_d 2 GPIO_ACTIVE_LOW>;
85
86	sdhc_xiao_round_display: sdhc@1 {
87		compatible = "zephyr,sdhc-spi-slot";
88		reg = <1>;
89		status = "okay";
90		mmc {
91			compatible = "zephyr,sdmmc-disk";
92			disk-name = "SD";
93			status = "okay";
94		};
95		spi-max-frequency = <DT_FREQ_M(24)>;
96	};
97};
98