1/*
2 * Copyright (C) 2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9#include <asm/sizes.h>
10
11#include "../hardware.h"
12#include "devices-common.h"
13
14#define imx_imx2_wdt_data_entry_single(soc, _id, _hwid, _size)		\
15	{								\
16		.id = _id,						\
17		.iobase = soc ## _WDOG ## _hwid ## _BASE_ADDR,		\
18		.iosize = _size,					\
19	}
20#define imx_imx2_wdt_data_entry(soc, _id, _hwid, _size)			\
21	[_id] = imx_imx2_wdt_data_entry_single(soc, _id, _hwid, _size)
22
23#ifdef CONFIG_SOC_IMX21
24const struct imx_imx2_wdt_data imx21_imx2_wdt_data __initconst =
25	imx_imx2_wdt_data_entry_single(MX21, 0, , SZ_4K);
26#endif /* ifdef CONFIG_SOC_IMX21 */
27
28#ifdef CONFIG_SOC_IMX27
29const struct imx_imx2_wdt_data imx27_imx2_wdt_data __initconst =
30	imx_imx2_wdt_data_entry_single(MX27, 0, , SZ_4K);
31#endif /* ifdef CONFIG_SOC_IMX27 */
32
33#ifdef CONFIG_SOC_IMX31
34const struct imx_imx2_wdt_data imx31_imx2_wdt_data __initconst =
35	imx_imx2_wdt_data_entry_single(MX31, 0, , SZ_16K);
36#endif /* ifdef CONFIG_SOC_IMX31 */
37
38#ifdef CONFIG_SOC_IMX35
39const struct imx_imx2_wdt_data imx35_imx2_wdt_data __initconst =
40	imx_imx2_wdt_data_entry_single(MX35, 0, , SZ_16K);
41#endif /* ifdef CONFIG_SOC_IMX35 */
42
43struct platform_device *__init imx_add_imx2_wdt(
44		const struct imx_imx2_wdt_data *data)
45{
46	struct resource res[] = {
47		{
48			.start = data->iobase,
49			.end = data->iobase + data->iosize - 1,
50			.flags = IORESOURCE_MEM,
51		},
52	};
53	return imx_add_platform_device("imx2-wdt", data->id,
54			res, ARRAY_SIZE(res), NULL, 0);
55}
56