Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * SuperH Mobile LCDC Framebuffer |
| 3 | * |
| 4 | * Copyright (c) 2008 Magnus Damm |
| 5 | * |
| 6 | * This file is subject to the terms and conditions of the GNU General Public |
| 7 | * License. See the file "COPYING" in the main directory of this archive |
| 8 | * for more details. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/delay.h> |
| 14 | #include <linux/mm.h> |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 15 | #include <linux/clk.h> |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 16 | #include <linux/pm_runtime.h> |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/dma-mapping.h> |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 19 | #include <linux/interrupt.h> |
Paul Mundt | 1c6a307 | 2009-07-01 06:50:31 +0000 | [diff] [blame] | 20 | #include <linux/vmalloc.h> |
Phil Edworthy | 40331b2 | 2010-02-15 13:57:49 +0000 | [diff] [blame] | 21 | #include <linux/ioctl.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 22 | #include <linux/slab.h> |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 23 | #include <linux/console.h> |
Alexandre Courbot | 3b0fd9d | 2011-02-16 03:49:01 +0000 | [diff] [blame] | 24 | #include <linux/backlight.h> |
| 25 | #include <linux/gpio.h> |
Paul Mundt | 225c9a8 | 2008-10-01 16:24:32 +0900 | [diff] [blame] | 26 | #include <video/sh_mobile_lcdc.h> |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 27 | #include <asm/atomic.h> |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 28 | |
Guennadi Liakhovetski | 6de9edd | 2010-09-03 07:20:23 +0000 | [diff] [blame] | 29 | #include "sh_mobile_lcdcfb.h" |
| 30 | |
Phil Edworthy | a6f15ad | 2009-09-15 12:00:30 +0000 | [diff] [blame] | 31 | #define SIDE_B_OFFSET 0x1000 |
| 32 | #define MIRROR_OFFSET 0x2000 |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 33 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 34 | /* shared registers */ |
| 35 | #define _LDDCKR 0x410 |
| 36 | #define _LDDCKSTPR 0x414 |
| 37 | #define _LDINTR 0x468 |
| 38 | #define _LDSR 0x46c |
| 39 | #define _LDCNT1R 0x470 |
| 40 | #define _LDCNT2R 0x474 |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 41 | #define _LDRCNTR 0x478 |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 42 | #define _LDDDSR 0x47c |
| 43 | #define _LDDWD0R 0x800 |
| 44 | #define _LDDRDR 0x840 |
| 45 | #define _LDDWAR 0x900 |
| 46 | #define _LDDRAR 0x904 |
| 47 | |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 48 | /* shared registers and their order for context save/restore */ |
| 49 | static int lcdc_shared_regs[] = { |
| 50 | _LDDCKR, |
| 51 | _LDDCKSTPR, |
| 52 | _LDINTR, |
| 53 | _LDDDSR, |
| 54 | _LDCNT1R, |
| 55 | _LDCNT2R, |
| 56 | }; |
| 57 | #define NR_SHARED_REGS ARRAY_SIZE(lcdc_shared_regs) |
| 58 | |
Guennadi Liakhovetski | d2ecbab | 2010-11-04 11:06:06 +0000 | [diff] [blame] | 59 | #define MAX_XRES 1920 |
| 60 | #define MAX_YRES 1080 |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 61 | |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 62 | static unsigned long lcdc_offs_mainlcd[NR_CH_REGS] = { |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 63 | [LDDCKPAT1R] = 0x400, |
| 64 | [LDDCKPAT2R] = 0x404, |
| 65 | [LDMT1R] = 0x418, |
| 66 | [LDMT2R] = 0x41c, |
| 67 | [LDMT3R] = 0x420, |
| 68 | [LDDFR] = 0x424, |
| 69 | [LDSM1R] = 0x428, |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 70 | [LDSM2R] = 0x42c, |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 71 | [LDSA1R] = 0x430, |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 72 | [LDSA2R] = 0x434, |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 73 | [LDMLSR] = 0x438, |
| 74 | [LDHCNR] = 0x448, |
| 75 | [LDHSYNR] = 0x44c, |
| 76 | [LDVLNR] = 0x450, |
| 77 | [LDVSYNR] = 0x454, |
| 78 | [LDPMR] = 0x460, |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 79 | [LDHAJR] = 0x4a0, |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 82 | static unsigned long lcdc_offs_sublcd[NR_CH_REGS] = { |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 83 | [LDDCKPAT1R] = 0x408, |
| 84 | [LDDCKPAT2R] = 0x40c, |
| 85 | [LDMT1R] = 0x600, |
| 86 | [LDMT2R] = 0x604, |
| 87 | [LDMT3R] = 0x608, |
| 88 | [LDDFR] = 0x60c, |
| 89 | [LDSM1R] = 0x610, |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 90 | [LDSM2R] = 0x614, |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 91 | [LDSA1R] = 0x618, |
| 92 | [LDMLSR] = 0x620, |
| 93 | [LDHCNR] = 0x624, |
| 94 | [LDHSYNR] = 0x628, |
| 95 | [LDVLNR] = 0x62c, |
| 96 | [LDVSYNR] = 0x630, |
| 97 | [LDPMR] = 0x63c, |
| 98 | }; |
| 99 | |
| 100 | #define START_LCDC 0x00000001 |
| 101 | #define LCDC_RESET 0x00000100 |
| 102 | #define DISPLAY_BEU 0x00000008 |
| 103 | #define LCDC_ENABLE 0x00000001 |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 104 | #define LDINTR_FE 0x00000400 |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 105 | #define LDINTR_VSE 0x00000200 |
| 106 | #define LDINTR_VEE 0x00000100 |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 107 | #define LDINTR_FS 0x00000004 |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 108 | #define LDINTR_VSS 0x00000002 |
| 109 | #define LDINTR_VES 0x00000001 |
Phil Edworthy | a6f15ad | 2009-09-15 12:00:30 +0000 | [diff] [blame] | 110 | #define LDRCNTR_SRS 0x00020000 |
| 111 | #define LDRCNTR_SRC 0x00010000 |
| 112 | #define LDRCNTR_MRS 0x00000002 |
| 113 | #define LDRCNTR_MRC 0x00000001 |
Phil Edworthy | 40331b2 | 2010-02-15 13:57:49 +0000 | [diff] [blame] | 114 | #define LDSR_MRS 0x00000100 |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 115 | |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 116 | static const struct fb_videomode default_720p = { |
| 117 | .name = "HDMI 720p", |
| 118 | .xres = 1280, |
| 119 | .yres = 720, |
| 120 | |
Guennadi Liakhovetski | 5ae0cf8 | 2010-11-04 11:06:01 +0000 | [diff] [blame] | 121 | .left_margin = 220, |
| 122 | .right_margin = 110, |
| 123 | .hsync_len = 40, |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 124 | |
| 125 | .upper_margin = 20, |
| 126 | .lower_margin = 5, |
| 127 | .vsync_len = 5, |
| 128 | |
| 129 | .pixclock = 13468, |
Guennadi Liakhovetski | 5ae0cf8 | 2010-11-04 11:06:01 +0000 | [diff] [blame] | 130 | .refresh = 60, |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 131 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT, |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | struct sh_mobile_lcdc_priv { |
| 135 | void __iomem *base; |
| 136 | int irq; |
| 137 | atomic_t hw_usecnt; |
| 138 | struct device *dev; |
| 139 | struct clk *dot_clk; |
| 140 | unsigned long lddckr; |
| 141 | struct sh_mobile_lcdc_chan ch[2]; |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 142 | struct notifier_block notifier; |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 143 | unsigned long saved_shared_regs[NR_SHARED_REGS]; |
| 144 | int started; |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 145 | int forced_bpp; /* 2 channel LCDC must share bpp setting */ |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
Phil Edworthy | a6f15ad | 2009-09-15 12:00:30 +0000 | [diff] [blame] | 148 | static bool banked(int reg_nr) |
| 149 | { |
| 150 | switch (reg_nr) { |
| 151 | case LDMT1R: |
| 152 | case LDMT2R: |
| 153 | case LDMT3R: |
| 154 | case LDDFR: |
| 155 | case LDSM1R: |
| 156 | case LDSA1R: |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 157 | case LDSA2R: |
Phil Edworthy | a6f15ad | 2009-09-15 12:00:30 +0000 | [diff] [blame] | 158 | case LDMLSR: |
| 159 | case LDHCNR: |
| 160 | case LDHSYNR: |
| 161 | case LDVLNR: |
| 162 | case LDVSYNR: |
| 163 | return true; |
| 164 | } |
| 165 | return false; |
| 166 | } |
| 167 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 168 | static void lcdc_write_chan(struct sh_mobile_lcdc_chan *chan, |
| 169 | int reg_nr, unsigned long data) |
| 170 | { |
| 171 | iowrite32(data, chan->lcdc->base + chan->reg_offs[reg_nr]); |
Phil Edworthy | a6f15ad | 2009-09-15 12:00:30 +0000 | [diff] [blame] | 172 | if (banked(reg_nr)) |
| 173 | iowrite32(data, chan->lcdc->base + chan->reg_offs[reg_nr] + |
| 174 | SIDE_B_OFFSET); |
| 175 | } |
| 176 | |
| 177 | static void lcdc_write_chan_mirror(struct sh_mobile_lcdc_chan *chan, |
| 178 | int reg_nr, unsigned long data) |
| 179 | { |
| 180 | iowrite32(data, chan->lcdc->base + chan->reg_offs[reg_nr] + |
| 181 | MIRROR_OFFSET); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | static unsigned long lcdc_read_chan(struct sh_mobile_lcdc_chan *chan, |
| 185 | int reg_nr) |
| 186 | { |
| 187 | return ioread32(chan->lcdc->base + chan->reg_offs[reg_nr]); |
| 188 | } |
| 189 | |
| 190 | static void lcdc_write(struct sh_mobile_lcdc_priv *priv, |
| 191 | unsigned long reg_offs, unsigned long data) |
| 192 | { |
| 193 | iowrite32(data, priv->base + reg_offs); |
| 194 | } |
| 195 | |
| 196 | static unsigned long lcdc_read(struct sh_mobile_lcdc_priv *priv, |
| 197 | unsigned long reg_offs) |
| 198 | { |
| 199 | return ioread32(priv->base + reg_offs); |
| 200 | } |
| 201 | |
| 202 | static void lcdc_wait_bit(struct sh_mobile_lcdc_priv *priv, |
| 203 | unsigned long reg_offs, |
| 204 | unsigned long mask, unsigned long until) |
| 205 | { |
| 206 | while ((lcdc_read(priv, reg_offs) & mask) != until) |
| 207 | cpu_relax(); |
| 208 | } |
| 209 | |
| 210 | static int lcdc_chan_is_sublcd(struct sh_mobile_lcdc_chan *chan) |
| 211 | { |
| 212 | return chan->cfg.chan == LCDC_CHAN_SUBLCD; |
| 213 | } |
| 214 | |
| 215 | static void lcdc_sys_write_index(void *handle, unsigned long data) |
| 216 | { |
| 217 | struct sh_mobile_lcdc_chan *ch = handle; |
| 218 | |
| 219 | lcdc_write(ch->lcdc, _LDDWD0R, data | 0x10000000); |
| 220 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); |
| 221 | lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); |
Magnus Damm | 909f10d | 2009-08-06 14:28:12 +0000 | [diff] [blame] | 222 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | static void lcdc_sys_write_data(void *handle, unsigned long data) |
| 226 | { |
| 227 | struct sh_mobile_lcdc_chan *ch = handle; |
| 228 | |
| 229 | lcdc_write(ch->lcdc, _LDDWD0R, data | 0x11000000); |
| 230 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); |
| 231 | lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); |
Magnus Damm | 909f10d | 2009-08-06 14:28:12 +0000 | [diff] [blame] | 232 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | static unsigned long lcdc_sys_read_data(void *handle) |
| 236 | { |
| 237 | struct sh_mobile_lcdc_chan *ch = handle; |
| 238 | |
| 239 | lcdc_write(ch->lcdc, _LDDRDR, 0x01000000); |
| 240 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); |
| 241 | lcdc_write(ch->lcdc, _LDDRAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); |
| 242 | udelay(1); |
Magnus Damm | 909f10d | 2009-08-06 14:28:12 +0000 | [diff] [blame] | 243 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 244 | |
Magnus Damm | ec56b66 | 2009-08-06 14:34:38 +0000 | [diff] [blame] | 245 | return lcdc_read(ch->lcdc, _LDDRDR) & 0x3ffff; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = { |
| 249 | lcdc_sys_write_index, |
| 250 | lcdc_sys_write_data, |
| 251 | lcdc_sys_read_data, |
| 252 | }; |
| 253 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 254 | static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv) |
| 255 | { |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 256 | if (atomic_inc_and_test(&priv->hw_usecnt)) { |
| 257 | pm_runtime_get_sync(priv->dev); |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 258 | if (priv->dot_clk) |
| 259 | clk_enable(priv->dot_clk); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv) |
| 264 | { |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 265 | if (atomic_sub_return(1, &priv->hw_usecnt) == -1) { |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 266 | if (priv->dot_clk) |
| 267 | clk_disable(priv->dot_clk); |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 268 | pm_runtime_put(priv->dev); |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 269 | } |
| 270 | } |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 271 | |
Paul Mundt | 1c6a307 | 2009-07-01 06:50:31 +0000 | [diff] [blame] | 272 | static int sh_mobile_lcdc_sginit(struct fb_info *info, |
| 273 | struct list_head *pagelist) |
| 274 | { |
| 275 | struct sh_mobile_lcdc_chan *ch = info->par; |
| 276 | unsigned int nr_pages_max = info->fix.smem_len >> PAGE_SHIFT; |
| 277 | struct page *page; |
| 278 | int nr_pages = 0; |
| 279 | |
| 280 | sg_init_table(ch->sglist, nr_pages_max); |
| 281 | |
| 282 | list_for_each_entry(page, pagelist, lru) |
| 283 | sg_set_page(&ch->sglist[nr_pages++], page, PAGE_SIZE, 0); |
| 284 | |
| 285 | return nr_pages; |
| 286 | } |
| 287 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 288 | static void sh_mobile_lcdc_deferred_io(struct fb_info *info, |
| 289 | struct list_head *pagelist) |
| 290 | { |
| 291 | struct sh_mobile_lcdc_chan *ch = info->par; |
Magnus Damm | ef61aae | 2009-12-07 14:20:06 +0000 | [diff] [blame] | 292 | struct sh_mobile_lcdc_board_cfg *bcfg = &ch->cfg.board_cfg; |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 293 | |
| 294 | /* enable clocks before accessing hardware */ |
| 295 | sh_mobile_lcdc_clk_on(ch->lcdc); |
| 296 | |
Paul Mundt | 5c1a56b | 2009-11-04 15:59:04 +0900 | [diff] [blame] | 297 | /* |
| 298 | * It's possible to get here without anything on the pagelist via |
| 299 | * sh_mobile_lcdc_deferred_io_touch() or via a userspace fsync() |
| 300 | * invocation. In the former case, the acceleration routines are |
| 301 | * stepped in to when using the framebuffer console causing the |
| 302 | * workqueue to be scheduled without any dirty pages on the list. |
| 303 | * |
| 304 | * Despite this, a panel update is still needed given that the |
| 305 | * acceleration routines have their own methods for writing in |
| 306 | * that still need to be updated. |
| 307 | * |
| 308 | * The fsync() and empty pagelist case could be optimized for, |
| 309 | * but we don't bother, as any application exhibiting such |
| 310 | * behaviour is fundamentally broken anyways. |
| 311 | */ |
| 312 | if (!list_empty(pagelist)) { |
| 313 | unsigned int nr_pages = sh_mobile_lcdc_sginit(info, pagelist); |
Paul Mundt | 1c6a307 | 2009-07-01 06:50:31 +0000 | [diff] [blame] | 314 | |
Paul Mundt | 5c1a56b | 2009-11-04 15:59:04 +0900 | [diff] [blame] | 315 | /* trigger panel update */ |
| 316 | dma_map_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE); |
Magnus Damm | ef61aae | 2009-12-07 14:20:06 +0000 | [diff] [blame] | 317 | if (bcfg->start_transfer) |
| 318 | bcfg->start_transfer(bcfg->board_data, ch, |
| 319 | &sh_mobile_lcdc_sys_bus_ops); |
Paul Mundt | 5c1a56b | 2009-11-04 15:59:04 +0900 | [diff] [blame] | 320 | lcdc_write_chan(ch, LDSM2R, 1); |
| 321 | dma_unmap_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE); |
Magnus Damm | ef61aae | 2009-12-07 14:20:06 +0000 | [diff] [blame] | 322 | } else { |
| 323 | if (bcfg->start_transfer) |
| 324 | bcfg->start_transfer(bcfg->board_data, ch, |
| 325 | &sh_mobile_lcdc_sys_bus_ops); |
Paul Mundt | 5c1a56b | 2009-11-04 15:59:04 +0900 | [diff] [blame] | 326 | lcdc_write_chan(ch, LDSM2R, 1); |
Magnus Damm | ef61aae | 2009-12-07 14:20:06 +0000 | [diff] [blame] | 327 | } |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info) |
| 331 | { |
| 332 | struct fb_deferred_io *fbdefio = info->fbdefio; |
| 333 | |
| 334 | if (fbdefio) |
| 335 | schedule_delayed_work(&info->deferred_work, fbdefio->delay); |
| 336 | } |
| 337 | |
| 338 | static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data) |
| 339 | { |
| 340 | struct sh_mobile_lcdc_priv *priv = data; |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 341 | struct sh_mobile_lcdc_chan *ch; |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 342 | unsigned long tmp; |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 343 | unsigned long ldintr; |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 344 | int is_sub; |
| 345 | int k; |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 346 | |
| 347 | /* acknowledge interrupt */ |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 348 | ldintr = tmp = lcdc_read(priv, _LDINTR); |
| 349 | /* |
| 350 | * disable further VSYNC End IRQs, preserve all other enabled IRQs, |
| 351 | * write 0 to bits 0-6 to ack all triggered IRQs. |
| 352 | */ |
| 353 | tmp &= 0xffffff00 & ~LDINTR_VEE; |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 354 | lcdc_write(priv, _LDINTR, tmp); |
| 355 | |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 356 | /* figure out if this interrupt is for main or sub lcd */ |
| 357 | is_sub = (lcdc_read(priv, _LDSR) & (1 << 10)) ? 1 : 0; |
| 358 | |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 359 | /* wake up channel and disable clocks */ |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 360 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { |
| 361 | ch = &priv->ch[k]; |
| 362 | |
| 363 | if (!ch->enabled) |
| 364 | continue; |
| 365 | |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 366 | /* Frame Start */ |
| 367 | if (ldintr & LDINTR_FS) { |
| 368 | if (is_sub == lcdc_chan_is_sublcd(ch)) { |
| 369 | ch->frame_end = 1; |
| 370 | wake_up(&ch->frame_end_wait); |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 371 | |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 372 | sh_mobile_lcdc_clk_off(priv); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | /* VSYNC End */ |
Phil Edworthy | 40331b2 | 2010-02-15 13:57:49 +0000 | [diff] [blame] | 377 | if (ldintr & LDINTR_VES) |
| 378 | complete(&ch->vsync_completion); |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 379 | } |
| 380 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 381 | return IRQ_HANDLED; |
| 382 | } |
| 383 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 384 | static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv *priv, |
| 385 | int start) |
| 386 | { |
| 387 | unsigned long tmp = lcdc_read(priv, _LDCNT2R); |
| 388 | int k; |
| 389 | |
| 390 | /* start or stop the lcdc */ |
| 391 | if (start) |
| 392 | lcdc_write(priv, _LDCNT2R, tmp | START_LCDC); |
| 393 | else |
| 394 | lcdc_write(priv, _LDCNT2R, tmp & ~START_LCDC); |
| 395 | |
| 396 | /* wait until power is applied/stopped on all channels */ |
| 397 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) |
| 398 | if (lcdc_read(priv, _LDCNT2R) & priv->ch[k].enabled) |
| 399 | while (1) { |
| 400 | tmp = lcdc_read_chan(&priv->ch[k], LDPMR) & 3; |
| 401 | if (start && tmp == 3) |
| 402 | break; |
| 403 | if (!start && tmp == 0) |
| 404 | break; |
| 405 | cpu_relax(); |
| 406 | } |
| 407 | |
| 408 | if (!start) |
| 409 | lcdc_write(priv, _LDDCKSTPR, 1); /* stop dotclock */ |
| 410 | } |
| 411 | |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 412 | static void sh_mobile_lcdc_geometry(struct sh_mobile_lcdc_chan *ch) |
| 413 | { |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 414 | struct fb_var_screeninfo *var = &ch->info->var, *display_var = &ch->display_var; |
| 415 | unsigned long h_total, hsync_pos, display_h_total; |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 416 | u32 tmp; |
| 417 | |
| 418 | tmp = ch->ldmt1r_value; |
| 419 | tmp |= (var->sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : 1 << 28; |
| 420 | tmp |= (var->sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : 1 << 27; |
| 421 | tmp |= (ch->cfg.flags & LCDC_FLAGS_DWPOL) ? 1 << 26 : 0; |
| 422 | tmp |= (ch->cfg.flags & LCDC_FLAGS_DIPOL) ? 1 << 25 : 0; |
| 423 | tmp |= (ch->cfg.flags & LCDC_FLAGS_DAPOL) ? 1 << 24 : 0; |
| 424 | tmp |= (ch->cfg.flags & LCDC_FLAGS_HSCNT) ? 1 << 17 : 0; |
| 425 | tmp |= (ch->cfg.flags & LCDC_FLAGS_DWCNT) ? 1 << 16 : 0; |
| 426 | lcdc_write_chan(ch, LDMT1R, tmp); |
| 427 | |
| 428 | /* setup SYS bus */ |
| 429 | lcdc_write_chan(ch, LDMT2R, ch->cfg.sys_bus_cfg.ldmt2r); |
| 430 | lcdc_write_chan(ch, LDMT3R, ch->cfg.sys_bus_cfg.ldmt3r); |
| 431 | |
| 432 | /* horizontal configuration */ |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 433 | h_total = display_var->xres + display_var->hsync_len + |
| 434 | display_var->left_margin + display_var->right_margin; |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 435 | tmp = h_total / 8; /* HTCN */ |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 436 | tmp |= (min(display_var->xres, var->xres) / 8) << 16; /* HDCN */ |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 437 | lcdc_write_chan(ch, LDHCNR, tmp); |
| 438 | |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 439 | hsync_pos = display_var->xres + display_var->right_margin; |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 440 | tmp = hsync_pos / 8; /* HSYNP */ |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 441 | tmp |= (display_var->hsync_len / 8) << 16; /* HSYNW */ |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 442 | lcdc_write_chan(ch, LDHSYNR, tmp); |
| 443 | |
| 444 | /* vertical configuration */ |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 445 | tmp = display_var->yres + display_var->vsync_len + |
| 446 | display_var->upper_margin + display_var->lower_margin; /* VTLN */ |
| 447 | tmp |= min(display_var->yres, var->yres) << 16; /* VDLN */ |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 448 | lcdc_write_chan(ch, LDVLNR, tmp); |
| 449 | |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 450 | tmp = display_var->yres + display_var->lower_margin; /* VSYNP */ |
| 451 | tmp |= display_var->vsync_len << 16; /* VSYNW */ |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 452 | lcdc_write_chan(ch, LDVSYNR, tmp); |
| 453 | |
| 454 | /* Adjust horizontal synchronisation for HDMI */ |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 455 | display_h_total = display_var->xres + display_var->hsync_len + |
| 456 | display_var->left_margin + display_var->right_margin; |
| 457 | tmp = ((display_var->xres & 7) << 24) | |
| 458 | ((display_h_total & 7) << 16) | |
| 459 | ((display_var->hsync_len & 7) << 8) | |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 460 | hsync_pos; |
| 461 | lcdc_write_chan(ch, LDHAJR, tmp); |
| 462 | } |
| 463 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 464 | static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) |
| 465 | { |
| 466 | struct sh_mobile_lcdc_chan *ch; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 467 | struct sh_mobile_lcdc_board_cfg *board_cfg; |
| 468 | unsigned long tmp; |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 469 | int bpp = 0; |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 470 | unsigned long ldddsr; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 471 | int k, m; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 472 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 473 | /* enable clocks before accessing the hardware */ |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 474 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { |
| 475 | if (priv->ch[k].enabled) { |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 476 | sh_mobile_lcdc_clk_on(priv); |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 477 | if (!bpp) |
| 478 | bpp = priv->ch[k].info->var.bits_per_pixel; |
| 479 | } |
| 480 | } |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 481 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 482 | /* reset */ |
| 483 | lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) | LCDC_RESET); |
| 484 | lcdc_wait_bit(priv, _LDCNT2R, LCDC_RESET, 0); |
| 485 | |
| 486 | /* enable LCDC channels */ |
| 487 | tmp = lcdc_read(priv, _LDCNT2R); |
| 488 | tmp |= priv->ch[0].enabled; |
| 489 | tmp |= priv->ch[1].enabled; |
| 490 | lcdc_write(priv, _LDCNT2R, tmp); |
| 491 | |
| 492 | /* read data from external memory, avoid using the BEU for now */ |
| 493 | lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) & ~DISPLAY_BEU); |
| 494 | |
| 495 | /* stop the lcdc first */ |
| 496 | sh_mobile_lcdc_start_stop(priv, 0); |
| 497 | |
| 498 | /* configure clocks */ |
| 499 | tmp = priv->lddckr; |
| 500 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { |
| 501 | ch = &priv->ch[k]; |
| 502 | |
| 503 | if (!priv->ch[k].enabled) |
| 504 | continue; |
| 505 | |
| 506 | m = ch->cfg.clock_divider; |
| 507 | if (!m) |
| 508 | continue; |
| 509 | |
| 510 | if (m == 1) |
| 511 | m = 1 << 6; |
| 512 | tmp |= m << (lcdc_chan_is_sublcd(ch) ? 8 : 0); |
| 513 | |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 514 | /* FIXME: sh7724 can only use 42, 48, 54 and 60 for the divider denominator */ |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 515 | lcdc_write_chan(ch, LDDCKPAT1R, 0); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 516 | lcdc_write_chan(ch, LDDCKPAT2R, (1 << (m/2)) - 1); |
| 517 | } |
| 518 | |
| 519 | lcdc_write(priv, _LDDCKR, tmp); |
| 520 | |
| 521 | /* start dotclock again */ |
| 522 | lcdc_write(priv, _LDDCKSTPR, 0); |
| 523 | lcdc_wait_bit(priv, _LDDCKSTPR, ~0, 0); |
| 524 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 525 | /* interrupts are disabled to begin with */ |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 526 | lcdc_write(priv, _LDINTR, 0); |
| 527 | |
| 528 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { |
| 529 | ch = &priv->ch[k]; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 530 | |
| 531 | if (!ch->enabled) |
| 532 | continue; |
| 533 | |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 534 | sh_mobile_lcdc_geometry(ch); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 535 | |
| 536 | /* power supply */ |
| 537 | lcdc_write_chan(ch, LDPMR, 0); |
| 538 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 539 | board_cfg = &ch->cfg.board_cfg; |
Guennadi Liakhovetski | 69843ba | 2011-05-05 16:32:36 +0000 | [diff] [blame] | 540 | if (board_cfg->setup_sys) { |
| 541 | int ret = board_cfg->setup_sys(board_cfg->board_data, |
| 542 | ch, &sh_mobile_lcdc_sys_bus_ops); |
| 543 | if (ret) |
| 544 | return ret; |
| 545 | } |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 546 | } |
| 547 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 548 | /* word and long word swap */ |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 549 | ldddsr = lcdc_read(priv, _LDDDSR); |
| 550 | if (priv->ch[0].info->var.nonstd) |
| 551 | lcdc_write(priv, _LDDDSR, ldddsr | 7); |
| 552 | else { |
| 553 | switch (bpp) { |
| 554 | case 16: |
| 555 | lcdc_write(priv, _LDDDSR, ldddsr | 6); |
| 556 | break; |
| 557 | case 24: |
| 558 | lcdc_write(priv, _LDDDSR, ldddsr | 7); |
| 559 | break; |
| 560 | case 32: |
| 561 | lcdc_write(priv, _LDDDSR, ldddsr | 4); |
| 562 | break; |
| 563 | } |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 564 | } |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 565 | |
| 566 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { |
| 567 | ch = &priv->ch[k]; |
| 568 | |
| 569 | if (!priv->ch[k].enabled) |
| 570 | continue; |
| 571 | |
| 572 | /* set bpp format in PKF[4:0] */ |
| 573 | tmp = lcdc_read_chan(ch, LDDFR); |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 574 | tmp &= ~0x0003031f; |
| 575 | if (ch->info->var.nonstd) { |
| 576 | tmp |= (ch->info->var.nonstd << 16); |
| 577 | switch (ch->info->var.bits_per_pixel) { |
| 578 | case 12: |
| 579 | break; |
| 580 | case 16: |
| 581 | tmp |= (0x1 << 8); |
| 582 | break; |
| 583 | case 24: |
| 584 | tmp |= (0x2 << 8); |
| 585 | break; |
| 586 | } |
| 587 | } else { |
| 588 | switch (ch->info->var.bits_per_pixel) { |
| 589 | case 16: |
| 590 | tmp |= 0x03; |
| 591 | break; |
| 592 | case 24: |
| 593 | tmp |= 0x0b; |
| 594 | break; |
| 595 | case 32: |
| 596 | break; |
| 597 | } |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 598 | } |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 599 | lcdc_write_chan(ch, LDDFR, tmp); |
| 600 | |
| 601 | /* point out our frame buffer */ |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 602 | lcdc_write_chan(ch, LDSA1R, ch->info->fix.smem_start); |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 603 | if (ch->info->var.nonstd) |
| 604 | lcdc_write_chan(ch, LDSA2R, |
| 605 | ch->info->fix.smem_start + |
| 606 | ch->info->var.xres * |
| 607 | ch->info->var.yres_virtual); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 608 | |
| 609 | /* set line size */ |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 610 | lcdc_write_chan(ch, LDMLSR, ch->info->fix.line_length); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 611 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 612 | /* setup deferred io if SYS bus */ |
| 613 | tmp = ch->cfg.sys_bus_cfg.deferred_io_msec; |
| 614 | if (ch->ldmt1r_value & (1 << 12) && tmp) { |
| 615 | ch->defio.deferred_io = sh_mobile_lcdc_deferred_io; |
| 616 | ch->defio.delay = msecs_to_jiffies(tmp); |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 617 | ch->info->fbdefio = &ch->defio; |
| 618 | fb_deferred_io_init(ch->info); |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 619 | |
| 620 | /* one-shot mode */ |
| 621 | lcdc_write_chan(ch, LDSM1R, 1); |
| 622 | |
| 623 | /* enable "Frame End Interrupt Enable" bit */ |
| 624 | lcdc_write(priv, _LDINTR, LDINTR_FE); |
| 625 | |
| 626 | } else { |
| 627 | /* continuous read mode */ |
| 628 | lcdc_write_chan(ch, LDSM1R, 0); |
| 629 | } |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | /* display output */ |
| 633 | lcdc_write(priv, _LDCNT1R, LCDC_ENABLE); |
| 634 | |
| 635 | /* start the lcdc */ |
| 636 | sh_mobile_lcdc_start_stop(priv, 1); |
Magnus Damm | 8e9bb19 | 2009-05-20 14:34:43 +0000 | [diff] [blame] | 637 | priv->started = 1; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 638 | |
| 639 | /* tell the board code to enable the panel */ |
| 640 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { |
| 641 | ch = &priv->ch[k]; |
Magnus Damm | 21bc1f0 | 2009-08-15 02:53:16 +0000 | [diff] [blame] | 642 | if (!ch->enabled) |
| 643 | continue; |
| 644 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 645 | board_cfg = &ch->cfg.board_cfg; |
Alexandre Courbot | 247f993 | 2011-02-23 08:41:50 +0000 | [diff] [blame] | 646 | if (board_cfg->display_on && try_module_get(board_cfg->owner)) { |
Guennadi Liakhovetski | c243939 | 2010-07-21 10:13:17 +0000 | [diff] [blame] | 647 | board_cfg->display_on(board_cfg->board_data, ch->info); |
Guennadi Liakhovetski | 6de9edd | 2010-09-03 07:20:23 +0000 | [diff] [blame] | 648 | module_put(board_cfg->owner); |
| 649 | } |
Alexandre Courbot | 3b0fd9d | 2011-02-16 03:49:01 +0000 | [diff] [blame] | 650 | |
| 651 | if (ch->bl) { |
| 652 | ch->bl->props.power = FB_BLANK_UNBLANK; |
| 653 | backlight_update_status(ch->bl); |
| 654 | } |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | return 0; |
| 658 | } |
| 659 | |
| 660 | static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv) |
| 661 | { |
| 662 | struct sh_mobile_lcdc_chan *ch; |
| 663 | struct sh_mobile_lcdc_board_cfg *board_cfg; |
| 664 | int k; |
| 665 | |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 666 | /* clean up deferred io and ask board code to disable panel */ |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 667 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { |
| 668 | ch = &priv->ch[k]; |
Magnus Damm | 21bc1f0 | 2009-08-15 02:53:16 +0000 | [diff] [blame] | 669 | if (!ch->enabled) |
| 670 | continue; |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 671 | |
| 672 | /* deferred io mode: |
| 673 | * flush frame, and wait for frame end interrupt |
| 674 | * clean up deferred io and enable clock |
| 675 | */ |
Guennadi Liakhovetski | 5ef6b50 | 2010-09-03 07:19:57 +0000 | [diff] [blame] | 676 | if (ch->info && ch->info->fbdefio) { |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 677 | ch->frame_end = 0; |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 678 | schedule_delayed_work(&ch->info->deferred_work, 0); |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 679 | wait_event(ch->frame_end_wait, ch->frame_end); |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 680 | fb_deferred_io_cleanup(ch->info); |
| 681 | ch->info->fbdefio = NULL; |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 682 | sh_mobile_lcdc_clk_on(priv); |
| 683 | } |
| 684 | |
Alexandre Courbot | 3b0fd9d | 2011-02-16 03:49:01 +0000 | [diff] [blame] | 685 | if (ch->bl) { |
| 686 | ch->bl->props.power = FB_BLANK_POWERDOWN; |
| 687 | backlight_update_status(ch->bl); |
| 688 | } |
| 689 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 690 | board_cfg = &ch->cfg.board_cfg; |
Alexandre Courbot | 247f993 | 2011-02-23 08:41:50 +0000 | [diff] [blame] | 691 | if (board_cfg->display_off && try_module_get(board_cfg->owner)) { |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 692 | board_cfg->display_off(board_cfg->board_data); |
Guennadi Liakhovetski | 6de9edd | 2010-09-03 07:20:23 +0000 | [diff] [blame] | 693 | module_put(board_cfg->owner); |
| 694 | } |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | /* stop the lcdc */ |
Magnus Damm | 8e9bb19 | 2009-05-20 14:34:43 +0000 | [diff] [blame] | 698 | if (priv->started) { |
| 699 | sh_mobile_lcdc_start_stop(priv, 0); |
| 700 | priv->started = 0; |
| 701 | } |
Magnus Damm | b51339f | 2008-10-31 20:23:26 +0900 | [diff] [blame] | 702 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 703 | /* stop clocks */ |
| 704 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) |
| 705 | if (priv->ch[k].enabled) |
| 706 | sh_mobile_lcdc_clk_off(priv); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch) |
| 710 | { |
| 711 | int ifm, miftyp; |
| 712 | |
| 713 | switch (ch->cfg.interface_type) { |
| 714 | case RGB8: ifm = 0; miftyp = 0; break; |
| 715 | case RGB9: ifm = 0; miftyp = 4; break; |
| 716 | case RGB12A: ifm = 0; miftyp = 5; break; |
| 717 | case RGB12B: ifm = 0; miftyp = 6; break; |
| 718 | case RGB16: ifm = 0; miftyp = 7; break; |
| 719 | case RGB18: ifm = 0; miftyp = 10; break; |
| 720 | case RGB24: ifm = 0; miftyp = 11; break; |
| 721 | case SYS8A: ifm = 1; miftyp = 0; break; |
| 722 | case SYS8B: ifm = 1; miftyp = 1; break; |
| 723 | case SYS8C: ifm = 1; miftyp = 2; break; |
| 724 | case SYS8D: ifm = 1; miftyp = 3; break; |
| 725 | case SYS9: ifm = 1; miftyp = 4; break; |
| 726 | case SYS12: ifm = 1; miftyp = 5; break; |
| 727 | case SYS16A: ifm = 1; miftyp = 7; break; |
| 728 | case SYS16B: ifm = 1; miftyp = 8; break; |
| 729 | case SYS16C: ifm = 1; miftyp = 9; break; |
| 730 | case SYS18: ifm = 1; miftyp = 10; break; |
| 731 | case SYS24: ifm = 1; miftyp = 11; break; |
| 732 | default: goto bad; |
| 733 | } |
| 734 | |
| 735 | /* SUBLCD only supports SYS interface */ |
| 736 | if (lcdc_chan_is_sublcd(ch)) { |
| 737 | if (ifm == 0) |
| 738 | goto bad; |
| 739 | else |
| 740 | ifm = 0; |
| 741 | } |
| 742 | |
| 743 | ch->ldmt1r_value = (ifm << 12) | miftyp; |
| 744 | return 0; |
| 745 | bad: |
| 746 | return -EINVAL; |
| 747 | } |
| 748 | |
Magnus Damm | b51339f | 2008-10-31 20:23:26 +0900 | [diff] [blame] | 749 | static int sh_mobile_lcdc_setup_clocks(struct platform_device *pdev, |
| 750 | int clock_source, |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 751 | struct sh_mobile_lcdc_priv *priv) |
| 752 | { |
| 753 | char *str; |
| 754 | int icksel; |
| 755 | |
| 756 | switch (clock_source) { |
| 757 | case LCDC_CLK_BUS: str = "bus_clk"; icksel = 0; break; |
| 758 | case LCDC_CLK_PERIPHERAL: str = "peripheral_clk"; icksel = 1; break; |
| 759 | case LCDC_CLK_EXTERNAL: str = NULL; icksel = 2; break; |
| 760 | default: |
| 761 | return -EINVAL; |
| 762 | } |
| 763 | |
| 764 | priv->lddckr = icksel << 16; |
| 765 | |
| 766 | if (str) { |
Magnus Damm | b51339f | 2008-10-31 20:23:26 +0900 | [diff] [blame] | 767 | priv->dot_clk = clk_get(&pdev->dev, str); |
| 768 | if (IS_ERR(priv->dot_clk)) { |
| 769 | dev_err(&pdev->dev, "cannot get dot clock %s\n", str); |
Magnus Damm | b51339f | 2008-10-31 20:23:26 +0900 | [diff] [blame] | 770 | return PTR_ERR(priv->dot_clk); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 771 | } |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 772 | } |
| 773 | |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 774 | /* Runtime PM support involves two step for this driver: |
| 775 | * 1) Enable Runtime PM |
| 776 | * 2) Force Runtime PM Resume since hardware is accessed from probe() |
| 777 | */ |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 778 | priv->dev = &pdev->dev; |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 779 | pm_runtime_enable(priv->dev); |
| 780 | pm_runtime_resume(priv->dev); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 781 | return 0; |
| 782 | } |
| 783 | |
| 784 | static int sh_mobile_lcdc_setcolreg(u_int regno, |
| 785 | u_int red, u_int green, u_int blue, |
| 786 | u_int transp, struct fb_info *info) |
| 787 | { |
| 788 | u32 *palette = info->pseudo_palette; |
| 789 | |
| 790 | if (regno >= PALETTE_NR) |
| 791 | return -EINVAL; |
| 792 | |
| 793 | /* only FB_VISUAL_TRUECOLOR supported */ |
| 794 | |
| 795 | red >>= 16 - info->var.red.length; |
| 796 | green >>= 16 - info->var.green.length; |
| 797 | blue >>= 16 - info->var.blue.length; |
| 798 | transp >>= 16 - info->var.transp.length; |
| 799 | |
| 800 | palette[regno] = (red << info->var.red.offset) | |
| 801 | (green << info->var.green.offset) | |
| 802 | (blue << info->var.blue.offset) | |
| 803 | (transp << info->var.transp.offset); |
| 804 | |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | static struct fb_fix_screeninfo sh_mobile_lcdc_fix = { |
| 809 | .id = "SH Mobile LCDC", |
| 810 | .type = FB_TYPE_PACKED_PIXELS, |
| 811 | .visual = FB_VISUAL_TRUECOLOR, |
| 812 | .accel = FB_ACCEL_NONE, |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 813 | .xpanstep = 0, |
| 814 | .ypanstep = 1, |
| 815 | .ywrapstep = 0, |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 816 | }; |
| 817 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 818 | static void sh_mobile_lcdc_fillrect(struct fb_info *info, |
| 819 | const struct fb_fillrect *rect) |
| 820 | { |
| 821 | sys_fillrect(info, rect); |
| 822 | sh_mobile_lcdc_deferred_io_touch(info); |
| 823 | } |
| 824 | |
| 825 | static void sh_mobile_lcdc_copyarea(struct fb_info *info, |
| 826 | const struct fb_copyarea *area) |
| 827 | { |
| 828 | sys_copyarea(info, area); |
| 829 | sh_mobile_lcdc_deferred_io_touch(info); |
| 830 | } |
| 831 | |
| 832 | static void sh_mobile_lcdc_imageblit(struct fb_info *info, |
| 833 | const struct fb_image *image) |
| 834 | { |
| 835 | sys_imageblit(info, image); |
| 836 | sh_mobile_lcdc_deferred_io_touch(info); |
| 837 | } |
| 838 | |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 839 | static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var, |
| 840 | struct fb_info *info) |
| 841 | { |
| 842 | struct sh_mobile_lcdc_chan *ch = info->par; |
Phil Edworthy | 92e1f9a | 2010-02-11 10:24:25 +0000 | [diff] [blame] | 843 | struct sh_mobile_lcdc_priv *priv = ch->lcdc; |
| 844 | unsigned long ldrcntr; |
| 845 | unsigned long new_pan_offset; |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 846 | unsigned long base_addr_y, base_addr_c; |
| 847 | unsigned long c_offset; |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 848 | |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 849 | if (!var->nonstd) |
| 850 | new_pan_offset = (var->yoffset * info->fix.line_length) + |
| 851 | (var->xoffset * (info->var.bits_per_pixel / 8)); |
| 852 | else |
| 853 | new_pan_offset = (var->yoffset * info->fix.line_length) + |
| 854 | (var->xoffset); |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 855 | |
Phil Edworthy | 92e1f9a | 2010-02-11 10:24:25 +0000 | [diff] [blame] | 856 | if (new_pan_offset == ch->pan_offset) |
| 857 | return 0; /* No change, do nothing */ |
| 858 | |
| 859 | ldrcntr = lcdc_read(priv, _LDRCNTR); |
| 860 | |
| 861 | /* Set the source address for the next refresh */ |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 862 | base_addr_y = ch->dma_handle + new_pan_offset; |
| 863 | if (var->nonstd) { |
| 864 | /* Set y offset */ |
| 865 | c_offset = (var->yoffset * |
| 866 | info->fix.line_length * |
| 867 | (info->var.bits_per_pixel - 8)) / 8; |
| 868 | base_addr_c = ch->dma_handle + var->xres * var->yres_virtual + |
| 869 | c_offset; |
| 870 | /* Set x offset */ |
| 871 | if (info->var.bits_per_pixel == 24) |
| 872 | base_addr_c += 2 * var->xoffset; |
| 873 | else |
| 874 | base_addr_c += var->xoffset; |
| 875 | } else |
| 876 | base_addr_c = 0; |
| 877 | |
| 878 | lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y); |
| 879 | if (base_addr_c) |
| 880 | lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c); |
| 881 | |
Phil Edworthy | 92e1f9a | 2010-02-11 10:24:25 +0000 | [diff] [blame] | 882 | if (lcdc_chan_is_sublcd(ch)) |
| 883 | lcdc_write(ch->lcdc, _LDRCNTR, ldrcntr ^ LDRCNTR_SRS); |
| 884 | else |
| 885 | lcdc_write(ch->lcdc, _LDRCNTR, ldrcntr ^ LDRCNTR_MRS); |
| 886 | |
| 887 | ch->pan_offset = new_pan_offset; |
| 888 | |
| 889 | sh_mobile_lcdc_deferred_io_touch(info); |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 890 | |
| 891 | return 0; |
| 892 | } |
| 893 | |
Phil Edworthy | 40331b2 | 2010-02-15 13:57:49 +0000 | [diff] [blame] | 894 | static int sh_mobile_wait_for_vsync(struct fb_info *info) |
| 895 | { |
| 896 | struct sh_mobile_lcdc_chan *ch = info->par; |
| 897 | unsigned long ldintr; |
| 898 | int ret; |
| 899 | |
| 900 | /* Enable VSync End interrupt */ |
| 901 | ldintr = lcdc_read(ch->lcdc, _LDINTR); |
| 902 | ldintr |= LDINTR_VEE; |
| 903 | lcdc_write(ch->lcdc, _LDINTR, ldintr); |
| 904 | |
| 905 | ret = wait_for_completion_interruptible_timeout(&ch->vsync_completion, |
| 906 | msecs_to_jiffies(100)); |
| 907 | if (!ret) |
| 908 | return -ETIMEDOUT; |
| 909 | |
| 910 | return 0; |
| 911 | } |
| 912 | |
| 913 | static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd, |
| 914 | unsigned long arg) |
| 915 | { |
| 916 | int retval; |
| 917 | |
| 918 | switch (cmd) { |
| 919 | case FBIO_WAITFORVSYNC: |
| 920 | retval = sh_mobile_wait_for_vsync(info); |
| 921 | break; |
| 922 | |
| 923 | default: |
| 924 | retval = -ENOIOCTLCMD; |
| 925 | break; |
| 926 | } |
| 927 | return retval; |
| 928 | } |
| 929 | |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 930 | static void sh_mobile_fb_reconfig(struct fb_info *info) |
| 931 | { |
| 932 | struct sh_mobile_lcdc_chan *ch = info->par; |
| 933 | struct fb_videomode mode1, mode2; |
| 934 | struct fb_event event; |
| 935 | int evnt = FB_EVENT_MODE_CHANGE_ALL; |
| 936 | |
| 937 | if (ch->use_count > 1 || (ch->use_count == 1 && !info->fbcon_par)) |
| 938 | /* More framebuffer users are active */ |
| 939 | return; |
| 940 | |
| 941 | fb_var_to_videomode(&mode1, &ch->display_var); |
| 942 | fb_var_to_videomode(&mode2, &info->var); |
| 943 | |
| 944 | if (fb_mode_is_equal(&mode1, &mode2)) |
| 945 | return; |
| 946 | |
| 947 | /* Display has been re-plugged, framebuffer is free now, reconfigure */ |
| 948 | if (fb_set_var(info, &ch->display_var) < 0) |
| 949 | /* Couldn't reconfigure, hopefully, can continue as before */ |
| 950 | return; |
| 951 | |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 952 | if (info->var.nonstd) |
| 953 | info->fix.line_length = mode1.xres; |
| 954 | else |
| 955 | info->fix.line_length = mode1.xres * (ch->cfg.bpp / 8); |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 956 | |
| 957 | /* |
| 958 | * fb_set_var() calls the notifier change internally, only if |
| 959 | * FBINFO_MISC_USEREVENT flag is set. Since we do not want to fake a |
| 960 | * user event, we have to call the chain ourselves. |
| 961 | */ |
| 962 | event.info = info; |
Arnd Hannemann | cc267ec | 2010-11-15 21:43:22 +0000 | [diff] [blame] | 963 | event.data = &mode1; |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 964 | fb_notifier_call_chain(evnt, &event); |
| 965 | } |
| 966 | |
| 967 | /* |
| 968 | * Locking: both .fb_release() and .fb_open() are called with info->lock held if |
| 969 | * user == 1, or with console sem held, if user == 0. |
| 970 | */ |
| 971 | static int sh_mobile_release(struct fb_info *info, int user) |
| 972 | { |
| 973 | struct sh_mobile_lcdc_chan *ch = info->par; |
| 974 | |
| 975 | mutex_lock(&ch->open_lock); |
| 976 | dev_dbg(info->dev, "%s(): %d users\n", __func__, ch->use_count); |
| 977 | |
| 978 | ch->use_count--; |
| 979 | |
| 980 | /* Nothing to reconfigure, when called from fbcon */ |
| 981 | if (user) { |
Torben Hohn | ac751ef | 2011-01-25 15:07:35 -0800 | [diff] [blame] | 982 | console_lock(); |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 983 | sh_mobile_fb_reconfig(info); |
Torben Hohn | ac751ef | 2011-01-25 15:07:35 -0800 | [diff] [blame] | 984 | console_unlock(); |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 985 | } |
| 986 | |
| 987 | mutex_unlock(&ch->open_lock); |
| 988 | |
| 989 | return 0; |
| 990 | } |
| 991 | |
| 992 | static int sh_mobile_open(struct fb_info *info, int user) |
| 993 | { |
| 994 | struct sh_mobile_lcdc_chan *ch = info->par; |
| 995 | |
| 996 | mutex_lock(&ch->open_lock); |
| 997 | ch->use_count++; |
| 998 | |
| 999 | dev_dbg(info->dev, "%s(): %d users\n", __func__, ch->use_count); |
| 1000 | mutex_unlock(&ch->open_lock); |
| 1001 | |
| 1002 | return 0; |
| 1003 | } |
| 1004 | |
| 1005 | static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
| 1006 | { |
| 1007 | struct sh_mobile_lcdc_chan *ch = info->par; |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 1008 | struct sh_mobile_lcdc_priv *p = ch->lcdc; |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 1009 | |
Guennadi Liakhovetski | d2ecbab | 2010-11-04 11:06:06 +0000 | [diff] [blame] | 1010 | if (var->xres > MAX_XRES || var->yres > MAX_YRES || |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 1011 | var->xres * var->yres * (ch->cfg.bpp / 8) * 2 > info->fix.smem_len) { |
Paul Mundt | 830539d | 2010-11-10 17:51:44 +0900 | [diff] [blame] | 1012 | dev_warn(info->dev, "Invalid info: %u-%u-%u-%u x %u-%u-%u-%u @ %lukHz!\n", |
Guennadi Liakhovetski | d2ecbab | 2010-11-04 11:06:06 +0000 | [diff] [blame] | 1013 | var->left_margin, var->xres, var->right_margin, var->hsync_len, |
| 1014 | var->upper_margin, var->yres, var->lower_margin, var->vsync_len, |
| 1015 | PICOS2KHZ(var->pixclock)); |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 1016 | return -EINVAL; |
| 1017 | } |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 1018 | |
| 1019 | /* only accept the forced_bpp for dual channel configurations */ |
| 1020 | if (p->forced_bpp && p->forced_bpp != var->bits_per_pixel) |
| 1021 | return -EINVAL; |
| 1022 | |
| 1023 | switch (var->bits_per_pixel) { |
| 1024 | case 16: /* PKF[4:0] = 00011 - RGB 565 */ |
| 1025 | case 24: /* PKF[4:0] = 01011 - RGB 888 */ |
| 1026 | case 32: /* PKF[4:0] = 00000 - RGBA 888 */ |
| 1027 | break; |
| 1028 | default: |
| 1029 | return -EINVAL; |
| 1030 | } |
| 1031 | |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 1032 | return 0; |
| 1033 | } |
Phil Edworthy | 40331b2 | 2010-02-15 13:57:49 +0000 | [diff] [blame] | 1034 | |
Alexandre Courbot | 8857b9a | 2011-02-23 08:36:30 +0000 | [diff] [blame] | 1035 | /* |
| 1036 | * Screen blanking. Behavior is as follows: |
| 1037 | * FB_BLANK_UNBLANK: screen unblanked, clocks enabled |
| 1038 | * FB_BLANK_NORMAL: screen blanked, clocks enabled |
| 1039 | * FB_BLANK_VSYNC, |
| 1040 | * FB_BLANK_HSYNC, |
| 1041 | * FB_BLANK_POWEROFF: screen blanked, clocks disabled |
| 1042 | */ |
| 1043 | static int sh_mobile_lcdc_blank(int blank, struct fb_info *info) |
| 1044 | { |
| 1045 | struct sh_mobile_lcdc_chan *ch = info->par; |
| 1046 | struct sh_mobile_lcdc_priv *p = ch->lcdc; |
| 1047 | |
| 1048 | /* blank the screen? */ |
| 1049 | if (blank > FB_BLANK_UNBLANK && ch->blank_status == FB_BLANK_UNBLANK) { |
| 1050 | struct fb_fillrect rect = { |
| 1051 | .width = info->var.xres, |
| 1052 | .height = info->var.yres, |
| 1053 | }; |
| 1054 | sh_mobile_lcdc_fillrect(info, &rect); |
| 1055 | } |
| 1056 | /* turn clocks on? */ |
| 1057 | if (blank <= FB_BLANK_NORMAL && ch->blank_status > FB_BLANK_NORMAL) { |
| 1058 | sh_mobile_lcdc_clk_on(p); |
| 1059 | } |
| 1060 | /* turn clocks off? */ |
| 1061 | if (blank > FB_BLANK_NORMAL && ch->blank_status <= FB_BLANK_NORMAL) { |
| 1062 | /* make sure the screen is updated with the black fill before |
| 1063 | * switching the clocks off. one vsync is not enough since |
| 1064 | * blanking may occur in the middle of a refresh. deferred io |
| 1065 | * mode will reenable the clocks and update the screen in time, |
| 1066 | * so it does not need this. */ |
| 1067 | if (!info->fbdefio) { |
| 1068 | sh_mobile_wait_for_vsync(info); |
| 1069 | sh_mobile_wait_for_vsync(info); |
| 1070 | } |
| 1071 | sh_mobile_lcdc_clk_off(p); |
| 1072 | } |
| 1073 | |
| 1074 | ch->blank_status = blank; |
| 1075 | return 0; |
| 1076 | } |
| 1077 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1078 | static struct fb_ops sh_mobile_lcdc_ops = { |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 1079 | .owner = THIS_MODULE, |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1080 | .fb_setcolreg = sh_mobile_lcdc_setcolreg, |
Magnus Damm | 2540c11 | 2008-12-17 17:29:49 +0900 | [diff] [blame] | 1081 | .fb_read = fb_sys_read, |
| 1082 | .fb_write = fb_sys_write, |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 1083 | .fb_fillrect = sh_mobile_lcdc_fillrect, |
| 1084 | .fb_copyarea = sh_mobile_lcdc_copyarea, |
| 1085 | .fb_imageblit = sh_mobile_lcdc_imageblit, |
Alexandre Courbot | 8857b9a | 2011-02-23 08:36:30 +0000 | [diff] [blame] | 1086 | .fb_blank = sh_mobile_lcdc_blank, |
Phil Edworthy | 9dd3881 | 2009-09-15 12:00:18 +0000 | [diff] [blame] | 1087 | .fb_pan_display = sh_mobile_fb_pan_display, |
Phil Edworthy | 40331b2 | 2010-02-15 13:57:49 +0000 | [diff] [blame] | 1088 | .fb_ioctl = sh_mobile_ioctl, |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 1089 | .fb_open = sh_mobile_open, |
| 1090 | .fb_release = sh_mobile_release, |
| 1091 | .fb_check_var = sh_mobile_check_var, |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1092 | }; |
| 1093 | |
Alexandre Courbot | 3b0fd9d | 2011-02-16 03:49:01 +0000 | [diff] [blame] | 1094 | static int sh_mobile_lcdc_update_bl(struct backlight_device *bdev) |
| 1095 | { |
| 1096 | struct sh_mobile_lcdc_chan *ch = bl_get_data(bdev); |
| 1097 | struct sh_mobile_lcdc_board_cfg *cfg = &ch->cfg.board_cfg; |
| 1098 | int brightness = bdev->props.brightness; |
| 1099 | |
| 1100 | if (bdev->props.power != FB_BLANK_UNBLANK || |
| 1101 | bdev->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) |
| 1102 | brightness = 0; |
| 1103 | |
| 1104 | return cfg->set_brightness(cfg->board_data, brightness); |
| 1105 | } |
| 1106 | |
| 1107 | static int sh_mobile_lcdc_get_brightness(struct backlight_device *bdev) |
| 1108 | { |
| 1109 | struct sh_mobile_lcdc_chan *ch = bl_get_data(bdev); |
| 1110 | struct sh_mobile_lcdc_board_cfg *cfg = &ch->cfg.board_cfg; |
| 1111 | |
| 1112 | return cfg->get_brightness(cfg->board_data); |
| 1113 | } |
| 1114 | |
| 1115 | static int sh_mobile_lcdc_check_fb(struct backlight_device *bdev, |
| 1116 | struct fb_info *info) |
| 1117 | { |
| 1118 | return (info->bl_dev == bdev); |
| 1119 | } |
| 1120 | |
| 1121 | static struct backlight_ops sh_mobile_lcdc_bl_ops = { |
| 1122 | .options = BL_CORE_SUSPENDRESUME, |
| 1123 | .update_status = sh_mobile_lcdc_update_bl, |
| 1124 | .get_brightness = sh_mobile_lcdc_get_brightness, |
| 1125 | .check_fb = sh_mobile_lcdc_check_fb, |
| 1126 | }; |
| 1127 | |
| 1128 | static struct backlight_device *sh_mobile_lcdc_bl_probe(struct device *parent, |
| 1129 | struct sh_mobile_lcdc_chan *ch) |
| 1130 | { |
| 1131 | struct backlight_device *bl; |
| 1132 | |
| 1133 | bl = backlight_device_register(ch->cfg.bl_info.name, parent, ch, |
| 1134 | &sh_mobile_lcdc_bl_ops, NULL); |
Dan Carpenter | beee1f2 | 2011-03-21 15:03:13 +0000 | [diff] [blame] | 1135 | if (IS_ERR(bl)) { |
| 1136 | dev_err(parent, "unable to register backlight device: %ld\n", |
| 1137 | PTR_ERR(bl)); |
Alexandre Courbot | 3b0fd9d | 2011-02-16 03:49:01 +0000 | [diff] [blame] | 1138 | return NULL; |
| 1139 | } |
| 1140 | |
| 1141 | bl->props.max_brightness = ch->cfg.bl_info.max_brightness; |
| 1142 | bl->props.brightness = bl->props.max_brightness; |
| 1143 | backlight_update_status(bl); |
| 1144 | |
| 1145 | return bl; |
| 1146 | } |
| 1147 | |
| 1148 | static void sh_mobile_lcdc_bl_remove(struct backlight_device *bdev) |
| 1149 | { |
| 1150 | backlight_device_unregister(bdev); |
| 1151 | } |
| 1152 | |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 1153 | static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp, |
| 1154 | int nonstd) |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1155 | { |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 1156 | if (nonstd) { |
| 1157 | switch (bpp) { |
| 1158 | case 12: |
| 1159 | case 16: |
| 1160 | case 24: |
| 1161 | var->bits_per_pixel = bpp; |
| 1162 | var->nonstd = nonstd; |
| 1163 | return 0; |
| 1164 | default: |
| 1165 | return -EINVAL; |
| 1166 | } |
| 1167 | } |
| 1168 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1169 | switch (bpp) { |
| 1170 | case 16: /* PKF[4:0] = 00011 - RGB 565 */ |
| 1171 | var->red.offset = 11; |
| 1172 | var->red.length = 5; |
| 1173 | var->green.offset = 5; |
| 1174 | var->green.length = 6; |
| 1175 | var->blue.offset = 0; |
| 1176 | var->blue.length = 5; |
| 1177 | var->transp.offset = 0; |
| 1178 | var->transp.length = 0; |
| 1179 | break; |
| 1180 | |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 1181 | case 24: /* PKF[4:0] = 01011 - RGB 888 */ |
| 1182 | var->red.offset = 16; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1183 | var->red.length = 8; |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 1184 | var->green.offset = 8; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1185 | var->green.length = 8; |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 1186 | var->blue.offset = 0; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1187 | var->blue.length = 8; |
| 1188 | var->transp.offset = 0; |
| 1189 | var->transp.length = 0; |
| 1190 | break; |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 1191 | |
| 1192 | case 32: /* PKF[4:0] = 00000 - RGBA 888 */ |
| 1193 | var->red.offset = 16; |
| 1194 | var->red.length = 8; |
| 1195 | var->green.offset = 8; |
| 1196 | var->green.length = 8; |
| 1197 | var->blue.offset = 0; |
| 1198 | var->blue.length = 8; |
| 1199 | var->transp.offset = 24; |
| 1200 | var->transp.length = 8; |
| 1201 | break; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1202 | default: |
| 1203 | return -EINVAL; |
| 1204 | } |
| 1205 | var->bits_per_pixel = bpp; |
| 1206 | var->red.msb_right = 0; |
| 1207 | var->green.msb_right = 0; |
| 1208 | var->blue.msb_right = 0; |
| 1209 | var->transp.msb_right = 0; |
| 1210 | return 0; |
| 1211 | } |
| 1212 | |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 1213 | static int sh_mobile_lcdc_suspend(struct device *dev) |
| 1214 | { |
| 1215 | struct platform_device *pdev = to_platform_device(dev); |
| 1216 | |
| 1217 | sh_mobile_lcdc_stop(platform_get_drvdata(pdev)); |
| 1218 | return 0; |
| 1219 | } |
| 1220 | |
| 1221 | static int sh_mobile_lcdc_resume(struct device *dev) |
| 1222 | { |
| 1223 | struct platform_device *pdev = to_platform_device(dev); |
| 1224 | |
| 1225 | return sh_mobile_lcdc_start(platform_get_drvdata(pdev)); |
| 1226 | } |
| 1227 | |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 1228 | static int sh_mobile_lcdc_runtime_suspend(struct device *dev) |
| 1229 | { |
| 1230 | struct platform_device *pdev = to_platform_device(dev); |
| 1231 | struct sh_mobile_lcdc_priv *p = platform_get_drvdata(pdev); |
| 1232 | struct sh_mobile_lcdc_chan *ch; |
| 1233 | int k, n; |
| 1234 | |
| 1235 | /* save per-channel registers */ |
| 1236 | for (k = 0; k < ARRAY_SIZE(p->ch); k++) { |
| 1237 | ch = &p->ch[k]; |
| 1238 | if (!ch->enabled) |
| 1239 | continue; |
| 1240 | for (n = 0; n < NR_CH_REGS; n++) |
| 1241 | ch->saved_ch_regs[n] = lcdc_read_chan(ch, n); |
| 1242 | } |
| 1243 | |
| 1244 | /* save shared registers */ |
| 1245 | for (n = 0; n < NR_SHARED_REGS; n++) |
| 1246 | p->saved_shared_regs[n] = lcdc_read(p, lcdc_shared_regs[n]); |
| 1247 | |
| 1248 | /* turn off LCDC hardware */ |
| 1249 | lcdc_write(p, _LDCNT1R, 0); |
| 1250 | return 0; |
| 1251 | } |
| 1252 | |
| 1253 | static int sh_mobile_lcdc_runtime_resume(struct device *dev) |
| 1254 | { |
| 1255 | struct platform_device *pdev = to_platform_device(dev); |
| 1256 | struct sh_mobile_lcdc_priv *p = platform_get_drvdata(pdev); |
| 1257 | struct sh_mobile_lcdc_chan *ch; |
| 1258 | int k, n; |
| 1259 | |
| 1260 | /* restore per-channel registers */ |
| 1261 | for (k = 0; k < ARRAY_SIZE(p->ch); k++) { |
| 1262 | ch = &p->ch[k]; |
| 1263 | if (!ch->enabled) |
| 1264 | continue; |
| 1265 | for (n = 0; n < NR_CH_REGS; n++) |
| 1266 | lcdc_write_chan(ch, n, ch->saved_ch_regs[n]); |
| 1267 | } |
| 1268 | |
| 1269 | /* restore shared registers */ |
| 1270 | for (n = 0; n < NR_SHARED_REGS; n++) |
| 1271 | lcdc_write(p, lcdc_shared_regs[n], p->saved_shared_regs[n]); |
| 1272 | |
| 1273 | return 0; |
| 1274 | } |
| 1275 | |
Alexey Dobriyan | 4714521 | 2009-12-14 18:00:08 -0800 | [diff] [blame] | 1276 | static const struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = { |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 1277 | .suspend = sh_mobile_lcdc_suspend, |
| 1278 | .resume = sh_mobile_lcdc_resume, |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 1279 | .runtime_suspend = sh_mobile_lcdc_runtime_suspend, |
| 1280 | .runtime_resume = sh_mobile_lcdc_runtime_resume, |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 1281 | }; |
| 1282 | |
Guennadi Liakhovetski | 6de9edd | 2010-09-03 07:20:23 +0000 | [diff] [blame] | 1283 | /* locking: called with info->lock held */ |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1284 | static int sh_mobile_lcdc_notify(struct notifier_block *nb, |
| 1285 | unsigned long action, void *data) |
| 1286 | { |
| 1287 | struct fb_event *event = data; |
| 1288 | struct fb_info *info = event->info; |
| 1289 | struct sh_mobile_lcdc_chan *ch = info->par; |
| 1290 | struct sh_mobile_lcdc_board_cfg *board_cfg = &ch->cfg.board_cfg; |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1291 | |
| 1292 | if (&ch->lcdc->notifier != nb) |
Guennadi Liakhovetski | baf1637 | 2010-09-03 07:20:08 +0000 | [diff] [blame] | 1293 | return NOTIFY_DONE; |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1294 | |
| 1295 | dev_dbg(info->dev, "%s(): action = %lu, data = %p\n", |
| 1296 | __func__, action, event->data); |
| 1297 | |
| 1298 | switch(action) { |
| 1299 | case FB_EVENT_SUSPEND: |
Alexandre Courbot | 247f993 | 2011-02-23 08:41:50 +0000 | [diff] [blame] | 1300 | if (board_cfg->display_off && try_module_get(board_cfg->owner)) { |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1301 | board_cfg->display_off(board_cfg->board_data); |
Guennadi Liakhovetski | 6de9edd | 2010-09-03 07:20:23 +0000 | [diff] [blame] | 1302 | module_put(board_cfg->owner); |
| 1303 | } |
Guennadi Liakhovetski | afe417c | 2010-09-03 07:20:39 +0000 | [diff] [blame] | 1304 | sh_mobile_lcdc_stop(ch->lcdc); |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1305 | break; |
| 1306 | case FB_EVENT_RESUME: |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 1307 | mutex_lock(&ch->open_lock); |
| 1308 | sh_mobile_fb_reconfig(info); |
| 1309 | mutex_unlock(&ch->open_lock); |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1310 | |
| 1311 | /* HDMI must be enabled before LCDC configuration */ |
Alexandre Courbot | 247f993 | 2011-02-23 08:41:50 +0000 | [diff] [blame] | 1312 | if (board_cfg->display_on && try_module_get(board_cfg->owner)) { |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 1313 | board_cfg->display_on(board_cfg->board_data, info); |
Guennadi Liakhovetski | 6de9edd | 2010-09-03 07:20:23 +0000 | [diff] [blame] | 1314 | module_put(board_cfg->owner); |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1315 | } |
| 1316 | |
Guennadi Liakhovetski | ebe5e12 | 2011-05-05 16:33:40 +0000 | [diff] [blame^] | 1317 | sh_mobile_lcdc_start(ch->lcdc); |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1318 | } |
| 1319 | |
Guennadi Liakhovetski | baf1637 | 2010-09-03 07:20:08 +0000 | [diff] [blame] | 1320 | return NOTIFY_OK; |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1321 | } |
| 1322 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1323 | static int sh_mobile_lcdc_remove(struct platform_device *pdev); |
| 1324 | |
Uwe Kleine-König | c2e1303 | 2010-02-04 20:56:51 +0100 | [diff] [blame] | 1325 | static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev) |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1326 | { |
| 1327 | struct fb_info *info; |
| 1328 | struct sh_mobile_lcdc_priv *priv; |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1329 | struct sh_mobile_lcdc_info *pdata = pdev->dev.platform_data; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1330 | struct resource *res; |
| 1331 | int error; |
| 1332 | void *buf; |
| 1333 | int i, j; |
| 1334 | |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1335 | if (!pdata) { |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1336 | dev_err(&pdev->dev, "no platform data defined\n"); |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1337 | return -EINVAL; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1338 | } |
| 1339 | |
| 1340 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 1341 | i = platform_get_irq(pdev, 0); |
| 1342 | if (!res || i < 0) { |
| 1343 | dev_err(&pdev->dev, "cannot get platform resources\n"); |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1344 | return -ENOENT; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1345 | } |
| 1346 | |
| 1347 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
| 1348 | if (!priv) { |
| 1349 | dev_err(&pdev->dev, "cannot allocate device data\n"); |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1350 | return -ENOMEM; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1351 | } |
| 1352 | |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1353 | platform_set_drvdata(pdev, priv); |
| 1354 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 1355 | error = request_irq(i, sh_mobile_lcdc_irq, IRQF_DISABLED, |
Kay Sievers | 7ad33e7 | 2009-03-24 16:38:21 -0700 | [diff] [blame] | 1356 | dev_name(&pdev->dev), priv); |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 1357 | if (error) { |
| 1358 | dev_err(&pdev->dev, "unable to request irq\n"); |
| 1359 | goto err1; |
| 1360 | } |
| 1361 | |
| 1362 | priv->irq = i; |
Guennadi Liakhovetski | 5ef6b50 | 2010-09-03 07:19:57 +0000 | [diff] [blame] | 1363 | atomic_set(&priv->hw_usecnt, -1); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1364 | |
| 1365 | j = 0; |
| 1366 | for (i = 0; i < ARRAY_SIZE(pdata->ch); i++) { |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1367 | struct sh_mobile_lcdc_chan *ch = priv->ch + j; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1368 | |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1369 | ch->lcdc = priv; |
| 1370 | memcpy(&ch->cfg, &pdata->ch[i], sizeof(pdata->ch[i])); |
| 1371 | |
| 1372 | error = sh_mobile_lcdc_check_interface(ch); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1373 | if (error) { |
| 1374 | dev_err(&pdev->dev, "unsupported interface type\n"); |
| 1375 | goto err1; |
| 1376 | } |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1377 | init_waitqueue_head(&ch->frame_end_wait); |
| 1378 | init_completion(&ch->vsync_completion); |
| 1379 | ch->pan_offset = 0; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1380 | |
Alexandre Courbot | 3b0fd9d | 2011-02-16 03:49:01 +0000 | [diff] [blame] | 1381 | /* probe the backlight is there is one defined */ |
| 1382 | if (ch->cfg.bl_info.max_brightness) |
| 1383 | ch->bl = sh_mobile_lcdc_bl_probe(&pdev->dev, ch); |
| 1384 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1385 | switch (pdata->ch[i].chan) { |
| 1386 | case LCDC_CHAN_MAINLCD: |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1387 | ch->enabled = 1 << 1; |
| 1388 | ch->reg_offs = lcdc_offs_mainlcd; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1389 | j++; |
| 1390 | break; |
| 1391 | case LCDC_CHAN_SUBLCD: |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1392 | ch->enabled = 1 << 2; |
| 1393 | ch->reg_offs = lcdc_offs_sublcd; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1394 | j++; |
| 1395 | break; |
| 1396 | } |
| 1397 | } |
| 1398 | |
| 1399 | if (!j) { |
| 1400 | dev_err(&pdev->dev, "no channels defined\n"); |
| 1401 | error = -EINVAL; |
| 1402 | goto err1; |
| 1403 | } |
| 1404 | |
Magnus Damm | 417d482 | 2011-01-05 10:21:00 +0000 | [diff] [blame] | 1405 | /* for dual channel LCDC (MAIN + SUB) force shared bpp setting */ |
| 1406 | if (j == 2) |
| 1407 | priv->forced_bpp = pdata->ch[0].bpp; |
| 1408 | |
Guennadi Liakhovetski | dba6f38 | 2010-06-30 09:26:35 +0000 | [diff] [blame] | 1409 | priv->base = ioremap_nocache(res->start, resource_size(res)); |
| 1410 | if (!priv->base) |
| 1411 | goto err1; |
| 1412 | |
Magnus Damm | b51339f | 2008-10-31 20:23:26 +0900 | [diff] [blame] | 1413 | error = sh_mobile_lcdc_setup_clocks(pdev, pdata->clock_source, priv); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1414 | if (error) { |
| 1415 | dev_err(&pdev->dev, "unable to setup clocks\n"); |
| 1416 | goto err1; |
| 1417 | } |
| 1418 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1419 | for (i = 0; i < j; i++) { |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1420 | struct fb_var_screeninfo *var; |
Guennadi Liakhovetski | 71d3b0f | 2010-09-03 07:20:12 +0000 | [diff] [blame] | 1421 | const struct fb_videomode *lcd_cfg, *max_cfg = NULL; |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1422 | struct sh_mobile_lcdc_chan *ch = priv->ch + i; |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 1423 | struct sh_mobile_lcdc_chan_cfg *cfg = &ch->cfg; |
| 1424 | const struct fb_videomode *mode = cfg->lcd_cfg; |
Guennadi Liakhovetski | 71d3b0f | 2010-09-03 07:20:12 +0000 | [diff] [blame] | 1425 | unsigned long max_size = 0; |
| 1426 | int k; |
Guennadi Liakhovetski | 5fd284e | 2010-11-04 11:06:11 +0000 | [diff] [blame] | 1427 | int num_cfg; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1428 | |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1429 | ch->info = framebuffer_alloc(0, &pdev->dev); |
| 1430 | if (!ch->info) { |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 1431 | dev_err(&pdev->dev, "unable to allocate fb_info\n"); |
| 1432 | error = -ENOMEM; |
| 1433 | break; |
| 1434 | } |
| 1435 | |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1436 | info = ch->info; |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1437 | var = &info->var; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1438 | info->fbops = &sh_mobile_lcdc_ops; |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 1439 | info->par = ch; |
Guennadi Liakhovetski | dd21050 | 2010-09-14 14:48:54 +0000 | [diff] [blame] | 1440 | |
| 1441 | mutex_init(&ch->open_lock); |
| 1442 | |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 1443 | for (k = 0, lcd_cfg = mode; |
| 1444 | k < cfg->num_cfg && lcd_cfg; |
Guennadi Liakhovetski | 71d3b0f | 2010-09-03 07:20:12 +0000 | [diff] [blame] | 1445 | k++, lcd_cfg++) { |
| 1446 | unsigned long size = lcd_cfg->yres * lcd_cfg->xres; |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 1447 | /* NV12 buffers must have even number of lines */ |
| 1448 | if ((cfg->nonstd) && cfg->bpp == 12 && |
| 1449 | (lcd_cfg->yres & 0x1)) { |
| 1450 | dev_err(&pdev->dev, "yres must be multiple of 2" |
| 1451 | " for YCbCr420 mode.\n"); |
| 1452 | error = -EINVAL; |
| 1453 | goto err1; |
| 1454 | } |
Guennadi Liakhovetski | 71d3b0f | 2010-09-03 07:20:12 +0000 | [diff] [blame] | 1455 | |
| 1456 | if (size > max_size) { |
| 1457 | max_cfg = lcd_cfg; |
| 1458 | max_size = size; |
| 1459 | } |
| 1460 | } |
| 1461 | |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 1462 | if (!mode) |
Guennadi Liakhovetski | d2ecbab | 2010-11-04 11:06:06 +0000 | [diff] [blame] | 1463 | max_size = MAX_XRES * MAX_YRES; |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 1464 | else if (max_cfg) |
| 1465 | dev_dbg(&pdev->dev, "Found largest videomode %ux%u\n", |
| 1466 | max_cfg->xres, max_cfg->yres); |
Guennadi Liakhovetski | 71d3b0f | 2010-09-03 07:20:12 +0000 | [diff] [blame] | 1467 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1468 | info->fix = sh_mobile_lcdc_fix; |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 1469 | info->fix.smem_len = max_size * 2 * cfg->bpp / 8; |
| 1470 | |
| 1471 | /* Only pan in 2 line steps for NV12 */ |
| 1472 | if (cfg->nonstd && cfg->bpp == 12) |
| 1473 | info->fix.ypanstep = 2; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1474 | |
Guennadi Liakhovetski | 5fd284e | 2010-11-04 11:06:11 +0000 | [diff] [blame] | 1475 | if (!mode) { |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 1476 | mode = &default_720p; |
Guennadi Liakhovetski | 5fd284e | 2010-11-04 11:06:11 +0000 | [diff] [blame] | 1477 | num_cfg = 1; |
| 1478 | } else { |
Guennadi Liakhovetski | e0b9fb2 | 2010-12-21 11:46:26 +0100 | [diff] [blame] | 1479 | num_cfg = cfg->num_cfg; |
Guennadi Liakhovetski | 5fd284e | 2010-11-04 11:06:11 +0000 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | fb_videomode_to_modelist(mode, num_cfg, &info->modelist); |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 1483 | |
| 1484 | fb_videomode_to_var(var, mode); |
Guennadi Liakhovetski | e0b9fb2 | 2010-12-21 11:46:26 +0100 | [diff] [blame] | 1485 | var->width = cfg->lcd_size_cfg.width; |
| 1486 | var->height = cfg->lcd_size_cfg.height; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1487 | /* Default Y virtual resolution is 2x panel size */ |
| 1488 | var->yres_virtual = var->yres * 2; |
Paul Mundt | 1c6a307 | 2009-07-01 06:50:31 +0000 | [diff] [blame] | 1489 | var->activate = FB_ACTIVATE_NOW; |
Paul Mundt | 1c6a307 | 2009-07-01 06:50:31 +0000 | [diff] [blame] | 1490 | |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 1491 | error = sh_mobile_lcdc_set_bpp(var, cfg->bpp, cfg->nonstd); |
Paul Mundt | 1c6a307 | 2009-07-01 06:50:31 +0000 | [diff] [blame] | 1492 | if (error) |
| 1493 | break; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1494 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1495 | buf = dma_alloc_coherent(&pdev->dev, info->fix.smem_len, |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1496 | &ch->dma_handle, GFP_KERNEL); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1497 | if (!buf) { |
| 1498 | dev_err(&pdev->dev, "unable to allocate buffer\n"); |
| 1499 | error = -ENOMEM; |
| 1500 | break; |
| 1501 | } |
| 1502 | |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1503 | info->pseudo_palette = &ch->pseudo_palette; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1504 | info->flags = FBINFO_FLAG_DEFAULT; |
| 1505 | |
| 1506 | error = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0); |
| 1507 | if (error < 0) { |
| 1508 | dev_err(&pdev->dev, "unable to allocate cmap\n"); |
| 1509 | dma_free_coherent(&pdev->dev, info->fix.smem_len, |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1510 | buf, ch->dma_handle); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1511 | break; |
| 1512 | } |
| 1513 | |
Guennadi Liakhovetski | 01ac25b | 2010-09-03 07:20:00 +0000 | [diff] [blame] | 1514 | info->fix.smem_start = ch->dma_handle; |
Damian Hobson-Garcia | 53b5031 | 2011-02-24 05:47:13 +0000 | [diff] [blame] | 1515 | if (var->nonstd) |
| 1516 | info->fix.line_length = var->xres; |
| 1517 | else |
| 1518 | info->fix.line_length = var->xres * (cfg->bpp / 8); |
| 1519 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1520 | info->screen_base = buf; |
| 1521 | info->device = &pdev->dev; |
Guennadi Liakhovetski | 1c120de | 2010-09-03 07:20:27 +0000 | [diff] [blame] | 1522 | ch->display_var = *var; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1523 | } |
| 1524 | |
| 1525 | if (error) |
| 1526 | goto err1; |
| 1527 | |
| 1528 | error = sh_mobile_lcdc_start(priv); |
| 1529 | if (error) { |
| 1530 | dev_err(&pdev->dev, "unable to start hardware\n"); |
| 1531 | goto err1; |
| 1532 | } |
| 1533 | |
| 1534 | for (i = 0; i < j; i++) { |
| 1535 | struct sh_mobile_lcdc_chan *ch = priv->ch + i; |
| 1536 | |
| 1537 | info = ch->info; |
| 1538 | |
| 1539 | if (info->fbdefio) { |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1540 | ch->sglist = vmalloc(sizeof(struct scatterlist) * |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1541 | info->fix.smem_len >> PAGE_SHIFT); |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1542 | if (!ch->sglist) { |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1543 | dev_err(&pdev->dev, "cannot allocate sglist\n"); |
| 1544 | goto err1; |
| 1545 | } |
| 1546 | } |
| 1547 | |
Alexandre Courbot | 3b0fd9d | 2011-02-16 03:49:01 +0000 | [diff] [blame] | 1548 | info->bl_dev = ch->bl; |
| 1549 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1550 | error = register_framebuffer(info); |
| 1551 | if (error < 0) |
| 1552 | goto err1; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1553 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1554 | dev_info(info->dev, |
| 1555 | "registered %s/%s as %dx%d %dbpp.\n", |
| 1556 | pdev->name, |
Paul Mundt | 1c6a307 | 2009-07-01 06:50:31 +0000 | [diff] [blame] | 1557 | (ch->cfg.chan == LCDC_CHAN_MAINLCD) ? |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1558 | "mainlcd" : "sublcd", |
Guennadi Liakhovetski | c44f9f7 | 2010-10-15 07:53:52 +0000 | [diff] [blame] | 1559 | info->var.xres, info->var.yres, |
Paul Mundt | 1c6a307 | 2009-07-01 06:50:31 +0000 | [diff] [blame] | 1560 | ch->cfg.bpp); |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 1561 | |
| 1562 | /* deferred io mode: disable clock to save power */ |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1563 | if (info->fbdefio || info->state == FBINFO_STATE_SUSPENDED) |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 1564 | sh_mobile_lcdc_clk_off(priv); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1565 | } |
| 1566 | |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1567 | /* Failure ignored */ |
| 1568 | priv->notifier.notifier_call = sh_mobile_lcdc_notify; |
| 1569 | fb_register_client(&priv->notifier); |
| 1570 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1571 | return 0; |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1572 | err1: |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1573 | sh_mobile_lcdc_remove(pdev); |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1574 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1575 | return error; |
| 1576 | } |
| 1577 | |
| 1578 | static int sh_mobile_lcdc_remove(struct platform_device *pdev) |
| 1579 | { |
| 1580 | struct sh_mobile_lcdc_priv *priv = platform_get_drvdata(pdev); |
| 1581 | struct fb_info *info; |
| 1582 | int i; |
| 1583 | |
Guennadi Liakhovetski | 6011bde | 2010-07-21 10:13:21 +0000 | [diff] [blame] | 1584 | fb_unregister_client(&priv->notifier); |
| 1585 | |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1586 | for (i = 0; i < ARRAY_SIZE(priv->ch); i++) |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1587 | if (priv->ch[i].info && priv->ch[i].info->dev) |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 1588 | unregister_framebuffer(priv->ch[i].info); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1589 | |
| 1590 | sh_mobile_lcdc_stop(priv); |
| 1591 | |
| 1592 | for (i = 0; i < ARRAY_SIZE(priv->ch); i++) { |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 1593 | info = priv->ch[i].info; |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1594 | |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 1595 | if (!info || !info->device) |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1596 | continue; |
| 1597 | |
Paul Mundt | 1c6a307 | 2009-07-01 06:50:31 +0000 | [diff] [blame] | 1598 | if (priv->ch[i].sglist) |
| 1599 | vfree(priv->ch[i].sglist); |
| 1600 | |
Magnus Damm | 1ffbb03 | 2010-10-13 07:17:45 +0000 | [diff] [blame] | 1601 | if (info->screen_base) |
| 1602 | dma_free_coherent(&pdev->dev, info->fix.smem_len, |
| 1603 | info->screen_base, |
| 1604 | priv->ch[i].dma_handle); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1605 | fb_dealloc_cmap(&info->cmap); |
Paul Mundt | e33afdd | 2009-07-07 11:24:32 +0900 | [diff] [blame] | 1606 | framebuffer_release(info); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1607 | } |
| 1608 | |
Alexandre Courbot | 3b0fd9d | 2011-02-16 03:49:01 +0000 | [diff] [blame] | 1609 | for (i = 0; i < ARRAY_SIZE(priv->ch); i++) { |
| 1610 | if (priv->ch[i].bl) |
| 1611 | sh_mobile_lcdc_bl_remove(priv->ch[i].bl); |
| 1612 | } |
| 1613 | |
Magnus Damm | b51339f | 2008-10-31 20:23:26 +0900 | [diff] [blame] | 1614 | if (priv->dot_clk) |
| 1615 | clk_put(priv->dot_clk); |
Magnus Damm | 0246c47 | 2009-08-14 10:49:08 +0000 | [diff] [blame] | 1616 | |
Guennadi Liakhovetski | 8bed905 | 2010-04-30 16:07:00 +0000 | [diff] [blame] | 1617 | if (priv->dev) |
| 1618 | pm_runtime_disable(priv->dev); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1619 | |
| 1620 | if (priv->base) |
| 1621 | iounmap(priv->base); |
| 1622 | |
Magnus Damm | 8564557 | 2008-12-19 15:34:41 +0900 | [diff] [blame] | 1623 | if (priv->irq) |
| 1624 | free_irq(priv->irq, priv); |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1625 | kfree(priv); |
| 1626 | return 0; |
| 1627 | } |
| 1628 | |
| 1629 | static struct platform_driver sh_mobile_lcdc_driver = { |
| 1630 | .driver = { |
| 1631 | .name = "sh_mobile_lcdc_fb", |
| 1632 | .owner = THIS_MODULE, |
Magnus Damm | 2feb075 | 2009-03-13 15:36:55 +0000 | [diff] [blame] | 1633 | .pm = &sh_mobile_lcdc_dev_pm_ops, |
Magnus Damm | cfb4f5d | 2008-07-23 21:31:24 -0700 | [diff] [blame] | 1634 | }, |
| 1635 | .probe = sh_mobile_lcdc_probe, |
| 1636 | .remove = sh_mobile_lcdc_remove, |
| 1637 | }; |
| 1638 | |
| 1639 | static int __init sh_mobile_lcdc_init(void) |
| 1640 | { |
| 1641 | return platform_driver_register(&sh_mobile_lcdc_driver); |
| 1642 | } |
| 1643 | |
| 1644 | static void __exit sh_mobile_lcdc_exit(void) |
| 1645 | { |
| 1646 | platform_driver_unregister(&sh_mobile_lcdc_driver); |
| 1647 | } |
| 1648 | |
| 1649 | module_init(sh_mobile_lcdc_init); |
| 1650 | module_exit(sh_mobile_lcdc_exit); |
| 1651 | |
| 1652 | MODULE_DESCRIPTION("SuperH Mobile LCDC Framebuffer driver"); |
| 1653 | MODULE_AUTHOR("Magnus Damm <damm@opensource.se>"); |
| 1654 | MODULE_LICENSE("GPL v2"); |