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

comment "RP23XX Configuration Options"

config RP23XX_RP2350B
	bool "Use RP2350B variant (QFN-80)"
	default n

config RP23XX_PSRAM
	bool "External QSPI PSRAM"
	default n
	---help---
		Enable support for external QSPI PSRAM connected to QMI chip
		select 1, such as the 8 MiB APS6404 fitted on the Pimoroni Pico
		Plus 2.  The chip is detected and switched to quad mode at boot,
		after which it is directly addressable and writable at
		0x11000000.  Configure the chip-select pin under the Board
		Selection menu (RP23XX_PSRAM_CS1_GPIO).

if RP23XX_PSRAM

choice
	prompt "PSRAM heap usage"
	default RP23XX_PSRAM_HEAP_SINGLE
	---help---
		How the detected PSRAM is exposed to the memory manager.

config RP23XX_PSRAM_HEAP_SINGLE
	bool "Add PSRAM to the main heap"
	depends on !MM_KERNEL_HEAP
	---help---
		Add the PSRAM region to the main heap.  Requires
		CONFIG_MM_REGIONS greater than 1 so the extra region can be
		registered.

config RP23XX_PSRAM_HEAP_USER
	bool "PSRAM as the user heap"
	depends on MM_KERNEL_HEAP
	---help---
		Use the PSRAM as the (user) heap and the internal SRAM as the
		kernel heap.

config RP23XX_PSRAM_HEAP_SEPARATE
	bool "Separate PSRAM heap"
	select ARCH_HAVE_EXTRA_HEAPS
	---help---
		Expose the PSRAM as a separate named heap ("psram") rather than
		adding it to the main heap.

endchoice

endif # RP23XX_PSRAM

config RP23XX_DMAC
	bool "DMAC support"
	default y
	select ARCH_DMA

config RP23XX_SYSTIMER_SYSTICK
	bool "SysTick System Timer"
	default n
	select TIMER_ARCH
	select TIMER
	select ARMV8M_SYSTICK
	---help---
		Use ARM SysTick.

config RP23XX_SYSTIMER_TICKLESS
	bool "Tickless OS using the RP2350 hardware TIMER"
	default n
	depends on !RP23XX_SYSTIMER_SYSTICK
	select ONESHOT
	select ONESHOT_COUNT
	select ALARM_ARCH
	---help---
		Use an RP2350 system timer block (TIMER0 or TIMER1, chosen below)
		as the OS time source and drive the scheduler through the
		alarm/oneshot interface.  Each block is a free-running 64-bit
		microsecond counter, independent of the ARM SysTick.  This is the
		arch-side support required by CONFIG_SCHED_TICKLESS (with
		CONFIG_SCHED_TICKLESS_ALARM) and gives long tickless idle intervals
		-- up to ~71 minutes per alarm -- with 1 us resolution.

choice
	prompt "Tickless timer block"
	default RP23XX_SYSTIMER_TICKLESS_TIMER0
	depends on RP23XX_SYSTIMER_TICKLESS
	---help---
		Which RP2350 system timer block drives the tickless OS clock.  The
		block used here is claimed exclusively by the scheduler; the other
		block stays available for the /dev/timer driver (CONFIG_RP23XX_TIMER),
		so both features can be enabled at once.

config RP23XX_SYSTIMER_TICKLESS_TIMER0
	bool "TIMER0"

config RP23XX_SYSTIMER_TICKLESS_TIMER1
	bool "TIMER1"

endchoice

#####################################################################
#  UART Configuration
#####################################################################

config RP23XX_UART0
	bool "UART0"
	default y
	select UART0_SERIALDRIVER
	select ARCH_HAVE_SERIAL_TERMIOS
	---help---
		Most UART parameters are configured here.  See also the
		Board Selection menu to configure the pins used by UART0

if RP23XX_UART0

