gpio.h 938 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2022 Starfive, Inc.
  4. * Author: yanhong <yanhong.wang@starfivetech.com>
  5. *
  6. */
  7. #ifndef _GPIO_STARFIVE_H_
  8. #define _GPIO_STARFIVE_H_
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif /* __cplusplus */
  12. #define GPIO_NUM_SHIFT 2 /*one dword include 4 gpios*/
  13. #define GPIO_BYTE_SHIFT 3
  14. #define GPIO_INDEX_MASK 0x3
  15. #define GPIO_DOEN_MASK 0x3f
  16. #define GPIO_DOUT_MASK 0x7f
  17. #define GPIO_DIN_MASK 0x7f
  18. #define NR_GPIOS 64
  19. #define GPIO_OFFSET(gpio) \
  20. (((gpio) >> GPIO_NUM_SHIFT) << GPIO_NUM_SHIFT)
  21. #define GPIO_SHIFT(gpio) \
  22. (((gpio) & GPIO_INDEX_MASK) << GPIO_BYTE_SHIFT)
  23. enum gpio_state {
  24. LOW,
  25. HIGH
  26. };
  27. #define GPIO_DOEN 0x0
  28. #define GPIO_DOUT 0x40
  29. #define GPIO_DIN 0x80
  30. #define GPIO_EN 0xdc
  31. #define GPIO_LOW_IE 0x100
  32. #define GPIO_HIGH_IE 0x104
  33. /* Details about a GPIO bank */
  34. struct starfive_gpio_platdata {
  35. void *base;
  36. };
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40. #endif /* _GPIO_STARFIVE_H_ */