Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: fbtft: use init function instead of init sequence

This patch converts the default init sequence of the ST7789V
display controller into an init function, as init sequences
are considered deprecated by the maintainers of fbtft.

Signed-off-by: Dennis Menschel <menschel-d@posteo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dennis Menschel and committed by
Greg Kroah-Hartman
ef8f3177 5d7b1692

+24 -19
+24 -19
drivers/staging/fbtft/fb_st7789v.c
··· 15 15 */ 16 16 17 17 #include <linux/bitops.h> 18 + #include <linux/delay.h> 18 19 #include <linux/init.h> 19 20 #include <linux/kernel.h> 20 21 #include <linux/module.h> ··· 70 69 #define MADCTL_MY BIT(7) /* bitmask for page address order */ 71 70 72 71 /** 73 - * default_init_sequence - default initialization sequence for ST7789V 72 + * init_display() - initialize the display controller 74 73 * 75 - * Most of the commands in this init sequence set their parameters to the 74 + * @par: FBTFT parameter object 75 + * 76 + * Most of the commands in this init function set their parameters to the 76 77 * same default values which are already in place after the display has been 77 78 * powered up. (The main exception to this rule is the pixel format which 78 79 * would default to 18 instead of 16 bit per pixel.) 79 80 * Nonetheless, this sequence can be used as a template for concrete 80 81 * displays which usually need some adjustments. 82 + * 83 + * Return: 0 on success, < 0 if error occurred. 81 84 */ 82 - static int default_init_sequence[] = { 85 + static int init_display(struct fbtft_par *par) 86 + { 83 87 /* turn off sleep mode */ 84 - -1, MIPI_DCS_EXIT_SLEEP_MODE, 85 - -2, 120, 88 + write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE); 89 + mdelay(120); 86 90 87 91 /* set pixel format to RGB-565 */ 88 - -1, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT, 92 + write_reg(par, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT); 89 93 90 - -1, PORCTRL, 0x08, 0x08, 0x00, 0x22, 0x22, 94 + write_reg(par, PORCTRL, 0x08, 0x08, 0x00, 0x22, 0x22); 91 95 92 96 /* 93 97 * VGH = 13.26V 94 98 * VGL = -10.43V 95 99 */ 96 - -1, GCTRL, 0x35, 100 + write_reg(par, GCTRL, 0x35); 97 101 98 102 /* 99 103 * VDV and VRH register values come from command write 100 104 * (instead of NVM) 101 105 */ 102 - -1, VDVVRHEN, 0x01, 0xFF, 106 + write_reg(par, VDVVRHEN, 0x01, 0xFF); 103 107 104 108 /* 105 109 * VAP = 4.1V + (VCOM + VCOM offset + 0.5 * VDV) 106 110 * VAN = -4.1V + (VCOM + VCOM offset + 0.5 * VDV) 107 111 */ 108 - -1, VRHS, 0x0B, 112 + write_reg(par, VRHS, 0x0B); 109 113 110 114 /* VDV = 0V */ 111 - -1, VDVS, 0x20, 115 + write_reg(par, VDVS, 0x20); 112 116 113 117 /* VCOM = 0.9V */ 114 - -1, VCOMS, 0x20, 118 + write_reg(par, VCOMS, 0x20); 115 119 116 120 /* VCOM offset = 0V */ 117 - -1, VCMOFSET, 0x20, 121 + write_reg(par, VCMOFSET, 0x20); 118 122 119 123 /* 120 124 * AVDD = 6.8V 121 125 * AVCL = -4.8V 122 126 * VDS = 2.3V 123 127 */ 124 - -1, PWCTRL1, 0xA4, 0xA1, 128 + write_reg(par, PWCTRL1, 0xA4, 0xA1); 125 129 126 - -1, MIPI_DCS_SET_DISPLAY_ON, 127 - 128 - -3, 129 - }; 130 + write_reg(par, MIPI_DCS_SET_DISPLAY_ON); 131 + return 0; 132 + } 130 133 131 134 /** 132 135 * set_var() - apply LCD properties like rotation and BGR mode ··· 242 237 .regwidth = 8, 243 238 .width = 240, 244 239 .height = 320, 245 - .init_sequence = default_init_sequence, 246 240 .gamma_num = 2, 247 241 .gamma_len = 14, 248 242 .gamma = DEFAULT_GAMMA, 249 243 .fbtftops = { 244 + .init_display = init_display, 250 245 .set_var = set_var, 251 246 .set_gamma = set_gamma, 252 247 .blank = blank,