Skip to content

Commit

Permalink
ARM: S5PV310: Add I2C channel 3, 4, 5, 6, and 7 device support
Browse files Browse the repository at this point in the history
S5PV310 and S5PC210 support more I2C devices than previous SoCs.
Add the device support code for them.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
  • Loading branch information
Kyungmin Park authored and Kukjin Kim committed Oct 25, 2010
1 parent 8a3710d commit b7a9825
Show file tree
Hide file tree
Showing 17 changed files with 531 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ config ARCH_S5PV310
select HAVE_CLK
select GENERIC_CLOCKEVENTS
select HAVE_S3C_RTC
select HAVE_S3C2410_I2C
select HAVE_S3C2410_WATCHDOG
help
Samsung S5PV310 series based systems
Expand Down
25 changes: 25 additions & 0 deletions arch/arm/mach-s5pv310/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.

config S5PV310_SETUP_SDHCI
bool
select S5PV310_SETUP_SDHCI_GPIO
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/mach-s5pv310/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@ obj-$(CONFIG_MACH_UNIVERSAL_C210) += mach-universal_c210.o

obj-$(CONFIG_S5PV310_SETUP_I2C1) += setup-i2c1.o
obj-$(CONFIG_S5PV310_SETUP_I2C2) += setup-i2c2.o
obj-$(CONFIG_S5PV310_SETUP_I2C3) += setup-i2c3.o
obj-$(CONFIG_S5PV310_SETUP_I2C4) += setup-i2c4.o
obj-$(CONFIG_S5PV310_SETUP_I2C5) += setup-i2c5.o
obj-$(CONFIG_S5PV310_SETUP_I2C6) += setup-i2c6.o
obj-$(CONFIG_S5PV310_SETUP_I2C7) += setup-i2c7.o
obj-$(CONFIG_S5PV310_SETUP_SDHCI) += setup-sdhci.o
obj-$(CONFIG_S5PV310_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
23 changes: 23 additions & 0 deletions arch/arm/mach-s5pv310/setup-i2c3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* linux/arch/arm/mach-s5pv310/setup-i2c3.c
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
*
* I2C3 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_i2c3_cfg_gpio(struct platform_device *dev)
{
s3c_gpio_cfgall_range(S5PV310_GPA1(2), 2,
S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
}
23 changes: 23 additions & 0 deletions arch/arm/mach-s5pv310/setup-i2c4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* linux/arch/arm/mach-s5pv310/setup-i2c4.c
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
*
* I2C4 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_i2c4_cfg_gpio(struct platform_device *dev)
{
s3c_gpio_cfgall_range(S5PV310_GPB(2), 2,
S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
}
23 changes: 23 additions & 0 deletions arch/arm/mach-s5pv310/setup-i2c5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* linux/arch/arm/mach-s5pv310/setup-i2c5.c
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
*
* I2C5 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_i2c5_cfg_gpio(struct platform_device *dev)
{
s3c_gpio_cfgall_range(S5PV310_GPB(6), 2,
S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
}
23 changes: 23 additions & 0 deletions arch/arm/mach-s5pv310/setup-i2c6.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* linux/arch/arm/mach-s5pv310/setup-i2c6.c
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
*
* I2C6 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_i2c6_cfg_gpio(struct platform_device *dev)
{
s3c_gpio_cfgall_range(S5PV310_GPC1(3), 2,
S3C_GPIO_SFN(4), S3C_GPIO_PULL_UP);
}
23 changes: 23 additions & 0 deletions arch/arm/mach-s5pv310/setup-i2c7.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* linux/arch/arm/mach-s5pv310/setup-i2c7.c
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
*
* I2C7 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_i2c7_cfg_gpio(struct platform_device *dev)
{
s3c_gpio_cfgall_range(S5PV310_GPD0(2), 2,
S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
}
25 changes: 25 additions & 0 deletions arch/arm/plat-samsung/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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 definition for I2C controller 3

config S3C_DEV_I2C4
bool
help
Compile in platform device definition for I2C controller 4

config S3C_DEV_I2C5
bool
help
Compile in platform device definition for I2C controller 5

config S3C_DEV_I2C6
bool
help
Compile in platform device definition for I2C controller 6

config S3C_DEV_I2C7
bool
help
Compile in platform device definition for I2C controller 7

config S3C_DEV_FB
bool
help
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/plat-samsung/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ 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-$(CONFIG_S3C_DEV_I2C3) += dev-i2c3.o
obj-$(CONFIG_S3C_DEV_I2C4) += dev-i2c4.o
obj-$(CONFIG_S3C_DEV_I2C5) += dev-i2c5.o
obj-$(CONFIG_S3C_DEV_I2C6) += dev-i2c6.o
obj-$(CONFIG_S3C_DEV_I2C7) += dev-i2c7.o
obj-$(CONFIG_S3C_DEV_FB) += dev-fb.o
obj-y += dev-uart.o
obj-$(CONFIG_S3C_DEV_USB_HOST) += dev-usb.o
Expand Down
68 changes: 68 additions & 0 deletions arch/arm/plat-samsung/dev-i2c3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* linux/arch/arm/plat-samsung/dev-i2c3.c
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
* http://www.samsung.com/
*
* S5P series device definition for i2c device 3
*
* 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.
*/

#include <linux/gfp.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/platform_device.h>

#include <mach/irqs.h>
#include <mach/map.h>

#include <plat/regs-iic.h>
#include <plat/iic.h>
#include <plat/devs.h>
#include <plat/cpu.h>

static struct resource s3c_i2c_resource[] = {
[0] = {
.start = S3C_PA_IIC3,
.end = S3C_PA_IIC3 + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_IIC3,
.end = IRQ_IIC3,
.flags = IORESOURCE_IRQ,
},
};

struct platform_device s3c_device_i2c3 = {
.name = "s3c2440-i2c",
.id = 3,
.num_resources = ARRAY_SIZE(s3c_i2c_resource),
.resource = s3c_i2c_resource,
};

static struct s3c2410_platform_i2c default_i2c_data3 __initdata = {
.flags = 0,
.bus_num = 3,
.slave_addr = 0x10,
.frequency = 100*1000,
.sda_delay = 100,
};

void __init s3c_i2c3_set_platdata(struct s3c2410_platform_i2c *pd)
{
struct s3c2410_platform_i2c *npd;

if (!pd)
pd = &default_i2c_data3;

npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
if (!npd)
printk(KERN_ERR "%s: no memory for platform data\n", __func__);
else if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c3_cfg_gpio;

s3c_device_i2c3.dev.platform_data = npd;
}
68 changes: 68 additions & 0 deletions arch/arm/plat-samsung/dev-i2c4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* linux/arch/arm/plat-samsung/dev-i2c4.c
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
* http://www.samsung.com/
*
* S5P series device definition for i2c device 3
*
* 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.
*/

#include <linux/gfp.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/platform_device.h>

#include <mach/irqs.h>
#include <mach/map.h>

#include <plat/regs-iic.h>
#include <plat/iic.h>
#include <plat/devs.h>
#include <plat/cpu.h>

static struct resource s3c_i2c_resource[] = {
[0] = {
.start = S3C_PA_IIC4,
.end = S3C_PA_IIC4 + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_IIC4,
.end = IRQ_IIC4,
.flags = IORESOURCE_IRQ,
},
};

struct platform_device s3c_device_i2c4 = {
.name = "s3c2440-i2c",
.id = 4,
.num_resources = ARRAY_SIZE(s3c_i2c_resource),
.resource = s3c_i2c_resource,
};

static struct s3c2410_platform_i2c default_i2c_data4 __initdata = {
.flags = 0,
.bus_num = 4,
.slave_addr = 0x10,
.frequency = 100*1000,
.sda_delay = 100,
};

void __init s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *pd)
{
struct s3c2410_platform_i2c *npd;

if (!pd)
pd = &default_i2c_data4;

npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
if (!npd)
printk(KERN_ERR "%s: no memory for platform data\n", __func__);
else if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c4_cfg_gpio;

s3c_device_i2c4.dev.platform_data = npd;
}
Loading

0 comments on commit b7a9825

Please sign in to comment.