config RP23XX_UART0_BAUD
	int "RP23XX UART0 BAUD"
	default 115200
	---help---
		RP23XX UART0 communication bit rate.  The range of available
		baud rates depend on the clock supplied to the UART. Given
		the normally configured 125 MHz clock, the baud
		rates between 120 and 7 812 500 baud are available.

config RP23XX_UART0_PARITY
	int "RP23XX UART0 parity"
	default 0
	range 0 2
	---help---
		RP23XX UART0 parity.  0=None, 1=Odd, 2=Even.  Default: None

config RP23XX_UART0_BITS
	int "RP23XX UART0 number of bits"
	default 8
	range 5 8
	---help---
		RP23XX UART0 number of bits.  Default: 8

config RP23XX_UART0_2STOP
	int "RP23XX UART0 two stop bits"
	default 0
	---help---
		0=1 stop bit, 1=Two stop bits.  Default: 1 stop bit

endif # RP23XX_UART0

config RP23XX_UART1
	bool "UART1"
	default n
	select UART1_SERIALDRIVER
	select ARCH_HAVE_SERIAL_TERMIOS
	---help---
		Most UART parameters are configured here.  See also the
		Board Selection menu to configure the pins used by UART1

if RP23XX_UART1

config RP23XX_UART1_BAUD
	int "RP23XX UART1 BAUD"
	default 115200
	---help---
		RP23XX UART0 communication bit rate.  The range of available
		baud rates depend on the clock supplied to the UART. Given
		the normally configured 125 MHz clock, the baud
		rates between 120 and 7 812 500 baud are available.

config RP23XX_UART1_PARITY
	int "RP23XX UART1 parity"
	default 0
	range 0 2
	---help---
		RP23XX UART1 parity.  0=None, 1=Odd, 2=Even.  Default: None

config RP23XX_UART1_BITS
	int "RP23XX UART1 number of bits"
	default 8
	range 5 8
	---help---
		RP23XX UART1 number of bits.  Default: 8

config RP23XX_UART1_2STOP
	int "RP23XX UART1 two stop bits"
	default 0
	---help---
		0=1 stop bit, 1=Two stop bits.  Default: 1 stop bit

endif # RP23XX_UART1

#####################################################################
#  SPI Configuration
#####################################################################

config RP23XX_SPI
	bool "SPI Master Mode Support"
	select SPI

if RP23XX_SPI

config RP23XX_SPI0
	bool "SPI0"
	default n
	---help---
		Most SPI parameters are configured here.  See also the
		Board Selection menu to configure the pins used by SPI0

config RP23XX_SPI1
	bool "SPI1"
	default n
	---help---
		Most SPI parameters are configured here.  See also the
		Board Selection menu to configure the pins used by SPI1

config RP23XX_SPI_DMA
	bool "SPI DMA"
	default y
	depends on RP23XX_DMAC
	---help---
		Use DMA to improve SPI transfer performance.

config RP23XX_SPI_DMATHRESHOLD
	int "SPI DMA threshold"
	default 4
	depends on RP23XX_SPI_DMA
	---help---
		When SPI DMA is enabled, small DMA transfers will still be performed
		by polling logic.  But we need a threshold value to determine what
		is small.  That value is provided by RP23XX_SPI_DMATHRESHOLD.

config RP23XX_SPI_DRIVER
	bool "SPI character driver"
	default y
	select SPI_DRIVER
	---help---
		Build in support for a character driver at /dev/spi[N] that may be
		used to perform SPI bus transfers from applications.  The intent of
		this driver is to support SPI testing.

endif # RP23XX_SPI

#####################################################################
#  I2C Configuration (Master)
#####################################################################

config RP23XX_I2C
	bool "I2C Master"
	select I2C
	---help---
		Build in support for I2C master mode.
		Note: Do not configure the same port as both master and slave.

if RP23XX_I2C

config RP23XX_I2C0
	bool "I2C0"
	default n
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

config RP23XX_I2C1
	bool "I2C1"
	default n
	---help---
		See the Board Selection menu to configure the pins used by I2C1.

