Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame^] | 1 | /* 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> |
| 18 | #include <linux/mmc/host.h> |
| 19 | #include <linux/mmc/card.h> |
| 20 | |
| 21 | #include <mach/gpio.h> |
| 22 | #include <plat/gpio-cfg.h> |
| 23 | #include <plat/regs-sdhci.h> |
| 24 | |
| 25 | void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) |
| 26 | { |
| 27 | unsigned int gpio; |
| 28 | |
| 29 | /* Set all the necessary GPG0/GPG1 pins to special-function 2 */ |
| 30 | for (gpio = S5PV210_GPG0(0); gpio < S5PV210_GPG0(2); gpio++) { |
| 31 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 32 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 33 | } |
| 34 | switch (width) { |
| 35 | case 8: |
| 36 | /* GPG1[3:6] special-funtion 3 */ |
| 37 | for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++) { |
| 38 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3)); |
| 39 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 40 | } |
| 41 | case 4: |
| 42 | /* GPG0[3:6] special-funtion 2 */ |
| 43 | for (gpio = S5PV210_GPG0(3); gpio <= S5PV210_GPG0(6); gpio++) { |
| 44 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 45 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 46 | } |
| 47 | default: |
| 48 | break; |
| 49 | } |
| 50 | |
| 51 | s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP); |
| 52 | s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2)); |
| 53 | } |
| 54 | |
| 55 | void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) |
| 56 | { |
| 57 | unsigned int gpio; |
| 58 | |
| 59 | /* Set all the necessary GPG1[0:1] pins to special-function 2 */ |
| 60 | for (gpio = S5PV210_GPG1(0); gpio < S5PV210_GPG1(2); gpio++) { |
| 61 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 62 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 63 | } |
| 64 | |
| 65 | /* Data pin GPG1[3:6] to special-function 2 */ |
| 66 | for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++) { |
| 67 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 68 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 69 | } |
| 70 | |
| 71 | s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP); |
| 72 | s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2)); |
| 73 | } |
| 74 | |
| 75 | void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) |
| 76 | { |
| 77 | unsigned int gpio; |
| 78 | |
| 79 | /* Set all the necessary GPG2[0:1] pins to special-function 2 */ |
| 80 | for (gpio = S5PV210_GPG2(0); gpio < S5PV210_GPG2(2); gpio++) { |
| 81 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 82 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 83 | } |
| 84 | |
| 85 | switch (width) { |
| 86 | case 8: |
| 87 | /* Data pin GPG3[3:6] to special-function 3 */ |
| 88 | for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++) { |
| 89 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3)); |
| 90 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 91 | } |
| 92 | case 4: |
| 93 | /* Data pin GPG2[3:6] to special-function 2 */ |
| 94 | for (gpio = S5PV210_GPG2(3); gpio <= S5PV210_GPG2(6); gpio++) { |
| 95 | s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); |
| 96 | s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); |
| 97 | } |
| 98 | default: |
| 99 | break; |
| 100 | } |
| 101 | |
| 102 | s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP); |
| 103 | s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2)); |
| 104 | } |