Angel Pons | 1ddb894 | 2020-04-04 18:51:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 2 | |
Julius Werner | 1ed0c8c | 2014-10-20 13:16:29 -0700 | [diff] [blame] | 3 | #include <console/console.h> |
| 4 | #include <soc/gpio.h> |
| 5 | #include <soc/pinmux.h> |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 6 | |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 7 | static void exynos_pinmux_uart(int start, int count) |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 8 | { |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 9 | int i; |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 10 | |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 11 | for (i = start; i < start + count; i++) { |
| 12 | gpio_set_pull(i, GPIO_PULL_NONE); |
| 13 | gpio_cfg_pin(i, GPIO_FUNC(0x2)); |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 14 | } |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 15 | } |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 16 | |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 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); |
Gabe Black | 63dd2cb | 2013-05-18 15:52:01 -0700 | [diff] [blame] | 46 | } |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 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 | /* |
Martin Roth | 4c3ab73 | 2013-07-08 16:23:54 -0600 | [diff] [blame] | 78 | * TODO: Need to add definitions for GPC4 before |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 79 | * enabling this. |
| 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; |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 91 | } |
| 92 | |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 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 | |
Julius Werner | ce011ec | 2013-08-06 16:00:37 -0700 | [diff] [blame] | 118 | for (i = 0; i < 4; i++) { |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 119 | gpio_cfg_pin(start + i, GPIO_FUNC(cfg)); |
Julius Werner | ce011ec | 2013-08-06 16:00:37 -0700 | [diff] [blame] | 120 | gpio_set_pull(start + i, GPIO_PULL_NONE); |
| 121 | gpio_set_drv(start + i, GPIO_DRV_3X); |
| 122 | } |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 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 | /* Set Hotplug detect for DP */ |
| 222 | gpio_cfg_pin(GPIO_X07, GPIO_FUNC(0x3)); |
| 223 | |
| 224 | /* |
| 225 | * Hotplug detect should have an external pullup; disable the |
| 226 | * internal pulldown so they don't fight. |
| 227 | */ |
| 228 | gpio_set_pull(GPIO_X07, GPIO_PULL_NONE); |
| 229 | } |
| 230 | |
Gabe Black | 4e195af | 2013-08-05 22:15:21 -0700 | [diff] [blame] | 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 | |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 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 | } |
Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame] | 249 | } |