blob: 550cfc2a1f2e95836d26137edfc8567311041bf7 [file] [log] [blame]
Vitaly Wool41561f22006-12-10 21:21:29 +01001/*
2 * I2C initialization for PNX4008.
3 *
4 * Author: Vitaly Wool <vitalywool@gmail.com>
5 *
6 * 2005-2006 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <linux/clk.h>
13#include <linux/i2c.h>
14#include <linux/i2c-pnx.h>
15#include <linux/platform_device.h>
16#include <linux/err.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010017#include <mach/platform.h>
Russell King18b20852009-01-08 11:00:03 +000018#include <mach/irqs.h>
Vitaly Wool41561f22006-12-10 21:21:29 +010019
Roland Stigge1451ba32012-04-22 11:59:47 +020020static struct resource i2c0_resources[] = {
21 {
22 .start = PNX4008_I2C1_BASE,
23 .end = PNX4008_I2C1_BASE + SZ_4K - 1,
24 .flags = IORESOURCE_MEM,
25 }, {
26 .start = I2C_1_INT,
27 .end = I2C_1_INT,
28 .flags = IORESOURCE_IRQ,
29 },
Vitaly Wool41561f22006-12-10 21:21:29 +010030};
31
Roland Stigge1451ba32012-04-22 11:59:47 +020032static struct resource i2c1_resources[] = {
33 {
34 .start = PNX4008_I2C2_BASE,
35 .end = PNX4008_I2C2_BASE + SZ_4K - 1,
36 .flags = IORESOURCE_MEM,
37 }, {
38 .start = I2C_2_INT,
39 .end = I2C_2_INT,
40 .flags = IORESOURCE_IRQ,
41 },
Vitaly Wool41561f22006-12-10 21:21:29 +010042};
43
Roland Stigge1451ba32012-04-22 11:59:47 +020044static struct resource i2c2_resources[] = {
45 {
46 .start = PNX4008_USB_CONFIG_BASE + 0x300,
47 .end = PNX4008_USB_CONFIG_BASE + 0x300 + SZ_4K - 1,
48 .flags = IORESOURCE_MEM,
49 }, {
50 .start = USB_I2C_INT,
51 .end = USB_I2C_INT,
52 .flags = IORESOURCE_IRQ,
53 },
Vitaly Wool41561f22006-12-10 21:21:29 +010054};
55
56static struct platform_device i2c0_device = {
Roland Stigge1451ba32012-04-22 11:59:47 +020057 .name = "pnx-i2c.0",
Vitaly Wool41561f22006-12-10 21:21:29 +010058 .id = 0,
Roland Stigge1451ba32012-04-22 11:59:47 +020059 .resource = i2c0_resources,
60 .num_resources = ARRAY_SIZE(i2c0_resources),
Vitaly Wool41561f22006-12-10 21:21:29 +010061};
62
63static struct platform_device i2c1_device = {
Roland Stigge1451ba32012-04-22 11:59:47 +020064 .name = "pnx-i2c.1",
Vitaly Wool41561f22006-12-10 21:21:29 +010065 .id = 1,
Roland Stigge1451ba32012-04-22 11:59:47 +020066 .resource = i2c1_resources,
67 .num_resources = ARRAY_SIZE(i2c1_resources),
Vitaly Wool41561f22006-12-10 21:21:29 +010068};
69
70static struct platform_device i2c2_device = {
Roland Stigge1451ba32012-04-22 11:59:47 +020071 .name = "pnx-i2c.2",
Vitaly Wool41561f22006-12-10 21:21:29 +010072 .id = 2,
Roland Stigge1451ba32012-04-22 11:59:47 +020073 .resource = i2c2_resources,
74 .num_resources = ARRAY_SIZE(i2c2_resources),
Vitaly Wool41561f22006-12-10 21:21:29 +010075};
76
77static struct platform_device *devices[] __initdata = {
78 &i2c0_device,
79 &i2c1_device,
80 &i2c2_device,
81};
82
83void __init pnx4008_register_i2c_devices(void)
84{
85 platform_add_devices(devices, ARRAY_SIZE(devices));
86}