## SPDX-License-Identifier: GPL-2.0-only

config EC_GOOGLE_CHROMEEC
	bool
	select EC_SUPPORTS_DPTF_TEVT
	select HAVE_EARLY_POWEROFF_SUPPORT
	help
	  Google's Chrome EC

if EC_GOOGLE_CHROMEEC

config EC_GOOGLE_CHROMEEC_ACPI_MEMMAP
	depends on EC_GOOGLE_CHROMEEC_LPC
	def_bool n
	help
	  When defined, ACPI accesses EC memmap data on ports 66h/62h. When
	  not defined, the memmap data is instead accessed on 900h-9ffh via
	  the LPC bus.

config EC_GOOGLE_CHROMEEC_ACPI_USB_PORT_POWER
	def_bool n
	help
	  Expose methods for enabling and disabling port power on individual USB
	  ports through the EC.

config EC_GOOGLE_CHROMEEC_BOARDID
	def_bool n
	help
	  Provides common routine for reading boardid from Chrome EC.

config EC_GOOGLE_CHROMEEC_I2C
	bool
	default n
	help
	  Google's Chrome EC via I2C bus.

config EC_GOOGLE_CHROMEEC_I2C_BUS
	depends on EC_GOOGLE_CHROMEEC_I2C
	hex "I2C bus for Google's Chrome EC"

config EC_GOOGLE_CHROMEEC_I2C_CHIP
	depends on EC_GOOGLE_CHROMEEC_I2C
	hex
	default 0x1e

config EC_GOOGLE_CHROMEEC_I2C_PROTO3
	depends on EC_GOOGLE_CHROMEEC_I2C
	bool
	default n
	help
	  Use only proto3 for i2c EC communication.

config EC_GOOGLE_CHROMEEC_ESPI
	depends on ARCH_X86  # Needs Plug-and-play.
	def_bool n
	select EC_GOOGLE_CHROMEEC_LPC
	help
	  Google Chrome EC via eSPI bus.

	  The EC communication code is the same between eSPI and LPC, so
	  this option simply enables the LPC EC code.  The eSPI device
	  still needs to correctly configure the bus transactions.

config EC_GOOGLE_CHROMEEC_MEMMAP_INDEXED_IO
	depends on EC_GOOGLE_CHROMEEC && ARCH_X86
	def_bool n
	help
	  Google Chrome EC enable support for indexed I/O access.

	  Indexed I/O allows devices with multiple memory locations to be
	  accessed using a single I/O port base address and an index register.
	  A separate data register, typically located at the address
	  immediately following the index register, is used for sending and
	  receiving data to the device.

	  Ensure port address and gen3_dec values are correct when selecting
	  this configuration.

config EC_GOOGLE_CHROMEEC_MEMMAP_INDEXED_IO_PORT
	depends on EC_GOOGLE_CHROMEEC_MEMMAP_INDEXED_IO
	hex
	default 0x380
	help
	  Google Chrome EC indexed I/O access address.

	  Index register port address for memory mapped indexed IO access

config EC_GOOGLE_CHROMEEC_LPC
	depends on ARCH_X86  # Needs Plug-and-play.
	def_bool n
	help
	  Google Chrome EC via LPC bus.

config EC_GOOGLE_CHROMEEC_MEC
	depends on EC_GOOGLE_CHROMEEC_LPC
	def_bool n
	select EC_GOOGLE_CHROMEEC_ACPI_MEMMAP
	select EC_GOOGLE_COMMON_MEC
	help
	  Microchip EC variant for LPC register access.

config EC_GOOGLE_CHROMEEC_RTK
	depends on EC_GOOGLE_CHROMEEC_LPC
	def_bool n
	select EC_GOOGLE_COMMON_RTK
	help
	  Realtek EC variant for LPC register access.

config EC_GOOGLE_CHROMEEC_EC_HOST_CMD_DEBUG
	depends on EC_GOOGLE_CHROMEEC_LPC && HAVE_MONOTONIC_TIMER
	def_bool n
	help
	  Enables timestamp and duration logging for host EC commands.

config EC_GOOGLE_CHROMEEC_PD
	def_bool n
	help
	  Indicates that Google's Chrome USB PD chip is present.

