]>
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 * const argv
[])
134 out_8((u8
*) LCD_CMD_ADDR
, 0x01);
140 static int do_lcd_puts (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char * const argv
[])
143 return cmd_usage(cmdtp
);
150 static int do_lcd_putc (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char * const argv
[])
153 return cmd_usage(cmdtp
);
155 lcd_putc((char)argv
[1][0]);
160 static int do_lcd_cur (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char * const argv
[])
167 return cmd_usage(cmdtp
);
169 count
= simple_strtoul(argv
[1], NULL
, 16);
171 printf("unable to shift > 0x20\n");
175 dir
= simple_strtoul(argv
[2], NULL
, 16);
176 cur_addr
= in_8((u8
*) LCD_CMD_ADDR
);
180 if (addr_flag
== 0x80) {
181 if (count
>= (cur_addr
& 0xf)) {
182 out_8((u8
*) LCD_CMD_ADDR
, 0x80);
187 if (count
>= ((cur_addr
& 0x0f) + 0x0f)) {
188 out_8((u8
*) LCD_CMD_ADDR
, 0x80);
192 } else if (count
>= ( cur_addr
& 0xf)) {
193 count
-= cur_addr
& 0xf ;
194 out_8((u8
*) LCD_CMD_ADDR
, 0x80 | 0xf);
200 if (addr_flag
== 0x80) {
201 if (count
>= (0x1f - (cur_addr
& 0xf))) {
204 out_8((u8
*) LCD_CMD_ADDR
, 0xc0 | 0xf);
206 } else if ((count
+ (cur_addr
& 0xf ))>= 0x0f) {
207 count
= count
+ (cur_addr
& 0xf) - 0x0f;
209 out_8((u8
*) LCD_CMD_ADDR
, 0xc0);
212 } else if ((count
+ (cur_addr
& 0xf )) >= 0x0f) {
214 out_8((u8
*) LCD_CMD_ADDR
, 0xC0 | 0x0F);
220 out_8((u8
*) LCD_CMD_ADDR
, 0x10);
222 out_8((u8
*) LCD_CMD_ADDR
, 0x14);
230 lcd_cls
, 1, 1, do_lcd_clear
,
236 lcd_puts
, 2, 1, do_lcd_puts
,
237 "display string on lcd",
238 "<string> - <string> to be displayed"
242 lcd_putc
, 2, 1, do_lcd_putc
,
243 "display char on lcd",
244 "<char> - <char> to be displayed"
248 lcd_cur
, 3, 1, do_lcd_cur
,
249 "shift cursor on lcd",
250 "<count> <dir> - shift cursor on lcd <count> times, direction is <dir> \n"
252 " <dir> - 0=backward 1=forward"