blob: 746777d56df95ab51e817227cf3c97ce4db34b62 [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 */
Kukjin Kima7aac9d2010-10-01 20:12:24 +090031 s3c_gpio_cfgrange_nopull(S5PV210_GPG0(0), 2, S3C_GPIO_SFN(2));
Ben Dooks64c5bd82010-10-01 14:27:31 +090032
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020033 switch (width) {
34 case 8:
35 /* GPG1[3:6] special-funtion 3 */
Ben Dooks5a350da2010-05-27 17:25:47 +090036 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3));
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020037 case 4:
38 /* GPG0[3:6] special-funtion 2 */
Ben Dooks5a350da2010-05-27 17:25:47 +090039 s3c_gpio_cfgrange_nopull(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2));
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020040 default:
41 break;
42 }
43
Marek Szyprowski19206b12010-07-23 09:27:18 +090044 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
45 s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP);
46 s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2));
47 }
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020048}
49
50void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
51{
Marek Szyprowski19206b12010-07-23 09:27:18 +090052 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020053
54 /* Set all the necessary GPG1[0:1] pins to special-function 2 */
Ben Dooks5a350da2010-05-27 17:25:47 +090055 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2));
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020056
57 /* Data pin GPG1[3:6] to special-function 2 */
Ben Dooks5a350da2010-05-27 17:25:47 +090058 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2));
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020059
Marek Szyprowski19206b12010-07-23 09:27:18 +090060 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
61 s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
62 s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2));
63 }
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020064}
65
66void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
67{
Marek Szyprowski19206b12010-07-23 09:27:18 +090068 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020069
70 /* Set all the necessary GPG2[0:1] pins to special-function 2 */
Ben Dooks5a350da2010-05-27 17:25:47 +090071 s3c_gpio_cfgrange_nopull(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2));
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020072
73 switch (width) {
74 case 8:
75 /* Data pin GPG3[3:6] to special-function 3 */
Ben Dooks5a350da2010-05-27 17:25:47 +090076 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3));
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020077 case 4:
78 /* Data pin GPG2[3:6] to special-function 2 */
Ben Dooks5a350da2010-05-27 17:25:47 +090079 s3c_gpio_cfgrange_nopull(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2));
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020080 default:
81 break;
82 }
83
Marek Szyprowski19206b12010-07-23 09:27:18 +090084 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
85 s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP);
86 s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2));
87 }
Marek Szyprowskie6f66a92010-05-20 08:13:07 +020088}
Hyuk Lee976a62f2010-06-14 10:18:56 +090089
90void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
91{
Kukjin Kima68fefe2010-08-09 18:30:16 +090092 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Hyuk Lee976a62f2010-06-14 10:18:56 +090093
Ben Dooks64c5bd82010-10-01 14:27:31 +090094 /* Set all the necessary GPG3[0:1] pins to special-function 2 */
Kukjin Kima7aac9d2010-10-01 20:12:24 +090095 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(0), 2, S3C_GPIO_SFN(2));
Hyuk Lee976a62f2010-06-14 10:18:56 +090096
97 /* Data pin GPG3[3:6] to special-function 2 */
Kukjin Kima7aac9d2010-10-01 20:12:24 +090098 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(2));
Hyuk Lee976a62f2010-06-14 10:18:56 +090099
Kukjin Kima68fefe2010-08-09 18:30:16 +0900100 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
101 s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP);
102 s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2));
103 }
Hyuk Lee976a62f2010-06-14 10:18:56 +0900104}