/* linux/include/asm-arm/arch-msm/hsusb.h * * Copyright (C) 2008 Google, Inc. * Author: Brian Swetland * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #ifndef __ASM_ARCH_MSM_HSUSB_H #define __ASM_ARCH_MSM_HSUSB_H #include #include #include #include /** * Supported USB modes * * USB_PERIPHERAL Only peripheral mode is supported. * USB_HOST Only host mode is supported. * USB_OTG OTG mode is supported. * */ enum usb_mode_type { USB_NONE = 0, USB_PERIPHERAL, USB_HOST, USB_OTG, }; /** * OTG control * * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host * only configuration. * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY. * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware. * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs. * */ enum otg_control_type { OTG_NO_CONTROL = 0, OTG_PHY_CONTROL, OTG_PMIC_CONTROL, OTG_USER_CONTROL, }; /** * PHY used in * * INVALID_PHY Unsupported PHY * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY * */ enum msm_usb_phy_type { INVALID_PHY = 0, CI_45NM_INTEGRATED_PHY, SNPS_28NM_INTEGRATED_PHY, }; #define IDEV_CHG_MAX 1500 #define IDEV_CHG_MIN 500 #define IUNIT 100 #define IDEV_ACA_CHG_MAX 1500 #define IDEV_ACA_CHG_LIMIT 500 /** * Different states involved in USB charger detection. * * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection * process is not yet started. * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact. * USB_CHG_STATE_DCD_DONE Data pin contact is detected. * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects * between SDP and DCP/CDP). * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects * between DCP and CDP). * USB_CHG_STATE_DETECTED USB charger type is determined. * */ enum usb_chg_state { USB_CHG_STATE_UNDEFINED = 0, USB_CHG_STATE_WAIT_FOR_DCD, USB_CHG_STATE_DCD_DONE, USB_CHG_STATE_PRIMARY_DONE, USB_CHG_STATE_SECONDARY_DONE, USB_CHG_STATE_DETECTED, }; /** * USB charger types * * USB_INVALID_CHARGER Invalid USB charger. * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port * on USB2.0 compliant host/hub. * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger). * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and * IDEV_CHG_MAX can be drawn irrespective of USB state. * USB_ACA_A_CHARGER B-device is connected on accessory port with charger * connected on charging port. This configuration allows * charging in host mode. * USB_ACA_B_CHARGER No device (or A-device without VBUS) is connected on * accessory port with charger connected on charging port. * USB_ACA_C_CHARGER A-device (with VBUS) is connected on * accessory port with charger connected on charging port. * USB_ACA_DOCK_CHARGER A docking station that has one upstream port and one * or more downstream ports. Capable of supplying * IDEV_CHG_MAX irrespective of devices connected on * accessory ports. */ enum usb_chg_type { USB_INVALID_CHARGER = 0, USB_SDP_CHARGER, USB_DCP_CHARGER, USB_CDP_CHARGER, USB_ACA_A_CHARGER, USB_ACA_B_CHARGER, USB_ACA_C_CHARGER, USB_ACA_DOCK_CHARGER, }; /** * SPS Pipes direction. * * USB_TO_PEER_PERIPHERAL USB (as Producer) to other * peer peripheral. * PEER_PERIPHERAL_TO_USB Other Peripheral to * USB (as consumer). */ enum usb_bam_pipe_dir { USB_TO_PEER_PERIPHERAL, PEER_PERIPHERAL_TO_USB, }; /** * struct msm_otg_platform_data - platform device data * for msm_otg driver. * @phy_init_seq: PHY configuration sequence. val, reg pairs * terminated by -1. * @vbus_power: VBUS power on/off routine. * @power_budget: VBUS power budget in mA (0 will be treated as 500mA). * @mode: Supported mode (OTG/peripheral/host). * @otg_control: OTG switch controlled by user/Id pin * @default_mode: Default operational mode. Applicable only if * OTG switch is controller by user. * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k * dfab_usb_hs_clk in case of 8660 and 8960. * @pmic_id_irq: IRQ number assigned for PMIC USB ID line. * @mhl_enable: indicates MHL connector or not. * @swfi_latency: miminum latency to allow swfi. */ struct msm_otg_platform_data { int *phy_init_seq; void (*vbus_power)(bool on); unsigned power_budget; enum usb_mode_type mode; enum otg_control_type otg_control; enum usb_mode_type default_mode; enum msm_usb_phy_type phy_type; void (*setup_gpio)(enum usb_otg_state state); const char *pclk_src_name; int pmic_id_irq; bool mhl_enable; u32 swfi_latency; }; /** * struct msm_otg: OTG driver data. Shared by HCD and DCD. * @otg: USB OTG Transceiver structure. * @pdata: otg device platform data. * @irq: IRQ number assigned for HSUSB controller. * @clk: clock struct of usb_hs_clk. * @pclk: clock struct of usb_hs_pclk. * @pclk_src: pclk source for voting. * @phy_reset_clk: clock struct of usb_phy_clk. * @core_clk: clock struct of usb_hs_core_clk. * @system_clk: clock struct of usb_system_clk. * @regs: ioremapped register base address. * @inputs: OTG state machine inputs(Id, SessValid etc). * @sm_work: OTG state machine work. * @in_lpm: indicates low power mode (LPM) state. * @async_int: Async interrupt arrived. * @cur_power: The amount of mA available from downstream port. * @chg_work: Charger detection work. * @chg_state: The state of charger detection process. * @chg_type: The type of charger attached. * @dcd_retires: The retry count used to track Data contact * detection process. * @wlock: Wake lock struct to prevent system suspend when * USB is active. * @usbdev_nb: The notifier block used to know about the B-device * connected. Useful only when ACA_A charger is * connected. * @mA_port: The amount of current drawn by the attached B-device. * @pm_qos_req_dma: miminum DMA latency to vote against idle power collapse when cable is connected. * @id_timer: The timer used for polling ID line to detect ACA states. * @xo_handle: TCXO buffer handle */ struct msm_otg { struct otg_transceiver otg; struct msm_otg_platform_data *pdata; int irq; struct clk *clk; struct clk *pclk; struct clk *pclk_src; struct clk *phy_reset_clk; struct clk *core_clk; struct clk *system_clk; void __iomem *regs; #define ID 0 #define B_SESS_VLD 1 #define ID_A 2 #define ID_B 3 #define ID_C 4 unsigned long inputs; struct work_struct sm_work; atomic_t in_lpm; int async_int; unsigned cur_power; struct delayed_work chg_work; enum usb_chg_state chg_state; enum usb_chg_type chg_type; u8 dcd_retries; struct wake_lock wlock; struct notifier_block usbdev_nb; unsigned mA_port; struct timer_list id_timer; unsigned long caps; struct msm_xo_voter *xo_handle; /* * Allowing PHY power collpase turns off the HSUSB 3.3v and 1.8v * analog regulators while going to low power mode. * Currently only 8960(28nm PHY) has the support to allowing PHY * power collapse since it doesn't have leakage currents while * turning off the power rails. */ #define ALLOW_PHY_POWER_COLLAPSE BIT(0) /* * Allow PHY RETENTION mode before turning off the digital * voltage regulator(VDDCX). */ #define ALLOW_PHY_RETENTION BIT(1) /* * Disable the OTG comparators to save more power * if depends on PMIC for VBUS and ID interrupts. */ #define ALLOW_PHY_COMP_DISABLE BIT(2) unsigned long lpm_flags; #define PHY_PWR_COLLAPSED BIT(0) #define PHY_RETENTIONED BIT(1) #define PHY_OTG_COMP_DISABLED BIT(2) struct pm_qos_request_list pm_qos_req_dma; }; struct msm_hsic_host_platform_data { unsigned strobe; unsigned data; unsigned hub_reset; }; struct usb_bam_pipe_connect { u32 src_phy_addr; int src_pipe_index; u32 dst_phy_addr; int dst_pipe_index; u32 data_fifo_base_offset; u32 data_fifo_size; u32 desc_fifo_base_offset; u32 desc_fifo_size; }; struct msm_usb_bam_platform_data { struct usb_bam_pipe_connect *connections; unsigned long usb_bam_phy_base; unsigned long usb_bam_phy_size; int usb_bam_num_pipes; }; #endif