blob: b9c9e7e194e3dfe468a2526397e0523798eb21c3 [file] [log] [blame]
Wolfgang Denkb87dfd22006-07-19 13:50:38 +02001/*
2 * (C) Copyright 2005 - 2006
3 * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*
25 * TB5200 specific functions
26 */
27/*#define DEBUG*/
28
29#include <common.h>
30#include <command.h>
31
Jon Loeligerab3abcb2007-07-09 18:45:16 -050032#if defined(CONFIG_CMD_BSP)
Wolfgang Denkb87dfd22006-07-19 13:50:38 +020033#if defined (CONFIG_TB5200)
34
35#define SM501_PANEL_DISPLAY_CONTROL 0x00080000UL
36
37static void led_init(void)
38{
39 struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
40
41 /* configure timer 4 for simple GPIO output */
42 gpt->gpt4.emsr |= 0x00000024;
43}
44
45int cmd_led(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
46{
47 struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
48
49 led_init();
50
51 if (strcmp (argv[1], "on") == 0) {
52 debug ("switch status LED on\n");
53 gpt->gpt4.emsr |= (1 << 4);
54 } else if (strcmp (argv[1], "off") == 0) {
55 debug ("switch status LED off\n");
56 gpt->gpt4.emsr &= ~(1 << 4);
57 } else {
58 printf ("Usage:\nled on/off\n");
59 return 1;
60 }
61
62 return 0;
63}
64
65static void sm501_backlight (unsigned int state)
66{
67 if (state == 1) {
68 *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) |=
69 (1 << 26) | (1 << 27);
70 } else if (state == 0)
71 *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) &=
72 ~((1 << 26) | (1 << 27));
73}
74
75int cmd_backlight(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
76{
77 if (strcmp (argv[1], "on") == 0) {
78 debug ("switch backlight on\n");
79 sm501_backlight (1);
80 } else if (strcmp (argv[1], "off") == 0) {
81 debug ("switch backlight off\n");
82 sm501_backlight (0);
83 } else {
84 printf ("Usage:\nbacklight on/off\n");
85 return 1;
86 }
87
88 return 0;
89}
90
91U_BOOT_CMD(
92 led , 2, 1, cmd_led,
Peter Tyser2fb26042009-01-27 18:03:12 -060093 "switch status LED on or off",
Wolfgang Denkb87dfd22006-07-19 13:50:38 +020094 "on/off\n"
95);
96
97U_BOOT_CMD(
98 backlight , 2, 1, cmd_backlight,
Peter Tyser2fb26042009-01-27 18:03:12 -060099 "switch backlight on or off",
Wolfgang Denkb87dfd22006-07-19 13:50:38 +0200100 "on/off\n"
101 );
102
103#endif /* CONFIG_STK52XX */
Jon Loeligerd39b5742007-07-10 10:48:22 -0500104#endif