0001 ========================
0002 Kernel driver i2c-ocores
0003 ========================
0004
0005 Supported adapters:
0006 * OpenCores.org I2C controller by Richard Herveille (see datasheet link)
0007 https://opencores.org/project/i2c/overview
0008
0009 Author: Peter Korsgaard <peter@korsgaard.com>
0010
0011 Description
0012 -----------
0013
0014 i2c-ocores is an i2c bus driver for the OpenCores.org I2C controller
0015 IP core by Richard Herveille.
0016
0017 Usage
0018 -----
0019
0020 i2c-ocores uses the platform bus, so you need to provide a struct
0021 platform_device with the base address and interrupt number. The
0022 dev.platform_data of the device should also point to a struct
0023 ocores_i2c_platform_data (see linux/platform_data/i2c-ocores.h) describing the
0024 distance between registers and the input clock speed.
0025 There is also a possibility to attach a list of i2c_board_info which
0026 the i2c-ocores driver will add to the bus upon creation.
0027
0028 E.G. something like::
0029
0030 static struct resource ocores_resources[] = {
0031 [0] = {
0032 .start = MYI2C_BASEADDR,
0033 .end = MYI2C_BASEADDR + 8,
0034 .flags = IORESOURCE_MEM,
0035 },
0036 [1] = {
0037 .start = MYI2C_IRQ,
0038 .end = MYI2C_IRQ,
0039 .flags = IORESOURCE_IRQ,
0040 },
0041 };
0042
0043 /* optional board info */
0044 struct i2c_board_info ocores_i2c_board_info[] = {
0045 {
0046 I2C_BOARD_INFO("tsc2003", 0x48),
0047 .platform_data = &tsc2003_platform_data,
0048 .irq = TSC_IRQ
0049 },
0050 {
0051 I2C_BOARD_INFO("adv7180", 0x42 >> 1),
0052 .irq = ADV_IRQ
0053 }
0054 };
0055
0056 static struct ocores_i2c_platform_data myi2c_data = {
0057 .regstep = 2, /* two bytes between registers */
0058 .clock_khz = 50000, /* input clock of 50MHz */
0059 .devices = ocores_i2c_board_info, /* optional table of devices */
0060 .num_devices = ARRAY_SIZE(ocores_i2c_board_info), /* table size */
0061 };
0062
0063 static struct platform_device myi2c = {
0064 .name = "ocores-i2c",
0065 .dev = {
0066 .platform_data = &myi2c_data,
0067 },
0068 .num_resources = ARRAY_SIZE(ocores_resources),
0069 .resource = ocores_resources,
0070 };