Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Lennert Buytenhek and committed by
Russell King
e25d64f1 7ae1f7ec

+111 -131
+9 -8
arch/arm/mach-iop32x/common.c
··· 14 14 15 15 #include <linux/delay.h> 16 16 #include <asm/hardware.h> 17 + #include <asm/hardware/iop3xx.h> 17 18 18 19 /* 19 20 * Shared variables ··· 40 39 */ 41 40 42 41 /* Send the Address byte w/ the start condition */ 43 - *IOP321_IDBR1 = 0x60; 44 - *IOP321_ICR1 = 0xE9; 42 + *IOP3XX_IDBR1 = 0x60; 43 + *IOP3XX_ICR1 = 0xE9; 45 44 mdelay(1); 46 45 47 46 /* Send the START_MSG byte w/ no start or stop condition */ 48 - *IOP321_IDBR1 = 0x0F; 49 - *IOP321_ICR1 = 0xE8; 47 + *IOP3XX_IDBR1 = 0x0F; 48 + *IOP3XX_ICR1 = 0xE8; 50 49 mdelay(1); 51 50 52 51 /* Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or stop condition */ 53 - *IOP321_IDBR1 = 0x03; 54 - *IOP321_ICR1 = 0xE8; 52 + *IOP3XX_IDBR1 = 0x03; 53 + *IOP3XX_ICR1 = 0xE8; 55 54 mdelay(1); 56 55 57 56 /* Send an ignored byte w/ stop condition */ 58 - *IOP321_IDBR1 = 0x00; 59 - *IOP321_ICR1 = 0xEA; 57 + *IOP3XX_IDBR1 = 0x00; 58 + *IOP3XX_ICR1 = 0xEA; 60 59 61 60 while (1) ; 62 61 }
+3 -50
arch/arm/mach-iop32x/setup.c
··· 29 29 #include <asm/hardware.h> 30 30 #include <asm/mach-types.h> 31 31 #include <asm/mach/arch.h> 32 + #include <asm/hardware/iop3xx.h> 32 33 33 34 #define IOP321_UART_XTAL 1843200 34 35 ··· 58 57 } 59 58 }; 60 59 61 - static struct resource iop32x_i2c_0_resources[] = { 62 - [0] = { 63 - .start = 0xfffff680, 64 - .end = 0xfffff698, 65 - .flags = IORESOURCE_MEM, 66 - }, 67 - [1] = { 68 - .start = IRQ_IOP321_I2C_0, 69 - .end = IRQ_IOP321_I2C_0, 70 - .flags = IORESOURCE_IRQ 71 - } 72 - }; 73 - 74 - static struct resource iop32x_i2c_1_resources[] = { 75 - [0] = { 76 - .start = 0xfffff6a0, 77 - .end = 0xfffff6b8, 78 - .flags = IORESOURCE_MEM, 79 - }, 80 - [1] = { 81 - .start = IRQ_IOP321_I2C_1, 82 - .end = IRQ_IOP321_I2C_1, 83 - .flags = IORESOURCE_IRQ 84 - } 85 - }; 86 - 87 - static struct platform_device iop32x_i2c_0_controller = { 88 - .name = "IOP3xx-I2C", 89 - .id = 0, 90 - .num_resources = 2, 91 - .resource = iop32x_i2c_0_resources 92 - }; 93 - 94 - static struct platform_device iop32x_i2c_1_controller = { 95 - .name = "IOP3xx-I2C", 96 - .id = 1, 97 - .num_resources = 2, 98 - .resource = iop32x_i2c_1_resources 99 - }; 100 - 101 - static struct platform_device *iop32x_devices[] __initdata = { 102 - &iop32x_i2c_0_controller, 103 - &iop32x_i2c_1_controller 104 - }; 105 - 106 60 void __init iop32x_init(void) 107 61 { 108 - if(iop_is_321()) 109 - { 110 - platform_add_devices(iop32x_devices, 111 - ARRAY_SIZE(iop32x_devices)); 112 - } 62 + platform_device_register(&iop3xx_i2c0_device); 63 + platform_device_register(&iop3xx_i2c1_device); 113 64 early_serial_setup(&iop321_serial_ports[0]); 114 65 } 115 66
+2 -42
arch/arm/mach-iop33x/setup.c
··· 100 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 103 static struct platform_device *iop33x_devices[] __initdata = { 144 104 &iop33x_uart0, 145 105 &iop33x_uart1, 146 - &iop33x_i2c_0_controller, 147 - &iop33x_i2c_1_controller 148 106 }; 149 107 150 108 void __init iop33x_init(void) ··· 112 154 platform_add_devices(iop33x_devices, 113 155 ARRAY_SIZE(iop33x_devices)); 114 156 } 157 + platform_device_register(&iop3xx_i2c0_device); 158 + platform_device_register(&iop3xx_i2c1_device); 115 159 } 116 160 117 161 #ifdef CONFIG_ARCH_IOP33X
+1 -1
arch/arm/plat-iop/Makefile
··· 2 2 # Makefile for the linux kernel. 3 3 # 4 4 5 - obj-y := setup.o 5 + obj-y := i2c.o setup.o 6 6 obj-m := 7 7 obj-n := 8 8 obj- :=
+81
arch/arm/plat-iop/i2c.c
··· 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 + };
-14
include/asm-arm/arch-iop32x/iop321.h
··· 314 314 315 315 /* SSP serial port unit 0x00001600 - 0x0000167F */ 316 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 318 /* for I2C bit defs see drivers/i2c/i2c-iop3xx.h */ 333 319
-16
include/asm-arm/arch-iop33x/iop331.h
··· 311 311 /* SSP serial port unit 0x00001600 - 0x0000167F */ 312 312 313 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 315 /* 0x00001700 through 0x0000172C UART 0 */ 332 316
+15
include/asm-arm/hardware/iop3xx.h
··· 23 23 #define IOP3XX_PERIPHERAL_SIZE 0x00002000 24 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 40 * IOP3XX I/O and Mem space regions for PCI autoconfiguration ··· 49 37 50 38 #ifndef __ASSEMBLY__ 51 39 void iop3xx_map_io(void); 40 + 41 + extern struct platform_device iop3xx_i2c0_device; 42 + extern struct platform_device iop3xx_i2c1_device; 52 43 #endif 53 44 54 45