config RP23XX_I2C_DRIVER
	bool "I2C character driver"
	default n
	select I2C_DRIVER
	---help---
		Build in support for a character driver at /dev/i2c[N] that may be
		used to perform I2C bus transfers from applications.  The intent of
		this driver is to support I2C testing.  It is not suitable for use
		in any real driver application.

endif # RP23XX_I2C

#####################################################################
#  I2C Configuration (Slave)
#####################################################################

config RP23XX_I2C_SLAVE
	bool "I2C Slave"
	select I2C_SLAVE
	---help---
		Build in support for I2C slave mode.
		Note: Do not configure the same port as both master and slave.

if RP23XX_I2C_SLAVE

config RP23XX_I2C0_SLAVE
	bool "I2C0"
	default n
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_I2C0_SLAVE

config RP23XX_I2C0_SLAVE_ADDRESS
	int "Slave Address (in decimal)"
	default 42
	---help---
		This is the default address of this device on the I2C bus.
		It should be the canonical address (not the shifted address)
		in the range 8-119 for 7-bit mode and in the range 0-1023
		for 10-bit mode.

config RP23XX_I2C0_SLAVE_10BIT
	bool "Enable 10-bit slave address"
	default n
	---help---
		Set to enable 10-bit mode addressing.

endif # RP23XX_I2C0_SLAVE

config RP23XX_I2C1_SLAVE
	bool "I2C1"
	default n
	---help---
		See the Board Selection menu to configure the pins used by I2C1.

if RP23XX_I2C1_SLAVE

config RP23XX_I2C1_SLAVE_ADDRESS
	int "Slave Address (in decimal)"
	default 42
	---help---
		This is the default address of this device on the I2C bus.
		It should be the canonical address (not the shifted address)
		in the range 8-119 for 7-bit mode and in the range 0-1023
		for 10-bit mode.

config RP23XX_I2C1_SLAVE_10BIT
	bool "Enable 10-bit slave address"
	default n
	---help---
		Set to enable 10-bit mode addressing.

endif # RP23XX_I2C1_SLAVE

endif # RP23XX_I2C_SLAVE

#####################################################################
#  PWM Configuration
#####################################################################

config RP23XX_PWM
	bool "PWM"
	select PWM
	---help---
		After enabling PWM support here, configure the GPIO pins to use
		under the Board Selection menu.

if RP23XX_PWM

config RP23XX_PWM_MULTICHAN
	bool "Support RP23XX Multi-Channel PWM"
	default y
	---help---
		If support for multi-channel PWM is disabled, the generated code
		will only support the A channel of the PWM slices.

if RP23XX_PWM_MULTICHAN

config RP23XX_PWM_NCHANNELS
	int "Number of channels"
	default 2
	range 1 2
	---help---
		If the number of channels is set to 1, the generated code will
		only support the A channel of the PWM slices.  This is functionally
		identical to disabling multi-channel PWM support.

endif # RP23XX_PWM_MULTICHAN

config RP23XX_PWM0
	bool "PWM0"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM0

config RP23XX_PWM0A_INVERT
	bool "PWM0 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM0B_INVERT
	bool "PWM0 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM0_PHASE_CORRECT
	bool "PWM0 phase correct"
	default n

endif # RP23XX_PWM0

config RP23XX_PWM1
	bool "PWM1"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM1

config RP23XX_PWM1A_INVERT
	bool "PWM1 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM1B_INVERT
	bool "PWM1 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM1_PHASE_CORRECT
	bool "PWM1 phase correct"
	default n

endif # RP23XX_PWM1

config RP23XX_PWM2
	bool "PWM2"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM2

config RP23XX_PWM2A_INVERT
	bool "PWM2 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM2B_INVERT
	bool "PWM2 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM2_PHASE_CORRECT
	bool "PWM2 phase correct"
	default n

endif # RP23XX_PWM2

config RP23XX_PWM3
	bool "PWM3"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM3

config RP23XX_PWM3A_INVERT
	bool "PWM3 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM3B_INVERT
	bool "PWM3 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM3_PHASE_CORRECT
	bool "PWM3 phase correct"
	default n

