gpio.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2012 Vikram Narayananan
  3. * <vikram186@gmail.com>
  4. * (C) Copyright 2012,2015 Stephen Warren
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef _BCM2835_GPIO_H_
  9. #define _BCM2835_GPIO_H_
  10. #ifndef CONFIG_BCM2835
  11. #define BCM2835_GPIO_BASE 0x3f200000
  12. #else
  13. #define BCM2835_GPIO_BASE 0x20200000
  14. #endif
  15. #define BCM2835_GPIO_COUNT 54
  16. #define BCM2835_GPIO_FSEL_MASK 0x7
  17. #define BCM2835_GPIO_INPUT 0x0
  18. #define BCM2835_GPIO_OUTPUT 0x1
  19. #define BCM2835_GPIO_ALT0 0x4
  20. #define BCM2835_GPIO_ALT1 0x5
  21. #define BCM2835_GPIO_ALT2 0x6
  22. #define BCM2835_GPIO_ALT3 0x7
  23. #define BCM2835_GPIO_ALT4 0x3
  24. #define BCM2835_GPIO_ALT5 0x2
  25. #define BCM2835_GPIO_COMMON_BANK(gpio) ((gpio < 32) ? 0 : 1)
  26. #define BCM2835_GPIO_COMMON_SHIFT(gpio) (gpio & 0x1f)
  27. #define BCM2835_GPIO_FSEL_BANK(gpio) (gpio / 10)
  28. #define BCM2835_GPIO_FSEL_SHIFT(gpio) ((gpio % 10) * 3)
  29. struct bcm2835_gpio_regs {
  30. u32 gpfsel[6];
  31. u32 reserved1;
  32. u32 gpset[2];
  33. u32 reserved2;
  34. u32 gpclr[2];
  35. u32 reserved3;
  36. u32 gplev[2];
  37. u32 reserved4;
  38. u32 gpeds[2];
  39. u32 reserved5;
  40. u32 gpren[2];
  41. u32 reserved6;
  42. u32 gpfen[2];
  43. u32 reserved7;
  44. u32 gphen[2];
  45. u32 reserved8;
  46. u32 gplen[2];
  47. u32 reserved9;
  48. u32 gparen[2];
  49. u32 reserved10;
  50. u32 gppud;
  51. u32 gppudclk[2];
  52. };
  53. /**
  54. * struct bcm2835_gpio_platdata - GPIO platform description
  55. *
  56. * @base: Base address of GPIO controller
  57. */
  58. struct bcm2835_gpio_platdata {
  59. unsigned long base;
  60. };
  61. #endif /* _BCM2835_GPIO_H_ */