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 | |
Sonic Zhang | 3edc3f3 | 2013-05-02 13:46:21 +0800 | [diff] [blame] | 10 | #include <asm-generic/gpio.h> |
Steven Miao | 18b03b5 | 2013-10-23 14:44:09 +0800 | [diff] [blame] | 11 | #include <asm/portmux.h> |
Sonic Zhang | 3edc3f3 | 2013-05-02 13:46:21 +0800 | [diff] [blame] | 12 | |
Mike Frysinger | 83ebf37 | 2010-06-02 04:17:26 -0400 | [diff] [blame] | 13 | #define gpio_bank(x) ((x) >> 4) |
| 14 | #define gpio_bit(x) (1<<((x) & 0xF)) |
| 15 | #define gpio_sub_n(x) ((x) & 0xF) |
| 16 | |
| 17 | #define GPIO_BANKSIZE 16 |
| 18 | #define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, GPIO_BANKSIZE) |
| 19 | |
| 20 | #define GPIO_0 0 |
| 21 | #define GPIO_1 1 |
| 22 | #define GPIO_2 2 |
| 23 | #define GPIO_3 3 |
| 24 | #define GPIO_4 4 |
| 25 | #define GPIO_5 5 |
| 26 | #define GPIO_6 6 |
| 27 | #define GPIO_7 7 |
| 28 | #define GPIO_8 8 |
| 29 | #define GPIO_9 9 |
| 30 | #define GPIO_10 10 |
| 31 | #define GPIO_11 11 |
| 32 | #define GPIO_12 12 |
| 33 | #define GPIO_13 13 |
| 34 | #define GPIO_14 14 |
| 35 | #define GPIO_15 15 |
| 36 | #define GPIO_16 16 |
| 37 | #define GPIO_17 17 |
| 38 | #define GPIO_18 18 |
| 39 | #define GPIO_19 19 |
| 40 | #define GPIO_20 20 |
| 41 | #define GPIO_21 21 |
| 42 | #define GPIO_22 22 |
| 43 | #define GPIO_23 23 |
| 44 | #define GPIO_24 24 |
| 45 | #define GPIO_25 25 |
| 46 | #define GPIO_26 26 |
| 47 | #define GPIO_27 27 |
| 48 | #define GPIO_28 28 |
| 49 | #define GPIO_29 29 |
| 50 | #define GPIO_30 30 |
| 51 | #define GPIO_31 31 |
| 52 | #define GPIO_32 32 |
| 53 | #define GPIO_33 33 |
| 54 | #define GPIO_34 34 |
| 55 | #define GPIO_35 35 |
| 56 | #define GPIO_36 36 |
| 57 | #define GPIO_37 37 |
| 58 | #define GPIO_38 38 |
| 59 | #define GPIO_39 39 |
| 60 | #define GPIO_40 40 |
| 61 | #define GPIO_41 41 |
| 62 | #define GPIO_42 42 |
| 63 | #define GPIO_43 43 |
| 64 | #define GPIO_44 44 |
| 65 | #define GPIO_45 45 |
| 66 | #define GPIO_46 46 |
| 67 | #define GPIO_47 47 |
| 68 | |
| 69 | #define PERIPHERAL_USAGE 1 |
| 70 | #define GPIO_USAGE 0 |
Sonic Zhang | 3edc3f3 | 2013-05-02 13:46:21 +0800 | [diff] [blame] | 71 | #define MAX_GPIOS MAX_BLACKFIN_GPIOS |
Mike Frysinger | 83ebf37 | 2010-06-02 04:17:26 -0400 | [diff] [blame] | 72 | |
| 73 | #ifndef __ASSEMBLY__ |
| 74 | |
Sonic Zhang | 84c38da | 2013-11-18 14:12:39 +0800 | [diff] [blame] | 75 | #ifndef CONFIG_ADI_GPIO2 |
Mike Frysinger | 83ebf37 | 2010-06-02 04:17:26 -0400 | [diff] [blame] | 76 | void set_gpio_dir(unsigned, unsigned short); |
| 77 | void set_gpio_inen(unsigned, unsigned short); |
| 78 | void set_gpio_polar(unsigned, unsigned short); |
| 79 | void set_gpio_edge(unsigned, unsigned short); |
| 80 | void set_gpio_both(unsigned, unsigned short); |
| 81 | void set_gpio_data(unsigned, unsigned short); |
| 82 | void set_gpio_maska(unsigned, unsigned short); |
| 83 | void set_gpio_maskb(unsigned, unsigned short); |
| 84 | void set_gpio_toggle(unsigned); |
| 85 | void set_gpiop_dir(unsigned, unsigned short); |
| 86 | void set_gpiop_inen(unsigned, unsigned short); |
| 87 | void set_gpiop_polar(unsigned, unsigned short); |
| 88 | void set_gpiop_edge(unsigned, unsigned short); |
| 89 | void set_gpiop_both(unsigned, unsigned short); |
| 90 | void set_gpiop_data(unsigned, unsigned short); |
| 91 | void set_gpiop_maska(unsigned, unsigned short); |
| 92 | void set_gpiop_maskb(unsigned, unsigned short); |
| 93 | unsigned short get_gpio_dir(unsigned); |
| 94 | unsigned short get_gpio_inen(unsigned); |
| 95 | unsigned short get_gpio_polar(unsigned); |
| 96 | unsigned short get_gpio_edge(unsigned); |
| 97 | unsigned short get_gpio_both(unsigned); |
| 98 | unsigned short get_gpio_maska(unsigned); |
| 99 | unsigned short get_gpio_maskb(unsigned); |
| 100 | unsigned short get_gpio_data(unsigned); |
| 101 | unsigned short get_gpiop_dir(unsigned); |
| 102 | unsigned short get_gpiop_inen(unsigned); |
| 103 | unsigned short get_gpiop_polar(unsigned); |
| 104 | unsigned short get_gpiop_edge(unsigned); |
| 105 | unsigned short get_gpiop_both(unsigned); |
| 106 | unsigned short get_gpiop_maska(unsigned); |
| 107 | unsigned short get_gpiop_maskb(unsigned); |
| 108 | unsigned short get_gpiop_data(unsigned); |
| 109 | |
| 110 | struct gpio_port_t { |
| 111 | unsigned short data; |
| 112 | unsigned short dummy1; |
| 113 | unsigned short data_clear; |
| 114 | unsigned short dummy2; |
| 115 | unsigned short data_set; |
| 116 | unsigned short dummy3; |
| 117 | unsigned short toggle; |
| 118 | unsigned short dummy4; |
| 119 | unsigned short maska; |
| 120 | unsigned short dummy5; |
| 121 | unsigned short maska_clear; |
| 122 | unsigned short dummy6; |
| 123 | unsigned short maska_set; |
| 124 | unsigned short dummy7; |
| 125 | unsigned short maska_toggle; |
| 126 | unsigned short dummy8; |
| 127 | unsigned short maskb; |
| 128 | unsigned short dummy9; |
| 129 | unsigned short maskb_clear; |
| 130 | unsigned short dummy10; |
| 131 | unsigned short maskb_set; |
| 132 | unsigned short dummy11; |
| 133 | unsigned short maskb_toggle; |
| 134 | unsigned short dummy12; |
| 135 | unsigned short dir; |
| 136 | unsigned short dummy13; |
| 137 | unsigned short polar; |
| 138 | unsigned short dummy14; |
| 139 | unsigned short edge; |
| 140 | unsigned short dummy15; |
| 141 | unsigned short both; |
| 142 | unsigned short dummy16; |
| 143 | unsigned short inen; |
| 144 | }; |
Steven Miao | 18b03b5 | 2013-10-23 14:44:09 +0800 | [diff] [blame] | 145 | #else |
| 146 | extern struct gpio_port_t * const gpio_array[]; |
Mike Frysinger | 83ebf37 | 2010-06-02 04:17:26 -0400 | [diff] [blame] | 147 | #endif |
| 148 | |
Sonic Zhang | 3edc3f3 | 2013-05-02 13:46:21 +0800 | [diff] [blame] | 149 | #ifdef ADI_SPECIAL_GPIO_BANKS |
| 150 | void special_gpio_free(unsigned gpio); |
| 151 | int special_gpio_request(unsigned gpio, const char *label); |
Mike Frysinger | 83ebf37 | 2010-06-02 04:17:26 -0400 | [diff] [blame] | 152 | #endif |
| 153 | |
Sonic Zhang | 3edc3f3 | 2013-05-02 13:46:21 +0800 | [diff] [blame] | 154 | void gpio_labels(void); |
Mike Frysinger | 83ebf37 | 2010-06-02 04:17:26 -0400 | [diff] [blame] | 155 | |
| 156 | static inline int gpio_is_valid(int number) |
| 157 | { |
Sonic Zhang | 3edc3f3 | 2013-05-02 13:46:21 +0800 | [diff] [blame] | 158 | return number >= 0 && number < MAX_GPIOS; |
Mike Frysinger | 83ebf37 | 2010-06-02 04:17:26 -0400 | [diff] [blame] | 159 | } |
| 160 | |
Mike Frysinger | 0e71f80 | 2011-04-03 04:40:46 -0400 | [diff] [blame] | 161 | #include <linux/ctype.h> |
| 162 | |
Sonic Zhang | 3edc3f3 | 2013-05-02 13:46:21 +0800 | [diff] [blame] | 163 | #define gpio_status() gpio_labels() |
Mike Frysinger | 0e71f80 | 2011-04-03 04:40:46 -0400 | [diff] [blame] | 164 | |
Mike Frysinger | 83ebf37 | 2010-06-02 04:17:26 -0400 | [diff] [blame] | 165 | #endif /* __ASSEMBLY__ */ |
| 166 | |
| 167 | #endif /* __ARCH_BLACKFIN_GPIO_H__ */ |