cmd_tb5200.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  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. * TB5200 specific functions
  25. */
  26. /*#define DEBUG*/
  27. #include <common.h>
  28. #include <command.h>
  29. #if defined(CONFIG_CMD_BSP)
  30. #if defined (CONFIG_TB5200)
  31. #define SM501_PANEL_DISPLAY_CONTROL 0x00080000UL
  32. static void led_init(void)
  33. {
  34. struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
  35. /* configure timer 4 for simple GPIO output */
  36. gpt->gpt4.emsr |= 0x00000024;
  37. }
  38. int cmd_led(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  39. {
  40. struct mpc5xxx_gpt_0_7 *gpt = (struct mpc5xxx_gpt_0_7 *)MPC5XXX_GPT;
  41. led_init();
  42. if (strcmp (argv[1], "on") == 0) {
  43. debug ("switch status LED on\n");
  44. gpt->gpt4.emsr |= (1 << 4);
  45. } else if (strcmp (argv[1], "off") == 0) {
  46. debug ("switch status LED off\n");
  47. gpt->gpt4.emsr &= ~(1 << 4);
  48. } else {
  49. printf ("Usage:\nled on/off\n");
  50. return 1;
  51. }
  52. return 0;
  53. }
  54. static void sm501_backlight (unsigned int state)
  55. {
  56. if (state == 1) {
  57. *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) |=
  58. (1 << 26) | (1 << 27);
  59. } else if (state == 0)
  60. *(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) &=
  61. ~((1 << 26) | (1 << 27));
  62. }
  63. int cmd_backlight(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  64. {
  65. if (strcmp (argv[1], "on") == 0) {
  66. debug ("switch backlight on\n");
  67. sm501_backlight (1);
  68. } else if (strcmp (argv[1], "off") == 0) {
  69. debug ("switch backlight off\n");
  70. sm501_backlight (0);
  71. } else {
  72. printf ("Usage:\nbacklight on/off\n");
  73. return 1;
  74. }
  75. return 0;
  76. }
  77. U_BOOT_CMD(
  78. led , 2, 1, cmd_led,
  79. "led - switch status LED on or off\n",
  80. "on/off\n"
  81. );
  82. U_BOOT_CMD(
  83. backlight , 2, 1, cmd_backlight,
  84. "backlight - switch backlight on or off\n",
  85. "on/off\n"
  86. );
  87. #endif /* CONFIG_STK52XX */
  88. #endif