MIPS: OCTEON: reintroduce crypto features check
authorAaro Koskinen <aaro.koskinen@iki.fi>
Sun, 21 Dec 2014 20:54:00 +0000 (22:54 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 23 Dec 2014 21:14:22 +0000 (08:14 +1100)
Reintroduce run-time check for crypto features. The old one was deleted
because it was unreliable, now decide the crypto availability on early
boot when the model string is constructed.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/mips/cavium-octeon/executive/octeon-model.c
arch/mips/include/asm/octeon/octeon-feature.h

index e15b049b3bd71049bf79416b41321bd279c14e19..b2104bd9ab3b7ef08a998253661b59cb7f914df4 100644 (file)
@@ -27,6 +27,9 @@
 
 #include <asm/octeon/octeon.h>
 
+enum octeon_feature_bits __octeon_feature_bits __read_mostly;
+EXPORT_SYMBOL_GPL(__octeon_feature_bits);
+
 /**
  * Read a byte of fuse data
  * @byte_addr:  address to read
@@ -103,6 +106,9 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
        else
                suffix = "NSP";
 
+       if (!fus_dat2.s.nocrypto)
+               __octeon_feature_bits |= OCTEON_HAS_CRYPTO;
+
        /*
         * Assume pass number is encoded using <5:3><2:0>. Exceptions
         * will be fixed later.
index c4fe81f47f53670fb535aba2895defe0e55d7b30..8ebd3f579b848ea5c1a1f6c3cb4d79a2bafbcfac 100644 (file)
@@ -46,8 +46,6 @@ enum octeon_feature {
        OCTEON_FEATURE_SAAD,
        /* Does this Octeon support the ZIP offload engine? */
        OCTEON_FEATURE_ZIP,
-       /* Does this Octeon support crypto acceleration using COP2? */
-       OCTEON_FEATURE_CRYPTO,
        OCTEON_FEATURE_DORM_CRYPTO,
        /* Does this Octeon support PCI express? */
        OCTEON_FEATURE_PCIE,
@@ -86,6 +84,21 @@ enum octeon_feature {
        OCTEON_MAX_FEATURE
 };
 
+enum octeon_feature_bits {
+       OCTEON_HAS_CRYPTO = 0x0001,     /* Crypto acceleration using COP2 */
+};
+extern enum octeon_feature_bits __octeon_feature_bits;
+
+/**
+ * octeon_has_crypto() - Check if this OCTEON has crypto acceleration support.
+ *
+ * Returns: Non-zero if the feature exists. Zero if the feature does not exist.
+ */
+static inline int octeon_has_crypto(void)
+{
+       return __octeon_feature_bits & OCTEON_HAS_CRYPTO;
+}
+
 /**
  * Determine if the current Octeon supports a specific feature. These
  * checks have been optimized to be fairly quick, but they should still