Vitaly Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 1 | /* |
| 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 King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 17 | #include <mach/platform.h> |
Russell King | 18b2085 | 2009-01-08 11:00:03 +0000 | [diff] [blame] | 18 | #include <mach/irqs.h> |
Vitaly Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 19 | |
Roland Stigge | 1451ba3 | 2012-04-22 11:59:47 +0200 | [diff] [blame^] | 20 | static 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 Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 30 | }; |
| 31 | |
Roland Stigge | 1451ba3 | 2012-04-22 11:59:47 +0200 | [diff] [blame^] | 32 | static 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 Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 42 | }; |
| 43 | |
Roland Stigge | 1451ba3 | 2012-04-22 11:59:47 +0200 | [diff] [blame^] | 44 | static 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 Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | static struct platform_device i2c0_device = { |
Roland Stigge | 1451ba3 | 2012-04-22 11:59:47 +0200 | [diff] [blame^] | 57 | .name = "pnx-i2c.0", |
Vitaly Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 58 | .id = 0, |
Roland Stigge | 1451ba3 | 2012-04-22 11:59:47 +0200 | [diff] [blame^] | 59 | .resource = i2c0_resources, |
| 60 | .num_resources = ARRAY_SIZE(i2c0_resources), |
Vitaly Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | static struct platform_device i2c1_device = { |
Roland Stigge | 1451ba3 | 2012-04-22 11:59:47 +0200 | [diff] [blame^] | 64 | .name = "pnx-i2c.1", |
Vitaly Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 65 | .id = 1, |
Roland Stigge | 1451ba3 | 2012-04-22 11:59:47 +0200 | [diff] [blame^] | 66 | .resource = i2c1_resources, |
| 67 | .num_resources = ARRAY_SIZE(i2c1_resources), |
Vitaly Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | static struct platform_device i2c2_device = { |
Roland Stigge | 1451ba3 | 2012-04-22 11:59:47 +0200 | [diff] [blame^] | 71 | .name = "pnx-i2c.2", |
Vitaly Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 72 | .id = 2, |
Roland Stigge | 1451ba3 | 2012-04-22 11:59:47 +0200 | [diff] [blame^] | 73 | .resource = i2c2_resources, |
| 74 | .num_resources = ARRAY_SIZE(i2c2_resources), |
Vitaly Wool | 41561f2 | 2006-12-10 21:21:29 +0100 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | static struct platform_device *devices[] __initdata = { |
| 78 | &i2c0_device, |
| 79 | &i2c1_device, |
| 80 | &i2c2_device, |
| 81 | }; |
| 82 | |
| 83 | void __init pnx4008_register_i2c_devices(void) |
| 84 | { |
| 85 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 86 | } |