platform-imx-i2c.c 2.3 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 * Copyright (C) 2009-2010 Pengutronix
 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
 *
 * 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.
 */
9
#include "../hardware.h"
10
#include "devices-common.h"
11

12
#define imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size)	\
13
	{								\
14
		.devid = _devid,					\
15 16 17 18 19 20
		.id = _id,						\
		.iobase = soc ## _I2C ## _hwid ## _BASE_ADDR,		\
		.iosize = _size,					\
		.irq = soc ## _INT_I2C ## _hwid,			\
	}

21 22
#define imx_imx_i2c_data_entry(soc, _devid, _id, _hwid, _size)		\
	[_id] = imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size)
23 24 25

#ifdef CONFIG_SOC_IMX21
const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst =
26
	imx_imx_i2c_data_entry_single(MX21, "imx21-i2c", 0, , SZ_4K);
27 28 29 30 31
#endif /* ifdef CONFIG_SOC_IMX21 */

#ifdef CONFIG_SOC_IMX27
const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
#define imx27_imx_i2c_data_entry(_id, _hwid)				\
32
	imx_imx_i2c_data_entry(MX27, "imx21-i2c", _id, _hwid, SZ_4K)
33 34 35 36 37
	imx27_imx_i2c_data_entry(0, 1),
	imx27_imx_i2c_data_entry(1, 2),
};
#endif /* ifdef CONFIG_SOC_IMX27 */

38
#ifdef CONFIG_SOC_IMX31
39 40
const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
#define imx31_imx_i2c_data_entry(_id, _hwid)				\
41
	imx_imx_i2c_data_entry(MX31, "imx21-i2c", _id, _hwid, SZ_4K)
42 43 44 45
	imx31_imx_i2c_data_entry(0, 1),
	imx31_imx_i2c_data_entry(1, 2),
	imx31_imx_i2c_data_entry(2, 3),
};
46
#endif /* ifdef CONFIG_SOC_IMX31 */
47

48
#ifdef CONFIG_SOC_IMX35
49 50
const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
#define imx35_imx_i2c_data_entry(_id, _hwid)				\
51
	imx_imx_i2c_data_entry(MX35, "imx21-i2c", _id, _hwid, SZ_4K)
52 53
	imx35_imx_i2c_data_entry(0, 1),
	imx35_imx_i2c_data_entry(1, 2),
54
	imx35_imx_i2c_data_entry(2, 3),
55
};
56
#endif /* ifdef CONFIG_SOC_IMX35 */
57 58 59

struct platform_device *__init imx_add_imx_i2c(
		const struct imx_imx_i2c_data *data,
60 61 62 63
		const struct imxi2c_platform_data *pdata)
{
	struct resource res[] = {
		{
64 65
			.start = data->iobase,
			.end = data->iobase + data->iosize - 1,
66 67
			.flags = IORESOURCE_MEM,
		}, {
68 69
			.start = data->irq,
			.end = data->irq,
70 71 72 73
			.flags = IORESOURCE_IRQ,
		},
	};

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