From patchwork Thu Sep 26 11:29:23 2019 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: 174469 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1920540ill; Thu, 26 Sep 2019 04:31:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmc29wkJQ+HUOhnXUphU670ba1fQfWzxrNk47Buu7T9L4tmOoElFlp1RIyRUVHWXjamagx X-Received: by 2002:a17:906:d97a:: with SMTP id rp26mr2604576ejb.251.1569497491516; Thu, 26 Sep 2019 04:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569497491; cv=none; d=google.com; s=arc-20160816; b=LSwNWstsmm8RSFVHWmepazquLQf+WvkEIn0apgZrD74QSCdJE9pe8YFdrvKiRlBDrp IA+CBLm8F8mymj/YGMBSxqAhBIqJlu+MH0oYhWd9Zas2Ef0qG0oqNa56ihza/t4IWMEY xZ61JQLl2RDDlCKyCbfuJJvz2bPlSFJR/Nnihvmp1qp8mDYPn0cMhHuQ159Q0WI/96uN jn5I34OF08htB5wJo3ED5q2OWz1h/RgVIkJP6bzRLSt3auGIMvA0DY48ep7XMqslPiag 8sfvntjz4MSjEtJTZOQ8h+2DnuIfTJMGBgLZ69jc64GZMgSqomtVS5A+BP7tmrE7Vfop ZPKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=5g6TwgnGUlfofXhn+QvD8y+MT6lDfC7QwOU9sIuCmvU=; b=XZbZna1pfnxsER5ZSIdaS7OwEQBm9M6JJj5PRfEeqogAHTT3EiuTBFEtuZ6ZUDPhbt TutOn/r+pusEhO4quHtAFdoF0Y5+4uNOQIKShMoaUNkBDejPXCf6JYgY9chSCmSzT+T/ DVGugj/KJpCpiQseILk8JleQ6Sl9VTdcvaukFZmFbQ3bl/NgLquN8w+wHuTSGvDUWevY /gayphxg4ARSEBNz2gnPpzJbqCxlif1mKgwI/dhrka/JfV1Kc6Mm0ViNi5jk3Oi1UhCA RxA3GQhhyz0h8y9QmaZCwv2OSFwsdk8YA4CLrpBZ9DX6B3/+5k5cP+LMoDqJ0LGk0/3b scYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=EKRJWt69; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si1083784eds.310.2019.09.26.04.31.31; Thu, 26 Sep 2019 04:31:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=EKRJWt69; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726619AbfIZLba (ORCPT + 26 others); Thu, 26 Sep 2019 07:31:30 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:52970 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726573AbfIZLb1 (ORCPT ); Thu, 26 Sep 2019 07:31:27 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8QBVKGg016189; Thu, 26 Sep 2019 06:31:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1569497480; bh=5g6TwgnGUlfofXhn+QvD8y+MT6lDfC7QwOU9sIuCmvU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=EKRJWt69th/MO9ynM8MWbD0RpM+vv+pbGpzNW/t2BbTlgvntevwY28WOnN0R7ex8a a5wDsuZXuiwtzpMZ8CC5I8iCPB82iH7dxOEqoZ3LIceK1RCgiYfJZInqAwJz1AYA96 q9/IMij7CgtySeLwZK/EbKAHKsd3xn40AnOesDYU= 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 x8QBVK37031817 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 26 Sep 2019 06:31:20 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) 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.1713.5; Thu, 26 Sep 2019 06:31:12 -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.1713.5 via Frontend Transport; Thu, 26 Sep 2019 06:31:12 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8QBUTk4069017; Thu, 26 Sep 2019 06:31:16 -0500 From: Kishon Vijay Abraham I To: Bjorn Helgaas , Jonathan Corbet , Rob Herring , Jon Mason , Dave Jiang , Allen Hubbe , Lorenzo Pieralisi CC: Mark Rutland , , , , , , Subject: [RFC PATCH 11/21] PCI: endpoint: Add helper API to populate header with values from DT Date: Thu, 26 Sep 2019 16:59:23 +0530 Message-ID: <20190926112933.8922-12-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190926112933.8922-1-kishon@ti.com> References: <20190926112933.8922-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add helper API pci_epc_of_parse_header() to populate header with values from device tree. These values will be written to the configuration space header in the endpoint controller. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-epc-core.c | 23 +++++++++++++++++++++++ include/linux/pci-epc.h | 2 ++ 2 files changed, 25 insertions(+) -- 2.17.1 diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 49bdff217777..98acadbfc934 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -31,6 +31,29 @@ static int devm_pci_epc_match(struct device *dev, void *res, void *match_data) return *epc == match_data; } +/** + * pci_epc_of_parse_header() - parse the device tree to get PCI config space + * header + * @node: The device tree node (of endpoint function) which has the PCI config + * space header values + * @header: standard configuration space header fields that has to be populated + * + * Invoke to populate *header* with the PCI configuration space values populated + * in device tree. + */ +void pci_epc_of_parse_header(struct device_node *node, + struct pci_epf_header *header) +{ + of_property_read_u16(node, "vendor-id", &header->vendorid); + of_property_read_u16(node, "device-id", &header->deviceid); + of_property_read_u8(node, "baseclass-code", &header->baseclass_code); + of_property_read_u8(node, "subclass-code", &header->subclass_code); + of_property_read_u16(node, "subsys-vendor-id", + &header->subsys_vendor_id); + of_property_read_u16(node, "subsys-id", &header->subsys_id); +} +EXPORT_SYMBOL_GPL(pci_epc_of_parse_header); + /** * pci_epc_put() - release the PCI endpoint controller * @epc: epc returned by pci_epc_get() diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index 993b1a55a239..18fff589a881 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -196,6 +196,8 @@ int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no, u8 vfunc_no, enum pci_epc_irq_type type, u16 interrupt_num); int pci_epc_start(struct pci_epc *epc); void pci_epc_stop(struct pci_epc *epc); +void pci_epc_of_parse_header(struct device_node *node, + struct pci_epf_header *header); const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc, u8 func_no, u8 vfunc_no); unsigned int pci_epc_get_first_free_bar(const struct pci_epc_features