Commit 8e128442 authored by charles.park's avatar charles.park

ODROIDXU3 : modified ioboard driver for remove parameter in dts file.

Change-Id: I97366c66865e66e0659dece5a35366083913f6f2
parent c3fe2fed
......@@ -506,21 +506,6 @@
spi_1: spi@12d30000 {
status = "okay";
samsung,spi-src-clk = <0>;
num-cs = <1>;
ioboard_spi {
compatible = "ioboard-spi";
reg = <0>;
spi-max-frequency = <20000000>;
pinctrl-names = "default";
pinctrl-0 = <&ioboard_flash_cs &ioboard_wp>;
wp-gpio = <&gpx1 5 0>;
controller-data {
cs-gpio = <&gpa2 5 0>;
samsung,spi-feedback-delay = <0>;
};
};
};
spi_2: spi@12d40000 {
......@@ -569,106 +554,6 @@
status = "okay";
};
pinctrl@13400000 {
gpio_i2c_sda: gpio-i2c-sda {
samsung,pins = "gpx3-1";
/* 0 = input, 1 = output */
samsung,pin-function = <0>;
/* 0 = disable, 1 = pull dn, 2 = reserved, 3 = pull up */
samsung,pin-pud = <0x00>;
};
gpio_i2c_scl: gpio-i2c-scl {
samsung,pins = "gpx1-7";
/* 0 = input, 1 = output */
samsung,pin-function = <0>;
/* 0 = disable, 1 = pull dn, 2 = reserved, 3 = pull up */
samsung,pin-pud = <0x00>;
};
ioboard_key: ioboard-key {
samsung,pins = "gpx2-5", "gpx2-6", "gpx1-6", "gpx1-2";
/* 0 = input, 1 = output */
samsung,pin-function = <0>;
/* 0 = disable, 1 = pull dn, 2 = reserved, 3 = pull up */
samsung,pin-pud = <0x00>;
};
ioboard_led: ioboard-led {
samsung,pins = "gpx2-7", "gpx2-4", "gpx1-3", "gpx2-0";
/* 0 = input, 1 = output */
samsung,pin-function = <1>;
/* 0 = disable, 1 = pull dn, 2 = reserved, 3 = pull up */
samsung,pin-pud = <0x03>;
};
ioboard_wp: ioboard-wp {
samsung,pins = "gpx1-5";
/* 0 = input, 1 = output */
samsung,pin-function = <0>;
/* 0 = disable, 1 = pull dn, 2 = reserved, 3 = pull up */
samsung,pin-pud = <0x00>;
};
};
pinctrl@14010000 {
ioboard_led_1: ioboard-led-1 {
samsung,pins = "gpb3-2";
/* 0 = input, 1 = output */
samsung,pin-function = <1>;
/* 0 = disable, 1 = pull dn, 2 = reserved, 3 = pull up */
samsung,pin-pud = <0x03>;
};
ioboard_flash_cs: ioboard-flash-cs {
samsung,pins = "gpa2-5";
/* 0 = input, 1 = output, 2 = SPI_nSS */
samsung,pin-function = <2>;
/* 0 = disable, 1 = pull dn, 2 = reserved, 3 = pull up */
samsung,pin-pud = <0>;
};
};
ioboard_key_led {
compatible = "ioboard-keyled";
pinctrl-names = "default";
pinctrl-0 = <&ioboard_key &ioboard_led &ioboard_led_1>;
gpios = <
&gpx2 5 0 /* IOBOARD_SW1 */
&gpx2 6 0 /* IOBOARD_SW2 */
&gpx1 6 0 /* IOBOARD_SW3 */
&gpx1 2 0 /* IOBOARD_SW4 */
&gpx2 7 0 /* IOBOARD_LED1 */
&gpx2 4 0 /* IOBOARD_LED2 */
&gpx1 3 0 /* IOBOARD_LED3 */
&gpb3 2 0 /* IOBOARD_LED4 */
&gpx2 0 0 /* IOBOARD_LED5 */
>;
status = "okay";
};
i2c_gpio {
compatible = "i2c-gpio";
gpios = <
&gpx3 1 0 /* sda */
&gpx1 7 0 /* scl */
>;
i2c-gpio,sda-open-drain;
i2c-gpio,scl-open-drain;
i2c-gpio,delay-us = <10>; /* ~50 kHz */
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&gpio_i2c_sda &gpio_i2c_scl>;
status = "okay";
/* light sensor : bh1780 dirver */
bh1780@29 {
compatible = "ioboard-bh1780";
reg = <0x29>;
};
/* pressure sensor : bmp180 dirver */
bmp180@77 {
compatible = "ioboard-bmp180";
reg = <0x77>;
};
};
pinctrl@14010000 {
pwm0_out: pwm0-out {
samsung,pins = "gpb2-0";
......
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm 3.10.72 Kernel Configuration
# Linux/arm 3.10.81 Kernel Configuration
#
CONFIG_ARM=y
CONFIG_ARM_HAS_SG_CHAIN=y
......@@ -1775,6 +1775,7 @@ CONFIG_I2C_ALGOBIT=y
# CONFIG_I2C_DESIGNWARE_PLATFORM is not set
CONFIG_I2C_EXYNOS5=y
CONFIG_I2C_GPIO=y
CONFIG_I2C_GPIO_CUSTOM=m
# CONFIG_I2C_NOMADIK is not set
# CONFIG_I2C_OCORES is not set
# CONFIG_I2C_PCA_PLATFORM is not set
......
......@@ -27,13 +27,11 @@
#include <mach/regs-pmu.h>
#include <plat/gpio-cfg.h>
#if defined(CONFIG_OF)
#include <linux/of_gpio.h>
#endif
//[*]--------------------------------------------------------------------------------------------------[*]
unsigned char BoardTestFlag = 1;
struct hrtimer BoardTestTimer; // Board Test Timer
static unsigned char BoardTestFlag = 1;
static struct hrtimer BoardTestTimer; // Board Test Timer
static struct platform_device *pd;
//[*]--------------------------------------------------------------------------------------------------[*]
// IOBOARD KEY & LED GPIO Define
//[*]--------------------------------------------------------------------------------------------------[*]
......@@ -51,6 +49,17 @@ enum {
};
//[*]--------------------------------------------------------------------------------------------------[*]
// GPIO Export Number define
#define GPX2_5_EXPORT_NUM 29
#define GPX2_6_EXPORT_NUM 30
#define GPX1_6_EXPORT_NUM 22
#define GPX1_2_EXPORT_NUM 18
#define GPX2_7_EXPORT_NUM 31
#define GPX2_4_EXPORT_NUM 28
#define GPX1_3_EXPORT_NUM 19
#define GPB3_2_EXPORT_NUM 209
#define GPX2_0_EXPORT_NUM 24
static struct {
int gpio_index; // Control Index
int gpio; // GPIO Number
......@@ -59,27 +68,15 @@ static struct {
int value; // Default Value(only for output)
int pud; // Pull up/down register setting : S3C_GPIO_PULL_DOWN, UP, NONE
} sControlGpios[] = {
#if defined(CONFIG_OF)
{ IOBOARD_SW1, 0xFFFF, "sw1", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_SW2, 0xFFFF, "sw2", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_SW3, 0xFFFF, "sw3", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_SW4, 0xFFFF, "sw4", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED1, 0xFFFF, "led1", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED2, 0xFFFF, "led2", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED3, 0xFFFF, "led3", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED4, 0xFFFF, "led4", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED5, 0xFFFF, "led5", 1, 1, S3C_GPIO_PULL_NONE },
#else
{ IOBOARD_SW1, EXYNOS5410_GPX2(5), "sw1", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_SW2, EXYNOS5410_GPX2(6), "sw2", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_SW3, EXYNOS5410_GPX1(6), "sw3", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_SW4, EXYNOS5410_GPX1(2), "sw4", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED1, EXYNOS5410_GPX2(7), "led1", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED2, EXYNOS5410_GPX2(4), "led2", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED3, EXYNOS5410_GPX1(3), "led3", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED4, EXYNOS5410_GPX1(0), "led4", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED5, EXYNOS5410_GPX2(0), "led5", 1, 1, S3C_GPIO_PULL_NONE },
#endif
{ IOBOARD_SW1, GPX2_5_EXPORT_NUM, "sw1", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_SW2, GPX2_6_EXPORT_NUM, "sw2", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_SW3, GPX1_6_EXPORT_NUM, "sw3", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_SW4, GPX1_2_EXPORT_NUM, "sw4", 0, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED1, GPX2_7_EXPORT_NUM, "led1", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED2, GPX2_4_EXPORT_NUM, "led2", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED3, GPX1_3_EXPORT_NUM, "led3", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED4, GPB3_2_EXPORT_NUM, "led4", 1, 0, S3C_GPIO_PULL_NONE },
{ IOBOARD_LED5, GPX2_0_EXPORT_NUM, "led5", 1, 1, S3C_GPIO_PULL_NONE },
};
//[*]--------------------------------------------------------------------------------------------------[*]
......@@ -209,6 +206,7 @@ static enum hrtimer_restart ioboard_test_timer(struct hrtimer *timer)
return HRTIMER_NORESTART;
}
//[*]--------------------------------------------------------------------------------------------------[*]
static int ioboard_keyled_resume(struct platform_device *dev)
{
......@@ -229,45 +227,14 @@ static int ioboard_keyled_suspend(struct platform_device *dev, pm_message_t stat
return 0;
}
//[*]--------------------------------------------------------------------------------------------------[*]
#if defined(CONFIG_OF)
static int of_ioboard_keyled_get_pins (struct device_node *np)
{
int cnt, gpio_cnt;
if ((gpio_cnt = of_gpio_count(np)) < IOBOARD_MAX) {
pr_err("Invalid GPIO pins. count = %d\n", gpio_cnt);
return -ENODEV;
}
for(cnt = 0; cnt < gpio_cnt; cnt++) {
sControlGpios[cnt].gpio = of_get_gpio(np, cnt);
if(!gpio_is_valid(sControlGpios[cnt].gpio)) {
pr_err("%s: invalid GPIO pins, gpio.name=%s/gpio_no=%d\n",
np->full_name, sControlGpios[cnt].name, sControlGpios[cnt].gpio);
return -ENODEV;
}
}
return 0;
}
#endif
//[*]--------------------------------------------------------------------------------------------------[*]
static int ioboard_keyled_probe (struct platform_device *pdev)
{
int i;
#if defined(CONFIG_OF)
if (pdev->dev.of_node) {
if(of_ioboard_keyled_get_pins(pdev->dev.of_node)) return -ENODEV;
}
else {
return -ENODEV;
}
#endif
// Control GPIO Init
for (i = 0; i < ARRAY_SIZE(sControlGpios); i++) {
if(sControlGpios[i].gpio) {
if(gpio_request(sControlGpios[i].gpio, sControlGpios[i].name)) {
printk("%s : %s gpio reqest err!\n", __FUNCTION__, sControlGpios[i].name);
......@@ -296,7 +263,7 @@ static int ioboard_keyled_probe (struct platform_device *pdev)
static int ioboard_keyled_remove (struct platform_device *pdev)
{
int i;
for (i = 0; i < ARRAY_SIZE(sControlGpios); i++) {
if(sControlGpios[i].gpio) gpio_free(sControlGpios[i].gpio);
}
......@@ -309,21 +276,10 @@ static int ioboard_keyled_remove (struct platform_device *pdev)
}
//[*]--------------------------------------------------------------------------------------------------[*]
#if defined(CONFIG_OF)
static const struct of_device_id ioboard_keyled_dt[] = {
{ .compatible = "ioboard-keyled" },
{ },
};
MODULE_DEVICE_TABLE(of, ioboard_keyled_dt);
#endif
static struct platform_driver ioboard_keyled_driver = {
.driver = {
.name = "ioboard-keyled",
.owner = THIS_MODULE,
#if defined(CONFIG_OF)
.of_match_table = of_match_ptr(ioboard_keyled_dt),
#endif
},
.probe = ioboard_keyled_probe,
.remove = ioboard_keyled_remove,
......@@ -333,13 +289,31 @@ static struct platform_driver ioboard_keyled_driver = {
//[*]--------------------------------------------------------------------------------------------------[*]
static int __init ioboard_keyled_init(void)
{
return platform_driver_register(&ioboard_keyled_driver);
{
int err;
if((err = platform_driver_register(&ioboard_keyled_driver)))
return err;
if((pd = platform_device_alloc("ioboard-keyled", -1)) == NULL) {
err = -ENOMEM;
goto exit_unregister;
}
if((err = platform_device_add(pd)))
goto exit_unregister;
return 0;
exit_unregister:
platform_driver_unregister(&ioboard_keyled_driver);
return err;
}
//[*]--------------------------------------------------------------------------------------------------[*]
static void __exit ioboard_keyled_exit(void)
{
platform_device_unregister(pd);
platform_driver_unregister(&ioboard_keyled_driver);
}
......
......@@ -87,7 +87,7 @@ int ioboard_spi_misc_probe(struct spi_device *spi)
struct ioboard_spi *ioboard_spi = dev_get_drvdata(&spi->dev);
if(!(ioboard_spi->misc = kzalloc(sizeof(struct miscdevice), GFP_KERNEL))) {
if(!(ioboard_spi->misc = devm_kzalloc(&spi->dev, sizeof(struct miscdevice), GFP_KERNEL))) {
printk("ioboard-spi misc struct malloc error!\n");
return -ENOMEM;
}
......@@ -111,9 +111,8 @@ void ioboard_spi_misc_remove(struct device *dev)
{
struct ioboard_spi *ioboard_spi = dev_get_drvdata(dev);
misc_deregister(ioboard_spi->misc);
kfree(ioboard_spi->misc);
if(ioboard_spi->misc)
misc_deregister(ioboard_spi->misc);
}
//[*]--------------------------------------------------------------------------------------------------[*]
......
This diff is collapsed.
......@@ -47,8 +47,10 @@ struct ioboard_spi_iocreg {
//[*]--------------------------------------------------------------------------------------------------[*]
struct ioboard_spi {
struct miscdevice *misc;
struct spi_device *spi;
struct miscdevice *misc;
struct spi_device *spi;
struct s3c64xx_spi_csinfo *csinfo;
unsigned int wp_gpio;
};
//[*]--------------------------------------------------------------------------------------------------[*]
......
......@@ -453,6 +453,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 GPIOLIB
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_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
......
......@@ -44,6 +44,7 @@ i2c-designware-pci-objs := i2c-designware-pcidrv.o
obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
obj-$(CONFIG_I2C_EXYNOS5) += i2c-exynos5.o
obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
obj-${CONFIG_I2C_GPIO_CUSTOM} += i2c-gpio-custom.o
obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o
obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o
obj-$(CONFIG_I2C_IMX) += i2c-imx.o
......
/*
* Custom GPIO-based I2C driver
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@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.
*
* ---------------------------------------------------------------------------
*
* 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 <id>,<sda>,<scl>,<udelay>,<timeout>,<sda_od>,<scl_od>,<scl_oo>
*
* where:
*
* <id> ID to used as device_id for the corresponding bus (required)
* <sda> GPIO pin ID to used for SDA (required)
* <scl> GPIO pin ID to used for SCL (required)
* <udelay> signal toggle delay.
* <timeout> clock stretching timeout.
* <sda_od> SDA is configured as open drain.
* <scl_od> SCL is configured as open drain.
* <scl_oo> 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 <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-based I2C driver"
#define DRV_VERSION "0.1.1"
#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_del(devices[i]);
platform_device_put(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;
}
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_put;
err = platform_device_add(pdev);
if (err)
goto err_put;
devices[nr_devices++] = pdev;
return 0;
err_put:
platform_device_put(pdev);
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 <juhosg@openwrt.org >");
MODULE_DESCRIPTION(DRV_DESC);
MODULE_VERSION(DRV_VERSION);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment