vireshk

Untitled

Jan 22nd, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. svc: Cache VID/PID received from bootrom for ES2
  2.  
  3. Signed-off-by: Viresh Kumar <[email protected]>
  4. ---
  5. firmware.c | 15 +++++----------
  6. svc.c | 24 ++++++++++++++++++++++++
  7. 2 files changed, 29 insertions(+), 10 deletions(-)
  8.  
  9. diff --git a/firmware.c b/firmware.c
  10. index 3cd6f1ebe5e6..6b695e94be02 100644
  11. --- a/firmware.c
  12. +++ b/firmware.c
  13. @@ -14,8 +14,6 @@
  14. struct gb_firmware {
  15. struct gb_connection *connection;
  16. const struct firmware *fw;
  17. - u32 vendor_id;
  18. - u32 product_id;
  19. };
  20.  
  21. static void free_firmware(struct gb_firmware *firmware)
  22. @@ -31,7 +29,7 @@ static void free_firmware(struct gb_firmware *firmware)
  23. * This fetches VID/PID (over firmware protocol) for es2 chip only, when VID/PID
  24. * already sent during hotplug are 0.
  25. *
  26. - * Otherwise, we keep firmware->vendor_id/product_id same as what's passed
  27. + * Otherwise, we keep intf->vendor_id/product_id same as what's passed
  28. * during hotplug.
  29. */
  30. static void firmware_es2_fixup_vid_pid(struct gb_firmware *firmware)
  31. @@ -59,11 +57,11 @@ static void firmware_es2_fixup_vid_pid(struct gb_firmware *firmware)
  32. return;
  33. }
  34.  
  35. - firmware->vendor_id = le32_to_cpu(response.vendor_id);
  36. - firmware->product_id = le32_to_cpu(response.product_id);
  37. + intf->vendor_id = le32_to_cpu(response.vendor_id);
  38. + intf->product_id = le32_to_cpu(response.product_id);
  39.  
  40. dev_dbg(&connection->bundle->dev, "Firmware got vid (0x%x)/pid (0x%x)\n",
  41. - firmware->vendor_id, firmware->product_id);
  42. + intf->vendor_id, intf->product_id);
  43. }
  44.  
  45. /* This returns path of the firmware blob on the disk */
  46. @@ -86,7 +84,7 @@ static int download_firmware(struct gb_firmware *firmware, u8 stage)
  47. snprintf(firmware_name, sizeof(firmware_name),
  48. "ara_%08x_%08x_%08x_%08x_%02x.tftf",
  49. intf->ddbl1_manufacturer_id, intf->ddbl1_product_id,
  50. - firmware->vendor_id, firmware->product_id, stage);
  51. + intf->vendor_id, intf->product_id, stage);
  52.  
  53. // FIXME:
  54. // Turn to dev_dbg later after everyone has valid bootloaders with good
  55. @@ -246,9 +244,6 @@ static int gb_firmware_connection_init(struct gb_connection *connection)
  56. firmware->connection = connection;
  57. connection->private = firmware;
  58.  
  59. - firmware->vendor_id = connection->intf->vendor_id;
  60. - firmware->product_id = connection->intf->product_id;
  61. -
  62. firmware_es2_fixup_vid_pid(firmware);
  63.  
  64. /*
  65. diff --git a/svc.c b/svc.c
  66. index ca358689ca50..c5c8988b8518 100644
  67. --- a/svc.c
  68. +++ b/svc.c
  69. @@ -457,6 +457,8 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
  70. struct gb_host_device *hd = connection->hd;
  71. struct gb_interface *intf;
  72. u8 intf_id, device_id;
  73. + u32 vendor_id;
  74. + u32 product_id;
  75. int ret;
  76.  
  77. /* The request message size has already been verified. */
  78. @@ -468,6 +470,14 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
  79. intf = gb_interface_find(hd, intf_id);
  80. if (intf) {
  81. /*
  82. + * For ES2, there is we need to maintain the same vendor/product
  83. + * ids we got from bootrom, otherwise userspace can't
  84. + * distinguish between modules.
  85. + */
  86. + vendor_id = intf->vendor_id;
  87. + product_id = intf->product_id;
  88. +
  89. + /*
  90. * We have received a hotplug request for an interface that
  91. * already exists.
  92. *
  93. @@ -499,6 +509,20 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
  94. intf->product_id = le32_to_cpu(request->data.ara_prod_id);
  95. intf->serial_number = le64_to_cpu(request->data.serial_number);
  96.  
  97. + /*
  98. + * Use VID/PID specified at hotplug if:
  99. + * - Bridge ASIC chip isn't ES2
  100. + * - Received non-zero Vendor/Product ids
  101. + *
  102. + * Otherwise, use the ids we received from bootrom.
  103. + */
  104. + if (intf->ddbl1_manufacturer_id == ES2_DDBL1_MFR_ID &&
  105. + intf->ddbl1_product_id == ES2_DDBL1_PROD_ID &&
  106. + intf->vendor_id == 0 && intf->product_id == 0) {
  107. + intf->vendor_id = vendor_id;
  108. + intf->product_id = product_id;
  109. + }
  110. +
  111. ret = gb_svc_read_and_clear_module_boot_status(intf);
  112. if (ret) {
  113. dev_err(&svc->dev, "failed to clear boot status of interface %u: %d\n",
Add Comment
Please, Sign In to add comment