platform-mxs-mmc.c 2.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Copyright (C) 2010 Pengutronix
 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
 *
 * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License version 2 as published by the
 * Free Software Foundation.
 */

#include <linux/compiler.h>
#include <linux/err.h>
#include <linux/init.h>

#include <mach/mx23.h>
#include <mach/mx28.h>
#include <mach/devices-common.h>

20
#define mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid)		\
21
	{								\
22
		.devid = _devid,					\
23 24 25 26 27 28 29
		.id = _id,						\
		.iobase = soc ## _SSP ## hwid ## _BASE_ADDR,		\
		.dma = soc ## _DMA_SSP ## hwid,				\
		.irq_err = soc ## _INT_SSP ## hwid ## _ERROR,		\
		.irq_dma = soc ## _INT_SSP ## hwid ## _DMA,		\
	}

30 31
#define mxs_mxs_mmc_data_entry(soc, _devid, _id, hwid)			\
	[_id] = mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid)
32 33 34 35


#ifdef CONFIG_SOC_IMX23
const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst = {
36 37
	mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 0, 1),
	mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 1, 2),
38 39 40 41 42
};
#endif

#ifdef CONFIG_SOC_IMX28
const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = {
43 44 45 46
	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 0, 0),
	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 1, 1),
	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 2, 2),
	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 3, 3),
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
};
#endif

struct platform_device *__init mxs_add_mxs_mmc(
		const struct mxs_mxs_mmc_data *data,
		const struct mxs_mmc_platform_data *pdata)
{
	struct resource res[] = {
		{
			.start	= data->iobase,
			.end	= data->iobase + SZ_8K - 1,
			.flags	= IORESOURCE_MEM,
		}, {
			.start	= data->dma,
			.end	= data->dma,
			.flags	= IORESOURCE_DMA,
		}, {
			.start	= data->irq_err,
			.end	= data->irq_err,
			.flags	= IORESOURCE_IRQ,
		}, {
			.start	= data->irq_dma,
			.end	= data->irq_dma,
			.flags	= IORESOURCE_IRQ,
		},
	};

74
	return mxs_add_platform_device(data->devid, data->id,
75 76
			res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
}