cx18-gpio.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * cx18 gpio functions
  3. *
  4. * Derived from ivtv-gpio.c
  5. *
  6. * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  21. * 02111-1307 USA
  22. */
  23. #include "cx18-driver.h"
  24. #include "cx18-cards.h"
  25. #include "cx18-gpio.h"
  26. #include "tuner-xc2028.h"
  27. /********************* GPIO stuffs *********************/
  28. /* GPIO registers */
  29. #define CX18_REG_GPIO_IN 0xc72010
  30. #define CX18_REG_GPIO_OUT1 0xc78100
  31. #define CX18_REG_GPIO_DIR1 0xc78108
  32. #define CX18_REG_GPIO_OUT2 0xc78104
  33. #define CX18_REG_GPIO_DIR2 0xc7810c
  34. /*
  35. * HVR-1600 GPIO pins, courtesy of Hauppauge:
  36. *
  37. * gpio0: zilog ir process reset pin
  38. * gpio1: zilog programming pin (you should never use this)
  39. * gpio12: cx24227 reset pin
  40. * gpio13: cs5345 reset pin
  41. */
  42. void cx18_gpio_init(struct cx18 *cx)
  43. {
  44. if (cx->card->gpio_init.direction == 0)
  45. return;
  46. CX18_DEBUG_INFO("GPIO initial dir: %08x out: %08x\n",
  47. read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_OUT1));
  48. /* init output data then direction */
  49. write_reg(cx->card->gpio_init.direction << 16, CX18_REG_GPIO_DIR1);
  50. write_reg(0, CX18_REG_GPIO_DIR2);
  51. write_reg((cx->card->gpio_init.direction << 16) |
  52. cx->card->gpio_init.initial_value, CX18_REG_GPIO_OUT1);
  53. write_reg(0, CX18_REG_GPIO_OUT2);
  54. }
  55. /* Xceive tuner reset function */
  56. int cx18_reset_tuner_gpio(void *dev, int cmd, int value)
  57. {
  58. struct i2c_algo_bit_data *algo = dev;
  59. struct cx18 *cx = algo->data;
  60. /* int curdir, curout;*/
  61. if (cmd != XC2028_TUNER_RESET)
  62. return 0;
  63. CX18_DEBUG_INFO("Resetting tuner\n");
  64. return 0;
  65. }