1 /*
2  * Copyright (C) 2010 Pengutronix
3  * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4  *
5  * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
6  *
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License version 2 as published by the
9  * Free Software Foundation.
10  */
11 
12 #include <linux/compiler.h>
13 #include <linux/err.h>
14 #include <linux/init.h>
15 
16 #include <mach/mx23.h>
17 #include <mach/mx28.h>
18 #include <mach/devices-common.h>
19 
20 #define mxs_mxs_mmc_data_entry_single(soc, _id, hwid)			\
21 	{								\
22 		.id = _id,						\
23 		.iobase = soc ## _SSP ## hwid ## _BASE_ADDR,		\
24 		.dma = soc ## _DMA_SSP ## hwid,				\
25 		.irq_err = soc ## _INT_SSP ## hwid ## _ERROR,		\
26 		.irq_dma = soc ## _INT_SSP ## hwid ## _DMA,		\
27 	}
28 
29 #define mxs_mxs_mmc_data_entry(soc, _id, hwid)				\
30 	[_id] = mxs_mxs_mmc_data_entry_single(soc, _id, hwid)
31 
32 
33 #ifdef CONFIG_SOC_IMX23
34 const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst = {
35 	mxs_mxs_mmc_data_entry(MX23, 0, 1),
36 	mxs_mxs_mmc_data_entry(MX23, 1, 2),
37 };
38 #endif
39 
40 #ifdef CONFIG_SOC_IMX28
41 const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = {
42 	mxs_mxs_mmc_data_entry(MX28, 0, 0),
43 	mxs_mxs_mmc_data_entry(MX28, 1, 1),
44 	mxs_mxs_mmc_data_entry(MX28, 2, 2),
45 	mxs_mxs_mmc_data_entry(MX28, 3, 3),
46 };
47 #endif
48 
mxs_add_mxs_mmc(const struct mxs_mxs_mmc_data * data,const struct mxs_mmc_platform_data * pdata)49 struct platform_device *__init mxs_add_mxs_mmc(
50 		const struct mxs_mxs_mmc_data *data,
51 		const struct mxs_mmc_platform_data *pdata)
52 {
53 	struct resource res[] = {
54 		{
55 			.start	= data->iobase,
56 			.end	= data->iobase + SZ_8K - 1,
57 			.flags	= IORESOURCE_MEM,
58 		}, {
59 			.start	= data->dma,
60 			.end	= data->dma,
61 			.flags	= IORESOURCE_DMA,
62 		}, {
63 			.start	= data->irq_err,
64 			.end	= data->irq_err,
65 			.flags	= IORESOURCE_IRQ,
66 		}, {
67 			.start	= data->irq_dma,
68 			.end	= data->irq_dma,
69 			.flags	= IORESOURCE_IRQ,
70 		},
71 	};
72 
73 	return mxs_add_platform_device("mxs-mmc", data->id,
74 			res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
75 }
76