1 /*
2  * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License version 2 as published by the
6  * Free Software Foundation.
7  */
8 #include <linux/compiler.h>
9 #include <linux/err.h>
10 #include <linux/init.h>
11 
12 #include <mach/mx23.h>
13 #include <mach/mx28.h>
14 #include <mach/devices-common.h>
15 
16 #define mxs_saif_data_entry_single(soc, _id)				\
17 	{								\
18 		.id = _id,						\
19 		.iobase = soc ## _SAIF ## _id ## _BASE_ADDR,		\
20 		.irq = soc ## _INT_SAIF ## _id,				\
21 		.dma = soc ## _DMA_SAIF ## _id,				\
22 		.dmairq = soc ## _INT_SAIF ## _id ##_DMA,		\
23 	}
24 
25 #define mxs_saif_data_entry(soc, _id)					\
26 	[_id] = mxs_saif_data_entry_single(soc, _id)
27 
28 #ifdef CONFIG_SOC_IMX28
29 const struct mxs_saif_data mx28_saif_data[] __initconst = {
30 	mxs_saif_data_entry(MX28, 0),
31 	mxs_saif_data_entry(MX28, 1),
32 };
33 #endif
34 
mxs_add_saif(const struct mxs_saif_data * data,const struct mxs_saif_platform_data * pdata)35 struct platform_device *__init mxs_add_saif(const struct mxs_saif_data *data,
36 				const struct mxs_saif_platform_data *pdata)
37 {
38 	struct resource res[] = {
39 		{
40 			.start = data->iobase,
41 			.end = data->iobase + SZ_4K - 1,
42 			.flags = IORESOURCE_MEM,
43 		}, {
44 			.start = data->irq,
45 			.end = data->irq,
46 			.flags = IORESOURCE_IRQ,
47 		}, {
48 			.start = data->dma,
49 			.end = data->dma,
50 			.flags = IORESOURCE_DMA,
51 		}, {
52 			.start = data->dmairq,
53 			.end = data->dmairq,
54 			.flags = IORESOURCE_IRQ,
55 		},
56 
57 	};
58 
59 	return mxs_add_platform_device("mxs-saif", data->id, res,
60 				ARRAY_SIZE(res), pdata, sizeof(*pdata));
61 }
62