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 gpio; |
| 29 | unsigned int end; |
| 30 | unsigned int num; |
| 31 | |
| 32 | num = width; |
| 33 | /* In case of 8 width, we should decrease the 2 */ |
| 34 | if (width == 8) |
| 35 | num = width - 2; |
| 36 | |
| 37 | end = S5PC100_GPG0(2 + num); |
| 38 | |
| 39 | /* Set all the necessary GPG0/GPG1 pins to special-function 0 */ |
| 40 | for (gpio = S5PC100_GPG0(0); gpio < end; gpio++) { |
| 41 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 42 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 43 | } |
| 44 | |
| 45 | if (width == 8) { |
| 46 | for (gpio = S5PC100_GPG1(0); gpio <= S5PC100_GPG1(1); gpio++) { |
| 47 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 48 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 49 | } |
| 50 | } |
| 51 | |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame^] | 52 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 53 | s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP); |
| 54 | s3c_gpio_cfgpin(S5PC100_GPG1(2), S3C_GPIO_SFN(2)); |
| 55 | } |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) |
| 59 | { |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame^] | 60 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 61 | unsigned int gpio; |
| 62 | unsigned int end; |
| 63 | |
| 64 | end = S5PC100_GPG2(2 + width); |
| 65 | |
| 66 | /* Set all the necessary GPG2 pins to special-function 2 */ |
| 67 | for (gpio = S5PC100_GPG2(0); gpio < end; gpio++) { |
| 68 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 69 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 70 | } |
| 71 | |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame^] | 72 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 73 | s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP); |
| 74 | s3c_gpio_cfgpin(S5PC100_GPG2(6), S3C_GPIO_SFN(2)); |
| 75 | } |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) |
| 79 | { |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame^] | 80 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 81 | unsigned int gpio; |
| 82 | unsigned int end; |
| 83 | |
| 84 | end = S5PC100_GPG3(2 + width); |
| 85 | |
| 86 | /* Set all the necessary GPG3 pins to special-function 2 */ |
| 87 | for (gpio = S5PC100_GPG3(0); gpio < end; gpio++) { |
| 88 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 89 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 90 | } |
| 91 | |
Marek Szyprowski | 19206b17 | 2010-07-23 09:27:18 +0900 | [diff] [blame^] | 92 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
| 93 | s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP); |
| 94 | s3c_gpio_cfgpin(S5PC100_GPG3(6), S3C_GPIO_SFN(2)); |
| 95 | } |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 96 | } |