fc8050_isr.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*****************************************************************************
  2. Copyright(c) 2009 FCI Inc. All Rights Reserved
  3. File name : fc8050_isr.c
  4. Description : fc8050 interrupt service routine
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. History :
  17. ----------------------------------------------------------------------
  18. 2009/08/29 jason initial
  19. *******************************************************************************/
  20. #include <linux/cache.h>
  21. #include "fci_types.h"
  22. #include "fci_hal.h"
  23. #include "fc8050_regs.h"
  24. #include "fc8050_isr.h"
  25. static u8 fic_buffer[512+4] __cacheline_aligned;
  26. static u8 msc_buffer[8192+4] __cacheline_aligned;
  27. int (*fic_callback)(u32 userdata, u8 *data, int length) = NULL;
  28. int (*msc_callback)(u32 userdata, u8 subchid, u8 *data, int length) = NULL;
  29. u32 fic_user_data;
  30. u32 msc_user_data;
  31. void fc8050_isr(HANDLE hDevice)
  32. {
  33. u8 ext_int_status = 0;
  34. bbm_read(hDevice, BBM_COM_INT_STATUS, &ext_int_status);
  35. bbm_write(hDevice, BBM_COM_INT_STATUS, ext_int_status);
  36. bbm_write(hDevice, BBM_COM_INT_STATUS, 0x00);
  37. if (ext_int_status & BBM_MF_INT) {
  38. u16 buf_int_status = 0;
  39. u16 size;
  40. int i;
  41. bbm_word_read(hDevice, BBM_BUF_STATUS, &buf_int_status);
  42. bbm_word_write(hDevice, BBM_BUF_STATUS, buf_int_status);
  43. bbm_word_write(hDevice, BBM_BUF_STATUS, 0x0000);
  44. if (buf_int_status & 0x0100) {
  45. bbm_word_read(hDevice, BBM_BUF_FIC_THR, &size);
  46. size += 1;
  47. if (size-1) {
  48. bbm_data(hDevice, BBM_COM_FIC_DATA
  49. , &fic_buffer[0], size);
  50. #ifdef CONFIG_TDMB_SPI
  51. if (fic_callback)
  52. (*fic_callback)(fic_user_data
  53. , &fic_buffer[2], size);
  54. #else
  55. if (fic_callback)
  56. (*fic_callback)(fic_user_data
  57. , &fic_buffer[0], size);
  58. #endif
  59. }
  60. }
  61. for (i = 0; i < 8; i++) {
  62. if (buf_int_status & (1 << i)) {
  63. bbm_word_read(hDevice
  64. , BBM_BUF_CH0_THR+i*2, &size);
  65. size += 1;
  66. if (size-1) {
  67. u8 sub_ch_id;
  68. bbm_read(hDevice, BBM_BUF_CH0_SUBCH+i
  69. , &sub_ch_id);
  70. sub_ch_id = sub_ch_id & 0x3f;
  71. bbm_data(hDevice, (BBM_COM_CH0_DATA+i)
  72. , &msc_buffer[0], size);
  73. #ifdef CONFIG_TDMB_SPI
  74. if (msc_callback)
  75. (*msc_callback)(
  76. msc_user_data
  77. , sub_ch_id
  78. , &msc_buffer[2]
  79. , size);
  80. #else
  81. if (msc_callback)
  82. (*msc_callback)(
  83. msc_user_data
  84. , sub_ch_id
  85. , &msc_buffer[0]
  86. , size);
  87. #endif
  88. }
  89. }
  90. }
  91. }
  92. }