Skip to contentSkip to conversation

ARM: S5PV310: Add I2C support

PATCH In review Jongsun Han 2 participants 5 messages Oct 7, 2010 – Oct 12, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ARM: S5PV310: Add I2C support

This patch adds the I2C support for S5PV310

[PATCH 1/3] ARM: SAMSUNG: Add a helper function for I2C(3,4,5,6,7) platform devices [PATCH 2/3] ARM: S5PV310: Add address and IRQ definitions for I2C(1,2,3,4,5,6,7) [PATCH 3/3] ARM: S5PV310: Add I2C(0,1,3,4,5,6,7) support

#1 lore raw

PATCH 1/3 ARM: SAMSUNG: Add a helper function for I2C(3,4,5,6,7) platform devices

This patch adds a helper function for I2C(3,4,5,6,7) in dev-i2c.c.

I2C(0,1,2) helper functions and definitions are moved to dev-i2c.c and dev-i2c(0,1,2).c are removed.

---
 arch/arm/plat-samsung/Kconfig             |   25 +++
 arch/arm/plat-samsung/Makefile            |    4 +-
 arch/arm/plat-samsung/dev-i2c.c           |  226 +++++++++++++++++++++++++++++
 arch/arm/plat-samsung/dev-i2c0.c          |   72 ---------
 arch/arm/plat-samsung/dev-i2c1.c          |   69 ---------
 arch/arm/plat-samsung/dev-i2c2.c          |   70 ---------
 arch/arm/plat-samsung/include/plat/devs.h |    1 +
 arch/arm/plat-samsung/include/plat/iic.h  |    6 +
 8 files changed, 259 insertions(+), 214 deletions(-)
 create mode 100644 arch/arm/plat-samsung/dev-i2c.c
 delete mode 100644 arch/arm/plat-samsung/dev-i2c0.c
 delete mode 100644 arch/arm/plat-samsung/dev-i2c1.c
 delete mode 100644 arch/arm/plat-samsung/dev-i2c2.c
arch/arm/plat-samsung/Kconfig +25 -0
index 7c0bde7..701f390 100644
@@ -180,6 +180,31 @@ config S3C_DEV_I2C2
 	help
 	  Compile in platform device definitions for I2C channel 2
 
+config S3C_DEV_I2C3
+	bool
+	help
+	  Compile in platform device definitions for I2C channel 3
+
+config S3C_DEV_I2C4
+	bool
+	help
+	  Compile in platform device definitions for I2C channel 4
+
+config S3C_DEV_I2C5
+	bool
+	help
+	  Compile in platform device definitions for I2C channel 5
+
+config S3C_DEV_I2C6
+	bool
+	help
+	  Compile in platform device definitions for I2C channel 6
+
+config S3C_DEV_I2C7
+	bool
+	help
+	  Compile in platform device definitions for I2C channel 7
+
 config S3C_DEV_FB
 	bool
 	help
arch/arm/plat-samsung/Makefile +1 -3
index 4d8ff92..f8ef381 100644
@@ -37,9 +37,7 @@ obj-$(CONFIG_S3C_DEV_HSMMC1)	+= dev-hsmmc1.o
 obj-$(CONFIG_S3C_DEV_HSMMC2)	+= dev-hsmmc2.o
 obj-$(CONFIG_S3C_DEV_HSMMC3)	+= dev-hsmmc3.o
 obj-$(CONFIG_S3C_DEV_HWMON)	+= dev-hwmon.o
-obj-y				+= dev-i2c0.o
-obj-$(CONFIG_S3C_DEV_I2C1)	+= dev-i2c1.o
-obj-$(CONFIG_S3C_DEV_I2C2)	+= dev-i2c2.o
+obj-y				+= dev-i2c.o
 obj-$(CONFIG_S3C_DEV_FB)	+= dev-fb.o
 obj-y				+= dev-uart.o
 obj-$(CONFIG_S3C_DEV_USB_HOST)	+= dev-usb.o
arch/arm/plat-samsung/dev-i2c.c new file +226 -0

226 lines not on this page · raw message

arch/arm/plat-samsung/dev-i2c0.c deleted +0 -72

72 lines not on this page · raw message

arch/arm/plat-samsung/dev-i2c1.c deleted +0 -69

69 lines not on this page · raw message