endif # RP23XX_PWM3

config RP23XX_PWM4
	bool "PWM4"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM4

config RP23XX_PWM4A_INVERT
	bool "PWM4 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM4B_INVERT
	bool "PWM4 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM4_PHASE_CORRECT
	bool "PWM4 phase correct"
	default n

endif # RP23XX_PWM4

config RP23XX_PWM5
	bool "PWM5"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM5

config RP23XX_PWM5A_INVERT
	bool "PWM5 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM5B_INVERT
	bool "PWM5 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM5_PHASE_CORRECT
	bool "PWM5 phase correct"
	default n

endif # RP23XX_PWM5

config RP23XX_PWM6
	bool "PWM6"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM6

config RP23XX_PWM6A_INVERT
	bool "PWM6 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM6B_INVERT
	bool "PWM6 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM6_PHASE_CORRECT
	bool "PWM6 phase correct"
	default n

endif # RP23XX_PWM6

config RP23XX_PWM7
	bool "PWM7"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM7

config RP23XX_PWM7A_INVERT
	bool "PWM7 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM7B_INVERT
	bool "PWM7 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM7_PHASE_CORRECT
	bool "PWM7 phase correct"
	default n

endif # RP23XX_PWM7

config RP23XX_PWM8
	bool "PWM7"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM8

config RP23XX_PWM8A_INVERT
	bool "PWM7 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM8B_INVERT
	bool "PWM7 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM8_PHASE_CORRECT
	bool "PWM7 phase correct"
	default n

endif # RP23XX_PWM8

config RP23XX_PWM9
	bool "PWM7"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM9

config RP23XX_PWM9A_INVERT
	bool "PWM7 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM9B_INVERT
	bool "PWM7 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM9_PHASE_CORRECT
	bool "PWM7 phase correct"
	default n

endif # RP23XX_PWM9

config RP23XX_PWM10
	bool "PWM7"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM10

config RP23XX_PWM10A_INVERT
	bool "PWM7 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM10B_INVERT
	bool "PWM7 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM10_PHASE_CORRECT
	bool "PWM7 phase correct"
	default n

endif # RP23XX_PWM10

config RP23XX_PWM11
	bool "PWM7"
	---help---
		See the Board Selection menu to configure the pins used by I2C0.

if RP23XX_PWM11

config RP23XX_PWM11A_INVERT
	bool "PWM7 channel 1 invert"
	default n
	---help---
		If invert is enabled, the PWM on the A pin will idle high
		with the pulse going low.

if RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM11B_INVERT
	bool "PWM7 channel 2 invert"
	default n
	---help---
		If invert is enabled, the PWM on the B pin will idle high
		with the pulse going low.

endif # RP23XX_PWM_MULTICHAN && RP23XX_PWM_NCHANNELS > 1

config RP23XX_PWM11_PHASE_CORRECT
	bool "PWM7 phase correct"
	default n

endif # RP23XX_PWM11

endif # RP23XX_PWM

#####################################################################
#  I2S Configuration
#####################################################################

config RP23XX_I2S
	bool "I2S"
	select I2S
	---help---
		See the Board Selection menu to configure the pins used by I2S.

if RP23XX_I2S

config RP23XX_I2S_MAXINFLIGHT
	int "I2S queue size"
	default 16
	---help---
		This is the total number of transfers that can be enqueue before
		the caller is required to wait.  This setting determines the number
		certain queue data structures that will be pre-allocated.

config RP23XX_I2S_DATALEN
	int "Data width (bits)"
	default 16
	---help---
		Data width in bits.  This is a default value and may be change
		via the I2S interface

config RP23XX_I2S_PIO
	int "RP23XX PIO number used for I2S (0-1)"
	default 0
	range 0 1

config RP23XX_I2S_PIO_SM
	int "RP23XX PIO state machine number used for I2S (0-3)"
	default 0
	range 0 3

