From: Gabor Juhos Date: Tue, 29 Apr 2008 17:18:21 +0000 (+0000) Subject: remove the i2c-gpio-custom driver from adm5120, and make it available on all platforms X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=363c6e196ad7c6c78534d040f9d0cc5eff4351e5;p=librecmc%2Flibrecmc.git remove the i2c-gpio-custom driver from adm5120, and make it available on all platforms SVN-Revision: 10979 --- diff --git a/package/i2c-gpio-custom/Makefile b/package/i2c-gpio-custom/Makefile new file mode 100644 index 0000000000..fd448cec45 --- /dev/null +++ b/package/i2c-gpio-custom/Makefile @@ -0,0 +1,55 @@ +# +# Copyright (C) 2008 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=i2c-gpio-custom +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/i2c-gpio-custom + SUBMENU:=I2C support + TITLE:=Custom GPIO-based I2C device + DEPENDS:=@GPIO_SUPPORT kmod-i2c-core +kmod-i2c-gpio + FILES:=$(PKG_BUILD_DIR)/i2c-gpio-custom.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,58,i2c-gpio-custom) + KCONFIG:= +endef + +define KernelPackage/i2c-gpio-custom/description + Kernel module for register a custom i2c-gpio platform device. +endef + +EXTRA_KCONFIG:= \ + CONFIG_I2C_GPIO_CUSTOM=m + +EXTRA_CFLAGS:= \ + $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \ + $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \ + +MAKE_OPTS:= \ + ARCH="$(LINUX_KARCH)" \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + SUBDIRS="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ + LINUXINCLUDE="-I$(LINUX_DIR)/include -include linux/autoconf.h" \ + $(EXTRA_KCONFIG) + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ +endef + +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,i2c-gpio-custom)) diff --git a/package/i2c-gpio-custom/src/Kconfig b/package/i2c-gpio-custom/src/Kconfig new file mode 100644 index 0000000000..e2e3a68d92 --- /dev/null +++ b/package/i2c-gpio-custom/src/Kconfig @@ -0,0 +1,10 @@ +config I2C_GPIO_CUSTOM + tristate "Custom GPIO-based I2C driver" + depends on GENERIC_GPIO + select I2C_GPIO + help + This is an I2C driver to register 1 to 4 custom I2C buses using + GPIO lines. + + This support is also available as a module. If so, the module + will be called i2c-gpio-custom. diff --git a/package/i2c-gpio-custom/src/Makefile b/package/i2c-gpio-custom/src/Makefile new file mode 100644 index 0000000000..dcb2e2abe2 --- /dev/null +++ b/package/i2c-gpio-custom/src/Makefile @@ -0,0 +1 @@ +obj-${CONFIG_I2C_GPIO_CUSTOM} += i2c-gpio-custom.o \ No newline at end of file diff --git a/package/i2c-gpio-custom/src/i2c-gpio-custom.c b/package/i2c-gpio-custom/src/i2c-gpio-custom.c new file mode 100644 index 0000000000..36a8bf0e37 --- /dev/null +++ b/package/i2c-gpio-custom/src/i2c-gpio-custom.c @@ -0,0 +1,197 @@ +/* + * Custom GPIO-based I2C driver + * + * Copyright (C) 2007 Gabor Juhos + * + * 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. + * + * --------------------------------------------------------------------------- + * + * The behaviour of this driver can be altered by setting some parameters + * from the insmod command line. + * + * The following parameters are adjustable: + * + * bus0 These four arguments can be arrays of + * bus1 1-8 unsigned integers as follows: + * bus2 + * bus3 ,,,,,,, + * + * where: + * + * ID to used as device_id for the corresponding bus (required) + * GPIO pin ID to used for SDA (required) + * GPIO pin ID to used for SCL (required) + * signal toggle delay. + * clock stretching timeout. + * SDA is configured as open drain. + * SCL is configured as open drain. + * SCL output drivers cannot be turned off. + * + * See include/i2c-gpio.h for more information about the parameters. + * + * If this driver is built into the kernel, you can use the following kernel + * command line parameters, with the same values as the corresponding module + * parameters listed above: + * + * i2c-gpio-custom.bus0 + * i2c-gpio-custom.bus1 + * i2c-gpio-custom.bus2 + * i2c-gpio-custom.bus3 + */ + +#include +#include +#include +#include + +#include + +#define DRV_NAME "i2c-gpio-custom" +#define DRV_DESC "Custom GPIO-based I2C driver" +#define DRV_VERSION "0.1.0" + +#define PFX DRV_NAME ": " + +#define BUS_PARAM_ID 0 +#define BUS_PARAM_SDA 1 +#define BUS_PARAM_SCL 2 +#define BUS_PARAM_UDELAY 3 +#define BUS_PARAM_TIMEOUT 4 +#define BUS_PARAM_SDA_OD 5 +#define BUS_PARAM_SCL_OD 6 +#define BUS_PARAM_SCL_OO 7 + +#define BUS_PARAM_REQUIRED 3 +#define BUS_PARAM_COUNT 8 +#define BUS_COUNT_MAX 4 + +static unsigned int bus0[BUS_PARAM_COUNT] __initdata; +static unsigned int bus1[BUS_PARAM_COUNT] __initdata; +static unsigned int bus2[BUS_PARAM_COUNT] __initdata; +static unsigned int bus3[BUS_PARAM_COUNT] __initdata; + +static unsigned int bus_nump[BUS_COUNT_MAX] __initdata; + +#define BUS_PARM_DESC \ + " config -> id,sda,scl[,udelay,timeout,sda_od,scl_od,scl_oo]" + +module_param_array(bus0, uint, &bus_nump[0], 0); +MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC); +module_param_array(bus1, uint, &bus_nump[1], 0); +MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC); +module_param_array(bus2, uint, &bus_nump[2], 0); +MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC); +module_param_array(bus3, uint, &bus_nump[3], 0); +MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC); + +static struct platform_device *devices[BUS_COUNT_MAX]; +static unsigned int nr_devices; + +static void i2c_gpio_custom_cleanup(void) +{ + int i; + + for (i = 0; i < nr_devices; i++) + if (devices[i]) + platform_device_unregister(devices[i]); +} + +static int __init i2c_gpio_custom_add_one(unsigned int id, unsigned int *params) +{ + struct platform_device *pdev; + struct i2c_gpio_platform_data pdata; + int err; + + if (!bus_nump[id]) + return 0; + + if (bus_nump[id] < BUS_PARAM_REQUIRED) { + printk(KERN_ERR PFX "not enough parameters for bus%d\n", id); + err = -EINVAL; + goto err; + } + + pdev = platform_device_alloc("i2c-gpio", params[BUS_PARAM_ID]); + if (!pdev) { + err = -ENOMEM; + goto err; + } + + devices[nr_devices++] = pdev; + + pdata.sda_pin = params[BUS_PARAM_SDA]; + pdata.scl_pin = params[BUS_PARAM_SCL]; + pdata.udelay = params[BUS_PARAM_UDELAY]; + pdata.timeout = params[BUS_PARAM_TIMEOUT]; + pdata.sda_is_open_drain = params[BUS_PARAM_SDA_OD] != 0; + pdata.scl_is_open_drain = params[BUS_PARAM_SCL_OD] != 0; + pdata.scl_is_output_only = params[BUS_PARAM_SCL_OO] != 0; + + err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); + if (err) + goto err; + + err = platform_device_register(pdev); + if (err) + goto err; + + return 0; + +err: + return err; +} + +static int __init i2c_gpio_custom_probe(void) +{ + int err; + + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n"); + + err = i2c_gpio_custom_add_one(0, bus0); + if (err) goto err; + + err = i2c_gpio_custom_add_one(1, bus1); + if (err) goto err; + + err = i2c_gpio_custom_add_one(2, bus2); + if (err) goto err; + + err = i2c_gpio_custom_add_one(3, bus3); + if (err) goto err; + + if (!nr_devices) { + printk(KERN_ERR PFX "no bus parameter(s) specified\n"); + err = -ENODEV; + goto err; + } + + return 0; + +err: + i2c_gpio_custom_cleanup(); + return err; +} + +#ifdef MODULE +static int __init i2c_gpio_custom_init(void) +{ + return i2c_gpio_custom_probe(); +} +module_init(i2c_gpio_custom_init); + +static void __exit i2c_gpio_custom_exit(void) +{ + i2c_gpio_custom_cleanup(); +} +module_exit(i2c_gpio_custom_exit); +#else +subsys_initcall(i2c_gpio_custom_probe); +#endif /* MODULE*/ + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Gabor Juhos "); +MODULE_DESCRIPTION(DRV_DESC); +MODULE_VERSION(DRV_VERSION); diff --git a/package/kernel/modules/i2c.mk b/package/kernel/modules/i2c.mk index c02672f439..687fa9fb29 100644 --- a/package/kernel/modules/i2c.mk +++ b/package/kernel/modules/i2c.mk @@ -93,22 +93,6 @@ 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 @@ -135,7 +119,7 @@ define KernelPackage/i2c-scx200-acb endef define KernelPackage/i2c-scx200-acb/description - Kernel module for I2C using the ACCESS.bus controllers on the Geode SCx200 + Kernel module for I2C using the ACCESS.bus controllers on the Geode SCx200 and SC1100 processors and the CS5535 and CS5536 Geode companion devices. endef diff --git a/target/linux/adm5120/files/drivers/i2c/busses/i2c-gpio-custom.c b/target/linux/adm5120/files/drivers/i2c/busses/i2c-gpio-custom.c deleted file mode 100644 index 36a8bf0e37..0000000000 --- a/target/linux/adm5120/files/drivers/i2c/busses/i2c-gpio-custom.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Custom GPIO-based I2C driver - * - * Copyright (C) 2007 Gabor Juhos - * - * 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. - * - * --------------------------------------------------------------------------- - * - * The behaviour of this driver can be altered by setting some parameters - * from the insmod command line. - * - * The following parameters are adjustable: - * - * bus0 These four arguments can be arrays of - * bus1 1-8 unsigned integers as follows: - * bus2 - * bus3 ,,,,,,, - * - * where: - * - * ID to used as device_id for the corresponding bus (required) - * GPIO pin ID to used for SDA (required) - * GPIO pin ID to used for SCL (required) - * signal toggle delay. - * clock stretching timeout. - * SDA is configured as open drain. - * SCL is configured as open drain. - * SCL output drivers cannot be turned off. - * - * See include/i2c-gpio.h for more information about the parameters. - * - * If this driver is built into the kernel, you can use the following kernel - * command line parameters, with the same values as the corresponding module - * parameters listed above: - * - * i2c-gpio-custom.bus0 - * i2c-gpio-custom.bus1 - * i2c-gpio-custom.bus2 - * i2c-gpio-custom.bus3 - */ - -#include -#include -#include -#include - -#include - -#define DRV_NAME "i2c-gpio-custom" -#define DRV_DESC "Custom GPIO-based I2C driver" -#define DRV_VERSION "0.1.0" - -#define PFX DRV_NAME ": " - -#define BUS_PARAM_ID 0 -#define BUS_PARAM_SDA 1 -#define BUS_PARAM_SCL 2 -#define BUS_PARAM_UDELAY 3 -#define BUS_PARAM_TIMEOUT 4 -#define BUS_PARAM_SDA_OD 5 -#define BUS_PARAM_SCL_OD 6 -#define BUS_PARAM_SCL_OO 7 - -#define BUS_PARAM_REQUIRED 3 -#define BUS_PARAM_COUNT 8 -#define BUS_COUNT_MAX 4 - -static unsigned int bus0[BUS_PARAM_COUNT] __initdata; -static unsigned int bus1[BUS_PARAM_COUNT] __initdata; -static unsigned int bus2[BUS_PARAM_COUNT] __initdata; -static unsigned int bus3[BUS_PARAM_COUNT] __initdata; - -static unsigned int bus_nump[BUS_COUNT_MAX] __initdata; - -#define BUS_PARM_DESC \ - " config -> id,sda,scl[,udelay,timeout,sda_od,scl_od,scl_oo]" - -module_param_array(bus0, uint, &bus_nump[0], 0); -MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC); -module_param_array(bus1, uint, &bus_nump[1], 0); -MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC); -module_param_array(bus2, uint, &bus_nump[2], 0); -MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC); -module_param_array(bus3, uint, &bus_nump[3], 0); -MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC); - -static struct platform_device *devices[BUS_COUNT_MAX]; -static unsigned int nr_devices; - -static void i2c_gpio_custom_cleanup(void) -{ - int i; - - for (i = 0; i < nr_devices; i++) - if (devices[i]) - platform_device_unregister(devices[i]); -} - -static int __init i2c_gpio_custom_add_one(unsigned int id, unsigned int *params) -{ - struct platform_device *pdev; - struct i2c_gpio_platform_data pdata; - int err; - - if (!bus_nump[id]) - return 0; - - if (bus_nump[id] < BUS_PARAM_REQUIRED) { - printk(KERN_ERR PFX "not enough parameters for bus%d\n", id); - err = -EINVAL; - goto err; - } - - pdev = platform_device_alloc("i2c-gpio", params[BUS_PARAM_ID]); - if (!pdev) { - err = -ENOMEM; - goto err; - } - - devices[nr_devices++] = pdev; - - pdata.sda_pin = params[BUS_PARAM_SDA]; - pdata.scl_pin = params[BUS_PARAM_SCL]; - pdata.udelay = params[BUS_PARAM_UDELAY]; - pdata.timeout = params[BUS_PARAM_TIMEOUT]; - pdata.sda_is_open_drain = params[BUS_PARAM_SDA_OD] != 0; - pdata.scl_is_open_drain = params[BUS_PARAM_SCL_OD] != 0; - pdata.scl_is_output_only = params[BUS_PARAM_SCL_OO] != 0; - - err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); - if (err) - goto err; - - err = platform_device_register(pdev); - if (err) - goto err; - - return 0; - -err: - return err; -} - -static int __init i2c_gpio_custom_probe(void) -{ - int err; - - printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n"); - - err = i2c_gpio_custom_add_one(0, bus0); - if (err) goto err; - - err = i2c_gpio_custom_add_one(1, bus1); - if (err) goto err; - - err = i2c_gpio_custom_add_one(2, bus2); - if (err) goto err; - - err = i2c_gpio_custom_add_one(3, bus3); - if (err) goto err; - - if (!nr_devices) { - printk(KERN_ERR PFX "no bus parameter(s) specified\n"); - err = -ENODEV; - goto err; - } - - return 0; - -err: - i2c_gpio_custom_cleanup(); - return err; -} - -#ifdef MODULE -static int __init i2c_gpio_custom_init(void) -{ - return i2c_gpio_custom_probe(); -} -module_init(i2c_gpio_custom_init); - -static void __exit i2c_gpio_custom_exit(void) -{ - i2c_gpio_custom_cleanup(); -} -module_exit(i2c_gpio_custom_exit); -#else -subsys_initcall(i2c_gpio_custom_probe); -#endif /* MODULE*/ - -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Gabor Juhos "); -MODULE_DESCRIPTION(DRV_DESC); -MODULE_VERSION(DRV_VERSION); diff --git a/target/linux/adm5120/patches/300-i2c_gpio_custom.patch b/target/linux/adm5120/patches/300-i2c_gpio_custom.patch deleted file mode 100644 index f7f8997d68..0000000000 --- a/target/linux/adm5120/patches/300-i2c_gpio_custom.patch +++ /dev/null @@ -1,34 +0,0 @@ -Index: linux-2.6.24.2/drivers/i2c/busses/Kconfig -=================================================================== ---- linux-2.6.24.2.orig/drivers/i2c/busses/Kconfig -+++ linux-2.6.24.2/drivers/i2c/busses/Kconfig -@@ -146,6 +146,17 @@ config I2C_GPIO - 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 driver" -+ depends on GENERIC_GPIO -+ select I2C_GPIO -+ help -+ This is an I2C driver to register 1 to 4 custom I2C buses using -+ GPIO lines. -+ -+ This support is also available as a module. If so, the module -+ will be called i2c-gpio-custom. -+ - config I2C_HYDRA - tristate "CHRP Apple Hydra Mac I/O I2C interface" - depends on PCI && PPC_CHRP && EXPERIMENTAL -Index: linux-2.6.24.2/drivers/i2c/busses/Makefile -=================================================================== ---- linux-2.6.24.2.orig/drivers/i2c/busses/Makefile -+++ linux-2.6.24.2/drivers/i2c/busses/Makefile -@@ -14,6 +14,7 @@ obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bf - obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.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