Marek Szyprowski | 2af716b | 2010-05-18 12:38:45 +0200 | [diff] [blame] | 1 | /* linux/arch/arm/plat-s5pc100/setup-sdhci-gpio.c |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 2 | * |
| 3 | * Copyright 2009 Samsung Eletronics |
| 4 | * |
Marek Szyprowski | 2af716b | 2010-05-18 12:38:45 +0200 | [diff] [blame] | 5 | * S5PC100 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC) |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 6 | * |
| 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 Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 23 | #include <plat/sdhci.h> |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 24 | |
| 25 | void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) |
| 26 | { |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 27 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 28 | 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 Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 35 | /* Set all the necessary GPG0/GPG1 pins to special-function 0 */ |
Ben Dooks | 8f89d5b | 2010-05-27 17:25:46 +0900 | [diff] [blame] | 36 | s3c_gpio_cfgrange_nopull(S5PC100_GPG0(0), 2 + num, S3C_GPIO_SFN(2)); |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 37 | |
Ben Dooks | a40af06 | 2010-10-01 16:49:11 +0900 | [diff] [blame] | 38 | if (width == 8) |
Ben Dooks | 8f89d5b | 2010-05-27 17:25:46 +0900 | [diff] [blame] | 39 | s3c_gpio_cfgrange_nopull(S5PC100_GPG1(0), 2, S3C_GPIO_SFN(2)); |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 40 | |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 41 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 42 | s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP); |
| 43 | s3c_gpio_cfgpin(S5PC100_GPG1(2), S3C_GPIO_SFN(2)); |
| 44 | } |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) |
| 48 | { |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 49 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 50 | |
| 51 | /* Set all the necessary GPG2 pins to special-function 2 */ |
Ben Dooks | 8f89d5b | 2010-05-27 17:25:46 +0900 | [diff] [blame] | 52 | s3c_gpio_cfgrange_nopull(S5PC100_GPG2(0), 2 + width, S3C_GPIO_SFN(2)); |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 53 | |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 54 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 55 | s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP); |
| 56 | s3c_gpio_cfgpin(S5PC100_GPG2(6), S3C_GPIO_SFN(2)); |
| 57 | } |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) |
| 61 | { |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 62 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 63 | |
| 64 | /* Set all the necessary GPG3 pins to special-function 2 */ |
Ben Dooks | 8f89d5b | 2010-05-27 17:25:46 +0900 | [diff] [blame] | 65 | s3c_gpio_cfgrange_nopull(S5PC100_GPG3(0), 2 + width, S3C_GPIO_SFN(2)); |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 66 | |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame] | 67 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 68 | s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP); |
| 69 | s3c_gpio_cfgpin(S5PC100_GPG3(6), S3C_GPIO_SFN(2)); |
| 70 | } |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 71 | } |