endif # RP23XX_I2S

#####################################################################
#  SPISD Configuration
#####################################################################

config RP23XX_SPISD
	bool "SPI SD Card"
	default n
	select MMCSD_SPI

if RP23XX_SPISD

config RP23XX_SPISD_SLOT_NO
	int "SPI SD Card Slot Number"
	default 0
	---help---
		Select spi sd card slot number.

config RP23XX_SPISD_SPI_CH
	int "SPI channel number"
	default 0
	range 0 1
	---help---
		Select spi channel number to use spi sd card.

endif # SPISD Configuration

#####################################################################
#  Timer Configuration
#####################################################################

menuconfig RP23XX_TIMER
	bool "System timer (/dev/timer) support"
	default n
	select TIMER
	---help---
		Build the /dev/timerN driver on top of the RP2350 system timer
		blocks (TIMER0 and TIMER1).  Each block is a free-running 64-bit
		microsecond counter, independent of the ARM SysTick that drives
		the OS tick, so it is available for application timers.  The
		driver uses ALARM0 of a block for a single-shot or periodic
		timeout with 1 us resolution.

		Enable one or both blocks below.  A block claimed by the tickless
		oneshot (CONFIG_RP23XX_SYSTIMER_TICKLESS) is removed from the list
		so the two features never collide on the same block.

if RP23XX_TIMER

config RP23XX_TIMER0
	bool "Register TIMER0 as /dev/timer0"
	default y
	depends on !RP23XX_SYSTIMER_TICKLESS_TIMER0
	---help---
		Bind the TIMER0 block to /dev/timer0.  Unavailable when the
		tickless oneshot is configured to use TIMER0.

config RP23XX_TIMER1
	bool "Register TIMER1 as /dev/timer1"
	default n
	depends on !RP23XX_SYSTIMER_TICKLESS_TIMER1
	---help---
		Bind the TIMER1 block to /dev/timer1.  Unavailable when the
		tickless oneshot is configured to use TIMER1.

endif # RP23XX_TIMER

#####################################################################
#  ADC Configuration
#####################################################################

config RP23XX_RNG
	bool "Enable hardware TRNG (/dev/random)"
	default n
	select ARCH_HAVE_RNG
	---help---
		Enable the RP2350 hardware true random number generator.  Provides
		/dev/random (and /dev/urandom when CONFIG_DEV_URANDOM selects the
		architecture source) via the TRNG entropy register (EHR).

config RP23XX_RTC
	bool "Enable RTC (POWMAN always-on timer)"
	default n
	select RTC
	---help---
		Use the RP2350 POWMAN always-on timer as the real-time clock backing
		the system clock.  The RP2350 has no dedicated RTC block; the POWMAN
		timer is a 64-bit millisecond counter clocked from the low-power
		oscillator, so it keeps running across warm resets.

config RP23XX_ADC
	bool "Enable ADC Support"
	default n
	---help---
		If y, the RP23XX ADC code will be built.
		If the ADC device driver is not built, basic functions
		to programmatically access the ADC ports will be added.

if RP23XX_ADC

if ADC

config RP23XX_ADC_CHANNEL0
	bool "Read ADC channel 0"
	default n
	---help---
		If y, then ADC0 will be read.

config RP23XX_ADC_CHANNEL1
	bool "Read ADC channel 1"
	default n
	---help---
		If y, then ADC1 will be read.

config RP23XX_ADC_CHANNEL2
	bool "Read ADC channel 2"
	default n
	---help---
		If y, then ADC2 will be read.

config RP23XX_ADC_CHANNEL3
	bool "Read ADC channel 3"
	default n
	---help---
		If y, then ADC3 will be read.

config RP23XX_ADC_CHANNEL4
	bool "Read ADC channel 4"
	default n
	---help---
		If y, then ADC4 will be read.

config RP23XX_ADC_CHANNEL5
	bool "Read ADC channel 5"
	default n
	---help---
		If y, then ADC5 will be read.

