@@ -12,9 +12,16 @@
#include "tb.h"
+/* ID of Router */
+#define ROUTER_VENDOR_ID_ASMEDIA 0x174c
+
/* Switch NVM support */
#define NVM_CSS 0x10
+/* ASMedia specific NVM offsets */
+#define ASMEDIA_NVM_DATE 0x1c
+#define ASMEDIA_NVM_VERSION 0x28
+
static DEFINE_IDA(nvm_ida);
/**
@@ -120,11 +127,43 @@ static int intel_nvm_validate(struct tb_switch *sw)
return 0;
}
+static int asmedia_nvm_version(struct tb_switch *sw)
+{
+ struct tb_nvm *nvm = sw->nvm;
+ u32 val;
+ int ret;
+
+ /* ASMedia get version and date format is xxxxxx.xxxxxx */
+ ret = nvm_read(sw, ASMEDIA_NVM_VERSION, &val, sizeof(val));
+ if (ret)
+ return ret;
+
+ nvm->major = (((u8)val) << 0x10 | ((u8)(val >> 0x8)) << 0x8 | (u8)(val >> 0x10));
+
+ ret = nvm_read(sw, ASMEDIA_NVM_DATE, &val, sizeof(val));
+ if (ret)
+ return ret;
+
+ nvm->minor = (((u8)val) << 0x10 | ((u8)(val >> 0x8)) << 0x8 | (u8)(val >> 0x10));
+
+ /*
+ * Asmedia NVM size fixed on 512K. We currently have no plan
+ * to increase size in the future.
+ */
+ nvm->nvm_size = SZ_512K;
+
+ return 0;
+}
+
static const struct tb_nvm_vendor_ops intel_switch_nvm_ops = {
.read_version = intel_nvm_version,
.validate = intel_nvm_validate,
};
+static const struct tb_nvm_vendor_ops asmedia_switch_nvm_ops = {
+ .read_version = asmedia_nvm_version,
+};
+
struct switch_nvm_vendor {
u16 vendor;
const struct tb_nvm_vendor_ops *vops;
@@ -133,6 +172,7 @@ struct switch_nvm_vendor {
static const struct switch_nvm_vendor switch_nvm_vendors[] = {
{ PCI_VENDOR_ID_INTEL, &intel_switch_nvm_ops },
{ 0x8087, &intel_switch_nvm_ops },
+ { ROUTER_VENDOR_ID_ASMEDIA, &asmedia_switch_nvm_ops },
};
/**
@@ -1417,7 +1417,7 @@ static int tb_start(struct tb *tb)
* mode that is not available so disable firmware upgrade of the
* root switch.
*/
- tb->root_switch->no_nvm_upgrade = true;
+ tb->root_switch->no_nvm_upgrade = !tb_switch_is_usb4(tb->root_switch);
/* All USB4 routers support runtime PM */
tb->root_switch->rpm = tb_switch_is_usb4(tb->root_switch);