Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 1 | /* linux/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c |
| 2 | * |
| 3 | * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com/ |
| 5 | * |
| 6 | * S5PV210 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC) |
| 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> |
Kukjin Kim | 1c739c7 | 2010-08-05 07:54:49 +0900 | [diff] [blame] | 18 | #include <linux/gpio.h> |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 19 | #include <linux/mmc/host.h> |
| 20 | #include <linux/mmc/card.h> |
| 21 | |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 22 | #include <plat/gpio-cfg.h> |
| 23 | #include <plat/regs-sdhci.h> |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 24 | #include <plat/sdhci.h> |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 25 | |
| 26 | void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) |
| 27 | { |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 28 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 29 | unsigned int gpio; |
| 30 | |
| 31 | /* Set all the necessary GPG0/GPG1 pins to special-function 2 */ |
| 32 | for (gpio = S5PV210_GPG0(0); gpio < S5PV210_GPG0(2); gpio++) { |
| 33 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 34 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 35 | } |
| 36 | switch (width) { |
| 37 | case 8: |
| 38 | /* GPG1[3:6] special-funtion 3 */ |
| 39 | for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++) { |
| 40 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3)); |
| 41 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 42 | } |
| 43 | case 4: |
| 44 | /* GPG0[3:6] special-funtion 2 */ |
| 45 | for (gpio = S5PV210_GPG0(3); gpio <= S5PV210_GPG0(6); gpio++) { |
| 46 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 47 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 48 | } |
| 49 | default: |
| 50 | break; |
| 51 | } |
| 52 | |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 53 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 54 | s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP); |
| 55 | s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2)); |
| 56 | } |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) |
| 60 | { |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 61 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 62 | unsigned int gpio; |
| 63 | |
| 64 | /* Set all the necessary GPG1[0:1] pins to special-function 2 */ |
| 65 | for (gpio = S5PV210_GPG1(0); gpio < S5PV210_GPG1(2); gpio++) { |
| 66 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 67 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 68 | } |
| 69 | |
| 70 | /* Data pin GPG1[3:6] to special-function 2 */ |
| 71 | for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++) { |
| 72 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 73 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 74 | } |
| 75 | |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 76 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 77 | s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP); |
| 78 | s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2)); |
| 79 | } |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) |
| 83 | { |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 84 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 85 | unsigned int gpio; |
| 86 | |
| 87 | /* Set all the necessary GPG2[0:1] pins to special-function 2 */ |
| 88 | for (gpio = S5PV210_GPG2(0); gpio < S5PV210_GPG2(2); gpio++) { |
| 89 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 90 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 91 | } |
| 92 | |
| 93 | switch (width) { |
| 94 | case 8: |
| 95 | /* Data pin GPG3[3:6] to special-function 3 */ |
| 96 | for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++) { |
| 97 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3)); |
| 98 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 99 | } |
| 100 | case 4: |
| 101 | /* Data pin GPG2[3:6] to special-function 2 */ |
| 102 | for (gpio = S5PV210_GPG2(3); gpio <= S5PV210_GPG2(6); gpio++) { |
| 103 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 104 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 105 | } |
| 106 | default: |
| 107 | break; |
| 108 | } |
| 109 | |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 110 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 111 | s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP); |
| 112 | s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2)); |
| 113 | } |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 114 | } |
Hyuk Lee | 976a62f | 2010-06-14 10:18:56 +0900 | [diff] [blame] | 115 | |
| 116 | void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width) |
| 117 | { |
Kukjin Kim | a68fefe | 2010-08-09 18:30:16 +0900 | [diff] [blame] | 118 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Hyuk Lee | 976a62f | 2010-06-14 10:18:56 +0900 | [diff] [blame] | 119 | unsigned int gpio; |
| 120 | |
| 121 | /* Set all the necessary GPG3[0:2] pins to special-function 2 */ |
| 122 | for (gpio = S5PV210_GPG3(0); gpio < S5PV210_GPG3(2); gpio++) { |
| 123 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 124 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 125 | } |
| 126 | |
| 127 | /* Data pin GPG3[3:6] to special-function 2 */ |
| 128 | for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++) { |
| 129 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 130 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 131 | } |
| 132 | |
Kukjin Kim | a68fefe | 2010-08-09 18:30:16 +0900 | [diff] [blame] | 133 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 134 | s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP); |
| 135 | s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2)); |
| 136 | } |
Hyuk Lee | 976a62f | 2010-06-14 10:18:56 +0900 | [diff] [blame] | 137 | } |