| 1 |
// SPDX-License-Identifier: GPL-2.0+ |
| 2 |
/* |
| 3 |
* FB driver for the ILI9481 LCD Controller |
| 4 |
* |
| 5 |
* Copyright (c) 2014 Petr Olivka |
| 6 |
* Copyright (c) 2013 Noralf Tronnes |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <linux/module.h> |
| 10 |
#include <linux/kernel.h> |
| 11 |
#include <linux/init.h> |
| 12 |
#include <linux/delay.h> |
| 13 |
#include <video/mipi_display.h> |
| 14 |
|
| 15 |
#include "fbtft.h" |
| 16 |
|
| 17 |
#define DRVNAME "fb_ili9481" |
| 18 |
#define WIDTH 320 |
| 19 |
#define HEIGHT 480 |
| 20 |
|
| 21 |
static const s16 default_init_sequence[] = { |
| 22 |
/* SLP_OUT - Sleep out */ |
| 23 |
-1, MIPI_DCS_EXIT_SLEEP_MODE, |
| 24 |
-2, 50, |
| 25 |
/* Power setting */ |
| 26 |
-1, 0xD0, 0x07, 0x42, 0x18, |
| 27 |
/* VCOM */ |
| 28 |
-1, 0xD1, 0x00, 0x07, 0x10, |
| 29 |
/* Power setting for norm. mode */ |
| 30 |
-1, 0xD2, 0x01, 0x02, |
| 31 |
/* Panel driving setting */ |
| 32 |
-1, 0xC0, 0x10, 0x3B, 0x00, 0x02, 0x11, |
| 33 |
/* Frame rate & inv. */ |
| 34 |
-1, 0xC5, 0x03, |
| 35 |
/* Pixel format */ |
| 36 |
-1, MIPI_DCS_SET_PIXEL_FORMAT, 0x55, |
| 37 |
/* Gamma */ |
| 38 |
-1, 0xC8, 0x00, 0x32, 0x36, 0x45, 0x06, 0x16, |
| 39 |
0x37, 0x75, 0x77, 0x54, 0x0C, 0x00, |
| 40 |
/* DISP_ON */ |
| 41 |
-1, MIPI_DCS_SET_DISPLAY_ON, |
| 42 |
-3 |
| 43 |
}; |
| 44 |
|
| 45 |
static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) |
| 46 |
{ |
| 47 |
write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS, |
| 48 |
xs >> 8, xs & 0xff, xe >> 8, xe & 0xff); |
| 49 |
|
| 50 |
write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS, |
| 51 |
ys >> 8, ys & 0xff, ye >> 8, ye & 0xff); |
| 52 |
|
| 53 |
write_reg(par, MIPI_DCS_WRITE_MEMORY_START); |
| 54 |
} |
| 55 |
|
| 56 |
#define HFLIP 0x01 |
| 57 |
#define VFLIP 0x02 |
| 58 |
#define ROW_X_COL 0x20 |
| 59 |
static int set_var(struct fbtft_par *par) |
| 60 |
{ |
| 61 |
switch (par->info->var.rotate) { |
| 62 |
case 270: |
| 63 |
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, |
| 64 |
ROW_X_COL | HFLIP | VFLIP | (par->bgr << 3)); |
| 65 |
break; |
| 66 |
case 180: |
| 67 |
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, |
| 68 |
VFLIP | (par->bgr << 3)); |
| 69 |
break; |
| 70 |
case 90: |
| 71 |
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, |
| 72 |
ROW_X_COL | (par->bgr << 3)); |
| 73 |
break; |
| 74 |
default: |
| 75 |
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, |
| 76 |
HFLIP | (par->bgr << 3)); |
| 77 |
break; |
| 78 |
} |
| 79 |
|
| 80 |
return 0; |
| 81 |
} |
| 82 |
|
| 83 |
static struct fbtft_display display = { |
| 84 |
.regwidth = 8, |
| 85 |
.width = WIDTH, |
| 86 |
.height = HEIGHT, |
| 87 |
.init_sequence = default_init_sequence, |
| 88 |
.fbtftops = { |
| 89 |
.set_addr_win = set_addr_win, |
| 90 |
.set_var = set_var, |
| 91 |
}, |
| 92 |
}; |
| 93 |
|
| 94 |
FBTFT_REGISTER_DRIVER(DRVNAME, "ilitek,ili9481", &display); |
| 95 |
|
| 96 |
MODULE_ALIAS("spi:" DRVNAME); |
| 97 |
MODULE_ALIAS("platform:" DRVNAME); |
| 98 |
MODULE_ALIAS("spi:ili9481"); |
| 99 |
MODULE_ALIAS("platform:ili9481"); |
| 100 |
|
| 101 |
MODULE_DESCRIPTION("FB driver for the ILI9481 LCD Controller"); |
| 102 |
MODULE_AUTHOR("Petr Olivka"); |
| 103 |
MODULE_LICENSE("GPL"); |