dp_aux.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _DP_AUX_H_
  7. #define _DP_AUX_H_
  8. #include "dp_catalog.h"
  9. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0))
  10. #include <drm/display/drm_dp_helper.h>
  11. #else
  12. #include <drm/drm_dp_helper.h>
  13. #endif
  14. #include "dp_aux_bridge.h"
  15. #define DP_STATE_NOTIFICATION_SENT BIT(0)
  16. #define DP_STATE_TRAIN_1_STARTED BIT(1)
  17. #define DP_STATE_TRAIN_1_SUCCEEDED BIT(2)
  18. #define DP_STATE_TRAIN_1_FAILED BIT(3)
  19. #define DP_STATE_TRAIN_2_STARTED BIT(4)
  20. #define DP_STATE_TRAIN_2_SUCCEEDED BIT(5)
  21. #define DP_STATE_TRAIN_2_FAILED BIT(6)
  22. #define DP_STATE_CTRL_POWERED_ON BIT(7)
  23. #define DP_STATE_CTRL_POWERED_OFF BIT(8)
  24. #define DP_STATE_LINK_MAINTENANCE_STARTED BIT(9)
  25. #define DP_STATE_LINK_MAINTENANCE_COMPLETED BIT(10)
  26. #define DP_STATE_LINK_MAINTENANCE_FAILED BIT(11)
  27. #define DP_STATE_AUX_TIMEOUT BIT(12)
  28. #define DP_STATE_PLL_LOCKED BIT(13)
  29. enum dp_aux_switch_type {
  30. DP_AUX_SWITCH_BYPASS,
  31. DP_AUX_SWITCH_FSA4480,
  32. DP_AUX_SWITCH_WCD939x,
  33. };
  34. enum dp_aux_error {
  35. DP_AUX_ERR_NONE = 0,
  36. DP_AUX_ERR_ADDR = -1,
  37. DP_AUX_ERR_TOUT = -2,
  38. DP_AUX_ERR_NACK = -3,
  39. DP_AUX_ERR_DEFER = -4,
  40. DP_AUX_ERR_NACK_DEFER = -5,
  41. DP_AUX_ERR_PHY = -6,
  42. };
  43. struct dp_aux {
  44. u32 state;
  45. bool read;
  46. struct mutex *access_lock;
  47. void *ipc_log_context;
  48. struct drm_dp_aux *drm_aux;
  49. int (*drm_aux_register)(struct dp_aux *aux, struct drm_device *drm_dev);
  50. void (*drm_aux_deregister)(struct dp_aux *aux);
  51. void (*isr)(struct dp_aux *aux);
  52. void (*init)(struct dp_aux *aux, struct dp_aux_cfg *aux_cfg);
  53. void (*deinit)(struct dp_aux *aux);
  54. void (*reconfig)(struct dp_aux *aux);
  55. void (*abort)(struct dp_aux *aux, bool abort);
  56. void (*set_sim_mode)(struct dp_aux *aux, struct dp_aux_bridge *sim_bridge);
  57. int (*switch_configure)(struct dp_aux *aux, bool enable, int orientation);
  58. int (*switch_register_notifier)(struct notifier_block *nb, struct device_node *node);
  59. int (*switch_unregister_notifier)(struct notifier_block *nb, struct device_node *node);
  60. };
  61. struct dp_aux *dp_aux_get(struct device *dev, struct dp_catalog_aux *catalog,
  62. struct dp_parser *parser, struct device_node *aux_switch,
  63. struct dp_aux_bridge *aux_bridge, void *ipc_log_context,
  64. enum dp_aux_switch_type switch_type);
  65. void dp_aux_put(struct dp_aux *aux);
  66. #endif /*__DP_AUX_H_*/