Merge tag 'mtd/for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux
[linux-2.6-block.git] / Documentation / i2c / busses / i2c-ocores.rst
CommitLineData
ccf988b6 1========================
18f98b1e 2Kernel driver i2c-ocores
ccf988b6 3========================
18f98b1e
PK
4
5Supported adapters:
6 * OpenCores.org I2C controller by Richard Herveille (see datasheet link)
a0ccb6b5 7 https://opencores.org/project/i2c/overview
18f98b1e 8
5d3a01a2 9Author: Peter Korsgaard <peter@korsgaard.com>
18f98b1e
PK
10
11Description
12-----------
13
14i2c-ocores is an i2c bus driver for the OpenCores.org I2C controller
15IP core by Richard Herveille.
16
17Usage
18-----
19
20i2c-ocores uses the platform bus, so you need to provide a struct
21platform_device with the base address and interrupt number. The
22dev.platform_data of the device should also point to a struct
985ecf00 23ocores_i2c_platform_data (see linux/platform_data/i2c-ocores.h) describing the
18f98b1e 24distance between registers and the input clock speed.
dd14be4c
RR
25There is also a possibility to attach a list of i2c_board_info which
26the i2c-ocores driver will add to the bus upon creation.
18f98b1e 27
ccf988b6 28E.G. something like::
18f98b1e 29
ccf988b6 30 static struct resource ocores_resources[] = {
18f98b1e
PK
31 [0] = {
32 .start = MYI2C_BASEADDR,
33 .end = MYI2C_BASEADDR + 8,
34 .flags = IORESOURCE_MEM,
35 },
36 [1] = {
37 .start = MYI2C_IRQ,
38 .end = MYI2C_IRQ,
39 .flags = IORESOURCE_IRQ,
40 },
ccf988b6 41 };
18f98b1e 42
ccf988b6
MCC
43 /* optional board info */
44 struct i2c_board_info ocores_i2c_board_info[] = {
dd14be4c
RR
45 {
46 I2C_BOARD_INFO("tsc2003", 0x48),
47 .platform_data = &tsc2003_platform_data,
48 .irq = TSC_IRQ
49 },
50 {
51 I2C_BOARD_INFO("adv7180", 0x42 >> 1),
52 .irq = ADV_IRQ
53 }
ccf988b6 54 };
dd14be4c 55
ccf988b6 56 static struct ocores_i2c_platform_data myi2c_data = {
18f98b1e
PK
57 .regstep = 2, /* two bytes between registers */
58 .clock_khz = 50000, /* input clock of 50MHz */
dd14be4c
RR
59 .devices = ocores_i2c_board_info, /* optional table of devices */
60 .num_devices = ARRAY_SIZE(ocores_i2c_board_info), /* table size */
ccf988b6 61 };
18f98b1e 62
ccf988b6 63 static struct platform_device myi2c = {
18f98b1e
PK
64 .name = "ocores-i2c",
65 .dev = {
66 .platform_data = &myi2c_data,
67 },
68 .num_resources = ARRAY_SIZE(ocores_resources),
69 .resource = ocores_resources,
ccf988b6 70 };