fingerprint_common_mtk.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include "fingerprint_common.h"
  2. #include <linux/of.h>
  3. #include <linux/platform_data/spi-mt65xx.h>
  4. void spi_get_ctrldata(struct spi_device *spi)
  5. {
  6. #ifndef ENABLE_SENSORS_FPRINT_SECURE
  7. struct device_node *np, *data_np = NULL;
  8. u32 tckdly = 0;
  9. np = spi->dev.of_node;
  10. if (!np) {
  11. pr_err("%s : device node not founded\n", __func__);
  12. return;
  13. }
  14. data_np = of_get_child_by_name(np, "controller-data");
  15. if (!data_np) {
  16. pr_err("%s : controller-data not founded\n", __func__);
  17. return;
  18. }
  19. of_property_read_u32(data_np, "mediatek,tckdly", &tckdly);
  20. ((struct mtk_chip_config *)spi->controller_data)->tick_delay = tckdly;
  21. of_node_put(data_np);
  22. pr_info("%s done\n", __func__);
  23. #endif
  24. }
  25. int spi_clk_register(struct spi_clk_setting *clk_setting, struct device *dev)
  26. {
  27. #ifdef ENABLE_SENSORS_FPRINT_SECURE
  28. clk_setting->fp_spi_pclk = devm_clk_get(dev, "sel-clk");
  29. if (IS_ERR(clk_setting->fp_spi_pclk)) {
  30. pr_err("Can't get sel-clk\n");
  31. return PTR_ERR(clk_setting->fp_spi_pclk);
  32. }
  33. clk_setting->fp_spi_sclk = devm_clk_get(dev, "spi-clk");
  34. if (IS_ERR(clk_setting->fp_spi_sclk)) {
  35. pr_err("Can't get spi-clk\n");
  36. return PTR_ERR(clk_setting->fp_spi_sclk);
  37. }
  38. #endif
  39. return 0;
  40. }
  41. int spi_clk_unregister(struct spi_clk_setting *clk_setting)
  42. {
  43. #ifdef ENABLE_SENSORS_FPRINT_SECURE
  44. clk_put(clk_setting->fp_spi_pclk);
  45. clk_put(clk_setting->fp_spi_sclk);
  46. #endif
  47. return 0;
  48. }
  49. int spi_clk_enable(struct spi_clk_setting *clk_setting)
  50. {
  51. int retval = 0;
  52. #ifdef ENABLE_SENSORS_FPRINT_SECURE
  53. if (!clk_setting->enabled_clk) {
  54. retval = clk_prepare_enable(clk_setting->fp_spi_sclk);
  55. if (retval < 0) {
  56. pr_err("Unable to enable spi clk\n");
  57. return retval;
  58. }
  59. pr_debug("ENABLE_SPI_CLOCK %d\n", clk_setting->spi_speed);
  60. __pm_stay_awake(clk_setting->spi_wake_lock);
  61. clk_setting->enabled_clk = true;
  62. }
  63. #endif
  64. return retval;
  65. }
  66. int spi_clk_disable(struct spi_clk_setting *clk_setting)
  67. {
  68. #ifdef ENABLE_SENSORS_FPRINT_SECURE
  69. if (clk_setting->enabled_clk) {
  70. clk_disable_unprepare(clk_setting->fp_spi_sclk);
  71. __pm_relax(clk_setting->spi_wake_lock);
  72. clk_setting->enabled_clk = false;
  73. pr_debug("DISABLE_SPI_CLOCK\n");
  74. }
  75. #endif
  76. return 0;
  77. }
  78. int cpu_speedup_enable(struct boosting_config *boosting)
  79. {
  80. return 0;
  81. }
  82. int cpu_speedup_disable(struct boosting_config *boosting)
  83. {
  84. return 0;
  85. }