Mike Frysinger | 83ebf37 | 2010-06-02 04:17:26 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006-2009 Analog Devices Inc. |
| 3 | * |
| 4 | * Licensed under the GPL-2 or later. |
| 5 | */ |
| 6 | |
| 7 | #ifndef __ARCH_BLACKFIN_GPIO_H__ |
| 8 | #define __ARCH_BLACKFIN_GPIO_H__ |
| 9 | |
| 10 | #define gpio_bank(x) ((x) >> 4) |
| 11 | #define gpio_bit(x) (1<<((x) & 0xF)) |
| 12 | #define gpio_sub_n(x) ((x) & 0xF) |
| 13 | |
| 14 | #define GPIO_BANKSIZE 16 |
| 15 | #define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, GPIO_BANKSIZE) |
| 16 | |
| 17 | #define GPIO_0 0 |
| 18 | #define GPIO_1 1 |
| 19 | #define GPIO_2 2 |
| 20 | #define GPIO_3 3 |
| 21 | #define GPIO_4 4 |
| 22 | #define GPIO_5 5 |
| 23 | #define GPIO_6 6 |
| 24 | #define GPIO_7 7 |
| 25 | #define GPIO_8 8 |
| 26 | #define GPIO_9 9 |
| 27 | #define GPIO_10 10 |
| 28 | #define GPIO_11 11 |
| 29 | #define GPIO_12 12 |
| 30 | #define GPIO_13 13 |
| 31 | #define GPIO_14 14 |
| 32 | #define GPIO_15 15 |
| 33 | #define GPIO_16 16 |
| 34 | #define GPIO_17 17 |
| 35 | #define GPIO_18 18 |
| 36 | #define GPIO_19 19 |
| 37 | #define GPIO_20 20 |
| 38 | #define GPIO_21 21 |
| 39 | #define GPIO_22 22 |
| 40 | #define GPIO_23 23 |
| 41 | #define GPIO_24 24 |
| 42 | #define GPIO_25 25 |
| 43 | #define GPIO_26 26 |
| 44 | #define GPIO_27 27 |
| 45 | #define GPIO_28 28 |
| 46 | #define GPIO_29 29 |
| 47 | #define GPIO_30 30 |
| 48 | #define GPIO_31 31 |
| 49 | #define GPIO_32 32 |
| 50 | #define GPIO_33 33 |
| 51 | #define GPIO_34 34 |
| 52 | #define GPIO_35 35 |
| 53 | #define GPIO_36 36 |
| 54 | #define GPIO_37 37 |
| 55 | #define GPIO_38 38 |
| 56 | #define GPIO_39 39 |
| 57 | #define GPIO_40 40 |
| 58 | #define GPIO_41 41 |
| 59 | #define GPIO_42 42 |
| 60 | #define GPIO_43 43 |
| 61 | #define GPIO_44 44 |
| 62 | #define GPIO_45 45 |
| 63 | #define GPIO_46 46 |
| 64 | #define GPIO_47 47 |
| 65 | |
| 66 | #define PERIPHERAL_USAGE 1 |
| 67 | #define GPIO_USAGE 0 |
| 68 | |
| 69 | #ifndef __ASSEMBLY__ |
| 70 | |
| 71 | #ifndef CONFIG_BF54x |
| 72 | void set_gpio_dir(unsigned, unsigned short); |
| 73 | void set_gpio_inen(unsigned, unsigned short); |
| 74 | void set_gpio_polar(unsigned, unsigned short); |
| 75 | void set_gpio_edge(unsigned, unsigned short); |
| 76 | void set_gpio_both(unsigned, unsigned short); |
| 77 | void set_gpio_data(unsigned, unsigned short); |
| 78 | void set_gpio_maska(unsigned, unsigned short); |
| 79 | void set_gpio_maskb(unsigned, unsigned short); |
| 80 | void set_gpio_toggle(unsigned); |
| 81 | void set_gpiop_dir(unsigned, unsigned short); |
| 82 | void set_gpiop_inen(unsigned, unsigned short); |
| 83 | void set_gpiop_polar(unsigned, unsigned short); |
| 84 | void set_gpiop_edge(unsigned, unsigned short); |
| 85 | void set_gpiop_both(unsigned, unsigned short); |
| 86 | void set_gpiop_data(unsigned, unsigned short); |
| 87 | void set_gpiop_maska(unsigned, unsigned short); |
| 88 | void set_gpiop_maskb(unsigned, unsigned short); |
| 89 | unsigned short get_gpio_dir(unsigned); |
| 90 | unsigned short get_gpio_inen(unsigned); |
| 91 | unsigned short get_gpio_polar(unsigned); |
| 92 | unsigned short get_gpio_edge(unsigned); |
| 93 | unsigned short get_gpio_both(unsigned); |
| 94 | unsigned short get_gpio_maska(unsigned); |
| 95 | unsigned short get_gpio_maskb(unsigned); |
| 96 | unsigned short get_gpio_data(unsigned); |
| 97 | unsigned short get_gpiop_dir(unsigned); |
| 98 | unsigned short get_gpiop_inen(unsigned); |
| 99 | unsigned short get_gpiop_polar(unsigned); |
| 100 | unsigned short get_gpiop_edge(unsigned); |
| 101 | unsigned short get_gpiop_both(unsigned); |
| 102 | unsigned short get_gpiop_maska(unsigned); |
| 103 | unsigned short get_gpiop_maskb(unsigned); |
| 104 | unsigned short get_gpiop_data(unsigned); |
| 105 | |
| 106 | struct gpio_port_t { |
| 107 | unsigned short data; |
| 108 | unsigned short dummy1; |
| 109 | unsigned short data_clear; |
| 110 | unsigned short dummy2; |
| 111 | unsigned short data_set; |
| 112 | unsigned short dummy3; |
| 113 | unsigned short toggle; |
| 114 | unsigned short dummy4; |
| 115 | unsigned short maska; |
| 116 | unsigned short dummy5; |
| 117 | unsigned short maska_clear; |
| 118 | unsigned short dummy6; |
| 119 | unsigned short maska_set; |
| 120 | unsigned short dummy7; |
| 121 | unsigned short maska_toggle; |
| 122 | unsigned short dummy8; |
| 123 | unsigned short maskb; |
| 124 | unsigned short dummy9; |
| 125 | unsigned short maskb_clear; |
| 126 | unsigned short dummy10; |
| 127 | unsigned short maskb_set; |
| 128 | unsigned short dummy11; |
| 129 | unsigned short maskb_toggle; |
| 130 | unsigned short dummy12; |
| 131 | unsigned short dir; |
| 132 | unsigned short dummy13; |
| 133 | unsigned short polar; |
| 134 | unsigned short dummy14; |
| 135 | unsigned short edge; |
| 136 | unsigned short dummy15; |
| 137 | unsigned short both; |
| 138 | unsigned short dummy16; |
| 139 | unsigned short inen; |
| 140 | }; |
| 141 | #endif |
| 142 | |
| 143 | #ifdef CONFIG_BFIN_GPIO_TRACK |
| 144 | void bfin_gpio_labels(void); |
| 145 | #else |
| 146 | #define bfin_gpio_labels() |
| 147 | #define bfin_gpio_request(gpio, label) bfin_gpio_request(gpio) |
| 148 | #define bfin_special_gpio_request(gpio, label) bfin_special_gpio_request(gpio) |
| 149 | #endif |
| 150 | |
| 151 | #ifdef BFIN_SPECIAL_GPIO_BANKS |
| 152 | void bfin_special_gpio_free(unsigned gpio); |
| 153 | int bfin_special_gpio_request(unsigned gpio, const char *label); |
| 154 | #endif |
| 155 | |
| 156 | int bfin_gpio_request(unsigned gpio, const char *label); |
| 157 | void bfin_gpio_free(unsigned gpio); |
| 158 | int bfin_gpio_direction_input(unsigned gpio); |
| 159 | int bfin_gpio_direction_output(unsigned gpio, int value); |
| 160 | int bfin_gpio_get_value(unsigned gpio); |
| 161 | void bfin_gpio_set_value(unsigned gpio, int value); |
| 162 | void bfin_gpio_toggle_value(unsigned gpio); |
| 163 | |
| 164 | static inline int gpio_request(unsigned gpio, const char *label) |
| 165 | { |
| 166 | return bfin_gpio_request(gpio, label); |
| 167 | } |
| 168 | |
| 169 | static inline void gpio_free(unsigned gpio) |
| 170 | { |
| 171 | return bfin_gpio_free(gpio); |
| 172 | } |
| 173 | |
| 174 | static inline int gpio_direction_input(unsigned gpio) |
| 175 | { |
| 176 | return bfin_gpio_direction_input(gpio); |
| 177 | } |
| 178 | |
| 179 | static inline int gpio_direction_output(unsigned gpio, int value) |
| 180 | { |
| 181 | return bfin_gpio_direction_output(gpio, value); |
| 182 | } |
| 183 | |
| 184 | static inline int gpio_get_value(unsigned gpio) |
| 185 | { |
| 186 | return bfin_gpio_get_value(gpio); |
| 187 | } |
| 188 | |
| 189 | static inline void gpio_set_value(unsigned gpio, int value) |
| 190 | { |
| 191 | return bfin_gpio_set_value(gpio, value); |
| 192 | } |
| 193 | |
| 194 | static inline int gpio_is_valid(int number) |
| 195 | { |
| 196 | return number >= 0 && number < MAX_BLACKFIN_GPIOS; |
| 197 | } |
| 198 | |
| 199 | #endif /* __ASSEMBLY__ */ |
| 200 | |
| 201 | #endif /* __ARCH_BLACKFIN_GPIO_H__ */ |