Signed-off-by: Regards, Florian Fainelli <flo...@openwrt.org>
---
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 413576a..ad119fc 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -358,6 +358,16 @@ config MFD_TIMBERDALE
The timberdale FPGA can be found on the Intel Atom development board
for in-vehicle infontainment, called Russellville.
+
+config MFD_RDC321X
+ tristate "Support for RDC-R321x southbridge"
+ select MFD_CORE
+ depends on PCI
+ help
+ Say yes here if you want to have support for the RDC R-321x SoC
+ southbridge which provides access to GPIOs and Watchdog using the
+ southbridge PCI device configuration space.
+
endmenu
menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 78295d6..d57ad38 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -57,3 +57,4 @@ obj-$(CONFIG_AB4500_CORE) += ab4500-core.o
obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o
obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o
obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
+obj-$(CONFIG_MFD_RDC321X) += rdc321x-southbridge.o
diff --git a/drivers/mfd/rdc321x-southbridge.c b/drivers/mfd/rdc321x-southbridge.c
new file mode 100644
index 0000000..05a56fb
--- /dev/null
+++ b/drivers/mfd/rdc321x-southbridge.c
@@ -0,0 +1,148 @@
+/*
+ * RDC321x MFD southbrige driver
+ *
+ * Copyright (C) 2007-2010 Florian Fainelli <flo...@openwrt.org>
+ * Copyright (C) 2010 Bernhard Loos <bernha...@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/pci.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/rdc321x.h>
+
+static struct pci_dev *rdc321x_sb_pdev;
+
+/*
+ * Unlocked PCI configuration space accessors
+ */
+int rdc321x_pci_read(int reg, u32 *val)
+{
+ int err;
+
+ err = pci_read_config_dword(rdc321x_sb_pdev, reg, val);
+ if (err)
+ return err;
+
+ return err;
+}
+EXPORT_SYMBOL(rdc321x_pci_read);
+
+int rdc321x_pci_write(int reg, u32 val)
+{
+ int err;
+
+ err = pci_write_config_dword(rdc321x_sb_pdev, reg, val);
+ if (err)
+ return err;
+
+ return err;
+}
+EXPORT_SYMBOL(rdc321x_pci_write);
+
+static struct resource rdc321x_wdt_resource[] = {
+ {
+ .name = "wdt-reg",
+ .start = RDC321X_WDT_CTRL,
+ .end = RDC321X_WDT_CTRL + 0x3,
+ .flags = IORESOURCE_MEM,
+ }
+};
+
+static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = {
+ .max_gpios = RDC321X_MAX_GPIO,
+};
+
+static struct resource rdc321x_gpio_resources[] = {
+ {
+ .name = "gpio-reg1",
+ .start = RDC321X_GPIO_CTRL_REG1,
+ .end = RDC321X_GPIO_CTRL_REG1 + 0x7,
+ .flags = IORESOURCE_MEM,
+ }, {
+ .name = "gpio-reg2",
+ .start = RDC321X_GPIO_CTRL_REG2,
+ .end = RDC321X_GPIO_CTRL_REG2 + 0x7,
+ .flags = IORESOURCE_MEM,
+ }
+};
+
+static struct mfd_cell rdc321x_sb_cells[] = {
+ {
+ .name = "rdc321x-wdt",
+ .resources = rdc321x_wdt_resource,
+ .num_resources = ARRAY_SIZE(rdc321x_wdt_resource),
+ }, {
+ .name = "rdc321x-gpio",
+ .resources = rdc321x_gpio_resources,
+ .num_resources = ARRAY_SIZE(rdc321x_gpio_resources),
+ .driver_data = &rdc321x_gpio_pdata,
+ },
+};
+
+static int __devinit rdc321x_sb_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int err;
+
+ err = pci_enable_device(pdev);
+ if (err) {
+ printk(KERN_ERR "failed to enable device\n");
+ return err;
+ }
+
+ rdc321x_sb_pdev = pdev;
+
+ return mfd_add_devices(&pdev->dev, -1,
+ rdc321x_sb_cells, ARRAY_SIZE(rdc321x_sb_cells), NULL, 0);
+}
+
+static void __devexit rdc321x_sb_remove(struct pci_dev *pdev)
+{
+ mfd_remove_devices(&pdev->dev);
+}
+
+static struct pci_device_id rdc321x_sb_table[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
+ {}
+};
+
+static struct pci_driver rdc321x_sb_driver = {
+ .name = "RDC321x Southbridge",
+ .id_table = rdc321x_sb_table,
+ .probe = rdc321x_sb_probe,
+ .remove = __devexit_p(rdc321x_sb_remove),
+};
+
+static int __init rdc321x_sb_init(void)
+{
+ return pci_register_driver(&rdc321x_sb_driver);
+}
+
+static void __exit rdc321x_sb_exit(void)
+{
+ pci_unregister_driver(&rdc321x_sb_driver);
+}
+
+module_init(rdc321x_sb_init);
+module_exit(rdc321x_sb_exit);
+
+MODULE_AUTHOR("Florian Fainelli <flo...@openwrt.org>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver");
diff --git a/include/linux/mfd/rdc321x.h b/include/linux/mfd/rdc321x.h
new file mode 100644
index 0000000..82c595f
--- /dev/null
+++ b/include/linux/mfd/rdc321x.h
@@ -0,0 +1,24 @@
+#ifndef __RDC321X_MFD_H
+#define __RDC321X_MFD_H
+
+#include <linux/types.h>
+
+/* Offsets to be accessed in the southbridge PCI
+ * device configuration register */
+#define RDC321X_WDT_CTRL 0x44
+#define RDC321X_GPIO_CTRL_REG1 0x48
+#define RDC321X_GPIO_DATA_REG1 0x4c
+#define RDC321X_GPIO_CTRL_REG2 0x84
+#define RDC321X_GPIO_DATA_REG2 0x88
+
+#define RDC321X_MAX_GPIO 58
+
+/* Definitions for the shared southbridge accessors */
+int rdc321x_pci_write(int reg, u32 val);
+int rdc321x_pci_read(int reg, u32 *val);
+
+struct rdc321x_gpio_pdata {
+ unsigned max_gpios;
+};
+
+#endif /* __RDC321X_MFD_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signed-off-by: Florian Fainelli <flo...@openwrt.org>
---
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 951fa9b..8cc8218 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -398,6 +398,15 @@ config LPC_SCH
LPC bridge function of the Intel SCH provides support for
System Management Bus and General Purpose I/O.
+config MFD_RDC321X
+ tristate "Support for RDC-R321x southbridge"
+ select MFD_CORE
+ depends on PCI
+ help
+ Say yes here if you want to have support for the RDC R-321x SoC
+ southbridge which provides access to GPIOs and Watchdog using the
+ southbridge PCI device configuration space.
+
endmenu
menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 22715ad..f5daffe 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -62,4 +62,5 @@ obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o
obj-$(CONFIG_AB4500_CORE) += ab4500-core.o
obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o
obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
-obj-$(CONFIG_LPC_SCH) += lpc_sch.o
\ No newline at end of file
+obj-$(CONFIG_LPC_SCH) += lpc_sch.o
My comments below:
On Thu, Mar 11, 2010 at 09:42:09AM +0100, Florian Fainelli wrote:
> +
> +static struct pci_dev *rdc321x_sb_pdev;
That's not very nice. I would have prefered to pass the pci_dev pointer along
with the platform data to the gpio and watchdog drivers. And then those could
call pci_read_config_dword() directly.
> +/*
> + * Unlocked PCI configuration space accessors
> + */
> +int rdc321x_pci_read(int reg, u32 *val)
> +{
> + int err;
> +
> + err = pci_read_config_dword(rdc321x_sb_pdev, reg, val);
> + if (err)
> + return err;
> +
> + return err;
If you want to keep your static pci_dev pointer around, please replace this
routine with:
int rdc321x_pci_read(int reg, u32 *val)
{
return pci_read_config_dword(rdc321x_sb_pdev, reg, val);
}
> +EXPORT_SYMBOL(rdc321x_pci_read);
> +
> +int rdc321x_pci_write(int reg, u32 val)
> +{
> + int err;
> +
> + err = pci_write_config_dword(rdc321x_sb_pdev, reg, val);
> + if (err)
> + return err;
> +
> + return err;
> +}
Ditto.
> +static int __devinit rdc321x_sb_probe(struct pci_dev *pdev,
> + const struct pci_device_id *ent)
> +{
> + int err;
> +
> + err = pci_enable_device(pdev);
> + if (err) {
> + printk(KERN_ERR "failed to enable device\n");
Please use dev_err()
> --- /dev/null
> +++ b/include/linux/mfd/rdc321x.h
> @@ -0,0 +1,24 @@
> +#ifndef __RDC321X_MFD_H
> +#define __RDC321X_MFD_H
> +
> +#include <linux/types.h>
> +
> +/* Offsets to be accessed in the southbridge PCI
> + * device configuration register */
> +#define RDC321X_WDT_CTRL 0x44
> +#define RDC321X_GPIO_CTRL_REG1 0x48
> +#define RDC321X_GPIO_DATA_REG1 0x4c
> +#define RDC321X_GPIO_CTRL_REG2 0x84
> +#define RDC321X_GPIO_DATA_REG2 0x88
> +
> +#define RDC321X_MAX_GPIO 58
As Wim pointed out, moving those definitions from rdc321x_defs.h to here
should be done in one patch, to avoid bisection breakage.
So, please merge the first patch of your serie with this one, and add a
watchdog driver fix that includes inux/mfd/rdc321x.h instead of
rdc321x_defs.h.
Cheers,
Samuel.
> +/* Definitions for the shared southbridge accessors */
> +int rdc321x_pci_write(int reg, u32 val);
> +int rdc321x_pci_read(int reg, u32 *val);
> +
> +struct rdc321x_gpio_pdata {
> + unsigned max_gpios;
> +};
> +
> +#endif /* __RDC321X_MFD_H */
--
Intel Open Source Technology Centre
http://oss.intel.com/
> +static struct pci_device_id rdc321x_sb_table[] = {
> + { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
> + {}
> +};
should be const, methinks.
On Fri, 19 Mar 2010 13:52:09 -0700 Andrew Morton <ak...@linux-foundation.org> wrote:
>
> On Thu, 11 Mar 2010 09:42:09 +0100
> Florian Fainelli <flo...@openwrt.org> wrote:
>
> > +static struct pci_device_id rdc321x_sb_table[] = {
> > + { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
> > + {}
> > +};
>
> should be const, methinks.
In fact maybe even
static DEFINE_PCI_DEVICE_TABLE(rdc321x_sb_table) = {
...
--
Cheers,
Stephen Rothwell s...@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
Signed-off-by: Florian Fainelli <flo...@openwrt.org>
---
Changes from v2:
- pass the pci_dev pointer to MFD cell drivers as platform_data
- remove the printk(KERN_ERR and use dev_err instead
- removed pci_dev accessors
- use DEFINE_PCI_DEVICE_TABLE
index 0000000..256dd56
--- /dev/null
+++ b/drivers/mfd/rdc321x-southbridge.c
@@ -0,0 +1,123 @@
+static struct rdc321x_wdt_pdata rdc321x_wdt_pdata;
+ .driver_data = &rdc321x_wdt_pdata,
+ }, {
+ .name = "rdc321x-gpio",
+ .resources = rdc321x_gpio_resources,
+ .num_resources = ARRAY_SIZE(rdc321x_gpio_resources),
+ .driver_data = &rdc321x_gpio_pdata,
+ },
+};
+
+static int __devinit rdc321x_sb_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int err;
+
+ err = pci_enable_device(pdev);
+ if (err) {
+ dev_err(&pdev->dev, "failed to enable device\n");
+ return err;
+ }
+
+ rdc321x_gpio_pdata.sb_pdev = pdev;
+ rdc321x_wdt_pdata.sb_pdev = pdev;
+
+ return mfd_add_devices(&pdev->dev, -1,
+ rdc321x_sb_cells, ARRAY_SIZE(rdc321x_sb_cells), NULL, 0);
+}
+
+static void __devexit rdc321x_sb_remove(struct pci_dev *pdev)
+{
+ mfd_remove_devices(&pdev->dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(rdc321x_sb_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
+ {}
+};
index 0000000..4bdf19c
--- /dev/null
+++ b/include/linux/mfd/rdc321x.h
@@ -0,0 +1,26 @@
+#ifndef __RDC321X_MFD_H
+#define __RDC321X_MFD_H
+
+#include <linux/types.h>
+#include <linux/pci.h>
+
+/* Offsets to be accessed in the southbridge PCI
+ * device configuration register */
+#define RDC321X_WDT_CTRL 0x44
+#define RDC321X_GPIO_CTRL_REG1 0x48
+#define RDC321X_GPIO_DATA_REG1 0x4c
+#define RDC321X_GPIO_CTRL_REG2 0x84
+#define RDC321X_GPIO_DATA_REG2 0x88
+
+#define RDC321X_MAX_GPIO 58
+
+struct rdc321x_gpio_pdata {
+ struct pci_dev *sb_pdev;
+ unsigned max_gpios;
+};
+
+struct rdc321x_wdt_pdata {
+ struct pci_dev *sb_pdev;
+};
+
+#endif /* __RDC321X_MFD_H */