summaryrefslogtreecommitdiff
path: root/arch/m68k/cpu/mcf5445x/dspi.c
blob: b0e2f2cb01ca2bd5509914006cc48177c6a79dc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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 */