Skip to content

Commit fac368a

Browse files
Nikolaus VossWolfram Sang
authored andcommitted
i2c: at91: add new driver
This driver has the following properties compared to the old driver: 1. Support for multiple interfaces. 2. Interrupt driven I/O as opposed to polling/busy waiting. 3. Support for _one_ repeated start (Sr) condition, which is enough for most real-world applications including all SMBus transfer types. (The hardware does not support issuing arbitrary Sr conditions on the bus.) testing: SoC: at91sam9g45 - BQ20Z80 battery SMBus client. - on a 2.6.38 kernel with several i2c clients (temp-sensor, audio-codec, touchscreen-controller, w1-bridge, io-expanders) Signed-off-by: Nikolaus Voss <n.voss@weinmann.de> Reviewed-by: Felipe Balbi <balbi@ti.com> Tested-by: Hubert Feurstein <h.feurstein@gmail.com> Tested-by: Ludovic Desroches <ludovic.desroches@atmel.com> Reviewed-by: Nicolas Ferre <nicolas.ferre@atmel.com> [wsa: squashed with the following patches from Ludovic to have some flaws fixed: i2c: at91: use managed resources i2c: at91: add warning about transmission issues for some devices i2c: at91: use an id table for SoC dependent parameters ] Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
1 parent a879e9c commit fac368a

File tree

15 files changed

+545
-22
lines changed

15 files changed

+545
-22
lines changed

arch/arm/mach-at91/at91rm9200.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
187187
CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
188188
CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
189189
CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
190-
CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
190+
CLKDEV_CON_DEV_ID(NULL, "i2c-at91rm9200", &twi_clk),
191191
/* fake hclk clock */
192192
CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
193193
CLKDEV_CON_ID("pioA", &pioA_clk),

arch/arm/mach-at91/at91rm9200_devices.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static struct resource twi_resources[] = {
495495
};
496496

497497
static struct platform_device at91rm9200_twi_device = {
498-
.name = "at91_i2c",
498+
.name = "i2c-at91rm9200",
499499
.id = -1,
500500
.resource = twi_resources,
501501
.num_resources = ARRAY_SIZE(twi_resources),

arch/arm/mach-at91/at91sam9260.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
211211
CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk),
212212
CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk),
213213
CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk),
214-
CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
214+
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260", &twi_clk),
215+
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20", &twi_clk),
215216
/* more usart lookup table for DT entries */
216217
CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
217218
CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk),

arch/arm/mach-at91/at91sam9260_devices.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,20 @@ static struct resource twi_resources[] = {
503503
};
504504

505505
static struct platform_device at91sam9260_twi_device = {
506-
.name = "at91_i2c",
507506
.id = -1,
508507
.resource = twi_resources,
509508
.num_resources = ARRAY_SIZE(twi_resources),
510509
};
511510

512511
void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
513512
{
513+
/* IP version is not the same on 9260 and g20 */
514+
if (cpu_is_at91sam9g20()) {
515+
at91sam9260_twi_device.name = "i2c-at91sam9g20";
516+
} else {
517+
at91sam9260_twi_device.name = "i2c-at91sam9260";
518+
}
519+
514520
/* pins used for TWI interface */
515521
at91_set_A_periph(AT91_PIN_PA23, 0); /* TWD */
516522
at91_set_multi_drive(AT91_PIN_PA23, 1);

arch/arm/mach-at91/at91sam9261.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
178178
CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
179179
CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
180180
CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &hck0),
181-
CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
181+
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9261", &twi_clk),
182+
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10", &twi_clk),
182183
CLKDEV_CON_ID("pioA", &pioA_clk),
183184
CLKDEV_CON_ID("pioB", &pioB_clk),
184185
CLKDEV_CON_ID("pioC", &pioC_clk),

arch/arm/mach-at91/at91sam9261_devices.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,20 @@ static struct resource twi_resources[] = {
317317
};
318318

319319
static struct platform_device at91sam9261_twi_device = {
320-
.name = "at91_i2c",
321320
.id = -1,
322321
.resource = twi_resources,
323322
.num_resources = ARRAY_SIZE(twi_resources),
324323
};
325324

326325
void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
327326
{
327+
/* IP version is not the same on 9261 and g10 */
328+
if (cpu_is_at91sam9g10()) {
329+
at91sam9261_twi_device.name = "i2c-at91sam9g10";
330+
} else {
331+
at91sam9261_twi_device.name = "i2c-at91sam9261";
332+
}
333+
328334
/* pins used for TWI interface */
329335
at91_set_A_periph(AT91_PIN_PA7, 0); /* TWD */
330336
at91_set_multi_drive(AT91_PIN_PA7, 1);

arch/arm/mach-at91/at91sam9263.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
193193
CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
194194
CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
195195
CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk),
196-
CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
196+
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260", &twi_clk),
197197
/* fake hclk clock */
198198
CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
199199
CLKDEV_CON_ID("pioA", &pioA_clk),

arch/arm/mach-at91/at91sam9263_devices.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ static struct resource twi_resources[] = {
574574
};
575575

576576
static struct platform_device at91sam9263_twi_device = {
577-
.name = "at91_i2c",
577+
.name = "i2c-at91sam9260",
578578
.id = -1,
579579
.resource = twi_resources,
580580
.num_resources = ARRAY_SIZE(twi_resources),

arch/arm/mach-at91/at91sam9g45.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
237237
CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
238238
CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb0_clk),
239239
CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk),
240-
CLKDEV_CON_DEV_ID(NULL, "at91_i2c.0", &twi0_clk),
241-
CLKDEV_CON_DEV_ID(NULL, "at91_i2c.1", &twi1_clk),
240+
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi0_clk),
241+
CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.1", &twi1_clk),
242242
CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
243243
CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
244244
CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk),

arch/arm/mach-at91/at91sam9g45_devices.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ static struct resource twi0_resources[] = {
653653
};
654654

655655
static struct platform_device at91sam9g45_twi0_device = {
656-
.name = "at91_i2c",
656+
.name = "i2c-at91sam9g10",
657657
.id = 0,
658658
.resource = twi0_resources,
659659
.num_resources = ARRAY_SIZE(twi0_resources),
@@ -673,7 +673,7 @@ static struct resource twi1_resources[] = {
673673
};
674674

675675
static struct platform_device at91sam9g45_twi1_device = {
676-
.name = "at91_i2c",
676+
.name = "i2c-at91sam9g10",
677677
.id = 1,
678678
.resource = twi1_resources,
679679
.num_resources = ARRAY_SIZE(twi1_resources),

0 commit comments

Comments
 (0)