Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Juergen Beisert, Pengutronix |
| 3 | * |
| 4 | * This code is based on: |
| 5 | * Author: Vitaly Wool <vital@embeddedalley.com> |
| 6 | * |
| 7 | * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved. |
| 8 | * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License |
| 12 | * as published by the Free Software Foundation; either version 2 |
| 13 | * of the License, or (at your option) any later version. |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | */ |
| 19 | |
| 20 | #define DRIVER_NAME "mxsfb" |
| 21 | |
| 22 | /** |
| 23 | * @file |
| 24 | * @brief LCDIF driver for i.MX23 and i.MX28 |
| 25 | * |
| 26 | * The LCDIF support four modes of operation |
| 27 | * - MPU interface (to drive smart displays) -> not supported yet |
| 28 | * - VSYNC interface (like MPU interface plus Vsync) -> not supported yet |
| 29 | * - Dotclock interface (to drive LC displays with RGB data and sync signals) |
| 30 | * - DVI (to drive ITU-R BT656) -> not supported yet |
| 31 | * |
| 32 | * This driver depends on a correct setup of the pins used for this purpose |
| 33 | * (platform specific). |
| 34 | * |
| 35 | * For the developer: Don't forget to set the data bus width to the display |
| 36 | * in the imx_fb_videomode structure. You will else end up with ugly colours. |
| 37 | * If you fight against jitter you can vary the clock delay. This is a feature |
| 38 | * of the i.MX28 and you can vary it between 2 ns ... 8 ns in 2 ns steps. Give |
| 39 | * the required value in the imx_fb_videomode structure. |
| 40 | */ |
| 41 | |
Axel Lin | 3689367 | 2011-09-01 08:11:59 +0800 | [diff] [blame] | 42 | #include <linux/module.h> |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 43 | #include <linux/kernel.h> |
Shawn Guo | 73fc610 | 2012-06-25 19:54:35 +0800 | [diff] [blame] | 44 | #include <linux/of_device.h> |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 45 | #include <linux/platform_device.h> |
| 46 | #include <linux/clk.h> |
| 47 | #include <linux/dma-mapping.h> |
| 48 | #include <linux/io.h> |
Shawn Guo | c8b5cfc | 2013-03-14 13:21:56 +0800 | [diff] [blame] | 49 | #include <linux/fb.h> |
Fabio Estevam | 4344429 | 2013-04-07 15:44:59 -0300 | [diff] [blame] | 50 | #include <linux/regulator/consumer.h> |
Fabio Estevam | d7321df | 2013-05-08 21:05:55 +0800 | [diff] [blame] | 51 | #include <video/of_display_timing.h> |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 52 | #include <video/of_videomode.h> |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 53 | #include <video/videomode.h> |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 54 | |
| 55 | #define REG_SET 4 |
| 56 | #define REG_CLR 8 |
| 57 | |
| 58 | #define LCDC_CTRL 0x00 |
| 59 | #define LCDC_CTRL1 0x10 |
| 60 | #define LCDC_V4_CTRL2 0x20 |
| 61 | #define LCDC_V3_TRANSFER_COUNT 0x20 |
| 62 | #define LCDC_V4_TRANSFER_COUNT 0x30 |
| 63 | #define LCDC_V4_CUR_BUF 0x40 |
| 64 | #define LCDC_V4_NEXT_BUF 0x50 |
| 65 | #define LCDC_V3_CUR_BUF 0x30 |
| 66 | #define LCDC_V3_NEXT_BUF 0x40 |
| 67 | #define LCDC_TIMING 0x60 |
| 68 | #define LCDC_VDCTRL0 0x70 |
| 69 | #define LCDC_VDCTRL1 0x80 |
| 70 | #define LCDC_VDCTRL2 0x90 |
| 71 | #define LCDC_VDCTRL3 0xa0 |
| 72 | #define LCDC_VDCTRL4 0xb0 |
| 73 | #define LCDC_DVICTRL0 0xc0 |
| 74 | #define LCDC_DVICTRL1 0xd0 |
| 75 | #define LCDC_DVICTRL2 0xe0 |
| 76 | #define LCDC_DVICTRL3 0xf0 |
| 77 | #define LCDC_DVICTRL4 0x100 |
| 78 | #define LCDC_V4_DATA 0x180 |
| 79 | #define LCDC_V3_DATA 0x1b0 |
| 80 | #define LCDC_V4_DEBUG0 0x1d0 |
| 81 | #define LCDC_V3_DEBUG0 0x1f0 |
| 82 | |
| 83 | #define CTRL_SFTRST (1 << 31) |
| 84 | #define CTRL_CLKGATE (1 << 30) |
| 85 | #define CTRL_BYPASS_COUNT (1 << 19) |
| 86 | #define CTRL_VSYNC_MODE (1 << 18) |
| 87 | #define CTRL_DOTCLK_MODE (1 << 17) |
| 88 | #define CTRL_DATA_SELECT (1 << 16) |
| 89 | #define CTRL_SET_BUS_WIDTH(x) (((x) & 0x3) << 10) |
| 90 | #define CTRL_GET_BUS_WIDTH(x) (((x) >> 10) & 0x3) |
| 91 | #define CTRL_SET_WORD_LENGTH(x) (((x) & 0x3) << 8) |
| 92 | #define CTRL_GET_WORD_LENGTH(x) (((x) >> 8) & 0x3) |
| 93 | #define CTRL_MASTER (1 << 5) |
| 94 | #define CTRL_DF16 (1 << 3) |
| 95 | #define CTRL_DF18 (1 << 2) |
| 96 | #define CTRL_DF24 (1 << 1) |
| 97 | #define CTRL_RUN (1 << 0) |
| 98 | |
| 99 | #define CTRL1_FIFO_CLEAR (1 << 21) |
| 100 | #define CTRL1_SET_BYTE_PACKAGING(x) (((x) & 0xf) << 16) |
| 101 | #define CTRL1_GET_BYTE_PACKAGING(x) (((x) >> 16) & 0xf) |
| 102 | |
| 103 | #define TRANSFER_COUNT_SET_VCOUNT(x) (((x) & 0xffff) << 16) |
| 104 | #define TRANSFER_COUNT_GET_VCOUNT(x) (((x) >> 16) & 0xffff) |
| 105 | #define TRANSFER_COUNT_SET_HCOUNT(x) ((x) & 0xffff) |
| 106 | #define TRANSFER_COUNT_GET_HCOUNT(x) ((x) & 0xffff) |
| 107 | |
| 108 | |
| 109 | #define VDCTRL0_ENABLE_PRESENT (1 << 28) |
| 110 | #define VDCTRL0_VSYNC_ACT_HIGH (1 << 27) |
| 111 | #define VDCTRL0_HSYNC_ACT_HIGH (1 << 26) |
Shawn Guo | c8b5cfc | 2013-03-14 13:21:56 +0800 | [diff] [blame] | 112 | #define VDCTRL0_DOTCLK_ACT_FALLING (1 << 25) |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 113 | #define VDCTRL0_ENABLE_ACT_HIGH (1 << 24) |
| 114 | #define VDCTRL0_VSYNC_PERIOD_UNIT (1 << 21) |
| 115 | #define VDCTRL0_VSYNC_PULSE_WIDTH_UNIT (1 << 20) |
| 116 | #define VDCTRL0_HALF_LINE (1 << 19) |
| 117 | #define VDCTRL0_HALF_LINE_MODE (1 << 18) |
| 118 | #define VDCTRL0_SET_VSYNC_PULSE_WIDTH(x) ((x) & 0x3ffff) |
| 119 | #define VDCTRL0_GET_VSYNC_PULSE_WIDTH(x) ((x) & 0x3ffff) |
| 120 | |
| 121 | #define VDCTRL2_SET_HSYNC_PERIOD(x) ((x) & 0x3ffff) |
| 122 | #define VDCTRL2_GET_HSYNC_PERIOD(x) ((x) & 0x3ffff) |
| 123 | |
| 124 | #define VDCTRL3_MUX_SYNC_SIGNALS (1 << 29) |
| 125 | #define VDCTRL3_VSYNC_ONLY (1 << 28) |
| 126 | #define SET_HOR_WAIT_CNT(x) (((x) & 0xfff) << 16) |
| 127 | #define GET_HOR_WAIT_CNT(x) (((x) >> 16) & 0xfff) |
| 128 | #define SET_VERT_WAIT_CNT(x) ((x) & 0xffff) |
| 129 | #define GET_VERT_WAIT_CNT(x) ((x) & 0xffff) |
| 130 | |
| 131 | #define VDCTRL4_SET_DOTCLK_DLY(x) (((x) & 0x7) << 29) /* v4 only */ |
| 132 | #define VDCTRL4_GET_DOTCLK_DLY(x) (((x) >> 29) & 0x7) /* v4 only */ |
| 133 | #define VDCTRL4_SYNC_SIGNALS_ON (1 << 18) |
| 134 | #define SET_DOTCLK_H_VALID_DATA_CNT(x) ((x) & 0x3ffff) |
| 135 | |
| 136 | #define DEBUG0_HSYNC (1 < 26) |
| 137 | #define DEBUG0_VSYNC (1 < 25) |
| 138 | |
| 139 | #define MIN_XRES 120 |
| 140 | #define MIN_YRES 120 |
| 141 | |
| 142 | #define RED 0 |
| 143 | #define GREEN 1 |
| 144 | #define BLUE 2 |
| 145 | #define TRANSP 3 |
| 146 | |
Shawn Guo | c8b5cfc | 2013-03-14 13:21:56 +0800 | [diff] [blame] | 147 | #define STMLCDIF_8BIT 1 /** pixel data bus to the display is of 8 bit width */ |
| 148 | #define STMLCDIF_16BIT 0 /** pixel data bus to the display is of 16 bit width */ |
| 149 | #define STMLCDIF_18BIT 2 /** pixel data bus to the display is of 18 bit width */ |
| 150 | #define STMLCDIF_24BIT 3 /** pixel data bus to the display is of 24 bit width */ |
| 151 | |
| 152 | #define MXSFB_SYNC_DATA_ENABLE_HIGH_ACT (1 << 6) |
Stefan Agner | 2d81482 | 2017-11-09 18:09:30 +0100 | [diff] [blame] | 153 | #define MXSFB_SYNC_DOTCLK_FALLING_ACT (1 << 7) /* negative edge sampling */ |
Shawn Guo | c8b5cfc | 2013-03-14 13:21:56 +0800 | [diff] [blame] | 154 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 155 | enum mxsfb_devtype { |
| 156 | MXSFB_V3, |
| 157 | MXSFB_V4, |
| 158 | }; |
| 159 | |
| 160 | /* CPU dependent register offsets */ |
| 161 | struct mxsfb_devdata { |
| 162 | unsigned transfer_count; |
| 163 | unsigned cur_buf; |
| 164 | unsigned next_buf; |
| 165 | unsigned debug0; |
| 166 | unsigned hs_wdth_mask; |
| 167 | unsigned hs_wdth_shift; |
| 168 | unsigned ipversion; |
| 169 | }; |
| 170 | |
| 171 | struct mxsfb_info { |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 172 | struct platform_device *pdev; |
| 173 | struct clk *clk; |
Fabio Estevam | d301a5a | 2014-10-25 11:28:47 -0200 | [diff] [blame] | 174 | struct clk *clk_axi; |
| 175 | struct clk *clk_disp_axi; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 176 | void __iomem *base; /* registers */ |
| 177 | unsigned allocated_size; |
| 178 | int enabled; |
| 179 | unsigned ld_intf_width; |
| 180 | unsigned dotclk_delay; |
| 181 | const struct mxsfb_devdata *devdata; |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 182 | u32 sync; |
Fabio Estevam | 4344429 | 2013-04-07 15:44:59 -0300 | [diff] [blame] | 183 | struct regulator *reg_lcd; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 184 | }; |
| 185 | |
| 186 | #define mxsfb_is_v3(host) (host->devdata->ipversion == 3) |
| 187 | #define mxsfb_is_v4(host) (host->devdata->ipversion == 4) |
| 188 | |
| 189 | static const struct mxsfb_devdata mxsfb_devdata[] = { |
| 190 | [MXSFB_V3] = { |
| 191 | .transfer_count = LCDC_V3_TRANSFER_COUNT, |
| 192 | .cur_buf = LCDC_V3_CUR_BUF, |
| 193 | .next_buf = LCDC_V3_NEXT_BUF, |
| 194 | .debug0 = LCDC_V3_DEBUG0, |
| 195 | .hs_wdth_mask = 0xff, |
| 196 | .hs_wdth_shift = 24, |
| 197 | .ipversion = 3, |
| 198 | }, |
| 199 | [MXSFB_V4] = { |
| 200 | .transfer_count = LCDC_V4_TRANSFER_COUNT, |
| 201 | .cur_buf = LCDC_V4_CUR_BUF, |
| 202 | .next_buf = LCDC_V4_NEXT_BUF, |
| 203 | .debug0 = LCDC_V4_DEBUG0, |
| 204 | .hs_wdth_mask = 0x3fff, |
| 205 | .hs_wdth_shift = 18, |
| 206 | .ipversion = 4, |
| 207 | }, |
| 208 | }; |
| 209 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 210 | /* mask and shift depends on architecture */ |
| 211 | static inline u32 set_hsync_pulse_width(struct mxsfb_info *host, unsigned val) |
| 212 | { |
| 213 | return (val & host->devdata->hs_wdth_mask) << |
| 214 | host->devdata->hs_wdth_shift; |
| 215 | } |
| 216 | |
| 217 | static inline u32 get_hsync_pulse_width(struct mxsfb_info *host, unsigned val) |
| 218 | { |
| 219 | return (val >> host->devdata->hs_wdth_shift) & |
| 220 | host->devdata->hs_wdth_mask; |
| 221 | } |
| 222 | |
| 223 | static const struct fb_bitfield def_rgb565[] = { |
| 224 | [RED] = { |
| 225 | .offset = 11, |
| 226 | .length = 5, |
| 227 | }, |
| 228 | [GREEN] = { |
| 229 | .offset = 5, |
| 230 | .length = 6, |
| 231 | }, |
| 232 | [BLUE] = { |
| 233 | .offset = 0, |
| 234 | .length = 5, |
| 235 | }, |
| 236 | [TRANSP] = { /* no support for transparency */ |
| 237 | .length = 0, |
| 238 | } |
| 239 | }; |
| 240 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 241 | static const struct fb_bitfield def_rgb888[] = { |
| 242 | [RED] = { |
| 243 | .offset = 16, |
| 244 | .length = 8, |
| 245 | }, |
| 246 | [GREEN] = { |
| 247 | .offset = 8, |
| 248 | .length = 8, |
| 249 | }, |
| 250 | [BLUE] = { |
| 251 | .offset = 0, |
| 252 | .length = 8, |
| 253 | }, |
| 254 | [TRANSP] = { /* no support for transparency */ |
| 255 | .length = 0, |
| 256 | } |
| 257 | }; |
| 258 | |
| 259 | static inline unsigned chan_to_field(unsigned chan, struct fb_bitfield *bf) |
| 260 | { |
| 261 | chan &= 0xffff; |
| 262 | chan >>= 16 - bf->length; |
| 263 | return chan << bf->offset; |
| 264 | } |
| 265 | |
| 266 | static int mxsfb_check_var(struct fb_var_screeninfo *var, |
| 267 | struct fb_info *fb_info) |
| 268 | { |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 269 | struct mxsfb_info *host = fb_info->par; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 270 | const struct fb_bitfield *rgb = NULL; |
| 271 | |
| 272 | if (var->xres < MIN_XRES) |
| 273 | var->xres = MIN_XRES; |
| 274 | if (var->yres < MIN_YRES) |
| 275 | var->yres = MIN_YRES; |
| 276 | |
| 277 | var->xres_virtual = var->xres; |
| 278 | |
| 279 | var->yres_virtual = var->yres; |
| 280 | |
| 281 | switch (var->bits_per_pixel) { |
| 282 | case 16: |
| 283 | /* always expect RGB 565 */ |
| 284 | rgb = def_rgb565; |
| 285 | break; |
| 286 | case 32: |
| 287 | switch (host->ld_intf_width) { |
| 288 | case STMLCDIF_8BIT: |
| 289 | pr_debug("Unsupported LCD bus width mapping\n"); |
| 290 | break; |
| 291 | case STMLCDIF_16BIT: |
| 292 | case STMLCDIF_18BIT: |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 293 | case STMLCDIF_24BIT: |
| 294 | /* real 24 bit */ |
| 295 | rgb = def_rgb888; |
| 296 | break; |
| 297 | } |
| 298 | break; |
| 299 | default: |
Lothar Waßmann | 18dd44d | 2014-01-06 14:17:57 +0100 | [diff] [blame] | 300 | pr_err("Unsupported colour depth: %u\n", var->bits_per_pixel); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 301 | return -EINVAL; |
| 302 | } |
| 303 | |
| 304 | /* |
| 305 | * Copy the RGB parameters for this display |
| 306 | * from the machine specific parameters. |
| 307 | */ |
| 308 | var->red = rgb[RED]; |
| 309 | var->green = rgb[GREEN]; |
| 310 | var->blue = rgb[BLUE]; |
| 311 | var->transp = rgb[TRANSP]; |
| 312 | |
| 313 | return 0; |
| 314 | } |
| 315 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 316 | static inline void mxsfb_enable_axi_clk(struct mxsfb_info *host) |
| 317 | { |
| 318 | if (host->clk_axi) |
| 319 | clk_prepare_enable(host->clk_axi); |
| 320 | } |
| 321 | |
| 322 | static inline void mxsfb_disable_axi_clk(struct mxsfb_info *host) |
| 323 | { |
| 324 | if (host->clk_axi) |
| 325 | clk_disable_unprepare(host->clk_axi); |
| 326 | } |
| 327 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 328 | static void mxsfb_enable_controller(struct fb_info *fb_info) |
| 329 | { |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 330 | struct mxsfb_info *host = fb_info->par; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 331 | u32 reg; |
Fabio Estevam | 4344429 | 2013-04-07 15:44:59 -0300 | [diff] [blame] | 332 | int ret; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 333 | |
| 334 | dev_dbg(&host->pdev->dev, "%s\n", __func__); |
| 335 | |
Fabio Estevam | 4344429 | 2013-04-07 15:44:59 -0300 | [diff] [blame] | 336 | if (host->reg_lcd) { |
| 337 | ret = regulator_enable(host->reg_lcd); |
| 338 | if (ret) { |
| 339 | dev_err(&host->pdev->dev, |
| 340 | "lcd regulator enable failed: %d\n", ret); |
| 341 | return; |
| 342 | } |
| 343 | } |
| 344 | |
Fabio Estevam | d301a5a | 2014-10-25 11:28:47 -0200 | [diff] [blame] | 345 | if (host->clk_disp_axi) |
| 346 | clk_prepare_enable(host->clk_disp_axi); |
Shawn Guo | ca4c22d3 | 2011-12-20 14:12:54 +0800 | [diff] [blame] | 347 | clk_prepare_enable(host->clk); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 348 | clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U); |
| 349 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 350 | mxsfb_enable_axi_clk(host); |
| 351 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 352 | /* if it was disabled, re-enable the mode again */ |
| 353 | writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_SET); |
| 354 | |
| 355 | /* enable the SYNC signals first, then the DMA engine */ |
| 356 | reg = readl(host->base + LCDC_VDCTRL4); |
| 357 | reg |= VDCTRL4_SYNC_SIGNALS_ON; |
| 358 | writel(reg, host->base + LCDC_VDCTRL4); |
| 359 | |
| 360 | writel(CTRL_RUN, host->base + LCDC_CTRL + REG_SET); |
| 361 | |
| 362 | host->enabled = 1; |
| 363 | } |
| 364 | |
| 365 | static void mxsfb_disable_controller(struct fb_info *fb_info) |
| 366 | { |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 367 | struct mxsfb_info *host = fb_info->par; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 368 | unsigned loop; |
| 369 | u32 reg; |
Fabio Estevam | 4344429 | 2013-04-07 15:44:59 -0300 | [diff] [blame] | 370 | int ret; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 371 | |
| 372 | dev_dbg(&host->pdev->dev, "%s\n", __func__); |
| 373 | |
| 374 | /* |
| 375 | * Even if we disable the controller here, it will still continue |
| 376 | * until its FIFOs are running out of data |
| 377 | */ |
| 378 | writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_CLR); |
| 379 | |
| 380 | loop = 1000; |
| 381 | while (loop) { |
| 382 | reg = readl(host->base + LCDC_CTRL); |
| 383 | if (!(reg & CTRL_RUN)) |
| 384 | break; |
| 385 | loop--; |
| 386 | } |
| 387 | |
Lothar Waßmann | 6c1ecba | 2012-11-22 13:49:14 +0100 | [diff] [blame] | 388 | reg = readl(host->base + LCDC_VDCTRL4); |
| 389 | writel(reg & ~VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 390 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 391 | mxsfb_disable_axi_clk(host); |
| 392 | |
Shawn Guo | ca4c22d3 | 2011-12-20 14:12:54 +0800 | [diff] [blame] | 393 | clk_disable_unprepare(host->clk); |
Fabio Estevam | d301a5a | 2014-10-25 11:28:47 -0200 | [diff] [blame] | 394 | if (host->clk_disp_axi) |
| 395 | clk_disable_unprepare(host->clk_disp_axi); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 396 | |
| 397 | host->enabled = 0; |
Fabio Estevam | 4344429 | 2013-04-07 15:44:59 -0300 | [diff] [blame] | 398 | |
| 399 | if (host->reg_lcd) { |
| 400 | ret = regulator_disable(host->reg_lcd); |
| 401 | if (ret) |
| 402 | dev_err(&host->pdev->dev, |
| 403 | "lcd regulator disable failed: %d\n", ret); |
| 404 | } |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | static int mxsfb_set_par(struct fb_info *fb_info) |
| 408 | { |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 409 | struct mxsfb_info *host = fb_info->par; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 410 | u32 ctrl, vdctrl0, vdctrl4; |
| 411 | int line_size, fb_size; |
| 412 | int reenable = 0; |
| 413 | |
| 414 | line_size = fb_info->var.xres * (fb_info->var.bits_per_pixel >> 3); |
| 415 | fb_size = fb_info->var.yres_virtual * line_size; |
| 416 | |
| 417 | if (fb_size > fb_info->fix.smem_len) |
| 418 | return -ENOMEM; |
| 419 | |
| 420 | fb_info->fix.line_length = line_size; |
| 421 | |
| 422 | /* |
| 423 | * It seems, you can't re-program the controller if it is still running. |
| 424 | * This may lead into shifted pictures (FIFO issue?). |
| 425 | * So, first stop the controller and drain its FIFOs |
| 426 | */ |
| 427 | if (host->enabled) { |
| 428 | reenable = 1; |
| 429 | mxsfb_disable_controller(fb_info); |
| 430 | } |
| 431 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 432 | mxsfb_enable_axi_clk(host); |
| 433 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 434 | /* clear the FIFOs */ |
| 435 | writel(CTRL1_FIFO_CLEAR, host->base + LCDC_CTRL1 + REG_SET); |
| 436 | |
| 437 | ctrl = CTRL_BYPASS_COUNT | CTRL_MASTER | |
Justin P. Mattock | 6eab04a | 2011-04-08 19:49:08 -0700 | [diff] [blame] | 438 | CTRL_SET_BUS_WIDTH(host->ld_intf_width); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 439 | |
| 440 | switch (fb_info->var.bits_per_pixel) { |
| 441 | case 16: |
| 442 | dev_dbg(&host->pdev->dev, "Setting up RGB565 mode\n"); |
| 443 | ctrl |= CTRL_SET_WORD_LENGTH(0); |
| 444 | writel(CTRL1_SET_BYTE_PACKAGING(0xf), host->base + LCDC_CTRL1); |
| 445 | break; |
| 446 | case 32: |
| 447 | dev_dbg(&host->pdev->dev, "Setting up RGB888/666 mode\n"); |
| 448 | ctrl |= CTRL_SET_WORD_LENGTH(3); |
| 449 | switch (host->ld_intf_width) { |
| 450 | case STMLCDIF_8BIT: |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 451 | mxsfb_disable_axi_clk(host); |
Lothar Waßmann | 18dd44d | 2014-01-06 14:17:57 +0100 | [diff] [blame] | 452 | dev_err(&host->pdev->dev, |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 453 | "Unsupported LCD bus width mapping\n"); |
| 454 | return -EINVAL; |
| 455 | case STMLCDIF_16BIT: |
| 456 | case STMLCDIF_18BIT: |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 457 | case STMLCDIF_24BIT: |
| 458 | /* real 24 bit */ |
| 459 | break; |
| 460 | } |
| 461 | /* do not use packed pixels = one pixel per word instead */ |
| 462 | writel(CTRL1_SET_BYTE_PACKAGING(0x7), host->base + LCDC_CTRL1); |
| 463 | break; |
| 464 | default: |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 465 | mxsfb_disable_axi_clk(host); |
Lothar Waßmann | 18dd44d | 2014-01-06 14:17:57 +0100 | [diff] [blame] | 466 | dev_err(&host->pdev->dev, "Unhandled color depth of %u\n", |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 467 | fb_info->var.bits_per_pixel); |
| 468 | return -EINVAL; |
| 469 | } |
| 470 | |
| 471 | writel(ctrl, host->base + LCDC_CTRL); |
| 472 | |
| 473 | writel(TRANSFER_COUNT_SET_VCOUNT(fb_info->var.yres) | |
| 474 | TRANSFER_COUNT_SET_HCOUNT(fb_info->var.xres), |
| 475 | host->base + host->devdata->transfer_count); |
| 476 | |
| 477 | vdctrl0 = VDCTRL0_ENABLE_PRESENT | /* always in DOTCLOCK mode */ |
| 478 | VDCTRL0_VSYNC_PERIOD_UNIT | |
| 479 | VDCTRL0_VSYNC_PULSE_WIDTH_UNIT | |
| 480 | VDCTRL0_SET_VSYNC_PULSE_WIDTH(fb_info->var.vsync_len); |
| 481 | if (fb_info->var.sync & FB_SYNC_HOR_HIGH_ACT) |
| 482 | vdctrl0 |= VDCTRL0_HSYNC_ACT_HIGH; |
| 483 | if (fb_info->var.sync & FB_SYNC_VERT_HIGH_ACT) |
| 484 | vdctrl0 |= VDCTRL0_VSYNC_ACT_HIGH; |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 485 | if (host->sync & MXSFB_SYNC_DATA_ENABLE_HIGH_ACT) |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 486 | vdctrl0 |= VDCTRL0_ENABLE_ACT_HIGH; |
Shawn Guo | c8b5cfc | 2013-03-14 13:21:56 +0800 | [diff] [blame] | 487 | if (host->sync & MXSFB_SYNC_DOTCLK_FALLING_ACT) |
| 488 | vdctrl0 |= VDCTRL0_DOTCLK_ACT_FALLING; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 489 | |
| 490 | writel(vdctrl0, host->base + LCDC_VDCTRL0); |
| 491 | |
| 492 | /* frame length in lines */ |
| 493 | writel(fb_info->var.upper_margin + fb_info->var.vsync_len + |
| 494 | fb_info->var.lower_margin + fb_info->var.yres, |
| 495 | host->base + LCDC_VDCTRL1); |
| 496 | |
| 497 | /* line length in units of clocks or pixels */ |
| 498 | writel(set_hsync_pulse_width(host, fb_info->var.hsync_len) | |
| 499 | VDCTRL2_SET_HSYNC_PERIOD(fb_info->var.left_margin + |
| 500 | fb_info->var.hsync_len + fb_info->var.right_margin + |
| 501 | fb_info->var.xres), |
| 502 | host->base + LCDC_VDCTRL2); |
| 503 | |
| 504 | writel(SET_HOR_WAIT_CNT(fb_info->var.left_margin + |
| 505 | fb_info->var.hsync_len) | |
| 506 | SET_VERT_WAIT_CNT(fb_info->var.upper_margin + |
| 507 | fb_info->var.vsync_len), |
| 508 | host->base + LCDC_VDCTRL3); |
| 509 | |
| 510 | vdctrl4 = SET_DOTCLK_H_VALID_DATA_CNT(fb_info->var.xres); |
| 511 | if (mxsfb_is_v4(host)) |
| 512 | vdctrl4 |= VDCTRL4_SET_DOTCLK_DLY(host->dotclk_delay); |
| 513 | writel(vdctrl4, host->base + LCDC_VDCTRL4); |
| 514 | |
| 515 | writel(fb_info->fix.smem_start + |
| 516 | fb_info->fix.line_length * fb_info->var.yoffset, |
| 517 | host->base + host->devdata->next_buf); |
| 518 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 519 | mxsfb_disable_axi_clk(host); |
| 520 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 521 | if (reenable) |
| 522 | mxsfb_enable_controller(fb_info); |
| 523 | |
| 524 | return 0; |
| 525 | } |
| 526 | |
| 527 | static int mxsfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, |
| 528 | u_int transp, struct fb_info *fb_info) |
| 529 | { |
| 530 | unsigned int val; |
| 531 | int ret = -EINVAL; |
| 532 | |
| 533 | /* |
| 534 | * If greyscale is true, then we convert the RGB value |
| 535 | * to greyscale no matter what visual we are using. |
| 536 | */ |
| 537 | if (fb_info->var.grayscale) |
| 538 | red = green = blue = (19595 * red + 38470 * green + |
| 539 | 7471 * blue) >> 16; |
| 540 | |
| 541 | switch (fb_info->fix.visual) { |
| 542 | case FB_VISUAL_TRUECOLOR: |
| 543 | /* |
| 544 | * 12 or 16-bit True Colour. We encode the RGB value |
| 545 | * according to the RGB bitfield information. |
| 546 | */ |
| 547 | if (regno < 16) { |
| 548 | u32 *pal = fb_info->pseudo_palette; |
| 549 | |
| 550 | val = chan_to_field(red, &fb_info->var.red); |
| 551 | val |= chan_to_field(green, &fb_info->var.green); |
| 552 | val |= chan_to_field(blue, &fb_info->var.blue); |
| 553 | |
| 554 | pal[regno] = val; |
| 555 | ret = 0; |
| 556 | } |
| 557 | break; |
| 558 | |
| 559 | case FB_VISUAL_STATIC_PSEUDOCOLOR: |
| 560 | case FB_VISUAL_PSEUDOCOLOR: |
| 561 | break; |
| 562 | } |
| 563 | |
| 564 | return ret; |
| 565 | } |
| 566 | |
| 567 | static int mxsfb_blank(int blank, struct fb_info *fb_info) |
| 568 | { |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 569 | struct mxsfb_info *host = fb_info->par; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 570 | |
| 571 | switch (blank) { |
| 572 | case FB_BLANK_POWERDOWN: |
| 573 | case FB_BLANK_VSYNC_SUSPEND: |
| 574 | case FB_BLANK_HSYNC_SUSPEND: |
| 575 | case FB_BLANK_NORMAL: |
| 576 | if (host->enabled) |
| 577 | mxsfb_disable_controller(fb_info); |
| 578 | break; |
| 579 | |
| 580 | case FB_BLANK_UNBLANK: |
| 581 | if (!host->enabled) |
| 582 | mxsfb_enable_controller(fb_info); |
| 583 | break; |
| 584 | } |
| 585 | return 0; |
| 586 | } |
| 587 | |
| 588 | static int mxsfb_pan_display(struct fb_var_screeninfo *var, |
| 589 | struct fb_info *fb_info) |
| 590 | { |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 591 | struct mxsfb_info *host = fb_info->par; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 592 | unsigned offset; |
| 593 | |
| 594 | if (var->xoffset != 0) |
| 595 | return -EINVAL; |
| 596 | |
| 597 | offset = fb_info->fix.line_length * var->yoffset; |
| 598 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 599 | mxsfb_enable_axi_clk(host); |
| 600 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 601 | /* update on next VSYNC */ |
| 602 | writel(fb_info->fix.smem_start + offset, |
| 603 | host->base + host->devdata->next_buf); |
| 604 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 605 | mxsfb_disable_axi_clk(host); |
| 606 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 607 | return 0; |
| 608 | } |
| 609 | |
| 610 | static struct fb_ops mxsfb_ops = { |
| 611 | .owner = THIS_MODULE, |
| 612 | .fb_check_var = mxsfb_check_var, |
| 613 | .fb_set_par = mxsfb_set_par, |
| 614 | .fb_setcolreg = mxsfb_setcolreg, |
| 615 | .fb_blank = mxsfb_blank, |
| 616 | .fb_pan_display = mxsfb_pan_display, |
| 617 | .fb_fillrect = cfb_fillrect, |
| 618 | .fb_copyarea = cfb_copyarea, |
| 619 | .fb_imageblit = cfb_imageblit, |
| 620 | }; |
| 621 | |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 622 | static int mxsfb_restore_mode(struct fb_info *fb_info, |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 623 | struct fb_videomode *vmode) |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 624 | { |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 625 | struct mxsfb_info *host = fb_info->par; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 626 | unsigned line_count; |
| 627 | unsigned period; |
| 628 | unsigned long pa, fbsize; |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 629 | int bits_per_pixel, ofs, ret = 0; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 630 | u32 transfer_count, vdctrl0, vdctrl2, vdctrl3, vdctrl4, ctrl; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 631 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 632 | mxsfb_enable_axi_clk(host); |
| 633 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 634 | /* Only restore the mode when the controller is running */ |
| 635 | ctrl = readl(host->base + LCDC_CTRL); |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 636 | if (!(ctrl & CTRL_RUN)) { |
| 637 | ret = -EINVAL; |
| 638 | goto err; |
| 639 | } |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 640 | |
| 641 | vdctrl0 = readl(host->base + LCDC_VDCTRL0); |
| 642 | vdctrl2 = readl(host->base + LCDC_VDCTRL2); |
| 643 | vdctrl3 = readl(host->base + LCDC_VDCTRL3); |
| 644 | vdctrl4 = readl(host->base + LCDC_VDCTRL4); |
| 645 | |
| 646 | transfer_count = readl(host->base + host->devdata->transfer_count); |
| 647 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 648 | vmode->xres = TRANSFER_COUNT_GET_HCOUNT(transfer_count); |
| 649 | vmode->yres = TRANSFER_COUNT_GET_VCOUNT(transfer_count); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 650 | |
| 651 | switch (CTRL_GET_WORD_LENGTH(ctrl)) { |
| 652 | case 0: |
| 653 | bits_per_pixel = 16; |
| 654 | break; |
| 655 | case 3: |
| 656 | bits_per_pixel = 32; |
Marek Vasut | 6d0bb81 | 2013-09-26 13:13:58 +0200 | [diff] [blame] | 657 | break; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 658 | case 1: |
| 659 | default: |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 660 | ret = -EINVAL; |
| 661 | goto err; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | fb_info->var.bits_per_pixel = bits_per_pixel; |
| 665 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 666 | vmode->pixclock = KHZ2PICOS(clk_get_rate(host->clk) / 1000U); |
| 667 | vmode->hsync_len = get_hsync_pulse_width(host, vdctrl2); |
| 668 | vmode->left_margin = GET_HOR_WAIT_CNT(vdctrl3) - vmode->hsync_len; |
| 669 | vmode->right_margin = VDCTRL2_GET_HSYNC_PERIOD(vdctrl2) - |
| 670 | vmode->hsync_len - vmode->left_margin - vmode->xres; |
| 671 | vmode->vsync_len = VDCTRL0_GET_VSYNC_PULSE_WIDTH(vdctrl0); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 672 | period = readl(host->base + LCDC_VDCTRL1); |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 673 | vmode->upper_margin = GET_VERT_WAIT_CNT(vdctrl3) - vmode->vsync_len; |
| 674 | vmode->lower_margin = period - vmode->vsync_len - |
| 675 | vmode->upper_margin - vmode->yres; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 676 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 677 | vmode->vmode = FB_VMODE_NONINTERLACED; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 678 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 679 | vmode->sync = 0; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 680 | if (vdctrl0 & VDCTRL0_HSYNC_ACT_HIGH) |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 681 | vmode->sync |= FB_SYNC_HOR_HIGH_ACT; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 682 | if (vdctrl0 & VDCTRL0_VSYNC_ACT_HIGH) |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 683 | vmode->sync |= FB_SYNC_VERT_HIGH_ACT; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 684 | |
| 685 | pr_debug("Reconstructed video mode:\n"); |
| 686 | pr_debug("%dx%d, hsync: %u left: %u, right: %u, vsync: %u, upper: %u, lower: %u\n", |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 687 | vmode->xres, vmode->yres, vmode->hsync_len, vmode->left_margin, |
| 688 | vmode->right_margin, vmode->vsync_len, vmode->upper_margin, |
| 689 | vmode->lower_margin); |
| 690 | pr_debug("pixclk: %ldkHz\n", PICOS2KHZ(vmode->pixclock)); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 691 | |
| 692 | host->ld_intf_width = CTRL_GET_BUS_WIDTH(ctrl); |
| 693 | host->dotclk_delay = VDCTRL4_GET_DOTCLK_DLY(vdctrl4); |
| 694 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 695 | fb_info->fix.line_length = vmode->xres * (bits_per_pixel >> 3); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 696 | |
| 697 | pa = readl(host->base + host->devdata->cur_buf); |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 698 | fbsize = fb_info->fix.line_length * vmode->yres; |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 699 | if (pa < fb_info->fix.smem_start) { |
| 700 | ret = -EINVAL; |
| 701 | goto err; |
| 702 | } |
| 703 | if (pa + fbsize > fb_info->fix.smem_start + fb_info->fix.smem_len) { |
| 704 | ret = -EINVAL; |
| 705 | goto err; |
| 706 | } |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 707 | ofs = pa - fb_info->fix.smem_start; |
| 708 | if (ofs) { |
| 709 | memmove(fb_info->screen_base, fb_info->screen_base + ofs, fbsize); |
| 710 | writel(fb_info->fix.smem_start, host->base + host->devdata->next_buf); |
| 711 | } |
| 712 | |
| 713 | line_count = fb_info->fix.smem_len / fb_info->fix.line_length; |
| 714 | fb_info->fix.ypanstep = 1; |
| 715 | |
Shawn Guo | ca4c22d3 | 2011-12-20 14:12:54 +0800 | [diff] [blame] | 716 | clk_prepare_enable(host->clk); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 717 | host->enabled = 1; |
| 718 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 719 | err: |
| 720 | if (ret) |
| 721 | mxsfb_disable_axi_clk(host); |
| 722 | |
| 723 | return ret; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 724 | } |
| 725 | |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 726 | static int mxsfb_init_fbinfo_dt(struct fb_info *fb_info, |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 727 | struct fb_videomode *vmode) |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 728 | { |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 729 | struct mxsfb_info *host = fb_info->par; |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 730 | struct fb_var_screeninfo *var = &fb_info->var; |
| 731 | struct device *dev = &host->pdev->dev; |
| 732 | struct device_node *np = host->pdev->dev.of_node; |
| 733 | struct device_node *display_np; |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 734 | struct videomode vm; |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 735 | u32 width; |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 736 | int ret; |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 737 | |
| 738 | display_np = of_parse_phandle(np, "display", 0); |
| 739 | if (!display_np) { |
| 740 | dev_err(dev, "failed to find display phandle\n"); |
| 741 | return -ENOENT; |
| 742 | } |
| 743 | |
| 744 | ret = of_property_read_u32(display_np, "bus-width", &width); |
| 745 | if (ret < 0) { |
| 746 | dev_err(dev, "failed to get property bus-width\n"); |
| 747 | goto put_display_node; |
| 748 | } |
| 749 | |
| 750 | switch (width) { |
| 751 | case 8: |
| 752 | host->ld_intf_width = STMLCDIF_8BIT; |
| 753 | break; |
| 754 | case 16: |
| 755 | host->ld_intf_width = STMLCDIF_16BIT; |
| 756 | break; |
| 757 | case 18: |
| 758 | host->ld_intf_width = STMLCDIF_18BIT; |
| 759 | break; |
| 760 | case 24: |
| 761 | host->ld_intf_width = STMLCDIF_24BIT; |
| 762 | break; |
| 763 | default: |
| 764 | dev_err(dev, "invalid bus-width value\n"); |
| 765 | ret = -EINVAL; |
| 766 | goto put_display_node; |
| 767 | } |
| 768 | |
| 769 | ret = of_property_read_u32(display_np, "bits-per-pixel", |
| 770 | &var->bits_per_pixel); |
| 771 | if (ret < 0) { |
| 772 | dev_err(dev, "failed to get property bits-per-pixel\n"); |
| 773 | goto put_display_node; |
| 774 | } |
| 775 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 776 | ret = of_get_videomode(display_np, &vm, OF_USE_NATIVE_MODE); |
| 777 | if (ret) { |
| 778 | dev_err(dev, "failed to get videomode from DT\n"); |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 779 | goto put_display_node; |
| 780 | } |
| 781 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 782 | ret = fb_videomode_from_videomode(&vm, vmode); |
| 783 | if (ret < 0) |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 784 | goto put_display_node; |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 785 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 786 | if (vm.flags & DISPLAY_FLAGS_DE_HIGH) |
| 787 | host->sync |= MXSFB_SYNC_DATA_ENABLE_HIGH_ACT; |
Stefan Agner | 2d81482 | 2017-11-09 18:09:30 +0100 | [diff] [blame] | 788 | |
| 789 | /* |
| 790 | * The PIXDATA flags of the display_flags enum are controller |
| 791 | * centric, e.g. NEGEDGE means drive data on negative edge. |
| 792 | * However, the drivers flag is display centric: Sample the |
| 793 | * data on negative (falling) edge. Therefore, check for the |
| 794 | * POSEDGE flag: |
| 795 | * drive on positive edge => sample on negative edge |
| 796 | */ |
| 797 | if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE) |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 798 | host->sync |= MXSFB_SYNC_DOTCLK_FALLING_ACT; |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 799 | |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 800 | put_display_node: |
| 801 | of_node_put(display_np); |
| 802 | return ret; |
| 803 | } |
| 804 | |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 805 | static int mxsfb_init_fbinfo(struct fb_info *fb_info, |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 806 | struct fb_videomode *vmode) |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 807 | { |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 808 | int ret; |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 809 | struct mxsfb_info *host = fb_info->par; |
Marek Vasut | 03577d6 | 2016-08-26 17:53:35 +0200 | [diff] [blame] | 810 | struct device *dev = &host->pdev->dev; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 811 | struct fb_var_screeninfo *var = &fb_info->var; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 812 | dma_addr_t fb_phys; |
| 813 | void *fb_virt; |
Shawn Guo | 4aa02c7 | 2013-03-13 14:03:12 +0800 | [diff] [blame] | 814 | unsigned fb_size; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 815 | |
| 816 | fb_info->fbops = &mxsfb_ops; |
| 817 | fb_info->flags = FBINFO_FLAG_DEFAULT | FBINFO_READS_FAST; |
| 818 | strlcpy(fb_info->fix.id, "mxs", sizeof(fb_info->fix.id)); |
| 819 | fb_info->fix.type = FB_TYPE_PACKED_PIXELS; |
| 820 | fb_info->fix.ypanstep = 1; |
| 821 | fb_info->fix.visual = FB_VISUAL_TRUECOLOR, |
| 822 | fb_info->fix.accel = FB_ACCEL_NONE; |
| 823 | |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 824 | ret = mxsfb_init_fbinfo_dt(fb_info, vmode); |
Shawn Guo | c8b5cfc | 2013-03-14 13:21:56 +0800 | [diff] [blame] | 825 | if (ret) |
| 826 | return ret; |
Shawn Guo | 6694065 | 2013-03-14 10:57:34 +0800 | [diff] [blame] | 827 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 828 | var->nonstd = 0; |
| 829 | var->activate = FB_ACTIVATE_NOW; |
| 830 | var->accel_flags = 0; |
| 831 | var->vmode = FB_VMODE_NONINTERLACED; |
| 832 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 833 | /* Memory allocation for framebuffer */ |
Shawn Guo | 4aa02c7 | 2013-03-13 14:03:12 +0800 | [diff] [blame] | 834 | fb_size = SZ_2M; |
Marek Vasut | 03577d6 | 2016-08-26 17:53:35 +0200 | [diff] [blame] | 835 | fb_virt = dma_alloc_wc(dev, PAGE_ALIGN(fb_size), &fb_phys, GFP_KERNEL); |
Shawn Guo | 4aa02c7 | 2013-03-13 14:03:12 +0800 | [diff] [blame] | 836 | if (!fb_virt) |
| 837 | return -ENOMEM; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 838 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 839 | fb_info->fix.smem_start = fb_phys; |
| 840 | fb_info->screen_base = fb_virt; |
| 841 | fb_info->screen_size = fb_info->fix.smem_len = fb_size; |
| 842 | |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 843 | if (mxsfb_restore_mode(fb_info, vmode)) |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 844 | memset(fb_virt, 0, fb_size); |
| 845 | |
| 846 | return 0; |
| 847 | } |
| 848 | |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 849 | static void mxsfb_free_videomem(struct fb_info *fb_info) |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 850 | { |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 851 | struct mxsfb_info *host = fb_info->par; |
Marek Vasut | 03577d6 | 2016-08-26 17:53:35 +0200 | [diff] [blame] | 852 | struct device *dev = &host->pdev->dev; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 853 | |
Marek Vasut | 03577d6 | 2016-08-26 17:53:35 +0200 | [diff] [blame] | 854 | dma_free_wc(dev, fb_info->screen_size, fb_info->screen_base, |
| 855 | fb_info->fix.smem_start); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 856 | } |
| 857 | |
Krzysztof Kozlowski | 99e62ef | 2015-05-02 00:38:40 +0900 | [diff] [blame] | 858 | static const struct platform_device_id mxsfb_devtype[] = { |
Shawn Guo | 73fc610 | 2012-06-25 19:54:35 +0800 | [diff] [blame] | 859 | { |
| 860 | .name = "imx23-fb", |
| 861 | .driver_data = MXSFB_V3, |
| 862 | }, { |
| 863 | .name = "imx28-fb", |
| 864 | .driver_data = MXSFB_V4, |
| 865 | }, { |
| 866 | /* sentinel */ |
| 867 | } |
| 868 | }; |
| 869 | MODULE_DEVICE_TABLE(platform, mxsfb_devtype); |
| 870 | |
| 871 | static const struct of_device_id mxsfb_dt_ids[] = { |
| 872 | { .compatible = "fsl,imx23-lcdif", .data = &mxsfb_devtype[0], }, |
| 873 | { .compatible = "fsl,imx28-lcdif", .data = &mxsfb_devtype[1], }, |
| 874 | { /* sentinel */ } |
| 875 | }; |
| 876 | MODULE_DEVICE_TABLE(of, mxsfb_dt_ids); |
| 877 | |
Greg Kroah-Hartman | 48c68c4 | 2012-12-21 13:07:39 -0800 | [diff] [blame] | 878 | static int mxsfb_probe(struct platform_device *pdev) |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 879 | { |
Shawn Guo | 73fc610 | 2012-06-25 19:54:35 +0800 | [diff] [blame] | 880 | const struct of_device_id *of_id = |
| 881 | of_match_device(mxsfb_dt_ids, &pdev->dev); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 882 | struct resource *res; |
| 883 | struct mxsfb_info *host; |
| 884 | struct fb_info *fb_info; |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 885 | struct fb_videomode *mode; |
Shawn Guo | c8b5cfc | 2013-03-14 13:21:56 +0800 | [diff] [blame] | 886 | int ret; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 887 | |
Shawn Guo | 73fc610 | 2012-06-25 19:54:35 +0800 | [diff] [blame] | 888 | if (of_id) |
| 889 | pdev->id_entry = of_id->data; |
| 890 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 891 | fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev); |
| 892 | if (!fb_info) { |
| 893 | dev_err(&pdev->dev, "Failed to allocate fbdev\n"); |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 894 | return -ENOMEM; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 895 | } |
| 896 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 897 | mode = devm_kzalloc(&pdev->dev, sizeof(struct fb_videomode), |
| 898 | GFP_KERNEL); |
| 899 | if (mode == NULL) |
| 900 | return -ENOMEM; |
| 901 | |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 902 | host = fb_info->par; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 903 | |
Julia Lawall | 51617d1 | 2013-08-14 11:11:06 +0200 | [diff] [blame] | 904 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 905 | host->base = devm_ioremap_resource(&pdev->dev, res); |
| 906 | if (IS_ERR(host->base)) { |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 907 | ret = PTR_ERR(host->base); |
| 908 | goto fb_release; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | host->pdev = pdev; |
| 912 | platform_set_drvdata(pdev, host); |
| 913 | |
| 914 | host->devdata = &mxsfb_devdata[pdev->id_entry->driver_data]; |
| 915 | |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 916 | host->clk = devm_clk_get(&host->pdev->dev, NULL); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 917 | if (IS_ERR(host->clk)) { |
| 918 | ret = PTR_ERR(host->clk); |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 919 | goto fb_release; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 920 | } |
| 921 | |
Fabio Estevam | d301a5a | 2014-10-25 11:28:47 -0200 | [diff] [blame] | 922 | host->clk_axi = devm_clk_get(&host->pdev->dev, "axi"); |
| 923 | if (IS_ERR(host->clk_axi)) |
| 924 | host->clk_axi = NULL; |
| 925 | |
| 926 | host->clk_disp_axi = devm_clk_get(&host->pdev->dev, "disp_axi"); |
| 927 | if (IS_ERR(host->clk_disp_axi)) |
| 928 | host->clk_disp_axi = NULL; |
| 929 | |
Fabio Estevam | 4344429 | 2013-04-07 15:44:59 -0300 | [diff] [blame] | 930 | host->reg_lcd = devm_regulator_get(&pdev->dev, "lcd"); |
| 931 | if (IS_ERR(host->reg_lcd)) |
| 932 | host->reg_lcd = NULL; |
Shawn Guo | 73fc610 | 2012-06-25 19:54:35 +0800 | [diff] [blame] | 933 | |
Kees Cook | a86854d | 2018-06-12 14:07:58 -0700 | [diff] [blame] | 934 | fb_info->pseudo_palette = devm_kcalloc(&pdev->dev, 16, sizeof(u32), |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 935 | GFP_KERNEL); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 936 | if (!fb_info->pseudo_palette) { |
| 937 | ret = -ENOMEM; |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 938 | goto fb_release; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 939 | } |
| 940 | |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 941 | ret = mxsfb_init_fbinfo(fb_info, mode); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 942 | if (ret != 0) |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 943 | goto fb_release; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 944 | |
Lothar Waßmann | 838bdf7 | 2014-01-06 14:17:58 +0100 | [diff] [blame] | 945 | fb_videomode_to_var(&fb_info->var, mode); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 946 | |
| 947 | /* init the color fields */ |
| 948 | mxsfb_check_var(&fb_info->var, fb_info); |
| 949 | |
| 950 | platform_set_drvdata(pdev, fb_info); |
| 951 | |
| 952 | ret = register_framebuffer(fb_info); |
| 953 | if (ret != 0) { |
| 954 | dev_err(&pdev->dev,"Failed to register framebuffer\n"); |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 955 | goto fb_destroy; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | if (!host->enabled) { |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 959 | mxsfb_enable_axi_clk(host); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 960 | writel(0, host->base + LCDC_CTRL); |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 961 | mxsfb_disable_axi_clk(host); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 962 | mxsfb_set_par(fb_info); |
| 963 | mxsfb_enable_controller(fb_info); |
| 964 | } |
| 965 | |
| 966 | dev_info(&pdev->dev, "initialized\n"); |
| 967 | |
| 968 | return 0; |
| 969 | |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 970 | fb_destroy: |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 971 | if (host->enabled) |
Shawn Guo | ca4c22d3 | 2011-12-20 14:12:54 +0800 | [diff] [blame] | 972 | clk_disable_unprepare(host->clk); |
Shawn Guo | 9e54857 | 2013-03-13 13:37:11 +0800 | [diff] [blame] | 973 | fb_release: |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 974 | framebuffer_release(fb_info); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 975 | |
| 976 | return ret; |
| 977 | } |
| 978 | |
Greg Kroah-Hartman | 48c68c4 | 2012-12-21 13:07:39 -0800 | [diff] [blame] | 979 | static int mxsfb_remove(struct platform_device *pdev) |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 980 | { |
| 981 | struct fb_info *fb_info = platform_get_drvdata(pdev); |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 982 | struct mxsfb_info *host = fb_info->par; |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 983 | |
| 984 | if (host->enabled) |
| 985 | mxsfb_disable_controller(fb_info); |
| 986 | |
| 987 | unregister_framebuffer(fb_info); |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 988 | mxsfb_free_videomem(fb_info); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 989 | |
| 990 | framebuffer_release(fb_info); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 991 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 992 | return 0; |
| 993 | } |
| 994 | |
Marek Vasut | d313a86 | 2012-04-19 20:31:02 +0200 | [diff] [blame] | 995 | static void mxsfb_shutdown(struct platform_device *pdev) |
| 996 | { |
| 997 | struct fb_info *fb_info = platform_get_drvdata(pdev); |
Michael Trimarchi | 91ae339 | 2018-01-15 17:04:22 +0100 | [diff] [blame] | 998 | struct mxsfb_info *host = fb_info->par; |
Marek Vasut | d313a86 | 2012-04-19 20:31:02 +0200 | [diff] [blame] | 999 | |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 1000 | mxsfb_enable_axi_clk(host); |
| 1001 | |
Marek Vasut | d313a86 | 2012-04-19 20:31:02 +0200 | [diff] [blame] | 1002 | /* |
| 1003 | * Force stop the LCD controller as keeping it running during reboot |
| 1004 | * might interfere with the BootROM's boot mode pads sampling. |
| 1005 | */ |
| 1006 | writel(CTRL_RUN, host->base + LCDC_CTRL + REG_CLR); |
Liu Ying | 2fa3b4c | 2015-04-03 12:51:05 +0800 | [diff] [blame] | 1007 | |
| 1008 | mxsfb_disable_axi_clk(host); |
Marek Vasut | d313a86 | 2012-04-19 20:31:02 +0200 | [diff] [blame] | 1009 | } |
| 1010 | |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 1011 | static struct platform_driver mxsfb_driver = { |
| 1012 | .probe = mxsfb_probe, |
Greg Kroah-Hartman | 48c68c4 | 2012-12-21 13:07:39 -0800 | [diff] [blame] | 1013 | .remove = mxsfb_remove, |
Marek Vasut | d313a86 | 2012-04-19 20:31:02 +0200 | [diff] [blame] | 1014 | .shutdown = mxsfb_shutdown, |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 1015 | .id_table = mxsfb_devtype, |
| 1016 | .driver = { |
| 1017 | .name = DRIVER_NAME, |
Shawn Guo | 73fc610 | 2012-06-25 19:54:35 +0800 | [diff] [blame] | 1018 | .of_match_table = mxsfb_dt_ids, |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 1019 | }, |
| 1020 | }; |
| 1021 | |
Marek Vasut | 396fa99 | 2011-12-19 16:37:59 +0100 | [diff] [blame] | 1022 | module_platform_driver(mxsfb_driver); |
Sascha Hauer | f0a523b | 2011-01-14 15:22:31 +0100 | [diff] [blame] | 1023 | |
| 1024 | MODULE_DESCRIPTION("Freescale mxs framebuffer driver"); |
| 1025 | MODULE_AUTHOR("Sascha Hauer, Pengutronix"); |
| 1026 | MODULE_LICENSE("GPL"); |