Greg Kroah-Hartman | 783de57 | 2018-01-11 11:08:54 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Greg Kroah-Hartman | 78c00cc | 2018-01-11 11:08:55 +0100 | [diff] [blame] | 2 | /* Copyright (C) 2013 Noralf Tronnes */ |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 3 | |
| 4 | #ifndef __LINUX_FBTFT_H |
| 5 | #define __LINUX_FBTFT_H |
| 6 | |
| 7 | #include <linux/fb.h> |
| 8 | #include <linux/spinlock.h> |
| 9 | #include <linux/spi/spi.h> |
| 10 | #include <linux/platform_device.h> |
| 11 | |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 12 | #define FBTFT_ONBOARD_BACKLIGHT 2 |
| 13 | |
| 14 | #define FBTFT_GPIO_NO_MATCH 0xFFFF |
| 15 | #define FBTFT_GPIO_NAME_SIZE 32 |
| 16 | #define FBTFT_MAX_INIT_SEQUENCE 512 |
| 17 | #define FBTFT_GAMMA_MAX_VALUES_TOTAL 128 |
| 18 | |
| 19 | #define FBTFT_OF_INIT_CMD BIT(24) |
| 20 | #define FBTFT_OF_INIT_DELAY BIT(25) |
| 21 | |
| 22 | /** |
| 23 | * struct fbtft_gpio - Structure that holds one pinname to gpio mapping |
| 24 | * @name: pinname (reset, dc, etc.) |
| 25 | * @gpio: GPIO number |
| 26 | * |
| 27 | */ |
| 28 | struct fbtft_gpio { |
| 29 | char name[FBTFT_GPIO_NAME_SIZE]; |
Ming Yang | 1c41494 | 2016-07-17 19:13:18 -0700 | [diff] [blame] | 30 | unsigned int gpio; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | struct fbtft_par; |
| 34 | |
| 35 | /** |
| 36 | * struct fbtft_ops - FBTFT operations structure |
| 37 | * @write: Writes to interface bus |
| 38 | * @read: Reads from interface bus |
| 39 | * @write_vmem: Writes video memory to display |
| 40 | * @write_reg: Writes to controller register |
| 41 | * @set_addr_win: Set the GRAM update window |
| 42 | * @reset: Reset the LCD controller |
| 43 | * @mkdirty: Marks display lines for update |
| 44 | * @update_display: Updates the display |
| 45 | * @init_display: Initializes the display |
| 46 | * @blank: Blank the display (optional) |
| 47 | * @request_gpios_match: Do pinname to gpio matching |
| 48 | * @request_gpios: Request gpios from the kernel |
| 49 | * @free_gpios: Free previously requested gpios |
| 50 | * @verify_gpios: Verify that necessary gpios is present (optional) |
| 51 | * @register_backlight: Used to register backlight device (optional) |
| 52 | * @unregister_backlight: Unregister backlight device (optional) |
| 53 | * @set_var: Configure LCD with values from variables like @rotate and @bgr |
| 54 | * (optional) |
| 55 | * @set_gamma: Set Gamma curve (optional) |
| 56 | * |
| 57 | * Most of these operations have default functions assigned to them in |
| 58 | * fbtft_framebuffer_alloc() |
| 59 | */ |
| 60 | struct fbtft_ops { |
| 61 | int (*write)(struct fbtft_par *par, void *buf, size_t len); |
| 62 | int (*read)(struct fbtft_par *par, void *buf, size_t len); |
| 63 | int (*write_vmem)(struct fbtft_par *par, size_t offset, size_t len); |
| 64 | void (*write_register)(struct fbtft_par *par, int len, ...); |
| 65 | |
| 66 | void (*set_addr_win)(struct fbtft_par *par, |
| 67 | int xs, int ys, int xe, int ye); |
| 68 | void (*reset)(struct fbtft_par *par); |
| 69 | void (*mkdirty)(struct fb_info *info, int from, int to); |
| 70 | void (*update_display)(struct fbtft_par *par, |
Ming Yang | 1c41494 | 2016-07-17 19:13:18 -0700 | [diff] [blame] | 71 | unsigned int start_line, unsigned int end_line); |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 72 | int (*init_display)(struct fbtft_par *par); |
| 73 | int (*blank)(struct fbtft_par *par, bool on); |
| 74 | |
| 75 | unsigned long (*request_gpios_match)(struct fbtft_par *par, |
| 76 | const struct fbtft_gpio *gpio); |
| 77 | int (*request_gpios)(struct fbtft_par *par); |
| 78 | int (*verify_gpios)(struct fbtft_par *par); |
| 79 | |
| 80 | void (*register_backlight)(struct fbtft_par *par); |
| 81 | void (*unregister_backlight)(struct fbtft_par *par); |
| 82 | |
| 83 | int (*set_var)(struct fbtft_par *par); |
Arnd Bergmann | 22eb36b | 2017-02-02 15:43:42 +0100 | [diff] [blame] | 84 | int (*set_gamma)(struct fbtft_par *par, u32 *curves); |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | /** |
| 88 | * struct fbtft_display - Describes the display properties |
| 89 | * @width: Width of display in pixels |
| 90 | * @height: Height of display in pixels |
| 91 | * @regwidth: LCD Controller Register width in bits |
| 92 | * @buswidth: Display interface bus width in bits |
| 93 | * @backlight: Backlight type. |
| 94 | * @fbtftops: FBTFT operations provided by driver or device (platform_data) |
| 95 | * @bpp: Bits per pixel |
| 96 | * @fps: Frames per second |
| 97 | * @txbuflen: Size of transmit buffer |
| 98 | * @init_sequence: Pointer to LCD initialization array |
| 99 | * @gamma: String representation of Gamma curve(s) |
| 100 | * @gamma_num: Number of Gamma curves |
| 101 | * @gamma_len: Number of values per Gamma curve |
| 102 | * @debug: Initial debug value |
| 103 | * |
| 104 | * This structure is not stored by FBTFT except for init_sequence. |
| 105 | */ |
| 106 | struct fbtft_display { |
Ming Yang | 1c41494 | 2016-07-17 19:13:18 -0700 | [diff] [blame] | 107 | unsigned int width; |
| 108 | unsigned int height; |
| 109 | unsigned int regwidth; |
| 110 | unsigned int buswidth; |
| 111 | unsigned int backlight; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 112 | struct fbtft_ops fbtftops; |
Ming Yang | 1c41494 | 2016-07-17 19:13:18 -0700 | [diff] [blame] | 113 | unsigned int bpp; |
| 114 | unsigned int fps; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 115 | int txbuflen; |
Joe Perches | 0a859b3 | 2017-02-22 21:54:56 -0800 | [diff] [blame] | 116 | const s16 *init_sequence; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 117 | char *gamma; |
| 118 | int gamma_num; |
| 119 | int gamma_len; |
| 120 | unsigned long debug; |
| 121 | }; |
| 122 | |
| 123 | /** |
| 124 | * struct fbtft_platform_data - Passes display specific data to the driver |
| 125 | * @display: Display properties |
Masanari Iida | 92def78 | 2015-03-21 11:48:37 +0900 | [diff] [blame] | 126 | * @gpios: Pointer to an array of pinname to gpio mappings |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 127 | * @rotate: Display rotation angle |
| 128 | * @bgr: LCD Controller BGR bit |
| 129 | * @fps: Frames per second (this will go away, use @fps in @fbtft_display) |
| 130 | * @txbuflen: Size of transmit buffer |
| 131 | * @startbyte: When set, enables use of Startbyte in transfers |
| 132 | * @gamma: String representation of Gamma curve(s) |
| 133 | * @extra: A way to pass extra info |
| 134 | */ |
| 135 | struct fbtft_platform_data { |
| 136 | struct fbtft_display display; |
| 137 | const struct fbtft_gpio *gpios; |
Ming Yang | 1c41494 | 2016-07-17 19:13:18 -0700 | [diff] [blame] | 138 | unsigned int rotate; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 139 | bool bgr; |
Ming Yang | 1c41494 | 2016-07-17 19:13:18 -0700 | [diff] [blame] | 140 | unsigned int fps; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 141 | int txbuflen; |
| 142 | u8 startbyte; |
| 143 | char *gamma; |
| 144 | void *extra; |
| 145 | }; |
| 146 | |
| 147 | /** |
| 148 | * struct fbtft_par - Main FBTFT data structure |
| 149 | * |
| 150 | * This structure holds all relevant data to operate the display |
| 151 | * |
| 152 | * See sourcefile for documentation since nested structs is not |
| 153 | * supported by kernel-doc. |
| 154 | * |
| 155 | */ |
| 156 | /* @spi: Set if it is a SPI device |
| 157 | * @pdev: Set if it is a platform device |
| 158 | * @info: Pointer to framebuffer fb_info structure |
| 159 | * @pdata: Pointer to platform data |
| 160 | * @ssbuf: Not used |
| 161 | * @pseudo_palette: Used by fb_set_colreg() |
| 162 | * @txbuf.buf: Transmit buffer |
| 163 | * @txbuf.len: Transmit buffer length |
| 164 | * @buf: Small buffer used when writing init data over SPI |
| 165 | * @startbyte: Used by some controllers when in SPI mode. |
| 166 | * Format: 6 bit Device id + RS bit + RW bit |
| 167 | * @fbtftops: FBTFT operations provided by driver or device (platform_data) |
| 168 | * @dirty_lock: Protects dirty_lines_start and dirty_lines_end |
| 169 | * @dirty_lines_start: Where to begin updating display |
| 170 | * @dirty_lines_end: Where to end updating display |
| 171 | * @gpio.reset: GPIO used to reset display |
| 172 | * @gpio.dc: Data/Command signal, also known as RS |
| 173 | * @gpio.rd: Read latching signal |
| 174 | * @gpio.wr: Write latching signal |
| 175 | * @gpio.latch: Bus latch signal, eg. 16->8 bit bus latch |
| 176 | * @gpio.cs: LCD Chip Select with parallel interface bus |
| 177 | * @gpio.db[16]: Parallel databus |
| 178 | * @gpio.led[16]: Led control signals |
Masanari Iida | 92def78 | 2015-03-21 11:48:37 +0900 | [diff] [blame] | 179 | * @gpio.aux[16]: Auxiliary signals, not used by core |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 180 | * @init_sequence: Pointer to LCD initialization array |
| 181 | * @gamma.lock: Mutex for Gamma curve locking |
| 182 | * @gamma.curves: Pointer to Gamma curve array |
| 183 | * @gamma.num_values: Number of values per Gamma curve |
| 184 | * @gamma.num_curves: Number of Gamma curves |
| 185 | * @debug: Pointer to debug value |
| 186 | * @current_debug: |
| 187 | * @first_update_done: Used to only time the first display update |
| 188 | * @update_time: Used to calculate 'fps' in debug output |
| 189 | * @bgr: BGR mode/\n |
| 190 | * @extra: Extra info needed by driver |
| 191 | */ |
| 192 | struct fbtft_par { |
| 193 | struct spi_device *spi; |
| 194 | struct platform_device *pdev; |
| 195 | struct fb_info *info; |
| 196 | struct fbtft_platform_data *pdata; |
| 197 | u16 *ssbuf; |
| 198 | u32 pseudo_palette[16]; |
| 199 | struct { |
| 200 | void *buf; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 201 | size_t len; |
| 202 | } txbuf; |
| 203 | u8 *buf; |
| 204 | u8 startbyte; |
| 205 | struct fbtft_ops fbtftops; |
| 206 | spinlock_t dirty_lock; |
Ming Yang | 1c41494 | 2016-07-17 19:13:18 -0700 | [diff] [blame] | 207 | unsigned int dirty_lines_start; |
| 208 | unsigned int dirty_lines_end; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 209 | struct { |
| 210 | int reset; |
| 211 | int dc; |
| 212 | int rd; |
| 213 | int wr; |
| 214 | int latch; |
| 215 | int cs; |
| 216 | int db[16]; |
| 217 | int led[16]; |
| 218 | int aux[16]; |
| 219 | } gpio; |
Joe Perches | 0a859b3 | 2017-02-22 21:54:56 -0800 | [diff] [blame] | 220 | const s16 *init_sequence; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 221 | struct { |
| 222 | struct mutex lock; |
Arnd Bergmann | 22eb36b | 2017-02-02 15:43:42 +0100 | [diff] [blame] | 223 | u32 *curves; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 224 | int num_values; |
| 225 | int num_curves; |
| 226 | } gamma; |
| 227 | unsigned long debug; |
| 228 | bool first_update_done; |
Ksenija Stanojevic | 367e856 | 2015-10-07 22:06:55 +0200 | [diff] [blame] | 229 | ktime_t update_time; |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 230 | bool bgr; |
| 231 | void *extra; |
| 232 | }; |
| 233 | |
| 234 | #define NUMARGS(...) (sizeof((int[]){__VA_ARGS__})/sizeof(int)) |
| 235 | |
| 236 | #define write_reg(par, ...) \ |
Helen Fornazier | 4ebe6f4 | 2015-03-25 20:56:43 -0300 | [diff] [blame] | 237 | par->fbtftops.write_register(par, NUMARGS(__VA_ARGS__), __VA_ARGS__) |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 238 | |
| 239 | /* fbtft-core.c */ |
Heiner Kallweit | 60da7020 | 2017-03-02 22:12:46 +0100 | [diff] [blame] | 240 | int fbtft_write_buf_dc(struct fbtft_par *par, void *buf, size_t len, int dc); |
Joe Perches | cd951dd | 2015-08-10 14:51:18 -0700 | [diff] [blame] | 241 | void fbtft_dbg_hex(const struct device *dev, int groupsize, |
| 242 | void *buf, size_t len, const char *fmt, ...); |
Noralf Trønnes | ad6d881 | 2015-07-30 19:55:01 +0200 | [diff] [blame] | 243 | struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, |
| 244 | struct device *dev, |
| 245 | struct fbtft_platform_data *pdata); |
Joe Perches | cd951dd | 2015-08-10 14:51:18 -0700 | [diff] [blame] | 246 | void fbtft_framebuffer_release(struct fb_info *info); |
| 247 | int fbtft_register_framebuffer(struct fb_info *fb_info); |
| 248 | int fbtft_unregister_framebuffer(struct fb_info *fb_info); |
| 249 | void fbtft_register_backlight(struct fbtft_par *par); |
| 250 | void fbtft_unregister_backlight(struct fbtft_par *par); |
| 251 | int fbtft_init_display(struct fbtft_par *par); |
| 252 | int fbtft_probe_common(struct fbtft_display *display, struct spi_device *sdev, |
| 253 | struct platform_device *pdev); |
| 254 | int fbtft_remove_common(struct device *dev, struct fb_info *info); |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 255 | |
| 256 | /* fbtft-io.c */ |
Joe Perches | cd951dd | 2015-08-10 14:51:18 -0700 | [diff] [blame] | 257 | int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len); |
| 258 | int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len); |
| 259 | int fbtft_read_spi(struct fbtft_par *par, void *buf, size_t len); |
| 260 | int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len); |
| 261 | int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len); |
| 262 | int fbtft_write_gpio16_wr_latched(struct fbtft_par *par, void *buf, size_t len); |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 263 | |
| 264 | /* fbtft-bus.c */ |
Joe Perches | cd951dd | 2015-08-10 14:51:18 -0700 | [diff] [blame] | 265 | int fbtft_write_vmem8_bus8(struct fbtft_par *par, size_t offset, size_t len); |
| 266 | int fbtft_write_vmem16_bus16(struct fbtft_par *par, size_t offset, size_t len); |
| 267 | int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len); |
| 268 | int fbtft_write_vmem16_bus9(struct fbtft_par *par, size_t offset, size_t len); |
| 269 | void fbtft_write_reg8_bus8(struct fbtft_par *par, int len, ...); |
| 270 | void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...); |
| 271 | void fbtft_write_reg16_bus8(struct fbtft_par *par, int len, ...); |
| 272 | void fbtft_write_reg16_bus16(struct fbtft_par *par, int len, ...); |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 273 | |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 274 | #define FBTFT_REGISTER_DRIVER(_name, _compatible, _display) \ |
| 275 | \ |
| 276 | static int fbtft_driver_probe_spi(struct spi_device *spi) \ |
| 277 | { \ |
| 278 | return fbtft_probe_common(_display, spi, NULL); \ |
| 279 | } \ |
| 280 | \ |
| 281 | static int fbtft_driver_remove_spi(struct spi_device *spi) \ |
| 282 | { \ |
| 283 | struct fb_info *info = spi_get_drvdata(spi); \ |
| 284 | \ |
| 285 | return fbtft_remove_common(&spi->dev, info); \ |
| 286 | } \ |
| 287 | \ |
| 288 | static int fbtft_driver_probe_pdev(struct platform_device *pdev) \ |
| 289 | { \ |
| 290 | return fbtft_probe_common(_display, NULL, pdev); \ |
| 291 | } \ |
| 292 | \ |
| 293 | static int fbtft_driver_remove_pdev(struct platform_device *pdev) \ |
| 294 | { \ |
| 295 | struct fb_info *info = platform_get_drvdata(pdev); \ |
| 296 | \ |
| 297 | return fbtft_remove_common(&pdev->dev, info); \ |
| 298 | } \ |
| 299 | \ |
| 300 | static const struct of_device_id dt_ids[] = { \ |
Helen Fornazier | 42efd00 | 2015-03-20 23:18:10 -0300 | [diff] [blame] | 301 | { .compatible = _compatible }, \ |
| 302 | {}, \ |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 303 | }; \ |
| 304 | \ |
| 305 | MODULE_DEVICE_TABLE(of, dt_ids); \ |
| 306 | \ |
| 307 | \ |
| 308 | static struct spi_driver fbtft_driver_spi_driver = { \ |
| 309 | .driver = { \ |
| 310 | .name = _name, \ |
Helen Fornazier | 42efd00 | 2015-03-20 23:18:10 -0300 | [diff] [blame] | 311 | .of_match_table = of_match_ptr(dt_ids), \ |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 312 | }, \ |
| 313 | .probe = fbtft_driver_probe_spi, \ |
| 314 | .remove = fbtft_driver_remove_spi, \ |
| 315 | }; \ |
| 316 | \ |
| 317 | static struct platform_driver fbtft_driver_platform_driver = { \ |
| 318 | .driver = { \ |
| 319 | .name = _name, \ |
| 320 | .owner = THIS_MODULE, \ |
Helen Fornazier | 42efd00 | 2015-03-20 23:18:10 -0300 | [diff] [blame] | 321 | .of_match_table = of_match_ptr(dt_ids), \ |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 322 | }, \ |
| 323 | .probe = fbtft_driver_probe_pdev, \ |
| 324 | .remove = fbtft_driver_remove_pdev, \ |
| 325 | }; \ |
| 326 | \ |
| 327 | static int __init fbtft_driver_module_init(void) \ |
| 328 | { \ |
| 329 | int ret; \ |
| 330 | \ |
| 331 | ret = spi_register_driver(&fbtft_driver_spi_driver); \ |
| 332 | if (ret < 0) \ |
| 333 | return ret; \ |
| 334 | return platform_driver_register(&fbtft_driver_platform_driver); \ |
| 335 | } \ |
| 336 | \ |
| 337 | static void __exit fbtft_driver_module_exit(void) \ |
| 338 | { \ |
| 339 | spi_unregister_driver(&fbtft_driver_spi_driver); \ |
| 340 | platform_driver_unregister(&fbtft_driver_platform_driver); \ |
| 341 | } \ |
| 342 | \ |
| 343 | module_init(fbtft_driver_module_init); \ |
| 344 | module_exit(fbtft_driver_module_exit); |
| 345 | |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 346 | /* Debug macros */ |
| 347 | |
| 348 | /* shorthand debug levels */ |
| 349 | #define DEBUG_LEVEL_1 DEBUG_REQUEST_GPIOS |
| 350 | #define DEBUG_LEVEL_2 (DEBUG_LEVEL_1 | DEBUG_DRIVER_INIT_FUNCTIONS | DEBUG_TIME_FIRST_UPDATE) |
| 351 | #define DEBUG_LEVEL_3 (DEBUG_LEVEL_2 | DEBUG_RESET | DEBUG_INIT_DISPLAY | DEBUG_BLANK | DEBUG_REQUEST_GPIOS | DEBUG_FREE_GPIOS | DEBUG_VERIFY_GPIOS | DEBUG_BACKLIGHT | DEBUG_SYSFS) |
| 352 | #define DEBUG_LEVEL_4 (DEBUG_LEVEL_2 | DEBUG_FB_READ | DEBUG_FB_WRITE | DEBUG_FB_FILLRECT | DEBUG_FB_COPYAREA | DEBUG_FB_IMAGEBLIT | DEBUG_FB_BLANK) |
| 353 | #define DEBUG_LEVEL_5 (DEBUG_LEVEL_3 | DEBUG_UPDATE_DISPLAY) |
| 354 | #define DEBUG_LEVEL_6 (DEBUG_LEVEL_4 | DEBUG_LEVEL_5) |
| 355 | #define DEBUG_LEVEL_7 0xFFFFFFFF |
| 356 | |
| 357 | #define DEBUG_DRIVER_INIT_FUNCTIONS (1<<3) |
| 358 | #define DEBUG_TIME_FIRST_UPDATE (1<<4) |
| 359 | #define DEBUG_TIME_EACH_UPDATE (1<<5) |
| 360 | #define DEBUG_DEFERRED_IO (1<<6) |
| 361 | #define DEBUG_FBTFT_INIT_FUNCTIONS (1<<7) |
| 362 | |
| 363 | /* fbops */ |
| 364 | #define DEBUG_FB_READ (1<<8) |
| 365 | #define DEBUG_FB_WRITE (1<<9) |
| 366 | #define DEBUG_FB_FILLRECT (1<<10) |
| 367 | #define DEBUG_FB_COPYAREA (1<<11) |
| 368 | #define DEBUG_FB_IMAGEBLIT (1<<12) |
| 369 | #define DEBUG_FB_SETCOLREG (1<<13) |
| 370 | #define DEBUG_FB_BLANK (1<<14) |
| 371 | |
| 372 | #define DEBUG_SYSFS (1<<16) |
| 373 | |
| 374 | /* fbtftops */ |
| 375 | #define DEBUG_BACKLIGHT (1<<17) |
| 376 | #define DEBUG_READ (1<<18) |
| 377 | #define DEBUG_WRITE (1<<19) |
| 378 | #define DEBUG_WRITE_VMEM (1<<20) |
| 379 | #define DEBUG_WRITE_REGISTER (1<<21) |
| 380 | #define DEBUG_SET_ADDR_WIN (1<<22) |
| 381 | #define DEBUG_RESET (1<<23) |
| 382 | #define DEBUG_MKDIRTY (1<<24) |
| 383 | #define DEBUG_UPDATE_DISPLAY (1<<25) |
| 384 | #define DEBUG_INIT_DISPLAY (1<<26) |
| 385 | #define DEBUG_BLANK (1<<27) |
| 386 | #define DEBUG_REQUEST_GPIOS (1<<28) |
| 387 | #define DEBUG_FREE_GPIOS (1<<29) |
| 388 | #define DEBUG_REQUEST_GPIOS_MATCH (1<<30) |
| 389 | #define DEBUG_VERIFY_GPIOS (1<<31) |
| 390 | |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 391 | #define fbtft_init_dbg(dev, format, arg...) \ |
| 392 | do { \ |
| 393 | if (unlikely((dev)->platform_data && \ |
| 394 | (((struct fbtft_platform_data *)(dev)->platform_data)->display.debug & DEBUG_DRIVER_INIT_FUNCTIONS))) \ |
| 395 | dev_info(dev, format, ##arg); \ |
| 396 | } while (0) |
| 397 | |
| 398 | #define fbtft_par_dbg(level, par, format, arg...) \ |
| 399 | do { \ |
| 400 | if (unlikely(par->debug & level)) \ |
| 401 | dev_info(par->info->device, format, ##arg); \ |
| 402 | } while (0) |
| 403 | |
Thomas Petazzoni | c296d5f | 2014-12-31 10:11:09 +0100 | [diff] [blame] | 404 | #define fbtft_par_dbg_hex(level, par, dev, type, buf, num, format, arg...) \ |
| 405 | do { \ |
| 406 | if (unlikely(par->debug & level)) \ |
| 407 | fbtft_dbg_hex(dev, sizeof(type), buf, num * sizeof(type), format, ##arg); \ |
| 408 | } while (0) |
| 409 | |
| 410 | #endif /* __LINUX_FBTFT_H */ |