Skip to contentSkip to conversation

MFD: add support for the RDC321x southbridge

PATCH Superseded Florian Fainelli 4 participants 4 messages Mar 11, 2010 – Mar 20, 2010 Multifunction devices (MFD)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/4 MFD: add support for the RDC321x southbridge

This patch adds a new MFD driver for the RDC321x southbridge. This southbridge is always present in the RDC321x System-on-a-Chip and provides access to some GPIOs as well as a watchdog. Access to these two functions is done using the southbridge PCI device configuration space.

---

drivers/mfd/Kconfig +9 -0
index 951fa9b..8cc8218 100644
@@ -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"
drivers/mfd/Makefile +2 -1
index 22715ad..f5daffe 100644
@@ -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
+obj-$(CONFIG_MFD_RDC321X)	+= rdc321x-southbridge.o
drivers/mfd/rdc321x-southbridge.c new file +148 -0

148 lines not on this page · raw message

include/linux/mfd/rdc321x.h new file +24 -0
new file mode 100644
index 0000000..82c595f
@@ -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 */
#1 lore raw

Hi Florian,

My comments below:

drivers/mfd/rdc321x-southbridge.c line 30

Quoted 2 lines · Florian Fainelli
drivers/mfd/rdc321x-southbridge.c new file +2 -0
+
+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.

drivers/mfd/rdc321x-southbridge.c line 43

Quoted 12 lines
drivers/mfd/rdc321x-southbridge.c new file +12 -0
+/*
+ * 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);
}

drivers/mfd/rdc321x-southbridge.c line 56

Quoted 12 lines
drivers/mfd/rdc321x-southbridge.c new file +12 -0
+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.

drivers/mfd/rdc321x-southbridge.c line 106

Quoted 8 lines
drivers/mfd/rdc321x-southbridge.c new file +8 -0
+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()

Quoted 7 lines
include/linux/mfd/rdc321x.h new file +4 -0
@@ -0,0 +1,24 @@
+#ifndef __RDC321X_MFD_H
+#define __RDC321X_MFD_H
+
+#include <linux/types.h>

include/linux/mfd/rdc321x.h line 14

Quoted 10 lines
include/linux/mfd/rdc321x.h new file +10 -0
+
+/* 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.

Quoted 9 lines
include/linux/mfd/rdc321x.h new file +9 -0
+/* 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 */
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#2 lore raw
In reply to Florian Fainelli

drivers/mfd/rdc321x-southbridge.c line 124

Quoted 4 lines · On Thu, 11 Mar 2010 09:42:09 +0100 Florian Fainelli <[email protected]> wrote:
drivers/mfd/rdc321x-southbridge.c new file +4 -0
+static struct pci_device_id rdc321x_sb_table[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
+	{}
+};

should be const, methinks.

#3 lore raw

Hi Florian,

Quoted 10 lines · On Fri, 19 Mar 2010 13:52:09 -0700 Andrew Morton <[email protected]>…

drivers/mfd/rdc321x-southbridge.c line 124

Quoted 4 lines · On Thu, 11 Mar 2010 09:42:09 +0100 Florian Fainelli <[email protected]> wrote:
drivers/mfd/rdc321x-southbridge.c new file +4 -0
+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) = {
	...
Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/