arch/arm/plat-samsung/dev-i2c2.c deleted +0 -70

70 lines not on this page · raw message

arch/arm/plat-samsung/include/plat/devs.h +1 -0
index 7d448e1..b346957 100644
@@ -46,6 +46,7 @@ extern struct platform_device s3c_device_wdt;
 extern struct platform_device s3c_device_i2c0;
 extern struct platform_device s3c_device_i2c1;
 extern struct platform_device s3c_device_i2c2;
+extern struct platform_device s3c_device_i2c[];
 extern struct platform_device s3c_device_rtc;
 extern struct platform_device s3c_device_adc;
 extern struct platform_device s3c_device_sdi;
arch/arm/plat-samsung/include/plat/iic.h +6 -0
index 133308b..0fb9c6e 100644
@@ -55,10 +55,16 @@ struct s3c2410_platform_i2c {
 extern void s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *i2c);
 extern void s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *i2c);
 extern void s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *i2c);
+extern void s3c_i2c_set_platdata(struct s3c2410_platform_i2c *i2c);
 
 /* defined by architecture to configure gpio */
 extern void s3c_i2c0_cfg_gpio(struct platform_device *dev);
 extern void s3c_i2c1_cfg_gpio(struct platform_device *dev);
 extern void s3c_i2c2_cfg_gpio(struct platform_device *dev);
+extern void s3c_i2c3_cfg_gpio(struct platform_device *dev);
+extern void s3c_i2c4_cfg_gpio(struct platform_device *dev);
+extern void s3c_i2c5_cfg_gpio(struct platform_device *dev);
+extern void s3c_i2c6_cfg_gpio(struct platform_device *dev);
+extern void s3c_i2c7_cfg_gpio(struct platform_device *dev);
 
 #endif /* __ASM_ARCH_IIC_H */
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH 2/3 ARM: S5PV310: Add address and IRQ definitions for I2C(1,2,3,4,5,6,7)

In reply to Jongsun Han

This patch adds address and IRQ definitions for I2C(1,2,3,4,5,6,7) devices.

S5PV310 supports 8 I2C channels.

---
 arch/arm/mach-s5pv310/include/mach/irqs.h |    8 ++++++++
 arch/arm/mach-s5pv310/include/mach/map.h  |   19 +++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)
arch/arm/mach-s5pv310/include/mach/irqs.h +8 -0
index e81332f..fcbfef6 100644
@@ -70,6 +70,14 @@
 #define IRQ_UART4		COMBINER_IRQ(26, 4)
 
 #define IRQ_IIC			COMBINER_IRQ(27, 0)
+#define IRQ_IIC1		COMBINER_IRQ(27, 1)
+#define IRQ_IIC2		COMBINER_IRQ(27, 2)
+#define IRQ_IIC3		COMBINER_IRQ(27, 3)
+#define IRQ_IIC4		COMBINER_IRQ(27, 4)
+#define IRQ_IIC5		COMBINER_IRQ(27, 5)
+#define IRQ_IIC6		COMBINER_IRQ(27, 6)
+#define IRQ_IIC7		COMBINER_IRQ(27, 7)
+
 
 #define IRQ_HSMMC0		COMBINER_IRQ(29, 0)
 #define IRQ_HSMMC1		COMBINER_IRQ(29, 1)
arch/arm/mach-s5pv310/include/mach/map.h +17 -2
index eab0ff7..3a5db9d 100644
@@ -70,6 +70,13 @@
 #define S5P_SZ_UART			SZ_256
 
 #define S5PV310_PA_IIC0			(0x13860000)
+#define S5PV310_PA_IIC1			(0x13870000)
+#define S5PV310_PA_IIC2			(0x13880000)
+#define S5PV310_PA_IIC3			(0x13890000)
+#define S5PV310_PA_IIC4			(0x138A0000)
+#define S5PV310_PA_IIC5			(0x138B0000)
+#define S5PV310_PA_IIC6			(0x138C0000)
+#define S5PV310_PA_IIC7			(0x138D0000)
 
 #define S5PV310_PA_TIMER		(0x139D0000)
 #define S5P_PA_TIMER			S5PV310_PA_TIMER
@@ -83,8 +90,16 @@
 #define S3C_PA_HSMMC1			S5PV310_PA_HSMMC(1)
 #define S3C_PA_HSMMC2			S5PV310_PA_HSMMC(2)
 #define S3C_PA_HSMMC3			S5PV310_PA_HSMMC(3)
-#define S3C_PA_IIC			S5PV310_PA_IIC0
-#define S3C_PA_RTC			S5PV310_PA_RTC
 #define S3C_PA_WDT			S5PV310_PA_WATCHDOG
+#define S3C_PA_RTC			S5PV310_PA_RTC
+
+#define S3C_PA_IIC			S5PV310_PA_IIC0
+#define S3C_PA_IIC1			S5PV310_PA_IIC1
+#define S3C_PA_IIC2			S5PV310_PA_IIC2
+#define S3C_PA_IIC3			S5PV310_PA_IIC3
+#define S3C_PA_IIC4			S5PV310_PA_IIC4
+#define S3C_PA_IIC5			S5PV310_PA_IIC5
+#define S3C_PA_IIC6			S5PV310_PA_IIC6
+#define S3C_PA_IIC7			S5PV310_PA_IIC7
 
 #endif /* __ASM_ARCH_MAP_H */
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 3/3 ARM: S5PV310: Add I2C(0,1,3,4,5,6,7) support

In reply to Jongsun Han

This patch adds the I2C support for S5PV310.

S5PV310 supports 8 I2C channels.
mach-smdkv310.c doesn't support I2C(2,3) because the GPIOs of these I2C channels are used by UART channel(1,2)
All I2C platform helper functions are moved to setup-i2c.c and setup-i2c(0,1,2).c files are removed.

---
 arch/arm/Kconfig                      |    1 +
 arch/arm/mach-s5pv310/Kconfig         |   40 +++++++++++++
 arch/arm/mach-s5pv310/Makefile        |    5 +-
 arch/arm/mach-s5pv310/mach-smdkv310.c |   39 +++++++++++++
 arch/arm/mach-s5pv310/setup-i2c.c     |   98 +++++++++++++++++++++++++++++++++
 arch/arm/mach-s5pv310/setup-i2c0.c    |   28 ---------
 arch/arm/mach-s5pv310/setup-i2c1.c    |   25 --------
 arch/arm/mach-s5pv310/setup-i2c2.c    |   25 --------
 8 files changed, 179 insertions(+), 82 deletions(-)
 create mode 100644 arch/arm/mach-s5pv310/setup-i2c.c
 delete mode 100644 arch/arm/mach-s5pv310/setup-i2c0.c
 delete mode 100644 arch/arm/mach-s5pv310/setup-i2c1.c
 delete mode 100644 arch/arm/mach-s5pv310/setup-i2c2.c
arch/arm/Kconfig +1 -0
index 903ab04..8b489a8 100644
@@ -738,6 +738,7 @@ config ARCH_S5PV310
 	select GENERIC_CLOCKEVENTS
 	select HAVE_S3C_RTC
 	select HAVE_S3C2410_WATCHDOG
+	select HAVE_S3C2410_I2C
 	help
 	  Samsung S5PV310 series based systems
 
arch/arm/mach-s5pv310/Kconfig +40 -0
index 9941852..dd92ef2 100644
@@ -24,6 +24,31 @@ config S5PV310_SETUP_I2C2
 	help
 	  Common setup code for i2c bus 2.
 
+config S5PV310_SETUP_I2C3
+	bool
+	help
+	  Common setup code for i2c bus 3.
+
+config S5PV310_SETUP_I2C4
+	bool
+	help
+	  Common setup code for i2c bus 4.
+
+config S5PV310_SETUP_I2C5
+	bool
+	help
+	  Common setup code for i2c bus 5.
+
+config S5PV310_SETUP_I2C6
+	bool
+	help
+	  Common setup code for i2c bus 6.
+
+config S5PV310_SETUP_I2C7
+	bool
+	help
+	  Common setup code for i2c bus 7.
+
 # machine support
 
 menu "S5PC210 Machines"
@@ -51,8 +76,23 @@ menu "S5PV310 Machines"
 config MACH_SMDKV310
 	bool "SMDKV310"
 	select CPU_S5PV310
+	select ARCH_SPARSEMEM_ENABLE
 	select S3C_DEV_RTC
 	select S3C_DEV_WDT
