]> git.ipfire.org Git - thirdparty/u-boot.git/blob - board/tqc/tqm5200/cmd_tb5200.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[thirdparty/u-boot.git] / board / tqc / tqm5200 / cmd_tb5200.c
1 /*
2 * (C) Copyright 2005 - 2006
3 * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de.
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8 /*
9 * TB5200 specific functions
10 */
11 /*#define DEBUG*/
12
13 #include <common.h>
14 #include <command.h>
15
16 #if defined(CONFIG_CMD_BSP)
17 #if defined (CONFIG_TB5200)
18
19 #define SM501_PANEL_DISPLAY_CONTROL 0x00080000UL
20
21 static void led_init(void)
22 {
23 struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
24
25 /* configure timer 4 for simple GPIO output */
26 gpt->gpt4.emsr |= 0x00000024;
27 }
28
29 int cmd_led(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
30 {
31 struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
32
33 led_init();
34
35 if (strcmp (argv[1], "on") == 0) {
36 debug ("switch status LED on\n");
37 gpt->gpt4.emsr |= (1 << 4);
38 } else if (strcmp (argv[1], "off") == 0) {
39 debug ("switch status LED off\n");
40 gpt->gpt4.emsr &= ~(1 << 4);
41 } else {
42 printf ("Usage:\nled on/off\n");
43 return 1;
44 }
45
46 return 0;
47 }
48
49 static void sm501_backlight (unsigned int state)
50 {
51 if (state == 1) {
52 *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) |=
53 (1 << 26) | (1 << 27);
54 } else if (state == 0)
55 *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) &=
56 ~((1 << 26) | (1 << 27));
57 }
58
59 int cmd_backlight(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
60 {
61 if (strcmp (argv[1], "on") == 0) {
62 debug ("switch backlight on\n");
63 sm501_backlight (1);
64 } else if (strcmp (argv[1], "off") == 0) {
65 debug ("switch backlight off\n");
66 sm501_backlight (0);
67 } else {
68 printf ("Usage:\nbacklight on/off\n");
69 return 1;
70 }
71
72 return 0;
73 }
74
75 U_BOOT_CMD(
76 led , 2, 1, cmd_led,
77 "switch status LED on or off",
78 "on/off"
79 );
80
81 U_BOOT_CMD(
82 backlight , 2, 1, cmd_backlight,
83 "switch backlight on or off",
84 "on/off"
85 );
86
87 #endif /* CONFIG_STK52XX */
88 #endif