config RP23XX_ADC_CHANNEL6
	bool "Read ADC channel 6"
	default n
	---help---
		If y, then ADC6 will be read.

config RP23XX_ADC_CHANNEL7
	bool "Read ADC channel 7"
	default n
	---help---
		If y, then ADC7 will be read.

config RP23XX_ADC_TEMPERATURE
	bool "Read ADC chip temperature channel"
	default n
	---help---
		If y, then the ADC chip temperature
		will be read.

endif # ADC

endif # RP23XX_ADC

#####################################################################
#  CLK_GPOUT Configuration
#####################################################################

menuconfig RP23XX_CLK_GPOUT_ENABLE
	bool "Enable Clock Outputs"
	default n

if RP23XX_CLK_GPOUT_ENABLE

config RP23XX_CLK_GPOUT0
	bool "CLK_GPOUT0 Clock Output (pin 21)"
	default n
	---help---
		Enable CLK_GPOUT0

if RP23XX_CLK_GPOUT0

choice
	prompt "Source Clock"

config RP23XX_CLK_GPOUT0_SRC_REF
	bool "REF (6 - 12 MHz)"
	---help---
		Reference clock that is always running unless in DORMANT mode. Runs from
		Ring Oscillator (ROSC) at power-up but can be switched to Crystal
		Oscillator (XOSC) for more accuracy.

config RP23XX_CLK_GPOUT0_SRC_SYS
	bool "SYS (150 MHz)"
	---help---
		System clock that is always running unless in DORMANT mode. Runs from
		clk_ref at power-up but is typically switched to a PLL.

config RP23XX_CLK_GPOUT0_SRC_USB
	bool "USB (48 MHz)"
	---help---
		USB reference clock. Must be 48MHz.

config RP23XX_CLK_GPOUT0_SRC_ADC
	bool "ADC (48 MHz)"
	---help---
		ADC reference clock. Must be 48MHz.

config RP23XX_CLK_GPOUT0_SRC_PERI
	bool "PERI (150 MHz)"
	---help---
		Peripheral reference clock. Defaults to system clock (150MHz).

config RP23XX_CLK_GPOUT0_SRC_HSTX
	bool "HSTX (150 MHz)"
	---help---
		HSTX reference clock. Defaults to system clock (150MHz).

endchoice # Source Clock

config RP23XX_CLK_GPOUT0_DIVINT
	int "Divisor (Integer)"
	default 1

config RP23XX_CLK_GPOUT0_DIVFRAC
	int "Divisor (Fractional)"
	default 0

endif # RP23XX_CLK_GPOUT0

config RP23XX_CLK_GPOUT1
	bool "CLK_GPOUT1 Clock Output (pin 23)"
	default n
	---help---
		Enable CLK_GPOUT1

if RP23XX_CLK_GPOUT1

choice
	prompt "Source Clock"

config RP23XX_CLK_GPOUT1_SRC_REF
	bool "REF (6 - 12 MHz)"
	---help---
		Reference clock that is always running unless in DORMANT mode. Runs from
		Ring Oscillator (ROSC) at power-up but can be switched to Crystal
		Oscillator (XOSC) for more accuracy.

config RP23XX_CLK_GPOUT1_SRC_SYS
	bool "SYS (150 MHz)"
	---help---
		System clock that is always running unless in DORMANT mode. Runs from
		clk_ref at power-up but is typically switched to a PLL.

config RP23XX_CLK_GPOUT1_SRC_USB
	bool "USB (48 MHz)"
	---help---
		USB reference clock. Must be 48MHz.

config RP23XX_CLK_GPOUT1_SRC_ADC
	bool "ADC (48 MHz)"
	---help---
		ADC reference clock. Must be 48MHz.

config RP23XX_CLK_GPOUT1_SRC_PERI
	bool "PERI (150 MHz)"
	---help---
		Peripheral reference clock. Defaults to system clock (150MHz).

