Advertisement
uaa

[wip:20140513] uchcom.c diff (worked)

uaa
May 12th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. --- uchcom.c.bak Fri Nov 15 19:17:39 2013
  2. +++ uchcom.c Tue May 13 09:03:42 2014
  3. @@ -48,9 +48,10 @@
  4. #include <dev/usb/usbdevs.h>
  5. #include <dev/usb/ucomvar.h>
  6.  
  7. +#define UCHCOM_DEBUG
  8. #ifdef UCHCOM_DEBUG
  9. #define DPRINTFN(n, x) do { if (uchcomdebug > (n)) printf x; } while (0)
  10. -int uchcomdebug = 0;
  11. +int uchcomdebug = 3;
  12. #else
  13. #define DPRINTFN(n, x)
  14. #endif
  15. @@ -91,14 +92,6 @@ int uchcomdebug = 0;
  16. #define UCHCOM_BRK1_MASK 0x01
  17. #define UCHCOM_BRK2_MASK 0x40
  18.  
  19. -#define UCHCOM_LCR1_MASK 0xAF
  20. -#define UCHCOM_LCR2_MASK 0x07
  21. -#define UCHCOM_LCR1_PARENB 0x80
  22. -#define UCHCOM_LCR2_PAREVEN 0x07
  23. -#define UCHCOM_LCR2_PARODD 0x06
  24. -#define UCHCOM_LCR2_PARMARK 0x05
  25. -#define UCHCOM_LCR2_PARSPACE 0x04
  26. -
  27. #define UCHCOM_INTR_STAT1 0x02
  28. #define UCHCOM_INTR_STAT2 0x03
  29. #define UCHCOM_INTR_LEAST 4
  30. @@ -707,29 +700,11 @@ uchcom_set_dte_rate(struct uchcom_softc *sc, uint32_t
  31. int
  32. uchcom_set_line_control(struct uchcom_softc *sc, tcflag_t cflag)
  33. {
  34. - usbd_status err;
  35. - uint8_t lcr1 = 0, lcr2 = 0;
  36. -
  37. - err = uchcom_read_reg(sc, UCHCOM_REG_LCR1, &lcr1, UCHCOM_REG_LCR2,
  38. - &lcr2);
  39. - if (err) {
  40. - printf("%s: cannot get LCR: %s\n",
  41. - sc->sc_dev.dv_xname, usbd_errstr(err));
  42. - return EIO;
  43. - }
  44. -
  45. - lcr1 &= ~UCHCOM_LCR1_MASK;
  46. - lcr2 &= ~UCHCOM_LCR2_MASK;
  47. -
  48. /*
  49. * XXX: it is difficult to handle the line control appropriately:
  50. - * - CS8, !CSTOPB and any parity mode seems ok, but
  51. - * - the chip doesn't have the function to calculate parity
  52. - * in !CS8 mode.
  53. - * - it is unclear that the chip supports CS5,6 mode.
  54. - * - it is unclear how to handle stop bits.
  55. + * work as chip default - CS8, no parity, 1 stop bit
  56. + * other modes are not supported.
  57. */
  58. -
  59. switch (ISSET(cflag, CSIZE)) {
  60. case CS5:
  61. case CS6:
  62. @@ -739,22 +714,9 @@ uchcom_set_line_control(struct uchcom_softc *sc, tcfla
  63. break;
  64. }
  65.  
  66. - if (ISSET(cflag, PARENB)) {
  67. - lcr1 |= UCHCOM_LCR1_PARENB;
  68. - if (ISSET(cflag, PARODD))
  69. - lcr2 |= UCHCOM_LCR2_PARODD;
  70. - else
  71. - lcr2 |= UCHCOM_LCR2_PAREVEN;
  72. - }
  73. + if (ISSET(cflag, PARENB) || ISSET(cflag, CSTOPB))
  74. + return EINVAL;
  75.  
  76. - err = uchcom_write_reg(sc, UCHCOM_REG_LCR1, lcr1, UCHCOM_REG_LCR2,
  77. - lcr2);
  78. - if (err) {
  79. - printf("%s: cannot set LCR: %s\n",
  80. - sc->sc_dev.dv_xname, usbd_errstr(err));
  81. - return EIO;
  82. - }
  83. -
  84. return 0;
  85. }
  86.  
  87. @@ -778,33 +740,10 @@ int
  88. uchcom_reset_chip(struct uchcom_softc *sc)
  89. {
  90. usbd_status err;
  91. - uint8_t lcr1, lcr2, pre, div, mod;
  92. - uint16_t val=0, idx=0;
  93. + uint16_t val, idx;
  94.  
  95. - err = uchcom_read_reg(sc, UCHCOM_REG_LCR1, &lcr1, UCHCOM_REG_LCR2, &lcr2);
  96. - if (err)
  97. - goto failed;
  98. -
  99. - err = uchcom_read_reg(sc, UCHCOM_REG_BPS_PRE, &pre, UCHCOM_REG_BPS_DIV,
  100. - &div);
  101. - if (err)
  102. - goto failed;
  103. -
  104. - err = uchcom_read_reg(sc, UCHCOM_REG_BPS_MOD, &mod, UCHCOM_REG_BPS_PAD,
  105. - NULL);
  106. - if (err)
  107. - goto failed;
  108. -
  109. - val |= (uint16_t)(lcr1&0xF0) << 8;
  110. - val |= 0x01;
  111. - val |= (uint16_t)(lcr2&0x0F) << 8;
  112. - val |= 0x02;
  113. - idx |= pre & 0x07;
  114. - val |= 0x04;
  115. - idx |= (uint16_t)div << 8;
  116. - val |= 0x08;
  117. - idx |= mod & 0xF8;
  118. - val |= 0x10;
  119. + val = 0x501f;
  120. + idx = 0xd90a;
  121.  
  122. DPRINTF(("%s: reset v=0x%04X, i=0x%04X\n",
  123. sc->sc_dev.dv_xname, val, idx));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement