| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <soc/gpio.h> |
| 5 |
#include <soc/pinmux.h> |
| 6 |
|
| 7 |
static void exynos_pinmux_uart(int start, int count) |
| 8 |
{ |
| 9 |
int i; |
| 10 |
|
| 11 |
for (i = start; i < start + count; i++) { |
| 12 |
gpio_set_pull(i, GPIO_PULL_NONE); |
| 13 |
gpio_cfg_pin(i, GPIO_FUNC(0x2)); |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
void exynos_pinmux_uart0(void) |
| 18 |
{ |
| 19 |
exynos_pinmux_uart(GPIO_A00, 4); |
| 20 |
} |
| 21 |
|
| 22 |
void exynos_pinmux_uart1(void) |
| 23 |
{ |
| 24 |
exynos_pinmux_uart(GPIO_D00, 4); |
| 25 |
} |
| 26 |
|
| 27 |
void exynos_pinmux_uart2(void) |
| 28 |
{ |
| 29 |
exynos_pinmux_uart(GPIO_A10, 4); |
| 30 |
} |
| 31 |
|
| 32 |
void exynos_pinmux_uart3(void) |
| 33 |
{ |
| 34 |
exynos_pinmux_uart(GPIO_A14, 2); |
| 35 |
} |
| 36 |
|
| 37 |
static void exynos_pinmux_sdmmc(int start, int start_ext) |
| 38 |
{ |
| 39 |
int i; |
| 40 |
|
| 41 |
if (start_ext) { |
| 42 |
for (i = 0; i <= 3; i++) { |
| 43 |
gpio_cfg_pin(start_ext + i, GPIO_FUNC(0x2)); |
| 44 |
gpio_set_pull(start_ext + i, GPIO_PULL_UP); |
| 45 |
gpio_set_drv(start_ext + i, GPIO_DRV_4X); |
| 46 |
} |
| 47 |
} |
| 48 |
for (i = 0; i < 2; i++) { |
| 49 |
gpio_cfg_pin(start + i, GPIO_FUNC(0x2)); |
| 50 |
gpio_set_pull(start + i, GPIO_PULL_NONE); |
| 51 |
gpio_set_drv(start + i, GPIO_DRV_4X); |
| 52 |
} |
| 53 |
for (i = 2; i <= 6; i++) { |
| 54 |
gpio_cfg_pin(start + i, GPIO_FUNC(0x2)); |
| 55 |
gpio_set_pull(start + i, GPIO_PULL_UP); |
| 56 |
gpio_set_drv(start + i, GPIO_DRV_4X); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
void exynos_pinmux_sdmmc0(void) |
| 61 |
{ |
| 62 |
exynos_pinmux_sdmmc(GPIO_C00, GPIO_C10); |
| 63 |
} |
| 64 |
|
| 65 |
void exynos_pinmux_sdmmc1(void) |
| 66 |
{ |
| 67 |
exynos_pinmux_sdmmc(GPIO_C20, 0); |
| 68 |
} |
| 69 |
|
| 70 |
void exynos_pinmux_sdmmc2(void) |
| 71 |
{ |
| 72 |
exynos_pinmux_sdmmc(GPIO_C30, 0); |
| 73 |
} |
| 74 |
|
| 75 |
void exynos_pinmux_sdmmc3(void) |
| 76 |
{ |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
printk(BIOS_DEBUG, "SDMMC3 not supported yet"); |
| 82 |
} |
| 83 |
|
| 84 |
void exynos_pinmux_sromc(int bank, int sixteen_bit) |
| 85 |
{ |
| 86 |
int i; |
| 87 |
|
| 88 |
if (bank > 3) { |
| 89 |
printk(BIOS_DEBUG, "Unsupported sromc bank %d.\n", bank); |
| 90 |
return; |
| 91 |
} |
| 92 |
|
| 93 |
gpio_cfg_pin(GPIO_Y00 + bank, GPIO_FUNC(2)); |
| 94 |
gpio_cfg_pin(GPIO_Y04, GPIO_FUNC(2)); |
| 95 |
gpio_cfg_pin(GPIO_Y05, GPIO_FUNC(2)); |
| 96 |
|
| 97 |
for (i = 2; i < 4; i++) |
| 98 |
gpio_cfg_pin(GPIO_Y10 + i, GPIO_FUNC(2)); |
| 99 |
|
| 100 |
for (i = 0; i < 8; i++) { |
| 101 |
gpio_cfg_pin(GPIO_Y30 + i, GPIO_FUNC(2)); |
| 102 |
gpio_set_pull(GPIO_Y30 + i, GPIO_PULL_UP); |
| 103 |
|
| 104 |
gpio_cfg_pin(GPIO_Y50 + i, GPIO_FUNC(2)); |
| 105 |
gpio_set_pull(GPIO_Y50 + i, GPIO_PULL_UP); |
| 106 |
|
| 107 |
if (sixteen_bit) { |
| 108 |
gpio_cfg_pin(GPIO_Y60 + i, GPIO_FUNC(2)); |
| 109 |
gpio_set_pull(GPIO_Y60 + i, GPIO_PULL_UP); |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
static void exynos_pinmux_spi(int start, int cfg) |
| 115 |
{ |
| 116 |
int i; |
| 117 |
|
| 118 |
for (i = 0; i < 4; i++) { |
| 119 |
gpio_cfg_pin(start + i, GPIO_FUNC(cfg)); |
| 120 |
gpio_set_pull(start + i, GPIO_PULL_NONE); |
| 121 |
gpio_set_drv(start + i, GPIO_DRV_3X); |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
void exynos_pinmux_spi0(void) |
| 126 |
{ |
| 127 |
exynos_pinmux_spi(GPIO_A20, 0x2); |
| 128 |
} |
| 129 |
|
| 130 |
void exynos_pinmux_spi1(void) |
| 131 |
{ |
| 132 |
exynos_pinmux_spi(GPIO_A24, 0x2); |
| 133 |
} |
| 134 |
|
| 135 |
void exynos_pinmux_spi2(void) |
| 136 |
{ |
| 137 |
exynos_pinmux_spi(GPIO_B11, 0x5); |
| 138 |
} |
| 139 |
|
| 140 |
void exynos_pinmux_spi3(void) |
| 141 |
{ |
| 142 |
exynos_pinmux_spi(GPIO_E00, 0x2); |
| 143 |
} |
| 144 |
|
| 145 |
void exynos_pinmux_spi4(void) |
| 146 |
{ |
| 147 |
int i; |
| 148 |
|
| 149 |
for (i = 0; i < 2; i++) |
| 150 |
gpio_cfg_pin(GPIO_F02 + i, GPIO_FUNC(0x4)); |
| 151 |
for (i = 2; i < 4; i++) |
| 152 |
gpio_cfg_pin(GPIO_E02 + i, GPIO_FUNC(0x4)); |
| 153 |
} |
| 154 |
|
| 155 |
void exynos_pinmux_backlight(void) |
| 156 |
{ |
| 157 |
gpio_cfg_pin(GPIO_B20, GPIO_OUTPUT); |
| 158 |
gpio_set_value(GPIO_B20, 1); |
| 159 |
} |
| 160 |
|
| 161 |
void exynos_pinmux_lcd(void) |
| 162 |
{ |
| 163 |
gpio_cfg_pin(GPIO_Y25, GPIO_OUTPUT); |
| 164 |
gpio_set_value(GPIO_Y25, 1); |
| 165 |
gpio_cfg_pin(GPIO_X15, GPIO_OUTPUT); |
| 166 |
gpio_set_value(GPIO_X15, 1); |
| 167 |
gpio_cfg_pin(GPIO_X30, GPIO_OUTPUT); |
| 168 |
gpio_set_value(GPIO_X30, 1); |
| 169 |
} |
| 170 |
|
| 171 |
static void exynos_pinmux_i2c(int start, int func) |
| 172 |
{ |
| 173 |
gpio_cfg_pin(start, GPIO_FUNC(func)); |
| 174 |
gpio_cfg_pin(start + 1, GPIO_FUNC(func)); |
| 175 |
gpio_set_pull(start, GPIO_PULL_NONE); |
| 176 |
gpio_set_pull(start + 1, GPIO_PULL_NONE); |
| 177 |
} |
| 178 |
|
| 179 |
void exynos_pinmux_i2c0(void) |
| 180 |
{ |
| 181 |
exynos_pinmux_i2c(GPIO_B30, 0x2); |
| 182 |
} |
| 183 |
|
| 184 |
void exynos_pinmux_i2c1(void) |
| 185 |
{ |
| 186 |
exynos_pinmux_i2c(GPIO_B32, 0x2); |
| 187 |
} |
| 188 |
|
| 189 |
void exynos_pinmux_i2c2(void) |
| 190 |
{ |
| 191 |
exynos_pinmux_i2c(GPIO_A06, 0x3); |
| 192 |
} |
| 193 |
|
| 194 |
void exynos_pinmux_i2c3(void) |
| 195 |
{ |
| 196 |
exynos_pinmux_i2c(GPIO_A12, 0x3); |
| 197 |
} |
| 198 |
|
| 199 |
void exynos_pinmux_i2c4(void) |
| 200 |
{ |
| 201 |
exynos_pinmux_i2c(GPIO_A20, 0x3); |
| 202 |
} |
| 203 |
|
| 204 |
void exynos_pinmux_i2c5(void) |
| 205 |
{ |
| 206 |
exynos_pinmux_i2c(GPIO_A22, 0x3); |
| 207 |
} |
| 208 |
|
| 209 |
void exynos_pinmux_i2c6(void) |
| 210 |
{ |
| 211 |
exynos_pinmux_i2c(GPIO_B13, 0x4); |
| 212 |
} |
| 213 |
|
| 214 |
void exynos_pinmux_i2c7(void) |
| 215 |
{ |
| 216 |
exynos_pinmux_i2c(GPIO_B22, 0x3); |
| 217 |
} |
| 218 |
|
| 219 |
void exynos_pinmux_dphpd(void) |
| 220 |
{ |
| 221 |
|
| 222 |
gpio_cfg_pin(GPIO_X07, GPIO_FUNC(0x3)); |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
gpio_set_pull(GPIO_X07, GPIO_PULL_NONE); |
| 229 |
} |
| 230 |
|
| 231 |
void exynos_pinmux_i2s0(void) |
| 232 |
{ |
| 233 |
int i; |
| 234 |
|
| 235 |
for (i = 0; i < 5; i++) { |
| 236 |
gpio_cfg_pin(GPIO_Z0 + i, GPIO_FUNC(0x02)); |
| 237 |
gpio_set_pull(GPIO_Z0 + i, GPIO_PULL_NONE); |
| 238 |
} |
| 239 |
} |
| 240 |
|
| 241 |
void exynos_pinmux_i2s1(void) |
| 242 |
{ |
| 243 |
int i; |
| 244 |
|
| 245 |
for (i = 0; i < 5; i++) { |
| 246 |
gpio_cfg_pin(GPIO_B00 + i, GPIO_FUNC(0x02)); |
| 247 |
gpio_set_pull(GPIO_B00 + i, GPIO_PULL_NONE); |
| 248 |
} |
| 249 |
} |