blob: a8d22a7b158144a7323ac148a74b11b5299d06a9 [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>
22#include <plat/regs-sdhci.h>
Marek Szyprowski19206b172010-07-23 09:27:18 +090023#include <plat/sdhci.h>
Kyungmin Park86cd4f52009-11-17 08:41:23 +010024
25void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
26{
Marek Szyprowski19206b172010-07-23 09:27:18 +090027 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Kyungmin Park86cd4f52009-11-17 08:41:23 +010028 unsigned int num;
29
30 num = width;
31 /* In case of 8 width, we should decrease the 2 */
32 if (width == 8)
33 num = width - 2;
34
Kyungmin Park86cd4f52009-11-17 08:41:23 +010035 /* Set all the necessary GPG0/GPG1 pins to special-function 0 */
Ben Dooksa40af062010-10-01 16:49:11 +090036 s3c_gpio_cfgall_range(S5PC100_GPG0(0), 2 + num,
37 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Kyungmin Park86cd4f52009-11-17 08:41:23 +010038
Ben Dooksa40af062010-10-01 16:49:11 +090039 if (width == 8)
40 s3c_gpio_cfgall_range(S5PC100_GPG1(0), 2,
41 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Kyungmin Park86cd4f52009-11-17 08:41:23 +010042
Marek Szyprowski19206b172010-07-23 09:27:18 +090043 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
44 s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP);
45 s3c_gpio_cfgpin(S5PC100_GPG1(2), S3C_GPIO_SFN(2));
46 }
Kyungmin Park86cd4f52009-11-17 08:41:23 +010047}
48
49void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
50{
Marek Szyprowski19206b172010-07-23 09:27:18 +090051 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Kyungmin Park86cd4f52009-11-17 08:41:23 +010052
53 /* Set all the necessary GPG2 pins to special-function 2 */
Ben Dooksa40af062010-10-01 16:49:11 +090054 s3c_gpio_cfgall_range(S5PC100_GPG2(0), 2 + width,
55 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Kyungmin Park86cd4f52009-11-17 08:41:23 +010056
Marek Szyprowski19206b172010-07-23 09:27:18 +090057 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
58 s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP);
59 s3c_gpio_cfgpin(S5PC100_GPG2(6), S3C_GPIO_SFN(2));
60 }
Kyungmin Park86cd4f52009-11-17 08:41:23 +010061}
62
63void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
64{
Marek Szyprowski19206b172010-07-23 09:27:18 +090065 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
Kyungmin Park86cd4f52009-11-17 08:41:23 +010066
67 /* Set all the necessary GPG3 pins to special-function 2 */
Ben Dooksa40af062010-10-01 16:49:11 +090068 s3c_gpio_cfgall_range(S5PC100_GPG3(0), 2 + width,
69 S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
Kyungmin Park86cd4f52009-11-17 08:41:23 +010070
Marek Szyprowski19206b172010-07-23 09:27:18 +090071 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
72 s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP);
73 s3c_gpio_cfgpin(S5PC100_GPG3(6), S3C_GPIO_SFN(2));
74 }
Kyungmin Park86cd4f52009-11-17 08:41:23 +010075}