blob: 6010c0310cb5203b9d76861ea69c2db656110f64 [file] [log] [blame]
Marek Szyprowski2af716b2010-05-18 12:38:45 +02001/* linux/arch/arm/plat-s5pc100/setup-sdhci-gpio.c
Kyungmin Park86cd4f52009-11-17 08:41:23 +01002 *
3 * Copyright 2009 Samsung Eletronics
4 *
Marek Szyprowski2af716b2010-05-18 12:38:45 +02005 * S5PC100 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
Kyungmin Park86cd4f52009-11-17 08:41:23 +01006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/interrupt.h>
15#include <linux/platform_device.h>
16#include <linux/io.h>
17#include <linux/gpio.h>
18#include <linux/mmc/host.h>
19#include <linux/mmc/card.h>
20
21#include <plat/gpio-cfg.h>
Marek Szyprowski19206b172010-07-23 09:27:18 +090022#include <plat/sdhci.h>
Kyungmin Park86cd4f52009-11-17 08:41:23 +010023
24void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
25{
Marek Szyprowski19206b172010-07-23 09:27:18 +090026 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Kyungmin Park86cd4f52009-11-17 08:41:23 +010027 unsigned int num;
28
29 num = width;
30 /* In case of 8 width, we should decrease the 2 */
31 if (width == 8)
32 num = width - 2;
33
Kyungmin Park86cd4f52009-11-17 08:41:23 +010034 /* Set all the necessary GPG0/GPG1 pins to special-function 0 */
Ben Dooks8f89d5b2010-05-27 17:25:46 +090035 s3c_gpio_cfgrange_nopull(S5PC100_GPG0(0), 2 + num, S3C_GPIO_SFN(2));
Kyungmin Park86cd4f52009-11-17 08:41:23 +010036
Ben Dooksa40af062010-10-01 16:49:11 +090037 if (width == 8)
Ben Dooks8f89d5b2010-05-27 17:25:46 +090038 s3c_gpio_cfgrange_nopull(S5PC100_GPG1(0), 2, S3C_GPIO_SFN(2));
Kyungmin Park86cd4f52009-11-17 08:41:23 +010039
Marek Szyprowski19206b172010-07-23 09:27:18 +090040 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
41 s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP);
42 s3c_gpio_cfgpin(S5PC100_GPG1(2), S3C_GPIO_SFN(2));
43 }
Kyungmin Park86cd4f52009-11-17 08:41:23 +010044}
45
46void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
47{
Marek Szyprowski19206b172010-07-23 09:27:18 +090048 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Kyungmin Park86cd4f52009-11-17 08:41:23 +010049
50 /* Set all the necessary GPG2 pins to special-function 2 */
Ben Dooks8f89d5b2010-05-27 17:25:46 +090051 s3c_gpio_cfgrange_nopull(S5PC100_GPG2(0), 2 + width, S3C_GPIO_SFN(2));
Kyungmin Park86cd4f52009-11-17 08:41:23 +010052
Marek Szyprowski19206b172010-07-23 09:27:18 +090053 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
54 s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP);
55 s3c_gpio_cfgpin(S5PC100_GPG2(6), S3C_GPIO_SFN(2));
56 }
Kyungmin Park86cd4f52009-11-17 08:41:23 +010057}
58
59void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
60{
Marek Szyprowski19206b172010-07-23 09:27:18 +090061 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Kyungmin Park86cd4f52009-11-17 08:41:23 +010062
63 /* Set all the necessary GPG3 pins to special-function 2 */
Ben Dooks8f89d5b2010-05-27 17:25:46 +090064 s3c_gpio_cfgrange_nopull(S5PC100_GPG3(0), 2 + width, S3C_GPIO_SFN(2));
Kyungmin Park86cd4f52009-11-17 08:41:23 +010065
Marek Szyprowski19206b172010-07-23 09:27:18 +090066 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
67 s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP);
68 s3c_gpio_cfgpin(S5PC100_GPG3(6), S3C_GPIO_SFN(2));
69 }
Kyungmin Park86cd4f52009-11-17 08:41:23 +010070}