Angel Pons | 1ddb894 | 2020-04-04 18:51:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 2 | |
Julius Werner | 80af442 | 2014-10-20 13:18:56 -0700 | [diff] [blame] | 3 | #include <soc/gpio.h> |
| 4 | #include <soc/pinmux.h> |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 5 | |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 6 | static void exynos_pinmux_uart(int start, int count) |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 7 | { |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 8 | int i; |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 9 | |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 10 | for (i = start; i < start + count; i++) { |
| 11 | gpio_set_pull(i, GPIO_PULL_NONE); |
| 12 | gpio_cfg_pin(i, GPIO_FUNC(0x2)); |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | void exynos_pinmux_uart0(void) |
| 17 | { |
| 18 | exynos_pinmux_uart(GPIO_A00, 4); |
| 19 | } |
| 20 | |
| 21 | void exynos_pinmux_uart1(void) |
| 22 | { |
| 23 | exynos_pinmux_uart(GPIO_A04, 4); |
| 24 | } |
| 25 | |
| 26 | void exynos_pinmux_uart2(void) |
| 27 | { |
| 28 | exynos_pinmux_uart(GPIO_A10, 4); |
| 29 | } |
| 30 | |
| 31 | void exynos_pinmux_uart3(void) |
| 32 | { |
| 33 | exynos_pinmux_uart(GPIO_A14, 2); |
| 34 | } |
| 35 | |
David Hendricks | e0cfad2 | 2013-08-08 14:09:46 -0700 | [diff] [blame] | 36 | struct gpio { |
| 37 | enum exynos5_gpio_pin pin; |
| 38 | unsigned int func; |
| 39 | unsigned int pull; |
| 40 | unsigned int drv; |
| 41 | }; |
| 42 | |
| 43 | static void exynos_pinmux_sdmmc(struct gpio *gpios, int num_gpios) |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 44 | { |
| 45 | int i; |
| 46 | |
David Hendricks | e0cfad2 | 2013-08-08 14:09:46 -0700 | [diff] [blame] | 47 | for (i = 0; i < num_gpios; i++) { |
| 48 | gpio_set_drv(gpios[i].pin, gpios[i].drv); |
| 49 | gpio_set_pull(gpios[i].pin, gpios[i].pull); |
| 50 | gpio_cfg_pin(gpios[i].pin, GPIO_FUNC(gpios[i].func)); |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 51 | } |
| 52 | } |
| 53 | |
| 54 | void exynos_pinmux_sdmmc0(void) |
| 55 | { |
David Hendricks | e0cfad2 | 2013-08-08 14:09:46 -0700 | [diff] [blame] | 56 | struct gpio gpios[] = { |
| 57 | { GPIO_C00, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CLK */ |
| 58 | { GPIO_C01, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CMD */ |
| 59 | /* |
| 60 | * MMC0 is intended to be used for eMMC. The card detect |
| 61 | * pin is used as a VDDEN signal to power on the eMMC. The |
| 62 | * 5420 iROM makes this same assumption. |
| 63 | */ |
| 64 | { GPIO_C02, GPIO_OUTPUT, GPIO_PULL_NONE, GPIO_DRV_4X }, |
| 65 | { GPIO_C03, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[0] */ |
| 66 | { GPIO_C04, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[1] */ |
| 67 | { GPIO_C05, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[2] */ |
| 68 | { GPIO_C06, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[3] */ |
| 69 | |
| 70 | { GPIO_C30, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[4] */ |
| 71 | { GPIO_C31, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[5] */ |
| 72 | { GPIO_C32, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[6] */ |
| 73 | { GPIO_C33, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[7] */ |
| 74 | }; |
| 75 | |
| 76 | exynos_pinmux_sdmmc(&gpios[0], ARRAY_SIZE(gpios)); |
| 77 | |
| 78 | /* set VDDEN */ |
David Hendricks | b9f267c | 2013-08-08 14:51:07 -0700 | [diff] [blame] | 79 | gpio_set_value(GPIO_C02, 1); |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | void exynos_pinmux_sdmmc1(void) |
| 83 | { |
David Hendricks | e0cfad2 | 2013-08-08 14:09:46 -0700 | [diff] [blame] | 84 | struct gpio gpios[] = { |
| 85 | { GPIO_C10, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CLK */ |
| 86 | { GPIO_C11, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CMD */ |
| 87 | { GPIO_C12, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CDn */ |
| 88 | { GPIO_C13, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[0] */ |
| 89 | { GPIO_C14, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[1] */ |
| 90 | { GPIO_C15, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[2] */ |
| 91 | { GPIO_C16, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[3] */ |
| 92 | |
| 93 | { GPIO_D14, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[4] */ |
| 94 | { GPIO_D15, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[5] */ |
| 95 | { GPIO_D16, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[6] */ |
| 96 | { GPIO_D17, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[7] */ |
| 97 | }; |
| 98 | |
| 99 | exynos_pinmux_sdmmc(&gpios[0], ARRAY_SIZE(gpios)); |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void exynos_pinmux_sdmmc2(void) |
| 103 | { |
David Hendricks | e0cfad2 | 2013-08-08 14:09:46 -0700 | [diff] [blame] | 104 | struct gpio gpios[] = { |
| 105 | { GPIO_C20, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CLK */ |
| 106 | { GPIO_C21, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CMD */ |
| 107 | { GPIO_C22, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CDn */ |
| 108 | { GPIO_C23, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[0] */ |
| 109 | { GPIO_C24, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[1] */ |
| 110 | { GPIO_C25, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[2] */ |
| 111 | { GPIO_C26, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[3] */ |
| 112 | }; |
| 113 | |
| 114 | exynos_pinmux_sdmmc(&gpios[0], ARRAY_SIZE(gpios)); |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | static void exynos_pinmux_spi(int start, int cfg) |
| 118 | { |
| 119 | int i; |
| 120 | |
Julius Werner | 45d2ff3 | 2013-08-12 18:04:06 -0700 | [diff] [blame] | 121 | for (i = start; i < start + 4; i++) { |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 122 | gpio_cfg_pin(i, cfg); |
Julius Werner | 45d2ff3 | 2013-08-12 18:04:06 -0700 | [diff] [blame] | 123 | gpio_set_pull(i, GPIO_PULL_NONE); |
| 124 | gpio_set_drv(i, GPIO_DRV_3X); |
| 125 | } |
Gabe Black | e6a44eb | 2013-06-15 23:40:26 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | void exynos_pinmux_spi0(void) |
| 129 | { |
| 130 | exynos_pinmux_spi(GPIO_A20, 0x2); |
| 131 | } |
| 132 | |
| 133 | void exynos_pinmux_spi1(void) |
| 134 | { |
| 135 | exynos_pinmux_spi(GPIO_A24, 0x2); |
| 136 | } |
| 137 | |
| 138 | void exynos_pinmux_spi2(void) |
| 139 | { |
| 140 | exynos_pinmux_spi(GPIO_B11, 0x5); |
| 141 | } |
| 142 | |
| 143 | void exynos_pinmux_spi3(void) |
| 144 | { |
| 145 | exynos_pinmux_spi(GPIO_F10, 0x2); |
| 146 | } |
| 147 | |
| 148 | void exynos_pinmux_spi4(void) |
| 149 | { |
| 150 | int i; |
| 151 | |
| 152 | for (i = 0; i < 2; i++) { |
| 153 | gpio_cfg_pin(GPIO_F02 + i, GPIO_FUNC(0x4)); |
| 154 | gpio_cfg_pin(GPIO_E04 + i, GPIO_FUNC(0x4)); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | static void exynos_pinmux_i2c(int start, int func) |
| 159 | { |
| 160 | gpio_cfg_pin(start, GPIO_FUNC(func)); |
| 161 | gpio_cfg_pin(start + 1, GPIO_FUNC(func)); |
| 162 | gpio_set_pull(start, GPIO_PULL_NONE); |
| 163 | gpio_set_pull(start + 1, GPIO_PULL_NONE); |
| 164 | } |
| 165 | |
| 166 | void exynos_pinmux_i2c0(void) |
| 167 | { |
| 168 | exynos_pinmux_i2c(GPIO_B30, 0x2); |
| 169 | } |
| 170 | |
| 171 | void exynos_pinmux_i2c1(void) |
| 172 | { |
| 173 | exynos_pinmux_i2c(GPIO_B32, 0x2); |
| 174 | } |
| 175 | |
| 176 | void exynos_pinmux_i2c2(void) |
| 177 | { |
| 178 | exynos_pinmux_i2c(GPIO_A06, 0x3); |
| 179 | } |
| 180 | |
| 181 | void exynos_pinmux_i2c3(void) |
| 182 | { |
| 183 | exynos_pinmux_i2c(GPIO_A12, 0x3); |
| 184 | } |
| 185 | |
| 186 | void exynos_pinmux_i2c4(void) |
| 187 | { |
| 188 | exynos_pinmux_i2c(GPIO_A20, 0x3); |
| 189 | } |
| 190 | |
| 191 | void exynos_pinmux_i2c5(void) |
| 192 | { |
| 193 | exynos_pinmux_i2c(GPIO_A22, 0x3); |
| 194 | } |
| 195 | |
| 196 | void exynos_pinmux_i2c6(void) |
| 197 | { |
| 198 | exynos_pinmux_i2c(GPIO_B13, 0x4); |
| 199 | } |
| 200 | |
| 201 | void exynos_pinmux_i2c7(void) |
| 202 | { |
| 203 | exynos_pinmux_i2c(GPIO_B22, 0x3); |
| 204 | } |
| 205 | |
| 206 | void exynos_pinmux_i2c8(void) |
| 207 | { |
| 208 | exynos_pinmux_i2c(GPIO_B34, 0x2); |
| 209 | } |
| 210 | |
| 211 | void exynos_pinmux_i2c9(void) |
| 212 | { |
| 213 | exynos_pinmux_i2c(GPIO_B36, 0x2); |
| 214 | } |
| 215 | |
| 216 | void exynos_pinmux_i2c10(void) |
| 217 | { |
| 218 | exynos_pinmux_i2c(GPIO_B40, 0x2); |
| 219 | } |
| 220 | |
| 221 | void exynos_pinmux_dphpd(void) |
| 222 | { |
| 223 | gpio_cfg_pin(GPIO_X07, GPIO_FUNC(0x3)); |
| 224 | gpio_set_pull(GPIO_X07, GPIO_PULL_NONE); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 225 | } |