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