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.
 
 
 
 
 
 

77 lines
1.5 KiB

  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * arch/arm/mach-imx/generic.c
  4. *
  5. * author: Sascha Hauer
  6. * Created: april 20th, 2004
  7. * Copyright: Synertronixx GmbH
  8. *
  9. * Common code for i.MX machines
  10. */
  11. #include <common.h>
  12. #ifdef CONFIG_IMX
  13. #include <asm/arch/imx-regs.h>
  14. void imx_gpio_mode(int gpio_mode)
  15. {
  16. unsigned int pin = gpio_mode & GPIO_PIN_MASK;
  17. unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> 5;
  18. unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> 10;
  19. unsigned int tmp;
  20. /* Pullup enable */
  21. if(gpio_mode & GPIO_PUEN)
  22. PUEN(port) |= (1<<pin);
  23. else
  24. PUEN(port) &= ~(1<<pin);
  25. /* Data direction */
  26. if(gpio_mode & GPIO_OUT)
  27. DDIR(port) |= 1<<pin;
  28. else
  29. DDIR(port) &= ~(1<<pin);
  30. /* Primary / alternate function */
  31. if(gpio_mode & GPIO_AF)
  32. GPR(port) |= (1<<pin);
  33. else
  34. GPR(port) &= ~(1<<pin);
  35. /* use as gpio? */
  36. if( ocr == 3 )
  37. GIUS(port) |= (1<<pin);
  38. else
  39. GIUS(port) &= ~(1<<pin);
  40. /* Output / input configuration */
  41. /* FIXME: I'm not very sure about OCR and ICONF, someone
  42. * should have a look over it
  43. */
  44. if(pin<16) {
  45. tmp = OCR1(port);
  46. tmp &= ~( 3<<(pin*2));
  47. tmp |= (ocr << (pin*2));
  48. OCR1(port) = tmp;
  49. if( gpio_mode & GPIO_AOUT )
  50. ICONFA1(port) &= ~( 3<<(pin*2));
  51. if( gpio_mode & GPIO_BOUT )
  52. ICONFB1(port) &= ~( 3<<(pin*2));
  53. } else {
  54. tmp = OCR2(port);
  55. tmp &= ~( 3<<((pin-16)*2));
  56. tmp |= (ocr << ((pin-16)*2));
  57. OCR2(port) = tmp;
  58. if( gpio_mode & GPIO_AOUT )
  59. ICONFA2(port) &= ~( 3<<((pin-16)*2));
  60. if( gpio_mode & GPIO_BOUT )
  61. ICONFB2(port) &= ~( 3<<((pin-16)*2));
  62. }
  63. }
  64. #endif /* CONFIG_IMX */