platform-imx-i2c.c 3.9 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 <mach/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_IMX1
const struct imx_imx_i2c_data imx1_imx_i2c_data __initconst =
26
	imx_imx_i2c_data_entry_single(MX1, "imx1-i2c", 0, , SZ_4K);
27 28 29 30
#endif /* ifdef CONFIG_SOC_IMX1 */

#ifdef CONFIG_SOC_IMX21
const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst =
31
	imx_imx_i2c_data_entry_single(MX21, "imx21-i2c", 0, , SZ_4K);
32 33
#endif /* ifdef CONFIG_SOC_IMX21 */

34
#ifdef CONFIG_SOC_IMX25
35 36
const struct imx_imx_i2c_data imx25_imx_i2c_data[] __initconst = {
#define imx25_imx_i2c_data_entry(_id, _hwid)				\
37
	imx_imx_i2c_data_entry(MX25, "imx21-i2c", _id, _hwid, SZ_16K)
38 39 40 41
	imx25_imx_i2c_data_entry(0, 1),
	imx25_imx_i2c_data_entry(1, 2),
	imx25_imx_i2c_data_entry(2, 3),
};
42
#endif /* ifdef CONFIG_SOC_IMX25 */
43 44 45 46

#ifdef CONFIG_SOC_IMX27
const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
#define imx27_imx_i2c_data_entry(_id, _hwid)				\
47
	imx_imx_i2c_data_entry(MX27, "imx21-i2c", _id, _hwid, SZ_4K)
48 49 50 51 52
	imx27_imx_i2c_data_entry(0, 1),
	imx27_imx_i2c_data_entry(1, 2),
};
#endif /* ifdef CONFIG_SOC_IMX27 */

53
#ifdef CONFIG_SOC_IMX31
54 55
const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
#define imx31_imx_i2c_data_entry(_id, _hwid)				\
56
	imx_imx_i2c_data_entry(MX31, "imx21-i2c", _id, _hwid, SZ_4K)
57 58 59 60
	imx31_imx_i2c_data_entry(0, 1),
	imx31_imx_i2c_data_entry(1, 2),
	imx31_imx_i2c_data_entry(2, 3),
};
61
#endif /* ifdef CONFIG_SOC_IMX31 */
62

63
#ifdef CONFIG_SOC_IMX35
64 65
const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
#define imx35_imx_i2c_data_entry(_id, _hwid)				\
66
	imx_imx_i2c_data_entry(MX35, "imx21-i2c", _id, _hwid, SZ_4K)
67 68
	imx35_imx_i2c_data_entry(0, 1),
	imx35_imx_i2c_data_entry(1, 2),
69
	imx35_imx_i2c_data_entry(2, 3),
70
};
71
#endif /* ifdef CONFIG_SOC_IMX35 */
72

73 74 75
#ifdef CONFIG_SOC_IMX50
const struct imx_imx_i2c_data imx50_imx_i2c_data[] __initconst = {
#define imx50_imx_i2c_data_entry(_id, _hwid)				\
76
	imx_imx_i2c_data_entry(MX50, "imx21-i2c", _id, _hwid, SZ_4K)
77 78 79 80 81 82
	imx50_imx_i2c_data_entry(0, 1),
	imx50_imx_i2c_data_entry(1, 2),
	imx50_imx_i2c_data_entry(2, 3),
};
#endif /* ifdef CONFIG_SOC_IMX51 */

F
Fabio Estevam 已提交
83
#ifdef CONFIG_SOC_IMX51
84 85
const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst = {
#define imx51_imx_i2c_data_entry(_id, _hwid)				\
86
	imx_imx_i2c_data_entry(MX51, "imx21-i2c", _id, _hwid, SZ_4K)
87 88
	imx51_imx_i2c_data_entry(0, 1),
	imx51_imx_i2c_data_entry(1, 2),
89
	{
90
		.devid = "imx21-i2c",
91 92 93 94 95
		.id = 2,
		.iobase = MX51_HSI2C_DMA_BASE_ADDR,
		.iosize = SZ_16K,
		.irq = MX51_INT_HS_I2C,
	},
96
};
F
Fabio Estevam 已提交
97
#endif /* ifdef CONFIG_SOC_IMX51 */
98

Y
Yong Shen 已提交
99 100 101
#ifdef CONFIG_SOC_IMX53
const struct imx_imx_i2c_data imx53_imx_i2c_data[] __initconst = {
#define imx53_imx_i2c_data_entry(_id, _hwid)				\
102
	imx_imx_i2c_data_entry(MX53, "imx21-i2c", _id, _hwid, SZ_4K)
Y
Yong Shen 已提交
103 104
	imx53_imx_i2c_data_entry(0, 1),
	imx53_imx_i2c_data_entry(1, 2),
A
Andre Silva 已提交
105
	imx53_imx_i2c_data_entry(2, 3),
Y
Yong Shen 已提交
106
};
A
Andre Silva 已提交
107
#endif /* ifdef CONFIG_SOC_IMX53 */
Y
Yong Shen 已提交
108

109 110
struct platform_device *__init imx_add_imx_i2c(
		const struct imx_imx_i2c_data *data,
111 112 113 114
		const struct imxi2c_platform_data *pdata)
{
	struct resource res[] = {
		{
115 116
			.start = data->iobase,
			.end = data->iobase + data->iosize - 1,
117 118
			.flags = IORESOURCE_MEM,
		}, {
119 120
			.start = data->irq,
			.end = data->irq,
121 122 123 124
			.flags = IORESOURCE_IRQ,
		},
	};

125
	return imx_add_platform_device(data->devid, data->id,
126
			res, ARRAY_SIZE(res),
127 128
			pdata, sizeof(*pdata));
}