blob: f5499aeb2b6c71009859f66f33a3f4551affa2cf [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
30 /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
Ben Dooks53134a72010-05-27 17:02:32 +090031 s3c_gpio_cfgall_range(S5PV210_GPG0(0), 2,
32 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Ben Dooks64c5bd82010-10-01 14:27:31 +090033
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020034 switch (width) {
35 case 8:
36 /* GPG1[3:6] special-funtion 3 */
Ben Dooks53134a72010-05-27 17:02:32 +090037 s3c_gpio_cfgall_range(S5PV210_GPG1(3), 4,
38 S3C_GPIO_SFN(3), S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020039 case 4:
40 /* GPG0[3:6] special-funtion 2 */
Ben Dooks53134a72010-05-27 17:02:32 +090041 s3c_gpio_cfgall_range(S5PV210_GPG0(3), 4,
42 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020043 default:
44 break;
45 }
46
Marek Szyprowski19206b12010-07-23 09:27:18 +090047 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 Szyprowskie6f66a92010-05-20 08:13:07 +020051}
52
53void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
54{
Marek Szyprowski19206b12010-07-23 09:27:18 +090055 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020056
57 /* Set all the necessary GPG1[0:1] pins to special-function 2 */
Ben Dooks53134a72010-05-27 17:02:32 +090058 s3c_gpio_cfgall_range(S5PV210_GPG1(0), 2,
59 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020060
61 /* Data pin GPG1[3:6] to special-function 2 */
Ben Dooks53134a72010-05-27 17:02:32 +090062 s3c_gpio_cfgall_range(S5PV210_GPG1(3), 4,
63 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020064
Marek Szyprowski19206b12010-07-23 09:27:18 +090065 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 Szyprowskie6f66a92010-05-20 08:13:07 +020069}
70
71void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
72{
Marek Szyprowski19206b12010-07-23 09:27:18 +090073 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020074
75 /* Set all the necessary GPG2[0:1] pins to special-function 2 */
Ben Dooks53134a72010-05-27 17:02:32 +090076 s3c_gpio_cfgall_range(S5PV210_GPG2(0), 2,
77 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020078
79 switch (width) {
80 case 8:
81 /* Data pin GPG3[3:6] to special-function 3 */
Ben Dooks53134a72010-05-27 17:02:32 +090082 s3c_gpio_cfgall_range(S5PV210_GPG3(3), 4,
83 S3C_GPIO_SFN(3), S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020084 case 4:
85 /* Data pin GPG2[3:6] to special-function 2 */
Ben Dooks53134a72010-05-27 17:02:32 +090086 s3c_gpio_cfgall_range(S5PV210_GPG2(3), 4,
87 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020088 default:
89 break;
90 }
91
Marek Szyprowski19206b12010-07-23 09:27:18 +090092 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 Szyprowskie6f66a92010-05-20 08:13:07 +020096}
Hyuk Lee976a62f2010-06-14 10:18:56 +090097
98void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
99{
Kukjin Kima68fefe2010-08-09 18:30:16 +0900100 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Hyuk Lee976a62f2010-06-14 10:18:56 +0900101
Ben Dooks64c5bd82010-10-01 14:27:31 +0900102 /* Set all the necessary GPG3[0:1] pins to special-function 2 */
Ben Dooks53134a72010-05-27 17:02:32 +0900103 s3c_gpio_cfgall_range(S5PV210_GPG3(0), 2,
104 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Hyuk Lee976a62f2010-06-14 10:18:56 +0900105
106 /* Data pin GPG3[3:6] to special-function 2 */
Ben Dooks53134a72010-05-27 17:02:32 +0900107 s3c_gpio_cfgall_range(S5PV210_GPG3(3), 4,
108 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Hyuk Lee976a62f2010-06-14 10:18:56 +0900109
Kukjin Kima68fefe2010-08-09 18:30:16 +0900110 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 Lee976a62f2010-06-14 10:18:56 +0900114}