[OpenWrt-Devel] [PATCH 1/3] ar71xx: add GPIO based S/W I2C master

miaoqing at qti.qualcomm.com miaoqing at qti.qualcomm.com
Fri Jul 10 03:18:44 EDT 2015


From: Miaoqing Pan <miaoqing at codeaurora.org>

Signed-off-by: Miaoqing Pan <miaoqing at codeaurora.org>
---
 .../linux/ar71xx/files/arch/mips/ath79/dev-i2c.c   | 33 ++++++++++++++++++++++
 .../linux/ar71xx/files/arch/mips/ath79/dev-i2c.h   | 24 ++++++++++++++++
 ...915-MIPS-ath79-add-gpio-based-i2c-support.patch | 22 +++++++++++++++
 3 files changed, 79 insertions(+)
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-i2c.c
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-i2c.h
 create mode 100644 target/linux/ar71xx/patches-3.18/915-MIPS-ath79-add-gpio-based-i2c-support.patch

diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-i2c.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-i2c.c
new file mode 100644
index 0000000..2e0a5dd
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-i2c.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <linux/i2c.h>
+#include <linux/i2c-gpio.h>
+#include <linux/platform_device.h>
+
+static struct platform_device ath79_i2c_gpio_device = {
+	.name		= "i2c-gpio",
+	.id		= 0,
+};
+
+void __init ath79_register_i2c(struct i2c_gpio_platform_data *pdata,
+			       struct i2c_board_info const *info,
+			       unsigned int n)
+{
+	i2c_register_board_info(0, info, n);
+	ath79_i2c_gpio_device.dev.platform_data = pdata;
+	platform_device_register(&ath79_i2c_gpio_device);
+}
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-i2c.h b/target/linux/ar71xx/files/arch/mips/ath79/dev-i2c.h
new file mode 100644
index 0000000..9b837bb
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-i2c.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _ATH79_DEV_I2C_H_
+#define _ATH79_DEV_I2C_H_
+
+void ath79_register_i2c(struct i2c_gpio_platform_data *pdata,
+			struct i2c_board_info const *info,
+			unsigned int n);
+
+#endif /* _ATH79_DEV_I2C_H_ */
diff --git a/target/linux/ar71xx/patches-3.18/915-MIPS-ath79-add-gpio-based-i2c-support.patch b/target/linux/ar71xx/patches-3.18/915-MIPS-ath79-add-gpio-based-i2c-support.patch
new file mode 100644
index 0000000..a8126fe
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.18/915-MIPS-ath79-add-gpio-based-i2c-support.patch
@@ -0,0 +1,22 @@
+--- a/arch/mips/ath79/Kconfig
++++ b/arch/mips/ath79/Kconfig
+@@ -1339,6 +1339,9 @@ config ATH79_DEV_NFC
+ config ATH79_DEV_SPI
+ 	def_bool n
+ 
++config ATH79_DEV_I2C
++	def_bool n
++
+ config ATH79_DEV_USB
+ 	def_bool n
+ 
+--- a/arch/mips/ath79/Makefile
++++ b/arch/mips/ath79/Makefile
+@@ -25,6 +25,7 @@ obj-$(CONFIG_ATH79_DEV_LEDS_GPIO)	+= dev-leds-gpio.o
+ obj-$(CONFIG_ATH79_DEV_M25P80)		+= dev-m25p80.o
+ obj-$(CONFIG_ATH79_DEV_NFC)		+= dev-nfc.o
+ obj-$(CONFIG_ATH79_DEV_SPI)		+= dev-spi.o
++obj-$(CONFIG_ATH79_DEV_I2C)		+= dev-i2c.o
+ obj-$(CONFIG_ATH79_DEV_USB)		+= dev-usb.o
+ obj-$(CONFIG_ATH79_DEV_WMAC)		+= dev-wmac.o
+ 
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list