isdbt_port_fc8300.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #include <linux/spi/spi.h>
  2. #include "isdbt.h"
  3. #include "isdbt_port_fc8300.h"
  4. struct isdbt_drv_func fc8300_drv_func_struct;
  5. extern void fc8300_set_port_if(unsigned long interface);
  6. bool isfirst = true;
  7. int probe_drv(void)
  8. {
  9. int res;
  10. fc8300_set_port_if((unsigned long)isdbt_get_if_handle());
  11. res = isdbt_drv_probe();
  12. return res;
  13. }
  14. int remove_drv(void)
  15. {
  16. int res;
  17. res = isdbt_drv_remove();
  18. isdbt_control_gpio(false);
  19. return res;
  20. }
  21. int hw_init_drv(unsigned long arg)
  22. {
  23. if(isfirst)
  24. {
  25. isdbt_control_gpio(true);
  26. isdbt_control_gpio(false);
  27. isfirst = false;
  28. }
  29. isdbt_control_gpio(true);
  30. // isdbt_control_irq(true);
  31. isdbt_set_drv_mode(0);
  32. return arg;
  33. }
  34. void hw_deinit_drv(void)
  35. {
  36. isdbt_control_gpio(false);
  37. // isdbt_control_irq(false);
  38. }
  39. int open_drv(struct inode *inode, struct file *filp)
  40. {
  41. int res;
  42. res = isdbt_drv_open(inode, filp);
  43. return res;
  44. }
  45. ssize_t read_drv(struct file *filp
  46. , char *buf, size_t count, loff_t *f_pos)
  47. {
  48. ssize_t size;
  49. size = isdbt_drv_read(filp, buf, count, f_pos);
  50. return size;
  51. }
  52. long ioctl_drv(struct file *filp, unsigned int cmd, unsigned long arg)
  53. {
  54. int res;
  55. res = isdbt_drv_ioctl(filp, cmd, arg);
  56. if (res == 0) {
  57. switch (cmd) {
  58. case IOCTL_ISDBT_POWER_ON:
  59. isdbt_power_on(0);
  60. break;
  61. case IOCTL_ISDBT_POWER_OFF:
  62. isdbt_power_off();
  63. break;
  64. default:
  65. break;
  66. }
  67. }
  68. return res;
  69. }
  70. int mmap_drv(struct file *filp, struct vm_area_struct *vma)
  71. {
  72. return isdbt_drv_mmap(filp, vma);
  73. }
  74. irqreturn_t irq_drv(int irq, void *dev_id)
  75. {
  76. return isdbt_threaded_irq(irq, dev_id);
  77. }
  78. int release_drv(struct inode *inode, struct file *filp)
  79. {
  80. return isdbt_drv_release(inode, filp);
  81. }
  82. struct isdbt_drv_func *fc8300_drv_func(void)
  83. {
  84. fc8300_drv_func_struct.probe = probe_drv;
  85. fc8300_drv_func_struct.remove = remove_drv;
  86. fc8300_drv_func_struct.power_on = hw_init_drv;
  87. fc8300_drv_func_struct.power_off = hw_deinit_drv;
  88. fc8300_drv_func_struct.open = open_drv;
  89. fc8300_drv_func_struct.read = read_drv;
  90. fc8300_drv_func_struct.ioctl = ioctl_drv;
  91. fc8300_drv_func_struct.mmap = mmap_drv;
  92. fc8300_drv_func_struct.irq_handler = irq_drv;
  93. fc8300_drv_func_struct.release = release_drv;
  94. return &fc8300_drv_func_struct;
  95. }