* [PATCH 0/3] Add Intel SCH GPIO driver @ 2010-02-11 10:24 Denis Turischev 2010-02-11 10:26 ` Denis Turischev ` (2 more replies) 0 siblings, 3 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-11 10:24 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c LPC bridge controller of Intel SCH contains several functions. Currently, LPC bridge controller PCI device is claimed by SMBus driver thus disabling ability to have an additional driver for the LPC bridge PCI device. This patch series introduces and MFD driver that creates platform_device for both SMBus and GPIO controller, converts SMBus driver to platform_driver and adds the driver for GPIO controller ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-11 10:26 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-11 10:26 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c Intel Poulsbo (SCH) chipset LPC bridge controller contains several functions. Creating and MFD driver for the LPC bridge controller allows simultaneous use of SMBus and GPIO interfaces on the SCH. Signed-off-by: Denis Turischev <denis@compulab.co.il> diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-10 15:15:40.000000000 +0200 @@ -348,6 +348,14 @@ read/write functions for the devices to get access to this chip. This chip embeds various other multimedia funtionalities as well. +config LPC_SCH + tristate "Intel SCH LPC" + default m + depends on PCI + help + LPC bridge function of the Intel SCH provides support for + System Management Bus and General Purpose I/O. + endmenu menu "Multimedia Capabilities Port drivers" diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 @@ -0,0 +1,133 @@ +/* + * lpc_sch.c - LPC interface for Intel Poulsbo SCH + * + * LPC bridge function of the Intel SCH contains many other + * functional units, such as Interrupt controllers, Timers, + * Power Management, System Management, GPIO, RTC, and LPC + * Configuration Registers. + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis@compulab.co.il> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/pci.h> +#include <linux/mfd/core.h> + +#define SMBASE 0x40 +#define SMBUS_IO_SIZE 64 + +#define GPIOBASE 0x44 +#define GPIO_IO_SIZE 64 + +static struct resource smbus_sch_resource = { + .flags = IORESOURCE_IO, +}; + + +static struct resource gpio_sch_resource = { + .flags = IORESOURCE_IO, +}; + +static struct mfd_cell lpc_sch_cells[] = { + { + .name = "isch_smbus", + .num_resources = 1, + .resources = &smbus_sch_resource, + }, + { + .name = "sch_gpio", + .num_resources = 1, + .resources = &gpio_sch_resource, + }, +}; + +static struct pci_device_id lpc_sch_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); + +static int __devinit lpc_sch_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + unsigned int base_addr_cfg; + unsigned short base_addr; + + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); + return -ENODEV; + } + + smbus_sch_resource.start = base_addr; + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; + + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); + return -ENODEV; + } + + gpio_sch_resource.start = base_addr; + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; + + return mfd_add_devices(&dev->dev, -1, + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); +} + +static void __devexit lpc_sch_remove(struct pci_dev *dev) +{ + mfd_remove_devices(&dev->dev); +} + +static struct pci_driver lpc_sch_driver = { + .name = "lpc_sch", + .id_table = lpc_sch_ids, + .probe = lpc_sch_probe, + .remove = __devexit_p(lpc_sch_remove), +}; + +static int __init lpc_sch_init(void) +{ + return pci_register_driver(&lpc_sch_driver); +} + +static void __exit lpc_sch_exit(void) +{ + pci_unregister_driver(&lpc_sch_driver); +} + +module_init(lpc_sch_init); +module_exit(lpc_sch_exit); + +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 @@ -55,4 +55,5 @@ obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o obj-$(CONFIG_AB4500_CORE) += ab4500-core.o obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o \ No newline at end of file +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o +obj-$(CONFIG_LPC_SCH) += lpc_sch.o ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-11 10:26 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-11 10:26 UTC (permalink / raw) To: LKML Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA Intel Poulsbo (SCH) chipset LPC bridge controller contains several functions. Creating and MFD driver for the LPC bridge controller allows simultaneous use of SMBus and GPIO interfaces on the SCH. Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-10 15:15:40.000000000 +0200 @@ -348,6 +348,14 @@ read/write functions for the devices to get access to this chip. This chip embeds various other multimedia funtionalities as well. +config LPC_SCH + tristate "Intel SCH LPC" + default m + depends on PCI + help + LPC bridge function of the Intel SCH provides support for + System Management Bus and General Purpose I/O. + endmenu menu "Multimedia Capabilities Port drivers" diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 @@ -0,0 +1,133 @@ +/* + * lpc_sch.c - LPC interface for Intel Poulsbo SCH + * + * LPC bridge function of the Intel SCH contains many other + * functional units, such as Interrupt controllers, Timers, + * Power Management, System Management, GPIO, RTC, and LPC + * Configuration Registers. + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/pci.h> +#include <linux/mfd/core.h> + +#define SMBASE 0x40 +#define SMBUS_IO_SIZE 64 + +#define GPIOBASE 0x44 +#define GPIO_IO_SIZE 64 + +static struct resource smbus_sch_resource = { + .flags = IORESOURCE_IO, +}; + + +static struct resource gpio_sch_resource = { + .flags = IORESOURCE_IO, +}; + +static struct mfd_cell lpc_sch_cells[] = { + { + .name = "isch_smbus", + .num_resources = 1, + .resources = &smbus_sch_resource, + }, + { + .name = "sch_gpio", + .num_resources = 1, + .resources = &gpio_sch_resource, + }, +}; + +static struct pci_device_id lpc_sch_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); + +static int __devinit lpc_sch_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + unsigned int base_addr_cfg; + unsigned short base_addr; + + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); + return -ENODEV; + } + + smbus_sch_resource.start = base_addr; + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; + + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); + return -ENODEV; + } + + gpio_sch_resource.start = base_addr; + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; + + return mfd_add_devices(&dev->dev, -1, + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); +} + +static void __devexit lpc_sch_remove(struct pci_dev *dev) +{ + mfd_remove_devices(&dev->dev); +} + +static struct pci_driver lpc_sch_driver = { + .name = "lpc_sch", + .id_table = lpc_sch_ids, + .probe = lpc_sch_probe, + .remove = __devexit_p(lpc_sch_remove), +}; + +static int __init lpc_sch_init(void) +{ + return pci_register_driver(&lpc_sch_driver); +} + +static void __exit lpc_sch_exit(void) +{ + pci_unregister_driver(&lpc_sch_driver); +} + +module_init(lpc_sch_init); +module_exit(lpc_sch_exit); + +MODULE_AUTHOR("Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>"); +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 @@ -55,4 +55,5 @@ obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o obj-$(CONFIG_AB4500_CORE) += ab4500-core.o obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o \ No newline at end of file +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o +obj-$(CONFIG_LPC_SCH) += lpc_sch.o ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 10:08 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-16 10:08 UTC (permalink / raw) To: Denis Turischev, Jacob Jun Pan Cc: LKML, David Brownell, Jean Delvare, linux-i2c Hi Denis, On Thu, Feb 11, 2010 at 12:26:19PM +0200, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. That looks like an nice patch to me. Before merging it, I'd like to get Jacob's view on it though. Jacob, does moving the SCH SMBus driver to a platform one look fine to you ? Cheers, Samuel. > Signed-off-by: Denis Turischev <denis@compulab.co.il> > > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-10 15:15:40.000000000 +0200 > @@ -348,6 +348,14 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + default m > + depends on PCI > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c > --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 > @@ -0,0 +1,133 @@ > +/* > + * lpc_sch.c - LPC interface for Intel Poulsbo SCH > + * > + * LPC bridge function of the Intel SCH contains many other > + * functional units, such as Interrupt controllers, Timers, > + * Power Management, System Management, GPIO, RTC, and LPC > + * Configuration Registers. > + * > + * Copyright (c) 2010 CompuLab Ltd > + * Author: Denis Turischev <denis@compulab.co.il> > + * > + * 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. > + */ > + > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/errno.h> > +#include <linux/acpi.h> > +#include <linux/pci.h> > +#include <linux/mfd/core.h> > + > +#define SMBASE 0x40 > +#define SMBUS_IO_SIZE 64 > + > +#define GPIOBASE 0x44 > +#define GPIO_IO_SIZE 64 > + > +static struct resource smbus_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > + > +static struct resource gpio_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > +static struct mfd_cell lpc_sch_cells[] = { > + { > + .name = "isch_smbus", > + .num_resources = 1, > + .resources = &smbus_sch_resource, > + }, > + { > + .name = "sch_gpio", > + .num_resources = 1, > + .resources = &gpio_sch_resource, > + }, > +}; > + > +static struct pci_device_id lpc_sch_ids[] = { > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > + { 0, } > +}; > +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); > + > +static int __devinit lpc_sch_probe(struct pci_dev *dev, > + const struct pci_device_id *id) > +{ > + unsigned int base_addr_cfg; > + unsigned short base_addr; > + > + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); > + return -ENODEV; > + } > + > + smbus_sch_resource.start = base_addr; > + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; > + > + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); > + return -ENODEV; > + } > + > + gpio_sch_resource.start = base_addr; > + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; > + > + return mfd_add_devices(&dev->dev, -1, > + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); > +} > + > +static void __devexit lpc_sch_remove(struct pci_dev *dev) > +{ > + mfd_remove_devices(&dev->dev); > +} > + > +static struct pci_driver lpc_sch_driver = { > + .name = "lpc_sch", > + .id_table = lpc_sch_ids, > + .probe = lpc_sch_probe, > + .remove = __devexit_p(lpc_sch_remove), > +}; > + > +static int __init lpc_sch_init(void) > +{ > + return pci_register_driver(&lpc_sch_driver); > +} > + > +static void __exit lpc_sch_exit(void) > +{ > + pci_unregister_driver(&lpc_sch_driver); > +} > + > +module_init(lpc_sch_init); > +module_exit(lpc_sch_exit); > + > +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); > +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); > +MODULE_LICENSE("GPL"); > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile > --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 > @@ -55,4 +55,5 @@ > obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o > obj-$(CONFIG_AB4500_CORE) += ab4500-core.o > obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o > -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > \ No newline at end of file > +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > +obj-$(CONFIG_LPC_SCH) += lpc_sch.o -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 10:08 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-16 10:08 UTC (permalink / raw) To: Denis Turischev, Jacob Jun Pan Cc: LKML, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA Hi Denis, On Thu, Feb 11, 2010 at 12:26:19PM +0200, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. That looks like an nice patch to me. Before merging it, I'd like to get Jacob's view on it though. Jacob, does moving the SCH SMBus driver to a platform one look fine to you ? Cheers, Samuel. > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-10 15:15:40.000000000 +0200 > @@ -348,6 +348,14 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + default m > + depends on PCI > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c > --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 > @@ -0,0 +1,133 @@ > +/* > + * lpc_sch.c - LPC interface for Intel Poulsbo SCH > + * > + * LPC bridge function of the Intel SCH contains many other > + * functional units, such as Interrupt controllers, Timers, > + * Power Management, System Management, GPIO, RTC, and LPC > + * Configuration Registers. > + * > + * Copyright (c) 2010 CompuLab Ltd > + * Author: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > + * > + * 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. > + */ > + > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/errno.h> > +#include <linux/acpi.h> > +#include <linux/pci.h> > +#include <linux/mfd/core.h> > + > +#define SMBASE 0x40 > +#define SMBUS_IO_SIZE 64 > + > +#define GPIOBASE 0x44 > +#define GPIO_IO_SIZE 64 > + > +static struct resource smbus_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > + > +static struct resource gpio_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > +static struct mfd_cell lpc_sch_cells[] = { > + { > + .name = "isch_smbus", > + .num_resources = 1, > + .resources = &smbus_sch_resource, > + }, > + { > + .name = "sch_gpio", > + .num_resources = 1, > + .resources = &gpio_sch_resource, > + }, > +}; > + > +static struct pci_device_id lpc_sch_ids[] = { > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > + { 0, } > +}; > +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); > + > +static int __devinit lpc_sch_probe(struct pci_dev *dev, > + const struct pci_device_id *id) > +{ > + unsigned int base_addr_cfg; > + unsigned short base_addr; > + > + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); > + return -ENODEV; > + } > + > + smbus_sch_resource.start = base_addr; > + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; > + > + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); > + return -ENODEV; > + } > + > + gpio_sch_resource.start = base_addr; > + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; > + > + return mfd_add_devices(&dev->dev, -1, > + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); > +} > + > +static void __devexit lpc_sch_remove(struct pci_dev *dev) > +{ > + mfd_remove_devices(&dev->dev); > +} > + > +static struct pci_driver lpc_sch_driver = { > + .name = "lpc_sch", > + .id_table = lpc_sch_ids, > + .probe = lpc_sch_probe, > + .remove = __devexit_p(lpc_sch_remove), > +}; > + > +static int __init lpc_sch_init(void) > +{ > + return pci_register_driver(&lpc_sch_driver); > +} > + > +static void __exit lpc_sch_exit(void) > +{ > + pci_unregister_driver(&lpc_sch_driver); > +} > + > +module_init(lpc_sch_init); > +module_exit(lpc_sch_exit); > + > +MODULE_AUTHOR("Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>"); > +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); > +MODULE_LICENSE("GPL"); > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile > --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 > @@ -55,4 +55,5 @@ > obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o > obj-$(CONFIG_AB4500_CORE) += ab4500-core.o > obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o > -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > \ No newline at end of file > +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > +obj-$(CONFIG_LPC_SCH) += lpc_sch.o -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* RE: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 13:59 ` Pan, Jacob jun 0 siblings, 0 replies; 73+ messages in thread From: Pan, Jacob jun @ 2010-02-16 13:59 UTC (permalink / raw) To: Samuel Ortiz, Denis Turischev Cc: LKML, David Brownell, Jean Delvare, linux-i2c > >On Thu, Feb 11, 2010 at 12:26:19PM +0200, Denis Turischev wrote: >> Intel Poulsbo (SCH) chipset LPC bridge controller contains several >> functions. Creating and MFD driver for the LPC bridge controller allows >> simultaneous use of SMBus and GPIO interfaces on the SCH. >That looks like an nice patch to me. Before merging it, I'd like to get >Jacob's view on it though. Jacob, does moving the SCH SMBus driver to a >platform one look fine to you ? > [[JPAN]] i agree with merging gpio and smbus into lpc driver. the only question i had was whether impact to the user space tools has been considered. iirc, there are sensors detect tools probe pci bus for smbus controllers, not sure it does that for platform bus. ^ permalink raw reply [flat|nested] 73+ messages in thread
* RE: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 13:59 ` Pan, Jacob jun 0 siblings, 0 replies; 73+ messages in thread From: Pan, Jacob jun @ 2010-02-16 13:59 UTC (permalink / raw) To: Samuel Ortiz, Denis Turischev Cc: LKML, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA > >On Thu, Feb 11, 2010 at 12:26:19PM +0200, Denis Turischev wrote: >> Intel Poulsbo (SCH) chipset LPC bridge controller contains several >> functions. Creating and MFD driver for the LPC bridge controller allows >> simultaneous use of SMBus and GPIO interfaces on the SCH. >That looks like an nice patch to me. Before merging it, I'd like to get >Jacob's view on it though. Jacob, does moving the SCH SMBus driver to a >platform one look fine to you ? > [[JPAN]] i agree with merging gpio and smbus into lpc driver. the only question i had was whether impact to the user space tools has been considered. iirc, there are sensors detect tools probe pci bus for smbus controllers, not sure it does that for platform bus. ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge 2010-02-16 13:59 ` Pan, Jacob jun (?) @ 2010-02-16 15:45 ` Jean Delvare 2010-02-16 17:19 ` Pan, Jacob jun -1 siblings, 1 reply; 73+ messages in thread From: Jean Delvare @ 2010-02-16 15:45 UTC (permalink / raw) To: Pan, Jacob jun Cc: Samuel Ortiz, Denis Turischev, LKML, David Brownell, linux-i2c On Tue, 16 Feb 2010 05:59:34 -0800, Pan, Jacob jun wrote: > > > > >On Thu, Feb 11, 2010 at 12:26:19PM +0200, Denis Turischev wrote: > >> Intel Poulsbo (SCH) chipset LPC bridge controller contains several > >> functions. Creating and MFD driver for the LPC bridge controller allows > >> simultaneous use of SMBus and GPIO interfaces on the SCH. > >That looks like an nice patch to me. Before merging it, I'd like to get > >Jacob's view on it though. Jacob, does moving the SCH SMBus driver to a > >platform one look fine to you ? > > > [[JPAN]] i agree with merging gpio and smbus into lpc driver. the only question > i had was whether impact to the user space tools has been considered. iirc, > there are sensors detect tools probe pci bus for smbus controllers, not sure it > does that for platform bus. That shouldn't be a problem. The PCI device is still present, so sensors-detect will see it. Then it will load the required driver, and that driver will instantiate i2c adapters. The script then probes all i2c adapters regardless of who created them, so the exact driver implementation doesn't matter. -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* RE: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 17:19 ` Pan, Jacob jun 0 siblings, 0 replies; 73+ messages in thread From: Pan, Jacob jun @ 2010-02-16 17:19 UTC (permalink / raw) To: Jean Delvare Cc: Samuel Ortiz, Denis Turischev, LKML, David Brownell, linux-i2c >> >On Thu, Feb 11, 2010 at 12:26:19PM +0200, Denis Turischev wrote: >> >> Intel Poulsbo (SCH) chipset LPC bridge controller contains several >> >> functions. Creating and MFD driver for the LPC bridge controller allows >> >> simultaneous use of SMBus and GPIO interfaces on the SCH. >> >That looks like an nice patch to me. Before merging it, I'd like to get >> >Jacob's view on it though. Jacob, does moving the SCH SMBus driver to a >> >platform one look fine to you ? >> > >> [[JPAN]] i agree with merging gpio and smbus into lpc driver. the only >question >> i had was whether impact to the user space tools has been considered. iirc, >> there are sensors detect tools probe pci bus for smbus controllers, not sure >it >> does that for platform bus. > >That shouldn't be a problem. The PCI device is still present, so >sensors-detect will see it. Then it will load the required driver, and >that driver will instantiate i2c adapters. The script then probes all >i2c adapters regardless of who created them, so the exact driver >implementation doesn't matter. > [[JPAN]] thanks for explaining it, all made sense to me. looking at sensors-detect, it will still load isch driver for the same pci id. but how would it know it depends on the new lpc driver to set up resources? i can't see shared symbols. }, { vendid => 0x8086, devid => 0x8119, procid => "Intel SCH", driver => "i2c-isch", }, ^ permalink raw reply [flat|nested] 73+ messages in thread
* RE: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 17:19 ` Pan, Jacob jun 0 siblings, 0 replies; 73+ messages in thread From: Pan, Jacob jun @ 2010-02-16 17:19 UTC (permalink / raw) To: Jean Delvare Cc: Samuel Ortiz, Denis Turischev, LKML, David Brownell, linux-i2c-u79uwXL29TY76Z2rM5mHXA >> >On Thu, Feb 11, 2010 at 12:26:19PM +0200, Denis Turischev wrote: >> >> Intel Poulsbo (SCH) chipset LPC bridge controller contains several >> >> functions. Creating and MFD driver for the LPC bridge controller allows >> >> simultaneous use of SMBus and GPIO interfaces on the SCH. >> >That looks like an nice patch to me. Before merging it, I'd like to get >> >Jacob's view on it though. Jacob, does moving the SCH SMBus driver to a >> >platform one look fine to you ? >> > >> [[JPAN]] i agree with merging gpio and smbus into lpc driver. the only >question >> i had was whether impact to the user space tools has been considered. iirc, >> there are sensors detect tools probe pci bus for smbus controllers, not sure >it >> does that for platform bus. > >That shouldn't be a problem. The PCI device is still present, so >sensors-detect will see it. Then it will load the required driver, and >that driver will instantiate i2c adapters. The script then probes all >i2c adapters regardless of who created them, so the exact driver >implementation doesn't matter. > [[JPAN]] thanks for explaining it, all made sense to me. looking at sensors-detect, it will still load isch driver for the same pci id. but how would it know it depends on the new lpc driver to set up resources? i can't see shared symbols. }, { vendid => 0x8086, devid => 0x8119, procid => "Intel SCH", driver => "i2c-isch", }, ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 17:29 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-16 17:29 UTC (permalink / raw) To: Pan, Jacob jun Cc: Samuel Ortiz, Denis Turischev, LKML, David Brownell, linux-i2c On Tue, 16 Feb 2010 09:19:58 -0800, Pan, Jacob jun wrote: > >That shouldn't be a problem. The PCI device is still present, so > >sensors-detect will see it. Then it will load the required driver, and > >that driver will instantiate i2c adapters. The script then probes all > >i2c adapters regardless of who created them, so the exact driver > >implementation doesn't matter. > > > [[JPAN]] thanks for explaining it, all made sense to me. looking at > sensors-detect, it will still load isch driver for the same pci id. > but how would it know it depends on the new lpc driver to set up resources? > i can't see shared symbols. > > }, { > vendid => 0x8086, > devid => 0x8119, > procid => "Intel SCH", > driver => "i2c-isch", > }, On systems with udev, I would expect the mfd driver to load automatically through module aliases, so this should be OK. Actually, even i2c-isch should load automatically if we setup proper aliases for the platform devices it instantiates. For other systems, indeed, the mfd driver won't load in the absence of a shared symbol. Might be worth adding request_module() call in platform drivers? If this isn't acceptable for whatever reason, I can certainly hack sensors-detect to treat this uncommon case properly, but solving this problem at the application level seems wrong. -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 17:29 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-16 17:29 UTC (permalink / raw) To: Pan, Jacob jun Cc: Samuel Ortiz, Denis Turischev, LKML, David Brownell, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Tue, 16 Feb 2010 09:19:58 -0800, Pan, Jacob jun wrote: > >That shouldn't be a problem. The PCI device is still present, so > >sensors-detect will see it. Then it will load the required driver, and > >that driver will instantiate i2c adapters. The script then probes all > >i2c adapters regardless of who created them, so the exact driver > >implementation doesn't matter. > > > [[JPAN]] thanks for explaining it, all made sense to me. looking at > sensors-detect, it will still load isch driver for the same pci id. > but how would it know it depends on the new lpc driver to set up resources? > i can't see shared symbols. > > }, { > vendid => 0x8086, > devid => 0x8119, > procid => "Intel SCH", > driver => "i2c-isch", > }, On systems with udev, I would expect the mfd driver to load automatically through module aliases, so this should be OK. Actually, even i2c-isch should load automatically if we setup proper aliases for the platform devices it instantiates. For other systems, indeed, the mfd driver won't load in the absence of a shared symbol. Might be worth adding request_module() call in platform drivers? If this isn't acceptable for whatever reason, I can certainly hack sensors-detect to treat this uncommon case properly, but solving this problem at the application level seems wrong. -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 19:57 ` David Brownell 0 siblings, 0 replies; 73+ messages in thread From: David Brownell @ 2010-02-16 19:57 UTC (permalink / raw) To: Denis Turischev; +Cc: LKML, Samuel Ortiz, Jean Delvare, linux-i2c On Thursday 11 February 2010, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows Spelling nit: "Creating an" (not and). Keyboard, brain, or edit fault. ;) > simultaneous use of SMBus and GPIO interfaces on the SCH. This looks like the right way to package such southbridge level componentry. Maye not just these two interfaces, either. But ... how does this play with ACPI? The last several Intel systems I looked at seemed to expect ACPI to manage GPIOs and the IRQs they may issue. (He wrote, staring at an ICH8-system where ACPI uses GPIOs to manage several buttons and LEDs.) It would seem error-prone to ignore that coupling on systems with ACPI. Linux has enough trouble sorting out issues caused by buggy AML (ACPI bytecode) without introducing conflicts in who manages which hardware resource (ACPI vs. operating system). Of course, if ACPI weren't being used to hide such board-specific details from operating systems, such issues would not exist. But such hiding is one of the basic goals of ACPI ... annoying. ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 19:57 ` David Brownell 0 siblings, 0 replies; 73+ messages in thread From: David Brownell @ 2010-02-16 19:57 UTC (permalink / raw) To: Denis Turischev Cc: LKML, Samuel Ortiz, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Thursday 11 February 2010, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows Spelling nit: "Creating an" (not and). Keyboard, brain, or edit fault. ;) > simultaneous use of SMBus and GPIO interfaces on the SCH. This looks like the right way to package such southbridge level componentry. Maye not just these two interfaces, either. But ... how does this play with ACPI? The last several Intel systems I looked at seemed to expect ACPI to manage GPIOs and the IRQs they may issue. (He wrote, staring at an ICH8-system where ACPI uses GPIOs to manage several buttons and LEDs.) It would seem error-prone to ignore that coupling on systems with ACPI. Linux has enough trouble sorting out issues caused by buggy AML (ACPI bytecode) without introducing conflicts in who manages which hardware resource (ACPI vs. operating system). Of course, if ACPI weren't being used to hide such board-specific details from operating systems, such issues would not exist. But such hiding is one of the basic goals of ACPI ... annoying. ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 21:49 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-16 21:49 UTC (permalink / raw) To: David Brownell; +Cc: Denis Turischev, LKML, Samuel Ortiz, linux-i2c On Tue, 16 Feb 2010 11:57:46 -0800, David Brownell wrote: > On Thursday 11 February 2010, Denis Turischev wrote: > > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > > functions. Creating and MFD driver for the LPC bridge controller allows > > Spelling nit: "Creating an" (not and). Keyboard, brain, or edit fault. ;) > > > > simultaneous use of SMBus and GPIO interfaces on the SCH. > > This looks like the right way to package such southbridge level > componentry. Maye not just these two interfaces, either. > > But ... how does this play with ACPI? The last several Intel > systems I looked at seemed to expect ACPI to manage GPIOs and the > IRQs they may issue. (He wrote, staring at an ICH8-system where > ACPI uses GPIOs to manage several buttons and LEDs.) > > It would seem error-prone to ignore that coupling on systems > with ACPI. Linux has enough trouble sorting out issues caused > by buggy AML (ACPI bytecode) without introducing conflicts in > who manages which hardware resource (ACPI vs. operating system). Might be a good idea to use acpi_check_resource_conflict() or similar before instantiating the platform devices. > Of course, if ACPI weren't being used to hide such board-specific > details from operating systems, such issues would not exist. But > such hiding is one of the basic goals of ACPI ... annoying. Don't start me on this :( -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-16 21:49 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-16 21:49 UTC (permalink / raw) To: David Brownell Cc: Denis Turischev, LKML, Samuel Ortiz, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Tue, 16 Feb 2010 11:57:46 -0800, David Brownell wrote: > On Thursday 11 February 2010, Denis Turischev wrote: > > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > > functions. Creating and MFD driver for the LPC bridge controller allows > > Spelling nit: "Creating an" (not and). Keyboard, brain, or edit fault. ;) > > > > simultaneous use of SMBus and GPIO interfaces on the SCH. > > This looks like the right way to package such southbridge level > componentry. Maye not just these two interfaces, either. > > But ... how does this play with ACPI? The last several Intel > systems I looked at seemed to expect ACPI to manage GPIOs and the > IRQs they may issue. (He wrote, staring at an ICH8-system where > ACPI uses GPIOs to manage several buttons and LEDs.) > > It would seem error-prone to ignore that coupling on systems > with ACPI. Linux has enough trouble sorting out issues caused > by buggy AML (ACPI bytecode) without introducing conflicts in > who manages which hardware resource (ACPI vs. operating system). Might be a good idea to use acpi_check_resource_conflict() or similar before instantiating the platform devices. > Of course, if ACPI weren't being used to hide such board-specific > details from operating systems, such issues would not exist. But > such hiding is one of the basic goals of ACPI ... annoying. Don't start me on this :( -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-17 10:03 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-17 10:03 UTC (permalink / raw) To: Jean Delvare; +Cc: David Brownell, LKML, Samuel Ortiz, linux-i2c Jean Delvare wrote: > On Tue, 16 Feb 2010 11:57:46 -0800, David Brownell wrote: >> On Thursday 11 February 2010, Denis Turischev wrote: >>> Intel Poulsbo (SCH) chipset LPC bridge controller contains several >>> functions. Creating and MFD driver for the LPC bridge controller allows >> Spelling nit: "Creating an" (not and). Keyboard, brain, or edit fault. ;) >> >> >>> simultaneous use of SMBus and GPIO interfaces on the SCH. >> This looks like the right way to package such southbridge level >> componentry. Maye not just these two interfaces, either. >> >> But ... how does this play with ACPI? The last several Intel >> systems I looked at seemed to expect ACPI to manage GPIOs and the >> IRQs they may issue. (He wrote, staring at an ICH8-system where >> ACPI uses GPIOs to manage several buttons and LEDs.) >> >> It would seem error-prone to ignore that coupling on systems >> with ACPI. Linux has enough trouble sorting out issues caused >> by buggy AML (ACPI bytecode) without introducing conflicts in >> who manages which hardware resource (ACPI vs. operating system). > > Might be a good idea to use acpi_check_resource_conflict() or similar > before instantiating the platform devices. May be it worth to add such resource check directly to mfd_add_device function? > >> Of course, if ACPI weren't being used to hide such board-specific >> details from operating systems, such issues would not exist. But >> such hiding is one of the basic goals of ACPI ... annoying. > > Don't start me on this :( > ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-17 10:03 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-17 10:03 UTC (permalink / raw) To: Jean Delvare Cc: David Brownell, LKML, Samuel Ortiz, linux-i2c-u79uwXL29TY76Z2rM5mHXA Jean Delvare wrote: > On Tue, 16 Feb 2010 11:57:46 -0800, David Brownell wrote: >> On Thursday 11 February 2010, Denis Turischev wrote: >>> Intel Poulsbo (SCH) chipset LPC bridge controller contains several >>> functions. Creating and MFD driver for the LPC bridge controller allows >> Spelling nit: "Creating an" (not and). Keyboard, brain, or edit fault. ;) >> >> >>> simultaneous use of SMBus and GPIO interfaces on the SCH. >> This looks like the right way to package such southbridge level >> componentry. Maye not just these two interfaces, either. >> >> But ... how does this play with ACPI? The last several Intel >> systems I looked at seemed to expect ACPI to manage GPIOs and the >> IRQs they may issue. (He wrote, staring at an ICH8-system where >> ACPI uses GPIOs to manage several buttons and LEDs.) >> >> It would seem error-prone to ignore that coupling on systems >> with ACPI. Linux has enough trouble sorting out issues caused >> by buggy AML (ACPI bytecode) without introducing conflicts in >> who manages which hardware resource (ACPI vs. operating system). > > Might be a good idea to use acpi_check_resource_conflict() or similar > before instantiating the platform devices. May be it worth to add such resource check directly to mfd_add_device function? > >> Of course, if ACPI weren't being used to hide such board-specific >> details from operating systems, such issues would not exist. But >> such hiding is one of the basic goals of ACPI ... annoying. > > Don't start me on this :( > ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-17 10:44 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-17 10:44 UTC (permalink / raw) To: Denis Turischev; +Cc: David Brownell, LKML, Samuel Ortiz, linux-i2c On Wed, 17 Feb 2010 12:03:17 +0200, Denis Turischev wrote: > Jean Delvare wrote: > > Might be a good idea to use acpi_check_resource_conflict() or similar > > before instantiating the platform devices. > > May be it worth to add such resource check directly to mfd_add_device function? I'm not sure. I suspect that many MFD devices are never used on ACPI-aware systems, so it might be considered overkill. OTOH the calls resolve to empty stubs when ACPI is disabled so... I have no objection, but I'll leave the decision to somebody else ;) -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-17 10:44 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-17 10:44 UTC (permalink / raw) To: Denis Turischev Cc: David Brownell, LKML, Samuel Ortiz, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Wed, 17 Feb 2010 12:03:17 +0200, Denis Turischev wrote: > Jean Delvare wrote: > > Might be a good idea to use acpi_check_resource_conflict() or similar > > before instantiating the platform devices. > > May be it worth to add such resource check directly to mfd_add_device function? I'm not sure. I suspect that many MFD devices are never used on ACPI-aware systems, so it might be considered overkill. OTOH the calls resolve to empty stubs when ACPI is disabled so... I have no objection, but I'll leave the decision to somebody else ;) -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-17 12:35 ` Mike Rapoport 0 siblings, 0 replies; 73+ messages in thread From: Mike Rapoport @ 2010-02-17 12:35 UTC (permalink / raw) To: Jean Delvare, Samuel Ortiz Cc: Denis Turischev, David Brownell, LKML, linux-i2c Samuel, Jean Delvare wrote: > On Wed, 17 Feb 2010 12:03:17 +0200, Denis Turischev wrote: >> Jean Delvare wrote: >>> Might be a good idea to use acpi_check_resource_conflict() or similar >>> before instantiating the platform devices. >> May be it worth to add such resource check directly to mfd_add_device function? > > I'm not sure. I suspect that many MFD devices are never used on > ACPI-aware systems, so it might be considered overkill. OTOH the calls > resolve to empty stubs when ACPI is disabled so... I have no objection, > but I'll leave the decision to somebody else ;) > What do you think? Shall we add something like mfd_verify_resources that will call acpi_check_region or something similar? -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-17 12:35 ` Mike Rapoport 0 siblings, 0 replies; 73+ messages in thread From: Mike Rapoport @ 2010-02-17 12:35 UTC (permalink / raw) To: Jean Delvare, Samuel Ortiz Cc: Denis Turischev, David Brownell, LKML, linux-i2c-u79uwXL29TY76Z2rM5mHXA Samuel, Jean Delvare wrote: > On Wed, 17 Feb 2010 12:03:17 +0200, Denis Turischev wrote: >> Jean Delvare wrote: >>> Might be a good idea to use acpi_check_resource_conflict() or similar >>> before instantiating the platform devices. >> May be it worth to add such resource check directly to mfd_add_device function? > > I'm not sure. I suspect that many MFD devices are never used on > ACPI-aware systems, so it might be considered overkill. OTOH the calls > resolve to empty stubs when ACPI is disabled so... I have no objection, > but I'll leave the decision to somebody else ;) > What do you think? Shall we add something like mfd_verify_resources that will call acpi_check_region or something similar? -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-17 14:37 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-17 14:37 UTC (permalink / raw) To: Mike Rapoport Cc: Jean Delvare, Denis Turischev, David Brownell, LKML, linux-i2c Hi Mike, On Wed, Feb 17, 2010 at 02:35:30PM +0200, Mike Rapoport wrote: > Samuel, > > Jean Delvare wrote: > > On Wed, 17 Feb 2010 12:03:17 +0200, Denis Turischev wrote: > >> Jean Delvare wrote: > >>> Might be a good idea to use acpi_check_resource_conflict() or similar > >>> before instantiating the platform devices. > >> May be it worth to add such resource check directly to mfd_add_device function? > > > > I'm not sure. I suspect that many MFD devices are never used on > > ACPI-aware systems, so it might be considered overkill. OTOH the calls > > resolve to empty stubs when ACPI is disabled so... I have no objection, > > but I'll leave the decision to somebody else ;) > > > > What do you think? Shall we add something like mfd_verify_resources that will call > acpi_check_region or something similar? Yes, that sounds like a reasonable idea. We should probably call acpi_check_resource_conflict() straight from mfd_add_device(). I'll do that, no need for Denis to add that patch for its code to be merged. Cheers, Samuel. > > -- > Sincerely yours, > Mike. -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-17 14:37 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-17 14:37 UTC (permalink / raw) To: Mike Rapoport Cc: Jean Delvare, Denis Turischev, David Brownell, LKML, linux-i2c-u79uwXL29TY76Z2rM5mHXA Hi Mike, On Wed, Feb 17, 2010 at 02:35:30PM +0200, Mike Rapoport wrote: > Samuel, > > Jean Delvare wrote: > > On Wed, 17 Feb 2010 12:03:17 +0200, Denis Turischev wrote: > >> Jean Delvare wrote: > >>> Might be a good idea to use acpi_check_resource_conflict() or similar > >>> before instantiating the platform devices. > >> May be it worth to add such resource check directly to mfd_add_device function? > > > > I'm not sure. I suspect that many MFD devices are never used on > > ACPI-aware systems, so it might be considered overkill. OTOH the calls > > resolve to empty stubs when ACPI is disabled so... I have no objection, > > but I'll leave the decision to somebody else ;) > > > > What do you think? Shall we add something like mfd_verify_resources that will call > acpi_check_region or something similar? Yes, that sounds like a reasonable idea. We should probably call acpi_check_resource_conflict() straight from mfd_add_device(). I'll do that, no need for Denis to add that patch for its code to be merged. Cheers, Samuel. > > -- > Sincerely yours, > Mike. -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v2 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-18 17:42 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-18 17:42 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c Intel Poulsbo (SCH) chipset LPC bridge controller contains several functions. Creating and MFD driver for the LPC bridge controller allows simultaneous use of SMBus and GPIO interfaces on the SCH. v2 version contains "select MFD_CORE" line. Signed-off-by: Denis Turischev <denis@compulab.co.il> diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 19:32:01.000000000 +0200 @@ -348,6 +348,15 @@ read/write functions for the devices to get access to this chip. This chip embeds various other multimedia funtionalities as well. +config LPC_SCH + tristate "Intel SCH LPC" + default m + depends on PCI + select MFD_CORE + help + LPC bridge function of the Intel SCH provides support for + System Management Bus and General Purpose I/O. + endmenu menu "Multimedia Capabilities Port drivers" diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 @@ -0,0 +1,133 @@ +/* + * lpc_sch.c - LPC interface for Intel Poulsbo SCH + * + * LPC bridge function of the Intel SCH contains many other + * functional units, such as Interrupt controllers, Timers, + * Power Management, System Management, GPIO, RTC, and LPC + * Configuration Registers. + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis@compulab.co.il> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/pci.h> +#include <linux/mfd/core.h> + +#define SMBASE 0x40 +#define SMBUS_IO_SIZE 64 + +#define GPIOBASE 0x44 +#define GPIO_IO_SIZE 64 + +static struct resource smbus_sch_resource = { + .flags = IORESOURCE_IO, +}; + + +static struct resource gpio_sch_resource = { + .flags = IORESOURCE_IO, +}; + +static struct mfd_cell lpc_sch_cells[] = { + { + .name = "isch_smbus", + .num_resources = 1, + .resources = &smbus_sch_resource, + }, + { + .name = "sch_gpio", + .num_resources = 1, + .resources = &gpio_sch_resource, + }, +}; + +static struct pci_device_id lpc_sch_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); + +static int __devinit lpc_sch_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + unsigned int base_addr_cfg; + unsigned short base_addr; + + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); + return -ENODEV; + } + + smbus_sch_resource.start = base_addr; + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; + + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); + return -ENODEV; + } + + gpio_sch_resource.start = base_addr; + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; + + return mfd_add_devices(&dev->dev, -1, + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); +} + +static void __devexit lpc_sch_remove(struct pci_dev *dev) +{ + mfd_remove_devices(&dev->dev); +} + +static struct pci_driver lpc_sch_driver = { + .name = "lpc_sch", + .id_table = lpc_sch_ids, + .probe = lpc_sch_probe, + .remove = __devexit_p(lpc_sch_remove), +}; + +static int __init lpc_sch_init(void) +{ + return pci_register_driver(&lpc_sch_driver); +} + +static void __exit lpc_sch_exit(void) +{ + pci_unregister_driver(&lpc_sch_driver); +} + +module_init(lpc_sch_init); +module_exit(lpc_sch_exit); + +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 @@ -55,4 +55,5 @@ obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o obj-$(CONFIG_AB4500_CORE) += ab4500-core.o obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o \ No newline at end of file +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o +obj-$(CONFIG_LPC_SCH) += lpc_sch.o ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v2 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-18 17:42 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-18 17:42 UTC (permalink / raw) To: LKML Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA Intel Poulsbo (SCH) chipset LPC bridge controller contains several functions. Creating and MFD driver for the LPC bridge controller allows simultaneous use of SMBus and GPIO interfaces on the SCH. v2 version contains "select MFD_CORE" line. Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 19:32:01.000000000 +0200 @@ -348,6 +348,15 @@ read/write functions for the devices to get access to this chip. This chip embeds various other multimedia funtionalities as well. +config LPC_SCH + tristate "Intel SCH LPC" + default m + depends on PCI + select MFD_CORE + help + LPC bridge function of the Intel SCH provides support for + System Management Bus and General Purpose I/O. + endmenu menu "Multimedia Capabilities Port drivers" diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 @@ -0,0 +1,133 @@ +/* + * lpc_sch.c - LPC interface for Intel Poulsbo SCH + * + * LPC bridge function of the Intel SCH contains many other + * functional units, such as Interrupt controllers, Timers, + * Power Management, System Management, GPIO, RTC, and LPC + * Configuration Registers. + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/pci.h> +#include <linux/mfd/core.h> + +#define SMBASE 0x40 +#define SMBUS_IO_SIZE 64 + +#define GPIOBASE 0x44 +#define GPIO_IO_SIZE 64 + +static struct resource smbus_sch_resource = { + .flags = IORESOURCE_IO, +}; + + +static struct resource gpio_sch_resource = { + .flags = IORESOURCE_IO, +}; + +static struct mfd_cell lpc_sch_cells[] = { + { + .name = "isch_smbus", + .num_resources = 1, + .resources = &smbus_sch_resource, + }, + { + .name = "sch_gpio", + .num_resources = 1, + .resources = &gpio_sch_resource, + }, +}; + +static struct pci_device_id lpc_sch_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); + +static int __devinit lpc_sch_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + unsigned int base_addr_cfg; + unsigned short base_addr; + + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); + return -ENODEV; + } + + smbus_sch_resource.start = base_addr; + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; + + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); + return -ENODEV; + } + + gpio_sch_resource.start = base_addr; + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; + + return mfd_add_devices(&dev->dev, -1, + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); +} + +static void __devexit lpc_sch_remove(struct pci_dev *dev) +{ + mfd_remove_devices(&dev->dev); +} + +static struct pci_driver lpc_sch_driver = { + .name = "lpc_sch", + .id_table = lpc_sch_ids, + .probe = lpc_sch_probe, + .remove = __devexit_p(lpc_sch_remove), +}; + +static int __init lpc_sch_init(void) +{ + return pci_register_driver(&lpc_sch_driver); +} + +static void __exit lpc_sch_exit(void) +{ + pci_unregister_driver(&lpc_sch_driver); +} + +module_init(lpc_sch_init); +module_exit(lpc_sch_exit); + +MODULE_AUTHOR("Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>"); +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 @@ -55,4 +55,5 @@ obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o obj-$(CONFIG_AB4500_CORE) += ab4500-core.o obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o \ No newline at end of file +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o +obj-$(CONFIG_LPC_SCH) += lpc_sch.o ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v2 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-18 17:45 ` Randy Dunlap 0 siblings, 0 replies; 73+ messages in thread From: Randy Dunlap @ 2010-02-18 17:45 UTC (permalink / raw) To: Denis Turischev Cc: LKML, Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c On 02/18/10 09:42, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. > > v2 version contains "select MFD_CORE" line. > > Signed-off-by: Denis Turischev <denis@compulab.co.il> > > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig > linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 > 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 > 19:32:01.000000000 +0200 > @@ -348,6 +348,15 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + default m Please don't default random modules to be enabled/built. That could be done via defconfig .. if at all. > + depends on PCI > + select MFD_CORE > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" -- ~Randy ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v2 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-18 17:45 ` Randy Dunlap 0 siblings, 0 replies; 73+ messages in thread From: Randy Dunlap @ 2010-02-18 17:45 UTC (permalink / raw) To: Denis Turischev Cc: LKML, Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA On 02/18/10 09:42, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. > > v2 version contains "select MFD_CORE" line. > > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig > linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 > 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 > 19:32:01.000000000 +0200 > @@ -348,6 +348,15 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + default m Please don't default random modules to be enabled/built. That could be done via defconfig .. if at all. > + depends on PCI > + select MFD_CORE > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" -- ~Randy ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-18 18:01 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-18 18:01 UTC (permalink / raw) To: LKML; +Cc: Randy Dunlap, Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c Intel Poulsbo (SCH) chipset LPC bridge controller contains several functions. Creating and MFD driver for the LPC bridge controller allows simultaneous use of SMBus and GPIO interfaces on the SCH. v2: added "select MFD_CORE" v3: removed "default m" Signed-off-by: Denis Turischev <denis@compulab.co.il> diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 19:56:19.000000000 +0200 @@ -348,6 +348,14 @@ read/write functions for the devices to get access to this chip. This chip embeds various other multimedia funtionalities as well. +config LPC_SCH + tristate "Intel SCH LPC" + depends on PCI + select MFD_CORE + help + LPC bridge function of the Intel SCH provides support for + System Management Bus and General Purpose I/O. + endmenu menu "Multimedia Capabilities Port drivers" diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 @@ -0,0 +1,133 @@ +/* + * lpc_sch.c - LPC interface for Intel Poulsbo SCH + * + * LPC bridge function of the Intel SCH contains many other + * functional units, such as Interrupt controllers, Timers, + * Power Management, System Management, GPIO, RTC, and LPC + * Configuration Registers. + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis@compulab.co.il> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/pci.h> +#include <linux/mfd/core.h> + +#define SMBASE 0x40 +#define SMBUS_IO_SIZE 64 + +#define GPIOBASE 0x44 +#define GPIO_IO_SIZE 64 + +static struct resource smbus_sch_resource = { + .flags = IORESOURCE_IO, +}; + + +static struct resource gpio_sch_resource = { + .flags = IORESOURCE_IO, +}; + +static struct mfd_cell lpc_sch_cells[] = { + { + .name = "isch_smbus", + .num_resources = 1, + .resources = &smbus_sch_resource, + }, + { + .name = "sch_gpio", + .num_resources = 1, + .resources = &gpio_sch_resource, + }, +}; + +static struct pci_device_id lpc_sch_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); + +static int __devinit lpc_sch_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + unsigned int base_addr_cfg; + unsigned short base_addr; + + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); + return -ENODEV; + } + + smbus_sch_resource.start = base_addr; + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; + + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); + return -ENODEV; + } + + gpio_sch_resource.start = base_addr; + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; + + return mfd_add_devices(&dev->dev, -1, + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); +} + +static void __devexit lpc_sch_remove(struct pci_dev *dev) +{ + mfd_remove_devices(&dev->dev); +} + +static struct pci_driver lpc_sch_driver = { + .name = "lpc_sch", + .id_table = lpc_sch_ids, + .probe = lpc_sch_probe, + .remove = __devexit_p(lpc_sch_remove), +}; + +static int __init lpc_sch_init(void) +{ + return pci_register_driver(&lpc_sch_driver); +} + +static void __exit lpc_sch_exit(void) +{ + pci_unregister_driver(&lpc_sch_driver); +} + +module_init(lpc_sch_init); +module_exit(lpc_sch_exit); + +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 @@ -55,4 +55,5 @@ obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o obj-$(CONFIG_AB4500_CORE) += ab4500-core.o obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o \ No newline at end of file +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o +obj-$(CONFIG_LPC_SCH) += lpc_sch.o ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-18 18:01 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-18 18:01 UTC (permalink / raw) To: LKML Cc: Randy Dunlap, Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA Intel Poulsbo (SCH) chipset LPC bridge controller contains several functions. Creating and MFD driver for the LPC bridge controller allows simultaneous use of SMBus and GPIO interfaces on the SCH. v2: added "select MFD_CORE" v3: removed "default m" Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 19:56:19.000000000 +0200 @@ -348,6 +348,14 @@ read/write functions for the devices to get access to this chip. This chip embeds various other multimedia funtionalities as well. +config LPC_SCH + tristate "Intel SCH LPC" + depends on PCI + select MFD_CORE + help + LPC bridge function of the Intel SCH provides support for + System Management Bus and General Purpose I/O. + endmenu menu "Multimedia Capabilities Port drivers" diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 @@ -0,0 +1,133 @@ +/* + * lpc_sch.c - LPC interface for Intel Poulsbo SCH + * + * LPC bridge function of the Intel SCH contains many other + * functional units, such as Interrupt controllers, Timers, + * Power Management, System Management, GPIO, RTC, and LPC + * Configuration Registers. + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/pci.h> +#include <linux/mfd/core.h> + +#define SMBASE 0x40 +#define SMBUS_IO_SIZE 64 + +#define GPIOBASE 0x44 +#define GPIO_IO_SIZE 64 + +static struct resource smbus_sch_resource = { + .flags = IORESOURCE_IO, +}; + + +static struct resource gpio_sch_resource = { + .flags = IORESOURCE_IO, +}; + +static struct mfd_cell lpc_sch_cells[] = { + { + .name = "isch_smbus", + .num_resources = 1, + .resources = &smbus_sch_resource, + }, + { + .name = "sch_gpio", + .num_resources = 1, + .resources = &gpio_sch_resource, + }, +}; + +static struct pci_device_id lpc_sch_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); + +static int __devinit lpc_sch_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + unsigned int base_addr_cfg; + unsigned short base_addr; + + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); + return -ENODEV; + } + + smbus_sch_resource.start = base_addr; + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; + + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); + if (!(base_addr_cfg & (1 << 31))) { + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); + return -ENODEV; + } + base_addr = (unsigned short)base_addr_cfg; + if (base_addr == 0) { + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); + return -ENODEV; + } + + gpio_sch_resource.start = base_addr; + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; + + return mfd_add_devices(&dev->dev, -1, + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); +} + +static void __devexit lpc_sch_remove(struct pci_dev *dev) +{ + mfd_remove_devices(&dev->dev); +} + +static struct pci_driver lpc_sch_driver = { + .name = "lpc_sch", + .id_table = lpc_sch_ids, + .probe = lpc_sch_probe, + .remove = __devexit_p(lpc_sch_remove), +}; + +static int __init lpc_sch_init(void) +{ + return pci_register_driver(&lpc_sch_driver); +} + +static void __exit lpc_sch_exit(void) +{ + pci_unregister_driver(&lpc_sch_driver); +} + +module_init(lpc_sch_init); +module_exit(lpc_sch_exit); + +MODULE_AUTHOR("Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>"); +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 @@ -55,4 +55,5 @@ obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o obj-$(CONFIG_AB4500_CORE) += ab4500-core.o obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o \ No newline at end of file +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o +obj-$(CONFIG_LPC_SCH) += lpc_sch.o ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-18 18:08 ` Randy Dunlap 0 siblings, 0 replies; 73+ messages in thread From: Randy Dunlap @ 2010-02-18 18:08 UTC (permalink / raw) To: Denis Turischev Cc: LKML, Randy Dunlap, Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c On 02/18/10 10:01, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. > > v2: added "select MFD_CORE" > v3: removed "default m" Thanks. > Signed-off-by: Denis Turischev <denis@compulab.co.il> > > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig > linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 > 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 > 19:56:19.000000000 +0200 > @@ -348,6 +348,14 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + depends on PCI > + select MFD_CORE > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" -- ~Randy ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-18 18:08 ` Randy Dunlap 0 siblings, 0 replies; 73+ messages in thread From: Randy Dunlap @ 2010-02-18 18:08 UTC (permalink / raw) To: Denis Turischev Cc: LKML, Randy Dunlap, Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA On 02/18/10 10:01, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. > > v2: added "select MFD_CORE" > v3: removed "default m" Thanks. > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig > linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 > 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 > 19:56:19.000000000 +0200 > @@ -348,6 +348,14 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + depends on PCI > + select MFD_CORE > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" -- ~Randy ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-19 10:30 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-19 10:30 UTC (permalink / raw) To: Denis Turischev Cc: LKML, Randy Dunlap, David Brownell, Jean Delvare, linux-i2c Hi Denis, On Thu, Feb 18, 2010 at 08:01:33PM +0200, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. > > v2: added "select MFD_CORE" > v3: removed "default m" > > Signed-off-by: Denis Turischev <denis@compulab.co.il> patch applied, many thanks. Cheers, Samuel. > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 19:56:19.000000000 +0200 > @@ -348,6 +348,14 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + depends on PCI > + select MFD_CORE > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c > --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 > @@ -0,0 +1,133 @@ > +/* > + * lpc_sch.c - LPC interface for Intel Poulsbo SCH > + * > + * LPC bridge function of the Intel SCH contains many other > + * functional units, such as Interrupt controllers, Timers, > + * Power Management, System Management, GPIO, RTC, and LPC > + * Configuration Registers. > + * > + * Copyright (c) 2010 CompuLab Ltd > + * Author: Denis Turischev <denis@compulab.co.il> > + * > + * 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. > + */ > + > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/errno.h> > +#include <linux/acpi.h> > +#include <linux/pci.h> > +#include <linux/mfd/core.h> > + > +#define SMBASE 0x40 > +#define SMBUS_IO_SIZE 64 > + > +#define GPIOBASE 0x44 > +#define GPIO_IO_SIZE 64 > + > +static struct resource smbus_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > + > +static struct resource gpio_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > +static struct mfd_cell lpc_sch_cells[] = { > + { > + .name = "isch_smbus", > + .num_resources = 1, > + .resources = &smbus_sch_resource, > + }, > + { > + .name = "sch_gpio", > + .num_resources = 1, > + .resources = &gpio_sch_resource, > + }, > +}; > + > +static struct pci_device_id lpc_sch_ids[] = { > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > + { 0, } > +}; > +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); > + > +static int __devinit lpc_sch_probe(struct pci_dev *dev, > + const struct pci_device_id *id) > +{ > + unsigned int base_addr_cfg; > + unsigned short base_addr; > + > + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); > + return -ENODEV; > + } > + > + smbus_sch_resource.start = base_addr; > + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; > + > + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); > + return -ENODEV; > + } > + > + gpio_sch_resource.start = base_addr; > + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; > + > + return mfd_add_devices(&dev->dev, -1, > + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); > +} > + > +static void __devexit lpc_sch_remove(struct pci_dev *dev) > +{ > + mfd_remove_devices(&dev->dev); > +} > + > +static struct pci_driver lpc_sch_driver = { > + .name = "lpc_sch", > + .id_table = lpc_sch_ids, > + .probe = lpc_sch_probe, > + .remove = __devexit_p(lpc_sch_remove), > +}; > + > +static int __init lpc_sch_init(void) > +{ > + return pci_register_driver(&lpc_sch_driver); > +} > + > +static void __exit lpc_sch_exit(void) > +{ > + pci_unregister_driver(&lpc_sch_driver); > +} > + > +module_init(lpc_sch_init); > +module_exit(lpc_sch_exit); > + > +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); > +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); > +MODULE_LICENSE("GPL"); > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile > --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 > @@ -55,4 +55,5 @@ > obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o > obj-$(CONFIG_AB4500_CORE) += ab4500-core.o > obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o > -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > \ No newline at end of file > +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > +obj-$(CONFIG_LPC_SCH) += lpc_sch.o -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-19 10:30 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-19 10:30 UTC (permalink / raw) To: Denis Turischev Cc: LKML, Randy Dunlap, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA Hi Denis, On Thu, Feb 18, 2010 at 08:01:33PM +0200, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. > > v2: added "select MFD_CORE" > v3: removed "default m" > > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> patch applied, many thanks. Cheers, Samuel. > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 19:56:19.000000000 +0200 > @@ -348,6 +348,14 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + depends on PCI > + select MFD_CORE > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c > --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 > @@ -0,0 +1,133 @@ > +/* > + * lpc_sch.c - LPC interface for Intel Poulsbo SCH > + * > + * LPC bridge function of the Intel SCH contains many other > + * functional units, such as Interrupt controllers, Timers, > + * Power Management, System Management, GPIO, RTC, and LPC > + * Configuration Registers. > + * > + * Copyright (c) 2010 CompuLab Ltd > + * Author: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > + * > + * 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. > + */ > + > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/errno.h> > +#include <linux/acpi.h> > +#include <linux/pci.h> > +#include <linux/mfd/core.h> > + > +#define SMBASE 0x40 > +#define SMBUS_IO_SIZE 64 > + > +#define GPIOBASE 0x44 > +#define GPIO_IO_SIZE 64 > + > +static struct resource smbus_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > + > +static struct resource gpio_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > +static struct mfd_cell lpc_sch_cells[] = { > + { > + .name = "isch_smbus", > + .num_resources = 1, > + .resources = &smbus_sch_resource, > + }, > + { > + .name = "sch_gpio", > + .num_resources = 1, > + .resources = &gpio_sch_resource, > + }, > +}; > + > +static struct pci_device_id lpc_sch_ids[] = { > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > + { 0, } > +}; > +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); > + > +static int __devinit lpc_sch_probe(struct pci_dev *dev, > + const struct pci_device_id *id) > +{ > + unsigned int base_addr_cfg; > + unsigned short base_addr; > + > + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); > + return -ENODEV; > + } > + > + smbus_sch_resource.start = base_addr; > + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; > + > + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); > + return -ENODEV; > + } > + > + gpio_sch_resource.start = base_addr; > + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; > + > + return mfd_add_devices(&dev->dev, -1, > + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); > +} > + > +static void __devexit lpc_sch_remove(struct pci_dev *dev) > +{ > + mfd_remove_devices(&dev->dev); > +} > + > +static struct pci_driver lpc_sch_driver = { > + .name = "lpc_sch", > + .id_table = lpc_sch_ids, > + .probe = lpc_sch_probe, > + .remove = __devexit_p(lpc_sch_remove), > +}; > + > +static int __init lpc_sch_init(void) > +{ > + return pci_register_driver(&lpc_sch_driver); > +} > + > +static void __exit lpc_sch_exit(void) > +{ > + pci_unregister_driver(&lpc_sch_driver); > +} > + > +module_init(lpc_sch_init); > +module_exit(lpc_sch_exit); > + > +MODULE_AUTHOR("Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>"); > +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); > +MODULE_LICENSE("GPL"); > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile > --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 > @@ -55,4 +55,5 @@ > obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o > obj-$(CONFIG_AB4500_CORE) += ab4500-core.o > obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o > -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > \ No newline at end of file > +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > +obj-$(CONFIG_LPC_SCH) += lpc_sch.o -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-23 8:26 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-23 8:26 UTC (permalink / raw) To: Denis Turischev Cc: LKML, Randy Dunlap, Samuel Ortiz, David Brownell, linux-i2c On Thu, 18 Feb 2010 20:01:33 +0200, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. > > v2: added "select MFD_CORE" > v3: removed "default m" > > Signed-off-by: Denis Turischev <denis@compulab.co.il> > > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 19:56:19.000000000 +0200 > @@ -348,6 +348,14 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + depends on PCI > + select MFD_CORE > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c > --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 > @@ -0,0 +1,133 @@ > +/* > + * lpc_sch.c - LPC interface for Intel Poulsbo SCH > + * > + * LPC bridge function of the Intel SCH contains many other > + * functional units, such as Interrupt controllers, Timers, > + * Power Management, System Management, GPIO, RTC, and LPC > + * Configuration Registers. > + * > + * Copyright (c) 2010 CompuLab Ltd > + * Author: Denis Turischev <denis@compulab.co.il> > + * > + * 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. > + */ > + > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/errno.h> > +#include <linux/acpi.h> > +#include <linux/pci.h> > +#include <linux/mfd/core.h> > + > +#define SMBASE 0x40 > +#define SMBUS_IO_SIZE 64 > + > +#define GPIOBASE 0x44 > +#define GPIO_IO_SIZE 64 > + > +static struct resource smbus_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > + > +static struct resource gpio_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > +static struct mfd_cell lpc_sch_cells[] = { > + { > + .name = "isch_smbus", > + .num_resources = 1, > + .resources = &smbus_sch_resource, > + }, > + { > + .name = "sch_gpio", > + .num_resources = 1, > + .resources = &gpio_sch_resource, > + }, > +}; These names are nicely inconsistent. What about "isch_gpio"? > + > +static struct pci_device_id lpc_sch_ids[] = { > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > + { 0, } > +}; > +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); > + > +static int __devinit lpc_sch_probe(struct pci_dev *dev, > + const struct pci_device_id *id) > +{ > + unsigned int base_addr_cfg; > + unsigned short base_addr; > + > + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); > + return -ENODEV; > + } > + > + smbus_sch_resource.start = base_addr; > + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; > + > + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); > + return -ENODEV; > + } > + > + gpio_sch_resource.start = base_addr; > + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; > + > + return mfd_add_devices(&dev->dev, -1, > + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); > +} > + > +static void __devexit lpc_sch_remove(struct pci_dev *dev) > +{ > + mfd_remove_devices(&dev->dev); > +} > + > +static struct pci_driver lpc_sch_driver = { > + .name = "lpc_sch", > + .id_table = lpc_sch_ids, > + .probe = lpc_sch_probe, > + .remove = __devexit_p(lpc_sch_remove), > +}; > + > +static int __init lpc_sch_init(void) > +{ > + return pci_register_driver(&lpc_sch_driver); > +} > + > +static void __exit lpc_sch_exit(void) > +{ > + pci_unregister_driver(&lpc_sch_driver); > +} > + > +module_init(lpc_sch_init); > +module_exit(lpc_sch_exit); > + > +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); > +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); > +MODULE_LICENSE("GPL"); > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile > --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 > @@ -55,4 +55,5 @@ > obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o > obj-$(CONFIG_AB4500_CORE) += ab4500-core.o > obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o > -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > \ No newline at end of file > +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > +obj-$(CONFIG_LPC_SCH) += lpc_sch.o I don't like this name either. There is another vendor (SMSC) shipping LPC devices with "SCH" in their names, so there is room for confusion. "isch" makes it clearer that we are talking about the Intel ones. -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-23 8:26 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-23 8:26 UTC (permalink / raw) To: Denis Turischev Cc: LKML, Randy Dunlap, Samuel Ortiz, David Brownell, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Thu, 18 Feb 2010 20:01:33 +0200, Denis Turischev wrote: > Intel Poulsbo (SCH) chipset LPC bridge controller contains several > functions. Creating and MFD driver for the LPC bridge controller allows > simultaneous use of SMBus and GPIO interfaces on the SCH. > > v2: added "select MFD_CORE" > v3: removed "default m" > > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Kconfig linux-2.6.33-rc7/drivers/mfd/Kconfig > --- linux-2.6.33-rc7.orig/drivers/mfd/Kconfig 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Kconfig 2010-02-18 19:56:19.000000000 +0200 > @@ -348,6 +348,14 @@ > read/write functions for the devices to get access to this chip. > This chip embeds various other multimedia funtionalities as well. > > +config LPC_SCH > + tristate "Intel SCH LPC" > + depends on PCI > + select MFD_CORE > + help > + LPC bridge function of the Intel SCH provides support for > + System Management Bus and General Purpose I/O. > + > endmenu > > menu "Multimedia Capabilities Port drivers" > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c linux-2.6.33-rc7/drivers/mfd/lpc_sch.c > --- linux-2.6.33-rc7.orig/drivers/mfd/lpc_sch.c 1970-01-01 02:00:00.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/lpc_sch.c 2010-02-11 10:31:54.000000000 +0200 > @@ -0,0 +1,133 @@ > +/* > + * lpc_sch.c - LPC interface for Intel Poulsbo SCH > + * > + * LPC bridge function of the Intel SCH contains many other > + * functional units, such as Interrupt controllers, Timers, > + * Power Management, System Management, GPIO, RTC, and LPC > + * Configuration Registers. > + * > + * Copyright (c) 2010 CompuLab Ltd > + * Author: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > + * > + * 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. > + */ > + > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/errno.h> > +#include <linux/acpi.h> > +#include <linux/pci.h> > +#include <linux/mfd/core.h> > + > +#define SMBASE 0x40 > +#define SMBUS_IO_SIZE 64 > + > +#define GPIOBASE 0x44 > +#define GPIO_IO_SIZE 64 > + > +static struct resource smbus_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > + > +static struct resource gpio_sch_resource = { > + .flags = IORESOURCE_IO, > +}; > + > +static struct mfd_cell lpc_sch_cells[] = { > + { > + .name = "isch_smbus", > + .num_resources = 1, > + .resources = &smbus_sch_resource, > + }, > + { > + .name = "sch_gpio", > + .num_resources = 1, > + .resources = &gpio_sch_resource, > + }, > +}; These names are nicely inconsistent. What about "isch_gpio"? > + > +static struct pci_device_id lpc_sch_ids[] = { > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > + { 0, } > +}; > +MODULE_DEVICE_TABLE(pci, lpc_sch_ids); > + > +static int __devinit lpc_sch_probe(struct pci_dev *dev, > + const struct pci_device_id *id) > +{ > + unsigned int base_addr_cfg; > + unsigned short base_addr; > + > + pci_read_config_dword(dev, SMBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); > + return -ENODEV; > + } > + > + smbus_sch_resource.start = base_addr; > + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; > + > + pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); > + if (!(base_addr_cfg & (1 << 31))) { > + dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); > + return -ENODEV; > + } > + base_addr = (unsigned short)base_addr_cfg; > + if (base_addr == 0) { > + dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); > + return -ENODEV; > + } > + > + gpio_sch_resource.start = base_addr; > + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; > + > + return mfd_add_devices(&dev->dev, -1, > + lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 0); > +} > + > +static void __devexit lpc_sch_remove(struct pci_dev *dev) > +{ > + mfd_remove_devices(&dev->dev); > +} > + > +static struct pci_driver lpc_sch_driver = { > + .name = "lpc_sch", > + .id_table = lpc_sch_ids, > + .probe = lpc_sch_probe, > + .remove = __devexit_p(lpc_sch_remove), > +}; > + > +static int __init lpc_sch_init(void) > +{ > + return pci_register_driver(&lpc_sch_driver); > +} > + > +static void __exit lpc_sch_exit(void) > +{ > + pci_unregister_driver(&lpc_sch_driver); > +} > + > +module_init(lpc_sch_init); > +module_exit(lpc_sch_exit); > + > +MODULE_AUTHOR("Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>"); > +MODULE_DESCRIPTION("LPC interface for Intel Poulsbo SCH"); > +MODULE_LICENSE("GPL"); > diff -Nru linux-2.6.33-rc7.orig/drivers/mfd/Makefile linux-2.6.33-rc7/drivers/mfd/Makefile > --- linux-2.6.33-rc7.orig/drivers/mfd/Makefile 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/mfd/Makefile 2010-02-10 15:15:40.000000000 +0200 > @@ -55,4 +55,5 @@ > obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o > obj-$(CONFIG_AB4500_CORE) += ab4500-core.o > obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o > -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > \ No newline at end of file > +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o > +obj-$(CONFIG_LPC_SCH) += lpc_sch.o I don't like this name either. There is another vendor (SMSC) shipping LPC devices with "SCH" in their names, so there is room for confusion. "isch" makes it clearer that we are talking about the Intel ones. -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-23 9:25 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-23 9:25 UTC (permalink / raw) To: Samuel Ortiz; +Cc: Jean Delvare, LKML, Randy Dunlap, David Brownell, linux-i2c Hi Samuel, Regarding renaming of sch* to isch* do you want incremental patch, or fresh version? Denis Jean Delvare wrote: >> +static struct mfd_cell lpc_sch_cells[] = { >> + { >> + .name = "isch_smbus", >> + .num_resources = 1, >> + .resources = &smbus_sch_resource, >> + }, >> + { >> + .name = "sch_gpio", >> + .num_resources = 1, >> + .resources = &gpio_sch_resource, >> + }, >> +}; > > These names are nicely inconsistent. What about "isch_gpio"? > >> +obj-$(CONFIG_LPC_SCH) += lpc_sch.o > > I don't like this name either. There is another vendor (SMSC) shipping > LPC devices with "SCH" in their names, so there is room for confusion. > "isch" makes it clearer that we are talking about the Intel ones. > ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-23 9:25 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-23 9:25 UTC (permalink / raw) To: Samuel Ortiz Cc: Jean Delvare, LKML, Randy Dunlap, David Brownell, linux-i2c-u79uwXL29TY76Z2rM5mHXA Hi Samuel, Regarding renaming of sch* to isch* do you want incremental patch, or fresh version? Denis Jean Delvare wrote: >> +static struct mfd_cell lpc_sch_cells[] = { >> + { >> + .name = "isch_smbus", >> + .num_resources = 1, >> + .resources = &smbus_sch_resource, >> + }, >> + { >> + .name = "sch_gpio", >> + .num_resources = 1, >> + .resources = &gpio_sch_resource, >> + }, >> +}; > > These names are nicely inconsistent. What about "isch_gpio"? > >> +obj-$(CONFIG_LPC_SCH) += lpc_sch.o > > I don't like this name either. There is another vendor (SMSC) shipping > LPC devices with "SCH" in their names, so there is room for confusion. > "isch" makes it clearer that we are talking about the Intel ones. > ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-23 9:41 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-23 9:41 UTC (permalink / raw) To: Denis Turischev Cc: Jean Delvare, LKML, Randy Dunlap, David Brownell, linux-i2c Hi Denis, On Tue, Feb 23, 2010 at 11:25:59AM +0200, Denis Turischev wrote: > Hi Samuel, > Regarding renaming of sch* to isch* do you want incremental patch, or fresh version? > I'll fix that myself, no worries. Cheers, Samuel. > Denis > > Jean Delvare wrote: > >>+static struct mfd_cell lpc_sch_cells[] = { > >>+ { > >>+ .name = "isch_smbus", > >>+ .num_resources = 1, > >>+ .resources = &smbus_sch_resource, > >>+ }, > >>+ { > >>+ .name = "sch_gpio", > >>+ .num_resources = 1, > >>+ .resources = &gpio_sch_resource, > >>+ }, > >>+}; > > > >These names are nicely inconsistent. What about "isch_gpio"? > > > > >>+obj-$(CONFIG_LPC_SCH) += lpc_sch.o > > > >I don't like this name either. There is another vendor (SMSC) shipping > >LPC devices with "SCH" in their names, so there is room for confusion. > >"isch" makes it clearer that we are talking about the Intel ones. > > > -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge @ 2010-02-23 9:41 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-23 9:41 UTC (permalink / raw) To: Denis Turischev Cc: Jean Delvare, LKML, Randy Dunlap, David Brownell, linux-i2c-u79uwXL29TY76Z2rM5mHXA Hi Denis, On Tue, Feb 23, 2010 at 11:25:59AM +0200, Denis Turischev wrote: > Hi Samuel, > Regarding renaming of sch* to isch* do you want incremental patch, or fresh version? > I'll fix that myself, no worries. Cheers, Samuel. > Denis > > Jean Delvare wrote: > >>+static struct mfd_cell lpc_sch_cells[] = { > >>+ { > >>+ .name = "isch_smbus", > >>+ .num_resources = 1, > >>+ .resources = &smbus_sch_resource, > >>+ }, > >>+ { > >>+ .name = "sch_gpio", > >>+ .num_resources = 1, > >>+ .resources = &gpio_sch_resource, > >>+ }, > >>+}; > > > >These names are nicely inconsistent. What about "isch_gpio"? > > > > >>+obj-$(CONFIG_LPC_SCH) += lpc_sch.o > > > >I don't like this name either. There is another vendor (SMSC) shipping > >LPC devices with "SCH" in their names, so there is room for confusion. > >"isch" makes it clearer that we are talking about the Intel ones. > > > -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-11 10:28 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-11 10:28 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c Signed-off-by: Denis Turischev <denis@compulab.co.il> diff -Nru linux-2.6.33-rc7.orig/drivers/i2c/busses/i2c-isch.c linux-2.6.33-rc7/drivers/i2c/busses/i2c-isch.c --- linux-2.6.33-rc7.orig/drivers/i2c/busses/i2c-isch.c 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/i2c/busses/i2c-isch.c 2010-02-10 15:45:23.000000000 +0200 @@ -27,7 +27,7 @@ */ #include <linux/module.h> -#include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/stddef.h> @@ -46,12 +46,6 @@ #define SMBHSTDAT1 (7 + sch_smba) #define SMBBLKDAT (0x20 + sch_smba) -/* count for request_region */ -#define SMBIOSIZE 64 - -/* PCI Address Constants */ -#define SMBBA_SCH 0x40 - /* Other settings */ #define MAX_TIMEOUT 500 @@ -63,7 +57,6 @@ #define SCH_BLOCK_DATA 0x05 static unsigned short sch_smba; -static struct pci_driver sch_driver; static struct i2c_adapter sch_adapter; /* @@ -256,37 +249,26 @@ .algo = &smbus_algorithm, }; -static struct pci_device_id sch_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, sch_ids); - -static int __devinit sch_probe(struct pci_dev *dev, - const struct pci_device_id *id) +static int __devinit smbus_sch_probe(struct platform_device *dev) { + struct resource *res; int retval; - unsigned int smba; - pci_read_config_dword(dev, SMBBA_SCH, &smba); - if (!(smba & (1 << 31))) { - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); - return -ENODEV; - } + res = platform_get_resource(dev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; - sch_smba = (unsigned short)smba; - if (sch_smba == 0) { - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); + if (acpi_check_region(res->start, resource_size(res), dev->name)) return -ENODEV; - } - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) - return -ENODEV; - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { + + if (!request_region(res->start, resource_size(res), dev->name)) { dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", sch_smba); return -EBUSY; } + + sch_smba = res->start; + dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); /* set up the sysfs linkage to our parent device */ @@ -298,37 +280,43 @@ retval = i2c_add_adapter(&sch_adapter); if (retval) { dev_err(&dev->dev, "Couldn't register adapter!\n"); - release_region(sch_smba, SMBIOSIZE); + release_region(res->start, resource_size(res)); sch_smba = 0; } return retval; } -static void __devexit sch_remove(struct pci_dev *dev) +static int __devexit smbus_sch_remove(struct platform_device *pdev) { + struct resource *res; if (sch_smba) { i2c_del_adapter(&sch_adapter); - release_region(sch_smba, SMBIOSIZE); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(res->start, resource_size(res)); sch_smba = 0; } + + return 0; } -static struct pci_driver sch_driver = { - .name = "isch_smbus", - .id_table = sch_ids, - .probe = sch_probe, - .remove = __devexit_p(sch_remove), +static struct platform_driver smbus_sch_driver = { + .driver = { + .name = "isch_smbus", + .owner = THIS_MODULE, + }, + .probe = smbus_sch_probe, + .remove = __devexit_p(smbus_sch_remove), }; static int __init i2c_sch_init(void) { - return pci_register_driver(&sch_driver); + return platform_driver_register(&smbus_sch_driver); } static void __exit i2c_sch_exit(void) { - pci_unregister_driver(&sch_driver); + platform_driver_unregister(&smbus_sch_driver); } MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); @@ -337,3 +325,4 @@ module_init(i2c_sch_init); module_exit(i2c_sch_exit); +MODULE_ALIAS("platform:isch_smbus"); diff -Nru linux-2.6.33-rc7.orig/drivers/i2c/busses/Kconfig linux-2.6.33-rc7/drivers/i2c/busses/Kconfig --- linux-2.6.33-rc7.orig/drivers/i2c/busses/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/i2c/busses/Kconfig 2010-02-10 15:23:12.000000000 +0200 @@ -104,7 +104,7 @@ config I2C_ISCH tristate "Intel SCH SMBus 1.0" - depends on PCI + select LPC_SCH help Say Y here if you want to use SMBus controller on the Intel SCH based systems. ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-11 10:28 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-11 10:28 UTC (permalink / raw) To: LKML Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> diff -Nru linux-2.6.33-rc7.orig/drivers/i2c/busses/i2c-isch.c linux-2.6.33-rc7/drivers/i2c/busses/i2c-isch.c --- linux-2.6.33-rc7.orig/drivers/i2c/busses/i2c-isch.c 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/i2c/busses/i2c-isch.c 2010-02-10 15:45:23.000000000 +0200 @@ -27,7 +27,7 @@ */ #include <linux/module.h> -#include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/stddef.h> @@ -46,12 +46,6 @@ #define SMBHSTDAT1 (7 + sch_smba) #define SMBBLKDAT (0x20 + sch_smba) -/* count for request_region */ -#define SMBIOSIZE 64 - -/* PCI Address Constants */ -#define SMBBA_SCH 0x40 - /* Other settings */ #define MAX_TIMEOUT 500 @@ -63,7 +57,6 @@ #define SCH_BLOCK_DATA 0x05 static unsigned short sch_smba; -static struct pci_driver sch_driver; static struct i2c_adapter sch_adapter; /* @@ -256,37 +249,26 @@ .algo = &smbus_algorithm, }; -static struct pci_device_id sch_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, sch_ids); - -static int __devinit sch_probe(struct pci_dev *dev, - const struct pci_device_id *id) +static int __devinit smbus_sch_probe(struct platform_device *dev) { + struct resource *res; int retval; - unsigned int smba; - pci_read_config_dword(dev, SMBBA_SCH, &smba); - if (!(smba & (1 << 31))) { - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); - return -ENODEV; - } + res = platform_get_resource(dev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; - sch_smba = (unsigned short)smba; - if (sch_smba == 0) { - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); + if (acpi_check_region(res->start, resource_size(res), dev->name)) return -ENODEV; - } - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) - return -ENODEV; - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { + + if (!request_region(res->start, resource_size(res), dev->name)) { dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", sch_smba); return -EBUSY; } + + sch_smba = res->start; + dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); /* set up the sysfs linkage to our parent device */ @@ -298,37 +280,43 @@ retval = i2c_add_adapter(&sch_adapter); if (retval) { dev_err(&dev->dev, "Couldn't register adapter!\n"); - release_region(sch_smba, SMBIOSIZE); + release_region(res->start, resource_size(res)); sch_smba = 0; } return retval; } -static void __devexit sch_remove(struct pci_dev *dev) +static int __devexit smbus_sch_remove(struct platform_device *pdev) { + struct resource *res; if (sch_smba) { i2c_del_adapter(&sch_adapter); - release_region(sch_smba, SMBIOSIZE); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(res->start, resource_size(res)); sch_smba = 0; } + + return 0; } -static struct pci_driver sch_driver = { - .name = "isch_smbus", - .id_table = sch_ids, - .probe = sch_probe, - .remove = __devexit_p(sch_remove), +static struct platform_driver smbus_sch_driver = { + .driver = { + .name = "isch_smbus", + .owner = THIS_MODULE, + }, + .probe = smbus_sch_probe, + .remove = __devexit_p(smbus_sch_remove), }; static int __init i2c_sch_init(void) { - return pci_register_driver(&sch_driver); + return platform_driver_register(&smbus_sch_driver); } static void __exit i2c_sch_exit(void) { - pci_unregister_driver(&sch_driver); + platform_driver_unregister(&smbus_sch_driver); } MODULE_AUTHOR("Jacob Pan <jacob.jun.pan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>"); @@ -337,3 +325,4 @@ module_init(i2c_sch_init); module_exit(i2c_sch_exit); +MODULE_ALIAS("platform:isch_smbus"); diff -Nru linux-2.6.33-rc7.orig/drivers/i2c/busses/Kconfig linux-2.6.33-rc7/drivers/i2c/busses/Kconfig --- linux-2.6.33-rc7.orig/drivers/i2c/busses/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/i2c/busses/Kconfig 2010-02-10 15:23:12.000000000 +0200 @@ -104,7 +104,7 @@ config I2C_ISCH tristate "Intel SCH SMBus 1.0" - depends on PCI + select LPC_SCH help Say Y here if you want to use SMBus controller on the Intel SCH based systems. ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v2 2/3] i2c: convert i2c-isch to platform_device 2010-02-11 10:28 ` Denis Turischev (?) @ 2010-02-17 15:42 ` Denis Turischev 2010-02-19 10:33 ` Samuel Ortiz 2010-02-21 12:46 ` Denis Turischev -1 siblings, 2 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-17 15:42 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c, Mike Rapoport acpi_check_region will be implemented in mfd-core, therefore v2 version avoids this check Signed-off-by: Denis Turischev <denis@compulab.co.il> --- linux-2.6.33-rc7.orig/drivers/i2c/busses/i2c-isch.c 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/i2c/busses/i2c-isch.c 2010-02-17 17:08:53.000000000 +0200 @@ -27,7 +27,7 @@ */ #include <linux/module.h> -#include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/stddef.h> @@ -46,12 +46,6 @@ #define SMBHSTDAT1 (7 + sch_smba) #define SMBBLKDAT (0x20 + sch_smba) -/* count for request_region */ -#define SMBIOSIZE 64 - -/* PCI Address Constants */ -#define SMBBA_SCH 0x40 - /* Other settings */ #define MAX_TIMEOUT 500 @@ -63,7 +57,6 @@ #define SCH_BLOCK_DATA 0x05 static unsigned short sch_smba; -static struct pci_driver sch_driver; static struct i2c_adapter sch_adapter; /* @@ -256,37 +249,23 @@ .algo = &smbus_algorithm, }; -static struct pci_device_id sch_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, sch_ids); - -static int __devinit sch_probe(struct pci_dev *dev, - const struct pci_device_id *id) +static int __devinit smbus_sch_probe(struct platform_device *dev) { + struct resource *res; int retval; - unsigned int smba; - pci_read_config_dword(dev, SMBBA_SCH, &smba); - if (!(smba & (1 << 31))) { - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); - return -ENODEV; - } + res = platform_get_resource(dev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; - sch_smba = (unsigned short)smba; - if (sch_smba == 0) { - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); - return -ENODEV; - } - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) - return -ENODEV; - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { + if (!request_region(res->start, resource_size(res), dev->name)) { dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", sch_smba); return -EBUSY; } + + sch_smba = res->start; + dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); /* set up the sysfs linkage to our parent device */ @@ -298,37 +277,43 @@ retval = i2c_add_adapter(&sch_adapter); if (retval) { dev_err(&dev->dev, "Couldn't register adapter!\n"); - release_region(sch_smba, SMBIOSIZE); + release_region(res->start, resource_size(res)); sch_smba = 0; } return retval; } -static void __devexit sch_remove(struct pci_dev *dev) +static int __devexit smbus_sch_remove(struct platform_device *pdev) { + struct resource *res; if (sch_smba) { i2c_del_adapter(&sch_adapter); - release_region(sch_smba, SMBIOSIZE); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(res->start, resource_size(res)); sch_smba = 0; } + + return 0; } -static struct pci_driver sch_driver = { - .name = "isch_smbus", - .id_table = sch_ids, - .probe = sch_probe, - .remove = __devexit_p(sch_remove), +static struct platform_driver smbus_sch_driver = { + .driver = { + .name = "isch_smbus", + .owner = THIS_MODULE, + }, + .probe = smbus_sch_probe, + .remove = __devexit_p(smbus_sch_remove), }; static int __init i2c_sch_init(void) { - return pci_register_driver(&sch_driver); + return platform_driver_register(&smbus_sch_driver); } static void __exit i2c_sch_exit(void) { - pci_unregister_driver(&sch_driver); + platform_driver_unregister(&smbus_sch_driver); } MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); @@ -337,3 +322,4 @@ module_init(i2c_sch_init); module_exit(i2c_sch_exit); +MODULE_ALIAS("platform:isch_smbus"); ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v2 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-19 10:33 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-19 10:33 UTC (permalink / raw) To: Denis Turischev Cc: LKML, David Brownell, Jean Delvare, linux-i2c, Mike Rapoport Hi Denis, On Wed, Feb 17, 2010 at 05:42:21PM +0200, Denis Turischev wrote: > acpi_check_region will be implemented in mfd-core, therefore v2 version avoids > this check > > Signed-off-by: Denis Turischev <denis@compulab.co.il> This patch doesnt apply properly against neither my mfd tree nor Linus tree. Could you refresh it against the latest Linus tree, please ? Same applies to the GPIO patch, btw. Cheers, Samuel. > --- linux-2.6.33-rc7.orig/drivers/i2c/busses/i2c-isch.c 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/i2c/busses/i2c-isch.c 2010-02-17 17:08:53.000000000 +0200 > @@ -27,7 +27,7 @@ > */ > > #include <linux/module.h> > -#include <linux/pci.h> > +#include <linux/platform_device.h> > #include <linux/kernel.h> > #include <linux/delay.h> > #include <linux/stddef.h> > @@ -46,12 +46,6 @@ > #define SMBHSTDAT1 (7 + sch_smba) > #define SMBBLKDAT (0x20 + sch_smba) > > -/* count for request_region */ > -#define SMBIOSIZE 64 > - > -/* PCI Address Constants */ > -#define SMBBA_SCH 0x40 > - > /* Other settings */ > #define MAX_TIMEOUT 500 > > @@ -63,7 +57,6 @@ > #define SCH_BLOCK_DATA 0x05 > > static unsigned short sch_smba; > -static struct pci_driver sch_driver; > static struct i2c_adapter sch_adapter; > > /* > @@ -256,37 +249,23 @@ > .algo = &smbus_algorithm, > }; > > -static struct pci_device_id sch_ids[] = { > - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > - { 0, } > -}; > - > -MODULE_DEVICE_TABLE(pci, sch_ids); > - > -static int __devinit sch_probe(struct pci_dev *dev, > - const struct pci_device_id *id) > +static int __devinit smbus_sch_probe(struct platform_device *dev) > { > + struct resource *res; > int retval; > - unsigned int smba; > > - pci_read_config_dword(dev, SMBBA_SCH, &smba); > - if (!(smba & (1 << 31))) { > - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); > - return -ENODEV; > - } > + res = platform_get_resource(dev, IORESOURCE_IO, 0); > + if (!res) > + return -EBUSY; > > - sch_smba = (unsigned short)smba; > - if (sch_smba == 0) { > - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); > - return -ENODEV; > - } > - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) > - return -ENODEV; > - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { > + if (!request_region(res->start, resource_size(res), dev->name)) { > dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", > sch_smba); > return -EBUSY; > } > + > + sch_smba = res->start; > + > dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); > > /* set up the sysfs linkage to our parent device */ > @@ -298,37 +277,43 @@ > retval = i2c_add_adapter(&sch_adapter); > if (retval) { > dev_err(&dev->dev, "Couldn't register adapter!\n"); > - release_region(sch_smba, SMBIOSIZE); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > > return retval; > } > > -static void __devexit sch_remove(struct pci_dev *dev) > +static int __devexit smbus_sch_remove(struct platform_device *pdev) > { > + struct resource *res; > if (sch_smba) { > i2c_del_adapter(&sch_adapter); > - release_region(sch_smba, SMBIOSIZE); > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > + > + return 0; > } > > -static struct pci_driver sch_driver = { > - .name = "isch_smbus", > - .id_table = sch_ids, > - .probe = sch_probe, > - .remove = __devexit_p(sch_remove), > +static struct platform_driver smbus_sch_driver = { > + .driver = { > + .name = "isch_smbus", > + .owner = THIS_MODULE, > + }, > + .probe = smbus_sch_probe, > + .remove = __devexit_p(smbus_sch_remove), > }; > > static int __init i2c_sch_init(void) > { > - return pci_register_driver(&sch_driver); > + return platform_driver_register(&smbus_sch_driver); > } > > static void __exit i2c_sch_exit(void) > { > - pci_unregister_driver(&sch_driver); > + platform_driver_unregister(&smbus_sch_driver); > } > > MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); > @@ -337,3 +322,4 @@ > > module_init(i2c_sch_init); > module_exit(i2c_sch_exit); > +MODULE_ALIAS("platform:isch_smbus"); -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v2 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-19 10:33 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-19 10:33 UTC (permalink / raw) To: Denis Turischev Cc: LKML, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Mike Rapoport Hi Denis, On Wed, Feb 17, 2010 at 05:42:21PM +0200, Denis Turischev wrote: > acpi_check_region will be implemented in mfd-core, therefore v2 version avoids > this check > > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> This patch doesnt apply properly against neither my mfd tree nor Linus tree. Could you refresh it against the latest Linus tree, please ? Same applies to the GPIO patch, btw. Cheers, Samuel. > --- linux-2.6.33-rc7.orig/drivers/i2c/busses/i2c-isch.c 2010-02-07 00:17:12.000000000 +0200 > +++ linux-2.6.33-rc7/drivers/i2c/busses/i2c-isch.c 2010-02-17 17:08:53.000000000 +0200 > @@ -27,7 +27,7 @@ > */ > > #include <linux/module.h> > -#include <linux/pci.h> > +#include <linux/platform_device.h> > #include <linux/kernel.h> > #include <linux/delay.h> > #include <linux/stddef.h> > @@ -46,12 +46,6 @@ > #define SMBHSTDAT1 (7 + sch_smba) > #define SMBBLKDAT (0x20 + sch_smba) > > -/* count for request_region */ > -#define SMBIOSIZE 64 > - > -/* PCI Address Constants */ > -#define SMBBA_SCH 0x40 > - > /* Other settings */ > #define MAX_TIMEOUT 500 > > @@ -63,7 +57,6 @@ > #define SCH_BLOCK_DATA 0x05 > > static unsigned short sch_smba; > -static struct pci_driver sch_driver; > static struct i2c_adapter sch_adapter; > > /* > @@ -256,37 +249,23 @@ > .algo = &smbus_algorithm, > }; > > -static struct pci_device_id sch_ids[] = { > - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > - { 0, } > -}; > - > -MODULE_DEVICE_TABLE(pci, sch_ids); > - > -static int __devinit sch_probe(struct pci_dev *dev, > - const struct pci_device_id *id) > +static int __devinit smbus_sch_probe(struct platform_device *dev) > { > + struct resource *res; > int retval; > - unsigned int smba; > > - pci_read_config_dword(dev, SMBBA_SCH, &smba); > - if (!(smba & (1 << 31))) { > - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); > - return -ENODEV; > - } > + res = platform_get_resource(dev, IORESOURCE_IO, 0); > + if (!res) > + return -EBUSY; > > - sch_smba = (unsigned short)smba; > - if (sch_smba == 0) { > - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); > - return -ENODEV; > - } > - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) > - return -ENODEV; > - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { > + if (!request_region(res->start, resource_size(res), dev->name)) { > dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", > sch_smba); > return -EBUSY; > } > + > + sch_smba = res->start; > + > dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); > > /* set up the sysfs linkage to our parent device */ > @@ -298,37 +277,43 @@ > retval = i2c_add_adapter(&sch_adapter); > if (retval) { > dev_err(&dev->dev, "Couldn't register adapter!\n"); > - release_region(sch_smba, SMBIOSIZE); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > > return retval; > } > > -static void __devexit sch_remove(struct pci_dev *dev) > +static int __devexit smbus_sch_remove(struct platform_device *pdev) > { > + struct resource *res; > if (sch_smba) { > i2c_del_adapter(&sch_adapter); > - release_region(sch_smba, SMBIOSIZE); > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > + > + return 0; > } > > -static struct pci_driver sch_driver = { > - .name = "isch_smbus", > - .id_table = sch_ids, > - .probe = sch_probe, > - .remove = __devexit_p(sch_remove), > +static struct platform_driver smbus_sch_driver = { > + .driver = { > + .name = "isch_smbus", > + .owner = THIS_MODULE, > + }, > + .probe = smbus_sch_probe, > + .remove = __devexit_p(smbus_sch_remove), > }; > > static int __init i2c_sch_init(void) > { > - return pci_register_driver(&sch_driver); > + return platform_driver_register(&smbus_sch_driver); > } > > static void __exit i2c_sch_exit(void) > { > - pci_unregister_driver(&sch_driver); > + platform_driver_unregister(&smbus_sch_driver); > } > > MODULE_AUTHOR("Jacob Pan <jacob.jun.pan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>"); > @@ -337,3 +322,4 @@ > > module_init(i2c_sch_init); > module_exit(i2c_sch_exit); > +MODULE_ALIAS("platform:isch_smbus"); -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-21 12:46 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-21 12:46 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, linux-i2c v2: there is no acpi_check_region, it will be implemented in mfd-core v3: patch refreshed against the latest Linus tree Signed-off-by: Denis Turischev <denis@compulab.co.il> --- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/busses/i2c-isch.c | 68 ++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 42 deletions(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 5f318ce..d15b6d3 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -104,7 +104,7 @@ config I2C_I801 config I2C_ISCH tristate "Intel SCH SMBus 1.0" - depends on PCI + select LPC_SCH help Say Y here if you want to use SMBus controller on the Intel SCH based systems. diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index dba6eb0..ddc258e 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -27,7 +27,7 @@ */ #include <linux/module.h> -#include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/stddef.h> @@ -46,12 +46,6 @@ #define SMBHSTDAT1 (7 + sch_smba) #define SMBBLKDAT (0x20 + sch_smba) -/* count for request_region */ -#define SMBIOSIZE 64 - -/* PCI Address Constants */ -#define SMBBA_SCH 0x40 - /* Other settings */ #define MAX_TIMEOUT 500 @@ -63,7 +57,6 @@ #define SCH_BLOCK_DATA 0x05 static unsigned short sch_smba; -static struct pci_driver sch_driver; static struct i2c_adapter sch_adapter; /* @@ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { .algo = &smbus_algorithm, }; -static struct pci_device_id sch_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, sch_ids); - -static int __devinit sch_probe(struct pci_dev *dev, - const struct pci_device_id *id) +static int __devinit smbus_sch_probe(struct platform_device *dev) { + struct resource *res; int retval; - unsigned int smba; - pci_read_config_dword(dev, SMBBA_SCH, &smba); - if (!(smba & (1 << 31))) { - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); - return -ENODEV; - } + res = platform_get_resource(dev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; - sch_smba = (unsigned short)smba; - if (sch_smba == 0) { - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); - return -ENODEV; - } - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) - return -ENODEV; - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { + if (!request_region(res->start, resource_size(res), dev->name)) { dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", sch_smba); return -EBUSY; } + + sch_smba = res->start; + dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); /* set up the sysfs linkage to our parent device */ @@ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, retval = i2c_add_adapter(&sch_adapter); if (retval) { dev_err(&dev->dev, "Couldn't register adapter!\n"); - release_region(sch_smba, SMBIOSIZE); + release_region(res->start, resource_size(res)); sch_smba = 0; } return retval; } -static void __devexit sch_remove(struct pci_dev *dev) +static int __devexit smbus_sch_remove(struct platform_device *pdev) { + struct resource *res; if (sch_smba) { i2c_del_adapter(&sch_adapter); - release_region(sch_smba, SMBIOSIZE); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(res->start, resource_size(res)); sch_smba = 0; } + + return 0; } -static struct pci_driver sch_driver = { - .name = "isch_smbus", - .id_table = sch_ids, - .probe = sch_probe, - .remove = __devexit_p(sch_remove), +static struct platform_driver smbus_sch_driver = { + .driver = { + .name = "isch_smbus", + .owner = THIS_MODULE, + }, + .probe = smbus_sch_probe, + .remove = __devexit_p(smbus_sch_remove), }; static int __init i2c_sch_init(void) { - return pci_register_driver(&sch_driver); + return platform_driver_register(&smbus_sch_driver); } static void __exit i2c_sch_exit(void) { - pci_unregister_driver(&sch_driver); + platform_driver_unregister(&smbus_sch_driver); } MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); @@ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); module_init(i2c_sch_init); module_exit(i2c_sch_exit); +MODULE_ALIAS("platform:isch_smbus"); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 73+ messages in thread
* [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-21 12:46 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-21 12:46 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, linux-i2c-u79uwXL29TY76Z2rM5mHXA v2: there is no acpi_check_region, it will be implemented in mfd-core v3: patch refreshed against the latest Linus tree Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> --- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/busses/i2c-isch.c | 68 ++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 42 deletions(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 5f318ce..d15b6d3 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -104,7 +104,7 @@ config I2C_I801 config I2C_ISCH tristate "Intel SCH SMBus 1.0" - depends on PCI + select LPC_SCH help Say Y here if you want to use SMBus controller on the Intel SCH based systems. diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index dba6eb0..ddc258e 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -27,7 +27,7 @@ */ #include <linux/module.h> -#include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/stddef.h> @@ -46,12 +46,6 @@ #define SMBHSTDAT1 (7 + sch_smba) #define SMBBLKDAT (0x20 + sch_smba) -/* count for request_region */ -#define SMBIOSIZE 64 - -/* PCI Address Constants */ -#define SMBBA_SCH 0x40 - /* Other settings */ #define MAX_TIMEOUT 500 @@ -63,7 +57,6 @@ #define SCH_BLOCK_DATA 0x05 static unsigned short sch_smba; -static struct pci_driver sch_driver; static struct i2c_adapter sch_adapter; /* @@ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { .algo = &smbus_algorithm, }; -static struct pci_device_id sch_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, sch_ids); - -static int __devinit sch_probe(struct pci_dev *dev, - const struct pci_device_id *id) +static int __devinit smbus_sch_probe(struct platform_device *dev) { + struct resource *res; int retval; - unsigned int smba; - pci_read_config_dword(dev, SMBBA_SCH, &smba); - if (!(smba & (1 << 31))) { - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); - return -ENODEV; - } + res = platform_get_resource(dev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; - sch_smba = (unsigned short)smba; - if (sch_smba == 0) { - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); - return -ENODEV; - } - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) - return -ENODEV; - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { + if (!request_region(res->start, resource_size(res), dev->name)) { dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", sch_smba); return -EBUSY; } + + sch_smba = res->start; + dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); /* set up the sysfs linkage to our parent device */ @@ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, retval = i2c_add_adapter(&sch_adapter); if (retval) { dev_err(&dev->dev, "Couldn't register adapter!\n"); - release_region(sch_smba, SMBIOSIZE); + release_region(res->start, resource_size(res)); sch_smba = 0; } return retval; } -static void __devexit sch_remove(struct pci_dev *dev) +static int __devexit smbus_sch_remove(struct platform_device *pdev) { + struct resource *res; if (sch_smba) { i2c_del_adapter(&sch_adapter); - release_region(sch_smba, SMBIOSIZE); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(res->start, resource_size(res)); sch_smba = 0; } + + return 0; } -static struct pci_driver sch_driver = { - .name = "isch_smbus", - .id_table = sch_ids, - .probe = sch_probe, - .remove = __devexit_p(sch_remove), +static struct platform_driver smbus_sch_driver = { + .driver = { + .name = "isch_smbus", + .owner = THIS_MODULE, + }, + .probe = smbus_sch_probe, + .remove = __devexit_p(smbus_sch_remove), }; static int __init i2c_sch_init(void) { - return pci_register_driver(&sch_driver); + return platform_driver_register(&smbus_sch_driver); } static void __exit i2c_sch_exit(void) { - pci_unregister_driver(&sch_driver); + platform_driver_unregister(&smbus_sch_driver); } MODULE_AUTHOR("Jacob Pan <jacob.jun.pan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>"); @@ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); module_init(i2c_sch_init); module_exit(i2c_sch_exit); +MODULE_ALIAS("platform:isch_smbus"); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 73+ messages in thread
* Re: [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-23 7:00 ` Mike Rapoport 0 siblings, 0 replies; 73+ messages in thread From: Mike Rapoport @ 2010-02-23 7:00 UTC (permalink / raw) To: Jean Delvare Cc: LKML, Samuel Ortiz, linux-i2c, Denis Turischev, Mike Rapoport Hi Jean, Denis Turischev wrote: > v2: there is no acpi_check_region, it will be implemented in mfd-core > v3: patch refreshed against the latest Linus tree > > Signed-off-by: Denis Turischev <denis@compulab.co.il> Any chance this can go to 2.6.34? > --- > drivers/i2c/busses/Kconfig | 2 +- > drivers/i2c/busses/i2c-isch.c | 68 > ++++++++++++++++------------------------ > 2 files changed, 28 insertions(+), 42 deletions(-) > > diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig > index 5f318ce..d15b6d3 100644 > --- a/drivers/i2c/busses/Kconfig > +++ b/drivers/i2c/busses/Kconfig > @@ -104,7 +104,7 @@ config I2C_I801 > > config I2C_ISCH > tristate "Intel SCH SMBus 1.0" > - depends on PCI > + select LPC_SCH > help > Say Y here if you want to use SMBus controller on the Intel SCH > based systems. > diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c > index dba6eb0..ddc258e 100644 > --- a/drivers/i2c/busses/i2c-isch.c > +++ b/drivers/i2c/busses/i2c-isch.c > @@ -27,7 +27,7 @@ > */ > > #include <linux/module.h> > -#include <linux/pci.h> > +#include <linux/platform_device.h> > #include <linux/kernel.h> > #include <linux/delay.h> > #include <linux/stddef.h> > @@ -46,12 +46,6 @@ > #define SMBHSTDAT1 (7 + sch_smba) > #define SMBBLKDAT (0x20 + sch_smba) > > -/* count for request_region */ > -#define SMBIOSIZE 64 > - > -/* PCI Address Constants */ > -#define SMBBA_SCH 0x40 > - > /* Other settings */ > #define MAX_TIMEOUT 500 > > @@ -63,7 +57,6 @@ > #define SCH_BLOCK_DATA 0x05 > > static unsigned short sch_smba; > -static struct pci_driver sch_driver; > static struct i2c_adapter sch_adapter; > > /* > @@ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { > .algo = &smbus_algorithm, > }; > > -static struct pci_device_id sch_ids[] = { > - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > - { 0, } > -}; > - > -MODULE_DEVICE_TABLE(pci, sch_ids); > - > -static int __devinit sch_probe(struct pci_dev *dev, > - const struct pci_device_id *id) > +static int __devinit smbus_sch_probe(struct platform_device *dev) > { > + struct resource *res; > int retval; > - unsigned int smba; > > - pci_read_config_dword(dev, SMBBA_SCH, &smba); > - if (!(smba & (1 << 31))) { > - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); > - return -ENODEV; > - } > + res = platform_get_resource(dev, IORESOURCE_IO, 0); > + if (!res) > + return -EBUSY; > > - sch_smba = (unsigned short)smba; > - if (sch_smba == 0) { > - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); > - return -ENODEV; > - } > - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) > - return -ENODEV; > - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { > + if (!request_region(res->start, resource_size(res), dev->name)) { > dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", > sch_smba); > return -EBUSY; > } > + > + sch_smba = res->start; > + > dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); > > /* set up the sysfs linkage to our parent device */ > @@ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, > retval = i2c_add_adapter(&sch_adapter); > if (retval) { > dev_err(&dev->dev, "Couldn't register adapter!\n"); > - release_region(sch_smba, SMBIOSIZE); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > > return retval; > } > > -static void __devexit sch_remove(struct pci_dev *dev) > +static int __devexit smbus_sch_remove(struct platform_device *pdev) > { > + struct resource *res; > if (sch_smba) { > i2c_del_adapter(&sch_adapter); > - release_region(sch_smba, SMBIOSIZE); > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > + > + return 0; > } > > -static struct pci_driver sch_driver = { > - .name = "isch_smbus", > - .id_table = sch_ids, > - .probe = sch_probe, > - .remove = __devexit_p(sch_remove), > +static struct platform_driver smbus_sch_driver = { > + .driver = { > + .name = "isch_smbus", > + .owner = THIS_MODULE, > + }, > + .probe = smbus_sch_probe, > + .remove = __devexit_p(smbus_sch_remove), > }; > > static int __init i2c_sch_init(void) > { > - return pci_register_driver(&sch_driver); > + return platform_driver_register(&smbus_sch_driver); > } > > static void __exit i2c_sch_exit(void) > { > - pci_unregister_driver(&sch_driver); > + platform_driver_unregister(&smbus_sch_driver); > } > > MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); > @@ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); > > module_init(i2c_sch_init); > module_exit(i2c_sch_exit); > +MODULE_ALIAS("platform:isch_smbus"); -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-23 7:00 ` Mike Rapoport 0 siblings, 0 replies; 73+ messages in thread From: Mike Rapoport @ 2010-02-23 7:00 UTC (permalink / raw) To: Jean Delvare Cc: LKML, Samuel Ortiz, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Denis Turischev, Mike Rapoport Hi Jean, Denis Turischev wrote: > v2: there is no acpi_check_region, it will be implemented in mfd-core > v3: patch refreshed against the latest Linus tree > > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> Any chance this can go to 2.6.34? > --- > drivers/i2c/busses/Kconfig | 2 +- > drivers/i2c/busses/i2c-isch.c | 68 > ++++++++++++++++------------------------ > 2 files changed, 28 insertions(+), 42 deletions(-) > > diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig > index 5f318ce..d15b6d3 100644 > --- a/drivers/i2c/busses/Kconfig > +++ b/drivers/i2c/busses/Kconfig > @@ -104,7 +104,7 @@ config I2C_I801 > > config I2C_ISCH > tristate "Intel SCH SMBus 1.0" > - depends on PCI > + select LPC_SCH > help > Say Y here if you want to use SMBus controller on the Intel SCH > based systems. > diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c > index dba6eb0..ddc258e 100644 > --- a/drivers/i2c/busses/i2c-isch.c > +++ b/drivers/i2c/busses/i2c-isch.c > @@ -27,7 +27,7 @@ > */ > > #include <linux/module.h> > -#include <linux/pci.h> > +#include <linux/platform_device.h> > #include <linux/kernel.h> > #include <linux/delay.h> > #include <linux/stddef.h> > @@ -46,12 +46,6 @@ > #define SMBHSTDAT1 (7 + sch_smba) > #define SMBBLKDAT (0x20 + sch_smba) > > -/* count for request_region */ > -#define SMBIOSIZE 64 > - > -/* PCI Address Constants */ > -#define SMBBA_SCH 0x40 > - > /* Other settings */ > #define MAX_TIMEOUT 500 > > @@ -63,7 +57,6 @@ > #define SCH_BLOCK_DATA 0x05 > > static unsigned short sch_smba; > -static struct pci_driver sch_driver; > static struct i2c_adapter sch_adapter; > > /* > @@ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { > .algo = &smbus_algorithm, > }; > > -static struct pci_device_id sch_ids[] = { > - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > - { 0, } > -}; > - > -MODULE_DEVICE_TABLE(pci, sch_ids); > - > -static int __devinit sch_probe(struct pci_dev *dev, > - const struct pci_device_id *id) > +static int __devinit smbus_sch_probe(struct platform_device *dev) > { > + struct resource *res; > int retval; > - unsigned int smba; > > - pci_read_config_dword(dev, SMBBA_SCH, &smba); > - if (!(smba & (1 << 31))) { > - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); > - return -ENODEV; > - } > + res = platform_get_resource(dev, IORESOURCE_IO, 0); > + if (!res) > + return -EBUSY; > > - sch_smba = (unsigned short)smba; > - if (sch_smba == 0) { > - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); > - return -ENODEV; > - } > - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) > - return -ENODEV; > - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { > + if (!request_region(res->start, resource_size(res), dev->name)) { > dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", > sch_smba); > return -EBUSY; > } > + > + sch_smba = res->start; > + > dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); > > /* set up the sysfs linkage to our parent device */ > @@ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, > retval = i2c_add_adapter(&sch_adapter); > if (retval) { > dev_err(&dev->dev, "Couldn't register adapter!\n"); > - release_region(sch_smba, SMBIOSIZE); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > > return retval; > } > > -static void __devexit sch_remove(struct pci_dev *dev) > +static int __devexit smbus_sch_remove(struct platform_device *pdev) > { > + struct resource *res; > if (sch_smba) { > i2c_del_adapter(&sch_adapter); > - release_region(sch_smba, SMBIOSIZE); > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > + > + return 0; > } > > -static struct pci_driver sch_driver = { > - .name = "isch_smbus", > - .id_table = sch_ids, > - .probe = sch_probe, > - .remove = __devexit_p(sch_remove), > +static struct platform_driver smbus_sch_driver = { > + .driver = { > + .name = "isch_smbus", > + .owner = THIS_MODULE, > + }, > + .probe = smbus_sch_probe, > + .remove = __devexit_p(smbus_sch_remove), > }; > > static int __init i2c_sch_init(void) > { > - return pci_register_driver(&sch_driver); > + return platform_driver_register(&smbus_sch_driver); > } > > static void __exit i2c_sch_exit(void) > { > - pci_unregister_driver(&sch_driver); > + platform_driver_unregister(&smbus_sch_driver); > } > > MODULE_AUTHOR("Jacob Pan <jacob.jun.pan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>"); > @@ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); > > module_init(i2c_sch_init); > module_exit(i2c_sch_exit); > +MODULE_ALIAS("platform:isch_smbus"); -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-23 8:12 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-23 8:12 UTC (permalink / raw) To: Mike Rapoport Cc: LKML, Samuel Ortiz, linux-i2c, Denis Turischev, Mike Rapoport Hi Mike, On Tue, 23 Feb 2010 09:00:28 +0200, Mike Rapoport wrote: > Hi Jean, > > Denis Turischev wrote: > > v2: there is no acpi_check_region, it will be implemented in mfd-core > > v3: patch refreshed against the latest Linus tree > > > > Signed-off-by: Denis Turischev <denis@compulab.co.il> > > Any chance this can go to 2.6.34? I can add my Acked-by: Jean Delvare <khali@linux-fr.org> but the patch itself would rather go through Samuel's mfd tree. The different patches depend on each other so pushing them through different trees would cause trouble. -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-23 8:12 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-23 8:12 UTC (permalink / raw) Cc: LKML, Samuel Ortiz, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Denis Turischev, Mike Rapoport Hi Mike, On Tue, 23 Feb 2010 09:00:28 +0200, Mike Rapoport wrote: > Hi Jean, > > Denis Turischev wrote: > > v2: there is no acpi_check_region, it will be implemented in mfd-core > > v3: patch refreshed against the latest Linus tree > > > > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > > Any chance this can go to 2.6.34? I can add my Acked-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> but the patch itself would rather go through Samuel's mfd tree. The different patches depend on each other so pushing them through different trees would cause trouble. -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-23 8:20 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-23 8:20 UTC (permalink / raw) To: Jean Delvare; +Cc: Mike Rapoport, LKML, linux-i2c, Denis Turischev Hi Jean, On Tue, Feb 23, 2010 at 09:12:21AM +0100, Jean Delvare wrote: > Hi Mike, > > On Tue, 23 Feb 2010 09:00:28 +0200, Mike Rapoport wrote: > > Hi Jean, > > > > Denis Turischev wrote: > > > v2: there is no acpi_check_region, it will be implemented in mfd-core > > > v3: patch refreshed against the latest Linus tree > > > > > > Signed-off-by: Denis Turischev <denis@compulab.co.il> > > > > Any chance this can go to 2.6.34? > > I can add my > > Acked-by: Jean Delvare <khali@linux-fr.org> > > but the patch itself would rather go through Samuel's mfd tree. The > different patches depend on each other so pushing them through > different trees would cause trouble. Exactly. I asked Denis to rebase them against Linus' latest because I was planning to merge them through my tree. I'll take patches 2 and 3 from this patchset. Cheers, Samuel. > -- > Jean Delvare -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-23 8:20 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-02-23 8:20 UTC (permalink / raw) To: Jean Delvare Cc: Mike Rapoport, LKML, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Denis Turischev Hi Jean, On Tue, Feb 23, 2010 at 09:12:21AM +0100, Jean Delvare wrote: > Hi Mike, > > On Tue, 23 Feb 2010 09:00:28 +0200, Mike Rapoport wrote: > > Hi Jean, > > > > Denis Turischev wrote: > > > v2: there is no acpi_check_region, it will be implemented in mfd-core > > > v3: patch refreshed against the latest Linus tree > > > > > > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > > > > Any chance this can go to 2.6.34? > > I can add my > > Acked-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> > > but the patch itself would rather go through Samuel's mfd tree. The > different patches depend on each other so pushing them through > different trees would cause trouble. Exactly. I asked Denis to rebase them against Linus' latest because I was planning to merge them through my tree. I'll take patches 2 and 3 from this patchset. Cheers, Samuel. > -- > Jean Delvare -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-23 8:24 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-23 8:24 UTC (permalink / raw) To: Samuel Ortiz; +Cc: Mike Rapoport, LKML, linux-i2c, Denis Turischev Hi Samuel, On Tue, 23 Feb 2010 09:20:55 +0100, Samuel Ortiz wrote: > Hi Jean, > > On Tue, Feb 23, 2010 at 09:12:21AM +0100, Jean Delvare wrote: > > I can add my > > > > Acked-by: Jean Delvare <khali@linux-fr.org> > > > > but the patch itself would rather go through Samuel's mfd tree. The > > different patches depend on each other so pushing them through > > different trees would cause trouble. > Exactly. I asked Denis to rebase them against Linus' latest because I was > planning to merge them through my tree. > I'll take patches 2 and 3 from this patchset. You mean patches 1 and 2? -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 2/3] i2c: convert i2c-isch to platform_device @ 2010-02-23 8:24 ` Jean Delvare 0 siblings, 0 replies; 73+ messages in thread From: Jean Delvare @ 2010-02-23 8:24 UTC (permalink / raw) To: Samuel Ortiz Cc: Mike Rapoport, LKML, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Denis Turischev Hi Samuel, On Tue, 23 Feb 2010 09:20:55 +0100, Samuel Ortiz wrote: > Hi Jean, > > On Tue, Feb 23, 2010 at 09:12:21AM +0100, Jean Delvare wrote: > > I can add my > > > > Acked-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> > > > > but the patch itself would rather go through Samuel's mfd tree. The > > different patches depend on each other so pushing them through > > different trees would cause trouble. > Exactly. I asked Denis to rebase them against Linus' latest because I was > planning to merge them through my tree. > I'll take patches 2 and 3 from this patchset. You mean patches 1 and 2? -- Jean Delvare ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 2/3] i2c: convert i2c-isch to platform_device 2010-02-21 12:46 ` Denis Turischev (?) (?) @ 2010-02-28 19:00 ` Samuel Ortiz 2010-03-01 16:59 ` Denis Turischev -1 siblings, 1 reply; 73+ messages in thread From: Samuel Ortiz @ 2010-02-28 19:00 UTC (permalink / raw) To: Denis Turischev; +Cc: LKML, linux-i2c Hi Denis, On Sun, Feb 21, 2010 at 02:46:58PM +0200, Denis Turischev wrote: > v2: there is no acpi_check_region, it will be implemented in mfd-core > v3: patch refreshed against the latest Linus tree Still failing to apply against Linus' latest tree: patching file drivers/i2c/busses/Kconfig Hunk #1 FAILED at 104. 1 out of 1 hunk FAILED -- saving rejects to file drivers/i2c/busses/Kconfig.rej patching file drivers/i2c/busses/i2c-isch.c Hunk #1 FAILED at 27. Hunk #2 FAILED at 46. Hunk #3 FAILED at 57. Hunk #4 FAILED at 249. Hunk #5 FAILED at 277. Hunk #6 FAILED at 322. 6 out of 6 hunks FAILED -- saving rejects to file drivers/i2c/busses/i2c-isch.c.rej Cheers, Samuel. > Signed-off-by: Denis Turischev <denis@compulab.co.il> > --- > drivers/i2c/busses/Kconfig | 2 +- > drivers/i2c/busses/i2c-isch.c | 68 ++++++++++++++++------------------------ > 2 files changed, 28 insertions(+), 42 deletions(-) > > diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig > index 5f318ce..d15b6d3 100644 > --- a/drivers/i2c/busses/Kconfig > +++ b/drivers/i2c/busses/Kconfig > @@ -104,7 +104,7 @@ config I2C_I801 > > config I2C_ISCH > tristate "Intel SCH SMBus 1.0" > - depends on PCI > + select LPC_SCH > help > Say Y here if you want to use SMBus controller on the Intel SCH > based systems. > diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c > index dba6eb0..ddc258e 100644 > --- a/drivers/i2c/busses/i2c-isch.c > +++ b/drivers/i2c/busses/i2c-isch.c > @@ -27,7 +27,7 @@ > */ > > #include <linux/module.h> > -#include <linux/pci.h> > +#include <linux/platform_device.h> > #include <linux/kernel.h> > #include <linux/delay.h> > #include <linux/stddef.h> > @@ -46,12 +46,6 @@ > #define SMBHSTDAT1 (7 + sch_smba) > #define SMBBLKDAT (0x20 + sch_smba) > > -/* count for request_region */ > -#define SMBIOSIZE 64 > - > -/* PCI Address Constants */ > -#define SMBBA_SCH 0x40 > - > /* Other settings */ > #define MAX_TIMEOUT 500 > > @@ -63,7 +57,6 @@ > #define SCH_BLOCK_DATA 0x05 > > static unsigned short sch_smba; > -static struct pci_driver sch_driver; > static struct i2c_adapter sch_adapter; > > /* > @@ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { > .algo = &smbus_algorithm, > }; > > -static struct pci_device_id sch_ids[] = { > - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > - { 0, } > -}; > - > -MODULE_DEVICE_TABLE(pci, sch_ids); > - > -static int __devinit sch_probe(struct pci_dev *dev, > - const struct pci_device_id *id) > +static int __devinit smbus_sch_probe(struct platform_device *dev) > { > + struct resource *res; > int retval; > - unsigned int smba; > > - pci_read_config_dword(dev, SMBBA_SCH, &smba); > - if (!(smba & (1 << 31))) { > - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); > - return -ENODEV; > - } > + res = platform_get_resource(dev, IORESOURCE_IO, 0); > + if (!res) > + return -EBUSY; > > - sch_smba = (unsigned short)smba; > - if (sch_smba == 0) { > - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); > - return -ENODEV; > - } > - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) > - return -ENODEV; > - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { > + if (!request_region(res->start, resource_size(res), dev->name)) { > dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", > sch_smba); > return -EBUSY; > } > + > + sch_smba = res->start; > + > dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); > > /* set up the sysfs linkage to our parent device */ > @@ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, > retval = i2c_add_adapter(&sch_adapter); > if (retval) { > dev_err(&dev->dev, "Couldn't register adapter!\n"); > - release_region(sch_smba, SMBIOSIZE); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > > return retval; > } > > -static void __devexit sch_remove(struct pci_dev *dev) > +static int __devexit smbus_sch_remove(struct platform_device *pdev) > { > + struct resource *res; > if (sch_smba) { > i2c_del_adapter(&sch_adapter); > - release_region(sch_smba, SMBIOSIZE); > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > + > + return 0; > } > > -static struct pci_driver sch_driver = { > - .name = "isch_smbus", > - .id_table = sch_ids, > - .probe = sch_probe, > - .remove = __devexit_p(sch_remove), > +static struct platform_driver smbus_sch_driver = { > + .driver = { > + .name = "isch_smbus", > + .owner = THIS_MODULE, > + }, > + .probe = smbus_sch_probe, > + .remove = __devexit_p(smbus_sch_remove), > }; > > static int __init i2c_sch_init(void) > { > - return pci_register_driver(&sch_driver); > + return platform_driver_register(&smbus_sch_driver); > } > > static void __exit i2c_sch_exit(void) > { > - pci_unregister_driver(&sch_driver); > + platform_driver_unregister(&smbus_sch_driver); > } > > MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); > @@ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); > > module_init(i2c_sch_init); > module_exit(i2c_sch_exit); > +MODULE_ALIAS("platform:isch_smbus"); > -- > 1.6.3.3 -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v4 2/3] i2c: convert i2c-isch to platform_device @ 2010-03-01 16:59 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-03-01 16:59 UTC (permalink / raw) To: Samuel Ortiz, LKML; +Cc: linux-i2c, denis v2: there is no acpi_check_region, it will be implemented in mfd-core v3: patch refreshed against the latest Linus tree v4: refreshed again Signed-off-by: Denis Turischev <denis@compulab.co.il> --- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/busses/i2c-isch.c | 68 ++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 42 deletions(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 5f318ce..d15b6d3 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -104,7 +104,7 @@ config I2C_I801 config I2C_ISCH tristate "Intel SCH SMBus 1.0" - depends on PCI + select LPC_SCH help Say Y here if you want to use SMBus controller on the Intel SCH based systems. diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index dba6eb0..ddc258e 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -27,7 +27,7 @@ */ #include <linux/module.h> -#include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/stddef.h> @@ -46,12 +46,6 @@ #define SMBHSTDAT1 (7 + sch_smba) #define SMBBLKDAT (0x20 + sch_smba) -/* count for request_region */ -#define SMBIOSIZE 64 - -/* PCI Address Constants */ -#define SMBBA_SCH 0x40 - /* Other settings */ #define MAX_TIMEOUT 500 @@ -63,7 +57,6 @@ #define SCH_BLOCK_DATA 0x05 static unsigned short sch_smba; -static struct pci_driver sch_driver; static struct i2c_adapter sch_adapter; /* @@ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { .algo = &smbus_algorithm, }; -static struct pci_device_id sch_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, sch_ids); - -static int __devinit sch_probe(struct pci_dev *dev, - const struct pci_device_id *id) +static int __devinit smbus_sch_probe(struct platform_device *dev) { + struct resource *res; int retval; - unsigned int smba; - pci_read_config_dword(dev, SMBBA_SCH, &smba); - if (!(smba & (1 << 31))) { - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); - return -ENODEV; - } + res = platform_get_resource(dev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; - sch_smba = (unsigned short)smba; - if (sch_smba == 0) { - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); - return -ENODEV; - } - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) - return -ENODEV; - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { + if (!request_region(res->start, resource_size(res), dev->name)) { dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", sch_smba); return -EBUSY; } + + sch_smba = res->start; + dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); /* set up the sysfs linkage to our parent device */ @@ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, retval = i2c_add_adapter(&sch_adapter); if (retval) { dev_err(&dev->dev, "Couldn't register adapter!\n"); - release_region(sch_smba, SMBIOSIZE); + release_region(res->start, resource_size(res)); sch_smba = 0; } return retval; } -static void __devexit sch_remove(struct pci_dev *dev) +static int __devexit smbus_sch_remove(struct platform_device *pdev) { + struct resource *res; if (sch_smba) { i2c_del_adapter(&sch_adapter); - release_region(sch_smba, SMBIOSIZE); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(res->start, resource_size(res)); sch_smba = 0; } + + return 0; } -static struct pci_driver sch_driver = { - .name = "isch_smbus", - .id_table = sch_ids, - .probe = sch_probe, - .remove = __devexit_p(sch_remove), +static struct platform_driver smbus_sch_driver = { + .driver = { + .name = "isch_smbus", + .owner = THIS_MODULE, + }, + .probe = smbus_sch_probe, + .remove = __devexit_p(smbus_sch_remove), }; static int __init i2c_sch_init(void) { - return pci_register_driver(&sch_driver); + return platform_driver_register(&smbus_sch_driver); } static void __exit i2c_sch_exit(void) { - pci_unregister_driver(&sch_driver); + platform_driver_unregister(&smbus_sch_driver); } MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); @@ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); module_init(i2c_sch_init); module_exit(i2c_sch_exit); +MODULE_ALIAS("platform:isch_smbus"); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 73+ messages in thread
* [PATCH v4 2/3] i2c: convert i2c-isch to platform_device @ 2010-03-01 16:59 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-03-01 16:59 UTC (permalink / raw) To: Samuel Ortiz, LKML Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, denis-UTxiZqZC01RS1MOuV/RT9w v2: there is no acpi_check_region, it will be implemented in mfd-core v3: patch refreshed against the latest Linus tree v4: refreshed again Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> --- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/busses/i2c-isch.c | 68 ++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 42 deletions(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 5f318ce..d15b6d3 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -104,7 +104,7 @@ config I2C_I801 config I2C_ISCH tristate "Intel SCH SMBus 1.0" - depends on PCI + select LPC_SCH help Say Y here if you want to use SMBus controller on the Intel SCH based systems. diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index dba6eb0..ddc258e 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -27,7 +27,7 @@ */ #include <linux/module.h> -#include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/stddef.h> @@ -46,12 +46,6 @@ #define SMBHSTDAT1 (7 + sch_smba) #define SMBBLKDAT (0x20 + sch_smba) -/* count for request_region */ -#define SMBIOSIZE 64 - -/* PCI Address Constants */ -#define SMBBA_SCH 0x40 - /* Other settings */ #define MAX_TIMEOUT 500 @@ -63,7 +57,6 @@ #define SCH_BLOCK_DATA 0x05 static unsigned short sch_smba; -static struct pci_driver sch_driver; static struct i2c_adapter sch_adapter; /* @@ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { .algo = &smbus_algorithm, }; -static struct pci_device_id sch_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, sch_ids); - -static int __devinit sch_probe(struct pci_dev *dev, - const struct pci_device_id *id) +static int __devinit smbus_sch_probe(struct platform_device *dev) { + struct resource *res; int retval; - unsigned int smba; - pci_read_config_dword(dev, SMBBA_SCH, &smba); - if (!(smba & (1 << 31))) { - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); - return -ENODEV; - } + res = platform_get_resource(dev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; - sch_smba = (unsigned short)smba; - if (sch_smba == 0) { - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); - return -ENODEV; - } - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) - return -ENODEV; - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { + if (!request_region(res->start, resource_size(res), dev->name)) { dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", sch_smba); return -EBUSY; } + + sch_smba = res->start; + dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); /* set up the sysfs linkage to our parent device */ @@ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, retval = i2c_add_adapter(&sch_adapter); if (retval) { dev_err(&dev->dev, "Couldn't register adapter!\n"); - release_region(sch_smba, SMBIOSIZE); + release_region(res->start, resource_size(res)); sch_smba = 0; } return retval; } -static void __devexit sch_remove(struct pci_dev *dev) +static int __devexit smbus_sch_remove(struct platform_device *pdev) { + struct resource *res; if (sch_smba) { i2c_del_adapter(&sch_adapter); - release_region(sch_smba, SMBIOSIZE); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(res->start, resource_size(res)); sch_smba = 0; } + + return 0; } -static struct pci_driver sch_driver = { - .name = "isch_smbus", - .id_table = sch_ids, - .probe = sch_probe, - .remove = __devexit_p(sch_remove), +static struct platform_driver smbus_sch_driver = { + .driver = { + .name = "isch_smbus", + .owner = THIS_MODULE, + }, + .probe = smbus_sch_probe, + .remove = __devexit_p(smbus_sch_remove), }; static int __init i2c_sch_init(void) { - return pci_register_driver(&sch_driver); + return platform_driver_register(&smbus_sch_driver); } static void __exit i2c_sch_exit(void) { - pci_unregister_driver(&sch_driver); + platform_driver_unregister(&smbus_sch_driver); } MODULE_AUTHOR("Jacob Pan <jacob.jun.pan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>"); @@ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); module_init(i2c_sch_init); module_exit(i2c_sch_exit); +MODULE_ALIAS("platform:isch_smbus"); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 73+ messages in thread
* Re: [PATCH v4 2/3] i2c: convert i2c-isch to platform_device @ 2010-03-02 10:06 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-03-02 10:06 UTC (permalink / raw) To: Denis Turischev; +Cc: LKML, linux-i2c Hi Denis, On Mon, Mar 01, 2010 at 06:59:55PM +0200, Denis Turischev wrote: > v2: there is no acpi_check_region, it will be implemented in mfd-core > v3: patch refreshed against the latest Linus tree > v4: refreshed again Patch applied, many thanks. Cheers, Samuel. > Signed-off-by: Denis Turischev <denis@compulab.co.il> > > --- > drivers/i2c/busses/Kconfig | 2 +- > drivers/i2c/busses/i2c-isch.c | 68 ++++++++++++++++------------------------ > 2 files changed, 28 insertions(+), 42 deletions(-) > > diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig > index 5f318ce..d15b6d3 100644 > --- a/drivers/i2c/busses/Kconfig > +++ b/drivers/i2c/busses/Kconfig > @@ -104,7 +104,7 @@ config I2C_I801 > > config I2C_ISCH > tristate "Intel SCH SMBus 1.0" > - depends on PCI > + select LPC_SCH > help > Say Y here if you want to use SMBus controller on the Intel SCH > based systems. > diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c > index dba6eb0..ddc258e 100644 > --- a/drivers/i2c/busses/i2c-isch.c > +++ b/drivers/i2c/busses/i2c-isch.c > @@ -27,7 +27,7 @@ > */ > > #include <linux/module.h> > -#include <linux/pci.h> > +#include <linux/platform_device.h> > #include <linux/kernel.h> > #include <linux/delay.h> > #include <linux/stddef.h> > @@ -46,12 +46,6 @@ > #define SMBHSTDAT1 (7 + sch_smba) > #define SMBBLKDAT (0x20 + sch_smba) > > -/* count for request_region */ > -#define SMBIOSIZE 64 > - > -/* PCI Address Constants */ > -#define SMBBA_SCH 0x40 > - > /* Other settings */ > #define MAX_TIMEOUT 500 > > @@ -63,7 +57,6 @@ > #define SCH_BLOCK_DATA 0x05 > > static unsigned short sch_smba; > -static struct pci_driver sch_driver; > static struct i2c_adapter sch_adapter; > > /* > @@ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { > .algo = &smbus_algorithm, > }; > > -static struct pci_device_id sch_ids[] = { > - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > - { 0, } > -}; > - > -MODULE_DEVICE_TABLE(pci, sch_ids); > - > -static int __devinit sch_probe(struct pci_dev *dev, > - const struct pci_device_id *id) > +static int __devinit smbus_sch_probe(struct platform_device *dev) > { > + struct resource *res; > int retval; > - unsigned int smba; > > - pci_read_config_dword(dev, SMBBA_SCH, &smba); > - if (!(smba & (1 << 31))) { > - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); > - return -ENODEV; > - } > + res = platform_get_resource(dev, IORESOURCE_IO, 0); > + if (!res) > + return -EBUSY; > > - sch_smba = (unsigned short)smba; > - if (sch_smba == 0) { > - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); > - return -ENODEV; > - } > - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) > - return -ENODEV; > - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { > + if (!request_region(res->start, resource_size(res), dev->name)) { > dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", > sch_smba); > return -EBUSY; > } > + > + sch_smba = res->start; > + > dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); > > /* set up the sysfs linkage to our parent device */ > @@ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, > retval = i2c_add_adapter(&sch_adapter); > if (retval) { > dev_err(&dev->dev, "Couldn't register adapter!\n"); > - release_region(sch_smba, SMBIOSIZE); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > > return retval; > } > > -static void __devexit sch_remove(struct pci_dev *dev) > +static int __devexit smbus_sch_remove(struct platform_device *pdev) > { > + struct resource *res; > if (sch_smba) { > i2c_del_adapter(&sch_adapter); > - release_region(sch_smba, SMBIOSIZE); > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > + > + return 0; > } > > -static struct pci_driver sch_driver = { > - .name = "isch_smbus", > - .id_table = sch_ids, > - .probe = sch_probe, > - .remove = __devexit_p(sch_remove), > +static struct platform_driver smbus_sch_driver = { > + .driver = { > + .name = "isch_smbus", > + .owner = THIS_MODULE, > + }, > + .probe = smbus_sch_probe, > + .remove = __devexit_p(smbus_sch_remove), > }; > > static int __init i2c_sch_init(void) > { > - return pci_register_driver(&sch_driver); > + return platform_driver_register(&smbus_sch_driver); > } > > static void __exit i2c_sch_exit(void) > { > - pci_unregister_driver(&sch_driver); > + platform_driver_unregister(&smbus_sch_driver); > } > > MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); > @@ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); > > module_init(i2c_sch_init); > module_exit(i2c_sch_exit); > +MODULE_ALIAS("platform:isch_smbus"); > -- > 1.6.3.3 -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v4 2/3] i2c: convert i2c-isch to platform_device @ 2010-03-02 10:06 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-03-02 10:06 UTC (permalink / raw) To: Denis Turischev; +Cc: LKML, linux-i2c-u79uwXL29TY76Z2rM5mHXA Hi Denis, On Mon, Mar 01, 2010 at 06:59:55PM +0200, Denis Turischev wrote: > v2: there is no acpi_check_region, it will be implemented in mfd-core > v3: patch refreshed against the latest Linus tree > v4: refreshed again Patch applied, many thanks. Cheers, Samuel. > Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> > > --- > drivers/i2c/busses/Kconfig | 2 +- > drivers/i2c/busses/i2c-isch.c | 68 ++++++++++++++++------------------------ > 2 files changed, 28 insertions(+), 42 deletions(-) > > diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig > index 5f318ce..d15b6d3 100644 > --- a/drivers/i2c/busses/Kconfig > +++ b/drivers/i2c/busses/Kconfig > @@ -104,7 +104,7 @@ config I2C_I801 > > config I2C_ISCH > tristate "Intel SCH SMBus 1.0" > - depends on PCI > + select LPC_SCH > help > Say Y here if you want to use SMBus controller on the Intel SCH > based systems. > diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c > index dba6eb0..ddc258e 100644 > --- a/drivers/i2c/busses/i2c-isch.c > +++ b/drivers/i2c/busses/i2c-isch.c > @@ -27,7 +27,7 @@ > */ > > #include <linux/module.h> > -#include <linux/pci.h> > +#include <linux/platform_device.h> > #include <linux/kernel.h> > #include <linux/delay.h> > #include <linux/stddef.h> > @@ -46,12 +46,6 @@ > #define SMBHSTDAT1 (7 + sch_smba) > #define SMBBLKDAT (0x20 + sch_smba) > > -/* count for request_region */ > -#define SMBIOSIZE 64 > - > -/* PCI Address Constants */ > -#define SMBBA_SCH 0x40 > - > /* Other settings */ > #define MAX_TIMEOUT 500 > > @@ -63,7 +57,6 @@ > #define SCH_BLOCK_DATA 0x05 > > static unsigned short sch_smba; > -static struct pci_driver sch_driver; > static struct i2c_adapter sch_adapter; > > /* > @@ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { > .algo = &smbus_algorithm, > }; > > -static struct pci_device_id sch_ids[] = { > - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, > - { 0, } > -}; > - > -MODULE_DEVICE_TABLE(pci, sch_ids); > - > -static int __devinit sch_probe(struct pci_dev *dev, > - const struct pci_device_id *id) > +static int __devinit smbus_sch_probe(struct platform_device *dev) > { > + struct resource *res; > int retval; > - unsigned int smba; > > - pci_read_config_dword(dev, SMBBA_SCH, &smba); > - if (!(smba & (1 << 31))) { > - dev_err(&dev->dev, "SMBus I/O space disabled!\n"); > - return -ENODEV; > - } > + res = platform_get_resource(dev, IORESOURCE_IO, 0); > + if (!res) > + return -EBUSY; > > - sch_smba = (unsigned short)smba; > - if (sch_smba == 0) { > - dev_err(&dev->dev, "SMBus base address uninitialized!\n"); > - return -ENODEV; > - } > - if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) > - return -ENODEV; > - if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { > + if (!request_region(res->start, resource_size(res), dev->name)) { > dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", > sch_smba); > return -EBUSY; > } > + > + sch_smba = res->start; > + > dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); > > /* set up the sysfs linkage to our parent device */ > @@ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, > retval = i2c_add_adapter(&sch_adapter); > if (retval) { > dev_err(&dev->dev, "Couldn't register adapter!\n"); > - release_region(sch_smba, SMBIOSIZE); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > > return retval; > } > > -static void __devexit sch_remove(struct pci_dev *dev) > +static int __devexit smbus_sch_remove(struct platform_device *pdev) > { > + struct resource *res; > if (sch_smba) { > i2c_del_adapter(&sch_adapter); > - release_region(sch_smba, SMBIOSIZE); > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + release_region(res->start, resource_size(res)); > sch_smba = 0; > } > + > + return 0; > } > > -static struct pci_driver sch_driver = { > - .name = "isch_smbus", > - .id_table = sch_ids, > - .probe = sch_probe, > - .remove = __devexit_p(sch_remove), > +static struct platform_driver smbus_sch_driver = { > + .driver = { > + .name = "isch_smbus", > + .owner = THIS_MODULE, > + }, > + .probe = smbus_sch_probe, > + .remove = __devexit_p(smbus_sch_remove), > }; > > static int __init i2c_sch_init(void) > { > - return pci_register_driver(&sch_driver); > + return platform_driver_register(&smbus_sch_driver); > } > > static void __exit i2c_sch_exit(void) > { > - pci_unregister_driver(&sch_driver); > + platform_driver_unregister(&smbus_sch_driver); > } > > MODULE_AUTHOR("Jacob Pan <jacob.jun.pan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>"); > @@ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); > > module_init(i2c_sch_init); > module_exit(i2c_sch_exit); > +MODULE_ALIAS("platform:isch_smbus"); > -- > 1.6.3.3 -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH 3/3] gpio: add Intel SCH GPIO controller driver @ 2010-02-11 10:28 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-11 10:28 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c Signed-off-by: Denis Turischev <denis@compulab.co.il> diff -Nru linux-2.6.33-rc7.orig/drivers/gpio/Kconfig linux-2.6.33-rc7/drivers/gpio/Kconfig --- linux-2.6.33-rc7.orig/drivers/gpio/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/gpio/Kconfig 2010-02-10 15:15:49.000000000 +0200 @@ -85,6 +85,22 @@ help Say yes here to support the NEC VR4100 series General-purpose I/O Uint +config GPIO_SCH + tristate "Intel SCH GPIO" + depends on GPIOLIB + select LPC_SCH + help + Say yes here to support GPIO interface on Intel Poulsbo SCH. + The Intel SCH contains a total of 14 GPIO pins. Ten GPIOs are + powered by the core power rail and are turned off during sleep + modes (S3 and higher). The remaining four GPIOs are powered by + the Intel SCH suspend power supply. These GPIOs remain + active during S3. The suspend powered GPIOs can be used to wake the + system from the Suspend-to-RAM state. + + This driver can also be built as a module. If so, the module + will be called sch-gpio. + comment "I2C GPIO expanders:" config GPIO_MAX732X diff -Nru linux-2.6.33-rc7.orig/drivers/gpio/Makefile linux-2.6.33-rc7/drivers/gpio/Makefile --- linux-2.6.33-rc7.orig/drivers/gpio/Makefile 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/gpio/Makefile 2010-02-10 15:15:49.000000000 +0200 @@ -22,3 +22,4 @@ obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_GPIO_WM831X) += wm831x-gpio.o +obj-$(CONFIG_GPIO_SCH) += sch_gpio.o diff -Nru linux-2.6.33-rc7.orig/drivers/gpio/sch_gpio.c linux-2.6.33-rc7/drivers/gpio/sch_gpio.c --- linux-2.6.33-rc7.orig/drivers/gpio/sch_gpio.c 1970-01-01 02:00:00.000000000 +0200 +++ linux-2.6.33-rc7/drivers/gpio/sch_gpio.c 2010-02-10 15:44:20.000000000 +0200 @@ -0,0 +1,285 @@ +/* + * sch_gpio.c - GPIO interface for Intel Poulsbo SCH + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis@compulab.co.il> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/io.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/platform_device.h> + +#include <linux/gpio.h> + +static DEFINE_SPINLOCK(gpio_lock); + +#define CGEN (0x00) +#define CGIO (0x04) +#define CGLV (0x08) + +#define RGEN (0x20) +#define RGIO (0x24) +#define RGLV (0x28) + +static unsigned short gpio_ba; + +static int sch_gpio_core_direction_in(struct gpio_chip *gc, unsigned gpio_num) +{ + u8 curr_dirs; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + + if (!(curr_dirs & (1 << bit))) + outb(curr_dirs | (1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_core_get(struct gpio_chip *gc, unsigned gpio_num) +{ + int res; + unsigned short offset, bit; + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + res = !!(inb(gpio_ba + offset) & (1 << bit)); + return res; +} + +static void sch_gpio_core_set(struct gpio_chip *gc, unsigned gpio_num, int val) +{ + u8 curr_vals; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + curr_vals = inb(gpio_ba + offset); + + if (val) + outb(curr_vals | (1 << bit), gpio_ba + offset); + else + outb((curr_vals & ~(1 << bit)), gpio_ba + offset); + spin_unlock(&gpio_lock); +} + +static int sch_gpio_core_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + unsigned short offset, bit; + + sch_gpio_core_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + if (curr_dirs & (1 << bit)) + outb(curr_dirs & ~(1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_core = { + .label = "sch_gpio_core", + .owner = THIS_MODULE, + .direction_input = sch_gpio_core_direction_in, + .get = sch_gpio_core_get, + .direction_output = sch_gpio_core_direction_out, + .set = sch_gpio_core_set, +}; + +static int sch_gpio_resume_direction_in(struct gpio_chip *gc, + unsigned gpio_num) +{ + u8 curr_dirs; + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + + if (!(curr_dirs & (1 << gpio_num))) + outb(curr_dirs | (1 << gpio_num) , gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_resume_get(struct gpio_chip *gc, unsigned gpio_num) +{ + return !!(inb(gpio_ba + RGLV) & (1 << gpio_num)); +} + +static void sch_gpio_resume_set(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_vals; + + spin_lock(&gpio_lock); + + curr_vals = inb(gpio_ba + RGLV); + + if (val) + outb(curr_vals | (1 << gpio_num), gpio_ba + RGLV); + else + outb((curr_vals & ~(1 << gpio_num)), gpio_ba + RGLV); + + spin_unlock(&gpio_lock); +} + +static int sch_gpio_resume_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + + sch_gpio_resume_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + if (curr_dirs & (1 << gpio_num)) + outb(curr_dirs & ~(1 << gpio_num), gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_resume = { + .label = "sch_gpio_resume", + .owner = THIS_MODULE, + .direction_input = sch_gpio_resume_direction_in, + .get = sch_gpio_resume_get, + .direction_output = sch_gpio_resume_direction_out, + .set = sch_gpio_resume_set, +}; + +static int __devinit sch_gpio_probe(struct platform_device *pdev) +{ + struct resource *res; + int err; + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; + + if (acpi_check_region(res->start, resource_size(res), pdev->name)) + return -ENODEV; + + if (!request_region(res->start, resource_size(res), pdev->name)) + return -EBUSY; + + gpio_ba = res->start; + + sch_gpio_core.base = 0; + sch_gpio_core.ngpio = 10; + sch_gpio_core.dev = &pdev->dev; + + sch_gpio_resume.base = 10; + sch_gpio_resume.ngpio = 4; + sch_gpio_resume.dev = &pdev->dev; + + err = gpiochip_add(&sch_gpio_core); + if (err < 0) + goto err_sch_gpio_core; + + err = gpiochip_add(&sch_gpio_resume); + if (err < 0) + goto err_sch_gpio_resume; + + /* + * GPIO[6:0] enabled by default + * GPIO7 is configured by the CMC as SLPIOVR + * Enable GPIO[9:8] core powered gpios explicitly + */ + outb(0x3, gpio_ba + CGEN + 1); + /* + * SUS_GPIO[2:0] enabled by default + * Enable SUS_GPIO3 resume powered gpio explicitly + */ + outb(0x8, gpio_ba + RGEN); + + return 0; + +err_sch_gpio_resume: + gpiochip_remove(&sch_gpio_core); + +err_sch_gpio_core: + release_region(res->start, resource_size(res)); + gpio_ba = 0; + + return err; +} + +static int __devexit sch_gpio_remove(struct platform_device *pdev) +{ + struct resource *res; + if (gpio_ba) { + gpiochip_remove(&sch_gpio_core); + gpiochip_remove(&sch_gpio_resume); + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + + release_region(res->start, resource_size(res)); + gpio_ba = 0; + } + + return 0; +} + +static struct platform_driver sch_gpio_driver = { + .driver = { + .name = "sch_gpio", + .owner = THIS_MODULE, + }, + .probe = sch_gpio_probe, + .remove = __devexit_p(sch_gpio_remove), +}; + +static int __init sch_gpio_init(void) +{ + return platform_driver_register(&sch_gpio_driver); +} + +static void __exit sch_gpio_exit(void) +{ + platform_driver_unregister(&sch_gpio_driver); +} + +module_init(sch_gpio_init); +module_exit(sch_gpio_exit); + +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); +MODULE_DESCRIPTION("GPIO interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:sch_gpio"); ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH 3/3] gpio: add Intel SCH GPIO controller driver @ 2010-02-11 10:28 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-11 10:28 UTC (permalink / raw) To: LKML Cc: Samuel Ortiz, David Brownell, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA Signed-off-by: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> diff -Nru linux-2.6.33-rc7.orig/drivers/gpio/Kconfig linux-2.6.33-rc7/drivers/gpio/Kconfig --- linux-2.6.33-rc7.orig/drivers/gpio/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/gpio/Kconfig 2010-02-10 15:15:49.000000000 +0200 @@ -85,6 +85,22 @@ help Say yes here to support the NEC VR4100 series General-purpose I/O Uint +config GPIO_SCH + tristate "Intel SCH GPIO" + depends on GPIOLIB + select LPC_SCH + help + Say yes here to support GPIO interface on Intel Poulsbo SCH. + The Intel SCH contains a total of 14 GPIO pins. Ten GPIOs are + powered by the core power rail and are turned off during sleep + modes (S3 and higher). The remaining four GPIOs are powered by + the Intel SCH suspend power supply. These GPIOs remain + active during S3. The suspend powered GPIOs can be used to wake the + system from the Suspend-to-RAM state. + + This driver can also be built as a module. If so, the module + will be called sch-gpio. + comment "I2C GPIO expanders:" config GPIO_MAX732X diff -Nru linux-2.6.33-rc7.orig/drivers/gpio/Makefile linux-2.6.33-rc7/drivers/gpio/Makefile --- linux-2.6.33-rc7.orig/drivers/gpio/Makefile 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/gpio/Makefile 2010-02-10 15:15:49.000000000 +0200 @@ -22,3 +22,4 @@ obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_GPIO_WM831X) += wm831x-gpio.o +obj-$(CONFIG_GPIO_SCH) += sch_gpio.o diff -Nru linux-2.6.33-rc7.orig/drivers/gpio/sch_gpio.c linux-2.6.33-rc7/drivers/gpio/sch_gpio.c --- linux-2.6.33-rc7.orig/drivers/gpio/sch_gpio.c 1970-01-01 02:00:00.000000000 +0200 +++ linux-2.6.33-rc7/drivers/gpio/sch_gpio.c 2010-02-10 15:44:20.000000000 +0200 @@ -0,0 +1,285 @@ +/* + * sch_gpio.c - GPIO interface for Intel Poulsbo SCH + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/io.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/platform_device.h> + +#include <linux/gpio.h> + +static DEFINE_SPINLOCK(gpio_lock); + +#define CGEN (0x00) +#define CGIO (0x04) +#define CGLV (0x08) + +#define RGEN (0x20) +#define RGIO (0x24) +#define RGLV (0x28) + +static unsigned short gpio_ba; + +static int sch_gpio_core_direction_in(struct gpio_chip *gc, unsigned gpio_num) +{ + u8 curr_dirs; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + + if (!(curr_dirs & (1 << bit))) + outb(curr_dirs | (1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_core_get(struct gpio_chip *gc, unsigned gpio_num) +{ + int res; + unsigned short offset, bit; + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + res = !!(inb(gpio_ba + offset) & (1 << bit)); + return res; +} + +static void sch_gpio_core_set(struct gpio_chip *gc, unsigned gpio_num, int val) +{ + u8 curr_vals; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + curr_vals = inb(gpio_ba + offset); + + if (val) + outb(curr_vals | (1 << bit), gpio_ba + offset); + else + outb((curr_vals & ~(1 << bit)), gpio_ba + offset); + spin_unlock(&gpio_lock); +} + +static int sch_gpio_core_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + unsigned short offset, bit; + + sch_gpio_core_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + if (curr_dirs & (1 << bit)) + outb(curr_dirs & ~(1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_core = { + .label = "sch_gpio_core", + .owner = THIS_MODULE, + .direction_input = sch_gpio_core_direction_in, + .get = sch_gpio_core_get, + .direction_output = sch_gpio_core_direction_out, + .set = sch_gpio_core_set, +}; + +static int sch_gpio_resume_direction_in(struct gpio_chip *gc, + unsigned gpio_num) +{ + u8 curr_dirs; + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + + if (!(curr_dirs & (1 << gpio_num))) + outb(curr_dirs | (1 << gpio_num) , gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_resume_get(struct gpio_chip *gc, unsigned gpio_num) +{ + return !!(inb(gpio_ba + RGLV) & (1 << gpio_num)); +} + +static void sch_gpio_resume_set(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_vals; + + spin_lock(&gpio_lock); + + curr_vals = inb(gpio_ba + RGLV); + + if (val) + outb(curr_vals | (1 << gpio_num), gpio_ba + RGLV); + else + outb((curr_vals & ~(1 << gpio_num)), gpio_ba + RGLV); + + spin_unlock(&gpio_lock); +} + +static int sch_gpio_resume_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + + sch_gpio_resume_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + if (curr_dirs & (1 << gpio_num)) + outb(curr_dirs & ~(1 << gpio_num), gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_resume = { + .label = "sch_gpio_resume", + .owner = THIS_MODULE, + .direction_input = sch_gpio_resume_direction_in, + .get = sch_gpio_resume_get, + .direction_output = sch_gpio_resume_direction_out, + .set = sch_gpio_resume_set, +}; + +static int __devinit sch_gpio_probe(struct platform_device *pdev) +{ + struct resource *res; + int err; + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; + + if (acpi_check_region(res->start, resource_size(res), pdev->name)) + return -ENODEV; + + if (!request_region(res->start, resource_size(res), pdev->name)) + return -EBUSY; + + gpio_ba = res->start; + + sch_gpio_core.base = 0; + sch_gpio_core.ngpio = 10; + sch_gpio_core.dev = &pdev->dev; + + sch_gpio_resume.base = 10; + sch_gpio_resume.ngpio = 4; + sch_gpio_resume.dev = &pdev->dev; + + err = gpiochip_add(&sch_gpio_core); + if (err < 0) + goto err_sch_gpio_core; + + err = gpiochip_add(&sch_gpio_resume); + if (err < 0) + goto err_sch_gpio_resume; + + /* + * GPIO[6:0] enabled by default + * GPIO7 is configured by the CMC as SLPIOVR + * Enable GPIO[9:8] core powered gpios explicitly + */ + outb(0x3, gpio_ba + CGEN + 1); + /* + * SUS_GPIO[2:0] enabled by default + * Enable SUS_GPIO3 resume powered gpio explicitly + */ + outb(0x8, gpio_ba + RGEN); + + return 0; + +err_sch_gpio_resume: + gpiochip_remove(&sch_gpio_core); + +err_sch_gpio_core: + release_region(res->start, resource_size(res)); + gpio_ba = 0; + + return err; +} + +static int __devexit sch_gpio_remove(struct platform_device *pdev) +{ + struct resource *res; + if (gpio_ba) { + gpiochip_remove(&sch_gpio_core); + gpiochip_remove(&sch_gpio_resume); + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + + release_region(res->start, resource_size(res)); + gpio_ba = 0; + } + + return 0; +} + +static struct platform_driver sch_gpio_driver = { + .driver = { + .name = "sch_gpio", + .owner = THIS_MODULE, + }, + .probe = sch_gpio_probe, + .remove = __devexit_p(sch_gpio_remove), +}; + +static int __init sch_gpio_init(void) +{ + return platform_driver_register(&sch_gpio_driver); +} + +static void __exit sch_gpio_exit(void) +{ + platform_driver_unregister(&sch_gpio_driver); +} + +module_init(sch_gpio_init); +module_exit(sch_gpio_exit); + +MODULE_AUTHOR("Denis Turischev <denis-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>"); +MODULE_DESCRIPTION("GPIO interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:sch_gpio"); ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v2 3/3] gpio: add Intel SCH GPIO controller driver 2010-02-11 10:28 ` Denis Turischev (?) @ 2010-02-17 15:39 ` Denis Turischev 2010-02-21 12:50 ` [PATCH v3 " Denis Turischev -1 siblings, 1 reply; 73+ messages in thread From: Denis Turischev @ 2010-02-17 15:39 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, Jean Delvare, David Brownell, Mike Rapoport acpi_check_region will be implemented in mfd-core, therefore v2 version avoids this check Signed-off-by: Denis Turischev <denis@compulab.co.il> diff -Nru linux-2.6.33-rc7.orig/drivers/gpio/Kconfig linux-2.6.33-rc7/drivers/gpio/Kconfig --- linux-2.6.33-rc7.orig/drivers/gpio/Kconfig 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/gpio/Kconfig 2010-02-10 15:15:49.000000000 +0200 @@ -85,6 +85,22 @@ help Say yes here to support the NEC VR4100 series General-purpose I/O Uint +config GPIO_SCH + tristate "Intel SCH GPIO" + depends on GPIOLIB + select LPC_SCH + help + Say yes here to support GPIO interface on Intel Poulsbo SCH. + The Intel SCH contains a total of 14 GPIO pins. Ten GPIOs are + powered by the core power rail and are turned off during sleep + modes (S3 and higher). The remaining four GPIOs are powered by + the Intel SCH suspend power supply. These GPIOs remain + active during S3. The suspend powered GPIOs can be used to wake the + system from the Suspend-to-RAM state. + + This driver can also be built as a module. If so, the module + will be called sch-gpio. + comment "I2C GPIO expanders:" config GPIO_MAX732X diff -Nru linux-2.6.33-rc7.orig/drivers/gpio/Makefile linux-2.6.33-rc7/drivers/gpio/Makefile --- linux-2.6.33-rc7.orig/drivers/gpio/Makefile 2010-02-07 00:17:12.000000000 +0200 +++ linux-2.6.33-rc7/drivers/gpio/Makefile 2010-02-10 15:15:49.000000000 +0200 @@ -22,3 +22,4 @@ obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_GPIO_WM831X) += wm831x-gpio.o +obj-$(CONFIG_GPIO_SCH) += sch_gpio.o diff -Nru linux-2.6.33-rc7.orig/drivers/gpio/sch_gpio.c linux-2.6.33-rc7/drivers/gpio/sch_gpio.c --- linux-2.6.33-rc7.orig/drivers/gpio/sch_gpio.c 1970-01-01 02:00:00.000000000 +0200 +++ linux-2.6.33-rc7/drivers/gpio/sch_gpio.c 2010-02-17 17:08:16.000000000 +0200 @@ -0,0 +1,282 @@ +/* + * sch_gpio.c - GPIO interface for Intel Poulsbo SCH + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis@compulab.co.il> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/io.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/platform_device.h> + +#include <linux/gpio.h> + +static DEFINE_SPINLOCK(gpio_lock); + +#define CGEN (0x00) +#define CGIO (0x04) +#define CGLV (0x08) + +#define RGEN (0x20) +#define RGIO (0x24) +#define RGLV (0x28) + +static unsigned short gpio_ba; + +static int sch_gpio_core_direction_in(struct gpio_chip *gc, unsigned gpio_num) +{ + u8 curr_dirs; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + + if (!(curr_dirs & (1 << bit))) + outb(curr_dirs | (1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_core_get(struct gpio_chip *gc, unsigned gpio_num) +{ + int res; + unsigned short offset, bit; + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + res = !!(inb(gpio_ba + offset) & (1 << bit)); + return res; +} + +static void sch_gpio_core_set(struct gpio_chip *gc, unsigned gpio_num, int val) +{ + u8 curr_vals; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + curr_vals = inb(gpio_ba + offset); + + if (val) + outb(curr_vals | (1 << bit), gpio_ba + offset); + else + outb((curr_vals & ~(1 << bit)), gpio_ba + offset); + spin_unlock(&gpio_lock); +} + +static int sch_gpio_core_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + unsigned short offset, bit; + + sch_gpio_core_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + if (curr_dirs & (1 << bit)) + outb(curr_dirs & ~(1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_core = { + .label = "sch_gpio_core", + .owner = THIS_MODULE, + .direction_input = sch_gpio_core_direction_in, + .get = sch_gpio_core_get, + .direction_output = sch_gpio_core_direction_out, + .set = sch_gpio_core_set, +}; + +static int sch_gpio_resume_direction_in(struct gpio_chip *gc, + unsigned gpio_num) +{ + u8 curr_dirs; + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + + if (!(curr_dirs & (1 << gpio_num))) + outb(curr_dirs | (1 << gpio_num) , gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_resume_get(struct gpio_chip *gc, unsigned gpio_num) +{ + return !!(inb(gpio_ba + RGLV) & (1 << gpio_num)); +} + +static void sch_gpio_resume_set(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_vals; + + spin_lock(&gpio_lock); + + curr_vals = inb(gpio_ba + RGLV); + + if (val) + outb(curr_vals | (1 << gpio_num), gpio_ba + RGLV); + else + outb((curr_vals & ~(1 << gpio_num)), gpio_ba + RGLV); + + spin_unlock(&gpio_lock); +} + +static int sch_gpio_resume_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + + sch_gpio_resume_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + if (curr_dirs & (1 << gpio_num)) + outb(curr_dirs & ~(1 << gpio_num), gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_resume = { + .label = "sch_gpio_resume", + .owner = THIS_MODULE, + .direction_input = sch_gpio_resume_direction_in, + .get = sch_gpio_resume_get, + .direction_output = sch_gpio_resume_direction_out, + .set = sch_gpio_resume_set, +}; + +static int __devinit sch_gpio_probe(struct platform_device *pdev) +{ + struct resource *res; + int err; + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; + + if (!request_region(res->start, resource_size(res), pdev->name)) + return -EBUSY; + + gpio_ba = res->start; + + sch_gpio_core.base = 0; + sch_gpio_core.ngpio = 10; + sch_gpio_core.dev = &pdev->dev; + + sch_gpio_resume.base = 10; + sch_gpio_resume.ngpio = 4; + sch_gpio_resume.dev = &pdev->dev; + + err = gpiochip_add(&sch_gpio_core); + if (err < 0) + goto err_sch_gpio_core; + + err = gpiochip_add(&sch_gpio_resume); + if (err < 0) + goto err_sch_gpio_resume; + + /* + * GPIO[6:0] enabled by default + * GPIO7 is configured by the CMC as SLPIOVR + * Enable GPIO[9:8] core powered gpios explicitly + */ + outb(0x3, gpio_ba + CGEN + 1); + /* + * SUS_GPIO[2:0] enabled by default + * Enable SUS_GPIO3 resume powered gpio explicitly + */ + outb(0x8, gpio_ba + RGEN); + + return 0; + +err_sch_gpio_resume: + gpiochip_remove(&sch_gpio_core); + +err_sch_gpio_core: + release_region(res->start, resource_size(res)); + gpio_ba = 0; + + return err; +} + +static int __devexit sch_gpio_remove(struct platform_device *pdev) +{ + struct resource *res; + if (gpio_ba) { + gpiochip_remove(&sch_gpio_core); + gpiochip_remove(&sch_gpio_resume); + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + + release_region(res->start, resource_size(res)); + gpio_ba = 0; + } + + return 0; +} + +static struct platform_driver sch_gpio_driver = { + .driver = { + .name = "sch_gpio", + .owner = THIS_MODULE, + }, + .probe = sch_gpio_probe, + .remove = __devexit_p(sch_gpio_remove), +}; + +static int __init sch_gpio_init(void) +{ + return platform_driver_register(&sch_gpio_driver); +} + +static void __exit sch_gpio_exit(void) +{ + platform_driver_unregister(&sch_gpio_driver); +} + +module_init(sch_gpio_init); +module_exit(sch_gpio_exit); + +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); +MODULE_DESCRIPTION("GPIO interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:sch_gpio"); ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v3 3/3] gpio: add Intel SCH GPIO controller driver 2010-02-17 15:39 ` [PATCH v2 " Denis Turischev @ 2010-02-21 12:50 ` Denis Turischev 2010-02-21 19:12 ` David Brownell 2010-02-28 19:01 ` Samuel Ortiz 0 siblings, 2 replies; 73+ messages in thread From: Denis Turischev @ 2010-02-21 12:50 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, David Brownell v2: there is no acpi_check_region, it will be implemented in mfd-core v3: patch refreshed against the latest Linus tree Signed-off-by: Denis Turischev <denis@compulab.co.il> --- drivers/gpio/Kconfig | 16 +++ drivers/gpio/Makefile | 1 + drivers/gpio/sch_gpio.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 299 insertions(+), 0 deletions(-) create mode 100644 drivers/gpio/sch_gpio.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 1f1d88a..1730068 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -85,6 +85,22 @@ config GPIO_VR41XX help Say yes here to support the NEC VR4100 series General-purpose I/O Uint +config GPIO_SCH + tristate "Intel SCH GPIO" + depends on GPIOLIB + select LPC_SCH + help + Say yes here to support GPIO interface on Intel Poulsbo SCH. + The Intel SCH contains a total of 14 GPIO pins. Ten GPIOs are + powered by the core power rail and are turned off during sleep + modes (S3 and higher). The remaining four GPIOs are powered by + the Intel SCH suspend power supply. These GPIOs remain + active during S3. The suspend powered GPIOs can be used to wake the + system from the Suspend-to-RAM state. + + This driver can also be built as a module. If so, the module + will be called sch-gpio. + comment "I2C GPIO expanders:" config GPIO_MAX732X diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 4868723..aa1d06e 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -22,3 +22,4 @@ obj-$(CONFIG_GPIO_CS5535) += cs5535-gpio.o obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_GPIO_WM831X) += wm831x-gpio.o +obj-$(CONFIG_GPIO_SCH) += sch_gpio.o diff --git a/drivers/gpio/sch_gpio.c b/drivers/gpio/sch_gpio.c new file mode 100644 index 0000000..761071a --- /dev/null +++ b/drivers/gpio/sch_gpio.c @@ -0,0 +1,282 @@ +/* + * sch_gpio.c - GPIO interface for Intel Poulsbo SCH + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis@compulab.co.il> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/io.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/platform_device.h> + +#include <linux/gpio.h> + +static DEFINE_SPINLOCK(gpio_lock); + +#define CGEN (0x00) +#define CGIO (0x04) +#define CGLV (0x08) + +#define RGEN (0x20) +#define RGIO (0x24) +#define RGLV (0x28) + +static unsigned short gpio_ba; + +static int sch_gpio_core_direction_in(struct gpio_chip *gc, unsigned gpio_num) +{ + u8 curr_dirs; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + + if (!(curr_dirs & (1 << bit))) + outb(curr_dirs | (1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_core_get(struct gpio_chip *gc, unsigned gpio_num) +{ + int res; + unsigned short offset, bit; + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + res = !!(inb(gpio_ba + offset) & (1 << bit)); + return res; +} + +static void sch_gpio_core_set(struct gpio_chip *gc, unsigned gpio_num, int val) +{ + u8 curr_vals; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + curr_vals = inb(gpio_ba + offset); + + if (val) + outb(curr_vals | (1 << bit), gpio_ba + offset); + else + outb((curr_vals & ~(1 << bit)), gpio_ba + offset); + spin_unlock(&gpio_lock); +} + +static int sch_gpio_core_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + unsigned short offset, bit; + + sch_gpio_core_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + if (curr_dirs & (1 << bit)) + outb(curr_dirs & ~(1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_core = { + .label = "sch_gpio_core", + .owner = THIS_MODULE, + .direction_input = sch_gpio_core_direction_in, + .get = sch_gpio_core_get, + .direction_output = sch_gpio_core_direction_out, + .set = sch_gpio_core_set, +}; + +static int sch_gpio_resume_direction_in(struct gpio_chip *gc, + unsigned gpio_num) +{ + u8 curr_dirs; + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + + if (!(curr_dirs & (1 << gpio_num))) + outb(curr_dirs | (1 << gpio_num) , gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_resume_get(struct gpio_chip *gc, unsigned gpio_num) +{ + return !!(inb(gpio_ba + RGLV) & (1 << gpio_num)); +} + +static void sch_gpio_resume_set(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_vals; + + spin_lock(&gpio_lock); + + curr_vals = inb(gpio_ba + RGLV); + + if (val) + outb(curr_vals | (1 << gpio_num), gpio_ba + RGLV); + else + outb((curr_vals & ~(1 << gpio_num)), gpio_ba + RGLV); + + spin_unlock(&gpio_lock); +} + +static int sch_gpio_resume_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + + sch_gpio_resume_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + if (curr_dirs & (1 << gpio_num)) + outb(curr_dirs & ~(1 << gpio_num), gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_resume = { + .label = "sch_gpio_resume", + .owner = THIS_MODULE, + .direction_input = sch_gpio_resume_direction_in, + .get = sch_gpio_resume_get, + .direction_output = sch_gpio_resume_direction_out, + .set = sch_gpio_resume_set, +}; + +static int __devinit sch_gpio_probe(struct platform_device *pdev) +{ + struct resource *res; + int err; + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; + + if (!request_region(res->start, resource_size(res), pdev->name)) + return -EBUSY; + + gpio_ba = res->start; + + sch_gpio_core.base = 0; + sch_gpio_core.ngpio = 10; + sch_gpio_core.dev = &pdev->dev; + + sch_gpio_resume.base = 10; + sch_gpio_resume.ngpio = 4; + sch_gpio_resume.dev = &pdev->dev; + + err = gpiochip_add(&sch_gpio_core); + if (err < 0) + goto err_sch_gpio_core; + + err = gpiochip_add(&sch_gpio_resume); + if (err < 0) + goto err_sch_gpio_resume; + + /* + * GPIO[6:0] enabled by default + * GPIO7 is configured by the CMC as SLPIOVR + * Enable GPIO[9:8] core powered gpios explicitly + */ + outb(0x3, gpio_ba + CGEN + 1); + /* + * SUS_GPIO[2:0] enabled by default + * Enable SUS_GPIO3 resume powered gpio explicitly + */ + outb(0x8, gpio_ba + RGEN); + + return 0; + +err_sch_gpio_resume: + gpiochip_remove(&sch_gpio_core); + +err_sch_gpio_core: + release_region(res->start, resource_size(res)); + gpio_ba = 0; + + return err; +} + +static int __devexit sch_gpio_remove(struct platform_device *pdev) +{ + struct resource *res; + if (gpio_ba) { + gpiochip_remove(&sch_gpio_core); + gpiochip_remove(&sch_gpio_resume); + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + + release_region(res->start, resource_size(res)); + gpio_ba = 0; + } + + return 0; +} + +static struct platform_driver sch_gpio_driver = { + .driver = { + .name = "sch_gpio", + .owner = THIS_MODULE, + }, + .probe = sch_gpio_probe, + .remove = __devexit_p(sch_gpio_remove), +}; + +static int __init sch_gpio_init(void) +{ + return platform_driver_register(&sch_gpio_driver); +} + +static void __exit sch_gpio_exit(void) +{ + platform_driver_unregister(&sch_gpio_driver); +} + +module_init(sch_gpio_init); +module_exit(sch_gpio_exit); + +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); +MODULE_DESCRIPTION("GPIO interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:sch_gpio"); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 73+ messages in thread
* Re: [PATCH v3 3/3] gpio: add Intel SCH GPIO controller driver 2010-02-21 12:50 ` [PATCH v3 " Denis Turischev @ 2010-02-21 19:12 ` David Brownell 2010-02-24 6:49 ` Mike Rapoport 2010-02-28 19:01 ` Samuel Ortiz 1 sibling, 1 reply; 73+ messages in thread From: David Brownell @ 2010-02-21 19:12 UTC (permalink / raw) To: Denis Turischev; +Cc: Samuel Ortiz, LKML On Sunday 21 February 2010, Denis Turischev wrote: > v2: there is no acpi_check_region, it will be implemented in mfd-core > v3: patch refreshed against the latest Linus tree Could such call really address the GPIO conflict issue I mentioned? The AML bytecodes I looked at were writing directly to Southbridge GPIO registers (or reading them), or relying on ACPI to mediate the GPIO interrupts. ISTR that button drivers, and code to switch into or out of low power states, were good sources of such bad examples. Calls like that should clearly be able to handle cases where ACPI has a "Real" Driver (tm) ... e.g. for SMBus hardware. I'm not sure what a good solution for this would be, short of just not using ACPI ... which may not be practical, given the limited degree of x86 board/system support for Linux. I mention this mostly because when I looked at the issue in the context of an ICHx GPIO driver, I didn't see a good solution to the problem then ... and nothing seems to have changed meanwhile. - Dave ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 3/3] gpio: add Intel SCH GPIO controller driver 2010-02-21 19:12 ` David Brownell @ 2010-02-24 6:49 ` Mike Rapoport 2010-03-01 18:09 ` Len Brown 0 siblings, 1 reply; 73+ messages in thread From: Mike Rapoport @ 2010-02-24 6:49 UTC (permalink / raw) To: David Brownell; +Cc: Denis Turischev, Samuel Ortiz, LKML, Mike Rapoport David Brownell wrote: > On Sunday 21 February 2010, Denis Turischev wrote: >> v2: there is no acpi_check_region, it will be implemented in mfd-core >> v3: patch refreshed against the latest Linus tree > > Could such call really address the GPIO conflict issue I mentioned? > > The AML bytecodes I looked at were writing directly to Southbridge > GPIO registers (or reading them), or relying on ACPI to mediate the > GPIO interrupts. ISTR that button drivers, and code to switch into > or out of low power states, were good sources of such bad examples. I'm really not an ACPI expert, but as far as I understand possibility of such conflicts largely depends on particular board/BIOS implementation. On the hardware we have such conflict cannot happen, unless there are bugs in ACPI we are not yet aware of. :) > Calls like that should clearly be able to handle cases where ACPI > has a "Real" Driver (tm) ... e.g. for SMBus hardware. > > I'm not sure what a good solution for this would be, short of just > not using ACPI ... which may not be practical, given the limited > degree of x86 board/system support for Linux. > > I mention this mostly because when I looked at the issue in the > context of an ICHx GPIO driver, I didn't see a good solution to > the problem then ... and nothing seems to have changed meanwhile. I've looked at two x86 drivers in drivers/gpiolib (cs5535 and langwell) and there's no treatment of ACPI in either of them. Since SCH is defined by Intel as "embedded" product, having a GPIO driver for it seems logical even despite problems you mention. > - Dave > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 3/3] gpio: add Intel SCH GPIO controller driver 2010-02-24 6:49 ` Mike Rapoport @ 2010-03-01 18:09 ` Len Brown 2010-03-01 19:50 ` Alan Cox 2010-03-02 6:42 ` Mike Rapoport 0 siblings, 2 replies; 73+ messages in thread From: Len Brown @ 2010-03-01 18:09 UTC (permalink / raw) To: Mike Rapoport; +Cc: David Brownell, Denis Turischev, Samuel Ortiz, LKML > I've looked at two x86 drivers in drivers/gpiolib (cs5535 and langwell) and > there's no treatment of ACPI in either of them. Since SCH is defined by Intel > as "embedded" product, having a GPIO driver for it seems logical even despite > problems you mention. FWIW I believe that Langwell is used only in products without an ACPI BIOS. Poulsbo, OTOH, is used in zillions of netbooks running Windows XP. I don't know what a cs5535 is. cheers, Len Brown, Intel Open Source Technology Center ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 3/3] gpio: add Intel SCH GPIO controller driver 2010-03-01 18:09 ` Len Brown @ 2010-03-01 19:50 ` Alan Cox 2010-03-02 6:42 ` Mike Rapoport 1 sibling, 0 replies; 73+ messages in thread From: Alan Cox @ 2010-03-01 19:50 UTC (permalink / raw) To: Len Brown; +Cc: David Brownell, Denis Turischev, Samuel Ortiz, LKML On Mon, 01 Mar 2010 13:09:22 -0500 (EST) Len Brown <lenb@kernel.org> wrote: > > I've looked at two x86 drivers in drivers/gpiolib (cs5535 and langwell) and > > there's no treatment of ACPI in either of them. Since SCH is defined by Intel > > as "embedded" product, having a GPIO driver for it seems logical even despite > > problems you mention. > > FWIW > I believe that Langwell is used only in products without an ACPI BIOS. > > Poulsbo, OTOH, is used in zillions of netbooks running Windows XP. > I don't know what a cs5535 is. Cyrix (then NatSemi then AMD) Geode companion chip. May be present without having ACPI although ACPI was added as a BIOS upgrade to the older ones. Alan ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 3/3] gpio: add Intel SCH GPIO controller driver 2010-03-01 18:09 ` Len Brown 2010-03-01 19:50 ` Alan Cox @ 2010-03-02 6:42 ` Mike Rapoport 2010-03-02 9:29 ` Denis Turischev 1 sibling, 1 reply; 73+ messages in thread From: Mike Rapoport @ 2010-03-02 6:42 UTC (permalink / raw) To: Len Brown; +Cc: David Brownell, Denis Turischev, Samuel Ortiz, LKML Len Brown wrote: >> I've looked at two x86 drivers in drivers/gpiolib (cs5535 and langwell) and >> there's no treatment of ACPI in either of them. Since SCH is defined by Intel >> as "embedded" product, having a GPIO driver for it seems logical even despite >> problems you mention. > > FWIW > I believe that Langwell is used only in products without an ACPI BIOS. > > Poulsbo, OTOH, is used in zillions of netbooks running Windows XP. > I don't know what a cs5535 is. The cs5535 is AMD Geode LX companion chip which is used with ACPI BIOS as well. > cheers, > Len Brown, Intel Open Source Technology Center > -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 3/3] gpio: add Intel SCH GPIO controller driver 2010-03-02 6:42 ` Mike Rapoport @ 2010-03-02 9:29 ` Denis Turischev 0 siblings, 0 replies; 73+ messages in thread From: Denis Turischev @ 2010-03-02 9:29 UTC (permalink / raw) To: Len Brown; +Cc: Mike Rapoport, David Brownell, Samuel Ortiz, LKML Mike Rapoport wrote: > Len Brown wrote: >>> I've looked at two x86 drivers in drivers/gpiolib (cs5535 and langwell) and >>> there's no treatment of ACPI in either of them. Since SCH is defined by Intel >>> as "embedded" product, having a GPIO driver for it seems logical even despite >>> problems you mention. >> FWIW >> I believe that Langwell is used only in products without an ACPI BIOS. >> >> Poulsbo, OTOH, is used in zillions of netbooks running Windows XP. >> I don't know what a cs5535 is. > > The cs5535 is AMD Geode LX companion chip which is used with ACPI BIOS > as well. > >> cheers, >> Len Brown, Intel Open Source Technology Center >> > > I'm really not an ACPI expert too, but as I see in LDD3 "...the role of a device driver is providing mechanism, not policy". HW manufacturer must warn users if some GPIOs may conflict with ACPI, and it is user`s responsibility to use the GPIOs in proper way. Denis ^ permalink raw reply [flat|nested] 73+ messages in thread
* Re: [PATCH v3 3/3] gpio: add Intel SCH GPIO controller driver 2010-02-21 12:50 ` [PATCH v3 " Denis Turischev 2010-02-21 19:12 ` David Brownell @ 2010-02-28 19:01 ` Samuel Ortiz 2010-03-01 17:02 ` [PATCH v4 " Denis Turischev 1 sibling, 1 reply; 73+ messages in thread From: Samuel Ortiz @ 2010-02-28 19:01 UTC (permalink / raw) To: Denis Turischev; +Cc: LKML, David Brownell Hi Denis, On Sun, Feb 21, 2010 at 02:50:41PM +0200, Denis Turischev wrote: > v2: there is no acpi_check_region, it will be implemented in mfd-core > v3: patch refreshed against the latest Linus tree As with patch #2 of that serie, patch still doesnt apply against Linus' latest tree: patching file drivers/gpio/Kconfig Hunk #1 FAILED at 85. 1 out of 1 hunk FAILED -- saving rejects to file drivers/gpio/Kconfig.rej patching file drivers/gpio/Makefile Hunk #1 FAILED at 22. 1 out of 1 hunk FAILED -- saving rejects to file drivers/gpio/Makefile.rej patching file drivers/gpio/sch_gpio.c Cheers, Samuel. > Signed-off-by: Denis Turischev <denis@compulab.co.il> > --- > drivers/gpio/Kconfig | 16 +++ > drivers/gpio/Makefile | 1 + > drivers/gpio/sch_gpio.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 299 insertions(+), 0 deletions(-) > create mode 100644 drivers/gpio/sch_gpio.c > > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig > index 1f1d88a..1730068 100644 > --- a/drivers/gpio/Kconfig > +++ b/drivers/gpio/Kconfig > @@ -85,6 +85,22 @@ config GPIO_VR41XX > help > Say yes here to support the NEC VR4100 series General-purpose I/O Uint > > +config GPIO_SCH > + tristate "Intel SCH GPIO" > + depends on GPIOLIB > + select LPC_SCH > + help > + Say yes here to support GPIO interface on Intel Poulsbo SCH. > + The Intel SCH contains a total of 14 GPIO pins. Ten GPIOs are > + powered by the core power rail and are turned off during sleep > + modes (S3 and higher). The remaining four GPIOs are powered by > + the Intel SCH suspend power supply. These GPIOs remain > + active during S3. The suspend powered GPIOs can be used to wake the > + system from the Suspend-to-RAM state. > + > + This driver can also be built as a module. If so, the module > + will be called sch-gpio. > + > comment "I2C GPIO expanders:" > > config GPIO_MAX732X > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile > index 4868723..aa1d06e 100644 > --- a/drivers/gpio/Makefile > +++ b/drivers/gpio/Makefile > @@ -22,3 +22,4 @@ obj-$(CONFIG_GPIO_CS5535) += cs5535-gpio.o > obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o > obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o > obj-$(CONFIG_GPIO_WM831X) += wm831x-gpio.o > +obj-$(CONFIG_GPIO_SCH) += sch_gpio.o > diff --git a/drivers/gpio/sch_gpio.c b/drivers/gpio/sch_gpio.c > new file mode 100644 > index 0000000..761071a > --- /dev/null > +++ b/drivers/gpio/sch_gpio.c > @@ -0,0 +1,282 @@ > +/* > + * sch_gpio.c - GPIO interface for Intel Poulsbo SCH > + * > + * Copyright (c) 2010 CompuLab Ltd > + * Author: Denis Turischev <denis@compulab.co.il> > + * > + * 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. > + */ > + > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/io.h> > +#include <linux/errno.h> > +#include <linux/acpi.h> > +#include <linux/platform_device.h> > + > +#include <linux/gpio.h> > + > +static DEFINE_SPINLOCK(gpio_lock); > + > +#define CGEN (0x00) > +#define CGIO (0x04) > +#define CGLV (0x08) > + > +#define RGEN (0x20) > +#define RGIO (0x24) > +#define RGLV (0x28) > + > +static unsigned short gpio_ba; > + > +static int sch_gpio_core_direction_in(struct gpio_chip *gc, unsigned gpio_num) > +{ > + u8 curr_dirs; > + unsigned short offset, bit; > + > + spin_lock(&gpio_lock); > + > + offset = CGIO + gpio_num / 8; > + bit = gpio_num % 8; > + > + curr_dirs = inb(gpio_ba + offset); > + > + if (!(curr_dirs & (1 << bit))) > + outb(curr_dirs | (1 << bit), gpio_ba + offset); > + > + spin_unlock(&gpio_lock); > + return 0; > +} > + > +static int sch_gpio_core_get(struct gpio_chip *gc, unsigned gpio_num) > +{ > + int res; > + unsigned short offset, bit; > + > + offset = CGLV + gpio_num / 8; > + bit = gpio_num % 8; > + > + res = !!(inb(gpio_ba + offset) & (1 << bit)); > + return res; > +} > + > +static void sch_gpio_core_set(struct gpio_chip *gc, unsigned gpio_num, int val) > +{ > + u8 curr_vals; > + unsigned short offset, bit; > + > + spin_lock(&gpio_lock); > + > + offset = CGLV + gpio_num / 8; > + bit = gpio_num % 8; > + > + curr_vals = inb(gpio_ba + offset); > + > + if (val) > + outb(curr_vals | (1 << bit), gpio_ba + offset); > + else > + outb((curr_vals & ~(1 << bit)), gpio_ba + offset); > + spin_unlock(&gpio_lock); > +} > + > +static int sch_gpio_core_direction_out(struct gpio_chip *gc, > + unsigned gpio_num, int val) > +{ > + u8 curr_dirs; > + unsigned short offset, bit; > + > + sch_gpio_core_set(gc, gpio_num, val); > + > + spin_lock(&gpio_lock); > + > + offset = CGIO + gpio_num / 8; > + bit = gpio_num % 8; > + > + curr_dirs = inb(gpio_ba + offset); > + if (curr_dirs & (1 << bit)) > + outb(curr_dirs & ~(1 << bit), gpio_ba + offset); > + > + spin_unlock(&gpio_lock); > + return 0; > +} > + > +static struct gpio_chip sch_gpio_core = { > + .label = "sch_gpio_core", > + .owner = THIS_MODULE, > + .direction_input = sch_gpio_core_direction_in, > + .get = sch_gpio_core_get, > + .direction_output = sch_gpio_core_direction_out, > + .set = sch_gpio_core_set, > +}; > + > +static int sch_gpio_resume_direction_in(struct gpio_chip *gc, > + unsigned gpio_num) > +{ > + u8 curr_dirs; > + > + spin_lock(&gpio_lock); > + > + curr_dirs = inb(gpio_ba + RGIO); > + > + if (!(curr_dirs & (1 << gpio_num))) > + outb(curr_dirs | (1 << gpio_num) , gpio_ba + RGIO); > + > + spin_unlock(&gpio_lock); > + return 0; > +} > + > +static int sch_gpio_resume_get(struct gpio_chip *gc, unsigned gpio_num) > +{ > + return !!(inb(gpio_ba + RGLV) & (1 << gpio_num)); > +} > + > +static void sch_gpio_resume_set(struct gpio_chip *gc, > + unsigned gpio_num, int val) > +{ > + u8 curr_vals; > + > + spin_lock(&gpio_lock); > + > + curr_vals = inb(gpio_ba + RGLV); > + > + if (val) > + outb(curr_vals | (1 << gpio_num), gpio_ba + RGLV); > + else > + outb((curr_vals & ~(1 << gpio_num)), gpio_ba + RGLV); > + > + spin_unlock(&gpio_lock); > +} > + > +static int sch_gpio_resume_direction_out(struct gpio_chip *gc, > + unsigned gpio_num, int val) > +{ > + u8 curr_dirs; > + > + sch_gpio_resume_set(gc, gpio_num, val); > + > + spin_lock(&gpio_lock); > + > + curr_dirs = inb(gpio_ba + RGIO); > + if (curr_dirs & (1 << gpio_num)) > + outb(curr_dirs & ~(1 << gpio_num), gpio_ba + RGIO); > + > + spin_unlock(&gpio_lock); > + return 0; > +} > + > +static struct gpio_chip sch_gpio_resume = { > + .label = "sch_gpio_resume", > + .owner = THIS_MODULE, > + .direction_input = sch_gpio_resume_direction_in, > + .get = sch_gpio_resume_get, > + .direction_output = sch_gpio_resume_direction_out, > + .set = sch_gpio_resume_set, > +}; > + > +static int __devinit sch_gpio_probe(struct platform_device *pdev) > +{ > + struct resource *res; > + int err; > + > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + if (!res) > + return -EBUSY; > + > + if (!request_region(res->start, resource_size(res), pdev->name)) > + return -EBUSY; > + > + gpio_ba = res->start; > + > + sch_gpio_core.base = 0; > + sch_gpio_core.ngpio = 10; > + sch_gpio_core.dev = &pdev->dev; > + > + sch_gpio_resume.base = 10; > + sch_gpio_resume.ngpio = 4; > + sch_gpio_resume.dev = &pdev->dev; > + > + err = gpiochip_add(&sch_gpio_core); > + if (err < 0) > + goto err_sch_gpio_core; > + > + err = gpiochip_add(&sch_gpio_resume); > + if (err < 0) > + goto err_sch_gpio_resume; > + > + /* > + * GPIO[6:0] enabled by default > + * GPIO7 is configured by the CMC as SLPIOVR > + * Enable GPIO[9:8] core powered gpios explicitly > + */ > + outb(0x3, gpio_ba + CGEN + 1); > + /* > + * SUS_GPIO[2:0] enabled by default > + * Enable SUS_GPIO3 resume powered gpio explicitly > + */ > + outb(0x8, gpio_ba + RGEN); > + > + return 0; > + > +err_sch_gpio_resume: > + gpiochip_remove(&sch_gpio_core); > + > +err_sch_gpio_core: > + release_region(res->start, resource_size(res)); > + gpio_ba = 0; > + > + return err; > +} > + > +static int __devexit sch_gpio_remove(struct platform_device *pdev) > +{ > + struct resource *res; > + if (gpio_ba) { > + gpiochip_remove(&sch_gpio_core); > + gpiochip_remove(&sch_gpio_resume); > + > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + > + release_region(res->start, resource_size(res)); > + gpio_ba = 0; > + } > + > + return 0; > +} > + > +static struct platform_driver sch_gpio_driver = { > + .driver = { > + .name = "sch_gpio", > + .owner = THIS_MODULE, > + }, > + .probe = sch_gpio_probe, > + .remove = __devexit_p(sch_gpio_remove), > +}; > + > +static int __init sch_gpio_init(void) > +{ > + return platform_driver_register(&sch_gpio_driver); > +} > + > +static void __exit sch_gpio_exit(void) > +{ > + platform_driver_unregister(&sch_gpio_driver); > +} > + > +module_init(sch_gpio_init); > +module_exit(sch_gpio_exit); > + > +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); > +MODULE_DESCRIPTION("GPIO interface for Intel Poulsbo SCH"); > +MODULE_LICENSE("GPL"); > +MODULE_ALIAS("platform:sch_gpio"); > -- > 1.6.3.3 > -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
* [PATCH v4 3/3] gpio: add Intel SCH GPIO controller driver 2010-02-28 19:01 ` Samuel Ortiz @ 2010-03-01 17:02 ` Denis Turischev 2010-03-02 10:09 ` Samuel Ortiz 0 siblings, 1 reply; 73+ messages in thread From: Denis Turischev @ 2010-03-01 17:02 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz, David Brownell v2: there is no acpi_check_region, it will be implemented in mfd-core v3: patch refreshed against the latest Linus tree v4: refreshed again Signed-off-by: Denis Turischev <denis@compulab.co.il> --- drivers/gpio/Kconfig | 16 +++ drivers/gpio/Makefile | 1 + drivers/gpio/sch_gpio.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 299 insertions(+), 0 deletions(-) create mode 100644 drivers/gpio/sch_gpio.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 1f1d88a..1730068 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -85,6 +85,22 @@ config GPIO_VR41XX help Say yes here to support the NEC VR4100 series General-purpose I/O Uint +config GPIO_SCH + tristate "Intel SCH GPIO" + depends on GPIOLIB + select LPC_SCH + help + Say yes here to support GPIO interface on Intel Poulsbo SCH. + The Intel SCH contains a total of 14 GPIO pins. Ten GPIOs are + powered by the core power rail and are turned off during sleep + modes (S3 and higher). The remaining four GPIOs are powered by + the Intel SCH suspend power supply. These GPIOs remain + active during S3. The suspend powered GPIOs can be used to wake the + system from the Suspend-to-RAM state. + + This driver can also be built as a module. If so, the module + will be called sch-gpio. + comment "I2C GPIO expanders:" config GPIO_MAX732X diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 4868723..aa1d06e 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -22,3 +22,4 @@ obj-$(CONFIG_GPIO_CS5535) += cs5535-gpio.o obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_GPIO_WM831X) += wm831x-gpio.o +obj-$(CONFIG_GPIO_SCH) += sch_gpio.o diff --git a/drivers/gpio/sch_gpio.c b/drivers/gpio/sch_gpio.c new file mode 100644 index 0000000..761071a --- /dev/null +++ b/drivers/gpio/sch_gpio.c @@ -0,0 +1,282 @@ +/* + * sch_gpio.c - GPIO interface for Intel Poulsbo SCH + * + * Copyright (c) 2010 CompuLab Ltd + * Author: Denis Turischev <denis@compulab.co.il> + * + * 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. + */ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/io.h> +#include <linux/errno.h> +#include <linux/acpi.h> +#include <linux/platform_device.h> + +#include <linux/gpio.h> + +static DEFINE_SPINLOCK(gpio_lock); + +#define CGEN (0x00) +#define CGIO (0x04) +#define CGLV (0x08) + +#define RGEN (0x20) +#define RGIO (0x24) +#define RGLV (0x28) + +static unsigned short gpio_ba; + +static int sch_gpio_core_direction_in(struct gpio_chip *gc, unsigned gpio_num) +{ + u8 curr_dirs; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + + if (!(curr_dirs & (1 << bit))) + outb(curr_dirs | (1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_core_get(struct gpio_chip *gc, unsigned gpio_num) +{ + int res; + unsigned short offset, bit; + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + res = !!(inb(gpio_ba + offset) & (1 << bit)); + return res; +} + +static void sch_gpio_core_set(struct gpio_chip *gc, unsigned gpio_num, int val) +{ + u8 curr_vals; + unsigned short offset, bit; + + spin_lock(&gpio_lock); + + offset = CGLV + gpio_num / 8; + bit = gpio_num % 8; + + curr_vals = inb(gpio_ba + offset); + + if (val) + outb(curr_vals | (1 << bit), gpio_ba + offset); + else + outb((curr_vals & ~(1 << bit)), gpio_ba + offset); + spin_unlock(&gpio_lock); +} + +static int sch_gpio_core_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + unsigned short offset, bit; + + sch_gpio_core_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + offset = CGIO + gpio_num / 8; + bit = gpio_num % 8; + + curr_dirs = inb(gpio_ba + offset); + if (curr_dirs & (1 << bit)) + outb(curr_dirs & ~(1 << bit), gpio_ba + offset); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_core = { + .label = "sch_gpio_core", + .owner = THIS_MODULE, + .direction_input = sch_gpio_core_direction_in, + .get = sch_gpio_core_get, + .direction_output = sch_gpio_core_direction_out, + .set = sch_gpio_core_set, +}; + +static int sch_gpio_resume_direction_in(struct gpio_chip *gc, + unsigned gpio_num) +{ + u8 curr_dirs; + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + + if (!(curr_dirs & (1 << gpio_num))) + outb(curr_dirs | (1 << gpio_num) , gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static int sch_gpio_resume_get(struct gpio_chip *gc, unsigned gpio_num) +{ + return !!(inb(gpio_ba + RGLV) & (1 << gpio_num)); +} + +static void sch_gpio_resume_set(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_vals; + + spin_lock(&gpio_lock); + + curr_vals = inb(gpio_ba + RGLV); + + if (val) + outb(curr_vals | (1 << gpio_num), gpio_ba + RGLV); + else + outb((curr_vals & ~(1 << gpio_num)), gpio_ba + RGLV); + + spin_unlock(&gpio_lock); +} + +static int sch_gpio_resume_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u8 curr_dirs; + + sch_gpio_resume_set(gc, gpio_num, val); + + spin_lock(&gpio_lock); + + curr_dirs = inb(gpio_ba + RGIO); + if (curr_dirs & (1 << gpio_num)) + outb(curr_dirs & ~(1 << gpio_num), gpio_ba + RGIO); + + spin_unlock(&gpio_lock); + return 0; +} + +static struct gpio_chip sch_gpio_resume = { + .label = "sch_gpio_resume", + .owner = THIS_MODULE, + .direction_input = sch_gpio_resume_direction_in, + .get = sch_gpio_resume_get, + .direction_output = sch_gpio_resume_direction_out, + .set = sch_gpio_resume_set, +}; + +static int __devinit sch_gpio_probe(struct platform_device *pdev) +{ + struct resource *res; + int err; + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -EBUSY; + + if (!request_region(res->start, resource_size(res), pdev->name)) + return -EBUSY; + + gpio_ba = res->start; + + sch_gpio_core.base = 0; + sch_gpio_core.ngpio = 10; + sch_gpio_core.dev = &pdev->dev; + + sch_gpio_resume.base = 10; + sch_gpio_resume.ngpio = 4; + sch_gpio_resume.dev = &pdev->dev; + + err = gpiochip_add(&sch_gpio_core); + if (err < 0) + goto err_sch_gpio_core; + + err = gpiochip_add(&sch_gpio_resume); + if (err < 0) + goto err_sch_gpio_resume; + + /* + * GPIO[6:0] enabled by default + * GPIO7 is configured by the CMC as SLPIOVR + * Enable GPIO[9:8] core powered gpios explicitly + */ + outb(0x3, gpio_ba + CGEN + 1); + /* + * SUS_GPIO[2:0] enabled by default + * Enable SUS_GPIO3 resume powered gpio explicitly + */ + outb(0x8, gpio_ba + RGEN); + + return 0; + +err_sch_gpio_resume: + gpiochip_remove(&sch_gpio_core); + +err_sch_gpio_core: + release_region(res->start, resource_size(res)); + gpio_ba = 0; + + return err; +} + +static int __devexit sch_gpio_remove(struct platform_device *pdev) +{ + struct resource *res; + if (gpio_ba) { + gpiochip_remove(&sch_gpio_core); + gpiochip_remove(&sch_gpio_resume); + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + + release_region(res->start, resource_size(res)); + gpio_ba = 0; + } + + return 0; +} + +static struct platform_driver sch_gpio_driver = { + .driver = { + .name = "sch_gpio", + .owner = THIS_MODULE, + }, + .probe = sch_gpio_probe, + .remove = __devexit_p(sch_gpio_remove), +}; + +static int __init sch_gpio_init(void) +{ + return platform_driver_register(&sch_gpio_driver); +} + +static void __exit sch_gpio_exit(void) +{ + platform_driver_unregister(&sch_gpio_driver); +} + +module_init(sch_gpio_init); +module_exit(sch_gpio_exit); + +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); +MODULE_DESCRIPTION("GPIO interface for Intel Poulsbo SCH"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:sch_gpio"); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 73+ messages in thread
* Re: [PATCH v4 3/3] gpio: add Intel SCH GPIO controller driver 2010-03-01 17:02 ` [PATCH v4 " Denis Turischev @ 2010-03-02 10:09 ` Samuel Ortiz 0 siblings, 0 replies; 73+ messages in thread From: Samuel Ortiz @ 2010-03-02 10:09 UTC (permalink / raw) To: Denis Turischev; +Cc: LKML, David Brownell Hi Denis, On Mon, Mar 01, 2010 at 07:02:35PM +0200, Denis Turischev wrote: > v2: there is no acpi_check_region, it will be implemented in mfd-core > v3: patch refreshed against the latest Linus tree > v4: refreshed again I'm taking this one as well, unless David NACKs it. Cheers, Samuel. > Signed-off-by: Denis Turischev <denis@compulab.co.il> > --- > drivers/gpio/Kconfig | 16 +++ > drivers/gpio/Makefile | 1 + > drivers/gpio/sch_gpio.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 299 insertions(+), 0 deletions(-) > create mode 100644 drivers/gpio/sch_gpio.c > > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig > index 1f1d88a..1730068 100644 > --- a/drivers/gpio/Kconfig > +++ b/drivers/gpio/Kconfig > @@ -85,6 +85,22 @@ config GPIO_VR41XX > help > Say yes here to support the NEC VR4100 series General-purpose I/O Uint > > +config GPIO_SCH > + tristate "Intel SCH GPIO" > + depends on GPIOLIB > + select LPC_SCH > + help > + Say yes here to support GPIO interface on Intel Poulsbo SCH. > + The Intel SCH contains a total of 14 GPIO pins. Ten GPIOs are > + powered by the core power rail and are turned off during sleep > + modes (S3 and higher). The remaining four GPIOs are powered by > + the Intel SCH suspend power supply. These GPIOs remain > + active during S3. The suspend powered GPIOs can be used to wake the > + system from the Suspend-to-RAM state. > + > + This driver can also be built as a module. If so, the module > + will be called sch-gpio. > + > comment "I2C GPIO expanders:" > > config GPIO_MAX732X > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile > index 4868723..aa1d06e 100644 > --- a/drivers/gpio/Makefile > +++ b/drivers/gpio/Makefile > @@ -22,3 +22,4 @@ obj-$(CONFIG_GPIO_CS5535) += cs5535-gpio.o > obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o > obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o > obj-$(CONFIG_GPIO_WM831X) += wm831x-gpio.o > +obj-$(CONFIG_GPIO_SCH) += sch_gpio.o > diff --git a/drivers/gpio/sch_gpio.c b/drivers/gpio/sch_gpio.c > new file mode 100644 > index 0000000..761071a > --- /dev/null > +++ b/drivers/gpio/sch_gpio.c > @@ -0,0 +1,282 @@ > +/* > + * sch_gpio.c - GPIO interface for Intel Poulsbo SCH > + * > + * Copyright (c) 2010 CompuLab Ltd > + * Author: Denis Turischev <denis@compulab.co.il> > + * > + * 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. > + */ > + > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/io.h> > +#include <linux/errno.h> > +#include <linux/acpi.h> > +#include <linux/platform_device.h> > + > +#include <linux/gpio.h> > + > +static DEFINE_SPINLOCK(gpio_lock); > + > +#define CGEN (0x00) > +#define CGIO (0x04) > +#define CGLV (0x08) > + > +#define RGEN (0x20) > +#define RGIO (0x24) > +#define RGLV (0x28) > + > +static unsigned short gpio_ba; > + > +static int sch_gpio_core_direction_in(struct gpio_chip *gc, unsigned gpio_num) > +{ > + u8 curr_dirs; > + unsigned short offset, bit; > + > + spin_lock(&gpio_lock); > + > + offset = CGIO + gpio_num / 8; > + bit = gpio_num % 8; > + > + curr_dirs = inb(gpio_ba + offset); > + > + if (!(curr_dirs & (1 << bit))) > + outb(curr_dirs | (1 << bit), gpio_ba + offset); > + > + spin_unlock(&gpio_lock); > + return 0; > +} > + > +static int sch_gpio_core_get(struct gpio_chip *gc, unsigned gpio_num) > +{ > + int res; > + unsigned short offset, bit; > + > + offset = CGLV + gpio_num / 8; > + bit = gpio_num % 8; > + > + res = !!(inb(gpio_ba + offset) & (1 << bit)); > + return res; > +} > + > +static void sch_gpio_core_set(struct gpio_chip *gc, unsigned gpio_num, int val) > +{ > + u8 curr_vals; > + unsigned short offset, bit; > + > + spin_lock(&gpio_lock); > + > + offset = CGLV + gpio_num / 8; > + bit = gpio_num % 8; > + > + curr_vals = inb(gpio_ba + offset); > + > + if (val) > + outb(curr_vals | (1 << bit), gpio_ba + offset); > + else > + outb((curr_vals & ~(1 << bit)), gpio_ba + offset); > + spin_unlock(&gpio_lock); > +} > + > +static int sch_gpio_core_direction_out(struct gpio_chip *gc, > + unsigned gpio_num, int val) > +{ > + u8 curr_dirs; > + unsigned short offset, bit; > + > + sch_gpio_core_set(gc, gpio_num, val); > + > + spin_lock(&gpio_lock); > + > + offset = CGIO + gpio_num / 8; > + bit = gpio_num % 8; > + > + curr_dirs = inb(gpio_ba + offset); > + if (curr_dirs & (1 << bit)) > + outb(curr_dirs & ~(1 << bit), gpio_ba + offset); > + > + spin_unlock(&gpio_lock); > + return 0; > +} > + > +static struct gpio_chip sch_gpio_core = { > + .label = "sch_gpio_core", > + .owner = THIS_MODULE, > + .direction_input = sch_gpio_core_direction_in, > + .get = sch_gpio_core_get, > + .direction_output = sch_gpio_core_direction_out, > + .set = sch_gpio_core_set, > +}; > + > +static int sch_gpio_resume_direction_in(struct gpio_chip *gc, > + unsigned gpio_num) > +{ > + u8 curr_dirs; > + > + spin_lock(&gpio_lock); > + > + curr_dirs = inb(gpio_ba + RGIO); > + > + if (!(curr_dirs & (1 << gpio_num))) > + outb(curr_dirs | (1 << gpio_num) , gpio_ba + RGIO); > + > + spin_unlock(&gpio_lock); > + return 0; > +} > + > +static int sch_gpio_resume_get(struct gpio_chip *gc, unsigned gpio_num) > +{ > + return !!(inb(gpio_ba + RGLV) & (1 << gpio_num)); > +} > + > +static void sch_gpio_resume_set(struct gpio_chip *gc, > + unsigned gpio_num, int val) > +{ > + u8 curr_vals; > + > + spin_lock(&gpio_lock); > + > + curr_vals = inb(gpio_ba + RGLV); > + > + if (val) > + outb(curr_vals | (1 << gpio_num), gpio_ba + RGLV); > + else > + outb((curr_vals & ~(1 << gpio_num)), gpio_ba + RGLV); > + > + spin_unlock(&gpio_lock); > +} > + > +static int sch_gpio_resume_direction_out(struct gpio_chip *gc, > + unsigned gpio_num, int val) > +{ > + u8 curr_dirs; > + > + sch_gpio_resume_set(gc, gpio_num, val); > + > + spin_lock(&gpio_lock); > + > + curr_dirs = inb(gpio_ba + RGIO); > + if (curr_dirs & (1 << gpio_num)) > + outb(curr_dirs & ~(1 << gpio_num), gpio_ba + RGIO); > + > + spin_unlock(&gpio_lock); > + return 0; > +} > + > +static struct gpio_chip sch_gpio_resume = { > + .label = "sch_gpio_resume", > + .owner = THIS_MODULE, > + .direction_input = sch_gpio_resume_direction_in, > + .get = sch_gpio_resume_get, > + .direction_output = sch_gpio_resume_direction_out, > + .set = sch_gpio_resume_set, > +}; > + > +static int __devinit sch_gpio_probe(struct platform_device *pdev) > +{ > + struct resource *res; > + int err; > + > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + if (!res) > + return -EBUSY; > + > + if (!request_region(res->start, resource_size(res), pdev->name)) > + return -EBUSY; > + > + gpio_ba = res->start; > + > + sch_gpio_core.base = 0; > + sch_gpio_core.ngpio = 10; > + sch_gpio_core.dev = &pdev->dev; > + > + sch_gpio_resume.base = 10; > + sch_gpio_resume.ngpio = 4; > + sch_gpio_resume.dev = &pdev->dev; > + > + err = gpiochip_add(&sch_gpio_core); > + if (err < 0) > + goto err_sch_gpio_core; > + > + err = gpiochip_add(&sch_gpio_resume); > + if (err < 0) > + goto err_sch_gpio_resume; > + > + /* > + * GPIO[6:0] enabled by default > + * GPIO7 is configured by the CMC as SLPIOVR > + * Enable GPIO[9:8] core powered gpios explicitly > + */ > + outb(0x3, gpio_ba + CGEN + 1); > + /* > + * SUS_GPIO[2:0] enabled by default > + * Enable SUS_GPIO3 resume powered gpio explicitly > + */ > + outb(0x8, gpio_ba + RGEN); > + > + return 0; > + > +err_sch_gpio_resume: > + gpiochip_remove(&sch_gpio_core); > + > +err_sch_gpio_core: > + release_region(res->start, resource_size(res)); > + gpio_ba = 0; > + > + return err; > +} > + > +static int __devexit sch_gpio_remove(struct platform_device *pdev) > +{ > + struct resource *res; > + if (gpio_ba) { > + gpiochip_remove(&sch_gpio_core); > + gpiochip_remove(&sch_gpio_resume); > + > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + > + release_region(res->start, resource_size(res)); > + gpio_ba = 0; > + } > + > + return 0; > +} > + > +static struct platform_driver sch_gpio_driver = { > + .driver = { > + .name = "sch_gpio", > + .owner = THIS_MODULE, > + }, > + .probe = sch_gpio_probe, > + .remove = __devexit_p(sch_gpio_remove), > +}; > + > +static int __init sch_gpio_init(void) > +{ > + return platform_driver_register(&sch_gpio_driver); > +} > + > +static void __exit sch_gpio_exit(void) > +{ > + platform_driver_unregister(&sch_gpio_driver); > +} > + > +module_init(sch_gpio_init); > +module_exit(sch_gpio_exit); > + > +MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>"); > +MODULE_DESCRIPTION("GPIO interface for Intel Poulsbo SCH"); > +MODULE_LICENSE("GPL"); > +MODULE_ALIAS("platform:sch_gpio"); > -- > 1.6.3.3 > -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 73+ messages in thread
end of thread, other threads:[~2010-03-02 10:08 UTC | newest] Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-02-11 10:24 [PATCH 0/3] Add Intel SCH GPIO driver Denis Turischev 2010-02-11 10:26 ` [PATCH 1/3] MFD: introduce lpc_sch for Intel SCH LPC bridge Denis Turischev 2010-02-11 10:26 ` Denis Turischev 2010-02-16 10:08 ` Samuel Ortiz 2010-02-16 10:08 ` Samuel Ortiz 2010-02-16 13:59 ` Pan, Jacob jun 2010-02-16 13:59 ` Pan, Jacob jun 2010-02-16 15:45 ` Jean Delvare 2010-02-16 17:19 ` Pan, Jacob jun 2010-02-16 17:19 ` Pan, Jacob jun 2010-02-16 17:29 ` Jean Delvare 2010-02-16 17:29 ` Jean Delvare 2010-02-16 19:57 ` David Brownell 2010-02-16 19:57 ` David Brownell 2010-02-16 21:49 ` Jean Delvare 2010-02-16 21:49 ` Jean Delvare 2010-02-17 10:03 ` Denis Turischev 2010-02-17 10:03 ` Denis Turischev 2010-02-17 10:44 ` Jean Delvare 2010-02-17 10:44 ` Jean Delvare 2010-02-17 12:35 ` Mike Rapoport 2010-02-17 12:35 ` Mike Rapoport 2010-02-17 14:37 ` Samuel Ortiz 2010-02-17 14:37 ` Samuel Ortiz 2010-02-18 17:42 ` [PATCH v2 " Denis Turischev 2010-02-18 17:42 ` Denis Turischev 2010-02-18 17:45 ` Randy Dunlap 2010-02-18 17:45 ` Randy Dunlap 2010-02-18 18:01 ` [PATCH v3 " Denis Turischev 2010-02-18 18:01 ` Denis Turischev 2010-02-18 18:08 ` Randy Dunlap 2010-02-18 18:08 ` Randy Dunlap 2010-02-19 10:30 ` Samuel Ortiz 2010-02-19 10:30 ` Samuel Ortiz 2010-02-23 8:26 ` Jean Delvare 2010-02-23 8:26 ` Jean Delvare 2010-02-23 9:25 ` Denis Turischev 2010-02-23 9:25 ` Denis Turischev 2010-02-23 9:41 ` Samuel Ortiz 2010-02-23 9:41 ` Samuel Ortiz 2010-02-11 10:28 ` [PATCH 2/3] i2c: convert i2c-isch to platform_device Denis Turischev 2010-02-11 10:28 ` Denis Turischev 2010-02-17 15:42 ` [PATCH v2 " Denis Turischev 2010-02-19 10:33 ` Samuel Ortiz 2010-02-19 10:33 ` Samuel Ortiz 2010-02-21 12:46 ` [PATCH v3 " Denis Turischev 2010-02-21 12:46 ` Denis Turischev 2010-02-23 7:00 ` Mike Rapoport 2010-02-23 7:00 ` Mike Rapoport 2010-02-23 8:12 ` Jean Delvare 2010-02-23 8:12 ` Jean Delvare 2010-02-23 8:20 ` Samuel Ortiz 2010-02-23 8:20 ` Samuel Ortiz 2010-02-23 8:24 ` Jean Delvare 2010-02-23 8:24 ` Jean Delvare 2010-02-28 19:00 ` Samuel Ortiz 2010-03-01 16:59 ` [PATCH v4 " Denis Turischev 2010-03-01 16:59 ` Denis Turischev 2010-03-02 10:06 ` Samuel Ortiz 2010-03-02 10:06 ` Samuel Ortiz 2010-02-11 10:28 ` [PATCH 3/3] gpio: add Intel SCH GPIO controller driver Denis Turischev 2010-02-11 10:28 ` Denis Turischev 2010-02-17 15:39 ` [PATCH v2 " Denis Turischev 2010-02-21 12:50 ` [PATCH v3 " Denis Turischev 2010-02-21 19:12 ` David Brownell 2010-02-24 6:49 ` Mike Rapoport 2010-03-01 18:09 ` Len Brown 2010-03-01 19:50 ` Alan Cox 2010-03-02 6:42 ` Mike Rapoport 2010-03-02 9:29 ` Denis Turischev 2010-02-28 19:01 ` Samuel Ortiz 2010-03-01 17:02 ` [PATCH v4 " Denis Turischev 2010-03-02 10:09 ` Samuel Ortiz
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.