Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2397519rdg; Mon, 16 Oct 2023 03:17:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVRcYVxvwguMUXk+/jxYRUocKxLuvkHs4s+BXyM3djQgBopvqDg3ajwNtoyLnJKqKts5se X-Received: by 2002:a17:902:e80e:b0:1c6:2d13:5b77 with SMTP id u14-20020a170902e80e00b001c62d135b77mr40292460plg.39.1697451457719; Mon, 16 Oct 2023 03:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697451457; cv=none; d=google.com; s=arc-20160816; b=YWhb/v1x5DmaBA96oEZxb6C0l9TUWloHnueFR/O7EAD/o/DWO5qh0pVdYjh4i2LSO+ kCb6uOuePQ9is7iTN6hFKxDHxFosshtkOt3I/6qBaUgxHYEstSLEnAT0AJl1xGDDtTG4 0gW5sQXnf2tqFwENEQqXUhQL3lFXtKnMVVQiaPAm81q20FfEMSYcnSDSZgM9+6BaTUbh jqwTQvdFrMVzMF9H9iyi4gQm5KouqEu+mYByJOzcaoKavhiiPyOoeIWtLrJVipnW37sC nKsd3VZs6GJdkL9k/oUKeFsdBzuE2bj2HIRbQ6Gjh864T5lxMTe/ucK4qUriqyH4uJPQ 4gnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mUEmS5X5FgjjtcAPHgw5AMBeixQExKA6lT4KW9jhDGw=; fh=zXIzpqU6fkcvkKYOWPETYAc8kHdGN5li0oSb9j2GXFE=; b=O+LyyAp4jvOfclDEkbCQxyqrOZ5pObdZj+HOrO1zIckkxBg/oSrLnkVozN8F1jc30f csNDv9ApTkExh45H4D9Z4XIK1NJb9PSe8m2CCVlZqA4g1lWvzTg0DVphr1lhsd9PvYqp 280uyYrKwaQu/kjJ5tTmTBcxJJOenWevIA9nMNURRQ8GaO6o8f3ltD5nPalw7v9FUrcd NSAserPSSuULl/E9anZTe1Bm3eMkvE08nNw19eMMalEL3gWlhPwzfawiK5GZSwjdrtam 2gshdvWjTZtHzR8We4gL5Dr3JdYslcMVD8Zl0pjehqzQtuUI6v8Gk3jgN+G0pnMdQ1GB 9Y7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=mHOQTwW0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id g11-20020a1709026b4b00b001c5b9ef1d34si9902731plt.340.2023.10.16.03.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 03:17:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=mHOQTwW0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 02E23804C201; Mon, 16 Oct 2023 03:17:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231571AbjJPKRO (ORCPT + 99 others); Mon, 16 Oct 2023 06:17:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233244AbjJPKQt (ORCPT ); Mon, 16 Oct 2023 06:16:49 -0400 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6D33D49 for ; Mon, 16 Oct 2023 03:16:30 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 39GAGJsZ119482; Mon, 16 Oct 2023 05:16:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1697451379; bh=mUEmS5X5FgjjtcAPHgw5AMBeixQExKA6lT4KW9jhDGw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=mHOQTwW0HDMKQPfWRDS7Zkq4jjdvExdDqf7w3cy8eLS+l6lixh+XZDV9SSG/0P2ya wjQbj5wRgBp5W+Q06C0wKWNr0D3rlAQHNsfGy6HqBgxgFmSJa+yVZ8Z8MqYKTAx2Zt vqKmIhwCuybhccTxg9n4qzj9X+kt6E05RV9NxbTE= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 39GAGJig020318 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 16 Oct 2023 05:16:19 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 16 Oct 2023 05:16:19 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 16 Oct 2023 05:16:19 -0500 Received: from a0497641-HP-Z2-Tower-G9-Workstation-Desktop-PC.dhcp.ti.com (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 39GAG90i033447; Mon, 16 Oct 2023 05:16:17 -0500 From: Neha Malcom Francis To: , , CC: , , , Subject: [PATCH v3 3/3] soc: ti: k3-socinfo: Revamp driver to accommodate different rev structs Date: Mon, 16 Oct 2023 15:46:08 +0530 Message-ID: <20231016101608.993921-4-n-francis@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231016101608.993921-1-n-francis@ti.com> References: <20231016101608.993921-1-n-francis@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 03:17:33 -0700 (PDT) k3-socinfo.c driver assumes silicon revisions for every platform are incremental and one-to-one, corresponding to JTAG_ID's variant field: 1.0, 2.0 etc. This assumption is wrong for SoCs such as J721E, where the variant field to revision mapping is 1.0, 1.1. Further, there are SoCs such as AM65x where the sub-variant version requires custom decoding of other registers. Address this by using conditional handling per JTAG ID that requires an exception with J721E as the first example. To facilitate this conversion, use macros to identify the JTAG_ID part number and map them to predefined string array. Signed-off-by: Neha Malcom Francis Co-developed-by: Thejasvi Konduru Signed-off-by: Thejasvi Konduru --- Changes since v2: - update commit message - move from double Signed-off-by to Co-developed-by - make j721e_rev_string_map[] a const char - drop k3_rev_string_map[] and continue using old "variant++" logic for the typical cases - appropriate error handling with no overrides distinguishing between ENODEV and ENOMEM drivers/soc/ti/k3-socinfo.c | 71 ++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/drivers/soc/ti/k3-socinfo.c b/drivers/soc/ti/k3-socinfo.c index 7fc3548e084c..7517a9c8c8fa 100644 --- a/drivers/soc/ti/k3-socinfo.c +++ b/drivers/soc/ti/k3-socinfo.c @@ -33,19 +33,33 @@ #define CTRLMMR_WKUP_JTAGID_MFG_TI 0x17 +#define JTAG_ID_PARTNO_AM65X 0xBB5A +#define JTAG_ID_PARTNO_J721E 0xBB64 +#define JTAG_ID_PARTNO_J7200 0xBB6D +#define JTAG_ID_PARTNO_AM64X 0xBB38 +#define JTAG_ID_PARTNO_J721S2 0xBB75 +#define JTAG_ID_PARTNO_AM62X 0xBB7E +#define JTAG_ID_PARTNO_J784S4 0xBB80 +#define JTAG_ID_PARTNO_AM62AX 0xBB8D +#define JTAG_ID_PARTNO_AM62PX 0xBB9D + static const struct k3_soc_id { unsigned int id; const char *family_name; } k3_soc_ids[] = { - { 0xBB5A, "AM65X" }, - { 0xBB64, "J721E" }, - { 0xBB6D, "J7200" }, - { 0xBB38, "AM64X" }, - { 0xBB75, "J721S2"}, - { 0xBB7E, "AM62X" }, - { 0xBB80, "J784S4" }, - { 0xBB8D, "AM62AX" }, - { 0xBB9D, "AM62PX" }, + { JTAG_ID_PARTNO_AM65X, "AM65X" }, + { JTAG_ID_PARTNO_J721E, "J721E" }, + { JTAG_ID_PARTNO_J7200, "J7200" }, + { JTAG_ID_PARTNO_AM64X, "AM64X" }, + { JTAG_ID_PARTNO_J721S2, "J721S2"}, + { JTAG_ID_PARTNO_AM62X, "AM62X" }, + { JTAG_ID_PARTNO_J784S4, "J784S4" }, + { JTAG_ID_PARTNO_AM62AX, "AM62AX" }, + { JTAG_ID_PARTNO_AM62PX, "AM62PX" }, +}; + +static const char * const j721e_rev_string_map[] = { + "1.0", "1.1", }; static int @@ -63,6 +77,32 @@ k3_chipinfo_partno_to_names(unsigned int partno, return -ENODEV; } +static int +k3_chipinfo_variant_to_sr(unsigned int partno, unsigned int variant, + struct soc_device_attribute *soc_dev_attr) +{ + switch (partno) { + case JTAG_ID_PARTNO_J721E: + if (variant >= ARRAY_SIZE(j721e_rev_string_map)) + goto err_unknown_variant; + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%s", + j721e_rev_string_map[variant]); + break; + default: + variant++; + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%x.0", + variant); + } + + if (!soc_dev_attr->revision) + return -ENOMEM; + + return 0; + +err_unknown_variant: + return -ENODEV; +} + static int k3_chipinfo_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; @@ -94,7 +134,6 @@ static int k3_chipinfo_probe(struct platform_device *pdev) variant = (jtag_id & CTRLMMR_WKUP_JTAGID_VARIANT_MASK) >> CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT; - variant++; partno_id = (jtag_id & CTRLMMR_WKUP_JTAGID_PARTNO_MASK) >> CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT; @@ -103,16 +142,16 @@ static int k3_chipinfo_probe(struct platform_device *pdev) if (!soc_dev_attr) return -ENOMEM; - soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%x.0", variant); - if (!soc_dev_attr->revision) { - ret = -ENOMEM; + ret = k3_chipinfo_partno_to_names(partno_id, soc_dev_attr); + if (ret) { + dev_err(dev, "Unknown SoC JTAGID[0x%08X]: %d\n", jtag_id, ret); goto err; } - ret = k3_chipinfo_partno_to_names(partno_id, soc_dev_attr); + ret = k3_chipinfo_variant_to_sr(partno_id, variant, soc_dev_attr); if (ret) { - dev_err(dev, "Unknown SoC JTAGID[0x%08X]: %d\n", jtag_id, ret); - goto err_free_rev; + dev_err(dev, "Unknown SoC SR[0x%08X]: %d\n", jtag_id, ret); + goto err; } node = of_find_node_by_path("/"); -- 2.34.1