From: Angelo Dureghello <angelo@sysam.it>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v5 13/13] m68k: add dspi chip-select support
Date: Wed, 13 Mar 2019 21:46:53 +0100 [thread overview]
Message-ID: <20190313204653.9115-13-angelo@sysam.it> (raw)
In-Reply-To: <20190313204653.9115-1-angelo@sysam.it>
Signed-off-by: Angelo Dureghello <angelo@sysam.it>
Changes for v5:
- new patch
---
arch/m68k/cpu/mcf5227x/Makefile | 2 +-
arch/m68k/cpu/mcf5227x/dspi.c | 43 +++++++++++++
arch/m68k/cpu/mcf5227x/start.S | 3 +-
arch/m68k/cpu/mcf5445x/Makefile | 2 +-
arch/m68k/cpu/mcf5445x/dspi.c | 88 +++++++++++++++++++++++++++
arch/m68k/include/asm/coldfire/dspi.h | 4 ++
6 files changed, 139 insertions(+), 3 deletions(-)
create mode 100644 arch/m68k/cpu/mcf5227x/dspi.c
create mode 100644 arch/m68k/cpu/mcf5445x/dspi.c
diff --git a/arch/m68k/cpu/mcf5227x/Makefile b/arch/m68k/cpu/mcf5227x/Makefile
index ef43893c51..6a38c4838e 100644
--- a/arch/m68k/cpu/mcf5227x/Makefile
+++ b/arch/m68k/cpu/mcf5227x/Makefile
@@ -6,4 +6,4 @@
# ccflags-y += -DET_DEBUG
extra-y = start.o
-obj-y = cpu.o speed.o cpu_init.o interrupts.o
+obj-y = cpu.o speed.o cpu_init.o interrupts.o dspi.o
diff --git a/arch/m68k/cpu/mcf5227x/dspi.c b/arch/m68k/cpu/mcf5227x/dspi.c
new file mode 100644
index 0000000000..8fc4da271e
--- /dev/null
+++ b/arch/m68k/cpu/mcf5227x/dspi.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2019
+ * Angelo Dureghello <angleo@sysam.it>
+ *
+ * CPU specific dspi routines
+ */
+
+#include <common.h>
+#include <asm/immap.h>
+#include <asm/io.h>
+
+#ifdef CONFIG_CF_DSPI
+void dspi_chip_select(int cs)
+{
+ struct gpio *gpio = (struct gpio *)MMAP_GPIO;
+
+ switch (cs) {
+ case 0:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_UNMASK);
+ setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
+ break;
+ case 2:
+ clrbits_8(&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK);
+ setbits_8(&gpio->par_timer, GPIO_PAR_TIMER_T2IN_DSPIPCS2);
+ break;
+ }
+}
+
+void dspi_chip_unselect(int cs)
+{
+ struct gpio *gpio = (struct gpio *)MMAP_GPIO;
+
+ switch (cs) {
+ case 0:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
+ break;
+ case 2:
+ clrbits_8(&gpio->par_timer, ~GPIO_PAR_TIMER_T2IN_UNMASK);
+ break;
+ }
+}
+#endif /* CONFIG_CF_DSPI */
diff --git a/arch/m68k/cpu/mcf5227x/start.S b/arch/m68k/cpu/mcf5227x/start.S
index e1b6c35133..61f9c6859c 100644
--- a/arch/m68k/cpu/mcf5227x/start.S
+++ b/arch/m68k/cpu/mcf5227x/start.S
@@ -378,7 +378,8 @@ _start:
clr.l %sp at -
/* run low-level board init code (from flash) */
- bsr board_init_f
+ move.l #board_init_f, %a1
+ jsr (%a1)
/* board_init_f() does not return */
diff --git a/arch/m68k/cpu/mcf5445x/Makefile b/arch/m68k/cpu/mcf5445x/Makefile
index be2cb2a6fb..ba90fc3c34 100644
--- a/arch/m68k/cpu/mcf5445x/Makefile
+++ b/arch/m68k/cpu/mcf5445x/Makefile
@@ -6,4 +6,4 @@
# ccflags-y += -DET_DEBUG
extra-y = start.o
-obj-y = cpu.o speed.o cpu_init.o interrupts.o pci.o
+obj-y = cpu.o speed.o cpu_init.o interrupts.o pci.o dspi.o
diff --git a/arch/m68k/cpu/mcf5445x/dspi.c b/arch/m68k/cpu/mcf5445x/dspi.c
new file mode 100644
index 0000000000..b0e2f2cb01
--- /dev/null
+++ b/arch/m68k/cpu/mcf5445x/dspi.c
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2019
+ * Angelo Dureghello <angleo@sysam.it>
+ *
+ * CPU specific dspi routines
+ */
+
+#include <common.h>
+#include <asm/immap.h>
+#include <asm/io.h>
+
+#ifdef CONFIG_CF_DSPI
+void dspi_chip_select(int cs)
+{
+ struct gpio *gpio = (struct gpio *)MMAP_GPIO;
+
+#ifdef CONFIG_MCF5445x
+ switch (cs) {
+ case 0:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
+ setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
+ break;
+ case 1:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
+ setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
+ break;
+ case 2:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
+ setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
+ break;
+ case 3:
+ clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK);
+ setbits_8(&gpio->par_dma, GPIO_PAR_DMA_DACK0_PCS3);
+ break;
+ case 5:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
+ setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
+ break;
+ }
+#endif
+#ifdef CONFIG_MCF5441x
+ switch (cs) {
+ case 0:
+ clrbits_8(&gpio->par_dspi0,
+ ~GPIO_PAR_DSPI0_PCS0_MASK);
+ setbits_8(&gpio->par_dspi0,
+ GPIO_PAR_DSPI0_PCS0_DSPI0PCS0);
+ break;
+ case 1:
+ clrbits_8(&gpio->par_dspiow,
+ GPIO_PAR_DSPIOW_DSPI0PSC1);
+ setbits_8(&gpio->par_dspiow,
+ GPIO_PAR_DSPIOW_DSPI0PSC1);
+ break;
+ }
+#endif
+}
+
+void dspi_chip_unselect(int cs)
+{
+ struct gpio *gpio = (struct gpio *)MMAP_GPIO;
+
+#ifdef CONFIG_MCF5445x
+ switch (cs) {
+ case 0:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
+ break;
+ case 1:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
+ break;
+ case 2:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
+ break;
+ case 3:
+ clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK);
+ break;
+ case 5:
+ clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
+ break;
+ }
+#endif
+#ifdef CONFIG_MCF5441x
+ if (cs == 1)
+ clrbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1);
+#endif
+}
+#endif /* CONFIG_CF_DSPI */
diff --git a/arch/m68k/include/asm/coldfire/dspi.h b/arch/m68k/include/asm/coldfire/dspi.h
index afd5c79f35..ddd8f33805 100644
--- a/arch/m68k/include/asm/coldfire/dspi.h
+++ b/arch/m68k/include/asm/coldfire/dspi.h
@@ -138,4 +138,8 @@ typedef struct dspi {
/* Bit definitions and macros for DRFDR group */
#define DSPI_RFDR_RXDATA(x) (((x)&0x0000FFFF))
+/* Architecture-related operations */
+void dspi_chip_select(int cs);
+void dspi_chip_unselect(int cs);
+
#endif /* __DSPI_H__ */
--
2.20.1
next prev parent reply other threads:[~2019-03-13 20:46 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-13 20:46 [U-Boot] [PATCH v5 01/13] m68k: add basic set of devicetrees Angelo Dureghello
2019-03-13 20:46 ` [U-Boot] [PATCH v5 02/13] m68k: architecture changes to support fdt Angelo Dureghello
2019-05-26 10:49 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 03/13] m68k: add initial dts files for all m68k boards Angelo Dureghello
2019-05-26 10:49 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 04/13] m68k: enabling long jumps on mcf54x5 SoCs Angelo Dureghello
2019-05-26 10:49 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 05/13] configs: enable use of DT for all m68k boards Angelo Dureghello
2019-05-26 10:49 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 06/13] drivers: spi: cf_spi: add Kconfig option Angelo Dureghello
2019-05-26 10:49 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 07/13] drivers: spi: cf_spi: convert to driver model Angelo Dureghello
2019-05-26 10:50 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 08/13] configs: add DM_SPI config option Angelo Dureghello
2019-05-26 10:50 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 09/13] drivers: serial: mcfuart: add DT support Angelo Dureghello
2019-05-26 10:50 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 10/13] configs: remove CONFIG_SYS_DSPI_XX references Angelo Dureghello
2019-05-26 10:50 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 11/13] m68k: add OF control support to m68k Angelo Dureghello
2019-05-26 10:50 ` Tom Rini
2019-03-13 20:46 ` [U-Boot] [PATCH v5 12/13] m68k: move dspi bus control functions into cf_spi.c driver Angelo Dureghello
2019-05-26 10:50 ` Tom Rini
2019-03-13 20:46 ` Angelo Dureghello [this message]
2019-05-26 10:50 ` [U-Boot] [PATCH v5 13/13] m68k: add dspi chip-select support Tom Rini
2019-04-19 6:40 ` [U-Boot] [PATCH v5 01/13] m68k: add basic set of devicetrees Jagan Teki
2019-04-22 14:06 ` Tom Rini
2019-04-26 15:27 ` Jagan Teki
2019-05-20 17:28 ` Jagan Teki
2019-05-20 17:44 ` Tom Rini
2019-05-26 10:49 ` Tom Rini
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=20190313204653.9115-13-angelo@sysam.it \
--to=angelo@sysam.it \
--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