mantis_vp1034.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. Mantis VP-1034 driver
  4. Copyright (C) Manu Abraham ([email protected])
  5. */
  6. #include <linux/signal.h>
  7. #include <linux/sched.h>
  8. #include <linux/interrupt.h>
  9. #include <asm/io.h>
  10. #include <media/dmxdev.h>
  11. #include <media/dvbdev.h>
  12. #include <media/dvb_demux.h>
  13. #include <media/dvb_frontend.h>
  14. #include <media/dvb_net.h>
  15. #include "mb86a16.h"
  16. #include "mantis_common.h"
  17. #include "mantis_ioc.h"
  18. #include "mantis_dvb.h"
  19. #include "mantis_vp1034.h"
  20. #include "mantis_reg.h"
  21. static const struct mb86a16_config vp1034_mb86a16_config = {
  22. .demod_address = 0x08,
  23. .set_voltage = vp1034_set_voltage,
  24. };
  25. #define MANTIS_MODEL_NAME "VP-1034"
  26. #define MANTIS_DEV_TYPE "DVB-S/DSS"
  27. int vp1034_set_voltage(struct dvb_frontend *fe, enum fe_sec_voltage voltage)
  28. {
  29. struct mantis_pci *mantis = fe->dvb->priv;
  30. switch (voltage) {
  31. case SEC_VOLTAGE_13:
  32. dprintk(MANTIS_ERROR, 1, "Polarization=[13V]");
  33. mantis_gpio_set_bits(mantis, 13, 1);
  34. mantis_gpio_set_bits(mantis, 14, 0);
  35. break;
  36. case SEC_VOLTAGE_18:
  37. dprintk(MANTIS_ERROR, 1, "Polarization=[18V]");
  38. mantis_gpio_set_bits(mantis, 13, 1);
  39. mantis_gpio_set_bits(mantis, 14, 1);
  40. break;
  41. case SEC_VOLTAGE_OFF:
  42. dprintk(MANTIS_ERROR, 1, "Frontend (dummy) POWERDOWN");
  43. break;
  44. default:
  45. dprintk(MANTIS_ERROR, 1, "Invalid = (%d)", (u32) voltage);
  46. return -EINVAL;
  47. }
  48. mmwrite(0x00, MANTIS_GPIF_DOUT);
  49. return 0;
  50. }
  51. static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
  52. {
  53. struct i2c_adapter *adapter = &mantis->adapter;
  54. int err = 0;
  55. err = mantis_frontend_power(mantis, POWER_ON);
  56. if (err == 0) {
  57. mantis_frontend_soft_reset(mantis);
  58. msleep(250);
  59. dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)");
  60. fe = dvb_attach(mb86a16_attach, &vp1034_mb86a16_config, adapter);
  61. if (fe) {
  62. dprintk(MANTIS_ERROR, 1,
  63. "found MB86A16 DVB-S/DSS frontend @0x%02x",
  64. vp1034_mb86a16_config.demod_address);
  65. } else {
  66. return -1;
  67. }
  68. } else {
  69. dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
  70. adapter->name,
  71. err);
  72. return -EIO;
  73. }
  74. mantis->fe = fe;
  75. dprintk(MANTIS_ERROR, 1, "Done!");
  76. return 0;
  77. }
  78. struct mantis_hwconfig vp1034_config = {
  79. .model_name = MANTIS_MODEL_NAME,
  80. .dev_type = MANTIS_DEV_TYPE,
  81. .ts_size = MANTIS_TS_204,
  82. .baud_rate = MANTIS_BAUD_9600,
  83. .parity = MANTIS_PARITY_NONE,
  84. .bytes = 0,
  85. .frontend_init = vp1034_frontend_init,
  86. .power = GPIF_A12,
  87. .reset = GPIF_A13,
  88. };