]>
Commit | Line | Data |
---|---|---|
b87dfd28 WD |
1 | /* |
2 | * (C) Copyright 2005 - 2006 | |
3 | * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de. | |
4 | * | |
1a459660 | 5 | * SPDX-License-Identifier: GPL-2.0+ |
b87dfd28 WD |
6 | */ |
7 | ||
8 | /* | |
9 | * TB5200 specific functions | |
10 | */ | |
11 | /*#define DEBUG*/ | |
12 | ||
13 | #include <common.h> | |
14 | #include <command.h> | |
15 | ||
ab3abcba | 16 | #if defined(CONFIG_CMD_BSP) |
b87dfd28 WD |
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 | ||
54841ab5 | 29 | int cmd_led(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
b87dfd28 WD |
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 | ||
54841ab5 | 59 | int cmd_backlight(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
b87dfd28 WD |
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, | |
2fb2604d | 77 | "switch status LED on or off", |
a89c33db | 78 | "on/off" |
b87dfd28 WD |
79 | ); |
80 | ||
81 | U_BOOT_CMD( | |
82 | backlight , 2, 1, cmd_backlight, | |
2fb2604d | 83 | "switch backlight on or off", |
a89c33db | 84 | "on/off" |
b87dfd28 WD |
85 | ); |
86 | ||
87 | #endif /* CONFIG_STK52XX */ | |
d39b5741 | 88 | #endif |