#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

if ARCH_BOARD_ESP32P4_TAB5

config ESP32P4_TAB5_HMI_POWER
	bool
	default n

config ESP32P4_TAB5_IOEXPANDER
	bool "Enable the Tab5 board IO Expander"
	default n
	select ESPRESSIF_I2C0
	select IOEXPANDER
	select IOEXPANDER_PI4IOE5V6408
	---help---
		Enable support for the Tab5 board IO Expander.
		There are two IO Expanders on the this board.
		The first IO Expander is at address 0x43 (address pin low) and
		the second is at address 0x44 (address pin high).

if ESP32P4_TAB5_IOEXPANDER
	config ESP32P4_TAB5_IOEXPANDER_LOW
		bool "Enable the first IO Expander"
		default y
		---help---
			Enable the first IO Expander.

	config ESP32P4_TAB5_IOEXPANDER_HIGH
		bool "Enable the second IO Expander"
		default n
		---help---
			Enable the second IO Expander.
endif

config ESP32P4_TAB5_LCD_POWER
	bool "LCD / MIPI PHY power and reset path"
	default n
	select ESP32P4_TAB5_IOEXPANDER
	select ESP32P4_TAB5_HMI_POWER
	---help---
		At board bring-up (after I2C0 init), enable on-chip LDO channel 3
		at 2500 mV for VDD_MIPI_DPHY and raise LCD_EN on expander pin P4.

		This does NOT initialize the MIPI-DSI host, the LCD panel, or
		/dev/fb0 by itself.  Enable ESP32P4_TAB5_MIPI_DSI (and
		ESPRESSIF_MIPI_DSI) to register the host after this power path.
		Enable ESP32P4_TAB5_LCD for panel initialization + /dev/fb0.

config ESP32P4_TAB5_MIPI_DSI
	bool "Register MIPI-DSI host at bring-up"
	default n
	depends on ESP32P4_TAB5_LCD_POWER && ESPRESSIF_MIPI_DSI
	---help---
		After the LCD power path succeeds, call
		esp_mipi_dsi_initialize() so the generic MIPI-DSI host is
		registered (LP DCS/generic transfer ready).

		Does NOT run panel initialization or create /dev/fb0 by itself;
		enable ESP32P4_TAB5_LCD for that.

config ESP32P4_TAB5_LCD
	bool "LCD panel and /dev/fb0"
	default n
	depends on ESP32P4_TAB5_MIPI_DSI
	select DRIVERS_VIDEO
	select VIDEO_FB
	select FB_UPDATE
	---help---
		Bring up the selected Tab5 MIPI-DSI panel (M5Stack init table and
		720×1280 RGB565 timings), allocate a PSRAM framebuffer, bind it
		to the DSI bridge via DW-GDMA, and register /dev/fb0.

config ESP32P4_TAB5_LCD_APO_TEST
	bool "All-Pixels-On flash after FB bring-up"
	default y
	depends on ESP32P4_TAB5_LCD
	---help---
		After /dev/fb0 is ready, force All-Pixels-On for ~1 s, then
		All-Pixels-Off and restore the solid red test fill.

choice
	prompt "Tab5 LCD panel controller"
	default ESP32P4_TAB5_LCD_ST7121
	depends on ESP32P4_TAB5_LCD

config ESP32P4_TAB5_LCD_ST7121
	bool "ST7121"
	---help---
		Use the ST7121 initialization table and display timings.

config ESP32P4_TAB5_LCD_ST7123
	bool "ST7123"
	---help---
		Use the ST7123 initialization table and display timings.

config ESP32P4_TAB5_LCD_ILI9881C
	bool "ILI9881C"
	---help---
		Use the ILI9881C initialization table and display timings.  This is
		the panel fitted to the earlier Tab5 units, the ones that also carry
		the GT911 touch controller.

endchoice

config ESP32P4_TAB5_TOUCHSCREEN
	bool "Touch Screen Controller"
	default n
	select INPUT
	select ESP32P4_TAB5_HMI_POWER
	---help---
		Initialize the touch screen controller.

if ESP32P4_TAB5_TOUCHSCREEN

choice
	prompt "Touch screen controller"
	default ESP32P4_TAB5_TOUCH_ST7123

config ESP32P4_TAB5_TOUCH_ST7123
	bool "ST7123"
	select INPUT_ST7123
	---help---
		Sitronix ST7123, fitted to the Tab5 units that ship with the
		ST7121/ST7123 panel.  Answers on I2C address 0x55.

config ESP32P4_TAB5_TOUCH_GT911
	bool "GT911"
	select INPUT_GT9XX
	---help---
		Goodix GT911, fitted to the earlier Tab5 units.

endchoice

config ESP32P4_TAB5_TOUCH_GT911_ADDR
	hex "GT911 I2C address"
	depends on ESP32P4_TAB5_TOUCH_GT911
	default 0x14
	---help---
		The GT911 latches its I2C address from the INT pin while it is
		held in reset: either 0x14 or 0x5d.  Scan the bus with
		"i2c dev -b 0 0x03 0x77" if unsure.

endif # ESP32P4_TAB5_TOUCHSCREEN

endif # ARCH_BOARD_ESP32P4_TAB5
