/*
 * Module-related material for wr-nic: load and unload
 *
 * Copyright (C) 2010 CERN (www.cern.ch)
 * Author: Alessandro Rubini <rubini@gnudd.com>
 * Partly from previous work by Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
 * Partly from previous work by  Emilio G. Cota <cota@braap.org>
 *
 * 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/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/platform_data/i2c-ocores.h>


/**************************************************/

static struct resource ocores_resources[] = {
	[0] = {
		.start	= 0x400054000,
		.end	= 0x400054000 + 0x20,
		.flags	= IORESOURCE_MEM,
	},
    {}
};

#if 1
/* optional board info */
struct i2c_board_info ocores_i2c_board_info[] = {
	{
		I2C_BOARD_INFO("sfp_adapter", 0xA0),
		//.platform_data = &tsc2003_platform_data,
		//.irq = TSC_IRQ
	},
};
#endif

static struct ocores_i2c_platform_data myi2c_data = {
	.reg_shift		= 2,		/* shift regs by 2 (multiply by 4) to match byte address to word address */
    .reg_io_width	= 4,        /* AXI - WB registers are 32 bytes */
	.clock_khz		= 62500,	/* input clock of 62.5MHz */
	.bus_khz		= 100,      /* I2C bus runs @ 100kHz for now */
	.big_endian		= false,
	//.devices	= ocores_i2c_board_info, /* optional table of devices */
	//.num_devices	= ARRAY_SIZE(ocores_i2c_board_info), /* table size */
};

static void ocores_test_release(struct device *dev)
{
	/* nothing to do, but mandatory function */
	pr_debug("%s\n", __func__);
    printk("ocores_test_release()\n");
}

static struct platform_device ocores_test_dev = {
	.name			= "ocores-i2c",
	//.name			= "i2c-ohwr",
	.dev = {
		.platform_data	= &myi2c_data,
        .release = ocores_test_release,
	},
	.num_resources		= ARRAY_SIZE(ocores_resources),
	.resource		= ocores_resources,
};


/*
 * Module init and exit stuff. Here we register the platform data
 * as well, but the driver itself is in device.c
 */
int __init ocores_test_init(void)
{
    printk("ocores_test_init()\n");
	platform_device_register(&ocores_test_dev);

    return 0;
}

void __exit ocores_test_exit(void)
{
    printk("ocores_test_exit()\n");
	platform_device_unregister(&ocores_test_dev);
	
    return;
}

module_init(ocores_test_init);
module_exit(ocores_test_exit);

MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:ocores-test");

