Received: by 10.223.164.202 with SMTP id h10csp3821085wrb; Mon, 20 Nov 2017 05:39:03 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ2cHkjZyDNa1oxeSaVK28nc8RwsBzOUIv5xjgWs5iCRtT5aBG5fBd/b1jsNdb3ODe+q/RR X-Received: by 10.84.174.4 with SMTP id q4mr14296993plb.233.1511185143738; Mon, 20 Nov 2017 05:39:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511185143; cv=none; d=google.com; s=arc-20160816; b=Qg3l01o6bgY5f9r9p9iCsfitAT/oYiMu57lely5zxYKHNzaxTsHu8+YcHlSigaw4jD TiSLknL6MhNH43XNHcE44KeuIYx0duumcb2ElwFwjCAqnx9L+e4Fpi9/aFW/RtrPW3LV zQEq/KsgfQAsZMt6bo2UdGkvOsoT+uILdFHu5dSwHZezp7urdBDN2aXl2NPDIDz2vzsf LYRWMarCb7K2d2RrsAtqS8MtWoqNPgKNSqG6CxzQ3H1xidlkx8ROQidDnusl2ipSLfe6 2j24Ur4vDuSETCb9TaJboGoNp+Y+2R67utDX2vaSV3Qyn6KoaJogbRvMPJby4zRqFnHl JCUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=rP5nlLuiFXdRXFXmQPV2mMHX828K1mu+XMd/yP9/Hgc=; b=FMGxP68RBAr+piD7YNoYAeGT4YmiGMdsD0d3QwGGuf8ToBa47aaD0jDbieX4GPZMhB zqcGj0czN2p3rDBFN5iyUvsJ5h6ut0q1F5SFaW80hDUHR4rAUkR6t6Ld+Ygoj6HajmJE sOmUWrYKIULDh5CS6Uy/wVvM+S74QUeOFn+L2mF3ScMQSpsJgpwPNFgpTW7uacN4+88M jNuDvAevHnsFLINaZxKEkp6vZPARGT99Jj8L7yAXPNNrx08m/tWPTvlqo3bgvIaN/Y2X qLIZSQ1VXTTTvpPbFAYHPwNqdzxd/xSycCE1Fmr+lW76UyyEodsN9YvcM8I0Rnwgu4JG hdNw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2si8327432pge.67.2017.11.20.05.38.53; Mon, 20 Nov 2017 05:39:03 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751282AbdKTNc6 (ORCPT + 66 others); Mon, 20 Nov 2017 08:32:58 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:39521 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751086AbdKTNc5 (ORCPT ); Mon, 20 Nov 2017 08:32:57 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id ABF15183B6; Mon, 20 Nov 2017 14:32:55 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id t5wukElBm1Ur; Mon, 20 Nov 2017 14:32:55 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id 0DAA2183B1; Mon, 20 Nov 2017 14:32:55 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EFD801E07D; Mon, 20 Nov 2017 14:32:54 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E292F1E07C; Mon, 20 Nov 2017 14:32:54 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Mon, 20 Nov 2017 14:32:54 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by thoth.se.axis.com (Postfix) with ESMTP id D5F1D19AA; Mon, 20 Nov 2017 14:32:54 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id D13A9400FE; Mon, 20 Nov 2017 14:32:54 +0100 (CET) From: Niklas Cassel To: Jingoo Han , Joao Pinto , Lorenzo Pieralisi , Bjorn Helgaas Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 03/18] PCI: designware-ep: Read-only registers need DBI_RO_WR_EN to be writable Date: Mon, 20 Nov 2017 14:32:06 +0100 Message-Id: <20171120133222.27771-4-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171120133222.27771-1-niklas.cassel@axis.com> References: <20171120133222.27771-1-niklas.cassel@axis.com> X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Certain registers that pcie-designware-ep tries to write to are read-only registers. However, these registers can become read/write if we first enable the DBI_RO_WR_EN bit. Set/unset the DBI_RO_WR_EN bit before/after writing these registers. Signed-off-by: Niklas Cassel --- drivers/pci/dwc/pcie-designware-ep.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index c92ab87fd660..3fb34be99715 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -35,8 +35,10 @@ static void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) u32 reg; reg = PCI_BASE_ADDRESS_0 + (4 * bar); + dw_pcie_dbi_ro_wr_en(pci); dw_pcie_writel_dbi2(pci, reg, 0x0); dw_pcie_writel_dbi(pci, reg, 0x0); + dw_pcie_dbi_ro_wr_dis(pci); } static int dw_pcie_ep_write_header(struct pci_epc *epc, @@ -45,6 +47,7 @@ static int dw_pcie_ep_write_header(struct pci_epc *epc, struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + dw_pcie_dbi_ro_wr_en(pci); dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, hdr->vendorid); dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, hdr->deviceid); dw_pcie_writeb_dbi(pci, PCI_REVISION_ID, hdr->revid); @@ -58,6 +61,7 @@ static int dw_pcie_ep_write_header(struct pci_epc *epc, dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_ID, hdr->subsys_id); dw_pcie_writeb_dbi(pci, PCI_INTERRUPT_PIN, hdr->interrupt_pin); + dw_pcie_dbi_ro_wr_dis(pci); return 0; } @@ -142,8 +146,10 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, enum pci_barno bar, if (ret) return ret; + dw_pcie_dbi_ro_wr_en(pci); dw_pcie_writel_dbi2(pci, reg, size - 1); dw_pcie_writel_dbi(pci, reg, flags); + dw_pcie_dbi_ro_wr_dis(pci); return 0; } @@ -223,7 +229,9 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 encode_int) val = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); val &= ~MSI_CAP_MMC_MASK; val |= (encode_int << MSI_CAP_MMC_SHIFT) & MSI_CAP_MMC_MASK; + dw_pcie_dbi_ro_wr_en(pci); dw_pcie_writew_dbi(pci, MSI_MESSAGE_CONTROL, val); + dw_pcie_dbi_ro_wr_dis(pci); return 0; } -- 2.14.2 From 1584194539730893864@xxx Thu Nov 16 04:14:04 +0000 2017 X-GM-THRID: 1584194539730893864 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread