From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/7] at91sam9x5: add i2c support
Date: Thu, 1 Nov 2012 16:07:21 +0100 [thread overview]
Message-ID: <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20121101143352.GJ29599@game.jcrosoft.org>
use i2c-gpio until we add the hw drivers
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/mach-at91/at91sam9x5_devices.c | 58 +++++++++++++++++++++++++++++++
arch/arm/mach-at91/include/mach/board.h | 3 ++
2 files changed, 61 insertions(+)
diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 26a380d..5a24325 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -19,6 +19,7 @@
#include <mach/gpio.h>
#include <mach/io.h>
#include <mach/cpu.h>
+#include <i2c/i2c-gpio.h>
#include "generic.h"
@@ -169,6 +170,63 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
void __init at91_add_device_nand(struct atmel_nand_data *data) {}
#endif
+#if defined(CONFIG_I2C_GPIO)
+static struct i2c_gpio_platform_data pdata_i2c0 = {
+ .sda_pin = AT91_PIN_PA30,
+ .sda_is_open_drain = 1,
+ .scl_pin = AT91_PIN_PA31,
+ .scl_is_open_drain = 1,
+ .udelay = 5, /* ~100 kHz */
+};
+
+static struct i2c_gpio_platform_data pdata_i2c1 = {
+ .sda_pin = AT91_PIN_PC0,
+ .sda_is_open_drain = 1,
+ .scl_pin = AT91_PIN_PC1,
+ .scl_is_open_drain = 1,
+ .udelay = 5, /* ~100 kHz */
+};
+
+static struct i2c_gpio_platform_data pdata_i2c2 = {
+ .sda_pin = AT91_PIN_PB4,
+ .sda_is_open_drain = 1,
+ .scl_pin = AT91_PIN_PB5,
+ .scl_is_open_drain = 1,
+ .udelay = 5, /* ~100 kHz */
+};
+
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
+{
+ struct i2c_gpio_platform_data *pdata;
+
+ i2c_register_board_info(i2c_id, devices, nr_devices);
+
+ switch (i2c_id) {
+ case 0:
+ pdata = &pdata_i2c0;
+ break;
+ case 1:
+ pdata = &pdata_i2c1;
+ break;
+ case 2:
+ pdata = &pdata_i2c2;
+ break;
+ default:
+ return;
+ }
+
+ at91_set_GPIO_periph(pdata->sda_pin, 1); /* TWD (SDA) */
+ at91_set_multi_drive(pdata->sda_pin, 1);
+
+ at91_set_GPIO_periph(pdata->scl_pin, 1); /* TWCK (SCL) */
+ at91_set_multi_drive(pdata->scl_pin, 1);
+
+ add_generic_device_res("i2c-gpio", i2c_id, NULL, 0, pdata);
+}
+#else
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
+#endif
+
/* --------------------------------------------------------------------
* UART
* -------------------------------------------------------------------- */
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index 670c73d..1ce0762 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -21,6 +21,7 @@
#include <mach/hardware.h>
#include <sizes.h>
#include <net.h>
+#include <i2c/i2c.h>
#include <spi/spi.h>
#include <linux/mtd/mtd.h>
@@ -71,6 +72,8 @@ struct at91_ether_platform_data {
void at91_add_device_eth(int id, struct at91_ether_platform_data *data);
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices);
+
/* SDRAM */
void at91_add_device_sdram(u32 size);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-11-01 15:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-01 14:33 [PATCH 0/7] at91 add i2c-gpio suport Jean-Christophe PLAGNIOL-VILLARD
2012-11-01 15:07 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-11-01 15:07 ` [PATCH 2/7] at91rm9200: add i2c support Jean-Christophe PLAGNIOL-VILLARD
2012-11-01 15:07 ` [PATCH 3/7] at91sam9260/sam9g20: " Jean-Christophe PLAGNIOL-VILLARD
2012-11-01 15:07 ` [PATCH 4/7] at91sam9263: " Jean-Christophe PLAGNIOL-VILLARD
2012-11-01 15:07 ` [PATCH 5/7] at91sam9261/sam9g10: " Jean-Christophe PLAGNIOL-VILLARD
2012-11-01 15:07 ` [PATCH 6/7] at91sam9g45: " Jean-Christophe PLAGNIOL-VILLARD
2012-11-01 15:07 ` [PATCH 7/7] at91sam9x5ek: " Jean-Christophe PLAGNIOL-VILLARD
2012-11-01 18:52 ` [PATCH 1/1 v2] " Jean-Christophe PLAGNIOL-VILLARD
2012-11-03 11:29 ` [PATCH 1/1 v3] " Jean-Christophe PLAGNIOL-VILLARD
2012-11-02 9:34 ` [PATCH 0/7] at91 add i2c-gpio suport Jean-Christophe PLAGNIOL-VILLARD
2012-11-02 20:24 ` Sascha Hauer
2012-11-03 7:25 ` Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox