Advertisement
Guest User

Untitled

a guest
Sep 14th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 12.90 KB | None | 0 0
  1. diff --git a/:drivers/usb/host/fusbh200-hcd.c b/:drivers/usb/host/fotg210-hcd.c
  2. index 3536515..000ed80 100644
  3. --- a/:drivers/usb/host/fusbh200-hcd.c
  4. +++ b/:drivers/usb/host/fotg210-hcd.c
  5. @@ -44,9 +44,9 @@
  6.  #include <linux/slab.h>
  7.  #include <linux/uaccess.h>
  8.  #include <linux/platform_device.h>
  9. +#include <linux/io.h>
  10.  
  11.  #include <asm/byteorder.h>
  12. -#include <asm/io.h>
  13.  #include <asm/irq.h>
  14.  #include <asm/unaligned.h>
  15.  
  16. @@ -58,6 +58,8 @@ static const char hcd_name[] = "fotg210_hcd";
  17.  
  18.  #undef FOTG210_URB_TRACE
  19.  
  20. +#define FOTG210_STATS
  21. +
  22.  /* magic numbers that can affect system performance */
  23.  #define    FOTG210_TUNE_CERR       3 /* 0-3 qtd retries; 0 == don't stop */
  24.  #define    FOTG210_TUNE_RL_HS      4 /* nak throttle; see 4.9 */
  25. @@ -73,12 +75,12 @@ static const char   hcd_name[] = "fotg210_hcd";
  26.  #define    FOTG210_TUNE_FLS        1 /* (medium) 512-frame schedule */
  27.  
  28.  /* Initial IRQ latency:  faster than hw default */
  29. -static int log2_irq_thresh = 0;        /* 0 to 6 */
  30. +static int log2_irq_thresh;        /* 0 to 6 */
  31.  module_param(log2_irq_thresh, int, S_IRUGO);
  32.  MODULE_PARM_DESC(log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");
  33.  
  34.  /* initial park setting:  slower than hw default */
  35. -static unsigned park = 0;
  36. +static unsigned park;
  37.  module_param(park, uint, S_IRUGO);
  38.  MODULE_PARM_DESC(park, "park setting; 1-3 back-to-back async packets");
  39.  
  40. @@ -245,8 +247,8 @@ dbg_command_buf(char *buf, unsigned len, const char *label, u32 command)
  41.         );
  42.  }
  43.  
  44. -static int
  45. -dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
  46. +static char
  47. +*dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
  48.  {
  49.     char    *sig;
  50.  
  51. @@ -266,7 +268,7 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
  52.         break;
  53.     }
  54.  
  55. -   return scnprintf(buf, len,
  56. +   scnprintf(buf, len,
  57.         "%s%sport:%d status %06x %d "
  58.         "sig=%s%s%s%s%s%s%s%s",
  59.         label, label[0] ? " " : "", port, status,
  60. @@ -279,6 +281,7 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
  61.         (status & PORT_PE) ? " PE" : "",
  62.         (status & PORT_CSC) ? " CSC" : "",
  63.         (status & PORT_CONNECT) ? " CONNECT" : "");
  64. +   return buf;
  65.  }
  66.  
  67.  /* functions have the "wrong" filename when they're output... */
  68. @@ -296,8 +299,7 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
  69.  
  70.  #define dbg_port(fotg210, label, port, status) { \
  71.     char _buf[80]; \
  72. -   dbg_port_buf(_buf, sizeof(_buf), label, port, status); \
  73. -   fotg210_dbg(fotg210, "%s\n", _buf); \
  74. +   fotg210_dbg(fotg210, "%s\n", dbg_port_buf(_buf, sizeof(_buf), label, port, status) ); \
  75.  }
  76.  
  77.  /*-------------------------------------------------------------------------*/
  78. @@ -666,8 +668,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
  79.     unsigned long       flags;
  80.     unsigned        temp, size, i;
  81.     char            *next, scratch[80];
  82. -   static char     fmt[] = "%*s\n";
  83. -   static char     label[] = "";
  84. +   static const char   fmt[] = "%*s\n";
  85. +   static const char   label[] = "";
  86.  
  87.     hcd = bus_to_hcd(buf->bus);
  88.     fotg210 = hcd_to_fotg210(hcd);
  89. @@ -743,6 +745,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
  90.         next += temp;
  91.     }
  92.  
  93. +#ifdef FOTG210_STATS
  94.     temp = scnprintf(next, size,
  95.         "irq normal %ld err %ld iaa %ld(lost %ld)\n",
  96.         fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa,
  97. @@ -754,6 +757,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
  98.         fotg210->stats.complete, fotg210->stats.unlink);
  99.     size -= temp;
  100.     next += temp;
  101. +#endif
  102.  
  103.  done:
  104.     spin_unlock_irqrestore(&fotg210->lock, flags);
  105. @@ -1588,6 +1592,7 @@ static int fotg210_hub_control(
  106.             if ((temp & PORT_PE) == 0)
  107.                 goto error;
  108.  
  109. +           /* resume signaling for 20 msec */
  110.             fotg210_writel(fotg210, temp | PORT_RESUME, status_reg);
  111.             fotg210->reset_done[wIndex] = jiffies
  112.                     + msecs_to_jiffies(USB_RESUME_TIMEOUT);
  113. @@ -1599,8 +1604,8 @@ static int fotg210_hub_control(
  114.             fotg210_writel(fotg210, temp | PORT_CSC, status_reg);
  115.             break;
  116.         case USB_PORT_FEAT_C_OVER_CURRENT:
  117. -           fotg210_writel(fotg210, temp | BMISR_OVC,
  118. -                      &fotg210->regs->bmisr);
  119. +           fotg210_writel(fotg210, temp | OTGISR_OVC,
  120. +                      &fotg210->regs->otgisr);
  121.             break;
  122.         case USB_PORT_FEAT_C_RESET:
  123.             /* GetPortStatus clears reset */
  124. @@ -1632,8 +1637,8 @@ static int fotg210_hub_control(
  125.         if (temp & PORT_PEC)
  126.             status |= USB_PORT_STAT_C_ENABLE << 16;
  127.  
  128. -       temp1 = fotg210_readl(fotg210, &fotg210->regs->bmisr);
  129. -       if (temp1 & BMISR_OVC)
  130. +       temp1 = fotg210_readl(fotg210, &fotg210->regs->otgisr);
  131. +       if (temp1 & OTGISR_OVC)
  132.             status |= USB_PORT_STAT_C_OVERCURRENT << 16;
  133.  
  134.         /* whoever resumes must GetPortStatus to complete it!! */
  135. @@ -1741,8 +1746,8 @@ static int fotg210_hub_control(
  136.                 set_bit(wIndex, &fotg210->port_c_suspend);
  137.         }
  138.  
  139. -       temp1 = fotg210_readl(fotg210, &fotg210->regs->bmisr);
  140. -       if (temp1 & BMISR_OVC)
  141. +       temp1 = fotg210_readl(fotg210, &fotg210->regs->otgisr);
  142. +       if (temp1 & OTGISR_OVC)
  143.             status |= USB_PORT_STAT_OVERCURRENT;
  144.         if (temp & PORT_RESET)
  145.             status |= USB_PORT_STAT_RESET;
  146. @@ -5111,11 +5116,13 @@ static void fotg210_stop(struct usb_hcd *hcd)
  147.     spin_unlock_irq(&fotg210->lock);
  148.     fotg210_mem_cleanup(fotg210);
  149.  
  150. +#ifdef FOTG210_STATS
  151.     fotg210_dbg(fotg210, "irq normal %ld err %ld iaa %ld (lost %ld)\n",
  152.         fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa,
  153.         fotg210->stats.lost_iaa);
  154.     fotg210_dbg(fotg210, "complete %ld unlink %ld\n",
  155.         fotg210->stats.complete, fotg210->stats.unlink);
  156. +#endif
  157.  
  158.     dbg_status(fotg210, "fotg210_stop completed",
  159.             fotg210_readl(fotg210, &fotg210->regs->status));
  160. @@ -5209,7 +5216,7 @@ static int hcd_fotg210_init(struct usb_hcd *hcd)
  161.          * make problems:  throughput reduction (!), data errors...
  162.          */
  163.         if (park) {
  164. -           park = min(park,(unsigned) 3);
  165. +           park = min_t(unsigned, park, 3);
  166.             temp |= CMD_PARK;
  167.             temp |= park << 8;
  168.         }
  169. @@ -5376,6 +5383,11 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
  170.     cmd = fotg210_readl(fotg210, &fotg210->regs->command);
  171.     bh = 0;
  172.  
  173. +   /* unrequested/ignored: Frame List Rollover */
  174. +   dbg_status(fotg210, "irq", status);
  175. +
  176. +   /* INT, ERR, and IAA interrupt rates can be throttled */
  177. +
  178.     /* normal [4.15.1.2] or error [4.15.1.1] completion */
  179.     if (likely((status & (STS_INT|STS_ERR)) != 0)) {
  180.         if (likely((status & STS_ERR) == 0))
  181. @@ -5776,16 +5788,15 @@ static const struct hc_driver fotg210_fotg210_hc_driver = {
  182.  
  183.  static void fotg210_init(struct fotg210_hcd *fotg210)
  184.  {
  185. -   u32 reg;
  186. +   u32 value;
  187.  
  188. -   reg = fotg210_readl(fotg210, &fotg210->regs->bmcsr);
  189. -   reg |= BMCSR_INT_POLARITY;
  190. -   reg &= ~BMCSR_VBUS_OFF;
  191. -   fotg210_writel(fotg210, reg, &fotg210->regs->bmcsr);
  192. +   iowrite32(GMIR_MDEV_INT | GMIR_MOTG_INT | GMIR_INT_POLARITY,
  193. +         &fotg210->regs->gmir);
  194.  
  195. -   reg = fotg210_readl(fotg210, &fotg210->regs->bmier);
  196. -   fotg210_writel(fotg210, reg | BMIER_OVC_EN | BMIER_VBUS_ERR_EN,
  197. -       &fotg210->regs->bmier);
  198. +   value = ioread32(&fotg210->regs->otgcsr);
  199. +   value &= ~OTGCSR_A_BUS_DROP;
  200. +   value |= OTGCSR_A_BUS_REQ;
  201. +   iowrite32(value, &fotg210->regs->otgcsr);
  202.  }
  203.  
  204.  /**
  205. @@ -5827,41 +5838,17 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
  206.         goto fail_create_hcd;
  207.     }
  208.  
  209. +   hcd->has_tt = 1;
  210. +
  211.     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  212. -   if (!res) {
  213. -       dev_err(dev,
  214. -           "Found HC with no register addr. Check %s setup!\n",
  215. -           dev_name(dev));
  216. -       retval = -ENODEV;
  217. -       goto fail_request_resource;
  218. +   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
  219. +   if (IS_ERR(hcd->regs)) {
  220. +       retval = PTR_ERR(hcd->regs);
  221. +       goto failed;
  222.     }
  223.  
  224.     hcd->rsrc_start = res->start;
  225.     hcd->rsrc_len = resource_size(res);
  226. -   hcd->has_tt = 1;
  227. -
  228. -   if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
  229. -               fotg210_fotg210_hc_driver.description)) {
  230. -       dev_dbg(dev, "controller already in use\n");
  231. -       retval = -EBUSY;
  232. -       goto fail_request_resource;
  233. -   }
  234. -
  235. -   res = platform_get_resource(pdev, IORESOURCE_IO, 0);
  236. -   if (!res) {
  237. -       dev_err(dev,
  238. -           "Found HC with no register addr. Check %s setup!\n",
  239. -           dev_name(dev));
  240. -       retval = -ENODEV;
  241. -       goto fail_request_resource;
  242. -   }
  243. -
  244. -   hcd->regs = ioremap_nocache(res->start, resource_size(res));
  245. -   if (hcd->regs == NULL) {
  246. -       dev_dbg(dev, "error mapping memory\n");
  247. -       retval = -EFAULT;
  248. -       goto fail_ioremap;
  249. -   }
  250.  
  251.     fotg210 = hcd_to_fotg210(hcd);
  252.  
  253. @@ -5869,24 +5856,20 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
  254.  
  255.     retval = fotg210_setup(hcd);
  256.     if (retval)
  257. -       goto fail_add_hcd;
  258. +       goto failed;
  259.  
  260.     fotg210_init(fotg210);
  261.  
  262.     retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
  263.     if (retval) {
  264.         dev_err(dev, "failed to add hcd with err %d\n", retval);
  265. -       goto fail_add_hcd;
  266. +       goto failed;
  267.     }
  268.     device_wakeup_enable(hcd->self.controller);
  269.  
  270.     return retval;
  271.  
  272. -fail_add_hcd:
  273. -   iounmap(hcd->regs);
  274. -fail_ioremap:
  275. -   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  276. -fail_request_resource:
  277. +failed:
  278.     usb_put_hcd(hcd);
  279.  fail_create_hcd:
  280.     dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval);
  281. @@ -5897,9 +5880,6 @@ fail_create_hcd:
  282.   * fotg210_hcd_remove - shutdown processing for EHCI HCDs
  283.   * @dev: USB Host Controller being removed
  284.   *
  285. - * Reverses the effect of fotg2xx_usb_hcd_probe(), first invoking
  286. - * the HCD's stop() method.  It is always called from a thread
  287. - * context, normally "rmmod", "apmd", or something similar.
  288.   */
  289.  static int fotg210_hcd_remove(struct platform_device *pdev)
  290.  {
  291. @@ -5910,8 +5890,6 @@ static int fotg210_hcd_remove(struct platform_device *pdev)
  292.         return 0;
  293.  
  294.     usb_remove_hcd(hcd);
  295. -   iounmap(hcd->regs);
  296. -   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  297.     usb_put_hcd(hcd);
  298.  
  299.     return 0;
  300. diff --git a/:drivers/usb/host/fusbh200.h b/:drivers/usb/host/fotg210.h
  301. index 54efa22..3bad178 100644
  302. --- a/:drivers/usb/host/fusbh200.h
  303. +++ b/:drivers/usb/host/fotg210.h
  304. @@ -168,8 +168,12 @@ struct fotg210_hcd {           /* one per controller */
  305.     u8          sbrn;       /* packed release number */
  306.  
  307.     /* irq statistics */
  308. +#ifdef FOTG210_STATS
  309.     struct fotg210_stats    stats;
  310. -#  define COUNT(x) do { (x)++; } while (0)
  311. +#  define COUNT(x) ((x)++)
  312. +#else
  313. +#  define COUNT(x)
  314. +#endif
  315.  
  316.     /* debug files */
  317.     struct dentry       *debug_dir;
  318. @@ -269,22 +273,26 @@ struct fotg210_regs {
  319.  #define PORT_CSC   (1<<1)      /* connect status change */
  320.  #define PORT_CONNECT   (1<<0)      /* device connected */
  321.  #define PORT_RWC_BITS   (PORT_CSC | PORT_PEC)
  322. -   u32     reserved2[3];
  323. -
  324. -   /* BMCSR: offset 0x30 */
  325. -   u32 bmcsr; /* Bus Moniter Control/Status Register */
  326. -#define BMCSR_HOST_SPD_TYP (3<<9)
  327. -#define BMCSR_VBUS_OFF     (1<<4)
  328. -#define BMCSR_INT_POLARITY (1<<3)
  329. -
  330. -   /* BMISR: offset 0x34 */
  331. -   u32 bmisr; /* Bus Moniter Interrupt Status Register*/
  332. -#define BMISR_OVC      (1<<1)
  333. -
  334. -   /* BMIER: offset 0x38 */
  335. -   u32 bmier; /* Bus Moniter Interrupt Enable Register */
  336. -#define BMIER_OVC_EN       (1<<1)
  337. -#define BMIER_VBUS_ERR_EN  (1<<0)
  338. +   u32     reserved2[19];
  339. +
  340. +   /* OTGCSR: offet 0x70 */
  341. +   u32     otgcsr;
  342. +#define OTGCSR_HOST_SPD_TYP     (3 << 22)
  343. +#define OTGCSR_A_BUS_DROP  (1 << 5)
  344. +#define OTGCSR_A_BUS_REQ   (1 << 4)
  345. +
  346. +   /* OTGISR: offset 0x74 */
  347. +   u32     otgisr;
  348. +#define OTGISR_OVC (1 << 10)
  349. +
  350. +   u32     reserved3[15];
  351. +
  352. +   /* GMIR: offset 0xB4 */
  353. +   u32     gmir;
  354. +#define GMIR_INT_POLARITY  (1 << 3) /*Active High*/
  355. +#define GMIR_MHC_INT       (1 << 2)
  356. +#define GMIR_MOTG_INT      (1 << 1)
  357. +#define GMIR_MDEV_INT  (1 << 0)
  358.  };
  359.  
  360.  /*-------------------------------------------------------------------------*/
  361. @@ -330,7 +338,7 @@ struct fotg210_qtd {
  362.     struct list_head    qtd_list;       /* sw qtd list */
  363.     struct urb      *urb;           /* qtd's urb */
  364.     size_t          length;         /* length of buffer */
  365. -} __attribute__ ((aligned(32)));
  366. +} __aligned(32);
  367.  
  368.  /* mask NakCnt+T in qh->hw_alt_next */
  369.  #define QTD_MASK(fotg210)  cpu_to_hc32(fotg210, ~0x1f)
  370. @@ -414,7 +422,7 @@ struct fotg210_qh_hw {
  371.     __hc32          hw_token;
  372.     __hc32          hw_buf[5];
  373.     __hc32          hw_buf_hi[5];
  374. -} __attribute__ ((aligned(32)));
  375. +} __aligned(32);
  376.  
  377.  struct fotg210_qh {
  378.     struct fotg210_qh_hw    *hw;        /* Must come first */
  379. @@ -550,7 +558,7 @@ struct fotg210_itd {
  380.     unsigned        frame;      /* where scheduled */
  381.     unsigned        pg;
  382.     unsigned        index[8];   /* in urb->iso_frame_desc */
  383. -} __attribute__ ((aligned(32)));
  384. +} __aligned(32);
  385.  
  386.  /*-------------------------------------------------------------------------*/
  387.  
  388. @@ -570,7 +578,7 @@ struct fotg210_fstn {
  389.     /* the rest is HCD-private */
  390.     dma_addr_t      fstn_dma;
  391.     union fotg210_shadow    fstn_next;  /* ptr to periodic q entry */
  392. -} __attribute__ ((aligned (32)));
  393. +} __aligned(32);
  394.  
  395.  /*-------------------------------------------------------------------------*/
  396.  
  397. @@ -594,8 +602,8 @@ struct fotg210_fstn {
  398.  static inline unsigned int
  399.  fotg210_get_speed(struct fotg210_hcd *fotg210, unsigned int portsc)
  400.  {
  401. -   return (readl(&fotg210->regs->bmcsr)
  402. -       & BMCSR_HOST_SPD_TYP) >> 9;
  403. +   return (readl(&fotg210->regs->otgcsr)
  404. +       & OTGCSR_HOST_SPD_TYP) >> 22;
  405.  }
  406.  
  407.  /* Returns the speed of a device attached to a port on the root hub. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement