2 #include <asm/arch/gpio.h>
6 static void cs_low(struct spi_platform_data *spi)
8 gpio_set_value(spi->cs_bank, spi->cs_num, 0);
11 static void cs_high(struct spi_platform_data *spi)
13 gpio_set_value(spi->cs_bank, spi->cs_num, 1);
16 static void clk_low(struct spi_platform_data *spi)
18 gpio_set_value(spi->clk_bank, spi->clk_num, 0);
21 static void clk_high(struct spi_platform_data *spi)
23 gpio_set_value(spi->clk_bank, spi->clk_num, 1);
26 static void si_low(struct spi_platform_data *spi)
28 gpio_set_value(spi->si_bank, spi->si_num, 0);
31 static void si_high(struct spi_platform_data *spi)
33 gpio_set_value(spi->si_bank, spi->si_num, 1);
37 static char so_read(struct spi_platform_data *spi)
39 return gpio_get_value(spi->so_bank, spi->so_num);
43 void spi_write_byte(struct spi_platform_data *spi, unsigned char address, unsigned char command)
47 unsigned char DELAY = 1;
49 data = (address << 8) + command;
59 for (j = PACKET_LEN; j >= 0; j--) {
62 /* data high or low */
63 if ((data >> j) & 0x1)
78 #ifdef UNUSED_FUNCTIONS
79 unsigned char spi_read_byte(struct spi_platform_data *spi, unsigned char select, unsigned char address)
82 static unsigned int first = 1;
83 unsigned char DELAY = 1;
84 unsigned short data = 0;
87 data = (select << 8) + address;
97 for (j = PACKET_LEN + 8; j >= 0; j--) {
102 /* data high or low */
103 if ((data >> (j - 8)) & 0x1)
112 gpio_cfg_pin(spi->so_bank, spi->so_num, GPIO_INPUT);
118 if (so_read(spi) & 0x1)
133 gpio_cfg_pin(spi->so_bank, spi->so_num, GPIO_OUTPUT);