Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 1 | /* linux/arch/arm/mach-exynos4/setup-sdhci-gpio.c |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 2 | * |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 3 | * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 5 | * |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 6 | * EXYNOS4 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC) |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/io.h> |
| 18 | #include <linux/gpio.h> |
| 19 | #include <linux/mmc/host.h> |
| 20 | #include <linux/mmc/card.h> |
| 21 | |
| 22 | #include <plat/gpio-cfg.h> |
| 23 | #include <plat/regs-sdhci.h> |
| 24 | #include <plat/sdhci.h> |
| 25 | |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 26 | void exynos4_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 27 | { |
| 28 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
| 29 | unsigned int gpio; |
| 30 | |
| 31 | /* Set all the necessary GPK0[0:1] pins to special-function 2 */ |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 32 | for (gpio = EXYNOS4_GPK0(0); gpio < EXYNOS4_GPK0(2); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 33 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 34 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 35 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 36 | } |
| 37 | |
| 38 | switch (width) { |
| 39 | case 8: |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 40 | for (gpio = EXYNOS4_GPK1(3); gpio <= EXYNOS4_GPK1(6); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 41 | /* Data pin GPK1[3:6] to special-funtion 3 */ |
| 42 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3)); |
| 43 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP); |
| 44 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 45 | } |
| 46 | case 4: |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 47 | for (gpio = EXYNOS4_GPK0(3); gpio <= EXYNOS4_GPK0(6); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 48 | /* Data pin GPK0[3:6] to special-funtion 2 */ |
| 49 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 50 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP); |
| 51 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 52 | } |
| 53 | default: |
| 54 | break; |
| 55 | } |
| 56 | |
| 57 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 58 | s3c_gpio_cfgpin(EXYNOS4_GPK0(2), S3C_GPIO_SFN(2)); |
| 59 | s3c_gpio_setpull(EXYNOS4_GPK0(2), S3C_GPIO_PULL_UP); |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 60 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 61 | } |
| 62 | } |
| 63 | |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 64 | void exynos4_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 65 | { |
| 66 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
| 67 | unsigned int gpio; |
| 68 | |
| 69 | /* Set all the necessary GPK1[0:1] pins to special-function 2 */ |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 70 | for (gpio = EXYNOS4_GPK1(0); gpio < EXYNOS4_GPK1(2); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 71 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 72 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 73 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 74 | } |
| 75 | |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 76 | for (gpio = EXYNOS4_GPK1(3); gpio <= EXYNOS4_GPK1(6); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 77 | /* Data pin GPK1[3:6] to special-function 2 */ |
| 78 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 79 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP); |
| 80 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 81 | } |
| 82 | |
| 83 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 84 | s3c_gpio_cfgpin(EXYNOS4_GPK1(2), S3C_GPIO_SFN(2)); |
| 85 | s3c_gpio_setpull(EXYNOS4_GPK1(2), S3C_GPIO_PULL_UP); |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 86 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 87 | } |
| 88 | } |
| 89 | |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 90 | void exynos4_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 91 | { |
| 92 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
| 93 | unsigned int gpio; |
| 94 | |
| 95 | /* Set all the necessary GPK2[0:1] pins to special-function 2 */ |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 96 | for (gpio = EXYNOS4_GPK2(0); gpio < EXYNOS4_GPK2(2); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 97 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 98 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 99 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 100 | } |
| 101 | |
| 102 | switch (width) { |
| 103 | case 8: |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 104 | for (gpio = EXYNOS4_GPK3(3); gpio <= EXYNOS4_GPK3(6); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 105 | /* Data pin GPK3[3:6] to special-function 3 */ |
| 106 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3)); |
| 107 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP); |
| 108 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 109 | } |
| 110 | case 4: |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 111 | for (gpio = EXYNOS4_GPK2(3); gpio <= EXYNOS4_GPK2(6); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 112 | /* Data pin GPK2[3:6] to special-function 2 */ |
| 113 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 114 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP); |
| 115 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 116 | } |
| 117 | default: |
| 118 | break; |
| 119 | } |
| 120 | |
| 121 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 122 | s3c_gpio_cfgpin(EXYNOS4_GPK2(2), S3C_GPIO_SFN(2)); |
| 123 | s3c_gpio_setpull(EXYNOS4_GPK2(2), S3C_GPIO_PULL_UP); |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 124 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 125 | } |
| 126 | } |
| 127 | |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 128 | void exynos4_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width) |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 129 | { |
| 130 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
| 131 | unsigned int gpio; |
| 132 | |
| 133 | /* Set all the necessary GPK3[0:1] pins to special-function 2 */ |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 134 | for (gpio = EXYNOS4_GPK3(0); gpio < EXYNOS4_GPK3(2); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 135 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 136 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 137 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 138 | } |
| 139 | |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 140 | for (gpio = EXYNOS4_GPK3(3); gpio <= EXYNOS4_GPK3(6); gpio++) { |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 141 | /* Data pin GPK3[3:6] to special-function 2 */ |
| 142 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 143 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP); |
| 144 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 145 | } |
| 146 | |
| 147 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
Kukjin Kim | 3db3ae5 | 2011-02-14 16:22:36 +0900 | [diff] [blame^] | 148 | s3c_gpio_cfgpin(EXYNOS4_GPK3(2), S3C_GPIO_SFN(2)); |
| 149 | s3c_gpio_setpull(EXYNOS4_GPK3(2), S3C_GPIO_PULL_UP); |
Hyuk Lee | 1931511 | 2010-10-06 11:09:42 +0900 | [diff] [blame] | 150 | s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); |
| 151 | } |
| 152 | } |