config RP23XX_CLK_GPOUT1_SRC_HSTX
	bool "HSTX (150 MHz)"
	---help---
		HSTX reference clock. Defaults to system clock (150MHz).

endchoice # Source Clock

config RP23XX_CLK_GPOUT1_DIVINT
	int "Divisor (Integer)"
	default 1

config RP23XX_CLK_GPOUT1_DIVFRAC
	int "Divisor (Fractional)"
	default 0

endif # RP23XX_CLK_GPOUT1

config RP23XX_CLK_GPOUT2
	bool "CLK_GPOUT2 Clock Output (pin 24)"
	default n
	---help---
		Enable CLK_GPOUT2

if RP23XX_CLK_GPOUT2

choice
	prompt "Source Clock"

config RP23XX_CLK_GPOUT2_SRC_REF
	bool "REF (6 - 12 MHz)"
	---help---
		Reference clock that is always running unless in DORMANT mode. Runs from
		Ring Oscillator (ROSC) at power-up but can be switched to Crystal
		Oscillator (XOSC) for more accuracy.

config RP23XX_CLK_GPOUT2_SRC_SYS
	bool "SYS (125 MHz)"
	---help---
		System clock that is always running unless in DORMANT mode. Runs from
		clk_ref at power-up but is typically switched to a PLL.

config RP23XX_CLK_GPOUT2_SRC_USB
	bool "USB (48 MHz)"
	---help---
		USB reference clock. Must be 48MHz.

config RP23XX_CLK_GPOUT2_SRC_ADC
	bool "ADC (48 MHz)"
	---help---
		ADC reference clock. Must be 48MHz.

config RP23XX_CLK_GPOUT2_SRC_PERI
	bool "PERI (150 MHz)"
	---help---
		Peripheral reference clock. Defaults to system clock (150MHz).

config RP23XX_CLK_GPOUT2_SRC_HSTX
	bool "HSTX (150 MHz)"
	---help---
		HSTX reference clock. Defaults to system clock (150MHz).

endchoice # Source Clock

config RP23XX_CLK_GPOUT2_DIVINT
	int "Divisor (Integer)"
	default 1

config RP23XX_CLK_GPOUT2_DIVFRAC
	int "Divisor (Fractional)"
	default 0

endif # RP23XX_CLK_GPOUT2

config RP23XX_CLK_GPOUT3
	bool "CLK_GPOUT3 Clock Output (pin 25)"
	default n
	---help---
		Enable CLK_GPOUT3

if RP23XX_CLK_GPOUT3

choice
	prompt "Source Clock"

config RP23XX_CLK_GPOUT3_SRC_REF
	bool "REF (6 - 12 MHz)"
	---help---
		Reference clock that is always running unless in DORMANT mode. Runs from
		Ring Oscillator (ROSC) at power-up but can be switched to Crystal
		Oscillator (XOSC) for more accuracy.

config RP23XX_CLK_GPOUT3_SRC_SYS
	bool "SYS (125 MHz)"
	---help---
		System clock that is always running unless in DORMANT mode. Runs from
		clk_ref at power-up but is typically switched to a PLL.

config RP23XX_CLK_GPOUT3_SRC_USB
	bool "USB (48 MHz)"
	---help---
		USB reference clock. Must be 48MHz.

config RP23XX_CLK_GPOUT3_SRC_ADC
	bool "ADC (48 MHz)"
	---help---
		ADC reference clock. Must be 48MHz.

config RP23XX_CLK_GPOUT3_SRC_PERI
	bool "PERI (150 MHz)"
	---help---
		Peripheral reference clock. Defaults to system clock (150MHz).

config RP23XX_CLK_GPOUT3_SRC_HSTX
	bool "HSTX (150 MHz)"
	---help---
		HSTX reference clock. Defaults to system clock (150MHz).

endchoice # Source Clock

config RP23XX_CLK_GPOUT3_DIVINT
	int "Divisor (Integer)"
	default 1

config RP23XX_CLK_GPOUT3_DIVFRAC
	int "Divisor (Fractional)"
	default 0

