#
# USB Dual Role (OTG-ready) Controller Drivers
# for silicon based on Mentor Graphics INVENTRA designs
#

comment "Enable Host or Gadget support to see Inventra options"
	depends on !USB && USB_GADGET=n

# (M)HDRC = (Multipoint) Highspeed Dual-Role Controller
config USB_MUSB_HDRC
	depends on (USB || USB_GADGET)
	depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523))
	select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN)
	select NOP_USB_XCEIV if (ARCH_TI81XX)
	select TWL4030_USB if MACH_OMAP_3430SDP
	select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
	select USB_OTG_UTILS
	tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
	help
	  Say Y here if your system has a dual role high speed USB
	  controller based on the Mentor Graphics silicon IP.  Then
	  configure options to match your silicon and the board
	  it's being used with, including the USB peripheral role,
	  or the USB host role, or both.

	  Texas Instruments familiies using this IP include DaVinci
	  (35x, 644x ...), OMAP 243x, OMAP 3, and TUSB 6010.

	  Analog Devices parts using this IP include Blackfin BF54x,
	  BF525 and BF527.

	  If you do not know what this is, please say N.

	  To compile this driver as a module, choose M here; the
	  module will be called "musb-hdrc".

comment "Platform Glue Layer"
	depends on USB_MUSB_HDRC

config USB_MUSB_DAVINCI_GLUE
	select USB_MUSB_DAVINCI
	tristate "DaVinci"
	depends on ARCH_DAVINCI_DMx && USB_MUSB_HDRC

config USB_MUSB_DA8XX_GLUE
	select USB_MUSB_DA8XX
	tristate "DA8xx/OMAP-L1x"
	depends on ARCH_DAVINCI_DA8XX && USB_MUSB_HDRC

config USB_MUSB_TUSB6010_GLUE
	select USB_MUSB_TUSB6010
	tristate "TUSB6010"
	depends on ARCH_OMAP && USB_MUSB_HDRC

config USB_MUSB_OMAP2PLUS_GLUE
	select USB_MUSB_OMAP2PLUS
	tristate "OMAP2430 and onwards"
	depends on ARCH_OMAP2PLUS && USB_MUSB_HDRC

config USB_MUSB_AM35X_GLUE
	select USB_MUSB_AM35X
	tristate "AM35x"
	depends on ARCH_OMAP && USB_MUSB_HDRC

config USB_MUSB_TI81XX_GLUE
	select USB_MUSB_TI81XX
	tristate "TI81XX"
	depends on ARCH_TI81XX && USB_MUSB_HDRC

config USB_MUSB_BLACKFIN_GLUE
	select USB_MUSB_BLACKFIN
	tristate "Blackfin"
	depends on ((BF54x && !BF544) || (BF52x && ! BF522 && !BF523)) && USB_MUSB_HDRC

config USB_MUSB_UX500_GLUE
	select USB_MUSB_UX500
	tristate "U8500 and U5500"
	depends on ((ARCH_U8500 && AB8500_USB) || ARCH_U5500) && USB_MUSB_HDRC

config USB_MUSB_DAVINCI
	bool
	default n
config USB_MUSB_DA8XX
	bool
	default n
config USB_MUSB_TUSB6010
	bool
	default n
config USB_MUSB_OMAP2PLUS
	bool
	default n
config USB_MUSB_AM35X
	bool
	default n
config USB_MUSB_TI81XX
	bool
	default n
config USB_MUSB_BLACKFIN
	bool
	default n
config USB_MUSB_UX500
	bool
	default n


choice
	prompt "TI81XX usb connector's ID pin control"
	depends on ARCH_TI81XX
	depends on USB_MUSB_HDRC && USB_MUSB_TI81XX_GLUE
	help
	  Dual-Role devices can support both host and peripheral roles,
	  as well as a the special "OTG Device" role which can switch
	  between both roles as needed. For this the ID pin can be
	  controlled either by software or by external usb connectors
	  ID pin (mini-A cable has ID pin grounded and mini-B side of
	  cable the ID pin is open)

config USB_TI81XX_USBID_CTRL_SW
	depends on USB_MUSB_HDRC
	bool "from software setting"
	help
	  Say Y here if your system supports the dual role configuration
	  based on the external usb connectors ID pin. The host role and
	  device role can be controlled by setting ID pin value (ground or
	  open) through software.

