diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-03 15:15:10 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-03 15:15:10 -0500 |
| commit | 73ad0adcb69d6a895ff73855ab366a7ae0b2fb0b (patch) | |
| tree | a66967eb3fe9b6162820c93b5c56221d90c291c8 /include/linux/usb | |
| parent | 99f14bd4d1b2a1b1b6cd508e08efdbc5e3919198 (diff) | |
| parent | 836a2164491b19dcd4f29d574e548bcadd421a6a (diff) | |
Merge tag 'usb-for-v3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next
Felipe writes:
usb: changes for v3.14 merge window
This pull request is quite extensive, containing
105 non-merge commits. Because of that, we describe
the changes in sections below:
New drivers:
- Keystone PHY driver and DWC3 Glue Layer
- Aeroflex Gaisler GRUSBDC
- Tahvo PHY driver for N770
- JZ4740 MUSB gluer Layer
- Broadcom PHY Driver
Important new features:
- MUSB DSPS learned about suspend/resume
- New quirk_ep_out_aligned_size flag added to struct usb_gadget
- DWC3 initializes the new quirk flag so gadget drivers can use it.
- AM335x PHY Driver learns about remote wakeup
- Renesas USBHS now requests DMA Engine only once
- s3c-hsotg is now re-used on Broadcom devices
- USB PHY layer now makes sure to initialize the notifier for all
drivers
- omap-control learned about TI's new AM437x devices
- few other usb gadget/function drivers learned about the new
configfs-based binding.
Misc Fixes and Clean Ups:
- Several sparse fixes all over the place
- Removal of redundant of_match_ptr()
- r-car gen2 phy now uses usb_add_phy_dev()
- removal of DEFINE_PCI_DEVICE_TABLE() from a few drivers
- conversion to clk_prepare/clk_unprepare on r8a66597-udc
- some randconfig errors and build warnings were fixed
- removal of unnecessary lock on dwc3-omap.c
Signed-of-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'include/linux/usb')
| -rw-r--r-- | include/linux/usb/composite.h | 2 | ||||
| -rw-r--r-- | include/linux/usb/functionfs.h | 30 | ||||
| -rw-r--r-- | include/linux/usb/gadget.h | 58 | ||||
| -rw-r--r-- | include/linux/usb/musb.h | 3 | ||||
| -rw-r--r-- | include/linux/usb/omap_control_usb.h | 6 | ||||
| -rw-r--r-- | include/linux/usb/otg-fsm.h | 244 |
6 files changed, 304 insertions, 39 deletions
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 5e61589fc166..dba63f53906c 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
| @@ -468,6 +468,8 @@ struct usb_function_instance { | |||
| 468 | struct config_group group; | 468 | struct config_group group; |
| 469 | struct list_head cfs_list; | 469 | struct list_head cfs_list; |
| 470 | struct usb_function_driver *fd; | 470 | struct usb_function_driver *fd; |
| 471 | int (*set_inst_name)(struct usb_function_instance *inst, | ||
| 472 | const char *name); | ||
| 471 | void (*free_func_inst)(struct usb_function_instance *inst); | 473 | void (*free_func_inst)(struct usb_function_instance *inst); |
| 472 | }; | 474 | }; |
| 473 | 475 | ||
diff --git a/include/linux/usb/functionfs.h b/include/linux/usb/functionfs.h index 65d0a88dbc67..71190663f1ee 100644 --- a/include/linux/usb/functionfs.h +++ b/include/linux/usb/functionfs.h | |||
| @@ -3,34 +3,4 @@ | |||
| 3 | 3 | ||
| 4 | #include <uapi/linux/usb/functionfs.h> | 4 | #include <uapi/linux/usb/functionfs.h> |
| 5 | 5 | ||
| 6 | |||
| 7 | struct ffs_data; | ||
| 8 | struct usb_composite_dev; | ||
| 9 | struct usb_configuration; | ||
| 10 | |||
| 11 | |||
| 12 | static int functionfs_init(void) __attribute__((warn_unused_result)); | ||
| 13 | static void functionfs_cleanup(void); | ||
| 14 | |||
| 15 | static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) | ||
| 16 | __attribute__((warn_unused_result, nonnull)); | ||
| 17 | static void functionfs_unbind(struct ffs_data *ffs) | ||
| 18 | __attribute__((nonnull)); | ||
| 19 | |||
| 20 | static int functionfs_bind_config(struct usb_composite_dev *cdev, | ||
| 21 | struct usb_configuration *c, | ||
| 22 | struct ffs_data *ffs) | ||
| 23 | __attribute__((warn_unused_result, nonnull)); | ||
| 24 | |||
| 25 | |||
| 26 | static int functionfs_ready_callback(struct ffs_data *ffs) | ||
| 27 | __attribute__((warn_unused_result, nonnull)); | ||
| 28 | static void functionfs_closed_callback(struct ffs_data *ffs) | ||
| 29 | __attribute__((nonnull)); | ||
| 30 | static void *functionfs_acquire_dev_callback(const char *dev_name) | ||
| 31 | __attribute__((warn_unused_result, nonnull)); | ||
| 32 | static void functionfs_release_dev_callback(struct ffs_data *ffs_data) | ||
| 33 | __attribute__((nonnull)); | ||
| 34 | |||
| 35 | |||
| 36 | #endif | 6 | #endif |
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 942ef5e053bf..c3a61853cd13 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
| @@ -148,6 +148,9 @@ struct usb_ep_ops { | |||
| 148 | * @maxpacket:The maximum packet size used on this endpoint. The initial | 148 | * @maxpacket:The maximum packet size used on this endpoint. The initial |
| 149 | * value can sometimes be reduced (hardware allowing), according to | 149 | * value can sometimes be reduced (hardware allowing), according to |
| 150 | * the endpoint descriptor used to configure the endpoint. | 150 | * the endpoint descriptor used to configure the endpoint. |
| 151 | * @maxpacket_limit:The maximum packet size value which can be handled by this | ||
| 152 | * endpoint. It's set once by UDC driver when endpoint is initialized, and | ||
| 153 | * should not be changed. Should not be confused with maxpacket. | ||
| 151 | * @max_streams: The maximum number of streams supported | 154 | * @max_streams: The maximum number of streams supported |
| 152 | * by this EP (0 - 16, actual number is 2^n) | 155 | * by this EP (0 - 16, actual number is 2^n) |
| 153 | * @mult: multiplier, 'mult' value for SS Isoc EPs | 156 | * @mult: multiplier, 'mult' value for SS Isoc EPs |
| @@ -171,6 +174,7 @@ struct usb_ep { | |||
| 171 | const struct usb_ep_ops *ops; | 174 | const struct usb_ep_ops *ops; |
| 172 | struct list_head ep_list; | 175 | struct list_head ep_list; |
| 173 | unsigned maxpacket:16; | 176 | unsigned maxpacket:16; |
| 177 | unsigned maxpacket_limit:16; | ||
| 174 | unsigned max_streams:16; | 178 | unsigned max_streams:16; |
| 175 | unsigned mult:2; | 179 | unsigned mult:2; |
| 176 | unsigned maxburst:5; | 180 | unsigned maxburst:5; |
| @@ -182,6 +186,21 @@ struct usb_ep { | |||
| 182 | /*-------------------------------------------------------------------------*/ | 186 | /*-------------------------------------------------------------------------*/ |
| 183 | 187 | ||
| 184 | /** | 188 | /** |
| 189 | * usb_ep_set_maxpacket_limit - set maximum packet size limit for endpoint | ||
| 190 | * @ep:the endpoint being configured | ||
| 191 | * @maxpacket_limit:value of maximum packet size limit | ||
| 192 | * | ||
| 193 | * This function shoud be used only in UDC drivers to initialize endpoint | ||
| 194 | * (usually in probe function). | ||
| 195 | */ | ||
| 196 | static inline void usb_ep_set_maxpacket_limit(struct usb_ep *ep, | ||
| 197 | unsigned maxpacket_limit) | ||
| 198 | { | ||
| 199 | ep->maxpacket_limit = maxpacket_limit; | ||
| 200 | ep->maxpacket = maxpacket_limit; | ||
| 201 | } | ||
| 202 | |||
| 203 | /** | ||
| 185 | * usb_ep_enable - configure endpoint, making it usable | 204 | * usb_ep_enable - configure endpoint, making it usable |
| 186 | * @ep:the endpoint being configured. may not be the endpoint named "ep0". | 205 | * @ep:the endpoint being configured. may not be the endpoint named "ep0". |
| 187 | * drivers discover endpoints through the ep_list of a usb_gadget. | 206 | * drivers discover endpoints through the ep_list of a usb_gadget. |
| @@ -485,6 +504,11 @@ struct usb_gadget_ops { | |||
| 485 | * @max_speed: Maximal speed the UDC can handle. UDC must support this | 504 | * @max_speed: Maximal speed the UDC can handle. UDC must support this |
| 486 | * and all slower speeds. | 505 | * and all slower speeds. |
| 487 | * @state: the state we are now (attached, suspended, configured, etc) | 506 | * @state: the state we are now (attached, suspended, configured, etc) |
| 507 | * @name: Identifies the controller hardware type. Used in diagnostics | ||
| 508 | * and sometimes configuration. | ||
| 509 | * @dev: Driver model state for this abstract device. | ||
| 510 | * @out_epnum: last used out ep number | ||
| 511 | * @in_epnum: last used in ep number | ||
| 488 | * @sg_supported: true if we can handle scatter-gather | 512 | * @sg_supported: true if we can handle scatter-gather |
| 489 | * @is_otg: True if the USB device port uses a Mini-AB jack, so that the | 513 | * @is_otg: True if the USB device port uses a Mini-AB jack, so that the |
| 490 | * gadget driver must provide a USB OTG descriptor. | 514 | * gadget driver must provide a USB OTG descriptor. |
| @@ -497,11 +521,8 @@ struct usb_gadget_ops { | |||
| 497 | * only supports HNP on a different root port. | 521 | * only supports HNP on a different root port. |
| 498 | * @b_hnp_enable: OTG device feature flag, indicating that the A-Host | 522 | * @b_hnp_enable: OTG device feature flag, indicating that the A-Host |
| 499 | * enabled HNP support. | 523 | * enabled HNP support. |
| 500 | * @name: Identifies the controller hardware type. Used in diagnostics | 524 | * @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to |
| 501 | * and sometimes configuration. | 525 | * MaxPacketSize. |
| 502 | * @dev: Driver model state for this abstract device. | ||
| 503 | * @out_epnum: last used out ep number | ||
| 504 | * @in_epnum: last used in ep number | ||
| 505 | * | 526 | * |
| 506 | * Gadgets have a mostly-portable "gadget driver" implementing device | 527 | * Gadgets have a mostly-portable "gadget driver" implementing device |
| 507 | * functions, handling all usb configurations and interfaces. Gadget | 528 | * functions, handling all usb configurations and interfaces. Gadget |
| @@ -530,16 +551,18 @@ struct usb_gadget { | |||
| 530 | enum usb_device_speed speed; | 551 | enum usb_device_speed speed; |
| 531 | enum usb_device_speed max_speed; | 552 | enum usb_device_speed max_speed; |
| 532 | enum usb_device_state state; | 553 | enum usb_device_state state; |
| 554 | const char *name; | ||
| 555 | struct device dev; | ||
| 556 | unsigned out_epnum; | ||
| 557 | unsigned in_epnum; | ||
| 558 | |||
| 533 | unsigned sg_supported:1; | 559 | unsigned sg_supported:1; |
| 534 | unsigned is_otg:1; | 560 | unsigned is_otg:1; |
| 535 | unsigned is_a_peripheral:1; | 561 | unsigned is_a_peripheral:1; |
| 536 | unsigned b_hnp_enable:1; | 562 | unsigned b_hnp_enable:1; |
| 537 | unsigned a_hnp_support:1; | 563 | unsigned a_hnp_support:1; |
| 538 | unsigned a_alt_hnp_support:1; | 564 | unsigned a_alt_hnp_support:1; |
| 539 | const char *name; | 565 | unsigned quirk_ep_out_aligned_size:1; |
| 540 | struct device dev; | ||
| 541 | unsigned out_epnum; | ||
| 542 | unsigned in_epnum; | ||
| 543 | }; | 566 | }; |
| 544 | #define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) | 567 | #define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) |
| 545 | 568 | ||
| @@ -558,6 +581,23 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) | |||
| 558 | 581 | ||
| 559 | 582 | ||
| 560 | /** | 583 | /** |
| 584 | * usb_ep_align_maybe - returns @len aligned to ep's maxpacketsize if gadget | ||
| 585 | * requires quirk_ep_out_aligned_size, otherwise reguens len. | ||
| 586 | * @g: controller to check for quirk | ||
| 587 | * @ep: the endpoint whose maxpacketsize is used to align @len | ||
| 588 | * @len: buffer size's length to align to @ep's maxpacketsize | ||
| 589 | * | ||
| 590 | * This helper is used in case it's required for any reason to check and maybe | ||
| 591 | * align buffer's size to an ep's maxpacketsize. | ||
| 592 | */ | ||
| 593 | static inline size_t | ||
| 594 | usb_ep_align_maybe(struct usb_gadget *g, struct usb_ep *ep, size_t len) | ||
| 595 | { | ||
| 596 | return !g->quirk_ep_out_aligned_size ? len : | ||
| 597 | round_up(len, (size_t)ep->desc->wMaxPacketSize); | ||
| 598 | } | ||
| 599 | |||
| 600 | /** | ||
| 561 | * gadget_is_dualspeed - return true iff the hardware handles high speed | 601 | * gadget_is_dualspeed - return true iff the hardware handles high speed |
| 562 | * @g: controller that might support both high and full speeds | 602 | * @g: controller that might support both high and full speeds |
| 563 | */ | 603 | */ |
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index eb505250940a..a4ee1b582183 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h | |||
| @@ -76,6 +76,9 @@ struct musb_hdrc_config { | |||
| 76 | unsigned dma:1 __deprecated; /* supports DMA */ | 76 | unsigned dma:1 __deprecated; /* supports DMA */ |
| 77 | unsigned vendor_req:1 __deprecated; /* vendor registers required */ | 77 | unsigned vendor_req:1 __deprecated; /* vendor registers required */ |
| 78 | 78 | ||
| 79 | /* need to explicitly de-assert the port reset after resume? */ | ||
| 80 | unsigned host_port_deassert_reset_at_resume:1; | ||
| 81 | |||
| 79 | u8 num_eps; /* number of endpoints _with_ ep0 */ | 82 | u8 num_eps; /* number of endpoints _with_ ep0 */ |
| 80 | u8 dma_channels __deprecated; /* number of dma channels */ | 83 | u8 dma_channels __deprecated; /* number of dma channels */ |
| 81 | u8 dyn_fifo_size; /* dynamic size in bytes */ | 84 | u8 dyn_fifo_size; /* dynamic size in bytes */ |
diff --git a/include/linux/usb/omap_control_usb.h b/include/linux/usb/omap_control_usb.h index 596b01918813..69ae383ee3cc 100644 --- a/include/linux/usb/omap_control_usb.h +++ b/include/linux/usb/omap_control_usb.h | |||
| @@ -24,6 +24,7 @@ enum omap_control_usb_type { | |||
| 24 | OMAP_CTRL_TYPE_USB2, /* USB2_PHY, power down in CONTROL_DEV_CONF */ | 24 | OMAP_CTRL_TYPE_USB2, /* USB2_PHY, power down in CONTROL_DEV_CONF */ |
| 25 | OMAP_CTRL_TYPE_PIPE3, /* PIPE3 PHY, DPLL & seperate Rx/Tx power */ | 25 | OMAP_CTRL_TYPE_PIPE3, /* PIPE3 PHY, DPLL & seperate Rx/Tx power */ |
| 26 | OMAP_CTRL_TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */ | 26 | OMAP_CTRL_TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */ |
| 27 | OMAP_CTRL_TYPE_AM437USB2, /* USB2 PHY, power e.g. AM437x */ | ||
| 27 | }; | 28 | }; |
| 28 | 29 | ||
| 29 | struct omap_control_usb { | 30 | struct omap_control_usb { |
| @@ -64,6 +65,11 @@ enum omap_control_usb_mode { | |||
| 64 | 65 | ||
| 65 | #define OMAP_CTRL_USB2_PHY_PD BIT(28) | 66 | #define OMAP_CTRL_USB2_PHY_PD BIT(28) |
| 66 | 67 | ||
| 68 | #define AM437X_CTRL_USB2_PHY_PD BIT(0) | ||
| 69 | #define AM437X_CTRL_USB2_OTG_PD BIT(1) | ||
| 70 | #define AM437X_CTRL_USB2_OTGVDET_EN BIT(19) | ||
| 71 | #define AM437X_CTRL_USB2_OTGSESSEND_EN BIT(20) | ||
| 72 | |||
| 67 | #if IS_ENABLED(CONFIG_OMAP_CONTROL_USB) | 73 | #if IS_ENABLED(CONFIG_OMAP_CONTROL_USB) |
| 68 | extern void omap_control_usb_phy_power(struct device *dev, int on); | 74 | extern void omap_control_usb_phy_power(struct device *dev, int on); |
| 69 | extern void omap_control_usb_set_mode(struct device *dev, | 75 | extern void omap_control_usb_set_mode(struct device *dev, |
diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h new file mode 100644 index 000000000000..b6ba1bfb86f2 --- /dev/null +++ b/include/linux/usb/otg-fsm.h | |||
| @@ -0,0 +1,244 @@ | |||
| 1 | /* Copyright (C) 2007,2008 Freescale Semiconductor, Inc. | ||
| 2 | * | ||
| 3 | * This program is free software; you can redistribute it and/or modify it | ||
| 4 | * under the terms of the GNU General Public License as published by the | ||
| 5 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 6 | * option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, but | ||
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 11 | * General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License along | ||
| 14 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 15 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef __LINUX_USB_OTG_FSM_H | ||
| 19 | #define __LINUX_USB_OTG_FSM_H | ||
| 20 | |||
| 21 | #include <linux/mutex.h> | ||
| 22 | #include <linux/errno.h> | ||
| 23 | |||
| 24 | #undef VERBOSE | ||
| 25 | |||
| 26 | #ifdef VERBOSE | ||
| 27 | #define VDBG(fmt, args...) pr_debug("[%s] " fmt , \ | ||
| 28 | __func__, ## args) | ||
| 29 | #else | ||
| 30 | #define VDBG(stuff...) do {} while (0) | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #ifdef VERBOSE | ||
| 34 | #define MPC_LOC printk("Current Location [%s]:[%d]\n", __FILE__, __LINE__) | ||
| 35 | #else | ||
| 36 | #define MPC_LOC do {} while (0) | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #define PROTO_UNDEF (0) | ||
| 40 | #define PROTO_HOST (1) | ||
| 41 | #define PROTO_GADGET (2) | ||
| 42 | |||
| 43 | enum otg_fsm_timer { | ||
| 44 | /* Standard OTG timers */ | ||
| 45 | A_WAIT_VRISE, | ||
| 46 | A_WAIT_VFALL, | ||
| 47 | A_WAIT_BCON, | ||
| 48 | A_AIDL_BDIS, | ||
| 49 | B_ASE0_BRST, | ||
| 50 | A_BIDL_ADIS, | ||
| 51 | |||
| 52 | /* Auxiliary timers */ | ||
| 53 | B_SE0_SRP, | ||
| 54 | B_SRP_FAIL, | ||
| 55 | A_WAIT_ENUM, | ||
| 56 | |||
| 57 | NUM_OTG_FSM_TIMERS, | ||
| 58 | }; | ||
| 59 | |||
| 60 | /* OTG state machine according to the OTG spec */ | ||
| 61 | struct otg_fsm { | ||
| 62 | /* Input */ | ||
| 63 | int id; | ||
| 64 | int adp_change; | ||
| 65 | int power_up; | ||
| 66 | int test_device; | ||
| 67 | int a_bus_drop; | ||
| 68 | int a_bus_req; | ||
| 69 | int a_srp_det; | ||
| 70 | int a_vbus_vld; | ||
| 71 | int b_conn; | ||
| 72 | int a_bus_resume; | ||
| 73 | int a_bus_suspend; | ||
| 74 | int a_conn; | ||
| 75 | int b_bus_req; | ||
| 76 | int b_se0_srp; | ||
| 77 | int b_ssend_srp; | ||
| 78 | int b_sess_vld; | ||
| 79 | /* Auxilary inputs */ | ||
| 80 | int a_sess_vld; | ||
| 81 | int b_bus_resume; | ||
| 82 | int b_bus_suspend; | ||
| 83 | |||
| 84 | /* Output */ | ||
| 85 | int data_pulse; | ||
| 86 | int drv_vbus; | ||
| 87 | int loc_conn; | ||
| 88 | int loc_sof; | ||
| 89 | int adp_prb; | ||
| 90 | int adp_sns; | ||
| 91 | |||
| 92 | /* Internal variables */ | ||
| 93 | int a_set_b_hnp_en; | ||
| 94 | int b_srp_done; | ||
| 95 | int b_hnp_enable; | ||
| 96 | int a_clr_err; | ||
| 97 | |||
| 98 | /* Informative variables */ | ||
| 99 | int a_bus_drop_inf; | ||
| 100 | int a_bus_req_inf; | ||
| 101 | int a_clr_err_inf; | ||
| 102 | int b_bus_req_inf; | ||
| 103 | /* Auxilary informative variables */ | ||
| 104 | int a_suspend_req_inf; | ||
| 105 | |||
| 106 | /* Timeout indicator for timers */ | ||
| 107 | int a_wait_vrise_tmout; | ||
| 108 | int a_wait_vfall_tmout; | ||
| 109 | int a_wait_bcon_tmout; | ||
| 110 | int a_aidl_bdis_tmout; | ||
| 111 | int b_ase0_brst_tmout; | ||
| 112 | int a_bidl_adis_tmout; | ||
| 113 | |||
| 114 | struct otg_fsm_ops *ops; | ||
| 115 | struct usb_otg *otg; | ||
| 116 | |||
| 117 | /* Current usb protocol used: 0:undefine; 1:host; 2:client */ | ||
| 118 | int protocol; | ||
| 119 | struct mutex lock; | ||
| 120 | }; | ||
| 121 | |||
| 122 | struct otg_fsm_ops { | ||
| 123 | void (*chrg_vbus)(struct otg_fsm *fsm, int on); | ||
| 124 | void (*drv_vbus)(struct otg_fsm *fsm, int on); | ||
| 125 | void (*loc_conn)(struct otg_fsm *fsm, int on); | ||
| 126 | void (*loc_sof)(struct otg_fsm *fsm, int on); | ||
| 127 | void (*start_pulse)(struct otg_fsm *fsm); | ||
| 128 | void (*start_adp_prb)(struct otg_fsm *fsm); | ||
| 129 | void (*start_adp_sns)(struct otg_fsm *fsm); | ||
| 130 | void (*add_timer)(struct otg_fsm *fsm, enum otg_fsm_timer timer); | ||
| 131 | void (*del_timer)(struct otg_fsm *fsm, enum otg_fsm_timer timer); | ||
| 132 | int (*start_host)(struct otg_fsm *fsm, int on); | ||
| 133 | int (*start_gadget)(struct otg_fsm *fsm, int on); | ||
| 134 | }; | ||
| 135 | |||
| 136 | |||
| 137 | static inline int otg_chrg_vbus(struct otg_fsm *fsm, int on) | ||
| 138 | { | ||
| 139 | if (!fsm->ops->chrg_vbus) | ||
| 140 | return -EOPNOTSUPP; | ||
| 141 | fsm->ops->chrg_vbus(fsm, on); | ||
| 142 | return 0; | ||
| 143 | } | ||
| 144 | |||
| 145 | static inline int otg_drv_vbus(struct otg_fsm *fsm, int on) | ||
| 146 | { | ||
| 147 | if (!fsm->ops->drv_vbus) | ||
| 148 | return -EOPNOTSUPP; | ||
| 149 | if (fsm->drv_vbus != on) { | ||
| 150 | fsm->drv_vbus = on; | ||
| 151 | fsm->ops->drv_vbus(fsm, on); | ||
| 152 | } | ||
| 153 | return 0; | ||
| 154 | } | ||
| 155 | |||
| 156 | static inline int otg_loc_conn(struct otg_fsm *fsm, int on) | ||
| 157 | { | ||
| 158 | if (!fsm->ops->loc_conn) | ||
| 159 | return -EOPNOTSUPP; | ||
| 160 | if (fsm->loc_conn != on) { | ||
| 161 | fsm->loc_conn = on; | ||
| 162 | fsm->ops->loc_conn(fsm, on); | ||
| 163 | } | ||
| 164 | return 0; | ||
| 165 | } | ||
| 166 | |||
| 167 | static inline int otg_loc_sof(struct otg_fsm *fsm, int on) | ||
| 168 | { | ||
| 169 | if (!fsm->ops->loc_sof) | ||
| 170 | return -EOPNOTSUPP; | ||
| 171 | if (fsm->loc_sof != on) { | ||
| 172 | fsm->loc_sof = on; | ||
| 173 | fsm->ops->loc_sof(fsm, on); | ||
| 174 | } | ||
| 175 | return 0; | ||
| 176 | } | ||
| 177 | |||
| 178 | static inline int otg_start_pulse(struct otg_fsm *fsm) | ||
| 179 | { | ||
| 180 | if (!fsm->ops->start_pulse) | ||
| 181 | return -EOPNOTSUPP; | ||
| 182 | if (!fsm->data_pulse) { | ||
| 183 | fsm->data_pulse = 1; | ||
| 184 | fsm->ops->start_pulse(fsm); | ||
| 185 | } | ||
| 186 | return 0; | ||
| 187 | } | ||
| 188 | |||
| 189 | static inline int otg_start_adp_prb(struct otg_fsm *fsm) | ||
| 190 | { | ||
| 191 | if (!fsm->ops->start_adp_prb) | ||
| 192 | return -EOPNOTSUPP; | ||
| 193 | if (!fsm->adp_prb) { | ||
| 194 | fsm->adp_sns = 0; | ||
| 195 | fsm->adp_prb = 1; | ||
| 196 | fsm->ops->start_adp_prb(fsm); | ||
| 197 | } | ||
| 198 | return 0; | ||
| 199 | } | ||
| 200 | |||
| 201 | static inline int otg_start_adp_sns(struct otg_fsm *fsm) | ||
| 202 | { | ||
| 203 | if (!fsm->ops->start_adp_sns) | ||
| 204 | return -EOPNOTSUPP; | ||
| 205 | if (!fsm->adp_sns) { | ||
| 206 | fsm->adp_sns = 1; | ||
| 207 | fsm->ops->start_adp_sns(fsm); | ||
| 208 | } | ||
| 209 | return 0; | ||
| 210 | } | ||
| 211 | |||
| 212 | static inline int otg_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer timer) | ||
| 213 | { | ||
| 214 | if (!fsm->ops->add_timer) | ||
| 215 | return -EOPNOTSUPP; | ||
| 216 | fsm->ops->add_timer(fsm, timer); | ||
| 217 | return 0; | ||
| 218 | } | ||
| 219 | |||
| 220 | static inline int otg_del_timer(struct otg_fsm *fsm, enum otg_fsm_timer timer) | ||
| 221 | { | ||
| 222 | if (!fsm->ops->del_timer) | ||
| 223 | return -EOPNOTSUPP; | ||
| 224 | fsm->ops->del_timer(fsm, timer); | ||
| 225 | return 0; | ||
| 226 | } | ||
| 227 | |||
| 228 | static inline int otg_start_host(struct otg_fsm *fsm, int on) | ||
| 229 | { | ||
| 230 | if (!fsm->ops->start_host) | ||
| 231 | return -EOPNOTSUPP; | ||
| 232 | return fsm->ops->start_host(fsm, on); | ||
| 233 | } | ||
| 234 | |||
| 235 | static inline int otg_start_gadget(struct otg_fsm *fsm, int on) | ||
| 236 | { | ||
| 237 | if (!fsm->ops->start_gadget) | ||
| 238 | return -EOPNOTSUPP; | ||
| 239 | return fsm->ops->start_gadget(fsm, on); | ||
| 240 | } | ||
| 241 | |||
| 242 | int otg_statemachine(struct otg_fsm *fsm); | ||
| 243 | |||
| 244 | #endif /* __LINUX_USB_OTG_FSM_H */ | ||
