|
@@ -2,9 +2,6 @@
|
|
#include <linux/errno.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/spi/spi.h>
|
|
-#ifdef CONFIG_ARCH_BCM2708
|
|
|
|
-#include <mach/platform.h>
|
|
|
|
-#endif
|
|
|
|
#include "fbtft.h"
|
|
#include "fbtft.h"
|
|
|
|
|
|
int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len)
|
|
int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len)
|
|
@@ -129,171 +126,6 @@ int fbtft_read_spi(struct fbtft_par *par, void *buf, size_t len)
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(fbtft_read_spi);
|
|
EXPORT_SYMBOL(fbtft_read_spi);
|
|
|
|
|
|
-
|
|
|
|
-#ifdef CONFIG_ARCH_BCM2708
|
|
|
|
-
|
|
|
|
-/*
|
|
|
|
- * Raspberry Pi
|
|
|
|
- * - writing directly to the registers is 40-50% faster than
|
|
|
|
- * optimized use of gpiolib
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
-#define GPIOSET(no, ishigh) \
|
|
|
|
-do { \
|
|
|
|
- if (ishigh) \
|
|
|
|
- set |= (1 << (no)); \
|
|
|
|
- else \
|
|
|
|
- reset |= (1 << (no)); \
|
|
|
|
-} while (0)
|
|
|
|
-
|
|
|
|
-int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
|
|
|
|
-{
|
|
|
|
- unsigned int set = 0;
|
|
|
|
- unsigned int reset = 0;
|
|
|
|
- u8 data;
|
|
|
|
-
|
|
|
|
- fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
|
|
|
|
- "%s(len=%d): ", __func__, len);
|
|
|
|
-
|
|
|
|
- while (len--) {
|
|
|
|
- data = *(u8 *) buf;
|
|
|
|
- buf++;
|
|
|
|
-
|
|
|
|
- /* Set data */
|
|
|
|
- GPIOSET(par->gpio.db[0], (data&0x01));
|
|
|
|
- GPIOSET(par->gpio.db[1], (data&0x02));
|
|
|
|
- GPIOSET(par->gpio.db[2], (data&0x04));
|
|
|
|
- GPIOSET(par->gpio.db[3], (data&0x08));
|
|
|
|
- GPIOSET(par->gpio.db[4], (data&0x10));
|
|
|
|
- GPIOSET(par->gpio.db[5], (data&0x20));
|
|
|
|
- GPIOSET(par->gpio.db[6], (data&0x40));
|
|
|
|
- GPIOSET(par->gpio.db[7], (data&0x80));
|
|
|
|
- writel(set, __io_address(GPIO_BASE+0x1C));
|
|
|
|
- writel(reset, __io_address(GPIO_BASE+0x28));
|
|
|
|
-
|
|
|
|
- /* Pulse /WR low */
|
|
|
|
- writel((1<<par->gpio.wr), __io_address(GPIO_BASE+0x28));
|
|
|
|
- writel(0, __io_address(GPIO_BASE+0x28)); /* used as a delay */
|
|
|
|
- writel((1<<par->gpio.wr), __io_address(GPIO_BASE+0x1C));
|
|
|
|
-
|
|
|
|
- set = 0;
|
|
|
|
- reset = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-EXPORT_SYMBOL(fbtft_write_gpio8_wr);
|
|
|
|
-
|
|
|
|
-int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
|
|
|
|
-{
|
|
|
|
- unsigned int set = 0;
|
|
|
|
- unsigned int reset = 0;
|
|
|
|
- u16 data;
|
|
|
|
-
|
|
|
|
- fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
|
|
|
|
- "%s(len=%d): ", __func__, len);
|
|
|
|
-
|
|
|
|
- while (len) {
|
|
|
|
- len -= 2;
|
|
|
|
- data = *(u16 *) buf;
|
|
|
|
- buf += 2;
|
|
|
|
-
|
|
|
|
- /* Start writing by pulling down /WR */
|
|
|
|
- gpio_set_value(par->gpio.wr, 0);
|
|
|
|
-
|
|
|
|
- /* Set data */
|
|
|
|
- GPIOSET(par->gpio.db[0], (data&0x0001));
|
|
|
|
- GPIOSET(par->gpio.db[1], (data&0x0002));
|
|
|
|
- GPIOSET(par->gpio.db[2], (data&0x0004));
|
|
|
|
- GPIOSET(par->gpio.db[3], (data&0x0008));
|
|
|
|
- GPIOSET(par->gpio.db[4], (data&0x0010));
|
|
|
|
- GPIOSET(par->gpio.db[5], (data&0x0020));
|
|
|
|
- GPIOSET(par->gpio.db[6], (data&0x0040));
|
|
|
|
- GPIOSET(par->gpio.db[7], (data&0x0080));
|
|
|
|
-
|
|
|
|
- GPIOSET(par->gpio.db[8], (data&0x0100));
|
|
|
|
- GPIOSET(par->gpio.db[9], (data&0x0200));
|
|
|
|
- GPIOSET(par->gpio.db[10], (data&0x0400));
|
|
|
|
- GPIOSET(par->gpio.db[11], (data&0x0800));
|
|
|
|
- GPIOSET(par->gpio.db[12], (data&0x1000));
|
|
|
|
- GPIOSET(par->gpio.db[13], (data&0x2000));
|
|
|
|
- GPIOSET(par->gpio.db[14], (data&0x4000));
|
|
|
|
- GPIOSET(par->gpio.db[15], (data&0x8000));
|
|
|
|
-
|
|
|
|
- writel(set, __io_address(GPIO_BASE+0x1C));
|
|
|
|
- writel(reset, __io_address(GPIO_BASE+0x28));
|
|
|
|
-
|
|
|
|
- /* Pullup /WR */
|
|
|
|
- gpio_set_value(par->gpio.wr, 1);
|
|
|
|
-
|
|
|
|
- set = 0;
|
|
|
|
- reset = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-EXPORT_SYMBOL(fbtft_write_gpio16_wr);
|
|
|
|
-
|
|
|
|
-int fbtft_write_gpio16_wr_latched(struct fbtft_par *par, void *buf, size_t len)
|
|
|
|
-{
|
|
|
|
- unsigned int set = 0;
|
|
|
|
- unsigned int reset = 0;
|
|
|
|
- u16 data;
|
|
|
|
-
|
|
|
|
- fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
|
|
|
|
- "%s(len=%d): ", __func__, len);
|
|
|
|
-
|
|
|
|
- while (len) {
|
|
|
|
- len -= 2;
|
|
|
|
- data = *(u16 *) buf;
|
|
|
|
- buf += 2;
|
|
|
|
-
|
|
|
|
- /* Start writing by pulling down /WR */
|
|
|
|
- gpio_set_value(par->gpio.wr, 0);
|
|
|
|
-
|
|
|
|
- /* Low byte */
|
|
|
|
- GPIOSET(par->gpio.db[0], (data&0x0001));
|
|
|
|
- GPIOSET(par->gpio.db[1], (data&0x0002));
|
|
|
|
- GPIOSET(par->gpio.db[2], (data&0x0004));
|
|
|
|
- GPIOSET(par->gpio.db[3], (data&0x0008));
|
|
|
|
- GPIOSET(par->gpio.db[4], (data&0x0010));
|
|
|
|
- GPIOSET(par->gpio.db[5], (data&0x0020));
|
|
|
|
- GPIOSET(par->gpio.db[6], (data&0x0040));
|
|
|
|
- GPIOSET(par->gpio.db[7], (data&0x0080));
|
|
|
|
- writel(set, __io_address(GPIO_BASE+0x1C));
|
|
|
|
- writel(reset, __io_address(GPIO_BASE+0x28));
|
|
|
|
-
|
|
|
|
- /* Pulse 'latch' high */
|
|
|
|
- gpio_set_value(par->gpio.latch, 1);
|
|
|
|
- gpio_set_value(par->gpio.latch, 0);
|
|
|
|
-
|
|
|
|
- /* High byte */
|
|
|
|
- GPIOSET(par->gpio.db[0], (data&0x0100));
|
|
|
|
- GPIOSET(par->gpio.db[1], (data&0x0200));
|
|
|
|
- GPIOSET(par->gpio.db[2], (data&0x0400));
|
|
|
|
- GPIOSET(par->gpio.db[3], (data&0x0800));
|
|
|
|
- GPIOSET(par->gpio.db[4], (data&0x1000));
|
|
|
|
- GPIOSET(par->gpio.db[5], (data&0x2000));
|
|
|
|
- GPIOSET(par->gpio.db[6], (data&0x4000));
|
|
|
|
- GPIOSET(par->gpio.db[7], (data&0x8000));
|
|
|
|
- writel(set, __io_address(GPIO_BASE+0x1C));
|
|
|
|
- writel(reset, __io_address(GPIO_BASE+0x28));
|
|
|
|
-
|
|
|
|
- /* Pullup /WR */
|
|
|
|
- gpio_set_value(par->gpio.wr, 1);
|
|
|
|
-
|
|
|
|
- set = 0;
|
|
|
|
- reset = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-EXPORT_SYMBOL(fbtft_write_gpio16_wr_latched);
|
|
|
|
-
|
|
|
|
-#undef GPIOSET
|
|
|
|
-
|
|
|
|
-#else
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* Optimized use of gpiolib is twice as fast as no optimization
|
|
* Optimized use of gpiolib is twice as fast as no optimization
|
|
* only one driver can use the optimized version at a time
|
|
* only one driver can use the optimized version at a time
|
|
@@ -405,5 +237,3 @@ int fbtft_write_gpio16_wr_latched(struct fbtft_par *par, void *buf, size_t len)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(fbtft_write_gpio16_wr_latched);
|
|
EXPORT_SYMBOL(fbtft_write_gpio16_wr_latched);
|
|
-
|
|
|
|
-#endif /* CONFIG_ARCH_BCM2708 */
|
|
|