Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'usb-ci-v4.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb into usb-testing

Peter writes:

The chipidea changes for v4.5-rc1

- Delete static debug for chipidea driver.
- Suspend USB core when A device tries to switch to peripheral mode,
at former design, it just stopped SoF simply but USB core doesn't know it.
- Several small changes.

+74 -95
+2 -2
Documentation/usb/chipidea.txt
··· 7 7 --------------------------------------- 8 8 Select CONFIG_USB_OTG_FSM, rebuild kernel Image and modules. 9 9 If you want to check some internal variables for otg fsm, 10 - select CONFIG_USB_CHIPIDEA_DEBUG, there are 2 files which 11 - can show otg fsm variables and some controller registers value: 10 + mount debugfs, there are 2 files which can show otg fsm 11 + variables and some controller registers value: 12 12 cat /sys/kernel/debug/ci_hdrc.0/otg 13 13 cat /sys/kernel/debug/ci_hdrc.0/registers 14 14
-5
drivers/usb/chipidea/Kconfig
··· 37 37 Say Y here to enable host controller functionality of the 38 38 ChipIdea driver. 39 39 40 - config USB_CHIPIDEA_DEBUG 41 - bool "ChipIdea driver debug" 42 - help 43 - Say Y here to enable debugging output of the ChipIdea driver. 44 - 45 40 endif
+1 -4
drivers/usb/chipidea/Makefile
··· 1 - ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG 2 - 3 1 obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o 4 2 5 - ci_hdrc-y := core.o otg.o 3 + ci_hdrc-y := core.o otg.o debug.o 6 4 ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o 7 5 ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o 8 - ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG) += debug.o 9 6 ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o 10 7 11 8 # Glue/Bridge layers go here
+3
drivers/usb/chipidea/ci.h
··· 433 433 434 434 void ci_platform_configure(struct ci_hdrc *ci); 435 435 436 + int dbg_create_files(struct ci_hdrc *ci); 437 + 438 + void dbg_remove_files(struct ci_hdrc *ci); 436 439 #endif /* __DRIVERS_USB_CHIPIDEA_CI_H */
+6
drivers/usb/chipidea/ci_hdrc_imx.c
··· 345 345 return 0; 346 346 } 347 347 348 + static void ci_hdrc_imx_shutdown(struct platform_device *pdev) 349 + { 350 + ci_hdrc_imx_remove(pdev); 351 + } 352 + 348 353 #ifdef CONFIG_PM 349 354 static int imx_controller_suspend(struct device *dev) 350 355 { ··· 467 462 static struct platform_driver ci_hdrc_imx_driver = { 468 463 .probe = ci_hdrc_imx_probe, 469 464 .remove = ci_hdrc_imx_remove, 465 + .shutdown = ci_hdrc_imx_shutdown, 470 466 .driver = { 471 467 .name = "imx_usb", 472 468 .of_match_table = ci_hdrc_imx_dt_ids,
+22 -37
drivers/usb/chipidea/core.c
··· 23 23 * - BUS: bus glue code, bus abstraction layer 24 24 * 25 25 * Compile Options 26 - * - CONFIG_USB_CHIPIDEA_DEBUG: enable debug facilities 27 26 * - STALL_IN: non-empty bulk-in pipes cannot be halted 28 27 * if defined mass storage compliance succeeds but with warnings 29 28 * => case 4: Hi > Dn ··· 70 71 #include "udc.h" 71 72 #include "bits.h" 72 73 #include "host.h" 73 - #include "debug.h" 74 74 #include "otg.h" 75 75 #include "otg_fsm.h" 76 76 ··· 686 688 if (usb_get_maximum_speed(dev) == USB_SPEED_FULL) 687 689 platdata->flags |= CI_HDRC_FORCE_FULLSPEED; 688 690 689 - if (of_find_property(dev->of_node, "phy-clkgate-delay-us", NULL)) 690 - of_property_read_u32(dev->of_node, "phy-clkgate-delay-us", 691 + of_property_read_u32(dev->of_node, "phy-clkgate-delay-us", 691 692 &platdata->phy_clkgate_delay_us); 692 693 693 694 platdata->itc_setting = 1; 694 - if (of_find_property(dev->of_node, "itc-setting", NULL)) { 695 - ret = of_property_read_u32(dev->of_node, "itc-setting", 696 - &platdata->itc_setting); 697 - if (ret) { 698 - dev_err(dev, 699 - "failed to get itc-setting\n"); 700 - return ret; 701 - } 702 - } 703 695 704 - if (of_find_property(dev->of_node, "ahb-burst-config", NULL)) { 705 - ret = of_property_read_u32(dev->of_node, "ahb-burst-config", 706 - &platdata->ahb_burst_config); 707 - if (ret) { 708 - dev_err(dev, 709 - "failed to get ahb-burst-config\n"); 710 - return ret; 711 - } 696 + of_property_read_u32(dev->of_node, "itc-setting", 697 + &platdata->itc_setting); 698 + 699 + ret = of_property_read_u32(dev->of_node, "ahb-burst-config", 700 + &platdata->ahb_burst_config); 701 + if (!ret) { 712 702 platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST; 703 + } else if (ret != -EINVAL) { 704 + dev_err(dev, "failed to get ahb-burst-config\n"); 705 + return ret; 713 706 } 714 707 715 - if (of_find_property(dev->of_node, "tx-burst-size-dword", NULL)) { 716 - ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword", 717 - &platdata->tx_burst_size); 718 - if (ret) { 719 - dev_err(dev, 720 - "failed to get tx-burst-size-dword\n"); 721 - return ret; 722 - } 708 + ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword", 709 + &platdata->tx_burst_size); 710 + if (!ret) { 723 711 platdata->flags |= CI_HDRC_OVERRIDE_TX_BURST; 712 + } else if (ret != -EINVAL) { 713 + dev_err(dev, "failed to get tx-burst-size-dword\n"); 714 + return ret; 724 715 } 725 716 726 - if (of_find_property(dev->of_node, "rx-burst-size-dword", NULL)) { 727 - ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword", 728 - &platdata->rx_burst_size); 729 - if (ret) { 730 - dev_err(dev, 731 - "failed to get rx-burst-size-dword\n"); 732 - return ret; 733 - } 717 + ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword", 718 + &platdata->rx_burst_size); 719 + if (!ret) { 734 720 platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST; 721 + } else if (ret != -EINVAL) { 722 + dev_err(dev, "failed to get rx-burst-size-dword\n"); 723 + return ret; 735 724 } 736 725 737 726 ext_id = ERR_PTR(-ENODEV);
-1
drivers/usb/chipidea/debug.c
··· 15 15 #include "ci.h" 16 16 #include "udc.h" 17 17 #include "bits.h" 18 - #include "debug.h" 19 18 #include "otg.h" 20 19 21 20 /**
-30
drivers/usb/chipidea/debug.h
··· 1 - /* 2 - * debug.h - ChipIdea USB driver debug interfaces 3 - * 4 - * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. 5 - * 6 - * Author: David Lopo 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License version 2 as 10 - * published by the Free Software Foundation. 11 - */ 12 - 13 - #ifndef __DRIVERS_USB_CHIPIDEA_DEBUG_H 14 - #define __DRIVERS_USB_CHIPIDEA_DEBUG_H 15 - 16 - #ifdef CONFIG_USB_CHIPIDEA_DEBUG 17 - int dbg_create_files(struct ci_hdrc *ci); 18 - void dbg_remove_files(struct ci_hdrc *ci); 19 - #else 20 - static inline int dbg_create_files(struct ci_hdrc *ci) 21 - { 22 - return 0; 23 - } 24 - 25 - static inline void dbg_remove_files(struct ci_hdrc *ci) 26 - { 27 - } 28 - #endif 29 - 30 - #endif /* __DRIVERS_USB_CHIPIDEA_DEBUG_H */
+2
drivers/usb/chipidea/host.c
··· 190 190 (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) 191 191 regulator_disable(ci->platdata->reg_vbus); 192 192 } 193 + ci->hcd = NULL; 194 + ci->otg.host = NULL; 193 195 } 194 196 195 197
+18 -8
drivers/usb/chipidea/otg_fsm.c
··· 485 485 486 486 /* 487 487 * Generate SOF by host. 488 - * This is controlled through suspend/resume the port. 489 488 * In host mode, controller will automatically send SOF. 490 489 * Suspend will block the data on the port. 490 + * 491 + * This is controlled through usbcore by usb autosuspend, 492 + * so the usb device class driver need support autosuspend, 493 + * otherwise the bus suspend will not happen. 491 494 */ 492 495 static void ci_otg_loc_sof(struct otg_fsm *fsm, int on) 493 496 { 494 - struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm); 497 + struct usb_device *udev; 495 498 496 - if (on) 497 - hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_FPR, 498 - PORTSC_FPR); 499 - else 500 - hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_SUSP, 501 - PORTSC_SUSP); 499 + if (!fsm->otg->host) 500 + return; 501 + 502 + udev = usb_hub_find_child(fsm->otg->host->root_hub, 1); 503 + if (!udev) 504 + return; 505 + 506 + if (on) { 507 + usb_disable_autosuspend(udev); 508 + } else { 509 + pm_runtime_set_autosuspend_delay(&udev->dev, 0); 510 + usb_enable_autosuspend(udev); 511 + } 502 512 } 503 513 504 514 /*
+20 -8
drivers/usb/chipidea/udc.c
··· 26 26 #include "ci.h" 27 27 #include "udc.h" 28 28 #include "bits.h" 29 - #include "debug.h" 30 29 #include "otg.h" 31 30 #include "otg_fsm.h" 32 31 ··· 402 403 } 403 404 404 405 /** 405 - * _hardware_queue: configures a request at hardware level 406 - * @gadget: gadget 406 + * _hardware_enqueue: configures a request at hardware level 407 407 * @hwep: endpoint 408 + * @hwreq: request 408 409 * 409 410 * This function returns an error code 410 411 */ ··· 433 434 if (hwreq->req.dma % PAGE_SIZE) 434 435 pages--; 435 436 436 - if (rest == 0) 437 - add_td_to_list(hwep, hwreq, 0); 437 + if (rest == 0) { 438 + ret = add_td_to_list(hwep, hwreq, 0); 439 + if (ret < 0) 440 + goto done; 441 + } 438 442 439 443 while (rest > 0) { 440 444 unsigned count = min(hwreq->req.length - hwreq->req.actual, 441 445 (unsigned)(pages * CI_HDRC_PAGE_SIZE)); 442 - add_td_to_list(hwep, hwreq, count); 446 + ret = add_td_to_list(hwep, hwreq, count); 447 + if (ret < 0) 448 + goto done; 449 + 443 450 rest -= count; 444 451 } 445 452 446 453 if (hwreq->req.zero && hwreq->req.length && hwep->dir == TX 447 - && (hwreq->req.length % hwep->ep.maxpacket == 0)) 448 - add_td_to_list(hwep, hwreq, 0); 454 + && (hwreq->req.length % hwep->ep.maxpacket == 0)) { 455 + ret = add_td_to_list(hwep, hwreq, 0); 456 + if (ret < 0) 457 + goto done; 458 + } 449 459 450 460 firstnode = list_first_entry(&hwreq->tds, struct td_node, td); 451 461 ··· 795 787 796 788 /** 797 789 * _ep_queue: queues (submits) an I/O request to an endpoint 790 + * @ep: endpoint 791 + * @req: request 792 + * @gfp_flags: GFP flags (not used) 798 793 * 799 794 * Caller must hold lock 795 + * This function returns an error code 800 796 */ 801 797 static int _ep_queue(struct usb_ep *ep, struct usb_request *req, 802 798 gfp_t __maybe_unused gfp_flags)