From patchwork Fri Dec 4 07:51:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 337727 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp37004ilb; Thu, 3 Dec 2020 23:53:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJz89b6wYZBwRedkuHoBP6A2A8/6hkoylWhtL5UfyU8SUr3NTWM7ALAaDG3FO6/wXvsUzNSW X-Received: by 2002:a17:906:2581:: with SMTP id m1mr5874964ejb.28.1607068424218; Thu, 03 Dec 2020 23:53:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607068424; cv=none; d=google.com; s=arc-20160816; b=iJJwEMWcvlXoE725AWtBjeI4hUAENbZwPRdHsP8zLA1ohIAdhCskuxoLtChIHsvFF1 +fwrI4SJiOH6D0G6rdIb86dLe4iI5RFMtTFBnzI6rul9HCuGZ1d9TX8VRrSrayX1l4ja C814oeKoe3MWNBKgZpkTvZWL3EzHr42aCluTMofPxqoFHoRE0hF/n3YwOrtO87mkUgoJ XJS/dkYjImQr+NiFhv5cVyMeUNKwSiCJCXUm91pe3E1wWEM5pqNOVJp5xcIm7fWDdyWv d17tELOTOY6AzODR4XW2VfaFygIFceMxtwfpmK7wg7Uafmz4+2/jKmUnIJDSTjFtu79P +d4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Dvc7KcefiCb7PBlxUNtWkFXErE0HJTFuqI/Pj5OA+TY=; b=u9FgAQJzy+Gjr7QgrNLn3HxUXswP+r8ziB5AKGtJcmNJL6cE4vqOw8iPSOuJQDyZOD V0Hp75+um6ZqKtO1e3Sevuh07L0JAg7GXT8cvmj3kydx/n91+LwHFTdIkdYoxpv2/r1l Zt65vUOvz0/X/oITgaOXEsAz2kmyug0qTckLqNH2bCUG3pUFEwkagqaWJklO2c1Ciosu 0ZdfIXxXE9CnNFPM5AWRJsQhMwcvEJoHj0aHa+tpz5iOy9Yi56E1pIx+jS8AHPXeU7o9 tlw4DpCHiLPcAsSWkvTBu6sEw+3e6l9ex97RGG/EgjdfJFdn+rMwLGghrS9rU+EHmOJG SEJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=qLEVkXzB; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t26si883861eji.212.2020.12.03.23.53.44; Thu, 03 Dec 2020 23:53:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=qLEVkXzB; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-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 S1728753AbgLDHxb (ORCPT + 3 others); Fri, 4 Dec 2020 02:53:31 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:36700 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbgLDHxb (ORCPT ); Fri, 4 Dec 2020 02:53:31 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0B47qWpc081729; Fri, 4 Dec 2020 01:52:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1607068352; bh=Dvc7KcefiCb7PBlxUNtWkFXErE0HJTFuqI/Pj5OA+TY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=qLEVkXzBHUbog4zDi8ggltskgQAyRrPp21Ljoh10fNbuko0gkBSmp/3FOs38senDJ aDhd7pVzKSQWStB9gVhV9Jn8r6Xdug0Z9E9CFElffpZjsP2iVLsujHenMK48hGI0Hz 6m2m+07wk2h/+Y8fQtiB/wn085+HSfsffH/ZbvKA= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0B47qWtt091160 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 4 Dec 2020 01:52:32 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 4 Dec 2020 01:52:31 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Fri, 4 Dec 2020 01:52:31 -0600 Received: from a0393678-ssd.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0B47pL6u031834; Fri, 4 Dec 2020 01:52:12 -0600 From: Kishon Vijay Abraham I To: Bjorn Helgaas , Rob Herring , Tero Kristo , Nishanth Menon , Kishon Vijay Abraham I , Tom Joseph , Lorenzo Pieralisi CC: , , , , Subject: [PATCH v2 2/3] PCI: j721e: Get offset within "syscon" from "ti, syscon-pcie-ctrl" phandle arg Date: Fri, 4 Dec 2020 13:21:16 +0530 Message-ID: <20201204075117.10430-3-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201204075117.10430-1-kishon@ti.com> References: <20201204075117.10430-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Get "syscon" pcie_ctrl offset from the argument of "ti,syscon-pcie-ctrl" phandle. Previously a subnode to "syscon" node was added which has the exact memory mapped address of pcie_ctrl but now the offset of pcie_ctrl within "syscon" is now being passed as argument to "ti,syscon-pcie-ctrl" phandle. If the offset is not provided in "ti,syscon-pcie-ctrl", the full memory mapped address of pcie_ctrl is used in order to maintain old DT compatibility. This change is as discussed in [1] [1] -> http://lore.kernel.org/r/CAL_JsqKiUcO76bo1GoepWM1TusJWoty_BRy2hFSgtEVMqtrvvQ@mail.gmail.com Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/controller/cadence/pci-j721e.c | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) -- 2.17.1 Reviewed-by: Rob Herring diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 586b9d69fa5e..dac1ac8a7615 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -153,7 +154,8 @@ static const struct cdns_pcie_ops j721e_pcie_ops = { .link_up = j721e_pcie_link_up, }; -static int j721e_pcie_set_mode(struct j721e_pcie *pcie, struct regmap *syscon) +static int j721e_pcie_set_mode(struct j721e_pcie *pcie, struct regmap *syscon, + unsigned int offset) { struct device *dev = pcie->dev; u32 mask = J721E_MODE_RC; @@ -164,7 +166,7 @@ static int j721e_pcie_set_mode(struct j721e_pcie *pcie, struct regmap *syscon) if (mode == PCI_MODE_RC) val = J721E_MODE_RC; - ret = regmap_update_bits(syscon, 0, mask, val); + ret = regmap_update_bits(syscon, offset, mask, val); if (ret) dev_err(dev, "failed to set pcie mode\n"); @@ -172,7 +174,7 @@ static int j721e_pcie_set_mode(struct j721e_pcie *pcie, struct regmap *syscon) } static int j721e_pcie_set_link_speed(struct j721e_pcie *pcie, - struct regmap *syscon) + struct regmap *syscon, unsigned int offset) { struct device *dev = pcie->dev; struct device_node *np = dev->of_node; @@ -185,7 +187,7 @@ static int j721e_pcie_set_link_speed(struct j721e_pcie *pcie, link_speed = 2; val = link_speed - 1; - ret = regmap_update_bits(syscon, 0, GENERATION_SEL_MASK, val); + ret = regmap_update_bits(syscon, offset, GENERATION_SEL_MASK, val); if (ret) dev_err(dev, "failed to set link speed\n"); @@ -193,7 +195,7 @@ static int j721e_pcie_set_link_speed(struct j721e_pcie *pcie, } static int j721e_pcie_set_lane_count(struct j721e_pcie *pcie, - struct regmap *syscon) + struct regmap *syscon, unsigned int offset) { struct device *dev = pcie->dev; u32 lanes = pcie->num_lanes; @@ -201,7 +203,7 @@ static int j721e_pcie_set_lane_count(struct j721e_pcie *pcie, int ret; val = LANE_COUNT(lanes - 1); - ret = regmap_update_bits(syscon, 0, LANE_COUNT_MASK, val); + ret = regmap_update_bits(syscon, offset, LANE_COUNT_MASK, val); if (ret) dev_err(dev, "failed to set link count\n"); @@ -212,6 +214,8 @@ static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie) { struct device *dev = pcie->dev; struct device_node *node = dev->of_node; + struct of_phandle_args args; + unsigned int offset = 0; struct regmap *syscon; int ret; @@ -221,19 +225,25 @@ static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie) return PTR_ERR(syscon); } - ret = j721e_pcie_set_mode(pcie, syscon); + /* Do not error out to maintain old DT compatibility */ + ret = of_parse_phandle_with_fixed_args(node, "ti,syscon-pcie-ctrl", 1, + 0, &args); + if (!ret) + offset = args.args[0]; + + ret = j721e_pcie_set_mode(pcie, syscon, offset); if (ret < 0) { dev_err(dev, "Failed to set pci mode\n"); return ret; } - ret = j721e_pcie_set_link_speed(pcie, syscon); + ret = j721e_pcie_set_link_speed(pcie, syscon, offset); if (ret < 0) { dev_err(dev, "Failed to set link speed\n"); return ret; } - ret = j721e_pcie_set_lane_count(pcie, syscon); + ret = j721e_pcie_set_lane_count(pcie, syscon, offset); if (ret < 0) { dev_err(dev, "Failed to set num-lanes\n"); return ret;