[U-Boot] [RFC 9/9] lib: crypto: add rsa public key parser

2019-09-02 Thread AKASHI Takahiro
Imported from linux kernel v5.0.

Signed-off-by: AKASHI Takahiro 
---
 include/crypto/internal/rsa.h | 62 +++
 lib/crypto/Makefile   | 10 -
 lib/crypto/rsa_helper.c   | 81 +++
 lib/crypto/rsapubkey.asn1 |  4 ++
 4 files changed, 156 insertions(+), 1 deletion(-)
 create mode 100644 include/crypto/internal/rsa.h
 create mode 100644 lib/crypto/rsa_helper.c
 create mode 100644 lib/crypto/rsapubkey.asn1

diff --git a/include/crypto/internal/rsa.h b/include/crypto/internal/rsa.h
new file mode 100644
index ..9e8f1590de98
--- /dev/null
+++ b/include/crypto/internal/rsa.h
@@ -0,0 +1,62 @@
+/*
+ * RSA internal helpers
+ *
+ * Copyright (c) 2015, Intel Corporation
+ * Authors: Tadeusz Struk 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef _RSA_HELPER_
+#define _RSA_HELPER_
+#include 
+
+/**
+ * rsa_key - RSA key structure
+ * @n   : RSA modulus raw byte stream
+ * @e   : RSA public exponent raw byte stream
+ * @d   : RSA private exponent raw byte stream
+ * @p   : RSA prime factor p of n raw byte stream
+ * @q   : RSA prime factor q of n raw byte stream
+ * @dp  : RSA exponent d mod (p - 1) raw byte stream
+ * @dq  : RSA exponent d mod (q - 1) raw byte stream
+ * @qinv: RSA CRT coefficient q^(-1) mod p raw byte stream
+ * @n_sz: length in bytes of RSA modulus n
+ * @e_sz: length in bytes of RSA public exponent
+ * @d_sz: length in bytes of RSA private exponent
+ * @p_sz: length in bytes of p field
+ * @q_sz: length in bytes of q field
+ * @dp_sz   : length in bytes of dp field
+ * @dq_sz   : length in bytes of dq field
+ * @qinv_sz : length in bytes of qinv field
+ */
+struct rsa_key {
+   const u8 *n;
+   const u8 *e;
+   const u8 *d;
+   const u8 *p;
+   const u8 *q;
+   const u8 *dp;
+   const u8 *dq;
+   const u8 *qinv;
+   size_t n_sz;
+   size_t e_sz;
+   size_t d_sz;
+   size_t p_sz;
+   size_t q_sz;
+   size_t dp_sz;
+   size_t dq_sz;
+   size_t qinv_sz;
+};
+
+int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key,
+ unsigned int key_len);
+
+int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
+  unsigned int key_len);
+
+extern struct crypto_template rsa_pkcs1pad_tmpl;
+#endif
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index 3e98d28ea17a..f2cd3fbb0413 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -17,7 +17,9 @@ x509_key_parser-y := \
x509.asn1.o \
x509_akid.asn1.o \
x509_cert_parser.o \
-   x509_public_key.o
+   x509_public_key.o \
+   rsapubkey.asn1.o \
+   rsa_helper.o
 
 $(obj)/x509_cert_parser.o: \
$(obj)/x509.asn1.h \
@@ -36,3 +38,9 @@ pkcs7_message-y := \
 
 $(obj)/pkcs7_parser.o: $(obj)/pkcs7.asn1.h
 $(obj)/pkcs7.asn1.o: $(obj)/pkcs7.asn1.c $(obj)/pkcs7.asn1.h
+
+#
+# RSA public key parser
+#
+$(obj)/rsapubkey.asn1.o: $(obj)/rsapubkey.asn1.c $(obj)/rsapubkey.asn1.h
+$(obj)/rsa_helper.o: $(obj)/rsapubkey.asn1.h
diff --git a/lib/crypto/rsa_helper.c b/lib/crypto/rsa_helper.c
new file mode 100644
index ..577dfbc1c5fd
--- /dev/null
+++ b/lib/crypto/rsa_helper.c
@@ -0,0 +1,81 @@
+/*
+ * RSA key extract helper
+ *
+ * Copyright (c) 2015, Intel Corporation
+ * Authors: Tadeusz Struk 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include 
+#include 
+#include "rsapubkey.asn1.h"
+
+int rsa_get_n(void *context, size_t hdrlen, unsigned char tag,
+ const void *value, size_t vlen)
+{
+   struct rsa_key *key = context;
+#ifndef __UBOOT__
+   const u8 *ptr = value;
+   size_t n_sz = vlen;
+#endif
+
+   /* invalid key provided */
+   if (!value || !vlen)
+   return -EINVAL;
+
+#ifndef __UBOOT__
+   if (fips_enabled) {
+   while (n_sz && !*ptr) {
+   ptr++;
+   n_sz--;
+   }
+
+   /* In FIPS mode only allow key size 2K and higher */
+   if (n_sz < 256) {
+   pr_err("RSA: key size not allowed in FIPS mode\n");
+   return -EINVAL;
+   }
+   }
+#endif
+
+   key->n = value;
+   key->n_sz = vlen;
+
+   return 0;
+}
+
+int rsa_get_e(void *context, size_t hdrlen, unsigned char tag,
+ const void *value, size_t vlen)
+{
+   struct rsa_key *key = context;

[U-Boot] [RFC 7/9] lib: crypto: add x509 parser

2019-09-02 Thread AKASHI Takahiro
Imported from linux kernel v5.0.

Signed-off-by: AKASHI Takahiro 
---
 lib/Kconfig   |   1 +
 lib/Makefile  |   1 +
 lib/crypto/Kconfig|  10 +
 lib/crypto/Makefile   |  17 +
 lib/crypto/x509.asn1  |  60 
 lib/crypto/x509_akid.asn1 |  35 ++
 lib/crypto/x509_cert_parser.c | 644 ++
 lib/crypto/x509_parser.h  |  61 
 lib/crypto/x509_public_key.c  | 284 +++
 9 files changed, 1113 insertions(+)
 create mode 100644 lib/crypto/x509.asn1
 create mode 100644 lib/crypto/x509_akid.asn1
 create mode 100644 lib/crypto/x509_cert_parser.c
 create mode 100644 lib/crypto/x509_parser.h
 create mode 100644 lib/crypto/x509_public_key.c

diff --git a/lib/Kconfig b/lib/Kconfig
index d2955c8feb0e..aa44f52d9181 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -253,6 +253,7 @@ config AES
  present.
 
 source lib/rsa/Kconfig
+source lib/crypto/Kconfig
 
 config TPM
bool "Trusted Platform Module (TPM) Support"
diff --git a/lib/Makefile b/lib/Makefile
index 677ec33a1ce1..64ff105945b3 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_CMD_DHRYSTONE) += dhry/
 obj-$(CONFIG_ARCH_AT91) += at91/
 obj-$(CONFIG_OPTEE) += optee/
 obj-$(CONFIG_BUILD_ASN1) += asn1_decoder.o
+obj-y += crypto/
 
 obj-$(CONFIG_AES) += aes.o
 
diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig
index b8e8288d2f80..a87cf6107fc1 100644
--- a/lib/crypto/Kconfig
+++ b/lib/crypto/Kconfig
@@ -16,4 +16,14 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
  appropriate hash algorithms (such as SHA-1) must be available.
  ENOPKG will be reported if the requisite algorithm is unavailable.
 
+config X509_CERTIFICATE_PARSER
+   bool "X.509 certificate parser"
+   depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE
+   select ASN1
+   select OID_REGISTRY
+   help
+ This option provides support for parsing X.509 format blobs for key
+ data and provides the ability to instantiate a crypto key from a
+ public key packet found inside the certificate.
+
 endif # ASYMMETRIC_KEY_TYPE
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index 870d2a90b181..1fb1459a3e4f 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -8,3 +8,20 @@ obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
 asymmetric_keys-y := asymmetric_type.o
 
 obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o public_key_local.o
+
+#
+# X.509 Certificate handling
+#
+obj-$(CONFIG_X509_CERTIFICATE_PARSER) += x509_key_parser.o
+x509_key_parser-y := \
+   x509.asn1.o \
+   x509_akid.asn1.o \
+   x509_cert_parser.o \
+   x509_public_key.o
+
+$(obj)/x509_cert_parser.o: \
+   $(obj)/x509.asn1.h \
+   $(obj)/x509_akid.asn1.h
+
+$(obj)/x509.asn1.o: $(obj)/x509.asn1.c $(obj)/x509.asn1.h
+$(obj)/x509_akid.asn1.o: $(obj)/x509_akid.asn1.c $(obj)/x509_akid.asn1.h
diff --git a/lib/crypto/x509.asn1 b/lib/crypto/x509.asn1
new file mode 100644
index ..aae0cde414e2
--- /dev/null
+++ b/lib/crypto/x509.asn1
@@ -0,0 +1,60 @@
+Certificate ::= SEQUENCE {
+   tbsCertificate  TBSCertificate ({ x509_note_tbs_certificate }),
+   signatureAlgorithm  AlgorithmIdentifier,
+   signature   BIT STRING ({ x509_note_signature })
+   }
+
+TBSCertificate ::= SEQUENCE {
+   version   [ 0 ] Version DEFAULT,
+   serialNumberCertificateSerialNumber ({ x509_note_serial }),
+   signature   AlgorithmIdentifier ({ x509_note_pkey_algo }),
+   issuer  Name ({ x509_note_issuer }),
+   validityValidity,
+   subject Name ({ x509_note_subject }),
+   subjectPublicKeyInfoSubjectPublicKeyInfo,
+   issuerUniqueID[ 1 ] IMPLICIT UniqueIdentifier OPTIONAL,
+   subjectUniqueID   [ 2 ] IMPLICIT UniqueIdentifier OPTIONAL,
+   extensions[ 3 ] Extensions OPTIONAL
+   }
+
+Version ::= INTEGER
+CertificateSerialNumber ::= INTEGER
+
+AlgorithmIdentifier ::= SEQUENCE {
+   algorithm   OBJECT IDENTIFIER ({ x509_note_OID }),
+   parameters  ANY OPTIONAL
+}
+
+Name ::= SEQUENCE OF RelativeDistinguishedName
+
+RelativeDistinguishedName ::= SET OF AttributeValueAssertion
+
+AttributeValueAssertion ::= SEQUENCE {
+   attributeType   OBJECT IDENTIFIER ({ x509_note_OID }),
+   attributeValue  ANY ({ x509_extract_name_segment })
+   }
+
+Validity ::= SEQUENCE {
+   notBefore   Time ({ x509_note_not_before }),
+   notAfterTime ({ x509_note_not_after })
+   }
+
+Time ::= CHOICE {
+   utcTime UTCTime,
+   generalTime GeneralizedTime
+   }
+
+SubjectPublicKeyInfo ::= SEQUENCE {
+   algorithm   AlgorithmIdentifier,
+   subjectPublicKeyBIT STRING ({ x509_extract_key_data })
+   }
+
+UniqueIdentifier 

[U-Boot] [RFC 8/9] lib: crypto: add pkcs7 message parser

2019-09-02 Thread AKASHI Takahiro
Imported from linux kernel v5.0.

Signed-off-by: AKASHI Takahiro 
---
 include/crypto/pkcs7.h|  51 +++
 lib/crypto/Kconfig|   9 +
 lib/crypto/Makefile   |  11 +
 lib/crypto/pkcs7.asn1 | 135 
 lib/crypto/pkcs7_parser.c | 690 ++
 lib/crypto/pkcs7_parser.h |  69 
 scripts/Makefile.build|   4 +-
 7 files changed, 966 insertions(+), 3 deletions(-)
 create mode 100644 include/crypto/pkcs7.h
 create mode 100644 lib/crypto/pkcs7.asn1
 create mode 100644 lib/crypto/pkcs7_parser.c
 create mode 100644 lib/crypto/pkcs7_parser.h

diff --git a/include/crypto/pkcs7.h b/include/crypto/pkcs7.h
new file mode 100644
index ..1c6a7cd7a995
--- /dev/null
+++ b/include/crypto/pkcs7.h
@@ -0,0 +1,51 @@
+/* PKCS#7 crypto data parser
+ *
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#ifndef _CRYPTO_PKCS7_H
+#define _CRYPTO_PKCS7_H
+
+#ifndef __UBOOT__
+#include 
+#include 
+#endif
+
+struct key;
+struct pkcs7_message;
+
+/*
+ * pkcs7_parser.c
+ */
+extern struct pkcs7_message *pkcs7_parse_message(const void *data,
+size_t datalen);
+extern void pkcs7_free_message(struct pkcs7_message *pkcs7);
+
+extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,
+ const void **_data, size_t *_datalen,
+ size_t *_headerlen);
+
+#ifndef __UBOOT__
+/*
+ * pkcs7_trust.c
+ */
+extern int pkcs7_validate_trust(struct pkcs7_message *pkcs7,
+   struct key *trust_keyring);
+
+/*
+ * pkcs7_verify.c
+ */
+extern int pkcs7_verify(struct pkcs7_message *pkcs7,
+   enum key_being_used_for usage);
+
+extern int pkcs7_supply_detached_data(struct pkcs7_message *pkcs7,
+ const void *data, size_t datalen);
+#endif
+
+#endif /* _CRYPTO_PKCS7_H */
diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig
index a87cf6107fc1..86b676515405 100644
--- a/lib/crypto/Kconfig
+++ b/lib/crypto/Kconfig
@@ -26,4 +26,13 @@ config X509_CERTIFICATE_PARSER
  data and provides the ability to instantiate a crypto key from a
  public key packet found inside the certificate.
 
+config PKCS7_MESSAGE_PARSER
+   bool "PKCS#7 message parser"
+   depends on X509_CERTIFICATE_PARSER
+   select ASN1
+   select OID_REGISTRY
+   help
+ This option provides support for parsing PKCS#7 format messages for
+ signature data and provides the ability to verify the signature.
+
 endif # ASYMMETRIC_KEY_TYPE
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index 1fb1459a3e4f..3e98d28ea17a 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -25,3 +25,14 @@ $(obj)/x509_cert_parser.o: \
 
 $(obj)/x509.asn1.o: $(obj)/x509.asn1.c $(obj)/x509.asn1.h
 $(obj)/x509_akid.asn1.o: $(obj)/x509_akid.asn1.c $(obj)/x509_akid.asn1.h
+
+#
+# PKCS#7 message handling
+#
+obj-$(CONFIG_PKCS7_MESSAGE_PARSER) += pkcs7_message.o
+pkcs7_message-y := \
+   pkcs7.asn1.o \
+   pkcs7_parser.o
+
+$(obj)/pkcs7_parser.o: $(obj)/pkcs7.asn1.h
+$(obj)/pkcs7.asn1.o: $(obj)/pkcs7.asn1.c $(obj)/pkcs7.asn1.h
diff --git a/lib/crypto/pkcs7.asn1 b/lib/crypto/pkcs7.asn1
new file mode 100644
index ..1eca740b816a
--- /dev/null
+++ b/lib/crypto/pkcs7.asn1
@@ -0,0 +1,135 @@
+PKCS7ContentInfo ::= SEQUENCE {
+   contentType ContentType ({ pkcs7_check_content_type }),
+   content [0] EXPLICIT SignedData OPTIONAL
+}
+
+ContentType ::= OBJECT IDENTIFIER ({ pkcs7_note_OID })
+
+SignedData ::= SEQUENCE {
+   version INTEGER ({ pkcs7_note_signeddata_version }),
+   digestAlgorithmsDigestAlgorithmIdentifiers,
+   contentInfo ContentInfo ({ pkcs7_note_content }),
+   certificatesCHOICE {
+   certSet [0] IMPLICIT 
ExtendedCertificatesAndCertificates,
+   certSequence[2] IMPLICIT Certificates
+   } OPTIONAL ({ pkcs7_note_certificate_list }),
+   crls CHOICE {
+   crlSet  [1] IMPLICIT CertificateRevocationLists,
+   crlSequence [3] IMPLICIT CRLSequence
+   } OPTIONAL,
+   signerInfos SignerInfos
+}
+
+ContentInfo ::= SEQUENCE {
+   contentType ContentType ({ pkcs7_note_OID }),
+   content [0] EXPLICIT Data OPTIONAL
+}
+
+Data ::= ANY ({ pkcs7_note_data })
+
+DigestAlgorithmIdentifiers ::= CHOICE {
+   daSet   SET OF DigestAlgorithmIdentifier,
+   daSequence  SEQUENCE OF DigestAlgorithmIdentifier
+}
+
+DigestAlgorithmIdentifier ::= 

[U-Boot] [RFC 5/9] lib: crypto: add public key utility

2019-09-02 Thread AKASHI Takahiro
Imported from linux kernel v5.0.

Signed-off-by: AKASHI Takahiro 
---
 include/crypto/public_key.h|  89 +
 include/keys/asymmetric-type.h |  92 +
 lib/crypto/Kconfig |  19 +
 lib/crypto/Makefile|  10 +
 lib/crypto/asymmetric_type.c   | 655 +
 lib/crypto/public_key.c| 344 +
 6 files changed, 1209 insertions(+)
 create mode 100644 include/crypto/public_key.h
 create mode 100644 include/keys/asymmetric-type.h
 create mode 100644 lib/crypto/Kconfig
 create mode 100644 lib/crypto/Makefile
 create mode 100644 lib/crypto/asymmetric_type.c
 create mode 100644 lib/crypto/public_key.c

diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
new file mode 100644
index ..91b1f2615294
--- /dev/null
+++ b/include/crypto/public_key.h
@@ -0,0 +1,89 @@
+/* Asymmetric public-key algorithm definitions
+ *
+ * See Documentation/crypto/asymmetric-keys.txt
+ *
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_PUBLIC_KEY_H
+#define _LINUX_PUBLIC_KEY_H
+
+#ifndef __UBOOT__
+#include 
+#endif
+#include 
+
+/*
+ * Cryptographic data for the public-key subtype of the asymmetric key type.
+ *
+ * Note that this may include private part of the key as well as the public
+ * part.
+ */
+struct public_key {
+   void *key;
+   u32 keylen;
+   bool key_is_private;
+   const char *id_type;
+   const char *pkey_algo;
+};
+
+extern void public_key_free(struct public_key *key);
+
+/*
+ * Public key cryptography signature data
+ */
+struct public_key_signature {
+   struct asymmetric_key_id *auth_ids[2];
+   u8 *s;  /* Signature */
+   u32 s_size; /* Number of bytes in signature */
+   u8 *digest;
+   u8 digest_size; /* Number of bytes in digest */
+   const char *pkey_algo;
+   const char *hash_algo;
+   const char *encoding;
+};
+
+extern void public_key_signature_free(struct public_key_signature *sig);
+
+#ifndef __UBOOT__
+extern struct asymmetric_key_subtype public_key_subtype;
+
+struct key;
+struct key_type;
+union key_payload;
+
+extern int restrict_link_by_signature(struct key *dest_keyring,
+ const struct key_type *type,
+ const union key_payload *payload,
+ struct key *trust_keyring);
+
+extern int restrict_link_by_key_or_keyring(struct key *dest_keyring,
+  const struct key_type *type,
+  const union key_payload *payload,
+  struct key *trusted);
+
+extern int restrict_link_by_key_or_keyring_chain(struct key *trust_keyring,
+const struct key_type *type,
+const union key_payload 
*payload,
+struct key *trusted);
+
+extern int query_asymmetric_key(const struct kernel_pkey_params *,
+   struct kernel_pkey_query *);
+
+extern int encrypt_blob(struct kernel_pkey_params *, const void *, void *);
+extern int decrypt_blob(struct kernel_pkey_params *, const void *, void *);
+extern int create_signature(struct kernel_pkey_params *, const void *, void *);
+extern int verify_signature(const struct key *,
+   const struct public_key_signature *);
+
+int public_key_verify_signature(const struct public_key *pkey,
+   const struct public_key_signature *sig);
+#endif /* !__UBOOT__ */
+
+#endif /* _LINUX_PUBLIC_KEY_H */
diff --git a/include/keys/asymmetric-type.h b/include/keys/asymmetric-type.h
new file mode 100644
index ..ac34780cd6a4
--- /dev/null
+++ b/include/keys/asymmetric-type.h
@@ -0,0 +1,92 @@
+/* Asymmetric Public-key cryptography key type interface
+ *
+ * See Documentation/crypto/asymmetric-keys.txt
+ *
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#ifndef _KEYS_ASYMMETRIC_TYPE_H
+#define _KEYS_ASYMMETRIC_TYPE_H
+
+#ifndef __UBOOT__
+#include 
+#include 
+
+extern struct key_type key_type_asymmetric;
+
+/*
+ * The key payload is four words.  The asymmetric-type key uses them as
+ * follows:
+ */
+enum 

[U-Boot] [RFC 6/9] lib: crypto: add public_key_verify_signature()

2019-09-02 Thread AKASHI Takahiro
Signed-off-by: AKASHI Takahiro 
---
 include/crypto/public_key.h   |  2 +-
 lib/crypto/Makefile   |  2 +-
 lib/crypto/public_key_local.c | 69 +++
 3 files changed, 71 insertions(+), 2 deletions(-)
 create mode 100644 lib/crypto/public_key_local.c

diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
index 91b1f2615294..f361d756119d 100644
--- a/include/crypto/public_key.h
+++ b/include/crypto/public_key.h
@@ -81,9 +81,9 @@ extern int decrypt_blob(struct kernel_pkey_params *, const 
void *, void *);
 extern int create_signature(struct kernel_pkey_params *, const void *, void *);
 extern int verify_signature(const struct key *,
const struct public_key_signature *);
+#endif /* !__UBOOT__ */
 
 int public_key_verify_signature(const struct public_key *pkey,
const struct public_key_signature *sig);
-#endif /* !__UBOOT__ */
 
 #endif /* _LINUX_PUBLIC_KEY_H */
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index a284de9e0411..870d2a90b181 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -7,4 +7,4 @@ obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
 
 asymmetric_keys-y := asymmetric_type.o
 
-obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
+obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o public_key_local.o
diff --git a/lib/crypto/public_key_local.c b/lib/crypto/public_key_local.c
new file mode 100644
index ..19721f319dbd
--- /dev/null
+++ b/lib/crypto/public_key_local.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  Public key utilities
+ *
+ * Copyright (c) 2019 AKASHI Takahiro, Linaro Limited
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * U-Boot version of kernel's public_key_verify_signature() --
+ *   Verify a signature using a public key
+ */
+int public_key_verify_signature(const struct public_key *pkey,
+   const struct public_key_signature *sig)
+{
+/*
+ * FIXME
+ * Currently, x509_check_for_self_signed() failed
+ * due to sig->digest == NULL
+ */
+#ifndef __UBOOT__
+   struct image_sign_info info;
+   struct image_region reg;
+   int ret;
+
+   memset(, '\0', sizeof(info));
+   /*
+* FIXME: Algo names here are hard-coded
+*/
+   if (!strcmp(sig->encoding, "pkcs1"))
+   info.padding = image_get_padding_algo("pkcs-1.5");
+   else
+   return -ENOPKG;
+
+   /*
+* Note: image_get_[checksum|crypto]_algo takes an string
+* argument like ","
+*/
+   if (!strcmp(sig->hash_algo, "sha256"))
+   info.checksum = image_get_checksum_algo("sha256,");
+   else
+   return -ENOPKG;
+
+   if (!strcmp(sig->pkey_algo, "rsa")) {
+   info.name = "sha256,rsa2048";
+   info.crypto = image_get_crypto_algo(info.name);
+   } else {
+   return -ENOPKG;
+   }
+
+   info.key = pkey->key;
+   info.keylen = pkey->keylen;
+
+   reg.data = sig->s;
+   reg.size = sig->s_size;
+
+   ret = rsa_verify(, , 1, sig->digest, sig->digest_size);
+   if (ret) {
+   debug("%s: Verifying a signature failed\n", __func__);
+   return -EKEYREJECTED;
+   }
+#endif /* __UBOOT__ */
+
+   return 0;
+}
-- 
2.21.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [RFC 3/9] lib: add asn1 decoder

2019-09-02 Thread AKASHI Takahiro
Imported from linux kernel v5.0.

Signed-off-by: AKASHI Takahiro 
---
 lib/Kconfig|   6 +
 lib/Makefile   |   1 +
 lib/asn1_decoder.c | 520 +
 3 files changed, 527 insertions(+)
 create mode 100644 lib/asn1_decoder.c

diff --git a/lib/Kconfig b/lib/Kconfig
index 3da45a5ec322..26c94f49ecd2 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -521,6 +521,12 @@ config SMBIOS_PRODUCT_NAME
 
 endmenu
 
+config ASN1
+   bool
+   select BUILD_ASN1
+   help
+ Enable asn1 decoder library.
+
 source lib/efi/Kconfig
 source lib/efi_loader/Kconfig
 source lib/optee/Kconfig
diff --git a/lib/Makefile b/lib/Makefile
index 2fffd68f943c..eb3a675fb8c2 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_OF_LIVE) += of_live.o
 obj-$(CONFIG_CMD_DHRYSTONE) += dhry/
 obj-$(CONFIG_ARCH_AT91) += at91/
 obj-$(CONFIG_OPTEE) += optee/
+obj-$(CONFIG_BUILD_ASN1) += asn1_decoder.o
 
 obj-$(CONFIG_AES) += aes.o
 
diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c
new file mode 100644
index ..39e78efa0bc8
--- /dev/null
+++ b/lib/asn1_decoder.c
@@ -0,0 +1,520 @@
+/* Decoder for ASN.1 BER/DER/CER encoded bytestream
+ *
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const unsigned char asn1_op_lengths[ASN1_OP__NR] = {
+   /*  OPC TAG JMP ACT */
+   [ASN1_OP_MATCH] = 1 + 1,
+   [ASN1_OP_MATCH_OR_SKIP] = 1 + 1,
+   [ASN1_OP_MATCH_ACT] = 1 + 1 + 1,
+   [ASN1_OP_MATCH_ACT_OR_SKIP] = 1 + 1 + 1,
+   [ASN1_OP_MATCH_JUMP]= 1 + 1 + 1,
+   [ASN1_OP_MATCH_JUMP_OR_SKIP]= 1 + 1 + 1,
+   [ASN1_OP_MATCH_ANY] = 1,
+   [ASN1_OP_MATCH_ANY_OR_SKIP] = 1,
+   [ASN1_OP_MATCH_ANY_ACT] = 1 + 1,
+   [ASN1_OP_MATCH_ANY_ACT_OR_SKIP] = 1 + 1,
+   [ASN1_OP_COND_MATCH_OR_SKIP]= 1 + 1,
+   [ASN1_OP_COND_MATCH_ACT_OR_SKIP]= 1 + 1 + 1,
+   [ASN1_OP_COND_MATCH_JUMP_OR_SKIP]   = 1 + 1 + 1,
+   [ASN1_OP_COND_MATCH_ANY]= 1,
+   [ASN1_OP_COND_MATCH_ANY_OR_SKIP]= 1,
+   [ASN1_OP_COND_MATCH_ANY_ACT]= 1 + 1,
+   [ASN1_OP_COND_MATCH_ANY_ACT_OR_SKIP]= 1 + 1,
+   [ASN1_OP_COND_FAIL] = 1,
+   [ASN1_OP_COMPLETE]  = 1,
+   [ASN1_OP_ACT]   = 1 + 1,
+   [ASN1_OP_MAYBE_ACT] = 1 + 1,
+   [ASN1_OP_RETURN]= 1,
+   [ASN1_OP_END_SEQ]   = 1,
+   [ASN1_OP_END_SEQ_OF]= 1 + 1,
+   [ASN1_OP_END_SET]   = 1,
+   [ASN1_OP_END_SET_OF]= 1 + 1,
+   [ASN1_OP_END_SEQ_ACT]   = 1 + 1,
+   [ASN1_OP_END_SEQ_OF_ACT]= 1 + 1 + 1,
+   [ASN1_OP_END_SET_ACT]   = 1 + 1,
+   [ASN1_OP_END_SET_OF_ACT]= 1 + 1 + 1,
+};
+
+/*
+ * Find the length of an indefinite length object
+ * @data: The data buffer
+ * @datalen: The end of the innermost containing element in the buffer
+ * @_dp: The data parse cursor (updated before returning)
+ * @_len: Where to return the size of the element.
+ * @_errmsg: Where to return a pointer to an error message on error
+ */
+static int asn1_find_indefinite_length(const unsigned char *data, size_t 
datalen,
+  size_t *_dp, size_t *_len,
+  const char **_errmsg)
+{
+   unsigned char tag, tmp;
+   size_t dp = *_dp, len, n;
+   int indef_level = 1;
+
+next_tag:
+   if (unlikely(datalen - dp < 2)) {
+   if (datalen == dp)
+   goto missing_eoc;
+   goto data_overrun_error;
+   }
+
+   /* Extract a tag from the data */
+   tag = data[dp++];
+   if (tag == ASN1_EOC) {
+   /* It appears to be an EOC. */
+   if (data[dp++] != 0)
+   goto invalid_eoc;
+   if (--indef_level <= 0) {
+   *_len = dp - *_dp;
+   *_dp = dp;
+   return 0;
+   }
+   goto next_tag;
+   }
+
+   if (unlikely((tag & 0x1f) == ASN1_LONG_TAG)) {
+   do {
+   if (unlikely(datalen - dp < 2))
+   

[U-Boot] [RFC 4/9] lib: add oid registry utility

2019-09-02 Thread AKASHI Takahiro
Imported from linux kernel v5.0.

Signed-off-by: AKASHI Takahiro 
---
 include/linux/oid_registry.h | 103 +
 lib/Kconfig  |   5 +
 lib/Makefile |  16 +++
 lib/build_OID_registry   | 207 +++
 lib/oid_registry.c   | 178 ++
 5 files changed, 509 insertions(+)
 create mode 100644 include/linux/oid_registry.h
 create mode 100755 lib/build_OID_registry
 create mode 100644 lib/oid_registry.c

diff --git a/include/linux/oid_registry.h b/include/linux/oid_registry.h
new file mode 100644
index ..d2fa9ca42e9a
--- /dev/null
+++ b/include/linux/oid_registry.h
@@ -0,0 +1,103 @@
+/* ASN.1 Object identifier (OID) registry
+ *
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_OID_REGISTRY_H
+#define _LINUX_OID_REGISTRY_H
+
+#include 
+
+/*
+ * OIDs are turned into these values if possible, or OID__NR if not held here.
+ *
+ * NOTE!  Do not mess with the format of each line as this is read by
+ *   build_OID_registry.pl to generate the data for look_up_OID().
+ */
+enum OID {
+   OID_id_dsa_with_sha1,   /* 1.2.840.10030.4.3 */
+   OID_id_dsa, /* 1.2.840.10040.4.1 */
+   OID_id_ecdsa_with_sha1, /* 1.2.840.10045.4.1 */
+   OID_id_ecPublicKey, /* 1.2.840.10045.2.1 */
+
+   /* PKCS#1 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 
pkcs-1(1)} */
+   OID_rsaEncryption,  /* 1.2.840.113549.1.1.1 */
+   OID_md2WithRSAEncryption,   /* 1.2.840.113549.1.1.2 */
+   OID_md3WithRSAEncryption,   /* 1.2.840.113549.1.1.3 */
+   OID_md4WithRSAEncryption,   /* 1.2.840.113549.1.1.4 */
+   OID_sha1WithRSAEncryption,  /* 1.2.840.113549.1.1.5 */
+   OID_sha256WithRSAEncryption,/* 1.2.840.113549.1.1.11 */
+   OID_sha384WithRSAEncryption,/* 1.2.840.113549.1.1.12 */
+   OID_sha512WithRSAEncryption,/* 1.2.840.113549.1.1.13 */
+   OID_sha224WithRSAEncryption,/* 1.2.840.113549.1.1.14 */
+   /* PKCS#7 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 
pkcs-7(7)} */
+   OID_data,   /* 1.2.840.113549.1.7.1 */
+   OID_signed_data,/* 1.2.840.113549.1.7.2 */
+   /* PKCS#9 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 
pkcs-9(9)} */
+   OID_email_address,  /* 1.2.840.113549.1.9.1 */
+   OID_contentType,/* 1.2.840.113549.1.9.3 */
+   OID_messageDigest,  /* 1.2.840.113549.1.9.4 */
+   OID_signingTime,/* 1.2.840.113549.1.9.5 */
+   OID_smimeCapabilites,   /* 1.2.840.113549.1.9.15 */
+   OID_smimeAuthenticatedAttrs,/* 1.2.840.113549.1.9.16.2.11 */
+
+   /* {iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2)} */
+   OID_md2,/* 1.2.840.113549.2.2 */
+   OID_md4,/* 1.2.840.113549.2.4 */
+   OID_md5,/* 1.2.840.113549.2.5 */
+
+   /* Microsoft Authenticode & Software Publishing */
+   OID_msIndirectData, /* 1.3.6.1.4.1.311.2.1.4 */
+   OID_msStatementType,/* 1.3.6.1.4.1.311.2.1.11 */
+   OID_msSpOpusInfo,   /* 1.3.6.1.4.1.311.2.1.12 */
+   OID_msPeImageDataObjId, /* 1.3.6.1.4.1.311.2.1.15 */
+   OID_msIndividualSPKeyPurpose,   /* 1.3.6.1.4.1.311.2.1.21 */
+   OID_msOutlookExpress,   /* 1.3.6.1.4.1.311.16.4 */
+
+   OID_certAuthInfoAccess, /* 1.3.6.1.5.5.7.1.1 */
+   OID_sha1,   /* 1.3.14.3.2.26 */
+   OID_sha256, /* 2.16.840.1.101.3.4.2.1 */
+   OID_sha384, /* 2.16.840.1.101.3.4.2.2 */
+   OID_sha512, /* 2.16.840.1.101.3.4.2.3 */
+   OID_sha224, /* 2.16.840.1.101.3.4.2.4 */
+
+   /* Distinguished Name attribute IDs [RFC 2256] */
+   OID_commonName, /* 2.5.4.3 */
+   OID_surname,/* 2.5.4.4 */
+   OID_countryName,/* 2.5.4.6 */
+   OID_locality,   /* 2.5.4.7 */
+   OID_stateOrProvinceName,/* 2.5.4.8 */
+   OID_organizationName,   /* 2.5.4.10 */
+   OID_organizationUnitName,   /* 2.5.4.11 */
+   OID_title,  /* 2.5.4.12 */
+   OID_description,/* 2.5.4.13 */
+   OID_name,   /* 2.5.4.41 */
+   OID_givenName,  /* 2.5.4.42 */
+   OID_initials,   /* 2.5.4.43 */
+   

[U-Boot] [RFC 2/9] Makefile: add build script for asn1 parsers

2019-09-02 Thread AKASHI Takahiro
This rule will be used to build x509 and pkcs7 parsers.

Signed-off-by: AKASHI Takahiro 
---
 scripts/Makefile.build | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f7a041296d3d..9357d310e50b 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -331,7 +331,7 @@ quiet_cmd_asn1_compiler = ASN.1   $@
   cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
$(subst .h,.c,$@) $(subst .c,.h,$@)
 
-$(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
+$(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
$(call cmd,asn1_compiler)
 
 # Build the compiled-in targets
@@ -419,9 +419,11 @@ targets += $(multi-used-y) $(multi-used-m)
 intermediate_targets = $(foreach sfx, $(2), \
$(patsubst %$(strip $(1)),%$(sfx), \
$(filter %$(strip $(1)), $(targets
+# %.asn1.o <- %.asn1.[ch] <- %.asn1
 # %.lex.o <- %.lex.c <- %.l
 # %.tab.o <- %.tab.[ch] <- %.y
-targets += $(call intermediate_targets, .lex.o, .lex.c) \
+targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
+  $(call intermediate_targets, .lex.o, .lex.c) \
   $(call intermediate_targets, .tab.o, .tab.c .tab.h)
 
 # Descending
-- 
2.21.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [RFC 1/9] cmd: add asn1_compiler

2019-09-02 Thread AKASHI Takahiro
Imported from linux kernel v5.0.

This host command will be used to create a ASN1 parser, for example,
for pkcs7 or x509.

Signed-off-by: AKASHI Takahiro 
---
 cmd/Kconfig   |3 +
 include/linux/asn1.h  |   69 ++
 include/linux/asn1_ber_bytecode.h |   93 ++
 include/linux/asn1_decoder.h  |   24 +
 scripts/Makefile  |3 +
 scripts/asn1_compiler.c   | 1615 +
 6 files changed, 1807 insertions(+)
 create mode 100644 include/linux/asn1.h
 create mode 100644 include/linux/asn1_ber_bytecode.h
 create mode 100644 include/linux/asn1_decoder.h
 create mode 100644 scripts/asn1_compiler.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 05872fa0d7f4..e3f38ee0a5fd 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -183,6 +183,9 @@ endmenu
 config BUILD_BIN2C
bool
 
+config BUILD_ASN1
+   bool
+
 comment "Commands"
 
 menu "Info commands"
diff --git a/include/linux/asn1.h b/include/linux/asn1.h
new file mode 100644
index ..eed6982860ba
--- /dev/null
+++ b/include/linux/asn1.h
@@ -0,0 +1,69 @@
+/* ASN.1 BER/DER/CER encoding definitions
+ *
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_ASN1_H
+#define _LINUX_ASN1_H
+
+/* Class */
+enum asn1_class {
+   ASN1_UNIV   = 0,/* Universal */
+   ASN1_APPL   = 1,/* Application */
+   ASN1_CONT   = 2,/* Context */
+   ASN1_PRIV   = 3 /* Private */
+};
+#define ASN1_CLASS_BITS0xc0
+
+
+enum asn1_method {
+   ASN1_PRIM   = 0,/* Primitive */
+   ASN1_CONS   = 1 /* Constructed */
+};
+#define ASN1_CONS_BIT  0x20
+
+/* Tag */
+enum asn1_tag {
+   ASN1_EOC= 0,/* End Of Contents or N/A */
+   ASN1_BOOL   = 1,/* Boolean */
+   ASN1_INT= 2,/* Integer */
+   ASN1_BTS= 3,/* Bit String */
+   ASN1_OTS= 4,/* Octet String */
+   ASN1_NULL   = 5,/* Null */
+   ASN1_OID= 6,/* Object Identifier  */
+   ASN1_ODE= 7,/* Object Description */
+   ASN1_EXT= 8,/* External */
+   ASN1_REAL   = 9,/* Real float */
+   ASN1_ENUM   = 10,   /* Enumerated */
+   ASN1_EPDV   = 11,   /* Embedded PDV */
+   ASN1_UTF8STR= 12,   /* UTF8 String */
+   ASN1_RELOID = 13,   /* Relative OID */
+   /* 14 - Reserved */
+   /* 15 - Reserved */
+   ASN1_SEQ= 16,   /* Sequence and Sequence of */
+   ASN1_SET= 17,   /* Set and Set of */
+   ASN1_NUMSTR = 18,   /* Numerical String */
+   ASN1_PRNSTR = 19,   /* Printable String */
+   ASN1_TEXSTR = 20,   /* T61 String / Teletext String */
+   ASN1_VIDSTR = 21,   /* Videotex String */
+   ASN1_IA5STR = 22,   /* IA5 String */
+   ASN1_UNITIM = 23,   /* Universal Time */
+   ASN1_GENTIM = 24,   /* General Time */
+   ASN1_GRASTR = 25,   /* Graphic String */
+   ASN1_VISSTR = 26,   /* Visible String */
+   ASN1_GENSTR = 27,   /* General String */
+   ASN1_UNISTR = 28,   /* Universal String */
+   ASN1_CHRSTR = 29,   /* Character String */
+   ASN1_BMPSTR = 30,   /* BMP String */
+   ASN1_LONG_TAG   = 31/* Long form tag */
+};
+
+#define ASN1_INDEFINITE_LENGTH 0x80
+
+#endif /* _LINUX_ASN1_H */
diff --git a/include/linux/asn1_ber_bytecode.h 
b/include/linux/asn1_ber_bytecode.h
new file mode 100644
index ..ab3a6c002f7b
--- /dev/null
+++ b/include/linux/asn1_ber_bytecode.h
@@ -0,0 +1,93 @@
+/* ASN.1 BER/DER/CER parsing state machine internal definitions
+ *
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_ASN1_BER_BYTECODE_H
+#define _LINUX_ASN1_BER_BYTECODE_H
+
+#ifdef __KERNEL__
+#include 
+#endif
+#include 
+
+typedef int (*asn1_action_t)(void *context,
+size_t hdrlen, /* In case of ANY type */
+unsigned char tag, /* In case of ANY type */
+const void *value, size_t vlen);
+
+struct asn1_decoder {
+   const unsigned char *machine;
+   size_t machlen;
+   const asn1_action_t *actions;
+};
+
+enum asn1_opcode {
+   /* The tag-matching ops come first and the odd-numbered slots
+* are for 

[U-Boot] [RFC 0/9] import x509/pkcs7 parsers from linux

2019-09-02 Thread AKASHI Takahiro
Asn1 parsers of x509 certificates and pkcs7 messages are required
to implement image authentication and variable authentication as
part of UEFI secure boot feature.

As we discussed before in the thread[1], most people insisted that
we should re-use corresponding source code from Linux repository
for this purpose.

Here is my attempt to import all the necessary files from Linux; Those
will eventually be part of UEFI secure boot implementation, but I'd like
to get early feedback from other peoples before submitting the whole
patchset so that they will be better formatted for merging.

My approach here is
* files from Linux 5.0
  (will be updated to the latest when I will submit them as finalized
   patches.)
* modify files as little as possible
* mark/protect unavoidable changes with "#if(n)def __UBOOT__"
so that future fixes/differences in Linux repository will easily
be applied to U-Boot.

Please note that checkpatch.pl will complain with a bunch of
warnings/errors but I intentionally left them unchanged for the sake
of better maintainability I said above.

Any comments will be appreciated.
-Takahiro Akashi

[1] https://lists.denx.de/pipermail/u-boot/2019-April/366423.html

AKASHI Takahiro (9):
  cmd: add asn1_compiler
  Makefile: add build script for asn1 parsers
  lib: add asn1 decoder
  lib: add oid registry utility
  lib: crypto: add public key utility
  lib: crypto: add public_key_verify_signature()
  lib: crypto: add x509 parser
  lib: crypto: add pkcs7 message parser
  lib: crypto: add rsa public key parser

 cmd/Kconfig   |3 +
 include/crypto/internal/rsa.h |   62 ++
 include/crypto/pkcs7.h|   51 +
 include/crypto/public_key.h   |   89 ++
 include/keys/asymmetric-type.h|   92 ++
 include/linux/asn1.h  |   69 ++
 include/linux/asn1_ber_bytecode.h |   93 ++
 include/linux/asn1_decoder.h  |   24 +
 include/linux/oid_registry.h  |  103 ++
 lib/Kconfig   |   12 +
 lib/Makefile  |   18 +
 lib/asn1_decoder.c|  520 ++
 lib/build_OID_registry|  207 
 lib/crypto/Kconfig|   38 +
 lib/crypto/Makefile   |   46 +
 lib/crypto/asymmetric_type.c  |  655 
 lib/crypto/pkcs7.asn1 |  135 +++
 lib/crypto/pkcs7_parser.c |  690 
 lib/crypto/pkcs7_parser.h |   69 ++
 lib/crypto/public_key.c   |  344 ++
 lib/crypto/public_key_local.c |   69 ++
 lib/crypto/rsa_helper.c   |   81 ++
 lib/crypto/rsapubkey.asn1 |4 +
 lib/crypto/x509.asn1  |   60 ++
 lib/crypto/x509_akid.asn1 |   35 +
 lib/crypto/x509_cert_parser.c |  644 
 lib/crypto/x509_parser.h  |   61 ++
 lib/crypto/x509_public_key.c  |  284 +
 lib/oid_registry.c|  178 
 scripts/Makefile  |3 +
 scripts/Makefile.build|2 +-
 scripts/asn1_compiler.c   | 1615 +
 32 files changed, 6355 insertions(+), 1 deletion(-)
 create mode 100644 include/crypto/internal/rsa.h
 create mode 100644 include/crypto/pkcs7.h
 create mode 100644 include/crypto/public_key.h
 create mode 100644 include/keys/asymmetric-type.h
 create mode 100644 include/linux/asn1.h
 create mode 100644 include/linux/asn1_ber_bytecode.h
 create mode 100644 include/linux/asn1_decoder.h
 create mode 100644 include/linux/oid_registry.h
 create mode 100644 lib/asn1_decoder.c
 create mode 100755 lib/build_OID_registry
 create mode 100644 lib/crypto/Kconfig
 create mode 100644 lib/crypto/Makefile
 create mode 100644 lib/crypto/asymmetric_type.c
 create mode 100644 lib/crypto/pkcs7.asn1
 create mode 100644 lib/crypto/pkcs7_parser.c
 create mode 100644 lib/crypto/pkcs7_parser.h
 create mode 100644 lib/crypto/public_key.c
 create mode 100644 lib/crypto/public_key_local.c
 create mode 100644 lib/crypto/rsa_helper.c
 create mode 100644 lib/crypto/rsapubkey.asn1
 create mode 100644 lib/crypto/x509.asn1
 create mode 100644 lib/crypto/x509_akid.asn1
 create mode 100644 lib/crypto/x509_cert_parser.c
 create mode 100644 lib/crypto/x509_parser.h
 create mode 100644 lib/crypto/x509_public_key.c
 create mode 100644 lib/oid_registry.c
 create mode 100644 scripts/asn1_compiler.c

-- 
2.21.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] cmd: env: correct a wrong comment of do_env_set_efi()

2019-09-02 Thread AKASHI Takahiro
Correct a function name in comments.

Signed-off-by: AKASHI Takahiro 
---
 cmd/nvedit_efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index a9ecb3ee4dc3..4532124c33d0 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -381,7 +381,7 @@ out:
 }
 
 /**
- * do_env_print_efi() - set UEFI variable
+ * do_env_set_efi() - set UEFI variable
  *
  * @cmdtp: Command table
  * @flag:  Command flag
-- 
2.21.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] cmd: env: extend "env [set|print] -e" to manage UEFI variables

2019-09-02 Thread AKASHI Takahiro
With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes,  BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
  TIME_BASED_AUTHENTICATED_WRITE_ACCESS respectively with
  "-bs", "-rt" and "-at",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
  at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

When "-at" is given, a variable should be authenticated with
appropriate signature database before setting or modifying its value.
(Authentication is not supported yet though.)

Meanwhile, "env print -e," will be modified so that it will dump
a variable's value only if '-v' (verbose) is specified.

Signed-off-by: AKASHI Takahiro 
---
 cmd/nvedit.c |  20 +++--
 cmd/nvedit_efi.c | 192 ++-
 2 files changed, 172 insertions(+), 40 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 1cb0bc1460b9..2d2adc8529db 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -1387,7 +1387,7 @@ static char env_help_text[] =
 #endif
"env print [-a | name ...] - print environment\n"
 #if defined(CONFIG_CMD_NVEDIT_EFI)
-   "env print -e [name ...] - print UEFI environment\n"
+   "env print -e [-v] [name ...] - print UEFI environment\n"
 #endif
 #if defined(CONFIG_CMD_RUN)
"env run var [...] - run commands in an environment variable\n"
@@ -1399,7 +1399,8 @@ static char env_help_text[] =
 #endif
 #endif
 #if defined(CONFIG_CMD_NVEDIT_EFI)
-   "env set -e name [arg ...] - set UEFI variable; unset if 'arg' not 
specified\n"
+   "env set -e [-nv][-bs][-rt][-at][-a][-i addr,size][-v] name [arg ...]\n"
+   "- set UEFI variable; unset if '-i' or 'arg' not specified\n"
 #endif
"env set [-f] name [arg ...]\n";
 #endif
@@ -1428,8 +1429,9 @@ U_BOOT_CMD_COMPLETE(
"print environment variables",
"[-a]\n- print [all] values of all environment variables\n"
 #if defined(CONFIG_CMD_NVEDIT_EFI)
-   "printenv -e [name ...]\n"
+   "printenv -e [-v] [name ...]\n"
"- print UEFI variable 'name' or all the variables\n"
+   "  \"-v\": verbose for signature database\n"
 #endif
"printenv name ...\n"
"- print value of environment variable 'name'",
@@ -1459,9 +1461,17 @@ U_BOOT_CMD_COMPLETE(
setenv, CONFIG_SYS_MAXARGS, 0,  do_env_set,
"set environment variables",
 #if defined(CONFIG_CMD_NVEDIT_EFI)
-   "-e [-nv] name [value ...]\n"
+   "-e [-guid guid][-nv][-bs][-rt][-at][-a][-v]\n"
+   "[-i addr,size name], or [name [value ...]]\n"
"- set UEFI variable 'name' to 'value' ...'\n"
-   "  'nv' option makes the variable non-volatile\n"
+   "  \"-guid\": set vendor guid\n"
+   "  \"-nv\": set non-volatile attribute\n"
+   "  \"-bs\": set boot-service attribute\n"
+   "  \"-rt\": set runtime attribute\n"
+   "  \"-at\": set time-based authentication attribute\n"
+   "  \"-a\": append-write\n"
+   "  \"-i addr,size\": use  as variable's value\n"
+   "  \"-v\": verbose print\n"
"- delete UEFI variable 'name' if 'value' not specified\n"
 #endif
"setenv [-f] name value ...\n"
diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index ed6d09a53046..a9ecb3ee4dc3 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /*
@@ -34,15 +35,48 @@ static const struct {
{EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS, "AT"},
 };
 
+static const struct {
+   efi_guid_t guid;
+   char *text;
+} efi_guid_text[] = {
+   /* signature database */
+   {EFI_GLOBAL_VARIABLE_GUID, "EFI_GLOBAL_VARIABLE_GUID"},
+};
+
+/* "----" */
+static char unknown_guid[37];
+
+/**
+ * efi_guid_to_str() - convert guid to readable name
+ *
+ * @guid:  GUID
+ * Return: string for GUID
+ *
+ * convert guid to readable name
+ */
+static const char *efi_guid_to_str(efi_guid_t *guid)
+{
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(efi_guid_text); i++)
+   if (!guidcmp(guid, _guid_text[i].guid))
+   return efi_guid_text[i].text;
+
+   uuid_bin_to_str(guid->b, unknown_guid, UUID_STR_FORMAT_GUID);
+
+   return unknown_guid;
+}
+
 /**
  * efi_dump_single_var() - show information about a UEFI variable
  *
  * @name:  Name of the variable
  * @guid:  Vendor GUID
+ * @verbose:   if true, dump data
  *
  * Show information encoded in one UEFI variable
  */
-static void efi_dump_single_var(u16 *name, efi_guid_t *guid)
+static void efi_dump_single_var(u16 *name, efi_guid_t *guid, bool verbose)
 {
u32 attributes;
u8 *data;
@@ -68,7 +102,7 @@ static void efi_dump_single_var(u16 *name, efi_guid_t *guid)
if (ret 

[U-Boot] [PATCH] efi_loader: variable: support APPEND_WRITE

2019-09-02 Thread AKASHI Takahiro
If EFI_VARIABLE_APPEND_WRITE is specified in attributes at
efi_set_variable(), specified data will be appended to the variable's
original value. Attributes other than APPEND_WRITE should not be
modified.

With this patch, APPEND_WRITE test in 'variables' selftest will pass.

Signed-off-by: AKASHI Takahiro 
---
 lib/efi_loader/efi_variable.c | 50 +--
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index 6687b69a400d..5d1ee50a606e 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -423,18 +423,17 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
 const efi_guid_t *vendor, u32 attributes,
 efi_uintn_t data_size, const void *data)
 {
-   char *native_name = NULL, *val = NULL, *s;
+   char *native_name = NULL, *oval, *val = NULL, *s;
+   size_t oval_size;
efi_status_t ret = EFI_SUCCESS;
u32 attr;
 
EFI_ENTRY("\"%ls\" %pUl %x %zu %p", variable_name, vendor, attributes,
  data_size, data);
 
-   /* TODO: implement APPEND_WRITE */
if (!variable_name || !*variable_name || !vendor ||
((attributes & EFI_VARIABLE_RUNTIME_ACCESS) &&
-!(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)) ||
-   (attributes & EFI_VARIABLE_APPEND_WRITE)) {
+!(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS))) {
ret = EFI_INVALID_PARAMETER;
goto out;
}
@@ -452,28 +451,37 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
goto out;
}
 
-   val = env_get(native_name);
-   if (val) {
-   parse_attr(val, );
+   oval = env_get(native_name);
+   if (oval) {
+   oval = parse_attr(oval, );
 
-   /* We should not free val */
-   val = NULL;
if (attr & READ_ONLY) {
ret = EFI_WRITE_PROTECTED;
goto out;
}
 
-   /*
-* attributes won't be changed
-* TODO: take care of APPEND_WRITE once supported
-*/
-   if (attr != attributes) {
+   /* attributes won't be changed */
+   if (attr != (attributes & ~EFI_VARIABLE_APPEND_WRITE)) {
ret = EFI_INVALID_PARAMETER;
goto out;
}
+
+   if (attributes & EFI_VARIABLE_APPEND_WRITE) {
+   if (!prefix(oval, "(blob)")) {
+   /* TODO: should support utf8? */
+   return EFI_DEVICE_ERROR;
+   goto out;
+   }
+   oval_size = strlen(oval);
+   } else {
+   oval_size = 0;
+   }
+   } else {
+   oval_size = 0;
}
 
-   val = malloc(2 * data_size + strlen("{ro,run,boot,nv}(blob)") + 1);
+   val = malloc(oval_size + 2 * data_size
++ strlen("{ro,run,boot,nv}(blob)") + 1);
if (!val) {
ret = EFI_OUT_OF_RESOURCES;
goto out;
@@ -481,10 +489,7 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
 
s = val;
 
-   /*
-* store attributes
-* TODO: several attributes are not supported
-*/
+   /* store attributes */
attributes &= (EFI_VARIABLE_NON_VOLATILE |
   EFI_VARIABLE_BOOTSERVICE_ACCESS |
   EFI_VARIABLE_RUNTIME_ACCESS);
@@ -505,8 +510,13 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
}
s += sprintf(s, "}");
 
+   if (oval_size)
+   /* APPEND_WRITE */
+   s += sprintf(s, oval);
+   else
+   s += sprintf(s, "(blob)");
+
/* store payload: */
-   s += sprintf(s, "(blob)");
s = bin2hex(s, data, data_size);
*s = '\0';
 
-- 
2.21.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/1] x86: efi_loader: Fix invalid address return from efi_alloc()

2019-09-02 Thread Park, Aiden
This issue can be seen on 32bit operation when one of E820_RAM type
entries is greater than 4GB memory space.

The efi_alloc() finds a free memory in the conventional memory which
is greater than 4GB. But, it does type cast to 32bit address space
and eventually returns invalid address.

Signed-off-by: Aiden Park 
---
Changes in v2:
  * Add efi_add_conventional_memory_map() for common code re-use

 arch/x86/lib/e820.c | 17 ++--
 include/efi_loader.h|  4 ++
 lib/efi_loader/efi_memory.c | 82 ++---
 3 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/arch/x86/lib/e820.c b/arch/x86/lib/e820.c
index d6ae2c4e9d..26da4d2f27 100644
--- a/arch/x86/lib/e820.c
+++ b/arch/x86/lib/e820.c
@@ -41,14 +41,17 @@ void efi_add_known_memory(void)
 {
struct e820_entry e820[E820MAX];
unsigned int i, num;
-   u64 start, pages;
+   u64 start, pages, ram_top;
int type;
 
num = install_e820_map(ARRAY_SIZE(e820), e820);
 
+   ram_top = (u64)gd->ram_top & ~EFI_PAGE_MASK;
+   if (!ram_top)
+   ram_top = 0x1ULL;
+
for (i = 0; i < num; ++i) {
start = e820[i].addr;
-   pages = ALIGN(e820[i].size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT;
 
switch (e820[i].type) {
case E820_RAM:
@@ -69,7 +72,15 @@ void efi_add_known_memory(void)
break;
}
 
-   efi_add_memory_map(start, pages, type, false);
+   if (type == EFI_CONVENTIONAL_MEMORY) {
+   efi_add_conventional_memory_map(start,
+   start + e820[i].size,
+   ram_top);
+   } else {
+   pages = ALIGN(e820[i].size, EFI_PAGE_SIZE)
+   >> EFI_PAGE_SHIFT;
+   efi_add_memory_map(start, pages, type, false);
+   }
}
 }
 #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 5298ea7997..00eba8afa4 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -478,6 +478,10 @@ efi_status_t efi_get_memory_map(efi_uintn_t 
*memory_map_size,
 /* Adds a range into the EFI memory map */
 efi_status_t efi_add_memory_map(uint64_t start, uint64_t pages, int 
memory_type,
bool overlap_only_ram);
+/* Adds a conventional range into the EFI memory map */
+efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end,
+u64 ram_top);
+
 /* Called by board init to initialize the EFI drivers */
 efi_status_t efi_driver_init(void);
 /* Called by board init to initialize the EFI memory map */
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index b5775e0399..83cbc9154f 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -655,6 +655,54 @@ efi_status_t efi_get_memory_map(efi_uintn_t 
*memory_map_size,
return EFI_SUCCESS;
 }
 
+/**
+ * efi_add_conventional_memory_map() - add a RAM memory area to the map
+ *
+ * @ram_start: start address of a RAM memory area
+ * @ram_end:   end address of a RAM memory area
+ * @ram_top:   max address to be used as conventional memory
+ * Return: status code
+ */
+efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end,
+u64 ram_top)
+{
+   u64 pages;
+
+   /* Remove partial pages */
+   ram_end &= ~EFI_PAGE_MASK;
+   ram_start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
+
+   if (ram_end <= ram_start) {
+   /* Invalid mapping */
+   return EFI_INVALID_PARAMETER;
+   }
+
+   pages = (ram_end - ram_start) >> EFI_PAGE_SHIFT;
+
+   efi_add_memory_map(ram_start, pages,
+  EFI_CONVENTIONAL_MEMORY, false);
+
+   /*
+* Boards may indicate to the U-Boot memory core that they
+* can not support memory above ram_top. Let's honor this
+* in the efi_loader subsystem too by declaring any memory
+* above ram_top as "already occupied by firmware".
+*/
+   if (ram_top < ram_start) {
+   /* ram_top is before this region, reserve all */
+   efi_add_memory_map(ram_start, pages,
+  EFI_BOOT_SERVICES_DATA, true);
+   } else if ((ram_top >= ram_start) && (ram_top < ram_end)) {
+   /* ram_top is inside this region, reserve parts */
+   pages = (ram_end - ram_top) >> EFI_PAGE_SHIFT;
+
+   efi_add_memory_map(ram_top, pages,
+  EFI_BOOT_SERVICES_DATA, true);
+   }
+
+   return EFI_SUCCESS;
+}
+
 __weak void efi_add_known_memory(void)
 {
u64 ram_top = board_get_usable_ram_top(0) & 

Re: [U-Boot] U-Boot: Environment flags broken for U-Boot

2019-09-02 Thread Heiko Schocher

Hello Patrick,

Am 02.09.2019 um 17:35 schrieb Patrick DELAUNAY:

Hi Heiko,



From: Heiko Schocher 
Sent: lundi 2 septembre 2019 16:03

Hello Patrick,

I am just testing U-Boot Environment flags and they do not work anymore with
current mainline U-Boot ... I should have made some tbot test for it, but did 
not
found yet time for it ...

Here log with current mainline:


=> printenv heiko
heiko=changed
=> env flags
Available variable type flags (position 0):
  FlagVariable Type Name
  --
  s   -   string
  d   -   decimal
  x   -   hexadecimal
  b   -   boolean
  i   -   IP address
  m   -   MAC address

Available variable access flags (position 1):
  FlagVariable Access Name
  
  a   -   any
  r   -   read-only
  o   -   write-once
  c   -   change-default

Static flags:
  Variable NameVariable TypeVariable Access
  -----
  eth\d*addr   MAC address  any
  ipaddr   IP address   any
  gatewayipIP address   any
  netmask  IP address   any
  serverip IP address   any
  nvlandecimal  any
  vlan decimal  any
  dnsipIP address   any
  heikostring   write-once

Active flags:
  Variable NameVariable TypeVariable Access
  -----
  .flags   string   write-once
  netmask  IP address   any
  serverip IP address   any
  heikostring   write-once
  ipaddr   IP address   any
=> setenv heiko foo
=> print heiko
heiko=foo
=> setenv heiko bar
=> print heiko
heiko=bar

I can change Environment variable "heiko" but flag is write-once !

Ok, digging around and I found, that in env/common.c changed_ok is NULL which
results in not checking U-Boot flags:

   26 struct hsearch_data env_htab = {
   27 #if CONFIG_IS_ENABLED(ENV_SUPPORT)
   28 /* defined in flags.c, only compile with ENV_SUPPORT */
   29 .change_ok = env_flags_validate,
   30 #endif
   31 };

reason is your commit:

commit 7d4776545b0f8a8827e5d061206faf61c9ba6ea9
Author: Patrick Delaunay 
Date:   Thu Apr 18 17:32:49 2019 +0200

  env: solve compilation error in SPL

  Solve compilation issue when cli_simple.o is used in SPL
  and CONFIG_SPL_ENV_SUPPORT is not defined.

  env/built-in.o:(.data.env_htab+0xc): undefined reference to 
`env_flags_validate'
  u-boot/scripts/Makefile.spl:384: recipe for target 'spl/u-boot-spl' failed
  make[2]: *** [spl/u-boot-spl] Error 1
  u-boot/Makefile:1649: recipe for target 'spl/u-boot-spl' failed
  make[1]: *** [spl/u-boot-spl] Error 2

  Signed-off-by: Patrick Delaunay 


ENV_SUPPORT is only defined for SPL and TPL not for U-Boot, which leads in
change_ok always NULL in U-Boot ...

:-(

reverting this commit and it works again as expected ...

Urgs ... since april 2019 nobody tested this feature

:-(

Nevertheless, reverting commit and I see:

=> print heiko
heiko=test
=> setenv heiko foo
## Error inserting "heiko" variable, errno=1 =>

So we should find a solution for this.

Any ideas?


Hi,

Yes I am responsible of the regression, sorry.

When I see the definition CONFIG_SPL_ENV_SUPPORT and CONFIG_TPL_ENV_SUPPORT, I 
use the generic macro to check the activation of these TPL/SPL feature in the 
SPL/TPL builds
But I don't check the existence of the U-Boot flag CONFIG_ENV_SUPPORT when I 
propose my patch... so my patch is incorrect.

As flags.o is always compiled for U-Boot :

ifndef CONFIG_SPL_BUILD
obj-y += attr.o
obj-y += callback.o
obj-y += flags.o
...
else
obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += attr.o
obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += flags.o
obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += callback.o
endif


I see 2 solutions:

1/ change my patch to check U-boot compilation case with 
!defined(CONFIG_SPL_BUILD)

  26 struct hsearch_data env_htab = {
  27 #if !defined(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(ENV_SUPPORT)
  28 /* defined in flags.c, only compile with ENV_SUPPORT for SPL / TPL 
*/
  29 .change_ok = env_flags_validate,
  30 #endif
  31 };


Hmmm ... in case of CONFIG_TPL_BUILD it is also active, which your original
patch wanted to prevent ... so this seems not a good solution to me.

We need a CONFIG_UBOOT_BUILD define in this case ...


2/ introduce a new Kconfig to env support in U-Boot


Yep, this would be the clean solution!


config ENV_SUPPORT
bool "Support an environment 

Re: [U-Boot] [PATCH 2/3] mmc: fsl_esdhc: clean up code

2019-09-02 Thread Y.b. Lu
Hi Lukasz,

Sorry for my late response. Please see my comments inline.

> -Original Message-
> From: Lukasz Majewski 
> Sent: Friday, August 23, 2019 4:45 PM
> To: Y.b. Lu 
> Cc: u-boot@lists.denx.de; Peng Fan 
> Subject: Re: [U-Boot] [PATCH 2/3] mmc: fsl_esdhc: clean up code
> 
> On Mon, 19 Aug 2019 16:27:49 +0800
> Yangbo Lu  wrote:
> 
> >  /* Return the XFERTYP flags for a given command and data packet */
> > -static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
> > +static uint esdhc_setup_xfertyp(struct mmc_cmd *cmd, struct mmc_data
> > *data) {
> > uint xfertyp = 0;
> >
> > @@ -310,9 +310,9 @@ static int esdhc_setup_data(struct fsl_esdhc_priv
> > *priv, struct mmc *mmc, return 0;
> >  }
> >
> > -static void check_and_invalidate_dcache_range
> > -   (struct mmc_cmd *cmd,
> > -struct mmc_data *data) {
> > +static void esdhc_invalidate_dcache_range(struct mmc_cmd *cmd,
> > + struct mmc_data *data)
>    - it shall be aligned
>   with the (

[Y.b. Lu] Although it's not aligned with the ( in email, it's aligned after 
applying the patch.
I believe there is no issue, and the checkpatch passed before I sent out the 
patches.

Thanks.

> 
> Could you double check this patch set with ./tools/checkpatch.py if it
> is clean?
> 
> (You can also test tools/patman - which does automatic checkpatch check)
> 
> > +{
> 
> 
> 
> Best regards,
> 
> Lukasz Majewski
> 
> --
> 
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
> lu...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 5/5] doc: rockchip: use idbloader.img for rk3399

2019-09-02 Thread Kever Yang


On 2019/8/24 上午1:29, Matwey V. Kornilov wrote:

Makefile now produces ready-to-deploy idbloader.img file.

u-boot has support for TPL at rk3399 platform for all boards,
so there is not reason to refer binary loaders.

Signed-off-by: Matwey V. Kornilov 
---
  doc/README.rockchip | 6 --
  1 file changed, 6 deletions(-)

diff --git a/doc/README.rockchip b/doc/README.rockchip
index 401dc19d91..b5311adcd8 100644
--- a/doc/README.rockchip
+++ b/doc/README.rockchip
@@ -324,12 +324,6 @@ To write an image that boots from an SD card (assumed to 
be /dev/sdc):
  
  Option 1: Package the image with Rockchip miniloader:
  
-  - Create idbloader.img

-
-=> cd /path/to/u-boot
-=> ./tools/mkimage  -n rk3399 -T rksd -d 
/path/to/rkbin/bin/rk33/rk3399_ddr_800MHz_v1.20.bin idbloader.img
-=> cat /path/to/rkbin/bin/rk33/rk3399_miniloader_v1.19.bin >> idbloader.img
-
- Write idbloader.img at 64 sector
This is create idbloader from rkbin, it should not be update since it's 
not U-Boot target,

you should update below description for rk3399 instead:
474 Option 3: Package the image with TPL:
475
476   - Prefix rk3399 header to TPL image
477
478 => cd /path/to/u-boot
479 => ./tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl-dtb.bin out
480
481   - Concatinate tpl with spl
482
483 => cd /path/to/u-boot
484 => cat ./spl/u-boot-spl-dtb.bin >> out

Thanks,
- Kever
  
  => sudo dd if=idbloader.img of=/dev/sdc seek=64



___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] imx: apalis_imx6: select MX6Q via Kconfig

2019-09-02 Thread Peng Fan
> Subject: [PATCH] imx: apalis_imx6: select MX6Q via Kconfig
> 
> Toradex Apalis iMX6 modules are available in the iMX6D and iMX6Q variants,
> which are quite similar and already managed via only one dtb in u-boot
> (imx6-apalis.dtb). Select MX6Q via Kconfig by default in order to 
> automatically
> enable the HAS_CAAM and MX6_SMP features.
> 
> Signed-off-by: Ricardo Salveti 
> ---
>  arch/arm/mach-imx/mx6/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/mach-imx/mx6/Kconfig
> b/arch/arm/mach-imx/mx6/Kconfig index 9c27176ba0..36e1c98fb5 100644
> --- a/arch/arm/mach-imx/mx6/Kconfig
> +++ b/arch/arm/mach-imx/mx6/Kconfig
> @@ -117,6 +117,7 @@ config TARGET_ADVANTECH_DMS_BA16  config
> TARGET_APALIS_IMX6
>   bool "Toradex Apalis iMX6 board"
>   select BOARD_LATE_INIT
> + select MX6Q
>   select DM
>   select DM_SERIAL
>   select DM_THERMAL

Reviewed-by: Peng Fan 

> --
> 2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] apalis_imx6: allocate specific region of memory to OP-TEE

2019-09-02 Thread Peng Fan
> Subject: [PATCH] apalis_imx6: allocate specific region of memory to OP-TEE
> 
> OP-TEE uses the memory region defined by the maximum DRAM address
> minus CONFIG_OPTEE_TZDRAM_SIZE, so subtract
> CONFIG_OPTEE_TZDRAM_SIZE from the available DRAM size to avoid
> conflicts.
> 
> Signed-off-by: Ricardo Salveti 
> ---
>  board/toradex/apalis_imx6/apalis_imx6.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/board/toradex/apalis_imx6/apalis_imx6.c
> b/board/toradex/apalis_imx6/apalis_imx6.c
> index 6421a22c25..fa7fcc8d46 100644
> --- a/board/toradex/apalis_imx6/apalis_imx6.c
> +++ b/board/toradex/apalis_imx6/apalis_imx6.c
> @@ -75,6 +75,11 @@ int dram_init(void)
>   gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
>   (ulong)imx_ddr_size());
> 
> + /* Subtract the defined OPTEE runtime firmware length */ #ifdef
> +CONFIG_OPTEE_TZDRAM_SIZE
> + gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE; #endif
> +

Has OPTEE been enabled? I not see that in defconfig.

Regards,
Peng.

>   return 0;
>  }
> 
> --
> 2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] apalis_imx6: add board_fit_config_name_match to support FIT in SPL

2019-09-02 Thread Peng Fan
> Subject: [PATCH] apalis_imx6: add board_fit_config_name_match to support
> FIT in SPL
> 
> Only one dtb is currently supported, so match with imx6-apalis.
> 
> Signed-off-by: Ricardo Salveti 
> ---
>  board/toradex/apalis_imx6/apalis_imx6.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/board/toradex/apalis_imx6/apalis_imx6.c
> b/board/toradex/apalis_imx6/apalis_imx6.c
> index fa7fcc8d46..ef668fcedc 100644
> --- a/board/toradex/apalis_imx6/apalis_imx6.c
> +++ b/board/toradex/apalis_imx6/apalis_imx6.c
> @@ -1121,6 +1121,16 @@ void board_init_f(ulong dummy)
>   board_init_r(NULL, 0);
>  }
> 
> +#ifdef CONFIG_SPL_LOAD_FIT
> +int board_fit_config_name_match(const char *name) {
> + if (!strcmp(name, "imx6-apalis"))
> + return 0;
> +
> + return -1;
> +}
> +#endif
> +
>  void reset_cpu(ulong addr)
>  {
>  }

Reviewed-by: Peng Fan 

> --
> 2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/5] doc: rockchip: use idbloader.img for rk3288

2019-09-02 Thread Kever Yang

Hi Matwey,

    Could you merge patch 2/3/5 into one patch? I think they are the 
one update for


the same reason, no need to split into 3 patches.


Thanks,

- Kever

On 2019/8/24 上午1:29, Matwey V. Kornilov wrote:

Makefile now produces ready-to-deploy idbloader.img file.

Signed-off-by: Matwey V. Kornilov 
---
  doc/README.rockchip | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/doc/README.rockchip b/doc/README.rockchip
index 7d4dc1b33b..6e58cfde49 100644
--- a/doc/README.rockchip
+++ b/doc/README.rockchip
@@ -276,9 +276,7 @@ As of now TPL is added on Vyasa-RK3288 board.
  
  To write an image that boots from an SD card (assumed to be /dev/mmcblk0):
  
-   ./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out &&

-cat ./spl/u-boot-spl-dtb.bin >> out &&
-sudo dd if=out of=/dev/mmcblk0 seek=64 &&
+sudo dd if=idbloader.img of=/dev/mmcblk0 seek=64 &&
  sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 seek=16384
  
  Booting from an SD card on RK3188



___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] spl: imx: only use HAB if spl fit signature is not enabled

2019-09-02 Thread Peng Fan
> Subject: [PATCH] spl: imx: only use HAB if spl fit signature is not enabled
> 
> There is no need to use HAB for FIT signature validation when
> SPL_FIT_SIGNATURE is also enabled, as that will be validated via the normal
> U-Boot signed FIT image flow.
> 
> This allows having SPL validated by HAB and the payloads to follow being
> validated with FIT signatures only.
> 
> Signed-off-by: Ricardo Salveti 
> ---
>  arch/arm/mach-imx/spl.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c index
> 1f230aca33..a98fab8f1c 100644
> --- a/arch/arm/mach-imx/spl.c
> +++ b/arch/arm/mach-imx/spl.c
> @@ -261,6 +261,7 @@ __weak void __noreturn
> jump_to_image_no_args(struct spl_image_info *spl_image)
>   }
>  }
> 
> +#if !defined(CONFIG_SPL_FIT_SIGNATURE)
>  ulong board_spl_fit_size_align(ulong size)  {
>   /*
> @@ -285,6 +286,7 @@ void board_spl_fit_post_load(ulong load_addr, size_t
> length)
>   hang();
>   }
>  }
> +#endif
> 
>  #endif

Reviewed-by: Peng Fan 

> 
> --
> 2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] apalis_imx6: fix broken fsl_esdhc_imx conversion

2019-09-02 Thread Peng Fan
> Subject: [PATCH] apalis_imx6: fix broken fsl_esdhc_imx conversion
> 
> Commit e37ac717d796 ("Convert to use fsl_esdhc_imx for i.MX platforms")
> converted FSL_ESDHC to FSL_ESDHC_IMX, but the config check for
> apalis_imx6 wasn't updated accordantly.
> 
> Signed-off-by: Ricardo Salveti 
> ---
>  board/toradex/apalis_imx6/apalis_imx6.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/board/toradex/apalis_imx6/apalis_imx6.c
> b/board/toradex/apalis_imx6/apalis_imx6.c
> index ef668fcedc..89680da53f 100644
> --- a/board/toradex/apalis_imx6/apalis_imx6.c
> +++ b/board/toradex/apalis_imx6/apalis_imx6.c
> @@ -93,7 +93,7 @@ iomux_v3_cfg_t const uart1_pads_dte[] = {
>   MX6_PAD_CSI0_DAT11__UART1_TX_DATA |
> MUX_PAD_CTRL(UART_PAD_CTRL),  };
> 
> -#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
> +#if defined(CONFIG_FSL_ESDHC_IMX) && defined(CONFIG_SPL_BUILD)
>  /* Apalis MMC1 */
>  iomux_v3_cfg_t const usdhc1_pads[] = {
>   MX6_PAD_SD1_CLK__SD1_CLK   |
> MUX_PAD_CTRL(USDHC_PAD_CTRL),
> @@ -290,7 +290,7 @@ int board_ehci_hcd_init(int port)  }  #endif
> 
> -#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
> +#if defined(CONFIG_FSL_ESDHC_IMX) && defined(CONFIG_SPL_BUILD)
>  /* use the following sequence: eMMC, MMC1, SD1 */  struct fsl_esdhc_cfg
> usdhc_cfg[CONFIG_SYS_FSL_USDHC_NUM] = {
>   {USDHC3_BASE_ADDR},

Reviewed-by: Peng Fan 

> --
> 2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/5] rockchip, Makefile: add idbloader.img target【请注意,邮件由u-boot-boun...@lists.denx.de代发】

2019-09-02 Thread Kever Yang

Hi Matwey,


On 2019/8/24 上午1:29, Matwey V. Kornilov wrote:

Many Rockchip platforms require the same u-boot deploy procedure
when TPL and SPL both enabled.

The following examples are taken from doc/README.rockchip
and board/theobroma-systems/lion_rk3368/README:

RK3288:

   ./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out
   cat ./spl/u-boot-spl-dtb.bin >> out
   sudo dd if=out of=/dev/mmcblk0 seek=64

RK3328:

   ./tools/mkimage -n rk3328 -T rksd -d ./tpl/u-boot-tpl.bin idbloader.img
   cat ./spl/u-boot-spl.bin >> idbloader.img
   sudo dd if=idbloader.img of=/dev/mmcblk0 seek=64

RK3368:

   ./tools/mkimage -n rk3368 -T rksd -d tpl/u-boot-tpl.bin spl-3368.img
   cat spl/u-boot-spl-dtb.bin >> spl-3368.img
   dd if=spl-3368.img of=/dev/sdb seek=64

RK3399:

   ./tools/mkimage -n rk3399 -T rksd -d ./tpl/u-boot-tpl-dtb.bin out
   cat ./spl/u-boot-spl-dtb.bin >> out
   sudo dd if=out of=/dev/sdc seek=64

Here, we introduce generic idbloader.img target
which is the TPL image followed by the SPL binary.

Signed-off-by: Matwey V. Kornilov 



Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  Makefile | 12 
  1 file changed, 12 insertions(+)

diff --git a/Makefile b/Makefile
index 3b0864ae8e..eb12af9364 100644
--- a/Makefile
+++ b/Makefile
@@ -882,6 +882,10 @@ ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy)
  ALL-y += u-boot-with-dtb.bin
  endif
  
+ifeq ($(CONFIG_ARCH_ROCKCHIP)$(CONFIG_SPL)$(CONFIG_TPL),yyy)

+ALL-y += idbloader.img
+endif
+
  LDFLAGS_u-boot += $(LDFLAGS_FINAL)
  
  # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.

@@ -1293,6 +1297,14 @@ OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \
  u-boot-with-spl.bin: $(SPL_IMAGE) $(SPL_PAYLOAD) FORCE
$(call if_changed,pad_cat)
  
+ifeq ($(CONFIG_ARCH_ROCKCHIP),y)

+MKIMAGEFLAGS_u-boot-tpl.img = -n $(CONFIG_SYS_SOC) -T rksd
+tpl/u-boot-tpl.img: tpl/u-boot-tpl.bin FORCE
+   $(call if_changed,mkimage)
+idbloader.img: tpl/u-boot-tpl.img spl/u-boot-spl.bin FORCE
+   $(call if_changed,cat)
+endif
+
  ifeq ($(CONFIG_ARCH_LPC32XX)$(CONFIG_SPL),yy)
  MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE)
  



___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Pull request: u-boot-riscv/master

2019-09-02 Thread uboot
Hi Tom,

Please pull some riscv updates:

- Skip unavailable hart in the get_count().
- fu540 set serial env from otp.
- fu540 add mmc0 as a boot target device.
- Update fix_rela_dyn and add absolute reloc addend.
- Andestech PLIC driver will skip unavailable hart.
- Support Andestech V5L2 cache driver.

https://travis-ci.org/rickchen36/u-boot-riscv/builds/579707002

Thanks
Rick


The following changes since commit d22c8be964a870f59d2fdab6c67cefa0c4799364:

  Merge branch 'master' of git://git.denx.de/u-boot-sh (2019-09-01 13:33:12 
-0400)

are available in the Git repository at:

  g...@gitlab.denx.de:u-boot/custodians/u-boot-riscv.git

for you to fetch changes up to 61ce84b2cf1a6672c8e402ce8174554b25629692:

  riscv: cache: use CCTL to flush d-cache (2019-09-03 09:31:03 +0800)


Alistair Francis (1):
  sifive-fu540: config: Add mmc0 as a boot target device

Bin Meng (1):
  riscv: cpu: Skip unavailable hart in the get_count() op

Marcus Comstedt (2):
  riscv: tools: Handle addend to absolute reloc in prelink-riscv
  riscv: update fix_rela_dyn

Rick Chen (9):
  riscv: andes_plic: init plic by scanning each cpu node
  dm: cache: Add enable and disable ops for cache uclass
  dm: cache: Add enable and disable ops for sandbox and test
  dm: cache: add v5l2 cache controller driver
  riscv: ae350: use the v5l2 driver to configure the cache
  riscv: ax25: add imply v5l2 cache controller
  riscv: cache: Flush L2 cache before jump to linux
  riscv: dts: move out AE350 L2 node from cpus node
  riscv: cache: use CCTL to flush d-cache

Sagar Shrikant Kadam (1):
  riscv: sifive: fu540: set serial environment variable from otp

 arch/riscv/cpu/ax25/Kconfig |   1 +
 arch/riscv/cpu/ax25/cache.c |  39 +--
 arch/riscv/cpu/start.S  |  10 +++---
 arch/riscv/dts/ae350_32.dts |  17 ++
 arch/riscv/dts/ae350_64.dts |  17 ++
 arch/riscv/lib/andes_plic.c |  36 ++---
 board/AndesTech/ax25-ae350/ax25-ae350.c |   9 ++
 board/sifive/fu540/fu540.c  |  18 ---
 drivers/cache/Kconfig   |   9 ++
 drivers/cache/Makefile  |   1 +
 drivers/cache/cache-uclass.c|  20 
 drivers/cache/cache-v5l2.c  | 186 
+
 drivers/cache/sandbox_cache.c   |  13 
 drivers/cpu/riscv_cpu.c |   4 +++
 include/cache.h |  31 +++
 include/configs/sifive-fu540.h  |   1 +
 test/dm/cache.c |   2 ++
 tools/prelink-riscv.inc |   8 +++--
 18 files changed, 379 insertions(+), 43 deletions(-)
 create mode 100644 drivers/cache/cache-v5l2.c
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 0/3] Support distro boot in pico-imx7d BL33 case

2019-09-02 Thread Peng Fan
Hi Jun,

> Subject: Re: [PATCH 0/3] Support distro boot in pico-imx7d BL33 case
> 
> Jun Nie  于2019年8月8日周四 下午12:04写道:
> >
> > Jun Nie  于2019年7月16日周二 下午3:43写道:
> > >
> > > Support distro boot in pico-imx7d BL33 case with changing the
> > > enviroment variables. While the other two patches are for polishing
> > > clock code and for feature enablement.
> > >
> > > Jun Nie (3):
> > >   pico-imx7d: add config to enable CAAM
> > >   pico-imx7d: Support distro boot for FIT image case
> > >   pico-imx7d: polish uart clock id definition
> > >
> > >  arch/arm/include/asm/arch-mx7/clock.h | 18 +
> > >  configs/pico-imx7d_bl33_defconfig |  1 +
> > >  include/configs/pico-imx7d.h  | 37
> +++
> > >  3 files changed, 13 insertions(+), 43 deletions(-)
> > >
> > > --
> >
> > Hi Vanessa,
> >
> > Do you have any comments on these 3 patches? Or we can merge it now?
> Thanks!
> >
> > Best Regards
> > Jun
> 
> Hi,
> 
> Does anyone has comments on these patches? Maybe we can merge them as
> no comments for a long time. Thanks!

I could merge this patchset into nxp-imx and send pull request to Stefano, if 
you
are fine with that.

Regards,
Peng. 

> 
> Regards,
> Jun
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3] imx: support i.MX8QM ROM 7720 a1 board

2019-09-02 Thread Peng Fan
> Subject: Re: [PATCH v3] imx: support i.MX8QM ROM 7720 a1 board
> 
> On 02/09/19, Peng Fan wrote:
> > > Subject: [PATCH v3] imx: support i.MX8QM ROM 7720 a1 board
> > >
> > > +echo "ATF_LOAD_ADDR=$ATF_LOAD_ADDR" >&2 echo
> > > +"BL33_LOAD_ADDR=$BL33_LOAD_ADDR" >&2
> > > +
> >
> > This is no needed.
> >
> 
> ok I`ll remove it
> 
> > > +config SYS_VENDOR
> > > + default "freescale"
> >
> > This board is not from nxp(freescale). Please correct vendor.
> 
> yes vendor is advantech, I'll change that in next version Then I need to move
> all files into the board/advantech folder?

Yes, please.

> >
> > > +Copy the following binaries to iMX8QM folder:
> > > +
> > > +$ cp imx-atf/build/imx8qm/release/bl31.bin .
> > > +$ cp u-boot/u-boot.bin .
> > > +
> > > +Copy the following firmwares U-Boot folder :
> > > +
> > > +$ cp firmware-imx-8.0/firmware/seco/mx8qm-ahab-container.img .
> > > +$ cp imx-sc-firmware-1.1/mx8qm-val-scfw-tcm.bin scfw_tcm.bin
> > > +
> > > +$ make SOC=iMX8QM flash_linux_m4
> >
> > flash_linux_m4 is not a valid build target in U-Boot.
> 
> yes indeed but this is the build target in the imx-mkimage repo. Which I
> currently need to build the complete bootstream with ATF and scu.

flash_linux_m4 is imx-mkimage target, not U-Boot target.
U-Boot already mkimage already has i.MX8QM support.

> 
> > > SC_PM_PW_MODE_ON);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + ret = sc_pm_set_clock_rate(-1, SC_R_UART_0, 2, );
> > > + if (ret)
> > > + return ret;
> > > +
> > > + /* Enable UART0 clock root */
> > > + ret = sc_pm_clock_enable(-1, SC_R_UART_0, 2, true, false);
> > > + if (ret)
> > > + return ret;
> >
> > Please use sc_pm_setup_uart
> 
> ok
> >
> > > +
> > > + setup_iomux_uart();
> > > +
> > > + sc_pm_set_resource_power_mode(-1, SC_R_DC_0,
> > > SC_PM_PW_MODE_ON);
> >
> > Why power up DC_0? Should not kernel do it by itself?
> 
> Without this change the kernel is stucked during the boot. So currently the
> kernel don't power up DC_0. So I would like to keep that until it is fixed in 
> the
> kernel.

Then, please add a comment here.

> 
> >
> > > +#if IS_ENABLED(CONFIG_DM_GPIO)
> > > +static void board_gpio_init(void)
> > > +{
> > > + /* TODO */
> > > +}
> > > +#else
> > > +static inline void board_gpio_init(void) {} #endif
> >
> > If do nothing, please drop.
> 
> ok
> >
> > > +
> > > +#if IS_ENABLED(CONFIG_FEC_MXC)
> > > +#include 
> > > +
> > > +int board_phy_config(struct phy_device *phydev) { #ifdef
> > > +CONFIG_FEC_ENABLE_MAX7322
> > > + u8 value;
> > > +
> > > + /* This is needed to drive the pads to 1.8V instead of 1.5V */
> > > + i2c_set_bus_num(CONFIG_MAX7322_I2C_BUS);
> > > +
> > > + if (!i2c_probe(CONFIG_MAX7322_I2C_ADDR)) {
> > > + /* Write 0x1 to enable O0 output, this device has no addr */
> > > + /* hence addr length is 0 */
> > > + value = 0x1;
> > > + if (i2c_write(CONFIG_MAX7322_I2C_ADDR, 0, 0, , 1))
> > > + printf("MAX7322 write failed\n");
> > > + } else {
> > > + printf("MAX7322 Not found\n");
> > > + }
> > > + mdelay(1);
> >
> > Please use DM_I2C.
> 
> I don't get what you mean here.

Enable CONFIG_DM_I2C and use dm_i2c_x api.

> 
> > > +#ifdef CONFIG_OF_BOARD_SETUP
> > > +int ft_board_setup(void *blob, bd_t *bd) {
> > > + return 0;
> > > +}
> > > +#endif
> >
> > Drop it do nothing.
> 
> I got some linking erros if I try to remove that ft_board_setup.

Drop CONFIG_OF_BOARD_SETUP if you not need it.

> 
> > > +int board_mmc_getcd(struct mmc *mmc) {
> > > + struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
> > > + int ret = 0;
> > > +
> > > + switch (cfg->esdhc_base) {
> > > + case USDHC1_BASE_ADDR:
> > > + ret = 1;
> > > + break;
> > > + case USDHC2_BASE_ADDR:
> > > + ret = !gpio_get_value(USDHC1_CD_GPIO);
> > > + break;
> > > + case USDHC3_BASE_ADDR:
> > > + ret = !gpio_get_value(USDHC2_CD_GPIO);
> > > + break;
> > > + }
> > > +
> > > + return ret;
> > > +}
> >
> > SPL_DM_MMC should help.
> 
> you mean I should turn on CONFIG_SPL_DM_MMC=y ?

Yes.

> >
> > > +
> > > +#endif /* CONFIG_FSL_ESDHC */
> > > +
> > > +void spl_dram_init(void)
> > > +{
> > > + /* do nothing for now */
> > > +}
> >
> > Drop
> >
> > > +CONFIG_SYS_MALLOC_F_LEN=0x4000
> >
> > This might not large enough, check how i.MX8QM MEK does in upstream.

Sorry. 0x4000 is ok.

> 
> should I use CONFIG_SYS_MALLOC_F_LEN=0x2000 ?
> 
> > > +CONFIG_DM_PCA953X=y
> > > +CONFIG_DM_I2C=y
> > > +CONFIG_SYS_I2C_IMX_LPI2C=y
> > > +CONFIG_I2C_MUX=y
> > > +CONFIG_I2C_MUX_PCA954x=y
> > > +CONFIG_MISC=y
> > > +CONFIG_DM_MMC=y
> > > +CONFIG_FSL_ESDHC_IMX=y
> > > +CONFIG_PHYLIB=y
> > > +CONFIG_PHY_ADDR_ENABLE=y
> > > +CONFIG_PHY_ATHEROS=y
> > > +CONFIG_DM_ETH=y
> > > +CONFIG_PHY_GIGE=y
> > > +CONFIG_FEC_MXC_SHARE_MDIO=y
> > > +CONFIG_FEC_MXC_MDIO_BASE=0x5B04
> > > +CONFIG_FEC_MXC=y
> > > +CONFIG_MII=y
> > > +CONFIG_PINCTRL=y
> > > +CONFIG_SPL_PINCTRL=y
> > > +CONFIG_PINCTRL_IMX8=y
> > > 

Re: [U-Boot] [PATCH] rpi3: Enable verified boot from FIT image

2019-09-02 Thread AKASHI Takahiro
On Mon, Sep 02, 2019 at 01:19:06PM +0200, Heinrich Schuchardt wrote:
> On 9/2/19 12:30 PM, Matthias Brugger wrote:
> >+Alex, Lukas, Heinrich, Bin and Simon
> >
> >On 31/07/2019 10:16, Jun Nie wrote:
> >>Matthias Brugger  于2019年7月31日周三 下午4:05写道:
> >>>
> >>>
> >>>
> >>>On 11/07/2019 05:55, Jun Nie wrote:
> Enable verified boot from FIT image with select configs
> and specify boot script image node in FIT image, the FIT
> image is verified before it is run.
> 
> Code that reusing dtb in firmware is disabled, so that
> the dtb with pubic key packed in u-boot.bin can be used
> to verify the signature of next stage FIT image.
> 
> Signed-off-by: Jun Nie 
> ---
>   board/raspberrypi/rpi/rpi.c |  6 ++
>   include/configs/rpi.h   | 15 ++-
>   2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> index 617c892..950ee84 100644
> --- a/board/raspberrypi/rpi/rpi.c
> +++ b/board/raspberrypi/rpi/rpi.c
> @@ -297,6 +297,7 @@ static void set_fdtfile(void)
>    env_set("fdtfile", fdtfile);
>   }
> 
> +#ifndef CONFIG_FIT_SIGNATURE
>   /*
>    * If the firmware provided a valid FDT at boot time, let's expose it in
>    * ${fdt_addr} so it may be passed unmodified to the kernel.
> @@ -311,6 +312,7 @@ static void set_fdt_addr(void)
> 
>    env_set_hex("fdt_addr", fw_dtb_pointer);
>   }
> +#endif
> 
>   /*
>    * Prevent relocation from stomping on a firmware provided FDT blob.
> @@ -393,7 +395,9 @@ static void set_serial_number(void)
> 
>   int misc_init_r(void)
>   {
> +#ifndef CONFIG_FIT_SIGNATURE
>    set_fdt_addr();
> +#endif
>    set_fdtfile();
>    set_usbethaddr();
>   #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
> @@ -470,6 +474,7 @@ int board_init(void)
>    return bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
>   }
> 
> +#ifndef CONFIG_FIT_SIGNATURE
>   /*
>    * If the firmware passed a device tree use it for U-Boot.
>    */
> @@ -479,6 +484,7 @@ void *board_fdt_blob_setup(void)
>    return NULL;
>    return (void *)fw_dtb_pointer;
>   }
> +#endif
> >>>
> >>>Just to get this clear we need this because we want to pass the device 
> >>>tree via
> >>>OF_SEPARATE, correct?
> >>
> >>You are right.  U-boot need to read he signature from dtb.
> >>
> >>>
> 
>   int ft_board_setup(void *blob, bd_t *bd)
>   {
> diff --git a/include/configs/rpi.h b/include/configs/rpi.h
> index f76c7d1..ba91205 100644
> --- a/include/configs/rpi.h
> +++ b/include/configs/rpi.h
> @@ -180,11 +180,24 @@
> 
>   #include 
> 
> +#ifdef CONFIG_FIT_SIGNATURE
> +#define FIT_BOOT_CMD \
> + "boot_a_script="\
> + "load ${devtype} ${devnum}:${distro_bootpart} " \
> + "${scriptaddr} ${prefix}${script}; "\
> + "iminfo ${scriptaddr};" \
> + "if test $? -eq 1; then reset; fi;" \
> + "source ${scriptaddr}:bootscr\0"
> +#else
> +#define FIT_BOOT_CMD ""
> +#endif
> +
> >>>
> >>>Doesn't this overwrite the boot_a_script in distro_bootcmd?
> >>>
> >>>Would it make sense to add FIT booting to the distro boot command?
> >>>
> >>>Regards,
> >>>Matthias
> >>
> >>Yes, it overwrite the boot_a_script in distro_bootcmd. It is make
> >>sense to add this to the distro boot command. I can send another patch
> >>to move these lines to common code later.
> >>
> >
> >Question to the people just added, as you have relevant submission to
> >distroboot. Do you think it makes sense to add FIT_BOOT_CMD to that?
> >
> >Regards,
> >Matthias
> 
> The idea of distro-boot was to make it easier for Linux distributions to
> update the information needed by U-Boot to find the right kernel and
> ramdisk.
> 
> According to doc/README.distro file extlinux.conf should be used for the
> communication between the distribution and U-Boot. Some distributions
> like Debian still rely on boot.scr.
> 
> Many distributions (OpenBSD, FreeBSD, Suse, Fedora) have moved from
> distro-boot to UEFI as booting standard. Unfortunately we have not
> documented our support for this in doc/README.distro (TODO for me).
> Takahiro is working on secure boot using UEFI. Once completed this could
> obsolete FIT images.

Well, UEFI secure boot handles PE(+) images and doesn't cover
dtb, initrd or whatever FIT may contain.

-Takahiro Akashi


> Would we expect Linux distributions to provide FIT images upon kernel
> updates?
> Is there any Linux distribution doing so?
> 
> Only if we can answer these questions with yes, adding 

Re: [U-Boot] [PATCH 1/1] net: nfs: remove superfluous packed attribute

2019-09-02 Thread Bin Meng
On Tue, Sep 3, 2019 at 6:05 AM Heinrich Schuchardt  wrote:
>
> With GCC 9.2.1 net/nfs.c leads to multiple errors of type
> address-of-packed-member.
>
> net/nfs.c: In function ‘rpc_req’:
> net/nfs.c:199:18: error: taking address of packed member of
> ‘struct rpc_t’ may result in an unaligned pointer value
> [-Werror=address-of-packed-member]
>   199 |  p = (uint32_t *)&(rpc_pkt.u.call.data);
>   |  ^~
> net/nfs.c: In function ‘nfs_readlink_reply’:
> net/nfs.c:631:46: error: taking address of packed member of
> ‘struct rpc_t’ may result in an unaligned pointer value
> [-Werror=address-of-packed-member]
>   631 |nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
>   |   ~~~^
>   LD  drivers/block/built-in.o
> net/nfs.c: In function ‘nfs_read_reply’:
> net/nfs.c:692:46: error: taking address of packed member of
> ‘struct rpc_t’ may result in an unaligned pointer value
> [-Werror=address-of-packed-member]
>   692 |nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
>   |   ~~~^
>
> struct rpc_t is only used as local variable. It is naturally packed. So
> there is no need for the attribute packed.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  net/nfs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] net: nfs: remove superfluous conversions

2019-09-02 Thread Bin Meng
On Tue, Sep 3, 2019 at 5:55 AM Heinrich Schuchardt  wrote:
>
> rpc_pkt.u.call.data is an array of uint32_t. There is no need to convert
> it to uint32_t *.
>
> memcpy() expects void * as it 1st and 2nd argument. There is no point in
> converting pointers to char * before passing them to memcpy().
>
> In ntohl(data[1]) != 0 calling ntohl() is superfluous. If the value is
> zero, does not depend on the byte order.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  net/nfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>

Reviewed-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] apalis_imx6: add board_fit_config_name_match to support FIT in SPL

2019-09-02 Thread Ricardo Salveti
Only one dtb is currently supported, so match with imx6-apalis.

Signed-off-by: Ricardo Salveti 
---
 board/toradex/apalis_imx6/apalis_imx6.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index fa7fcc8d46..ef668fcedc 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -1121,6 +1121,16 @@ void board_init_f(ulong dummy)
board_init_r(NULL, 0);
 }
 
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+   if (!strcmp(name, "imx6-apalis"))
+   return 0;
+
+   return -1;
+}
+#endif
+
 void reset_cpu(ulong addr)
 {
 }
-- 
2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] apalis_imx6: allocate specific region of memory to OP-TEE

2019-09-02 Thread Ricardo Salveti
OP-TEE uses the memory region defined by the maximum DRAM address minus
CONFIG_OPTEE_TZDRAM_SIZE, so subtract CONFIG_OPTEE_TZDRAM_SIZE from the
available DRAM size to avoid conflicts.

Signed-off-by: Ricardo Salveti 
---
 board/toradex/apalis_imx6/apalis_imx6.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 6421a22c25..fa7fcc8d46 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -75,6 +75,11 @@ int dram_init(void)
gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
(ulong)imx_ddr_size());
 
+   /* Subtract the defined OPTEE runtime firmware length */
+#ifdef CONFIG_OPTEE_TZDRAM_SIZE
+   gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE;
+#endif
+
return 0;
 }
 
-- 
2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] imx: apalis_imx6: select MX6Q via Kconfig

