public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jagan Teki <jteki@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 14/16] spi: zynq_spi: Add config reg shift named macros
Date: Tue,  1 Sep 2015 11:41:45 +0530	[thread overview]
Message-ID: <1441087907-25993-15-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1441087907-25993-1-git-send-email-jteki@openedev.com>

Update the numerical values for baudrate and chipselect
with config reg shift named macro's

Signed-off-by: Jagan Teki <jteki@openedev.com>
---
 drivers/spi/zynq_spi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/zynq_spi.c b/drivers/spi/zynq_spi.c
index b9cf335..817728c 100644
--- a/drivers/spi/zynq_spi.c
+++ b/drivers/spi/zynq_spi.c
@@ -28,6 +28,10 @@ DECLARE_GLOBAL_DATA_PTR;
 #define ZYNQ_SPI_IXR_ALL_MASK		0x7F		/* All IXR bits */
 #define ZYNQ_SPI_ENR_SPI_EN_MASK	(1 << 0)	/* SPI Enable */
 
+#define ZYNQ_SPI_CR_BAUD_MAX		8	/* Baud rate divisor max val */
+#define ZYNQ_SPI_CR_BAUD_SHIFT		3	/* Baud rate divisor shift */
+#define ZYNQ_SPI_CR_SS_SHIFT		10	/* Slave select shift */
+
 #define ZYNQ_SPI_FIFO_DEPTH		128
 #ifndef CONFIG_SYS_ZYNQ_SPI_WAIT
 #define CONFIG_SYS_ZYNQ_SPI_WAIT	(CONFIG_SYS_HZ/100)	/* 10 ms */
@@ -139,7 +143,7 @@ static void spi_cs_activate(struct udevice *dev, uint cs)
 	 * xx01	- cs1
 	 * x011 - cs2
 	 */
-	cr |= (~(0x1 << cs) << 10) & ZYNQ_SPI_CR_CS_MASK;
+	cr |= (~(0x1 << cs) << ZYNQ_SPI_CR_SS_SHIFT) & ZYNQ_SPI_CR_CS_MASK;
 	writel(cr, &regs->cr);
 }
 
@@ -256,14 +260,14 @@ static int zynq_spi_set_speed(struct udevice *bus, uint speed)
 		/* Set baudrate x8, if the freq is 0 */
 		baud_rate_val = 0x2;
 	} else if (plat->speed_hz != speed) {
-		while ((baud_rate_val < 8) &&
+		while ((baud_rate_val < ZYNQ_SPI_CR_BAUD_MAX) &&
 				((plat->frequency /
 				(2 << baud_rate_val)) > speed))
 			baud_rate_val++;
 		plat->speed_hz = speed / (2 << baud_rate_val);
 	}
 	confr &= ~ZYNQ_SPI_CR_BRD_MASK;
-	confr |= (baud_rate_val << 3);
+	confr |= (baud_rate_val << ZYNQ_SPI_CR_BAUD_SHIFT);
 
 	writel(confr, &regs->cr);
 	priv->freq = speed;
-- 
1.9.1

  parent reply	other threads:[~2015-09-01  6:11 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01  6:11 [U-Boot] [PATCH v4 00/16] spi: zynq qspi support Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 01/16] spi: Add zynq qspi controller driver Jagan Teki
2015-09-03  7:26   ` Siva Durga Prasad Paladugu
2015-09-03  8:07     ` Jagan Teki
2015-09-03  8:38       ` Siva Durga Prasad Paladugu
2015-09-03  9:47         ` Jagan Teki
2015-09-04 11:38       ` Siva Durga Prasad Paladugu
2015-10-13 12:22   ` Hannes Schmelzer
2015-10-15  8:39   ` Hannes Schmelzer
2015-11-05  7:33     ` Hannes Schmelzer
2015-11-05  7:56       ` Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 02/16] dts: zynq: Add zynq qspi controller nodes Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 03/16] doc: device-tree-bindings: spi: Add zynq qspi info Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 04/16] dts: microzed: Enable zynq qspi controller node Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 05/16] dts: zc702: " Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 06/16] dts: zc706: " Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 07/16] dts: zc770-xm010: " Jagan Teki
2015-09-01  8:22   ` Michal Simek
2015-09-01  8:43     ` Jagan Teki
2015-09-01  9:00       ` Michal Simek
2015-09-01  6:11 ` [U-Boot] [PATCH v4 08/16] dts: zed: " Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 09/16] configs: Enable legacy SPI flash interface support Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 10/16] zynq-common: Enable zynq qspi controller support Jagan Teki
2015-09-01  8:19   ` Michal Simek
2015-09-01  6:11 ` [U-Boot] [PATCH v4 11/16] zynq-common: Enable Bank/Extended address register support Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 12/16] configs: zynq: Enable zynq qspi controller Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 13/16] spi: Kconfig: Add Zynq QSPI controller entry Jagan Teki
2015-09-01  8:18   ` Michal Simek
2015-09-01  6:11 ` Jagan Teki [this message]
2015-09-01  6:11 ` [U-Boot] [PATCH v4 15/16] spi: zynq_spi: Rename baudrate divisor mask name Jagan Teki
2015-09-01  6:11 ` [U-Boot] [PATCH v4 16/16] spi: zynq_spi: Store cs value into private data Jagan Teki
2015-09-01  6:14 ` [U-Boot] [PATCH v4 00/16] spi: zynq qspi support Jagan Teki
2015-09-01  8:23   ` Michal Simek
2015-09-04 12:33     ` Jagan Teki

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=1441087907-25993-15-git-send-email-jteki@openedev.com \
    --to=jteki@openedev.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox