Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Renesas SH-mobile MIPI DSI support |
| 3 | * |
| 4 | * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de> |
| 5 | * |
| 6 | * This is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of version 2 of the GNU General Public License as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
Kuninori Morimoto | 26c3d7a | 2011-11-08 20:34:43 -0800 | [diff] [blame] | 11 | #include <linux/bitmap.h> |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 12 | #include <linux/clk.h> |
| 13 | #include <linux/delay.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/io.h> |
| 16 | #include <linux/platform_device.h> |
Guennadi Liakhovetski | 236782a | 2010-12-27 10:23:05 +0000 | [diff] [blame] | 17 | #include <linux/pm_runtime.h> |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 18 | #include <linux/slab.h> |
| 19 | #include <linux/string.h> |
| 20 | #include <linux/types.h> |
Paul Gortmaker | 355b200 | 2011-07-03 16:17:28 -0400 | [diff] [blame] | 21 | #include <linux/module.h> |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 22 | |
| 23 | #include <video/mipi_display.h> |
| 24 | #include <video/sh_mipi_dsi.h> |
| 25 | #include <video/sh_mobile_lcdc.h> |
| 26 | |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 27 | #include "sh_mobile_lcdcfb.h" |
| 28 | |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 29 | #define SYSCTRL 0x0000 |
| 30 | #define SYSCONF 0x0004 |
| 31 | #define TIMSET 0x0008 |
| 32 | #define RESREQSET0 0x0018 |
| 33 | #define RESREQSET1 0x001c |
| 34 | #define HSTTOVSET 0x0020 |
| 35 | #define LPRTOVSET 0x0024 |
| 36 | #define TATOVSET 0x0028 |
| 37 | #define PRTOVSET 0x002c |
| 38 | #define DSICTRL 0x0030 |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 39 | #define DSIINTE 0x0060 |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 40 | #define PHYCTRL 0x0070 |
| 41 | |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 42 | /* relative to linkbase */ |
| 43 | #define DTCTR 0x0000 |
| 44 | #define VMCTR1 0x0020 |
| 45 | #define VMCTR2 0x0024 |
| 46 | #define VMLEN1 0x0028 |
Kuninori Morimoto | 0875061 | 2011-11-08 20:35:05 -0800 | [diff] [blame] | 47 | #define VMLEN2 0x002c |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 48 | #define CMTSRTREQ 0x0070 |
| 49 | #define CMTSRTCTR 0x00d0 |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 50 | |
| 51 | /* E.g., sh7372 has 2 MIPI-DSIs - one for each LCDC */ |
| 52 | #define MAX_SH_MIPI_DSI 2 |
| 53 | |
| 54 | struct sh_mipi { |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 55 | struct sh_mobile_lcdc_entity entity; |
| 56 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 57 | void __iomem *base; |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 58 | void __iomem *linkbase; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 59 | struct clk *dsit_clk; |
Kuninori Morimoto | 7d9f88b | 2011-11-08 20:35:36 -0800 | [diff] [blame] | 60 | struct platform_device *pdev; |
Guennadi Liakhovetski | 236782a | 2010-12-27 10:23:05 +0000 | [diff] [blame] | 61 | |
| 62 | void *next_board_data; |
| 63 | void (*next_display_on)(void *board_data, struct fb_info *info); |
| 64 | void (*next_display_off)(void *board_data); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 67 | #define to_sh_mipi(e) container_of(e, struct sh_mipi, entity) |
| 68 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 69 | static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI]; |
| 70 | |
| 71 | /* Protect the above array */ |
| 72 | static DEFINE_MUTEX(array_lock); |
| 73 | |
| 74 | static struct sh_mipi *sh_mipi_by_handle(int handle) |
| 75 | { |
| 76 | if (handle >= ARRAY_SIZE(mipi_dsi) || handle < 0) |
| 77 | return NULL; |
| 78 | |
| 79 | return mipi_dsi[handle]; |
| 80 | } |
| 81 | |
| 82 | static int sh_mipi_send_short(struct sh_mipi *mipi, u8 dsi_cmd, |
| 83 | u8 cmd, u8 param) |
| 84 | { |
| 85 | u32 data = (dsi_cmd << 24) | (cmd << 16) | (param << 8); |
| 86 | int cnt = 100; |
| 87 | |
| 88 | /* transmit a short packet to LCD panel */ |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 89 | iowrite32(1 | data, mipi->linkbase + CMTSRTCTR); |
| 90 | iowrite32(1, mipi->linkbase + CMTSRTREQ); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 91 | |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 92 | while ((ioread32(mipi->linkbase + CMTSRTREQ) & 1) && --cnt) |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 93 | udelay(1); |
| 94 | |
| 95 | return cnt ? 0 : -ETIMEDOUT; |
| 96 | } |
| 97 | |
| 98 | #define LCD_CHAN2MIPI(c) ((c) < LCDC_CHAN_MAINLCD || (c) > LCDC_CHAN_SUBLCD ? \ |
| 99 | -EINVAL : (c) - 1) |
| 100 | |
| 101 | static int sh_mipi_dcs(int handle, u8 cmd) |
| 102 | { |
| 103 | struct sh_mipi *mipi = sh_mipi_by_handle(LCD_CHAN2MIPI(handle)); |
| 104 | if (!mipi) |
| 105 | return -ENODEV; |
| 106 | return sh_mipi_send_short(mipi, MIPI_DSI_DCS_SHORT_WRITE, cmd, 0); |
| 107 | } |
| 108 | |
| 109 | static int sh_mipi_dcs_param(int handle, u8 cmd, u8 param) |
| 110 | { |
| 111 | struct sh_mipi *mipi = sh_mipi_by_handle(LCD_CHAN2MIPI(handle)); |
| 112 | if (!mipi) |
| 113 | return -ENODEV; |
| 114 | return sh_mipi_send_short(mipi, MIPI_DSI_DCS_SHORT_WRITE_PARAM, cmd, |
| 115 | param); |
| 116 | } |
| 117 | |
| 118 | static void sh_mipi_dsi_enable(struct sh_mipi *mipi, bool enable) |
| 119 | { |
| 120 | /* |
| 121 | * enable LCDC data tx, transition to LPS after completion of each HS |
| 122 | * packet |
| 123 | */ |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 124 | iowrite32(0x00000002 | enable, mipi->linkbase + DTCTR); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | static void sh_mipi_shutdown(struct platform_device *pdev) |
| 128 | { |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 129 | struct sh_mipi *mipi = to_sh_mipi(platform_get_drvdata(pdev)); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 130 | |
| 131 | sh_mipi_dsi_enable(mipi, false); |
| 132 | } |
| 133 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 134 | static int __init sh_mipi_setup(struct sh_mipi *mipi, |
| 135 | struct sh_mipi_dsi_info *pdata) |
| 136 | { |
| 137 | void __iomem *base = mipi->base; |
| 138 | struct sh_mobile_lcdc_chan_cfg *ch = pdata->lcd_chan; |
Kuninori Morimoto | f832906a | 2011-11-08 20:34:55 -0800 | [diff] [blame] | 139 | u32 pctype, datatype, pixfmt, linelength, vmctr2; |
Kuninori Morimoto | a2e6297 | 2011-11-08 20:35:27 -0800 | [diff] [blame] | 140 | u32 tmp, top, bottom, delay, div; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 141 | bool yuv; |
Kuninori Morimoto | 0875061 | 2011-11-08 20:35:05 -0800 | [diff] [blame] | 142 | int bpp; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 143 | |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 144 | /* |
| 145 | * Select data format. MIPI DSI is not hot-pluggable, so, we just use |
| 146 | * the default videomode. If this ever becomes a problem, We'll have to |
| 147 | * move this to mipi_display_on() above and use info->var.xres |
| 148 | */ |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 149 | switch (pdata->data_format) { |
| 150 | case MIPI_RGB888: |
| 151 | pctype = 0; |
| 152 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_24; |
| 153 | pixfmt = MIPI_DCS_PIXEL_FMT_24BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 154 | linelength = ch->lcd_cfg[0].xres * 3; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 155 | yuv = false; |
| 156 | break; |
| 157 | case MIPI_RGB565: |
| 158 | pctype = 1; |
| 159 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_16; |
| 160 | pixfmt = MIPI_DCS_PIXEL_FMT_16BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 161 | linelength = ch->lcd_cfg[0].xres * 2; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 162 | yuv = false; |
| 163 | break; |
| 164 | case MIPI_RGB666_LP: |
| 165 | pctype = 2; |
| 166 | datatype = MIPI_DSI_PIXEL_STREAM_3BYTE_18; |
| 167 | pixfmt = MIPI_DCS_PIXEL_FMT_24BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 168 | linelength = ch->lcd_cfg[0].xres * 3; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 169 | yuv = false; |
| 170 | break; |
| 171 | case MIPI_RGB666: |
| 172 | pctype = 3; |
| 173 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_18; |
| 174 | pixfmt = MIPI_DCS_PIXEL_FMT_18BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 175 | linelength = (ch->lcd_cfg[0].xres * 18 + 7) / 8; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 176 | yuv = false; |
| 177 | break; |
| 178 | case MIPI_BGR888: |
| 179 | pctype = 8; |
| 180 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_24; |
| 181 | pixfmt = MIPI_DCS_PIXEL_FMT_24BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 182 | linelength = ch->lcd_cfg[0].xres * 3; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 183 | yuv = false; |
| 184 | break; |
| 185 | case MIPI_BGR565: |
| 186 | pctype = 9; |
| 187 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_16; |
| 188 | pixfmt = MIPI_DCS_PIXEL_FMT_16BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 189 | linelength = ch->lcd_cfg[0].xres * 2; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 190 | yuv = false; |
| 191 | break; |
| 192 | case MIPI_BGR666_LP: |
| 193 | pctype = 0xa; |
| 194 | datatype = MIPI_DSI_PIXEL_STREAM_3BYTE_18; |
| 195 | pixfmt = MIPI_DCS_PIXEL_FMT_24BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 196 | linelength = ch->lcd_cfg[0].xres * 3; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 197 | yuv = false; |
| 198 | break; |
| 199 | case MIPI_BGR666: |
| 200 | pctype = 0xb; |
| 201 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_18; |
| 202 | pixfmt = MIPI_DCS_PIXEL_FMT_18BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 203 | linelength = (ch->lcd_cfg[0].xres * 18 + 7) / 8; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 204 | yuv = false; |
| 205 | break; |
| 206 | case MIPI_YUYV: |
| 207 | pctype = 4; |
| 208 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16; |
| 209 | pixfmt = MIPI_DCS_PIXEL_FMT_16BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 210 | linelength = ch->lcd_cfg[0].xres * 2; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 211 | yuv = true; |
| 212 | break; |
| 213 | case MIPI_UYVY: |
| 214 | pctype = 5; |
| 215 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16; |
| 216 | pixfmt = MIPI_DCS_PIXEL_FMT_16BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 217 | linelength = ch->lcd_cfg[0].xres * 2; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 218 | yuv = true; |
| 219 | break; |
| 220 | case MIPI_YUV420_L: |
| 221 | pctype = 6; |
| 222 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12; |
| 223 | pixfmt = MIPI_DCS_PIXEL_FMT_12BIT; |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 224 | linelength = (ch->lcd_cfg[0].xres * 12 + 7) / 8; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 225 | yuv = true; |
| 226 | break; |
| 227 | case MIPI_YUV420: |
| 228 | pctype = 7; |
| 229 | datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12; |
| 230 | pixfmt = MIPI_DCS_PIXEL_FMT_12BIT; |
| 231 | /* Length of U/V line */ |
Guennadi Liakhovetski | 4443240 | 2010-09-03 07:20:04 +0000 | [diff] [blame] | 232 | linelength = (ch->lcd_cfg[0].xres + 1) / 2; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 233 | yuv = true; |
| 234 | break; |
| 235 | default: |
| 236 | return -EINVAL; |
| 237 | } |
| 238 | |
| 239 | if ((yuv && ch->interface_type != YUV422) || |
| 240 | (!yuv && ch->interface_type != RGB24)) |
| 241 | return -EINVAL; |
| 242 | |
Kuninori Morimoto | 26c3d7a | 2011-11-08 20:34:43 -0800 | [diff] [blame] | 243 | if (!pdata->lane) |
| 244 | return -EINVAL; |
| 245 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 246 | /* reset DSI link */ |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 247 | iowrite32(0x00000001, base + SYSCTRL); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 248 | /* Hold reset for 100 cycles of the slowest of bus, HS byte and LP clock */ |
| 249 | udelay(50); |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 250 | iowrite32(0x00000000, base + SYSCTRL); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 251 | |
| 252 | /* setup DSI link */ |
| 253 | |
| 254 | /* |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 255 | * T_wakeup = 0x7000 |
| 256 | * T_hs-trail = 3 |
| 257 | * T_hs-prepare = 3 |
| 258 | * T_clk-trail = 3 |
| 259 | * T_clk-prepare = 2 |
| 260 | */ |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 261 | iowrite32(0x70003332, base + TIMSET); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 262 | /* no responses requested */ |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 263 | iowrite32(0x00000000, base + RESREQSET0); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 264 | /* request response to packets of type 0x28 */ |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 265 | iowrite32(0x00000100, base + RESREQSET1); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 266 | /* High-speed transmission timeout, default 0xffffffff */ |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 267 | iowrite32(0x0fffffff, base + HSTTOVSET); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 268 | /* LP reception timeout, default 0xffffffff */ |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 269 | iowrite32(0x0fffffff, base + LPRTOVSET); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 270 | /* Turn-around timeout, default 0xffffffff */ |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 271 | iowrite32(0x0fffffff, base + TATOVSET); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 272 | /* Peripheral reset timeout, default 0xffffffff */ |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 273 | iowrite32(0x0fffffff, base + PRTOVSET); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 274 | /* Interrupts not used, disable all */ |
| 275 | iowrite32(0, base + DSIINTE); |
| 276 | /* DSI-Tx bias on */ |
Magnus Damm | 71b146c | 2010-11-17 06:44:25 +0000 | [diff] [blame] | 277 | iowrite32(0x00000001, base + PHYCTRL); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 278 | udelay(200); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 279 | /* Deassert resets, power on */ |
| 280 | iowrite32(0x03070001, base + PHYCTRL); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 281 | |
Kuninori Morimoto | a2065a3 | 2011-11-08 20:35:56 -0800 | [diff] [blame] | 282 | /* |
| 283 | * Default = ULPS enable | |
| 284 | * Contention detection enabled | |
| 285 | * EoT packet transmission enable | |
| 286 | * CRC check enable | |
| 287 | * ECC check enable |
| 288 | */ |
| 289 | bitmap_fill((unsigned long *)&tmp, pdata->lane); |
| 290 | tmp |= 0x00003700; |
| 291 | iowrite32(tmp, base + SYSCONF); |
| 292 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 293 | /* setup l-bridge */ |
| 294 | |
| 295 | /* |
| 296 | * Enable transmission of all packets, |
| 297 | * transmit LPS after each HS packet completion |
| 298 | */ |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 299 | iowrite32(0x00000006, mipi->linkbase + DTCTR); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 300 | /* VSYNC width = 2 (<< 17) */ |
Guennadi Liakhovetski | 14bbb7c | 2010-12-29 08:12:29 +0000 | [diff] [blame] | 301 | iowrite32((ch->lcd_cfg[0].vsync_len << pdata->vsynw_offset) | |
| 302 | (pdata->clksrc << 16) | (pctype << 12) | datatype, |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 303 | mipi->linkbase + VMCTR1); |
Guennadi Liakhovetski | 14bbb7c | 2010-12-29 08:12:29 +0000 | [diff] [blame] | 304 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 305 | /* |
| 306 | * Non-burst mode with sync pulses: VSE and HSE are output, |
| 307 | * HSA period allowed, no commands in LP |
| 308 | */ |
Kuninori Morimoto | f832906a | 2011-11-08 20:34:55 -0800 | [diff] [blame] | 309 | vmctr2 = 0; |
| 310 | if (pdata->flags & SH_MIPI_DSI_VSEE) |
| 311 | vmctr2 |= 1 << 23; |
| 312 | if (pdata->flags & SH_MIPI_DSI_HSEE) |
| 313 | vmctr2 |= 1 << 22; |
| 314 | if (pdata->flags & SH_MIPI_DSI_HSAE) |
| 315 | vmctr2 |= 1 << 21; |
Kuninori Morimoto | d07a9d2 | 2011-11-08 20:34:33 -0800 | [diff] [blame] | 316 | if (pdata->flags & SH_MIPI_DSI_BL2E) |
| 317 | vmctr2 |= 1 << 17; |
Guennadi Liakhovetski | 14bbb7c | 2010-12-29 08:12:29 +0000 | [diff] [blame] | 318 | if (pdata->flags & SH_MIPI_DSI_HSABM) |
Kuninori Morimoto | 3c2a659 | 2011-11-08 20:34:12 -0800 | [diff] [blame] | 319 | vmctr2 |= 1 << 5; |
Kuninori Morimoto | 32ba95c | 2011-11-08 20:34:01 -0800 | [diff] [blame] | 320 | if (pdata->flags & SH_MIPI_DSI_HBPBM) |
Kuninori Morimoto | 3c2a659 | 2011-11-08 20:34:12 -0800 | [diff] [blame] | 321 | vmctr2 |= 1 << 4; |
Kuninori Morimoto | f7b0af6 | 2011-11-08 20:34:24 -0800 | [diff] [blame] | 322 | if (pdata->flags & SH_MIPI_DSI_HFPBM) |
| 323 | vmctr2 |= 1 << 3; |
Guennadi Liakhovetski | 14bbb7c | 2010-12-29 08:12:29 +0000 | [diff] [blame] | 324 | iowrite32(vmctr2, mipi->linkbase + VMCTR2); |
| 325 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 326 | /* |
Kuninori Morimoto | 0875061 | 2011-11-08 20:35:05 -0800 | [diff] [blame] | 327 | * VMLEN1 = RGBLEN | HSALEN |
| 328 | * |
| 329 | * see |
| 330 | * Video mode - Blanking Packet setting |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 331 | */ |
Kuninori Morimoto | 0875061 | 2011-11-08 20:35:05 -0800 | [diff] [blame] | 332 | top = linelength << 16; /* RGBLEN */ |
| 333 | bottom = 0x00000001; |
| 334 | if (pdata->flags & SH_MIPI_DSI_HSABM) /* HSALEN */ |
| 335 | bottom = (pdata->lane * ch->lcd_cfg[0].hsync_len) - 10; |
| 336 | iowrite32(top | bottom , mipi->linkbase + VMLEN1); |
| 337 | |
| 338 | /* |
| 339 | * VMLEN2 = HBPLEN | HFPLEN |
| 340 | * |
| 341 | * see |
| 342 | * Video mode - Blanking Packet setting |
| 343 | */ |
| 344 | top = 0x00010000; |
| 345 | bottom = 0x00000001; |
| 346 | delay = 0; |
| 347 | |
Kuninori Morimoto | a2e6297 | 2011-11-08 20:35:27 -0800 | [diff] [blame] | 348 | div = 1; /* HSbyteCLK is calculation base |
| 349 | * HS4divCLK = HSbyteCLK/2 |
| 350 | * HS6divCLK is not supported for now */ |
| 351 | if (pdata->flags & SH_MIPI_DSI_HS4divCLK) |
| 352 | div = 2; |
| 353 | |
Kuninori Morimoto | 0875061 | 2011-11-08 20:35:05 -0800 | [diff] [blame] | 354 | if (pdata->flags & SH_MIPI_DSI_HFPBM) { /* HBPLEN */ |
| 355 | top = ch->lcd_cfg[0].hsync_len + ch->lcd_cfg[0].left_margin; |
Kuninori Morimoto | a2e6297 | 2011-11-08 20:35:27 -0800 | [diff] [blame] | 356 | top = ((pdata->lane * top / div) - 10) << 16; |
Kuninori Morimoto | 0875061 | 2011-11-08 20:35:05 -0800 | [diff] [blame] | 357 | } |
| 358 | if (pdata->flags & SH_MIPI_DSI_HBPBM) { /* HFPLEN */ |
| 359 | bottom = ch->lcd_cfg[0].right_margin; |
Kuninori Morimoto | a2e6297 | 2011-11-08 20:35:27 -0800 | [diff] [blame] | 360 | bottom = (pdata->lane * bottom / div) - 12; |
Kuninori Morimoto | 0875061 | 2011-11-08 20:35:05 -0800 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | bpp = linelength / ch->lcd_cfg[0].xres; /* byte / pixel */ |
Kuninori Morimoto | a2e6297 | 2011-11-08 20:35:27 -0800 | [diff] [blame] | 364 | if ((pdata->lane / div) > bpp) { |
Kuninori Morimoto | 0875061 | 2011-11-08 20:35:05 -0800 | [diff] [blame] | 365 | tmp = ch->lcd_cfg[0].xres / bpp; /* output cycle */ |
| 366 | tmp = ch->lcd_cfg[0].xres - tmp; /* (input - output) cycle */ |
| 367 | delay = (pdata->lane * tmp); |
| 368 | } |
| 369 | |
| 370 | iowrite32(top | (bottom + delay) , mipi->linkbase + VMLEN2); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 371 | |
| 372 | msleep(5); |
| 373 | |
| 374 | /* setup LCD panel */ |
| 375 | |
| 376 | /* cf. drivers/video/omap/lcd_mipid.c */ |
| 377 | sh_mipi_dcs(ch->chan, MIPI_DCS_EXIT_SLEEP_MODE); |
| 378 | msleep(120); |
| 379 | /* |
| 380 | * [7] - Page Address Mode |
| 381 | * [6] - Column Address Mode |
| 382 | * [5] - Page / Column Address Mode |
| 383 | * [4] - Display Device Line Refresh Order |
| 384 | * [3] - RGB/BGR Order |
| 385 | * [2] - Display Data Latch Data Order |
| 386 | * [1] - Flip Horizontal |
| 387 | * [0] - Flip Vertical |
| 388 | */ |
| 389 | sh_mipi_dcs_param(ch->chan, MIPI_DCS_SET_ADDRESS_MODE, 0x00); |
| 390 | /* cf. set_data_lines() */ |
| 391 | sh_mipi_dcs_param(ch->chan, MIPI_DCS_SET_PIXEL_FORMAT, |
| 392 | pixfmt << 4); |
| 393 | sh_mipi_dcs(ch->chan, MIPI_DCS_SET_DISPLAY_ON); |
| 394 | |
Kuninori Morimoto | 97cab45 | 2011-11-08 20:36:07 -0800 | [diff] [blame] | 395 | /* Enable timeout counters */ |
| 396 | iowrite32(0x00000f00, base + DSICTRL); |
| 397 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 398 | return 0; |
| 399 | } |
| 400 | |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 401 | static int __mipi_display_on(struct sh_mobile_lcdc_entity *entity, |
| 402 | struct fb_info *info) |
Kuninori Morimoto | c2658b7 | 2011-11-08 20:35:45 -0800 | [diff] [blame] | 403 | { |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 404 | struct sh_mipi *mipi = to_sh_mipi(entity); |
Kuninori Morimoto | c2658b7 | 2011-11-08 20:35:45 -0800 | [diff] [blame] | 405 | struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data; |
| 406 | int ret; |
| 407 | |
| 408 | pm_runtime_get_sync(&mipi->pdev->dev); |
| 409 | |
| 410 | ret = pdata->set_dot_clock(mipi->pdev, mipi->base, 1); |
| 411 | if (ret < 0) |
| 412 | goto mipi_display_on_fail1; |
| 413 | |
| 414 | ret = sh_mipi_setup(mipi, pdata); |
| 415 | if (ret < 0) |
| 416 | goto mipi_display_on_fail2; |
| 417 | |
| 418 | sh_mipi_dsi_enable(mipi, true); |
| 419 | |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 420 | return 0; |
Kuninori Morimoto | c2658b7 | 2011-11-08 20:35:45 -0800 | [diff] [blame] | 421 | |
| 422 | mipi_display_on_fail1: |
| 423 | pm_runtime_put_sync(&mipi->pdev->dev); |
| 424 | mipi_display_on_fail2: |
| 425 | pdata->set_dot_clock(mipi->pdev, mipi->base, 0); |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 426 | |
| 427 | return ret; |
Kuninori Morimoto | c2658b7 | 2011-11-08 20:35:45 -0800 | [diff] [blame] | 428 | } |
| 429 | |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 430 | static void mipi_display_on(void *arg, struct fb_info *info) |
Kuninori Morimoto | c2658b7 | 2011-11-08 20:35:45 -0800 | [diff] [blame] | 431 | { |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 432 | struct sh_mobile_lcdc_entity *entity = arg; |
| 433 | struct sh_mipi *mipi = to_sh_mipi(entity); |
| 434 | int ret; |
Kuninori Morimoto | c2658b7 | 2011-11-08 20:35:45 -0800 | [diff] [blame] | 435 | |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 436 | ret = __mipi_display_on(entity, info); |
| 437 | if (ret < 0) |
| 438 | return; |
| 439 | |
| 440 | if (mipi->next_display_on) |
| 441 | mipi->next_display_on(mipi->next_board_data, info); |
| 442 | } |
| 443 | |
| 444 | static void __mipi_display_off(struct sh_mobile_lcdc_entity *entity) |
| 445 | { |
| 446 | struct sh_mipi *mipi = to_sh_mipi(entity); |
| 447 | struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data; |
Kuninori Morimoto | c2658b7 | 2011-11-08 20:35:45 -0800 | [diff] [blame] | 448 | |
| 449 | sh_mipi_dsi_enable(mipi, false); |
| 450 | |
| 451 | pdata->set_dot_clock(mipi->pdev, mipi->base, 0); |
| 452 | |
| 453 | pm_runtime_put_sync(&mipi->pdev->dev); |
| 454 | } |
| 455 | |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 456 | static void mipi_display_off(void *arg) |
| 457 | { |
| 458 | struct sh_mobile_lcdc_entity *entity = arg; |
| 459 | struct sh_mipi *mipi = to_sh_mipi(entity); |
| 460 | |
| 461 | if (mipi->next_display_off) |
| 462 | mipi->next_display_off(mipi->next_board_data); |
| 463 | |
| 464 | __mipi_display_off(entity); |
| 465 | } |
| 466 | |
| 467 | static const struct sh_mobile_lcdc_entity_ops mipi_ops = { |
| 468 | .display_on = __mipi_display_on, |
| 469 | .display_off = __mipi_display_off, |
| 470 | }; |
| 471 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 472 | static int __init sh_mipi_probe(struct platform_device *pdev) |
| 473 | { |
| 474 | struct sh_mipi *mipi; |
| 475 | struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data; |
| 476 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 477 | struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 478 | unsigned long rate, f_current; |
| 479 | int idx = pdev->id, ret; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 480 | |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 481 | if (!res || !res2 || idx >= ARRAY_SIZE(mipi_dsi) || !pdata) |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 482 | return -ENODEV; |
| 483 | |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 484 | if (!pdata->set_dot_clock) |
| 485 | return -EINVAL; |
| 486 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 487 | mutex_lock(&array_lock); |
| 488 | if (idx < 0) |
| 489 | for (idx = 0; idx < ARRAY_SIZE(mipi_dsi) && mipi_dsi[idx]; idx++) |
| 490 | ; |
| 491 | |
| 492 | if (idx == ARRAY_SIZE(mipi_dsi)) { |
| 493 | ret = -EBUSY; |
| 494 | goto efindslot; |
| 495 | } |
| 496 | |
| 497 | mipi = kzalloc(sizeof(*mipi), GFP_KERNEL); |
| 498 | if (!mipi) { |
| 499 | ret = -ENOMEM; |
| 500 | goto ealloc; |
| 501 | } |
| 502 | |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 503 | mipi->entity.owner = THIS_MODULE; |
| 504 | mipi->entity.ops = &mipi_ops; |
| 505 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 506 | if (!request_mem_region(res->start, resource_size(res), pdev->name)) { |
| 507 | dev_err(&pdev->dev, "MIPI register region already claimed\n"); |
| 508 | ret = -EBUSY; |
| 509 | goto ereqreg; |
| 510 | } |
| 511 | |
| 512 | mipi->base = ioremap(res->start, resource_size(res)); |
| 513 | if (!mipi->base) { |
| 514 | ret = -ENOMEM; |
| 515 | goto emap; |
| 516 | } |
| 517 | |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 518 | if (!request_mem_region(res2->start, resource_size(res2), pdev->name)) { |
| 519 | dev_err(&pdev->dev, "MIPI register region 2 already claimed\n"); |
| 520 | ret = -EBUSY; |
| 521 | goto ereqreg2; |
| 522 | } |
| 523 | |
| 524 | mipi->linkbase = ioremap(res2->start, resource_size(res2)); |
| 525 | if (!mipi->linkbase) { |
| 526 | ret = -ENOMEM; |
| 527 | goto emap2; |
| 528 | } |
| 529 | |
Kuninori Morimoto | 7d9f88b | 2011-11-08 20:35:36 -0800 | [diff] [blame] | 530 | mipi->pdev = pdev; |
Guennadi Liakhovetski | 236782a | 2010-12-27 10:23:05 +0000 | [diff] [blame] | 531 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 532 | mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk"); |
| 533 | if (IS_ERR(mipi->dsit_clk)) { |
| 534 | ret = PTR_ERR(mipi->dsit_clk); |
| 535 | goto eclktget; |
| 536 | } |
| 537 | |
| 538 | f_current = clk_get_rate(mipi->dsit_clk); |
| 539 | /* 80MHz required by the datasheet */ |
| 540 | rate = clk_round_rate(mipi->dsit_clk, 80000000); |
| 541 | if (rate > 0 && rate != f_current) |
| 542 | ret = clk_set_rate(mipi->dsit_clk, rate); |
| 543 | else |
| 544 | ret = rate; |
| 545 | if (ret < 0) |
| 546 | goto esettrate; |
| 547 | |
| 548 | dev_dbg(&pdev->dev, "DSI-T clk %lu -> %lu\n", f_current, rate); |
| 549 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 550 | ret = clk_enable(mipi->dsit_clk); |
| 551 | if (ret < 0) |
| 552 | goto eclkton; |
| 553 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 554 | mipi_dsi[idx] = mipi; |
| 555 | |
Guennadi Liakhovetski | 236782a | 2010-12-27 10:23:05 +0000 | [diff] [blame] | 556 | pm_runtime_enable(&pdev->dev); |
| 557 | pm_runtime_resume(&pdev->dev); |
| 558 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 559 | mutex_unlock(&array_lock); |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 560 | platform_set_drvdata(pdev, &mipi->entity); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 561 | |
Magnus Damm | 6722a40 | 2010-11-17 06:44:54 +0000 | [diff] [blame] | 562 | /* Save original LCDC callbacks */ |
| 563 | mipi->next_board_data = pdata->lcd_chan->board_cfg.board_data; |
| 564 | mipi->next_display_on = pdata->lcd_chan->board_cfg.display_on; |
| 565 | mipi->next_display_off = pdata->lcd_chan->board_cfg.display_off; |
| 566 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 567 | /* Set up LCDC callbacks */ |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 568 | pdata->lcd_chan->board_cfg.board_data = &mipi->entity; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 569 | pdata->lcd_chan->board_cfg.display_on = mipi_display_on; |
| 570 | pdata->lcd_chan->board_cfg.display_off = mipi_display_off; |
Guennadi Liakhovetski | 236782a | 2010-12-27 10:23:05 +0000 | [diff] [blame] | 571 | pdata->lcd_chan->board_cfg.owner = THIS_MODULE; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 572 | |
| 573 | return 0; |
| 574 | |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 575 | eclkton: |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 576 | esettrate: |
| 577 | clk_put(mipi->dsit_clk); |
| 578 | eclktget: |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 579 | iounmap(mipi->linkbase); |
| 580 | emap2: |
| 581 | release_mem_region(res2->start, resource_size(res2)); |
| 582 | ereqreg2: |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 583 | iounmap(mipi->base); |
| 584 | emap: |
| 585 | release_mem_region(res->start, resource_size(res)); |
| 586 | ereqreg: |
| 587 | kfree(mipi); |
| 588 | ealloc: |
| 589 | efindslot: |
| 590 | mutex_unlock(&array_lock); |
| 591 | |
| 592 | return ret; |
| 593 | } |
| 594 | |
| 595 | static int __exit sh_mipi_remove(struct platform_device *pdev) |
| 596 | { |
| 597 | struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data; |
| 598 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 599 | struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
Laurent Pinchart | 732bbcc | 2011-09-11 18:27:50 +0200 | [diff] [blame^] | 600 | struct sh_mipi *mipi = to_sh_mipi(platform_get_drvdata(pdev)); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 601 | int i, ret; |
| 602 | |
| 603 | mutex_lock(&array_lock); |
| 604 | |
| 605 | for (i = 0; i < ARRAY_SIZE(mipi_dsi) && mipi_dsi[i] != mipi; i++) |
| 606 | ; |
| 607 | |
| 608 | if (i == ARRAY_SIZE(mipi_dsi)) { |
| 609 | ret = -EINVAL; |
| 610 | } else { |
| 611 | ret = 0; |
| 612 | mipi_dsi[i] = NULL; |
| 613 | } |
| 614 | |
| 615 | mutex_unlock(&array_lock); |
| 616 | |
| 617 | if (ret < 0) |
| 618 | return ret; |
| 619 | |
Guennadi Liakhovetski | 236782a | 2010-12-27 10:23:05 +0000 | [diff] [blame] | 620 | pdata->lcd_chan->board_cfg.owner = NULL; |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 621 | pdata->lcd_chan->board_cfg.display_on = NULL; |
| 622 | pdata->lcd_chan->board_cfg.display_off = NULL; |
| 623 | pdata->lcd_chan->board_cfg.board_data = NULL; |
| 624 | |
Guennadi Liakhovetski | 236782a | 2010-12-27 10:23:05 +0000 | [diff] [blame] | 625 | pm_runtime_disable(&pdev->dev); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 626 | clk_disable(mipi->dsit_clk); |
| 627 | clk_put(mipi->dsit_clk); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 628 | |
Magnus Damm | deaba19 | 2010-11-17 09:53:25 +0000 | [diff] [blame] | 629 | iounmap(mipi->linkbase); |
| 630 | if (res2) |
| 631 | release_mem_region(res2->start, resource_size(res2)); |
Guennadi Liakhovetski | 9fd04fe | 2010-05-23 14:00:43 +0000 | [diff] [blame] | 632 | iounmap(mipi->base); |
| 633 | if (res) |
| 634 | release_mem_region(res->start, resource_size(res)); |
| 635 | platform_set_drvdata(pdev, NULL); |
| 636 | kfree(mipi); |
| 637 | |
| 638 | return 0; |
| 639 | } |
| 640 | |
| 641 | static struct platform_driver sh_mipi_driver = { |
| 642 | .remove = __exit_p(sh_mipi_remove), |
| 643 | .shutdown = sh_mipi_shutdown, |
| 644 | .driver = { |
| 645 | .name = "sh-mipi-dsi", |
| 646 | }, |
| 647 | }; |
| 648 | |
| 649 | static int __init sh_mipi_init(void) |
| 650 | { |
| 651 | return platform_driver_probe(&sh_mipi_driver, sh_mipi_probe); |
| 652 | } |
| 653 | module_init(sh_mipi_init); |
| 654 | |
| 655 | static void __exit sh_mipi_exit(void) |
| 656 | { |
| 657 | platform_driver_unregister(&sh_mipi_driver); |
| 658 | } |
| 659 | module_exit(sh_mipi_exit); |
| 660 | |
| 661 | MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>"); |
| 662 | MODULE_DESCRIPTION("SuperH / ARM-shmobile MIPI DSI driver"); |
| 663 | MODULE_LICENSE("GPL v2"); |