2 * File: drivers/video/omap/hwa742.c
4 * Epson HWA742 LCD controller driver
6 * Copyright (C) 2004-2005 Nokia Corporation
7 * Authors: Juha Yrjölä <juha.yrjola@nokia.com>
8 * Imre Deak <imre.deak@nokia.com>
9 * YUV support: Jussi Laako <jussi.laako@nokia.com>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <linux/config.h>
26 #include <linux/module.h>
29 #include <linux/delay.h>
30 #include <linux/clk.h>
32 #include <asm/arch/dma.h>
33 #include <asm/arch/omapfb.h>
35 /* #define OMAPFB_DBG 1 */
40 #define MODULE_NAME "omapfb-hwa742"
42 #define HWA742_REV_CODE_REG 0x0
43 #define HWA742_CONFIG_REG 0x2
44 #define HWA742_PLL_DIV_REG 0x4
45 #define HWA742_PLL_0_REG 0x6
46 #define HWA742_PLL_1_REG 0x8
47 #define HWA742_PLL_2_REG 0xa
48 #define HWA742_PLL_3_REG 0xc
49 #define HWA742_PLL_4_REG 0xe
50 #define HWA742_CLK_SRC_REG 0x12
51 #define HWA742_PANEL_TYPE_REG 0x14
52 #define HWA742_H_DISP_REG 0x16
53 #define HWA742_H_NDP_REG 0x18
54 #define HWA742_V_DISP_1_REG 0x1a
55 #define HWA742_V_DISP_2_REG 0x1c
56 #define HWA742_V_NDP_REG 0x1e
57 #define HWA742_HS_W_REG 0x20
58 #define HWA742_HP_S_REG 0x22
59 #define HWA742_VS_W_REG 0x24
60 #define HWA742_VP_S_REG 0x26
61 #define HWA742_PCLK_POL_REG 0x28
62 #define HWA742_INPUT_MODE_REG 0x2a
63 #define HWA742_TRANSL_MODE_REG1 0x2e
64 #define HWA742_DISP_MODE_REG 0x34
65 #define HWA742_WINDOW_TYPE 0x36
66 #define HWA742_WINDOW_X_START_0 0x38
67 #define HWA742_WINDOW_X_START_1 0x3a
68 #define HWA742_WINDOW_Y_START_0 0x3c
69 #define HWA742_WINDOW_Y_START_1 0x3e
70 #define HWA742_WINDOW_X_END_0 0x40
71 #define HWA742_WINDOW_X_END_1 0x42
72 #define HWA742_WINDOW_Y_END_0 0x44
73 #define HWA742_WINDOW_Y_END_1 0x46
74 #define HWA742_MEMORY_WRITE_LSB 0x48
75 #define HWA742_MEMORY_WRITE_MSB 0x49
76 #define HWA742_MEMORY_READ_0 0x4a
77 #define HWA742_MEMORY_READ_1 0x4c
78 #define HWA742_MEMORY_READ_2 0x4e
79 #define HWA742_POWER_SAVE 0x56
80 #define HWA742_NDP_CTRL 0x58
82 #define HWA742_AUTO_UPDATE_TIME (HZ / 20)
84 #define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": " fmt, ## args)
86 /* Reserve 4 request slots for requests in irq context */
87 #define REQ_POOL_SIZE 24
88 #define IRQ_REQ_POOL_SIZE 4
91 int x, y, width, height;
96 #define REQ_FROM_IRQ_POOL 0x01
98 #define REQ_COMPLETE 0
101 struct hwa742_request {
102 struct list_head entry;
105 int (*handler)(struct hwa742_request *req);
106 void (*complete)(void *data);
110 struct update_param update;
111 struct completion *sync;
115 struct hwa742_struct {
116 enum omapfb_update_mode update_mode;
117 enum omapfb_update_mode update_mode_before_suspend;
119 struct timer_list auto_update_timer;
120 int stop_auto_update;
121 struct omapfb_update_window auto_update_window;
123 struct hwa742_request req_pool[REQ_POOL_SIZE];
124 struct list_head pending_req_list;
125 struct list_head free_req_list;
126 struct semaphore req_sema;
130 struct extif_timings reg_timings, lut_timings;
136 u32 max_transmit_size;
137 u32 extif_clk_period;
139 struct omapfb_device *fbdev;
140 struct lcd_ctrl_extif *extif;
141 struct lcd_ctrl *int_ctrl;
144 static u8 hwa742_read_reg(u8 reg)
148 hwa742.extif->set_bits_per_cycle(8);
149 hwa742.extif->write_command(®, 1);
150 hwa742.extif->read_data(&data, 1);
155 static void hwa742_write_reg(u8 reg, u8 data)
157 hwa742.extif->set_bits_per_cycle(8);
158 hwa742.extif->write_command(®, 1);
159 hwa742.extif->write_data(&data, 1);
162 void hwa742_read_id(int *rev_code, int *config)
164 *rev_code = hwa742_read_reg(HWA742_REV_CODE_REG);
165 *config = hwa742_read_reg(HWA742_CONFIG_REG);
167 EXPORT_SYMBOL(hwa742_read_id);
169 static void set_window_regs(int x_start, int y_start, int x_end, int y_end)
177 tmp[1] = x_start >> 8;
179 tmp[3] = y_start >> 8;
185 hwa742.extif->set_bits_per_cycle(8);
186 cmd = HWA742_WINDOW_X_START_0;
188 hwa742.extif->write_command(&cmd, 1);
190 hwa742.extif->write_data(tmp, 8);
193 static void set_format_regs(int conv, int transl, int flags)
195 if (flags & OMAPFB_FORMAT_FLAG_DOUBLE) {
196 hwa742.window_type = ((hwa742.window_type & 0xfc) | 0x01);
197 DBGPRINT(2, "hwa742: enabled pixel doubling\n");
199 hwa742.window_type = (hwa742.window_type & 0xfc);
200 DBGPRINT(2, "hwa742: disabled pixel doubling\n");
203 hwa742_write_reg(HWA742_INPUT_MODE_REG, conv);
204 hwa742_write_reg(HWA742_TRANSL_MODE_REG1, transl);
205 hwa742_write_reg(HWA742_WINDOW_TYPE, hwa742.window_type);
208 static inline struct hwa742_request *alloc_req(void)
211 struct hwa742_request *req;
215 down(&hwa742.req_sema);
217 req_flags = REQ_FROM_IRQ_POOL;
219 spin_lock_irqsave(&hwa742.req_lock, flags);
220 BUG_ON(list_empty(&hwa742.free_req_list));
221 req = list_entry(hwa742.free_req_list.next,
222 struct hwa742_request, entry);
223 list_del(&req->entry);
224 spin_unlock_irqrestore(&hwa742.req_lock, flags);
226 INIT_LIST_HEAD(&req->entry);
227 req->flags = req_flags;
232 static inline void free_req(struct hwa742_request *req)
236 spin_lock_irqsave(&hwa742.req_lock, flags);
238 list_del(&req->entry);
239 list_add(&req->entry, &hwa742.free_req_list);
240 if (!(req->flags & REQ_FROM_IRQ_POOL))
241 up(&hwa742.req_sema);
243 spin_unlock_irqrestore(&hwa742.req_lock, flags);
246 static void process_pending_requests(void)
252 spin_lock_irqsave(&hwa742.req_lock, flags);
254 while (!list_empty(&hwa742.pending_req_list)) {
255 struct hwa742_request *req;
256 void (*complete)(void *);
259 req = list_entry(hwa742.pending_req_list.next,
260 struct hwa742_request, entry);
261 spin_unlock_irqrestore(&hwa742.req_lock, flags);
263 if (req->handler(req) == REQ_PENDING)
266 complete = req->complete;
267 complete_data = req->complete_data;
271 complete(complete_data);
273 spin_lock_irqsave(&hwa742.req_lock, flags);
276 spin_unlock_irqrestore(&hwa742.req_lock, flags);
281 static void submit_req_list(struct list_head *head)
288 spin_lock_irqsave(&hwa742.req_lock, flags);
289 if (likely(!list_empty(&hwa742.pending_req_list)))
291 list_splice_init(head, hwa742.pending_req_list.prev);
292 spin_unlock_irqrestore(&hwa742.req_lock, flags);
295 process_pending_requests();
300 static void request_complete(void *data)
302 struct hwa742_request *req = (struct hwa742_request *)data;
303 void (*complete)(void *);
306 complete = req->complete;
307 complete_data = req->complete_data;
312 complete(complete_data);
314 process_pending_requests();
317 static int send_frame_handler(struct hwa742_request *req)
319 struct update_param *par = &req->par.update;
326 unsigned long offset;
327 int color_mode = par->color_mode;
328 int flags = par->flags;
331 DBGPRINT(2, "x %d y %d w %d h %d scr_width %d color_mode %d flags %d\n",
332 x, y, w, h, scr_width, color_mode, flags);
334 switch (color_mode) {
335 case OMAPFB_COLOR_YUV422:
340 case OMAPFB_COLOR_YUV420:
345 case OMAPFB_COLOR_RGB565:
354 if (hwa742.prev_flags != flags ||
355 hwa742.prev_color_mode != color_mode) {
356 set_format_regs(conv, transl, flags);
357 hwa742.prev_color_mode = color_mode;
358 hwa742.prev_flags = flags;
361 set_window_regs(x, y, x + w, y + h);
363 offset = (scr_width * y + x) * bpp / 8;
365 hwa742.int_ctrl->setup_plane(OMAPFB_PLANE_GFX,
366 OMAPFB_CHANNEL_OUT_LCD, offset, scr_width, 0, 0, w, h,
369 hwa742.extif->set_bits_per_cycle(16);
371 hwa742.int_ctrl->enable_plane(OMAPFB_PLANE_GFX, 1);
372 hwa742.extif->transfer_area(w, h, request_complete, req);
377 static void send_frame_complete(void *data)
379 hwa742.int_ctrl->enable_plane(OMAPFB_PLANE_GFX, 0);
382 #define ADD_PREQ(_x, _y, _w, _h) do { \
384 req->handler = send_frame_handler; \
385 req->complete = send_frame_complete; \
386 req->par.update.x = _x; \
387 req->par.update.y = _y; \
388 req->par.update.width = _w; \
389 req->par.update.height = _h; \
390 req->par.update.color_mode = color_mode;\
391 req->par.update.flags = flags; \
392 list_add_tail(&req->entry, req_head); \
395 static void create_req_list(struct omapfb_update_window *win,
396 struct list_head *req_head)
398 struct hwa742_request *req;
401 int width = win->width;
402 int height = win->height;
406 flags = win->format & OMAPFB_FORMAT_FLAG_DOUBLE;
407 color_mode = win->format & OMAPFB_FORMAT_MASK;
410 ADD_PREQ(x, y, 1, height);
415 unsigned int xspan = width & ~1;
416 unsigned int ystart = y;
417 unsigned int yspan = height;
419 if (xspan * height * 2 > hwa742.max_transmit_size) {
420 yspan = hwa742.max_transmit_size / (xspan * 2);
421 ADD_PREQ(x, ystart, xspan, yspan);
423 yspan = height - yspan;
426 ADD_PREQ(x, ystart, xspan, yspan);
431 ADD_PREQ(x, y, 1, height);
434 static void auto_update_complete(void *data)
438 if (!hwa742.stop_auto_update)
439 mod_timer(&hwa742.auto_update_timer,
440 jiffies + HWA742_AUTO_UPDATE_TIME);
445 static void hwa742_update_window_auto(unsigned long arg)
448 struct hwa742_request *last;
452 create_req_list(&hwa742.auto_update_window, &req_list);
453 last = list_entry(req_list.prev, struct hwa742_request, entry);
455 last->complete = auto_update_complete;
456 last->complete_data = NULL;
458 submit_req_list(&req_list);
463 int hwa742_update_window_async(struct omapfb_update_window *win,
464 void (*complete_callback)(void *arg),
465 void *complete_callback_data)
468 struct hwa742_request *last;
473 if (hwa742.update_mode != OMAPFB_MANUAL_UPDATE) {
477 if (unlikely(win->format & ~(0x03 | OMAPFB_FORMAT_FLAG_DOUBLE))) {
482 create_req_list(win, &req_list);
483 last = list_entry(req_list.prev, struct hwa742_request, entry);
485 last->complete = complete_callback;
486 last->complete_data = (void *)complete_callback_data;
488 submit_req_list(&req_list);
494 EXPORT_SYMBOL(hwa742_update_window_async);
496 static int hwa742_setup_plane(int plane, int channel_out,
497 unsigned long offset, int screen_width,
498 int pos_x, int pos_y, int width, int height,
501 if (plane != OMAPFB_PLANE_GFX ||
502 channel_out != OMAPFB_CHANNEL_OUT_LCD)
508 static int hwa742_enable_plane(int plane, int enable)
513 hwa742.int_ctrl->enable_plane(plane, enable);
518 static int sync_handler(struct hwa742_request *req)
520 complete(req->par.sync);
524 static void hwa742_sync(void)
527 struct hwa742_request *req;
528 struct completion comp;
534 req->handler = sync_handler;
535 req->complete = NULL;
536 init_completion(&comp);
537 req->par.sync = ∁
539 list_add(&req->entry, &req_list);
540 submit_req_list(&req_list);
542 wait_for_completion(&comp);
547 static struct notifier_block *hwa742_client_list;
549 int hwa742_register_client(struct hwa742_notifier_block *hwa742_nb,
550 hwa742_notifier_callback_t callback,
555 DBGPRINT(1, "update_mode %d\n", hwa742.update_mode);
556 hwa742_nb->nb.notifier_call = (int (*)(struct notifier_block *,
557 unsigned long, void *))callback;
558 hwa742_nb->data = callback_data;
559 r = notifier_chain_register(&hwa742_client_list, &hwa742_nb->nb);
562 if (hwa742.update_mode == OMAPFB_MANUAL_UPDATE) {
563 DBGPRINT(1, "calling client list\n");
564 notifier_call_chain(&hwa742_client_list,
570 EXPORT_SYMBOL(hwa742_register_client);
572 int hwa742_unregister_client(struct hwa742_notifier_block *hwa742_nb)
574 return notifier_chain_unregister(&hwa742_client_list,
577 EXPORT_SYMBOL(hwa742_unregister_client);
579 static int hwa742_set_update_mode(enum omapfb_update_mode mode)
585 if (mode != OMAPFB_MANUAL_UPDATE && mode != OMAPFB_AUTO_UPDATE &&
586 mode != OMAPFB_UPDATE_DISABLED) {
591 if (mode == hwa742.update_mode)
594 printk(KERN_INFO "hwa742: setting update mode to %s\n",
595 mode == OMAPFB_UPDATE_DISABLED ? "disabled" :
596 (mode == OMAPFB_AUTO_UPDATE ? "auto" : "manual"));
598 switch (hwa742.update_mode) {
599 case OMAPFB_MANUAL_UPDATE:
600 notifier_call_chain(&hwa742_client_list,
601 HWA742_EVENT_DISABLED,
604 case OMAPFB_AUTO_UPDATE:
605 hwa742.stop_auto_update = 1;
606 del_timer_sync(&hwa742.auto_update_timer);
608 case OMAPFB_UPDATE_DISABLED:
612 hwa742.update_mode = mode;
614 hwa742.stop_auto_update = 0;
617 case OMAPFB_MANUAL_UPDATE:
618 notifier_call_chain(&hwa742_client_list,
622 case OMAPFB_AUTO_UPDATE:
623 hwa742_update_window_auto(0);
625 case OMAPFB_UPDATE_DISABLED:
634 static enum omapfb_update_mode hwa742_get_update_mode(void)
636 return hwa742.update_mode;
639 static unsigned long round_to_extif_ticks(unsigned long ps, int div)
641 int bus_tick = hwa742.extif_clk_period * div;
642 return (ps + bus_tick - 1) / bus_tick * bus_tick;
645 static int calc_reg_timing(unsigned long sysclk, int div)
647 struct extif_timings *t;
648 unsigned long systim;
650 /* CSOnTime 0, WEOnTime 2 ns, REOnTime 2 ns,
651 * AccessTime 2 ns + 12.2 ns (regs),
652 * WEOffTime = WEOnTime + 1 ns,
653 * REOffTime = REOnTime + 16 ns (regs),
654 * CSOffTime = REOffTime + 1 ns
655 * ReadCycle = 2ns + 2*SYSCLK (regs),
656 * WriteCycle = 2*SYSCLK + 2 ns,
657 * CSPulseWidth = 10 ns */
658 systim = 1000000000 / (sysclk / 1000);
659 DBGPRINT(1, "HWA742 systim %lu ps extif_clk_period %u ps"
660 "extif_clk_div %d\n", systim, hwa742.extif_clk_period, div);
662 t = &hwa742.reg_timings;
663 memset(t, 0, sizeof(*t));
666 t->we_on_time = round_to_extif_ticks(t->cs_on_time + 2000, div);
667 t->re_on_time = round_to_extif_ticks(t->cs_on_time + 2000, div);
668 t->access_time = round_to_extif_ticks(t->re_on_time + 12200, div);
669 t->we_off_time = round_to_extif_ticks(t->we_on_time + 1000, div);
670 t->re_off_time = round_to_extif_ticks(t->re_on_time + 16000, div);
671 t->cs_off_time = round_to_extif_ticks(t->re_off_time + 1000, div);
672 t->we_cycle_time = round_to_extif_ticks(2 * systim + 2000, div);
673 if (t->we_cycle_time < t->we_off_time)
674 t->we_cycle_time = t->we_off_time;
675 t->re_cycle_time = round_to_extif_ticks(2 * systim + 2000, div);
676 if (t->re_cycle_time < t->re_off_time)
677 t->re_cycle_time = t->re_off_time;
678 t->cs_pulse_width = 0;
680 DBGPRINT(1, "[reg]cson %d csoff %d reon %d reoff %d\n",
681 t->cs_on_time, t->cs_off_time, t->re_on_time, t->re_off_time);
682 DBGPRINT(1, "[reg]weon %d weoff %d recyc %d wecyc %d\n",
683 t->we_on_time, t->we_off_time, t->re_cycle_time,
685 DBGPRINT(1, "[reg]rdaccess %d cspulse %d\n",
686 t->access_time, t->cs_pulse_width);
688 return hwa742.extif->convert_timings(t);
691 static int calc_lut_timing(unsigned long sysclk, int div)
693 struct extif_timings *t;
694 unsigned long systim;
696 /* CSOnTime 0, WEOnTime 2 ns, REOnTime 2 ns,
697 * AccessTime 2 ns + 4 * SYSCLK + 26 (lut),
698 * WEOffTime = WEOnTime + 1 ns,
699 * REOffTime = REOnTime + 4*SYSCLK + 26 ns (lut),
700 * CSOffTime = REOffTime + 1 ns
701 * ReadCycle = 2ns + 4*SYSCLK + 26 ns (lut),
702 * WriteCycle = 2*SYSCLK + 2 ns,
703 * CSPulseWidth = 10 ns
705 systim = 1000000000 / (sysclk / 1000);
706 DBGPRINT(1, "HWA742 systim %lu ps extif_clk_period %u ps"
707 "extif_clk_div %d\n", systim, hwa742.extif_clk_period, div);
709 t = &hwa742.lut_timings;
710 memset(t, 0, sizeof(*t));
715 t->we_on_time = round_to_extif_ticks(t->cs_on_time + 2000, div);
716 t->re_on_time = round_to_extif_ticks(t->cs_on_time + 2000, div);
717 t->access_time = round_to_extif_ticks(t->re_on_time + 4 * systim +
719 t->we_off_time = round_to_extif_ticks(t->we_on_time + 1000, div);
720 t->re_off_time = round_to_extif_ticks(t->re_on_time + 4 * systim +
722 t->cs_off_time = round_to_extif_ticks(t->re_off_time + 1000, div);
723 t->we_cycle_time = round_to_extif_ticks(2 * systim + 2000, div);
724 if (t->we_cycle_time < t->we_off_time)
725 t->we_cycle_time = t->we_off_time;
726 t->re_cycle_time = round_to_extif_ticks(2000 + 4 * systim + 26000, div);
727 if (t->re_cycle_time < t->re_off_time)
728 t->re_cycle_time = t->re_off_time;
729 t->cs_pulse_width = 0;
731 DBGPRINT(1, "[lut]cson %d csoff %d reon %d reoff %d\n",
732 t->cs_on_time, t->cs_off_time, t->re_on_time, t->re_off_time);
733 DBGPRINT(1, "[lut]weon %d weoff %d recyc %d wecyc %d\n",
734 t->we_on_time, t->we_off_time, t->re_cycle_time,
736 DBGPRINT(1, "[lut]rdaccess %d cspulse %d\n",
737 t->access_time, t->cs_pulse_width);
739 return hwa742.extif->convert_timings(t);
742 static int calc_extif_timings(unsigned long sysclk)
747 hwa742.extif->get_clk_info(&hwa742.extif_clk_period, &max_clk_div);
748 for (div = 1; div < max_clk_div; div++) {
749 if (calc_reg_timing(sysclk, div) == 0)
752 if (div == max_clk_div)
755 for (div = 1; div < max_clk_div; div++) {
756 if (calc_lut_timing(sysclk, div) == 0)
760 if (div < max_clk_div)
764 pr_err("can't setup timings\n");
768 static unsigned long hwa742_get_caps(void)
770 return OMAPFB_CAPS_MANUAL_UPDATE;
773 static void hwa742_suspend(void)
775 hwa742.update_mode_before_suspend = hwa742.update_mode;
776 hwa742_set_update_mode(OMAPFB_UPDATE_DISABLED);
777 /* Enable sleep mode */
778 hwa742_write_reg(HWA742_POWER_SAVE, 1 << 1);
779 clk_disable(hwa742.sys_ck);
782 static void hwa742_resume(void)
784 if (clk_enable(hwa742.sys_ck) != 0)
785 pr_err("failed to enable SYS clock\n");
786 /* Disable sleep mode */
787 hwa742_write_reg(HWA742_POWER_SAVE, 0);
789 /* Loop until PLL output is stabilized */
790 if (hwa742_read_reg(HWA742_PLL_DIV_REG) & (1 << 7))
792 set_current_state(TASK_UNINTERRUPTIBLE);
793 schedule_timeout(msecs_to_jiffies(5));
795 hwa742_set_update_mode(hwa742.update_mode_before_suspend);
798 struct lcd_ctrl hwa742_ctrl;
800 static int hwa742_init(struct omapfb_device *fbdev, int ext_mode, int req_vram_size)
804 unsigned long sysfreq;
809 hwa742.sys_ck = clk_get(0, "bclk");
810 if (IS_ERR(hwa742.sys_ck)) {
811 pr_err("can't get SYS clock\n");
812 return PTR_ERR(hwa742.sys_ck);
815 if ((r = clk_enable(hwa742.sys_ck)) != 0) {
816 pr_err("can't enable SYS clock\n");
817 clk_put(hwa742.sys_ck);
821 BUG_ON(!fbdev->ext_if || !fbdev->int_ctrl);
823 hwa742.fbdev = fbdev;
824 hwa742.extif = fbdev->ext_if;
825 hwa742.int_ctrl = fbdev->int_ctrl;
827 spin_lock_init(&hwa742.req_lock);
829 if ((r = hwa742.int_ctrl->init(fbdev, 1, req_vram_size)) < 0)
832 if ((r = hwa742.extif->init()) < 0)
835 hwa742_ctrl.get_vram_layout = hwa742.int_ctrl->get_vram_layout;
836 hwa742_ctrl.mmap = hwa742.int_ctrl->mmap;
838 sysfreq = clk_get_rate(hwa742.sys_ck);
839 if ((r = calc_extif_timings(sysfreq)) < 0)
841 hwa742.extif->set_timings(&hwa742.reg_timings);
843 div = (hwa742_read_reg(HWA742_PLL_DIV_REG) & 0x3f) + 1;
845 nd = (hwa742_read_reg(HWA742_PLL_4_REG) & 0x7f) + 1;
847 if ((r = calc_extif_timings(sysfreq / div * nd)) < 0)
849 hwa742.extif->set_timings(&hwa742.reg_timings);
851 rev = hwa742_read_reg(HWA742_REV_CODE_REG);
852 if ((rev & 0xfc) != 0x80) {
853 pr_err("invalid revision %02x\n", rev);
858 conf = hwa742_read_reg(HWA742_CONFIG_REG);
859 pr_info(MODULE_NAME ": Epson HWA742 LCD controller rev. %d "
860 "initialized (CNF pins %x)\n", rev & 0x03, conf & 0x07);
862 if (!(hwa742_read_reg(HWA742_PLL_DIV_REG) & 0x80)) {
863 pr_err("controller not initialized by the bootloader\n");
868 hwa742.max_transmit_size = hwa742.extif->max_transmit_size;
870 hwa742.update_mode = OMAPFB_UPDATE_DISABLED;
872 hwa742.auto_update_window.x = 0;
873 hwa742.auto_update_window.y = 0;
874 hwa742.auto_update_window.width = fbdev->panel->x_res;
875 hwa742.auto_update_window.height = fbdev->panel->y_res;
876 hwa742.auto_update_window.format = 0;
878 init_timer(&hwa742.auto_update_timer);
879 hwa742.auto_update_timer.function = hwa742_update_window_auto;
880 hwa742.auto_update_timer.data = 0;
882 hwa742.prev_color_mode = -1;
883 hwa742.prev_flags = 0;
885 hwa742.fbdev = fbdev;
887 INIT_LIST_HEAD(&hwa742.free_req_list);
888 INIT_LIST_HEAD(&hwa742.pending_req_list);
889 for (i = 0; i < ARRAY_SIZE(hwa742.req_pool); i++)
890 list_add(&hwa742.req_pool[i].entry, &hwa742.free_req_list);
891 BUG_ON(i <= IRQ_REQ_POOL_SIZE);
892 sema_init(&hwa742.req_sema, i - IRQ_REQ_POOL_SIZE);
896 hwa742.extif->cleanup();
898 hwa742.int_ctrl->cleanup();
900 clk_disable(hwa742.sys_ck);
901 clk_put(hwa742.sys_ck);
905 static void hwa742_cleanup(void)
907 hwa742_set_update_mode(OMAPFB_UPDATE_DISABLED);
908 hwa742.extif->cleanup();
909 hwa742.int_ctrl->cleanup();
910 clk_disable(hwa742.sys_ck);
911 clk_put(hwa742.sys_ck);
914 struct lcd_ctrl hwa742_ctrl = {
917 .cleanup = hwa742_cleanup,
918 .get_caps = hwa742_get_caps,
919 .set_update_mode = hwa742_set_update_mode,
920 .get_update_mode = hwa742_get_update_mode,
921 .setup_plane = hwa742_setup_plane,
922 .enable_plane = hwa742_enable_plane,
923 .update_window = hwa742_update_window_async,
925 .suspend = hwa742_suspend,
926 .resume = hwa742_resume,