vbus_drv.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * VMM Bus Driver
  3. *
  4. * COPYRIGHT (C) 2015, Shanghai Real-Thread Technology Co., Ltd
  5. * http://www.rt-thread.com
  6. *
  7. * This file is part of RT-Thread (http://www.rt-thread.org)
  8. *
  9. * All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License along
  22. * with this program; if not, write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  24. *
  25. * Change Logs:
  26. * Date Author Notes
  27. * 2015-01-07 Grissiom add comment
  28. */
  29. #include <rtthread.h>
  30. #ifdef RT_USING_VBUS
  31. #include <rtdevice.h>
  32. #include <rthw.h>
  33. #include <interrupt.h>
  34. #include <vbus.h>
  35. #include <board.h>
  36. int rt_vbus_do_init(void)
  37. {
  38. return rt_vbus_init((void*)_RT_VBUS_RING_BASE,
  39. (void*)(_RT_VBUS_RING_BASE + _RT_VBUS_RING_SZ));
  40. }
  41. INIT_COMPONENT_EXPORT(rt_vbus_do_init);
  42. static void _bus_resume_in_thread(int irqnr, void *param)
  43. {
  44. rt_vbus_isr(irqnr, RT_NULL);
  45. }
  46. int rt_vbus_hw_init(void)
  47. {
  48. rt_kprintf("install irq: %d\n", RT_VBUS_HOST_VIRQ);
  49. rt_hw_interrupt_install(RT_VBUS_HOST_VIRQ,
  50. _bus_resume_in_thread, RT_NULL,
  51. "vbusin");
  52. rt_hw_interrupt_umask(RT_VBUS_HOST_VIRQ);
  53. return 0;
  54. }
  55. int rt_vbus_hw_eoi(int irqnr, void *param)
  56. {
  57. rt_hw_interrupt_clear(irqnr);
  58. return 0;
  59. }
  60. #define RT_VBUS_SER_PRIO 20
  61. #define RT_VBUS_RFS_PRIO 19
  62. #define RT_VBUS_TASK2_PRIO 6
  63. #define RT_VBUS_INT_PRIO 4
  64. struct rt_vbus_dev rt_vbus_chn_devx[] = {
  65. {
  66. .req =
  67. {
  68. .prio = RT_VBUS_SER_PRIO,
  69. .name = RT_VBUS_SHELL_DEV_NAME,
  70. .is_server = 1,
  71. .recv_wm.low = RT_VMM_RB_BLK_NR / 3,
  72. .recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  73. .post_wm.low = RT_VMM_RB_BLK_NR / 3,
  74. .post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  75. }
  76. },
  77. {
  78. .req =
  79. {
  80. .prio = 23,
  81. .name = RT_VBUS_RFS_DEV_NAME,
  82. .is_server = 0,
  83. .recv_wm.low = RT_VMM_RB_BLK_NR / 3,
  84. .recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  85. .post_wm.low = RT_VMM_RB_BLK_NR / 3,
  86. .post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  87. }
  88. },
  89. {
  90. .req =
  91. {
  92. .prio = 30,
  93. .name = "vecho",
  94. .is_server = 1,
  95. .recv_wm.low = RT_VMM_RB_BLK_NR / 3,
  96. .recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  97. .post_wm.low = RT_VMM_RB_BLK_NR / 3,
  98. .post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
  99. }
  100. },
  101. {
  102. .req =
  103. {
  104. .name = RT_NULL,
  105. }
  106. },
  107. };
  108. #endif /* RT_USING_VBUS */