]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/emk/top9000/spi.c
gic: fixed compilation error in GICv2 wait for interrupt macro
[karo-tx-uboot.git] / board / emk / top9000 / spi.c
1 /*
2  * Copyright (C) 2010
3  * Reinhard Meyer, EMK Elektronik, reinhard.meyer@emk-elektronik.de
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <asm/arch/hardware.h>
10 #include <asm/arch/at91_spi.h>
11 #include <asm/arch/gpio.h>
12 #include <spi.h>
13
14 static const struct {
15         u32     port;
16         u32     bit;
17 } cs_to_portbit[2][4] = {
18         {{AT91_PIO_PORTA,  3}, {AT91_PIO_PORTC, 11},
19                         {AT91_PIO_PORTC, 16}, {AT91_PIO_PORTC, 17} },
20         {{AT91_PIO_PORTB,  3}, {AT91_PIO_PORTC,  5},
21                         {AT91_PIO_PORTC,  4}, {AT91_PIO_PORTC,  3} }
22 };
23
24 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
25 {
26         debug("spi_cs_is_valid: bus=%u cs=%u\n", bus, cs);
27         if (bus < 2 && cs < 4)
28                 return 1;
29         return 0;
30 }
31
32 void spi_cs_activate(struct spi_slave *slave)
33 {
34         debug("spi_cs_activate: bus=%u cs=%u\n", slave->bus, slave->cs);
35         at91_set_pio_output(cs_to_portbit[slave->bus][slave->cs].port,
36                 cs_to_portbit[slave->bus][slave->cs].bit, 0);
37 }
38
39 void spi_cs_deactivate(struct spi_slave *slave)
40 {
41         debug("spi_cs_deactivate: bus=%u cs=%u\n", slave->bus, slave->cs);
42         at91_set_pio_output(cs_to_portbit[slave->bus][slave->cs].port,
43                 cs_to_portbit[slave->bus][slave->cs].bit, 1);
44 }