diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c index 3a95388b841493..99a727f984a100 100644 --- a/arch/arm/mach-bcm2708/bcm2708.c +++ b/arch/arm/mach-bcm2708/bcm2708.c @@ -521,12 +521,6 @@ static struct platform_device bcm2708_spi_device = { static struct spi_board_info bcm2708_spi_devices[] = { { - .modalias = "spidev", - .max_speed_hz = 500000, - .bus_num = 0, - .chip_select = 0, - .mode = SPI_MODE_0, - }, { .modalias = "spidev", .max_speed_hz = 500000, .bus_num = 0, diff --git a/drivers/Makefile b/drivers/Makefile index 7fa433a7030c4e..855d414fe61a1f 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -51,6 +51,10 @@ obj-$(CONFIG_ATA) += ata/ obj-$(CONFIG_TARGET_CORE) += target/ obj-$(CONFIG_MTD) += mtd/ obj-$(CONFIG_SPI) += spi/ + +#st7735fb depends on SPI +obj-y += video/st7735fb/ + obj-y += net/ obj-$(CONFIG_ATM) += atm/ obj-$(CONFIG_FUSION) += message/ diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 26124d12e9720a..2c3976e2f22561 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -2397,16 +2397,7 @@ config FB_PUV3_UNIGFX Choose this option if you want to use the Unigfx device as a framebuffer device. Without the support of PCI & AGP. -config FB_ST7735 - tristate "ST7735 framebuffer support" - depends on FB - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_DEFERRED_IO - select FB_SYS_FOPS - help - Support for ST7735 framebuffer device family +source "drivers/video/st7735fb/Kconfig" source "drivers/video/omap/Kconfig" source "drivers/video/omap2/Kconfig" diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 21b53fefa3ce09..0c5cee3b6c431c 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -157,7 +157,6 @@ obj-$(CONFIG_FB_BFIN_7393) += bfin_adv7393fb.o obj-$(CONFIG_FB_MX3) += mx3fb.o obj-$(CONFIG_FB_DA8XX) += da8xx-fb.o obj-$(CONFIG_FB_MXS) += mxsfb.o -obj-$(CONFIG_FB_ST7735) += st7735fb.o # the test framebuffer is last obj-$(CONFIG_FB_VIRTUAL) += vfb.o diff --git a/drivers/video/st7735fb/Kconfig b/drivers/video/st7735fb/Kconfig new file mode 100644 index 00000000000000..8f6be413737d90 --- /dev/null +++ b/drivers/video/st7735fb/Kconfig @@ -0,0 +1,17 @@ +config FB_ST7735 + tristate "ST7735 framebuffer support" + depends on FB + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + select FB_DEFERRED_IO + select FB_SYS_FOPS + help + Support for ST7735 framebuffer device family + +config FB_ST7735_MAP + tristate "ST7735 framebuffer mapping to SPI0.0" + depends on FB_ST7735 + default n + help + Include support for an ST7735FB display on SPI0, CS0. diff --git a/drivers/video/st7735fb/Makefile b/drivers/video/st7735fb/Makefile new file mode 100644 index 00000000000000..441f9868adc2d9 --- /dev/null +++ b/drivers/video/st7735fb/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_FB_ST7735) += st7735fb.o +obj-$(CONFIG_FB_ST7735_MAP) += st7735fb_map.o diff --git a/drivers/video/st7735fb.c b/drivers/video/st7735fb/st7735fb.c similarity index 100% rename from drivers/video/st7735fb.c rename to drivers/video/st7735fb/st7735fb.c diff --git a/drivers/video/st7735fb.h b/drivers/video/st7735fb/st7735fb.h similarity index 100% rename from drivers/video/st7735fb.h rename to drivers/video/st7735fb/st7735fb.h diff --git a/drivers/video/st7735fb/st7735fb_map.c b/drivers/video/st7735fb/st7735fb_map.c new file mode 100644 index 00000000000000..ffe6d89714932a --- /dev/null +++ b/drivers/video/st7735fb/st7735fb_map.c @@ -0,0 +1,101 @@ +#include +#include +#include "st7735fb.h" + +#define SPI_BUS 0 +#define SPI_BUS_CS 0 +#define SPI_BUS_SPEED 12000000 + +const char this_driver_name[] = "adafruit_tft18"; + +static struct st7735fb_platform_data st7735fb_data = { + .rst_gpio = 23, + .dc_gpio = 24, +}; + + +static int __init add_st7735fb_device_to_bus(void) +{ + struct spi_master *spi_master; + struct spi_device *spi_device; + struct device *pdev; + char buff[64]; + int status = 0; + + spi_master = spi_busnum_to_master(SPI_BUS); + if (!spi_master) { + printk(KERN_ALERT "spi_busnum_to_master(%d) returned NULL\n", + SPI_BUS); + printk(KERN_ALERT "SPI bus initialised?\n"); + return -1; + } + + spi_device = spi_alloc_device(spi_master); + if (!spi_device) { + put_device(&spi_master->dev); + printk(KERN_ALERT "spi_alloc_device() failed\n"); + return -1; + } + + /* specify a chip select line */ + spi_device->chip_select = SPI_BUS_CS; + + /* Check whether this SPI bus.cs is already claimed */ + snprintf(buff, sizeof(buff), "%s.%u", + dev_name(&spi_device->master->dev), + spi_device->chip_select); + + pdev = bus_find_device_by_name(spi_device->dev.bus, NULL, buff); + if (pdev) { + /* We are not going to use this spi_device, so free it */ + spi_dev_put(spi_device); + + /* + * There is already a device configured for this bus.cs combination. + * It's okay if it's us. This happens if we previously loaded then + * unloaded our driver. + * If it is not us, we complain and fail. + */ + if (pdev->driver && pdev->driver->name && + strcmp(this_driver_name, pdev->driver->name)) { + printk(KERN_ALERT + "Driver [%s] already registered for %s\n", + pdev->driver->name, buff); + status = -1; + } + } else { + spi_device->dev.platform_data = &st7735fb_data; + spi_device->max_speed_hz = SPI_BUS_SPEED; + spi_device->mode = SPI_MODE_3; + spi_device->bits_per_word = 8; + spi_device->irq = -1; + spi_device->controller_state = NULL; + spi_device->controller_data = NULL; + strlcpy(spi_device->modalias, this_driver_name, SPI_NAME_SIZE); + status = spi_add_device(spi_device); + + if (status < 0) { + spi_dev_put(spi_device); + printk(KERN_ALERT "spi_add_device() failed: %d\n", + status); + } + } + + put_device(&spi_master->dev); + + return status; +} +module_init(add_st7735fb_device_to_bus); + +static void __exit st7735fb_unmap(void) +{ + printk(KERN_ALERT "no unmap function written yet - device still registered\n"); +} +module_exit(st7735fb_unmap); + +MODULE_AUTHOR("Neil Greatorex"); +MODULE_DESCRIPTION("Bind SPI to st7735fb"); +MODULE_LICENSE("GPL"); +MODULE_VERSION("0.2"); + +