Wolfgang Denk | b87dfd2 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2005 - 2006 |
| 3 | * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | b87dfd2 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * TB5200 specific functions |
| 10 | */ |
| 11 | /*#define DEBUG*/ |
| 12 | |
| 13 | #include <common.h> |
| 14 | #include <command.h> |
| 15 | |
Jon Loeliger | ab3abcb | 2007-07-09 18:45:16 -0500 | [diff] [blame] | 16 | #if defined(CONFIG_CMD_BSP) |
Wolfgang Denk | b87dfd2 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 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 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 29 | int cmd_led(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Wolfgang Denk | b87dfd2 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 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 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 59 | int cmd_backlight(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Wolfgang Denk | b87dfd2 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 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, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 77 | "switch status LED on or off", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 78 | "on/off" |
Wolfgang Denk | b87dfd2 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 79 | ); |
| 80 | |
| 81 | U_BOOT_CMD( |
| 82 | backlight , 2, 1, cmd_backlight, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 83 | "switch backlight on or off", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 84 | "on/off" |
Wolfgang Denk | b87dfd2 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 85 | ); |
| 86 | |
| 87 | #endif /* CONFIG_STK52XX */ |
Jon Loeliger | d39b574 | 2007-07-10 10:48:22 -0500 | [diff] [blame] | 88 | #endif |