2 * Custom FB driver for tinylcd.com display
4 * Copyright (C) 2013 Noralf Tronnes
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <linux/module.h>
22 #include <linux/kernel.h>
23 #include <linux/init.h>
24 #include <linux/delay.h>
28 #define DRVNAME "fb_tinylcd"
33 static int init_display(struct fbtft_par *par)
35 fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
37 par->fbtftops.reset(par);
39 write_reg(par, 0xB0, 0x80);
40 write_reg(par, 0xC0, 0x0A, 0x0A);
41 write_reg(par, 0xC1, 0x45, 0x07);
42 write_reg(par, 0xC2, 0x33);
43 write_reg(par, 0xC5, 0x00, 0x42, 0x80);
44 write_reg(par, 0xB1, 0xD0, 0x11);
45 write_reg(par, 0xB4, 0x02);
46 write_reg(par, 0xB6, 0x00, 0x22, 0x3B);
47 write_reg(par, 0xB7, 0x07);
48 write_reg(par, 0x36, 0x58);
49 write_reg(par, 0xF0, 0x36, 0xA5, 0xD3);
50 write_reg(par, 0xE5, 0x80);
51 write_reg(par, 0xE5, 0x01);
52 write_reg(par, 0xB3, 0x00);
53 write_reg(par, 0xE5, 0x00);
54 write_reg(par, 0xF0, 0x36, 0xA5, 0x53);
55 write_reg(par, 0xE0, 0x00, 0x35, 0x33, 0x00, 0x00, 0x00,
56 0x00, 0x35, 0x33, 0x00, 0x00, 0x00);
57 write_reg(par, 0x3A, 0x55);
65 static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
67 fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par,
68 "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye);
71 write_reg(par, 0x2A, xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
74 write_reg(par, 0x2B, ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
80 static int set_var(struct fbtft_par *par)
82 fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
84 switch (par->info->var.rotate) {
86 write_reg(par, 0xB6, 0x00, 0x02, 0x3B);
87 write_reg(par, 0x36, 0x28);
90 write_reg(par, 0xB6, 0x00, 0x22, 0x3B);
91 write_reg(par, 0x36, 0x58);
94 write_reg(par, 0xB6, 0x00, 0x22, 0x3B);
95 write_reg(par, 0x36, 0x38);
98 write_reg(par, 0xB6, 0x00, 0x22, 0x3B);
99 write_reg(par, 0x36, 0x08);
107 static struct fbtft_display display = {
112 .init_display = init_display,
113 .set_addr_win = set_addr_win,
117 FBTFT_REGISTER_DRIVER(DRVNAME, "neosec,tinylcd", &display);
119 MODULE_ALIAS("spi:" DRVNAME);
120 MODULE_ALIAS("spi:tinylcd");
122 MODULE_DESCRIPTION("Custom FB driver for tinylcd.com display");
123 MODULE_AUTHOR("Noralf Tronnes");
124 MODULE_LICENSE("GPL");