Commit 0e26da0f authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'i2c-for-2630-v2' of git://aeryn.fluff.org.uk/bjdooks/linux

* 'i2c-for-2630-v2' of git://aeryn.fluff.org.uk/bjdooks/linux:
  i2c: imx: Make disable_delay a per-device variable
  i2c: xtensa s6000 i2c driver
  powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
  i2c: i2c-mpc: make I2C bus speed configurable
  i2c: i2c-mpc: use dev based printout function
  i2c: i2c-mpc: various coding style fixes
  i2c: imx: Add missing request_mem_region in probe()
  i2c: i2c-s3c2410: Initialise Samsung I2C controller early
  i2c-s3c2410: Simplify bus frequency calculation
  i2c-s3c2410: sda_delay should be in ns, not clock ticks
  i2c: iMX/MXC support
parents 10a0d912 65de394d
......@@ -409,8 +409,7 @@ static struct platform_device bast_sio = {
static struct s3c2410_platform_i2c __initdata bast_i2c_info = {
.flags = 0,
.slave_addr = 0x10,
.bus_freq = 100*1000,
.max_freq = 130*1000,
.frequency = 100*1000,
};
/* Asix AX88796 10/100 ethernet controller */
......
......@@ -340,8 +340,7 @@ static struct platform_device *n35_devices[] __initdata = {
static struct s3c2410_platform_i2c n30_i2ccfg = {
.flags = 0,
.slave_addr = 0x10,
.bus_freq = 10*1000,
.max_freq = 10*1000,
.frequency = 10*1000,
};
/* Lots of hardcoded stuff, but it sets up the hardware in a useful
......
......@@ -453,8 +453,7 @@ static struct spi_board_info __initdata jive_spi_devs[] = {
/* I2C bus and device configuration. */
static struct s3c2410_platform_i2c jive_i2c_cfg __initdata = {
.max_freq = 80 * 1000,
.bus_freq = 50 * 1000,
.frequency = 80 * 1000,
.flags = S3C_IICFLG_FILTER,
.sda_delay = 2,
};
......
/*
* i2c.h - i.MX I2C driver header file
*
* Copyright (c) 2008, Darius Augulis <augulis.darius@gmail.com>
*
* This file is released under the GPLv2
*/
#ifndef __ASM_ARCH_I2C_H_
#define __ASM_ARCH_I2C_H_
/**
* struct imxi2c_platform_data - structure of platform data for MXC I2C driver
* @init: Initialise gpio's and other board specific things
* @exit: Free everything initialised by @init
* @bitrate: Bus speed measured in Hz
*
**/
struct imxi2c_platform_data {
int (*init)(struct device *dev);
void (*exit)(struct device *dev);
int bitrate;
};
#endif /* __ASM_ARCH_I2C_H_ */
/* linux/arch/arm/plat-s3c/dev-i2c0.c
*
* Copyright 2008 Simtec Electronics
* Copyright 2008,2009 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
* http://armlinux.simtec.co.uk/
*
......@@ -50,9 +50,8 @@ struct platform_device s3c_device_i2c0 = {
static struct s3c2410_platform_i2c default_i2c_data0 __initdata = {
.flags = 0,
.slave_addr = 0x10,
.bus_freq = 100*1000,
.max_freq = 400*1000,
.sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
.frequency = 100*1000,
.sda_delay = 100,
};
void __init s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *pd)
......
/* linux/arch/arm/plat-s3c/dev-i2c1.c
*
* Copyright 2008 Simtec Electronics
* Copyright 2008,2009 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
* http://armlinux.simtec.co.uk/
*
......@@ -47,9 +47,8 @@ static struct s3c2410_platform_i2c default_i2c_data1 __initdata = {
.flags = 0,
.bus_num = 1,
.slave_addr = 0x10,
.bus_freq = 100*1000,
.max_freq = 400*1000,
.sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
.frequency = 100*1000,
.sda_delay = 100,
};
void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd)
......
/* arch/arm/mach-s3c2410/include/mach/iic.h
/* arch/arm/plat-s3c/include/plat/iic.h
*
* Copyright (c) 2004 Simtec Electronics
* Copyright 2004,2009 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* S3C2410 - I2C Controller platfrom_device info
* S3C - I2C Controller platform_device info
*
* 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
......@@ -15,19 +15,24 @@
#define S3C_IICFLG_FILTER (1<<0) /* enable s3c2440 filter */
/* Notes:
* 1) All frequencies are expressed in Hz
* 2) A value of zero is `do not care`
*/
/**
* struct s3c2410_platform_i2c - Platform data for s3c I2C.
* @bus_num: The bus number to use (if possible).
* @flags: Any flags for the I2C bus (E.g. S3C_IICFLK_FILTER).
* @slave_addr: The I2C address for the slave device (if enabled).
* @frequency: The desired frequency in Hz of the bus. This is
* guaranteed to not be exceeded. If the caller does
* not care, use zero and the driver will select a
* useful default.
* @sda_delay: The delay (in ns) applied to SDA edges.
* @cfg_gpio: A callback to configure the pins for I2C operation.
*/
struct s3c2410_platform_i2c {
int bus_num; /* bus number to use */
int bus_num;
unsigned int flags;
unsigned int slave_addr; /* slave address for controller */
unsigned long bus_freq; /* standard bus frequency */
unsigned long max_freq; /* max frequency for the bus */
unsigned long min_freq; /* min frequency for the bus */
unsigned int sda_delay; /* pclks (s3c2440 only) */
unsigned int slave_addr;
unsigned long frequency;
unsigned int sda_delay;
void (*cfg_gpio)(struct platform_device *dev);
};
......
......@@ -79,11 +79,11 @@ i2c@3000 {
#address-cells = <1>;
#size-cells = <0>;
cell-index = <0>;
compatible = "fsl-i2c";
compatible = "fsl,mpc8544-i2c", "fsl-i2c";
reg = <0x3000 0x100>;
interrupts = <43 2>;
interrupt-parent = <&mpic>;
dfsrr;
fsl,preserve-clocking;
dtt@28 {
compatible = "winbond,w83782d";
......@@ -111,11 +111,11 @@ i2c@3100 {
#address-cells = <1>;
#size-cells = <0>;
cell-index = <1>;
compatible = "fsl-i2c";
compatible = "fsl,mpc8544-i2c", "fsl-i2c";
reg = <0x3100 0x100>;
interrupts = <43 2>;
interrupt-parent = <&mpic>;
dfsrr;
fsl,preserve-clocking;
};
enet0: ethernet@24000 {
......
......@@ -356,6 +356,16 @@ config I2C_IBM_IIC
This driver can also be built as a module. If so, the module
will be called i2c-ibm_iic.
config I2C_IMX
tristate "IMX I2C interface"
depends on ARCH_MXC
help
Say Y here if you want to use the IIC bus controller on
the Freescale i.MX/MXC processors.
This driver can also be built as a module. If so, the module
will be called i2c-imx.
config I2C_IOP3XX
tristate "Intel IOPx3xx and IXP4xx on-chip I2C interface"
depends on ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX || ARCH_IOP13XX
......@@ -462,6 +472,16 @@ config I2C_S3C2410
Say Y here to include support for I2C controller in the
Samsung S3C2410 based System-on-Chip devices.
config I2C_S6000
tristate "S6000 I2C support"
depends on XTENSA_VARIANT_S6000
help
This driver supports the on chip I2C device on the
S6000 xtensa processor family.
To compile this driver as a module, choose M here. The module
will be called i2c-s6000.
config I2C_SH7760
tristate "Renesas SH7760 I2C Controller"
depends on CPU_SUBTYPE_SH7760
......
......@@ -33,6 +33,7 @@ obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o
obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o
obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o
obj-$(CONFIG_I2C_IMX) += i2c-imx.o
obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o
obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o
obj-$(CONFIG_I2C_MPC) += i2c-mpc.o
......@@ -43,6 +44,7 @@ obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o
obj-$(CONFIG_I2C_PNX) += i2c-pnx.o
obj-$(CONFIG_I2C_PXA) += i2c-pxa.o
obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o
obj-$(CONFIG_I2C_S6000) += i2c-s6000.o
obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o
obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o
obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o
......
This diff is collapsed.
This diff is collapsed.
/* linux/drivers/i2c/busses/i2c-s3c2410.c
*
* Copyright (C) 2004,2005 Simtec Electronics
* Copyright (C) 2004,2005,2009 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* S3C2410 I2C Controller
......@@ -590,18 +590,6 @@ static int s3c24xx_i2c_calcdivisor(unsigned long clkin, unsigned int wanted,
return clkin / (calc_divs * calc_div1);
}
/* freq_acceptable
*
* test wether a frequency is within the acceptable range of error
*/
static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
{
int diff = freq - wanted;
return diff >= -2 && diff <= 2;
}
/* s3c24xx_i2c_clockrate
*
* work out a divisor for the user requested frequency setting,
......@@ -614,44 +602,28 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
struct s3c2410_platform_i2c *pdata = i2c->dev->platform_data;
unsigned long clkin = clk_get_rate(i2c->clk);
unsigned int divs, div1;
unsigned long target_frequency;
u32 iiccon;
int freq;
int start, end;
i2c->clkrate = clkin;
clkin /= 1000; /* clkin now in KHz */
dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n",
pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq);
if (pdata->bus_freq != 0) {
freq = s3c24xx_i2c_calcdivisor(clkin, pdata->bus_freq/1000,
&div1, &divs);
if (freq_acceptable(freq, pdata->bus_freq/1000))
goto found;
}
/* ok, we may have to search for something suitable... */
dev_dbg(i2c->dev, "pdata desired frequency %lu\n", pdata->frequency);
start = (pdata->max_freq == 0) ? pdata->bus_freq : pdata->max_freq;
end = pdata->min_freq;
target_frequency = pdata->frequency ? pdata->frequency : 100000;
start /= 1000;
end /= 1000;
target_frequency /= 1000; /* Target frequency now in KHz */
/* search loop... */
freq = s3c24xx_i2c_calcdivisor(clkin, target_frequency, &div1, &divs);
for (; start > end; start--) {
freq = s3c24xx_i2c_calcdivisor(clkin, start, &div1, &divs);
if (freq_acceptable(freq, start))
goto found;
if (freq > target_frequency) {
dev_err(i2c->dev,
"Unable to achieve desired frequency %luKHz." \
" Lowest achievable %dKHz\n", target_frequency, freq);
return -EINVAL;
}
/* cannot find frequency spec */
return -EINVAL;
found:
*got = freq;
iiccon = readl(i2c->regs + S3C2410_IICCON);
......@@ -663,6 +635,23 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
writel(iiccon, i2c->regs + S3C2410_IICCON);
if (s3c24xx_i2c_is2440(i2c)) {
unsigned long sda_delay;
if (pdata->sda_delay) {
sda_delay = (freq / 1000) * pdata->sda_delay;
sda_delay /= 1000000;
sda_delay = DIV_ROUND_UP(sda_delay, 5);
if (sda_delay > 3)
sda_delay = 3;
sda_delay |= S3C2410_IICLC_FILTER_ON;
} else
sda_delay = 0;
dev_dbg(i2c->dev, "IICLC=%08lx\n", sda_delay);
writel(sda_delay, i2c->regs + S3C2440_IICLC);
}
return 0;
}
......@@ -769,11 +758,8 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
/* check for s3c2440 i2c controller */
if (s3c24xx_i2c_is2440(i2c)) {
dev_dbg(i2c->dev, "S3C2440_IICLC=%08x\n", pdata->sda_delay);
writel(pdata->sda_delay, i2c->regs + S3C2440_IICLC);
}
if (s3c24xx_i2c_is2440(i2c))
writel(0x0, i2c->regs + S3C2440_IICLC);
return 0;
}
......@@ -1018,14 +1004,13 @@ static int __init i2c_adap_s3c_init(void)
return ret;
}
subsys_initcall(i2c_adap_s3c_init);
static void __exit i2c_adap_s3c_exit(void)
{
platform_driver_unregister(&s3c2410_i2c_driver);
platform_driver_unregister(&s3c2440_i2c_driver);
}
module_init(i2c_adap_s3c_init);
module_exit(i2c_adap_s3c_exit);
MODULE_DESCRIPTION("S3C24XX I2C Bus driver");
......
This diff is collapsed.
/*
* drivers/i2c/busses/i2c-s6000.h
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 2008 Emlix GmbH <info@emlix.com>
* Author: Oskar Schirmer <os@emlix.com>
*/
#ifndef __DRIVERS_I2C_BUSSES_I2C_S6000_H
#define __DRIVERS_I2C_BUSSES_I2C_S6000_H
#define S6_I2C_CON 0x000
#define S6_I2C_CON_MASTER 0
#define S6_I2C_CON_SPEED 1
#define S6_I2C_CON_SPEED_NORMAL 1
#define S6_I2C_CON_SPEED_FAST 2
#define S6_I2C_CON_SPEED_MASK 3
#define S6_I2C_CON_10BITSLAVE 3
#define S6_I2C_CON_10BITMASTER 4
#define S6_I2C_CON_RESTARTENA 5
#define S6_I2C_CON_SLAVEDISABLE 6
#define S6_I2C_TAR 0x004
#define S6_I2C_TAR_GCORSTART 10
#define S6_I2C_TAR_SPECIAL 11
#define S6_I2C_SAR 0x008
#define S6_I2C_HSMADDR 0x00C
#define S6_I2C_DATACMD 0x010
#define S6_I2C_DATACMD_READ 8
#define S6_I2C_SSHCNT 0x014
#define S6_I2C_SSLCNT 0x018
#define S6_I2C_FSHCNT 0x01C
#define S6_I2C_FSLCNT 0x020
#define S6_I2C_INTRSTAT 0x02C
#define S6_I2C_INTRMASK 0x030
#define S6_I2C_RAWINTR 0x034
#define S6_I2C_INTR_RXUNDER 0
#define S6_I2C_INTR_RXOVER 1
#define S6_I2C_INTR_RXFULL 2
#define S6_I2C_INTR_TXOVER 3
#define S6_I2C_INTR_TXEMPTY 4
#define S6_I2C_INTR_RDREQ 5
#define S6_I2C_INTR_TXABRT 6
#define S6_I2C_INTR_RXDONE 7
#define S6_I2C_INTR_ACTIVITY 8
#define S6_I2C_INTR_STOPDET 9
#define S6_I2C_INTR_STARTDET 10
#define S6_I2C_INTR_GENCALL 11
#define S6_I2C_RXTL 0x038
#define S6_I2C_TXTL 0x03C
#define S6_I2C_CLRINTR 0x040
#define S6_I2C_CLRRXUNDER 0x044
#define S6_I2C_CLRRXOVER 0x048
#define S6_I2C_CLRTXOVER 0x04C
#define S6_I2C_CLRRDREQ 0x050
#define S6_I2C_CLRTXABRT 0x054
#define S6_I2C_CLRRXDONE 0x058
#define S6_I2C_CLRACTIVITY 0x05C
#define S6_I2C_CLRSTOPDET 0x060
#define S6_I2C_CLRSTARTDET 0x064
#define S6_I2C_CLRGENCALL 0x068
#define S6_I2C_ENABLE 0x06C
#define S6_I2C_STATUS 0x070
#define S6_I2C_STATUS_ACTIVITY 0
#define S6_I2C_STATUS_TFNF 1
#define S6_I2C_STATUS_TFE 2
#define S6_I2C_STATUS_RFNE 3
#define S6_I2C_STATUS_RFF 4
#define S6_I2C_TXFLR 0x074
#define S6_I2C_RXFLR 0x078
#define S6_I2C_SRESET 0x07C
#define S6_I2C_SRESET_IC_SRST 0
#define S6_I2C_SRESET_IC_MASTER_SRST 1
#define S6_I2C_SRESET_IC_SLAVE_SRST 2
#define S6_I2C_TXABRTSOURCE 0x080
#endif
#ifndef __LINUX_I2C_S6000_H
#define __LINUX_I2C_S6000_H
struct s6_i2c_platform_data {
const char *clock; /* the clock to use */
int bus_num; /* the bus number to register */
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment