2006-12-11 04:21:29 +08:00
|
|
|
/*
|
|
|
|
* Provides I2C support for Philips PNX010x/PNX4008 boards.
|
|
|
|
*
|
|
|
|
* Authors: Dennis Kovalev <dkovalev@ru.mvista.com>
|
|
|
|
* Vitaly Wool <vwool@ru.mvista.com>
|
|
|
|
*
|
|
|
|
* 2004-2006 (c) MontaVista Software, Inc. This file is licensed under
|
|
|
|
* the terms of the GNU General Public License version 2. This program
|
|
|
|
* is licensed "as is" without any warranty of any kind, whether express
|
|
|
|
* or implied.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/completion.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/i2c-pnx.h>
|
2009-11-12 07:25:52 +08:00
|
|
|
#include <linux/io.h>
|
2009-11-20 19:12:26 +08:00
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/clk.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-11-20 19:12:26 +08:00
|
|
|
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/hardware.h>
|
2009-11-12 07:25:52 +08:00
|
|
|
#include <mach/i2c.h>
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
#define I2C_PNX_TIMEOUT 10 /* msec */
|
|
|
|
#define I2C_PNX_SPEED_KHZ 100
|
|
|
|
#define I2C_PNX_REGION_SIZE 0x100
|
|
|
|
|
|
|
|
static inline int wait_timeout(long timeout, struct i2c_pnx_algo_data *data)
|
|
|
|
{
|
|
|
|
while (timeout > 0 &&
|
|
|
|
(ioread32(I2C_REG_STS(data)) & mstatus_active)) {
|
|
|
|
mdelay(1);
|
|
|
|
timeout--;
|
|
|
|
}
|
|
|
|
return (timeout <= 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int wait_reset(long timeout, struct i2c_pnx_algo_data *data)
|
|
|
|
{
|
|
|
|
while (timeout > 0 &&
|
|
|
|
(ioread32(I2C_REG_CTL(data)) & mcntrl_reset)) {
|
|
|
|
mdelay(1);
|
|
|
|
timeout--;
|
|
|
|
}
|
|
|
|
return (timeout <= 0);
|
|
|
|
}
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data)
|
2006-12-11 04:21:29 +08:00
|
|
|
{
|
2009-11-21 20:40:00 +08:00
|
|
|
struct timer_list *timer = &alg_data->mif.timer;
|
2009-11-21 20:58:13 +08:00
|
|
|
unsigned long expires = msecs_to_jiffies(I2C_PNX_TIMEOUT);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
2009-11-12 07:28:13 +08:00
|
|
|
if (expires <= 1)
|
|
|
|
expires = 2;
|
|
|
|
|
2006-12-11 04:21:29 +08:00
|
|
|
del_timer_sync(timer);
|
|
|
|
|
2009-11-21 20:58:13 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "Timer armed at %lu plus %lu jiffies.\n",
|
2006-12-11 04:21:29 +08:00
|
|
|
jiffies, expires);
|
|
|
|
|
|
|
|
timer->expires = jiffies + expires;
|
2011-04-29 21:30:02 +08:00
|
|
|
timer->data = (unsigned long)alg_data;
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
add_timer(timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* i2c_pnx_start - start a device
|
|
|
|
* @slave_addr: slave address
|
|
|
|
* @adap: pointer to adapter structure
|
|
|
|
*
|
|
|
|
* Generate a START signal in the desired mode.
|
|
|
|
*/
|
2009-11-21 20:40:00 +08:00
|
|
|
static int i2c_pnx_start(unsigned char slave_addr,
|
|
|
|
struct i2c_pnx_algo_data *alg_data)
|
2006-12-11 04:21:29 +08:00
|
|
|
{
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): addr 0x%x mode %d\n", __func__,
|
2006-12-11 04:21:29 +08:00
|
|
|
slave_addr, alg_data->mif.mode);
|
|
|
|
|
|
|
|
/* Check for 7 bit slave addresses only */
|
|
|
|
if (slave_addr & ~0x7f) {
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_err(&alg_data->adapter.dev,
|
|
|
|
"%s: Invalid slave address %x. Only 7-bit addresses are supported\n",
|
|
|
|
alg_data->adapter.name, slave_addr);
|
2006-12-11 04:21:29 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First, make sure bus is idle */
|
|
|
|
if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) {
|
|
|
|
/* Somebody else is monopolizing the bus */
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_err(&alg_data->adapter.dev,
|
|
|
|
"%s: Bus busy. Slave addr = %02x, cntrl = %x, stat = %x\n",
|
|
|
|
alg_data->adapter.name, slave_addr,
|
|
|
|
ioread32(I2C_REG_CTL(alg_data)),
|
|
|
|
ioread32(I2C_REG_STS(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
return -EBUSY;
|
|
|
|
} else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) {
|
|
|
|
/* Sorry, we lost the bus */
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_err(&alg_data->adapter.dev,
|
|
|
|
"%s: Arbitration failure. Slave addr = %02x\n",
|
|
|
|
alg_data->adapter.name, slave_addr);
|
2006-12-11 04:21:29 +08:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OK, I2C is enabled and we have the bus.
|
|
|
|
* Clear the current TDI and AFI status flags.
|
|
|
|
*/
|
|
|
|
iowrite32(ioread32(I2C_REG_STS(alg_data)) | mstatus_tdi | mstatus_afi,
|
|
|
|
I2C_REG_STS(alg_data));
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): sending %#x\n", __func__,
|
2006-12-11 04:21:29 +08:00
|
|
|
(slave_addr << 1) | start_bit | alg_data->mif.mode);
|
|
|
|
|
|
|
|
/* Write the slave address, START bit and R/W bit */
|
|
|
|
iowrite32((slave_addr << 1) | start_bit | alg_data->mif.mode,
|
|
|
|
I2C_REG_TX(alg_data));
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): exit\n", __func__);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* i2c_pnx_stop - stop a device
|
|
|
|
* @adap: pointer to I2C adapter structure
|
|
|
|
*
|
|
|
|
* Generate a STOP signal to terminate the master transaction.
|
|
|
|
*/
|
2009-11-21 20:40:00 +08:00
|
|
|
static void i2c_pnx_stop(struct i2c_pnx_algo_data *alg_data)
|
2006-12-11 04:21:29 +08:00
|
|
|
{
|
|
|
|
/* Only 1 msec max timeout due to interrupt context */
|
|
|
|
long timeout = 1000;
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, ioread32(I2C_REG_STS(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Write a STOP bit to TX FIFO */
|
|
|
|
iowrite32(0xff | stop_bit, I2C_REG_TX(alg_data));
|
|
|
|
|
|
|
|
/* Wait until the STOP is seen. */
|
|
|
|
while (timeout > 0 &&
|
|
|
|
(ioread32(I2C_REG_STS(alg_data)) & mstatus_active)) {
|
|
|
|
/* may be called from interrupt context */
|
|
|
|
udelay(1);
|
|
|
|
timeout--;
|
|
|
|
}
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, ioread32(I2C_REG_STS(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* i2c_pnx_master_xmit - transmit data to slave
|
|
|
|
* @adap: pointer to I2C adapter structure
|
|
|
|
*
|
|
|
|
* Sends one byte of data to the slave
|
|
|
|
*/
|
2009-11-21 20:40:00 +08:00
|
|
|
static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
|
2006-12-11 04:21:29 +08:00
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, ioread32(I2C_REG_STS(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
if (alg_data->mif.len > 0) {
|
|
|
|
/* We still have something to talk about... */
|
|
|
|
val = *alg_data->mif.buf++;
|
|
|
|
|
2010-03-17 06:55:37 +08:00
|
|
|
if (alg_data->mif.len == 1)
|
|
|
|
val |= stop_bit;
|
|
|
|
|
2006-12-11 04:21:29 +08:00
|
|
|
alg_data->mif.len--;
|
|
|
|
iowrite32(val, I2C_REG_TX(alg_data));
|
|
|
|
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): xmit %#x [%d]\n",
|
|
|
|
__func__, val, alg_data->mif.len + 1);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
if (alg_data->mif.len == 0) {
|
|
|
|
if (alg_data->last) {
|
|
|
|
/* Wait until the STOP is seen. */
|
|
|
|
if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_err(&alg_data->adapter.dev,
|
|
|
|
"The bus is still active after timeout\n");
|
2006-12-11 04:21:29 +08:00
|
|
|
}
|
|
|
|
/* Disable master interrupts */
|
|
|
|
iowrite32(ioread32(I2C_REG_CTL(alg_data)) &
|
|
|
|
~(mcntrl_afie | mcntrl_naie | mcntrl_drmie),
|
|
|
|
I2C_REG_CTL(alg_data));
|
|
|
|
|
|
|
|
del_timer_sync(&alg_data->mif.timer);
|
|
|
|
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
|
|
|
"%s(): Waking up xfer routine.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
complete(&alg_data->mif.complete);
|
|
|
|
}
|
|
|
|
} else if (alg_data->mif.len == 0) {
|
|
|
|
/* zero-sized transfer */
|
2009-11-21 20:40:00 +08:00
|
|
|
i2c_pnx_stop(alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Disable master interrupts. */
|
|
|
|
iowrite32(ioread32(I2C_REG_CTL(alg_data)) &
|
|
|
|
~(mcntrl_afie | mcntrl_naie | mcntrl_drmie),
|
|
|
|
I2C_REG_CTL(alg_data));
|
|
|
|
|
|
|
|
/* Stop timer. */
|
|
|
|
del_timer_sync(&alg_data->mif.timer);
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
|
|
|
"%s(): Waking up xfer routine after zero-xfer.\n",
|
|
|
|
__func__);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
complete(&alg_data->mif.complete);
|
|
|
|
}
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, ioread32(I2C_REG_STS(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* i2c_pnx_master_rcv - receive data from slave
|
|
|
|
* @adap: pointer to I2C adapter structure
|
|
|
|
*
|
|
|
|
* Reads one byte data from the slave
|
|
|
|
*/
|
2009-11-21 20:40:00 +08:00
|
|
|
static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data)
|
2006-12-11 04:21:29 +08:00
|
|
|
{
|
|
|
|
unsigned int val = 0;
|
|
|
|
u32 ctl = 0;
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, ioread32(I2C_REG_STS(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Check, whether there is already data,
|
|
|
|
* or we didn't 'ask' for it yet.
|
|
|
|
*/
|
|
|
|
if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) {
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
|
|
|
"%s(): Write dummy data to fill Rx-fifo...\n",
|
|
|
|
__func__);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
if (alg_data->mif.len == 1) {
|
2010-03-17 06:55:37 +08:00
|
|
|
/* Last byte, do not acknowledge next rcv. */
|
|
|
|
val |= stop_bit;
|
|
|
|
|
2006-12-11 04:21:29 +08:00
|
|
|
/*
|
|
|
|
* Enable interrupt RFDAIE (data in Rx fifo),
|
|
|
|
* and disable DRMIE (need data for Tx)
|
|
|
|
*/
|
|
|
|
ctl = ioread32(I2C_REG_CTL(alg_data));
|
|
|
|
ctl |= mcntrl_rffie | mcntrl_daie;
|
|
|
|
ctl &= ~mcntrl_drmie;
|
|
|
|
iowrite32(ctl, I2C_REG_CTL(alg_data));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now we'll 'ask' for data:
|
|
|
|
* For each byte we want to receive, we must
|
|
|
|
* write a (dummy) byte to the Tx-FIFO.
|
|
|
|
*/
|
|
|
|
iowrite32(val, I2C_REG_TX(alg_data));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle data. */
|
|
|
|
if (alg_data->mif.len > 0) {
|
|
|
|
val = ioread32(I2C_REG_RX(alg_data));
|
|
|
|
*alg_data->mif.buf++ = (u8) (val & 0xff);
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): rcv 0x%x [%d]\n",
|
|
|
|
__func__, val, alg_data->mif.len);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
alg_data->mif.len--;
|
|
|
|
if (alg_data->mif.len == 0) {
|
|
|
|
if (alg_data->last)
|
|
|
|
/* Wait until the STOP is seen. */
|
|
|
|
if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_err(&alg_data->adapter.dev,
|
|
|
|
"The bus is still active after timeout\n");
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Disable master interrupts */
|
|
|
|
ctl = ioread32(I2C_REG_CTL(alg_data));
|
|
|
|
ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie |
|
|
|
|
mcntrl_drmie | mcntrl_daie);
|
|
|
|
iowrite32(ctl, I2C_REG_CTL(alg_data));
|
|
|
|
|
|
|
|
/* Kill timer. */
|
|
|
|
del_timer_sync(&alg_data->mif.timer);
|
|
|
|
complete(&alg_data->mif.complete);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, ioread32(I2C_REG_STS(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-04 20:07:03 +08:00
|
|
|
static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
|
2006-12-11 04:21:29 +08:00
|
|
|
{
|
2009-11-21 20:40:00 +08:00
|
|
|
struct i2c_pnx_algo_data *alg_data = dev_id;
|
2006-12-11 04:21:29 +08:00
|
|
|
u32 stat, ctl;
|
|
|
|
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
|
|
|
"%s(): mstat = %x mctrl = %x, mode = %d\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__,
|
2006-12-11 04:21:29 +08:00
|
|
|
ioread32(I2C_REG_STS(alg_data)),
|
|
|
|
ioread32(I2C_REG_CTL(alg_data)),
|
|
|
|
alg_data->mif.mode);
|
|
|
|
stat = ioread32(I2C_REG_STS(alg_data));
|
|
|
|
|
|
|
|
/* let's see what kind of event this is */
|
|
|
|
if (stat & mstatus_afi) {
|
|
|
|
/* We lost arbitration in the midst of a transfer */
|
|
|
|
alg_data->mif.ret = -EIO;
|
|
|
|
|
|
|
|
/* Disable master interrupts. */
|
|
|
|
ctl = ioread32(I2C_REG_CTL(alg_data));
|
|
|
|
ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie |
|
|
|
|
mcntrl_drmie);
|
|
|
|
iowrite32(ctl, I2C_REG_CTL(alg_data));
|
|
|
|
|
|
|
|
/* Stop timer, to prevent timeout. */
|
|
|
|
del_timer_sync(&alg_data->mif.timer);
|
|
|
|
complete(&alg_data->mif.complete);
|
|
|
|
} else if (stat & mstatus_nai) {
|
|
|
|
/* Slave did not acknowledge, generate a STOP */
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
|
|
|
"%s(): Slave did not acknowledge, generating a STOP.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__);
|
2009-11-21 20:40:00 +08:00
|
|
|
i2c_pnx_stop(alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Disable master interrupts. */
|
|
|
|
ctl = ioread32(I2C_REG_CTL(alg_data));
|
|
|
|
ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie |
|
|
|
|
mcntrl_drmie);
|
|
|
|
iowrite32(ctl, I2C_REG_CTL(alg_data));
|
|
|
|
|
|
|
|
/* Our return value. */
|
|
|
|
alg_data->mif.ret = -EIO;
|
|
|
|
|
|
|
|
/* Stop timer, to prevent timeout. */
|
|
|
|
del_timer_sync(&alg_data->mif.timer);
|
|
|
|
complete(&alg_data->mif.complete);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Two options:
|
|
|
|
* - Master Tx needs data.
|
|
|
|
* - There is data in the Rx-fifo
|
|
|
|
* The latter is only the case if we have requested for data,
|
|
|
|
* via a dummy write. (See 'i2c_pnx_master_rcv'.)
|
|
|
|
* We therefore check, as a sanity check, whether that interrupt
|
|
|
|
* has been enabled.
|
|
|
|
*/
|
|
|
|
if ((stat & mstatus_drmi) || !(stat & mstatus_rfe)) {
|
|
|
|
if (alg_data->mif.mode == I2C_SMBUS_WRITE) {
|
2009-11-21 20:40:00 +08:00
|
|
|
i2c_pnx_master_xmit(alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
} else if (alg_data->mif.mode == I2C_SMBUS_READ) {
|
2009-11-21 20:40:00 +08:00
|
|
|
i2c_pnx_master_rcv(alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear TDI and AFI bits */
|
|
|
|
stat = ioread32(I2C_REG_STS(alg_data));
|
|
|
|
iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data));
|
|
|
|
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
|
|
|
"%s(): exiting, stat = %x ctrl = %x.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, ioread32(I2C_REG_STS(alg_data)),
|
2006-12-11 04:21:29 +08:00
|
|
|
ioread32(I2C_REG_CTL(alg_data)));
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void i2c_pnx_timeout(unsigned long data)
|
|
|
|
{
|
2009-11-21 20:40:00 +08:00
|
|
|
struct i2c_pnx_algo_data *alg_data = (struct i2c_pnx_algo_data *)data;
|
2006-12-11 04:21:29 +08:00
|
|
|
u32 ctl;
|
|
|
|
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_err(&alg_data->adapter.dev,
|
|
|
|
"Master timed out. stat = %04x, cntrl = %04x. Resetting master...\n",
|
|
|
|
ioread32(I2C_REG_STS(alg_data)),
|
|
|
|
ioread32(I2C_REG_CTL(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Reset master and disable interrupts */
|
|
|
|
ctl = ioread32(I2C_REG_CTL(alg_data));
|
|
|
|
ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie | mcntrl_drmie);
|
|
|
|
iowrite32(ctl, I2C_REG_CTL(alg_data));
|
|
|
|
|
|
|
|
ctl |= mcntrl_reset;
|
|
|
|
iowrite32(ctl, I2C_REG_CTL(alg_data));
|
|
|
|
wait_reset(I2C_PNX_TIMEOUT, alg_data);
|
|
|
|
alg_data->mif.ret = -EIO;
|
|
|
|
complete(&alg_data->mif.complete);
|
|
|
|
}
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
static inline void bus_reset_if_active(struct i2c_pnx_algo_data *alg_data)
|
2006-12-11 04:21:29 +08:00
|
|
|
{
|
|
|
|
u32 stat;
|
|
|
|
|
|
|
|
if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) {
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_err(&alg_data->adapter.dev,
|
2006-12-11 04:21:29 +08:00
|
|
|
"%s: Bus is still active after xfer. Reset it...\n",
|
2009-11-21 20:46:31 +08:00
|
|
|
alg_data->adapter.name);
|
2006-12-11 04:21:29 +08:00
|
|
|
iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
|
|
|
|
I2C_REG_CTL(alg_data));
|
|
|
|
wait_reset(I2C_PNX_TIMEOUT, alg_data);
|
|
|
|
} else if (!(stat & mstatus_rfe) || !(stat & mstatus_tfe)) {
|
|
|
|
/* If there is data in the fifo's after transfer,
|
|
|
|
* flush fifo's by reset.
|
|
|
|
*/
|
|
|
|
iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
|
|
|
|
I2C_REG_CTL(alg_data));
|
|
|
|
wait_reset(I2C_PNX_TIMEOUT, alg_data);
|
|
|
|
} else if (stat & mstatus_nai) {
|
|
|
|
iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
|
|
|
|
I2C_REG_CTL(alg_data));
|
|
|
|
wait_reset(I2C_PNX_TIMEOUT, alg_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* i2c_pnx_xfer - generic transfer entry point
|
|
|
|
* @adap: pointer to I2C adapter structure
|
|
|
|
* @msgs: array of messages
|
|
|
|
* @num: number of messages
|
|
|
|
*
|
|
|
|
* Initiates the transfer
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
|
|
|
|
{
|
|
|
|
struct i2c_msg *pmsg;
|
|
|
|
int rc = 0, completed = 0, i;
|
|
|
|
struct i2c_pnx_algo_data *alg_data = adap->algo_data;
|
|
|
|
u32 stat = ioread32(I2C_REG_STS(alg_data));
|
|
|
|
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
|
|
|
"%s(): entering: %d messages, stat = %04x.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, num, ioread32(I2C_REG_STS(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
bus_reset_if_active(alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Process transactions in a loop. */
|
|
|
|
for (i = 0; rc >= 0 && i < num; i++) {
|
|
|
|
u8 addr;
|
|
|
|
|
|
|
|
pmsg = &msgs[i];
|
|
|
|
addr = pmsg->addr;
|
|
|
|
|
|
|
|
if (pmsg->flags & I2C_M_TEN) {
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_err(&alg_data->adapter.dev,
|
2006-12-11 04:21:29 +08:00
|
|
|
"%s: 10 bits addr not supported!\n",
|
2009-11-21 20:40:00 +08:00
|
|
|
alg_data->adapter.name);
|
2006-12-11 04:21:29 +08:00
|
|
|
rc = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
alg_data->mif.buf = pmsg->buf;
|
|
|
|
alg_data->mif.len = pmsg->len;
|
|
|
|
alg_data->mif.mode = (pmsg->flags & I2C_M_RD) ?
|
|
|
|
I2C_SMBUS_READ : I2C_SMBUS_WRITE;
|
|
|
|
alg_data->mif.ret = 0;
|
|
|
|
alg_data->last = (i == num - 1);
|
|
|
|
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): mode %d, %d bytes\n",
|
|
|
|
__func__, alg_data->mif.mode, alg_data->mif.len);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
i2c_pnx_arm_timer(alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* initialize the completion var */
|
|
|
|
init_completion(&alg_data->mif.complete);
|
|
|
|
|
|
|
|
/* Enable master interrupt */
|
|
|
|
iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_afie |
|
|
|
|
mcntrl_naie | mcntrl_drmie,
|
|
|
|
I2C_REG_CTL(alg_data));
|
|
|
|
|
|
|
|
/* Put start-code and slave-address on the bus. */
|
2009-11-21 20:40:00 +08:00
|
|
|
rc = i2c_pnx_start(addr, alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
if (rc < 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Wait for completion */
|
|
|
|
wait_for_completion(&alg_data->mif.complete);
|
|
|
|
|
|
|
|
if (!(rc = alg_data->mif.ret))
|
|
|
|
completed++;
|
2009-11-21 20:46:31 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
|
|
|
"%s(): Complete, return code = %d.\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, rc);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Clear TDI and AFI bits in case they are set. */
|
|
|
|
if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_tdi) {
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
2006-12-11 04:21:29 +08:00
|
|
|
"%s: TDI still set... clearing now.\n",
|
2009-11-21 20:40:00 +08:00
|
|
|
alg_data->adapter.name);
|
2006-12-11 04:21:29 +08:00
|
|
|
iowrite32(stat, I2C_REG_STS(alg_data));
|
|
|
|
}
|
|
|
|
if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_afi) {
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev,
|
2006-12-11 04:21:29 +08:00
|
|
|
"%s: AFI still set... clearing now.\n",
|
2009-11-21 20:40:00 +08:00
|
|
|
alg_data->adapter.name);
|
2006-12-11 04:21:29 +08:00
|
|
|
iowrite32(stat, I2C_REG_STS(alg_data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
bus_reset_if_active(alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Cleanup to be sure... */
|
|
|
|
alg_data->mif.buf = NULL;
|
|
|
|
alg_data->mif.len = 0;
|
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
dev_dbg(&alg_data->adapter.dev, "%s(): exiting, stat = %x\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__, ioread32(I2C_REG_STS(alg_data)));
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
if (completed != num)
|
|
|
|
return ((rc < 0) ? rc : -EREMOTEIO);
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 i2c_pnx_func(struct i2c_adapter *adapter)
|
|
|
|
{
|
|
|
|
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct i2c_algorithm pnx_algorithm = {
|
|
|
|
.master_xfer = i2c_pnx_xfer,
|
|
|
|
.functionality = i2c_pnx_func,
|
|
|
|
};
|
|
|
|
|
2009-11-20 18:50:34 +08:00
|
|
|
#ifdef CONFIG_PM
|
2006-12-11 04:21:29 +08:00
|
|
|
static int i2c_pnx_controller_suspend(struct platform_device *pdev,
|
|
|
|
pm_message_t state)
|
|
|
|
{
|
2009-11-21 20:25:27 +08:00
|
|
|
struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
|
2009-11-20 19:12:26 +08:00
|
|
|
|
2009-11-20 19:44:46 +08:00
|
|
|
/* FIXME: shouldn't this be clk_disable? */
|
|
|
|
clk_enable(alg_data->clk);
|
2009-11-20 19:12:26 +08:00
|
|
|
|
|
|
|
return 0;
|
2006-12-11 04:21:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int i2c_pnx_controller_resume(struct platform_device *pdev)
|
|
|
|
{
|
2009-11-21 20:25:27 +08:00
|
|
|
struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
|
2009-11-20 19:12:26 +08:00
|
|
|
|
2009-11-20 19:44:46 +08:00
|
|
|
return clk_enable(alg_data->clk);
|
2006-12-11 04:21:29 +08:00
|
|
|
}
|
2009-11-20 18:50:34 +08:00
|
|
|
#else
|
|
|
|
#define i2c_pnx_controller_suspend NULL
|
|
|
|
#define i2c_pnx_controller_resume NULL
|
|
|
|
#endif
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
static int __devinit i2c_pnx_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
unsigned long tmp;
|
|
|
|
int ret = 0;
|
|
|
|
struct i2c_pnx_algo_data *alg_data;
|
2009-11-20 20:46:07 +08:00
|
|
|
unsigned long freq;
|
2006-12-11 04:21:29 +08:00
|
|
|
struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data;
|
|
|
|
|
2009-11-21 20:25:27 +08:00
|
|
|
if (!i2c_pnx || !i2c_pnx->name) {
|
2006-12-11 04:21:29 +08:00
|
|
|
dev_err(&pdev->dev, "%s: no platform data supplied\n",
|
2008-04-23 04:16:47 +08:00
|
|
|
__func__);
|
2006-12-11 04:21:29 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2009-11-21 20:10:54 +08:00
|
|
|
alg_data = kzalloc(sizeof(*alg_data), GFP_KERNEL);
|
|
|
|
if (!alg_data) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_kzalloc;
|
|
|
|
}
|
|
|
|
|
2009-11-21 20:25:27 +08:00
|
|
|
platform_set_drvdata(pdev, alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
2009-11-21 20:25:27 +08:00
|
|
|
strlcpy(alg_data->adapter.name, i2c_pnx->name,
|
|
|
|
sizeof(alg_data->adapter.name));
|
|
|
|
alg_data->adapter.dev.parent = &pdev->dev;
|
|
|
|
alg_data->adapter.algo = &pnx_algorithm;
|
|
|
|
alg_data->adapter.algo_data = alg_data;
|
|
|
|
alg_data->adapter.nr = pdev->id;
|
|
|
|
alg_data->i2c_pnx = i2c_pnx;
|
2009-11-20 19:12:26 +08:00
|
|
|
|
|
|
|
alg_data->clk = clk_get(&pdev->dev, NULL);
|
|
|
|
if (IS_ERR(alg_data->clk)) {
|
|
|
|
ret = PTR_ERR(alg_data->clk);
|
|
|
|
goto out_drvdata;
|
|
|
|
}
|
|
|
|
|
2006-12-11 04:21:29 +08:00
|
|
|
init_timer(&alg_data->mif.timer);
|
|
|
|
alg_data->mif.timer.function = i2c_pnx_timeout;
|
2009-11-21 20:40:00 +08:00
|
|
|
alg_data->mif.timer.data = (unsigned long)alg_data;
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* Register I/O resource */
|
2009-11-21 20:10:54 +08:00
|
|
|
if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE,
|
2009-09-19 04:45:51 +08:00
|
|
|
pdev->name)) {
|
2006-12-11 04:21:29 +08:00
|
|
|
dev_err(&pdev->dev,
|
|
|
|
"I/O region 0x%08x for I2C already in use.\n",
|
2009-11-21 20:10:54 +08:00
|
|
|
i2c_pnx->base);
|
2006-12-11 04:21:29 +08:00
|
|
|
ret = -ENODEV;
|
2009-11-20 19:12:26 +08:00
|
|
|
goto out_clkget;
|
2006-12-11 04:21:29 +08:00
|
|
|
}
|
|
|
|
|
2009-11-21 20:10:54 +08:00
|
|
|
alg_data->ioaddr = ioremap(i2c_pnx->base, I2C_PNX_REGION_SIZE);
|
2009-11-21 19:58:36 +08:00
|
|
|
if (!alg_data->ioaddr) {
|
2006-12-11 04:21:29 +08:00
|
|
|
dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n");
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out_release;
|
|
|
|
}
|
|
|
|
|
2009-11-20 19:44:46 +08:00
|
|
|
ret = clk_enable(alg_data->clk);
|
|
|
|
if (ret)
|
|
|
|
goto out_unmap;
|
2006-12-11 04:21:29 +08:00
|
|
|
|
2009-11-20 20:46:07 +08:00
|
|
|
freq = clk_get_rate(alg_data->clk);
|
|
|
|
|
2006-12-11 04:21:29 +08:00
|
|
|
/*
|
|
|
|
* Clock Divisor High This value is the number of system clocks
|
|
|
|
* the serial clock (SCL) will be high.
|
|
|
|
* For example, if the system clock period is 50 ns and the maximum
|
|
|
|
* desired serial period is 10000 ns (100 kHz), then CLKHI would be
|
|
|
|
* set to 0.5*(f_sys/f_i2c)-2=0.5*(20e6/100e3)-2=98. The actual value
|
|
|
|
* programmed into CLKHI will vary from this slightly due to
|
|
|
|
* variations in the output pad's rise and fall times as well as
|
|
|
|
* the deglitching filter length.
|
|
|
|
*/
|
|
|
|
|
2009-11-20 20:46:07 +08:00
|
|
|
tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2;
|
2010-03-17 06:55:36 +08:00
|
|
|
if (tmp > 0x3FF)
|
|
|
|
tmp = 0x3FF;
|
2006-12-11 04:21:29 +08:00
|
|
|
iowrite32(tmp, I2C_REG_CKH(alg_data));
|
|
|
|
iowrite32(tmp, I2C_REG_CKL(alg_data));
|
|
|
|
|
|
|
|
iowrite32(mcntrl_reset, I2C_REG_CTL(alg_data));
|
|
|
|
if (wait_reset(I2C_PNX_TIMEOUT, alg_data)) {
|
|
|
|
ret = -ENODEV;
|
2009-11-20 19:44:46 +08:00
|
|
|
goto out_clock;
|
2006-12-11 04:21:29 +08:00
|
|
|
}
|
|
|
|
init_completion(&alg_data->mif.complete);
|
|
|
|
|
2009-11-21 20:10:54 +08:00
|
|
|
ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt,
|
2009-11-21 20:40:00 +08:00
|
|
|
0, pdev->name, alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
if (ret)
|
|
|
|
goto out_clock;
|
|
|
|
|
|
|
|
/* Register this adapter with the I2C subsystem */
|
2009-11-21 20:25:27 +08:00
|
|
|
ret = i2c_add_numbered_adapter(&alg_data->adapter);
|
2006-12-11 04:21:29 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(&pdev->dev, "I2C: Failed to add bus\n");
|
|
|
|
goto out_irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n",
|
2009-11-21 20:25:27 +08:00
|
|
|
alg_data->adapter.name, i2c_pnx->base, i2c_pnx->irq);
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_irq:
|
2009-11-21 20:40:00 +08:00
|
|
|
free_irq(i2c_pnx->irq, alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
out_clock:
|
2009-11-20 19:44:46 +08:00
|
|
|
clk_disable(alg_data->clk);
|
2006-12-11 04:21:29 +08:00
|
|
|
out_unmap:
|
2009-11-21 19:58:36 +08:00
|
|
|
iounmap(alg_data->ioaddr);
|
2006-12-11 04:21:29 +08:00
|
|
|
out_release:
|
2009-11-21 20:10:54 +08:00
|
|
|
release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);
|
2009-11-20 19:12:26 +08:00
|
|
|
out_clkget:
|
|
|
|
clk_put(alg_data->clk);
|
2006-12-11 04:21:29 +08:00
|
|
|
out_drvdata:
|
2009-11-21 20:10:54 +08:00
|
|
|
kfree(alg_data);
|
|
|
|
err_kzalloc:
|
2006-12-11 04:21:29 +08:00
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devexit i2c_pnx_remove(struct platform_device *pdev)
|
|
|
|
{
|
2009-11-21 20:25:27 +08:00
|
|
|
struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
|
|
|
|
struct i2c_pnx_data *i2c_pnx = alg_data->i2c_pnx;
|
2006-12-11 04:21:29 +08:00
|
|
|
|
2009-11-21 20:40:00 +08:00
|
|
|
free_irq(i2c_pnx->irq, alg_data);
|
2009-11-21 20:25:27 +08:00
|
|
|
i2c_del_adapter(&alg_data->adapter);
|
2009-11-20 19:44:46 +08:00
|
|
|
clk_disable(alg_data->clk);
|
2009-11-21 19:58:36 +08:00
|
|
|
iounmap(alg_data->ioaddr);
|
2009-11-21 20:10:54 +08:00
|
|
|
release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);
|
2009-11-20 19:12:26 +08:00
|
|
|
clk_put(alg_data->clk);
|
2009-11-21 20:10:54 +08:00
|
|
|
kfree(alg_data);
|
2006-12-11 04:21:29 +08:00
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver i2c_pnx_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "pnx-i2c",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.probe = i2c_pnx_probe,
|
|
|
|
.remove = __devexit_p(i2c_pnx_remove),
|
|
|
|
.suspend = i2c_pnx_controller_suspend,
|
|
|
|
.resume = i2c_pnx_controller_resume,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init i2c_adap_pnx_init(void)
|
|
|
|
{
|
|
|
|
return platform_driver_register(&i2c_pnx_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit i2c_adap_pnx_exit(void)
|
|
|
|
{
|
|
|
|
platform_driver_unregister(&i2c_pnx_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Vitaly Wool, Dennis Kovalev <source@mvista.com>");
|
|
|
|
MODULE_DESCRIPTION("I2C driver for Philips IP3204-based I2C busses");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-23 04:16:49 +08:00
|
|
|
MODULE_ALIAS("platform:pnx-i2c");
|
2006-12-11 04:21:29 +08:00
|
|
|
|
|
|
|
/* We need to make sure I2C is initialized before USB */
|
|
|
|
subsys_initcall(i2c_adap_pnx_init);
|
|
|
|
module_exit(i2c_adap_pnx_exit);
|