bf16-gpiodevice.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef BF16_GPIODEVICE_H
  2. #define BF16_GPIODEVICE_H
  3. #include "bf16-device.h"
  4. #define GPIO_BUFFER_SIZE 64
  5. /* GPIO/CTRL function types */
  6. #define GPIO0_INDEX 0
  7. #define GPIO1_INDEX 1
  8. #define GPIO2_INDEX 2
  9. #define GPIO3_INDEX 3
  10. #define MAX_GPIO_INDEX 4
  11. #define GPIO_SIZE 0x2000
  12. #define GPIO0_START_ADDR 0x44E07000
  13. #define GPIO1_START_ADDR 0x4804C000
  14. #define GPIO2_START_ADDR 0x481AC000
  15. #define GPIO3_START_ADDR 0x481AE000
  16. #define GPIO_OE 0x134
  17. #define GPIO_SETDATAOUT 0x194
  18. #define GPIO_CLEARDATAOUT 0x190
  19. #define GPIO_DATAIN 0x138
  20. #define GPIO_DATAOUT 0x13C
  21. #define OE_REG_INDEX 0
  22. #define DATAOUT_REG_INDEX 1
  23. #define DATASET_REG_INDEX 2
  24. #define DATACLR_REG_INDEX 3
  25. #define DATAIN_REG_INDEX 4
  26. #define MAX_REGISTER_INDEX 5
  27. typedef struct {
  28. uint32_t gpioIndex;
  29. uint32_t regIndex;
  30. uint32_t data;
  31. } gpio_rq_t;
  32. typedef struct {
  33. uint32_t oe_reg0;
  34. uint32_t out_reg0;
  35. uint32_t in_reg0;
  36. uint32_t oe_reg1;
  37. uint32_t out_reg1;
  38. uint32_t in_reg1;
  39. uint32_t oe_reg2;
  40. uint32_t out_reg2;
  41. uint32_t in_reg2;
  42. uint32_t oe_reg3;
  43. uint32_t out_reg3;
  44. uint32_t in_reg3;
  45. } gpio_resp_t;
  46. extern char *gpio_device_name;
  47. int gpio_read_ctrl(gpio_rq_t* rq);
  48. int8_t gpio_write_ctrl(gpio_rq_t* rq);
  49. int8_t gpio_init(device_t* attr, char *device, uint16_t size);
  50. void gpio_release(device_t *attr);
  51. #endif /* BF16_GPIODEVICE_H */