1275970Scy// SPDX-License-Identifier: GPL-2.0
2275970Scy//
3275970Scy// Copyright 2008 Simtec Electronics
4275970Scy//	Ben Dooks <ben@simtec.co.uk>
5275970Scy//	http://armlinux.simtec.co.uk/
6275970Scy//
7275970Scy// S3C64XX - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
8275970Scy
9275970Scy#include <linux/kernel.h>
10275970Scy#include <linux/types.h>
11275970Scy#include <linux/interrupt.h>
12275970Scy#include <linux/platform_device.h>
13275970Scy#include <linux/io.h>
14275970Scy#include <linux/gpio.h>
15275970Scy
16275970Scy#include "gpio-cfg.h"
17275970Scy#include "sdhci.h"
18275970Scy#include "gpio-samsung.h"
19275970Scy
20275970Scyvoid s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
21275970Scy{
22275970Scy	struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
23275970Scy
24275970Scy	/* Set all the necessary GPG pins to special-function 2 */
25275970Scy	s3c_gpio_cfgrange_nopull(S3C64XX_GPG(0), 2 + width, S3C_GPIO_SFN(2));
26275970Scy
27275970Scy	if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
28275970Scy		s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_UP);
29275970Scy		s3c_gpio_cfgpin(S3C64XX_GPG(6), S3C_GPIO_SFN(2));
30275970Scy	}
31275970Scy}
32275970Scy
33275970Scyvoid s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
34275970Scy{
35275970Scy	struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
36275970Scy
37275970Scy	/* Set all the necessary GPH pins to special-function 2 */
38275970Scy	s3c_gpio_cfgrange_nopull(S3C64XX_GPH(0), 2 + width, S3C_GPIO_SFN(2));
39275970Scy
40275970Scy	if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
41		s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_UP);
42		s3c_gpio_cfgpin(S3C64XX_GPG(6), S3C_GPIO_SFN(3));
43	}
44}
45
46void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
47{
48	/* Set all the necessary GPH pins to special-function 3 */
49	s3c_gpio_cfgrange_nopull(S3C64XX_GPH(6), width, S3C_GPIO_SFN(3));
50
51	/* Set all the necessary GPC pins to special-function 3 */
52	s3c_gpio_cfgrange_nopull(S3C64XX_GPC(4), 2, S3C_GPIO_SFN(3));
53}
54