Commit | Line | Data |
---|---|---|
d416d5c0 TP |
1 | /* |
2 | * FB driver for the ILI9481 LCD Controller | |
3 | * | |
4 | * Copyright (c) 2014 Petr Olivka | |
5 | * Copyright (c) 2013 Noralf Tronnes | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
d416d5c0 TP |
16 | */ |
17 | ||
18 | #include <linux/module.h> | |
19 | #include <linux/kernel.h> | |
20 | #include <linux/init.h> | |
21 | #include <linux/delay.h> | |
89823edc | 22 | #include <video/mipi_display.h> |
d416d5c0 TP |
23 | |
24 | #include "fbtft.h" | |
25 | ||
26 | #define DRVNAME "fb_ili9481" | |
27 | #define WIDTH 320 | |
28 | #define HEIGHT 480 | |
29 | ||
30 | static int default_init_sequence[] = { | |
d416d5c0 | 31 | /* SLP_OUT - Sleep out */ |
89823edc | 32 | -1, MIPI_DCS_EXIT_SLEEP_MODE, |
d416d5c0 TP |
33 | -2, 50, |
34 | /* Power setting */ | |
35 | -1, 0xD0, 0x07, 0x42, 0x18, | |
36 | /* VCOM */ | |
37 | -1, 0xD1, 0x00, 0x07, 0x10, | |
38 | /* Power setting for norm. mode */ | |
39 | -1, 0xD2, 0x01, 0x02, | |
40 | /* Panel driving setting */ | |
41 | -1, 0xC0, 0x10, 0x3B, 0x00, 0x02, 0x11, | |
42 | /* Frame rate & inv. */ | |
43 | -1, 0xC5, 0x03, | |
44 | /* Pixel format */ | |
89823edc | 45 | -1, MIPI_DCS_SET_PIXEL_FORMAT, 0x55, |
d416d5c0 TP |
46 | /* Gamma */ |
47 | -1, 0xC8, 0x00, 0x32, 0x36, 0x45, 0x06, 0x16, | |
48 | 0x37, 0x75, 0x77, 0x54, 0x0C, 0x00, | |
49 | /* DISP_ON */ | |
89823edc | 50 | -1, MIPI_DCS_SET_DISPLAY_ON, |
d416d5c0 TP |
51 | -3 |
52 | }; | |
53 | ||
54 | static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) | |
55 | { | |
89823edc PL |
56 | write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS, |
57 | xs >> 8, xs & 0xff, xe >> 8, xe & 0xff); | |
d416d5c0 | 58 | |
89823edc PL |
59 | write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS, |
60 | ys >> 8, ys & 0xff, ye >> 8, ye & 0xff); | |
d416d5c0 | 61 | |
89823edc | 62 | write_reg(par, MIPI_DCS_WRITE_MEMORY_START); |
d416d5c0 TP |
63 | } |
64 | ||
65 | #define HFLIP 0x01 | |
66 | #define VFLIP 0x02 | |
61abd03a | 67 | #define ROW_X_COL 0x20 |
d416d5c0 TP |
68 | static int set_var(struct fbtft_par *par) |
69 | { | |
d416d5c0 TP |
70 | switch (par->info->var.rotate) { |
71 | case 270: | |
89823edc | 72 | write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, |
61abd03a | 73 | ROW_X_COL | HFLIP | VFLIP | (par->bgr << 3)); |
d416d5c0 TP |
74 | break; |
75 | case 180: | |
89823edc PL |
76 | write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, |
77 | VFLIP | (par->bgr << 3)); | |
d416d5c0 TP |
78 | break; |
79 | case 90: | |
89823edc | 80 | write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, |
61abd03a | 81 | ROW_X_COL | (par->bgr << 3)); |
d416d5c0 TP |
82 | break; |
83 | default: | |
89823edc PL |
84 | write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, |
85 | HFLIP | (par->bgr << 3)); | |
d416d5c0 TP |
86 | break; |
87 | } | |
88 | ||
89 | return 0; | |
90 | } | |
91 | ||
92 | static struct fbtft_display display = { | |
93 | .regwidth = 8, | |
94 | .width = WIDTH, | |
95 | .height = HEIGHT, | |
96 | .init_sequence = default_init_sequence, | |
97 | .fbtftops = { | |
98 | .set_addr_win = set_addr_win, | |
99 | .set_var = set_var, | |
100 | }, | |
101 | }; | |
1014c2ce | 102 | |
d416d5c0 TP |
103 | FBTFT_REGISTER_DRIVER(DRVNAME, "ilitek,ili9481", &display); |
104 | ||
105 | MODULE_ALIAS("spi:" DRVNAME); | |
106 | MODULE_ALIAS("platform:" DRVNAME); | |
107 | MODULE_ALIAS("spi:ili9481"); | |
108 | MODULE_ALIAS("platform:ili9481"); | |
109 | ||
110 | MODULE_DESCRIPTION("FB driver for the ILI9481 LCD Controller"); | |
111 | MODULE_AUTHOR("Petr Olivka"); | |
112 | MODULE_LICENSE("GPL"); |