]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/amcc/taihu/lcd.c
2 * See file CREDITS for list of people who contributed to this
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #define LCD_CMD_ADDR 0x50100002
28 #define LCD_DATA_ADDR 0x50100003
29 #define LCD_BLK_CTRL CPLD_REG1_ADDR
31 static char *amcc_logo
= "AMCC 405EP TAIHU EVALUATION KIT";
32 static int addr_flag
= 0x80;
34 static void lcd_bl_ctrl(char val
)
36 out_8((u8
*) LCD_BLK_CTRL
, in_8((u8
*) LCD_BLK_CTRL
) | val
);
39 static void lcd_putc(int val
)
45 if ((in_8((u8
*) LCD_CMD_ADDR
) & 0x80) != 0x80) { /*BF = 1 ?*/
52 if (in_8((u8
*) LCD_CMD_ADDR
) & 0x80) {
53 printf("LCD is busy\n");
57 addr
= in_8((u8
*) LCD_CMD_ADDR
);
59 if ((addr
!= 0) && (addr
% 0x10 == 0)) {
61 out_8((u8
*) LCD_CMD_ADDR
, addr_flag
);
65 out_8((u8
*) LCD_DATA_ADDR
, val
);
69 static void lcd_puts(char *s
)
75 if ((in_8((u8
*) LCD_CMD_ADDR
) & 0x80) != 0x80) { /*BF = 1 ?*/
82 if (in_8((u8
*) LCD_CMD_ADDR
) & 0x80) {
83 printf("LCD is busy\n");
91 static void lcd_put_logo(void)
97 if ((in_8((u8
*) LCD_CMD_ADDR
) & 0x80) != 0x80) { /*BF = 1 ?*/
104 if (in_8((u8
*) LCD_CMD_ADDR
) & 0x80) {
105 printf("LCD is busy\n");
109 out_8((u8
*) LCD_CMD_ADDR
, 0x80);
117 out_8((u8
*) LCD_CMD_ADDR
, 0x38); /* set function:8-bit,2-line,5x7 font type */
119 out_8((u8
*) LCD_CMD_ADDR
, 0x0f); /* set display on,cursor on,blink on */
121 out_8((u8
*) LCD_CMD_ADDR
, 0x01); /* display clear */
123 out_8((u8
*) LCD_CMD_ADDR
, 0x06); /* set entry */
125 lcd_bl_ctrl(0x02); /* set backlight on */
132 static int do_lcd_clear (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
134 out_8((u8
*) LCD_CMD_ADDR
, 0x01);
140 static int do_lcd_puts (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
143 printf("%s", cmdtp
->usage
);
151 static int do_lcd_putc (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
154 printf("%s", cmdtp
->usage
);
157 lcd_putc((char)argv
[1][0]);
162 static int do_lcd_cur (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
169 printf("%s", cmdtp
->usage
);
173 count
= simple_strtoul(argv
[1], NULL
, 16);
175 printf("unable to shift > 0x20\n");
179 dir
= simple_strtoul(argv
[2], NULL
, 16);
180 cur_addr
= in_8((u8
*) LCD_CMD_ADDR
);
184 if (addr_flag
== 0x80) {
185 if (count
>= (cur_addr
& 0xf)) {
186 out_8((u8
*) LCD_CMD_ADDR
, 0x80);
191 if (count
>= ((cur_addr
& 0x0f) + 0x0f)) {
192 out_8((u8
*) LCD_CMD_ADDR
, 0x80);
196 } else if (count
>= ( cur_addr
& 0xf)) {
197 count
-= cur_addr
& 0xf ;
198 out_8((u8
*) LCD_CMD_ADDR
, 0x80 | 0xf);
204 if (addr_flag
== 0x80) {
205 if (count
>= (0x1f - (cur_addr
& 0xf))) {
208 out_8((u8
*) LCD_CMD_ADDR
, 0xc0 | 0xf);
210 } else if ((count
+ (cur_addr
& 0xf ))>= 0x0f) {
211 count
= count
+ (cur_addr
& 0xf) - 0x0f;
213 out_8((u8
*) LCD_CMD_ADDR
, 0xc0);
216 } else if ((count
+ (cur_addr
& 0xf )) >= 0x0f) {
218 out_8((u8
*) LCD_CMD_ADDR
, 0xC0 | 0x0F);
224 out_8((u8
*) LCD_CMD_ADDR
, 0x10);
226 out_8((u8
*) LCD_CMD_ADDR
, 0x14);
234 lcd_cls
, 1, 1, do_lcd_clear
,
235 "lcd_cls - lcd clear display\n",
240 lcd_puts
, 2, 1, do_lcd_puts
,
241 "lcd_puts - display string on lcd\n",
242 "<string> - <string> to be displayed\n"
246 lcd_putc
, 2, 1, do_lcd_putc
,
247 "lcd_putc - display char on lcd\n",
248 "<char> - <char> to be displayed\n"
252 lcd_cur
, 3, 1, do_lcd_cur
,
253 "lcd_cur - shift cursor on lcd\n",
254 "<count> <dir> - shift cursor on lcd <count> times, direction is <dir> \n"
256 " <dir> - 0=backward 1=forward\n"