Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
platform-ipu-core.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Pengutronix
3  * Uwe Kleine-Koenig <[email protected]>
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 2 as published by the
7  * Free Software Foundation.
8  */
9 #include <linux/dma-mapping.h>
10 #include <mach/hardware.h>
11 #include <mach/devices-common.h>
12 
13 #define imx_ipu_core_entry_single(soc) \
14 { \
15  .iobase = soc ## _IPU_CTRL_BASE_ADDR, \
16  .synirq = soc ## _INT_IPU_SYN, \
17  .errirq = soc ## _INT_IPU_ERR, \
18 }
19 
20 #ifdef CONFIG_SOC_IMX31
23 #endif
24 
25 #ifdef CONFIG_SOC_IMX35
26 const struct imx_ipu_core_data imx35_ipu_core_data __initconst =
28 #endif
29 
30 static struct platform_device *imx_ipu_coredev __initdata;
31 
33  const struct imx_ipu_core_data *data)
34 {
35  /* The resource order is important! */
36  struct resource res[] = {
37  {
38  .start = data->iobase,
39  .end = data->iobase + 0x5f,
40  .flags = IORESOURCE_MEM,
41  }, {
42  .start = data->iobase + 0x88,
43  .end = data->iobase + 0xb3,
44  .flags = IORESOURCE_MEM,
45  }, {
46  .start = data->synirq,
47  .end = data->synirq,
48  .flags = IORESOURCE_IRQ,
49  }, {
50  .start = data->errirq,
51  .end = data->errirq,
52  .flags = IORESOURCE_IRQ,
53  },
54  };
55 
56  return imx_ipu_coredev = imx_add_platform_device("ipu-core", -1,
57  res, ARRAY_SIZE(res), NULL, 0);
58 }
59 
61  const struct imx_ipu_core_data *data,
62  const struct mx3_camera_pdata *pdata)
63 {
64  struct resource res[] = {
65  {
66  .start = data->iobase + 0x60,
67  .end = data->iobase + 0x87,
68  .flags = IORESOURCE_MEM,
69  },
70  };
71  int ret = -ENOMEM;
72  struct platform_device *pdev;
73 
74  if (IS_ERR_OR_NULL(imx_ipu_coredev))
75  return ERR_PTR(-ENODEV);
76 
77  pdev = platform_device_alloc("mx3-camera", 0);
78  if (!pdev)
79  goto err;
80 
81  pdev->dev.dma_mask = kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
82  if (!pdev->dev.dma_mask)
83  goto err;
84 
85  *pdev->dev.dma_mask = DMA_BIT_MASK(32);
86  pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
87 
88  ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
89  if (ret)
90  goto err;
91 
92  if (pdata) {
93  struct mx3_camera_pdata *copied_pdata;
94 
95  ret = platform_device_add_data(pdev, pdata, sizeof(*pdata));
96  if (ret) {
97 err:
98  kfree(pdev->dev.dma_mask);
99  platform_device_put(pdev);
100  return ERR_PTR(-ENODEV);
101  }
102  copied_pdata = dev_get_platdata(&pdev->dev);
103  copied_pdata->dma_dev = &imx_ipu_coredev->dev;
104  }
105 
106  return pdev;
107 }
108 
110  const struct imx_ipu_core_data *data,
111  struct mx3fb_platform_data *pdata)
112 {
113  struct resource res[] = {
114  {
115  .start = data->iobase + 0xb4,
116  .end = data->iobase + 0x1bf,
117  .flags = IORESOURCE_MEM,
118  },
119  };
120 
121  if (IS_ERR_OR_NULL(imx_ipu_coredev))
122  return ERR_PTR(-ENODEV);
123 
124  pdata->dma_dev = &imx_ipu_coredev->dev;
125 
126  return imx_add_platform_device_dmamask("mx3_sdc_fb", -1,
127  res, ARRAY_SIZE(res), pdata, sizeof(*pdata),
128  DMA_BIT_MASK(32));
129 }