2019-09-02 Thread Ricardo Salveti
Toradex Apalis iMX6 modules are available in the iMX6D and iMX6Q
variants, which are quite similar and already managed via only one
dtb in u-boot (imx6-apalis.dtb). Select MX6Q via Kconfig by default in
order to automatically enable the HAS_CAAM and MX6_SMP features.

Signed-off-by: Ricardo Salveti 
---
 arch/arm/mach-imx/mx6/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
index 9c27176ba0..36e1c98fb5 100644
--- a/arch/arm/mach-imx/mx6/Kconfig
+++ b/arch/arm/mach-imx/mx6/Kconfig
@@ -117,6 +117,7 @@ config TARGET_ADVANTECH_DMS_BA16
 config TARGET_APALIS_IMX6
bool "Toradex Apalis iMX6 board"
select BOARD_LATE_INIT
+   select MX6Q
select DM
select DM_SERIAL
select DM_THERMAL
-- 
2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] spl: imx: only use HAB if spl fit signature is not enabled

2019-09-02 Thread Ricardo Salveti
There is no need to use HAB for FIT signature validation when
SPL_FIT_SIGNATURE is also enabled, as that will be validated via the
normal U-Boot signed FIT image flow.

This allows having SPL validated by HAB and the payloads to follow
being validated with FIT signatures only.

