From 196afe62d6b3e720295bbda046d260ccc6292a28 Mon Sep 17 00:00:00 2001 From: Angelo Dureghello Date: Wed, 13 Mar 2019 21:46:53 +0100 Subject: m68k: add dspi chip-select support Signed-off-by: Angelo Dureghello 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 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 arch/m68k/cpu/mcf5227x/dspi.c create mode 100644 arch/m68k/cpu/mcf5445x/dspi.c (limited to 'arch/m68k/cpu') 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 + * + * CPU specific dspi routines + */ + +#include +#include +#include + +#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@- /* 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 + * + * CPU specific dspi routines + */ + +#include +#include +#include + +#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 */ -- cgit v1.2.3