Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make st7735fb work #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
11 changes: 1 addition & 10 deletions drivers/video/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion drivers/video/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions drivers/video/st7735fb/Kconfig
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions drivers/video/st7735fb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obj-$(CONFIG_FB_ST7735) += st7735fb.o
obj-$(CONFIG_FB_ST7735_MAP) += st7735fb_map.o
File renamed without changes.
File renamed without changes.
101 changes: 101 additions & 0 deletions drivers/video/st7735fb/st7735fb_map.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#include <linux/module.h>
#include <linux/spi/spi.h>
#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");