linux/arch/arm/mach-s5p6442/dev-audio.c
<<
>>
Prefs
   1/* linux/arch/arm/mach-s5p6442/dev-audio.c
   2 *
   3 * Copyright (c) 2010 Samsung Electronics Co. Ltd
   4 *      Jaswinder Singh <jassi.brar@samsung.com>
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License version 2 as
   8 * published by the Free Software Foundation.
   9 */
  10
  11#include <linux/platform_device.h>
  12#include <linux/dma-mapping.h>
  13#include <linux/gpio.h>
  14
  15#include <plat/gpio-cfg.h>
  16#include <plat/audio.h>
  17
  18#include <mach/map.h>
  19#include <mach/dma.h>
  20#include <mach/irqs.h>
  21
  22static int s5p6442_cfg_i2s(struct platform_device *pdev)
  23{
  24        unsigned int base;
  25
  26        /* configure GPIO for i2s port */
  27        switch (pdev->id) {
  28        case 1:
  29                base = S5P6442_GPC1(0);
  30                break;
  31
  32        case 0:
  33                base = S5P6442_GPC0(0);
  34                break;
  35
  36        default:
  37                printk(KERN_ERR "Invalid Device %d\n", pdev->id);
  38                return -EINVAL;
  39        }
  40
  41        s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
  42        return 0;
  43}
  44
  45static const char *rclksrc_v35[] = {
  46        [0] = "busclk",
  47        [1] = "i2sclk",
  48};
  49
  50static struct s3c_audio_pdata i2sv35_pdata = {
  51        .cfg_gpio = s5p6442_cfg_i2s,
  52        .type = {
  53                .i2s = {
  54                        .quirks = QUIRK_SEC_DAI | QUIRK_NEED_RSTCLR,
  55                        .src_clk = rclksrc_v35,
  56                },
  57        },
  58};
  59
  60static struct resource s5p6442_iis0_resource[] = {
  61        [0] = {
  62                .start = S5P6442_PA_I2S0,
  63                .end   = S5P6442_PA_I2S0 + 0x100 - 1,
  64                .flags = IORESOURCE_MEM,
  65        },
  66        [1] = {
  67                .start = DMACH_I2S0_TX,
  68                .end   = DMACH_I2S0_TX,
  69                .flags = IORESOURCE_DMA,
  70        },
  71        [2] = {
  72                .start = DMACH_I2S0_RX,
  73                .end   = DMACH_I2S0_RX,
  74                .flags = IORESOURCE_DMA,
  75        },
  76        [3] = {
  77                .start = DMACH_I2S0S_TX,
  78                .end = DMACH_I2S0S_TX,
  79                .flags = IORESOURCE_DMA,
  80        },
  81};
  82
  83struct platform_device s5p6442_device_iis0 = {
  84        .name = "samsung-i2s",
  85        .id = 0,
  86        .num_resources    = ARRAY_SIZE(s5p6442_iis0_resource),
  87        .resource         = s5p6442_iis0_resource,
  88        .dev = {
  89                .platform_data = &i2sv35_pdata,
  90        },
  91};
  92
  93static const char *rclksrc_v3[] = {
  94        [0] = "iis",
  95        [1] = "sclk_audio",
  96};
  97
  98static struct s3c_audio_pdata i2sv3_pdata = {
  99        .cfg_gpio = s5p6442_cfg_i2s,
 100        .type = {
 101                .i2s = {
 102                        .src_clk = rclksrc_v3,
 103                },
 104        },
 105};
 106
 107static struct resource s5p6442_iis1_resource[] = {
 108        [0] = {
 109                .start = S5P6442_PA_I2S1,
 110                .end   = S5P6442_PA_I2S1 + 0x100 - 1,
 111                .flags = IORESOURCE_MEM,
 112        },
 113        [1] = {
 114                .start = DMACH_I2S1_TX,
 115                .end   = DMACH_I2S1_TX,
 116                .flags = IORESOURCE_DMA,
 117        },
 118        [2] = {
 119                .start = DMACH_I2S1_RX,
 120                .end   = DMACH_I2S1_RX,
 121                .flags = IORESOURCE_DMA,
 122        },
 123};
 124
 125struct platform_device s5p6442_device_iis1 = {
 126        .name             = "samsung-i2s",
 127        .id               = 1,
 128        .num_resources    = ARRAY_SIZE(s5p6442_iis1_resource),
 129        .resource         = s5p6442_iis1_resource,
 130        .dev = {
 131                .platform_data = &i2sv3_pdata,
 132        },
 133};
 134
 135/* PCM Controller platform_devices */
 136
 137static int s5p6442_pcm_cfg_gpio(struct platform_device *pdev)
 138{
 139        unsigned int base;
 140
 141        switch (pdev->id) {
 142        case 0:
 143                base = S5P6442_GPC0(0);
 144                break;
 145
 146        case 1:
 147                base = S5P6442_GPC1(0);
 148                break;
 149
 150        default:
 151                printk(KERN_DEBUG "Invalid PCM Controller number!");
 152                return -EINVAL;
 153        }
 154
 155        s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
 156        return 0;
 157}
 158
 159static struct s3c_audio_pdata s3c_pcm_pdata = {
 160        .cfg_gpio = s5p6442_pcm_cfg_gpio,
 161};
 162
 163static struct resource s5p6442_pcm0_resource[] = {
 164        [0] = {
 165                .start = S5P6442_PA_PCM0,
 166                .end   = S5P6442_PA_PCM0 + 0x100 - 1,
 167                .flags = IORESOURCE_MEM,
 168        },
 169        [1] = {
 170                .start = DMACH_PCM0_TX,
 171                .end   = DMACH_PCM0_TX,
 172                .flags = IORESOURCE_DMA,
 173        },
 174        [2] = {
 175                .start = DMACH_PCM0_RX,
 176                .end   = DMACH_PCM0_RX,
 177                .flags = IORESOURCE_DMA,
 178        },
 179};
 180
 181struct platform_device s5p6442_device_pcm0 = {
 182        .name             = "samsung-pcm",
 183        .id               = 0,
 184        .num_resources    = ARRAY_SIZE(s5p6442_pcm0_resource),
 185        .resource         = s5p6442_pcm0_resource,
 186        .dev = {
 187                .platform_data = &s3c_pcm_pdata,
 188        },
 189};
 190
 191static struct resource s5p6442_pcm1_resource[] = {
 192        [0] = {
 193                .start = S5P6442_PA_PCM1,
 194                .end   = S5P6442_PA_PCM1 + 0x100 - 1,
 195                .flags = IORESOURCE_MEM,
 196        },
 197        [1] = {
 198                .start = DMACH_PCM1_TX,
 199                .end   = DMACH_PCM1_TX,
 200                .flags = IORESOURCE_DMA,
 201        },
 202        [2] = {
 203                .start = DMACH_PCM1_RX,
 204                .end   = DMACH_PCM1_RX,
 205                .flags = IORESOURCE_DMA,
 206        },
 207};
 208
 209struct platform_device s5p6442_device_pcm1 = {
 210        .name             = "samsung-pcm",
 211        .id               = 1,
 212        .num_resources    = ARRAY_SIZE(s5p6442_pcm1_resource),
 213        .resource         = s5p6442_pcm1_resource,
 214        .dev = {
 215                .platform_data = &s3c_pcm_pdata,
 216        },
 217};
 218