tdmb_spi.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. *
  3. * drivers/media/tdmb/tdmb_spi.c
  4. *
  5. * tdmb driver
  6. *
  7. * Copyright (C) (2011, 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 <mach/gpiomux.h>
  23. #include "tdmb.h"
  24. struct spi_device *spi_dmb;
  25. static int tdmbspi_probe(struct spi_device *spi)
  26. {
  27. int ret;
  28. spi_dmb = spi;
  29. DPRINTK("tdmbspi_probe() spi_dmb : 0x%x\n", (unsigned int)spi_dmb);
  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 const struct of_device_id tdmb_spi_match_table[] = {
  40. {.compatible = "tdmb_spi_comp"},
  41. {}
  42. };
  43. static int __devexit tdmbspi_remove(struct spi_device *spi)
  44. {
  45. return 0;
  46. }
  47. static struct spi_driver tdmbspi_driver = {
  48. .driver = {
  49. .name = "tdmbspi",
  50. .of_match_table = tdmb_spi_match_table,
  51. .owner = THIS_MODULE,
  52. },
  53. .probe = tdmbspi_probe,
  54. .remove = __devexit_p(tdmbspi_remove),
  55. };
  56. static int __init tdmb_spi_init(void)
  57. {
  58. return spi_register_driver(&tdmbspi_driver);
  59. }
  60. static void __exit tdmb_spi_exit(void)
  61. {
  62. spi_unregister_driver(&tdmbspi_driver);
  63. }
  64. unsigned long tdmb_get_if_handle(void)
  65. {
  66. DPRINTK("%s : spi_dmb 0x%p\n", __func__, spi_dmb);
  67. return (unsigned long)spi_dmb;
  68. }
  69. EXPORT_SYMBOL_GPL(tdmb_get_if_handle);
  70. late_initcall(tdmb_spi_init);
  71. module_exit(tdmb_spi_exit);
  72. MODULE_AUTHOR("Samsung");
  73. MODULE_DESCRIPTION("TDMB SPI Driver");
  74. MODULE_LICENSE("GPL v2");