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