From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Grant Likely <grant.likely@secretlab.ca>,
David Brownell <david-b@pacbell.net>
Cc: benh@kernel.crashing.org, linux-kernel@vger.kernel.org,
David Miller <davem@davemloft.net>
Subject: [PATCH 6/6] gpio: OpenFirmware bindings for the pca953x
Date: Tue, 28 Oct 2008 20:46:21 +0300 [thread overview]
Message-ID: <20081028174621.GF25349@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20081028174532.GA23834@oksana.dev.rtsoft.ru>
Unfortunately we have to duplicate compatibles list, since
MODULE_DEVICE_TABLE() doesn't work with the extern symbols. :-(
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
drivers/gpio/Kconfig | 7 ++
drivers/gpio/Makefile | 1 +
drivers/gpio/of_pca953x.c | 134 +++++++++++++++++++++++++++++++++++++++++++++
drivers/of/base.c | 21 +++++++
4 files changed, 163 insertions(+), 0 deletions(-)
create mode 100644 drivers/gpio/of_pca953x.c
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 7f2ee27..d5a9e2c 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -103,6 +103,13 @@ config GPIO_PCA953X
This driver can also be built as a module. If so, the module
will be called pca953x.
+config GPIO_OF_PCA953X
+ tristate "OpenFirmware Bindings for PCA953x, PCA955x, and MAX7310"
+ depends on GPIO_PCA953X
+ help
+ Say yes here to enable OpenFirmware bindings for PCA953x, PCA955x,
+ and MAX7310 I/O ports.
+
config GPIO_PCF857X
tristate "PCF857x, PCA{85,96}7x, and MAX732[89] I2C GPIO expanders"
depends on I2C
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 6aafdeb..b6edf33 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_GPIO_MAX7301) += max7301.o
obj-$(CONFIG_GPIO_MAX732X) += max732x.o
obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o
obj-$(CONFIG_GPIO_PCA953X) += pca953x.o
+obj-$(CONFIG_GPIO_OF_PCA953X) += of_pca953x.o
obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o
obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o
obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o
diff --git a/drivers/gpio/of_pca953x.c b/drivers/gpio/of_pca953x.c
new file mode 100644
index 0000000..6884776
--- /dev/null
+++ b/drivers/gpio/of_pca953x.c
@@ -0,0 +1,134 @@
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/of.h>
+#include <linux/of_i2c.h>
+#include <linux/of_gpio.h>
+#include <linux/of_platform.h>
+#include <linux/i2c/pca953x.h>
+
+struct of_pca953x {
+ struct device_node *node;
+ struct pca953x_platform_data pdata;
+ struct i2c_client *client;
+};
+
+static int of_pca953x_setup(struct i2c_client *client, struct gpio_chip *chip,
+ void *context)
+{
+ struct of_pca953x *of_pca = context;
+ struct of_gpio_chip *of_gc;
+
+ of_gc = kzalloc(sizeof(*of_gc), GFP_KERNEL);
+ if (!of_gc)
+ return -ENOMEM;
+
+ of_gc->gpio_cells = 2;
+ of_gc->xlate = of_gpio_simple_xlate;
+
+ of_gc->chip = chip;
+ of_pca->node->data = of_gc;
+
+ return 0;
+}
+
+static int of_pca953x_teardown(struct i2c_client *client,
+ struct gpio_chip *chip,
+ void *context)
+{
+ struct of_pca953x *of_pca = context;
+ struct of_gpio_chip *of_gc = of_pca->node->data;
+
+ of_pca->node->data = NULL;
+ kfree(of_gc);
+ return 0;
+}
+
+static int __devinit of_pca953x_platform_probe(struct of_device *ofdev,
+ const struct of_device_id *match)
+{
+ struct device *dev = &ofdev->dev;
+ struct device *adap_dev = dev->parent;
+ struct i2c_adapter *adap = to_i2c_adapter(adap_dev);
+ struct device_node *node = ofdev->node;
+ struct i2c_board_info info = {};
+ struct of_pca953x *of_pca;
+ int ret;
+
+ of_pca = kzalloc(sizeof(*of_pca), GFP_KERNEL);
+ if (!of_pca)
+ return -ENOMEM;
+
+ of_pca->node = node;
+ of_pca->pdata.gpio_base = -1;
+ of_pca->pdata.context = of_pca;
+ of_pca->pdata.setup = of_pca953x_setup;
+ of_pca->pdata.teardown = of_pca953x_teardown;
+ info.platform_data = &of_pca->pdata;
+
+ of_pca->client = of_register_i2c_device(adap, &info, node);
+ if (!of_pca->client) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ dev_set_drvdata(dev, of_pca);
+ return 0;
+err:
+ kfree(of_pca);
+ return ret;
+}
+
+static int __devexit of_pca953x_platform_remove(struct of_device *ofdev)
+{
+ struct of_pca953x *of_pca = dev_get_drvdata(&ofdev->dev);
+
+ of_unregister_i2c_device(of_pca->client);
+ return 0;
+}
+
+static const struct of_device_id of_pca953x_ids[] = {
+ { "nxp,pca9534" },
+ { "nxp,pca9535" },
+ { "nxp,pca9536" },
+ { "nxp,pca9537" },
+ { "nxp,pca9538" },
+ { "nxp,pca9539" },
+ { "nxp,pca9554" },
+ { "nxp,pca9555" },
+ { "nxp,pca9557" },
+ { "ti,pca9534" },
+ { "ti,pca9535" },
+ { "ti,pca9536" },
+ { "ti,pca9537" },
+ { "ti,pca9538" },
+ { "ti,pca9539" },
+ { "ti,pca9554" },
+ { "ti,pca9555" },
+ { "ti,pca9557" },
+ { "maxim,max7310" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, of_pca953x_ids);
+
+static struct of_platform_driver of_pca953x_platform_driver = {
+ .name = "of_pca953x_platform",
+ .match_table = of_pca953x_ids,
+ .probe = of_pca953x_platform_probe,
+ .remove = __devexit_p(of_pca953x_platform_remove),
+};
+
+static int __init of_pca953x_platform_init(void)
+{
+ return of_register_platform_driver(&of_pca953x_platform_driver);
+}
+module_init(of_pca953x_platform_init);
+
+static void __exit of_pca953x_platform_exit(void)
+{
+ of_unregister_platform_driver(&of_pca953x_platform_driver);
+}
+module_exit(of_pca953x_platform_exit);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 1baeee3..f828792 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -464,6 +464,27 @@ EXPORT_SYMBOL_GPL(of_modalias_node);
* devices.
*/
static const char *of_pdev_list[] = {
+#if defined(CONFIG_GPIO_OF_PCA953X) || defined(CONFIG_GPIO_OF_PCA953X_MODULE)
+ "nxp,pca9534",
+ "nxp,pca9535",
+ "nxp,pca9536",
+ "nxp,pca9537",
+ "nxp,pca9538",
+ "nxp,pca9539",
+ "nxp,pca9554",
+ "nxp,pca9555",
+ "nxp,pca9557",
+ "ti,pca9534",
+ "ti,pca9535",
+ "ti,pca9536",
+ "ti,pca9537",
+ "ti,pca9538",
+ "ti,pca9539",
+ "ti,pca9554",
+ "ti,pca9555",
+ "ti,pca9557",
+ "maxim,max7310",
+#endif
};
/**
--
1.5.6.3
next prev parent reply other threads:[~2008-10-28 17:47 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-16 17:12 [PATCH 0/7 RFC] Handle I2C GPIO controllers with the OF (was: pca9539 I2C gpio expander) Anton Vorontsov
2008-10-16 17:12 ` Anton Vorontsov
2008-10-16 17:12 ` [PATCH 1/7] powerpc and sparc: introduce dev_archdata node accessors Anton Vorontsov
2008-10-16 17:12 ` Anton Vorontsov
2008-10-16 22:36 ` David Miller
2008-10-16 22:36 ` David Miller
2008-10-16 23:02 ` Grant Likely
2008-10-16 23:02 ` Grant Likely
2008-10-16 17:12 ` [PATCH 2/7] i2c: add info->archdata field Anton Vorontsov
2008-10-16 17:12 ` Anton Vorontsov
2008-10-17 9:21 ` Jean Delvare
2008-10-17 9:21 ` Jean Delvare
[not found] ` <20081017112125.1f2c9d94-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-10-22 0:27 ` Benjamin Herrenschmidt
2008-10-22 0:27 ` Benjamin Herrenschmidt
2008-10-22 0:27 ` Benjamin Herrenschmidt
2008-10-22 6:50 ` Jean Delvare
2008-10-22 6:50 ` Jean Delvare
2008-10-22 6:50 ` Jean Delvare
[not found] ` <20081022085002.0698e2a8-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-10-22 7:37 ` Benjamin Herrenschmidt
2008-10-22 7:37 ` Benjamin Herrenschmidt
2008-10-22 7:37 ` Benjamin Herrenschmidt
2008-10-22 10:08 ` Anton Vorontsov
2008-10-22 10:08 ` Anton Vorontsov
2008-10-22 11:07 ` Jean Delvare
2008-10-22 11:07 ` Jean Delvare
2008-10-22 12:50 ` Anton Vorontsov
2008-10-22 12:50 ` Anton Vorontsov
[not found] ` <20081016171222.GA24812-wnGakbxT3iijyJ0x5qLZdcN33GVbZNy3@public.gmane.org>
2008-10-16 17:12 ` [PATCH 3/7] of: fill the archdata for I2C devices Anton Vorontsov
2008-10-16 17:12 ` Anton Vorontsov
2008-10-16 17:12 ` Anton Vorontsov
2008-10-22 4:14 ` Grant Likely
2008-10-22 4:14 ` Grant Likely
2008-10-16 17:12 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add, remove} calls Anton Vorontsov
2008-10-16 17:12 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add,remove} calls Anton Vorontsov
2008-10-16 17:12 ` Anton Vorontsov
2008-10-17 20:24 ` David Brownell
2008-10-17 20:24 ` David Brownell
2008-10-17 21:29 ` Anton Vorontsov
2008-10-17 21:29 ` Anton Vorontsov
2008-10-20 7:29 ` David Brownell
2008-10-20 7:29 ` David Brownell
2008-10-20 15:48 ` Anton Vorontsov
2008-10-20 15:48 ` Anton Vorontsov
[not found] ` <20081020154835.GA3234-wnGakbxT3iijyJ0x5qLZdcN33GVbZNy3@public.gmane.org>
2008-10-22 0:29 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add, remove} calls Benjamin Herrenschmidt
2008-10-22 0:29 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add,remove} calls Benjamin Herrenschmidt
2008-10-22 0:29 ` Benjamin Herrenschmidt
2008-10-22 1:03 ` Anton Vorontsov
2008-10-22 1:03 ` Anton Vorontsov
2008-10-22 1:42 ` Anton Vorontsov
2008-10-22 1:42 ` Anton Vorontsov
[not found] ` <20081022014243.GA19362-wnGakbxT3iijyJ0x5qLZdcN33GVbZNy3@public.gmane.org>
2008-10-22 2:28 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add, remove} calls Benjamin Herrenschmidt
2008-10-22 2:28 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add,remove} calls Benjamin Herrenschmidt
2008-10-22 2:28 ` Benjamin Herrenschmidt
2008-10-22 4:20 ` Grant Likely
2008-10-22 4:20 ` Grant Likely
2008-10-22 4:22 ` David Brownell
2008-10-22 4:22 ` David Brownell
2008-10-22 10:36 ` Anton Vorontsov
2008-10-22 10:36 ` Anton Vorontsov
2008-10-22 10:46 ` Anton Vorontsov
2008-10-22 10:46 ` Anton Vorontsov
2008-10-22 18:32 ` Anton Vorontsov
2008-10-22 18:32 ` Anton Vorontsov
2008-10-22 21:04 ` David Brownell
2008-10-22 21:04 ` David Brownell
2008-10-22 21:22 ` Anton Vorontsov
2008-10-22 21:22 ` Anton Vorontsov
2008-10-22 21:52 ` David Brownell
2008-10-22 21:52 ` David Brownell
2008-10-22 22:29 ` Anton Vorontsov
2008-10-22 22:29 ` Anton Vorontsov
2008-10-23 5:19 ` David Brownell
2008-10-23 5:19 ` David Brownell
[not found] ` <200810221404.52798.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-10-23 4:45 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add, remove} calls Benjamin Herrenschmidt
2008-10-23 4:45 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add,remove} calls Benjamin Herrenschmidt
2008-10-23 4:45 ` Benjamin Herrenschmidt
2008-10-23 6:06 ` David Brownell
2008-10-23 6:06 ` David Brownell
2008-10-23 6:15 ` David Brownell
2008-10-23 6:15 ` David Brownell
2008-10-28 17:45 ` [PATCH 0/6 RFC] OF-glue devices for I2C/SPI (was: " Anton Vorontsov
2008-10-28 17:45 ` Anton Vorontsov
2008-10-28 17:46 ` [PATCH 1/6] of/base: Add new helper of_should_create_pdev() Anton Vorontsov
2008-10-28 17:46 ` [PATCH 2/6] of/of_i2c: implement of_{,un}register_i2c_device Anton Vorontsov
2008-10-28 17:46 ` [PATCH 3/6] of/of_i2c: add support for dedicated OF I2C devices Anton Vorontsov
2008-10-28 18:41 ` David Miller
2008-10-28 17:46 ` [PATCH 4/6] of/gpio: add support for two-stage registration for the of_gpio_chips Anton Vorontsov
2008-10-28 17:46 ` [PATCH 5/6] gpio/pca953x: pass gpio_chip pointer to the setup/teardown callbacks Anton Vorontsov
2008-10-28 17:46 ` Anton Vorontsov [this message]
2008-10-28 17:53 ` [PATCH 0/6 RFC] OF-glue devices for I2C/SPI (was: Re: [PATCH 4/7] gpiolib: implement dev_gpiochip_{add,remove} calls Grant Likely
2008-10-28 17:53 ` [PATCH 0/6 RFC] OF-glue devices for I2C/SPI (was: Re: [PATCH 4/7] gpiolib: implement dev_gpiochip_{add, remove} calls Grant Likely
[not found] ` <20081022010347.GA7377-wnGakbxT3iijyJ0x5qLZdcN33GVbZNy3@public.gmane.org>
2008-10-22 2:27 ` Benjamin Herrenschmidt
2008-10-22 2:27 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add,remove} calls Benjamin Herrenschmidt
2008-10-22 2:27 ` Benjamin Herrenschmidt
2008-10-16 17:13 ` [PATCH 5/7] of/gpio: implement of_dev_gpiochip_{add,remove} calls Anton Vorontsov
2008-10-16 17:13 ` Anton Vorontsov
2008-10-17 20:25 ` David Brownell
2008-10-17 20:25 ` [PATCH 5/7] of/gpio: implement of_dev_gpiochip_{add, remove} calls David Brownell
2008-10-17 21:13 ` [PATCH 5/7] of/gpio: implement of_dev_gpiochip_{add,remove} calls Anton Vorontsov
2008-10-17 21:13 ` Anton Vorontsov
2008-10-17 21:13 ` Anton Vorontsov
2008-10-16 17:13 ` [PATCH 6/7] gpio/pca953x: convert to dev_gpiochip_add and make it work with the OF Anton Vorontsov
2008-10-16 17:13 ` Anton Vorontsov
2008-10-16 17:13 ` [PATCH 7/7] i2c/mcu_mpc8349emitx: convert to the new I2C/OF/GPIO infrastructure Anton Vorontsov
2008-10-16 17:13 ` Anton Vorontsov
2008-10-17 16:07 ` [PATCH 0/7 RFC] Handle I2C GPIO controllers with the OF (was: pca9539 I2C gpio expander) Steven A. Falco
2008-10-17 16:07 ` Steven A. Falco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081028174621.GF25349@oksana.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=david-b@pacbell.net \
--cc=grant.likely@secretlab.ca \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.