From patchwork Fri Oct 30 14:07:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 1391056 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN3zc1vKgz9sSG for ; Sat, 31 Oct 2020 01:07:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8CCD782557; Fri, 30 Oct 2020 15:07:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 722E282555; Fri, 30 Oct 2020 15:07:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, KHOP_HELO_FCRDNS,SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by phobos.denx.de (Postfix) with ESMTP id 4CE1C82555 for ; Fri, 30 Oct 2020 15:07:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=biju.das.jz@bp.renesas.com X-IronPort-AV: E=Sophos;i="5.77,433,1596466800"; d="scan'208";a="61272938" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 30 Oct 2020 23:07:28 +0900 Received: from localhost.localdomain (unknown [172.29.51.5]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id C96814006CDA; Fri, 30 Oct 2020 23:07:26 +0900 (JST) From: Biju Das To: Simon Glass Cc: Biju Das , Dave Gerlach , Lad Prabhakar , Tom Rini , u-boot@lists.denx.de, Marek Vasut , Nobuhiro Iwamatsu , Chris Paterson Subject: [PATCH] dm: soc: Add SoC id for attribute matching Date: Fri, 30 Oct 2020 14:07:24 +0000 Message-Id: <20201030140724.12773-1-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Add SoC identification string for attribute matching. Also changed the comments from "an SOC" to "a SoC". Signed-off-by: Biju Das Reviewed-by: Lad Prabhakar --- drivers/soc/soc-uclass.c | 19 ++++++++++++++++++- drivers/soc/soc_sandbox.c | 8 ++++++++ include/soc.h | 39 +++++++++++++++++++++++++++++++++------ test/dm/soc.c | 8 ++++++++ 4 files changed, 67 insertions(+), 7 deletions(-) diff --git a/drivers/soc/soc-uclass.c b/drivers/soc/soc-uclass.c index c32d647864..a3f8be841b 100644 --- a/drivers/soc/soc-uclass.c +++ b/drivers/soc/soc-uclass.c @@ -46,6 +46,16 @@ int soc_get_revision(struct udevice *dev, char *buf, int size) return ops->get_revision(dev, buf, size); } +int soc_get_soc_id(struct udevice *dev, char *buf, int size) +{ + struct soc_ops *ops = soc_get_ops(dev); + + if (!ops->get_soc_id) + return -ENOSYS; + + return ops->get_soc_id(dev, buf, size); +} + const struct soc_attr * soc_device_match(const struct soc_attr *matches) { @@ -61,7 +71,7 @@ soc_device_match(const struct soc_attr *matches) while (1) { if (!(matches->machine || matches->family || - matches->revision)) + matches->revision || matches->soc_id)) break; match = true; @@ -87,6 +97,13 @@ soc_device_match(const struct soc_attr *matches) } } + if (matches->soc_id) { + if (!soc_get_soc_id(soc, str, SOC_MAX_STR_SIZE)) { + if (strcmp(matches->soc_id, str)) + match = false; + } + } + if (match) return matches; diff --git a/drivers/soc/soc_sandbox.c b/drivers/soc/soc_sandbox.c index 5c82ad84fc..1a81d3562a 100644 --- a/drivers/soc/soc_sandbox.c +++ b/drivers/soc/soc_sandbox.c @@ -31,10 +31,18 @@ int soc_sandbox_get_revision(struct udevice *dev, char *buf, int size) return 0; } +int soc_sandbox_get_soc_id(struct udevice *dev, char *buf, int size) +{ + snprintf(buf, size, "r8a774a1"); + + return 0; +} + static const struct soc_ops soc_sandbox_ops = { .get_family = soc_sandbox_get_family, .get_revision = soc_sandbox_get_revision, .get_machine = soc_sandbox_get_machine, + .get_soc_id = soc_sandbox_get_soc_id, }; int soc_sandbox_probe(struct udevice *dev) diff --git a/include/soc.h b/include/soc.h index a55eb1b572..ae7b36846f 100644 --- a/include/soc.h +++ b/include/soc.h @@ -20,18 +20,20 @@ * variants. Example: am33 * @machine - Name of a specific SoC. Example: am3352 * @revision - Name of a specific SoC revision. Example: SR1.1 + * @soc_id - SoC identification String. Example: r8a774a1 * @data - A pointer to user data for the SoC variant */ struct soc_attr { const char *family; const char *machine; const char *revision; + const char *soc_id; const void *data; }; struct soc_ops { /** - * get_machine() - Get machine name of an SOC + * get_machine() - Get machine name of a SoC * * @dev: Device to check (UCLASS_SOC) * @buf: Buffer to place string @@ -41,7 +43,7 @@ struct soc_ops { int (*get_machine)(struct udevice *dev, char *buf, int size); /** - * get_revision() - Get revision name of a SOC + * get_revision() - Get revision name of a SoC * * @dev: Device to check (UCLASS_SOC) * @buf: Buffer to place string @@ -51,7 +53,7 @@ struct soc_ops { int (*get_revision)(struct udevice *dev, char *buf, int size); /** - * get_family() - Get family name of an SOC + * get_family() - Get family name of a SoC * * @dev: Device to check (UCLASS_SOC) * @buf: Buffer to place string @@ -59,6 +61,16 @@ struct soc_ops { * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ int (*get_family)(struct udevice *dev, char *buf, int size); + + /** + * get_soc_id() - Get SoC identification name of a SoC + * + * @dev: Device to check (UCLASS_SOC) + * @buf: Buffer to place string + * @size: Size of string space + * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error + */ + int (*get_soc_id)(struct udevice *dev, char *buf, int size); }; #define soc_get_ops(dev) ((struct soc_ops *)(dev)->driver->ops) @@ -76,7 +88,7 @@ struct soc_ops { int soc_get(struct udevice **devp); /** - * soc_get_machine() - Get machine name of an SOC + * soc_get_machine() - Get machine name of a SoC * @dev: Device to check (UCLASS_SOC) * @buf: Buffer to place string * @size: Size of string space @@ -86,7 +98,7 @@ int soc_get(struct udevice **devp); int soc_get_machine(struct udevice *dev, char *buf, int size); /** - * soc_get_revision() - Get revision name of an SOC + * soc_get_revision() - Get revision name of a SoC * @dev: Device to check (UCLASS_SOC) * @buf: Buffer to place string * @size: Size of string space @@ -96,7 +108,7 @@ int soc_get_machine(struct udevice *dev, char *buf, int size); int soc_get_revision(struct udevice *dev, char *buf, int size); /** - * soc_get_family() - Get family name of an SOC + * soc_get_family() - Get family name of a SoC * @dev: Device to check (UCLASS_SOC) * @buf: Buffer to place string * @size: Size of string space @@ -105,6 +117,16 @@ int soc_get_revision(struct udevice *dev, char *buf, int size); */ int soc_get_family(struct udevice *dev, char *buf, int size); +/** + * soc_get_soc_id() - Get SoC identification name of a SoC + * @dev: Device to check (UCLASS_SOC) + * @buf: Buffer to place string + * @size: Size of string space + * + * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error + */ +int soc_get_soc_id(struct udevice *dev, char *buf, int size); + /** * soc_device_match() - Return match from an array of soc_attr * @matches: Array with any combination of family, revision or machine set @@ -136,6 +158,11 @@ static inline int soc_get_family(struct udevice *dev, char *buf, int size) return -ENOSYS; } +static inline int soc_get_soc_id(struct udevice *dev, char *buf, int size) +{ + return -ENOSYS; +} + static inline const struct soc_attr * soc_device_match(const struct soc_attr *matches) { diff --git a/test/dm/soc.c b/test/dm/soc.c index 17e1b5ba01..82cd53ff29 100644 --- a/test/dm/soc.c +++ b/test/dm/soc.c @@ -32,24 +32,28 @@ static int dm_test_soc(struct unit_test_state *uts) .family = "SANDBOX0xx", .machine = "SANDBOX012", .revision = "1.0", + .soc_id = "r8a774a1", .data = NULL, }, { .family = "SANDBOX1xx", .machine = "SANDBOX107", .revision = "1.0", + .soc_id = "r8a774a1", .data = NULL, }, { .family = "SANDBOX1xx", .machine = "SANDBOX123", .revision = "1.0", + .soc_id = "r8a774a1", .data = &soc_sandbox123_data, }, { .family = "SANDBOX1xx", .machine = "SANDBOX131", .revision = "2.0", + .soc_id = "r8a774a1", .data = NULL, }, { /* sentinel */ } @@ -78,6 +82,7 @@ static int dm_test_soc(struct unit_test_state *uts) { .family = "SANDBOX0xx", .revision = "1.0", + .soc_id = "r8a774b1", .data = NULL, }, { @@ -99,6 +104,9 @@ static int dm_test_soc(struct unit_test_state *uts) ut_assertok(soc_get_revision(dev, text, sizeof(text))); ut_asserteq_str(text, "1.0"); + ut_assertok(soc_get_soc_id(dev, text, sizeof(text))); + ut_asserteq_str(text, "r8a774a1"); + soc_data = soc_device_match(sb_soc_devices_full); ut_assert(soc_data);