pppcielanes.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #include <linux/types.h>
  24. #include "atom-types.h"
  25. #include "atombios.h"
  26. #include "pppcielanes.h"
  27. /** \file
  28. * Functions related to PCIe lane changes.
  29. */
  30. /* For converting from number of lanes to lane bits. */
  31. static const unsigned char pp_r600_encode_lanes[] = {
  32. 0, /* 0 Not Supported */
  33. 1, /* 1 Lane */
  34. 2, /* 2 Lanes */
  35. 0, /* 3 Not Supported */
  36. 3, /* 4 Lanes */
  37. 0, /* 5 Not Supported */
  38. 0, /* 6 Not Supported */
  39. 0, /* 7 Not Supported */
  40. 4, /* 8 Lanes */
  41. 0, /* 9 Not Supported */
  42. 0, /* 10 Not Supported */
  43. 0, /* 11 Not Supported */
  44. 5, /* 12 Lanes (Not actually supported) */
  45. 0, /* 13 Not Supported */
  46. 0, /* 14 Not Supported */
  47. 0, /* 15 Not Supported */
  48. 6 /* 16 Lanes */
  49. };
  50. static const unsigned char pp_r600_decoded_lanes[8] = { 16, 1, 2, 4, 8, 12, 16, };
  51. uint8_t encode_pcie_lane_width(uint32_t num_lanes)
  52. {
  53. return pp_r600_encode_lanes[num_lanes];
  54. }
  55. uint8_t decode_pcie_lane_width(uint32_t num_lanes)
  56. {
  57. return pp_r600_decoded_lanes[num_lanes];
  58. }