/***********************************************************************
 *
 * (C) Copyright 2005
 * DENX Software Engineering
 * Wolfgang Denk, wd@denx.de
 * All rights reserved.
 ***********************************************************************/

/* ------------------------------------------------------------------------- */
/* i2c-cpc45.c I2C Interface driver module for the CPC45 board               */
/* ------------------------------------------------------------------------- */
/*
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.		     */
/* ------------------------------------------------------------------------- */

#include <linux/kernel.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/version.h>
#include <linux/init.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <platforms/cpc45.h>

#include <linux/i2c.h>
#include <linux/i2c-algo-8245.h>


static int cpc45_i2c_reg(struct i2c_client *client)
{
	return 0;
}


static int cpc45_i2c_unreg(struct i2c_client *client)
{
	return 0;
}

static void cpc45_i2c_inc_use(struct i2c_adapter *adap)
{
#ifdef MODULE
	MOD_INC_USE_COUNT;
#endif
}

static void cpc45_i2c_dec_use(struct i2c_adapter *adap)
{
#ifdef MODULE
	MOD_DEC_USE_COUNT;
#endif
}


static struct i2c_algo_8245_data cpc45_i2c_data = {
	NULL
};

static struct i2c_adapter cpc45_i2c_ops = {
	"CPC45 I2C Interface",
	I2C_HW_MPC8245_CPC45,
	NULL,
	&cpc45_i2c_data,
	cpc45_i2c_inc_use,
	cpc45_i2c_dec_use,
	cpc45_i2c_reg,
	cpc45_i2c_unreg,
};

int __init i2c_cpc45_init(void)
{
	int res = -ENODEV;

	printk(KERN_INFO "i2c-cpc45.o: i2c CPC45 module\n");

	cpc45_i2c_data.i2c = ioremap(0xfdf00000 + M8245_I2C_OFFSET, M8245_I2C_SIZE);
	if (i2c_8245_add_bus(&cpc45_i2c_ops) < 0) {
		goto Done;
	}

	printk(KERN_INFO "i2c-cpc45.o: found device at 0x%08x.\n",
	       (unsigned int)cpc45_i2c_data.i2c);

	res = 0;
Done:
	return res;
}

EXPORT_NO_SYMBOLS;

module_init(i2c_cpc45_init);

#ifdef MODULE
MODULE_AUTHOR("Wolfgang Denk <wd@denx.de>");
MODULE_DESCRIPTION("I2C-Bus driver routines for the CPC45 board");

int init_module(void)
{
	return i2c_cpc45_init();
}

void cleanup_module(void)
{
	i2c_8245_del_bus(&cpc45_i2c_ops);
}

#endif
