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 v3 12/16] spi: zynq_spi: Add fdt support in driver
Date: Sat, 27 Jun 2015 00:51:34 +0530	[thread overview]
Message-ID: <1435346498-3676-13-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1435346498-3676-1-git-send-email-jteki@openedev.com>

Now zynq spi driver platform data is controlled by devicetree,
enable the status by saying "okay" on respective board dts to use
the devicetree generated platdata.

Ex:
&spi1 {
	status = "okay";
};

Signed-off-by: Jagan Teki <jteki@openedev.com>
Acked-by: Simon Glass <sjg@chromium.org>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Tested-by: Jagan Teki <jteki@openedev.com>
---
 arch/arm/dts/zynq-7000.dtsi               |  2 ++
 doc/device-tree-bindings/spi/spi-zynq.txt |  2 ++
 drivers/spi/zynq_spi.c                    | 23 +++++++++++++----------
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/arch/arm/dts/zynq-7000.dtsi b/arch/arm/dts/zynq-7000.dtsi
index f66f8dc..9207159 100644
--- a/arch/arm/dts/zynq-7000.dtsi
+++ b/arch/arm/dts/zynq-7000.dtsi
@@ -117,6 +117,7 @@
 			interrupts = <0 26 4>;
 			clocks = <&clkc 25>, <&clkc 34>;
 			clock-names = "ref_clk", "pclk";
+			spi-max-frequency = <166666700>;
 			#address-cells = <1>;
 			#size-cells = <0>;
 		};
@@ -129,6 +130,7 @@
 			interrupts = <0 49 4>;
 			clocks = <&clkc 26>, <&clkc 35>;
 			clock-names = "ref_clk", "pclk";
+			spi-max-frequency = <166666700>;
 			#address-cells = <1>;
 			#size-cells = <0>;
 		};
diff --git a/doc/device-tree-bindings/spi/spi-zynq.txt b/doc/device-tree-bindings/spi/spi-zynq.txt
index a7c2757..f397a36 100644
--- a/doc/device-tree-bindings/spi/spi-zynq.txt
+++ b/doc/device-tree-bindings/spi/spi-zynq.txt
@@ -11,6 +11,7 @@ Required properties:
 - clocks		: Clock phandles (see clock bindings for details).
 - clock-names		: List of input clock names - "ref_clk", "pclk"
 			  (See clock bindings for details).
+- spi-max-frequency	: Maximum SPI clocking speed of device in Hz
 
 Example:
 
@@ -22,6 +23,7 @@ Example:
 		interrupts = <0 26 4>;
 		clocks = <&clkc 25>, <&clkc 34>;
 		clock-names = "ref_clk", "pclk";
+		spi-max-frequency = <166666700>;
 		#address-cells = <1>;
 		#size-cells = <0>;
 	} ;
diff --git a/drivers/spi/zynq_spi.c b/drivers/spi/zynq_spi.c
index 50fb1aa..c5c3e10 100644
--- a/drivers/spi/zynq_spi.c
+++ b/drivers/spi/zynq_spi.c
@@ -13,9 +13,12 @@
 #include <errno.h>
 #include <malloc.h>
 #include <spi.h>
+#include <fdtdec.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* zynq spi register bit masks ZYNQ_SPI_<REG>_<BIT>_MASK */
 #define ZYNQ_SPI_CR_MSA_MASK		(1 << 15)	/* Manual start enb */
 #define ZYNQ_SPI_CR_MCS_MASK		(1 << 14)	/* Manual chip select */
@@ -63,22 +66,22 @@ struct zynq_spi_priv {
 	u32 freq;		/* required frequency */
 };
 
-static inline struct zynq_spi_regs *get_zynq_spi_regs(struct udevice *bus)
-{
-	if (bus->seq)
-		return (struct zynq_spi_regs *)ZYNQ_SPI_BASEADDR1;
-	else
-		return (struct zynq_spi_regs *)ZYNQ_SPI_BASEADDR0;
-}
-
 static int zynq_spi_ofdata_to_platdata(struct udevice *bus)
 {
 	struct zynq_spi_platdata *plat = bus->platdata;
+	const void *blob = gd->fdt_blob;
+	int node = bus->of_offset;
+
+	plat->regs = (struct zynq_spi_regs *)fdtdec_get_addr(blob, node, "reg");
 
-	plat->regs = get_zynq_spi_regs(bus);
-	plat->frequency = 166666700;
+	/* FIXME: Use 250MHz as a suitable default */
+	plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
+					250000000);
 	plat->speed_hz = plat->frequency / 2;
 
+	debug("zynq_spi_ofdata_to_platdata: regs=%p max-frequency=%d\n",
+	      plat->regs, plat->frequency);
+
 	return 0;
 }
 
-- 
1.9.1

  parent reply	other threads:[~2015-06-26 19:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26 19:21 [U-Boot] [PATCH v3 00/16] spi/sf: Cleansup and driver model Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 01/16] spi: Zap andes_spi driver Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 02/16] spi: Zap ftssp010_spi driver Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 03/16] spi: Zap oc_tiny_spi driver Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 04/16] spi: xilinx_spi: Move header code to driver Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 05/16] spi: xilinx_spi: Driver clean-up Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 06/16] spi: davinci_spi: Move header code to driver Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 07/16] spi: davinci_spi: Driver cleanup Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 08/16] spi/sf: Minor cleanups Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 09/16] dm: spi: zynq_spi: Convert to driver model Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 10/16] zynq: Kconfig: Enable dm spi and spi_flash Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 11/16] dts: zynq: Add zynq spi controller nodes Jagan Teki
2015-06-26 19:21 ` Jagan Teki [this message]
2015-06-26 19:21 ` [U-Boot] [PATCH v3 13/16] dts: zynq: Enable spi1 for zc770_xm010 board Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 14/16] dm: spi: xilinx_spi: Convert to driver model Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 15/16] spi: xilinx_spi: Add asm/io.h include file Jagan Teki
2015-06-26 19:21 ` [U-Boot] [PATCH v3 16/16] spi: Kconfig: Add Zynq SPI controller entry Jagan Teki
2015-06-30 14:58   ` Simon Glass
2015-06-26 19:27 ` [U-Boot] [PATCH v3 00/16] spi/sf: Cleansup and driver model Jagan Teki
2015-07-01 16:52   ` 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=1435346498-3676-13-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