Albin Tonnerre | 9453967 | 2009-08-24 18:03:26 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 |
| 3 | * Albin Tonnerre, Free Electrons <albin.tonnerre@free-electrons.com> |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Albin Tonnerre | 9453967 | 2009-08-24 18:03:26 +0200 | [diff] [blame] | 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 | #define SBC_A9260_CS0_PIN AT91_PIN_PA3 |
| 15 | #define SBC_A9260_CS1_PIN AT91_PIN_PC11 |
| 16 | |
| 17 | int spi_cs_is_valid(unsigned int bus, unsigned int cs) |
| 18 | { |
| 19 | return bus == 0 && (cs == 1 || cs == 0); |
| 20 | } |
| 21 | |
| 22 | void spi_cs_activate(struct spi_slave *slave) |
| 23 | { |
| 24 | if(slave->cs == 0) |
| 25 | at91_set_gpio_value(SBC_A9260_CS0_PIN, 0); |
| 26 | else if(slave->cs == 1) |
| 27 | at91_set_gpio_value(SBC_A9260_CS1_PIN, 0); |
| 28 | } |
| 29 | |
| 30 | void spi_cs_deactivate(struct spi_slave *slave) |
| 31 | { |
| 32 | if(slave->cs == 0) |
| 33 | at91_set_gpio_value(SBC_A9260_CS0_PIN, 1); |
| 34 | else if(slave->cs == 1) |
| 35 | at91_set_gpio_value(SBC_A9260_CS1_PIN, 1); |
| 36 | } |
| 37 | |
| 38 | void spi_init_f(void) |
| 39 | { |
| 40 | /* everything done in board_init */ |
| 41 | } |