Skip to contentSkip to conversation

mfd: Add LPC driver for Intel ICH chipsets

PATCH Superseded Aaron Sierra 2 participants 3 messages Feb 17, 2012 1 message not in the archive

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 0080ec60-4f91-4642-bf3b-42ab667b3b13@zimbra

#1 lore raw

PATCH v3 1/3 mfd: Add LPC driver for Intel ICH chipsets

This driver currently creates resources for use by a forthcoming ICH chipset GPIO driver. It could be expanded to created the resources for converting the esb2rom (mtd) and iTCO_wdt (wdt), and potentially more, drivers to use the mfd model.

---
 drivers/mfd/Kconfig         |    9 +
 drivers/mfd/Makefile        |    1 +
 drivers/mfd/lpc_ich.c       |  513 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/lpc_ich.h |   32 +++
 4 files changed, 555 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/lpc_ich.c
 create mode 100644 include/linux/mfd/lpc_ich.h
drivers/mfd/Kconfig +9 -0
index cd13e9f..f581e59 100644
@@ -724,6 +724,15 @@ config LPC_SCH
 	  LPC bridge function of the Intel SCH provides support for
 	  System Management Bus and General Purpose I/O.
 
+config LPC_ICH
+	tristate "Intel ICH LPC"
+	depends on PCI
+	select MFD_CORE
+	help
+	  The LPC bridge function of the Intel ICH provides support for
+	  many functional units. This driver provides needed support for
+	  other drivers to control these functions, currently GPIO.
+
 config MFD_RDC321X
 	tristate "Support for RDC-R321x southbridge"
 	select MFD_CORE
drivers/mfd/Makefile +1 -0
index b953bab..6636c5a 100644
@@ -98,6 +98,7 @@ obj-$(CONFIG_MFD_DB5500_PRCMU)	+= db5500-prcmu.o
 obj-$(CONFIG_MFD_TIMBERDALE)    += timberdale.o
 obj-$(CONFIG_PMIC_ADP5520)	+= adp5520.o
 obj-$(CONFIG_LPC_SCH)		+= lpc_sch.o
+obj-$(CONFIG_LPC_ICH)		+= lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)	+= rdc321x-southbridge.o
 obj-$(CONFIG_MFD_JANZ_CMODIO)	+= janz-cmodio.o
 obj-$(CONFIG_MFD_JZ4740_ADC)	+= jz4740-adc.o
drivers/mfd/lpc_ich.c new file +513 -0

513 lines not on this page · raw message

include/linux/mfd/lpc_ich.h new file +32 -0
new file mode 100644
index 0000000..286c778
@@ -0,0 +1,32 @@
+/*
+ *  linux/drivers/mfd/lpc_ich.h
+ *
+ *  Copyright (c) 2012 Extreme Engineering Solution, Inc.
+ *  Author: Aaron Sierra <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License 2 as published
+ *  by the Free Software Foundation.
+ *
+ *  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; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef LPC_ICH_H
+#define LPC_ICH_H
+
+/* GPIO resources */
+#define ICH_RES_GPIO	0
+#define ICH_RES_GPE0	1
+
+struct lpc_ich_info {
+	char name[32];
+	unsigned int gpio_version;
+};
+
+#endif
Signature · 1 line
1.7.0.4
Tested-by on v3 1/3
#2 lore raw

Hi Aaron,

Quoted 7 lines · Aaron Sierra

This driver currently creates resources for use by a forthcoming ICH chipset GPIO driver. It could be expanded to created the resources for converting the esb2rom (mtd) and iTCO_wdt (wdt), and potentially more, drivers to use the mfd model.

Quoted 8 lines
---
 drivers/mfd/Kconfig         |    9 +
 drivers/mfd/Makefile        |    1 +
 drivers/mfd/lpc_ich.c       |  513 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/lpc_ich.h |   32 +++
 4 files changed, 555 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/lpc_ich.c
 create mode 100644 include/linux/mfd/lpc_ich.h

Looks alright this time, except:

drivers/mfd/lpc_ich.c line 488

Quoted 8 lines
drivers/mfd/lpc_ich.c new file +8 -0
+static void __devexit lpc_ich_remove(struct pci_dev *dev)
+{
+	mfd_remove_devices(&dev->dev);
+
+	if (lpc_ich_gpio_save > 0)
+		pci_write_config_byte(dev, GPIOCTRL, (u8)lpc_ich_gpio_save);
+	if (lpc_ich_acpi_save > 0)
+		pci_write_config_byte(dev, ACPICTRL, (u8)lpc_ich_acpi_save);

I think you really mean >= 0 above. And the casts aren't needed. You should also reset lpc_ich_gpio_save and lpc_ich_acpi_save to -1 after restoring the values, it matters if the device is removed and re-added through sysfs.

This cleanup is missing from the error path in lpc_ich_probe, BTW. You may want to move it to a separate function so that you can call it from both lpc_ich_probe and lpc_ich_remove.

Signature · 1 line
Jean Delvare
#3 lore raw
Quoted 5 lines
Quoted 5 lines
drivers/mfd/lpc_ich.c new file +5 -0
+static void __devexit lpc_ich_remove(struct pci_dev *dev)
+{
+	mfd_remove_devices(&dev->dev);
+
+	if (lpc_ich_gpio_save > 0)
Quoted 8 lines

drivers/mfd/lpc_ich.c line 488

Quoted 3 lines
drivers/mfd/lpc_ich.c new file +3 -0
+		pci_write_config_byte(dev, GPIOCTRL, (u8)lpc_ich_gpio_save);
+	if (lpc_ich_acpi_save > 0)
+		pci_write_config_byte(dev, ACPICTRL, (u8)lpc_ich_acpi_save);

I think you really mean >= 0 above. And the casts aren't needed. You should also reset lpc_ich_gpio_save and lpc_ich_acpi_save to -1 after restoring the values, it matters if the device is removed and re-added through sysfs.

I seriously almost changed that compare in this patch... I wish I had. I've made these changes, now.

Quoted 3 lines

This cleanup is missing from the error path in lpc_ich_probe, BTW. You may want to move it to a separate function so that you can call it from both lpc_ich_probe and lpc_ich_remove.

Good point. I've got this change ready to go, too. Thanks.

-Aaron S.