All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <marek.behun@nic.cz>
To: Stefan Roese <sr@denx.de>
Cc: u-boot@lists.denx.de, pali@kernel.org,
	"Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH u-boot-marvell 1/9] arm: mvebu: a38x: serdes: Add comments and use macros in PCIe code
Date: Fri, 24 Sep 2021 22:59:14 +0200	[thread overview]
Message-ID: <20210924205922.25432-2-marek.behun@nic.cz> (raw)
In-Reply-To: <20210924205922.25432-1-marek.behun@nic.cz>

From: Pali Rohár <pali@kernel.org>

Replace magic register offsets by macros to make code more readable.
Add comments about what this code is doing.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
---
 .../serdes/a38x/high_speed_env_spec.c         | 37 +++++++++++++------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c b/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c
index 3b41c7d49b..09192acef2 100644
--- a/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c
+++ b/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c
@@ -1723,31 +1723,44 @@ int serdes_power_up_ctrl(u32 serdes_num, int serdes_power_up,
 					reg_data &= ~0x4000;
 				reg_write(SOC_CONTROL_REG1, reg_data);
 
-				reg_data =
-				    reg_read(((PEX_IF_REGS_BASE(pex_idx)) +
-					      0x6c));
+				/* Set Maximum Link Width to X1 or X4 */
+				reg_data = reg_read(PEX_CFG_DIRECT_ACCESS(
+						     pex_idx,
+						     PEX_LINK_CAPABILITY_REG));
 				reg_data &= ~0x3f0;
 				if (is_pex_by1 == 1)
 					reg_data |= 0x10;
 				else
 					reg_data |= 0x40;
-				reg_write(((PEX_IF_REGS_BASE(pex_idx)) + 0x6c),
+				reg_write(PEX_CFG_DIRECT_ACCESS(
+					   pex_idx,
+					   PEX_LINK_CAPABILITY_REG),
 					  reg_data);
 
-				reg_data =
-				    reg_read(((PEX_IF_REGS_BASE(pex_idx)) +
-					      0x6c));
+				/* Set Maximum Link Speed to 5 GT/s */
+				reg_data = reg_read(PEX_CFG_DIRECT_ACCESS(
+						     pex_idx,
+						     PEX_LINK_CAPABILITY_REG));
 				reg_data &= ~0xf;
 				reg_data |= 0x2;
-				reg_write(((PEX_IF_REGS_BASE(pex_idx)) + 0x6c),
+				reg_write(PEX_CFG_DIRECT_ACCESS(
+					   pex_idx,
+					   PEX_LINK_CAPABILITY_REG),
 					  reg_data);
 
-				reg_data =
-				    reg_read(((PEX_IF_REGS_BASE(pex_idx)) +
-					      0x70));
+				/*
+				 * Set Common Clock Configuration to indicates
+				 * that both devices on the link use a
+				 * distributed common reference clock.
+				 */
+				reg_data = reg_read(PEX_CFG_DIRECT_ACCESS(
+						     pex_idx,
+						     PEX_LINK_CTRL_STAT_REG));
 				reg_data &= ~0x40;
 				reg_data |= 0x40;
-				reg_write(((PEX_IF_REGS_BASE(pex_idx)) + 0x70),
+				reg_write(PEX_CFG_DIRECT_ACCESS(
+					   pex_idx,
+					   PEX_LINK_CTRL_STAT_REG),
 					  reg_data);
 			}
 
-- 
2.32.0


  reply	other threads:[~2021-09-24 20:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24 20:59 [PATCH u-boot-marvell 0/9] a38x serdes cleanup Marek Behún
2021-09-24 20:59 ` Marek Behún [this message]
2021-10-08  6:24   ` [PATCH u-boot-marvell 1/9] arm: mvebu: a38x: serdes: Add comments and use macros in PCIe code Stefan Roese
2021-09-24 20:59 ` [PATCH u-boot-marvell 2/9] arm: mvebu: a38x: serdes: Remove duplicate macro SOC_CTRL_REG Marek Behún
2021-10-08  6:26   ` Stefan Roese
2021-09-24 20:59 ` [PATCH u-boot-marvell 3/9] arm: mvebu: a38x: serdes: Add comments for hws_pex_config() code Marek Behún
2021-10-08  6:27   ` Stefan Roese
2021-09-24 20:59 ` [PATCH u-boot-marvell 4/9] arm: mvebu: a38x: serdes: Don't overwrite read-only SAR PCIe registers Marek Behún
2021-10-08  6:27   ` Stefan Roese
2021-09-24 20:59 ` [PATCH u-boot-marvell 5/9] arm: mvebu: a38x: serdes: Don't set PCIe Common Clock Configuration Marek Behún
2021-10-08  6:28   ` Stefan Roese
2021-09-24 20:59 ` [PATCH u-boot-marvell 6/9] arm: mvebu: a38x: serdes: Don't overwrite PCI device ID Marek Behún
2021-10-08  6:28   ` Stefan Roese
2021-09-24 20:59 ` [PATCH u-boot-marvell 7/9] arm: mvebu: a38x: serdes: Don't configure PCIe cards in SerDes init code Marek Behún
2021-10-08  6:29   ` Stefan Roese
2021-09-24 20:59 ` [PATCH u-boot-marvell 8/9] arm: mvebu: a38x: serdes: Remove unused PCIe macros and functions Marek Behún
2021-10-08  6:29   ` Stefan Roese
2021-09-24 20:59 ` [PATCH u-boot-marvell 9/9] arm: mvebu: a38x: serdes: Update comment about PCIE*_ENABLE_* defines Marek Behún
2021-10-08  6:30   ` Stefan Roese
2021-10-08  6:31 ` [PATCH u-boot-marvell 0/9] a38x serdes cleanup Stefan Roese
2021-10-08  9:18 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210924205922.25432-2-marek.behun@nic.cz \
    --to=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.