diff options
author | Lennert Buytenhek <buytenh@wantstofly.org> | 2006-09-18 18:15:21 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-09-25 05:25:38 -0400 |
commit | e25d64f1242e8586f6e20c26fd876a4d956a6c45 (patch) | |
tree | 1a68da7173716896254847708dcd1675102a24ac | |
parent | 7ae1f7ec525c32db441836ab0ab010b85cb819a2 (diff) |
[ARM] 3819/1: iop3xx: factor out shared i2c code
Move the i2c bits shared between iop32x and iop33x to plat-iop/i2c.c
and include/asm-arm/hardware/iop3xx.h.
Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/mach-iop32x/common.c | 17 | ||||
-rw-r--r-- | arch/arm/mach-iop32x/setup.c | 53 | ||||
-rw-r--r-- | arch/arm/mach-iop33x/setup.c | 44 | ||||
-rw-r--r-- | arch/arm/plat-iop/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/plat-iop/i2c.c | 81 | ||||
-rw-r--r-- | include/asm-arm/arch-iop32x/iop321.h | 14 | ||||
-rw-r--r-- | include/asm-arm/arch-iop33x/iop331.h | 16 | ||||
-rw-r--r-- | include/asm-arm/hardware/iop3xx.h | 15 |
8 files changed, 111 insertions, 131 deletions
diff --git a/arch/arm/mach-iop32x/common.c b/arch/arm/mach-iop32x/common.c index 8044af6a54e1..17e7d650fecb 100644 --- a/arch/arm/mach-iop32x/common.c +++ b/arch/arm/mach-iop32x/common.c | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <asm/hardware.h> | 16 | #include <asm/hardware.h> |
17 | #include <asm/hardware/iop3xx.h> | ||
17 | 18 | ||
18 | /* | 19 | /* |
19 | * Shared variables | 20 | * Shared variables |
@@ -39,23 +40,23 @@ void ep80219_power_off(void) | |||
39 | */ | 40 | */ |
40 | 41 | ||
41 | /* Send the Address byte w/ the start condition */ | 42 | /* Send the Address byte w/ the start condition */ |
42 | *IOP321_IDBR1 = 0x60; | 43 | *IOP3XX_IDBR1 = 0x60; |
43 | *IOP321_ICR1 = 0xE9; | 44 | *IOP3XX_ICR1 = 0xE9; |
44 | mdelay(1); | 45 | mdelay(1); |
45 | 46 | ||
46 | /* Send the START_MSG byte w/ no start or stop condition */ | 47 | /* Send the START_MSG byte w/ no start or stop condition */ |
47 | *IOP321_IDBR1 = 0x0F; | 48 | *IOP3XX_IDBR1 = 0x0F; |
48 | *IOP321_ICR1 = 0xE8; | 49 | *IOP3XX_ICR1 = 0xE8; |
49 | mdelay(1); | 50 | mdelay(1); |
50 | 51 | ||
51 | /* Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or stop condition */ | 52 | /* Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or stop condition */ |
52 | *IOP321_IDBR1 = 0x03; | 53 | *IOP3XX_IDBR1 = 0x03; |
53 | *IOP321_ICR1 = 0xE8; | 54 | *IOP3XX_ICR1 = 0xE8; |
54 | mdelay(1); | 55 | mdelay(1); |
55 | 56 | ||
56 | /* Send an ignored byte w/ stop condition */ | 57 | /* Send an ignored byte w/ stop condition */ |
57 | *IOP321_IDBR1 = 0x00; | 58 | *IOP3XX_IDBR1 = 0x00; |
58 | *IOP321_ICR1 = 0xEA; | 59 | *IOP3XX_ICR1 = 0xEA; |
59 | 60 | ||
60 | while (1) ; | 61 | while (1) ; |
61 | } | 62 | } |
diff --git a/arch/arm/mach-iop32x/setup.c b/arch/arm/mach-iop32x/setup.c index 48d806474f40..1a03b0b41baa 100644 --- a/arch/arm/mach-iop32x/setup.c +++ b/arch/arm/mach-iop32x/setup.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <asm/hardware.h> | 29 | #include <asm/hardware.h> |
30 | #include <asm/mach-types.h> | 30 | #include <asm/mach-types.h> |
31 | #include <asm/mach/arch.h> | 31 | #include <asm/mach/arch.h> |
32 | #include <asm/hardware/iop3xx.h> | ||
32 | 33 | ||
33 | #define IOP321_UART_XTAL 1843200 | 34 | #define IOP321_UART_XTAL 1843200 |
34 | 35 | ||
@@ -57,58 +58,10 @@ static struct uart_port iop321_serial_ports[] = { | |||
57 | } | 58 | } |
58 | }; | 59 | }; |
59 | 60 | ||
60 | static struct resource iop32x_i2c_0_resources[] = { | ||
61 | [0] = { | ||
62 | .start = 0xfffff680, | ||
63 | .end = 0xfffff698, | ||
64 | .flags = IORESOURCE_MEM, | ||
65 | }, | ||
66 | [1] = { | ||
67 | .start = IRQ_IOP321_I2C_0, | ||
68 | .end = IRQ_IOP321_I2C_0, | ||
69 | .flags = IORESOURCE_IRQ | ||
70 | } | ||
71 | }; | ||
72 | |||
73 | static struct resource iop32x_i2c_1_resources[] = { | ||
74 | [0] = { | ||
75 | .start = 0xfffff6a0, | ||
76 | .end = 0xfffff6b8, | ||
77 | .flags = IORESOURCE_MEM, | ||
78 | }, | ||
79 | [1] = { | ||
80 | .start = IRQ_IOP321_I2C_1, | ||
81 | .end = IRQ_IOP321_I2C_1, | ||
82 | .flags = IORESOURCE_IRQ | ||
83 | } | ||
84 | }; | ||
85 | |||
86 | static struct platform_device iop32x_i2c_0_controller = { | ||
87 | .name = "IOP3xx-I2C", | ||
88 | .id = 0, | ||
89 | .num_resources = 2, | ||
90 | .resource = iop32x_i2c_0_resources | ||
91 | }; | ||
92 | |||
93 | static struct platform_device iop32x_i2c_1_controller = { | ||
94 | .name = "IOP3xx-I2C", | ||
95 | .id = 1, | ||
96 | .num_resources = 2, | ||
97 | .resource = iop32x_i2c_1_resources | ||
98 | }; | ||
99 | |||
100 | static struct platform_device *iop32x_devices[] __initdata = { | ||
101 | &iop32x_i2c_0_controller, | ||
102 | &iop32x_i2c_1_controller | ||
103 | }; | ||
104 | |||
105 | void __init iop32x_init(void) | 61 | void __init iop32x_init(void) |
106 | { | 62 | { |
107 | if(iop_is_321()) | 63 | platform_device_register(&iop3xx_i2c0_device); |
108 | { | 64 | platform_device_register(&iop3xx_i2c1_device); |
109 | platform_add_devices(iop32x_devices, | ||
110 | ARRAY_SIZE(iop32x_devices)); | ||
111 | } | ||
112 | early_serial_setup(&iop321_serial_ports[0]); | 65 | early_serial_setup(&iop321_serial_ports[0]); |
113 | } | 66 | } |
114 | 67 | ||
diff --git a/arch/arm/mach-iop33x/setup.c b/arch/arm/mach-iop33x/setup.c index 67cb21cb0ad9..ad737d6582b5 100644 --- a/arch/arm/mach-iop33x/setup.c +++ b/arch/arm/mach-iop33x/setup.c | |||
@@ -100,51 +100,9 @@ static struct platform_device iop33x_uart1 = { | |||
100 | .resource = iop33x_uart1_resources, | 100 | .resource = iop33x_uart1_resources, |
101 | }; | 101 | }; |
102 | 102 | ||
103 | static struct resource iop33x_i2c_0_resources[] = { | ||
104 | [0] = { | ||
105 | .start = 0xfffff680, | ||
106 | .end = 0xfffff698, | ||
107 | .flags = IORESOURCE_MEM, | ||
108 | }, | ||
109 | [1] = { | ||
110 | .start = IRQ_IOP331_I2C_0, | ||
111 | .end = IRQ_IOP331_I2C_0, | ||
112 | .flags = IORESOURCE_IRQ | ||
113 | } | ||
114 | }; | ||
115 | |||
116 | static struct resource iop33x_i2c_1_resources[] = { | ||
117 | [0] = { | ||
118 | .start = 0xfffff6a0, | ||
119 | .end = 0xfffff6b8, | ||
120 | .flags = IORESOURCE_MEM, | ||
121 | }, | ||
122 | [1] = { | ||
123 | .start = IRQ_IOP331_I2C_1, | ||
124 | .end = IRQ_IOP331_I2C_1, | ||
125 | .flags = IORESOURCE_IRQ | ||
126 | } | ||
127 | }; | ||
128 | |||
129 | static struct platform_device iop33x_i2c_0_controller = { | ||
130 | .name = "IOP3xx-I2C", | ||
131 | .id = 0, | ||
132 | .num_resources = 2, | ||
133 | .resource = iop33x_i2c_0_resources | ||
134 | }; | ||
135 | |||
136 | static struct platform_device iop33x_i2c_1_controller = { | ||
137 | .name = "IOP3xx-I2C", | ||
138 | .id = 1, | ||
139 | .num_resources = 2, | ||
140 | .resource = iop33x_i2c_1_resources | ||
141 | }; | ||
142 | |||
143 | static struct platform_device *iop33x_devices[] __initdata = { | 103 | static struct platform_device *iop33x_devices[] __initdata = { |
144 | &iop33x_uart0, | 104 | &iop33x_uart0, |
145 | &iop33x_uart1, | 105 | &iop33x_uart1, |
146 | &iop33x_i2c_0_controller, | ||
147 | &iop33x_i2c_1_controller | ||
148 | }; | 106 | }; |
149 | 107 | ||
150 | void __init iop33x_init(void) | 108 | void __init iop33x_init(void) |
@@ -154,6 +112,8 @@ void __init iop33x_init(void) | |||
154 | platform_add_devices(iop33x_devices, | 112 | platform_add_devices(iop33x_devices, |
155 | ARRAY_SIZE(iop33x_devices)); | 113 | ARRAY_SIZE(iop33x_devices)); |
156 | } | 114 | } |
115 | platform_device_register(&iop3xx_i2c0_device); | ||
116 | platform_device_register(&iop3xx_i2c1_device); | ||
157 | } | 117 | } |
158 | 118 | ||
159 | #ifdef CONFIG_ARCH_IOP33X | 119 | #ifdef CONFIG_ARCH_IOP33X |
diff --git a/arch/arm/plat-iop/Makefile b/arch/arm/plat-iop/Makefile index b299103537c5..be6ab7c71ca3 100644 --- a/arch/arm/plat-iop/Makefile +++ b/arch/arm/plat-iop/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the linux kernel. | 2 | # Makefile for the linux kernel. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := setup.o | 5 | obj-y := i2c.o setup.o |
6 | obj-m := | 6 | obj-m := |
7 | obj-n := | 7 | obj-n := |
8 | obj- := | 8 | obj- := |
diff --git a/arch/arm/plat-iop/i2c.c b/arch/arm/plat-iop/i2c.c new file mode 100644 index 000000000000..7ae149c2e982 --- /dev/null +++ b/arch/arm/plat-iop/i2c.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-iop/i2c.c | ||
3 | * | ||
4 | * Author: Nicolas Pitre <nico@cam.org> | ||
5 | * Copyright (C) 2001 MontaVista Software, Inc. | ||
6 | * Copyright (C) 2004 Intel Corporation. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/mm.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/major.h> | ||
16 | #include <linux/fs.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/serial.h> | ||
19 | #include <linux/tty.h> | ||
20 | #include <linux/serial_core.h> | ||
21 | #include <asm/io.h> | ||
22 | #include <asm/pgtable.h> | ||
23 | #include <asm/page.h> | ||
24 | #include <asm/mach/map.h> | ||
25 | #include <asm/setup.h> | ||
26 | #include <asm/system.h> | ||
27 | #include <asm/memory.h> | ||
28 | #include <asm/hardware.h> | ||
29 | #include <asm/hardware/iop3xx.h> | ||
30 | #include <asm/mach-types.h> | ||
31 | #include <asm/mach/arch.h> | ||
32 | |||
33 | #ifdef CONFIG_ARCH_IOP32X | ||
34 | #define IRQ_IOP3XX_I2C_0 IRQ_IOP321_I2C_0 | ||
35 | #define IRQ_IOP3XX_I2C_1 IRQ_IOP321_I2C_1 | ||
36 | #endif | ||
37 | #ifdef CONFIG_ARCH_IOP33X | ||
38 | #define IRQ_IOP3XX_I2C_0 IRQ_IOP331_I2C_0 | ||
39 | #define IRQ_IOP3XX_I2C_1 IRQ_IOP331_I2C_1 | ||
40 | #endif | ||
41 | |||
42 | static struct resource iop3xx_i2c0_resources[] = { | ||
43 | [0] = { | ||
44 | .start = 0xfffff680, | ||
45 | .end = 0xfffff697, | ||
46 | .flags = IORESOURCE_MEM, | ||
47 | }, | ||
48 | [1] = { | ||
49 | .start = IRQ_IOP3XX_I2C_0, | ||
50 | .end = IRQ_IOP3XX_I2C_0, | ||
51 | .flags = IORESOURCE_IRQ, | ||
52 | }, | ||
53 | }; | ||
54 | |||
55 | struct platform_device iop3xx_i2c0_device = { | ||
56 | .name = "IOP3xx-I2C", | ||
57 | .id = 0, | ||
58 | .num_resources = 2, | ||
59 | .resource = iop3xx_i2c0_resources, | ||
60 | }; | ||
61 | |||
62 | |||
63 | static struct resource iop3xx_i2c1_resources[] = { | ||
64 | [0] = { | ||
65 | .start = 0xfffff6a0, | ||
66 | .end = 0xfffff6b7, | ||
67 | .flags = IORESOURCE_MEM, | ||
68 | }, | ||
69 | [1] = { | ||
70 | .start = IRQ_IOP3XX_I2C_1, | ||
71 | .end = IRQ_IOP3XX_I2C_1, | ||
72 | .flags = IORESOURCE_IRQ, | ||
73 | } | ||
74 | }; | ||
75 | |||
76 | struct platform_device iop3xx_i2c1_device = { | ||
77 | .name = "IOP3xx-I2C", | ||
78 | .id = 1, | ||
79 | .num_resources = 2, | ||
80 | .resource = iop3xx_i2c1_resources, | ||
81 | }; | ||
diff --git a/include/asm-arm/arch-iop32x/iop321.h b/include/asm-arm/arch-iop32x/iop321.h index 307272b07809..1a82dd96bf50 100644 --- a/include/asm-arm/arch-iop32x/iop321.h +++ b/include/asm-arm/arch-iop32x/iop321.h | |||
@@ -314,20 +314,6 @@ | |||
314 | 314 | ||
315 | /* SSP serial port unit 0x00001600 - 0x0000167F */ | 315 | /* SSP serial port unit 0x00001600 - 0x0000167F */ |
316 | /* I2C bus interface unit 0x00001680 - 0x000016FF */ | 316 | /* I2C bus interface unit 0x00001680 - 0x000016FF */ |
317 | #define IOP321_ICR0 (volatile u32 *)IOP321_REG_ADDR(0x00001680) | ||
318 | #define IOP321_ISR0 (volatile u32 *)IOP321_REG_ADDR(0x00001684) | ||
319 | #define IOP321_ISAR0 (volatile u32 *)IOP321_REG_ADDR(0x00001688) | ||
320 | #define IOP321_IDBR0 (volatile u32 *)IOP321_REG_ADDR(0x0000168C) | ||
321 | /* Reserved 0x00001690 */ | ||
322 | #define IOP321_IBMR0 (volatile u32 *)IOP321_REG_ADDR(0x00001694) | ||
323 | /* Reserved 0x00001698 */ | ||
324 | /* Reserved 0x0000169C */ | ||
325 | #define IOP321_ICR1 (volatile u32 *)IOP321_REG_ADDR(0x000016A0) | ||
326 | #define IOP321_ISR1 (volatile u32 *)IOP321_REG_ADDR(0x000016A4) | ||
327 | #define IOP321_ISAR1 (volatile u32 *)IOP321_REG_ADDR(0x000016A8) | ||
328 | #define IOP321_IDBR1 (volatile u32 *)IOP321_REG_ADDR(0x000016AC) | ||
329 | #define IOP321_IBMR1 (volatile u32 *)IOP321_REG_ADDR(0x000016B4) | ||
330 | /* Reserved 0x000016B8 through 0x000016FC */ | ||
331 | 317 | ||
332 | /* for I2C bit defs see drivers/i2c/i2c-iop3xx.h */ | 318 | /* for I2C bit defs see drivers/i2c/i2c-iop3xx.h */ |
333 | 319 | ||
diff --git a/include/asm-arm/arch-iop33x/iop331.h b/include/asm-arm/arch-iop33x/iop331.h index 21430f877ea7..a7f47122c5e1 100644 --- a/include/asm-arm/arch-iop33x/iop331.h +++ b/include/asm-arm/arch-iop33x/iop331.h | |||
@@ -311,22 +311,6 @@ | |||
311 | /* SSP serial port unit 0x00001600 - 0x0000167F */ | 311 | /* SSP serial port unit 0x00001600 - 0x0000167F */ |
312 | 312 | ||
313 | /* I2C bus interface unit 0x00001680 - 0x000016FF */ | 313 | /* I2C bus interface unit 0x00001680 - 0x000016FF */ |
314 | /* for I2C bit defs see drivers/i2c/i2c-iop3xx.h */ | ||
315 | |||
316 | #define IOP331_ICR0 (volatile u32 *)IOP331_REG_ADDR(0x00001680) | ||
317 | #define IOP331_ISR0 (volatile u32 *)IOP331_REG_ADDR(0x00001684) | ||
318 | #define IOP331_ISAR0 (volatile u32 *)IOP331_REG_ADDR(0x00001688) | ||
319 | #define IOP331_IDBR0 (volatile u32 *)IOP331_REG_ADDR(0x0000168C) | ||
320 | /* Reserved 0x00001690 */ | ||
321 | #define IOP331_IBMR0 (volatile u32 *)IOP331_REG_ADDR(0x00001694) | ||
322 | /* Reserved 0x00001698 */ | ||
323 | /* Reserved 0x0000169C */ | ||
324 | #define IOP331_ICR1 (volatile u32 *)IOP331_REG_ADDR(0x000016A0) | ||
325 | #define IOP331_ISR1 (volatile u32 *)IOP331_REG_ADDR(0x000016A4) | ||
326 | #define IOP331_ISAR1 (volatile u32 *)IOP331_REG_ADDR(0x000016A8) | ||
327 | #define IOP331_IDBR1 (volatile u32 *)IOP331_REG_ADDR(0x000016AC) | ||
328 | #define IOP331_IBMR1 (volatile u32 *)IOP331_REG_ADDR(0x000016B4) | ||
329 | /* Reserved 0x000016B8 through 0x000016FF */ | ||
330 | 314 | ||
331 | /* 0x00001700 through 0x0000172C UART 0 */ | 315 | /* 0x00001700 through 0x0000172C UART 0 */ |
332 | 316 | ||
diff --git a/include/asm-arm/hardware/iop3xx.h b/include/asm-arm/hardware/iop3xx.h index c17cc19cdfab..ea7d05970001 100644 --- a/include/asm-arm/hardware/iop3xx.h +++ b/include/asm-arm/hardware/iop3xx.h | |||
@@ -23,6 +23,18 @@ | |||
23 | #define IOP3XX_PERIPHERAL_SIZE 0x00002000 | 23 | #define IOP3XX_PERIPHERAL_SIZE 0x00002000 |
24 | #define IOP3XX_REG_ADDR(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + (reg)) | 24 | #define IOP3XX_REG_ADDR(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + (reg)) |
25 | 25 | ||
26 | /* I2C bus interface unit */ | ||
27 | #define IOP3XX_ICR0 (volatile u32 *)IOP3XX_REG_ADDR(0x1680) | ||
28 | #define IOP3XX_ISR0 (volatile u32 *)IOP3XX_REG_ADDR(0x1684) | ||
29 | #define IOP3XX_ISAR0 (volatile u32 *)IOP3XX_REG_ADDR(0x1688) | ||
30 | #define IOP3XX_IDBR0 (volatile u32 *)IOP3XX_REG_ADDR(0x168c) | ||
31 | #define IOP3XX_IBMR0 (volatile u32 *)IOP3XX_REG_ADDR(0x1694) | ||
32 | #define IOP3XX_ICR1 (volatile u32 *)IOP3XX_REG_ADDR(0x16a0) | ||
33 | #define IOP3XX_ISR1 (volatile u32 *)IOP3XX_REG_ADDR(0x16a4) | ||
34 | #define IOP3XX_ISAR1 (volatile u32 *)IOP3XX_REG_ADDR(0x16a8) | ||
35 | #define IOP3XX_IDBR1 (volatile u32 *)IOP3XX_REG_ADDR(0x16ac) | ||
36 | #define IOP3XX_IBMR1 (volatile u32 *)IOP3XX_REG_ADDR(0x16b4) | ||
37 | |||
26 | 38 | ||
27 | /* | 39 | /* |
28 | * IOP3XX I/O and Mem space regions for PCI autoconfiguration | 40 | * IOP3XX I/O and Mem space regions for PCI autoconfiguration |
@@ -37,6 +49,9 @@ | |||
37 | 49 | ||
38 | #ifndef __ASSEMBLY__ | 50 | #ifndef __ASSEMBLY__ |
39 | void iop3xx_map_io(void); | 51 | void iop3xx_map_io(void); |
52 | |||
53 | extern struct platform_device iop3xx_i2c0_device; | ||
54 | extern struct platform_device iop3xx_i2c1_device; | ||
40 | #endif | 55 | #endif |
41 | 56 | ||
42 | 57 | ||