Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // Copyright 2009 Wolfson Microelectronics
0004 //      Mark Brown <broonie@opensource.wolfsonmicro.com>
0005 
0006 #include <linux/kernel.h>
0007 #include <linux/string.h>
0008 #include <linux/platform_device.h>
0009 #include <linux/dma-mapping.h>
0010 #include <linux/gpio.h>
0011 #include <linux/export.h>
0012 
0013 #include "irqs.h"
0014 #include "map.h"
0015 
0016 #include "devs.h"
0017 #include <linux/platform_data/asoc-s3c.h>
0018 #include "gpio-cfg.h"
0019 #include "gpio-samsung.h"
0020 
0021 static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
0022 {
0023     unsigned int base;
0024 
0025     switch (pdev->id) {
0026     case 0:
0027         base = S3C64XX_GPD(0);
0028         break;
0029     case 1:
0030         base = S3C64XX_GPE(0);
0031         break;
0032     case 2:
0033         s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
0034         s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
0035         s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
0036         s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
0037         return 0;
0038     default:
0039         printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
0040             pdev->id);
0041         return -EINVAL;
0042     }
0043 
0044     s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
0045 
0046     return 0;
0047 }
0048 
0049 static struct resource s3c64xx_iis0_resource[] = {
0050     [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
0051 };
0052 
0053 static struct s3c_audio_pdata i2s0_pdata = {
0054     .cfg_gpio = s3c64xx_i2s_cfg_gpio,
0055 };
0056 
0057 struct platform_device s3c64xx_device_iis0 = {
0058     .name         = "samsung-i2s",
0059     .id       = 0,
0060     .num_resources    = ARRAY_SIZE(s3c64xx_iis0_resource),
0061     .resource     = s3c64xx_iis0_resource,
0062     .dev = {
0063         .platform_data = &i2s0_pdata,
0064     },
0065 };
0066 EXPORT_SYMBOL(s3c64xx_device_iis0);
0067 
0068 static struct resource s3c64xx_iis1_resource[] = {
0069     [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
0070 };
0071 
0072 static struct s3c_audio_pdata i2s1_pdata = {
0073     .cfg_gpio = s3c64xx_i2s_cfg_gpio,
0074 };
0075 
0076 struct platform_device s3c64xx_device_iis1 = {
0077     .name         = "samsung-i2s",
0078     .id       = 1,
0079     .num_resources    = ARRAY_SIZE(s3c64xx_iis1_resource),
0080     .resource     = s3c64xx_iis1_resource,
0081     .dev = {
0082         .platform_data = &i2s1_pdata,
0083     },
0084 };
0085 EXPORT_SYMBOL(s3c64xx_device_iis1);
0086 
0087 static struct resource s3c64xx_iisv4_resource[] = {
0088     [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
0089 };
0090 
0091 static struct s3c_audio_pdata i2sv4_pdata = {
0092     .cfg_gpio = s3c64xx_i2s_cfg_gpio,
0093     .type = {
0094         .quirks = QUIRK_PRI_6CHAN,
0095     },
0096 };
0097 
0098 struct platform_device s3c64xx_device_iisv4 = {
0099     .name = "samsung-i2s",
0100     .id = 2,
0101     .num_resources    = ARRAY_SIZE(s3c64xx_iisv4_resource),
0102     .resource     = s3c64xx_iisv4_resource,
0103     .dev = {
0104         .platform_data = &i2sv4_pdata,
0105     },
0106 };
0107 EXPORT_SYMBOL(s3c64xx_device_iisv4);
0108 
0109 
0110 /* PCM Controller platform_devices */
0111 
0112 static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
0113 {
0114     unsigned int base;
0115 
0116     switch (pdev->id) {
0117     case 0:
0118         base = S3C64XX_GPD(0);
0119         break;
0120     case 1:
0121         base = S3C64XX_GPE(0);
0122         break;
0123     default:
0124         printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
0125             pdev->id);
0126         return -EINVAL;
0127     }
0128 
0129     s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
0130     return 0;
0131 }
0132 
0133 static struct resource s3c64xx_pcm0_resource[] = {
0134     [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
0135 };
0136 
0137 static struct s3c_audio_pdata s3c_pcm0_pdata = {
0138     .cfg_gpio = s3c64xx_pcm_cfg_gpio,
0139 };
0140 
0141 struct platform_device s3c64xx_device_pcm0 = {
0142     .name         = "samsung-pcm",
0143     .id       = 0,
0144     .num_resources    = ARRAY_SIZE(s3c64xx_pcm0_resource),
0145     .resource     = s3c64xx_pcm0_resource,
0146     .dev = {
0147         .platform_data = &s3c_pcm0_pdata,
0148     },
0149 };
0150 EXPORT_SYMBOL(s3c64xx_device_pcm0);
0151 
0152 static struct resource s3c64xx_pcm1_resource[] = {
0153     [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
0154 };
0155 
0156 static struct s3c_audio_pdata s3c_pcm1_pdata = {
0157     .cfg_gpio = s3c64xx_pcm_cfg_gpio,
0158 };
0159 
0160 struct platform_device s3c64xx_device_pcm1 = {
0161     .name         = "samsung-pcm",
0162     .id       = 1,
0163     .num_resources    = ARRAY_SIZE(s3c64xx_pcm1_resource),
0164     .resource     = s3c64xx_pcm1_resource,
0165     .dev = {
0166         .platform_data = &s3c_pcm1_pdata,
0167     },
0168 };
0169 EXPORT_SYMBOL(s3c64xx_device_pcm1);
0170 
0171 /* AC97 Controller platform devices */
0172 
0173 static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
0174 {
0175     return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
0176 }
0177 
0178 static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
0179 {
0180     return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
0181 }
0182 
0183 static struct resource s3c64xx_ac97_resource[] = {
0184     [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
0185     [1] = DEFINE_RES_IRQ(IRQ_AC97),
0186 };
0187 
0188 static struct s3c_audio_pdata s3c_ac97_pdata = {
0189 };
0190 
0191 static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
0192 
0193 struct platform_device s3c64xx_device_ac97 = {
0194     .name         = "samsung-ac97",
0195     .id       = -1,
0196     .num_resources    = ARRAY_SIZE(s3c64xx_ac97_resource),
0197     .resource     = s3c64xx_ac97_resource,
0198     .dev = {
0199         .platform_data = &s3c_ac97_pdata,
0200         .dma_mask = &s3c64xx_ac97_dmamask,
0201         .coherent_dma_mask = DMA_BIT_MASK(32),
0202     },
0203 };
0204 EXPORT_SYMBOL(s3c64xx_device_ac97);
0205 
0206 void __init s3c64xx_ac97_setup_gpio(int num)
0207 {
0208     if (num == S3C64XX_AC97_GPD)
0209         s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
0210     else
0211         s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
0212 }