btrtl.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_get_uart_settings(struct hci_dev *hdev,
  58. struct btrtl_device_info *btrtl_dev,
  59. unsigned int *controller_baudrate,
  60. u32 *device_baudrate, bool *flow_control);
  61. #else
  62. static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
  63. const char *postfix)
  64. {
  65. return ERR_PTR(-EOPNOTSUPP);
  66. }
  67. static inline void btrtl_free(struct btrtl_device_info *btrtl_dev)
  68. {
  69. }
  70. static inline int btrtl_download_firmware(struct hci_dev *hdev,
  71. struct btrtl_device_info *btrtl_dev)
  72. {
  73. return -EOPNOTSUPP;
  74. }
  75. static inline int btrtl_setup_realtek(struct hci_dev *hdev)
  76. {
  77. return -EOPNOTSUPP;
  78. }
  79. static inline int btrtl_get_uart_settings(struct hci_dev *hdev,
  80. struct btrtl_device_info *btrtl_dev,
  81. unsigned int *controller_baudrate,
  82. u32 *device_baudrate,
  83. bool *flow_control)
  84. {
  85. return -ENOENT;
  86. }
  87. #endif