btpower.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __LINUX_BLUETOOTH_POWER_H
  7. #define __LINUX_BLUETOOTH_POWER_H
  8. #include <linux/cdev.h>
  9. #include <linux/types.h>
  10. #include <linux/mailbox_client.h>
  11. #include <linux/mailbox/qmp.h>
  12. /*
  13. * voltage regulator information required for configuring the
  14. * bluetooth chipset
  15. */
  16. enum bt_power_modes {
  17. BT_POWER_DISABLE = 0,
  18. BT_POWER_ENABLE,
  19. BT_POWER_RETENTION
  20. };
  21. struct log_index {
  22. int init;
  23. int crash;
  24. };
  25. struct bt_power_vreg_data {
  26. struct regulator *reg; /* voltage regulator handle */
  27. const char *name; /* regulator name */
  28. u32 min_vol; /* min voltage level */
  29. u32 max_vol; /* max voltage level */
  30. u32 load_curr; /* current */
  31. bool is_enabled; /* is this regulator enabled? */
  32. bool is_retention_supp; /* does this regulator support retention mode */
  33. struct log_index indx; /* Index for reg. w.r.t init & crash */
  34. };
  35. struct bt_power {
  36. char compatible[32];
  37. struct bt_power_vreg_data *vregs;
  38. int num_vregs;
  39. };
  40. struct bt_power_clk_data {
  41. struct clk *clk; /* clock regulator handle */
  42. const char *name; /* clock name */
  43. bool is_enabled; /* is this clock enabled? */
  44. };
  45. /*
  46. * Platform data for the bluetooth power driver.
  47. */
  48. struct btpower_platform_data {
  49. struct platform_device *pdev;
  50. int bt_gpio_sys_rst; /* Bluetooth reset gpio */
  51. int wl_gpio_sys_rst; /* Wlan reset gpio */
  52. int bt_gpio_sw_ctrl; /* Bluetooth sw_ctrl gpio */
  53. int bt_gpio_debug; /* Bluetooth debug gpio */
  54. #ifdef CONFIG_MSM_BT_OOBS
  55. int bt_gpio_dev_wake; /* Bluetooth bt_wake */
  56. int bt_gpio_host_wake; /* Bluetooth bt_host_wake */
  57. int irq; /* Bluetooth host_wake IRQ */
  58. #endif
  59. int xo_gpio_clk; /* XO clock gpio*/
  60. struct device *slim_dev;
  61. struct bt_power_vreg_data *vreg_info; /* VDDIO voltage regulator */
  62. struct bt_power_clk_data *bt_chip_clk; /* bluetooth reference clock */
  63. int (*bt_power_setup)(int id); /* Bluetooth power setup function */
  64. char compatible[32]; /*Bluetooth SoC name */
  65. int num_vregs;
  66. struct mbox_client mbox_client_data;
  67. struct mbox_chan *mbox_chan;
  68. const char *vreg_ipa;
  69. #ifdef CONFIG_MSM_BT_OOBS
  70. struct file *reffilp_obs;
  71. struct task_struct *reftask_obs;
  72. #endif
  73. };
  74. int btpower_register_slimdev(struct device *dev);
  75. int btpower_get_chipset_version(void);
  76. int btpower_aop_mbox_init(struct btpower_platform_data *pdata);
  77. #define BT_CMD_SLIM_TEST 0xbfac
  78. #define BT_CMD_PWR_CTRL 0xbfad
  79. #define BT_CMD_CHIPSET_VERS 0xbfae
  80. #define BT_CMD_GET_CHIPSET_ID 0xbfaf
  81. #define BT_CMD_CHECK_SW_CTRL 0xbfb0
  82. #define BT_CMD_GETVAL_POWER_SRCS 0xbfb1
  83. #define BT_CMD_SET_IPA_TCS_INFO 0xbfc0
  84. #ifdef CONFIG_MSM_BT_OOBS
  85. #define BT_CMD_OBS_SIGNAL_TASK 0xbfd0
  86. #define BT_CMD_OBS_VOTE_CLOCK 0xbfd1
  87. /**
  88. * enum btpower_obs_param: OOBS low power param
  89. * @BTPOWER_OBS_CLK_OFF: Transport bus is no longer acquired
  90. * @BTPOWER_OBS_CLK_ON: Acquire transport bus for either transmitting or receiving
  91. * @BTPOWER_OBS_DEV_OFF: Bluetooth is released because of no more transmission
  92. * @BTPOWER_OBS_DEV_ON: Wake up the Bluetooth controller for transmission
  93. */
  94. enum btpower_obs_param {
  95. BTPOWER_OBS_CLK_OFF = 0,
  96. BTPOWER_OBS_CLK_ON,
  97. BTPOWER_OBS_DEV_OFF,
  98. BTPOWER_OBS_DEV_ON,
  99. };
  100. #endif
  101. #endif /* __LINUX_BLUETOOTH_POWER_H */