0023-fotg210-udc-Improve-device-initialization.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From 367747c7813cecf19b46ef7134691f903ab76dc9 Mon Sep 17 00:00:00 2001
  2. From: Fabian Vogt <[email protected]>
  3. Date: Mon, 23 Jan 2023 08:35:08 +0100
  4. Subject: [PATCH 23/29] fotg210-udc: Improve device initialization
  5. Reset the device explicitly to get into a known state and also set the chip
  6. enable bit. Additionally, mask interrupts which aren't handled.
  7. Signed-off-by: Fabian Vogt <[email protected]>
  8. Signed-off-by: Linus Walleij <[email protected]>
  9. Link: https://lore.kernel.org/r/[email protected]
  10. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  11. ---
  12. --- a/drivers/usb/fotg210/fotg210-udc.c
  13. +++ b/drivers/usb/fotg210/fotg210-udc.c
  14. @@ -7,6 +7,7 @@
  15. * Author : Yuan-Hsin Chen <[email protected]>
  16. */
  17. +#include <linux/delay.h>
  18. #include <linux/dma-mapping.h>
  19. #include <linux/err.h>
  20. #include <linux/interrupt.h>
  21. @@ -1022,6 +1023,11 @@ static int fotg210_udc_start(struct usb_
  22. dev_err(fotg210->dev, "can't bind to phy\n");
  23. }
  24. + /* chip enable */
  25. + value = ioread32(fotg210->reg + FOTG210_DMCR);
  26. + value |= DMCR_CHIP_EN;
  27. + iowrite32(value, fotg210->reg + FOTG210_DMCR);
  28. +
  29. /* enable device global interrupt */
  30. value = ioread32(fotg210->reg + FOTG210_DMCR);
  31. value |= DMCR_GLINT_EN;
  32. @@ -1038,6 +1044,15 @@ static void fotg210_init(struct fotg210_
  33. iowrite32(GMIR_MHC_INT | GMIR_MOTG_INT | GMIR_INT_POLARITY,
  34. fotg210->reg + FOTG210_GMIR);
  35. + /* mask interrupts for groups other than 0-2 */
  36. + iowrite32(~(DMIGR_MINT_G0 | DMIGR_MINT_G1 | DMIGR_MINT_G2),
  37. + fotg210->reg + FOTG210_DMIGR);
  38. +
  39. + /* udc software reset */
  40. + iowrite32(DMCR_SFRST, fotg210->reg + FOTG210_DMCR);
  41. + /* Better wait a bit, but without a datasheet, no idea how long. */
  42. + usleep_range(100, 200);
  43. +
  44. /* disable device global interrupt */
  45. value = ioread32(fotg210->reg + FOTG210_DMCR);
  46. value &= ~DMCR_GLINT_EN;
  47. --- a/drivers/usb/fotg210/fotg210-udc.h
  48. +++ b/drivers/usb/fotg210/fotg210-udc.h
  49. @@ -58,6 +58,8 @@
  50. /* Device Mask of Interrupt Group Register (0x130) */
  51. #define FOTG210_DMIGR 0x130
  52. +#define DMIGR_MINT_G2 (1 << 2)
  53. +#define DMIGR_MINT_G1 (1 << 1)
  54. #define DMIGR_MINT_G0 (1 << 0)
  55. /* Device Mask of Interrupt Source Group 0(0x134) */