Re: [PATCH v3 01/11] tpm: Don't include cr50 in TPL/SPL
On Sat, Jan 23, 2021 at 10:25:57AM -0700, Simon Glass wrote: > At present the security chip is not used in these U-Boot phases. Update > the Makefile to exclude it. > > Fix a few logging statements while we are here. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > drivers/tpm/Makefile | 2 +- > drivers/tpm/cr50_i2c.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile > index 8f075b9f45f..f64d20067f8 100644 > --- a/drivers/tpm/Makefile > +++ b/drivers/tpm/Makefile > @@ -10,7 +10,7 @@ obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o > obj-$(CONFIG_TPM_ST33ZP24_I2C) += tpm_tis_st33zp24_i2c.o > obj-$(CONFIG_TPM_ST33ZP24_SPI) += tpm_tis_st33zp24_spi.o > > -obj-$(CONFIG_TPM2_CR50_I2C) += cr50_i2c.o > +obj-$(CONFIG_$(SPL_TPL_)TPM2_CR50_I2C) += cr50_i2c.o > obj-$(CONFIG_TPM2_TIS_SANDBOX) += tpm2_tis_sandbox.o > obj-$(CONFIG_TPM2_TIS_SPI) += tpm2_tis_spi.o > obj-$(CONFIG_TPM2_FTPM_TEE) += tpm2_ftpm_tee.o > diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c > index b103a6fdc39..76432bdec1f 100644 > --- a/drivers/tpm/cr50_i2c.c > +++ b/drivers/tpm/cr50_i2c.c > @@ -309,7 +309,7 @@ static int cr50_i2c_recv(struct udevice *dev, u8 *buf, > size_t buf_len) > int status; > int ret; > > - log_debug("%s: len=%x\n", __func__, buf_len); > + log_debug("%s: buf_len=%x\n", __func__, buf_len); > if (buf_len < TPM_HEADER_SIZE) > return -E2BIG; > > @@ -386,7 +386,7 @@ static int cr50_i2c_send(struct udevice *dev, const u8 > *buf, size_t len) > ulong timeout; > int ret; > > - log_debug("%s: len=%x\n", __func__, len); > + log_debug("len=%x\n", len); > timeout = timer_get_us() + TIMEOUT_LONG_US; > do { > ret = cr50_i2c_status(dev); > -- > 2.30.0.280.ga3ce27912f-goog > Reviewed-by: Ilias Apalodimas
Re: [PATCH v3 02/11] tpm: Use logging in the uclass
On Sat, Jan 23, 2021 at 10:25:58AM -0700, Simon Glass wrote: > Update this to use log_debug() instead of the old debug(). > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > drivers/tpm/tpm-uclass.c | 8 +--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/tpm/tpm-uclass.c b/drivers/tpm/tpm-uclass.c > index beb0fa3f93c..35774a6289e 100644 > --- a/drivers/tpm/tpm-uclass.c > +++ b/drivers/tpm/tpm-uclass.c > @@ -4,6 +4,8 @@ > * Written by Simon Glass > */ > > +#define LOG_CATEGORY UCLASS_TPM > + > #include > #include > #include > @@ -87,15 +89,15 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, > size_t send_size, > ordinal = get_unaligned_be32(sendbuf + TPM_CMD_ORDINAL_BYTE); > > if (count == 0) { > - debug("no data\n"); > + log_debug("no data\n"); > return -ENODATA; > } > if (count > send_size) { > - debug("invalid count value %x %zx\n", count, send_size); > + log_debug("invalid count value %x %zx\n", count, send_size); > return -E2BIG; > } > > - debug("%s: Calling send\n", __func__); > + log_debug("%s: Calling send\n", __func__); > ret = ops->send(dev, sendbuf, send_size); > if (ret < 0) > return ret; > -- > 2.30.0.280.ga3ce27912f-goog > Reviewed-by: Ilias Apalodimas
Re: [PATCH v3 03/11] tpm: Add debugging of request in tpm_sendrecv_command()
On Sat, Jan 23, 2021 at 10:25:59AM -0700, Simon Glass wrote: > The response is shown but not the request. Update the code to show both > if debugging is enabled. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > lib/tpm-common.c | 11 --- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/lib/tpm-common.c b/lib/tpm-common.c > index e4af87f76aa..0255d3bd9cf 100644 > --- a/lib/tpm-common.c > +++ b/lib/tpm-common.c > @@ -165,7 +165,7 @@ u32 tpm_sendrecv_command(struct udevice *dev, const void > *command, > int err, ret; > u8 response_buffer[COMMAND_BUFFER_SIZE]; > size_t response_length; > - int i; > + int i, size; > > if (response) { > response_length = *size_ptr; > @@ -174,8 +174,13 @@ u32 tpm_sendrecv_command(struct udevice *dev, const void > *command, > response_length = sizeof(response_buffer); > } > > - err = tpm_xfer(dev, command, tpm_command_size(command), > -response, &response_length); > + size = tpm_command_size(command); tpm_command_size is u32. Is there a the declaration here is int for size? > + log_debug("TPM request [size:%d]: ", size); > + for (i = 0; i < size; i++) > + log_debug("%02x ", ((u8 *)command)[i]); > + log_debug("\n"); > + > + err = tpm_xfer(dev, command, size, response, &response_length); > > if (err < 0) > return err; > -- > 2.30.0.280.ga3ce27912f-goog >
Re: [PATCH v3 04/11] tpm: Add an API that can support v1.2 and v2
On Sat, Jan 23, 2021 at 10:26:00AM -0700, Simon Glass wrote: > There are two different TPM standards. U-Boot supports both but each has > its own set of functions. We really need a single TPM API that can call > one or the other. This is not always possible as there are some > differences between the two standards, but it is mostly possible. > > Add an API to handle this. So far it is not plumbed into the build and > only supports TPMv1. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > include/tpm_api.h | 322 ++ > lib/tpm_api.c | 215 +++ > 2 files changed, 537 insertions(+) > create mode 100644 include/tpm_api.h > create mode 100644 lib/tpm_api.c > > diff --git a/include/tpm_api.h b/include/tpm_api.h > new file mode 100644 > index 000..f13d98cae47 > --- /dev/null > +++ b/include/tpm_api.h > @@ -0,0 +1,322 @@ > +/* SPDX-License-Identifier: GPL-2.0+ */ > +/* > + * Copyright (c) 2013 The Chromium OS Authors. > + * Coypright (c) 2013 Guntermann & Drunck GmbH > + */ > + > +#ifndef __TPM_API_H > +#define __TPM_API_H > + > +#include > +#include > +#include > + > +/** > + * Issue a TPM_Startup command. > + * > + * @param devTPM device > + * @param mode TPM startup mode > + * @return return code of the operation > + */ > +u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode); > + > +/** > + * Issue a TPM_SelfTestFull command. > + * > + * @param devTPM device > + * @return return code of the operation > + */ > +u32 tpm_self_test_full(struct udevice *dev); > + > +/** > + * Issue a TPM_ContinueSelfTest command. > + * > + * @param devTPM device > + * @return return code of the operation > + */ > +u32 tpm_continue_self_test(struct udevice *dev); > + > +/** > + * Issue a TPM_NV_DefineSpace command. The implementation is limited > + * to specify TPM_NV_ATTRIBUTES and size of the area. The area index > + * could be one of the special value listed in enum tpm_nv_index. > + * > + * @param devTPM device > + * @param index index of the area > + * @param perm TPM_NV_ATTRIBUTES of the area > + * @param size size of the area > + * @return return code of the operation > + */ > +u32 tpm_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size); > + > +/** > + * Issue a TPM_NV_ReadValue command. This implementation is limited > + * to read the area from offset 0. The area index could be one of > + * the special value listed in enum tpm_nv_index. > + * > + * @param devTPM device > + * @param index index of the area > + * @param data output buffer of the area contents > + * @param count size of output buffer > + * @return return code of the operation > + */ > +u32 tpm_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count); > + > +/** > + * Issue a TPM_NV_WriteValue command. This implementation is limited > + * to write the area from offset 0. The area index could be one of > + * the special value listed in enum tpm_nv_index. > + * > + * @param devTPM device > + * @param index index of the area > + * @param data input buffer to be wrote to the area > + * @param length length of data bytes of input buffer > + * @return return code of the operation > + */ > +u32 tpm_nv_write_value(struct udevice *dev, u32 index, const void *data, > +u32 length); > + > +/** > + * Issue a TPM_Extend command. > + * > + * @param devTPM device > + * @param index index of the PCR > + * @param in_digest 160-bit value representing the event to be > + * recorded > + * @param out_digest 160-bit PCR value after execution of the > + * command > + * @return return code of the operation > + */ > +u32 tpm_pcr_extend(struct udevice *dev, u32 index, const void *in_digest, > +void *out_digest); > + > +/** > + * Issue a TPM_PCRRead command. > + * > + * @param devTPM device > + * @param index index of the PCR > + * @param data output buffer for contents of the named PCR > + * @param count size of output buffer > + * @return return code of the operation > + */ > +u32 tpm_pcr_read(struct udevice *dev, u32 index, void *data, size_t count); > + > +/** > + * Issue a TSC_PhysicalPresence command. TPM physical presence flag > + * is bit-wise OR'ed of flags listed in enum tpm_physical_presence. > + * > + * @param devTPM device > + * @param presence TPM physical presence flag > + * @return return code of the operation > + */ > +u32 tpm_tsc_physical_presence(struct udevice *dev, u16 presence); > + > +/** > + * Issue a TPM_ReadPubek command. > + * > + * @param devTPM device > + * @param data output buffer for
Re: [PATCH v3 05/11] tpm: Switch TPMv1 over to use the new API
On Sat, Jan 23, 2021 at 10:26:01AM -0700, Simon Glass wrote: > Take over the plain 'tpm_...' functions for use by the new TPM API. Rename > all the TPMv1 functions so they are called from the API. > > Update the TPMv1 functions so that they are called from the API. Change > existing users to use the tpm1_ prefix so they don't need to go through > the API, which might introduce uncertainty. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > board/gdsys/a38x/controlcenterdc.c| 4 +- > board/gdsys/a38x/hre.c| 28 +++ > board/gdsys/a38x/keyprogram.c | 8 +- > board/gdsys/mpc8308/gazerbeam.c | 4 +- > board/gdsys/p1022/controlcenterd-id.c | 36 > cmd/tpm-v1.c | 25 +++--- > cmd/tpm_test.c| 40 + > include/tpm-v1.h | 76 - > lib/Makefile | 1 + > lib/tpm-v1.c | 115 -- > 10 files changed, 168 insertions(+), 169 deletions(-) > > diff --git a/board/gdsys/a38x/controlcenterdc.c > b/board/gdsys/a38x/controlcenterdc.c > index a2287f9deb1..187ac8c4f9f 100644 > --- a/board/gdsys/a38x/controlcenterdc.c > +++ b/board/gdsys/a38x/controlcenterdc.c > @@ -286,8 +286,8 @@ int last_stage_init(void) > ccdc_eth_init(); > #endif > ret = get_tpm(&tpm); > - if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR) || > - tpm_continue_self_test(tpm)) { > + if (ret || tpm_init(tpm) || tpm1_startup(tpm, TPM_ST_CLEAR) || > + tpm1_continue_self_test(tpm)) { > return 1; > } > > diff --git a/board/gdsys/a38x/hre.c b/board/gdsys/a38x/hre.c > index 699241b3e62..de5411a6b93 100644 > --- a/board/gdsys/a38x/hre.c > +++ b/board/gdsys/a38x/hre.c > @@ -107,8 +107,8 @@ static int get_tpm_nv_size(struct udevice *tpm, uint32_t > index, uint32_t *size) > uint8_t *ptr; > uint16_t v16; > > - err = tpm_get_capability(tpm, TPM_CAP_NV_INDEX, index, > - info, sizeof(info)); > + err = tpm1_get_capability(tpm, TPM_CAP_NV_INDEX, index, info, > + sizeof(info)); For all subsequent usage, can't we use tpm_get_capability() etc? Why do we need to explicitly use the tpm1_get_capability() since we now have a common API? > if (err) { > printf("tpm_get_capability(CAP_NV_INDEX, %08x) failed: %u\n", > index, err); > @@ -150,8 +150,8 @@ static int find_key(struct udevice *tpm, const uint8_t > auth[20], > unsigned int i; > > /* fetch list of already loaded keys in the TPM */ > - err = tpm_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf, > - sizeof(buf)); > + err = tpm1_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf, > + sizeof(buf)); > if (err) > return -1; > key_count = get_unaligned_be16(buf); > @@ -162,8 +162,8 @@ static int find_key(struct udevice *tpm, const uint8_t > auth[20], > /* now search a(/ the) key which we can access with the given auth */ > for (i = 0; i < key_count; ++i) { > buf_len = sizeof(buf); > - err = tpm_get_pub_key_oiap(tpm, key_handles[i], auth, buf, > -&buf_len); > + err = tpm1_get_pub_key_oiap(tpm, key_handles[i], auth, buf, > + &buf_len); > if (err && err != TPM_AUTHFAIL) > return -1; > if (err) > @@ -192,8 +192,8 @@ static int read_common_data(struct udevice *tpm) > if (get_tpm_nv_size(tpm, NV_COMMON_DATA_INDEX, &size) || > size < NV_COMMON_DATA_MIN_SIZE) > return 1; > - err = tpm_nv_read_value(tpm, NV_COMMON_DATA_INDEX, > - buf, min(sizeof(buf), size)); > + err = tpm1_nv_read_value(tpm, NV_COMMON_DATA_INDEX, buf, > + min(sizeof(buf), size)); > if (err) { > printf("tpm_nv_read_value() failed: %u\n", err); > return 1; > @@ -270,8 +270,8 @@ static struct h_reg *access_hreg(struct udevice *tpm, > uint8_t spec, > if (mode & HREG_RD) { > if (!result->valid) { > if (IS_PCR_HREG(spec)) { > - hre_tpm_err = tpm_pcr_read(tpm, HREG_IDX(spec), > - result->digest, 20); > + hre_tpm_err = tpm1_pcr_read(tpm, HREG_IDX(spec), > + result->digest, 20); > result->valid = (hre_tpm_err == TPM_SUCCESS); > } else if (IS_FIX_HREG(spec)) { > switch (HREG_IDX(spec)) { > @@ -357,8 +357,8 @@ static int hre_op_loadkey(struct udevice *tpm, struct > h_reg *src
Re: [PATCH v3 06/11] tpm: Add a basic API implementation for TPMv2
On Sat, Jan 23, 2021 at 10:26:02AM -0700, Simon Glass wrote: > Add support for TPMv2 versions of API functions. So far this is not > complete as the standard is quite large, but it implements everything > currently available for TPMv2 in U-Boot. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > lib/tpm_api.c | 84 ++- > 1 file changed, 77 insertions(+), 7 deletions(-) > > diff --git a/lib/tpm_api.c b/lib/tpm_api.c > index 758350bd18d..f1553512cc5 100644 > --- a/lib/tpm_api.c > +++ b/lib/tpm_api.c > @@ -16,18 +16,41 @@ static bool is_tpm1(struct udevice *dev) > return IS_ENABLED(CONFIG_TPM_V1) && tpm_get_version(dev) == TPM_V1; > } > > +static bool is_tpm2(struct udevice *dev) > +{ > + return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2; > +} > + > u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode) > { > - if (is_tpm1(dev)) > + if (is_tpm1(dev)) { > return tpm1_startup(dev, mode); > - else > + } else if (is_tpm2(dev)) { > + enum tpm2_startup_types type; > + > + switch (mode) { > + case TPM_ST_CLEAR: > + type = TPM2_SU_CLEAR; > + break; > + case TPM_ST_STATE: > + type = TPM2_SU_STATE; > + break; > + default: > + case TPM_ST_DEACTIVATED: > + return -EINVAL; > + } > + return tpm2_startup(dev, type); > + } else { > return -ENOSYS; > + } > } > > u32 tpm_resume(struct udevice *dev) > { > if (is_tpm1(dev)) > return tpm1_startup(dev, TPM_ST_STATE); > + else if (is_tpm2(dev)) > + return tpm2_startup(dev, TPM2_SU_STATE); > else > return -ENOSYS; > } > @@ -36,6 +59,8 @@ u32 tpm_self_test_full(struct udevice *dev) > { > if (is_tpm1(dev)) > return tpm1_self_test_full(dev); > + else if (is_tpm2(dev)) > + return tpm2_self_test(dev, TPMI_YES); > else > return -ENOSYS; > } > @@ -44,6 +69,8 @@ u32 tpm_continue_self_test(struct udevice *dev) > { > if (is_tpm1(dev)) > return tpm1_continue_self_test(dev); > + else if (is_tpm2(dev)) > + return tpm2_self_test(dev, TPMI_NO); > else > return -ENOSYS; > } > @@ -71,8 +98,6 @@ u32 tpm_clear_and_reenable(struct udevice *dev) > log_err("TPM: Can't set deactivated state\n"); > return ret; > } > - } else { > - return -ENOSYS; > } > > return TPM_SUCCESS; > @@ -82,6 +107,8 @@ u32 tpm_nv_enable_locking(struct udevice *dev) > { > if (is_tpm1(dev)) > return tpm1_nv_define_space(dev, TPM_NV_INDEX_LOCK, 0, 0); > + else if (is_tpm2(dev)) > + return -ENOSYS; > else > return -ENOSYS; > } > @@ -90,6 +117,8 @@ u32 tpm_nv_read_value(struct udevice *dev, u32 index, void > *data, u32 count) > { > if (is_tpm1(dev)) > return tpm1_nv_read_value(dev, index, data, count); > + else if (is_tpm2(dev)) > + return -ENOSYS; > else > return -ENOSYS; > } > @@ -99,6 +128,8 @@ u32 tpm_nv_write_value(struct udevice *dev, u32 index, > const void *data, > { > if (is_tpm1(dev)) > return tpm1_nv_write_value(dev, index, data, count); > + else if (is_tpm2(dev)) > + return -ENOSYS; > else > return -ENOSYS; > } > @@ -112,6 +143,8 @@ u32 tpm_write_lock(struct udevice *dev, u32 index) > { > if (is_tpm1(dev)) > return -ENOSYS; > + else if (is_tpm2(dev)) > + return -ENOSYS; > else > return -ENOSYS; > } > @@ -121,6 +154,9 @@ u32 tpm_pcr_extend(struct udevice *dev, u32 index, const > void *in_digest, > { > if (is_tpm1(dev)) > return tpm1_extend(dev, index, in_digest, out_digest); > + else if (is_tpm2(dev)) > + return tpm2_pcr_extend(dev, index, TPM2_ALG_SHA256, in_digest, > +TPM2_DIGEST_LEN); > else > return -ENOSYS; > } > @@ -129,6 +165,8 @@ u32 tpm_pcr_read(struct udevice *dev, u32 index, void > *data, size_t count) > { > if (is_tpm1(dev)) > return tpm1_pcr_read(dev, index, data, count); > + else if (is_tpm2(dev)) > + return -ENOSYS; > else > return -ENOSYS; > } > @@ -137,6 +175,13 @@ u32 tpm_tsc_physical_presence(struct udevice *dev, u16 > presence) > { > if (is_tpm1(dev)) > return tpm1_tsc_physical_presence(dev, presence); > + > + /* > + * Nothing to do on TPM2 for this; use platform hierarchy availability > + * instead. > + */ > + else if (is_tpm2(dev)) > + return 0; >
Re: [PATCH v3 07/11] tpm: Reduce duplication in a few functions
On Sat, Jan 23, 2021 at 10:26:03AM -0700, Simon Glass wrote: > Update tpm2_clear() and tpm2_pcr_extend() so that the command size > is not repeated twice. Add a small comment to the latter. > > Signed-off-by: Simon Glass > --- > > (no changes since v2) > > Changes in v2: > - Add comments for the offset value > > lib/tpm-v2.c | 13 - > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c > index 1f3deb06e48..c4e869ec5b5 100644 > --- a/lib/tpm-v2.c > +++ b/lib/tpm-v2.c > @@ -47,9 +47,11 @@ u32 tpm2_self_test(struct udevice *dev, enum tpm2_yes_no > full_test) > u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw, > const ssize_t pw_sz) > { > + /* Length of the message header, up to start of password */ > + uint offset = 27; > u8 command_v2[COMMAND_BUFFER_SIZE] = { > tpm_u16(TPM2_ST_SESSIONS), /* TAG */ > - tpm_u32(27 + pw_sz),/* Length */ > + tpm_u32(offset + pw_sz),/* Length */ > tpm_u32(TPM2_CC_CLEAR), /* Command code */ > > /* HANDLE */ > @@ -64,7 +66,6 @@ u32 tpm2_clear(struct udevice *dev, u32 handle, const char > *pw, > tpm_u16(pw_sz), /* Size of */ > /* STRING(pw) (if any) */ > }; > - unsigned int offset = 27; > int ret; > > /* > @@ -83,9 +84,11 @@ u32 tpm2_clear(struct udevice *dev, u32 handle, const char > *pw, > u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 algorithm, > const u8 *digest, u32 digest_len) > { > + /* Length of the message header, up to start of digest */ > + uint offset = 33; > u8 command_v2[COMMAND_BUFFER_SIZE] = { > tpm_u16(TPM2_ST_SESSIONS), /* TAG */ > - tpm_u32(33 + digest_len), /* Length */ > + tpm_u32(offset + digest_len), /* Length */ > tpm_u32(TPM2_CC_PCR_EXTEND),/* Command code */ > > /* HANDLE */ > @@ -99,11 +102,12 @@ u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 > algorithm, > 0, /* Attributes: Cont/Excl/Rst */ > tpm_u16(0), /* Size of */ > /* (if any) */ > + > + /* hashes */ > tpm_u32(1), /* Count (number of hashes) */ > tpm_u16(algorithm), /* Algorithm of the hash */ > /* STRING(digest) Digest */ > }; > - unsigned int offset = 33; > int ret; > > /* > @@ -112,7 +116,6 @@ u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 > algorithm, >*/ > ret = pack_byte_string(command_v2, sizeof(command_v2), "s", > offset, digest, digest_len); > - offset += digest_len; > if (ret) > return TPM_LIB_ERROR; > > -- > 2.30.0.280.ga3ce27912f-goog > Reviewed-by: Ilias Apalodimas
Re: [PATCH v3 08/11] tpm: Add an implementation of define_space
On Sat, Jan 23, 2021 at 10:26:04AM -0700, Simon Glass wrote: > Add support for this so that the TPM can be set up for use with > Chromium OS verified boot. > > Signed-off-by: Simon Glass > --- [...] > + /* > + * Fill the command structure starting from the first buffer: > + * - the password (if any) > + */ > + ret = pack_byte_string(command_v2, sizeof(command_v2), "s", > +offset, nv_policy, nv_policy_size); > + offset += nv_policy_size; Do we need to increase offsetr here? It doesn't seem to be used afterwards. > + if (ret) > + return TPM_LIB_ERROR; > + > + return tpm_sendrecv_command(dev, command_v2, NULL, NULL); > +} > + > u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 algorithm, > const u8 *digest, u32 digest_len) > { > -- > 2.30.0.280.ga3ce27912f-goog >
Re: [PATCH v3 09/11] tpm: Add TPM2 support for read/write values
On Sat, Jan 23, 2021 at 10:26:05AM -0700, Simon Glass wrote: > Implement this API function for TPM2. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > include/tpm-common.h | 3 ++ > include/tpm-v2.h | 38 > lib/tpm-v2.c | 84 > lib/tpm_api.c| 4 +-- > 4 files changed, 127 insertions(+), 2 deletions(-) > > diff --git a/include/tpm-common.h b/include/tpm-common.h > index e29b10b1766..080183779b3 100644 > --- a/include/tpm-common.h > +++ b/include/tpm-common.h > @@ -53,6 +53,8 @@ enum tpm_version { > * @buf: Buffer used during the exchanges with the chip > * @pcr_count: Number of PCR per bank > * @pcr_select_min: Minimum size in bytes of the pcrSelect array > + * @plat_hier_disabled: Platform hierarchy has been disabled (TPM is > locked > + * down until next reboot) > */ > struct tpm_chip_priv { > enum tpm_version version; > @@ -64,6 +66,7 @@ struct tpm_chip_priv { > /* TPM v2 specific data */ > uint pcr_count; > uint pcr_select_min; > + bool plat_hier_disabled; > }; > > /** > diff --git a/include/tpm-v2.h b/include/tpm-v2.h > index 2766dc72a65..6a400771af1 100644 > --- a/include/tpm-v2.h > +++ b/include/tpm-v2.h > @@ -240,6 +240,7 @@ enum tpm2_command_codes { > TPM2_CC_HIERCHANGEAUTH = 0x0129, > TPM2_CC_NV_DEFINE_SPACE = 0x012a, > TPM2_CC_PCR_SETAUTHPOL = 0x012C, > + TPM2_CC_NV_WRITE= 0x0137, > TPM2_CC_DAM_RESET = 0x0139, > TPM2_CC_DAM_PARAMETERS = 0x013A, > TPM2_CC_NV_READ = 0x014E, > @@ -354,6 +355,20 @@ enum { > TPM_MAX_BUF_SIZE= 1260, > }; > > +enum { > + /* Secure storage for firmware settings */ > + TPM_HT_PCR = 0, > + TPM_HT_NV_INDEX, > + TPM_HT_HMAC_SESSION, > + TPM_HT_POLICY_SESSION, > + > + HR_SHIFT= 24, > + HR_PCR = TPM_HT_PCR << HR_SHIFT, > + HR_HMAC_SESSION = TPM_HT_HMAC_SESSION << HR_SHIFT, > + HR_POLICY_SESSION = TPM_HT_POLICY_SESSION << HR_SHIFT, > + HR_NV_INDEX = TPM_HT_NV_INDEX << HR_SHIFT, > +}; > + > /** > * Issue a TPM2_Startup command. > * > @@ -418,6 +433,29 @@ u32 tpm2_nv_define_space(struct udevice *dev, u32 > space_index, > u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 algorithm, > const u8 *digest, u32 digest_len); > > +/** > + * Read data from the secure storage > + * > + * @dev TPM device > + * @indexIndex of data to read > + * @data Place to put data > + * @countNumber of bytes of data > + * @return code of the operation > + */ > +u32 tpm2_nv_read_value(struct udevice *dev, u32 index, void *data, u32 > count); > + > +/** > + * Write data to the secure storage > + * > + * @dev TPM device > + * @indexIndex of data to write > + * @data Data to write > + * @countNumber of bytes of data > + * @return code of the operation > + */ > +u32 tpm2_nv_write_value(struct udevice *dev, u32 index, const void *data, > + u32 count); > + > /** > * Issue a TPM2_PCR_Read command. > * > diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c > index aea1dfb6ba0..7bf43264ab0 100644 > --- a/lib/tpm-v2.c > +++ b/lib/tpm-v2.c > @@ -170,6 +170,90 @@ u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 > algorithm, > return tpm_sendrecv_command(dev, command_v2, NULL, NULL); > } > > +u32 tpm2_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count) > +{ > + u8 command_v2[COMMAND_BUFFER_SIZE] = { > + /* header 10 bytes */ > + tpm_u16(TPM2_ST_SESSIONS), /* TAG */ > + tpm_u32(10 + 8 + 4 + 9 + 4),/* Length */ > + tpm_u32(TPM2_CC_NV_READ), /* Command code */ > + > + /* handles 8 bytes */ > + tpm_u32(TPM2_RH_PLATFORM), /* Primary platform seed */ > + tpm_u32(HR_NV_INDEX + index), /* Password authorisation */ > + > + /* AUTH_SESSION */ > + tpm_u32(9), /* Authorization size */ > + tpm_u32(TPM2_RS_PW),/* Session handle */ > + tpm_u16(0), /* Size of */ > + /* (if any) */ > + 0, /* Attributes: Cont/Excl/Rst */ > + tpm_u16(0), /* Size of */ > + /* (if any) */ > + > + tpm_u16(count), /* Number of bytes */ > + tpm_u16(0), /* Offset */ > + }; > + size_t response_len = COMMAND_BUFFER_SIZE; > + u8 response[COMMAND_BUFFER_SIZE]; > + int ret; > + u16 tag; > + u32 size, code; > + > + ret = tpm_sendrecv_command(dev, command_v2, response, &response_len); > + if (ret) > +
Re: [PATCH v3 10/11] tpm: Add TPM2 support for write_lock
On Sat, Jan 23, 2021 at 10:26:06AM -0700, Simon Glass wrote: > Implement this API function for TPM2. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > include/tpm-v2.h | 12 > lib/tpm-v2.c | 23 +++ > lib/tpm_api.c| 2 +- > 3 files changed, 36 insertions(+), 1 deletion(-) > > diff --git a/include/tpm-v2.h b/include/tpm-v2.h > index 6a400771af1..1ca1e7e2011 100644 > --- a/include/tpm-v2.h > +++ b/include/tpm-v2.h > @@ -241,6 +241,7 @@ enum tpm2_command_codes { > TPM2_CC_NV_DEFINE_SPACE = 0x012a, > TPM2_CC_PCR_SETAUTHPOL = 0x012C, > TPM2_CC_NV_WRITE= 0x0137, > + TPM2_CC_NV_WRITELOCK= 0x0138, > TPM2_CC_DAM_RESET = 0x0139, > TPM2_CC_DAM_PARAMETERS = 0x013A, > TPM2_CC_NV_READ = 0x014E, > @@ -570,4 +571,15 @@ u32 tpm2_pcr_setauthvalue(struct udevice *dev, const > char *pw, > */ > u32 tpm2_get_random(struct udevice *dev, void *data, u32 count); > > +/** > + * Lock data in the TPM > + * > + * Once locked the data cannot be written until after a reboot > + * > + * @dev TPM device > + * @indexIndex of data to lock > + * @return code of the operation > + */ > +u32 tpm2_write_lock(struct udevice *dev, u32 index); > + > #endif /* __TPM_V2_H */ > diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c > index 7bf43264ab0..35f3917aeb5 100644 > --- a/lib/tpm-v2.c > +++ b/lib/tpm-v2.c > @@ -602,3 +602,26 @@ u32 tpm2_get_random(struct udevice *dev, void *data, u32 > count) > > return 0; > } > + > +u32 tpm2_write_lock(struct udevice *dev, u32 index) > +{ > + u8 command_v2[COMMAND_BUFFER_SIZE] = { > + /* header 10 bytes */ > + tpm_u16(TPM2_ST_SESSIONS), /* TAG */ > + tpm_u32(10 + 8 + 13), /* Length */ > + tpm_u32(TPM2_CC_NV_WRITELOCK), /* Command code */ > + > + /* handles 8 bytes */ > + tpm_u32(TPM2_RH_PLATFORM), /* Primary platform seed */ > + tpm_u32(HR_NV_INDEX + index), /* Password authorisation */ > + > + /* session header 9 bytes */ > + tpm_u32(9), /* Header size */ > + tpm_u32(TPM2_RS_PW),/* Password authorisation */ > + tpm_u16(0), /* nonce_size */ > + 0, /* session_attrs */ > + tpm_u16(0), /* auth_size */ > + }; > + > + return tpm_sendrecv_command(dev, command_v2, NULL, NULL); > +} > diff --git a/lib/tpm_api.c b/lib/tpm_api.c > index 687fc8bc7ee..4c662640a92 100644 > --- a/lib/tpm_api.c > +++ b/lib/tpm_api.c > @@ -144,7 +144,7 @@ u32 tpm_write_lock(struct udevice *dev, u32 index) > if (is_tpm1(dev)) > return -ENOSYS; > else if (is_tpm2(dev)) > - return -ENOSYS; > + return tpm2_write_lock(dev, index); > else > return -ENOSYS; > } > -- > 2.30.0.280.ga3ce27912f-goog > Acked-by: Ilias Apalodimas
Re: [PATCH v3 11/11] tpm: Allow disabling platform hierarchy with TPM2
On Sat, Jan 23, 2021 at 10:26:07AM -0700, Simon Glass wrote: > With TPM2 we don't actually lock the TPM once verified boot is finished. > Instead we disable the platform hierarchy which serves the same purpose. > Add an implementation of this so we can safely boot into the kernel. > > Signed-off-by: Simon Glass > --- > > (no changes since v2) > > Changes in v2: > - Add definition of TPM2_RC_NV_DEFINED return code > > include/tpm-v2.h | 13 + > lib/tpm-v2.c | 35 +++ > 2 files changed, 48 insertions(+) > > diff --git a/include/tpm-v2.h b/include/tpm-v2.h > index 1ca1e7e2011..e18c8b1ccca 100644 > --- a/include/tpm-v2.h > +++ b/include/tpm-v2.h > @@ -235,6 +235,7 @@ enum tpm2_handles { > enum tpm2_command_codes { > TPM2_CC_STARTUP = 0x0144, > TPM2_CC_SELF_TEST = 0x0143, > + TPM2_CC_HIER_CONTROL= 0x0121, > TPM2_CC_CLEAR = 0x0126, > TPM2_CC_CLEARCONTROL= 0x0127, > TPM2_CC_HIERCHANGEAUTH = 0x0129, > @@ -272,6 +273,7 @@ enum tpm2_return_codes { > TPM2_RC_COMMAND_CODE= TPM2_RC_VER1 + 0x0043, > TPM2_RC_AUTHSIZE= TPM2_RC_VER1 + 0x0044, > TPM2_RC_AUTH_CONTEXT= TPM2_RC_VER1 + 0x0045, > + TPM2_RC_NV_DEFINED = TPM2_RC_VER1 + 0x004c, > TPM2_RC_NEEDS_TEST = TPM2_RC_VER1 + 0x0053, > TPM2_RC_WARN= 0x0900, > TPM2_RC_TESTING = TPM2_RC_WARN + 0x000A, > @@ -582,4 +584,15 @@ u32 tpm2_get_random(struct udevice *dev, void *data, u32 > count); > */ > u32 tpm2_write_lock(struct udevice *dev, u32 index); > > +/** > + * Disable access to any platform data > + * > + * This can be called to close off access to the firmware data in the data, > + * before calling the kernel. > + * > + * @dev TPM device > + * @return code of the operation > + */ > +u32 tpm2_disable_platform_hierarchy(struct udevice *dev); > + > #endif /* __TPM_V2_H */ > diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c > index 35f3917aeb5..1b32661979d 100644 > --- a/lib/tpm-v2.c > +++ b/lib/tpm-v2.c > @@ -625,3 +625,38 @@ u32 tpm2_write_lock(struct udevice *dev, u32 index) > > return tpm_sendrecv_command(dev, command_v2, NULL, NULL); > } > + > +u32 tpm2_disable_platform_hierarchy(struct udevice *dev) > +{ > + struct tpm_chip_priv *priv = dev_get_uclass_priv(dev); > + u8 command_v2[COMMAND_BUFFER_SIZE] = { > + /* header 10 bytes */ > + tpm_u16(TPM2_ST_SESSIONS), /* TAG */ > + tpm_u32(10 + 4 + 13 + 5), /* Length */ > + tpm_u32(TPM2_CC_HIER_CONTROL), /* Command code */ > + > + /* 4 bytes */ > + tpm_u32(TPM2_RH_PLATFORM), /* Primary platform seed */ > + > + /* session header 9 bytes */ > + tpm_u32(9), /* Header size */ > + tpm_u32(TPM2_RS_PW),/* Password authorisation */ > + tpm_u16(0), /* nonce_size */ > + 0, /* session_attrs */ > + tpm_u16(0), /* auth_size */ > + > + /* payload 5 bytes */ > + tpm_u32(TPM2_RH_PLATFORM), /* Hierarchy to disable */ > + 0, /* 0=disable */ > + }; > + int ret; > + > + ret = tpm_sendrecv_command(dev, command_v2, NULL, NULL); > + log_info("ret=%s, %x\n", dev->name, ret); > + if (ret) > + return ret; > + > + priv->plat_hier_disabled = true; > + > + return 0; > +} > -- > 2.30.0.280.ga3ce27912f-goog > Acked-by: Ilias Apalodimas
Re: [PATCH v2 1/3] mem: spi-mem: add declaration for spi_mem_default_supports_op
On 25/01/21 03:55AM, Mathew McBride wrote: > spi_mem_default_supports_op is used internally by controller > drivers to verify operation semantics are correct. > > It is used internally inside spi-mem but has not (in U-Boot) > been declared in spi-mem.h for external use. > > Signed-off-by: Mathew McBride Reviewed-by: Pratyush Yadav > --- > include/spi-mem.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/include/spi-mem.h b/include/spi-mem.h > index ca0f55c8fd..8be3e2bf6b 100644 > --- a/include/spi-mem.h > +++ b/include/spi-mem.h > @@ -240,6 +240,9 @@ bool spi_mem_supports_op(struct spi_slave *slave, const > struct spi_mem_op *op); > > int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op); > > +bool spi_mem_default_supports_op(struct spi_slave *mem, > + const struct spi_mem_op *op); > + > #ifndef __UBOOT__ > int spi_mem_driver_register_with_owner(struct spi_mem_driver *drv, > struct module *owner); > -- > 2.30.0 > -- Regards, Pratyush Yadav Texas Instruments India
Re: [RFC PATCH v2 1/2] optee: obtain emmc rpmb info from dt
Hi Igor, On Sun, Jan 24, 2021 at 11:39:45AM +0200, Igor Opaniuk wrote: > From: Igor Opaniuk > > Add support for rpmb-dev property in optee node. > Prioritize that provided eMMC info from DT for RPMB operations over > the one provided by OP-TEE OS core in RPC calls. > > Signed-off-by: Igor Opaniuk > --- > > Changes in v2: > - Return NULL instead of ERR_PTR(-ENXIO) in get_rpmb_dev in case there > is no rpmb-dev property or somemithing went wrong > > drivers/tee/optee/core.c | 33 + > drivers/tee/optee/optee_private.h | 2 +- > drivers/tee/optee/rpmb.c | 60 ++- > 3 files changed, 70 insertions(+), 25 deletions(-) > > diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c > index b898c32edc..828ab9b00a 100644 > --- a/drivers/tee/optee/core.c > +++ b/drivers/tee/optee/core.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > > #include "optee_smc.h" > #include "optee_msg.h" > @@ -607,14 +608,46 @@ static optee_invoke_fn *get_invoke_func(struct udevice > *dev) > return ERR_PTR(-EINVAL); > } > > +static struct mmc *get_rpmb_dev(struct udevice *dev) > +{ > + struct udevice *mmc_dev; > + const fdt32_t *phandle_p; > + u32 phandle; > + int ret = 0; > + > + debug("optee: looking for rpmb device in DT.\n"); > + > + phandle_p = ofnode_get_property(dev_ofnode(dev), > + "rpmb-dev", NULL); > + if (!phandle_p) { > + debug("optee: missing \"rpmb-dev\" property\n"); With this we'll complain in the log each time "rpmb-dev" isn't found even when OP-TEE isn't configured to use RPMB. This might cause some confusion. Cheers, Jens > + return NULL; > + } > + > + phandle = fdt32_to_cpu(*phandle_p); > + > + ret = uclass_get_device_by_phandle_id(UCLASS_MMC, phandle, &mmc_dev); > + if (ret) { > + printf("optee: invalid phandle value in \"rpmb-dev\".\n"); > + return NULL; > + } > + > + debug("optee: using phandle %d from \"rpmd-dev\" property.\n", > + phandle); > + return mmc_get_mmc_dev(mmc_dev); > +} > + > static int optee_of_to_plat(struct udevice *dev) > { > struct optee_pdata *pdata = dev_get_plat(dev); > + struct optee_private *priv = dev_get_priv(dev); > > pdata->invoke_fn = get_invoke_func(dev); > if (IS_ERR(pdata->invoke_fn)) > return PTR_ERR(pdata->invoke_fn); > > + priv->rpmb_mmc = get_rpmb_dev(dev); > + > return 0; > } > > diff --git a/drivers/tee/optee/optee_private.h > b/drivers/tee/optee/optee_private.h > index 1f07a27ee4..8e5a280622 100644 > --- a/drivers/tee/optee/optee_private.h > +++ b/drivers/tee/optee/optee_private.h > @@ -19,8 +19,8 @@ > */ > struct optee_private { > struct mmc *rpmb_mmc; > - int rpmb_dev_id; > int rpmb_original_part; > + bool rpmb_inited; > }; > > struct optee_msg_arg; > diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c > index 0804fc963c..0137c44be1 100644 > --- a/drivers/tee/optee/rpmb.c > +++ b/drivers/tee/optee/rpmb.c > @@ -45,55 +45,67 @@ static void release_mmc(struct optee_private *priv) > { > int rc; > > - if (!priv->rpmb_mmc) > + if (!priv->rpmb_mmc || !priv->rpmb_inited) > return; > > - rc = blk_select_hwpart_devnum(IF_TYPE_MMC, priv->rpmb_dev_id, > - priv->rpmb_original_part); > + rc = mmc_switch_part(priv->rpmb_mmc, priv->rpmb_original_part); > if (rc) > debug("%s: blk_select_hwpart_devnum() failed: %d\n", > __func__, rc); > > - priv->rpmb_mmc = NULL; > + priv->rpmb_inited = false; > +} > + > +static int check_mmc(struct mmc *mmc) > +{ > + if (!mmc) { > + debug("Cannot find RPMB device\n"); > + return -ENODEV; > + } > + if (!(mmc->version & MMC_VERSION_MMC)) { > + debug("Device id is not an eMMC device\n"); > + return -ENODEV; > + } > + if (mmc->version < MMC_VERSION_4_41) { > + debug("RPMB is not supported before version 4.41\n"); > + return -ENODEV; > + } > + > + return 0; > } > > static struct mmc *get_mmc(struct optee_private *priv, int dev_id) > { > - struct mmc *mmc; > int rc; > > - if (priv->rpmb_mmc && priv->rpmb_dev_id == dev_id) > + if (priv->rpmb_mmc && priv->rpmb_inited) > return priv->rpmb_mmc; > > release_mmc(priv); > > - mmc = find_mmc_device(dev_id); > - if (!mmc) { > - debug("Cannot find RPMB device\n"); > - return NULL; > - } > - if (!(mmc->version & MMC_VERSION_MMC)) { > - debug("Device id %d is not an eMMC device\n", dev_id); > - return NULL; > - } > - if (mmc->version < MMC_VERSION_4_41) { > - debug("Device id %d: RPMB not supported before version
Re: [PATCH v3 01/20] mmc: sdhci: Add helper functions for UHS modes
Hi Simon, On 24/01/21 7:33 am, Simon Glass wrote: > Hi Aswath, > > On Thu, 21 Jan 2021 at 05:41, Aswath Govindraju wrote: >> >> From: Faiz Abbas >> >> Add a set_voltage() function which handles the switch from 3.3V to 1.8V >> for SD card UHS modes. >> >> Signed-off-by: Faiz Abbas >> Signed-off-by: Aswath Govindraju >> --- >> drivers/mmc/sdhci.c | 80 + >> include/sdhci.h | 1 + >> 2 files changed, 81 insertions(+) >> >> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c >> index 06289343124e..e7e3e22d1a7e 100644 >> --- a/drivers/mmc/sdhci.c >> +++ b/drivers/mmc/sdhci.c >> @@ -20,6 +20,7 @@ >> #include >> #include >> #include >> +#include >> >> static void sdhci_reset(struct sdhci_host *host, u8 mask) >> { >> @@ -509,6 +510,85 @@ void sdhci_set_uhs_timing(struct sdhci_host *host) >> sdhci_writew(host, reg, SDHCI_HOST_CONTROL2); >> } >> >> +#if CONFIG_IS_ENABLED(MMC_IO_VOLTAGE) [1] >> +static void sdhci_set_voltage(struct sdhci_host *host) >> +{ >> + struct mmc *mmc = (struct mmc *)host->mmc; >> + u32 ctrl; >> + int ret; >> + >> + ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); >> + >> + switch (mmc->signal_voltage) { >> + case MMC_SIGNAL_VOLTAGE_330: >> +#if CONFIG_IS_ENABLED(DM_REGULATOR) > > Can you use if(), please? You should see a patman warning about this. Here if() can not be used as a pre-processor directive is necessary. In include/mmc.h the field vqmmc_supply in the structure mmc is defined inside #if CONFIG_IS_ENABLED(DM_REGULATOR). So, when DM_REGULATOR config is not enabled then the field vqmmc_supply is not defined which would result in a error. The #if at [1] can be converted to if(IS_ENABLED()). I will convert this in the respin. > >> + if (mmc->vqmmc_supply) { >> + ret = regulator_set_enable(mmc->vqmmc_supply, false); >> + if (ret) { >> + pr_err("failed to disable vqmmc-supply: >> %d\n", ret); >> + return; >> + } >> + >> + ret = regulator_set_value(mmc->vqmmc_supply, >> 330); >> + if (ret) { >> + pr_err("failed to set vqmmc-voltage to 3.3V: >> %d\n", ret); >> + return; >> + } >> + >> + ret = regulator_set_enable(mmc->vqmmc_supply, true); >> + if (ret) { >> + pr_err("failed to enable vqmmc-supply: >> %d\n", ret); >> + return; >> + } >> + } >> +#endif >> + mdelay(5); >> + if (IS_SD(mmc)) { >> + ctrl &= ~SDHCI_CTRL_VDD_180; >> + sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); >> + } >> + break; >> + case MMC_SIGNAL_VOLTAGE_180: >> +#if CONFIG_IS_ENABLED(DM_REGULATOR) >> + if (mmc->vqmmc_supply) { >> + regulator_set_enable(mmc->vqmmc_supply, false); >> + if (ret) { >> + pr_err("failed to disable vqmmc-supply: >> %d\n", ret); >> + return; >> + } >> + >> + regulator_set_value(mmc->vqmmc_supply, 180); >> + if (ret) { >> + pr_err("failed to set vqmmc-voltage to 1.8V: >> %d\n", ret); >> + return; >> + } >> + >> + regulator_set_enable(mmc->vqmmc_supply, true); >> + if (ret) { >> + pr_err("failed to enable vqmmc-supply: >> %d\n", ret); >> + return; >> + } >> + } >> +#endif >> + if (IS_SD(mmc)) { >> + ctrl |= SDHCI_CTRL_VDD_180; >> + sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); >> + } >> + break; >> + default: >> + /* No signal voltage switch required */ >> + return; >> + } >> +} >> +#else >> +static void sdhci_set_voltage(struct sdhci_host *host) { } >> +#endif >> +void sdhci_set_control_reg(struct sdhci_host *host) >> +{ >> + sdhci_set_voltage(host); >> + sdhci_set_uhs_timing(host); >> +} >> + >> #ifdef CONFIG_DM_MMC >> static int sdhci_set_ios(struct udevice *dev) >> { >> diff --git a/include/sdhci.h b/include/sdhci.h >> index 3e5a64981857..0f820c6d2669 100644 >> --- a/include/sdhci.h >> +++ b/include/sdhci.h >> @@ -491,6 +491,7 @@ void sdhci_set_uhs_timing(struct sdhci_host *host); >> /* Export the operations to drivers */ >> int sdhci_probe(struct udevice *dev); >> int sdhci_set_clock(struct mmc *mmc, unsigned int clock);
RE: IMX8MM SD UHS support
Hi Tim and Andrey, I find the root cause, it is because during the 1.8v voltage switch process, SD clock do not gate off/ on according to the SD spec. For i.MX usdhc, if want to gate off the sd card clock, need to clear the bit 8 of VEND_SPEC, and set this bit to gate on the sd card clock. For the bit[14:11] of VEND_SPEC, our IP do not implement the function, just mark as reserved bits. So for current logic, we'll see the second mmc_wait_dat0() in mmc_switch_voltage() always return timeout. Let me double confirm with our IC team, and will send a formal fix patch tomorrow. Haibo > -Original Message- > From: Bough Chen > Sent: 2021年1月22日 20:42 > To: 'ZHIZHIKIN Andrey' ; > thar...@gateworks.com > Cc: Adam Ford ; Fabio Estevam > ; Peng Fan ; u-boot > ; Stefano Babic ; Jaehoon Chung > > Subject: RE: IMX8MM SD UHS support > > Hi Tim and Andrey > > I can reproduce this issue on my side, after revert my patch which you point > out, > SD can work on SDR104 mode. > Till now, I do not know why wait for data0 status will cause this issue. Give > me > more time, I will try to dig that out. > > Again, thanks for report this issue. > > Haibo > > > -Original Message- > > From: ZHIZHIKIN Andrey [mailto:andrey.zhizhi...@leica-geosystems.com] > > Sent: 2021年1月20日 4:48 > > To: thar...@gateworks.com > > Cc: Bough Chen ; Adam Ford > ; > > Fabio Estevam ; Peng Fan ; > > u-boot ; Stefano Babic ; Jaehoon > > Chung > > Subject: RE: IMX8MM SD UHS support > > > > Hello Tim, > > > > > -Original Message- > > > From: Tim Harvey > > > Sent: Tuesday, January 19, 2021 6:32 PM > > > To: ZHIZHIKIN Andrey > > > Cc: haibo.c...@nxp.com; Adam Ford ; Fabio > > Estevam > > > ; Peng Fan ; u-boot > > b...@lists.denx.de>; Stefano Babic ; Jaehoon Chung > > > > > > Subject: Re: IMX8MM SD UHS support > > > > > > On Mon, Jan 18, 2021 at 11:38 AM ZHIZHIKIN Andrey > > > wrote: > > > > > > > > Hello Tim, > > > > > > > > Sorry it took me quite some time to get this sorted out, but I > > > > believe I was able > > > to identify an offending commit that is preventing the USDHC to > > > switch to higher speed modes. > > > > > > > > It is in fact b5874b552f ("mmc: fsl_esdhc_imx: add wait_dat0() > > > > support"), > > > reverting it makes SD Card to properly report capabilities and > > > switch to high speed modes. > > > > > > > > Can you try to revert this on your end to see if the SD Card would > > > > start to > > > operate in high speed mode? > > > > > > > > I'm still investigating why this addition of wait_dat0() caused > > > > this, I believe this > > > is due to the fact that the same wait is already performed while > > > voltage switch to handle the errata, thus this addition wait might > > erroneously timeout. > > > > > > > > ++ Haibo Chen > > > > > > > > Haibo, > > > > > > > > Can you please explain the purpose of adding wait_dat0() > > > > Introduced with > > > commit b5874b552f? It is not clear from the commit message what was > > > the purpose of adding it. Have you tested the USDHC switch to higher > > > modes with this change? > > > > > > Andrey, > > > > > > Reverting b5874b552f ("mmc: fsl_esdhc_imx: add wait_dat0() support") > > > does not resolve the issue. That function waits for a specified > > > timeout for the card to assert DAT[0] either high or low depending > > > on arg and is used to check for command busy or failure. The patch > > > in question adds that function so that the common mmc code can > > > utilize it. If the function does not exist in the host controller > > > driver any call to mmc_wait_dat0 returns -ENOSYS so it must be there > > > to support UHS anyway. > > > > Perhaps, this is due to the fact that the same wait cycle is already > > executed during the invocation of mmc_send_cmd above the > > mmc_wait_dat0() in drivers/mmc/mmc.c. > > > > mmc_send_cmd calls esdhc_send_cmd_common in > > drivers/mmc/fsl_esdhc_imx.c, which already has a wait loop implemented > > to cover the "Workaround for ESDHC errata ENGcm03648" > > (as seen from the comment), which might explain why consecutive wait > > fails to return within timeout value. > > > > > > > > What is not clear to me is why the card would hold DAT[0] low on the > > > voltage switch indicating a failure as it does not in the Linux > > > driver which appears to me to be doing the same thing. > > > > This behavior might be explained by the implementation I traced above. > > > > > Again, if we ignore the return code UHS works fine and I'm not at > > > all clear why you wouldn't run into this issue: > > > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index > > > a6394bc..5ea3cd2 100644 > > > --- a/drivers/mmc/mmc.c > > > +++ b/drivers/mmc/mmc.c > > > @@ -579,10 +579,12 @@ static int mmc_switch_voltage(struct mmc > > *mmc, > > > int signal_voltage) > > > * dat[0:3] low. Wait for at least 1 ms according to spec > > > */ > > > err = mmc_wait_dat0(mmc, 1, 1000); > > > +#if 0 // hack: not clear why card a
[PATCH 1/1] avb: AVB_VERIFY depends on MMC
AVB Verified Boot uses functions related to MMC. Signed-off-by: Heinrich Schuchardt --- common/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/common/Kconfig b/common/Kconfig index d8982ba377..be4dd815c0 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -561,6 +561,7 @@ config HASH config AVB_VERIFY bool "Build Android Verified Boot operations" depends on LIBAVB + depends on MMC depends on PARTITION_UUIDS help This option enables compilation of bootloader-dependent operations, -- 2.29.2
Re: [PATCH 1/1] avb: AVB_VERIFY depends on MMC
Hi Heinrich, On Mon, Jan 25, 2021 at 1:18 PM Heinrich Schuchardt wrote: > > AVB Verified Boot uses functions related to MMC. > > Signed-off-by: Heinrich Schuchardt > --- > common/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/common/Kconfig b/common/Kconfig > index d8982ba377..be4dd815c0 100644 > --- a/common/Kconfig > +++ b/common/Kconfig > @@ -561,6 +561,7 @@ config HASH > config AVB_VERIFY > bool "Build Android Verified Boot operations" > depends on LIBAVB > + depends on MMC > depends on PARTITION_UUIDS > help > This option enables compilation of bootloader-dependent operations, > -- > 2.29.2 > Reviewed-by: Igor Opaniuk Thanks! -- Best regards - Freundliche Grüsse - Meilleures salutations Igor Opaniuk Embedded Software Engineer T: +380 938364067 E: igor.opan...@foundries.io W: www.foundries.io
Re: [RFC PATCH v2 1/2] optee: obtain emmc rpmb info from dt
Hi Jens, On Mon, Jan 25, 2021 at 10:50 AM Jens Wiklander wrote: > > Hi Igor, > > On Sun, Jan 24, 2021 at 11:39:45AM +0200, Igor Opaniuk wrote: > > From: Igor Opaniuk > > > > Add support for rpmb-dev property in optee node. > > Prioritize that provided eMMC info from DT for RPMB operations over > > the one provided by OP-TEE OS core in RPC calls. > > > > Signed-off-by: Igor Opaniuk > > --- > > > > Changes in v2: > > - Return NULL instead of ERR_PTR(-ENXIO) in get_rpmb_dev in case there > > is no rpmb-dev property or somemithing went wrong > > > > drivers/tee/optee/core.c | 33 + > > drivers/tee/optee/optee_private.h | 2 +- > > drivers/tee/optee/rpmb.c | 60 ++- > > 3 files changed, 70 insertions(+), 25 deletions(-) > > > > diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c > > index b898c32edc..828ab9b00a 100644 > > --- a/drivers/tee/optee/core.c > > +++ b/drivers/tee/optee/core.c > > @@ -12,6 +12,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "optee_smc.h" > > #include "optee_msg.h" > > @@ -607,14 +608,46 @@ static optee_invoke_fn *get_invoke_func(struct > > udevice *dev) > > return ERR_PTR(-EINVAL); > > } > > > > +static struct mmc *get_rpmb_dev(struct udevice *dev) > > +{ > > + struct udevice *mmc_dev; > > + const fdt32_t *phandle_p; > > + u32 phandle; > > + int ret = 0; > > + > > + debug("optee: looking for rpmb device in DT.\n"); > > + > > + phandle_p = ofnode_get_property(dev_ofnode(dev), > > + "rpmb-dev", NULL); > > + if (!phandle_p) { > > + debug("optee: missing \"rpmb-dev\" property\n"); > > With this we'll complain in the log each time "rpmb-dev" isn't found > even when OP-TEE isn't configured to use RPMB. This might cause some > confusion. Sure I'll wrap with "if (IS_ENABLED(CONFIG_SUPPORT_EMMC_RPMB))" get_rpmb_dev() invocation in optee_of_to_plat() . But as it's just a debug message, I would prefer to keep it for debugging purposes (I can adjust it, adding the phrase that the driver will use OP-TEE provided dev id instead). > Cheers, > Jens > > > + return NULL; > > + } > > + > > + phandle = fdt32_to_cpu(*phandle_p); > > + > > + ret = uclass_get_device_by_phandle_id(UCLASS_MMC, phandle, &mmc_dev); > > + if (ret) { > > + printf("optee: invalid phandle value in \"rpmb-dev\".\n"); > > + return NULL; > > + } > > + > > + debug("optee: using phandle %d from \"rpmd-dev\" property.\n", > > + phandle); > > + return mmc_get_mmc_dev(mmc_dev); > > +} > > + > > static int optee_of_to_plat(struct udevice *dev) > > { > > struct optee_pdata *pdata = dev_get_plat(dev); > > + struct optee_private *priv = dev_get_priv(dev); > > > > pdata->invoke_fn = get_invoke_func(dev); > > if (IS_ERR(pdata->invoke_fn)) > > return PTR_ERR(pdata->invoke_fn); > > > > + priv->rpmb_mmc = get_rpmb_dev(dev); > > + > > return 0; > > } > > > > diff --git a/drivers/tee/optee/optee_private.h > > b/drivers/tee/optee/optee_private.h > > index 1f07a27ee4..8e5a280622 100644 > > --- a/drivers/tee/optee/optee_private.h > > +++ b/drivers/tee/optee/optee_private.h > > @@ -19,8 +19,8 @@ > > */ > > struct optee_private { > > struct mmc *rpmb_mmc; > > - int rpmb_dev_id; > > int rpmb_original_part; > > + bool rpmb_inited; > > }; > > > > struct optee_msg_arg; > > diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c > > index 0804fc963c..0137c44be1 100644 > > --- a/drivers/tee/optee/rpmb.c > > +++ b/drivers/tee/optee/rpmb.c > > @@ -45,55 +45,67 @@ static void release_mmc(struct optee_private *priv) > > { > > int rc; > > > > - if (!priv->rpmb_mmc) > > + if (!priv->rpmb_mmc || !priv->rpmb_inited) > > return; > > > > - rc = blk_select_hwpart_devnum(IF_TYPE_MMC, priv->rpmb_dev_id, > > - priv->rpmb_original_part); > > + rc = mmc_switch_part(priv->rpmb_mmc, priv->rpmb_original_part); > > if (rc) > > debug("%s: blk_select_hwpart_devnum() failed: %d\n", > > __func__, rc); > > > > - priv->rpmb_mmc = NULL; > > + priv->rpmb_inited = false; > > +} > > + > > +static int check_mmc(struct mmc *mmc) > > +{ > > + if (!mmc) { > > + debug("Cannot find RPMB device\n"); > > + return -ENODEV; > > + } > > + if (!(mmc->version & MMC_VERSION_MMC)) { > > + debug("Device id is not an eMMC device\n"); > > + return -ENODEV; > > + } > > + if (mmc->version < MMC_VERSION_4_41) { > > + debug("RPMB is not supported before version 4.41\n"); > > + return -ENODEV; > > + } > > + > > + return 0; > > } > > > > static struct mmc *get_mmc(struct optee_private *priv, int dev_id) > > { > > - struct mmc *mmc; >
[PATCH 0/2] disk: part: sandbox support in dev_print()
Without the series the fatinfo command shows an error for host file backed block devices: => host bind 0 ../sandbox.img => fatinfo host 0:1 Interface: Unknown Device 0: Unhandled device type: 9 Filesystem: FAT16 "NO NAME" => With the series reasonable information is shown: => host bind 0 ../sandbox.img => fatinfo host 0:1 Interface: Unknown Device 0: Vendor: U-Boot Rev: 1.0 Prod: hostfile Type: Removable Hard Disk Capacity: 128.9 MB = 0.1 GB (264190 x 512) Filesystem: FAT16 "NO NAME" => The "Interface:" line is created in file_fat_detectfs() and still needs to be fixed. Heinrich Schuchardt (2): sandbox: fill block device meta information disk: part: sandbox support in dev_print() disk/part.c | 1 + drivers/block/sandbox.c | 11 +++ 2 files changed, 12 insertions(+) -- 2.29.2
[PATCH 2/2] disk: part: sandbox support in dev_print()
Commands like 'fatinfo' call dev_print() to print device information. If the block device is created via 'host bind', we should print accurate information. Signed-off-by: Heinrich Schuchardt --- disk/part.c | 1 + 1 file changed, 1 insertion(+) diff --git a/disk/part.c b/disk/part.c index b69fd345f3..85b1af55e2 100644 --- a/disk/part.c +++ b/disk/part.c @@ -150,6 +150,7 @@ void dev_print (struct blk_desc *dev_desc) case IF_TYPE_USB: case IF_TYPE_NVME: case IF_TYPE_PVBLOCK: + case IF_TYPE_HOST: printf ("Vendor: %s Rev: %s Prod: %s\n", dev_desc->vendor, dev_desc->revision, -- 2.29.2
[PATCH 1/2] sandbox: fill block device meta information
Provide information about host backed block device. Mark the device created by 'host bind' as removable. Signed-off-by: Heinrich Schuchardt --- drivers/block/sandbox.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c index 34c26cda47..f57f690d3c 100644 --- a/drivers/block/sandbox.c +++ b/drivers/block/sandbox.c @@ -92,6 +92,7 @@ int host_dev_bind(int devnum, char *filename) { struct host_block_dev *host_dev; struct udevice *dev; + struct blk_desc *desc; char dev_name[20], *str, *fname; int ret, fd; @@ -143,6 +144,12 @@ int host_dev_bind(int devnum, char *filename) goto err_file; } + desc = blk_get_devnum_by_type(IF_TYPE_HOST, devnum); + desc->removable = 1; + snprintf(desc->vendor, BLK_VEN_SIZE, "U-Boot"); + snprintf(desc->product, BLK_PRD_SIZE, "hostfile"); + snprintf(desc->revision, BLK_REV_SIZE, "1.0"); + return 0; err_file: os_close(fd); @@ -187,6 +194,10 @@ int host_dev_bind(int dev, char *filename) blk_dev->block_write = host_block_write; blk_dev->devnum = dev; blk_dev->part_type = PART_TYPE_UNKNOWN; + blk_dev->removable = 1; + snprintf(blk_dev->vendor, BLK_VEN_SIZE, "U-Boot"); + snprintf(blk_dev->product, BLK_PRD_SIZE, "hostfile"); + snprintf(blk_dev->revision, BLK_REV_SIZE, "1.0"); part_init(blk_dev); return 0; -- 2.29.2
Pull request for documentation tag doc-2021-04-rc1-2
The following changes since commit 69d29fe1c0aeb33f42633a7d30b7921c02aa: Merge tag 'efi-2021-04-rc1-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi (2021-01-23 19:07:00 -0500) are available in the Git repository at: https://gitlab.denx.de/u-boot/custodians/u-boot-efi.git tags/doc-2021-04-rc1-2 for you to fetch changes up to 5b6dac01e636aa8b799a68c115d9fd86e4bbbf09: doc: describe command conitrace (2021-01-25 01:15:34 +0100) Pull request for documentation tag doc-2021-04-rc1 (2) * Man-pages for sbi, exit, for, echo, loady, true, false, conitrace * Adjust suppression of newline in echo command. * Provide unit test for echo command. Heinrich Schuchardt (12): doc: document sbi command doc: describe exit command doc: document for statement cmd: change suppress newline in echo command test: unit test for echo command doc: document echo command cmd: correct long text loadb, loadx, loady doc: describe loady command doc: document true command dm: core: describe uclass_root_s doc: describe the false command doc: describe command conitrace MAINTAINERS | 1 + cmd/echo.c| 49 +++- cmd/load.c| 12 +++ doc/usage/conitrace.rst | 54 +++ doc/usage/echo.rst| 65 + doc/usage/exit.rst| 40 +++ doc/usage/false.rst | 28 doc/usage/for.rst | 65 + doc/usage/index.rst | 8 + doc/usage/loady.rst | 67 +++ doc/usage/sbi.rst | 49 doc/usage/true.rst| 28 include/asm-generic/global_data.h | 16 +++--- test/cmd/Makefile | 3 ++ test/cmd/test_echo.c | 57 + 15 files changed, 501 insertions(+), 41 deletions(-) create mode 100644 doc/usage/conitrace.rst create mode 100644 doc/usage/echo.rst create mode 100644 doc/usage/exit.rst create mode 100644 doc/usage/false.rst create mode 100644 doc/usage/for.rst create mode 100644 doc/usage/loady.rst create mode 100644 doc/usage/sbi.rst create mode 100644 doc/usage/true.rst create mode 100644 test/cmd/test_echo.c
Re: [RFC PATCH v2 1/2] optee: obtain emmc rpmb info from dt
On Mon, Jan 25, 2021 at 12:50 PM Igor Opaniuk wrote: > > Hi Jens, > > On Mon, Jan 25, 2021 at 10:50 AM Jens Wiklander > wrote: > > > > Hi Igor, > > > > On Sun, Jan 24, 2021 at 11:39:45AM +0200, Igor Opaniuk wrote: > > > From: Igor Opaniuk > > > > > > Add support for rpmb-dev property in optee node. > > > Prioritize that provided eMMC info from DT for RPMB operations over > > > the one provided by OP-TEE OS core in RPC calls. > > > > > > Signed-off-by: Igor Opaniuk > > > --- > > > > > > Changes in v2: > > > - Return NULL instead of ERR_PTR(-ENXIO) in get_rpmb_dev in case there > > > is no rpmb-dev property or somemithing went wrong > > > > > > drivers/tee/optee/core.c | 33 + > > > drivers/tee/optee/optee_private.h | 2 +- > > > drivers/tee/optee/rpmb.c | 60 ++- > > > 3 files changed, 70 insertions(+), 25 deletions(-) > > > > > > diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c > > > index b898c32edc..828ab9b00a 100644 > > > --- a/drivers/tee/optee/core.c > > > +++ b/drivers/tee/optee/core.c > > > @@ -12,6 +12,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #include "optee_smc.h" > > > #include "optee_msg.h" > > > @@ -607,14 +608,46 @@ static optee_invoke_fn *get_invoke_func(struct > > > udevice *dev) > > > return ERR_PTR(-EINVAL); > > > } > > > > > > +static struct mmc *get_rpmb_dev(struct udevice *dev) > > > +{ > > > + struct udevice *mmc_dev; > > > + const fdt32_t *phandle_p; > > > + u32 phandle; > > > + int ret = 0; > > > + > > > + debug("optee: looking for rpmb device in DT.\n"); > > > + > > > + phandle_p = ofnode_get_property(dev_ofnode(dev), > > > + "rpmb-dev", NULL); > > > + if (!phandle_p) { > > > + debug("optee: missing \"rpmb-dev\" property\n"); > > > > With this we'll complain in the log each time "rpmb-dev" isn't found > > even when OP-TEE isn't configured to use RPMB. This might cause some > > confusion. > > Sure I'll wrap with "if (IS_ENABLED(CONFIG_SUPPORT_EMMC_RPMB))" > get_rpmb_dev() invocation in optee_of_to_plat() . > > But as it's just a debug message, I would prefer to keep it for > debugging purposes > (I can adjust it, adding the phrase that the driver will use OP-TEE > provided dev id instead). Sounds good. Cheers, Jens
[PATCH v4 0/7] Introduce DSA Ethernet switch class and Felix driver
From: Vladimir Oltean DSA stands for Distributed Switch Architecture and it is a subsystem introduced in the Linux kernel to support switches that: - have an Ethernet link up to the CPU - use some form of tagging to identify the source/destination port for Rx/Tx - may be cascaded in tree-like structures. DSA is described in depth here: https://www.kernel.org/doc/Documentation/networking/dsa/dsa.txt This patch set introduces a DSA class in U-Boot to support drivers of DSA switches. DSA drivers have to implement the following ops: - enable/disable of switch ports, - insert a tag in frames being transmitted, used by the switch to select the egress port, - parse a tag in frames being received, used for Rx traffic. DSA class code deals with presentation of switch ports as Ethernet interfaces, deals with the master Ethernet device for I/O and helps with parsing of the DT assuming the structure follows the DSA kernel binding. Support for switch cascading is not included yet. In the sandbox environment, the DSA sandbox driver, the switch ports and master eth interface look like this: => dm tree Class Index Probed DriverName --- [...] eth 4 [ + ] eth_sandbox |-- dsa-test-eth dsa 0 [ + ] dsa_sandbox |-- dsa-test eth 5 [ + ] dsa-port | |-- lan0 eth 6 [ + ] dsa-port | `-- lan1 => setenv ethact lan1 => ping 1.2.3.5 Using lan1 device host 1.2.3.5 is alive => This patch set also introduces a driver for the Ethernet switch integrated into NXP LS1028A, called Felix. The switch has 4 front panel ports, I/O to/from it is done though an ENETC Ethernet interface and meta-data is carried between the switch and the driver though an additional header pre-pended to the original frame. Network commands like tftp can be used on these front panel ports. The ports are disabled unless used so they do not cause issues on network topologies that include loops. Felix as seen on LS1028A RDB: => dm tree Class Index Probed DriverName --- [...] dsa 0 [ + ] felix-switch | |-- felix-switch eth 4 [ + ] dsa-port | | |-- swp0 eth 5 [ + ] dsa-port | | |-- swp1 eth 6 [ + ] dsa-port | | |-- swp2 eth 7 [ + ] dsa-port | | `-- swp3 => mdio list [...] 10 - Vitesse VSC8514 <--> swp0 11 - Vitesse VSC8514 <--> swp1 12 - Vitesse VSC8514 <--> swp2 13 - Vitesse VSC8514 <--> swp3 NOTE: This patchset is a major rework of the dsa-class code since the last submission from May 5th: https://patchwork.ozlabs.org/project/uboot/cover/1588700588-8587-1-git-send-email-claudiu.man...@nxp.com/ The basic concepts and data path operation (tagging) in the DSA class code remain the same as in the initial patchset from Alex, however the external API has been changed significantly (simplified), the driver model integration has been improved to the point that the DSA class code no longer needs to allocate extra memory internally (via malloc), reduced memory footprint, internal state data moved from the external API and internalized, cleaner external API, internal code reworked, completely reworked DSA sandbox driver and unit tests for better coverage and to integrate better with the eth sandbox driver and tests, etc. v4: - Implemented the TODO for having a phy_device on the CPU port. - Enabled CONFIG_PHY_FIXED which is a new dependency of CONFIG_DM_DSA. v3: - Removed all infrastructure associated with dsa_foreach_port, which is no longer needed. - Only inherit the DSA master's MAC address if the environment does not already have a specific MAC address that should be used for the DSA port. - Be compatible with the new "ethernet-ports" container name which has been introduced in the Linux kernel as commit 85e05d263ed2 ("net: dsa: of: Allow ethernet-ports as encapsulating node") in v5.9. - Fixed the felix driver not getting its ports initialized, due to dsa_foreach_port() being actually unusable when called from the probe function of the DSA udevice - the eth port udevices are _not_ yet probed at that point. We are now initializing all ports from the .port_enable() callback of each eth udevice. - Deleted the unit tests associated with the infrastructure for dsa_foreach_port, since that function no longer exists. - Enabled the config options for the Kontron LS1028A board too. v2: Switch node structure defined in dtsi now consistent with the Linux switch node definition. Moved aliases from dtsi to the RDB dts to minimize impact on other boards (and for improved flexibility). Alex Marginean (3): drivers: net: Add Felix DSA switch driver arm: dts: ls1028a: Add Ethernet switch node and dependencies configs: ls1028a: Enable the Etherne
[PATCH v4 1/7] net: phy: fixed: support speeds of 2500 and 10000
From: Vladimir Oltean Unlike the Linux fixed PHY driver, the one in U-Boot does not attempt to emulate the clause 22 register set of a gigabit copper PHY driver through the swphy framework. Therefore, the limitation of being unable to support speeds higher than gigabit in fixed-link does not apply to the U-Boot fixed PHY driver. This makes the fixed-link U-Boot implementation more similar to the one from phylink, which can work with any valid link speed. Signed-off-by: Vladimir Oltean --- Changes in v4: Patch is new. drivers/net/phy/fixed.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c index 9d9f746e1dba..be06e542040b 100644 --- a/drivers/net/phy/fixed.c +++ b/drivers/net/phy/fixed.c @@ -23,7 +23,8 @@ int fixedphy_probe(struct phy_device *phydev) /* check for mandatory properties within fixed-link node */ val = fdt_getprop_u32_default_node(gd->fdt_blob, ofnode, 0, "speed", 0); - if (val != SPEED_10 && val != SPEED_100 && val != SPEED_1000) { + if (val != SPEED_10 && val != SPEED_100 && val != SPEED_1000 && + val != SPEED_2500 && val != SPEED_1) { printf("ERROR: no/invalid speed given in fixed-link node!"); return -EINVAL; } -- 2.25.1
[PATCH v4 2/7] net: phy: introduce fixed_phy_create for DSA CPU ports
From: Vladimir Oltean The DSA (Distributed Switch Architecture) implementation has made a design decision when it got introduced to the Linux kernel in 2008. That was to hide away from the user the CPU-facing Ethernet MAC, since it does not make sense to register it as a struct net_device (UCLASS_ETH udevice for U-Boot), because that would never be beneficial for a user: they would not be able to use it for traffic, since conceptually, a packet delivered to the CPU port should loop back into the system. Nonetheless, DSA has had numerous growing pains due to the lack of a struct net_device for the CPU port, but so far it has overcome them. It is unlikely at this stage of maturity that this aspect of it will change. We would like U-Boot to present the same information as Linux, to be at parity in terms of number of interfaces, so that ethNaddr environment variables could directly be associated between U-Boot and Linux. Therefore, we would implicitly like U-Boot to hide the CPU port from the user as well. But the paradox is that DSA still needs a struct phy_device to inform the driver of the parameters of the link that it should configure the CPU port to. The problem is that the phy_device is typically returned via a call to phy_connect, which needs an udevice to attach the PHY to, and to search its ofnode for the 'fixed-link' property. But we don't have an udevice to present for the CPU port. Since 99% of DSA setups are MAC-to-MAC connections between the switch and the host Ethernet controller, the struct phy_device is going to be a fixed PHY. This simplifies things quite a bit. In U-Boot, a fixed PHY does not need an MDIO bus, and does not need an attached dev either. Basically, the phy_connect call doesn't do any connection, it just creates the fixed PHY. The proposal of this patch is to introduce a new fixed_phy_create function which will take a single argument: the ofnode that holds this: port@4 { reg = <4>; phy-mode = "internal"; fixed-link { speed = <2500>; full-duplex; }; }; and probe a fixed PHY driver using the information from this ofnode. DSA will probably be the only user of this function. Signed-off-by: Vladimir Oltean --- Changes in v4: Patch is new. drivers/net/phy/phy.c | 31 +++ include/phy.h | 21 + 2 files changed, 52 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 9587e6b9fae4..849ad0487de4 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -973,6 +973,37 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus, #endif #ifdef CONFIG_PHY_FIXED +/** + * fixed_phy_create() - create an unconnected fixed-link pseudo-PHY device + * @node: OF node for the container of the fixed-link node + * + * Description: Creates a struct phy_device based on a fixed-link of_node + * description. Can be used without phy_connect by drivers which do not expose + * a UCLASS_ETH udevice. + */ +struct phy_device *fixed_phy_create(ofnode node) +{ + phy_interface_t interface = PHY_INTERFACE_MODE_NONE; + const char *if_str; + ofnode subnode; + + if_str = ofnode_read_string(node, "phy-mode"); + if (!if_str) { + if_str = ofnode_read_string(node, "phy-interface-type"); + } + if (if_str) { + interface = phy_get_interface_by_name(if_str); + } + + subnode = ofnode_find_subnode(node, "fixed-link"); + if (!ofnode_valid(subnode)) { + return NULL; + } + + return phy_device_create(NULL, ofnode_to_offset(subnode), PHY_FIXED_ID, +false, interface); +} + #ifdef CONFIG_DM_ETH static struct phy_device *phy_connect_fixed(struct mii_dev *bus, struct udevice *dev, diff --git a/include/phy.h b/include/phy.h index cbdb10d6fced..633c1e492fc9 100644 --- a/include/phy.h +++ b/include/phy.h @@ -402,6 +402,27 @@ int phy_reset(struct phy_device *phydev); struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask, phy_interface_t interface); +#ifdef CONFIG_PHY_FIXED + +/** + * fixed_phy_create() - create an unconnected fixed-link pseudo-PHY device + * @node: OF node for the container of the fixed-link node + * + * Description: Creates a struct phy_device based on a fixed-link of_node + * description. Can be used without phy_connect by drivers which do not expose + * a UCLASS_ETH udevice. + */ +struct phy_device *fixed_phy_create(ofnode node); + +#else + +static inline struct phy_device *fixed_phy_create(ofnode node) +{ + return NULL; +} + +#endif + #ifdef CONFIG_DM_ETH /** -- 2.25.1
[PATCH v4 4/7] sandbox: Add a DSA sandbox driver and unit test
From: Claudiu Manoil The DSA sandbox driver is used for unit testing the DSA class code. It implements a simple 2 port switch plus 1 CPU port, and uses a very simple tag to identify the ports. The DSA sandbox device is connected via CPU port to a regular Ethernet sandbox device, called 'dsa-test-eth, managed by the existing eth sandbox driver. The 'dsa-test-eth' is not intended for testing the eth class code however, but it is used to emulate traffic through the 'lan0' and 'lan1' front pannel switch ports. To achieve this the dsa sandbox driver registers a tx handler for the 'dsa-test-eth' device. The switch ports, labeled as 'lan0' and 'lan1', are also registered as eth devices by the dsa class code this time. So pinging through these switch ports is as easy as: => setenv ethact lan0 => ping 1.2.3.5 Unit tests for the dsa class code were also added. The 'dsa_probe' test exercises most API functions from dsa.h. The 'dsa' unit test simply exercises ARP/ICMP traffic through the two switch ports, including tag injection and extraction, with the help of the dsa sandbox driver. I took care to minimize the impact on the existing eth unit tests, though some adjustments needed to be made with the addition of extra eth interfaces used by the dsa unit tests. The additional eth interfaces also require MAC addresses, these have been added to the sandbox default environment. Signed-off-by: Alex Marginean Signed-off-by: Claudiu Manoil Reviewed-by: Simon Glass Signed-off-by: Vladimir Oltean --- v4: none. v3: - deleted the unit tests associated with the infrastructure for dsa_foreach_port, since that function no longer exists. - added fixed-link and phy-mode to lan0 from the sandbox device tree. We don't support ports that don't have a PHY and are not fixed-link either. v2: none arch/Kconfig | 1 + arch/sandbox/dts/test.dts | 48 ++ drivers/net/Kconfig | 9 ++ drivers/net/Makefile | 1 + drivers/net/dsa_sandbox.c | 179 ++ include/configs/sandbox.h | 2 + test/dm/Makefile | 1 + test/dm/dsa.c | 82 + test/dm/eth.c | 10 +-- 9 files changed, 328 insertions(+), 5 deletions(-) create mode 100644 drivers/net/dsa_sandbox.c create mode 100644 test/dm/dsa.c diff --git a/arch/Kconfig b/arch/Kconfig index 27843cd79c4c..8a8130f0c823 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -160,6 +160,7 @@ config SANDBOX imply CMD_CLONE imply SILENT_CONSOLE imply BOOTARGS_SUBST + imply DM_DSA config SH bool "SuperH architecture" diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index f86cd0d3b277..0b7e853f40c5 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -14,7 +14,9 @@ aliases { console = &uart0; eth0 = "/eth@10002000"; + eth2 = &swp_0; eth3 = ð_3; + eth4 = &dsa_eth0; eth5 = ð_5; gpio1 = &gpio_a; gpio2 = &gpio_b; @@ -422,6 +424,52 @@ fake-host-hwaddr = [00 00 66 44 22 22]; }; + dsa_eth0: dsa-test-eth { + compatible = "sandbox,eth"; + reg = <0x10006000 0x1000>; + fake-host-hwaddr = [00 00 66 44 22 66]; + }; + + dsa-test { + compatible = "sandbox,dsa"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + swp_0: port@0 { + reg = <0>; + label = "lan0"; + phy-mode = "rgmii-rxid"; + + fixed-link { + speed = <100>; + full-duplex; + }; + }; + + swp_1: port@1 { + reg = <1>; + label = "lan1"; + phy-mode = "rgmii-txid"; + + fixed-link { + speed = <100>; + full-duplex; + }; + }; + + port@2 { + reg = <2>; + ethernet = <&dsa_eth0>; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; + firmware { sandbox_firmware: sandbox-firmware { compatible = "sandbox,firmware"; diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 7d3f31ddcff0..1a9bc7cfa195 100644 --- a/drivers/net/K
[PATCH v4 3/7] net: Introduce DSA class for Ethernet switches
From: Claudiu Manoil DSA stands for Distributed Switch Architecture and it covers switches that are connected to the CPU through an Ethernet link and generally use frame tags to pass information about the source/destination ports to/from CPU. Front panel ports are presented as regular ethernet devices in U-Boot and they are expected to support the typical networking commands. DSA switches may be cascaded, DSA class code does not currently support this. Signed-off-by: Alex Marginean Signed-off-by: Claudiu Manoil Reviewed-by: Simon Glass Signed-off-by: Vladimir Oltean --- v4: - Implemented the TODO for having a phy_device on the CPU port. v3: - Removed all infrastructure associated with dsa_foreach_port, which is no longer needed. - Only inherit the DSA master's MAC address if the environment does not already have a specific MAC address that should be used for the DSA port. - Be compatible with the new "ethernet-ports" container name which has been introduced in the Linux kernel as commit 85e05d263ed2 ("net: dsa: of: Allow ethernet-ports as encapsulating node") in v5.9. v2: none drivers/net/Kconfig| 15 ++ include/dm/uclass-id.h | 1 + include/net.h | 6 + include/net/dsa.h | 165 ++ net/Makefile | 1 + net/dsa-uclass.c | 478 + 6 files changed, 666 insertions(+) create mode 100644 include/net/dsa.h create mode 100644 net/dsa-uclass.c diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 3a5e03688059..7d3f31ddcff0 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -37,6 +37,21 @@ config DM_MDIO_MUX This is currently implemented in net/mdio-mux-uclass.c Look in include/miiphy.h for details. +config DM_DSA + bool "Enable Driver Model for DSA switches" + depends on DM_ETH && DM_MDIO + depends on PHY_FIXED + help + Enable driver model for DSA switches + + Adds UCLASS_DSA class supporting switches that follow the Distributed + Switch Architecture (DSA). These switches rely on the presence of a + management switch port connected to an Ethernet controller capable of + receiving frames from the switch. This host Ethernet controller is + called the "master" Ethernet interface in DSA terminology. + This is currently implemented in net/dsa-uclass.c, refer to + include/net/dsa.h for API details. + config MDIO_SANDBOX depends on DM_MDIO && SANDBOX default y diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index ae4425d7a57a..d75de368c5a8 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -46,6 +46,7 @@ enum uclass_id { UCLASS_DISPLAY, /* Display (e.g. DisplayPort, HDMI) */ UCLASS_DSI_HOST,/* Display Serial Interface host */ UCLASS_DMA, /* Direct Memory Access */ + UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */ UCLASS_EFI, /* EFI managed devices */ UCLASS_ETH, /* Ethernet device */ UCLASS_ETH_PHY, /* Ethernet PHY device */ diff --git a/include/net.h b/include/net.h index 13da69b7c145..b95d6a6f60eb 100644 --- a/include/net.h +++ b/include/net.h @@ -499,7 +499,13 @@ struct icmp_hdr { * maximum packet size and multiple of 32 bytes = 1536 */ #define PKTSIZE1522 +#ifndef CONFIG_DM_DSA #define PKTSIZE_ALIGN 1536 +#else +/* Maximum DSA tagging overhead (headroom and/or tailroom) */ +#define DSA_MAX_OVR256 +#define PKTSIZE_ALIGN (1536 + DSA_MAX_OVR) +#endif /* * Maximum receive ring size; that is, the number of packets diff --git a/include/net/dsa.h b/include/net/dsa.h new file mode 100644 index ..0f31a908c9d1 --- /dev/null +++ b/include/net/dsa.h @@ -0,0 +1,165 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019-2021 NXP Semiconductors + */ + +#ifndef __DSA_H__ +#define __DSA_H__ + +#include +#include + +/** + * DSA stands for Distributed Switch Architecture and it is infrastructure + * intended to support drivers for Switches that rely on an intermediary + * Ethernet device for I/O. These switches may support cascading allowing + * them to be arranged as a tree. + * DSA is documented in detail in the Linux kernel documentation under + * Documentation/networking/dsa/dsa.txt + * The network layout of such a switch is shown below: + * + * |--| + * | eth0 | <--- master eth device (regular eth driver) + * |--| + *^ | + * tag added by switch -->| | + *| | + *| |<-- tag added by DSA driver + *| v + * |--| + * | | CPU port | | <-- DSA (switch) device + * | --
[PATCH v4 5/7] drivers: net: Add Felix DSA switch driver
From: Alex Marginean This driver is used for the Ethernet switch integrated into LS1028A NXP. Felix on LS1028A has 4 front panel ports and two internal ports, I/O to/from the switch is done through an ENETC Ethernet interface. The 4 front panel ports are available as Ethernet interfaces and can be used with the typical network commands like tftp. Signed-off-by: Alex Marginean Signed-off-by: Claudiu Manoil Signed-off-by: Vladimir Oltean --- v4: none v3: dsa_foreach_port() does not work when called from the probe function of the DSA udevice, because the eth port udevices are _not_ yet probed at that point. To fix this, we are now initializing all ports from the .port_enable() callback of each eth udevice. v2: none drivers/net/fsl_enetc.h | 5 + drivers/net/mscc_eswitch/Kconfig| 8 + drivers/net/mscc_eswitch/Makefile | 1 + drivers/net/mscc_eswitch/felix_switch.c | 414 4 files changed, 428 insertions(+) create mode 100644 drivers/net/mscc_eswitch/felix_switch.c diff --git a/drivers/net/fsl_enetc.h b/drivers/net/fsl_enetc.h index 37e7e858435b..110c1d78fbc6 100644 --- a/drivers/net/fsl_enetc.h +++ b/drivers/net/fsl_enetc.h @@ -201,6 +201,11 @@ struct enetc_priv { /* PCS replicator block for USXGMII */ #define ENETC_PCS_DEVAD_REPL 0x1f +#define ENETC_PCS_REPL_LINK_TIMER_10x12 +#define ENETC_PCS_REPL_LINK_TIMER_1_DEF 0x0003 +#define ENETC_PCS_REPL_LINK_TIMER_20x13 +#define ENETC_PCS_REPL_LINK_TIMER_2_DEF 0x06a0 + /* ENETC external MDIO registers */ #define ENETC_MDIO_BASE0x1c00 #define ENETC_MDIO_CFG 0x00 diff --git a/drivers/net/mscc_eswitch/Kconfig b/drivers/net/mscc_eswitch/Kconfig index 80dd22f98b7f..ccf7822dbe7a 100644 --- a/drivers/net/mscc_eswitch/Kconfig +++ b/drivers/net/mscc_eswitch/Kconfig @@ -36,3 +36,11 @@ config MSCC_SERVAL_SWITCH select PHYLIB help This driver supports the Serval network switch device. + +config MSCC_FELIX_SWITCH + bool "Felix switch driver" + depends on DM_DSA && DM_PCI + select FSL_ENETC + help + This driver supports the Ethernet switch integrated in the + NXP LS1028A SoC. diff --git a/drivers/net/mscc_eswitch/Makefile b/drivers/net/mscc_eswitch/Makefile index d583fe9fc4bb..22342ed11417 100644 --- a/drivers/net/mscc_eswitch/Makefile +++ b/drivers/net/mscc_eswitch/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_MSCC_LUTON_SWITCH) += luton_switch.o mscc_xfer.o mscc_mac_table.o m obj-$(CONFIG_MSCC_JR2_SWITCH) += jr2_switch.o mscc_xfer.o mscc_miim.o obj-$(CONFIG_MSCC_SERVALT_SWITCH) += servalt_switch.o mscc_xfer.o mscc_miim.o obj-$(CONFIG_MSCC_SERVAL_SWITCH) += serval_switch.o mscc_xfer.o mscc_mac_table.o mscc_miim.o +obj-$(CONFIG_MSCC_FELIX_SWITCH) += felix_switch.o diff --git a/drivers/net/mscc_eswitch/felix_switch.c b/drivers/net/mscc_eswitch/felix_switch.c new file mode 100644 index ..f20e84e0f10c --- /dev/null +++ b/drivers/net/mscc_eswitch/felix_switch.c @@ -0,0 +1,414 @@ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +/* + * Felix (VSC9959) Ethernet switch driver + * Copyright 2018-2021 NXP Semiconductors + */ + +/* + * This driver is used for the Ethernet switch integrated into NXP LS1028A. + * Felix switch is derived from Microsemi Ocelot but there are several NXP + * adaptations that makes the two U-Boot drivers largely incompatible. + * + * Felix on LS1028A has 4 front panel ports and two internal ports, connected + * to ENETC interfaces. We're using one of the ENETC interfaces to push traffic + * into the switch. Injection/extraction headers are used to identify + * egress/ingress ports in the switch for Tx/Rx. + */ + +#include +#include +#include +#include +#include +#include + +/* defines especially around PCS are reused from enetc */ +#include "../fsl_enetc.h" + +#define PCI_DEVICE_ID_FELIX_ETHSW 0xEEF0 + +/* Felix has in fact 6 ports, but we don't use the last internal one */ +#define FELIX_PORT_COUNT 5 +/* Front panel port mask */ +#define FELIX_FP_PORT_MASK 0xf + +/* Register map for BAR4 */ +#define FELIX_SYS 0x01 +#define FELIX_ES0 0x04 +#define FELIX_IS1 0x05 +#define FELIX_IS2 0x06 +#define FELIX_GMII(port) (0x10 + (port) * 0x1) +#define FELIX_QSYS 0x20 + +#define FELIX_SYS_SYSTEM (FELIX_SYS + 0x0E00) +#define FELIX_SYS_SYSTEM_EN BIT(0) +#define FELIX_SYS_RAM_CTRL (FELIX_SYS + 0x0F24) +#define FELIX_SYS_RAM_CTRL_INIT BIT(1) +#define FELIX_SYS_SYSTEM_PORT_MODE(a) (FELIX_SYS_SYSTEM + 0xC + (a) * 4) +#define FELIX_SYS_SYSTEM_PORT_MODE_CPU0x001e + +#define FELIX_ES0_TCAM_CTRL(FELIX_ES0 + 0x03C0) +#define FELIX_ES0_TCAM_CTRL_ENBIT(0) +#define FELIX_IS1_TCAM_CTR
[PATCH v4 6/7] arm: dts: ls1028a: Add Ethernet switch node and dependencies
From: Alex Marginean The definition follows the DSA binding in kernel and describes the switch, its ports and PHYs. The switch node has the same structure as in Linux and this patch enables it (and relevant ports) for the LS1028A RDB board. ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028A, it is not used in U-Boot and was disabled. Ethernet port aliases were also added to better manage the multitude of ports available now. Signed-off-by: Alex Marginean Signed-off-by: Claudiu Manoil Signed-off-by: Vladimir Oltean --- v4: none. v3: Added a comment denoting the PHY model present on the RDB. v2: Switch node structure defined in dtsi now consistent with the Linux switch node definition. Moved aliases from dtsi to the RDB DTS to minimize impact on other boards (and for improved flexibility). arch/arm/dts/fsl-ls1028a-rdb.dts | 64 arch/arm/dts/fsl-ls1028a.dtsi| 56 +++- 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/fsl-ls1028a-rdb.dts b/arch/arm/dts/fsl-ls1028a-rdb.dts index 85b4815b2ed7..3432fca35269 100644 --- a/arch/arm/dts/fsl-ls1028a-rdb.dts +++ b/arch/arm/dts/fsl-ls1028a-rdb.dts @@ -15,6 +15,12 @@ compatible = "fsl,ls1028a-rdb", "fsl,ls1028a"; aliases { spi0 = &fspi; + eth0 = &enetc0; + eth1 = &enetc2; + eth2 = &mscc_felix_port0; + eth3 = &mscc_felix_port1; + eth4 = &mscc_felix_port2; + eth5 = &mscc_felix_port3; }; }; @@ -131,9 +137,67 @@ phy-handle = <&rdb_phy0>; }; +&enetc2 { + status = "okay"; +}; + +&mscc_felix { + status = "okay"; +}; + +&mscc_felix_port0 { + label = "swp0"; + phy-handle = <&sw_phy0>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port1 { + label = "swp1"; + phy-handle = <&sw_phy1>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port2 { + label = "swp2"; + phy-handle = <&sw_phy2>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port3 { + label = "swp3"; + phy-handle = <&sw_phy3>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port4 { + ethernet = <&enetc2>; + status = "okay"; +}; + &mdio0 { status = "okay"; rdb_phy0: phy@2 { reg = <2>; }; + + /* VSC8514 QSGMII PHY */ + sw_phy0: phy@10 { + reg = <0x10>; + }; + + sw_phy1: phy@11 { + reg = <0x11>; + }; + + sw_phy2: phy@12 { + reg = <0x12>; + }; + + sw_phy3: phy@13 { + reg = <0x13>; + }; }; diff --git a/arch/arm/dts/fsl-ls1028a.dtsi b/arch/arm/dts/fsl-ls1028a.dtsi index d0850237c797..9740006689ca 100644 --- a/arch/arm/dts/fsl-ls1028a.dtsi +++ b/arch/arm/dts/fsl-ls1028a.dtsi @@ -151,9 +151,63 @@ reg = <0x000300 0 0 0 0>; status = "disabled"; }; + + mscc_felix: pci@0,5 { + reg = <0x000500 0 0 0 0>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + mscc_felix_port0: port@0 { + reg = <0>; + status = "disabled"; + }; + + mscc_felix_port1: port@1 { + reg = <1>; + status = "disabled"; + }; + + mscc_felix_port2: port@2 { + reg = <2>; + status = "disabled"; + }; + + mscc_felix_port3: port@3 { + reg = <3>; + status = "disabled"; + }; + + mscc_felix_port4: port@4 { + reg = <4>; + phy-mode = "internal"; + status = "disabled"; + + fixed-link { + speed = <2500>; + full-duplex; + }; + }; + + mscc_felix_port5: port@5 { + reg = <5>; + phy-mode = "internal"; + status = "disabled"; + + fixed-link { +
[PATCH v4 7/7] configs: ls1028a: Enable the Ethernet switch driver in defconfig
From: Alex Marginean The switch driver for LS1028A Ethernet switch is now compiled in for the NXP LS1028A reference design boards and for the Kontron SMARC-sAL28. Signed-off-by: Alex Marginean Signed-off-by: Claudiu Manoil Signed-off-by: Vladimir Oltean Acked-by: Michael Walle --- v4: enabled CONFIG_PHY_FIXED which is a new dependency of CONFIG_DM_DSA v3: enable the config options for the Kontron board too. v2: none configs/kontron_sl28_defconfig | 3 +++ configs/ls1028aqds_tfa_SECURE_BOOT_defconfig | 3 +++ configs/ls1028aqds_tfa_defconfig | 3 +++ configs/ls1028ardb_tfa_SECURE_BOOT_defconfig | 3 +++ configs/ls1028ardb_tfa_defconfig | 3 +++ 5 files changed, 15 insertions(+) diff --git a/configs/kontron_sl28_defconfig b/configs/kontron_sl28_defconfig index c1a096799c2c..f4bed697cf29 100644 --- a/configs/kontron_sl28_defconfig +++ b/configs/kontron_sl28_defconfig @@ -82,6 +82,9 @@ CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_FSL_ENETC=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y diff --git a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig index 14c49cd0d6f7..decd06e75ffe 100644 --- a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig +++ b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig @@ -61,6 +61,9 @@ CONFIG_DM_MDIO_MUX=y CONFIG_E1000=y CONFIG_FSL_ENETC=y CONFIG_MDIO_MUX_I2CREG=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y diff --git a/configs/ls1028aqds_tfa_defconfig b/configs/ls1028aqds_tfa_defconfig index 09a692370876..3da2970eca2e 100644 --- a/configs/ls1028aqds_tfa_defconfig +++ b/configs/ls1028aqds_tfa_defconfig @@ -67,6 +67,9 @@ CONFIG_DM_MDIO_MUX=y CONFIG_E1000=y CONFIG_FSL_ENETC=y CONFIG_MDIO_MUX_I2CREG=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y diff --git a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig index b034580aeff6..99c18722667f 100644 --- a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig +++ b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig @@ -58,6 +58,9 @@ CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_FSL_ENETC=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y diff --git a/configs/ls1028ardb_tfa_defconfig b/configs/ls1028ardb_tfa_defconfig index 4bed352420a0..38a86ee396e0 100644 --- a/configs/ls1028ardb_tfa_defconfig +++ b/configs/ls1028ardb_tfa_defconfig @@ -64,6 +64,9 @@ CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_FSL_ENETC=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y -- 2.25.1
[PATCH v8 0/4] OP-TEE I2C trampoline and associated tests
From: Igor Opaniuk This patchset allows OP-TEE to communicate with I2C devices; a typical use case would be servicing U-Boot requests that require underlying cryptographic operations implemented by an I2C chip. On a board fitted with the NXP SE050 I2C secure element, OP-TEE can route some of the cryptographic operations it needs to that device (ie RSA, ECC, CTR..). Before the REE executes, OP-TEE would use its own I2C drivers to communicate with the device on the bus; later on, once the REE is up, accesses to the I2C bus should be coordinated with the REE to avoid collisions. However instead of implementing such a synchronization mechanism, this trampoline service permits OP-TEE to route those I2C requests back to U-boot without then having to worry about collisions. Lets suppose that U-Boot executes the trusted application Android Verified Boot; when OP-TEE receives the request - and before executing the application - it uses RSA to verify it. So on the back of the TA function invocation, OP-TEE returns to U-boot with a sequence of RPC calls requesting I2C transfers (check carefully the implementation in do_call_with_arg(...) implemented in drivers/tee/optee/core.c and notice the while loop) When using sandbox testing, RPC is called directly to validate its actual implementation; however as succintly described above, these calls will always be originated in OP-TEE. Changes v8: * [Etienne Carriere] extended TA param description (missed one param) Changes v7: * [Etienne Carriere] extended TA param description, adding info about i2c xfer flags. Applied A-b and R-b tags * [Jens Wiklander] applied R-b tag Changes v6: * [Etienne Carriere] fixed func return code handling * [Etienne Carriere] tee_optee_ta_uuid passing a pointer instead of full struct * [Etienne Carriere] pass additionally i2c control flags in tests * Fixed mispelling in the comments Changes v5: * [Jens Wiklander] Addressed comment about optee_alloc_and_init_page_list(): drop inline, proper return value and comment Changes v4: * [Simon Glass] Reduced amount ifdefs warnings and move to if (IS_ENABLED(CONFIG_*)) where possible * Fixed pointer-sign warnings Changes v3: * [Simon Glass] Added RPC I2C test coverage Changes v2: * [Simon Glass] Adjusted the usage of DM internal api (dev_get_parent_platdata) * [Simon Glass] Added additional comments to functions * [Jens Wiklander] s/tmem/rmem/g Igor Opaniuk (3): test: py: add pygit2 and pyelftools to requirements.txt drivers: tee: sandbox: add rpc test ta emulation test: dm: tee: extend with RPC test Jorge Ramirez-Ortiz (1): drivers: tee: i2c trampoline driver drivers/tee/Makefile | 2 + drivers/tee/optee/Kconfig| 9 ++ drivers/tee/optee/Makefile | 1 + drivers/tee/optee/i2c.c | 90 ++ drivers/tee/optee/optee_msg.h| 21 drivers/tee/optee/optee_msg_supplicant.h | 5 + drivers/tee/optee/optee_private.h| 17 +++ drivers/tee/optee/supplicant.c | 3 + drivers/tee/sandbox.c| 142 ++- include/tee/optee_ta_rpc_test.h | 30 + test/dm/tee.c| 116 -- test/py/requirements.txt | 2 + 12 files changed, 427 insertions(+), 11 deletions(-) create mode 100644 drivers/tee/optee/i2c.c create mode 100644 include/tee/optee_ta_rpc_test.h -- 2.25.1
[PATCH v8 1/4] drivers: tee: i2c trampoline driver
From: Jorge Ramirez-Ortiz This commit gives the secure world access to the I2C bus so it can communicate with I2C slaves (typically those would be secure elements like the NXP SE050). A similar service implementation has been merged in linux: c05210ab ("drivers: optee: allow op-tee to access devices on the i2c bus") Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- drivers/tee/optee/Makefile | 1 + drivers/tee/optee/i2c.c | 90 drivers/tee/optee/optee_msg.h| 21 ++ drivers/tee/optee/optee_msg_supplicant.h | 5 ++ drivers/tee/optee/optee_private.h| 17 + drivers/tee/optee/supplicant.c | 3 + 6 files changed, 137 insertions(+) create mode 100644 drivers/tee/optee/i2c.c diff --git a/drivers/tee/optee/Makefile b/drivers/tee/optee/Makefile index 928d3f8002..068c6e7aa1 100644 --- a/drivers/tee/optee/Makefile +++ b/drivers/tee/optee/Makefile @@ -2,4 +2,5 @@ obj-y += core.o obj-y += supplicant.o +obj-$(CONFIG_DM_I2C) += i2c.o obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o diff --git a/drivers/tee/optee/i2c.c b/drivers/tee/optee/i2c.c new file mode 100644 index 00..ef4e10f991 --- /dev/null +++ b/drivers/tee/optee/i2c.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2020 Foundries.io Ltd + */ + +#include +#include +#include +#include +#include "optee_msg.h" +#include "optee_private.h" + +static int check_xfer_flags(struct udevice *chip, uint tee_flags) +{ + uint flags; + int ret; + + ret = i2c_get_chip_flags(chip, &flags); + if (ret) + return ret; + + if (tee_flags & OPTEE_MSG_RPC_CMD_I2C_FLAGS_TEN_BIT) { + if (!(flags & DM_I2C_CHIP_10BIT)) + return -EINVAL; + } else { + if (flags & DM_I2C_CHIP_10BIT) + return -EINVAL; + } + + return 0; +} + +void optee_suppl_cmd_i2c_transfer(struct optee_msg_arg *arg) +{ + const u8 attr[] = { + OPTEE_MSG_ATTR_TYPE_VALUE_INPUT, + OPTEE_MSG_ATTR_TYPE_VALUE_INPUT, + OPTEE_MSG_ATTR_TYPE_RMEM_INOUT, + OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT, + }; + struct udevice *chip_dev; + struct tee_shm *shm; + u8 *buf; + int ret; + + if (arg->num_params != ARRAY_SIZE(attr) || + arg->params[0].attr != attr[0] || + arg->params[1].attr != attr[1] || + arg->params[2].attr != attr[2] || + arg->params[3].attr != attr[3]) { + goto bad; + } + + shm = (struct tee_shm *)(unsigned long)arg->params[2].u.rmem.shm_ref; + buf = shm->addr; + if (!buf) + goto bad; + + if (i2c_get_chip_for_busnum((int)arg->params[0].u.value.b, + (int)arg->params[0].u.value.c, + 0, &chip_dev)) + goto bad; + + if (check_xfer_flags(chip_dev, arg->params[1].u.value.a)) + goto bad; + + switch (arg->params[0].u.value.a) { + case OPTEE_MSG_RPC_CMD_I2C_TRANSFER_RD: + ret = dm_i2c_read(chip_dev, 0, buf, + (size_t)arg->params[2].u.rmem.size); + break; + case OPTEE_MSG_RPC_CMD_I2C_TRANSFER_WR: + ret = dm_i2c_write(chip_dev, 0, buf, + (size_t)arg->params[2].u.rmem.size); + break; + default: + goto bad; + } + + if (ret) { + arg->ret = TEE_ERROR_COMMUNICATION; + } else { + arg->params[3].u.value.a = arg->params[2].u.rmem.size; + arg->ret = TEE_SUCCESS; + } + + return; +bad: + arg->ret = TEE_ERROR_BAD_PARAMETERS; +} diff --git a/drivers/tee/optee/optee_msg.h b/drivers/tee/optee/optee_msg.h index 24c60960fc..8d40ce60c2 100644 --- a/drivers/tee/optee/optee_msg.h +++ b/drivers/tee/optee/optee_msg.h @@ -422,4 +422,25 @@ struct optee_msg_arg { */ #define OPTEE_MSG_RPC_CMD_SHM_FREE 7 +/* + * Access a device on an i2c bus + * + * [in] param[0].u.value.amode: RD(0), WR(1) + * [in] param[0].u.value.bi2c adapter + * [in] param[0].u.value.ci2c chip + * + * [in] param[1].u.value.ai2c control flags + * + * [in/out] memref[2] buffer to exchange the transfer data + * with the secure world + * + * [out] param[3].u.value.a bytes transferred by the driver + */ +#define OPTEE_MSG_RPC_CMD_I2C_TRANSFER 21 +/* I2C master transfer modes */ +#define OPTEE_MSG_RPC_CMD_I2C_TRANSFER_RD 0 +#define OPTEE_MSG_RPC_CMD_I2C_TRANSFER_WR 1 +/* I2C master control flags */ +#define OPTEE_MSG_RPC_CMD_I2C_FLAGS_TEN_BIT BIT(0) + #endif /* _OPTEE_MSG_H */ diff --git a/drivers/tee/optee/optee_msg_supplicant.h b/drivers/
[PATCH v8 2/4] test: py: add pygit2 and pyelftools to requirements.txt
From: Igor Opaniuk Add pygit2 and pyelftools to the list of packages for virtualenv needed to run all sets of pytests.This fixes warnings like: binman.elf_test.TestElf.testDecodeElf (subunit.RemotedTestCase): Python elftools not available Signed-off-by: Igor Opaniuk Reviewed-by: Simon Glass --- test/py/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/py/requirements.txt b/test/py/requirements.txt index cf251186f4..926bccad69 100644 --- a/test/py/requirements.txt +++ b/test/py/requirements.txt @@ -10,6 +10,8 @@ packaging==19.2 pbr==5.4.3 pluggy==0.13.0 py==1.8.0 +pyelftools==0.27 +pygit2==1.4.0 pyparsing==2.4.2 pytest==5.2.1 python-mimeparse==1.6.0 -- 2.25.1
[PATCH v8 3/4] drivers: tee: sandbox: add rpc test ta emulation
From: Igor Opaniuk This adds support for RPC test trusted application emulation, which permits to test reverse RPC calls to TEE supplicant. Currently it covers requests to the I2C bus from TEE. Signed-off-by: Igor Opaniuk Reviewed-by: Simon Glass Reviewed-by: Jens Wiklander Acked-by: Etienne Carriere --- drivers/tee/Makefile| 2 + drivers/tee/optee/Kconfig | 9 ++ drivers/tee/sandbox.c | 142 +++- include/tee/optee_ta_rpc_test.h | 30 +++ 4 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 include/tee/optee_ta_rpc_test.h diff --git a/drivers/tee/Makefile b/drivers/tee/Makefile index 5c8ffdbce8..ff844195ae 100644 --- a/drivers/tee/Makefile +++ b/drivers/tee/Makefile @@ -2,5 +2,7 @@ obj-y += tee-uclass.o obj-$(CONFIG_SANDBOX) += sandbox.o +obj-$(CONFIG_OPTEE_TA_RPC_TEST) += optee/supplicant.o +obj-$(CONFIG_OPTEE_TA_RPC_TEST) += optee/i2c.o obj-$(CONFIG_OPTEE) += optee/ obj-y += broadcom/ diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig index d489834df9..65622f30b1 100644 --- a/drivers/tee/optee/Kconfig +++ b/drivers/tee/optee/Kconfig @@ -22,6 +22,15 @@ config OPTEE_TA_AVB The TA can support the "avb" subcommands "read_rb", "write"rb" and "is_unlocked". +config OPTEE_TA_RPC_TEST + bool "Support RPC TEST TA" + depends on SANDBOX_TEE + default y + help + Enables support for RPC test trusted application emulation, which + permits to test reverse RPC calls to TEE supplicant. Should + be used only in sandbox env. + endmenu endif diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c index e1ba027fd6..3a1d34d6fc 100644 --- a/drivers/tee/sandbox.c +++ b/drivers/tee/sandbox.c @@ -7,11 +7,15 @@ #include #include #include +#include + +#include "optee/optee_msg.h" +#include "optee/optee_private.h" /* * The sandbox tee driver tries to emulate a generic Trusted Exectution - * Environment (TEE) with the Trusted Application (TA) OPTEE_TA_AVB - * available. + * Environment (TEE) with the Trusted Applications (TA) OPTEE_TA_AVB and + * OPTEE_TA_RPC_TEST available. */ static const u32 pstorage_max = 16; @@ -32,7 +36,38 @@ struct ta_entry { struct tee_param *params); }; -#ifdef CONFIG_OPTEE_TA_AVB +static int get_msg_arg(struct udevice *dev, uint num_params, + struct tee_shm **shmp, struct optee_msg_arg **msg_arg) +{ + int rc; + struct optee_msg_arg *ma; + + rc = __tee_shm_add(dev, OPTEE_MSG_NONCONTIG_PAGE_SIZE, NULL, + OPTEE_MSG_GET_ARG_SIZE(num_params), TEE_SHM_ALLOC, + shmp); + if (rc) + return rc; + + ma = (*shmp)->addr; + memset(ma, 0, OPTEE_MSG_GET_ARG_SIZE(num_params)); + ma->num_params = num_params; + *msg_arg = ma; + + return 0; +} + +void *optee_alloc_and_init_page_list(void *buf, ulong len, +u64 *phys_buf_ptr) +{ + /* +* An empty stub is added just to fix linking issues. +* This function isn't supposed to be called in sandbox +* setup, otherwise replace this with a proper +* implementation from optee/core.c +*/ + return NULL; +} + static u32 get_attr(uint n, uint num_params, struct tee_param *params) { if (n >= num_params) @@ -63,6 +98,7 @@ bad_params: return TEE_ERROR_BAD_PARAMETERS; } +#ifdef CONFIG_OPTEE_TA_AVB static u32 ta_avb_open_session(struct udevice *dev, uint num_params, struct tee_param *params) { @@ -214,7 +250,99 @@ static u32 ta_avb_invoke_func(struct udevice *dev, u32 func, uint num_params, return TEE_ERROR_NOT_SUPPORTED; } } -#endif /*OPTEE_TA_AVB*/ +#endif /* OPTEE_TA_AVB */ + +#ifdef CONFIG_OPTEE_TA_RPC_TEST +static u32 ta_rpc_test_open_session(struct udevice *dev, uint num_params, + struct tee_param *params) +{ + /* +* We don't expect additional parameters when opening a session to +* this TA. +*/ + return check_params(TEE_PARAM_ATTR_TYPE_NONE, TEE_PARAM_ATTR_TYPE_NONE, + TEE_PARAM_ATTR_TYPE_NONE, TEE_PARAM_ATTR_TYPE_NONE, + num_params, params); +} + +static void fill_i2c_rpc_params(struct optee_msg_arg *msg_arg, u64 bus_num, + u64 chip_addr, u64 xfer_flags, u64 op, + struct tee_param_memref memref) +{ + msg_arg->params[0].attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT; + msg_arg->params[1].attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT; + msg_arg->params[2].attr = OPTEE_MSG_ATTR_TYPE_RMEM_INOUT; + msg_arg->params[3].attr = OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT; + + /* trigger I2C services of TEE supplicant */ + msg_arg->cmd = OPTEE_MSG_RPC_CMD_I2C_TRANSFER; + +
[PATCH v8 4/4] test: dm: tee: extend with RPC test
From: Igor Opaniuk Extend existing DM tee tests adding test coverage for reverse RPC calls. Currently this commit only adds tests for I2C requests from TEE driver to TEE supplicant, for instance reading/writing data to emulated i2c eeprom defines in standard sandbox test device tree (arch/sandbox/dts/test.dtb): => i2c bus Bus 0: i2c@0 (active 0) 2c: eeprom@2c, offset len 1, flags 0 ... Running TEE tests: => ut dm tee Test: dm_test_tee: tee.c Test: dm_test_tee: tee.c (flat tree) Failures: 0 Signed-off-by: Igor Opaniuk Reviewed-by: Simon Glass Acked-by: Etienne Carriere --- test/dm/tee.c | 116 +++--- 1 file changed, 109 insertions(+), 7 deletions(-) diff --git a/test/dm/tee.c b/test/dm/tee.c index ddbdcfb0cf..7a11bf8913 100644 --- a/test/dm/tee.c +++ b/test/dm/tee.c @@ -13,15 +13,16 @@ #include #include #include +#include -static int open_session(struct udevice *dev, u32 *session) +static int open_session(struct udevice *dev, u32 *session, + struct tee_optee_ta_uuid *uuid) { struct tee_open_session_arg arg; - const struct tee_optee_ta_uuid uuid = TA_AVB_UUID; int rc; memset(&arg, 0, sizeof(arg)); - tee_optee_ta_uuid_to_octets(arg.uuid, &uuid); + tee_optee_ta_uuid_to_octets(arg.uuid, uuid); rc = tee_open_session(dev, &arg, 0, NULL); if (rc) return rc; @@ -32,7 +33,7 @@ static int open_session(struct udevice *dev, u32 *session) return 0; } -static int invoke_func(struct udevice *dev, u32 session) +static int invoke_func_avb(struct udevice *dev, u32 session) { struct tee_param param = { .attr = TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT }; struct tee_invoke_arg arg; @@ -47,6 +48,48 @@ static int invoke_func(struct udevice *dev, u32 session) return 0; } +static int invoke_func_rpc_test(struct udevice *dev, u32 session, + u64 op, u64 busnum, u64 chip_addr, + u64 xfer_flags, u8 *buf, size_t buf_size) +{ + struct tee_param param[2]; + struct tee_invoke_arg arg; + struct tee_shm *shm_buf; + int rc; + + memset(&arg, 0, sizeof(arg)); + arg.session = session; + arg.func = op; + + rc = tee_shm_alloc(dev, buf_size, + TEE_SHM_ALLOC, &shm_buf); + if (rc) + return rc; + + if (op == TA_RPC_TEST_CMD_I2C_WRITE) + memcpy(shm_buf->addr, buf, buf_size); + + memset(param, 0, sizeof(param)); + param[0].attr = TEE_PARAM_ATTR_TYPE_VALUE_INPUT; + param[0].u.value.a = busnum; + param[0].u.value.b = chip_addr; + param[0].u.value.c = xfer_flags; + param[1].attr = TEE_PARAM_ATTR_TYPE_MEMREF_INOUT; + param[1].u.memref.shm = shm_buf; + param[1].u.memref.size = buf_size; + + if (tee_invoke_func(dev, &arg, 2, param) || arg.ret) { + rc = -1; + goto out; + } + + if (op == TA_RPC_TEST_CMD_I2C_READ) + memcpy(buf, shm_buf->addr, buf_size); +out: + tee_shm_free(shm_buf); + return rc; +} + static int match(struct tee_version_data *vers, const void *data) { return vers->gen_caps & TEE_GEN_CAP_GP; @@ -62,6 +105,7 @@ static int test_tee(struct unit_test_state *uts, struct test_tee_vars *vars) struct tee_version_data vers; struct udevice *dev; struct sandbox_tee_state *state; + struct tee_optee_ta_uuid avb_uuid = TA_AVB_UUID; u32 session = 0; int rc; u8 data[128]; @@ -71,11 +115,11 @@ static int test_tee(struct unit_test_state *uts, struct test_tee_vars *vars) state = dev_get_priv(dev); ut_assert(!state->session); - rc = open_session(dev, &session); + rc = open_session(dev, &session, &avb_uuid); ut_assert(!rc); ut_assert(session == state->session); - rc = invoke_func(dev, session); + rc = invoke_func_avb(dev, session); ut_assert(!rc); rc = tee_close_session(dev, session); @@ -100,7 +144,59 @@ static int test_tee(struct unit_test_state *uts, struct test_tee_vars *vars) vars->alloc_shm = NULL; ut_assert(!state->num_shms); - return 0; + return rc; +} + +#define I2C_BUF_SIZE 64 + +static int test_tee_rpc(struct unit_test_state *uts) +{ + struct tee_version_data vers; + struct udevice *dev; + struct sandbox_tee_state *state; + struct tee_optee_ta_uuid rpc_test_uuid = TA_RPC_TEST_UUID; + u32 session = 0; + int rc; + + char *test_str = "Test string"; + u8 data[I2C_BUF_SIZE] = {0}; + u8 data_from_eeprom[I2C_BUF_SIZE] = {0}; + + /* Use sandbox I2C EEPROM emulation; bus: 0, chip: 0x2c */ + u64 bus = 0; + u64 chip = 0x2c; + u64 xfer_flags = 0; + + dev = tee_find_device(NULL, match, NULL, &vers); + ut_assert(dev); +
Re: [PATCH v4 6/7] arm: dts: ls1028a: Add Ethernet switch node and dependencies
Am 2021-01-25 13:23, schrieb Vladimir Oltean: From: Alex Marginean The definition follows the DSA binding in kernel and describes the switch, its ports and PHYs. The switch node has the same structure as in Linux and this patch enables it (and relevant ports) for the LS1028A RDB board. ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028A, it is not used in U-Boot and was disabled. Ethernet port aliases were also added to better manage the multitude of ports available now. Signed-off-by: Alex Marginean Signed-off-by: Claudiu Manoil Signed-off-by: Vladimir Oltean You don't seem to like my review tag :p Reviewed-by: Michael Walle --- v4: none. v3: Added a comment denoting the PHY model present on the RDB. v2: Switch node structure defined in dtsi now consistent with the Linux switch node definition. Moved aliases from dtsi to the RDB DTS to minimize impact on other boards (and for improved flexibility). arch/arm/dts/fsl-ls1028a-rdb.dts | 64 arch/arm/dts/fsl-ls1028a.dtsi| 56 +++- 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/fsl-ls1028a-rdb.dts b/arch/arm/dts/fsl-ls1028a-rdb.dts index 85b4815b2ed7..3432fca35269 100644 --- a/arch/arm/dts/fsl-ls1028a-rdb.dts +++ b/arch/arm/dts/fsl-ls1028a-rdb.dts @@ -15,6 +15,12 @@ compatible = "fsl,ls1028a-rdb", "fsl,ls1028a"; aliases { spi0 = &fspi; + eth0 = &enetc0; + eth1 = &enetc2; + eth2 = &mscc_felix_port0; + eth3 = &mscc_felix_port1; + eth4 = &mscc_felix_port2; + eth5 = &mscc_felix_port3; }; }; @@ -131,9 +137,67 @@ phy-handle = <&rdb_phy0>; }; +&enetc2 { + status = "okay"; +}; + +&mscc_felix { + status = "okay"; +}; + +&mscc_felix_port0 { + label = "swp0"; + phy-handle = <&sw_phy0>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port1 { + label = "swp1"; + phy-handle = <&sw_phy1>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port2 { + label = "swp2"; + phy-handle = <&sw_phy2>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port3 { + label = "swp3"; + phy-handle = <&sw_phy3>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port4 { + ethernet = <&enetc2>; + status = "okay"; +}; + &mdio0 { status = "okay"; rdb_phy0: phy@2 { reg = <2>; }; + + /* VSC8514 QSGMII PHY */ + sw_phy0: phy@10 { + reg = <0x10>; + }; + + sw_phy1: phy@11 { + reg = <0x11>; + }; + + sw_phy2: phy@12 { + reg = <0x12>; + }; + + sw_phy3: phy@13 { + reg = <0x13>; + }; }; diff --git a/arch/arm/dts/fsl-ls1028a.dtsi b/arch/arm/dts/fsl-ls1028a.dtsi index d0850237c797..9740006689ca 100644 --- a/arch/arm/dts/fsl-ls1028a.dtsi +++ b/arch/arm/dts/fsl-ls1028a.dtsi @@ -151,9 +151,63 @@ reg = <0x000300 0 0 0 0>; status = "disabled"; }; + + mscc_felix: pci@0,5 { + reg = <0x000500 0 0 0 0>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + mscc_felix_port0: port@0 { + reg = <0>; + status = "disabled"; + }; + + mscc_felix_port1: port@1 { + reg = <1>; + status = "disabled"; + }; + + mscc_felix_port2: port@2 { + reg = <2>; + status = "disabled"; + }; + + mscc_felix_port3: port@3 { + reg = <3>; + status = "disabled"; + }; + + mscc_felix_port4: port@4 { + reg = <4>; + phy-mode = "internal"; + status = "disabled"; + + fixed-link { + speed = <2500>; + full-duplex; + }; + }; + + mscc_felix_port5: port@5 { + reg = <5>; + phy-mode =
Re: [PATCH 1/5] arm: dts: r8a774a1: Import DTS queued for Linux 5.12-rc1
On 1/25/21 12:22 AM, Adam Ford wrote: On Sun, Jan 24, 2021 at 11:10 AM Marek Vasut wrote: On 1/13/21 12:52 AM, Adam Ford wrote: Update the RZ/G2M dtsi and r8a774a1-beacon-rzg2m-kit kit from Renesas repo destined to become 5.12-rc1. I picked a DT sync for Linux 5.10 from Biju (on CC), does your board need something from 5.12-rc1 or can it be based on 5.10 too ? I honestly don't remember. I had to unexpectedly leave town for this week due to a funeral, and I won't be near a Linux development computer to run tests until Feb 1, so I don't know if the board will build using 5.10 or not. Sorry I don't have a better answer. Lets revisit this later then.
Re: [PATCH v4 0/7] Introduce DSA Ethernet switch class and Felix driver
Am 2021-01-25 13:23, schrieb Vladimir Oltean: From: Vladimir Oltean DSA stands for Distributed Switch Architecture and it is a subsystem introduced in the Linux kernel to support switches that: - have an Ethernet link up to the CPU - use some form of tagging to identify the source/destination port for Rx/Tx - may be cascaded in tree-like structures. DSA is described in depth here: https://www.kernel.org/doc/Documentation/networking/dsa/dsa.txt This patch set introduces a DSA class in U-Boot to support drivers of DSA switches. DSA drivers have to implement the following ops: - enable/disable of switch ports, - insert a tag in frames being transmitted, used by the switch to select the egress port, - parse a tag in frames being received, used for Rx traffic. DSA class code deals with presentation of switch ports as Ethernet interfaces, deals with the master Ethernet device for I/O and helps with parsing of the DT assuming the structure follows the DSA kernel binding. Support for switch cascading is not included yet. In the sandbox environment, the DSA sandbox driver, the switch ports and master eth interface look like this: => dm tree Class Index Probed DriverName --- [...] eth 4 [ + ] eth_sandbox |-- dsa-test-eth dsa 0 [ + ] dsa_sandbox |-- dsa-test eth 5 [ + ] dsa-port | |-- lan0 eth 6 [ + ] dsa-port | `-- lan1 => setenv ethact lan1 => ping 1.2.3.5 Using lan1 device host 1.2.3.5 is alive => This patch set also introduces a driver for the Ethernet switch integrated into NXP LS1028A, called Felix. The switch has 4 front panel ports, I/O to/from it is done though an ENETC Ethernet interface and meta-data is carried between the switch and the driver though an additional header pre-pended to the original frame. Network commands like tftp can be used on these front panel ports. The ports are disabled unless used so they do not cause issues on network topologies that include loops. Felix as seen on LS1028A RDB: => dm tree Class Index Probed DriverName --- [...] dsa 0 [ + ] felix-switch | |-- felix-switch eth 4 [ + ] dsa-port | | |-- swp0 eth 5 [ + ] dsa-port | | |-- swp1 eth 6 [ + ] dsa-port | | |-- swp2 eth 7 [ + ] dsa-port | | `-- swp3 => mdio list [...] 10 - Vitesse VSC8514 <--> swp0 11 - Vitesse VSC8514 <--> swp1 12 - Vitesse VSC8514 <--> swp2 13 - Vitesse VSC8514 <--> swp3 NOTE: This patchset is a major rework of the dsa-class code since the last submission from May 5th: https://patchwork.ozlabs.org/project/uboot/cover/1588700588-8587-1-git-send-email-claudiu.man...@nxp.com/ The basic concepts and data path operation (tagging) in the DSA class code remain the same as in the initial patchset from Alex, however the external API has been changed significantly (simplified), the driver model integration has been improved to the point that the DSA class code no longer needs to allocate extra memory internally (via malloc), reduced memory footprint, internal state data moved from the external API and internalized, cleaner external API, internal code reworked, completely reworked DSA sandbox driver and unit tests for better coverage and to integrate better with the eth sandbox driver and tests, etc. v4: - Implemented the TODO for having a phy_device on the CPU port. - Enabled CONFIG_PHY_FIXED which is a new dependency of CONFIG_DM_DSA. v3: - Removed all infrastructure associated with dsa_foreach_port, which is no longer needed. - Only inherit the DSA master's MAC address if the environment does not already have a specific MAC address that should be used for the DSA port. - Be compatible with the new "ethernet-ports" container name which has been introduced in the Linux kernel as commit 85e05d263ed2 ("net: dsa: of: Allow ethernet-ports as encapsulating node") in v5.9. - Fixed the felix driver not getting its ports initialized, due to dsa_foreach_port() being actually unusable when called from the probe function of the DSA udevice - the eth port udevices are _not_ yet probed at that point. We are now initializing all ports from the .port_enable() callback of each eth udevice. - Deleted the unit tests associated with the infrastructure for dsa_foreach_port, since that function no longer exists. - Enabled the config options for the Kontron LS1028A board too. v2: Switch node structure defined in dtsi now consistent with the Linux switch node definition. Moved aliases from dtsi to the RDB dts to minimize impact on other boards (and for improved flexibility). Alex Marginean (3): drivers: net: Add Felix DSA switch driver arm: dts: ls1028a: Add Ethernet swi
Re: [PATCH v4 0/7] Introduce DSA Ethernet switch class and Felix driver
On Mon, Jan 25, 2021 at 02:02:07PM +0100, Michael Walle wrote: > Works now. Tested on Kontron sl28 var2 with two switch > ports routed to two SGMII lanes. > > Tested-by: Michael Walle [on kontron_sl28] Thanks for the patience!
[PATCH 0/1] Add flash protection support for Winbond's w25q128
From: Su Baocheng According to datasheets, all 3 types of w25q128 support ST Micro-like flash protection that using BP{0-2}/TB bits in status register. Su Baocheng (1): mtd: spi-nor-ids: Add support of flash protection to w25q128 drivers/mtd/spi/spi-nor-ids.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.25.1
[PATCH 1/1] mtd: spi-nor-ids: Add support of flash protection to w25q128
From: Su Baocheng The NOR flash w25q128 denoted by JEDEC ID 0xef4018 actually represents various models. From Winbond's website, I could only find 3 types of them: W25Q128JV-IQ/JQ datasheet:https://www.winbond.com/resource-files/ w25q128jv%20revg%2004082019%20plus.pdf W25Q128FV (SPI Mode) datasheet: https://www.winbond.com/resource-files/ w25q128fv%20rev.m%2005132016%20kms.pdf W25Q128BV datesheet: https://www.winbond.com/resource-files/ w25q128bv_revh_100313_wo_automotive.pdf According to the datasheets, all of these 3 types support BP(0,1,2) and TB bits in the status register (SR), so it could reuse the flash protection logic for ST Micro. So it should be safe to add the SPI_NOR_HAS_LOCK and SPI_NOR_HAS_TB flags to the w25q128 entry of spi_nor_ids table. Signed-off-by: Su Baocheng --- drivers/mtd/spi/spi-nor-ids.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c index 5bd5dd3003..dcce25bec2 100644 --- a/drivers/mtd/spi/spi-nor-ids.c +++ b/drivers/mtd/spi/spi-nor-ids.c @@ -319,7 +319,17 @@ const struct flash_info spi_nor_ids[] = { { INFO("w25q80bl", 0xef4014, 0, 64 * 1024, 16, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("w25q16cl", 0xef4015, 0, 64 * 1024, 32, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("w25q64cv", 0xef4017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, - { INFO("w25q128", 0xef4018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + /* There are 3 types of w25q128 with JEDEC ID 0xef4018: +* W25Q128JV-IQ/JQ +* W25Q128FV (SPI Mode) +* W25Q128BV +* According to the datasheets, All of these 3 types support +* protection through BP{0,1,2}, TB in the status register (SR). +*/ + { INFO("w25q128", 0xef4018, 0, 64 * 1024, 256, + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | + SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) + }, { INFO("w25q256", 0xef4019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("w25m512jw", 0xef6119, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("w25m512jv", 0xef7119, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, -- 2.25.1
Re: [PATCH] mmc: mmc_spi: Do not drop first RX byte after CMD TX
在 2021/1/24 下午7:38, Meng, Bin 写道: It looks somehow this email did not arrive the mailing list? Yes, it is waiting list moderator for approval as it's my first mail to U-Boot list. As for the patch, U-Boot mms_spi driver does nothing wrong. The dropped byte is for Ncr as required by the spec. The issue you mentioned in QEMU is fixed by the following patch: http://patchwork.ozlabs.org/project/qemu-devel/patch/20210123104016.17485-4-bmeng...@gmail.com/ Thanks, It solved by problem. - Jiaxun Regards, Bin
[PATCH V2 00/17] usb: gadget: update
From: Peng Fan V2: Fix imx6dl_mamoj size SPL exceeded issue V1: This patchset is to upstream NXP downstream gadget driver patches for feature update. Jun Li (2): usb: gadget: set correct usb_configuration for os_desc_config usb: gadget: update os_desc_config when add config Li Jun (13): usb: gadget: don't change ep name for dwc3 while ep autoconfig usb: gadget: OS String support usb: gadget: move utf8_to_utf16le to header file usb: gadget: OS Feature Descriptors support usb: gadget: add WCID support for mfgtool usb: gadget: fastboot: add ext properties for WCID usb: gadget: add super speed support usb: fastboot: add super speed support usb: gadget: dnl: set dnl to be super speed usb: composite: force gadget to be USB2 for HS only function usb: udc: ci: update speed handling usb: gadget: fastboot: use correct max packet size usb: gaget: ci: set ep's desc when enable ep Peng Fan (1): usb: gadget: add Kconfig for OS descriptors Ye Li (1): usb: gadget: Add ep_config call back to usb_gadget_ops drivers/usb/gadget/Kconfig | 9 + drivers/usb/gadget/ci_udc.c | 5 +- drivers/usb/gadget/composite.c | 392 +--- drivers/usb/gadget/epautoconf.c | 6 + drivers/usb/gadget/f_fastboot.c | 83 ++- drivers/usb/gadget/g_dnl.c | 1 + drivers/usb/gadget/u_os_desc.h | 123 ++ drivers/usb/gadget/usbstring.c | 74 +- include/linux/usb/composite.h | 71 ++ include/linux/usb/gadget.h | 9 + include/linux/utf.h | 75 ++ 11 files changed, 743 insertions(+), 105 deletions(-) create mode 100644 drivers/usb/gadget/u_os_desc.h create mode 100644 include/linux/utf.h -- 2.28.0
[PATCH V2 01/17] usb: gadget: Add ep_config call back to usb_gadget_ops
From: Ye Li Since some new fields in usb_ep structure been moved to usb_ss_ep. The CDNS3 gadget driver should replies on this operation to bind the usb_ss_ep with the endpoint descriptor when function layer uses usb_ep_autoconfig to add endpoint descriptors to gadget. So that CDNS3 driver can know the EP information and configure the EP once the set configuration request is received. Signed-off-by: Sherry Sun Signed-off-by: Ye Li Signed-off-by: Peng Fan --- drivers/usb/gadget/epautoconf.c | 4 include/linux/usb/gadget.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index e61fe5d114..3f8842976d 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -167,6 +167,10 @@ static int ep_matches( size = 64; put_unaligned(cpu_to_le16(size), &desc->wMaxPacketSize); } + + if (gadget->ops->ep_conf) + return gadget->ops->ep_conf(gadget, ep, desc); + return 1; } diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 06292ddeb6..8d54b91734 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -470,6 +470,9 @@ struct usb_gadget_ops { struct usb_ep *(*match_ep)(struct usb_gadget *, struct usb_endpoint_descriptor *, struct usb_ss_ep_comp_descriptor *); + int (*ep_conf)(struct usb_gadget *, + struct usb_ep *, + struct usb_endpoint_descriptor *); void(*udc_set_speed)(struct usb_gadget *gadget, enum usb_device_speed); }; -- 2.28.0
[PATCH V2 02/17] usb: gadget: don't change ep name for dwc3 while ep autoconfig
From: Li Jun As the SDP protocol use the predefined ep num for communication, we can't change its name hence reset its ep num while do ep autoconfig, this is only apply for SPL. Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/epautoconf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 3f8842976d..7da334f5d3 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -262,6 +262,7 @@ struct usb_ep *usb_ep_autoconfig( ep = find_ep(gadget, "ep1-bulk"); if (ep && ep_matches(gadget, ep, desc)) return ep; +#ifndef CONFIG_SPL_BUILD } else if (gadget_is_dwc3(gadget)) { const char *name = NULL; /* @@ -284,6 +285,7 @@ struct usb_ep *usb_ep_autoconfig( ep = find_ep(gadget, name); if (ep && ep_matches(gadget, ep, desc)) return ep; +#endif } if (gadget->ops->match_ep) -- 2.28.0
[PATCH V2 03/17] usb: gadget: OS String support
From: Li Jun This is a porting patch from linux kernel: 19824d5eeece ("usb: gadget: OS String support"), original commit log see below: "There is a custom (non-USB IF) extension to the USB standard: http://msdn.microsoft.com/library/windows/hardware/gg463182 They grant permission to use the specification - there is "Microsoft OS Descriptor Specification License Agreement" under the link mentioned above, and its Section 2 "Grant of License", letter (b) reads: "Patent license. Microsoft hereby grants to You a nonexclusive, royalty-free, nontransferable, worldwide license under Microsoft鈥檚 patents embodied solely within the Specification and that are owned or licensable by Microsoft to make, use, import, offer to sell, sell and distribute directly or indirectly to Your Licensees Your Implementation. You may sublicense this patent license to Your Licensees under the same terms and conditions." The said extension is maintained by Microsoft for Microsoft. Yet it is fairly common for various devices to use it, and a popular proprietary operating system expects devices to provide "OS descriptors", so Linux-based USB gadgets whishing to be able to talk to a variety of operating systems should be able to provide the "OS descriptors". This patch adds optional support for gadgets whishing to expose the so called "OS String" under index 0xEE of language 0. The contents of the string is generated based on the qw_sign array and b_vendor_code. Interested gadgets need to set the cdev->use_os_string flag, fill cdev->qw_sign with appropriate values and fill cdev->b_vendor_code with a value of their choice. This patch does not however implement responding to any vendor-specific USB requests." Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/composite.c | 26 ++ include/linux/usb/composite.h | 10 ++ 2 files changed, 36 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 91ed7fcec5..63855af52e 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -25,6 +25,22 @@ static inline void le16_add_cpu_packed(__le16_packed *var, u16 val) var->val = cpu_to_le16(le16_to_cpu(var->val) + val); } +/** + * struct usb_os_string - represents OS String to be reported by a gadget + * @bLength: total length of the entire descritor, always 0x12 + * @bDescriptorType: USB_DT_STRING + * @qwSignature: the OS String proper + * @bMS_VendorCode: code used by the host for subsequent requests + * @bPad: not used, must be zero + */ +struct usb_os_string { + __u8bLength; + __u8bDescriptorType; + __u8qwSignature[OS_STRING_QW_SIGN_LEN]; + __u8bMS_VendorCode; + __u8bPad; +} __packed; + /** * usb_add_function() - add a function to a configuration * @config: the configuration @@ -577,6 +593,16 @@ static int get_string(struct usb_composite_dev *cdev, return s->bLength; } + if (cdev->use_os_string && language == 0 && id == OS_STRING_IDX) { + struct usb_os_string *b = buf; + b->bLength = sizeof(*b); + b->bDescriptorType = USB_DT_STRING; + memcpy(&b->qwSignature, cdev->qw_sign, sizeof(b->qwSignature)); + b->bMS_VendorCode = cdev->b_vendor_code; + b->bPad = 0; + return sizeof(*b); + } + /* * Otherwise, look up and return a specified string. String IDs * are device-scoped, so we look up each string table we're told diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index a49a66f2f8..d4f2a49869 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -284,6 +284,8 @@ struct usb_composite_driver { extern int usb_composite_register(struct usb_composite_driver *); extern void usb_composite_unregister(struct usb_composite_driver *); +#define OS_STRING_QW_SIGN_LEN 14 +#define OS_STRING_IDX 0xEE /** * struct usb_composite_device - represents one composite usb gadget @@ -291,6 +293,9 @@ extern void usb_composite_unregister(struct usb_composite_driver *); * @req: used for control responses; buffer is pre-allocated * @bufsiz: size of buffer pre-allocated in @req * @config: the currently active configuration + * @qw_sign: qwSignature part of the OS string + * @b_vendor_code: bMS_VendorCode part of the OS string + * @use_os_string: false by default, interested gadgets set it * * One of these devices is allocated and initialized before the * associated device driver's bind() is called. @@ -324,6 +329,11 @@ struct usb_composite_dev { struct usb_configuration*config; + /* OS String is a custom (yet popular) extension to the USB standard. */ + u8 qw_sign[OS_STRING_QW_SIGN_LEN]; + u8 b_vendor_code; + unsigned int
[PATCH V2 04/17] usb: gadget: move utf8_to_utf16le to header file
From: Li Jun As other users may use utf8_to_utf16le() to convert the utf8 to utf16 for usb, so move it to head file. Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/usbstring.c | 74 + include/linux/utf.h| 75 ++ 2 files changed, 76 insertions(+), 73 deletions(-) create mode 100644 include/linux/utf.h diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 83cdd8a259..e2464ad923 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -10,79 +10,7 @@ #include #include #include - -#include - - -static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len) -{ - int count = 0; - u8 c; - u16 uchar; - - /* -* this insists on correct encodings, though not minimal ones. -* BUT it currently rejects legit 4-byte UTF-8 code points, -* which need surrogate pairs. (Unicode 3.1 can use them.) -*/ - while (len != 0 && (c = (u8) *s++) != 0) { - if ((c & 0x80)) { - /* -* 2-byte sequence: -* 0yxx = 110y 10xx -*/ - if ((c & 0xe0) == 0xc0) { - uchar = (c & 0x1f) << 6; - - c = (u8) *s++; - if ((c & 0xc0) != 0x80) - goto fail; - c &= 0x3f; - uchar |= c; - - /* -* 3-byte sequence (most CJKV characters): -* yyxx = 1110 10yy 10xx -*/ - } else if ((c & 0xf0) == 0xe0) { - uchar = (c & 0x0f) << 12; - - c = (u8) *s++; - if ((c & 0xc0) != 0x80) - goto fail; - c &= 0x3f; - uchar |= c << 6; - - c = (u8) *s++; - if ((c & 0xc0) != 0x80) - goto fail; - c &= 0x3f; - uchar |= c; - - /* no bogus surrogates */ - if (0xd800 <= uchar && uchar <= 0xdfff) - goto fail; - - /* -* 4-byte sequence (surrogate pairs, currently rare): -* 11101110yy + 110111xx -* = 0uuu 10uu 10yy 10xx -* (u = + 1) -* FIXME accept the surrogate code points (only) -*/ - } else - goto fail; - } else - uchar = c; - put_unaligned_le16(uchar, cp++); - count++; - len--; - } - return count; -fail: - return -1; -} - +#include /** * usb_gadget_get_string - fill out a string descriptor diff --git a/include/linux/utf.h b/include/linux/utf.h new file mode 100644 index 00..e1f7d3bd1d --- /dev/null +++ b/include/linux/utf.h @@ -0,0 +1,75 @@ +#ifndef _LINUX_UTF_H +#define _LINUX_UTF_H + +#include + +static inline int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len) +{ + int count = 0; + u8 c; + u16 uchar; + + /* +* this insists on correct encodings, though not minimal ones. +* BUT it currently rejects legit 4-byte UTF-8 code points, +* which need surrogate pairs. (Unicode 3.1 can use them.) +*/ + while (len != 0 && (c = (u8) *s++) != 0) { + if ((c & 0x80)) { + /* +* 2-byte sequence: +* 0yxx = 110y 10xx +*/ + if ((c & 0xe0) == 0xc0) { + uchar = (c & 0x1f) << 6; + + c = (u8) *s++; + if ((c & 0xc0) != 0x80) + goto fail; + c &= 0x3f; + uchar |= c; + + /* +* 3-byte sequence (most CJKV characters): +* yyxx = 1110 10yy 10xx +*/ + } else if ((c & 0xf0) == 0xe0) { + uchar = (c & 0x0f) << 12; + + c = (u8) *s++; + if ((c & 0xc0) != 0x80) +
[PATCH V2 05/17] usb: gadget: add Kconfig for OS descriptors
From: Peng Fan Add Kconfig for OS descriptors Signed-off-by: Peng Fan --- drivers/usb/gadget/Kconfig | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 7c0df5c264..4a3b22e6de 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -98,6 +98,15 @@ config USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8 endif # USB_GADGET_DWC2_OTG +config USB_GADGET_OS_DESCRIPTORS + bool "USB OS Feature Descriptors support" + help + This is a porting patch from linux kernel: 37a3a533429e + ("usb: gadget: OS Feature Descriptors support"), the original commit + log see below: + There is a custom (non-USB IF) extension to the USB standard: + http://msdn.microsoft.com/library/windows/hardware/gg463182 + config CI_UDC bool "ChipIdea device controller" select USB_GADGET_DUALSPEED -- 2.28.0
[PATCH V2 06/17] usb: gadget: OS Feature Descriptors support
From: Li Jun This is a proting patch from linux kernel: 37a3a533429e ("usb: gadget: OS Feature Descriptors support"), the original commit log see below: There is a custom (non-USB IF) extension to the USB standard: http://msdn.microsoft.com/library/windows/hardware/gg463182 They grant permission to use the specification - there is "Microsoft OS Descriptor Specification License Agreement" under the link mentioned above, and its Section 2 "Grant of License", letter (b) reads: "Patent license. Microsoft hereby grants to You a nonexclusive, royalty-free, nontransferable, worldwide license under Microsoft鈥檚 patents embodied solely within the Specification and that are owned or licensable by Microsoft to make, use, import, offer to sell, sell and distribute directly or indirectly to Your Licensees Your Implementation. You may sublicense this patent license to Your Licensees under the same terms and conditions." The said extension is maintained by Microsoft for Microsoft. Yet it is fairly common for various devices to use it, and a popular proprietary operating system expects devices to provide "OS descriptors", so Linux-based USB gadgets whishing to be able to talk to a variety of operating systems should be able to provide the "OS descriptors". This patch adds optional support for gadgets whishing to expose the so called "OS Feature Descriptors", that is "Extended Compatibility ID" and "Extended Properties". Hosts which do request "OS descriptors" from gadgets do so during the enumeration phase and before the configuration is set with SET_CONFIGURATION. What is more, those hosts never ask for configurations at indices other than 0. Therefore, gadgets whishing to provide "OS descriptors" must designate one configuration to be used with this kind of hosts - this is what os_desc_config is added for in struct usb_composite_dev. There is an additional advantage to it: if a gadget provides "OS descriptors" and designates one configuration to be used with such non-USB-compliant hosts it can invoke "usb_add_config" in any order because the designated configuration will be reported to be at index 0 anyway. This patch also adds handling vendor-specific requests addressed at device or interface and related to handling "OS descriptors"." Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/composite.c | 252 - drivers/usb/gadget/u_os_desc.h | 123 include/linux/usb/composite.h | 57 3 files changed, 431 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/gadget/u_os_desc.h diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 63855af52e..a0c28dbe59 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -12,6 +12,7 @@ #include #include #include +#include "u_os_desc.h" #define USB_BUFSIZ 4096 @@ -244,6 +245,7 @@ static int config_desc(struct usb_composite_dev *cdev, unsigned w_value) u8 type = w_value >> 8; int hs = 0; struct usb_configuration*c; + struct list_head*pos; if (gadget_is_dualspeed(gadget)) { if (gadget->speed == USB_SPEED_HIGH) @@ -255,7 +257,20 @@ static int config_desc(struct usb_composite_dev *cdev, unsigned w_value) } w_value &= 0xff; - list_for_each_entry(c, &cdev->configs, list) { + + pos = &cdev->configs; + c = cdev->os_desc_config; + if (c) + goto check_config; + + while ((pos = pos->next) != &cdev->configs) { + c = list_entry(pos, typeof(*c), list); + + /* skip OS Descriptors config which is handled separately */ + if (c == cdev->os_desc_config) + continue; + +check_config: if (speed == USB_SPEED_HIGH) { if (!c->highspeed) continue; @@ -779,6 +794,156 @@ static int bos_desc(struct usb_composite_dev *cdev) return le16_to_cpu(bos->wTotalLength); } +static int count_ext_compat(struct usb_configuration *c) +{ + int i, res; + + res = 0; + for (i = 0; i < c->next_interface_id; ++i) { + struct usb_function *f; + int j; + + f = c->interface[i]; + for (j = 0; j < f->os_desc_n; ++j) { + struct usb_os_desc *d; + + if (i != f->os_desc_table[j].if_id) + continue; + d = f->os_desc_table[j].os_desc; + if (d && d->ext_compat_id) + ++res; + } + } + BUG_ON(res > 255); + return res; +} + +static void fill_ext_compat(struct usb_configuration *c, u8 *buf) +{ + int i, count; + + count = 16; + for (i = 0; i < c->next_interface_id; ++i) { +
[PATCH V2 08/17] usb: gadget: fastboot: add ext properties for WCID
From: Li Jun Add device interface GUID for Microsoft Extended Properties Feature Descriptor. Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/f_fastboot.c | 34 + 1 file changed, 34 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index d1d087e12b..e330456390 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -46,6 +46,25 @@ struct f_fastboot { struct usb_request *in_req, *out_req; }; +static char fb_ext_prop_name[] = "DeviceInterfaceGUID"; +static char fb_ext_prop_data[] = "{4866319A-F4D6-4374-93B9-DC2DEB361BA9}"; + +static struct usb_os_desc_ext_prop fb_ext_prop = { + .type = 1, /* NUL-terminated Unicode String (REG_SZ) */ + .name = fb_ext_prop_name, + .data = fb_ext_prop_data, +}; + +/* 16 bytes of "Compatible ID" and "Subcompatible ID" */ +static char fb_cid[16] = {'W', 'I', 'N', 'U', 'S', 'B'}; +static struct usb_os_desc fb_os_desc = { + .ext_compat_id = fb_cid, +}; + +static struct usb_os_desc_table fb_os_desc_table = { + .os_desc = &fb_os_desc, +}; + static inline struct f_fastboot *func_to_fastboot(struct usb_function *f) { return container_of(f, struct f_fastboot, usb_function); @@ -161,6 +180,19 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) return id; interface_desc.bInterfaceNumber = id; + /* Enable OS and Extended Properties Feature Descriptor */ + c->cdev->use_os_string = 1; + f->os_desc_table = &fb_os_desc_table; + f->os_desc_n = 1; + f->os_desc_table->if_id = id; + INIT_LIST_HEAD(&fb_os_desc.ext_prop); + fb_ext_prop.name_len = strlen(fb_ext_prop.name) * 2 + 2; + fb_os_desc.ext_prop_len = 10 + fb_ext_prop.name_len; + fb_os_desc.ext_prop_count = 1; + fb_ext_prop.data_len = strlen(fb_ext_prop.data) * 2 + 2; + fb_os_desc.ext_prop_len += fb_ext_prop.data_len + 4; + list_add_tail(&fb_ext_prop.entry, &fb_os_desc.ext_prop); + id = usb_string_id(c->cdev); if (id < 0) return id; @@ -196,6 +228,8 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) static void fastboot_unbind(struct usb_configuration *c, struct usb_function *f) { + f->os_desc_table = NULL; + list_del(&fb_os_desc.ext_prop); memset(fastboot_func, 0, sizeof(*fastboot_func)); } -- 2.28.0
[PATCH V2 07/17] usb: gadget: add WCID support for mfgtool
From: Li Jun Enable WCID(Microsoft Compatible ID Feature Descriptor) for mfgtool. Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/composite.c | 20 1 file changed, 20 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index a0c28dbe59..cd61bfec38 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -20,6 +20,10 @@ typedef struct { __le16 val; } __packed __le16_packed; static struct usb_composite_driver *composite; +static struct usb_configuration *os_desc_config; + +/* Microsoft OS String Descriptor */ +static char qw_sign_buf[OS_STRING_QW_SIGN_LEN / 2] = {'M', 'S', 'F', 'T', '1', '0', '0'}; static inline void le16_add_cpu_packed(__le16_packed *var, u16 val) { @@ -395,6 +399,10 @@ static int set_config(struct usb_composite_dev *cdev, goto done; cdev->config = c; + if (cdev->use_os_string) { + cdev->os_desc_config = c; + os_desc_config = c; + } /* Initialize all interfaces by setting them to altsetting zero. */ for (tmp = 0; tmp < MAX_CONFIG_INTERFACES; tmp++) { @@ -1358,6 +1366,18 @@ static int composite_bind(struct usb_gadget *gadget) sizeof(struct usb_device_descriptor)); cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket; + if (cdev->use_os_string) { + /* TODO: Do we want to pass this via platform? */ + cdev->b_vendor_code = 0x40; + + /* Microsoft OS String Descriptor */ + utf8_to_utf16le(qw_sign_buf, (__le16 *)cdev->qw_sign, + OS_STRING_QW_SIGN_LEN / 2); + + if (os_desc_config) + cdev->os_desc_config = os_desc_config; + } + debug("%s: ready\n", composite->name); return 0; -- 2.28.0
[PATCH V2 09/17] usb: gadget: set correct usb_configuration for os_desc_config
From: Jun Li The current way to set cdev->os_desc_config is wrong if user restart fastboot, as the old config is not used anymore and new allocated usb_configuration will be used, so set the os_desc_config while usb_add_config. Reviewed-by: Ye Li Signed-off-by: Li Jun Signed-off-by: Peter Chen Signed-off-by: Peng Fan --- drivers/usb/gadget/composite.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index cd61bfec38..e6fdefd3d0 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -399,10 +399,6 @@ static int set_config(struct usb_composite_dev *cdev, goto done; cdev->config = c; - if (cdev->use_os_string) { - cdev->os_desc_config = c; - os_desc_config = c; - } /* Initialize all interfaces by setting them to altsetting zero. */ for (tmp = 0; tmp < MAX_CONFIG_INTERFACES; tmp++) { @@ -516,6 +512,9 @@ int usb_add_config(struct usb_composite_dev *cdev, usb_ep_autoconfig_reset(cdev->gadget); + if (os_desc_config) + cdev->os_desc_config = os_desc_config; + done: if (status) debug("added config '%s'/%u --> %d\n", config->label, @@ -1373,9 +1372,6 @@ static int composite_bind(struct usb_gadget *gadget) /* Microsoft OS String Descriptor */ utf8_to_utf16le(qw_sign_buf, (__le16 *)cdev->qw_sign, OS_STRING_QW_SIGN_LEN / 2); - - if (os_desc_config) - cdev->os_desc_config = os_desc_config; } debug("%s: ready\n", composite->name); -- 2.28.0
[PATCH V2 10/17] usb: gadget: update os_desc_config when add config
From: Jun Li Always use the new added config for os_desc_config to fix cdev-> os_desc_config may miss set in case we restart usb gadget driver. Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/composite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index e6fdefd3d0..404da12754 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -512,8 +512,8 @@ int usb_add_config(struct usb_composite_dev *cdev, usb_ep_autoconfig_reset(cdev->gadget); - if (os_desc_config) - cdev->os_desc_config = os_desc_config; + os_desc_config = config; + cdev->os_desc_config = os_desc_config; done: if (status) -- 2.28.0
[PATCH V2 11/17] usb: gadget: add super speed support
From: Li Jun This patch is to add usb gadget super speed support in common driver, including BOS descriptor and select the super speed descriptor from function driver. Reviewed-by: Ye Li Reviewed-by: Peter Chen Tested-by: faqiang.zhu Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/composite.c | 85 -- include/linux/usb/composite.h | 4 ++ include/linux/usb/gadget.h | 6 +++ 3 files changed, 70 insertions(+), 25 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 404da12754..1063c571d8 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -88,6 +88,8 @@ int usb_add_function(struct usb_configuration *config, config->fullspeed = 1; if (!config->highspeed && function->hs_descriptors) config->highspeed = 1; + if (!config->superspeed && function->ss_descriptors) + config->superspeed = 1; done: if (value) @@ -223,7 +225,9 @@ static int config_buf(struct usb_configuration *config, /* add each function's descriptors */ list_for_each_entry(f, &config->functions, list) { - if (speed == USB_SPEED_HIGH) + if (speed == USB_SPEED_SUPER) + descriptors = f->ss_descriptors; + else if (speed == USB_SPEED_HIGH) descriptors = f->hs_descriptors; else descriptors = f->descriptors; @@ -251,7 +255,9 @@ static int config_desc(struct usb_composite_dev *cdev, unsigned w_value) struct usb_configuration*c; struct list_head*pos; - if (gadget_is_dualspeed(gadget)) { + if (gadget_is_superspeed(gadget)) { + speed = gadget->speed; + } else if (gadget_is_dualspeed(gadget)) { if (gadget->speed == USB_SPEED_HIGH) hs = 1; if (type == USB_DT_OTHER_SPEED_CONFIG) @@ -275,7 +281,10 @@ static int config_desc(struct usb_composite_dev *cdev, unsigned w_value) continue; check_config: - if (speed == USB_SPEED_HIGH) { + if (speed == USB_SPEED_SUPER) { + if (!c->superspeed) + continue; + } else if (speed == USB_SPEED_HIGH) { if (!c->highspeed) continue; } else { @@ -294,8 +303,12 @@ static int count_configs(struct usb_composite_dev *cdev, unsigned type) struct usb_gadget *gadget = cdev->gadget; unsignedcount = 0; int hs = 0; + int ss = 0; struct usb_configuration*c; + if (gadget->speed == USB_SPEED_SUPER) + ss = 1; + if (gadget_is_dualspeed(gadget)) { if (gadget->speed == USB_SPEED_HIGH) hs = 1; @@ -304,7 +317,10 @@ static int count_configs(struct usb_composite_dev *cdev, unsigned type) } list_for_each_entry(c, &cdev->configs, list) { /* ignore configs that won't work at this speed */ - if (hs) { + if (ss) { + if (!c->superspeed) + continue; + } else if (hs) { if (!c->highspeed) continue; } else { @@ -388,6 +404,9 @@ static int set_config(struct usb_composite_dev *cdev, case USB_SPEED_HIGH: speed = "high"; break; +case USB_SPEED_SUPER: +speed = "super"; +break; default: speed = "?"; break; @@ -412,7 +431,9 @@ static int set_config(struct usb_composite_dev *cdev, * function's setup callback instead of the current * configuration's setup callback. */ - if (gadget->speed == USB_SPEED_HIGH) + if (gadget->speed == USB_SPEED_SUPER) + descriptors = f->ss_descriptors; + else if (gadget->speed == USB_SPEED_HIGH) descriptors = f->hs_descriptors; else descriptors = f->descriptors; @@ -492,8 +513,9 @@ int usb_add_config(struct usb_composite_dev *cdev, list_del(&config->list); config->cdev = NULL; } else { - debug("cfg %d/%p speeds:%s%s\n", + debug("cfg %d/%p speeds:%s%s%s\n", config->bConfigurationValue, config, + config->superspeed ? " super" : "", co
[PATCH V2 12/17] usb: fastboot: add super speed support
From: Li Jun Add super speed EP config. Reviewed-by: Ye Li Reviewed-by: Peter Chen Tested-by: faqiang.zhu Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/f_fastboot.c | 47 ++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index e330456390..c2abdd66a8 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -128,10 +128,45 @@ static struct usb_descriptor_header *fb_hs_function[] = { NULL, }; +/* Super speed */ +static struct usb_endpoint_descriptor ss_ep_in = { + .bLength= USB_DT_ENDPOINT_SIZE, + .bDescriptorType= USB_DT_ENDPOINT, + .bEndpointAddress = USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), +}; + +static struct usb_endpoint_descriptor ss_ep_out = { + .bLength= USB_DT_ENDPOINT_SIZE, + .bDescriptorType= USB_DT_ENDPOINT, + .bEndpointAddress = USB_DIR_OUT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), +}; + +static struct usb_ss_ep_comp_descriptor fb_ss_bulk_comp_desc = { + .bLength = sizeof(fb_ss_bulk_comp_desc), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, +}; + +static struct usb_descriptor_header *fb_ss_function[] = { + (struct usb_descriptor_header *)&interface_desc, + (struct usb_descriptor_header *)&ss_ep_in, + (struct usb_descriptor_header *)&fb_ss_bulk_comp_desc, + (struct usb_descriptor_header *)&ss_ep_out, + (struct usb_descriptor_header *)&fb_ss_bulk_comp_desc, + NULL, +}; + static struct usb_endpoint_descriptor * fb_ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *fs, - struct usb_endpoint_descriptor *hs) + struct usb_endpoint_descriptor *hs, + struct usb_endpoint_descriptor *ss) { + if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER) + return ss; + if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) return hs; return fs; @@ -219,6 +254,12 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) f->hs_descriptors = fb_hs_function; } + if (gadget_is_superspeed(gadget)) { + ss_ep_in.bEndpointAddress = fs_ep_in.bEndpointAddress; + ss_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress; + f->ss_descriptors = fb_ss_function; + } + s = env_get("serial#"); if (s) g_dnl_set_serialnumber((char *)s); @@ -283,7 +324,7 @@ static int fastboot_set_alt(struct usb_function *f, debug("%s: func: %s intf: %d alt: %d\n", __func__, f->name, interface, alt); - d = fb_ep_desc(gadget, &fs_ep_out, &hs_ep_out); + d = fb_ep_desc(gadget, &fs_ep_out, &hs_ep_out, &ss_ep_out); ret = usb_ep_enable(f_fb->out_ep, d); if (ret) { puts("failed to enable out ep\n"); @@ -298,7 +339,7 @@ static int fastboot_set_alt(struct usb_function *f, } f_fb->out_req->complete = rx_handler_command; - d = fb_ep_desc(gadget, &fs_ep_in, &hs_ep_in); + d = fb_ep_desc(gadget, &fs_ep_in, &hs_ep_in, &ss_ep_in); ret = usb_ep_enable(f_fb->in_ep, d); if (ret) { puts("failed to enable in ep\n"); -- 2.28.0
[PATCH V2 13/17] usb: gadget: dnl: set dnl to be super speed
From: Li Jun Set its max_speed to be super speed. Reviewed-by: Ye Li Reviewed-by: Peter Chen Tested-by: faqiang.zhu Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/g_dnl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c index 86fdd16b01..afb7b74f30 100644 --- a/drivers/usb/gadget/g_dnl.c +++ b/drivers/usb/gadget/g_dnl.c @@ -286,6 +286,7 @@ static struct usb_composite_driver g_dnl_driver = { .name = NULL, .dev = &device_desc, .strings = g_dnl_composite_strings, + .max_speed = USB_SPEED_SUPER, .bind = g_dnl_bind, .unbind = g_dnl_unbind, -- 2.28.0
[PATCH V2 14/17] usb: composite: force gadget to be USB2 for HS only function
From: Li Jun If one of functions is not super speed capable, we need force the udc to be high speed, this is an equivalent implementation of usb_gadget_udc_set_speed() in kernel but simple, which set the gadget max_speed to be high speed, so afterwards when start gadget duc can set the HW to be USB 2.0 mode. Reviewed-by: Ye Li Reviewed-by: Peter Chen Tested-by: faqiang.zhu Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/composite.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 1063c571d8..2a309e624e 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -532,6 +532,19 @@ int usb_add_config(struct usb_composite_dev *cdev, } } + /* +* If one function of config is not super speed capable, +* force the gadget to be high speed so controller driver +* can init HW to be USB 2.0 +*/ + if (gadget_is_superspeed(cdev->gadget)) { + list_for_each_entry(f, &config->functions, list) { + if (!f->ss_descriptors) + cdev->gadget->max_speed = + USB_SPEED_HIGH; + } + } + usb_ep_autoconfig_reset(cdev->gadget); os_desc_config = config; -- 2.28.0
[PATCH V2 15/17] usb: udc: ci: update speed handling
From: Li Jun Remove the gadget driver speed check, and set its max_speed to be USB_SPEED_HIGH. Reviewed-by: Ye Li Reviewed-by: Peter Chen Tested-by: faqiang.zhu Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/ci_udc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index cdb8f6fb3d..b64e4bb605 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -145,6 +145,7 @@ static struct ci_drv controller = { .name = "ci_udc", .ops= &ci_udc_ops, .is_dualspeed = 1, + .max_speed = USB_SPEED_HIGH, }, }; @@ -1015,8 +1016,6 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) return -EINVAL; if (!driver->bind || !driver->setup || !driver->disconnect) return -EINVAL; - if (driver->speed != USB_SPEED_FULL && driver->speed != USB_SPEED_HIGH) - return -EINVAL; #if CONFIG_IS_ENABLED(DM_USB) ret = usb_setup_ehci_gadget(&controller.ctrl); -- 2.28.0
[PATCH V2 16/17] usb: gadget: fastboot: use correct max packet size
From: Li Jun Change to use wMaxPacketSize of current speed EP desc for request length wrap up. Reviewed-by: Peter Chen Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/f_fastboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index c2abdd66a8..2ef75a1388 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -427,7 +427,7 @@ static unsigned int rx_bytes_expected(struct usb_ep *ep) { int rx_remain = fastboot_data_remaining(); unsigned int rem; - unsigned int maxpacket = ep->maxpacket; + unsigned int maxpacket = usb_endpoint_maxp(ep->desc); if (rx_remain <= 0) return 0; -- 2.28.0
[PATCH V2 17/17] usb: gaget: ci: set ep's desc when enable ep
From: Li Jun As we need standard usb_ep's desc, so set it when enable ep. Reviewed-by: Peter Chen Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/ci_udc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index b64e4bb605..226a9e6d67 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -336,6 +336,7 @@ static int ci_ep_enable(struct usb_ep *ep, num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; in = (desc->bEndpointAddress & USB_DIR_IN) != 0; ci_ep->desc = desc; + ep->desc = desc; if (num) { int max = get_unaligned_le16(&desc->wMaxPacketSize); @@ -358,6 +359,7 @@ static int ci_ep_disable(struct usb_ep *ep) struct ci_ep *ci_ep = container_of(ep, struct ci_ep, ep); ci_ep->desc = NULL; + ep->desc = NULL; return 0; } -- 2.28.0
Re: [PATCH] clk: stm32mp1: add support of I2C6_K
Hi Patrick On 1/22/21 3:34 PM, Patrick Delaunay wrote: > Add support of missing I2C6_K with bit 3 of RCC_MC_APB5ENSETR = > I2C6EN: I2C6 peripheral clocks enable. > > This patch allows customer to use I2C6 in SPL or in U-Boot > as other I2C instance, already support in clk driver. > > Signed-off-by: Patrick Delaunay > --- > > drivers/clk/clk_stm32mp1.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c > index d4f1048591..8a5bdcb11d 100644 > --- a/drivers/clk/clk_stm32mp1.c > +++ b/drivers/clk/clk_stm32mp1.c > @@ -549,6 +549,7 @@ static const struct stm32mp1_clk_gate stm32mp1_clk_gate[] > = { > STM32MP1_CLK_SET_CLR(RCC_MP_APB4ENSETR, 16, USBPHY_K, _USBPHY_SEL), > > STM32MP1_CLK_SET_CLR(RCC_MP_APB5ENSETR, 2, I2C4_K, _I2C46_SEL), > + STM32MP1_CLK_SET_CLR(RCC_MP_APB5ENSETR, 3, I2C6_K, _I2C46_SEL), > STM32MP1_CLK_SET_CLR(RCC_MP_APB5ENSETR, 8, RTCAPB, _PCLK5), > STM32MP1_CLK_SET_CLR(RCC_MP_APB5ENSETR, 20, STGEN_K, _STGEN_SEL), > > Reviewed-by: Patrice Chotard Thanks Patrice
Pull request: u-boot-imx u-boot-imx-20210125
Hi Tom, please pull from u-boot-imx, thanks ! The following changes since commit 184aa6504143b452132e28cd3ebecc7b941cdfa1: Merge tag 'u-boot-rockchip-20210121' of https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip (2021-01-21 07:39:47 -0500) are available in the Git repository at: https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git tags/u-boot-imx-20210125 for you to fetch changes up to 4f37aa957939937f9f5b472f829ab81ef13c479a: ARM: imx: add i.MX8MN lpddr4 image cfg file (2021-01-23 14:01:59 +0100) Changes for 2020.04 --- - new board: Phytec phyCORE-i.MX8MP i.MX8MN Beacon EmbeddedWorks devkit - Fixes: several nanbcb fixes fix for imx8mm_beacon - further switch to distro boot commands - DM: DM Ether for MX6UL CI: https://gitlab.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/6013 Adam Ford (6): imx8mm_beacon: Enable fixed regulator in SPL imx: imx8mm-beacon: Remove relocation restrictions spi: nxp_fspi: Enable support for nxp,imx8mm-fspi imx8mm_beacon: Enable QSPI Support arm64: dts: imx8mm-beacon: Resync imx8mm-beacon-som with 5.11-rc4 imx: Add support for i.MX8MN Beacon EmbeddedWorks devkit. Alice Guo (5): imx8mm: configs: add support for distro boot commands board: imx8mm: add boot.cmd for distro boot on iMX8MM imx8mp: configs: add support for distro boot commands board: imx8mp: add boot.cmd for distro boot on iMX8MP imx8mq: configs: add support for distro boot commands Han Xu (1): nandbcb: nand support for i.MX8MP Heiko Schocher (1): mmc: fsl_esdhc_imx.c: fix compiler warning Marc Ferland (2): arm: dart6ul: enable DM_ETH for the dart6ul arm: dart6ul: fix ddr size macro Marek Vasut (5): ARM: imx6: dh-imx6: Move bootcounter to SNVS_LPGDR clk: imx: Add ECSPI to iMX8MN spi: imx: Define register bits in the driver spi: imx: Use clock framework if enabled ARM: imx: add i.MX8MN lpddr4 image cfg file Martin Fuzzey (1): w1: mxc: fix build Peng Fan (11): imx: imx8mp_evk: enable eth support imx: imx8mn_ddr4_evk: Use CONFIG_TARGET_IMX8MN_DDR4_EVK for DDR4 EVK board imx: imx8mn_evk: correct stack/malloc adress arm: dts: imx8mn: sync dts from Linux Kernel imx8m: clock: add type of set_clk_eqos arm: dts: imx8mp: sync dts from Linux Kernel arm: dts: imx8mm: sync dts from Linux Kernel arm: dts: imx8mq: sync dts from Linux Kernel imx8m: lowlevel_init: tune alignment imx: imx8mn/p: drop CONFIG_SYS_[I,D]CACHE_OFF imx8m: add QSPI boot dev Sean Anderson (1): mx6ul(l)evk: Enable DM_ETH_PHY Teresa Remmet (1): board: phytec: imx8mp: Add PHYTEC phyCORE-i.MX8MP support Ye Li (9): imx: ddr: imx8m: Move selfref_en after DDR scrub nandbcb: Fix uninitialized variable imx: nandbcb: Fix resource leak imx: nandbcb: Fix resource leak in read_fcb imx: nandbcb: Fix potential overflow in fill_dbbt_data imx: nandbcb: Fix potential overflow in nandbcb_set_boot_config imx: Fix market segment fuse offset on iMX8MP imx6: Remove AHCI device before boot OS imx: timer: Modify GPT timer driver for mx7 arch/arm/dts/Makefile |2 + arch/arm/dts/imx6ull-dart-6ul.dts | 48 arch/arm/dts/imx6ull-dart-6ul.dtsi | 57 ++--- arch/arm/dts/imx8mm-beacon-som.dtsi | 326 +++--- arch/arm/dts/imx8mm-evk.dts | 534 ++ arch/arm/dts/imx8mm-evk.dtsi| 489 ++ arch/arm/dts/imx8mm.dtsi| 53 - arch/arm/dts/imx8mn-beacon-baseboard.dtsi | 236 +++ arch/arm/dts/imx8mn-beacon-kit-u-boot.dtsi | 122 ++ arch/arm/dts/imx8mn-beacon-kit.dts | 19 ++ arch/arm/dts/imx8mn-beacon-som.dtsi | 405 arch/arm/dts/imx8mn-ddr4-evk.dts| 321 ++--- arch/arm/dts/imx8mn-evk.dtsi| 360 arch/arm/dts/imx8mn-pinfunc.h | 1266 +- arch/arm/dts/imx8mn.dtsi| 411 +++- arch/arm/dts/imx8mp-evk-u-boot.dtsi |4 + arch/arm/dts/imx8mp-evk.dts | 117 +- arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi | 114 + arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts | 161 + arch/arm/dts/imx8mp-phycor
[PATCH] pci: pci_mvebu: Disable config access to PCI host bridge ports
This patch changes the PCI config routines in the Armada XP / 38x driver to not allow access to the PCIe root ports. While updating the Armada XP based theadorable to the latest mainline and testing it with the DM PCI driver I noticed, that the PCI root bridge was being configured incorrectly. Resulting in the PCIe Intel WiFi was not working correctly in Linux. With this patch applied, all PCIe devices work without any issues in Linux again. Signed-off-by: Stefan Roese Cc: Marek Behún Cc: Phil Sutter Cc: Mario Six --- drivers/pci/pci_mvebu.c | 66 + 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c index 9528e7c40ecf..46ffa8df4403 100644 --- a/drivers/pci/pci_mvebu.c +++ b/drivers/pci/pci_mvebu.c @@ -153,28 +153,21 @@ static int mvebu_pcie_read_config(const struct udevice *bus, pci_dev_t bdf, u32 reg; u32 data; - debug("PCIE CFG read: (b,d,f)=(%2d,%2d,%2d) ", - PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf)); - - /* Only allow one other device besides the local one on the local bus */ - if (PCI_BUS(bdf) == local_bus && PCI_DEV(bdf) != local_dev) { - if (local_dev == 0 && PCI_DEV(bdf) != 1) { - debug("- out of range\n"); - /* -* If local dev is 0, the first other dev can -* only be 1 -*/ - *valuep = pci_get_ff(size); - return 0; - } else if (local_dev != 0 && PCI_DEV(bdf) != 0) { - debug("- out of range\n"); - /* -* If local dev is not 0, the first other dev can -* only be 0 -*/ - *valuep = pci_get_ff(size); - return 0; - } + debug("PCIE CFG read: loc_bus=%d loc_dev=%d (b,d,f)=(%2d,%2d,%2d) ", + local_bus, local_dev, PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf)); + + /* Don't access the local host controller via this API */ + if (PCI_BUS(bdf) == local_bus && PCI_DEV(bdf) == local_dev) { + debug("- skipping host controller\n"); + *valuep = pci_get_ff(size); + return 0; + } + + /* If local dev is 0, the first other dev can only be 1 */ + if (PCI_BUS(bdf) == local_bus && local_dev == 0 && PCI_DEV(bdf) != 1) { + debug("- out of range\n"); + *valuep = pci_get_ff(size); + return 0; } /* write address */ @@ -196,25 +189,20 @@ static int mvebu_pcie_write_config(struct udevice *bus, pci_dev_t bdf, int local_dev = PCI_DEV(pcie->dev); u32 data; - debug("PCIE CFG write: (b,d,f)=(%2d,%2d,%2d) ", - PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf)); + debug("PCIE CFG write: loc_bus=%d loc_dev=%d (b,d,f)=(%2d,%2d,%2d) ", + local_bus, local_dev, PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf)); debug("(addr,val)=(0x%04x, 0x%08lx)\n", offset, value); - /* Only allow one other device besides the local one on the local bus */ - if (PCI_BUS(bdf) == local_bus && PCI_DEV(bdf) != local_dev) { - if (local_dev == 0 && PCI_DEV(bdf) != 1) { - /* -* If local dev is 0, the first other dev can -* only be 1 -*/ - return 0; - } else if (local_dev != 0 && PCI_DEV(bdf) != 0) { - /* -* If local dev is not 0, the first other dev can -* only be 0 -*/ - return 0; - } + /* Don't access the local host controller via this API */ + if (PCI_BUS(bdf) == local_bus && PCI_DEV(bdf) == local_dev) { + debug("- skipping host controller\n"); + return 0; + } + + /* If local dev is 0, the first other dev can only be 1 */ + if (PCI_BUS(bdf) == local_bus && local_dev == 0 && PCI_DEV(bdf) != 1) { + debug("- out of range\n"); + return 0; } writel(PCIE_CONF_ADDR(bdf, offset), pcie->base + PCIE_CONF_ADDR_OFF); -- 2.30.0
[PATCH 2/2] arm: mvebu: theadorable: Set deephasis bit in PCIe configs very early
Testing has shown, that the quality of the PCIe signals and also the stability of correct link establishment on the 2 PCIe ports is better, when the deemphasis bit is set in the PCIe config register. This needs to be done very early, even before the SERDES setup code is run. This way, the first link will already be established with this setup. Signed-off-by: Stefan Roese --- board/theadorable/theadorable.c | 24 1 file changed, 24 insertions(+) diff --git a/board/theadorable/theadorable.c b/board/theadorable/theadorable.c index 4b99d9842efd..dd7f900773d6 100644 --- a/board/theadorable/theadorable.c +++ b/board/theadorable/theadorable.c @@ -148,6 +148,18 @@ u8 board_sat_r_get(u8 dev_num, u8 reg) return 0xe; /* PEX port 0 is PCIe Gen1, PEX port 1..3 PCIe Gen2 */ } +#define PCIE_LNK_CTRL_STAT_2_OFF 0x0090 +#define PCIE_LNK_CTRL_STAT_2_DEEM_BIT BIT(6) + +static void pcie_set_deemphasis(u32 base) +{ + u32 reg; + + reg = readl((void *)base + PCIE_LNK_CTRL_STAT_2_OFF); + reg |= PCIE_LNK_CTRL_STAT_2_DEEM_BIT; + writel(reg, (void *)base + PCIE_LNK_CTRL_STAT_2_OFF); +} + int board_early_init_f(void) { /* Configure MPP */ @@ -169,6 +181,18 @@ int board_early_init_f(void) writel(THEADORABLE_GPP_OUT_VAL_HIGH, MVEBU_GPIO2_BASE + 0x00); writel(THEADORABLE_GPP_OUT_ENA_HIGH, MVEBU_GPIO2_BASE + 0x04); + /* +* Set deephasis bit in the PCIe configuration of both PCIe ports +* used on this board. +* +* This needs to be done very early, even before the SERDES setup +* code is run. This way, the first link will already be established +* with this setup. Testing has shown, that this results in a more +* stable PCIe link with better signal quality. +*/ + pcie_set_deemphasis(MVEBU_REG_PCIE_BASE); /* Port 0 */ + pcie_set_deemphasis(MVEBU_REG_PCIE_BASE + 0x2000); /* Port 2 */ + return 0; } -- 2.30.0
[PATCH 1/2] arm: mvebu: theadorable: Enhance "pcie" test cmd to check link width/speed
This patch changes the board specific "pcie" U-Boot command to not only check for PCIe device existance but also for the correct link speed and width that has been established. This cmd can be used by U-Boot scripts for automated testing, if the PCIe setup is correct. Meaning, that all PCIe devices are correctly detected and the link speed and width is corrent. Signed-off-by: Stefan Roese --- board/theadorable/theadorable.c | 108 +--- 1 file changed, 87 insertions(+), 21 deletions(-) diff --git a/board/theadorable/theadorable.c b/board/theadorable/theadorable.c index 67bc00b65b03..4b99d9842efd 100644 --- a/board/theadorable/theadorable.c +++ b/board/theadorable/theadorable.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -311,42 +312,107 @@ int board_late_init(void) #endif #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_PCI) -int do_pcie_test(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +static int pcie_get_link_speed_width(pci_dev_t bdf, int *speed, int *width) { - pci_dev_t bdf; + struct udevice *dev; u16 ven_id, dev_id; + u16 lnksta; + int ret; + int pos; - if (argc != 3) - return cmd_usage(cmdtp); + /* +* Check if the PCIe device is detected (sometimes its not available +* on the PCIe bus) +*/ + ret = dm_pci_bus_find_bdf(bdf, &dev); + if (ret) + return -ENODEV; + + /* PCIe device found */ + dm_pci_read_config16(dev, PCI_VENDOR_ID, &ven_id); + dm_pci_read_config16(dev, PCI_DEVICE_ID, &dev_id); + printf("Detected PCIe device: VendorID 0x%04x DeviceId 0x%04x @ BDF %d.%d.%d\n", + ven_id, dev_id, PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf)); + + /* Now read EXP_LNKSTA register */ + pos = dm_pci_find_capability(dev, PCI_CAP_ID_EXP); + dm_pci_read_config16(dev, pos + PCI_EXP_LNKSTA, &lnksta); + *speed = lnksta & PCI_EXP_LNKSTA_CLS; + *width = (lnksta & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT; - ven_id = simple_strtoul(argv[1], NULL, 16); - dev_id = simple_strtoul(argv[2], NULL, 16); + return 0; +} + +/* + * U-Boot cmd to test for the presence of the directly connected PCIe devices + * the theadorable board. This cmd can be used by U-Boot scripts for automated + * testing, if the PCIe setup is correct. Meaning, that all PCIe devices are + * correctly detected and the link speed and width is corrent. + * + * Here a short script that may be used for an automated test. It results in + * an endless reboot loop, if the PCIe devices are detected correctly. If at + * any time a problem is detected (PCIe device not available or link is + * incorrect), then booting will halt. So just use this "bootcmd" and let the + * board run over a longer time (e.g. one night) and if the board still reboots + * after this time, then everything is okay. + * + * bootcmd=echo bootcount=$bootcount; pcie ;if test $? -eq 0; + * then echo PCIe status okay, resetting...; reset; else; + * echo PCIe status NOT okay, hanging (bootcount=$bootcount); fi; + */ +int do_pcie_test(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + pci_dev_t bdf; + int speed; + int width; + int ret; - printf("Checking for PCIe device: VendorID 0x%04x, DeviceId 0x%04x\n", - ven_id, dev_id); + if (argc != 1) + return cmd_usage(cmdtp); /* -* Check if the PCIe device is detected (somtimes its not available +* Check if the PCIe device is detected (sometimes its not available * on the PCIe bus) */ - bdf = pci_find_device(ven_id, dev_id, 0); - if (bdf == -1) { + + /* Check for PCIe device on PCIe port/bus 0 */ + bdf = PCI_BDF(0, 1, 0); + ret = pcie_get_link_speed_width(bdf, &speed, &width); + if (ret) { /* PCIe device not found! */ - printf("Failed to find PCIe device\n"); - } else { - /* PCIe device found! */ - printf("PCIe device found, resetting board...\n"); + printf("Failed to find PCIe device @ BDF %d.%d.%d\n", + PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf)); + return CMD_RET_FAILURE; + } - /* default handling: SOFT reset */ - do_reset(NULL, 0, 0, NULL); + printf("Established speed=%d width=%d\n", speed, width); + if ((speed != 1 || width != 1)) { + printf("Detected incorrect speed/width!!!\n"); + return CMD_RET_FAILURE; } - return 0; + /* Check for PCIe device on PCIe port/bus 1 */ + bdf = PCI_BDF(1, 1, 0); + ret = pcie_get_link_speed_width(bdf, &speed, &width); + if (ret) { + /* PCIe device not found! */ + printf("Failed to find PCI
Re: [PATCH] gpio-uclass: fix gpio flags save condition
Hello Simon, On Sun, 24 Jan 2021 13:24:14 -0700 Simon Glass wrote: > Hi Kory, > > On Fri, 22 Jan 2021 at 08:23, Kory Maincent wrote: > > > > The commit cd2faeba1a moves the location where we save the flags to the gpio > > descriptor but it adds a "!" character. > > This breaks the condition we expect to save the flags. > > > > Signed-off-by: Kory Maincent > > --- > > drivers/gpio/gpio-uclass.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > This does indeed seem to be a bug, and the tests do not cover it. But > this happens to be fixed by my GPIO series. I'm about to send out v3 > so will copy you on it. Thanks. I have tested your series of patch and it seems to have also an issue with my use case. I am working with w1-gpio. I got this issue: => w1 bus check_dir_flags: flags 0x16 has GPIOD_IS_OUT and GPIOD_IS_IN gpio_sunxi PD: PD error: set_dir_flags for gpio PD2 has invalid dir flags 0x16 Bus 0: onewire (active) w1_eeprom@0 (0) uclass w1_eeprom : family 0x0 Regards, Köry
[PULL] u-boot-atmel-2021.04-b
Hi Tom, Please pull tag u-boot-atmel-2021.04-b , the second set of new atmel features for 2021.04 cycle. This feature set includes macb updates for all interfaces and new sama7g5 variant support; micrel ksz9031 DLL support; a new board from Giant based on Adafruit feather form factor which contains a SAMA5D27 SoC; several fixes regarding the NAND flash PMECC block; and pincontrol drive strength support for pio4 controller. Thanks, Eugen The following changes since commit ae3d8b6c403218e68b56bce962ba7737161cc6f4: Merge https://gitlab.denx.de/u-boot/custodians/u-boot-sh (2021-01-18 12:38:22 -0500) are available in the Git repository at: https://gitlab.denx.de/u-boot/custodians/u-boot-atmel.git tags/u-boot-atmel-2021.04-b for you to fetch changes up to 786f35b619ddbfb88e4532d11a56413f5dab473f: ARM: at91: spl: add spl_early_init for sama5d2 platforms (2021-01-22 15:09:59 +0200) Second set of u-boot-atmel features for 2021.04 cycle Claudiu Beznea (7): net: phy: micrel: add support for DLL setup on ksz9131 net: phy: micrel: fix typo net: macb: add user io config data structure net: macb: check clk_set_rate return value to be negative net: macb: add support for sama7g5 gmac net: macb: add support for sama7g5 emac net: macb: take into account all RGMII interface types Eugen Hristev (4): dt-bindings: pinctrl: at91-pio4: update license to SPDX style dt-bindings: pinctrl: at91-pio4: add property for drive strength pinctrl: at91-pio4: convert to dev_read_prop pinctrl: at91-pio4: implement drive strength support Greg Gallagher (3): board: atmel: Add SAMA5D27 giant board configs: sama5d27_som1_ek: Set FDT filename based on defconfig ARM: at91: spl: add spl_early_init for sama5d2 platforms Kai Stuhlemmer (ebee Engineering) (1): sam9x60.h: Fix Galois Field Table offsets Tudor Ambarus (3): configs: at91: Fix the involuntarily disablement of NAND PMECC configs: at91: Fix wrong definitions for CONFIG_PMECC_CAP sama5d3: Fix Galois Field Table offsets arch/arm/dts/Makefile | 3 +- arch/arm/dts/at91-sama5d27_giantboard.dts | 128 + arch/arm/mach-at91/include/mach/atmel_pio4.h | 1 + arch/arm/mach-at91/include/mach/sam9x60.h | 4 +- arch/arm/mach-at91/include/mach/sama5d3.h | 4 +- arch/arm/mach-at91/spl_atmel.c | 7 ++ board/atmel/sama5d27_som1_ek/MAINTAINERS | 6 + configs/at91sam9n12ek_mmc_defconfig| 1 + configs/at91sam9n12ek_spiflash_defconfig | 1 + configs/at91sam9x5ek_mmc_defconfig | 1 + configs/at91sam9x5ek_spiflash_defconfig| 1 + configs/sama5d27_giantboard_defconfig | 97 configs/sama5d36ek_cmp_mmc_defconfig | 2 + configs/sama5d36ek_cmp_nandflash_defconfig | 1 + configs/sama5d36ek_cmp_spiflash_defconfig | 2 + configs/sama5d3_xplained_mmc_defconfig | 2 + configs/sama5d3xek_mmc_defconfig | 2 + configs/sama5d3xek_spiflash_defconfig | 2 + configs/sama5d4_xplained_spiflash_defconfig| 2 + configs/sama5d4ek_mmc_defconfig| 2 + configs/sama5d4ek_spiflash_defconfig | 2 + .../pinctrl/atmel,at91-pio4-pinctrl.txt| 2 + drivers/net/macb.c | 100 +--- drivers/net/phy/micrel_ksz90x1.c | 65 ++- drivers/pinctrl/pinctrl-at91-pio4.c| 14 ++- include/configs/sama5d27_som1_ek.h | 7 +- include/dt-bindings/pinctrl/at91.h | 7 +- 27 files changed, 436 insertions(+), 30 deletions(-) create mode 100644 arch/arm/dts/at91-sama5d27_giantboard.dts create mode 100644 configs/sama5d27_giantboard_defconfig
Re: [patch v3 0/9] rk3399 (Pinebook pro) EDP support
On Fri, Nov 20, 2020 at 1:29 PM Arnaud Patard wrote: > > This patchset add support for the rk3399 eDP. It has been tested on the > pinebook > pro and Google Kevin chromeos devices. > > The changes have been written by studying the linux code, since I didn't find > any > manual for theses part of the RK3399 SoC. > > On the linux kernel side, on recent kernels, it needs commit "pwm: rockchip: > Keep > enabled PWMs running while probing" otherwise the pinebook pro will freeze > when probing > the display. So for me you can add for the series: Tested-by: Peter Robinson > Changes since v2: > - Respect alphabetical order in uboot.dtsi in patch > "rk3399-pinebook-pro-u-boot.dtsi: Enable edp" > - drop "configs/pinebook-pro-rk3399_defconfig: enable > SYS_USB_EVENT_POLL_VIA_INT_QUEUE" > (pbp_defconfig_usb_poll.patch) patch, since the same change has been merged > with change > > https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip/-/commit/b197c934b11f611dcc1a083d90e68019d1e010cf > - change patch subjects. > > Changes since v1: > - Add reset support for the VOP and eDP. This was needed and it appears to > also solve > the issue with warm reset. > - Fix a debug string in the vop driver > - Drop the patch "drivers/video/rockchip/rk_edp.c: Change clock rate". > - Address various comments > > >
[RFC 1/1] disk: PARTITIONS should depend on HAVE_BLOCK_DEVICE
Partitions are only relevant for block devices. Signed-off-by: Heinrich Schuchardt --- I still need to check if the part command is needed on boards w/o DISTRO_DEFAULTS. --- cmd/Kconfig | 4 ++-- disk/Kconfig | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 0625ee4050..e253fb7a68 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1171,8 +1171,8 @@ config CMD_OSD config CMD_PART bool "part" - select HAVE_BLOCK_DEVICE - select PARTITION_UUIDS + depends on PARTITION_UUIDS + default y if DISTRO_DEFAULTS help Read and display information about the partition table on various media. diff --git a/disk/Kconfig b/disk/Kconfig index cee16a80bc..1dfe3a0667 100644 --- a/disk/Kconfig +++ b/disk/Kconfig @@ -3,6 +3,7 @@ menu "Partition Types" config PARTITIONS bool "Enable Partition Labels (disklabels) support" + depends on HAVE_BLOCK_DEVICE default y select SPL_SPRINTF if SPL select TPL_SPRINTF if TPL -- 2.29.2
Re: [PATCH 0/2] Console/stdio use after free
Hi Andy, Simon On Wed, 2021-01-20 at 17:57 +0200, Andy Shevchenko wrote: > On Wed, Jan 20, 2021 at 4:05 PM Nicolas Saenz Julienne > wrote: > > > > With today's master, 70c2525c0d3c ('IOMUX: Stop dropped consoles') > > introduces a use after free in usb_kbd_remove(): > > > > - usbkbd's stdio device is de-registered with stdio_deregister_dev(), > > the struct stdio_dev is freed. > > > > - iomux_doenv() is called, usbkbd removed from the console list, and > > console_stop() is called on the struct stdio_dev pointer that no > > longer exists. > > > > This series mitigates this by making sure the pointer is really a stdio > > device prior performing the stop operation. It's not ideal, but I > > couldn't figure out a nicer way to fix this. > > Thanks for the report and indeed this sounds like a papering over the > real issue somewhere else. > If we have a device in the console_list, IOMUX may access it. So, > whenever we drop device, we must update console_list accordingly. Sorry, but I don't have time to address this ATM. If someone else can it'd be nice. Regards, Nicolas signature.asc Description: This is a digitally signed message part
Re: [PATCH 1/2] stdio: Introduce stdio_valid()
On Sat, 2021-01-23 at 19:03 -0700, Simon Glass wrote: > Hi Nicolas, > > On Wed, 20 Jan 2021 at 07:05, Nicolas Saenz Julienne > wrote: > > > > stdio_valid() will confirm that a struct stdio_dev pointer is indeed > > valid. > > > > Signed-off-by: Nicolas Saenz Julienne > > --- > > common/stdio.c | 11 +++ > > include/stdio_dev.h | 1 + > > 2 files changed, 12 insertions(+) > > > > diff --git a/common/stdio.c b/common/stdio.c > > index abf9b1e915..69b7d2692d 100644 > > --- a/common/stdio.c > > +++ b/common/stdio.c > > @@ -157,6 +157,17 @@ static int stdio_probe_device(const char *name, enum > > uclass_id id, > > return 0; > > } > > > > +bool stdio_valid(struct stdio_dev *dev) > > +{ > > + struct stdio_dev *sdev; > > + > > + list_for_each_entry(sdev, &devs.list, list) > > + if (sdev == dev) > > + return true; > > + > > + return false; > > +} > > + > > struct stdio_dev *stdio_get_by_name(const char *name) > > { > > struct list_head *pos; > > diff --git a/include/stdio_dev.h b/include/stdio_dev.h > > index 48871a6a22..f341439b03 100644 > > --- a/include/stdio_dev.h > > +++ b/include/stdio_dev.h > > @@ -97,6 +97,7 @@ int stdio_deregister_dev(struct stdio_dev *dev, int > > force); > > struct list_head *stdio_get_list(void); > > struct stdio_dev *stdio_get_by_name(const char *name); > > struct stdio_dev *stdio_clone(struct stdio_dev *dev); > > +bool stdio_valid(struct stdio_dev *dev); > > Please add a full function comment and explain what valid means. As discussed with Andy, this is a workaround that doesn't address the underlying issue. If it's good enough for the time being I'll be happy to send a v2. I'll leave a comment stating that it's something to fix. Regards, Nicolas signature.asc Description: This is a digitally signed message part
Re: [PATCH 02/11] pinctrl: single: fix the loop counter variable type
Hi Dario, On 23/01/21 07:27PM, Dario Binacchi wrote: > The patch changes the variable 'n' type from phys_addr_t to int. This information can very easily be obtained by reading the diff. The commit message should also explain _why_ the change is made. For example here it would be a good idea to add something like: n is used as a loop counter, not as a physical address, and is used in a comparison with an int. So it makes sense to set its type to int. Other than that, Reviewed-by: Pratyush Yadav > Signed-off-by: Dario Binacchi > --- > > drivers/pinctrl/pinctrl-single.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/pinctrl/pinctrl-single.c > b/drivers/pinctrl/pinctrl-single.c > index c9a6c272bf..49ed15211d 100644 > --- a/drivers/pinctrl/pinctrl-single.c > +++ b/drivers/pinctrl/pinctrl-single.c > @@ -75,8 +75,8 @@ static int single_configure_pins(struct udevice *dev, >int size) > { > struct single_pdata *pdata = dev_get_plat(dev); > - int count = size / sizeof(struct single_fdt_pin_cfg); > - phys_addr_t n, reg; > + int n, count = size / sizeof(struct single_fdt_pin_cfg); > + phys_addr_t reg; > u32 val; > > for (n = 0; n < count; n++, pins++) { > @@ -109,8 +109,8 @@ static int single_configure_bits(struct udevice *dev, >int size) > { > struct single_pdata *pdata = dev_get_plat(dev); > - int count = size / sizeof(struct single_fdt_bits_cfg); > - phys_addr_t n, reg; > + int n, count = size / sizeof(struct single_fdt_bits_cfg); > + phys_addr_t reg; > u32 val, mask; > > for (n = 0; n < count; n++, pins++) { > -- > 2.17.1 > -- Regards, Pratyush Yadav Texas Instruments India
Re: [PATCH 03/11] pinctrl: single: fix debug messages formatting
Hi Dario, On 23/01/21 07:27PM, Dario Binacchi wrote: > The printf '%pa' format specifier appends the '0x' prefix to the > displayed address. Furthermore, the offset variable is displayed with > the '%x' format specifier instead of '%pa'. I agree with Simon that the commit message does not explain why this change is needed. > Signed-off-by: Dario Binacchi > --- > > drivers/pinctrl/pinctrl-single.c | 28 > 1 file changed, 16 insertions(+), 12 deletions(-) > > diff --git a/drivers/pinctrl/pinctrl-single.c > b/drivers/pinctrl/pinctrl-single.c > index 49ed15211d..cec00e289c 100644 > --- a/drivers/pinctrl/pinctrl-single.c > +++ b/drivers/pinctrl/pinctrl-single.c > @@ -77,15 +77,17 @@ static int single_configure_pins(struct udevice *dev, > struct single_pdata *pdata = dev_get_plat(dev); > int n, count = size / sizeof(struct single_fdt_pin_cfg); > phys_addr_t reg; > - u32 val; > + u32 offset, val; > > for (n = 0; n < count; n++, pins++) { > - reg = fdt32_to_cpu(pins->reg); > - if ((reg < 0) || (reg > pdata->offset)) { > - dev_dbg(dev, " invalid register offset 0x%pa\n", ®); > + offset = fdt32_to_cpu(pins->reg); > + if (offset < 0 || offset > pdata->offset) { > + dev_dbg(dev, " invalid register offset 0x%x\n", > + offset); You are not just fixing "debug messages formatting" here. You have made other changes to the structure of the code here. While these changes might all be correct, they don't belong in a commit that claims to fix message formatting. For example, this dev_dbg() statement in the pre-image prints "®" as the offset. This would be the address of the variable reg on the stack. This looks like it is a bug. The offset is stored in "reg", not in "®". The post-image fixes this bug. A person reading this diff might not look so closely at this because you only claim to change formatting. And some important discussion/context on this bug might be skipped over. Please re-word the commit subject and message to clearly explain why you are making these structural changes and separate them from the formatting changes (which also warrant an explanation on their own). > continue; > } > - reg += pdata->base; > + > + reg = pdata->base + offset; > val = fdt32_to_cpu(pins->val) & pdata->mask; > switch (pdata->width) { > case 16: > @@ -99,7 +101,7 @@ static int single_configure_pins(struct udevice *dev, >pdata->width); > continue; > } > - dev_dbg(dev, " reg/val 0x%pa/0x%08x\n", ®, val); > + dev_dbg(dev, " reg/val %pa/0x%08x\n", ®, val); In a similar fashion as above, shouldn't "®" be replaced with "reg"? I am not too familiar with the code to say for sure. Same for the changes below. > } > return 0; > } > @@ -111,15 +113,17 @@ static int single_configure_bits(struct udevice *dev, > struct single_pdata *pdata = dev_get_plat(dev); > int n, count = size / sizeof(struct single_fdt_bits_cfg); > phys_addr_t reg; > - u32 val, mask; > + u32 offset, val, mask; > > for (n = 0; n < count; n++, pins++) { > - reg = fdt32_to_cpu(pins->reg); > - if ((reg < 0) || (reg > pdata->offset)) { > - dev_dbg(dev, " invalid register offset 0x%pa\n", ®); > + offset = fdt32_to_cpu(pins->reg); > + if (offset < 0 || offset > pdata->offset) { > + dev_dbg(dev, " invalid register offset 0x%x\n", > + offset); > continue; > } > - reg += pdata->base; > + > + reg = pdata->base + offset; > > mask = fdt32_to_cpu(pins->mask); > val = fdt32_to_cpu(pins->val) & mask; > @@ -136,7 +140,7 @@ static int single_configure_bits(struct udevice *dev, >pdata->width); > continue; > } > - dev_dbg(dev, " reg/val 0x%pa/0x%08x\n", ®, val); > + dev_dbg(dev, " reg/val %pa/0x%08x\n", ®, val); > } > return 0; > } > -- > 2.17.1 > -- Regards, Pratyush Yadav Texas Instruments India
Re: [PATCH 1/5] net: Introduce DSA class for Ethernet switches
On Tue, Jan 19, 2021 at 05:15:26PM -0700, Simon Glass wrote: > Hi Tom, > > On Tue, 19 Jan 2021 at 14:00, Tom Rini wrote: > > > > On Tue, Jan 19, 2021 at 11:06:10AM -0700, Simon Glass wrote: > > > Hi Claudiu, > > > > > > On Fri, 15 Jan 2021 at 09:47, Claudiu Manoil > > > wrote: > > > > > > > > >-Original Message- > > > > >From: Simon Glass > > > > >Sent: Thursday, January 14, 2021 5:42 PM > > > > >To: Claudiu Manoil > > > > >Cc: Joe Hershberger ; Bin Meng > > > > >; Michael Walle ; U-Boot Mailing > > > > >List ; Vladimir Oltean ; > > > > >Alexandru Marginean > > > > >Subject: Re: [PATCH 1/5] net: Introduce DSA class for Ethernet switches > > > > > > > > > [...] > > > > > > > > > >Reviewed-by: Simon Glass > > > > > > > > > >I don't think it is necessary to have the 'if (!pdev)' checks around > > > > >the place. We need a way in U-Boot to have checks like that to catch > > > > >programming errors but to be able to turn them off in production code > > > > >to reduce size. > > > > > > > > > >I suppose a Kconfig would do it, with: > > > > > > > > > >if (CONFIG_IS_ENABLED(SAFETY) && !pdev) > > > > >return log_,msg_ref("safety", -ENODEV) > > > > > > > > > >Also note that -ENODEV is used by drive rmodel so it generally isn't > > > > >safe to return it as a logic error. I think in this case because it > > > > >never happens, it should be OK. > > > > > > > > > > > > > Thanks for the review, Simon. > > > > I thought about using assert(pdev) checks, but during development the > > > > simple "if (!pdev)..." proved more friendly. I like your idea about > > > > enabling > > > > the checks at compile time and disabling them in production. > > > > For now, since this SAFETY flag is not implemented, my understanding is > > > > that you’re ok with leaving the pdev checks in the code as they are > > > > right now > > > > and sometime in the future these will be converted to the "SAFETY" > > > > construct > > > > you mention. > > > > > > > > > > Yes that's fine, you have my review tag. > > > > > > +Tom Rini what do you think about CONFIG_SAFETY or similar to allow > > > these bug checks to be disabled for code-size reasons? > > > > I don't know. Setting aside the name, my first concern is "so we > > disable certain forms of sanity checks, now assuming a malicious entity > > somewhere, what's now able to be exploited?" > > Well if you are able to inject code then I suppose you can do > anything. You don't need to worry about existing parameter checking. > > The difference in my mind is whether there is user/input data > involved. If so, then we need lots of checks. If it is just telling > the clock to go a 2GHz, then the checks are probably just bloating the > code. So rather than leave this to individual preference, I am > wondering whether a Kconfig option might be best. Thinking about this more, yes, if we can macro the check, then we can hide it (and potential other checks) under some SANITY_CHECKS option. -- Tom signature.asc Description: PGP signature
[PULL] u-boot-mips
Hi Tom, please pull updates for MIPS. This adds support for Mediatek MT7620 SoCs. Gitlab CI: https://gitlab.denx.de/u-boot/custodians/u-boot-mips/-/pipelines/6039 Azure: https://dev.azure.com/danielschwierzeck/u-boot/_build/results?buildId=15&view=results The following changes since commit 69d29fe1c0aeb33f42633a7d30b7921c02aa: Merge tag 'efi-2021-04-rc1-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi (2021-01-23 19:07:00 -0500) are available in the Git repository at: https://gitlab.denx.de/u-boot/custodians/u-boot-mips.git tags/mips-pull-2021-01-24 for you to fetch changes up to 9f03585e8dd5554f131bbe507ccebbc30354f493: MAINTAINERS: add maintainer for MediaTek MIPS platform (2021-01-24 21:39:27 +0100) - MIPS: add support for Mediatek MT7620 SoCs Weijie Gao (23): mips: dts: switch to board defines for dtb for mtmips mips: mtmips: move mt7628 related Kconfig into mt7628 subdirectory mips: mtmips: select SYSRESET for mt7628 only mips: mtmips: fix dram size detection in dram_init mips: enable _machine_restart for spl mips: mtmips: add support to initialize SDRAM mips: mtmips: add support for MediaTek MT7620 SoC mips: mtmips: add two reference boards for mt7620 configs: mtmips: refresh for mt7628 based boards serial: add uart driver for MediaTek MT7620 SoC clk: add clock driver for MediaTek MT7620 SoC reset: mtmips: add reset controller support for MediaTek MT7620 SoC pinctrl: mtmips: add support for MediaTek MT7620 SoC watchdog: add watchdog driver for MediaTek MT7620 SoC gpio: add GPIO controller driver for MediaTek MT7620 SoC spi: add spi controller support for MediaTek MT7620 SoC phy: add USB PHY driver for MediaTek MT7620 SoC net: add ethernet driver for MediaTek MT7620 SoC mmc: mtk-sd: fix sclk cycles shift value mmc: mtk-sd: add pad control settings for MediaTek MT7620/MT76x8 SoCs mmc: mtk-sd: assign plat->cfg.f_max with a correct value reset: reset-mtmips: add DM_FLAG_PRE_RELOC flag MAINTAINERS: add maintainer for MediaTek MIPS platform MAINTAINERS | 23 + arch/mips/Kconfig|1 - arch/mips/cpu/cpu.c |2 +- arch/mips/dts/Makefile |7 +- arch/mips/dts/mediatek,mt7620-mt7530-rfb.dts | 100 ++ arch/mips/dts/mediatek,mt7620-rfb.dts| 97 ++ arch/mips/dts/mt7620-u-boot.dtsi | 14 + arch/mips/dts/mt7620.dtsi| 296 ++ arch/mips/mach-mtmips/Kconfig| 72 +- arch/mips/mach-mtmips/Makefile |1 + arch/mips/mach-mtmips/cpu.c |5 +- arch/mips/mach-mtmips/ddr_init.c | 59 ++ arch/mips/mach-mtmips/include/mach/ddr.h |4 + arch/mips/mach-mtmips/include/mach/mt7620-sysc.h | 54 + arch/mips/mach-mtmips/mt7620/Kconfig | 71 ++ arch/mips/mach-mtmips/mt7620/Makefile| 10 + arch/mips/mach-mtmips/mt7620/dram.c | 113 ++ arch/mips/mach-mtmips/mt7620/init.c | 193 arch/mips/mach-mtmips/mt7620/lowlevel_init.S | 53 + arch/mips/mach-mtmips/mt7620/mt7620.h| 103 ++ arch/mips/mach-mtmips/mt7620/serial.c| 36 + arch/mips/mach-mtmips/mt7620/sysc.c | 172 +++ arch/mips/mach-mtmips/mt7628/Kconfig | 53 + board/mediatek/mt7620/Kconfig| 12 + board/mediatek/mt7620/MAINTAINERS|9 + board/mediatek/mt7620/Makefile |3 + board/mediatek/mt7620/board.c|6 + configs/gardena-smart-gateway-mt7688_defconfig |1 + configs/linkit-smart-7688_defconfig |1 + configs/mt7620_mt7530_rfb_defconfig | 58 + configs/mt7620_rfb_defconfig | 76 ++ configs/mt7628_rfb_defconfig |1 + configs/vocore2_defconfig|1 + drivers/clk/mtmips/Makefile |1 + drivers/clk/mtmips/clk-mt7620.c | 159 +++ drivers/gpio/Kconfig |8 + drivers/gpio/Makefile|1 + drivers/gpio/mt7620_gpio.c | 146 +++ drivers/mmc/mtk-sd.c | 136 ++- drivers/net/Kconfig | 12 + drivers/net/Makefile |1 + drivers/net/mt7620-eth.c | 1222 ++ drivers/phy/Kconfig |7 + drivers/phy/Makefile |1 + drivers/phy/mt7620-usb-phy.c | 110 ++ drivers/pinctrl/
[U-Boot] Question: PCIe enumeration of PEX switch does not go thru
Hi U-boot is unable to enumerate pericom PCIe switch and subsequent end point devices on our board (arm v8.2, 64-bit) When booted to linux, we see the same enumerated with endpoints Have any one come ever come across this issue and found a workaround to it? I hope we no need to have a special driver in u-boot for it? U-boot rommon> dm tree Class Index Probed Driver Name --- pci_generi 25 [ ] pci_generic_drv | | `-- pci_15:0.0 PCIe debug logs pci_auto_config_devices: done pci_uclass_pre_probe, bus=25/pci@8e00, parent=soc@0 decode_regions: len=28, cells_per_record=7 decode_regions: region 0, pci_addr=0, addr=8860, size=10, space_code=1 - type=1, pos=0 decode_regions: region 1, pci_addr=100, addr=88200100, size=10, space_code=3 - type=0, pos=1 decode_regions: region 2, pci_addr=10, addr=8840, size=10, space_code=3 - type=8, pos=2 decode_regions: region 3, pci_addr=8e00, addr=8e00, size=10, space_code=3 - type=0, pos=3 pci_uclass_post_probe: probing bus 25 bdf 19 01.00.00: u1 0 (10) 01.00.00: u1 0 (87803010) 0 word 87803010 01.00.00: u1 0 (87803010) -> 12d8 bdf 19 01.00.00: u0 e (10) 01.00.00: u0 e (87803010) pci_find_and_bind_driver: Searching for driver: vendor=12d8, device=8619 pci_find_and_bind_driver: No match found: bound generic driver instead bdf 19 01.00.00: u2 100 (10) 01.00.00: u2 100 (87803010) 19ff00 long 878030100100 01.00.00: u2 100 (87803010) -> fb410003 bdf 19 01.00.00: u2 fb4 (10) 01.00.00: u2 fb4 (87803010) fb410003 long 878030100fb4 01.00.00: u2 fb4 (87803010) -> 13810001 bdf 19 01.00.00: u2 138 (10) 01.00.00: u2 138 (87803010) 13810001 long 878030100138 01.00.00: u2 138 (87803010) -> 14810004 bdf 19 01.00.00: u2 148 (10) 01.00.00: u2 148 (87803010) 14810004 long 878030100148 01.00.00: u2 148 (87803010) -> 27010002 bdf 19 01.00.00: u2 270 (10) 01.00.00: u2 270 (87803010) 27010002 long 878030100270 01.00.00: u2 270 (87803010) -> 9001001e bdf 19 01.00.00: u2 900 (10) 01.00.00: u2 900 (87803010) 9001001e long 878030100900 01.00.00: u2 900 (87803010) -> 10012 bdf 190100 01.00.01: u1 0 (101000) 01.00.01: u1 0 (878030101000) 12d8 word 878030101000 01.00.01: u1 0 (878030101000) -> 12d8 bdf 190100 01.00.01: u0 e (101000) 01.00.01: u0 e (878030101000) 81 byte 87803010100e 01.00.01: u0 e (878030101000) -> 80 pci_bind_bus_devices: bus 25/pci@8e00: found device 0, function 1 bdf 190100 01.00.01: u1 2 (101000) 01.00.01: u1 2 (878030101000) 8619 word 878030101002 01.00.01: u1 2 (878030101000) -> 8619 bdf 190100 01.00.01: u2 8 (101000) pci_uclass_pre_probe, bus=57/pci_19:1f.0, parent=pci@8e00 pci_uclass_post_probe: probing bus 57 bdf 39 21.00.00: u1 0 (210) 21.00.00: u1 0 (87803210) 0 word 87803210 21.00.00: u1 0 (87803210) -> bdf 390800 21.01.00: u1 0 (2108000) 21.01.00: u1 0 (878032108000) word 878032108000 21.01.00: u1 0 (878032108000) -> bdf 391000 21.02.00: u1 0 (211) 21.02.00: u1 0 (87803211) word 87803211 21.02.00: u1 0 (87803211) -> bdf 391800 21.03.00: u1 0 (2118000) 21.03.00: u1 0 (878032118000) word 878032118000 21.03.00: u1 0 (878032118000) -> bdf 392000 21.04.00: u1 0 (212) 21.04.00: u1 0 (87803212) word 87803212 21.04.00: u1 0 (87803212) -> bdf 392800 21.05.00: u1 0 (2128000) 21.05.00: u1 0 (878032128000) word 878032128000 21.05.00: u1 0 (878032128000) -> bdf 393000 21.06.00: u1 0 (213) 21.06.00: u1 0 (87803213) word 87803213 21.06.00: u1 0 (87803213) -> bdf 393800 21.07.00: u1 0 (2138000) 21.07.00: u1 0 (878032138000) word 878032138000 21.07.00: u1 0 (878032138000) -> bdf 394000 21.08.00: u1 0 (214) 21.08.00: u1 0 (87803214) word 87803214 21.08.00: u1 0 (87803214) -> bdf 394800 21.09.00: u1 0 (2148000) 21.09.00: u1 0 (878032148000) word 878032148000 21.09.00: u1 0 (878032148000) -> bdf 395000 21.0a.00: u1 0 (215) 21.0a.00: u1 0 (87803215) word 87803215 21.0a.00: u1 0 (87803215) -> bdf 395800 21.0b.00: u1 0 (2158000) 21.0b.00: u1 0 (878032158000) word 878032158000 21.0b.00: u1 0 (878032158000) -> bdf 396000 21.0c.00: u1 0 (216) 21.0c.00: u1 0 (87803216) word 87803216 21.0c.00: u1 0 (87803216) -> bdf 396800 21.0d.00: u1 0 (2168000) 21.0d.00: u1 0 (878032168000) word 878032168000 21.0d.00: u1 0 (878032168000) -> bdf 397000 21.0e.00: u1 0 (217) 21.0e.00: u1 0 (87803217) word 87803217 21.0e.00: u1 0 (87803217) -> bdf 397800 21.0f.00: u1 0 (
Re: [PULL] u-boot-atmel-2021.04-b
On Mon, Jan 25, 2021 at 10:44:42AM +, eugen.hris...@microchip.com wrote: > Hi Tom, > > Please pull tag u-boot-atmel-2021.04-b , the second set of new atmel > features for 2021.04 cycle. > > This feature set includes macb updates for all interfaces and new > sama7g5 variant support; micrel ksz9031 DLL support; a new board from > Giant based on Adafruit feather form factor which contains a SAMA5D27 > SoC; several fixes regarding the NAND flash PMECC block; and pincontrol > drive strength support for pio4 controller. > > Thanks, > Eugen > > > The following changes since commit ae3d8b6c403218e68b56bce962ba7737161cc6f4: > >Merge https://gitlab.denx.de/u-boot/custodians/u-boot-sh (2021-01-18 > 12:38:22 -0500) > > are available in the Git repository at: > >https://gitlab.denx.de/u-boot/custodians/u-boot-atmel.git > tags/u-boot-atmel-2021.04-b > > for you to fetch changes up to 786f35b619ddbfb88e4532d11a56413f5dab473f: > >ARM: at91: spl: add spl_early_init for sama5d2 platforms (2021-01-22 > 15:09:59 +0200) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: Pull request for documentation tag doc-2021-04-rc1-2
On Mon, Jan 25, 2021 at 01:14:21PM +0100, Heinrich Schuchardt wrote: > The following changes since commit 69d29fe1c0aeb33f42633a7d30b7921c02aa: > > Merge tag 'efi-2021-04-rc1-3' of > https://gitlab.denx.de/u-boot/custodians/u-boot-efi (2021-01-23 19:07:00 > -0500) > > are available in the Git repository at: > > https://gitlab.denx.de/u-boot/custodians/u-boot-efi.git > tags/doc-2021-04-rc1-2 > > for you to fetch changes up to 5b6dac01e636aa8b799a68c115d9fd86e4bbbf09: > > doc: describe command conitrace (2021-01-25 01:15:34 +0100) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: Pull request: u-boot-imx u-boot-imx-20210125
On Mon, Jan 25, 2021 at 03:01:52PM +0100, Stefano Babic wrote: > Hi Tom, > > please pull from u-boot-imx, thanks ! > > The following changes since commit 184aa6504143b452132e28cd3ebecc7b941cdfa1: > > Merge tag 'u-boot-rockchip-20210121' of > https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip (2021-01-21 > 07:39:47 -0500) > > are available in the Git repository at: > > https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git > tags/u-boot-imx-20210125 > > for you to fetch changes up to 4f37aa957939937f9f5b472f829ab81ef13c479a: > > ARM: imx: add i.MX8MN lpddr4 image cfg file (2021-01-23 14:01:59 +0100) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [RESEND 6/7] Revert "fastboot: Add default fastboot_set_reboot_flag implementation"
On Mon, Jan 25, 2021 at 07:16:37PM +0200, Roman Kovalivskyi wrote: > Hi Lukasz, > > On 1/23/21 5:08 PM, Lukasz Majewski wrote: > > Hi Roman, > > > > > This reverts commit 0ebf9842e56c5b8cb7cb1f990bb452cc14af6225. > > > > > > Current generic implementation of fastboot_set_reboot_flag is somewhat > > > messy and requires some additional configuration option to be enabled > > > besides CMD_BCB, so it reverts that implementtion in order to bring a > > > new cleaner one. > > > > > > Next commit introduces new generic implementation of > > > fastboot_set_reboot_flag. > > > > > > Signed-off-by: Roman Kovalivskyi > > > --- > > > drivers/fastboot/Kconfig | 12 -- > > > drivers/fastboot/Makefile | 1 - > > > drivers/fastboot/fb_bcb_impl.c | 43 > > > -- include/fastboot.h | > > > 9 --- 4 files changed, 65 deletions(-) > > > delete mode 100644 drivers/fastboot/fb_bcb_impl.c > > > > > > diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig > > > index 4352ba67a713..d4436dfc9173 100644 > > > --- a/drivers/fastboot/Kconfig > > > +++ b/drivers/fastboot/Kconfig > > > @@ -165,18 +165,6 @@ config FASTBOOT_CMD_OEM_FORMAT > > > relies on the env variable partitions to contain the list > > > of partitions as required by the gpt command. > > > -config FASTBOOT_USE_BCB_SET_REBOOT_FLAG > > > - bool "Use BCB by fastboot to set boot reason" > > > - depends on CMD_BCB && !ARCH_MESON && !ARCH_ROCKCHIP && > > > !TARGET_KC1 && \ > > > - !TARGET_SNIPER && !TARGET_AM57XX_EVM && !TARGET_DRA7XX_EVM > > > - default y > > > - help > > > - Fastboot could implement setting of reboot reason in a > > > generic fashion > > > - via BCB commands. BCB commands are able to write reboot > > > reason into > > > - command field of boot control block. In general case it is > > > sufficient > > > - implementation if your platform supports BCB commands and > > > doesn't > > > - require any specific reboot reason handling. > > > - > > > endif # FASTBOOT > > > endmenu > > > diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile > > > index 2b2c390fe4de..048af5aa8234 100644 > > > --- a/drivers/fastboot/Makefile > > > +++ b/drivers/fastboot/Makefile > > > @@ -5,4 +5,3 @@ obj-y += fb_getvar.o > > > obj-y += fb_command.o > > > obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o > > > obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o > > > -obj-$(CONFIG_FASTBOOT_USE_BCB_SET_REBOOT_FLAG) += fb_bcb_impl.o > > > diff --git a/drivers/fastboot/fb_bcb_impl.c > > > b/drivers/fastboot/fb_bcb_impl.c deleted file mode 100644 > > > index 89ec3601b6f6.. > > > --- a/drivers/fastboot/fb_bcb_impl.c > > > +++ /dev/null > > > @@ -1,43 +0,0 @@ > > > -// SPDX-License-Identifier: GPL-2.0+ > > > -/* > > > - * Copyright 2020 GlobalLogic. > > > - * Roman Kovalivskyi > > > - */ > > > - > > > -#include > > > -#include > > > - > > > -/** > > > - * fastboot_set_reboot_flag() - Set flag to indicate > > > reboot-bootloader > > > - * > > > - * Set flag which indicates that we should reboot into the bootloader > > > - * following the reboot that fastboot executes after this function. > > > - * > > > - * This function should be overridden in your board file with one > > > - * which sets whatever flag your board specific Android bootloader > > > flow > > > - * requires in order to re-enter the bootloader. > > > - */ > > > -int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason) > > > -{ > > > - char cmd[64]; > > > - > > > - if (reason >= FASTBOOT_REBOOT_REASONS_COUNT) > > > - return -EINVAL; > > > - > > > - snprintf(cmd, sizeof(cmd), "bcb load %d misc", > > > - CONFIG_FASTBOOT_FLASH_MMC_DEV); > > > - > > > - if (run_command(cmd, 0)) > > > - return -ENODEV; > > > - > > > - snprintf(cmd, sizeof(cmd), "bcb set command %s", > > > - fastboot_boot_cmds[reason]); > > > - > > > - if (run_command(cmd, 0)) > > > - return -ENOEXEC; > > > - > > > - if (run_command("bcb store", 0)) > > > - return -EIO; > > > - > > > - return 0; > > > -} > > > diff --git a/include/fastboot.h b/include/fastboot.h > > > index 8e9ee80907df..b86b508e69fd 100644 > > > --- a/include/fastboot.h > > > +++ b/include/fastboot.h > > > @@ -52,15 +52,6 @@ enum fastboot_reboot_reason { > > > FASTBOOT_REBOOT_REASONS_COUNT > > > }; > > > -/** > > > - * BCB boot commands > > > - */ > > > -static const char * const fastboot_boot_cmds[] = { > > > - [FASTBOOT_REBOOT_REASON_BOOTLOADER] = "bootonce-bootloader", > > > - [FASTBOOT_REBOOT_REASON_FASTBOOTD] = "boot-fastboot", > > > - [FASTBOOT_REBOOT_REASON_RECOVERY] = "boot-recovery" > > > -}; > > > - > > > /** > > >* fastboot_response() - Writes a response of the form "$tag$reason". > > >* > > > > If this patch is still needed - please rebase it on newest master > > (after the incoming PR) as it causes build breaks. > > > > > > Best regards, > > > > Lukasz Majewski > > > > --
Re: [RESEND 6/7] Revert "fastboot: Add default fastboot_set_reboot_flag implementation"
On 1/25/21 6:16 PM, Roman Kovalivskyi wrote: [...] Could you please share some info on how do you build it (used defconfig, error messages, used compiler, etc.)? I cannot reproduce those issues on my side. I've tried to rebase my patches onto the current master and rebase was done cleanly, there are no conflicts. I've tried building it with rcar3_ulcb_defconfig and build was successful. Used defconfig: rcar3_ulcb_defconfig Used arch: ARM Used compiler: gcc 7.1 for aarch64-linux-gnu Used CFLAGS: -fgnu89-inline Mainline U-Boot for rcar3 has no USB gadget support though ?
[PATCH 1/1] doc: board: fix Microchip MPFS Icicle Kit doc
Two sibling headings (here eMMC) cannot have the same title. Warning, treated as error: doc/board/microchip/mpfs_icicle.rst:423:duplicate label board/microchip/mpfs_icicle:emmc, other instance in doc/board/microchip/mpfs_icicle.rst make[1]: *** [doc/Makefile:69: htmldocs] Error 2 * Correct the heading levels. * Add missing empty lines after headings. Fixes: 9e550e18305f ("doc: board: Add Microchip MPFS Icicle Kit doc") Signed-off-by: Heinrich Schuchardt --- doc/board/microchip/mpfs_icicle.rst | 51 +++-- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/doc/board/microchip/mpfs_icicle.rst b/doc/board/microchip/mpfs_icicle.rst index 7489761501..c71c2f3cab 100644 --- a/doc/board/microchip/mpfs_icicle.rst +++ b/doc/board/microchip/mpfs_icicle.rst @@ -5,6 +5,7 @@ Microchip PolarFire SoC Icicle Kit RISC-V PolarFire SoC + The PolarFire SoC is the 4+1 64-bit RISC-V SoC from Microchip. The Icicle Kit development platform is based on PolarFire SoC and capable @@ -12,6 +13,7 @@ of running Linux. Mainline support + The support for following drivers are already enabled: 1. NS16550 UART Driver. @@ -23,7 +25,7 @@ Booting from eMMC using HSS --- Building U-Boot +~~~ 1. Add the RISC-V toolchain to your PATH. 2. Setup ARCH & cross compilation environment variable: @@ -36,7 +38,7 @@ Building U-Boot 4. make Flashing - + The current U-Boot port is supported in S-mode only and loaded from DRAM. @@ -48,11 +50,13 @@ boot-flow) and OpenSBI generic platform fw_payload.bin (with u-boot.bin embedded as HSS payload (Custom boot-flow) Microchip boot-flow +~~~ + HSS with OpenSBI (M-Mode) -> U-Boot (S-Mode) -> Linux (S-Mode) Build the HSS (Hart Software Services) - Microchip boot-flow - + + (Note: HSS git repo is at https://github.com/polarfire-soc/hart-software-services) 1. Configure @@ -74,13 +78,15 @@ Alternatively, copy the default config for Microchip boot-flow. The FPGA design will use the hss.hex or hss.bin. FPGA design with HSS programming file -- +' + https://github.com/polarfire-soc/polarfire-soc-documentation/blob/master/boards/mpfs-icicle-kit-es/updating-icicle-kit/updating-icicle-kit-design-and-linux.md The HSS firmware runs from the PolarFire SoC eNVM on reset. Creating the HSS payload - Microchip boot-flow --- +'' + 1. You will be creating a payload from `u-boot-dtb.bin`. Copy this file to the HSS/tools/hss-payload-generator/test directory. 2. Go to hss-payload-generator source directory. @@ -108,11 +114,12 @@ Please refer to HSS documenation to build the HSS firmware for payload. (Note: HSS git repo is at https://github.com/polarfire-soc/hart-software-services/blob/master/tools/hss-payload-generator/README.md) Custom boot-flow - + + HSS without OpenSBI (M-Mode) -> OpenSBI (M-Mode) -> U-Boot (S-Mode) -> Linux (S-Mode) Build OpenSBI -- +' 1. Get the OpenSBI source @@ -132,7 +139,8 @@ Build OpenSBI "/build/platform/generic/firmware/fw_payload.bin" Build the HSS (Hart Software Services)- Custom boot-flow - + + (Note: HSS git repo is at https://github.com/polarfire-soc/hart-software-services) 1. Configure @@ -154,7 +162,8 @@ Alternatively, copy the default custom config for Custom boot-flow. The FPGA design will use the hss.hex or hss.bin. Creating the HSS payload - Custom boot-flow +''' + 1. You will be creating a payload from `fw_payload.bin`. Copy this file to the HSS/tools/hss-payload-generator/test directory. 2. Go to hss-payload-generator source directory. @@ -183,7 +192,8 @@ Please refer to HSS documenation to build the HSS firmware for payload. and also refer the HSS payload generator at https://github.com/polarfire-soc/polarfire-soc-documentation/blob/master/software-development/hss-payloads.md) eMMC - + + Program eMMC with payload binary is explained in the PolarFire SoC documentation. (Note: PolarFire SoC Documentation git repo is at https://github.com/polarfire-soc/polarfire-soc-documentation/blob/master/boards/mpfs-icicle-kit-es/updating-icicle-kit/updating-icicle-kit-design-and-linux.md#eMMC) @@ -195,17 +205,19 @@ line interface, then type 'boot' and enter to boot the newly copied image. sudo dd if= of=/dev/sdX bs=512 GUID type -- +~ + The HSS always picks up HSS payload from a GPT
Re: [PATCH] ata: sunxi: fix debug messages
Hi Dario, On Sun, 24 Jan 2021 at 11:13, Dario Binacchi wrote: > > It is useless and misleading to print the ret variable that is not set > by the dev_read_addr routine. Also, move the '\n' character after the > round bracket that contains the error code. > > Signed-off-by: Dario Binacchi > --- > > drivers/ata/ahci_sunxi.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) Reviewed-by: Simon Glass You could consider using log_debug() (with LOG_CATEGORY defined at the top) and then you can drop the __func__ stuff. Regards, Simon
Re: [PATCH 1/1] cmd: correct long text loadb, loadx, loady
On Fri, 22 Jan 2021 at 11:00, Heinrich Schuchardt wrote: > > The first argument is the load address and not an offset. > > The second argument cannot be entered without the first one. > > Signed-off-by: Heinrich Schuchardt > --- > cmd/load.c | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) > Reviewed-by: Simon Glass
Re: [PATCH v2 1/1] dm: core: describe uclass_root_s
On Sun, 24 Jan 2021 at 13:56, Heinrich Schuchardt wrote: > > make htmldocs creates a warning: > > ./include/asm-generic/global_data.h:443: > warning: Function parameter or member 'uclass_root_s' > not described in 'global_data' > > Correct the member descriptions. > > Cc: Simon Glass > Signed-off-by: Heinrich Schuchardt > --- > v2: > include information provided by Simon > --- > include/asm-generic/global_data.h | 16 > 1 file changed, 12 insertions(+), 4 deletions(-) Reviewed-by: Simon Glass
[PATCH 1/1] doc: fix doc/develop/logging.rst
Sphinx 3 builds fail due to doc/develop/logging.rst producing duplicate labels. Include logging.h only once in the API section and use cross-references for the enums log_level_t and log_category_t. Signed-off-by: Heinrich Schuchardt --- doc/api/index.rst | 1 + doc/api/logging.rst | 6 ++ doc/develop/logging.rst | 13 +++-- 3 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 doc/api/logging.rst diff --git a/doc/api/index.rst b/doc/api/index.rst index cbecd10755..ea02aa5715 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -10,6 +10,7 @@ U-Boot API documentation efi getopt linker_lists + logging pinctrl rng sandbox diff --git a/doc/api/logging.rst b/doc/api/logging.rst new file mode 100644 index 00..1e6cbc4931 --- /dev/null +++ b/doc/api/logging.rst @@ -0,0 +1,6 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Logging API +=== + +.. kernel-doc:: include/log.h diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst index 7fdd1132ef..60c18c5b3a 100644 --- a/doc/develop/logging.rst +++ b/doc/develop/logging.rst @@ -26,8 +26,7 @@ Logging levels There are a number logging levels available. -.. kernel-doc:: include/log.h - :identifiers: log_level_t +See enum :c:type:`log_level_t` Logging category @@ -36,8 +35,7 @@ Logging can come from a wide variety of places within U-Boot. Each log message has a category which is intended to allow messages to be filtered according to their source. -.. kernel-doc:: include/log.h - :identifiers: log_category_t +See enum :c:type:`log_category_t` Enabling logging @@ -67,7 +65,7 @@ to enable building in of all logging statements in a single file. Put it at the top of the file, before any #includes. To actually get U-Boot to output this you need to also set the default logging -level - e.g. set CONFIG_LOG_DEFAULT_LEVEL to 7 (:c:type:`LOGL_DEBUG`) or more. +level - e.g. set CONFIG_LOG_DEFAULT_LEVEL to 7 (:c:data:`LOGL_DEBUG`) or more. Otherwise debug output is suppressed and will not be generated. Using DEBUG @@ -290,8 +288,3 @@ number dropped due to them being generated before the log system was ready. Add a printf() format string pragma so that log statements are checked properly Add a command to delete existing log records. - -Logging API -.. kernel-doc:: include/log.h - :internal: -- 2.29.2
Re: [RESEND 6/7] Revert "fastboot: Add default fastboot_set_reboot_flag implementation"
Hi Lukasz, On 1/23/21 5:08 PM, Lukasz Majewski wrote: Hi Roman, This reverts commit 0ebf9842e56c5b8cb7cb1f990bb452cc14af6225. Current generic implementation of fastboot_set_reboot_flag is somewhat messy and requires some additional configuration option to be enabled besides CMD_BCB, so it reverts that implementtion in order to bring a new cleaner one. Next commit introduces new generic implementation of fastboot_set_reboot_flag. Signed-off-by: Roman Kovalivskyi --- drivers/fastboot/Kconfig | 12 -- drivers/fastboot/Makefile | 1 - drivers/fastboot/fb_bcb_impl.c | 43 -- include/fastboot.h | 9 --- 4 files changed, 65 deletions(-) delete mode 100644 drivers/fastboot/fb_bcb_impl.c diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 4352ba67a713..d4436dfc9173 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -165,18 +165,6 @@ config FASTBOOT_CMD_OEM_FORMAT relies on the env variable partitions to contain the list of partitions as required by the gpt command. -config FASTBOOT_USE_BCB_SET_REBOOT_FLAG - bool "Use BCB by fastboot to set boot reason" - depends on CMD_BCB && !ARCH_MESON && !ARCH_ROCKCHIP && !TARGET_KC1 && \ - !TARGET_SNIPER && !TARGET_AM57XX_EVM && !TARGET_DRA7XX_EVM - default y - help - Fastboot could implement setting of reboot reason in a generic fashion - via BCB commands. BCB commands are able to write reboot reason into - command field of boot control block. In general case it is sufficient - implementation if your platform supports BCB commands and doesn't - require any specific reboot reason handling. - endif # FASTBOOT endmenu diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile index 2b2c390fe4de..048af5aa8234 100644 --- a/drivers/fastboot/Makefile +++ b/drivers/fastboot/Makefile @@ -5,4 +5,3 @@ obj-y += fb_getvar.o obj-y += fb_command.o obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o -obj-$(CONFIG_FASTBOOT_USE_BCB_SET_REBOOT_FLAG) += fb_bcb_impl.o diff --git a/drivers/fastboot/fb_bcb_impl.c b/drivers/fastboot/fb_bcb_impl.c deleted file mode 100644 index 89ec3601b6f6.. --- a/drivers/fastboot/fb_bcb_impl.c +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright 2020 GlobalLogic. - * Roman Kovalivskyi - */ - -#include -#include - -/** - * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader - * - * Set flag which indicates that we should reboot into the bootloader - * following the reboot that fastboot executes after this function. - * - * This function should be overridden in your board file with one - * which sets whatever flag your board specific Android bootloader flow - * requires in order to re-enter the bootloader. - */ -int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason) -{ - char cmd[64]; - - if (reason >= FASTBOOT_REBOOT_REASONS_COUNT) - return -EINVAL; - - snprintf(cmd, sizeof(cmd), "bcb load %d misc", -CONFIG_FASTBOOT_FLASH_MMC_DEV); - - if (run_command(cmd, 0)) - return -ENODEV; - - snprintf(cmd, sizeof(cmd), "bcb set command %s", -fastboot_boot_cmds[reason]); - - if (run_command(cmd, 0)) - return -ENOEXEC; - - if (run_command("bcb store", 0)) - return -EIO; - - return 0; -} diff --git a/include/fastboot.h b/include/fastboot.h index 8e9ee80907df..b86b508e69fd 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -52,15 +52,6 @@ enum fastboot_reboot_reason { FASTBOOT_REBOOT_REASONS_COUNT }; -/** - * BCB boot commands - */ -static const char * const fastboot_boot_cmds[] = { - [FASTBOOT_REBOOT_REASON_BOOTLOADER] = "bootonce-bootloader", - [FASTBOOT_REBOOT_REASON_FASTBOOTD] = "boot-fastboot", - [FASTBOOT_REBOOT_REASON_RECOVERY] = "boot-recovery" -}; - /** * fastboot_response() - Writes a response of the form "$tag$reason". * If this patch is still needed - please rebase it on newest master (after the incoming PR) as it causes build breaks. 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 Could you please share some info on how do you build it (used defconfig, error messages, used compiler, etc.)? I cannot reproduce those issues on my side. I've tried to rebase my patches onto the current master and rebase was done cleanly, there are no conflicts. I've tried building it with rcar3_ulcb_defconfig and build was successful. Used defconfig: rcar3_ulcb_defconfig Used arch: ARM Used compiler: gcc 7.1 for aarch64-linux-gnu Used CFLAGS: -fgnu89-inline
Re: [RFC 1/1] disk: PARTITIONS should depend on HAVE_BLOCK_DEVICE
On Mon, Jan 25, 2021 at 05:28:39PM +0100, Heinrich Schuchardt wrote: > Partitions are only relevant for block devices. > > Signed-off-by: Heinrich Schuchardt > --- > I still need to check if the part command is needed on boards > w/o DISTRO_DEFAULTS. > --- > cmd/Kconfig | 4 ++-- > disk/Kconfig | 1 + > 2 files changed, 3 insertions(+), 2 deletions(-) So, https://gist.github.com/trini/806edc6d37b0e53931a3b8195cbf9da2 shows all of the boards that had been building with this now invalid combination and are discarding a bunch of code. The next step is to look at these and see which of them likely have a use case not been described by these Kconfig choices. -- Tom signature.asc Description: PGP signature
[PATCH 1/1] doc: remove illegal characters
Avoid errors when generating the HTML documentation like: 'ascii' codec can't decode byte 0xc2 Correct capitalization of 'U-Boot'. Signed-off-by: Heinrich Schuchardt --- doc/board/freescale/b4860qds.rst| 2 +- doc/board/microchip/mpfs_icicle.rst | 4 ++-- doc/board/sifive/fu540.rst | 2 +- doc/board/xen/xenguest_arm64.rst| 14 +++--- doc/driver-model/design.rst | 2 +- doc/usage/bootmenu.rst | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/board/freescale/b4860qds.rst b/doc/board/freescale/b4860qds.rst index de14d857b9..efb1422e1c 100644 --- a/doc/board/freescale/b4860qds.rst +++ b/doc/board/freescale/b4860qds.rst @@ -9,7 +9,7 @@ The B4860QDS is a Freescale reference board that hosts the B4860 SoC B4860 Overview -- The B4860 QorIQ Qonverge device is a Freescale high-end, multicore SoC based on -StarCore and Power Architecture® cores. It targets the broadband wireless +StarCore and Power Architecture cores. It targets the broadband wireless infrastructure and builds upon the proven success of the existing multicore DSPs and Power CPUs. It is designed to bolster the rapidly changing and expanding wireless markets, such as 3GLTE (FDD and TDD), LTE-Advanced, and UMTS. diff --git a/doc/board/microchip/mpfs_icicle.rst b/doc/board/microchip/mpfs_icicle.rst index c71c2f3cab..1f9ce13a3c 100644 --- a/doc/board/microchip/mpfs_icicle.rst +++ b/doc/board/microchip/mpfs_icicle.rst @@ -702,9 +702,9 @@ Sample boot log from MPFS Icicle Kit [2.756098] systemd[1]: Created slice User and Session Slice. [ OK ] Created slice User and Session Slice. [2.789065] systemd[1]: Started Dispatch Password Requests to Console Directory Watch. - [ OK ] Started Dispatch Password …ts to Console Directory Watch. + [ OK ] Started Dispatch Password ..ts to Console Directory Watch. [2.828974] systemd[1]: Started Forward Password Requests to Wall Directory Watch. - [ OK ] Started Forward Password R…uests to Wall Directory Watch. + [ OK ] Started Forward Password R..uests to Wall Directory Watch. [2.869009] systemd[1]: Reached target Paths. [ OK ] Reached target Paths. [2.898808] systemd[1]: Reached target Remote File Systems. diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst index 4e4c852ff3..c8091f6490 100644 --- a/doc/board/sifive/fu540.rst +++ b/doc/board/sifive/fu540.rst @@ -5,7 +5,7 @@ HiFive Unleashed FU540-C000 RISC-V SoC - -The FU540-C000 is the world’s first 4+1 64-bit RISC-V SoC from SiFive. +The FU540-C000 is the world's first 4+1 64-bit RISC-V SoC from SiFive. The HiFive Unleashed development platform is based on FU540-C000 and capable of running Linux. diff --git a/doc/board/xen/xenguest_arm64.rst b/doc/board/xen/xenguest_arm64.rst index 1327f88f99..31a5c23dfd 100644 --- a/doc/board/xen/xenguest_arm64.rst +++ b/doc/board/xen/xenguest_arm64.rst @@ -6,17 +6,17 @@ Xen guest ARM64 board This board specification -This board is to be run as a virtual Xen [1] guest with U-boot as its primary +This board is to be run as a virtual Xen [1] guest with U-Boot as its primary bootloader. Xen is a type 1 hypervisor that allows multiple operating systems to run simultaneously on a single physical server. Xen is capable of running virtual machines in both full virtualization and para-virtualization (PV) -modes. Xen runs virtual machines, which are called “domains”. +modes. Xen runs virtual machines, which are called "domains". Paravirtualized drivers are a special type of device drivers that are used in a guest system in the Xen domain and perform I/O operations using a special interface provided by the virtualization system and the host system. -Xen support for U-boot is implemented by introducing a new Xen guest ARM64 +Xen support for U-Boot is implemented by introducing a new Xen guest ARM64 board and porting essential drivers from MiniOS [3] as well as some of the work previously done by NXP [4]: @@ -39,7 +39,7 @@ previously done by NXP [4]: Board limitations - -1. U-boot runs without MMU enabled at the early stages. +1. U-Boot runs without MMU enabled at the early stages. According to Xen on ARM ABI (xen/include/public/arch-arm.h): all memory which is shared with other entities in the system (including the hypervisor and other guests) must reside in memory which is mapped as Normal Inner @@ -54,14 +54,14 @@ Board limitations 2. No serial console until MMU is up. Because data cache maintenance is required until the MMU setup the early/debug serial console is not implemented. Therefore, we do not have - usual prints like U-boot’s banner etc. until the serial driver is + usual prints like U-Boot's banner etc. until the serial driver is initialized. 3. Single RAM bank supported. If a Xen guest is given much memory it is possible that Xen
[PATCH 1/1] .gitlab-ci: install doc/sphinx/requirements.txt
Install all requirements according to doc/sphinx/requirements.txt in the virtual environment used for testing 'make htmldocs'. Signed-off-by: Heinrich Schuchardt --- .azure-pipelines.yml | 6 +- .gitlab-ci.yml | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 620696c22e..7a3eb78a5e 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -67,7 +67,11 @@ jobs: image: $(ci_runner_image) options: $(container_option) steps: - - script: make htmldocs + - script: | + virtualenv -p /usr/bin/python3 /tmp/venvhtml + . /tmp/venvhtml/bin/activate + pip install -r doc/sphinx/requirements.txt + make htmldocs - job: todo displayName: 'Search for TODO within source tree' diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4b0680887b..2cdcd864c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -122,6 +122,9 @@ htmldocs: tags: [ 'all' ] stage: testsuites script: +- virtualenv -p /usr/bin/python3 /tmp/venvhtml +- . /tmp/venvhtml/bin/activate +- pip install -r doc/sphinx/requirements.txt - make htmldocs # some statistics about the code base -- 2.29.2
Re: [PATCH 1/1] doc: remove illegal characters
Hello Heinrich! Does this change mean that UTF-8 is now disallowed in U-Boot? On Monday 25 January 2021 22:48:56 Heinrich Schuchardt wrote: > Avoid errors when generating the HTML documentation like: > > 'ascii' codec can't decode byte 0xc2 This sounds like an incorrect configuration of tool which is generating HTML documentation. > Correct capitalization of 'U-Boot'. > > Signed-off-by: Heinrich Schuchardt > --- > doc/board/freescale/b4860qds.rst| 2 +- > doc/board/microchip/mpfs_icicle.rst | 4 ++-- > doc/board/sifive/fu540.rst | 2 +- > doc/board/xen/xenguest_arm64.rst| 14 +++--- > doc/driver-model/design.rst | 2 +- > doc/usage/bootmenu.rst | 2 +- > 6 files changed, 13 insertions(+), 13 deletions(-) > > diff --git a/doc/board/freescale/b4860qds.rst > b/doc/board/freescale/b4860qds.rst > index de14d857b9..efb1422e1c 100644 > --- a/doc/board/freescale/b4860qds.rst > +++ b/doc/board/freescale/b4860qds.rst > @@ -9,7 +9,7 @@ The B4860QDS is a Freescale reference board that hosts the > B4860 SoC > B4860 Overview > -- > The B4860 QorIQ Qonverge device is a Freescale high-end, multicore SoC based > on > -StarCore and Power Architecture® cores. It targets the broadband wireless > +StarCore and Power Architecture cores. It targets the broadband wireless > infrastructure and builds upon the proven success of the existing multicore > DSPs and Power CPUs. It is designed to bolster the rapidly changing and > expanding wireless markets, such as 3GLTE (FDD and TDD), LTE-Advanced, and > UMTS. > diff --git a/doc/board/microchip/mpfs_icicle.rst > b/doc/board/microchip/mpfs_icicle.rst > index c71c2f3cab..1f9ce13a3c 100644 > --- a/doc/board/microchip/mpfs_icicle.rst > +++ b/doc/board/microchip/mpfs_icicle.rst > @@ -702,9 +702,9 @@ Sample boot log from MPFS Icicle Kit > [2.756098] systemd[1]: Created slice User and Session Slice. > [ OK ] Created slice User and Session Slice. > [2.789065] systemd[1]: Started Dispatch Password Requests to Console > Directory Watch. > - [ OK ] Started Dispatch Password …ts to Console Directory Watch. > + [ OK ] Started Dispatch Password ..ts to Console Directory Watch. > [2.828974] systemd[1]: Started Forward Password Requests to Wall > Directory Watch. > - [ OK ] Started Forward Password R…uests to Wall Directory Watch. > + [ OK ] Started Forward Password R..uests to Wall Directory Watch. > [2.869009] systemd[1]: Reached target Paths. > [ OK ] Reached target Paths. > [2.898808] systemd[1]: Reached target Remote File Systems. > diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst > index 4e4c852ff3..c8091f6490 100644 > --- a/doc/board/sifive/fu540.rst > +++ b/doc/board/sifive/fu540.rst > @@ -5,7 +5,7 @@ HiFive Unleashed > > FU540-C000 RISC-V SoC > - > -The FU540-C000 is the world’s first 4+1 64-bit RISC-V SoC from SiFive. > +The FU540-C000 is the world's first 4+1 64-bit RISC-V SoC from SiFive. > > The HiFive Unleashed development platform is based on FU540-C000 and capable > of running Linux. > diff --git a/doc/board/xen/xenguest_arm64.rst > b/doc/board/xen/xenguest_arm64.rst > index 1327f88f99..31a5c23dfd 100644 > --- a/doc/board/xen/xenguest_arm64.rst > +++ b/doc/board/xen/xenguest_arm64.rst > @@ -6,17 +6,17 @@ Xen guest ARM64 board > This board specification > > > -This board is to be run as a virtual Xen [1] guest with U-boot as its primary > +This board is to be run as a virtual Xen [1] guest with U-Boot as its primary > bootloader. Xen is a type 1 hypervisor that allows multiple operating systems > to run simultaneously on a single physical server. Xen is capable of running > virtual machines in both full virtualization and para-virtualization (PV) > -modes. Xen runs virtual machines, which are called “domains”. > +modes. Xen runs virtual machines, which are called "domains". > > Paravirtualized drivers are a special type of device drivers that are used in > a guest system in the Xen domain and perform I/O operations using a special > interface provided by the virtualization system and the host system. > > -Xen support for U-boot is implemented by introducing a new Xen guest ARM64 > +Xen support for U-Boot is implemented by introducing a new Xen guest ARM64 > board and porting essential drivers from MiniOS [3] as well as some of the > work > previously done by NXP [4]: > > @@ -39,7 +39,7 @@ previously done by NXP [4]: > Board limitations > - > > -1. U-boot runs without MMU enabled at the early stages. > +1. U-Boot runs without MMU enabled at the early stages. > According to Xen on ARM ABI (xen/include/public/arch-arm.h): all memory > which is shared with other entities in the system (including the > hypervisor > and other guests) must reside in memory which is mapped as Normal Inner > @@ -54,14 +54,14 @@ Board limitat
Re: [PATCH v3 01/20] mmc: sdhci: Add helper functions for UHS modes
On 1/21/21 9:40 PM, Aswath Govindraju wrote: > From: Faiz Abbas > > Add a set_voltage() function which handles the switch from 3.3V to 1.8V > for SD card UHS modes. > > Signed-off-by: Faiz Abbas > Signed-off-by: Aswath Govindraju > --- > drivers/mmc/sdhci.c | 80 + > include/sdhci.h | 1 + > 2 files changed, 81 insertions(+) > > diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c > index 06289343124e..e7e3e22d1a7e 100644 > --- a/drivers/mmc/sdhci.c > +++ b/drivers/mmc/sdhci.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > > static void sdhci_reset(struct sdhci_host *host, u8 mask) > { > @@ -509,6 +510,85 @@ void sdhci_set_uhs_timing(struct sdhci_host *host) > sdhci_writew(host, reg, SDHCI_HOST_CONTROL2); > } > > +#if CONFIG_IS_ENABLED(MMC_IO_VOLTAGE) > +static void sdhci_set_voltage(struct sdhci_host *host) > +{ > + struct mmc *mmc = (struct mmc *)host->mmc; > + u32 ctrl; > + int ret; > + > + ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); > + > + switch (mmc->signal_voltage) { > + case MMC_SIGNAL_VOLTAGE_330: > +#if CONFIG_IS_ENABLED(DM_REGULATOR) > + if (mmc->vqmmc_supply) { > + ret = regulator_set_enable(mmc->vqmmc_supply, false); > + if (ret) { > + pr_err("failed to disable vqmmc-supply: %d\n", > ret); > + return; > + } > + > + ret = regulator_set_value(mmc->vqmmc_supply, 330); > + if (ret) { > + pr_err("failed to set vqmmc-voltage to 3.3V: > %d\n", ret); > + return; > + } > + > + ret = regulator_set_enable(mmc->vqmmc_supply, true); > + if (ret) { > + pr_err("failed to enable vqmmc-supply: %d\n", > ret); > + return; > + } > + } > +#endif > + mdelay(5); Could you add just comment for mdelay(5)? Maybe it needs to be stable, right? Best Regards, Jaehoon Chung > + if (IS_SD(mmc)) { > + ctrl &= ~SDHCI_CTRL_VDD_180; > + sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); > + } > + break; > + case MMC_SIGNAL_VOLTAGE_180: > +#if CONFIG_IS_ENABLED(DM_REGULATOR) > + if (mmc->vqmmc_supply) { > + regulator_set_enable(mmc->vqmmc_supply, false); > + if (ret) { > + pr_err("failed to disable vqmmc-supply: %d\n", > ret); > + return; > + } > + > + regulator_set_value(mmc->vqmmc_supply, 180); > + if (ret) { > + pr_err("failed to set vqmmc-voltage to 1.8V: > %d\n", ret); > + return; > + } > + > + regulator_set_enable(mmc->vqmmc_supply, true); > + if (ret) { > + pr_err("failed to enable vqmmc-supply: %d\n", > ret); > + return; > + } > + } > +#endif > + if (IS_SD(mmc)) { > + ctrl |= SDHCI_CTRL_VDD_180; > + sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); > + } > + break; > + default: > + /* No signal voltage switch required */ > + return; > + } > +} > +#else > +static void sdhci_set_voltage(struct sdhci_host *host) { } > +#endif > +void sdhci_set_control_reg(struct sdhci_host *host) > +{ > + sdhci_set_voltage(host); > + sdhci_set_uhs_timing(host); > +} > + > #ifdef CONFIG_DM_MMC > static int sdhci_set_ios(struct udevice *dev) > { > diff --git a/include/sdhci.h b/include/sdhci.h > index 3e5a64981857..0f820c6d2669 100644 > --- a/include/sdhci.h > +++ b/include/sdhci.h > @@ -491,6 +491,7 @@ void sdhci_set_uhs_timing(struct sdhci_host *host); > /* Export the operations to drivers */ > int sdhci_probe(struct udevice *dev); > int sdhci_set_clock(struct mmc *mmc, unsigned int clock); > +void sdhci_set_control_reg(struct sdhci_host *host); > extern const struct dm_mmc_ops sdhci_ops; > #else > #endif >
Re: [RFC 1/1] disk: PARTITIONS should depend on HAVE_BLOCK_DEVICE
On 1/25/21 10:02 PM, Tom Rini wrote: On Mon, Jan 25, 2021 at 05:28:39PM +0100, Heinrich Schuchardt wrote: Partitions are only relevant for block devices. Signed-off-by: Heinrich Schuchardt --- I still need to check if the part command is needed on boards w/o DISTRO_DEFAULTS. --- cmd/Kconfig | 4 ++-- disk/Kconfig | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) So, https://gist.github.com/trini/806edc6d37b0e53931a3b8195cbf9da2 shows all of the boards that had been building with this now invalid combination and are discarding a bunch of code. The next step is to look at these and see which of them likely have a use case not been described by these Kconfig choices. With the patch for boards not using distro_defaults the following configuration items are dropped: CONFIG_CMD_PART=y CONFIG_PARTITION_UUIDS=y I will try to minimize the configuration changes produced by the next version of the patch. Best regards Heinrich
Re: [PATCH v3 02/20] mmc: am654_sdhci: Unconditionally switch off DLL in the beginning of ios_post()
On 1/21/21 9:40 PM, Aswath Govindraju wrote: > From: Faiz Abbas > > There are some speed modes that work without switching the dll on. > Unconditionally switch off the DLL before setting clock frequency to > support this case. The software will automatically enable DLL for speed > modes that require it. This also means the dll_on priv data member is no > longer required. > > Signed-off-by: Faiz Abbas > Signed-off-by: Aswath Govindraju Reviewed-by: Jaehoon Chung Best Regards, Jaehoon Chung > --- > drivers/mmc/am654_sdhci.c | 10 +- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c > index baa935e0d5b0..33f658fba719 100644 > --- a/drivers/mmc/am654_sdhci.c > +++ b/drivers/mmc/am654_sdhci.c > @@ -84,7 +84,6 @@ struct am654_sdhci_plat { > #define IOMUX_PRESENT(1 << 1) > #define FREQSEL_2_BIT(1 << 2) > #define STRBSEL_4_BIT(1 << 3) > - bool dll_on; > }; > > struct timing_data { > @@ -141,12 +140,7 @@ static int am654_sdhci_set_ios_post(struct sdhci_host > *host) > val &= ~SDHCI_CLOCK_CARD_EN; > sdhci_writew(host, val, SDHCI_CLOCK_CONTROL); > > - /* power off phy */ > - if (plat->dll_on) { > - regmap_update_bits(plat->base, PHY_CTRL1, ENDLL_MASK, 0); > - > - plat->dll_on = false; > - } > + regmap_update_bits(plat->base, PHY_CTRL1, ENDLL_MASK, 0); > > /* restart clock */ > sdhci_set_clock(host->mmc, speed); > @@ -212,8 +206,6 @@ static int am654_sdhci_set_ios_post(struct sdhci_host > *host) >val & DLLRDY_MASK, 1000, 100); > if (ret) > return ret; > - > - plat->dll_on = true; > } > > return 0; >
Re: [PATCH v3 03/20] mmc: am654_sdhci: Convert flag fields to BIT macro
On 1/21/21 9:40 PM, Aswath Govindraju wrote: > From: Faiz Abbas > > Convert the flags field defines to use the BIT() macro. > > Signed-off-by: Faiz Abbas > Signed-off-by: Aswath Govindraju Reviewed-by: Jaehoon Chung Best Regards, Jaehoon Chung > --- > drivers/mmc/am654_sdhci.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c > index 33f658fba719..e0136dff9711 100644 > --- a/drivers/mmc/am654_sdhci.c > +++ b/drivers/mmc/am654_sdhci.c > @@ -80,10 +80,10 @@ struct am654_sdhci_plat { > u32 drv_strength; > u32 strb_sel; > u32 flags; > -#define DLL_PRESENT (1 << 0) > -#define IOMUX_PRESENT(1 << 1) > -#define FREQSEL_2_BIT(1 << 2) > -#define STRBSEL_4_BIT(1 << 3) > +#define DLL_PRESENT BIT(0) > +#define IOMUX_PRESENTBIT(1) > +#define FREQSEL_2_BITBIT(2) > +#define STRBSEL_4_BITBIT(3) > }; > > struct timing_data { >
Re: [PATCH v3 05/20] mmc: am654_sdhci: Add support for AM65x SR2.0
On 1/21/21 9:40 PM, Aswath Govindraju wrote: > From: Faiz Abbas > > Add Support for AM65x PG2.0. Use the SoC bus framework to fixup > the platform data and do DLL calibration if the revision is 1.0 Is there no method to get the revision from H/W? If not, looks good tome. > > Signed-off-by: Faiz Abbas > Signed-off-by: Aswath Govindraju Reviewed-by: Jaehoon Chung Best Regards, Jaehoon Chung > --- > drivers/mmc/am654_sdhci.c | 30 ++ > 1 file changed, 30 insertions(+) > > diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c > index 1e0654183811..5790fa3d0dbf 100644 > --- a/drivers/mmc/am654_sdhci.c > +++ b/drivers/mmc/am654_sdhci.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -292,6 +293,11 @@ const struct sdhci_ops am654_sdhci_ops = { > }; > > const struct am654_driver_data am654_drv_data = { > + .ops = &am654_sdhci_ops, > + .flags = DLL_PRESENT | IOMUX_PRESENT | FREQSEL_2_BIT | STRBSEL_4_BIT, > +}; > + > +const struct am654_driver_data am654_sr1_drv_data = { > .ops = &am654_sdhci_ops, > .flags = IOMUX_PRESENT | FREQSEL_2_BIT | DLL_PRESENT | DLL_CALIB | >STRBSEL_4_BIT, > @@ -326,6 +332,11 @@ const struct am654_driver_data j721e_4bit_drv_data = { > .flags = IOMUX_PRESENT, > }; > > +const struct soc_attr am654_sdhci_soc_attr[] = { > + { .family = "AM65X", .revision = "SR1.0", .data = &am654_sr1_drv_data}, > + {/* sentinel */} > +}; > + > static int sdhci_am654_get_otap_delay(struct udevice *dev, > struct mmc_config *cfg) > { > @@ -365,6 +376,8 @@ static int am654_sdhci_probe(struct udevice *dev) > struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); > struct sdhci_host *host = dev_get_priv(dev); > struct mmc_config *cfg = &plat->cfg; > + const struct soc_attr *soc; > + const struct am654_driver_data *soc_drv_data; > struct clk clk; > unsigned long clock; > int ret; > @@ -394,6 +407,14 @@ static int am654_sdhci_probe(struct udevice *dev) > return ret; > > host->ops = drv_data->ops; > + > + /* Update ops based on SoC revision */ > + soc = soc_device_match(am654_sdhci_soc_attr); > + if (soc && soc->data) { > + soc_drv_data = soc->data; > + host->ops = soc_drv_data->ops; > + } > + > host->mmc->priv = host; > upriv->mmc = host->mmc; > > @@ -458,9 +479,18 @@ static int am654_sdhci_bind(struct udevice *dev) > struct am654_driver_data *drv_data = > (struct am654_driver_data *)dev_get_driver_data(dev); > struct am654_sdhci_plat *plat = dev_get_plat(dev); > + const struct soc_attr *soc; > + const struct am654_driver_data *soc_drv_data; > > plat->flags = drv_data->flags; > > + /* Update flags based on SoC revision */ > + soc = soc_device_match(am654_sdhci_soc_attr); > + if (soc && soc->data) { > + soc_drv_data = soc->data; > + plat->flags = soc_drv_data->flags; > + } > + > return sdhci_bind(dev, &plat->mmc, &plat->cfg); > } > >
Re: [PATCH v3 04/20] mmc: am654_sdhci: Add flag for PHY calibration
On 1/21/21 9:40 PM, Aswath Govindraju wrote: > From: Faiz Abbas > > Not all controllers need calibration for the PHY DLL. Add a DLL_CALIB > flag to indicate the same. > > Also move the write of trm_icp and driver strength to the set_clock() > function to match the kernel configuration flow. > > Signed-off-by: Faiz Abbas > Signed-off-by: Aswath Govindraju Reviewed-by: Jaehoon Chung Best Regards, Jaehoon Chung > --- > drivers/mmc/am654_sdhci.c | 26 ++ > 1 file changed, 14 insertions(+), 12 deletions(-) > > diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c > index e0136dff9711..1e0654183811 100644 > --- a/drivers/mmc/am654_sdhci.c > +++ b/drivers/mmc/am654_sdhci.c > @@ -84,6 +84,7 @@ struct am654_sdhci_plat { > #define IOMUX_PRESENTBIT(1) > #define FREQSEL_2_BITBIT(2) > #define STRBSEL_4_BITBIT(3) > +#define DLL_CALIBBIT(4) > }; > > struct timing_data { > @@ -195,6 +196,15 @@ static int am654_sdhci_set_ios_post(struct sdhci_host > *host) > freqsel << FREQSEL_SHIFT); > } > > + /* Configure DLL TRIM */ > + mask = DLL_TRIM_ICP_MASK; > + val = plat->trm_icp << DLL_TRIM_ICP_SHIFT; > + > + /* Configure DLL driver strength */ > + mask |= DR_TY_MASK; > + val |= plat->drv_strength << DR_TY_SHIFT; > + regmap_update_bits(plat->base, PHY_CTRL1, mask, val); > + > /* Enable DLL */ > regmap_update_bits(plat->base, PHY_CTRL1, ENDLL_MASK, > 0x1 << ENDLL_SHIFT); > @@ -221,7 +231,7 @@ int am654_sdhci_init(struct am654_sdhci_plat *plat) > mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK; > regmap_update_bits(plat->base, PHY_CTRL4, mask, 0x0); > > - if (plat->flags & DLL_PRESENT) { > + if (plat->flags & DLL_CALIB) { > regmap_read(plat->base, PHY_STAT1, &val); > if (~val & CALDONE_MASK) { > /* Calibrate IO lines */ > @@ -233,15 +243,6 @@ int am654_sdhci_init(struct am654_sdhci_plat *plat) > if (ret) > return ret; > } > - > - /* Configure DLL TRIM */ > - mask = DLL_TRIM_ICP_MASK; > - val = plat->trm_icp << DLL_TRIM_ICP_SHIFT; > - > - /* Configure DLL driver strength */ > - mask |= DR_TY_MASK; > - val |= plat->drv_strength << DR_TY_SHIFT; > - regmap_update_bits(plat->base, PHY_CTRL1, mask, val); > } > > /* Enable pins by setting IO mux to 0 */ > @@ -292,12 +293,13 @@ const struct sdhci_ops am654_sdhci_ops = { > > const struct am654_driver_data am654_drv_data = { > .ops = &am654_sdhci_ops, > - .flags = IOMUX_PRESENT | FREQSEL_2_BIT | DLL_PRESENT | STRBSEL_4_BIT, > + .flags = IOMUX_PRESENT | FREQSEL_2_BIT | DLL_PRESENT | DLL_CALIB | > + STRBSEL_4_BIT, > }; > > const struct am654_driver_data j721e_8bit_drv_data = { > .ops = &am654_sdhci_ops, > - .flags = DLL_PRESENT, > + .flags = DLL_PRESENT | DLL_CALIB, > }; > > static int j721e_4bit_sdhci_set_ios_post(struct sdhci_host *host) >
Re: [PATCH v3 06/20] mmc: am654_sdhci: Add support for input tap delay
On 1/21/21 9:40 PM, Aswath Govindraju wrote: > From: Faiz Abbas > > DLL need only be enabled for speed modes and clock frequencies at or > above 50 MHz. For speed modes that don't enable the DLL, we need to > configure a static input delay value. This involves reading an optional > itap-del-sel-* value from the device tree and configuring it for the > appropriate speed mode. > > Therefore, move all dll configurations to their own functions and gate it > with 50 MHz speed and a minimum mode. If both these conditions are not > satisfied then configure delay chain modes. > > Signed-off-by: Faiz Abbas > Signed-off-by: Aswath Govindraju Reviewed-by: Jaehoon Chung Best Regards, Jaehoon Chung > --- > drivers/mmc/am654_sdhci.c | 241 +- > 1 file changed, 161 insertions(+), 80 deletions(-) > > diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c > index 5790fa3d0dbf..b82558254ebb 100644 > --- a/drivers/mmc/am654_sdhci.c > +++ b/drivers/mmc/am654_sdhci.c > @@ -62,6 +62,16 @@ > #define CALDONE_MASK BIT(CALDONE_SHIFT) > #define RETRIM_SHIFT 17 > #define RETRIM_MASK BIT(RETRIM_SHIFT) > +#define SELDLYTXCLK_SHIFT17 > +#define SELDLYTXCLK_MASK BIT(SELDLYTXCLK_SHIFT) > +#define SELDLYRXCLK_SHIFT16 > +#define SELDLYRXCLK_MASK BIT(SELDLYRXCLK_SHIFT) > +#define ITAPDLYSEL_SHIFT 0 > +#define ITAPDLYSEL_MASK GENMASK(4, 0) > +#define ITAPDLYENA_SHIFT 8 > +#define ITAPDLYENA_MASK BIT(ITAPDLYENA_SHIFT) > +#define ITAPCHGWIN_SHIFT 9 > +#define ITAPCHGWIN_MASK BIT(ITAPCHGWIN_SHIFT) > > #define DRIVER_STRENGTH_50_OHM 0x0 > #define DRIVER_STRENGTH_33_OHM 0x1 > @@ -70,6 +80,7 @@ > #define DRIVER_STRENGTH_40_OHM 0x4 > > #define AM654_SDHCI_MIN_FREQ 40 > +#define CLOCK_TOO_SLOW_HZ5000 > > struct am654_sdhci_plat { > struct mmc_config cfg; > @@ -77,6 +88,7 @@ struct am654_sdhci_plat { > struct regmap *base; > bool non_removable; > u32 otap_del_sel[MMC_MODES_END]; > + u32 itap_del_sel[MMC_MODES_END]; > u32 trm_icp; > u32 drv_strength; > u32 strb_sel; > @@ -89,22 +101,45 @@ struct am654_sdhci_plat { > }; > > struct timing_data { > - const char *binding; > + const char *otap_binding; > + const char *itap_binding; > u32 capability; > }; > > static const struct timing_data td[] = { > - [MMC_LEGACY] = {"ti,otap-del-sel-legacy", 0}, > - [MMC_HS] = {"ti,otap-del-sel-mmc-hs", MMC_CAP(MMC_HS)}, > - [SD_HS] = {"ti,otap-del-sel-sd-hs", MMC_CAP(SD_HS)}, > - [UHS_SDR12] = {"ti,otap-del-sel-sdr12", MMC_CAP(UHS_SDR12)}, > - [UHS_SDR25] = {"ti,otap-del-sel-sdr25", MMC_CAP(UHS_SDR25)}, > - [UHS_SDR50] = {"ti,otap-del-sel-sdr50", MMC_CAP(UHS_SDR50)}, > - [UHS_SDR104] = {"ti,otap-del-sel-sdr104", MMC_CAP(UHS_SDR104)}, > - [UHS_DDR50] = {"ti,otap-del-sel-ddr50", MMC_CAP(UHS_DDR50)}, > - [MMC_DDR_52] = {"ti,otap-del-sel-ddr52", MMC_CAP(MMC_DDR_52)}, > - [MMC_HS_200] = {"ti,otap-del-sel-hs200", MMC_CAP(MMC_HS_200)}, > - [MMC_HS_400] = {"ti,otap-del-sel-hs400", MMC_CAP(MMC_HS_400)}, > + [MMC_LEGACY]= {"ti,otap-del-sel-legacy", > +"ti,itap-del-sel-legacy", > +0}, > + [MMC_HS]= {"ti,otap-del-sel-mmc-hs", > +"ti,itap-del-sel-mms-hs", > +MMC_CAP(MMC_HS)}, > + [SD_HS] = {"ti,otap-del-sel-sd-hs", > +"ti,itap-del-sel-sd-hs", > +MMC_CAP(SD_HS)}, > + [UHS_SDR12] = {"ti,otap-del-sel-sdr12", > +"ti,itap-del-sel-sdr12", > +MMC_CAP(UHS_SDR12)}, > + [UHS_SDR25] = {"ti,otap-del-sel-sdr25", > +"ti,itap-del-sel-sdr25", > +MMC_CAP(UHS_SDR25)}, > + [UHS_SDR50] = {"ti,otap-del-sel-sdr50", > +NULL, > +MMC_CAP(UHS_SDR50)}, > + [UHS_SDR104]= {"ti,otap-del-sel-sdr104", > +NULL, > +MMC_CAP(UHS_SDR104)}, > + [UHS_DDR50] = {"ti,otap-del-sel-ddr50", > +NULL, > +MMC_CAP(UHS_DDR50)}, > + [MMC_DDR_52]= {"ti,otap-del-sel-ddr52", > +"ti,itap-del-sel-ddr52", > +MMC_CAP(MMC_DDR_52)}, > + [MMC_HS_200]= {"ti,otap-del-sel-hs200", > +NULL, > +MMC_CAP(MMC_HS_200)}, > + [MMC_HS_400]= {"ti,otap-del-sel-hs400", > +NULL, > +MMC_CAP(MMC_HS_400)}, > }; > > struct am654_driver_data { > @@ -127,12 +162,99 @@ static void am654_sdhci_set_control_reg(struct > sdhci_host *host) > sdhci_set_uhs_timing(host); > } > > +static int am654_sdhci_setup_dll(struct am654_sdhci_plat *plat
Re: [PATCH v3 07/20] mmc: am654_sdhci: Add support for writing to clkbuf_sel
On 1/21/21 9:40 PM, Aswath Govindraju wrote: > From: Faiz Abbas > > Add support for writing new clock buffer select property for both > the am654x and j721e 4 bit IPs > > Signed-off-by: Faiz Abbas > Signed-off-by: Aswath Govindraju Reviewed-by: Jaehoon Chung Best Regards, Jaehoon Chung > --- > drivers/mmc/am654_sdhci.c | 11 +++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c > index b82558254ebb..e86ef1a8b218 100644 > --- a/drivers/mmc/am654_sdhci.c > +++ b/drivers/mmc/am654_sdhci.c > @@ -48,6 +48,8 @@ > #define SEL100_MASK BIT(SEL100_SHIFT) > #define FREQSEL_SHIFT8 > #define FREQSEL_MASK GENMASK(10, 8) > +#define CLKBUFSEL_SHIFT 0 > +#define CLKBUFSEL_MASK GENMASK(2, 0) > #define DLL_TRIM_ICP_SHIFT 4 > #define DLL_TRIM_ICP_MASKGENMASK(7, 4) > #define DR_TY_SHIFT 20 > @@ -92,6 +94,7 @@ struct am654_sdhci_plat { > u32 trm_icp; > u32 drv_strength; > u32 strb_sel; > + u32 clkbuf_sel; > u32 flags; > #define DLL_PRESENT BIT(0) > #define IOMUX_PRESENTBIT(1) > @@ -295,6 +298,9 @@ static int am654_sdhci_set_ios_post(struct sdhci_host > *host) > am654_sdhci_setup_delay_chain(plat, mode); > } > > + regmap_update_bits(plat->base, PHY_CTRL5, CLKBUFSEL_MASK, > +plat->clkbuf_sel); > + > return 0; > } > > @@ -395,6 +401,9 @@ static int j721e_4bit_sdhci_set_ios_post(struct > sdhci_host *host) > val = (1 << OTAPDLYENA_SHIFT) | (otap_del_sel << OTAPDLYSEL_SHIFT); > regmap_update_bits(plat->base, PHY_CTRL4, mask, val); > > + regmap_update_bits(plat->base, PHY_CTRL5, CLKBUFSEL_MASK, > +plat->clkbuf_sel); > + > return 0; > } > > @@ -548,6 +557,8 @@ static int am654_sdhci_of_to_plat(struct udevice *dev) > } > } > > + dev_read_u32(dev, "ti,clkbuf-sel", &plat->clkbuf_sel); > + > ret = mmc_of_parse(dev, cfg); > if (ret) > return ret; >