+	select S3C_DEV_I2C1
+	select S3C_DEV_I2C2
+	select S3C_DEV_I2C3
+	select S3C_DEV_I2C4
+	select S3C_DEV_I2C5
+	select S3C_DEV_I2C6
+	select S3C_DEV_I2C7
+	select S5PV310_SETUP_I2C1
+	select S5PV310_SETUP_I2C2
+	select S5PV310_SETUP_I2C3
+	select S5PV310_SETUP_I2C4
+	select S5PV310_SETUP_I2C5
+	select S5PV310_SETUP_I2C6
+	select S5PV310_SETUP_I2C7
 	help
 	  Machine support for Samsung SMDKV310
 
arch/arm/mach-s5pv310/Makefile +1 -4
index d17c8c7..32ea94f 100644
@@ -13,7 +13,7 @@ obj-				:=
 # Core support for S5PV310 system
 
 obj-$(CONFIG_CPU_S5PV310)	+= cpu.o init.o clock.o irq-combiner.o
-obj-$(CONFIG_CPU_S5PV310)	+= setup-i2c0.o time.o
+obj-$(CONFIG_CPU_S5PV310)	+= setup-i2c.o time.o
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq.o
 
 obj-$(CONFIG_SMP)		+= platsmp.o headsmp.o
@@ -27,6 +27,3 @@ obj-$(CONFIG_MACH_SMDKV310)	+= mach-smdkv310.o
 obj-$(CONFIG_MACH_UNIVERSAL_C210)	+= mach-universal_c210.o
 
 # device support
-
-obj-$(CONFIG_S5PV310_SETUP_I2C1)	+= setup-i2c1.o
-obj-$(CONFIG_S5PV310_SETUP_I2C2)	+= setup-i2c2.o
arch/arm/mach-s5pv310/mach-smdkv310.c +39 -0
index 9cb827d..404a7cc 100644
@@ -9,6 +9,7 @@
 */
 
 #include <linux/serial_core.h>
+#include <linux/i2c.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
@@ -18,6 +19,7 @@
 #include <plat/s5pv310.h>
 #include <plat/cpu.h>
 #include <plat/devs.h>
+#include <plat/iic.h>
 
 #include <mach/map.h>
 
@@ -69,6 +71,32 @@ static struct s3c2410_uartcfg smdkv310_uartcfgs[] __initdata = {
 static struct platform_device *smdkv310_devices[] __initdata = {
 	&s3c_device_rtc,
 	&s3c_device_wdt,
+	&s3c_device_i2c0,
+	&s3c_device_i2c1,
+	&s3c_device_i2c[4],
+	&s3c_device_i2c[5],
+	&s3c_device_i2c[6],
+	&s3c_device_i2c[7],
+};
+
+static struct i2c_board_info i2c_devs0[] __initdata = {
+	{ I2C_BOARD_INFO("24c128", 0x50), },	 /* Samsung S524AD0XD1 */
+	{ I2C_BOARD_INFO("24c128", 0x52), },	 /* Samsung S524AD0XD1 */
+};
+
+static struct i2c_board_info i2c_devs1[] __initdata = {
+};
+
+static struct i2c_board_info i2c_devs4[] __initdata = {
+};
+
+static struct i2c_board_info i2c_devs5[] __initdata = {
+};
+
+static struct i2c_board_info i2c_devs6[] __initdata = {
+};
+
+static struct i2c_board_info i2c_devs7[] __initdata = {
 };
 
 static void __init smdkv310_map_io(void)
@@ -84,6 +112,17 @@ static void __init smdkv310_machine_init(void)
 	l2x0_init(S5P_VA_L2CC, 1 << 28, 0xffffffff);
 #endif
 
+	s3c_i2c0_set_platdata(NULL);
+	s3c_i2c1_set_platdata(NULL);
+	s3c_i2c_set_platdata(NULL);
+
+	i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
+	i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
+	i2c_register_board_info(4, i2c_devs4, ARRAY_SIZE(i2c_devs4));
+	i2c_register_board_info(5, i2c_devs5, ARRAY_SIZE(i2c_devs5));
+	i2c_register_board_info(6, i2c_devs6, ARRAY_SIZE(i2c_devs6));
+	i2c_register_board_info(7, i2c_devs7, ARRAY_SIZE(i2c_devs7));
+
 	platform_add_devices(smdkv310_devices, ARRAY_SIZE(smdkv310_devices));
 }
 
