171b9114dSArnd Bergmann // SPDX-License-Identifier: GPL-2.0
271b9114dSArnd Bergmann //
371b9114dSArnd Bergmann // Copyright 2009 Wolfson Microelectronics
471b9114dSArnd Bergmann // Mark Brown <broonie@opensource.wolfsonmicro.com>
571b9114dSArnd Bergmann
671b9114dSArnd Bergmann #include <linux/kernel.h>
771b9114dSArnd Bergmann #include <linux/string.h>
871b9114dSArnd Bergmann #include <linux/platform_device.h>
971b9114dSArnd Bergmann #include <linux/dma-mapping.h>
1071b9114dSArnd Bergmann #include <linux/gpio.h>
1171b9114dSArnd Bergmann #include <linux/export.h>
1271b9114dSArnd Bergmann
13*c78a41fcSArnd Bergmann #include "irqs.h"
14c6ff132dSArnd Bergmann #include "map.h"
1571b9114dSArnd Bergmann
16c6ff132dSArnd Bergmann #include "devs.h"
1771b9114dSArnd Bergmann #include <linux/platform_data/asoc-s3c.h>
18c6ff132dSArnd Bergmann #include "gpio-cfg.h"
19c6ff132dSArnd Bergmann #include "gpio-samsung.h"
2071b9114dSArnd Bergmann
s3c64xx_i2s_cfg_gpio(struct platform_device * pdev)2171b9114dSArnd Bergmann static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
2271b9114dSArnd Bergmann {
2371b9114dSArnd Bergmann unsigned int base;
2471b9114dSArnd Bergmann
2571b9114dSArnd Bergmann switch (pdev->id) {
2671b9114dSArnd Bergmann case 0:
2771b9114dSArnd Bergmann base = S3C64XX_GPD(0);
2871b9114dSArnd Bergmann break;
2971b9114dSArnd Bergmann case 1:
3071b9114dSArnd Bergmann base = S3C64XX_GPE(0);
3171b9114dSArnd Bergmann break;
3271b9114dSArnd Bergmann case 2:
3371b9114dSArnd Bergmann s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
3471b9114dSArnd Bergmann s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
3571b9114dSArnd Bergmann s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
3671b9114dSArnd Bergmann s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
3771b9114dSArnd Bergmann return 0;
3871b9114dSArnd Bergmann default:
3971b9114dSArnd Bergmann printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
4071b9114dSArnd Bergmann pdev->id);
4171b9114dSArnd Bergmann return -EINVAL;
4271b9114dSArnd Bergmann }
4371b9114dSArnd Bergmann
4471b9114dSArnd Bergmann s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
4571b9114dSArnd Bergmann
4671b9114dSArnd Bergmann return 0;
4771b9114dSArnd Bergmann }
4871b9114dSArnd Bergmann
4971b9114dSArnd Bergmann static struct resource s3c64xx_iis0_resource[] = {
5071b9114dSArnd Bergmann [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
5171b9114dSArnd Bergmann };
5271b9114dSArnd Bergmann
5371b9114dSArnd Bergmann static struct s3c_audio_pdata i2s0_pdata = {
5471b9114dSArnd Bergmann .cfg_gpio = s3c64xx_i2s_cfg_gpio,
5571b9114dSArnd Bergmann };
5671b9114dSArnd Bergmann
5771b9114dSArnd Bergmann struct platform_device s3c64xx_device_iis0 = {
5871b9114dSArnd Bergmann .name = "samsung-i2s",
5971b9114dSArnd Bergmann .id = 0,
6071b9114dSArnd Bergmann .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
6171b9114dSArnd Bergmann .resource = s3c64xx_iis0_resource,
6271b9114dSArnd Bergmann .dev = {
6371b9114dSArnd Bergmann .platform_data = &i2s0_pdata,
6471b9114dSArnd Bergmann },
6571b9114dSArnd Bergmann };
6671b9114dSArnd Bergmann EXPORT_SYMBOL(s3c64xx_device_iis0);
6771b9114dSArnd Bergmann
6871b9114dSArnd Bergmann static struct resource s3c64xx_iis1_resource[] = {
6971b9114dSArnd Bergmann [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
7071b9114dSArnd Bergmann };
7171b9114dSArnd Bergmann
7271b9114dSArnd Bergmann static struct s3c_audio_pdata i2s1_pdata = {
7371b9114dSArnd Bergmann .cfg_gpio = s3c64xx_i2s_cfg_gpio,
7471b9114dSArnd Bergmann };
7571b9114dSArnd Bergmann
7671b9114dSArnd Bergmann struct platform_device s3c64xx_device_iis1 = {
7771b9114dSArnd Bergmann .name = "samsung-i2s",
7871b9114dSArnd Bergmann .id = 1,
7971b9114dSArnd Bergmann .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
8071b9114dSArnd Bergmann .resource = s3c64xx_iis1_resource,
8171b9114dSArnd Bergmann .dev = {
8271b9114dSArnd Bergmann .platform_data = &i2s1_pdata,
8371b9114dSArnd Bergmann },
8471b9114dSArnd Bergmann };
8571b9114dSArnd Bergmann EXPORT_SYMBOL(s3c64xx_device_iis1);
86