config EC_GOOGLE_CHROMEEC_SPI
	def_bool n
	help
	  Google's Chrome EC via SPI bus.

config EC_GOOGLE_CHROMEEC_SPI_BUS
	depends on EC_GOOGLE_CHROMEEC_SPI
	hex

config EC_GOOGLE_CHROMEEC_SPI_WAKEUP_DELAY_US
	depends on EC_GOOGLE_CHROMEEC_SPI
	int
	default 0
	help
	  Force delay after asserting /CS to allow EC to wakeup.

config EC_GOOGLE_CHROMEEC_SPI_CHIP
	depends on EC_GOOGLE_CHROMEEC_SPI
	hex
	default 0x0

config EC_GOOGLE_CHROMEEC_SKUID
	def_bool n
	help
	  Provides common routine for reporting the skuid to ChromeOS.

config EC_GOOGLE_CHROMEEC_SMBIOS
	def_bool n
	help
	  Enable support to get SKU and board information for SMBIOS table
	  using Chrome EC host commands.

config EC_GOOGLE_CHROMEEC_RTC
	bool "Enable ChromeOS EC RTC"
	help
	  Enable support for the real-time clock on the ChromeOS EC. This
	  uses the EC_CMD_RTC_GET_VALUE command to read the current time.

config EC_GOOGLE_CHROMEEC_FIRMWARE_EXTERNAL
	bool "Include an external EC firmware binary"
	help
	  Include a precompiled EC firmware binary in the image.

config EC_GOOGLE_CHROMEEC_FIRMWARE_FILE
	string "Chrome EC firmware path and filename"
	depends on EC_GOOGLE_CHROMEEC_FIRMWARE_EXTERNAL
	help
	  The path and filename of the EC firmware file to use.

config EC_GOOGLE_CHROMEEC_PD_FIRMWARE_EXTERNAL
	bool "Include an external PD firmware binary"
	depends on EC_GOOGLE_CHROMEEC_PD
	help
	  Include a precompiled PD firmware binary in the image.

config EC_GOOGLE_CHROMEEC_PD_FIRMWARE_FILE
	string "Chrome EC firmware path and filename for PD"
	depends on EC_GOOGLE_CHROMEEC_PD_FIRMWARE_EXTERNAL
	help
	  The path and filename of the PD firmware file to use.

config EC_GOOGLE_CHROMEEC_SWITCHES
	depends on VBOOT
	bool
	help
	  Enable support for ChromeOS mode switches provided by the ChromeOS
	  EC.

config EC_GOOGLE_CHROMEEC_INCLUDE_SSFC_IN_FW_CONFIG
	depends on FW_CONFIG_SOURCE_CHROMEEC_CBI
	bool
	help
	  Fetch Second Source Factory Cache from CBI EEPROM and add it in the most significant
	  32 bits of firmware configuration.

config EC_GOOGLE_CHROMEEC_AUTO_FAN_CTRL
	bool "Enable automatic fan control"
	help
	  Put the fan in auto mode at boot.

config EC_GOOGLE_CHROMEEC_READ_BATTERY_LONG_STRING
	depends on TPM_GOOGLE
	bool
	default y
	help
	  The Chrome EC currently supports two ways to read battery strings on
	  ACPI platforms:

	  * Read up to 8 bytes from EC shared memory BMFG, BMOD, ...
	  * Send a EC_CMD_BATTERY_GET_STATIC host command and read longer strings as a response.

	  Select this config to support readout of longer battery strings.

	  If unsure, say N.

config EC_GOOGLE_CHROMEEC_LPC_GENERIC_MEMORY_RANGE
	def_bool n
	help
	  Select this option to access LPC GMR (Generic Memory Range) Register to
	  implement MMIO based communication between EC and AP firmware.

config EC_GOOGLE_CHROMEEC_LPC_GENERIC_MEMORY_BASE
	hex
	default 0xfe0b0000

config EC_GOOGLE_CHROMEEC_LPC_GENERIC_MEMORY_SIZE
	hex
	default 0x10000

endif # EC_GOOGLE_CHROMEEC

source "src/ec/google/chromeec/*/Kconfig"
