blob: 706427837d82adcdc2e06a3ece5ef8c78f8a34e7 [file] [log] [blame]
Marek Szyprowskie6f66a92010-05-20 08:13:07 +02001/* 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 Kim1c739c72010-08-05 07:54:49 +090018#include <linux/gpio.h>
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020019#include <linux/mmc/host.h>
20#include <linux/mmc/card.h>
21
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020022#include <plat/gpio-cfg.h>
23#include <plat/regs-sdhci.h>
Marek Szyprowski19206b12010-07-23 09:27:18 +090024#include <plat/sdhci.h>
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020025
26void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
27{
Marek Szyprowski19206b12010-07-23 09:27:18 +090028 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020029 unsigned int gpio;
30
31 /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
Ben Dooks64c5bd82010-10-01 14:27:31 +090032 s3c_gpio_cfgpin_range(S5PV210_GPG0(0), 2, S3C_GPIO_SFN(2));
33 for (gpio = S5PV210_GPG0(0); gpio < S5PV210_GPG0(2); gpio++)
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020034 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Ben Dooks64c5bd82010-10-01 14:27:31 +090035
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020036 switch (width) {
37 case 8:
38 /* GPG1[3:6] special-funtion 3 */
Ben Dooks64c5bd82010-10-01 14:27:31 +090039 s3c_gpio_cfgpin_range(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3));
40 for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++)
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020041 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020042 case 4:
43 /* GPG0[3:6] special-funtion 2 */
Ben Dooks64c5bd82010-10-01 14:27:31 +090044 s3c_gpio_cfgpin_range(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2));
45 for (gpio = S5PV210_GPG0(3); gpio <= S5PV210_GPG0(6); gpio++)
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020046 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020047 default:
48 break;
49 }
50
Marek Szyprowski19206b12010-07-23 09:27:18 +090051 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
52 s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP);
53 s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2));
54 }
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020055}
56
57void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
58{
Marek Szyprowski19206b12010-07-23 09:27:18 +090059 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020060 unsigned int gpio;
61
62 /* Set all the necessary GPG1[0:1] pins to special-function 2 */
Ben Dooks64c5bd82010-10-01 14:27:31 +090063 s3c_gpio_cfgpin_range(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2));
64 for (gpio = S5PV210_GPG1(0); gpio < S5PV210_GPG1(2); gpio++)
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020065 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020066
67 /* Data pin GPG1[3:6] to special-function 2 */
Ben Dooks64c5bd82010-10-01 14:27:31 +090068 s3c_gpio_cfgpin_range(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2));
69 for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++)
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020070 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020071
Marek Szyprowski19206b12010-07-23 09:27:18 +090072 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
73 s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
74 s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2));
75 }
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020076}
77
78void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
79{
Marek Szyprowski19206b12010-07-23 09:27:18 +090080 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020081 unsigned int gpio;
82
83 /* Set all the necessary GPG2[0:1] pins to special-function 2 */
Ben Dooks64c5bd82010-10-01 14:27:31 +090084 s3c_gpio_cfgpin_range(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2));
85 for (gpio = S5PV210_GPG2(0); gpio < S5PV210_GPG2(2); gpio++)
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020086 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020087
88 switch (width) {
89 case 8:
90 /* Data pin GPG3[3:6] to special-function 3 */
Ben Dooks64c5bd82010-10-01 14:27:31 +090091 s3c_gpio_cfgpin_range(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3));
92 for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++)
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020093 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020094 case 4:
95 /* Data pin GPG2[3:6] to special-function 2 */
Ben Dooks64c5bd82010-10-01 14:27:31 +090096 s3c_gpio_cfgpin_range(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2));
97 for (gpio = S5PV210_GPG2(3); gpio <= S5PV210_GPG2(6); gpio++)
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020098 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020099 default:
100 break;
101 }
102
Marek Szyprowski19206b12010-07-23 09:27:18 +0900103 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
104 s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP);
105 s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2));
106 }
Marek Szyprowskie6f66a92010-05-20 08:13:07 +0200107}
Hyuk Lee976a62f2010-06-14 10:18:56 +0900108
109void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
110{
Kukjin Kima68fefe2010-08-09 18:30:16 +0900111 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Hyuk Lee976a62f2010-06-14 10:18:56 +0900112 unsigned int gpio;
113
Ben Dooks64c5bd82010-10-01 14:27:31 +0900114 /* Set all the necessary GPG3[0:1] pins to special-function 2 */
115 s3c_gpio_cfgpin_range(S5PV210_GPG3(0), 2, S3C_GPIO_SFN(2));
116 for (gpio = S5PV210_GPG3(0); gpio < S5PV210_GPG3(2); gpio++)
Hyuk Lee976a62f2010-06-14 10:18:56 +0900117 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Hyuk Lee976a62f2010-06-14 10:18:56 +0900118
119 /* Data pin GPG3[3:6] to special-function 2 */
Ben Dooks64c5bd82010-10-01 14:27:31 +0900120 s3c_gpio_cfgpin_range(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(2));
121 for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++)
Hyuk Lee976a62f2010-06-14 10:18:56 +0900122 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
Hyuk Lee976a62f2010-06-14 10:18:56 +0900123
Kukjin Kima68fefe2010-08-09 18:30:16 +0900124 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
125 s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP);
126 s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2));
127 }
Hyuk Lee976a62f2010-06-14 10:18:56 +0900128}