b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2015 Marvell International Ltd. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * This file is subject to the terms and conditions of the GNU General Public |
| 6 | * License. See the file COPYING in the main directory of this archive for |
| 7 | * more details. |
| 8 | */ |
| 9 | #include <common.h> |
| 10 | #include <command.h> |
| 11 | #include <asm/arch/pxa1826fb.h> |
| 12 | |
| 13 | enum lcd_cmd { |
| 14 | LCD_WRITE, |
| 15 | LCD_READ, |
| 16 | LCD_ONOFF, |
| 17 | LCD_LOGO |
| 18 | }; |
| 19 | |
| 20 | static int lcd_io(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 21 | { |
| 22 | unsigned int data = 0; |
| 23 | unsigned int addr = 0; |
| 24 | unsigned int on = 0; |
| 25 | enum lcd_cmd sub_cmd; |
| 26 | const char *str_cmd; |
| 27 | int i = 0; |
| 28 | |
| 29 | str_cmd = argv[1]; |
| 30 | /* parse the operation */ |
| 31 | switch (*str_cmd) { |
| 32 | case 'w': |
| 33 | sub_cmd = LCD_WRITE; |
| 34 | break; |
| 35 | case 'r': |
| 36 | sub_cmd = LCD_READ; |
| 37 | break; |
| 38 | case 'o': |
| 39 | sub_cmd = LCD_ONOFF; |
| 40 | break; |
| 41 | case 'l': |
| 42 | sub_cmd = LCD_LOGO; |
| 43 | break; |
| 44 | default: |
| 45 | return CMD_RET_USAGE; |
| 46 | } |
| 47 | |
| 48 | if (sub_cmd == LCD_WRITE) { |
| 49 | printf("## LCD write to panel\n"); |
| 50 | addr = simple_strtoul(argv[2], NULL, 32); |
| 51 | printf("cmd: 0x%08X\n", addr); |
| 52 | lcd_send_cmd(addr); |
| 53 | for (i = 3; i < argc; i++) { |
| 54 | data = simple_strtoul(argv[i], NULL, 32); |
| 55 | lcd_send_data(data); |
| 56 | printf("data: 0x%08X\n", data); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | if (sub_cmd == LCD_READ) { |
| 61 | printf("## LCD read from panel\n"); |
| 62 | addr = simple_strtoul(argv[2], NULL, 32); |
| 63 | data = (unsigned int)pxa1826fb_read((unsigned short)addr); |
| 64 | printf("cmd: 0x%08X\n", addr); |
| 65 | printf("data: 0x%08X\n", data); |
| 66 | } |
| 67 | |
| 68 | if (sub_cmd == LCD_ONOFF) { |
| 69 | printf("## LCD panel on/off\n"); |
| 70 | on = simple_strtoul(argv[2], NULL, 32); |
| 71 | lcd_panel_on(on); |
| 72 | } |
| 73 | |
| 74 | if (sub_cmd == LCD_LOGO) { |
| 75 | printf("## LCD show logo\n"); |
| 76 | lcd_show_logo(); |
| 77 | } |
| 78 | |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | /***************************************************/ |
| 83 | |
| 84 | U_BOOT_CMD( |
| 85 | lcd, CONFIG_SYS_MAXARGS, 1, lcd_io, |
| 86 | "pxa1826 lcd operation", |
| 87 | "[r/w] [command] [value]\n" |
| 88 | " - with <r/w> argument: read/write operation\n" |
| 89 | " - with <command> argument: specify the command value\n" |
| 90 | " - with <value> argument: specify the data to write to panel\n" |
| 91 | " [o] [on/off] turn on/off panel\n" |
| 92 | " on_off: 0 -- off 1 -- on\n" |
| 93 | " [l] -- display boot up logo\n" |
| 94 | ); |