2 * Custom GPIO-based I2C driver
4 * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
16 #include <linux/i2c-gpio.h>
18 #define DRV_NAME "i2c-gpio-custom"
19 #define DRV_DESC "Custom GPIO I2C device driver"
21 static unsigned int sda
= CONFIG_I2C_GPIO_CUSTOM_SDA
;
22 static unsigned int scl
= CONFIG_I2C_GPIO_CUSTOM_SCL
;
23 static int id
= CONFIG_I2C_GPIO_CUSTOM_DEVICE_ID
;
25 module_param(sda
, uint
, S_IRUGO
);
26 MODULE_PARM_DESC(sda
, "GPIO pin for SDA");
28 module_param(scl
, uint
, S_IRUGO
);
29 MODULE_PARM_DESC(scl
, "GPIO pin for SCL");
31 module_param(id
, int, S_IRUGO
);
32 MODULE_PARM_DESC(id
, "device id of the i2c-gpio device");
34 static struct i2c_gpio_platform_data i2c_data
;
35 static struct platform_device i2c_device
;
37 static void i2c_gpio_custom_release(struct platform_device
*pdev
)
42 static int __init
i2c_gpio_custom_init(void)
46 i2c_data
.sda_pin
= sda
;
47 i2c_data
.scl_pin
= scl
;
49 i2c_device
.name
= "i2c-gpio";
52 i2c_device
.dev
.platform_data
= &i2c_data
,
53 i2c_device
.dev
.release
= i2c_gpio_custom_release
,
55 err
= platform_device_register(&i2c_device
);
60 static void __exit
i2c_gpio_custom_exit(void)
62 platform_device_unregister(&i2c_device
);
65 module_init(i2c_gpio_custom_init
);
66 module_exit(i2c_gpio_custom_exit
);
68 MODULE_LICENSE("GPL v2");
69 MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org >");
70 MODULE_DESCRIPTION(DRV_DESC
);