Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3173445ybi; Fri, 5 Jul 2019 03:09:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWZYWANIzKt7Ai4TcnkxmZX/p7Ij2F0TVub1mqNii/5SzZyPrx7qOp9mMbJku4Bvk9iCBi X-Received: by 2002:a63:101b:: with SMTP id f27mr4279393pgl.291.1562321351709; Fri, 05 Jul 2019 03:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562321351; cv=none; d=google.com; s=arc-20160816; b=LE/yKCAZP5e5rUSQV8Jo95AY+2gK+To6FPmS0X5q1zxcISspOJ+bWkRXJcZzFGKXJg cN4aWxd8FyblsPWjunOFhBdTMaD2sRKu0D3b5Q6C6QLj3oNVpZLv50D6lnZAFfXTCj7G Sw+dTfWdLxd5O42WdL6SBEhITYUZYcuHQiW6cCQYSvriMSndXZRHtjq+EO16FT6GaI3o w5XojUuvQBvhU0zCXzzsNr+72VvJ3vaKiEQWkO45UDPp+JiowpDC/zeP99k4p2Hk4UWS lhYZmsJ4GOqndwL77cyiHRXalVwtnEIDYvyeG7ccgiUTQFmrhObsuDpFPVfKPT2dlg1Q kbEg== 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; bh=nJi408nR/yrMJKs8fh7BrtrfO3/zqaoBb5waBEbdJbg=; b=yA1Cn2g1jaIfqq/iSiQsBgMhGJeIHCocFUqlzlIjQZP2sjC6xfD5sPL6Z4jlxLDLRR Rm6oHGSSWtaIkkreKrR5CDwEq8M7CDYzt+ljXWtOyo2OEolbIMwsorNr8o/3BLsKvuiI voLKfcxIukVN48kIE8jAJ3t9t/wNs2IX6/EearGmLxgbFE4jxCh95AK+lLtDMgiUMuzh LHJDeWQGgAGsopoz26o9fKK6mEFhvyL7AVpYakh+qjSY1J7HpwiGS57+2ZVADDVf+qR2 z79B1X9EL8by2PC6RzkygtiGu3v3t3QTdOvIeDQHH+s3XXD5sWEWJ0rHYMwrXIoy5xhW IeAw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b19si7373270pgl.189.2019.07.05.03.08.56; Fri, 05 Jul 2019 03:09:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728416AbfGEKHo (ORCPT + 99 others); Fri, 5 Jul 2019 06:07:44 -0400 Received: from inva021.nxp.com ([92.121.34.21]:48432 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728353AbfGEKHj (ORCPT ); Fri, 5 Jul 2019 06:07:39 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id AE409200703; Fri, 5 Jul 2019 12:07:36 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2FFD62006F9; Fri, 5 Jul 2019 12:07:28 +0200 (CEST) Received: from titan.ap.freescale.net (TITAN.ap.freescale.net [10.192.208.233]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id B002E40327; Fri, 5 Jul 2019 18:07:17 +0800 (SGT) From: Hou Zhiqiang To: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, bhelgaas@google.com, robh+dt@kernel.org, mark.rutland@arm.com, l.subrahmanya@mobiveil.co.in, shawnguo@kernel.org, leoyang.li@nxp.com, lorenzo.pieralisi@arm.com, catalin.marinas@arm.com, will.deacon@arm.com Cc: Mingkai.Hu@nxp.com, Minghuan.Lian@nxp.com, Xiaowei.Bao@nxp.com, Hou Zhiqiang Subject: [PATCHv6 21/28] PCI: mobiveil: Clear the target fields before updating the register Date: Fri, 5 Jul 2019 17:56:49 +0800 Message-Id: <20190705095656.19191-22-Zhiqiang.Hou@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20190705095656.19191-1-Zhiqiang.Hou@nxp.com> References: <20190705095656.19191-1-Zhiqiang.Hou@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clear the target fields in the register before programming with an new value. Signed-off-by: Hou Zhiqiang Reviewed-by: Minghuan Lian Reviewed-by: Subrahmanya Lingappa --- V6: - Splited from #9 of v5 patches, no functional change. drivers/pci/controller/pcie-mobiveil.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c index 0560344..7d18e59 100644 --- a/drivers/pci/controller/pcie-mobiveil.c +++ b/drivers/pci/controller/pcie-mobiveil.c @@ -65,6 +65,8 @@ #define PAB_AXI_AMAP_CTRL(win) PAB_REG_ADDR(0x0ba0, win) #define WIN_ENABLE_SHIFT 0 #define WIN_TYPE_SHIFT 1 +#define WIN_TYPE_MASK 0x3 +#define WIN_SIZE_MASK 0xfffffc00 #define PAB_EXT_AXI_AMAP_SIZE(win) PAB_EXT_REG_ADDR(0xbaf0, win) @@ -82,6 +84,7 @@ #define PAB_PEX_AMAP_CTRL(win) PAB_REG_ADDR(0x4ba0, win) #define AMAP_CTRL_EN_SHIFT 0 #define AMAP_CTRL_TYPE_SHIFT 1 +#define AMAP_CTRL_TYPE_MASK 3 #define PAB_EXT_PEX_AMAP_SIZEN(win) PAB_EXT_REG_ADDR(0xbef0, win) #define PAB_PEX_AMAP_AXI_WIN(win) PAB_REG_ADDR(0x4ba4, win) @@ -469,9 +472,9 @@ static void program_ib_windows(struct mobiveil_pcie *pcie, int win_num, csr_writel(pcie, value, PAB_PEX_PIO_CTRL); value = csr_readl(pcie, PAB_PEX_AMAP_CTRL(win_num)); - value |= (type << AMAP_CTRL_TYPE_SHIFT) | - (1 << AMAP_CTRL_EN_SHIFT) | - lower_32_bits(size64); + value &= ~(AMAP_CTRL_TYPE_MASK << AMAP_CTRL_TYPE_SHIFT | WIN_SIZE_MASK); + value |= type << AMAP_CTRL_TYPE_SHIFT | 1 << AMAP_CTRL_EN_SHIFT | + lower_32_bits(size64); csr_writel(pcie, value, PAB_PEX_AMAP_CTRL(win_num)); csr_writel(pcie, upper_32_bits(size64), @@ -490,6 +493,7 @@ static void program_ib_windows(struct mobiveil_pcie *pcie, int win_num, static void program_ob_windows(struct mobiveil_pcie *pcie, int win_num, u64 cpu_addr, u64 pci_addr, u32 type, u64 size) { + u32 value; u64 size64 = ~(size - 1); if (win_num >= pcie->apio_wins) { @@ -502,8 +506,11 @@ static void program_ob_windows(struct mobiveil_pcie *pcie, int win_num, * program Enable Bit to 1, Type Bit to (00) base 2, AXI Window Size Bit * to 4 KB in PAB_AXI_AMAP_CTRL register */ - csr_writel(pcie, 1 << WIN_ENABLE_SHIFT | type << WIN_TYPE_SHIFT | - lower_32_bits(size64), PAB_AXI_AMAP_CTRL(win_num)); + value = csr_readl(pcie, PAB_AXI_AMAP_CTRL(win_num)); + value &= ~(WIN_TYPE_MASK << WIN_TYPE_SHIFT | WIN_SIZE_MASK); + value |= 1 << WIN_ENABLE_SHIFT | type << WIN_TYPE_SHIFT | + lower_32_bits(size64); + csr_writel(pcie, value, PAB_AXI_AMAP_CTRL(win_num)); csr_writel(pcie, upper_32_bits(size64), PAB_EXT_AXI_AMAP_SIZE(win_num)); -- 1.7.1