Signed-off-by: Ricardo Salveti 
---
 arch/arm/mach-imx/spl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 1f230aca33..a98fab8f1c 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -261,6 +261,7 @@ __weak void __noreturn jump_to_image_no_args(struct 
spl_image_info *spl_image)
}
 }
 
+#if !defined(CONFIG_SPL_FIT_SIGNATURE)
 ulong board_spl_fit_size_align(ulong size)
 {
/*
@@ -285,6 +286,7 @@ void board_spl_fit_post_load(ulong load_addr, size_t length)
hang();
}
 }
+#endif
 
 #endif
 
-- 
2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] apalis_imx6: fix broken fsl_esdhc_imx conversion

2019-09-02 Thread Ricardo Salveti
Commit e37ac717d796 ("Convert to use fsl_esdhc_imx for i.MX platforms")
converted FSL_ESDHC to FSL_ESDHC_IMX, but the config check for
apalis_imx6 wasn't updated accordantly.

Signed-off-by: Ricardo Salveti 
---
 board/toradex/apalis_imx6/apalis_imx6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index ef668fcedc..89680da53f 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -93,7 +93,7 @@ iomux_v3_cfg_t const uart1_pads_dte[] = {
MX6_PAD_CSI0_DAT11__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
-#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_FSL_ESDHC_IMX) && defined(CONFIG_SPL_BUILD)
 /* Apalis MMC1 */
 iomux_v3_cfg_t const usdhc1_pads[] = {
MX6_PAD_SD1_CLK__SD1_CLK   | MUX_PAD_CTRL(USDHC_PAD_CTRL),
@@ -290,7 +290,7 @@ int board_ehci_hcd_init(int port)
 }
 #endif
 
-#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_FSL_ESDHC_IMX) && defined(CONFIG_SPL_BUILD)
 /* use the following sequence: eMMC, MMC1, SD1 */
 struct fsl_esdhc_cfg usdhc_cfg[CONFIG_SYS_FSL_USDHC_NUM] = {
{USDHC3_BASE_ADDR},
-- 
2.23.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/1] net: nfs: remove superfluous packed attribute

2019-09-02 Thread Heinrich Schuchardt
With GCC 9.2.1 net/nfs.c leads to multiple errors of type
address-of-packed-member.

net/nfs.c: In function ‘rpc_req’:
net/nfs.c:199:18: error: taking address of packed member of
‘struct rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  199 |  p = (uint32_t *)&(rpc_pkt.u.call.data);
  |  ^~
net/nfs.c: In function ‘nfs_readlink_reply’:
net/nfs.c:631:46: error: taking address of packed member of
‘struct rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  631 |nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
  |   ~~~^
  LD  drivers/block/built-in.o
net/nfs.c: In function ‘nfs_read_reply’:
net/nfs.c:692:46: error: taking address of packed member of
‘struct rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  692 |nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
  |   ~~~^

struct rpc_t is only used as local variable. It is naturally packed. So
there is no need for the attribute packed.

Signed-off-by: Heinrich Schuchardt 
---
 net/nfs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/nfs.h b/net/nfs.h
index a377c90088..68ada0efeb 100644
--- a/net/nfs.h
+++ b/net/nfs.h
@@ -78,7 +78,7 @@ struct rpc_t {
NFS_MAX_ATTRS];
} reply;
} u;
-} __attribute__((packed));
+};
 void nfs_start(void);  /* Begin NFS */


--
2.23.0.rc1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/1] net: nfs: remove superfluous conversions

2019-09-02 Thread Heinrich Schuchardt
rpc_pkt.u.call.data is an array of uint32_t. There is no need to convert
it to uint32_t *.

memcpy() expects void * as it 1st and 2nd argument. There is no point in
converting pointers to char * before passing them to memcpy().

In ntohl(data[1]) != 0 calling ntohl() is superfluous. If the value is
zero, does not depend on the byte order.

Signed-off-by: Heinrich Schuchardt 
---
 net/nfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/nfs.c b/net/nfs.c
index d6a7f8e827..105f990360 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -196,10 +196,10 @@ static void rpc_req(int rpc_prog, int rpc_proc, uint32_t 
*data, int datalen)
rpc_pkt.u.call.vers = htonl(2); /* portmapper is version 2 */
}
rpc_pkt.u.call.proc = htonl(rpc_proc);
-   p = (uint32_t *)&(rpc_pkt.u.call.data);
+   p = rpc_pkt.u.call.data;

if (datalen)
-   memcpy((char *)p, (char *)data, datalen*sizeof(uint32_t));
+   memcpy(p, data, datalen * sizeof(uint32_t));

pktlen = (char *)p + datalen * sizeof(uint32_t) - (char *)_pkt;

@@ -579,7 +579,7 @@ static int nfs_lookup_reply(uchar *pkt, unsigned len)

 static int nfs3_get_attributes_offset(uint32_t *data)
 {
-   if (ntohl(data[1]) != 0) {
+   if (data[1]) {
/* 'attributes_follow' flag is TRUE,
 * so we have attributes on 21 dwords */
/* Skip unused values :
--
2.23.0.rc1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [BUG] net: nfs: -Werror=address-of-packed-member

2019-09-02 Thread Heinrich Schuchardt

Hello Joe,

GCC 9.2.1 (of Debian Bullseye) produces the warnings below when building
pine64-lts_defconfig. Is it really necessary to define struct rpc_t as
packed? The structure is composed out of uint32_t only. So shouldn't it
be naturally packed without the attribute?

net/nfs.c: In function ‘rpc_req’:
net/nfs.c:199:18: error: taking address of packed member of ‘struct
rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  199 |  p = (uint32_t *)&(rpc_pkt.u.call.data);
  |  ^~
net/nfs.c: In function ‘nfs_readlink_reply’:
net/nfs.c:631:46: error: taking address of packed member of ‘struct
rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  631 |nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
  |   ~~~^
  LD  drivers/block/built-in.o
net/nfs.c: In function ‘nfs_read_reply’:
net/nfs.c:692:46: error: taking address of packed member of ‘struct
rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  692 |nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
  |   ~~~^

Best regards

Heinrich
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [EXT] Re: [RFC/RESEND 01/22] arm: introduce ARCH_THUNDERX

2019-09-02 Thread Matthias Brugger
Hi Suneel,

On 27/08/2019 02:59, Chandrakala Chavva wrote:
> Tim,
> 
> It was scheduled to post the patches on August 15th, it got delayed as Suneel 
> got sick, he will post in 2 weeks.
> 

Hope you are fine again. Do you have an update about the patches?

Best regards,
Matthias

> Chandra
> 
> From: Tim Harvey 
> Sent: Monday, August 26, 2019 10:54:34 AM
> To: Suneel Garapati 
> Cc: Matthias Brugger ; Chandrakala Chavva 
> ; prasun.kap...@cavium.com ; 
> Sergey Temerkhanov ; u-boot ; 
> chandrakala.cha...@cavium.com ; Zi Shen Lim 
> ; Maen Suleiman ; Aaron Williams 
> ; Chris Packham 
> Subject: [EXT] Re: [U-Boot] [RFC/RESEND 01/22] arm: introduce ARCH_THUNDERX
> 
> External Email
> 
> --
> On Wed, Jul 31, 2019 at 5:32 PM Suneel Garapati  
> wrote:
>>
>> Hi Matthias,
>>
>> Hard deadline is Aug 15th, so you should see first series before that.
>>
> 
> Suneel,
> 
> Update? I'm really wishing my patches posted last March were
> considered instead of all of this waiting.
> 
> Regards,
> 
> Tim
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Using CONFIG_ENV_FLAGS_LIST

2019-09-02 Thread Claudius Heine
Hi,

I am currently looking into variable flags in order to make some
variables read-only for secure boot.

The idea is that the u-boot binary is signed, while the environment
file/partition is not. So the built-in default environment of u-boot can
be trusted, while the external environment cannot. The assumption is
that those flags can be used to customize the validation when the
external environment is loaded or scripts/commands are executed.

From the '/README' I gather that the access attributes can be any of
"any", "read-only", "write-once" or "change-default".

I first tried to restrict the variables by choosing 'read-only', but
apparently this applies to the internal environment as well, and now
those variables are not loaded from the internal environment.

Then I tried 'write-once', this worked now as expected from within
u-boot, but I could modify the environment from the linux userspace via
fw_setenv and those changes appear in u-boot as well. The same for
'change-default'.

Is there another way to fill the internal environment variable hash
table, so that 'read-only' works as expected?

Heiko wrote some patches that change the behavior of the environment
loading so that the internal environment is loaded first before the
external environment. This way 'write-once' should work as expected, but
I think 'read-only' should work that way already and we are missing
something here.

Thanks,
Claudius

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: c...@denx.de

   PGP key: 6FF2 E59F 00C6 BC28 31D8 64C1 1173 CB19 9808 B153
 Keyserver: hkp://pool.sks-keyservers.net



signature.asc
Description: OpenPGP digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: dw_mmc: fix timeout calculate method

2019-09-02 Thread Tom Rini
On Mon, Sep 02, 2019 at 12:24:42PM +, Alexey Brodkin wrote:
> Hi Kever,
> 
> > -Original Message-
> > From: Kever Yang 
> > Sent: Monday, September 2, 2019 11:05 AM
> > To: Alexey Brodkin 
> > Cc: tr...@konsulko.com; eugeniy.palt...@synopsys.com; Simon Glass 
> > ; Peng Fan
> > ; u-boot@lists.denx.de
> > Subject: Re: [PATCH] mmc: dw_mmc: fix timeout calculate method
> >
> > Hi Alexey,
> >
> > On 2019/8/30 下午9:28, Alexey Brodkin wrote:
> > > Hi Kever,
> > >
> > > [snip]
> > >
> > >> I think this tree does not including this patch, Peng drop it because of
> > >> this issue,
> > >> so you need to apply this patch in your branch to reproduce the problem.
> > >> I have send out V2 patch for this fix with only using 32bit variable
> > > Could you please refer me to the problematic patch so I may try it?
> >
> > This is the patch with problem, and here is the link on patchwork:
> > https://patchwork.ozlabs.org/patch/1146845/
> 
> Please find my fixes here:
> https://patchwork.ozlabs.org/patch/1156541/
> https://patchwork.ozlabs.org/patch/1156617/
> 
> Tom do we want https://patchwork.ozlabs.org/patch/1146845/ and fixes for it
> (see 2 items above) to become a part of upcoming v2019.10 release or
> it will be slated for the next one?

I think we should aim to get all the fixes in for this release.

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mx53loco: Fix U-Boot corruption after saving the environment

2019-09-02 Thread Fabio Estevam
Hi Tom,

On Fri, Aug 30, 2019 at 3:14 PM Tom Rini  wrote:

> Are there more i.mx platforms that are not setting BOARD_SIZE_LIMIT
> today?  I assume there are, sadly.  Can you audit and catch the rest of

Yes, only a very few i.MX boards set BOARD_SIZE_LIMIT currently.

> these likely problems, and add limits so we won't repeat this again.

Yes, I can audit this, but this task requires more time and I can do
that after 2019.10 is released.

Could this one that fixes mx53qsb be applied for 2019.10?

Thanks
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] U-Boot: Environment flags broken for U-Boot

2019-09-02 Thread Patrick DELAUNAY
Hi Heiko,


> From: Heiko Schocher 
> Sent: lundi 2 septembre 2019 16:03
> 
> Hello Patrick,
> 
> I am just testing U-Boot Environment flags and they do not work anymore with
> current mainline U-Boot ... I should have made some tbot test for it, but did 
> not
> found yet time for it ...
> 
> Here log with current mainline:
> 
> 
> => printenv heiko
> heiko=changed
> => env flags
> Available variable type flags (position 0):
>  FlagVariable Type Name
>  --
>  s   -   string
>  d   -   decimal
>  x   -   hexadecimal
>  b   -   boolean
>  i   -   IP address
>  m   -   MAC address
> 
> Available variable access flags (position 1):
>  FlagVariable Access Name
>  
>  a   -   any
>  r   -   read-only
>  o   -   write-once
>  c   -   change-default
> 
> Static flags:
>  Variable NameVariable TypeVariable Access
>  -----
>  eth\d*addr   MAC address  any
>  ipaddr   IP address   any
>  gatewayipIP address   any
>  netmask  IP address   any
>  serverip IP address   any
>  nvlandecimal  any
>  vlan decimal  any
>  dnsipIP address   any
>  heikostring   write-once
> 
> Active flags:
>  Variable NameVariable TypeVariable Access
>  -----
>  .flags   string   write-once
>  netmask  IP address   any
>  serverip IP address   any
>  heikostring   write-once
>  ipaddr   IP address   any
> => setenv heiko foo
> => print heiko
> heiko=foo
> => setenv heiko bar
> => print heiko
> heiko=bar
> 
> I can change Environment variable "heiko" but flag is write-once !
> 
> Ok, digging around and I found, that in env/common.c changed_ok is NULL which
> results in not checking U-Boot flags:
> 
>   26 struct hsearch_data env_htab = {
>   27 #if CONFIG_IS_ENABLED(ENV_SUPPORT)
>   28 /* defined in flags.c, only compile with ENV_SUPPORT */
>   29 .change_ok = env_flags_validate,
>   30 #endif
>   31 };
> 
> reason is your commit:
> 
> commit 7d4776545b0f8a8827e5d061206faf61c9ba6ea9
> Author: Patrick Delaunay 
> Date:   Thu Apr 18 17:32:49 2019 +0200
> 
>  env: solve compilation error in SPL
> 
>  Solve compilation issue when cli_simple.o is used in SPL
>  and CONFIG_SPL_ENV_SUPPORT is not defined.
> 
>  env/built-in.o:(.data.env_htab+0xc): undefined reference to 
> `env_flags_validate'
>  u-boot/scripts/Makefile.spl:384: recipe for target 'spl/u-boot-spl' 
> failed
>  make[2]: *** [spl/u-boot-spl] Error 1
>  u-boot/Makefile:1649: recipe for target 'spl/u-boot-spl' failed
>  make[1]: *** [spl/u-boot-spl] Error 2
> 
>  Signed-off-by: Patrick Delaunay 
> 
> 
> ENV_SUPPORT is only defined for SPL and TPL not for U-Boot, which leads in
> change_ok always NULL in U-Boot ...
> 
> :-(
> 
> reverting this commit and it works again as expected ...
> 
> Urgs ... since april 2019 nobody tested this feature
> 
> :-(
> 
> Nevertheless, reverting commit and I see:
> 
> => print heiko
> heiko=test
> => setenv heiko foo
> ## Error inserting "heiko" variable, errno=1 =>
> 
> So we should find a solution for this.
> 
> Any ideas?

Hi, 

Yes I am responsible of the regression, sorry.

When I see the definition CONFIG_SPL_ENV_SUPPORT and CONFIG_TPL_ENV_SUPPORT, I 
use the generic macro to check the activation of these TPL/SPL feature in the 
SPL/TPL builds
But I don't check the existence of the U-Boot flag CONFIG_ENV_SUPPORT when I 
propose my patch... so my patch is incorrect.

As flags.o is always compiled for U-Boot :

ifndef CONFIG_SPL_BUILD
obj-y += attr.o
obj-y += callback.o
obj-y += flags.o
...
else
obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += attr.o
obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += flags.o
obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += callback.o
endif


I see 2 solutions:

1/ change my patch to check U-boot compilation case with 
!defined(CONFIG_SPL_BUILD)

 26 struct hsearch_data env_htab = {
 27 #if !defined(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(ENV_SUPPORT)
 28 /* defined in flags.c, only compile with ENV_SUPPORT for SPL / TPL 
*/
 29 .change_ok = env_flags_validate,
 30 #endif
 31 };

2/ introduce a new Kconfig to env support in U-Boot

config ENV_SUPPORT
bool "Support an environment features"
default y
help
  Enable full environment support in U-Boot.
  Including attributes, callbacks 

Re: [U-Boot] [PATCH v2 1/2] dm: core: Add functions to read 64-bit dt properties

2019-09-02 Thread Bin Meng
On Mon, Sep 2, 2019 at 10:34 PM Michal Simek  wrote:
>
> From: T Karthik Reddy 
>
> This patch adds functions dev_read_u64_default & dev_read_u64
> to read unsigned 64-bit values from devicetree.
>
> Signed-off-by: T Karthik Reddy 
> Signed-off-by: Michal Simek 
> ---
>
> Changes in v2:
> - Moved newly added 64-bit funtion definations & prototypes below
>32-bit functions.
>
>  drivers/core/ofnode.c |  2 +-
>  drivers/core/read.c   | 10 ++
>  include/dm/ofnode.h   |  2 +-
>  include/dm/read.h | 33 +
>  4 files changed, 45 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] mmc: sdhci: Add support for dt caps & caps mask

2019-09-02 Thread Michal Simek
From: T Karthik Reddy 

The sdhci capabilities registers can be incorrect. The
sdhci-caps-mask and sdhci-caps dt properties specify which bits of
the registers are incorrect and what their values should be. This
patch makes the sdhci driver use those properties to correct the caps.
Also use "dev_read_u64_default" instead of "dev_read_u32_array" for
caps mask.

Signed-off-by: T Karthik Reddy 
Signed-off-by: Michal Simek 
---

Changes in v2: None

 drivers/mmc/sdhci.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 2779bca93f08..fbc576fd726e 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -711,17 +711,19 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct 
sdhci_host *host,
 {
u32 caps, caps_1 = 0;
 #if CONFIG_IS_ENABLED(DM_MMC)
-   u32 mask[2] = {0};
-   int ret;
-   ret = dev_read_u32_array(host->mmc->dev, "sdhci-caps-mask",
-mask, 2);
-   if (ret && ret != -1)
-   return ret;
-
-   caps = ~mask[1] & sdhci_readl(host, SDHCI_CAPABILITIES);
+   u64 dt_caps, dt_caps_mask;
+
+   dt_caps_mask = dev_read_u64_default(host->mmc->dev,
+   "sdhci-caps-mask", 0);
+   dt_caps = dev_read_u64_default(host->mmc->dev,
+  "sdhci-caps", 0);
+   caps = ~(u32)dt_caps_mask &
+  sdhci_readl(host, SDHCI_CAPABILITIES);
+   caps |= (u32)dt_caps;
 #else
caps = sdhci_readl(host, SDHCI_CAPABILITIES);
 #endif
+   debug("%s, caps: 0x%x\n", __func__, caps);
 
 #ifdef CONFIG_MMC_SDHCI_SDMA
if (!(caps & SDHCI_CAN_DO_SDMA)) {
@@ -762,10 +764,13 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct 
sdhci_host *host,
/* Check whether the clock multiplier is supported or not */
if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) {
 #if CONFIG_IS_ENABLED(DM_MMC)
-   caps_1 = ~mask[0] & sdhci_readl(host, SDHCI_CAPABILITIES_1);
+   caps_1 = ~(u32)(dt_caps_mask >> 32) &
+sdhci_readl(host, SDHCI_CAPABILITIES_1);
+   caps_1 |= (u32)(dt_caps >> 32);
 #else
caps_1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
 #endif
+   debug("%s, caps_1: 0x%x\n", __func__, caps_1);
host->clk_mul = (caps_1 & SDHCI_CLOCK_MUL_MASK) >>
SDHCI_CLOCK_MUL_SHIFT;
}
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/2] dm: core: Add functions to read 64-bit dt properties

2019-09-02 Thread Michal Simek
From: T Karthik Reddy 

This patch adds functions dev_read_u64_default & dev_read_u64
to read unsigned 64-bit values from devicetree.

Signed-off-by: T Karthik Reddy 
Signed-off-by: Michal Simek 
---

Changes in v2:
- Moved newly added 64-bit funtion definations & prototypes below
   32-bit functions.

 drivers/core/ofnode.c |  2 +-
 drivers/core/read.c   | 10 ++
 include/dm/ofnode.h   |  2 +-
 include/dm/read.h | 33 +
 4 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index e74a662d1d30..7eca00cd6613 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -79,7 +79,7 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 
*outp)
return 0;
 }
 
-int ofnode_read_u64_default(ofnode node, const char *propname, u64 def)
+u64 ofnode_read_u64_default(ofnode node, const char *propname, u64 def)
 {
assert(ofnode_valid(node));
ofnode_read_u64(node, propname, );
diff --git a/drivers/core/read.c b/drivers/core/read.c
index 8b5502de1159..fb3dcd9a7905 100644
--- a/drivers/core/read.c
+++ b/drivers/core/read.c
@@ -44,6 +44,16 @@ int dev_read_u32u(struct udevice *dev, const char *propname, 
uint *outp)
return 0;
 }
 
+int dev_read_u64(struct udevice *dev, const char *propname, u64 *outp)
+{
+   return ofnode_read_u64(dev_ofnode(dev), propname, outp);
+}
+
+u64 dev_read_u64_default(struct udevice *dev, const char *propname, u64 def)
+{
+   return ofnode_read_u64_default(dev_ofnode(dev), propname, def);
+}
+
 const char *dev_read_string(struct udevice *dev, const char *propname)
 {
return ofnode_read_string(dev_ofnode(dev), propname);
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 4f89db44c19e..5c4cbf099869 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -254,7 +254,7 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 
*outp);
  * @def:   default value to return if the property has no value
  * @return property value, or @def if not found
  */
-int ofnode_read_u64_default(ofnode node, const char *propname, u64 def);
+u64 ofnode_read_u64_default(ofnode node, const char *propname, u64 def);
 
 /**
  * ofnode_read_string() - Read a string from a property
diff --git a/include/dm/read.h b/include/dm/read.h
index 0c62d62f1148..803daf7620c8 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -44,6 +44,7 @@ static inline bool dev_of_valid(struct udevice *dev)
 }
 
 #ifndef CONFIG_DM_DEV_READ_INLINE
+
 /**
  * dev_read_u32() - read a 32-bit integer from a device's DT property
  *
@@ -96,6 +97,26 @@ int dev_read_s32_default(struct udevice *dev, const char 
*propname, int def);
  */
 int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp);
 
+/**
+ * dev_read_u64() - read a 64-bit integer from a device's DT property
+ *
+ * @dev:device to read DT property from
+ * @propname:   name of the property to read from
+ * @outp:   place to put value (if found)
+ * @return 0 if OK, -ve on error
+ */
+int dev_read_u64(struct udevice *dev, const char *propname, u64 *outp);
+
+/**
+ * dev_read_u64_default() - read a 64-bit integer from a device's DT property
+ *
+ * @dev:device to read DT property from
+ * @propname:   name of the property to read from
+ * @def:default value to return if the property has no value
+ * @return property value, or @def if not found
+ */
+u64 dev_read_u64_default(struct udevice *dev, const char *propname, u64 def);
+
 /**
  * dev_read_string() - Read a string from a device's DT property
  *
@@ -601,6 +622,18 @@ static inline int dev_read_u32u(struct udevice *dev,
return 0;
 }
 
+static inline int dev_read_u64(struct udevice *dev,
+  const char *propname, u64 *outp)
+{
+   return ofnode_read_u64(dev_ofnode(dev), propname, outp);
+}
+
+static inline u64 dev_read_u64_default(struct udevice *dev,
+  const char *propname, u64 def)
+{
+   return ofnode_read_u64_default(dev_ofnode(dev), propname, def);
+}
+
 static inline const char *dev_read_string(struct udevice *dev,
  const char *propname)
 {
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 0/2] Add sdhci dt caps & caps mask support

2019-09-02 Thread Michal Simek
Hi,

This patch series adds support for reading 64-bit dt properties & add
support sdhci dt caps & caps mask.

Thanks,
Michal

Changes in v2:
- Moved newly added 64-bit funtion definations & prototypes below
   32-bit functions.

T Karthik Reddy (2):
  dm: core: Add functions to read 64-bit dt properties
  mmc: sdhci: Add support for dt caps & caps mask

 drivers/core/ofnode.c |  2 +-
 drivers/core/read.c   | 10 ++
 drivers/mmc/sdhci.c   | 23 ++-
 include/dm/ofnode.h   |  2 +-
 include/dm/read.h | 33 +
 5 files changed, 59 insertions(+), 11 deletions(-)

-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: omap2: am43xx: Enable CONFIG_DM_USB

2019-09-02 Thread Tom Rini
On Thu, Aug 29, 2019 at 07:08:59PM +0530, suni...@techveda.org wrote:

> From: Suniel Mahesh 
> 
> Enable CONFIG_DM_USB to remove compile warning for
> am43xx based targets:
> 
> = WARNING ==
> This board does not use CONFIG_DM_USB. Please update
> the board to use CONFIG_DM_USB before the v2019.07 release.
> Failure to update by the deadline may result in board removal.
> See doc/driver-model/MIGRATION.txt for more info.
> 
> 
> Signed-off-by: Suniel Mahesh 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] Makefile: fix newline escaping for CONFIG_DEFAULT_ENV_FILE

2019-09-02 Thread Tom Rini
On Wed, Aug 28, 2019 at 11:00:46AM +, Rasmus Villemoes wrote:

> I wanted this to be compatible with mkenvimage, including the ability
> to embed newlines in variables by escaping them. But I failed to check
> that it works more than once.
> 
> Fixes: f3d8f7dd73a (Allow providing default environment from file)
> Signed-off-by: Rasmus Villemoes 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] u-boot-sh/master

2019-09-02 Thread Tom Rini
On Thu, Aug 29, 2019 at 02:07:11PM +0200, Marek Vasut wrote:

> The following changes since commit 1e60ccd94318fb86610e1e28512b2aaac5f4b069:
> 
>   Merge branch '2019-08-20-master-imports' (2019-08-20 21:40:12 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-sh.git master
> 
> for you to fetch changes up to be1e9dc0800a9d44514a0c640ded0bd70400ddc6:
> 
>   ARM: renesas: Enable R8A66597 USB host on GR Peach (2019-08-22
> 18:23:37 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 3/3] configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2

2019-09-02 Thread Tom Rini
On Tue, Aug 27, 2019 at 03:32:20PM +0800, Weijie Gao wrote:

> This patch enables CONFIG_BLOCK_CACHE for mt7623n_bpir2.
> 
> Signed-off-by: Weijie Gao 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] board_f: fix noncached reservation calculation

2019-09-02 Thread Tom Rini
On Tue, Aug 27, 2019 at 11:54:31AM -0600, Stephen Warren wrote:

> From: Stephen Warren 
> 
> The current code in reserve_noncached() has two issues:
> 
> 1) The first update of gd->start_addr_sp always rounds down to a section
> start. However, the equivalent calculation in cache.c:noncached_init()
> always first rounds up to a section start, then subtracts a section size.
> These two calculations differ if the initial value is already rounded to
> section alignment.
> 
> 2) The second update of gd->start_addr_sp subtracts exactly
> CONFIG_SYS_NONCACHED_MEMORY, whereas the equivalent calculation in
> cache.c:noncached_init() rounds the noncached size up to section
> alignment before subtracting it. The two calculations differ if the
> noncached region size is not a multiple of the MMU section size.
> 
> In practice, one/both of those issues causes a practical problem on
> Jetson TX1; U-Boot triggers a synchronous abort during initialization,
> likely due to overlapping use of some memory region.
> 
> This change fixes both these issues by duplicating the exact calculations
> from noncached_init() into reserve_noncached().
> 
> However, this fix assumes that gd->start_addr_sp on entry to
> reserve_noncached() exactly matches mem_malloc_start on entry to
> noncached_init(). I haven't traced the code to see whether it absolutely
> guarantees this in all (or indeed any!) cases. Consequently, I added some
> comments in the hope that this condition will continue to be true.
> 
> Fixes: 5f7adb5b1c02 ("board_f: reserve noncached space below malloc area")
> Cc: Vikas Manocha 
> Signed-off-by: Stephen Warren 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] Makefile: clean build generated SPL binary for TI AM65x

2019-09-02 Thread Tom Rini
On Tue, Aug 27, 2019 at 01:27:56PM +0530, suni...@techveda.org wrote:

> From: Suniel Mahesh 
> 
> TI AM65x platforms (evm and HS) generate an SPL image
> 'tispl.bin*' and there is no rule for cleanup.
> Added entry for cleanup in clean target.
> 
> Signed-off-by: Suniel Mahesh 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart"

2019-09-02 Thread Tom Rini
On Tue, Aug 27, 2019 at 03:32:18PM +0800, Weijie Gao wrote:

> This reverts commit 0ebe112d09b48230ba4be833cd3504b06997d9a4.
> 
> Most block devices have only one hwpart. Multiple hwparts only found used
> by eMMC devices in u-boot. The mmc driver do blk_dselect_hwpart() at the
> beginning of mmc_bread() which causes block cache being invalidated too
> frequently and makes block cache useless.
> 
> So it's not a good idea to put blkcache_invalidate() in the common
> functions. It should be called inside mmc_select_hwpart().
> 
> Signed-off-by: Weijie Gao 
> Tested-by: Felix Brack 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] Revert "vexpress64: fvp dram: add DRAM configuration"

2019-09-02 Thread Tom Rini
On Tue, Aug 27, 2019 at 11:56:49AM +0100, Ryan Harkin wrote:

> This reverts commit fc04b923541d984b1544056fd3bfa8129d4e5aac where the
> FVP DRAM configuration was added.
> 
> Signed-off-by: Ryan Harkin 
> Acked-by: Sudeep Holla 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] siemens: avoid out of bound access

2019-09-02 Thread Tom Rini
On Thu, Aug 22, 2019 at 09:58:26PM +0200, Heinrich Schuchardt wrote:

> char num[1];
>   sprintf(num, "%d", i);
> 
> leads to a buffer overrun.
> 
> Simplify the overly complex coding.
> 
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Bin Meng 
> Acked-by: Heiko Schocher 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully

2019-09-02 Thread Tom Rini
On Tue, Aug 27, 2019 at 03:32:19PM +0800, Weijie Gao wrote:

> eMMC device has multiple hw partitions both address from zero. However the
> mmc driver lacks block cache invalidation for switch hwpart. This causes a
> problem that data of current hw partition is cached before switching to
> another hw partition. And the following read operation of the latter hw
> partition will get wrong data when reading from the addresses that have
> been cached previously.
> 
> To solve this problem, invalidate block cache after a successful
> mmc_switch_part() operation.
> 
> Signed-off-by: Weijie Gao 
> Tested-by: Felix Brack 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] U-Boot: Environment flags broken for U-Boot

2019-09-02 Thread Heiko Schocher

Hello Patrick,

I am just testing U-Boot Environment flags and they do not work anymore with
current mainline U-Boot ... I should have made some tbot test for it,
but did not found yet time for it ...

Here log with current mainline:


=> printenv heiko
heiko=changed
=> env flags
Available variable type flags (position 0):
FlagVariable Type Name
--
s   -   string
d   -   decimal
x   -   hexadecimal
b   -   boolean
i   -   IP address
m   -   MAC address

Available variable access flags (position 1):
FlagVariable Access Name

a   -   any
r   -   read-only
o   -   write-once
c   -   change-default

Static flags:
Variable NameVariable TypeVariable Access
-----
eth\d*addr   MAC address  any
ipaddr   IP address   any
gatewayipIP address   any
netmask  IP address   any
serverip IP address   any
nvlandecimal  any
vlan decimal  any
dnsipIP address   any
heikostring   write-once

Active flags:
Variable NameVariable TypeVariable Access
-----
.flags   string   write-once
netmask  IP address   any
serverip IP address   any
heikostring   write-once
ipaddr   IP address   any
=> setenv heiko foo
=> print heiko
heiko=foo
=> setenv heiko bar
=> print heiko
heiko=bar

I can change Environment variable "heiko" but flag is write-once !

Ok, digging around and I found, that in env/common.c changed_ok is NULL
which results in not checking U-Boot flags:

 26 struct hsearch_data env_htab = {
 27 #if CONFIG_IS_ENABLED(ENV_SUPPORT)
 28 /* defined in flags.c, only compile with ENV_SUPPORT */
 29 .change_ok = env_flags_validate,
 30 #endif
 31 };

reason is your commit:

commit 7d4776545b0f8a8827e5d061206faf61c9ba6ea9
Author: Patrick Delaunay 
Date:   Thu Apr 18 17:32:49 2019 +0200

env: solve compilation error in SPL

Solve compilation issue when cli_simple.o is used in SPL
and CONFIG_SPL_ENV_SUPPORT is not defined.

env/built-in.o:(.data.env_htab+0xc): undefined reference to 
`env_flags_validate'
u-boot/scripts/Makefile.spl:384: recipe for target 'spl/u-boot-spl' failed
make[2]: *** [spl/u-boot-spl] Error 1
u-boot/Makefile:1649: recipe for target 'spl/u-boot-spl' failed
make[1]: *** [spl/u-boot-spl] Error 2

Signed-off-by: Patrick Delaunay 


ENV_SUPPORT is only defined for SPL and TPL not for U-Boot, which
leads in change_ok always NULL in U-Boot ...

:-(

reverting this commit and it works again as expected ...

Urgs ... since april 2019 nobody tested this feature

:-(

Nevertheless, reverting commit and I see:

=> print heiko
heiko=test
=> setenv heiko foo
## Error inserting "heiko" variable, errno=1
=>

So we should find a solution for this.

Any ideas?

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arm: imx6: cm_fx6: Enable DM SPI and SPI_FLASH, fix SPL build errors

2019-09-02 Thread sunil . m
From: Suniel Mahesh 

Enable driver model for SPI and SPI_FLASH to remove the following
compile warning on CM-FX6 SOM:
= WARNING ==
This board does not use CONFIG_DM_SPI_FLASH. Please update
the board to use CONFIG_SPI_FLASH before the v2019.07 release.


This change introduced SPL build error as shown:

In file included from include/common.h:47:0,
 from drivers/mtd/spi/sf_probe.c:10:
drivers/mtd/spi/sf_probe.c: In function 'spi_flash_std_probe':
drivers/mtd/spi/sf_probe.c:149:54: error: dereferencing pointer to incomplete 
type 'struct dm_spi_slave_platdata'
scripts/Makefile.build:278: recipe for target 'spl/drivers/mtd/spi/sf_probe.o' 
failed
make[3]: *** [spl/drivers/mtd/spi/sf_probe.o] Error 1
scripts/Makefile.build:432: recipe for target 'spl/drivers/mtd/spi' failed
make[2]: *** [spl/drivers/mtd/spi] Error 2

Disabling DM for SPI support(SPI and SF) in SPL resolves the issue.
Target was compile tested, build was clean.

Signed-off-by: Suniel Mahesh 
---
 configs/cm_fx6_defconfig | 2 ++
 include/configs/cm_fx6.h | 7 +++
 2 files changed, 9 insertions(+)

diff --git a/configs/cm_fx6_defconfig b/configs/cm_fx6_defconfig
index fd0db4d..d236875 100644
--- a/configs/cm_fx6_defconfig
+++ b/configs/cm_fx6_defconfig
@@ -62,6 +62,7 @@ CONFIG_FSL_USDHC=y
 CONFIG_NAND=y
 CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_MODE=0
 CONFIG_SF_DEFAULT_SPEED=2500
 CONFIG_SPI_FLASH_ATMEL=y
@@ -77,6 +78,7 @@ CONFIG_MII=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_REGULATOR=y
 CONFIG_SPI=y
+CONFIG_DM_SPI=y
 CONFIG_MXC_SPI=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
index b957e9c..4dd2b40 100644
--- a/include/configs/cm_fx6.h
+++ b/include/configs/cm_fx6.h
@@ -163,6 +163,13 @@
 /* APBH DMA is required for NAND support */
 #endif
 
+/* SPI Flash Configs */
+#if defined(CONFIG_SPL_BUILD)
+#undef CONFIG_DM_SPI
+#undef CONFIG_DM_SPI_FLASH
+#undef CONFIG_SPI_FLASH_MTD
+#endif
+
 /* Ethernet */
 #define CONFIG_FEC_MXC
 #define CONFIG_FEC_MXC_PHYADDR 0
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: dts: Import and update DT for Khadas VIM3

2019-09-02 Thread Neil Armstrong
On 02/09/2019 14:45, Andreas Färber wrote:
> Hi Neil,
> 
> Am 02.09.19 um 14:10 schrieb Neil Armstrong:
>> On 02/09/2019 14:03, Andreas Färber wrote:
>>> Am 02.09.19 um 12:03 schrieb Neil Armstrong:
 On 02/09/2019 04:28, Andreas Färber wrote:
> In Linux meson-g12-common.dtsi was introduced as well as new g12b nodes
> and headers, as dependencies of new meson-g12b-a311d-khadas-vim3.dts.

 Can you precise the Linux commit ID you sync'ed from ?
>>>
>>> It was yesterday's linux-next.git (via cgit), adding tag next-20190830.
>>
>> Please don't use linux next, it's not a stable tree, either wait for 5.4-rc1
>> or use kevin's amlogic-dt64-2.1 tag, since it will be kept in the final
>> merge.
> 
> Well, in my view linux-next would contain whatever vX patchset Kevin
> applied to his tree... let's wait for -rc1 then.

Sorry to be picky, but yes let's wait -rc1 since I'll anyway wait until next 
U-Boot
release cycle to send these patches to Tom.

> 
>>>
 The best would be to sync from the v2 dt64 PR from kevin :
 https://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic.git/tag/?h=amlogic-dt64-2.1

 Thanks,
 Neil

>
> Signed-off-by: Andreas Färber 
> ---
>  arch/arm/dts/Makefile  |3 +-
>  arch/arm/dts/meson-g12-common.dtsi | 2435 
> 
>  arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts  |   15 +

 Can you also sync the s922x version ?
>>>
>>> Why? No such model is being sold: https://www.khadas.com/vim3
>>>
>>> In any case, if you or someone has such a pre-production model you can
>>> add it as follow-up. In fact you could even entirely replace this import
>>> patch if you so desired, it's intentionally separate.
>>
>> Didn't want to offend you, don't sync it if you don't want...
> 
> It was an honest question. So I take it you have such a prototype?
> 
> What I do feel offended about is that my NanoPi K2 patch got ignored and
> someone else's got merged without crediting or even notifying me. I've
> become rather hesitant to send U-Boot patches for new boards since, as I
> don't have much time for it lately and I'd rather spend it productively.

I was not aware you did the Nanopi K2 support... since I only managed the 
Amlogic
U-boot patches in a Custodian and send PRs to Tom since early this year,
I can't really be accused of ignoring a patch you sent 2y ago before I sent a 
single
patch to the U-Boot ML about Amlogic SoCs support:

commit 486221564920e8fcb9a58854a485dac1f8f4d1d3
Author: Neil Armstrong 
Date:   Thu Oct 12 15:50:30 2017 +0200

ARM: dts: Synchronize Amlogic from Linux Mainline 4.13.5

> 
> https://patchwork.ozlabs.org/patch/762194/
> https://patchwork.ozlabs.org/patch/762483/
> https://patchwork.ozlabs.org/patch/934377/

As you can see, Thomas McKahan did the work and I simply posted the patch
to the list.

> https://gitlab.denx.de/u-boot/u-boot/commit/eee45b4f545902a9089f68331c925898da813ac0
> 
>  arch/arm/dts/meson-g12b-a311d.dtsi |  149 ++
>  arch/arm/dts/meson-g12b-khadas-vim3.dtsi   |  544 +
>  arch/arm/dts/meson-g12b.dtsi   |   39 +-
>  include/dt-bindings/clock/g12a-clkc.h  |6 +
>  include/dt-bindings/power/meson-g12a-power.h   |   13 +
>  .../reset/amlogic,meson-g12a-audio-reset.h |   38 +
>  9 files changed, 3238 insertions(+), 4 deletions(-)
>  create mode 100644 arch/arm/dts/meson-g12-common.dtsi
>  create mode 100644 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts
>  create mode 100644 arch/arm/dts/meson-g12b-a311d.dtsi
>  create mode 100644 arch/arm/dts/meson-g12b-khadas-vim3.dtsi
>  create mode 100644 include/dt-bindings/power/meson-g12a-power.h
>  create mode 100644 
> include/dt-bindings/reset/amlogic,meson-g12a-audio-reset.h
>
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index aac1b83d49..6de5e4c62a 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -141,7 +141,8 @@ dtb-$(CONFIG_ARCH_MESON) += \
>   meson-axg-s400.dtb \
>   meson-g12a-u200.dtb \
>   meson-g12a-sei510.dtb \
> - meson-g12b-odroid-n2.dtb
> + meson-g12b-odroid-n2.dtb \
> + meson-g12b-a311d-khadas-vim3.dtb

 Same here, can you also build the s922x variant ?
>>>
>>> Again, I don't see why, in particular when we don't have a defconfig
>>> using it. If you intend to add one, you can still add it later
>>
>> Since I maintain the whole stuff, it would have saved my time.
> 
> Sorry, no time to redo this patch the next ~3 weeks due to travels.
> It was not scripted.
> 
> Thanks for your quick review.
> 
> Regards,
> Andreas
> 

Thanks for doing this anyway,
Neil
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: dts: Import and update DT for Khadas VIM3

2019-09-02 Thread Andreas Färber
Hi Neil,

Am 02.09.19 um 14:10 schrieb Neil Armstrong:
> On 02/09/2019 14:03, Andreas Färber wrote:
>> Am 02.09.19 um 12:03 schrieb Neil Armstrong:
>>> On 02/09/2019 04:28, Andreas Färber wrote:
 In Linux meson-g12-common.dtsi was introduced as well as new g12b nodes
 and headers, as dependencies of new meson-g12b-a311d-khadas-vim3.dts.
>>>
>>> Can you precise the Linux commit ID you sync'ed from ?
>>
>> It was yesterday's linux-next.git (via cgit), adding tag next-20190830.
> 
> Please don't use linux next, it's not a stable tree, either wait for 5.4-rc1
> or use kevin's amlogic-dt64-2.1 tag, since it will be kept in the final
> merge.

Well, in my view linux-next would contain whatever vX patchset Kevin
applied to his tree... let's wait for -rc1 then.

>>
>>> The best would be to sync from the v2 dt64 PR from kevin :
>>> https://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic.git/tag/?h=amlogic-dt64-2.1
>>>
>>> Thanks,
>>> Neil
>>>

 Signed-off-by: Andreas Färber 
 ---
  arch/arm/dts/Makefile  |3 +-
  arch/arm/dts/meson-g12-common.dtsi | 2435 
 
  arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts  |   15 +
>>>
>>> Can you also sync the s922x version ?
>>
>> Why? No such model is being sold: https://www.khadas.com/vim3
>>
>> In any case, if you or someone has such a pre-production model you can
>> add it as follow-up. In fact you could even entirely replace this import
>> patch if you so desired, it's intentionally separate.
> 
> Didn't want to offend you, don't sync it if you don't want...

It was an honest question. So I take it you have such a prototype?

What I do feel offended about is that my NanoPi K2 patch got ignored and
someone else's got merged without crediting or even notifying me. I've
become rather hesitant to send U-Boot patches for new boards since, as I
don't have much time for it lately and I'd rather spend it productively.

https://patchwork.ozlabs.org/patch/762194/
https://patchwork.ozlabs.org/patch/762483/
https://patchwork.ozlabs.org/patch/934377/
https://gitlab.denx.de/u-boot/u-boot/commit/eee45b4f545902a9089f68331c925898da813ac0

  arch/arm/dts/meson-g12b-a311d.dtsi |  149 ++
  arch/arm/dts/meson-g12b-khadas-vim3.dtsi   |  544 +
  arch/arm/dts/meson-g12b.dtsi   |   39 +-
  include/dt-bindings/clock/g12a-clkc.h  |6 +
  include/dt-bindings/power/meson-g12a-power.h   |   13 +
  .../reset/amlogic,meson-g12a-audio-reset.h |   38 +
  9 files changed, 3238 insertions(+), 4 deletions(-)
  create mode 100644 arch/arm/dts/meson-g12-common.dtsi
  create mode 100644 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts
  create mode 100644 arch/arm/dts/meson-g12b-a311d.dtsi
  create mode 100644 arch/arm/dts/meson-g12b-khadas-vim3.dtsi
  create mode 100644 include/dt-bindings/power/meson-g12a-power.h
  create mode 100644 
 include/dt-bindings/reset/amlogic,meson-g12a-audio-reset.h

 diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
 index aac1b83d49..6de5e4c62a 100644
 --- a/arch/arm/dts/Makefile
 +++ b/arch/arm/dts/Makefile
 @@ -141,7 +141,8 @@ dtb-$(CONFIG_ARCH_MESON) += \
meson-axg-s400.dtb \
meson-g12a-u200.dtb \
meson-g12a-sei510.dtb \
 -  meson-g12b-odroid-n2.dtb
 +  meson-g12b-odroid-n2.dtb \
 +  meson-g12b-a311d-khadas-vim3.dtb
>>>
>>> Same here, can you also build the s922x variant ?
>>
>> Again, I don't see why, in particular when we don't have a defconfig
>> using it. If you intend to add one, you can still add it later
> 
> Since I maintain the whole stuff, it would have saved my time.

Sorry, no time to redo this patch the next ~3 weeks due to travels.
It was not scripted.

Thanks for your quick review.

Regards,
Andreas

-- 
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer
HRB 247165 (AG München)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 4/4] arm: meson: Recognize A311D SoC

2019-09-02 Thread Andreas Färber
Values imported from Linux driver, but in correct numeric order.

Khadas VIM3 prints: Amlogic Meson G12B (A311D) Revision 29:b (10:2)

Cc: Christian Hewitt 
Signed-off-by: Andreas Färber 
---
 v2: New
 
 arch/arm/mach-meson/board-info.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-meson/board-info.c b/arch/arm/mach-meson/board-info.c
index ea32c01d11..9571b5a189 100644
--- a/arch/arm/mach-meson/board-info.c
+++ b/arch/arm/mach-meson/board-info.c
@@ -59,6 +59,7 @@ static const struct meson_gx_package_id {
{ "A113D",  0x25, 0x22, 0xff },
{ "S905D2", 0x28, 0x10, 0xf0 },
{ "S905X2", 0x28, 0x40, 0xf0 },
+   { "A311D",  0x29, 0x10, 0xf0 },
{ "S922X",  0x29, 0x40, 0xf0 },
 };
 
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/4] configs: Add Khadas VIM3 defconfig

2019-09-02 Thread Andreas Färber
Derived from odroid-n2_defconfig and README.odroid-n2.

Reviewed-by: Neil Armstrong 
Signed-off-by: Andreas Färber 
---
 v1 -> v2:
 * Fixed branch name in README
 
 board/amlogic/w400/MAINTAINERS|   1 +
 board/amlogic/w400/README.khadas-vim3 | 132 ++
 configs/khadas-vim3_defconfig |  54 ++
 3 files changed, 187 insertions(+)
 create mode 100644 board/amlogic/w400/README.khadas-vim3
 create mode 100644 configs/khadas-vim3_defconfig

diff --git a/board/amlogic/w400/MAINTAINERS b/board/amlogic/w400/MAINTAINERS
index 6e68fa73f7..3b21f50367 100644
--- a/board/amlogic/w400/MAINTAINERS
+++ b/board/amlogic/w400/MAINTAINERS
@@ -3,4 +3,5 @@ M:  Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/w400/
+F: configs/khadas-vim3_defconfig
 F: configs/odroid-n2_defconfig
diff --git a/board/amlogic/w400/README.khadas-vim3 
b/board/amlogic/w400/README.khadas-vim3
new file mode 100644
index 00..45ef90c1b0
--- /dev/null
+++ b/board/amlogic/w400/README.khadas-vim3
@@ -0,0 +1,132 @@
+U-Boot for Khadas VIM3
+==
+
+Khadas VIM3 is a single board computer manufactured by Shenzhen Wesion
+Technology Co., Ltd. with the following specifications:
+
+ - Amlogic A311D Arm Cortex-A53 dual-core + Cortex-A73 quad-core SoC
+ - 4GB LPDDR4 SDRAM
+ - Gigabit Ethernet
+ - HDMI 2.1 display
+ - 40-pin GPIO header
+ - 1 x USB 3.0 Host, 1 x USB 2.0 Host
+ - eMMC, microSD
+ - M.2
+ - Infrared receiver
+
+Schematics are available on the manufacturer website.
+
+Currently the U-Boot port supports the following devices:
+ - serial
+ - eMMC, microSD
+ - Ethernet
+ - I2C
+ - Regulators
+ - Reset controller
+ - Clock controller
+ - ADC
+
+u-boot compilation
+==
+
+ > export ARCH=arm
+ > export CROSS_COMPILE=aarch64-none-elf-
+ > make khadas-vim3_defconfig
+ > make
+
+Image creation
+==
+
+Amlogic doesn't provide sources for the firmware and for tools needed
+to create the bootloader image, so it is necessary to obtain them from
+the git tree published by the board vendor:
+
+ > wget 
https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
+ > wget 
https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
+ > tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
+ > tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
+ > export 
PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
+
+ > DIR=vim3-u-boot
+ > git clone --depth 1 \
+   https://github.com/khadas/u-boot.git -b khadas-vims-v2015.01 \
+   $DIR
+
+ > cd vim3-u-boot
+ > make kvim3_defconfig
+ > make
+ > export UBOOTDIR=$PWD
+
+ Go back to mainline U-Boot source tree then :
+ > mkdir fip
+
+ > cp $UBOOTDIR/build/scp_task/bl301.bin fip/
+ > cp $UBOOTDIR/build/board/khadas/kvim3/firmware/acs.bin fip/
+ > cp $UBOOTDIR/fip/g12b/bl2.bin fip/
+ > cp $UBOOTDIR/fip/g12b/bl30.bin fip/
+ > cp $UBOOTDIR/fip/g12b/bl31.img fip/
+ > cp $UBOOTDIR/fip/g12b/ddr3_1d.fw fip/
+ > cp $UBOOTDIR/fip/g12b/ddr4_1d.fw fip/
+ > cp $UBOOTDIR/fip/g12b/ddr4_2d.fw fip/
+ > cp $UBOOTDIR/fip/g12b/diag_lpddr4.fw fip/
+ > cp $UBOOTDIR/fip/g12b/lpddr3_1d.fw fip/
+ > cp $UBOOTDIR/fip/g12b/lpddr4_1d.fw fip/
+ > cp $UBOOTDIR/fip/g12b/lpddr4_2d.fw fip/
+ > cp $UBOOTDIR/fip/g12b/piei.fw fip/
+ > cp $UBOOTDIR/fip/g12b/aml_ddr.fw fip/
+ > cp u-boot.bin fip/bl33.bin
+
+ > sh fip/blx_fix.sh \
+   fip/bl30.bin \
+   fip/zero_tmp \
+   fip/bl30_zero.bin \
+   fip/bl301.bin \
+   fip/bl301_zero.bin \
+   fip/bl30_new.bin \
+   bl30
+
+ > sh fip/blx_fix.sh \
+   fip/bl2.bin \
+   fip/zero_tmp \
+   fip/bl2_zero.bin \
+   fip/acs.bin \
+   fip/bl21_zero.bin \
+   fip/bl2_new.bin \
+   bl2
+
+ > $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \
+   --output fip/bl30_new.bin.g12a.enc \
+   --level v3
+ > $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input 
fip/bl30_new.bin.g12a.enc \
+   --output fip/bl30_new.bin.enc \
+   --level v3 --type bl30
+ > $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
+   --output fip/bl31.img.enc \
+   --level v3 --type bl31
+ > $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin 
--compress lz4 \
+   --output fip/bl33.bin.enc \
+   --level v3 --type bl33 --compress lz4
+ > $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
+   --output fip/bl2.n.bin.sig
+ > 

[U-Boot] [PATCH v2 3/4] arm: meson: Tidy SoC information output

2019-09-02 Thread Andreas Färber
Write SoC instead of Soc. The Linux driver is not affected.

Fixes: f41d723b9f ("ARM: meson: display Amlogic SoC Information")
Signed-off-by: Julien Masson 
Signed-off-by: Andreas Färber 
---
 v2: New
 
 arch/arm/mach-meson/board-info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-meson/board-info.c b/arch/arm/mach-meson/board-info.c
index ba248e8ff6..ea32c01d11 100644
--- a/arch/arm/mach-meson/board-info.c
+++ b/arch/arm/mach-meson/board-info.c
@@ -154,7 +154,7 @@ int show_board_info(void)
 
/* print board information */
print_board_model();
-   printf("Soc:   Amlogic Meson %s (%s) Revision %x:%x (%x:%x)\n",
+   printf("SoC:   Amlogic Meson %s (%s) Revision %x:%x (%x:%x)\n",
   socinfo_to_soc_id(socinfo),
   socinfo_to_package_id(socinfo),
   socinfo_to_major(socinfo),
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/4] arm: dts: Import and update DT for Khadas VIM3

2019-09-02 Thread Andreas Färber
In Linux meson-g12-common.dtsi was introduced as well as new g12b nodes
and headers, as dependencies of new meson-g12b-a311d-khadas-vim3.dts.

Copied from next-20190830.

Signed-off-by: Andreas Färber 
---
 v1 -> v2:
 * Mention linux-next tag for DT/header import (Neil)
 
 arch/arm/dts/Makefile  |3 +-
 arch/arm/dts/meson-g12-common.dtsi | 2435 
 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts  |   15 +
 arch/arm/dts/meson-g12b-a311d.dtsi |  149 ++
 arch/arm/dts/meson-g12b-khadas-vim3.dtsi   |  544 +
 arch/arm/dts/meson-g12b.dtsi   |   39 +-
 include/dt-bindings/clock/g12a-clkc.h  |6 +
 include/dt-bindings/power/meson-g12a-power.h   |   13 +
 .../reset/amlogic,meson-g12a-audio-reset.h |   38 +
 9 files changed, 3238 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/meson-g12-common.dtsi
 create mode 100644 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts
 create mode 100644 arch/arm/dts/meson-g12b-a311d.dtsi
 create mode 100644 arch/arm/dts/meson-g12b-khadas-vim3.dtsi
 create mode 100644 include/dt-bindings/power/meson-g12a-power.h
 create mode 100644 include/dt-bindings/reset/amlogic,meson-g12a-audio-reset.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index aac1b83d49..6de5e4c62a 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -141,7 +141,8 @@ dtb-$(CONFIG_ARCH_MESON) += \
meson-axg-s400.dtb \
meson-g12a-u200.dtb \
meson-g12a-sei510.dtb \
-   meson-g12b-odroid-n2.dtb
+   meson-g12b-odroid-n2.dtb \
+   meson-g12b-a311d-khadas-vim3.dtb
 dtb-$(CONFIG_TEGRA) += tegra20-harmony.dtb \
tegra20-medcom-wide.dtb \
tegra20-paz00.dtb \
diff --git a/arch/arm/dts/meson-g12-common.dtsi 
b/arch/arm/dts/meson-g12-common.dtsi
new file mode 100644
index 00..3f39e020f7
--- /dev/null
+++ b/arch/arm/dts/meson-g12-common.dtsi
@@ -0,0 +1,2435 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2018 Amlogic, Inc. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/ {
+   interrupt-parent = <>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   tdmif_a: audio-controller-0 {
+   compatible = "amlogic,axg-tdm-iface";
+   #sound-dai-cells = <0>;
+   sound-name-prefix = "TDM_A";
+   clocks = <_audio AUD_CLKID_MST_A_MCLK>,
+<_audio AUD_CLKID_MST_A_SCLK>,
+<_audio AUD_CLKID_MST_A_LRCLK>;
+   clock-names = "mclk", "sclk", "lrclk";
+   status = "disabled";
+   };
+
+   tdmif_b: audio-controller-1 {
+   compatible = "amlogic,axg-tdm-iface";
+   #sound-dai-cells = <0>;
+   sound-name-prefix = "TDM_B";
+   clocks = <_audio AUD_CLKID_MST_B_MCLK>,
+<_audio AUD_CLKID_MST_B_SCLK>,
+<_audio AUD_CLKID_MST_B_LRCLK>;
+   clock-names = "mclk", "sclk", "lrclk";
+   status = "disabled";
+   };
+
+   tdmif_c: audio-controller-2 {
+   compatible = "amlogic,axg-tdm-iface";
+   #sound-dai-cells = <0>;
+   sound-name-prefix = "TDM_C";
+   clocks = <_audio AUD_CLKID_MST_C_MCLK>,
+<_audio AUD_CLKID_MST_C_SCLK>,
+<_audio AUD_CLKID_MST_C_LRCLK>;
+   clock-names = "mclk", "sclk", "lrclk";
+   status = "disabled";
+   };
+
+   efuse: efuse {
+   compatible = "amlogic,meson-gxbb-efuse";
+   clocks = < CLKID_EFUSE>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   read-only;
+   };
+
+   psci {
+   compatible = "arm,psci-1.0";
+   method = "smc";
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   /* 3 MiB reserved for ARM Trusted Firmware (BL31) */
+   secmon_reserved: secmon@500 {
+   reg = <0x0 0x0500 0x0 0x30>;
+   no-map;
+   };
+
+   linux,cma {
+   compatible = "shared-dma-pool";
+   reusable;
+   size = <0x0 0x1000>;
+   alignment = <0x0 0x40>;
+   linux,cma-default;
+   };
+   };
+
+   sm: secure-monitor {
+   compatible = "amlogic,meson-gxbb-sm";
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   ethmac: ethernet@ff3f {
+   

[U-Boot] [PATCH v2 0/4] amlogic: Add Khadas VIM3 support

2019-09-02 Thread Andreas Färber
Hi Neil,

This mini-series adds initial support for Amlogic A311D based Khadas VIM3.

v2 fixes an oversight and adds some cleanups.

Regards,
Andreas

v1 -> v2:
* Fixed branch name in README
* Mention linux-next tag for DT/header import (Neil)
* Avoid "Unknown" SoC output for A311D, fixing a typo while at it

Cc: Neil Armstrong 

Andreas Färber (4):
  arm: dts: Import and update DT for Khadas VIM3
  configs: Add Khadas VIM3 defconfig
  arm: meson: Tidy SoC information output
  arm: meson: Recognize A311D SoC

 arch/arm/dts/Makefile  |3 +-
 arch/arm/dts/meson-g12-common.dtsi | 2435 
 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts  |   15 +
 arch/arm/dts/meson-g12b-a311d.dtsi |  149 ++
 arch/arm/dts/meson-g12b-khadas-vim3.dtsi   |  544 +
 arch/arm/dts/meson-g12b.dtsi   |   39 +-
 arch/arm/mach-meson/board-info.c   |3 +-
 board/amlogic/w400/MAINTAINERS |1 +
 board/amlogic/w400/README.khadas-vim3  |  132 ++
 configs/khadas-vim3_defconfig  |   54 +
 include/dt-bindings/clock/g12a-clkc.h  |6 +
 include/dt-bindings/power/meson-g12a-power.h   |   13 +
 .../reset/amlogic,meson-g12a-audio-reset.h |   38 +
 13 files changed, 3427 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/dts/meson-g12-common.dtsi
 create mode 100644 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts
 create mode 100644 arch/arm/dts/meson-g12b-a311d.dtsi
 create mode 100644 arch/arm/dts/meson-g12b-khadas-vim3.dtsi
 create mode 100644 board/amlogic/w400/README.khadas-vim3
 create mode 100644 configs/khadas-vim3_defconfig
 create mode 100644 include/dt-bindings/power/meson-g12a-power.h
 create mode 100644 include/dt-bindings/reset/amlogic,meson-g12a-audio-reset.h

-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: dw_mmc: fix timeout calculate method

2019-09-02 Thread Alexey Brodkin
Hi Kever,

> -Original Message-
> From: Kever Yang 
> Sent: Monday, September 2, 2019 11:05 AM
> To: Alexey Brodkin 
> Cc: tr...@konsulko.com; eugeniy.palt...@synopsys.com; Simon Glass 
> ; Peng Fan
> ; u-boot@lists.denx.de
> Subject: Re: [PATCH] mmc: dw_mmc: fix timeout calculate method
> 
> Hi Alexey,
> 
> On 2019/8/30 下午9:28, Alexey Brodkin wrote:
> > Hi Kever,
> >
> > [snip]
> >
> >> I think this tree does not including this patch, Peng drop it because of
> >> this issue,
> >> so you need to apply this patch in your branch to reproduce the problem.
> >> I have send out V2 patch for this fix with only using 32bit variable
> > Could you please refer me to the problematic patch so I may try it?
> 
> This is the patch with problem, and here is the link on patchwork:
> https://patchwork.ozlabs.org/patch/1146845/

Please find my fixes here:
https://patchwork.ozlabs.org/patch/1156541/
https://patchwork.ozlabs.org/patch/1156617/

Tom do we want https://patchwork.ozlabs.org/patch/1146845/ and fixes for it
(see 2 items above) to become a part of upcoming v2019.10 release or
it will be slated for the next one?

-Alexey


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arc: emsdp: Add more platform-specific compiler options

2019-09-02 Thread Alexey Brodkin
Even though EM SDP is FPGA-based board and different FPGA
images (known as .bit-files) are awailable for the board still
there's a common subset of options we may rely on for all configs.

These are:
 * Normalizer
 * Swap instructions
 * Simple multiplier
 * Barrel-shifter
 * Floating-point unit
 * Shorter instructions (code density)

This among other improvements allows to compile code with
64-bit divisions, see [1].

[1] https://patchwork.ozlabs.org/patch/1156541/

Signed-off-by: Alexey Brodkin 
Cc: Kever Yang 
---
 board/synopsys/emsdp/config.mk | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 board/synopsys/emsdp/config.mk

diff --git a/board/synopsys/emsdp/config.mk b/board/synopsys/emsdp/config.mk
new file mode 100644
index 00..67fd7bf82a
--- /dev/null
+++ b/board/synopsys/emsdp/config.mk
@@ -0,0 +1,2 @@
+PLATFORM_CPPFLAGS += -mlittle-endian -mnorm -mswap -mmpy-option=3 \
+ -mbarrel-shifter -mfpu=fpuda_all -mcode-density
-- 
2.16.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] arc: libgcc: Import __udivdi3 & __udivmoddi4 to allow 64-bit division

2019-09-02 Thread Alexey Brodkin
Hi,

> -Original Message-
> From: Alexey Brodkin 
> Sent: Monday, September 2, 2019 12:43 PM
> To: u-boot@lists.denx.de
> Cc: uboot-snps-...@synopsys.com; linux-snps-...@lists.infradead.org; Alexey 
> Brodkin
> ; Kever Yang 
> Subject: [PATCH] arc: libgcc: Import __udivdi3 & __udivmoddi4 to allow 64-bit 
> division
> 
> As reported by Kever here [1] we were unable to compile 64-bit division
> code due to missing definition of __udivdi3().
> 
> Import its implementation and __udivmoddi4() as its direct dependency
> from today's libgcc [2].
> 
> [1] https://patchwork.ozlabs.org/patch/1146845/
> [2] 
> https://github.com/gcc-mirror/gcc/commit/5d8723600bc0eed41226b5a6785bc02a053b45d5
> 
> Signed-off-by: Alexey Brodkin 
> Cc: Kever Yang 

For the record for EM SDP (emsdp_defconfig) building still
fails this way:
->8-
arc-linux-ld.bfd: arch/arc/lib/lib.a(libgcc2.o): in function `__udivmoddi4':
.../arch/arc/lib/libgcc2.c:195: undefined reference to `__clzdi2'
arc-linux-ld.bfd: .../arch/arc/lib/libgcc2.c:195: undefined reference to 
`__clzdi2'
arc-linux-ld.bfd: .../arch/arc/lib/libgcc2.c:196: undefined reference to 
`__clzdi2'
arc-linux-ld.bfd: .../arch/arc/lib/libgcc2.c:196: undefined reference to 
`__clzdi2'
->8-

That happens because we use a very simple -mcpu=arcem which doesn't use
HW normalizer unit. I'm preparing a patch that will improve EM SDP's compiler
options.

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: dts: Import and update DT for Khadas VIM3

2019-09-02 Thread Neil Armstrong
Hi Andreas

On 02/09/2019 14:03, Andreas Färber wrote:
> Hi Neil,
> 
> Am 02.09.19 um 12:03 schrieb Neil Armstrong:
>> On 02/09/2019 04:28, Andreas Färber wrote:
>>> In Linux meson-g12-common.dtsi was introduced as well as new g12b nodes
>>> and headers, as dependencies of new meson-g12b-a311d-khadas-vim3.dts.
>>
>> Can you precise the Linux commit ID you sync'ed from ?
> 
> It was yesterday's linux-next.git (via cgit), adding tag next-20190830.

Please don't use linux next, it's not a stable tree, either wait for 5.4-rc1
or use kevin's amlogic-dt64-2.1 tag, since it will be kept in the final
merge.

> 
>> The best would be to sync from the v2 dt64 PR from kevin :
>> https://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic.git/tag/?h=amlogic-dt64-2.1
>>
>> Thanks,
>> Neil
>>
>>>
>>> Signed-off-by: Andreas Färber 
>>> ---
>>>  arch/arm/dts/Makefile  |3 +-
>>>  arch/arm/dts/meson-g12-common.dtsi | 2435 
>>> 
>>>  arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts  |   15 +
>>
>> Can you also sync the s922x version ?
> 
> Why? No such model is being sold: https://www.khadas.com/vim3
> 
> In any case, if you or someone has such a pre-production model you can
> add it as follow-up. In fact you could even entirely replace this import
> patch if you so desired, it's intentionally separate.

Didn't want to offend you, don't sync it if you don't want...

> 
>>>  arch/arm/dts/meson-g12b-a311d.dtsi |  149 ++
>>>  arch/arm/dts/meson-g12b-khadas-vim3.dtsi   |  544 +
>>>  arch/arm/dts/meson-g12b.dtsi   |   39 +-
>>>  include/dt-bindings/clock/g12a-clkc.h  |6 +
>>>  include/dt-bindings/power/meson-g12a-power.h   |   13 +
>>>  .../reset/amlogic,meson-g12a-audio-reset.h |   38 +
>>>  9 files changed, 3238 insertions(+), 4 deletions(-)
>>>  create mode 100644 arch/arm/dts/meson-g12-common.dtsi
>>>  create mode 100644 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts
>>>  create mode 100644 arch/arm/dts/meson-g12b-a311d.dtsi
>>>  create mode 100644 arch/arm/dts/meson-g12b-khadas-vim3.dtsi
>>>  create mode 100644 include/dt-bindings/power/meson-g12a-power.h
>>>  create mode 100644 
>>> include/dt-bindings/reset/amlogic,meson-g12a-audio-reset.h
>>>
>>> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
>>> index aac1b83d49..6de5e4c62a 100644
>>> --- a/arch/arm/dts/Makefile
>>> +++ b/arch/arm/dts/Makefile
>>> @@ -141,7 +141,8 @@ dtb-$(CONFIG_ARCH_MESON) += \
>>> meson-axg-s400.dtb \
>>> meson-g12a-u200.dtb \
>>> meson-g12a-sei510.dtb \
>>> -   meson-g12b-odroid-n2.dtb
>>> +   meson-g12b-odroid-n2.dtb \
>>> +   meson-g12b-a311d-khadas-vim3.dtb
>>
>> Same here, can you also build the s922x variant ?
> 
> Again, I don't see why, in particular when we don't have a defconfig
> using it. If you intend to add one, you can still add it later

Since I maintain the whole stuff, it would have saved my time.

Neil

> 
> Adding Gouwa for insights.
> 
> To my knowledge the VIM3L will have S905D3, not S922X. VIM3 is A311D.
> 
> https://www.khadas.com/post/khadas-vim3-won-t-use-s922x
> 
> Regards,
> Andreas
> 

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: dts: Import and update DT for Khadas VIM3

2019-09-02 Thread Andreas Färber
Hi Neil,

Am 02.09.19 um 12:03 schrieb Neil Armstrong:
> On 02/09/2019 04:28, Andreas Färber wrote:
>> In Linux meson-g12-common.dtsi was introduced as well as new g12b nodes
>> and headers, as dependencies of new meson-g12b-a311d-khadas-vim3.dts.
> 
> Can you precise the Linux commit ID you sync'ed from ?

It was yesterday's linux-next.git (via cgit), adding tag next-20190830.

> The best would be to sync from the v2 dt64 PR from kevin :
> https://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic.git/tag/?h=amlogic-dt64-2.1
> 
> Thanks,
> Neil
> 
>>
>> Signed-off-by: Andreas Färber 
>> ---
>>  arch/arm/dts/Makefile  |3 +-
>>  arch/arm/dts/meson-g12-common.dtsi | 2435 
>> 
>>  arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts  |   15 +
> 
> Can you also sync the s922x version ?

Why? No such model is being sold: https://www.khadas.com/vim3

In any case, if you or someone has such a pre-production model you can
add it as follow-up. In fact you could even entirely replace this import
patch if you so desired, it's intentionally separate.

>>  arch/arm/dts/meson-g12b-a311d.dtsi |  149 ++
>>  arch/arm/dts/meson-g12b-khadas-vim3.dtsi   |  544 +
>>  arch/arm/dts/meson-g12b.dtsi   |   39 +-
>>  include/dt-bindings/clock/g12a-clkc.h  |6 +
>>  include/dt-bindings/power/meson-g12a-power.h   |   13 +
>>  .../reset/amlogic,meson-g12a-audio-reset.h |   38 +
>>  9 files changed, 3238 insertions(+), 4 deletions(-)
>>  create mode 100644 arch/arm/dts/meson-g12-common.dtsi
>>  create mode 100644 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts
>>  create mode 100644 arch/arm/dts/meson-g12b-a311d.dtsi
>>  create mode 100644 arch/arm/dts/meson-g12b-khadas-vim3.dtsi
>>  create mode 100644 include/dt-bindings/power/meson-g12a-power.h
>>  create mode 100644 
>> include/dt-bindings/reset/amlogic,meson-g12a-audio-reset.h
>>
>> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
>> index aac1b83d49..6de5e4c62a 100644
>> --- a/arch/arm/dts/Makefile
>> +++ b/arch/arm/dts/Makefile
>> @@ -141,7 +141,8 @@ dtb-$(CONFIG_ARCH_MESON) += \
>>  meson-axg-s400.dtb \
>>  meson-g12a-u200.dtb \
>>  meson-g12a-sei510.dtb \
>> -meson-g12b-odroid-n2.dtb
>> +meson-g12b-odroid-n2.dtb \
>> +meson-g12b-a311d-khadas-vim3.dtb
> 
> Same here, can you also build the s922x variant ?

Again, I don't see why, in particular when we don't have a defconfig
using it. If you intend to add one, you can still add it later.

Adding Gouwa for insights.

To my knowledge the VIM3L will have S905D3, not S922X. VIM3 is A311D.

https://www.khadas.com/post/khadas-vim3-won-t-use-s922x

Regards,
Andreas

-- 
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer
HRB 247165 (AG München)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 3/4] ARM: omapl138_lcdk: Enable DM_GPIO and DM and GPIO Commands

2019-09-02 Thread Adam Ford
The da8xx GPIO driver is available with DM_GPIO support.  This
patch enables the CMD_GPIO, CMD_DM, and DM_GPIO and DA8XX_GPIO.

Signed-off-by: Adam Ford 
---
V2:  Fix GPIO redefinition warning by making the max number of GPIOS's be 
consistent

diff --git a/arch/arm/mach-davinci/include/mach/gpio.h 
b/arch/arm/mach-davinci/include/mach/gpio.h
index 3dca50f776..c150240962 100644
--- a/arch/arm/mach-davinci/include/mach/gpio.h
+++ b/arch/arm/mach-davinci/include/mach/gpio.h
@@ -22,11 +22,7 @@
 #define gpio_status()  gpio_info()
 #endif
 #define GPIO_NAME_SIZE 20
-#if !defined(CONFIG_SOC_DA850)
-#define MAX_NUM_GPIOS  128
-#else
 #define MAX_NUM_GPIOS  144
-#endif
 #define GPIO_BANK(gp)  (davinci_gpio_bank01 + ((gp) >> 5))
 
 void gpio_info(void);
diff --git a/configs/omapl138_lcdk_defconfig b/configs/omapl138_lcdk_defconfig
index 6813a8b2ae..c74d78b547 100644
--- a/configs/omapl138_lcdk_defconfig
+++ b/configs/omapl138_lcdk_defconfig
@@ -29,8 +29,8 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CRC32_VERIFY=y
 # CONFIG_CMD_EEPROM is not set
 CONFIG_MX_CYCLIC=y
+CONFIG_CMD_DM=y
 # CONFIG_CMD_FLASH is not set
-# CONFIG_CMD_GPIO is not set
 CONFIG_CMD_NAND=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_MTDPARTS=y
@@ -46,6 +46,8 @@ CONFIG_ENV_IS_IN_NAND=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DM=y
 CONFIG_SPL_DM=y
+CONFIG_DM_GPIO=y
+CONFIG_DA8XX_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DAVINCI=y
 CONFIG_DM_MMC=y
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 4/4] ARM: omapl138_lcdk: Enable Pinctrl

2019-09-02 Thread Adam Ford
The single pinctrl supports the da8xx, so this patch enables
pinctrl in U-Boot.

Signed-off-by: Adam Ford 
---
V2:  No change

diff --git a/configs/omapl138_lcdk_defconfig b/configs/omapl138_lcdk_defconfig
index c74d78b547..266f2c251c 100644
--- a/configs/omapl138_lcdk_defconfig
+++ b/configs/omapl138_lcdk_defconfig
@@ -32,6 +32,7 @@ CONFIG_MX_CYCLIC=y
 CONFIG_CMD_DM=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_NAND=y
+# CONFIG_CMD_PINMUX is not set
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=nand256"
@@ -64,6 +65,8 @@ CONFIG_MII=y
 CONFIG_DRIVER_TI_EMAC=y
 CONFIG_PHY=y
 CONFIG_PHY_DA8XX_USB=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_SINGLE=y
 CONFIG_SPECIFY_CONSOLE_INDEX=y
 CONFIG_DM_SERIAL=y
 CONFIG_SYS_NS16550=y
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 2/4] ARM: omapl138_lcdk: Disable SPL_DM_USB

2019-09-02 Thread Adam Ford
The USB was just recently enabled, so it is unlikely anyone is
using it in SPL, so this patch removes it from SPL to further
reduce the SPL code size.

Signed-off-by: Adam Ford 
---
V2:  No Change

diff --git a/configs/omapl138_lcdk_defconfig b/configs/omapl138_lcdk_defconfig
index 7e470bf73e..6813a8b2ae 100644
--- a/configs/omapl138_lcdk_defconfig
+++ b/configs/omapl138_lcdk_defconfig
@@ -67,6 +67,7 @@ CONFIG_DM_SERIAL=y
 CONFIG_SYS_NS16550=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
+# CONFIG_SPL_DM_USB is not set
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_OHCI_DA8XX=y
 CONFIG_USB_MUSB_HOST=y
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 1/4] ARM: omapl138_lcdk: Remove dead code

2019-09-02 Thread Adam Ford
The header it littered with #ifdefs and #defines and that appear
to be legacy associations to the older da850-evm and in some cases
obsolete with either Kconfig or DM migrations.  This patch removes
these legacy references.

Signed-off-by: Adam Ford 
---
V2:  No Change

diff --git a/include/configs/omapl138_lcdk.h b/include/configs/omapl138_lcdk.h
index 33155f0114..d34a5fcb37 100644
--- a/include/configs/omapl138_lcdk.h
+++ b/include/configs/omapl138_lcdk.h
@@ -13,8 +13,6 @@
 /*
  * Board
  */
-#undef CONFIG_USE_SPIFLASH
-#undef CONFIG_SYS_USE_NOR
 
 /*
  * SoC Configuration
@@ -103,21 +101,10 @@
  * Serial Driver info
  */
 #define CONFIG_SYS_NS16550_CLK clk_get(DAVINCI_UART2_CLKID)
-#if !defined(CONFIG_DM_SERIAL)
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE-4  /* NS16550 register size */
-#define CONFIG_SYS_NS16550_COM1DAVINCI_UART2_BASE /* Base address of 
UART2 */
-#define CONFIG_SYS_NS16550_CLK clk_get(DAVINCI_UART2_CLKID)
-#define CONFIG_SYS_BAUDRATE_TABLE  { 9600, 19200, 38400, 57600, 115200 }
-#endif
 
 #define CONFIG_SYS_SPI_BASEDAVINCI_SPI1_BASE
 #define CONFIG_SYS_SPI_CLK clk_get(DAVINCI_SPI1_CLKID)
 
-#ifdef CONFIG_USE_SPIFLASH
-#define CONFIG_SYS_SPI_U_BOOT_SIZE 0x3
-#endif
-
 /*
  * I2C Configuration
  */
@@ -167,24 +154,6 @@
 #define CONFIG_SPL_NAND_LOAD
 #endif
 
-#ifdef CONFIG_SYS_USE_NOR
-#define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of flash banks */
-#define CONFIG_SYS_FLASH_SECT_SZ   (128 << 10) /* 128KB */
-#define CONFIG_ENV_OFFSET  (CONFIG_SYS_FLASH_SECT_SZ * 3)
-#define CONFIG_ENV_SIZE(128 << 10)
-#define CONFIG_SYS_FLASH_BASE  DAVINCI_ASYNC_EMIF_DATA_CE2_BASE
-#define PHYS_FLASH_SIZE(8 << 20) /* Flash size 8MB */
-#define CONFIG_SYS_MAX_FLASH_SECT ((PHYS_FLASH_SIZE/CONFIG_SYS_FLASH_SECT_SZ)\
-  + 3)
-#define CONFIG_ENV_SECT_SIZE   CONFIG_SYS_FLASH_SECT_SZ
-#endif
-
-#ifdef CONFIG_USE_SPIFLASH
-#define CONFIG_ENV_SIZE(64 << 10)
-#define CONFIG_ENV_OFFSET  (256 << 10)
-#define CONFIG_ENV_SECT_SIZE   (64 << 10)
-#endif
-
 /*
  * Network & Ethernet Configuration
  */
@@ -243,12 +212,6 @@
 #define CONFIG_CLOCKS
 #endif
 
-#if !defined(CONFIG_NAND) && \
-   !defined(CONFIG_SYS_USE_NOR) && \
-   !defined(CONFIG_USE_SPIFLASH)
-#define CONFIG_ENV_SIZE(16 << 10)
-#endif
-
 /* SD/MMC */
 
 #ifdef CONFIG_ENV_IS_IN_MMC
@@ -258,7 +221,6 @@
 #define CONFIG_ENV_OFFSET  (51 << 9)   /* Sector 51 */
 #endif
 
-#ifndef CONFIG_DIRECT_NOR_BOOT
 /* defines for SPL */
 #define CONFIG_SYS_SPL_MALLOC_START(CONFIG_SYS_TEXT_BASE - \
CONFIG_SYS_MALLOC_LEN)
@@ -266,7 +228,6 @@
 #define CONFIG_SPL_STACK   0x8001ff00
 #define CONFIG_SPL_MAX_FOOTPRINT   32768
 #define CONFIG_SPL_PAD_TO  32768
-#endif
 
 /* additions for new relocation code, must added to all boards */
 #define CONFIG_SYS_SDRAM_BASE  0xc000
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 2/4] USB: host: Add the USB3 host driver

2019-09-02 Thread Sherry Sun
Hi Vignesh,

> 
> Hi Sherry,
> 
> [...]
> >> AFAIK, U-Boot does not support runtime switching of USB port to host
> >> from device and vice versa. This is the case for existing driver like
> DWC3/MUSB etc.
> >>
> >> Ideally we would need a role switch driver that unbinds and rebinds
> >> host vs device driver as when required based on U-Boot cmd or via an
> >> API (if required to be done during SPL stage etc).
> >
> > I wonder if we can add two subnodes under the wrapper node as below,
> one bind to usb gadget driver and another bind to usb host driver.
> > So if we want to use usb device, just call the gadget driver, and if want to
> use usb host, just call the host driver. The driver will probe correspond 
> node.
> > I'm not sure if it is feasible, what do you think about it?
> >
> >   usbss0: cdns_usb@4104000 {
> >   compatible = "ti,j721e-usb";
> >   []
> >   usb0: usb@601 {   /* xhci reg address*/
> >   compatible = "cdns,usb3-1.0.1";
> > dr_mode = "host";
> > []
> > }
> >   usb1: usb@602 {   /* dev reg address*/
> >   compatible = "cdns,usb3-1.0.1";
> > dr_mode = "peripheral";
> > []
> > }
> > }
> >
> 
> But this is not how DT would look in kernel. There will be single DT node
> representing both Host and Device node. DT repesentation should not be
> changed based on OS/bootloader, its HW description and must remain same.
> Unbinding host/gadget driver and rebinding with a different role should not
> be hard as the U-Boot core infrastructure exists.
> 
> Moreover if xhci reg and dev reg are separated into different nodes dont we
> still need access to OTG register block to switch b/w host and device mode?

I think we may not need to access OTG register if we add two subnodes for 
gadget and host.

But I see a for loop in dwc3_glue_bind() as follows, if there only one single 
node representing both Host and Device node under usb wrapper node, why we need 
this for loop?

212 for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
213  node = fdt_next_subnode(fdt, node)) {

Best regards
Sherry sun

> 
> Regards
> Vignesh
> 
> > Best regards
> > Sherry sun
> >
> >>
> >> Regards
> >> Vignesh
> >>
> >>> Best regards
> >>> Sherry sun
> >>>
> 
>  JJ
> 
> >> Then when binding the wrapper node, it will hard-coded the two
>  subnodes
> >> to different driver(gadge/host driver) according to the dr_mode
> >> property
>  in
> >> nodes.
> >>
> > Do you think I understand it right?
> 
> >
> > Best regards
> > Sherry sun
> >
> >> Best regards
> >> Sherry sun
> >>
> >>> JJ
> >>>
> >>>
> >>>
> > +   { }
> > +};
> >> ___
> >> U-Boot mailing list
> >> U-Boot@lists.denx.de
> >> https://l
> >>
> >>
> ists.ddata=02%7C01%7Csherry.sun%40nxp.com%7C7d1d76a7124f4c3f
> >> e9
> >>
> >>
> 9d08d72d3ddf82%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63
> >> 70276
> >>
> >>
> 16080089878sdata=70BPVQkomokcNpxsHRD3njfZQvuG51VSD1QKBjQ
> >> o1kA%3
> >> Dreserved=0
> >> enx.de%2Flistinfo%2Fu-
> >>
> 
> >>
> bootdata=02%7C01%7Csherry.sun%40nxp.com%7C35f1d34da1ea4b7
> >>
> 
> >>
> 670ba08d72b823e9a%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7
> >>
> 
> >>
> C637025710721487079sdata=Nfk0qWtSViz60wJHAOr2m5tgIwTWjNwI
> >> GrNOxDH6HC0%3Dreserved=0
> >>
> >> --
> >> Regards
> >> Vignesh
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] rpi3: Enable verified boot from FIT image

2019-09-02 Thread Heinrich Schuchardt

On 9/2/19 12:30 PM, Matthias Brugger wrote:

+Alex, Lukas, Heinrich, Bin and Simon

On 31/07/2019 10:16, Jun Nie wrote:

Matthias Brugger  于2019年7月31日周三 下午4:05写道:




On 11/07/2019 05:55, Jun Nie wrote:

Enable verified boot from FIT image with select configs
and specify boot script image node in FIT image, the FIT
image is verified before it is run.

Code that reusing dtb in firmware is disabled, so that
the dtb with pubic key packed in u-boot.bin can be used
to verify the signature of next stage FIT image.

Signed-off-by: Jun Nie 
---
  board/raspberrypi/rpi/rpi.c |  6 ++
  include/configs/rpi.h   | 15 ++-
  2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 617c892..950ee84 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -297,6 +297,7 @@ static void set_fdtfile(void)
   env_set("fdtfile", fdtfile);
  }

+#ifndef CONFIG_FIT_SIGNATURE
  /*
   * If the firmware provided a valid FDT at boot time, let's expose it in
   * ${fdt_addr} so it may be passed unmodified to the kernel.
@@ -311,6 +312,7 @@ static void set_fdt_addr(void)

   env_set_hex("fdt_addr", fw_dtb_pointer);
  }
+#endif

  /*
   * Prevent relocation from stomping on a firmware provided FDT blob.
@@ -393,7 +395,9 @@ static void set_serial_number(void)

  int misc_init_r(void)
  {
+#ifndef CONFIG_FIT_SIGNATURE
   set_fdt_addr();
+#endif
   set_fdtfile();
   set_usbethaddr();
  #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
@@ -470,6 +474,7 @@ int board_init(void)
   return bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
  }

+#ifndef CONFIG_FIT_SIGNATURE
  /*
   * If the firmware passed a device tree use it for U-Boot.
   */
@@ -479,6 +484,7 @@ void *board_fdt_blob_setup(void)
   return NULL;
   return (void *)fw_dtb_pointer;
  }
+#endif


Just to get this clear we need this because we want to pass the device tree via
OF_SEPARATE, correct?


You are right.  U-boot need to read he signature from dtb.





  int ft_board_setup(void *blob, bd_t *bd)
  {
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index f76c7d1..ba91205 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -180,11 +180,24 @@

  #include 

+#ifdef CONFIG_FIT_SIGNATURE
+#define FIT_BOOT_CMD \
+ "boot_a_script="\
+ "load ${devtype} ${devnum}:${distro_bootpart} " \
+ "${scriptaddr} ${prefix}${script}; "\
+ "iminfo ${scriptaddr};" \
+ "if test $? -eq 1; then reset; fi;" \
+ "source ${scriptaddr}:bootscr\0"
+#else
+#define FIT_BOOT_CMD ""
+#endif
+


Doesn't this overwrite the boot_a_script in distro_bootcmd?

Would it make sense to add FIT booting to the distro boot command?

Regards,
Matthias


Yes, it overwrite the boot_a_script in distro_bootcmd. It is make
sense to add this to the distro boot command. I can send another patch
to move these lines to common code later.



Question to the people just added, as you have relevant submission to
distroboot. Do you think it makes sense to add FIT_BOOT_CMD to that?

Regards,
Matthias


The idea of distro-boot was to make it easier for Linux distributions to
update the information needed by U-Boot to find the right kernel and
ramdisk.

According to doc/README.distro file extlinux.conf should be used for the
communication between the distribution and U-Boot. Some distributions
like Debian still rely on boot.scr.

Many distributions (OpenBSD, FreeBSD, Suse, Fedora) have moved from
distro-boot to UEFI as booting standard. Unfortunately we have not
documented our support for this in doc/README.distro (TODO for me).
Takahiro is working on secure boot using UEFI. Once completed this could
obsolete FIT images.

Would we expect Linux distributions to provide FIT images upon kernel
updates?
Is there any Linux distribution doing so?

Only if we can answer these questions with yes, adding FIT_BOOT_CMD to
distro-boot would make sense to me.

Best regards

Heinrich






  #define CONFIG_EXTRA_ENV_SETTINGS \
   "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \
   ENV_DEVICE_SETTINGS \
   ENV_MEM_LAYOUT_SETTINGS \
- BOOTENV
+ BOOTENV \
+ FIT_BOOT_CMD


  #endif







___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3] imx: support i.MX8QM ROM 7720 a1 board

2019-09-02 Thread Oliver Graute
On 02/09/19, Peng Fan wrote:
> > Subject: [PATCH v3] imx: support i.MX8QM ROM 7720 a1 board
> > 
> > +echo "ATF_LOAD_ADDR=$ATF_LOAD_ADDR" >&2 echo
> > +"BL33_LOAD_ADDR=$BL33_LOAD_ADDR" >&2
> > +
> 
> This is no needed.
> 

ok I`ll remove it

> > +config SYS_VENDOR
> > +   default "freescale"
> 
> This board is not from nxp(freescale). Please correct vendor.

yes vendor is advantech, I'll change that in next version
Then I need to move all files into the board/advantech folder?
> 
> > +Copy the following binaries to iMX8QM folder:
> > +
> > +$ cp imx-atf/build/imx8qm/release/bl31.bin .
> > +$ cp u-boot/u-boot.bin .
> > +
> > +Copy the following firmwares U-Boot folder :
> > +
> > +$ cp firmware-imx-8.0/firmware/seco/mx8qm-ahab-container.img .
> > +$ cp imx-sc-firmware-1.1/mx8qm-val-scfw-tcm.bin scfw_tcm.bin
> > +
> > +$ make SOC=iMX8QM flash_linux_m4
> 
> flash_linux_m4 is not a valid build target in U-Boot.

yes indeed but this is the build target in the imx-mkimage repo. Which I
currently need to build the complete bootstream with ATF and scu.

> > SC_PM_PW_MODE_ON);
> > +   if (ret)
> > +   return ret;
> > +
> > +   ret = sc_pm_set_clock_rate(-1, SC_R_UART_0, 2, );
> > +   if (ret)
> > +   return ret;
> > +
> > +   /* Enable UART0 clock root */
> > +   ret = sc_pm_clock_enable(-1, SC_R_UART_0, 2, true, false);
> > +   if (ret)
> > +   return ret;
> 
> Please use sc_pm_setup_uart

ok
> 
> > +
> > +   setup_iomux_uart();
> > +
> > +   sc_pm_set_resource_power_mode(-1, SC_R_DC_0,
> > SC_PM_PW_MODE_ON);
> 
> Why power up DC_0? Should not kernel do it by itself?

Without this change the kernel is stucked during the boot. So currently
the kernel don't power up DC_0. So I would like to keep that until it is
fixed in the kernel.

> 
> > +#if IS_ENABLED(CONFIG_DM_GPIO)
> > +static void board_gpio_init(void)
> > +{
> > +   /* TODO */
> > +}
> > +#else
> > +static inline void board_gpio_init(void) {} #endif
> 
> If do nothing, please drop.

ok
> 
> > +
> > +#if IS_ENABLED(CONFIG_FEC_MXC)
> > +#include 
> > +
> > +int board_phy_config(struct phy_device *phydev) { #ifdef
> > +CONFIG_FEC_ENABLE_MAX7322
> > +   u8 value;
> > +
> > +   /* This is needed to drive the pads to 1.8V instead of 1.5V */
> > +   i2c_set_bus_num(CONFIG_MAX7322_I2C_BUS);
> > +
> > +   if (!i2c_probe(CONFIG_MAX7322_I2C_ADDR)) {
> > +   /* Write 0x1 to enable O0 output, this device has no addr */
> > +   /* hence addr length is 0 */
> > +   value = 0x1;
> > +   if (i2c_write(CONFIG_MAX7322_I2C_ADDR, 0, 0, , 1))
> > +   printf("MAX7322 write failed\n");
> > +   } else {
> > +   printf("MAX7322 Not found\n");
> > +   }
> > +   mdelay(1);
> 
> Please use DM_I2C.

I don't get what you mean here.

> > +#ifdef CONFIG_OF_BOARD_SETUP
> > +int ft_board_setup(void *blob, bd_t *bd) {
> > +   return 0;
> > +}
> > +#endif
> 
> Drop it do nothing.

I got some linking erros if I try to remove that ft_board_setup.

> > +int board_mmc_getcd(struct mmc *mmc)
> > +{
> > +   struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
> > +   int ret = 0;
> > +
> > +   switch (cfg->esdhc_base) {
> > +   case USDHC1_BASE_ADDR:
> > +   ret = 1;
> > +   break;
> > +   case USDHC2_BASE_ADDR:
> > +   ret = !gpio_get_value(USDHC1_CD_GPIO);
> > +   break;
> > +   case USDHC3_BASE_ADDR:
> > +   ret = !gpio_get_value(USDHC2_CD_GPIO);
> > +   break;
> > +   }
> > +
> > +   return ret;
> > +}
> 
> SPL_DM_MMC should help.

you mean I should turn on CONFIG_SPL_DM_MMC=y ?
> 
> > +
> > +#endif /* CONFIG_FSL_ESDHC */
> > +
> > +void spl_dram_init(void)
> > +{
> > +   /* do nothing for now */
> > +}
> 
> Drop
> 
> > +CONFIG_SYS_MALLOC_F_LEN=0x4000
> 
> This might not large enough, check how i.MX8QM MEK does in upstream.

should I use CONFIG_SYS_MALLOC_F_LEN=0x2000 ?

> > +CONFIG_DM_PCA953X=y
> > +CONFIG_DM_I2C=y
> > +CONFIG_SYS_I2C_IMX_LPI2C=y
> > +CONFIG_I2C_MUX=y
> > +CONFIG_I2C_MUX_PCA954x=y
> > +CONFIG_MISC=y
> > +CONFIG_DM_MMC=y
> > +CONFIG_FSL_ESDHC_IMX=y
> > +CONFIG_PHYLIB=y
> > +CONFIG_PHY_ADDR_ENABLE=y
> > +CONFIG_PHY_ATHEROS=y
> > +CONFIG_DM_ETH=y
> > +CONFIG_PHY_GIGE=y
> > +CONFIG_FEC_MXC_SHARE_MDIO=y
> > +CONFIG_FEC_MXC_MDIO_BASE=0x5B04
> > +CONFIG_FEC_MXC=y
> > +CONFIG_MII=y
> > +CONFIG_PINCTRL=y
> > +CONFIG_SPL_PINCTRL=y
> > +CONFIG_PINCTRL_IMX8=y
> > +CONFIG_POWER_DOMAIN=y
> > +CONFIG_IMX8_POWER_DOMAIN=y
> > +CONFIG_DM_REGULATOR=y
> > +CONFIG_SPL_DM_REGULATOR=y
> > +CONFIG_DM_REGULATOR_FIXED=y
> > +CONFIG_DM_REGULATOR_GPIO=y
> > +CONFIG_SPL_DM_REGULATOR_GPIO=y
> > +CONFIG_DM_SERIAL=y
> > +CONFIG_FSL_LPUART=y
> > +CONFIG_SPL_TINY_MEMSET=y
> > +# CONFIG_EFI_LOADER is not set
> > +CONFIG_ARCH_MISC_INIT
> > +CONFIG_NET_RANDOM_ETHADDR=y
> > diff --git a/include/configs/imx8qm_rom7720.h
> > b/include/configs/imx8qm_rom7720.h
> > new file mode 100644
> > index 00..a5c869b94e
> > --- /dev/null
> > +++ b/include/configs/imx8qm_rom7720.h

Re: [U-Boot] [PATCH] avb: verify: return fail if there is no uuid in partition info

2019-09-02 Thread Igor Opaniuk
Hi Kever,

On Mon, Sep 2, 2019 at 11:01 AM Kever Yang  wrote:
>
> There is not always have uuid in disk_partition_t, we can only get from
> partitions info when PARTITION_UUIDS is available.
>
> Signed-off-by: Kever Yang 
> ---
>
>  common/avb_verify.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/common/avb_verify.c b/common/avb_verify.c
> index 36898a610f..314c5f7a3e 100644
> --- a/common/avb_verify.c
> +++ b/common/avb_verify.c
> @@ -803,6 +803,7 @@ static AvbIOResult get_unique_guid_for_partition(AvbOps 
> *ops,
>  char *guid_buf,
>  size_t guid_buf_size)
>  {
> +#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
> struct mmc_part *part;
> size_t uuid_size;
>
> @@ -818,6 +819,9 @@ static AvbIOResult get_unique_guid_for_partition(AvbOps 
> *ops,
> guid_buf[uuid_size - 1] = 0;
>
> return AVB_IO_RESULT_OK;
> +#else
> +   return AVB_IO_RESULT_ERROR_IO;
> +#endif
>  }
>
>  /**
> --
> 2.17.1
>
get_unique_guid_for_partition() is mandatory for proper
avb_slot_verify() functioning, so having stub which returns
AVB_IO_RESULT_ERROR_IO makes no sense (
avb_sub_cmdline() will be always failing). IMHO that would be
better to imply/add dependency on PARTITION_UUIDS
in lib/Kconfig.

You can just move dependency on PARTITION_UUIDS
from common/Kconfig (AVB_VERIFY symbol) to lib/Kconfig
for LIBAVB symbol.

Thanks!

-- 
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opan...@gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] rpi3: Enable verified boot from FIT image

2019-09-02 Thread Matthias Brugger
+Alex, Lukas, Heinrich, Bin and Simon

On 31/07/2019 10:16, Jun Nie wrote:
> Matthias Brugger  于2019年7月31日周三 下午4:05写道:
>>
>>
>>
>> On 11/07/2019 05:55, Jun Nie wrote:
>>> Enable verified boot from FIT image with select configs
>>> and specify boot script image node in FIT image, the FIT
>>> image is verified before it is run.
>>>
>>> Code that reusing dtb in firmware is disabled, so that
>>> the dtb with pubic key packed in u-boot.bin can be used
>>> to verify the signature of next stage FIT image.
>>>
>>> Signed-off-by: Jun Nie 
>>> ---
>>>  board/raspberrypi/rpi/rpi.c |  6 ++
>>>  include/configs/rpi.h   | 15 ++-
>>>  2 files changed, 20 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
>>> index 617c892..950ee84 100644
>>> --- a/board/raspberrypi/rpi/rpi.c
>>> +++ b/board/raspberrypi/rpi/rpi.c
>>> @@ -297,6 +297,7 @@ static void set_fdtfile(void)
>>>   env_set("fdtfile", fdtfile);
>>>  }
>>>
>>> +#ifndef CONFIG_FIT_SIGNATURE
>>>  /*
>>>   * If the firmware provided a valid FDT at boot time, let's expose it in
>>>   * ${fdt_addr} so it may be passed unmodified to the kernel.
>>> @@ -311,6 +312,7 @@ static void set_fdt_addr(void)
>>>
>>>   env_set_hex("fdt_addr", fw_dtb_pointer);
>>>  }
>>> +#endif
>>>
>>>  /*
>>>   * Prevent relocation from stomping on a firmware provided FDT blob.
>>> @@ -393,7 +395,9 @@ static void set_serial_number(void)
>>>
>>>  int misc_init_r(void)
>>>  {
>>> +#ifndef CONFIG_FIT_SIGNATURE
>>>   set_fdt_addr();
>>> +#endif
>>>   set_fdtfile();
>>>   set_usbethaddr();
>>>  #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
>>> @@ -470,6 +474,7 @@ int board_init(void)
>>>   return bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
>>>  }
>>>
>>> +#ifndef CONFIG_FIT_SIGNATURE
>>>  /*
>>>   * If the firmware passed a device tree use it for U-Boot.
>>>   */
>>> @@ -479,6 +484,7 @@ void *board_fdt_blob_setup(void)
>>>   return NULL;
>>>   return (void *)fw_dtb_pointer;
>>>  }
>>> +#endif
>>
>> Just to get this clear we need this because we want to pass the device tree 
>> via
>> OF_SEPARATE, correct?
> 
> You are right.  U-boot need to read he signature from dtb.
> 
>>
>>>
>>>  int ft_board_setup(void *blob, bd_t *bd)
>>>  {
>>> diff --git a/include/configs/rpi.h b/include/configs/rpi.h
>>> index f76c7d1..ba91205 100644
>>> --- a/include/configs/rpi.h
>>> +++ b/include/configs/rpi.h
>>> @@ -180,11 +180,24 @@
>>>
>>>  #include 
>>>
>>> +#ifdef CONFIG_FIT_SIGNATURE
>>> +#define FIT_BOOT_CMD \
>>> + "boot_a_script="\
>>> + "load ${devtype} ${devnum}:${distro_bootpart} " \
>>> + "${scriptaddr} ${prefix}${script}; "\
>>> + "iminfo ${scriptaddr};" \
>>> + "if test $? -eq 1; then reset; fi;" \
>>> + "source ${scriptaddr}:bootscr\0"
>>> +#else
>>> +#define FIT_BOOT_CMD ""
>>> +#endif
>>> +
>>
>> Doesn't this overwrite the boot_a_script in distro_bootcmd?
>>
>> Would it make sense to add FIT booting to the distro boot command?
>>
>> Regards,
>> Matthias
> 
> Yes, it overwrite the boot_a_script in distro_bootcmd. It is make
> sense to add this to the distro boot command. I can send another patch
> to move these lines to common code later.
> 

Question to the people just added, as you have relevant submission to
distroboot. Do you think it makes sense to add FIT_BOOT_CMD to that?

Regards,
Matthias

>>
>>>  #define CONFIG_EXTRA_ENV_SETTINGS \
>>>   "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \
>>>   ENV_DEVICE_SETTINGS \
>>>   ENV_MEM_LAYOUT_SETTINGS \
>>> - BOOTENV
>>> + BOOTENV \
>>> + FIT_BOOT_CMD
>>>
>>>
>>>  #endif
>>>
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/7] arm: dts: imx8qxp-mek: add u-boot, dm-spl for lpuart0

2019-09-02 Thread Peng Fan
lpuart0 is the uart used by SPL and U-Boot proper, and DM_SERIAL
is enabled. Since uclass power domain is also enabled, to make
lpuart work properly, need add u-boot,dm-spl for lpuart power domain
and its parent.

Signed-off-by: Peng Fan 
---
 arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi 
b/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi
index 201559008c..771ab635f1 100644
--- a/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi
+++ b/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi
@@ -72,6 +72,14 @@
u-boot,dm-spl;
 };
 
+_dma {
+   u-boot,dm-spl;
+};
+
+_dma_lpuart0 {
+   u-boot,dm-spl;
+};
+
  {
u-boot,dm-spl;
 };
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 5/7] misc: scu: Increase the timeout for MU communication

2019-09-02 Thread Peng Fan
From: Ye Li 

When power on some sources in Video system, current timeout 10ms is
too short and returns before SCU response. So increase the timeout
to 1s.

Signed-off-by: Ye Li 
Signed-off-by: Peng Fan 
---
 drivers/misc/imx8/scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c
index a7654a7817..6916b754f6 100644
--- a/drivers/misc/imx8/scu.c
+++ b/drivers/misc/imx8/scu.c
@@ -74,7 +74,7 @@ static int mu_hal_receivemsg(struct mu_type *base, u32 
reg_index, u32 *msg)
assert(reg_index < MU_TR_COUNT);
 
/* Wait RX register to be full. */
-   ret = readl_poll_timeout(>sr, val, val & mask, 1);
+   ret = readl_poll_timeout(>sr, val, val & mask, 100);
if (ret < 0) {
printf("%s timeout\n", __func__);
return -ETIMEDOUT;
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 6/7] power: domain: make imx8-power-domain.c legacy

2019-09-02 Thread Peng Fan
The current i.MX8 power domain driver is based on i.MX vendor
power domain tree which will retire later.

The Linux upstream use a single pd node for power domain driver,
and U-Boot will adopt that. When U-Boot i.MX8 dts synced with
Linux Kernel upstream and related driver ready, the legacy
driver will be removed.

Signed-off-by: Peng Fan 
---
 drivers/power/domain/Makefile   | 2 +-
 .../power/domain/{imx8-power-domain.c => imx8-power-domain-legacy.c}| 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename drivers/power/domain/{imx8-power-domain.c => 
imx8-power-domain-legacy.c} (100%)

diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile
index 695aafe17d..97194787c0 100644
--- a/drivers/power/domain/Makefile
+++ b/drivers/power/domain/Makefile
@@ -5,7 +5,7 @@
 
 obj-$(CONFIG_$(SPL_)POWER_DOMAIN) += power-domain-uclass.o
 obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
-obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain.o
+obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o
 obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
 obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
 obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o
diff --git a/drivers/power/domain/imx8-power-domain.c 
b/drivers/power/domain/imx8-power-domain-legacy.c
similarity index 100%
rename from drivers/power/domain/imx8-power-domain.c
rename to drivers/power/domain/imx8-power-domain-legacy.c
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 4/7] misc: imx8: scu: simplify code to make it extendable

2019-09-02 Thread Peng Fan
clk and pinctrl will be get(probed) during each device probe,
we don't need to probe them in scu driver. Only need to bind the sub-nodes
(clk and iomuxc) of MU node with their drivers.

So drop the code to probe the clk/pinctrl, and this patch will make it
easy to add more subnodes.

Signed-off-by: Peng Fan 
---
 drivers/misc/imx8/scu.c | 46 +++---
 1 file changed, 7 insertions(+), 39 deletions(-)

diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c
index 9ec00457b8..a7654a7817 100644
--- a/drivers/misc/imx8/scu.c
+++ b/drivers/misc/imx8/scu.c
@@ -26,8 +26,6 @@ struct mu_type {
 
 struct imx8_scu {
struct mu_type *base;
-   struct udevice *clk;
-   struct udevice *pinclk;
 };
 
 #define MU_CR_GIE_MASK 0xF000u
@@ -202,9 +200,6 @@ static int imx8_scu_probe(struct udevice *dev)
 
gd->arch.scu_dev = dev;
 
-   device_probe(plat->clk);
-   device_probe(plat->pinclk);
-
return 0;
 }
 
@@ -215,44 +210,17 @@ static int imx8_scu_remove(struct udevice *dev)
 
 static int imx8_scu_bind(struct udevice *dev)
 {
-   struct imx8_scu *plat = dev_get_platdata(dev);
int ret;
struct udevice *child;
-   int node;
-   char *clk_compatible, *iomuxc_compatible;
-
-   if (IS_ENABLED(CONFIG_IMX8QXP)) {
-   clk_compatible = "fsl,imx8qxp-clk";
-   iomuxc_compatible = "fsl,imx8qxp-iomuxc";
-   } else if (IS_ENABLED(CONFIG_IMX8QM)) {
-   clk_compatible = "fsl,imx8qm-clk";
-   iomuxc_compatible = "fsl,imx8qm-iomuxc";
-   } else {
-   return -EINVAL;
-   }
+   ofnode node;
 
debug("%s(dev=%p)\n", __func__, dev);
-
-   node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, clk_compatible);
-   if (node < 0)
-   panic("No clk node found\n");
-
-   ret = lists_bind_fdt(dev, offset_to_ofnode(node), , true);
-   if (ret)
-   return ret;
-
-   plat->clk = child;
-
-   node = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
-iomuxc_compatible);
-   if (node < 0)
-   panic("No iomuxc node found\n");
-
-   ret = lists_bind_fdt(dev, offset_to_ofnode(node), , true);
-   if (ret)
-   return ret;
-
-   plat->pinclk = child;
+   ofnode_for_each_subnode(node, dev_ofnode(dev)) {
+   ret = lists_bind_fdt(dev, node, , true);
+   if (ret)
+   return ret;
+   debug("bind child dev %s\n", child->name);
+   }
 
return 0;
 }
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 7/7] power: domain: add i.MX8 scu power domain driver

2019-09-02 Thread Peng Fan
The power domain tree is not accepted by Linux Kernel upstream.
only a single pd node is used currently, as following:

pd: imx8qx-pd {
compatible = "fsl,imx8qm-scu-pd", "fsl,scu-pd";
#power-domain-cells = <1>;
};

So to migrate to use upstream linux dts, we also need a driver
to support this.

This patch is to support the new method, compared with legacy power
domain tree, it will be simpiler, because each device will
has resource id as power domain index, it will be directly passed
to scfw, and no need to let power domain build that tree. If multiple
power domain is needed, it is the dts node should has correctly power
domains entry added and sequence correct.

Signed-off-by: Peng Fan 
---
 drivers/power/domain/Makefile|  2 +-
 drivers/power/domain/imx8-power-domain.c | 87 
 2 files changed, 88 insertions(+), 1 deletion(-)
 create mode 100644 drivers/power/domain/imx8-power-domain.c

diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile
index 97194787c0..81fbd89e15 100644
--- a/drivers/power/domain/Makefile
+++ b/drivers/power/domain/Makefile
@@ -5,7 +5,7 @@
 
 obj-$(CONFIG_$(SPL_)POWER_DOMAIN) += power-domain-uclass.o
 obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
-obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o
+obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o 
imx8-power-domain.o
 obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
 obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
 obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o
