]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/fbtft/fb_tinylcd.c
Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[mirror_ubuntu-artful-kernel.git] / drivers / staging / fbtft / fb_tinylcd.c
1 /*
2 * Custom FB driver for tinylcd.com display
3 *
4 * Copyright (C) 2013 Noralf Tronnes
5 *
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.
10 *
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.
15 */
16
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/delay.h>
21 #include <video/mipi_display.h>
22
23 #include "fbtft.h"
24
25 #define DRVNAME "fb_tinylcd"
26 #define WIDTH 320
27 #define HEIGHT 480
28
29 static int init_display(struct fbtft_par *par)
30 {
31 par->fbtftops.reset(par);
32
33 write_reg(par, 0xB0, 0x80);
34 write_reg(par, 0xC0, 0x0A, 0x0A);
35 write_reg(par, 0xC1, 0x45, 0x07);
36 write_reg(par, 0xC2, 0x33);
37 write_reg(par, 0xC5, 0x00, 0x42, 0x80);
38 write_reg(par, 0xB1, 0xD0, 0x11);
39 write_reg(par, 0xB4, 0x02);
40 write_reg(par, 0xB6, 0x00, 0x22, 0x3B);
41 write_reg(par, 0xB7, 0x07);
42 write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, 0x58);
43 write_reg(par, 0xF0, 0x36, 0xA5, 0xD3);
44 write_reg(par, 0xE5, 0x80);
45 write_reg(par, 0xE5, 0x01);
46 write_reg(par, 0xB3, 0x00);
47 write_reg(par, 0xE5, 0x00);
48 write_reg(par, 0xF0, 0x36, 0xA5, 0x53);
49 write_reg(par, 0xE0, 0x00, 0x35, 0x33, 0x00, 0x00, 0x00,
50 0x00, 0x35, 0x33, 0x00, 0x00, 0x00);
51 write_reg(par, MIPI_DCS_SET_PIXEL_FORMAT, 0x55);
52 write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE);
53 udelay(250);
54 write_reg(par, MIPI_DCS_SET_DISPLAY_ON);
55
56 return 0;
57 }
58
59 static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
60 {
61 write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,
62 xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
63
64 write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS,
65 ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
66
67 write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
68 }
69
70 static int set_var(struct fbtft_par *par)
71 {
72 switch (par->info->var.rotate) {
73 case 270:
74 write_reg(par, 0xB6, 0x00, 0x02, 0x3B);
75 write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, 0x28);
76 break;
77 case 180:
78 write_reg(par, 0xB6, 0x00, 0x22, 0x3B);
79 write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, 0x58);
80 break;
81 case 90:
82 write_reg(par, 0xB6, 0x00, 0x22, 0x3B);
83 write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, 0x38);
84 break;
85 default:
86 write_reg(par, 0xB6, 0x00, 0x22, 0x3B);
87 write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, 0x08);
88 break;
89 }
90
91 return 0;
92 }
93
94 static struct fbtft_display display = {
95 .regwidth = 8,
96 .width = WIDTH,
97 .height = HEIGHT,
98 .fbtftops = {
99 .init_display = init_display,
100 .set_addr_win = set_addr_win,
101 .set_var = set_var,
102 },
103 };
104
105 FBTFT_REGISTER_DRIVER(DRVNAME, "neosec,tinylcd", &display);
106
107 MODULE_ALIAS("spi:" DRVNAME);
108 MODULE_ALIAS("spi:tinylcd");
109
110 MODULE_DESCRIPTION("Custom FB driver for tinylcd.com display");
111 MODULE_AUTHOR("Noralf Tronnes");
112 MODULE_LICENSE("GPL");