From patchwork Wed Jan 18 12:59:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Achal Verma X-Patchwork-Id: 45283 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2342033wrn; Wed, 18 Jan 2023 05:40:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXuqcBBt/eulXSPUGRt1CDQI2iqNcgf94MwXYColoX4wawoAt7KBa1Hcr6z8r/qcERqLPoit X-Received: by 2002:a05:6402:1956:b0:45c:835b:9448 with SMTP id f22-20020a056402195600b0045c835b9448mr7358753edz.4.1674049234278; Wed, 18 Jan 2023 05:40:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674049234; cv=none; d=google.com; s=arc-20160816; b=fpCfTuNZBhPWkNWPsNJchCxIWaw/6zT/XFE1yHCBJCtT3TBBKS5Q21lGfVPT7pY5/G BrkeICllcWtrn6+HqxNQQIxLbtib5Qr0qYJFr4Gzd4iBzVTbtt+eR3HJKdB2tlUycwij y1yEeFlvq9dzaq/29VrlYvFe9PJH6k4eaoGr3KRsx+cXNAXj6FcS0wyUVnFmO2yghMft sndV1SuWOKAV8w2SpHaJA+IHUK3Er+yd+kkx/w7cmMZ5xlc88hXZ2O7XflS/QGbqD5Rb CrxkT/TgJeTnygzx0mTJ+mphxsbnOO/tRsEKp/P47sapIbf3EKEvn4FmZCMoxIX83lEw gCAg== 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=6txK6JhGNmC1mVhE7nu+ujxZBb0FV1uO3fUqV2jp4bY=; b=GPIlvChnuVDNc3Y8TYxOW2nhtb1n29SSkMjpvQO4Zzz+jWmI6gmIeHBvI5o+Lk3Ias ED/OyHOmwsMro/kqJTZH7bljhWb9iN/JeCzGtKmU7Eyax45/+Mn2cAQq+OJf0VB7Za5U 5b/xmxScR0RKgQFqZhYbwtttuOS81C/8a8fpNDwwATapKZLOkVz57/UOKiUlRjcak91i 4khJFxy86Xhzq8J8i5c4hOXARQCvV7f14PAj9BOLFKPMTuVQgvRtLQpvRxE9SvpbvkOY XJ+Ua+kHx4K8Y0px1gLppIYPl4wA0B2lDjGIQ1NjMp5HO8CY2WCpqfQnA7zAELxmoIMF RDBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=g4uD3aON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a05640235c400b0048c44c8cfcdsi225260edc.167.2023.01.18.05.40.09; Wed, 18 Jan 2023 05:40:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=g4uD3aON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230195AbjARNdv (ORCPT + 99 others); Wed, 18 Jan 2023 08:33:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231263AbjARNdB (ORCPT ); Wed, 18 Jan 2023 08:33:01 -0500 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8235158954; Wed, 18 Jan 2023 05:00:03 -0800 (PST) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 30ICxfRY079760; Wed, 18 Jan 2023 06:59:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1674046781; bh=6txK6JhGNmC1mVhE7nu+ujxZBb0FV1uO3fUqV2jp4bY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=g4uD3aONbWA5QTotkEAoAh8rtZYiGe2WKO9Nwoyoi8wGAjTI+QLoWua7qAeNz9S5j I/W5IF57131YC1Xl+E1XbquDX+z5W1EGbzoMIVC1QmwgN2av+9S0Ad7AFxikOJfrjT tBlAI9lJDgx7ZB/1jDGuWLo9DfV9/M9y626IlQn0= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 30ICxfI9033217 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 18 Jan 2023 06:59:41 -0600 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Wed, 18 Jan 2023 06:59:41 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Wed, 18 Jan 2023 06:59:41 -0600 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 30ICxedL110636; Wed, 18 Jan 2023 06:59:40 -0600 From: Achal Verma To: , , , , , , , , , , , CC: , , , Subject: [PATCH v8 2/5] PCI: j721e: Add per platform maximum lane settings Date: Wed, 18 Jan 2023 18:29:33 +0530 Message-ID: <20230118125936.3456716-3-a-verma1@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118125936.3456716-1-a-verma1@ti.com> References: <20230118125936.3456716-1-a-verma1@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755367849653442431?= X-GMAIL-MSGID: =?utf-8?q?1755367849653442431?= From: Matt Ranostay Various platforms have different maximum amount of lanes that can be selected. Add max_lanes to struct j721e_pcie to allow for detection of this which is needed to calculate the needed bitmask size for the possible lane count. Signed-off-by: Matt Ranostay Signed-off-by: Vignesh Raghavendra Signed-off-by: Achal Verma --- drivers/pci/controller/cadence/pci-j721e.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index cc83a8925ce0..f4dc2c5abedb 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -47,8 +47,6 @@ enum link_status { #define GENERATION_SEL_MASK GENMASK(1, 0) -#define MAX_LANES 2 - struct j721e_pcie { struct cdns_pcie *cdns_pcie; struct clk *refclk; @@ -71,6 +69,7 @@ struct j721e_pcie_data { unsigned int quirk_disable_flr:1; u32 linkdown_irq_regfield; unsigned int byte_access_allowed:1; + unsigned int max_lanes; }; static inline u32 j721e_pcie_user_readl(struct j721e_pcie *pcie, u32 offset) @@ -290,11 +289,13 @@ static const struct j721e_pcie_data j721e_pcie_rc_data = { .quirk_retrain_flag = true, .byte_access_allowed = false, .linkdown_irq_regfield = LINK_DOWN, + .max_lanes = 2, }; static const struct j721e_pcie_data j721e_pcie_ep_data = { .mode = PCI_MODE_EP, .linkdown_irq_regfield = LINK_DOWN, + .max_lanes = 2, }; static const struct j721e_pcie_data j7200_pcie_rc_data = { @@ -302,23 +303,27 @@ static const struct j721e_pcie_data j7200_pcie_rc_data = { .quirk_detect_quiet_flag = true, .linkdown_irq_regfield = J7200_LINK_DOWN, .byte_access_allowed = true, + .max_lanes = 2, }; static const struct j721e_pcie_data j7200_pcie_ep_data = { .mode = PCI_MODE_EP, .quirk_detect_quiet_flag = true, .quirk_disable_flr = true, + .max_lanes = 2, }; static const struct j721e_pcie_data am64_pcie_rc_data = { .mode = PCI_MODE_RC, .linkdown_irq_regfield = J7200_LINK_DOWN, .byte_access_allowed = true, + .max_lanes = 1, }; static const struct j721e_pcie_data am64_pcie_ep_data = { .mode = PCI_MODE_EP, .linkdown_irq_regfield = J7200_LINK_DOWN, + .max_lanes = 1, }; static const struct of_device_id of_j721e_pcie_match[] = { @@ -432,8 +437,10 @@ static int j721e_pcie_probe(struct platform_device *pdev) pcie->user_cfg_base = base; ret = of_property_read_u32(node, "num-lanes", &num_lanes); - if (ret || num_lanes > MAX_LANES) + if (ret || num_lanes > data->max_lanes) { + dev_warn(dev, "num-lanes property not provided or invalid, setting num-lanes to 1\n"); num_lanes = 1; + } pcie->num_lanes = num_lanes; if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48)))