aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s3c
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-10-31 12:14:55 -0400
committerBen Dooks <ben-linux@fluff.org>2008-12-15 18:56:41 -0500
commit1aba834da12989bb769d1dcbf6b0ea29f730c92c (patch)
tree4f06c055eb265919ab137a49a21d3a5ace5d393d /arch/arm/plat-s3c
parent8f995cc3ac94b114fe84782b023d8706d1adf960 (diff)
[ARM] S3C: Add i2c1 device definition
Add device definition and support functions for the second i2c device (i2c1). If this is selected, the first i2c bus will become index 0 instead of index -1. Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s3c')
-rw-r--r--arch/arm/plat-s3c/Kconfig6
-rw-r--r--arch/arm/plat-s3c/Makefile1
-rw-r--r--arch/arm/plat-s3c/dev-i2c0.c8
-rw-r--r--arch/arm/plat-s3c/dev-i2c1.c68
-rw-r--r--arch/arm/plat-s3c/include/plat/devs.h1
-rw-r--r--arch/arm/plat-s3c/include/plat/iic.h2
6 files changed, 84 insertions, 2 deletions
diff --git a/arch/arm/plat-s3c/Kconfig b/arch/arm/plat-s3c/Kconfig
index e6e64968a611..d7a6e487f218 100644
--- a/arch/arm/plat-s3c/Kconfig
+++ b/arch/arm/plat-s3c/Kconfig
@@ -160,3 +160,9 @@ config S3C_DEV_HSMMC1
160 depends on PLAT_S3C 160 depends on PLAT_S3C
161 help 161 help
162 Compile in platform device definitions for HSMMC channel 1 162 Compile in platform device definitions for HSMMC channel 1
163
164config S3C_DEV_I2C1
165 bool
166 depends on PLAT_S3C
167 help
168 Compile in platform device definitions for I2C channel 1
diff --git a/arch/arm/plat-s3c/Makefile b/arch/arm/plat-s3c/Makefile
index 187fa95b87d5..3fcee0c44e18 100644
--- a/arch/arm/plat-s3c/Makefile
+++ b/arch/arm/plat-s3c/Makefile
@@ -23,3 +23,4 @@ obj-y += gpio-config.o
23obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o 23obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o
24obj-$(CONFIG_S3C_DEV_HSMMC1) += dev-hsmmc1.o 24obj-$(CONFIG_S3C_DEV_HSMMC1) += dev-hsmmc1.o
25obj-y += dev-i2c0.o 25obj-y += dev-i2c0.o
26obj-$(CONFIG_S3C_DEV_I2C1) += dev-i2c1.o
diff --git a/arch/arm/plat-s3c/dev-i2c0.c b/arch/arm/plat-s3c/dev-i2c0.c
index 21870fd2ec98..2c0128c77c6e 100644
--- a/arch/arm/plat-s3c/dev-i2c0.c
+++ b/arch/arm/plat-s3c/dev-i2c0.c
@@ -37,12 +37,16 @@ static struct resource s3c_i2c_resource[] = {
37 37
38struct platform_device s3c_device_i2c0 = { 38struct platform_device s3c_device_i2c0 = {
39 .name = "s3c2410-i2c", 39 .name = "s3c2410-i2c",
40#ifdef CONFIG_S3C_DEV_I2C1
41 .id = 0,
42#else
40 .id = -1, 43 .id = -1,
44#endif
41 .num_resources = ARRAY_SIZE(s3c_i2c_resource), 45 .num_resources = ARRAY_SIZE(s3c_i2c_resource),
42 .resource = s3c_i2c_resource, 46 .resource = s3c_i2c_resource,
43}; 47};
44 48
45struct s3c2410_platform_i2c default_i2c_data __initdata = { 49static struct s3c2410_platform_i2c default_i2c_data0 __initdata = {
46 .flags = 0, 50 .flags = 0,
47 .slave_addr = 0x10, 51 .slave_addr = 0x10,
48 .bus_freq = 100*1000, 52 .bus_freq = 100*1000,
@@ -55,7 +59,7 @@ void __init s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *pd)
55 struct s3c2410_platform_i2c *npd; 59 struct s3c2410_platform_i2c *npd;
56 60
57 if (!pd) 61 if (!pd)
58 pd = &default_i2c_data; 62 pd = &default_i2c_data0;
59 63
60 npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL); 64 npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
61 if (!npd) 65 if (!npd)
diff --git a/arch/arm/plat-s3c/dev-i2c1.c b/arch/arm/plat-s3c/dev-i2c1.c
new file mode 100644
index 000000000000..9658fb0aec95
--- /dev/null
+++ b/arch/arm/plat-s3c/dev-i2c1.c
@@ -0,0 +1,68 @@
1/* linux/arch/arm/plat-s3c/dev-i2c1.c
2 *
3 * Copyright 2008 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 * http://armlinux.simtec.co.uk/
6 *
7 * S3C series device definition for i2c device 1
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#include <linux/kernel.h>
15#include <linux/string.h>
16#include <linux/platform_device.h>
17
18#include <mach/map.h>
19
20#include <plat/regs-iic.h>
21#include <plat/iic.h>
22#include <plat/devs.h>
23#include <plat/cpu.h>
24
25static struct resource s3c_i2c_resource[] = {
26 [0] = {
27 .start = S3C_PA_IIC1,
28 .end = S3C_PA_IIC1 + SZ_4K - 1,
29 .flags = IORESOURCE_MEM,
30 },
31 [1] = {
32 .start = IRQ_IIC1,
33 .end = IRQ_IIC1,
34 .flags = IORESOURCE_IRQ,
35 },
36};
37
38struct platform_device s3c_device_i2c1 = {
39 .name = "s3c2410-i2c",
40 .id = 1,
41 .num_resources = ARRAY_SIZE(s3c_i2c_resource),
42 .resource = s3c_i2c_resource,
43};
44
45static struct s3c2410_platform_i2c default_i2c_data1 __initdata = {
46 .flags = 0,
47 .bus_num = 1,
48 .slave_addr = 0x10,
49 .bus_freq = 100*1000,
50 .max_freq = 400*1000,
51 .sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
52};
53
54void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd)
55{
56 struct s3c2410_platform_i2c *npd;
57
58 if (!pd)
59 pd = &default_i2c_data1;
60
61 npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
62 if (!npd)
63 printk(KERN_ERR "%s: no memory for platform data\n", __func__);
64 else if (!npd->cfg_gpio)
65 npd->cfg_gpio = s3c_i2c1_cfg_gpio;
66
67 s3c_device_i2c1.dev.platform_data = npd;
68}
diff --git a/arch/arm/plat-s3c/include/plat/devs.h b/arch/arm/plat-s3c/include/plat/devs.h
index d9e0c543ebd6..0e342d1fafbb 100644
--- a/arch/arm/plat-s3c/include/plat/devs.h
+++ b/arch/arm/plat-s3c/include/plat/devs.h
@@ -28,6 +28,7 @@ extern struct platform_device s3c_device_usb;
28extern struct platform_device s3c_device_lcd; 28extern struct platform_device s3c_device_lcd;
29extern struct platform_device s3c_device_wdt; 29extern struct platform_device s3c_device_wdt;
30extern struct platform_device s3c_device_i2c0; 30extern struct platform_device s3c_device_i2c0;
31extern struct platform_device s3c_device_i2c1;
31extern struct platform_device s3c_device_iis; 32extern struct platform_device s3c_device_iis;
32extern struct platform_device s3c_device_rtc; 33extern struct platform_device s3c_device_rtc;
33extern struct platform_device s3c_device_adc; 34extern struct platform_device s3c_device_adc;
diff --git a/arch/arm/plat-s3c/include/plat/iic.h b/arch/arm/plat-s3c/include/plat/iic.h
index 5073b1e74ee8..dc1dfcb9bc6c 100644
--- a/arch/arm/plat-s3c/include/plat/iic.h
+++ b/arch/arm/plat-s3c/include/plat/iic.h
@@ -48,8 +48,10 @@ struct s3c2410_platform_i2c {
48 * as the driver will no longer carry defaults. 48 * as the driver will no longer carry defaults.
49 */ 49 */
50extern void s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *i2c); 50extern void s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *i2c);
51extern void s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *i2c);
51 52
52/* defined by architecture to configure gpio */ 53/* defined by architecture to configure gpio */
53extern void s3c_i2c0_cfg_gpio(struct platform_device *dev); 54extern void s3c_i2c0_cfg_gpio(struct platform_device *dev);
55extern void s3c_i2c1_cfg_gpio(struct platform_device *dev);
54 56
55#endif /* __ASM_ARCH_IIC_H */ 57#endif /* __ASM_ARCH_IIC_H */