endif # RP23XX_CLK_GPOUT3

endif # RP23XX_CLK_GPOUT_ENABLE

#####################################################################
#  WS2812 Configuration
#####################################################################

config RP23XX_BOARD_HAS_WS2812
	bool "Has ws2812 pixels"
	default n
	depends on WS2812
	select WS2812_NON_SPI_DRIVER
	---help---
		See the Board Selection menu to configure the pins used
		by ws2812.

#####################################################################
#  Flash MTD Configuration
#####################################################################

config RP23XX_FLASH_MTD
	bool "MTD driver over unused QSPI flash"
	default n
	depends on MTD
	---help---
		Expose the part of the QSPI flash that the NuttX image does not
		occupy as an MTD device.

		This driver answers the BIOC_XIPBASE ioctl, because the RP2350 maps
		its QSPI flash into the address space at 0x10000000 and executes
		from it directly.  That allows a filesystem such as XIPFS to hand
		out real flash pointers so that code can be executed in place.

		Note that erasing or programming this flash stalls all instruction
		fetches from it.  The driver therefore runs those operations from
		SRAM with interrupts disabled and the other core parked, which will
		visibly affect interrupt latency for the duration.

if RP23XX_FLASH_MTD

config RP23XX_FLASH_MTD_OFFSET
	hex "Offset of the MTD region from the start of flash"
	default 0x100000
	---help---
		Byte offset from 0x10000000 at which the MTD region begins.  Must
		be a multiple of the 4096 byte erase sector, and must lie beyond
		the end of the NuttX image; the driver refuses to initialize if it
		would overlap __flash_binary_end.

config RP23XX_FLASH_MTD_SIZE
	hex "Size of the MTD region in bytes"
	default 0x100000
	---help---
		Size of the MTD region in bytes.  Must be a multiple of the 4096
		byte erase sector, and must fit within the flash fitted to the
		board.

config RP23XX_FLASH_MTD_SAFE_XIP
	bool "Always restore XIP with the bootrom command mode"
	default n
	---help---
		After each erase or program the QSPI interface must be put back
		into execute-in-place mode.  By default the driver restores the
		fast read mode the bootrom configured at boot, which is what code
		executing in place from this flash needs.

		Enable this to always use the bootrom flash_enter_cmd_xip routine
		instead.  That is slower to execute from, but depends on nothing
		beyond the documented bootrom entry point, so it is the safe
		choice when bringing up a new board.

endif # RP23XX_FLASH_MTD

#####################################################################
#  OTP Configuration
#####################################################################

config RP23XX_OTP
	bool "OTP (one-time-programmable memory) driver"
	default n
	select EFUSE
	---help---
		Expose the RP2350 OTP through the NuttX efuse interface as a
		character device, by default /dev/efuse.

		The OTP is an array of 4096 rows of 24 bits.  This driver uses the
		ECC interpretation of a row, where 16 bits carry data and the rest
		carry a Hamming code, so it presents a flat space of 4096 * 16 bits
		that the efuse field descriptors index into: a field at bit offset
		N refers to bit N % 16 of row N / 16.

		Reads come straight from the chip's ECC-translated window, and are
		free of side effects.  A page locked against reads is reported as
		an error rather than being allowed to raise a bus fault.

		Programming is a separate option below, and is off by default.

if RP23XX_OTP

config RP23XX_OTP_WRITE
	bool "Allow programming the OTP"
	default n
	---help---
		Build the code that programs OTP rows, through the bootrom.

		Leave this off unless the application really has to burn fuses.
		Programming is IRREVERSIBLE: a bit can only ever go from zero to
		one, and because the ECC bits are computed over the whole row, a
		row can only be programmed once.  A mistake here permanently
		damages the part, and some rows control boot and debug behaviour,
		so a wrong write can make a board unbootable or lock out the
		debugger for good.

		With this option off, EFUSEIOC_WRITE_FIELD fails with EPERM and
		reads still work normally.

endif # RP23XX_OTP
