Add MPIO HD200 port - new files
[maemo-rb.git] / firmware / target / coldfire / mpio / hd200 / lcd-as-hd200.S
blobadd9f694de15ad8727d78ab32dc360b6b6a16fad
1 /***************************************************************************
2  *             __________               __   ___.
3  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7  *                     \/            \/     \/    \/            \/
8  * $Id:$
9  *
10  * Copyright (C) 2010 Marcin Bukat
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18  * KIND, either express or implied.
19  *
20  ****************************************************************************/
22 #include "config.h" 
23 #include "cpu.h"
26 #define LCD_BASE_ADDRESS 0xf0000000
28     .section    .icode,"ax",@progbits
30     .align      2
31     .global     lcd_write_command
32     .type       lcd_write_command,@function
34 lcd_write_command:
35     move.l  (4, %sp), %d0
36     move.w  %d0, LCD_BASE_ADDRESS       /* data is 1byte but CF uses word
37                                          * transfers only */
38     rts
39 .wc_end:
40     .size   lcd_write_command,.wc_end-lcd_write_command
43     .align      2
44     .global     lcd_write_command_e
45     .type       lcd_write_command_e,@function
47 lcd_write_command_e:
48     lea.l   LCD_BASE_ADDRESS, %a0
50     move.l  (4, %sp), %d0       /* Command */
51     move.w  %d0, (%a0)         
52     move.l  (8, %sp), %d0       /* Data */
53     move.w  %d0, (%a0)          /* Write to LCD */
55     rts
56 .wce_end:
57     .size   lcd_write_command_e,.wce_end-lcd_write_command_e
60     .align      2
61     .global     lcd_write_data
62     .type       lcd_write_data,@function
64 /* PIXELFORMAT = VERTICAL_INTERLEAVED
65  * this means that data is packed verticaly in 8 pixels columns
66  * first byte is lsb of 2bit color in column
67  * second byte is msb of 2bit color in column
68  * so one word of data equals 8 pixels i 2bits color depth packed
69  * verticaly
70  */
71 lcd_write_data:
72     movem.l (4, %sp), %a0            /* Data pointer */
73     move.l  (8, %sp), %d0            /* Length i in words */
74     lea     LCD_BASE_ADDRESS+2, %a1  /* LCD data port address */
76     btst    #0, %d0    /* longwords multiply? */
77     beq    .l_write
79 .w_write:
80     move.w  (%a0)+, %d1  /* load data         3 cycles*/
81     move.w  %d1, (%a1)   /* first byte        1 cycle*/
82     lsr.l   #8, %d1      /* load second byte  1 cycle*/
83     move.w  %d1, (%a1)   /* transfer          1 cycle*/
84     subq.l  #1, %d0      /* decrement counter 1 cycle*/
85     beq     .write_end   
86     
87 .l_write:
88     move.l  (%a0)+, %d1  /* load data         2 cycles*/
89     swap    %d1          /*                   1 cycle */
90     move.w  %d1, (%a1)   /* first byte        1 cycle*/
91     lsr.l   #8, %d1      /*                   1 cycle */
92     move.w  %d1, (%a1)   /* second byte       1 cycle*/
93     lsr.l   #8, %d1      /*                   1 cycle */
94     move.w  %d1, (%a1)   /* third byte        1 cycle*/
95     lsr.l   #8, %d1      /*                   1 cycle */
96     move.w  %d1, (%a1)   /* forth byte        1 cycle*/
97     subq.l  #2, %d0      /* decrement counter 1 cycle*/
98     bne     .l_write
100 .write_end:
101     rts
102     .size   lcd_write_data,.wd_end-lcd_write_data