From patchwork Sun Jan 22 12:21:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Achal Verma X-Patchwork-Id: 46940 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1128487wrn; Sun, 22 Jan 2023 04:23:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXtkZfVdw8nBMoPt/AxdPGZn9AobwCLwFg0WhbtCXCPGS4X3ou7dFbnVAPcR4MShyd+QcZjV X-Received: by 2002:a17:90a:4b84:b0:226:5900:f2f4 with SMTP id i4-20020a17090a4b8400b002265900f2f4mr23229789pjh.4.1674390220360; Sun, 22 Jan 2023 04:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674390220; cv=none; d=google.com; s=arc-20160816; b=S8i/sHEKFaLRIjiSmsREAQssYi+iu6+HK3Ea79g/3YTRGvxmzfdieRX+qsbZSnZPet 4ceCn2w2nGo8Fvsh1R9TIDCy5Ic5358fMdkg3YyH72K3j3Z8aKt5YueTaukP+K8JjHRG NvC7dJy6UG+OuU+iMiXZ7sFHK3tYZepUdtfFqnDkULRdYPVAqmxjpBcPA/7v55b0GkVz yy3JtJswuE8CsQQC54yRjTmhwZEZ+PsCJ3RhztslLlGR7nuIyzCLXAPjnQm3PaQ0XhqQ +raq5Q1GQcytAd+QUbPZ9EhbEW3O290AUttj21ZZr2ebsox4mwr4nFRfSNdD5CnSJyS7 Z15Q== 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=oDHhzp2y2KPGJwNFuyFTnwr484/8xzp7nNMYumYZmhwAiOCwDs11fZuOHx6zPdjKMT 3SNNDC8Iogr8y2gIvntLqVjl1DCDX0/5BcTTnHzuFxMIjhZ07mWobeyjzzby+dTssnLV m0ciTEVLe1NnDkjV6f0keWQttLcBCMtz2kEzC/mKxSXI/1uIGmsnolM+UXH9HmQ2kuUD 8Sx1IC3ZN7asVXyZ/WWzMiBoqghJZa+c+H1flmVRbl5zhNsWQmV9m2ulH0yCfTHNgQ12 wZe20yCo8kA/F6s8vfhmkPkjUiW7BSprmR8OXNOpOqKHLUI/eMyJt7Tb5pelHYP6jczc bSFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=uUD0wdUc; 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 r2-20020a632b02000000b004ce425ce69esi20072805pgr.378.2023.01.22.04.23.27; Sun, 22 Jan 2023 04:23:40 -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=uUD0wdUc; 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 S230108AbjAVMVo (ORCPT + 99 others); Sun, 22 Jan 2023 07:21:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbjAVMVj (ORCPT ); Sun, 22 Jan 2023 07:21:39 -0500 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C00899EC9; Sun, 22 Jan 2023 04:21:37 -0800 (PST) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 30MCLQGx106729; Sun, 22 Jan 2023 06:21:26 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1674390086; bh=6txK6JhGNmC1mVhE7nu+ujxZBb0FV1uO3fUqV2jp4bY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=uUD0wdUcGMaWaRNapg1jUIaE8rsytnwXeUV0aotHoz6HwgiJA07zrOV+va6qVEpd1 mHIaOK1ckBHRivrv6Ce3fZZgYI62fjJviHX7Tz27AZiuAwEJjftSWosnsp7LZQID6w nPF8WZJxhnDQZ+TuPCwrQ64RxEIb/gmTgukBAJo0= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 30MCLQbJ066532 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 22 Jan 2023 06:21:26 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Sun, 22 Jan 2023 06:21:25 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE100.ent.ti.com (157.170.170.30) 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; Sun, 22 Jan 2023 06:21:25 -0600 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 30MCLPtf076458; Sun, 22 Jan 2023 06:21:25 -0600 From: Achal Verma To: , , , , , , , , , , , CC: , , , Subject: [PATCH v9 2/5] PCI: j721e: Add per platform maximum lane settings Date: Sun, 22 Jan 2023 17:51:18 +0530 Message-ID: <20230122122121.3552375-3-a-verma1@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230122122121.3552375-1-a-verma1@ti.com> References: <20230122122121.3552375-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,URIBL_BLOCKED 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?1755725399661395097?= X-GMAIL-MSGID: =?utf-8?q?1755725399661395097?= 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)))