Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fac368a0 authored by Nikolaus Voss's avatar Nikolaus Voss Committed by Wolfram Sang
Browse files

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: default avatarNikolaus Voss <n.voss@weinmann.de>
Reviewed-by: default avatarFelipe Balbi <balbi@ti.com>
Tested-by: default avatarHubert Feurstein <h.feurstein@gmail.com>
Tested-by: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
Reviewed-by: default avatarNicolas 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: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: default avatarWolfram Sang <w.sang@pengutronix.de>
parent a879e9c3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
	CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
	CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
	CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
	CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
	CLKDEV_CON_DEV_ID(NULL, "i2c-at91rm9200", &twi_clk),
	/* fake hclk clock */
	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
	CLKDEV_CON_ID("pioA", &pioA_clk),
+1 −1
Original line number Diff line number Diff line
@@ -495,7 +495,7 @@ static struct resource twi_resources[] = {
};

static struct platform_device at91rm9200_twi_device = {
	.name		= "at91_i2c",
	.name		= "i2c-at91rm9200",
	.id		= -1,
	.resource	= twi_resources,
	.num_resources	= ARRAY_SIZE(twi_resources),
+2 −1
Original line number Diff line number Diff line
@@ -211,7 +211,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
	CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk),
	CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk),
	CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk),
	CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260", &twi_clk),
	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20", &twi_clk),
	/* more usart lookup table for DT entries */
	CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
	CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk),
+7 −1
Original line number Diff line number Diff line
@@ -503,7 +503,6 @@ static struct resource twi_resources[] = {
};

static struct platform_device at91sam9260_twi_device = {
	.name		= "at91_i2c",
	.id		= -1,
	.resource	= twi_resources,
	.num_resources	= ARRAY_SIZE(twi_resources),
@@ -511,6 +510,13 @@ static struct platform_device at91sam9260_twi_device = {

void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
{
	/* IP version is not the same on 9260 and g20 */
	if (cpu_is_at91sam9g20()) {
		at91sam9260_twi_device.name = "i2c-at91sam9g20";
	} else {
		at91sam9260_twi_device.name = "i2c-at91sam9260";
	}

	/* pins used for TWI interface */
	at91_set_A_periph(AT91_PIN_PA23, 0);		/* TWD */
	at91_set_multi_drive(AT91_PIN_PA23, 1);
+2 −1
Original line number Diff line number Diff line
@@ -178,7 +178,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
	CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
	CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &hck0),
	CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9261", &twi_clk),
	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10", &twi_clk),
	CLKDEV_CON_ID("pioA", &pioA_clk),
	CLKDEV_CON_ID("pioB", &pioB_clk),
	CLKDEV_CON_ID("pioC", &pioC_clk),
Loading