mt_freqhopping_drv.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef __FREQHOPPING_DRV_H
  2. #define __FREQHOPPING_DRV_H
  3. #include <linux/proc_fs.h>
  4. #include "mach/mt_freqhopping.h"
  5. /* move to /mediatek/platform/prj, can config. by prj. */
  6. /* #define MEMPLL_SSC 0 */
  7. /* #define MAINPLL_SSC 1 */
  8. /* Export API */
  9. int mt_freqhopping_devctl(unsigned int cmd, void *args);
  10. struct mt_fh_hal_proc_func {
  11. int (*clk_gen_read)(char *, char **, off_t, int, int *, void *);
  12. int (*clk_gen_write)(struct file *, const char *, unsigned long, void *);
  13. int (*dramc_read)(struct seq_file *m, void *v); /* (char *, char **, off_t, int, int *, void *); */
  14. int (*dramc_write)(struct file *, const char *, unsigned long, void *);
  15. int (*dumpregs_read)(struct seq_file *m, void *v); /* (char *, char **, off_t, int, int *, void *); */
  16. int (*dvfs_read)(struct seq_file *m, void *v); /* (char *, char **, off_t, int, int *, void *); */
  17. int (*dvfs_write)(struct file *, const char *, unsigned long, void *);
  18. };
  19. struct mt_fh_hal_driver {
  20. fh_pll_t *fh_pll;
  21. struct freqhopping_ssc *fh_usrdef;
  22. unsigned int mempll;
  23. unsigned int lvdspll;
  24. unsigned int mainpll;
  25. unsigned int msdcpll;
  26. unsigned int mmpll;
  27. unsigned int vencpll;
  28. unsigned int pll_cnt;
  29. struct mt_fh_hal_proc_func proc;
  30. void (*mt_fh_hal_init)(void);
  31. int (*mt_fh_hal_ctrl)(struct freqhopping_ioctl *, bool);
  32. void (*mt_fh_lock)(unsigned long *);
  33. void (*mt_fh_unlock)(unsigned long *);
  34. int (*mt_fh_get_init)(void);
  35. void (*mt_fh_popod_restore)(void);
  36. void (*mt_fh_popod_save)(void);
  37. int (*mt_l2h_mempll)(void);
  38. int (*mt_h2l_mempll)(void);
  39. int (*mt_dfs_armpll)(unsigned int, unsigned int);
  40. int (*mt_dfs_mmpll)(unsigned int);
  41. int (*mt_dfs_vencpll)(unsigned int);
  42. int (*mt_dfs_mpll)(unsigned int);
  43. int (*mt_dfs_mempll)(unsigned int);
  44. int (*mt_is_support_DFS_mode)(void);
  45. int (*mt_l2h_dvfs_mempll)(void);
  46. int (*mt_h2l_dvfs_mempll)(void);
  47. int (*mt_dram_overclock)(int);
  48. int (*mt_get_dramc)(void);
  49. void (*mt_fh_default_conf)(void);
  50. void (*ioctl)(unsigned int ctlid, void *);
  51. };
  52. /* define ctlid for ioctl() */
  53. #define FH_IO_PROC_READ 0x001
  54. enum FH_DEVCTL_CMD_ID {
  55. FH_DCTL_CMD_ID = 0x1000,
  56. FH_DCTL_CMD_DVFS = 0x1001,
  57. FH_DCTL_CMD_DVFS_SSC_ENABLE = 0x1002,
  58. FH_DCTL_CMD_DVFS_SSC_DISABLE = 0x1003,
  59. FH_DCTL_CMD_SSC_ENABLE = 0x1004,
  60. FH_DCTL_CMD_SSC_DISABLE = 0x1005,
  61. FH_DCTL_CMD_MAX
  62. };
  63. /* define structure for correspoinding ctlid */
  64. typedef struct {
  65. struct seq_file *m;
  66. void *v;
  67. fh_pll_t *pll;
  68. } FH_IO_PROC_READ_T;
  69. struct mt_fh_hal_driver *mt_get_fh_hal_drv(void);
  70. #define FH_BUG_ON(x) \
  71. do { \
  72. if ((x)) \
  73. pr_err("BUGON %s:%d %s:%d\n", __func__, __LINE__, current->comm, current->pid); \
  74. } while (0)
  75. #endif