arch/arm/mach-s5pv310/setup-i2c.c new file +98 -0

98 lines not on this page · raw message

arch/arm/mach-s5pv310/setup-i2c0.c deleted +0 -28
deleted file mode 100644
index 4367128..0000000
@@ -1,28 +0,0 @@
-/*
- * linux/arch/arm/mach-s5pv310/setup-i2c0.c
- *
- * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
- *		http://www.samsung.com/
- *
- * I2C0 GPIO configuration.
- *
- * Based on plat-s3c64xx/setup-i2c0.c
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
-*/
-
-struct platform_device; /* don't need the contents */
-
-#include <linux/gpio.h>
-#include <plat/iic.h>
-#include <plat/gpio-cfg.h>
-
-void s3c_i2c0_cfg_gpio(struct platform_device *dev)
-{
-	s3c_gpio_cfgpin(S5PV310_GPD1(0), S3C_GPIO_SFN(2));
-	s3c_gpio_setpull(S5PV310_GPD1(0), S3C_GPIO_PULL_UP);
-	s3c_gpio_cfgpin(S5PV310_GPD1(1), S3C_GPIO_SFN(2));
-	s3c_gpio_setpull(S5PV310_GPD1(1), S3C_GPIO_PULL_UP);
-}
arch/arm/mach-s5pv310/setup-i2c1.c deleted +0 -25
deleted file mode 100644
index 1ecd5bc..0000000
@@ -1,25 +0,0 @@
-/*
- * linux/arch/arm/mach-s5pv310/setup-i2c1.c
- *
- * Copyright (C) 2010 Samsung Electronics Co., Ltd.
- *
- * I2C1 GPIO configuration.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
-*/
-
-struct platform_device; /* don't need the contents */
-
-#include <linux/gpio.h>
-#include <plat/iic.h>
-#include <plat/gpio-cfg.h>
-
-void s3c_i2c1_cfg_gpio(struct platform_device *dev)
-{
-	s3c_gpio_cfgpin(S5PV310_GPD1(2), S3C_GPIO_SFN(2));
-	s3c_gpio_setpull(S5PV310_GPD1(2), S3C_GPIO_PULL_UP);
-	s3c_gpio_cfgpin(S5PV310_GPD1(3), S3C_GPIO_SFN(2));
-	s3c_gpio_setpull(S5PV310_GPD1(3), S3C_GPIO_PULL_UP);
-}
arch/arm/mach-s5pv310/setup-i2c2.c deleted +0 -25
deleted file mode 100644
index 4c0d8de..0000000
@@ -1,25 +0,0 @@
-/*
- * linux/arch/arm/mach-s5pv310/setup-i2c2.c
- *
- * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
- *
- * I2C2 GPIO configuration.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
-*/
-
-struct platform_device; /* don't need the contents */
-
-#include <linux/gpio.h>
-#include <plat/iic.h>
-#include <plat/gpio-cfg.h>
-
-void s3c_i2c2_cfg_gpio(struct platform_device *dev)
-{
-	s3c_gpio_cfgpin(S5PV310_GPA0(6), S3C_GPIO_SFN(3));
-	s3c_gpio_setpull(S5PV310_GPA0(6), S3C_GPIO_PULL_UP);
-	s3c_gpio_cfgpin(S5PV310_GPA0(7), S3C_GPIO_SFN(3));
-	s3c_gpio_setpull(S5PV310_GPA0(7), S3C_GPIO_PULL_UP);
-}
Signature · 1 line
1.6.3.3
#4 lore raw
In reply to Jongsun Han
Quoted 4 lines · Jongsun Han

This patch adds the I2C support for S5PV310

[PATCH 1/3] ARM: SAMSUNG: Add a helper function for I2C(3,4,5,6,7)

platform

Quoted 2 lines

devices
[PATCH 2/3] ARM: S5PV310: Add address and IRQ definitions for

I2C(1,2,3,4,5,6,7)

Quoted 1 line

[PATCH 3/3] ARM: S5PV310: Add I2C(0,1,3,4,5,6,7) support

Hello Jongsun,

Thanks for your patch.
But we have not enough time to update/discuss it for 37 merge window. So right now, I applied Kyungmin and Marek's old style I2C patches for many I2C channels on S5PV310/S5PC210.

But I also hope to change its style to better something and will review your patches soon.

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.