Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

86 lines
1.8 KiB

  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2010, 2009 Matthias Kaehlcke <matthias@kaehlcke.net>
  4. */
  5. #include <asm/io.h>
  6. #include <asm/arch/ep93xx.h>
  7. #include <config.h>
  8. #include <status_led.h>
  9. static uint8_t saved_state[2] = {CONFIG_LED_STATUS_OFF, CONFIG_LED_STATUS_OFF};
  10. static uint32_t gpio_pin[2] = {1 << CONFIG_LED_STATUS_GREEN,
  11. 1 << CONFIG_LED_STATUS_RED};
  12. static inline void switch_LED_on(uint8_t led)
  13. {
  14. register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
  15. writel(readl(&gpio->pedr) | gpio_pin[led], &gpio->pedr);
  16. saved_state[led] = CONFIG_LED_STATUS_ON;
  17. }
  18. static inline void switch_LED_off(uint8_t led)
  19. {
  20. register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
  21. writel(readl(&gpio->pedr) & ~gpio_pin[led], &gpio->pedr);
  22. saved_state[led] = CONFIG_LED_STATUS_OFF;
  23. }
  24. void red_led_on(void)
  25. {
  26. switch_LED_on(CONFIG_LED_STATUS_RED);
  27. }
  28. void red_led_off(void)
  29. {
  30. switch_LED_off(CONFIG_LED_STATUS_RED);
  31. }
  32. void green_led_on(void)
  33. {
  34. switch_LED_on(CONFIG_LED_STATUS_GREEN);
  35. }
  36. void green_led_off(void)
  37. {
  38. switch_LED_off(CONFIG_LED_STATUS_GREEN);
  39. }
  40. void __led_init(led_id_t mask, int state)
  41. {
  42. __led_set(mask, state);
  43. }
  44. void __led_toggle(led_id_t mask)
  45. {
  46. if (CONFIG_LED_STATUS_RED == mask) {
  47. if (CONFIG_LED_STATUS_ON == saved_state[CONFIG_LED_STATUS_RED])
  48. red_led_off();
  49. else
  50. red_led_on();
  51. } else if (CONFIG_LED_STATUS_GREEN == mask) {
  52. if (CONFIG_LED_STATUS_ON ==
  53. saved_state[CONFIG_LED_STATUS_GREEN])
  54. green_led_off();
  55. else
  56. green_led_on();
  57. }
  58. }
  59. void __led_set(led_id_t mask, int state)
  60. {
  61. if (CONFIG_LED_STATUS_RED == mask) {
  62. if (CONFIG_LED_STATUS_ON == state)
  63. red_led_on();
  64. else
  65. red_led_off();
  66. } else if (CONFIG_LED_STATUS_GREEN == mask) {
  67. if (CONFIG_LED_STATUS_ON == state)
  68. green_led_on();
  69. else
  70. green_led_off();
  71. }
  72. }