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