isdbt_spi.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. *
  3. * drivers/media/isdbt/isdbt_spi.c
  4. *
  5. * isdbt driver
  6. *
  7. * Copyright (C) (2014, Samsung Electronics)
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation version 2.
  12. *
  13. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  14. * kind, whether express or implied; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #include <linux/module.h>
  20. #include <linux/spi/spi.h>
  21. #include <linux/of_gpio.h>
  22. #include "isdbt.h"
  23. #define SPI_DEV_NAME "isdbt"
  24. struct spi_device *isdbt_spi_device;
  25. int isdbt_spi_probe(struct spi_device *spi)
  26. {
  27. int ret;
  28. isdbt_spi_device = spi;
  29. DPRINTK("isdbtspi_probe() isdbt_spi_device : 0x%x\n", (unsigned int)isdbt_spi_device);
  30. spi->mode = SPI_MODE_0;
  31. spi->bits_per_word = 8;
  32. ret = spi_setup(spi);
  33. if (ret < 0) {
  34. DPRINTK("spi_setup() fail ret : %d\n", ret);
  35. return ret;
  36. }
  37. return 0;
  38. }
  39. static int __devexit isdbt_spi_remove(struct spi_device *spi)
  40. {
  41. return 0;
  42. }
  43. static const struct of_device_id isdbt_spi_match_table[] = {
  44. {.compatible = "isdbt_spi_comp"},
  45. {}
  46. };
  47. static struct spi_driver isdbt_spi_driver = {
  48. .driver = {
  49. .name = SPI_DEV_NAME,
  50. .owner = THIS_MODULE,
  51. .of_match_table = isdbt_spi_match_table,
  52. },
  53. .probe = isdbt_spi_probe,
  54. .remove = __devexit_p(isdbt_spi_remove),
  55. };
  56. int isdbt_spi_init(void)
  57. {
  58. DPRINTK("isdbt_spi_init\n");
  59. return spi_register_driver(&isdbt_spi_driver);
  60. }
  61. void isdbt_spi_exit(void)
  62. {
  63. DPRINTK("isdbt_spi_exit\n");
  64. spi_unregister_driver(&isdbt_spi_driver);
  65. }
  66. struct spi_device *isdbt_get_if_handle(void)
  67. {
  68. return isdbt_spi_device;
  69. }