blob: 876258d8f7d7409b2d0c0d37ca15bb050abe196f [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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Wolfgang Denkb87dfd22006-07-19 13:50:38 +02006 */
7
8/*
9 * TB5200 specific functions
10 */
11/*#define DEBUG*/
12
13#include <common.h>
14#include <command.h>
15
Jon Loeligerab3abcb2007-07-09 18:45:16 -050016#if defined(CONFIG_CMD_BSP)
Wolfgang Denkb87dfd22006-07-19 13:50:38 +020017#if defined (CONFIG_TB5200)
18
19#define SM501_PANEL_DISPLAY_CONTROL 0x00080000UL
20
21static 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
Wolfgang Denk54841ab2010-06-28 22:00:46 +020029int cmd_led(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denkb87dfd22006-07-19 13:50:38 +020030{
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
49static 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
Wolfgang Denk54841ab2010-06-28 22:00:46 +020059int cmd_backlight(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denkb87dfd22006-07-19 13:50:38 +020060{
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
75U_BOOT_CMD(
76 led , 2, 1, cmd_led,
Peter Tyser2fb26042009-01-27 18:03:12 -060077 "switch status LED on or off",
Wolfgang Denka89c33d2009-05-24 17:06:54 +020078 "on/off"
Wolfgang Denkb87dfd22006-07-19 13:50:38 +020079);
80
81U_BOOT_CMD(
82 backlight , 2, 1, cmd_backlight,
Peter Tyser2fb26042009-01-27 18:03:12 -060083 "switch backlight on or off",
Wolfgang Denka89c33d2009-05-24 17:06:54 +020084 "on/off"
Wolfgang Denkb87dfd22006-07-19 13:50:38 +020085 );
86
87#endif /* CONFIG_STK52XX */
Jon Loeligerd39b5742007-07-10 10:48:22 -050088#endif