mfd: Add LPC driver for Intel ICH chipsets
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): c68928fc-816e-4738-9108-ee3dfbf6427b@zimbra
PATCH v4 1/3 mfd: Add LPC driver for Intel ICH chipsets
This driver currently creates resources for use by a forthcoming ICH chipset GPIO driver. It could be expanded to created the resources for converting the esb2rom (mtd) and iTCO_wdt (wdt), and potentially more, drivers to use the mfd model.
--- drivers/mfd/Kconfig | 9 + drivers/mfd/Makefile | 1 + drivers/mfd/lpc_ich.c | 525 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/lpc_ich.h | 32 +++ 4 files changed, 567 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/lpc_ich.c create mode 100644 include/linux/mfd/lpc_ich.h
drivers/mfd/Kconfig +9 -0
@@ -724,6 +724,15 @@ config LPC_SCH LPC bridge function of the Intel SCH provides support for System Management Bus and General Purpose I/O. +config LPC_ICH + tristate "Intel ICH LPC" + depends on PCI + select MFD_CORE + help + The LPC bridge function of the Intel ICH provides support for + many functional units. This driver provides needed support for + other drivers to control these functions, currently GPIO. + config MFD_RDC321X tristate "Support for RDC-R321x southbridge" select MFD_CORE
drivers/mfd/Makefile +1 -0
@@ -98,6 +98,7 @@ obj-$(CONFIG_MFD_DB5500_PRCMU) += db5500-prcmu.o obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o obj-$(CONFIG_PMIC_ADP5520) += adp5520.o obj-$(CONFIG_LPC_SCH) += lpc_sch.o +obj-$(CONFIG_LPC_ICH) += lpc_ich.o obj-$(CONFIG_MFD_RDC321X) += rdc321x-southbridge.o obj-$(CONFIG_MFD_JANZ_CMODIO) += janz-cmodio.o obj-$(CONFIG_MFD_JZ4740_ADC) += jz4740-adc.o
drivers/mfd/lpc_ich.c new file +525 -0
525 lines not on this page · raw message
include/linux/mfd/lpc_ich.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* linux/drivers/mfd/lpc_ich.h +* +* Copyright (c) 2012 Extreme Engineering Solution, Inc. +* Author: Aaron Sierra <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; see the file COPYING. If not, write to +* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#ifndef LPC_ICH_H +#define LPC_ICH_H + +/* GPIO resources */ +#define ICH_RES_GPIO 0 +#define ICH_RES_GPE0 1 + +struct lpc_ich_info { +char name[32 ]; +unsigned int gpio_version; +}; + +#endif
Signature · 1 line
1.7.0.4
Hi Aaron,
Quoted 7 lines · Aaron Sierra
This driver currently creates resources for use by a forthcoming ICH chipset GPIO driver. It could be expanded to created the resources for converting the esb2rom (mtd) and
iTCO_wdt(wdt), and potentially more, drivers to use the mfd model.Signed-off-by Aaron Sierra <[email protected]>Signed-off-by Guenter Roeck <[email protected]>
Sorry I have some more comments. You resent the patch series yesterday faster than I could review v3.
Quoted 10 lines
--- drivers/mfd/Kconfig | 9 + drivers/mfd/Makefile | 1 + drivers/mfd/lpc_ich.c | 525 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/lpc_ich.h | 32 +++ 4 files changed, 567 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/lpc_ich.c create mode 100644 include/linux/mfd/lpc_ich.h(...)
drivers/mfd/lpc_ich.c line 94
Quoted 5 lines
drivers/mfd/lpc_ich.c new file +5
-0+static struct mfd_cell lpc_ich_cells[] = { + [LPC_GPIO ] = { + .name ="gpio_ich" , + .num_resources =ARRAY_SIZE (gpio_ich_res), + .resources = gpio_ich_res,
I think you should set ignore_resource_conflicts here too. Your code is already checking for ACPI resource conflicts, so there is no point in having mfd-core check again. This is not only redundant, this also makes the kernel log harder to read as the warnings are printed multiple times.
drivers/mfd/lpc_ich.c line 405
Quoted 11 lines
(...)
drivers/mfd/lpc_ich.c new file +10
-0+static void lpc_ich_restore_config_space (struct pci_dev *dev) +{ +if (lpc_ich_acpi_save >=0 ) +pci_write_config_byte (dev,ACPICTRL , lpc_ich_acpi_save); +if (lpc_ich_gpio_save >=0 ) +pci_write_config_byte (dev,GPIOCTRL , lpc_ich_gpio_save); + + lpc_ich_acpi_save =-1 ; + lpc_ich_gpio_save =-1 ; +}
A minor optimization is possible here, by including the "save = -1" statements inside their respective conditional.
drivers/mfd/lpc_ich.c line 408
Quoted 3 lines
drivers/mfd/lpc_ich.c new file +3
-0+ +static void lpc_ich_finalize_cell (struct mfd_cell *cell, +const struct pci_device_id *id)
Called from a __devinit function so could be made __devinit too.
Quoted 21 lines
drivers/mfd/lpc_ich.c new file +21
-0+{ + cell->id = id->driver_data; + cell->platform_data = &lpc_chipset_info[id->driver_data]; + cell->pdata_size =sizeof (struct lpc_ich_info ); +} + +static int __devinit lpc_ich_probe (struct pci_dev *dev, +const struct pci_device_id *id) +{ +u32 base_addr_cfg; +u32 base_addr; +u8 reg_save; +int ret; +bool cell_added = false; +bool acpi_conflict = false; + +/* Setup power management base register */ +pci_read_config_dword (dev,ACPIBASE , &base_addr_cfg); + base_addr = base_addr_cfg &0x0000ff80 ; +if (!base_addr) { +dev_err (&dev->dev,"I/O space for ACPI uninitialized\n" );
drivers/mfd/lpc_ich.c line 439
Quoted 10 lines
drivers/mfd/lpc_ich.c new file +10
-0+ goto pm_done; + } + + gpio_ich_res[ICH_RES_GPE0 ].start = base_addr +ACPIBASE_GPE_OFF ; + gpio_ich_res[ICH_RES_GPE0 ].end = base_addr +ACPIBASE_GPE_END ; + ret =acpi_check_resource_conflict (&gpio_ich_res[ICH_RES_GPE0 ]); +if (ret) { +/* this isn't necessarily fatal for the GPIO */ + gpio_ich_res[ICH_RES_GPE0 ].start =0 ; + gpio_ich_res[ICH_RES_GPE0 ].end =0 ;
Is it really sufficient to disable the resource? I see that you handle this case properly in the gpio-ich driver, however there's also the platform subsystem which needs to be considered. The above will cause platform_device_add_resources (called by mfd_add_device) to register an I/O resource at address 0, size 1. I can see it in /proc/ioports:
0000-0cf7 : PCI Bus 0000:00
0000-001f : dma1
0000-0000 : gpio_ich.32 <-- HERE
0020-0021 : pic1
This is not clean and could cause a conflict on its own. So I don't think this is the right approach. See below for a possible solution.
Review
Quoted 1 line
(quoted diff) +1
-0+ acpi_conflict = true;
Don't you want to jump to pm_done here? There's no point in enabling the LPC ACPI space if you are never going to access it. Not that it should really make a difference in practice, I presume that if ACPI is using the resource, the LPC ACPI space is already enabled...
Quoted 14 lines
drivers/mfd/lpc_ich.c new file +14
-0+ } + +/* Enable LPC ACPI space */ +pci_read_config_byte (dev,ACPICTRL , ®_save); +pci_write_config_byte (dev,ACPICTRL , reg_save |0x10 ); + lpc_ich_acpi_save = reg_save; + +pm_done: +/* Setup GPIO base register */ +pci_read_config_dword (dev,GPIOBASE , &base_addr_cfg); + base_addr = base_addr_cfg &0x0000ff80 ; +if (!base_addr) { +dev_err (&dev->dev,"I/O space for GPIO uninitialized\n" ); +/* GPIO in power-management space may still be available */
drivers/mfd/lpc_ich.c line 464
Quoted 10 lines
drivers/mfd/lpc_ich.c new file +10
-0+ goto gpio_reg; + } + + gpio_ich_res[ICH_RES_GPIO ].start = base_addr; + gpio_ich_res[ICH_RES_GPIO ].end = base_addr +GPIOBASE_IO_SIZE -1 ; + ret =acpi_check_resource_conflict (&gpio_ich_res[ICH_RES_GPIO ]); +if (ret) { +/* this isn't necessarily fatal for the GPIO */ + gpio_ich_res[ICH_RES_GPIO ].start =0 ; + gpio_ich_res[ICH_RES_GPIO ].end =0 ;
I don't quite get how this can be non-fatal, given that the gpio-ich driver's probe function will return -ENODEV in this case. So if this resource is mandatory, let's make it exactly that. This means that resource 0 is mandatory and resource 1 is optional. All you have to do then is:
* Don't register the mfd device at all if GPIO resource is unavailable.
* If ACPI resource is unavailable, set num_resources to 1.
That should work, and this solves the ghost resource problem I mentioned earlier.
Yet a completely different approach would be to delegate the ACPI resource conflict checking to the gpio-ich subdriver. I suspect we may end up doing that anyway, as requesting the whole I/O range when we only need subsets thereof is likely to cause ACPI resource conflicts on too many systems for the driver to be useful in practice. This is a bigger change though and I would understand if you are reluctant to do it as this point of the review cycle. This can be changed later and I volunteer to take care of it (I need it for my Asus Z8NA-D6 board.)
drivers/mfd/lpc_ich.c line 474
Quoted 10 lines
drivers/mfd/lpc_ich.c new file +10
-0+ acpi_conflict = true; + goto gpio_reg; + } + +/* Enable LPC GPIO space */ +pci_read_config_byte (dev,GPIOCTRL , ®_save); +pci_write_config_byte (dev,GPIOCTRL , reg_save |0x10 ); + lpc_ich_gpio_save = reg_save; + +gpio_reg:
Shouldn't this label be named gpio_done for consistency? Probably a moot point given my remark above anyway.
drivers/mfd/lpc_ich.c line 483
Quoted 9 lines
drivers/mfd/lpc_ich.c new file +9
-0+lpc_ich_finalize_cell (&lpc_ich_cells[LPC_GPIO ], id); + ret =mfd_add_devices (&dev->dev,0 , &lpc_ich_cells[LPC_GPIO ], +1 ,NULL ,0 ); +if (!ret) + cell_added = true; + +if (acpi_conflict) +dev_info (&dev->dev,"ACPI resource conflicts found; " +"consider using acpi_enforce_resources=lax?\n" );
I'm not sure if it really makes sense to report this. ACPI resource conflicts are already reported quite loudly by the acpi core. And passing acpi_enforce_resources=lax blindly isn't quite recommended, so I'm not sure if we really want to mention it here, it might do more harm than help.
Quoted 12 lines
drivers/mfd/lpc_ich.c new file +12
-0+ +/* +* We only care if at least one or none of the cells registered +* successfully. +*/ +if (!cell_added) { +lpc_ich_restore_config_space (dev); +return -ENODEV ; + } + +return 0 ; +}
Signature · 1 line
Jean Delvare
Quoted 38 lines
Quoted 21 lines
drivers/mfd/lpc_ich.c new file +21
-0+{ + cell->id = id->driver_data; + cell->platform_data = &lpc_chipset_info[id->driver_data]; + cell->pdata_size =sizeof (struct lpc_ich_info ); +} + +static int __devinit lpc_ich_probe (struct pci_dev *dev, +const struct pci_device_id *id) +{ +u32 base_addr_cfg; +u32 base_addr; +u8 reg_save; +int ret; +bool cell_added = false; +bool acpi_conflict = false; + +/* Setup power management base register */ +pci_read_config_dword (dev,ACPIBASE , &base_addr_cfg); + base_addr = base_addr_cfg &0x0000ff80 ; +if (!base_addr) { +dev_err (&dev->dev,"I/O space for ACPI uninitialized\n" );drivers/mfd/lpc_ich.c line 439
Quoted 10 lines
drivers/mfd/lpc_ich.c new file +10
-0+ goto pm_done; + } + + gpio_ich_res[ICH_RES_GPE0 ].start = base_addr +ACPIBASE_GPE_OFF ; + gpio_ich_res[ICH_RES_GPE0 ].end = base_addr +ACPIBASE_GPE_END ; + ret =acpi_check_resource_conflict (&gpio_ich_res[ICH_RES_GPE0 ]); +if (ret) { +/* this isn't necessarily fatal for the GPIO */ + gpio_ich_res[ICH_RES_GPE0 ].start =0 ; + gpio_ich_res[ICH_RES_GPE0 ].end =0 ;Is it really sufficient to disable the resource? I see that you handle this case properly in the gpio-ich driver, however there's also the platform subsystem which needs to be considered. The above will cause
platform_device_add_resources(called bymfd_add_device) to register an I/O resource at address 0, size 1. I can see it in/proc/ioports:
Quoted 7 lines
0000-0cf7 : PCI Bus 0000:00
0000-001f : dma10000-0000 : gpio_ich.32 <-- HERE0020-0021 : pic1
This is not clean and could cause a conflict on its own. So I don't think this is the right approach. See below for a possible solution.
I will work on a solution for this.
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ acpi_conflict = true;Don't you want to jump to
pm_donehere? There's no point in enabling the LPC ACPI space if you are never going to access it. Not that it should really make a difference in practice, I presume that if ACPI is using the resource, the LPC ACPI space is already enabled...
I think this is another case where the code structure is based on the complete 3-patch set. In this patch it would makes sense to have a jump here, but after the 3rd patch is applied it would be removed anyway because I consider the GPE region to be not strictly mandatory (which I get into more below) and the watchdog timer regions in ACPI space need to be tested before jumping.
Quoted 21 lines
Quoted 21 lines
drivers/mfd/lpc_ich.c new file +19
-0+ } + +/* Enable LPC ACPI space */ +pci_read_config_byte (dev,ACPICTRL , ®_save); +pci_write_config_byte (dev,ACPICTRL , reg_save |0x10 ); + lpc_ich_acpi_save = reg_save; + +pm_done: +/* Setup GPIO base register */ +pci_read_config_dword (dev,GPIOBASE , &base_addr_cfg); + base_addr = base_addr_cfg &0x0000ff80 ; +if (!base_addr) { +dev_err (&dev->dev,"I/O space for GPIO uninitialized\n" ); +/* GPIO in power-management space may still be available */ + goto gpio_reg; + } + + gpio_ich_res[ICH_RES_GPIO ].start = base_addr; + gpio_ich_res[ICH_RES_GPIO].end = base_addr + GPIOBASE_IO_SIZE -1;
drivers/mfd/lpc_ich.c new file +1
-0+ ret =acpi_check_resource_conflict (&gpio_ich_res[ICH_RES_GPIO ]);
Quoted 8 lines
drivers/mfd/lpc_ich.c line 464
Quoted 4 lines
drivers/mfd/lpc_ich.c new file +4
-0+if (ret) { +/* this isn't necessarily fatal for the GPIO */ + gpio_ich_res[ICH_RES_GPIO ].start =0 ; + gpio_ich_res[ICH_RES_GPIO ].end =0 ;I don't quite get how this can be non-fatal, given that the gpio-ich driver's probe function will return
-ENODEVin this case. So if this resource is mandatory, let's make it exactly that.
The necessity for the ICH_RES_GPIO resource to exist is an issue I thought better left to the gpio-ich driver. The way that driver is currently written it is mandatory, but it doesn't *have* to be written that way. For chipsets that have GPE0 and GPIO space, only one needs to be present to have some usable GPIO.
Quoted 9 lines
This means that resource 0 is mandatory and resource 1 is optional. All you have to do then is:
* Don't register the mfd device at all if GPIO resource is unavailable.
* If ACPI resource is unavailable, setnum_resourcesto 1.That should work, and this solves the ghost resource problem I mentioned earlier.
Quoted 9 lines
Yet a completely different approach would be to delegate the ACPI resource conflict checking to the gpio-ich subdriver. I suspect we may end up doing that anyway, as requesting the whole I/O range when we only need subsets thereof is likely to cause ACPI resource conflicts on too many systems for the driver to be useful in practice. This is a bigger change though and I would understand if you are reluctant to do it as this point of the review cycle. This can be changed later and I volunteer to take care of it (I need it for my Asus Z8NA-D6 board.)
You mean creating resources for individual bytes within 32-bit registers? Otherwise, the only optimization (fix) I see is that ACPIBASE_GPE0_BASE should be 0x28, not 0x20 and gpe0_sts_ofs in gpio-ich should be removed. Currently, that portion of gpio-ich appears to be broken.
The whole issue of anything related to boot firmware having dominion over hardware after booting to an OS is very frustrating.
Quoted 5 lines
Quoted 5 lines
drivers/mfd/lpc_ich.c new file +5
-0+ acpi_conflict = true; + goto gpio_reg; + } + +/* Enable LPC GPIO space */
Quoted 8 lines
drivers/mfd/lpc_ich.c line 474
Quoted 5 lines
drivers/mfd/lpc_ich.c new file +5
-0+pci_read_config_byte (dev,GPIOCTRL , ®_save); +pci_write_config_byte (dev,GPIOCTRL , reg_save |0x10 ); + lpc_ich_gpio_save = reg_save; + +gpio_reg:Shouldn't this label be named
gpio_donefor consistency? Probably a moot point given my remark above anyway.
Again, the label names come from lpc_ich after all three patches have been applied. In that case one label jumps to code immediately following WDT cell registration, "done with registration" and the other jumps immediately before GPIO cell registration, "do registration". If I make ICH_RES_GPIO mandatory, like you suggest, these labels could both follow cell registration and be named consistently.
Quoted 7 lines
Quoted 7 lines
drivers/mfd/lpc_ich.c new file +7
-0+lpc_ich_finalize_cell (&lpc_ich_cells[LPC_GPIO ], id); + ret =mfd_add_devices (&dev->dev,0 , &lpc_ich_cells[LPC_GPIO ], +1 ,NULL ,0 ); +if (!ret) + cell_added = true; + +if (acpi_conflict)
Quoted 8 lines
drivers/mfd/lpc_ich.c line 483
Quoted 2 lines
drivers/mfd/lpc_ich.c new file +2
-0+dev_info (&dev->dev,"ACPI resource conflicts found; " +"consider using acpi_enforce_resources=lax?\n" );I'm not sure if it really makes sense to report this. ACPI resource conflicts are already reported quite loudly by the acpi core. And passing acpi_enforce_resources=lax blindly isn't quite recommended, so I'm not sure if we really want to mention it here, it might do more harm than help.
So the question mark doesn't imply strongly enough that it's not an action that should definitely be taken. Would you prefer a warning summarizing which drivers are affected by the detected resource conflicts or no additional warning at all?
-Aaron S.
Quoted 30 lines · Aaron Sierra
Quoted 21 lines
Quoted 21 lines
drivers/mfd/lpc_ich.c new file +19
-0+ } + +/* Enable LPC ACPI space */ +pci_read_config_byte (dev,ACPICTRL , ®_save); +pci_write_config_byte (dev,ACPICTRL , reg_save |0x10 ); + lpc_ich_acpi_save = reg_save; + +pm_done: +/* Setup GPIO base register */ +pci_read_config_dword (dev,GPIOBASE , &base_addr_cfg); + base_addr = base_addr_cfg &0x0000ff80 ; +if (!base_addr) { +dev_err (&dev->dev,"I/O space for GPIO uninitialized\n" ); +/* GPIO in power-management space may still be available */ + goto gpio_reg; + } + + gpio_ich_res[ICH_RES_GPIO ].start = base_addr; + gpio_ich_res[ICH_RES_GPIO].end = base_addr + GPIOBASE_IO_SIZE -1;
drivers/mfd/lpc_ich.c new file +1
-0+ ret =acpi_check_resource_conflict (&gpio_ich_res[ICH_RES_GPIO ]);Quoted 8 lines
drivers/mfd/lpc_ich.c line 464
Quoted 4 lines
drivers/mfd/lpc_ich.c new file +4
-0+if (ret) { +/* this isn't necessarily fatal for the GPIO */ + gpio_ich_res[ICH_RES_GPIO ].start =0 ; + gpio_ich_res[ICH_RES_GPIO ].end =0 ;I don't quite get how this can be non-fatal, given that the gpio-ich driver's probe function will return
-ENODEVin this case. So if this resource is mandatory, let's make it exactly that.
Quoted 5 lines
The necessity for the
ICH_RES_GPIOresource to exist is an issue I thought better left to the gpio-ich driver. The way that driver is currently written it is mandatory, but it doesn't *have* to be written that way. For chipsets that have GPE0 and GPIO space, only one needs to be present to have some usable GPIO.
Ah, OK, I had misunderstood this, I thought GPIO was always mandatory.
We're only talking about the ICH6 and 3100, right? I find it questionable that you even attempt to request and enable the GPE0 space on all other chips then. This could cause error messages that are not relevant at all.
Quoted 20 lines
Quoted 10 lines
This means that resource 0 is mandatory and resource 1 is optional. All you have to do then is:
* Don't register the mfd device at all if GPIO resource is unavailable.
* If ACPI resource is unavailable, setnum_resourcesto 1.That should work, and this solves the ghost resource problem I mentioned earlier.
Quoted 9 lines
Yet a completely different approach would be to delegate the ACPI resource conflict checking to the gpio-ich subdriver. I suspect we may end up doing that anyway, as requesting the whole I/O range when we only need subsets thereof is likely to cause ACPI resource conflicts on too many systems for the driver to be useful in practice. This is a bigger change though and I would understand if you are reluctant to do it as this point of the review cycle. This can be changed later and I volunteer to take care of it (I need it for my Asus Z8NA-D6 board.)
Quoted 1 line
You mean creating resources for individual bytes within 32-bit registers?
No, no, not to this level of granularity. My idea is to request 3 16-byte regions separately, namely starting at offsets 0x00, 0x30 and 0x40. This has two advantages :
* If the ACPI BIOS requests optional I/O ports as is the case on my board (they request one port at offset 0x1A, presumably to blink a LED) we can still request everything else. Of course we shouldn't touch the one GPIO used by the ACPI BIOS, but you should never touch a GPIO if you don't know what you're doing anyway.
* If the ACPI BIOS requests one block of GPIOs, this still gives us a chance to get our hands on the other blocks. I have not yet see a BIOS doing that but I imagine it could happen.
Quoted 3 lines
Otherwise, the only optimization (fix) I see is that
ACPIBASE_GPE0_BASEshould be0x28, not0x20andgpe0_sts_ofsin gpio-ich should be removed. Currently, that portion of gpio-ich appears to be broken.
If you only need the I/O port at offset 0x28, then indeed it might make sense to only request that one to limit the risk of resource conflicts.
Quoted 2 lines
The whole issue of anything related to boot firmware having dominion over hardware after booting to an OS is very frustrating.
Oh yes :( I really would like to see future versions of the ACPI specification come up with a general solution to this problem.
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
drivers/mfd/lpc_ich.c new file +5
-0+ acpi_conflict = true; + goto gpio_reg; + } + +/* Enable LPC GPIO space */ Quoted 8 lines
drivers/mfd/lpc_ich.c line 474
Quoted 5 lines
drivers/mfd/lpc_ich.c new file +5
-0+pci_read_config_byte (dev,GPIOCTRL , ®_save); +pci_write_config_byte (dev,GPIOCTRL , reg_save |0x10 ); + lpc_ich_gpio_save = reg_save; + +gpio_reg:Shouldn't this label be named
gpio_donefor consistency? Probably a moot point given my remark above anyway.
Quoted 6 lines
Again, the label names come from
lpc_ichafter all three patches have been applied. In that case one label jumps to code immediately following WDT cell registration, "done with registration" and the other jumps immediately before GPIO cell registration, "do registration". If I makeICH_RES_GPIOmandatory, like you suggest, these labels could both follow cell registration and be named consistently.
Oh, OK. I have to admit I didn't look at the watchdog patch at all, as I'm not using this feature. So feel free to ignore every comment of mine which would find an answer in that patch ;)
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
drivers/mfd/lpc_ich.c new file +7
-0+lpc_ich_finalize_cell (&lpc_ich_cells[LPC_GPIO ], id); + ret =mfd_add_devices (&dev->dev,0 , &lpc_ich_cells[LPC_GPIO ], +1 ,NULL ,0 ); +if (!ret) + cell_added = true; + +if (acpi_conflict)Quoted 8 lines
drivers/mfd/lpc_ich.c line 483
Quoted 2 lines
drivers/mfd/lpc_ich.c new file +2
-0+dev_info (&dev->dev,"ACPI resource conflicts found; " +"consider using acpi_enforce_resources=lax?\n" );I'm not sure if it really makes sense to report this. ACPI resource conflicts are already reported quite loudly by the acpi core. And passing acpi_enforce_resources=lax blindly isn't quite recommended, so I'm not sure if we really want to mention it here, it might do more harm than help.
Quoted 4 lines
So the question mark doesn't imply strongly enough that it's not an action that should definitely be taken. Would you prefer a warning summarizing which drivers are affected by the detected resource conflicts or no additional warning at all?
I wouldn't put any additional warning at all. But maybe that's just me.
Signature · 1 line
Jean Delvare
Quoted 40 lines · Aaron Sierra
Quoted 33 lines
Quoted 24 lines
Quoted 24 lines
drivers/mfd/lpc_ich.c new file +19
-1+ } + +/* Enable LPC ACPI space */ +pci_read_config_byte (dev,ACPICTRL , ®_save); +pci_write_config_byte (dev,ACPICTRL , reg_save |0x10 ); + lpc_ich_acpi_save = reg_save; + +pm_done: +/* Setup GPIO base register */ +pci_read_config_dword (dev,GPIOBASE , &base_addr_cfg); + base_addr = base_addr_cfg &0x0000ff80 ; +if (!base_addr) { +dev_err (&dev->dev,"I/O space for GPIO uninitialized\n" ); +/* GPIO in power-management space may still be available */ + goto gpio_reg; + } + + gpio_ich_res[ICH_RES_GPIO ].start = base_addr; + gpio_ich_res[ICH_RES_GPIO ].end = base_addr +GPIOBASE_IO_SIZE -1;
(quoted diff) +1
-0+ ret =
acpi_check_resource_conflict(&gpio_ich_res[ICH_RES_GPIO]);(quoted diff) +1
-0+ if (ret) {Quoted 8 lines
drivers/mfd/lpc_ich.c line 464
Quoted 3 lines
drivers/mfd/lpc_ich.c new file +3
-0+/* this isn't necessarily fatal for the GPIO */ + gpio_ich_res[ICH_RES_GPIO ].start =0 ; + gpio_ich_res[ICH_RES_GPIO ].end =0 ;I don't quite get how this can be non-fatal, given that the gpio-ich driver's probe function will return
-ENODEVin this case. So if this resource is mandatory, let's make it exactly that.Quoted 5 lines
The necessity for the
ICH_RES_GPIOresource to exist is an issue I thought better left to the gpio-ich driver. The way that driver is currently written it is mandatory, but it doesn't *have* to be written that way. For chipsets that have GPE0 and GPIO space, only one needs to be present to have some usable GPIO.
Quoted 7 lines
Ah, OK, I had misunderstood this, I thought GPIO was always mandatory.
We're only talking about the ICH6 and 3100, right? I find it questionable that you even attempt to request and enable the GPE0 space on all other chips then. This could cause error messages that are not relevant at all.
You'll see in the V5 patch that I followed your suggestion and now treat the GPIO space as mandatory. The local version I have prepared for V6 only looks for GPE0 space for ICH6 and i3100 devices.
Quoted 8 lines
Quoted 4 lines
Otherwise, the only optimization (fix) I see is that
ACPIBASE_GPE0_BASEshould be0x28, not0x20andgpe0_sts_ofsin gpio-ich should be removed. Currently, that portion of gpio-ich appears to be broken.If you only need the I/O port at offset
0x28, then indeed it might make sense to only request that one to limit the risk of resource conflicts.
I addressed this with V5.
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
drivers/mfd/lpc_ich.c line 483
Quoted 9 lines
drivers/mfd/lpc_ich.c new file +9
-0+lpc_ich_finalize_cell (&lpc_ich_cells[LPC_GPIO ], id); + ret =mfd_add_devices (&dev->dev,0 , &lpc_ich_cells[LPC_GPIO ], +1 ,NULL ,0 ); +if (!ret) + cell_added = true; + +if (acpi_conflict) +dev_info (&dev->dev,"ACPI resource conflicts found; " +"consider using acpi_enforce_resources=lax?\n" );I'm not sure if it really makes sense to report this. ACPI resource
conflicts are already reported quite loudly by the acpi core. And passing acpi_enforce_resources=lax blindly isn't quite recommended,
so I'm not sure if we really want to mention it here, it might do more
harm than help.
Quoted 7 lines
Quoted 4 lines
So the question mark doesn't imply strongly enough that it's not an action that should definitely be taken. Would you prefer a warning summarizing which drivers are affected by the detected resource conflicts or no additional warning at all?
I wouldn't put any additional warning at all. But maybe that's just me.
In V5, I added warnings indicating which drivers are affected by conflicts, since it was trivial with the way that I compartmentalized gpio and watchdog mfd cell creation in that version.
-Aaron S.
Oh, BTW...
drivers/mfd/lpc_ich.c line 410
Quoted 13 lines · Aaron Sierra
This driver currently creates resources for use by a forthcoming ICH chipset GPIO driver. It could be expanded to created the resources for converting the esb2rom (mtd) and
iTCO_wdt(wdt), and potentially more, drivers to use the mfd model.Signed-off-by Aaron Sierra <[email protected]>Signed-off-by Guenter Roeck <[email protected]>---
(...)drivers/mfd/lpc_ich.c new file +4
-0+static void lpc_ich_finalize_cell (struct mfd_cell *cell, +const struct pci_device_id *id) +{ + cell->id = id->driver_data;
I don't think this makes any sense. By using global variables for per-device resources and states, your driver pretty much assumes that at most one supported device is present on every given system (which is indeed always the case AFAIK.) So you should set id to 0 here...
drivers/mfd/lpc_ich.c line 477
Quoted 6 lines
drivers/mfd/lpc_ich.c new file +5
-0+ cell->platform_data = &lpc_chipset_info[id->driver_data]; + cell->pdata_size =sizeof (struct lpc_ich_info ); +} + ret =mfd_add_devices (&dev->dev,0 , &lpc_ich_cells[LPC_GPIO ], +1 ,NULL ,0 );
... and to -1 here, so that the platform devices created don't receive a number at all. Many mfd drivers do exactly this.
Signature · 1 line
Jean Delvare