add custom GPIO-based I2C driver
SVN-Revision: 9218
This commit is contained in:
parent
27baec04a1
commit
c0fb2f61f4
4 changed files with 141 additions and 0 deletions
|
@ -93,6 +93,22 @@ endef
|
|||
$(eval $(call KernelPackage,i2c-gpio))
|
||||
|
||||
|
||||
define KernelPackage/i2c-gpio-custom
|
||||
SUBMENU:=$(I2C_MENU)
|
||||
TITLE:=Custom GPIO-based I2C device
|
||||
DEPENDS:=@TARGET_adm5120 kmod-i2c-core +kmod-i2c-gpio
|
||||
KCONFIG:=CONFIG_I2C_GPIO_CUSTOM
|
||||
FILES:=$(LINUX_DIR)/drivers/i2c/busses/i2c-gpio-custom.$(LINUX_KMOD_SUFFIX)
|
||||
AUTOLOAD:=$(call AutoLoad,58,i2c-gpio-custom)
|
||||
endef
|
||||
|
||||
define KernelPackage/i2c-gpio-custom/description
|
||||
Kernel module for register a custom i2c-gpio platform device.
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,i2c-gpio-custom))
|
||||
|
||||
|
||||
define KernelPackage/i2c-scx200
|
||||
SUBMENU:=$(I2C_MENU)
|
||||
TITLE:=Geode SCx200 I2C using GPIO pins
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Custom GPIO-based I2C driver
|
||||
*
|
||||
* Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <linux/i2c-gpio.h>
|
||||
|
||||
#define DRV_NAME "i2c-gpio-custom"
|
||||
#define DRV_DESC "Custom GPIO I2C device driver"
|
||||
|
||||
static unsigned int sda = CONFIG_I2C_GPIO_CUSTOM_SDA;
|
||||
static unsigned int scl = CONFIG_I2C_GPIO_CUSTOM_SCL;
|
||||
static int id = CONFIG_I2C_GPIO_CUSTOM_DEVICE_ID;
|
||||
|
||||
module_param(sda, uint, S_IRUGO);
|
||||
MODULE_PARM_DESC(sda, "GPIO pin for SDA");
|
||||
|
||||
module_param(scl, uint, S_IRUGO);
|
||||
MODULE_PARM_DESC(scl, "GPIO pin for SCL");
|
||||
|
||||
module_param(id, int, S_IRUGO);
|
||||
MODULE_PARM_DESC(id, "device id of the i2c-gpio device");
|
||||
|
||||
static struct i2c_gpio_platform_data i2c_data;
|
||||
static struct platform_device i2c_device;
|
||||
|
||||
static void i2c_gpio_custom_release(struct platform_device *pdev)
|
||||
{
|
||||
/* nothing to do */
|
||||
}
|
||||
|
||||
static int __init i2c_gpio_custom_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
i2c_data.sda_pin = sda;
|
||||
i2c_data.scl_pin = scl;
|
||||
|
||||
i2c_device.name = "i2c-gpio";
|
||||
i2c_device.id = id;
|
||||
|
||||
i2c_device.dev.platform_data = &i2c_data,
|
||||
i2c_device.dev.release = i2c_gpio_custom_release,
|
||||
|
||||
err = platform_device_register(&i2c_device);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void __exit i2c_gpio_custom_exit(void)
|
||||
{
|
||||
platform_device_unregister(&i2c_device);
|
||||
}
|
||||
|
||||
module_init(i2c_gpio_custom_init);
|
||||
module_exit(i2c_gpio_custom_exit);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org >");
|
||||
MODULE_DESCRIPTION(DRV_DESC);
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
--- linux-2.6.22.4.orig/drivers/i2c/busses/Kconfig 2007-08-21 06:33:06.000000000 +0200
|
||||
+++ linux-2.6.22.4/drivers/i2c/busses/Kconfig 2007-10-09 12:53:13.000000000 +0200
|
||||
@@ -125,6 +125,40 @@
|
||||
This is a very simple bitbanging I2C driver utilizing the
|
||||
arch-neutral GPIO API to control the SCL and SDA lines.
|
||||
|
||||
+config I2C_GPIO_CUSTOM
|
||||
+ tristate "Custom GPIO-based I2C device"
|
||||
+ depends on GENERIC_GPIO
|
||||
+ select I2C_GPIO
|
||||
+ help
|
||||
+ This is an I2C driver to register a custom i2c-gpio device.
|
||||
+
|
||||
+ This support is also available as a module. If so, the module
|
||||
+ will be called i2c-gpio-dev.
|
||||
+
|
||||
+config I2C_GPIO_CUSTOM_SDA
|
||||
+ int "Custom GPIO pin for SDA"
|
||||
+ depends on I2C_GPIO_CUSTOM
|
||||
+ default "0"
|
||||
+ help
|
||||
+ Enter the GPIO pin number used for the SDA signal. This value can
|
||||
+ also be specified with a module parameter.
|
||||
+
|
||||
+config I2C_GPIO_CUSTOM_SCL
|
||||
+ int "Custom GPIO pin for SCL"
|
||||
+ depends on I2C_GPIO_CUSTOM
|
||||
+ default "1"
|
||||
+ help
|
||||
+ Enter the GPIO pin number used for the SCL signal. This value can
|
||||
+ also be specified with a module parameter.
|
||||
+
|
||||
+config I2C_GPIO_CUSTOM_DEVICE_ID
|
||||
+ int "Custom GPIO device id"
|
||||
+ depends on I2C_GPIO_CUSTOM
|
||||
+ default "0"
|
||||
+ help
|
||||
+ Enter the number used for the device id of the custom i2c-gpio device.
|
||||
+ This value can also be specified with a module parameter.
|
||||
+
|
||||
config I2C_HYDRA
|
||||
tristate "CHRP Apple Hydra Mac I/O I2C interface"
|
||||
depends on PCI && PPC_CHRP && EXPERIMENTAL
|
||||
--- linux-2.6.22.4.orig/drivers/i2c/busses/Makefile 2007-08-21 06:33:06.000000000 +0200
|
||||
+++ linux-2.6.22.4/drivers/i2c/busses/Makefile 2007-10-09 12:07:45.000000000 +0200
|
||||
@@ -13,6 +13,7 @@
|
||||
obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
|
||||
obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
|
||||
obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
|
||||
+obj-$(CONFIG_I2C_GPIO_CUSTOM) += i2c-gpio-custom.o
|
||||
obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o
|
||||
obj-$(CONFIG_I2C_I801) += i2c-i801.o
|
||||
obj-$(CONFIG_I2C_I810) += i2c-i810.o
|
|
@ -387,6 +387,7 @@ CONFIG_HZ_100=y
|
|||
# CONFIG_I2C_DEBUG_CORE is not set
|
||||
# CONFIG_I2C_ELEKTOR is not set
|
||||
# CONFIG_I2C_GPIO is not set
|
||||
# CONFIG_I2C_GPIO_CUSTOM is not set
|
||||
# CONFIG_I2C_I801 is not set
|
||||
# CONFIG_I2C_I810 is not set
|
||||
# CONFIG_I2C_NFORCE2 is not set
|
||||
|
|
Loading…
Reference in a new issue