config USB_TI81XX_USBID_CTRL_HW
	depends on USB_MUSB_HDRC
	bool "from usb connector"
	help
	  Say Y here if your system supports the dual role configuration
	  based on the external usb connectors ID pin. For host role
	  use mini-A/micro-A usb cable (ID pin grounded) and for device
	  role use mini-B/micro-B usb cable. The USB-ID pin controlled
	  through external ID pin based on usb cable connected.
endchoice

choice
	prompt "Force TI81XX USB0 to "
	depends on USB_MUSB_HDRC && USB_MUSB_OTG && USB_TI81XX_USBID_CTRL_SW
	help
	  The usb0 controller can be configured to host role or
	  device role. The USB ID pin configuration is done
	  through software control. For host role the USB ID pin is grounded
	  and for device role the USB ID pin is open.

config USB_MUSB0_HOST
	depends on USB_MUSB_HDRC
	bool "Host mode"
	help
	  Select this configuration to configure the usb0 for
	  host role. The USB ID pin is configuration through
	  software control. For host role the USB ID pin is grounded
	  and for device role the USB ID pin is open.

config USB_MUSB0_DEVICE
	depends on USB_MUSB_HDRC
	bool "Device mode"
	help
	  Select this configuration to configure the usb0 for
	  device role. The USB ID pin is configuration through
	  software control. For host role the USB ID pin is grounded
	  and for device role the USB ID pin is open.

endchoice

choice
	prompt "Force TI81XX USB1 to "
	depends on USB_MUSB_HDRC && USB_MUSB_OTG && USB_TI81XX_USBID_CTRL_SW
	help
	  The usb1 controller can be configured to host role or
	  device role. The USB ID pin configuration is done
	  through software control. For host role the USB ID pin is grounded
	  and for device role the USB ID pin is open.

config USB_MUSB1_HOST
	depends on USB_MUSB_HDRC
	bool "Host mode"
	help
	  Select this configuration to configure the usb1 for
	  host role. The USB ID pin is configuration through
	  software control. For host role the USB ID pin is grounded
	  and for device role the USB ID pin is open.

config USB_MUSB1_DEVICE
	depends on USB_MUSB_HDRC
	bool "Device mode"
	help
	  Select this configuration to configure the usb1 for
	  device role. The USB ID pin is configuration through
	  software control. For host role the USB ID pin is grounded
	  and for device role the USB ID pin is open.

endchoice

choice
	prompt "Driver Mode"
	depends on USB_MUSB_HDRC
	help
	  Dual-Role devices can support both host and peripheral roles,
	  as well as a the special "OTG Device" role which can switch
	  between both roles as needed.

# use USB_MUSB_HDRC_HCD not USB_MUSB_HOST to #ifdef host side support;
# OTG needs both roles, not just USB_MUSB_HOST.
config USB_MUSB_HOST
	depends on USB
	bool "USB Host"
	help
	  Say Y here if your system supports the USB host role.
	  If it has a USB "A" (rectangular), "Mini-A" (uncommon),
	  or "Mini-AB" connector, it supports the host role.
	  (With a "Mini-AB" connector, you should enable USB OTG.)

# use USB_GADGET_MUSB_HDRC not USB_MUSB_PERIPHERAL to #ifdef peripheral
# side support ... OTG needs both roles
config USB_MUSB_PERIPHERAL
	depends on USB_GADGET
	bool "USB Peripheral (gadget stack)"
	select USB_GADGET_MUSB_HDRC
	help
	  Say Y here if your system supports the USB peripheral role.
	  If it has a USB "B" (squarish), "Mini-B", or "Mini-AB"
	  connector, it supports the peripheral role.
	  (With a "Mini-AB" connector, you should enable USB OTG.)

config USB_MUSB_OTG
	depends on USB && USB_GADGET && PM && EXPERIMENTAL
	bool "Both host and peripheral:  USB OTG (On The Go) Device"
	select USB_GADGET_MUSB_HDRC
	select USB_OTG
	help
	   The most notable feature of USB OTG is support for a
	   "Dual-Role" device, which can act as either a device
	   or a host.  The initial role choice can be changed
	   later, when two dual-role devices talk to each other.

	   At this writing, the OTG support in this driver is incomplete,
	   omitting the mandatory HNP or SRP protocols.  However, some
	   of the cable based role switching works.  (That is, grounding
	   the ID pin switches the controller to host mode, while leaving
	   it floating leaves it in peripheral mode.)

	   Select this if your system has a Mini-AB connector, or
	   to simplify certain kinds of configuration.

	   To implement your OTG Targeted Peripherals List (TPL), enable
	   USB_OTG_WHITELIST and update "drivers/usb/core/otg_whitelist.h"
	   to match your requirements.

endchoice

# enable peripheral support (including with OTG)
config USB_GADGET_MUSB_HDRC
	bool
	depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG)
#	default y
#	select USB_GADGET_DUALSPEED
#	select USB_GADGET_SELECTED

# enables host support (including with OTG)
config USB_MUSB_HDRC_HCD
	bool
	depends on USB_MUSB_HDRC && (USB_MUSB_HOST || USB_MUSB_OTG)
	select USB_OTG if USB_GADGET_MUSB_HDRC
	default y


config MUSB_PIO_ONLY
	bool 'Disable DMA (always use PIO)'
	depends on USB_MUSB_HDRC
	default USB_MUSB_TUSB6010 || USB_MUSB_DA8XX
	help
	  All data is copied between memory and FIFO by the CPU.
	  DMA controllers are ignored.

	  Do not select 'n' here unless DMA support for your SOC or board
	  is unavailable (or unstable).  When DMA is enabled at compile time,
	  you can still disable it at run time using the "use_dma=n" module
	  parameter.

config USB_INVENTRA_DMA_HW
	select USB_INVENTRA_DMA
	tristate
	depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY && !USB_MUSB_AM35X
	default USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN
	help
	  Enable DMA transfers using Mentor's engine.

config USB_TI_CPPI_DMA_HW
	select USB_TI_CPPI_DMA
	tristate
	depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY
	default USB_MUSB_DAVINCI
	help
	  Enable DMA transfers when TI CPPI DMA is available.

config USB_TI_CPPI41_DMA_HW
	select USB_TI_CPPI41_DMA
	tristate
	depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY
	default ARCH_DAVINCI_DA8XX || USB_MUSB_AM35X || ARCH_TI81XX
	select CPPI41
	help
	 Configure this option to include the CPPI 4.1 support,
	 The CPPI 4.1 DMA engine integrated with musb controller
	 accelarate the usb packet transmission and receception
	 to/from musb endpoints.

config USB_TUSB_OMAP_DMA_HW
	select USB_TUSB_OMAP_DMA
	tristate
	depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY
	depends on USB_MUSB_TUSB6010
	depends on ARCH_OMAP
	default y
	help
	  Enable DMA transfers on TUSB 6010 when OMAP DMA is available.

config USB_INVENTRA_DMA
	bool
	default n

config MUSB_USE_SYSTEM_DMA_WORKAROUND
	bool 'Use System DMA for Mentor DMA workaround'
	depends on USB_MUSB_HDRC && USB_INVENTRA_DMA && ARCH_OMAP
	default y
	help
          MUSB RTL version 1.4 (OMAP34x/35x) has a hardware issue when
	  TX and RX DMA channels are simultaneously enabled. To work
	  around this issue, you can choose to use System DMA for RX
	  channels.

	  Also on Mentor DMA in MUSB RTL version 1.8 (OMAP3630, AM/DM37x)
	  requires buffers to be aligned on a four byte boundary. This affects
	  USB CDC/RNDIS class application where buffers are always unaligned.
	  To work around this issue, you can choose to use System DMA for
	  unaligned buffers.

config USB_TI_CPPI_DMA
	bool
	default n

config USB_TI_CPPI41_DMA
	bool
	default n

config USB_TUSB_OMAP_DMA
	bool
	default n


config	USB_MUSB_DEBUG
	depends on USB_MUSB_HDRC
	bool "Enable debugging messages"
	default n
	help
	  This enables musb debugging. To set the logging level use the debug
	  module parameter. Starting at level 3, per-transfer (urb, usb_request,
	  packet, or dma transfer) tracing may kick in.
