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 | |
| 30 | /* Set all the necessary GPG0/GPG1 pins to special-function 2 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 31 | s3c_gpio_cfgall_range(S5PV210_GPG0(0), 2, |
| 32 | S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE); |
Ben Dooks | 64c5bd8 | 2010-10-01 14:27:31 +0900 | [diff] [blame] | 33 | |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 34 | switch (width) { |
| 35 | case 8: |
| 36 | /* GPG1[3:6] special-funtion 3 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 37 | s3c_gpio_cfgall_range(S5PV210_GPG1(3), 4, |
| 38 | S3C_GPIO_SFN(3), S3C_GPIO_PULL_NONE); |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 39 | case 4: |
| 40 | /* GPG0[3:6] special-funtion 2 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 41 | s3c_gpio_cfgall_range(S5PV210_GPG0(3), 4, |
| 42 | S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE); |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 43 | default: |
| 44 | break; |
| 45 | } |
| 46 | |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 47 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 48 | s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP); |
| 49 | s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2)); |
| 50 | } |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) |
| 54 | { |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 55 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 56 | |
| 57 | /* Set all the necessary GPG1[0:1] pins to special-function 2 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 58 | s3c_gpio_cfgall_range(S5PV210_GPG1(0), 2, |
| 59 | S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE); |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 60 | |
| 61 | /* Data pin GPG1[3:6] to special-function 2 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 62 | s3c_gpio_cfgall_range(S5PV210_GPG1(3), 4, |
| 63 | S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE); |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 64 | |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 65 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 66 | s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP); |
| 67 | s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2)); |
| 68 | } |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) |
| 72 | { |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 73 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 74 | |
| 75 | /* Set all the necessary GPG2[0:1] pins to special-function 2 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 76 | s3c_gpio_cfgall_range(S5PV210_GPG2(0), 2, |
| 77 | S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE); |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 78 | |
| 79 | switch (width) { |
| 80 | case 8: |
| 81 | /* Data pin GPG3[3:6] to special-function 3 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 82 | s3c_gpio_cfgall_range(S5PV210_GPG3(3), 4, |
| 83 | S3C_GPIO_SFN(3), S3C_GPIO_PULL_NONE); |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 84 | case 4: |
| 85 | /* Data pin GPG2[3:6] to special-function 2 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 86 | s3c_gpio_cfgall_range(S5PV210_GPG2(3), 4, |
| 87 | S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE); |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 88 | default: |
| 89 | break; |
| 90 | } |
| 91 | |
Marek Szyprowski | 19206b1 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 92 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 93 | s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP); |
| 94 | s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2)); |
| 95 | } |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 96 | } |
Hyuk Lee | 976a62f | 2010-06-14 10:18:56 +0900 | [diff] [blame] | 97 | |
| 98 | void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width) |
| 99 | { |
Kukjin Kim | a68fefe | 2010-08-09 18:30:16 +0900 | [diff] [blame] | 100 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Hyuk Lee | 976a62f | 2010-06-14 10:18:56 +0900 | [diff] [blame] | 101 | |
Ben Dooks | 64c5bd8 | 2010-10-01 14:27:31 +0900 | [diff] [blame] | 102 | /* Set all the necessary GPG3[0:1] pins to special-function 2 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 103 | s3c_gpio_cfgall_range(S5PV210_GPG3(0), 2, |
| 104 | S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE); |
Hyuk Lee | 976a62f | 2010-06-14 10:18:56 +0900 | [diff] [blame] | 105 | |
| 106 | /* Data pin GPG3[3:6] to special-function 2 */ |
Ben Dooks | 53134a7 | 2010-05-27 17:02:32 +0900 | [diff] [blame^] | 107 | s3c_gpio_cfgall_range(S5PV210_GPG3(3), 4, |
| 108 | S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE); |
Hyuk Lee | 976a62f | 2010-06-14 10:18:56 +0900 | [diff] [blame] | 109 | |
Kukjin Kim | a68fefe | 2010-08-09 18:30:16 +0900 | [diff] [blame] | 110 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 111 | s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP); |
| 112 | s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2)); |
| 113 | } |
Hyuk Lee | 976a62f | 2010-06-14 10:18:56 +0900 | [diff] [blame] | 114 | } |