mantis_vp1034.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. Mantis VP-1034 driver
  3. Copyright (C) Manu Abraham (abraham.manu@gmail.com)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include <linux/signal.h>
  17. #include <linux/sched.h>
  18. #include <linux/interrupt.h>
  19. #include <asm/io.h>
  20. #include "dmxdev.h"
  21. #include "dvbdev.h"
  22. #include "dvb_demux.h"
  23. #include "dvb_frontend.h"
  24. #include "dvb_net.h"
  25. #include "mb86a16.h"
  26. #include "mantis_common.h"
  27. #include "mantis_ioc.h"
  28. #include "mantis_dvb.h"
  29. #include "mantis_vp1034.h"
  30. #include "mantis_reg.h"
  31. static struct mb86a16_config vp1034_mb86a16_config = {
  32. .demod_address = 0x08,
  33. .set_voltage = vp1034_set_voltage,
  34. };
  35. #define MANTIS_MODEL_NAME "VP-1034"
  36. #define MANTIS_DEV_TYPE "DVB-S/DSS"
  37. int vp1034_set_voltage(struct dvb_frontend *fe, enum fe_sec_voltage voltage)
  38. {
  39. struct mantis_pci *mantis = fe->dvb->priv;
  40. switch (voltage) {
  41. case SEC_VOLTAGE_13:
  42. dprintk(MANTIS_ERROR, 1, "Polarization=[13V]");
  43. mantis_gpio_set_bits(mantis, 13, 1);
  44. mantis_gpio_set_bits(mantis, 14, 0);
  45. break;
  46. case SEC_VOLTAGE_18:
  47. dprintk(MANTIS_ERROR, 1, "Polarization=[18V]");
  48. mantis_gpio_set_bits(mantis, 13, 1);
  49. mantis_gpio_set_bits(mantis, 14, 1);
  50. break;
  51. case SEC_VOLTAGE_OFF:
  52. dprintk(MANTIS_ERROR, 1, "Frontend (dummy) POWERDOWN");
  53. break;
  54. default:
  55. dprintk(MANTIS_ERROR, 1, "Invalid = (%d)", (u32) voltage);
  56. return -EINVAL;
  57. }
  58. mmwrite(0x00, MANTIS_GPIF_DOUT);
  59. return 0;
  60. }
  61. static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
  62. {
  63. struct i2c_adapter *adapter = &mantis->adapter;
  64. int err = 0;
  65. err = mantis_frontend_power(mantis, POWER_ON);
  66. if (err == 0) {
  67. mantis_frontend_soft_reset(mantis);
  68. msleep(250);
  69. dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)");
  70. fe = dvb_attach(mb86a16_attach, &vp1034_mb86a16_config, adapter);
  71. if (fe) {
  72. dprintk(MANTIS_ERROR, 1,
  73. "found MB86A16 DVB-S/DSS frontend @0x%02x",
  74. vp1034_mb86a16_config.demod_address);
  75. } else {
  76. return -1;
  77. }
  78. } else {
  79. dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
  80. adapter->name,
  81. err);
  82. return -EIO;
  83. }
  84. mantis->fe = fe;
  85. dprintk(MANTIS_ERROR, 1, "Done!");
  86. return 0;
  87. }
  88. struct mantis_hwconfig vp1034_config = {
  89. .model_name = MANTIS_MODEL_NAME,
  90. .dev_type = MANTIS_DEV_TYPE,
  91. .ts_size = MANTIS_TS_204,
  92. .baud_rate = MANTIS_BAUD_9600,
  93. .parity = MANTIS_PARITY_NONE,
  94. .bytes = 0,
  95. .frontend_init = vp1034_frontend_init,
  96. .power = GPIF_A12,
  97. .reset = GPIF_A13,
  98. };