diff --git a/drivers/power/domain/imx8-power-domain.c 
b/drivers/power/domain/imx8-power-domain.c
new file mode 100644
index 00..aa768365b4
--- /dev/null
+++ b/drivers/power/domain/imx8-power-domain.c
@@ -0,0 +1,87 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2019 NXP
+ */
+
+#define DEBUG
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int imx8_power_domain_request(struct power_domain *power_domain)
+{
+   debug("%s(power_domain=%p)\n", __func__, power_domain);
+
+   return 0;
+}
+
+static int imx8_power_domain_free(struct power_domain *power_domain)
+{
+   debug("%s(power_domain=%p)\n", __func__, power_domain);
+
+   return 0;
+}
+
+static int imx8_power_domain_on(struct power_domain *power_domain)
+{
+   u32 resource_id = power_domain->id;
+   int ret;
+
+   debug("%s: resource_id %u\n", __func__, resource_id);
+
+   ret = sc_pm_set_resource_power_mode(-1, resource_id, SC_PM_PW_MODE_ON);
+   if (ret) {
+   printf("Error: %u Power up failed! (error = %d)\n",
+  resource_id, ret);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int imx8_power_domain_off(struct power_domain *power_domain)
+{
+   u32 resource_id = power_domain->id;
+   int ret;
+
+   debug("%s: resource_id %u\n", __func__, resource_id);
+
+   ret = sc_pm_set_resource_power_mode(-1, resource_id, SC_PM_PW_MODE_OFF);
+   if (ret) {
+   printf("Error: %u Power off failed! (error = %d)\n",
+  resource_id, ret);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int imx8_power_domain_probe(struct udevice *dev)
+{
+   debug("%s(dev=%s)\n", __func__, dev->name);
+
+   return 0;
+}
+
+static const struct udevice_id imx8_power_domain_ids[] = {
+   { .compatible = "fsl,imx8qxp-scu-pd" },
+   { .compatible = "fsl,scu-pd" },
+   { }
+};
+
+struct power_domain_ops imx8_power_domain_ops_v2 = {
+   .request = imx8_power_domain_request,
+   .free = imx8_power_domain_free,
+   .on = imx8_power_domain_on,
+   .off = imx8_power_domain_off,
+};
+
+U_BOOT_DRIVER(imx8_power_domain_v2) = {
+   .name = "imx8_power_domain_v2",
+   .id = UCLASS_POWER_DOMAIN,
+   .of_match = imx8_power_domain_ids,
+   .probe = imx8_power_domain_probe,
+   .ops = _power_domain_ops_v2,
+};
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/7] arm: dts: imx8qm-mek: add u-boot, dm-spl for lpuart0

2019-09-02 Thread Peng Fan
lpuart0 is the uart used by SPL and U-Boot proper, and DM_SERIAL
is enabled. Since uclass power domain is also enabled, to make
lpuart work properly, need add u-boot,dm-spl for lpuart power domain
and its parent.

Signed-off-by: Peng Fan 
---
 arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi 
b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi
index 9a4a83b70e..80d6475b7c 100644
--- a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi
+++ b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi
@@ -72,6 +72,14 @@
u-boot,dm-spl;
 };
 
+_dma {
+   u-boot,dm-spl;
+};
+
+_dma_lpuart0 {
+   u-boot,dm-spl;
+};
+
  {
u-boot,dm-spl;
 };
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/7] imx8qm: mek: enable dm-spl for pm

2019-09-02 Thread Peng Fan
with u-boot,dm-spl added for imx8qm-pm node, and SPL_SIMPLE_BUS enabled,
the bind and probe code in board file could be removed.

Also we need to enlarge SYS_MALLOC_F_LEN to avoid calloc fail.

Signed-off-by: Peng Fan 
---
 arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi |  5 +
 board/freescale/imx8qm_mek/spl.c| 16 
 configs/imx8qm_mek_defconfig|  1 +
 3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi 
b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi
index 5d50eb028e..9a4a83b70e 100644
--- a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi
+++ b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi
@@ -3,6 +3,11 @@
  * Copyright 2018 NXP
  */
 
+&{/imx8qm-pm} {
+
+   u-boot,dm-spl;
+};
+
  {
u-boot,dm-spl;
 };
diff --git a/board/freescale/imx8qm_mek/spl.c b/board/freescale/imx8qm_mek/spl.c
index 95ce9f37e8..cb4006eb2a 100644
--- a/board/freescale/imx8qm_mek/spl.c
+++ b/board/freescale/imx8qm_mek/spl.c
@@ -18,7 +18,6 @@ DECLARE_GLOBAL_DATA_PTR;
 void spl_board_init(void)
 {
struct udevice *dev;
-   int offset;
 
uclass_find_first_device(UCLASS_MISC, );
 
@@ -27,21 +26,6 @@ void spl_board_init(void)
continue;
}
 
-   offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "nxp,imx8-pd");
-   while (offset != -FDT_ERR_NOTFOUND) {
-   lists_bind_fdt(gd->dm_root, offset_to_ofnode(offset),
-  NULL, true);
-   offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
-  "nxp,imx8-pd");
-   }
-
-   uclass_find_first_device(UCLASS_POWER_DOMAIN, );
-
-   for (; dev; uclass_find_next_device()) {
-   if (device_probe(dev))
-   continue;
-   }
-
arch_cpu_init();
 
