Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4381285ioa; Wed, 27 Apr 2022 02:31:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxrbDOV/3/NtV275QwSP0042/1+QFh6DkWx93biS22PX0qFekoDMrEjzphURQ4+5zTy/hG X-Received: by 2002:a63:1263:0:b0:3ab:812a:e070 with SMTP id 35-20020a631263000000b003ab812ae070mr7965744pgs.321.1651051886006; Wed, 27 Apr 2022 02:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651051886; cv=none; d=google.com; s=arc-20160816; b=a443jUVJ1rZOGIfFnVHgp6iuHswMAMvjfKNcZ9Lz7pT4QvjqkknlY/2plJrXVPy38+ /gvJ5qSkzjVg8H5LOtjIAWisyeY3VXvgkaF7Hv4vEGVR6EWFuQt0qimXj3LrmQgE6N4t jUBTn28pQpjhV9fvv/tgb9ucs5lGwXiQZbEeWKExC8G9Nyo7d4BY04Lgl+zOXRt74SRi 0MOvEiH3l28AHfKur0bD2LUWmgpmVJpeqXkUz2PTNKQZddzD1WQNCPXZQhYlvQ8o+BWU pLEy1iMheBUbdR1HN6xyWeNGgKHMbcDt1bouSyLtzSRbfiTM6gjZ7U2I49PtoOvtqbDE HmJA== 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=EP/4HyFu5fE1FWV2bSGg4OigpJgql6J8UxiMncmb55g=; b=nDwbee02qFWPwYhd0OE7VJnQdUS0EtHOY2+j+G0v+xSxP8RUGfDAt/l0friPwEMyl1 pmyaMg9XIpmg4oyo/abRawZmL80gN6Oo+s3hsILQlxsrK1ycNOYa6hy6WQDtz3+tRYZb FCMXX47xXA+nPu2mnr0Wa6zpdgoLdQuI4QrsFEAQ0hffeWyJJP1N8jIAtt03CqMyLMuH QxnsyBpBHuwFSBJNXE4qfHvmFoeWaCFr997nV19QfAkmvKzURamnxH90JZGWV5uTYCoR Iq4QISrKevyReu+Aby/hc4Il5JwR2nAQVnzVWTKJR59BLxatQIZWdUZC8hTKmFjrNpl9 ZV/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b=b2J8CHK0; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v6-20020a655c46000000b003aa91344e53si975086pgr.362.2022.04.27.02.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 02:31:25 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b=b2J8CHK0; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9A0B224E900; Wed, 27 Apr 2022 02:12:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348245AbiDZNZ1 (ORCPT + 99 others); Tue, 26 Apr 2022 09:25:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350895AbiDZNZO (ORCPT ); Tue, 26 Apr 2022 09:25:14 -0400 Received: from mxout3.routing.net (mxout3.routing.net [IPv6:2a03:2900:1:a::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C4D714DEA4; Tue, 26 Apr 2022 06:22:06 -0700 (PDT) Received: from mxbox1.masterlogin.de (unknown [192.168.10.88]) by mxout3.routing.net (Postfix) with ESMTP id E0502603D5; Tue, 26 Apr 2022 13:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1650979324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EP/4HyFu5fE1FWV2bSGg4OigpJgql6J8UxiMncmb55g=; b=b2J8CHK05TJhuJsV1YzrcrVB5YFprHk1U3MaIj3KXtDmKaiPtj4Cxh3CMlkhrIx2xjGDkd AXx1hkjRIJzg9O+VGS1KhBsQT+u6ABRlnPquNcbxFXrtOro1Rk821cy7f84QKB9yq6Koxu z4foqaWiIOmwAYr3o+bvW8uaIqmIt4c= Received: from localhost.localdomain (fttx-pool-80.245.77.37.bambit.de [80.245.77.37]) by mxbox1.masterlogin.de (Postfix) with ESMTPSA id B5570401C9; Tue, 26 Apr 2022 13:22:03 +0000 (UTC) From: Frank Wunderlich To: linux-rockchip@lists.infradead.org Cc: Frank Wunderlich , Bjorn Helgaas , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Kishon Vijay Abraham I , Vinod Koul , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Philipp Zabel , Johan Jonker , Peter Geis , Michael Riesch , linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Subject: [RFC/RFT v2 10/11] PCI: rockchip: add a lane-map to rockchip pcie driver Date: Tue, 26 Apr 2022 15:21:38 +0200 Message-Id: <20220426132139.26761-11-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426132139.26761-1-linux@fw-web.de> References: <20220426132139.26761-1-linux@fw-web.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mail-ID: b94f3b49-ffe6-4505-9833-b0b59dbfd0ed X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 From: Frank Wunderlich Add a basic lane-map to define which PCIe lanes should be used with this controller. Rockchip driver uses this for bifurcation (true/false) based on lanes should be splitted across controllers or not. On rk3568 there are 2 PCIe Controllers which share PCIe lanes. pcie3x1: pcie@fe270000 //lane1 when using 1+1 pcie3x2: pcie@fe280000 //lane0 when using 1+1 This ends up in one Controller (pcie3x1) uses lane-map = <0 1>; and the other lane-map = <1 0>; (pcie3x2) This means there are 2 lanes (count of numbers), one (by position) is mapped to the first controller, the other one is used on the other controller. In this driver the lane-map is simply converted to the bifurcation bool instead of direct mapping a specific lane to a controller. Signed-off-by: Frank Wunderlich --- v2: - new patch --- drivers/pci/controller/dwc/pcie-dw-rockchip.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c index 79e909df241c..21cb697a5be1 100644 --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c @@ -60,6 +60,7 @@ struct rockchip_pcie { struct regulator *vpcie3v3; struct irq_domain *irq_domain; bool bifurcation; + u32 lane_map[2]; }; static int rockchip_pcie_readl_apb(struct rockchip_pcie *rockchip, @@ -293,8 +294,10 @@ static int rockchip_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct rockchip_pcie *rockchip; + unsigned int lanecnt = 0; struct pcie_port *pp; int ret; + int len; rockchip = devm_kzalloc(dev, sizeof(*rockchip), GFP_KERNEL); if (!rockchip) @@ -327,8 +330,16 @@ static int rockchip_pcie_probe(struct platform_device *pdev) } } - if (device_property_read_bool(dev, "bifurcation")) - rockchip->bifurcation = true; + len = of_property_read_variable_u32_array(dev->of_node, "lane-map", rockchip->lane_map, + 2, ARRAY_SIZE(rockchip->lane_map)); + + for (int i = 0; i < len; i++) + if (rockchip->lane_map[i]) + lanecnt++; + + rockchip->bifurcation = ((lanecnt > 0) && (lanecnt != len)); + + dev_info(dev, "bifurcation: %s\n", rockchip->bifurcation ? "true" : "false"); ret = rockchip_pcie_phy_init(rockchip); if (ret) -- 2.25.1