btrtl.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Bluetooth support for Realtek devices
  3. *
  4. * Copyright (C) 2015 Endless Mobile, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #define RTL_FRAG_LEN 252
  18. #define rtl_dev_err(dev, fmt, ...) bt_dev_err(dev, "RTL: " fmt, ##__VA_ARGS__)
  19. #define rtl_dev_warn(dev, fmt, ...) bt_dev_warn(dev, "RTL: " fmt, ##__VA_ARGS__)
  20. #define rtl_dev_info(dev, fmt, ...) bt_dev_info(dev, "RTL: " fmt, ##__VA_ARGS__)
  21. #define rtl_dev_dbg(dev, fmt, ...) bt_dev_dbg(dev, "RTL: " fmt, ##__VA_ARGS__)
  22. struct btrtl_device_info;
  23. struct rtl_download_cmd {
  24. __u8 index;
  25. __u8 data[RTL_FRAG_LEN];
  26. } __packed;
  27. struct rtl_download_response {
  28. __u8 status;
  29. __u8 index;
  30. } __packed;
  31. struct rtl_rom_version_evt {
  32. __u8 status;
  33. __u8 version;
  34. } __packed;
  35. struct rtl_epatch_header {
  36. __u8 signature[8];
  37. __le32 fw_version;
  38. __le16 num_patches;
  39. } __packed;
  40. struct rtl_vendor_config_entry {
  41. __le16 offset;
  42. __u8 len;
  43. __u8 data[0];
  44. } __packed;
  45. struct rtl_vendor_config {
  46. __le32 signature;
  47. __le16 total_len;
  48. struct rtl_vendor_config_entry entry[0];
  49. } __packed;
  50. #if IS_ENABLED(CONFIG_BT_RTL)
  51. struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
  52. const char *postfix);
  53. void btrtl_free(struct btrtl_device_info *btrtl_dev);
  54. int btrtl_download_firmware(struct hci_dev *hdev,
  55. struct btrtl_device_info *btrtl_dev);
  56. int btrtl_setup_realtek(struct hci_dev *hdev);
  57. int btrtl_shutdown_realtek(struct hci_dev *hdev);
  58. int btrtl_get_uart_settings(struct hci_dev *hdev,
  59. struct btrtl_device_info *btrtl_dev,
  60. unsigned int *controller_baudrate,
  61. u32 *device_baudrate, bool *flow_control);
  62. #else
  63. static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
  64. const char *postfix)
  65. {
  66. return ERR_PTR(-EOPNOTSUPP);
  67. }
  68. static inline void btrtl_free(struct btrtl_device_info *btrtl_dev)
  69. {
  70. }
  71. static inline int btrtl_download_firmware(struct hci_dev *hdev,
  72. struct btrtl_device_info *btrtl_dev)
  73. {
  74. return -EOPNOTSUPP;
  75. }
  76. static inline int btrtl_setup_realtek(struct hci_dev *hdev)
  77. {
  78. return -EOPNOTSUPP;
  79. }
  80. static inline int btrtl_shutdown_realtek(struct hci_dev *hdev)
  81. {
  82. return -EOPNOTSUPP;
  83. }
  84. static inline int btrtl_get_uart_settings(struct hci_dev *hdev,
  85. struct btrtl_device_info *btrtl_dev,
  86. unsigned int *controller_baudrate,
  87. u32 *device_baudrate,
  88. bool *flow_control)
  89. {
  90. return -ENOENT;
  91. }
  92. #endif