board_early_init_f();
diff --git a/configs/imx8qm_mek_defconfig b/configs/imx8qm_mek_defconfig
index 3294931ef8..594eb9efb2 100644
--- a/configs/imx8qm_mek_defconfig
+++ b/configs/imx8qm_mek_defconfig
@@ -6,6 +6,7 @@ CONFIG_SYS_TEXT_BASE=0x8002
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_TARGET_IMX8QM_MEK=y
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] core: device: support multiple power domains for one device

2019-09-02 Thread Peng Fan
When device has multiple power domains, power_domain_get could
not able to support that. So let's iterate each power domain
and enable it.

Signed-off-by: Peng Fan 
---
 drivers/core/device.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 474c1642ee..67fcff87fa 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -311,7 +311,7 @@ int device_probe(struct udevice *dev)
const struct driver *drv;
int size = 0;
int ret;
-   int seq;
+   int seq, i, count;
 
if (!dev)
return -EINVAL;
@@ -390,8 +390,16 @@ int device_probe(struct udevice *dev)
 
if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent &&
device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) {
-   if (!power_domain_get(dev, ))
-   power_domain_on();
+   count = dev_count_phandle_with_args(dev, "power-domains",
+   "#power-domain-cells");
+   for (i = 0; i < count; i++) {
+   ret = power_domain_get_by_index(dev, , i);
+   if (ret)
+   goto fail;
+   ret = power_domain_on();
+   if (ret)
+   goto fail;
+   }
}
 
ret = uclass_pre_probe_device(dev);
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] configs: Add Khadas VIM3 defconfig

2019-09-02 Thread Neil Armstrong
On 02/09/2019 05:02, Andreas Färber wrote:
> Am 02.09.19 um 04:28 schrieb Andreas Färber:
>> diff --git a/board/amlogic/w400/README.khadas-vim3 
>> b/board/amlogic/w400/README.khadas-vim3
>> new file mode 100644
>> index 00..39b2b06000
>> --- /dev/null
>> +++ b/board/amlogic/w400/README.khadas-vim3
> [...]
>> + > DIR=vim3-u-boot
>> + > git clone --depth 1 \
>> +   https://github.com/khadas/u-boot.git -b khadas-vim3-v2015.01 \
>> +   $DIR
> 
> That branch name should've been khadas-vims-v2015.01 - both exist, the
> above one was not working and the reason I held back the patches.

Ok, this patch looks fine, please add :
Reviewed-by: Neil Armstrong 
when you re-spin.

Neil

> 
> Regards,
> Andreas
> 

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: dts: Import and update DT for Khadas VIM3

2019-09-02 Thread Neil Armstrong
Hi Andreas,

On 02/09/2019 04:28, Andreas Färber wrote:
> In Linux meson-g12-common.dtsi was introduced as well as new g12b nodes
> and headers, as dependencies of new meson-g12b-a311d-khadas-vim3.dts.

Can you precise the Linux commit ID you sync'ed from ?
The best would be to sync from the v2 dt64 PR from kevin :
https://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic.git/tag/?h=amlogic-dt64-2.1

Thanks,
Neil

> 
> Signed-off-by: Andreas Färber 
> ---
>  arch/arm/dts/Makefile  |3 +-
>  arch/arm/dts/meson-g12-common.dtsi | 2435 
> 
>  arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts  |   15 +

Can you also sync the s922x version ?

>  arch/arm/dts/meson-g12b-a311d.dtsi |  149 ++
>  arch/arm/dts/meson-g12b-khadas-vim3.dtsi   |  544 +
>  arch/arm/dts/meson-g12b.dtsi   |   39 +-
>  include/dt-bindings/clock/g12a-clkc.h  |6 +
>  include/dt-bindings/power/meson-g12a-power.h   |   13 +
>  .../reset/amlogic,meson-g12a-audio-reset.h |   38 +
>  9 files changed, 3238 insertions(+), 4 deletions(-)
>  create mode 100644 arch/arm/dts/meson-g12-common.dtsi
>  create mode 100644 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts
>  create mode 100644 arch/arm/dts/meson-g12b-a311d.dtsi
>  create mode 100644 arch/arm/dts/meson-g12b-khadas-vim3.dtsi
>  create mode 100644 include/dt-bindings/power/meson-g12a-power.h
>  create mode 100644 include/dt-bindings/reset/amlogic,meson-g12a-audio-reset.h
> 
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index aac1b83d49..6de5e4c62a 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -141,7 +141,8 @@ dtb-$(CONFIG_ARCH_MESON) += \
>   meson-axg-s400.dtb \
>   meson-g12a-u200.dtb \
>   meson-g12a-sei510.dtb \
> - meson-g12b-odroid-n2.dtb
> + meson-g12b-odroid-n2.dtb \
> + meson-g12b-a311d-khadas-vim3.dtb

Same here, can you also build the s922x variant ?

>  dtb-$(CONFIG_TEGRA) += tegra20-harmony.dtb \
>   tegra20-medcom-wide.dtb \
>   tegra20-paz00.dtb \
> diff --git a/arch/arm/dts/meson-g12-common.dtsi 
> b/arch/arm/dts/meson-g12-common.dtsi
> new file mode 100644
> index 00..3f39e020f7
> --- /dev/null
> +++ b/arch/arm/dts/meson-g12-common.dtsi
> @@ -0,0 +1,2435 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright (c) 2018 Amlogic, Inc. All rights reserved.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/ {
> + interrupt-parent = <>;
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + tdmif_a: audio-controller-0 {
> + compatible = "amlogic,axg-tdm-iface";
> + #sound-dai-cells = <0>;
> + sound-name-prefix = "TDM_A";
> + clocks = <_audio AUD_CLKID_MST_A_MCLK>,
> +  <_audio AUD_CLKID_MST_A_SCLK>,
> +  <_audio AUD_CLKID_MST_A_LRCLK>;
> + clock-names = "mclk", "sclk", "lrclk";
> + status = "disabled";
> + };
> +
> + tdmif_b: audio-controller-1 {
> + compatible = "amlogic,axg-tdm-iface";
> + #sound-dai-cells = <0>;
> + sound-name-prefix = "TDM_B";
> + clocks = <_audio AUD_CLKID_MST_B_MCLK>,
> +  <_audio AUD_CLKID_MST_B_SCLK>,
> +  <_audio AUD_CLKID_MST_B_LRCLK>;
> + clock-names = "mclk", "sclk", "lrclk";
> + status = "disabled";
> + };
> +
> + tdmif_c: audio-controller-2 {
> + compatible = "amlogic,axg-tdm-iface";
> + #sound-dai-cells = <0>;
> + sound-name-prefix = "TDM_C";
> + clocks = <_audio AUD_CLKID_MST_C_MCLK>,
> +  <_audio AUD_CLKID_MST_C_SCLK>,
> +  <_audio AUD_CLKID_MST_C_LRCLK>;
> + clock-names = "mclk", "sclk", "lrclk";
> + status = "disabled";
> + };
> +
> + efuse: efuse {
> + compatible = "amlogic,meson-gxbb-efuse";
> + clocks = < CLKID_EFUSE>;
> + #address-cells = <1>;
> + #size-cells = <1>;
> + read-only;
> + };
> +
> + psci {
> + compatible = "arm,psci-1.0";
> + method = "smc";
> + };
> +
> + reserved-memory {
> + #address-cells = <2>;
> + #size-cells = <2>;
> + ranges;
> +
> + /* 3 MiB reserved for ARM Trusted Firmware (BL31) */
> + secmon_reserved: secmon@500 {
> + reg = <0x0 0x0500 0x0 0x30>;
> + no-map;
> + };
> +
> + linux,cma {
> + compatible = "shared-dma-pool";
> + reusable;
> + size = <0x0 0x1000>;
> + alignment = <0x0 0x40>;

[U-Boot] [PATCH] arc: libgcc: Import __udivdi3 & __udivmoddi4 to allow 64-bit division

2019-09-02 Thread Alexey Brodkin
As reported by Kever here [1] we were unable to compile 64-bit division
code due to missing definition of __udivdi3().

Import its implementation and __udivmoddi4() as its direct dependency
from today's libgcc [2].

[1] https://patchwork.ozlabs.org/patch/1146845/
[2] 
https://github.com/gcc-mirror/gcc/commit/5d8723600bc0eed41226b5a6785bc02a053b45d5

Signed-off-by: Alexey Brodkin 
Cc: Kever Yang 
---
 arch/arc/lib/libgcc2.c | 75 ++
 1 file changed, 75 insertions(+)

diff --git a/arch/arc/lib/libgcc2.c b/arch/arc/lib/libgcc2.c
index b92a841a37..ab1dbe1c13 100644
--- a/arch/arc/lib/libgcc2.c
+++ b/arch/arc/lib/libgcc2.c
@@ -158,3 +158,78 @@ __umodsi3(long a, long b)
 {
return udivmodsi4(a, b, 1);
 }
+
+UDWtype
+__udivmoddi4(UDWtype n, UDWtype d, UDWtype *rp)
+{
+   UDWtype q = 0, r = n, y = d;
+   UWtype lz1, lz2, i, k;
+
+   /*
+* Implements align divisor shift dividend method. This algorithm
+* aligns the divisor under the dividend and then perform number of
+* test-subtract iterations which shift the dividend left. Number of
+* iterations is k + 1 where k is the number of bit positions the
+* divisor must be shifted left  to align it under the dividend.
+* quotient bits can be saved in the rightmost positions of the
+* dividend as it shifts left on each test-subtract iteration.
+*/
+
+   if (y <= r) {
+   lz1 = __builtin_clzll(d);
+   lz2 = __builtin_clzll(n);
+
+   k = lz1 - lz2;
+   y = (y << k);
+
+   /*
+* Dividend can exceed 2 ^ (width - 1) - 1 but still be less
+* than the aligned divisor. Normal iteration can drops the
+* high order bit of the dividend. Therefore, first
+* test-subtract iteration is a special case, saving its
+* quotient bit in a separate location and not shifting
+* the dividend.
+*/
+
+   if (r >= y) {
+   r = r - y;
+   q = (1ULL << k);
+   }
+
+   if (k > 0) {
+   y = y >> 1;
+
+   /*
+* k additional iterations where k regular test
+* subtract shift dividend iterations are done.
+*/
+   i = k;
+   do {
+   if (r >= y)
+   r = ((r - y) << 1) + 1;
+   else
+   r = (r << 1);
+   i = i - 1;
+   } while (i != 0);
+
+   /*
+* First quotient bit is combined with the quotient
+* bits resulting from the k regular iterations.
+*/
+   q = q + r;
+   r = r >> k;
+   q = q - (r << k);
+   }
+   }
+
+   if (rp)
+   *rp = r;
+
+   return q;
+}
+
+UDWtype
+__udivdi3(UDWtype n, UDWtype d)
+{
+   return __udivmoddi4(n, d, (UDWtype *)0);
+}
-- 
2.16.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Please pull from u-boot-i2c

2019-09-02 Thread Heiko Schocher

Hello Tom,

one late pull request for u-boot-i2c as I missed Pengs patch...

The following changes since commit 877294b56a52f1cb60bbfa7e4722fcc33451f7b2:

  Merge tag 'efi-2019-10-rc4' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi (2019-08-29 
07:26:42 -0400)


are available in the Git repository at:

  origin/master for-v2019.10-v2

for you to fetch changes up to 6dba0864ece3f4006abae8ff9e2ad74f4374359d:

  i2c: mxc: add CONFIG_CLK support (2019-09-02 06:35:08 +0200)


i2c bugfixes for 2019.10 take 2
- i2c: mxc: add CONFIG_CLK support
  If CONFIG_CLK is enabled use clk framework for clock settings.


Peng Fan (1):
  i2c: mxc: add CONFIG_CLK support

 arch/arm/include/asm/mach-imx/mxc_i2c.h |  6 ++
 drivers/i2c/mxc_i2c.c   | 18 ++
 2 files changed, 24 insertions(+)

Clean travis build:
https://travis-ci.org/hsdenx/u-boot-i2c/builds/579626889

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] dm: spi: Check cs number before accessing slaves

2019-09-02 Thread Bin Meng
On Thu, Aug 29, 2019 at 10:10 PM Bin Meng  wrote:
>
> In spi_get_bus_and_cs() only bus number is checked before accessing
> slaves. We should check cs number as well.
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/spi/spi-uclass.c | 6 ++
>  1 file changed, 6 insertions(+)
>

Ping?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] dm: spi: Return 0 if driver does not implement ops->cs_info

2019-09-02 Thread Bin Meng
On Thu, Aug 29, 2019 at 10:10 PM Bin Meng  wrote:
>
> If an SPI controller driver does not implement ops->cs_info, that
> probably means any chip select number could be valid, hence let's
> return 0 for spi_cs_info().
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/spi/spi-uclass.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
>

Ping?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support

2019-09-02 Thread Heiko Schocher

Hello Peng,

Am 27.08.2019 um 11:55 schrieb Peng Fan:

Hi Heiko,


Subject: [PATCH v2] i2c: mxc: add CONFIG_CLK support


Would you pick up this patch?

Thanks,
Peng.



When CONFIG_CLK enabled, use CLK UCLASS for clk related settings.

Signed-off-by: Peng Fan 
---

V2:
  use clk_get_rate when getting i2c per clk rate with CLK UCLASS

  arch/arm/include/asm/mach-imx/mxc_i2c.h |  6 ++
  drivers/i2c/mxc_i2c.c   | 22
++
  2 files changed, 28 insertions(+)


Applied to u-boot-i2c.git:

https://gitlab.denx.de/u-boot/custodians/u-boot-i2c/commit/6dba0864ece3f4006abae8ff9e2ad74f4374359d

Travis builds fine, pull request follows soon.

bye,
Heiko


diff --git a/arch/arm/include/asm/mach-imx/mxc_i2c.h
b/arch/arm/include/asm/mach-imx/mxc_i2c.h
index 8e1ea9af19..81fd981444 100644
--- a/arch/arm/include/asm/mach-imx/mxc_i2c.h
+++ b/arch/arm/include/asm/mach-imx/mxc_i2c.h
@@ -6,6 +6,9 @@
  #define __ASM_ARCH_MXC_MXC_I2C_H__
  #include 
  #include 
+#if CONFIG_IS_ENABLED(CLK)
+#include 
+#endif

  struct i2c_pin_ctrl {
iomux_v3_cfg_t i2c_mode;
@@ -47,6 +50,9 @@ struct mxc_i2c_bus {
ulong driver_data;
int speed;
struct i2c_pads_info *pads_info;
+#if CONFIG_IS_ENABLED(CLK)
+   struct clk per_clk;
+#endif
  #ifndef CONFIG_DM_I2C
int (*idle_bus_fn)(void *p);
void *idle_bus_data;
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index
23119cce65..8d6b4650ff 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -149,7 +149,12 @@ static uint8_t i2c_imx_get_clk(struct mxc_i2c_bus
*i2c_bus, unsigned int rate)  #endif

/* Divider value calculation */
+#if CONFIG_IS_ENABLED(CLK)
+   i2c_clk_rate = clk_get_rate(_bus->per_clk); #else
i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
+#endif
+
div = (i2c_clk_rate + rate - 1) / rate;
if (div < i2c_clk_div[0][0])
clk_div = 0;
@@ -890,9 +895,22 @@ static int mxc_i2c_probe(struct udevice *bus)
i2c_bus->bus = bus;

/* Enable clk */
+#if CONFIG_IS_ENABLED(CLK)
+   ret = clk_get_by_index(bus, 0, _bus->per_clk);
+   if (ret) {
+   printf("Failed to get i2c clk\n");
+   return ret;
+   }
+   ret = clk_enable(_bus->per_clk);
+   if (ret) {
+   printf("Failed to enable i2c clk\n");
+   return ret;
+   }
+#else
ret = enable_i2c_clk(1, bus->seq);
if (ret < 0)
return ret;
+#endif

/*
 * See Documentation/devicetree/bindings/i2c/i2c-imx.txt
@@ -919,7 +937,11 @@ static int mxc_i2c_probe(struct udevice *bus)
ret = i2c_idle_bus(i2c_bus);
if (ret < 0) {
/* Disable clk */
+#if CONFIG_IS_ENABLED(CLK)
+   clk_disable(_bus->per_clk);
+#else
enable_i2c_clk(0, bus->seq);
+#endif
return ret;
}

--
2.16.4




--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 01/16] rockchip: Add cpu-info

2019-09-02 Thread Kever Yang


On 2019/8/27 上午2:20, Jagan Teki wrote:

Add cpu information for rockchip soc.

This would help to print the SoC family number, with
associated temparature, clock and reason for reset etc.

Signed-off-by: Jagan Teki 


Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  arch/arm/mach-rockchip/Makefile   |  1 +
  arch/arm/mach-rockchip/cpu-info.c | 16 
  2 files changed, 17 insertions(+)
  create mode 100644 arch/arm/mach-rockchip/cpu-info.c

diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index 207f900011..76fc4942ee 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -20,6 +20,7 @@ ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
  # we can have the preprocessor correctly recognise both 0x0 and 0
  # meaning "turn it off".
  obj-y += boot_mode.o
+obj-$(CONFIG_DISPLAY_CPUINFO) += cpu-info.o
  obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
  endif
  
diff --git a/arch/arm/mach-rockchip/cpu-info.c b/arch/arm/mach-rockchip/cpu-info.c

new file mode 100644
index 00..90ce65d9ff
--- /dev/null
+++ b/arch/arm/mach-rockchip/cpu-info.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * (C) Copyright 2019 Amarula Solutions.
+ * Author: Jagan Teki 
+ */
+
+#include 
+
+int print_cpuinfo(void)
+{
+   printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC);
+
+   /* TODO print operating temparature and clock */
+
+   return 0;
+}



___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] rpi3: Enable verified boot from FIT image

2019-09-02 Thread Jun Nie
Jun Nie  于2019年7月11日周四 上午11:56写道:
>
> Enable verified boot from FIT image with select configs
> and specify boot script image node in FIT image, the FIT
> image is verified before it is run.
>
> Code that reusing dtb in firmware is disabled, so that
> the dtb with pubic key packed in u-boot.bin can be used
> to verify the signature of next stage FIT image.
>
> Signed-off-by: Jun Nie 
> ---
>  board/raspberrypi/rpi/rpi.c |  6 ++
>  include/configs/rpi.h   | 15 ++-
>  2 files changed, 20 insertions(+), 1 deletion(-)
>

Hi Matthias,

Do you have any concern or comments for merging this patch?

Regards,
Jun
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/1] env: net: U_BOOT_ENV_CALLBACKs should not depend on CMD_NET

2019-09-02 Thread Heinrich Schuchardt
Some environment variables are relevant for networking. For these
U_BOOT_ENV_CALLBACKs have been defined. When the corresponding environment
variable is updated the callback updates the state of the network
sub-system.

In the UEFI subsystem we can use the network even if CONFIG_CMD_NET is not
defined.

Let the usage of the U_BOOT_ENV_CALLBACKs depend on CONFIG_NET and not on
CONFIG_CMD_NET.

Signed-off-by: Heinrich Schuchardt 
---
Travis CI tested:
https://travis-ci.org/xypron2/u-boot/builds/579439014
---
 include/env_callback.h | 2 +-
 include/env_flags.h| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/env_callback.h b/include/env_callback.h
index 982c07854d..74da20eec3 100644
--- a/include/env_callback.h
+++ b/include/env_callback.h
@@ -42,7 +42,7 @@
 #define DNS_CALLBACK
 #endif

-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
 #define NET_CALLBACKS \
"bootfile:bootfile," \
"ipaddr:ipaddr," \
diff --git a/include/env_flags.h b/include/env_flags.h
index e5380f2948..725841a891 100644
--- a/include/env_flags.h
+++ b/include/env_flags.h
@@ -36,7 +36,7 @@ enum env_flags_varaccess {
 #define CONFIG_ENV_FLAGS_LIST_STATIC ""
 #endif

-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
 #ifdef CONFIG_REGEX
 #define ETHADDR_WILDCARD "\\d*"
 #else
--
2.20.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 0/3] Support distro boot in pico-imx7d BL33 case

2019-09-02 Thread Jun Nie
Jun Nie  于2019年8月8日周四 下午12:04写道:
>
> Jun Nie  于2019年7月16日周二 下午3:43写道:
> >
> > Support distro boot in pico-imx7d BL33 case with changing the enviroment
> > variables. While the other two patches are for polishing clock code and
> > for feature enablement.
> >
> > Jun Nie (3):
> >   pico-imx7d: add config to enable CAAM
> >   pico-imx7d: Support distro boot for FIT image case
> >   pico-imx7d: polish uart clock id definition
> >
> >  arch/arm/include/asm/arch-mx7/clock.h | 18 +
> >  configs/pico-imx7d_bl33_defconfig |  1 +
> >  include/configs/pico-imx7d.h  | 37 
> > +++
> >  3 files changed, 13 insertions(+), 43 deletions(-)
> >
> > --
>
> Hi Vanessa,
>
> Do you have any comments on these 3 patches? Or we can merge it now? Thanks!
>
> Best Regards
> Jun

Hi,

Does anyone has comments on these patches? Maybe we can merge them as
no comments for a long time. Thanks!

Regards,
Jun
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: dw_mmc: fix timeout calculate method

2019-09-02 Thread Kever Yang

Hi Alexey,

On 2019/8/30 下午9:28, Alexey Brodkin wrote:

Hi Kever,

[snip]
  

I think this tree does not including this patch, Peng drop it because of
this issue,
so you need to apply this patch in your branch to reproduce the problem.
I have send out V2 patch for this fix with only using 32bit variable

Could you please refer me to the problematic patch so I may try it?


This is the patch with problem, and here is the link on patchwork:
https://patchwork.ozlabs.org/patch/1146845/

Thanks,
- Kever


-Alexey



___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


  1   2   >