* [patch 0/5] PNP: convert x86 legacy serial to platform devs, add SMC IR PNP probe
@ 2007-04-04 22:45 Bjorn Helgaas
2007-04-04 22:45 ` [patch 1/5] PNP: notice whether we have PNP devices (PNPBIOS or PNPACPI) Bjorn Helgaas
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2007-04-04 22:45 UTC (permalink / raw)
To: Andrew Morton
Cc: Keith Owens, Len Brown, Adam Belay, Matthieu CASTET,
Jean Tourrilhes, Matthew Garrett, Ville Syrjala, Russell King,
linux-serial, Samuel Ortiz, linux-kernel
This series converts i386 and x86_64 legacy serial ports to be platform
devices and prevents probing for them if we have PNP.
This prevents double discovery, where a device was found both by the
legacy probe and by 8250_pnp.
This also prevents the serial driver from claiming IRDA devices (unless
they have a UART PNP ID). The serial legacy probe sometimes assumed the
wrong IRQ, so the user had to use "setserial" to fix it.
Removing the need for setserial to make IRDA devices work seems good,
but it does break some things. In particular, you may need to keep
setserial from poking legacy UART stuff back in by doing something like
"dpkg-reconfigure setserial" with the "kernel" option. Otherwise, the
setserial-discovered "UART" will claim resources and prevent the IRDA
driver from loading.
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* [patch 1/5] PNP: notice whether we have PNP devices (PNPBIOS or PNPACPI)
2007-04-04 22:45 [patch 0/5] PNP: convert x86 legacy serial to platform devs, add SMC IR PNP probe Bjorn Helgaas
@ 2007-04-04 22:45 ` Bjorn Helgaas
2007-04-04 22:45 ` [patch 2/5] PNP: workaround HP BIOS defect that leaves SMCF010 device partly enabled Bjorn Helgaas
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2007-04-04 22:45 UTC (permalink / raw)
To: Andrew Morton
Cc: Keith Owens, Len Brown, Adam Belay, Matthieu CASTET,
Jean Tourrilhes, Matthew Garrett, Ville Syrjala, Russell King,
linux-serial, Samuel Ortiz, linux-kernel
[-- Attachment #1: pnp-platform-devs.patch --]
[-- Type: text/plain, Size: 2645 bytes --]
If we can discover devices using PNP, we can skip some legacy probes.
This flag ("pnp_platform_devices") indicates that PNPBIOS or PNPACPI
is enabled and should tell us about builtin devices.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work/drivers/pnp/core.c
===================================================================
--- work.orig/drivers/pnp/core.c 2007-03-27 13:05:23.000000000 -0600
+++ work/drivers/pnp/core.c 2007-03-27 16:12:54.000000000 -0600
@@ -23,6 +23,14 @@
LIST_HEAD(pnp_global);
DEFINE_SPINLOCK(pnp_lock);
+/*
+ * ACPI or PNPBIOS should tell us about all platform devices, so we can
+ * skip some blind probes. ISAPNP typically enumerates only plug-in ISA
+ * devices, not built-in things like COM ports.
+ */
+int pnp_platform_devices;
+EXPORT_SYMBOL(pnp_platform_devices);
+
void *pnp_alloc(long size)
{
void *result;
Index: work/drivers/pnp/pnpacpi/core.c
===================================================================
--- work.orig/drivers/pnp/pnpacpi/core.c 2007-03-27 13:05:23.000000000 -0600
+++ work/drivers/pnp/pnpacpi/core.c 2007-03-27 14:44:05.000000000 -0600
@@ -247,6 +247,7 @@
pnp_register_protocol(&pnpacpi_protocol);
acpi_get_devices(NULL, pnpacpi_add_device_handler, NULL, NULL);
pnp_info("PnP ACPI: found %d devices", num);
+ pnp_platform_devices = 1;
return 0;
}
subsys_initcall(pnpacpi_init);
Index: work/drivers/pnp/pnpbios/core.c
===================================================================
--- work.orig/drivers/pnp/pnpbios/core.c 2007-03-27 13:05:23.000000000 -0600
+++ work/drivers/pnp/pnpbios/core.c 2007-03-27 14:44:05.000000000 -0600
@@ -574,6 +574,7 @@
/* scan for pnpbios devices */
build_devlist();
+ pnp_platform_devices = 1;
return 0;
}
Index: work/include/linux/pnp.h
===================================================================
--- work.orig/include/linux/pnp.h 2007-03-27 13:05:23.000000000 -0600
+++ work/include/linux/pnp.h 2007-03-27 14:44:05.000000000 -0600
@@ -364,6 +364,7 @@
int pnp_device_attach(struct pnp_dev *pnp_dev);
void pnp_device_detach(struct pnp_dev *pnp_dev);
extern struct list_head pnp_global;
+extern int pnp_platform_devices;
/* multidevice card support */
int pnp_add_card(struct pnp_card *card);
@@ -411,6 +412,7 @@
static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { ; }
+#define pnp_platform_devices 0
/* multidevice card support */
static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; }
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* [patch 2/5] PNP: workaround HP BIOS defect that leaves SMCF010 device partly enabled
2007-04-04 22:45 [patch 0/5] PNP: convert x86 legacy serial to platform devs, add SMC IR PNP probe Bjorn Helgaas
2007-04-04 22:45 ` [patch 1/5] PNP: notice whether we have PNP devices (PNPBIOS or PNPACPI) Bjorn Helgaas
@ 2007-04-04 22:45 ` Bjorn Helgaas
2007-04-04 22:45 ` [patch 3/5] smsc-ircc2: tidy up module parameter checking Bjorn Helgaas
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2007-04-04 22:45 UTC (permalink / raw)
To: Andrew Morton
Cc: Keith Owens, Len Brown, Adam Belay, Matthieu CASTET,
Jean Tourrilhes, Matthew Garrett, Ville Syrjala, Russell King,
linux-serial, Samuel Ortiz, linux-kernel
[-- Attachment #1: hp-smcf010-quirk.patch --]
[-- Type: text/plain, Size: 1753 bytes --]
Some HP/Compaq firmware reports via ACPI that the SMCF010 IR device is
enabled, but in fact, it leaves the device partly disabled.
HP nw8240 BIOS 68DTV Ver. F.0F, released 9/15/2005 is one BIOS that has
this problem.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: w/drivers/pnp/quirks.c
===================================================================
--- w.orig/drivers/pnp/quirks.c 2007-03-29 14:24:51.000000000 -0600
+++ w/drivers/pnp/quirks.c 2007-03-29 14:42:54.000000000 -0600
@@ -16,6 +16,7 @@
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/pnp.h>
+#include <linux/io.h>
#include "base.h"
@@ -106,6 +107,34 @@
return;
}
+static void quirk_smc_enable(struct pnp_dev *dev)
+{
+ unsigned int firbase;
+
+ if (!dev->active || !pnp_port_valid(dev, 1))
+ return;
+
+ /*
+ * On the HP/Compaq nw8240 (and probably other similar machines),
+ * there is an SMCF010 device with two I/O port regions:
+ *
+ * 0x3e8-0x3ef SIR
+ * 0x100-0x10f FIR
+ *
+ * _STA reports the device is enabled, but in fact, the BIOS
+ * neglects to enable the FIR range. Fortunately, it does fully
+ * enable the device if we call _SRS.
+ */
+ firbase = pnp_port_start(dev, 1);
+ if (inb(firbase + 0x7 /* IRCC_MASTER */) == 0xff) {
+ pnp_err("%s (%s) enabled but not responding, disabling and "
+ "re-enabling", dev->dev.bus_id, pnp_dev_name(dev));
+ pnp_disable_dev(dev);
+ pnp_activate_dev(dev);
+ }
+}
+
+
/*
* PnP Quirks
* Cards or devices that need some tweaking due to incomplete resource info
@@ -126,6 +155,7 @@
{ "CTL0043", quirk_sb16audio_resources },
{ "CTL0044", quirk_sb16audio_resources },
{ "CTL0045", quirk_sb16audio_resources },
+ { "SMCf010", quirk_smc_enable },
{ "" }
};
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* [patch 3/5] smsc-ircc2: tidy up module parameter checking
2007-04-04 22:45 [patch 0/5] PNP: convert x86 legacy serial to platform devs, add SMC IR PNP probe Bjorn Helgaas
2007-04-04 22:45 ` [patch 1/5] PNP: notice whether we have PNP devices (PNPBIOS or PNPACPI) Bjorn Helgaas
2007-04-04 22:45 ` [patch 2/5] PNP: workaround HP BIOS defect that leaves SMCF010 device partly enabled Bjorn Helgaas
@ 2007-04-04 22:45 ` Bjorn Helgaas
2007-04-04 22:45 ` [patch 4/5] smsc-ircc2: add PNP support Bjorn Helgaas
2007-04-04 22:45 ` [patch 5/5] x86, serial: convert legacy COM ports to platform devices Bjorn Helgaas
4 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2007-04-04 22:45 UTC (permalink / raw)
To: Andrew Morton
Cc: Keith Owens, Len Brown, Adam Belay, Matthieu CASTET,
Jean Tourrilhes, Matthew Garrett, Ville Syrjala, Russell King,
linux-serial, Samuel Ortiz, linux-kernel
[-- Attachment #1: smsc-ircc2-tidy-module-param-checking.patch --]
[-- Type: text/plain, Size: 1794 bytes --]
To determine whether the user specified a module parameter, use some #defines
instead of checking for bare magic numbers.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: w/drivers/net/irda/smsc-ircc2.c
===================================================================
--- w.orig/drivers/net/irda/smsc-ircc2.c 2007-04-04 13:38:30.000000000 -0600
+++ w/drivers/net/irda/smsc-ircc2.c 2007-04-04 13:45:18.000000000 -0600
@@ -79,11 +79,13 @@
MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver");
MODULE_LICENSE("GPL");
-static int ircc_dma = 255;
+#define DMA_INVAL 255
+static int ircc_dma = DMA_INVAL;
module_param(ircc_dma, int, 0);
MODULE_PARM_DESC(ircc_dma, "DMA channel");
-static int ircc_irq = 255;
+#define IRQ_INVAL 255
+static int ircc_irq = IRQ_INVAL;
module_param(ircc_irq, int, 0);
MODULE_PARM_DESC(ircc_irq, "IRQ line");
@@ -646,7 +648,7 @@
self->io.fifo_size = SMSC_IRCC2_FIFO_SIZE;
self->io.speed = SMSC_IRCC2_C_IRDA_FALLBACK_SPEED;
- if (irq < 255) {
+ if (irq != IRQ_INVAL) {
if (irq != chip_irq)
IRDA_MESSAGE("%s, Overriding IRQ - chip says %d, using %d\n",
driver_name, chip_irq, irq);
@@ -654,7 +656,7 @@
} else
self->io.irq = chip_irq;
- if (dma < 255) {
+ if (dma != DMA_INVAL) {
if (dma != chip_dma)
IRDA_MESSAGE("%s, Overriding DMA - chip says %d, using %d\n",
driver_name, chip_dma, dma);
@@ -2836,9 +2838,9 @@
tmpconf.fir_io = ircc_fir;
if (ircc_sir != 0)
tmpconf.sir_io = ircc_sir;
- if (ircc_dma != 0xff)
+ if (ircc_dma != DMA_INVAL)
tmpconf.fir_dma = ircc_dma;
- if (ircc_irq != 0xff)
+ if (ircc_irq != IRQ_INVAL)
tmpconf.fir_irq = ircc_irq;
IRDA_MESSAGE("Detected unconfigured %s SMSC IrDA chip, pre-configuring device.\n", conf->name);
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* [patch 4/5] smsc-ircc2: add PNP support
2007-04-04 22:45 [patch 0/5] PNP: convert x86 legacy serial to platform devs, add SMC IR PNP probe Bjorn Helgaas
` (2 preceding siblings ...)
2007-04-04 22:45 ` [patch 3/5] smsc-ircc2: tidy up module parameter checking Bjorn Helgaas
@ 2007-04-04 22:45 ` Bjorn Helgaas
2007-04-04 23:16 ` Randy Dunlap
2007-04-04 22:45 ` [patch 5/5] x86, serial: convert legacy COM ports to platform devices Bjorn Helgaas
4 siblings, 1 reply; 8+ messages in thread
From: Bjorn Helgaas @ 2007-04-04 22:45 UTC (permalink / raw)
To: Andrew Morton
Cc: Keith Owens, Len Brown, Adam Belay, Matthieu CASTET,
Jean Tourrilhes, Matthew Garrett, Ville Syrjala, Russell King,
linux-serial, Samuel Ortiz, linux-kernel
[-- Attachment #1: smsc-ircc2-add-pnp-probe.patch --]
[-- Type: TEXT/PLAIN, Size: 5168 bytes --]
Claim devices using PNP, unless the user explicitly specified device
addresses. This can be disabled with the "smsc-ircc2.nopnp" option.
This removes the need for probing legacy addresses and helps untangle
IR devices from serial8250 devices.
Sometimes the SMC device is at a legacy COM port address but does not
use the legacy COM IRQ. In this case, claiming the device using PNP
rather than 8250 legacy probe means we can automatically use the
correct IRQ rather than forcing the user to use "setserial" to set the
IRQ manually.
If the PNP claim doesn't work, make sure you don't have a setserial init
script, e.g., /etc/init.d/setserial, configured to poke in legacy COM
port resources for the IRDA device. That causes the serial driver to
claim resources needed by this driver.
Based on this patch by Ville Syrjälä:
http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/ir260_smsc_pnp.diff
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: w/drivers/net/irda/smsc-ircc2.c
===================================================================
--- w.orig/drivers/net/irda/smsc-ircc2.c 2007-04-04 13:45:18.000000000 -0600
+++ w/drivers/net/irda/smsc-ircc2.c 2007-04-04 13:47:00.000000000 -0600
@@ -79,6 +79,10 @@
MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver");
MODULE_LICENSE("GPL");
+static int smsc_nopnp;
+module_param_named(nopnp, smsc_nopnp, bool, 0);
+MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings");
+
#define DMA_INVAL 255
static int ircc_dma = DMA_INVAL;
module_param(ircc_dma, int, 0);
@@ -362,7 +366,6 @@
iobase + IRCC_MASTER);
}
-#ifdef CONFIG_PNP
/* PNP hotplug support */
static const struct pnp_device_id smsc_ircc_pnp_table[] = {
{ .id = "SMCf010", .driver_data = 0 },
@@ -370,7 +373,35 @@
{ }
};
MODULE_DEVICE_TABLE(pnp, smsc_ircc_pnp_table);
-#endif
+
+static int pnp_driver_registered;
+
+static int __init smsc_ircc_pnp_probe(struct pnp_dev *dev,
+ const struct pnp_device_id *dev_id)
+{
+ unsigned int firbase, sirbase;
+ u8 dma, irq;
+
+ if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) &&
+ pnp_dma_valid(dev, 0) && pnp_irq_valid(dev, 0)))
+ return -EINVAL;
+
+ sirbase = pnp_port_start(dev, 0);
+ firbase = pnp_port_start(dev, 1);
+ dma = pnp_dma(dev, 0);
+ irq = pnp_irq(dev, 0);
+
+ if (smsc_ircc_open(firbase, sirbase, dma, irq))
+ return -ENODEV;
+
+ return 0;
+}
+
+static struct pnp_driver smsc_ircc_pnp_driver = {
+ .name = "smsc-ircc2",
+ .id_table = smsc_ircc_pnp_table,
+ .probe = smsc_ircc_pnp_probe,
+};
/*******************************************************************************
@@ -381,6 +412,35 @@
*
*******************************************************************************/
+static int __init smsc_ircc_legacy_probe(void)
+{
+ int ret = 0;
+
+ if (ircc_fir > 0 && ircc_sir > 0) {
+ IRDA_MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir);
+ IRDA_MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir);
+
+ if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq))
+ ret = -ENODEV;
+ } else {
+ ret = -ENODEV;
+
+ /* try user provided configuration register base address */
+ if (ircc_cfg > 0) {
+ IRDA_MESSAGE(" Overriding configuration address "
+ "0x%04x\n", ircc_cfg);
+ if (!smsc_superio_fdc(ircc_cfg))
+ ret = 0;
+ if (!smsc_superio_lpc(ircc_cfg))
+ ret = 0;
+ }
+
+ if (smsc_ircc_look_for_chips() > 0)
+ ret = 0;
+ }
+ return ret;
+}
+
/*
* Function smsc_ircc_init ()
*
@@ -408,31 +468,20 @@
dev_count = 0;
- if (ircc_fir > 0 && ircc_sir > 0) {
- IRDA_MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir);
- IRDA_MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir);
-
- if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq))
- ret = -ENODEV;
+ if (smsc_nopnp || !pnp_platform_devices ||
+ ircc_cfg || ircc_fir || ircc_sir ||
+ ircc_dma != DMA_INVAL || ircc_irq != IRQ_INVAL) {
+ ret = smsc_ircc_legacy_probe();
} else {
- ret = -ENODEV;
-
- /* try user provided configuration register base address */
- if (ircc_cfg > 0) {
- IRDA_MESSAGE(" Overriding configuration address "
- "0x%04x\n", ircc_cfg);
- if (!smsc_superio_fdc(ircc_cfg))
- ret = 0;
- if (!smsc_superio_lpc(ircc_cfg))
- ret = 0;
- }
-
- if (smsc_ircc_look_for_chips() > 0)
- ret = 0;
+ if (pnp_register_driver(&smsc_ircc_pnp_driver) == 0)
+ pnp_driver_registered = 1;
}
- if (ret)
+ if (ret) {
+ if (pnp_driver_registered)
+ pnp_unregister_driver(&smsc_ircc_pnp_driver);
platform_driver_unregister(&smsc_ircc_driver);
+ }
return ret;
}
@@ -1842,6 +1891,9 @@
smsc_ircc_close(dev_self[i]);
}
+ if (pnp_driver_registered)
+ pnp_unregister_driver(&smsc_ircc_pnp_driver);
+
platform_driver_unregister(&smsc_ircc_driver);
}
--
-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [patch 5/5] x86, serial: convert legacy COM ports to platform devices
2007-04-04 22:45 [patch 0/5] PNP: convert x86 legacy serial to platform devs, add SMC IR PNP probe Bjorn Helgaas
` (3 preceding siblings ...)
2007-04-04 22:45 ` [patch 4/5] smsc-ircc2: add PNP support Bjorn Helgaas
@ 2007-04-04 22:45 ` Bjorn Helgaas
4 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2007-04-04 22:45 UTC (permalink / raw)
To: Andrew Morton
Cc: Keith Owens, Len Brown, Adam Belay, Matthieu CASTET,
Jean Tourrilhes, Matthew Garrett, Ville Syrjala, Russell King,
linux-serial, Samuel Ortiz, linux-kernel
[-- Attachment #1: x86-change-legacy-serial-to-platform.patch --]
[-- Type: text/plain, Size: 7982 bytes --]
Make x86 COM ports into platform devices and don't probe for them
if we have PNP.
This prevents double discovery, where a device was found both by
the legacy probe and by 8250_pnp, e.g.,
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:02: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
This also means IRDA devices without a UART PNP ID will no longer be
claimed by the serial driver, which might require changes in IRDA
drivers and administration.
In addition to this patch, you may need to configure a setserial init
script, e.g., /etc/init.d/setserial, so it doesn't poke legacy UART
stuff back in. On Debian, "dpkg-reconfigure setserial" with the "kernel"
option does this.
To force the old legacy probe behavior even when we have PNPBIOS or
ACPI, load the new legacy_serial module (or build 8250 static) with
the "legacy_serial.force" option.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: w/include/asm-i386/serial.h
===================================================================
--- w.orig/include/asm-i386/serial.h 2007-03-27 16:12:29.000000000 -0600
+++ w/include/asm-i386/serial.h 2007-03-27 16:13:04.000000000 -0600
@@ -11,19 +11,3 @@
* megabits/second; but this requires the faster clock.
*/
#define BASE_BAUD ( 1843200 / 16 )
-
-/* Standard COM flags (except for COM4, because of the 8514 problem) */
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ)
-#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-#define STD_COM4_FLAGS ASYNC_BOOT_AUTOCONF
-#endif
-
-#define SERIAL_PORT_DFNS \
- /* UART CLK PORT IRQ FLAGS */ \
- { 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \
- { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */ \
- { 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */ \
- { 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */
Index: w/include/asm-x86_64/serial.h
===================================================================
--- w.orig/include/asm-x86_64/serial.h 2007-03-27 16:12:29.000000000 -0600
+++ w/include/asm-x86_64/serial.h 2007-03-27 16:13:04.000000000 -0600
@@ -11,19 +11,3 @@
* megabits/second; but this requires the faster clock.
*/
#define BASE_BAUD ( 1843200 / 16 )
-
-/* Standard COM flags (except for COM4, because of the 8514 problem) */
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ)
-#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-#define STD_COM4_FLAGS ASYNC_BOOT_AUTOCONF
-#endif
-
-#define SERIAL_PORT_DFNS \
- /* UART CLK PORT IRQ FLAGS */ \
- { 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \
- { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */ \
- { 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */ \
- { 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */
Index: w/arch/i386/kernel/legacy_serial.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ w/arch/i386/kernel/legacy_serial.c 2007-03-28 16:37:26.000000000 -0600
@@ -0,0 +1,67 @@
+/*
+ * Legacy COM port devices for x86 platforms without PNPBIOS or ACPI.
+ * Data taken from include/asm-i386/serial.h.
+ *
+ * (c) Copyright 2007 Hewlett-Packard Development Company, L.P.
+ * Bjorn Helgaas <bjorn.helgaas@hp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/pnp.h>
+#include <linux/serial_8250.h>
+
+/* Standard COM flags (except for COM4, because of the 8514 problem) */
+#ifdef CONFIG_SERIAL_DETECT_IRQ
+#define COM_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ)
+#define COM4_FLAGS (UPF_BOOT_AUTOCONF | UPF_AUTO_IRQ)
+#else
+#define COM_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST)
+#define COM4_FLAGS UPF_BOOT_AUTOCONF
+#endif
+
+#define PORT(_base,_irq,_flags) \
+ { \
+ .iobase = _base, \
+ .irq = _irq, \
+ .uartclk = 1843200, \
+ .iotype = UPIO_PORT, \
+ .flags = _flags, \
+ }
+
+static struct plat_serial8250_port x86_com_data[] = {
+ PORT(0x3F8, 4, COM_FLAGS),
+ PORT(0x2F8, 3, COM_FLAGS),
+ PORT(0x3E8, 4, COM_FLAGS),
+ PORT(0x2E8, 3, COM4_FLAGS),
+ { },
+};
+
+static struct platform_device x86_com_device = {
+ .name = "serial8250",
+ .id = PLAT8250_DEV_PLATFORM,
+ .dev = {
+ .platform_data = x86_com_data,
+ },
+};
+
+static int force_legacy_probe;
+module_param_named(force, force_legacy_probe, bool, 0);
+MODULE_PARM_DESC(force, "Force legacy serial port probe");
+
+static int __init serial8250_x86_com_init(void)
+{
+ if (pnp_platform_devices && !force_legacy_probe)
+ return -ENODEV;
+
+ return platform_device_register(&x86_com_device);
+}
+
+module_init(serial8250_x86_com_init);
+
+MODULE_AUTHOR("Bjorn Helgaas");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Generic 8250/16x50 legacy probe module");
Index: w/arch/i386/kernel/Makefile
===================================================================
--- w.orig/arch/i386/kernel/Makefile 2007-03-27 16:12:29.000000000 -0600
+++ w/arch/i386/kernel/Makefile 2007-03-27 16:13:04.000000000 -0600
@@ -39,6 +39,7 @@
obj-$(CONFIG_HPET_TIMER) += hpet.o
obj-$(CONFIG_K8_NB) += k8.o
obj-$(CONFIG_MARKERS_ENABLE_OPTIMIZATION) += marker.o
+obj-$(CONFIG_SERIAL_8250) += legacy_serial.o
obj-$(CONFIG_VMI) += vmi.o vmitime.o
obj-$(CONFIG_PARAVIRT) += paravirt.o
Index: w/arch/x86_64/kernel/Makefile
===================================================================
--- w.orig/arch/x86_64/kernel/Makefile 2007-03-27 16:12:29.000000000 -0600
+++ w/arch/x86_64/kernel/Makefile 2007-03-27 16:21:49.000000000 -0600
@@ -36,6 +36,7 @@
obj-$(CONFIG_X86_VSMP) += vsmp.o
obj-$(CONFIG_K8_NB) += k8.o
obj-$(CONFIG_AUDIT) += audit.o
+obj-$(CONFIG_SERIAL_8250) += legacy_serial.o
obj-$(CONFIG_MODULES) += module.o
obj-$(CONFIG_PCI) += early-quirks.o
Index: w/drivers/serial/Kconfig
===================================================================
--- w.orig/drivers/serial/Kconfig 2007-03-27 16:12:29.000000000 -0600
+++ w/drivers/serial/Kconfig 2007-03-27 16:13:04.000000000 -0600
@@ -73,17 +73,21 @@
depends on SERIAL_8250 && PCI
default SERIAL_8250
help
- This builds standard PCI serial support. You may be able to
- disable this feature if you only need legacy serial support.
- Saves about 9K.
+ Say Y here if you have PCI serial ports.
+
+ To compile this driver as a module, choose M here: the module
+ will be called 8250_pci.
config SERIAL_8250_PNP
tristate "8250/16550 PNP device support" if EMBEDDED
depends on SERIAL_8250 && PNP
default SERIAL_8250
help
- This builds standard PNP serial support. You may be able to
- disable this feature if you only need legacy serial support.
+ Say Y here if you have serial ports described by PNPBIOS or ACPI.
+ These are typically ports built into the system board.
+
+ To compile this driver as a module, choose M here: the module
+ will be called 8250_pnp.
config SERIAL_8250_HP300
tristate
Index: w/Documentation/kernel-parameters.txt
===================================================================
--- w.orig/Documentation/kernel-parameters.txt 2007-03-26 15:42:45.000000000 -0600
+++ w/Documentation/kernel-parameters.txt 2007-03-28 16:29:21.000000000 -0600
@@ -799,6 +799,11 @@
lasi= [HW,SCSI] PARISC LASI driver for the 53c700 chip
Format: addr:<io>,irq:<irq>
+ legacy_serial.force [HW,IA-32,X86-64]
+ Probe for COM ports at legacy addresses even
+ if PNPBIOS or ACPI should describe them. This
+ is for working around firmware defects.
+
llsc*= [IA64] See function print_params() in
arch/ia64/sn/kernel/llsc4.c.
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch 4/5] smsc-ircc2: add PNP support
2007-04-04 22:45 ` [patch 4/5] smsc-ircc2: add PNP support Bjorn Helgaas
@ 2007-04-04 23:16 ` Randy Dunlap
2007-04-05 18:45 ` Bjorn Helgaas
0 siblings, 1 reply; 8+ messages in thread
From: Randy Dunlap @ 2007-04-04 23:16 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Andrew Morton, Keith Owens, Len Brown, Adam Belay,
Matthieu CASTET, Jean Tourrilhes, Matthew Garrett, Ville Syrjala,
Russell King, linux-serial, Samuel Ortiz, linux-kernel
On Wed, 04 Apr 2007 16:45:40 -0600 Bjorn Helgaas wrote:
> Index: w/drivers/net/irda/smsc-ircc2.c
> ===================================================================
> --- w.orig/drivers/net/irda/smsc-ircc2.c 2007-04-04 13:45:18.000000000 -0600
> +++ w/drivers/net/irda/smsc-ircc2.c 2007-04-04 13:47:00.000000000 -0600
> @@ -79,6 +79,10 @@
> MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver");
> MODULE_LICENSE("GPL");
>
> +static int smsc_nopnp;
> +module_param_named(nopnp, smsc_nopnp, bool, 0);
> +MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings");
Document this parameter (like you did "legacy_serial.force" in the
other patch -- thanks).
> #define DMA_INVAL 255
> static int ircc_dma = DMA_INVAL;
> module_param(ircc_dma, int, 0);
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch 4/5] smsc-ircc2: add PNP support
2007-04-04 23:16 ` Randy Dunlap
@ 2007-04-05 18:45 ` Bjorn Helgaas
0 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2007-04-05 18:45 UTC (permalink / raw)
To: Randy Dunlap
Cc: Andrew Morton, Keith Owens, Len Brown, Adam Belay,
Matthieu CASTET, Jean Tourrilhes, Matthew Garrett, Ville Syrjala,
Russell King, linux-serial, Samuel Ortiz, linux-kernel
On Wednesday 04 April 2007 17:16, Randy Dunlap wrote:
> On Wed, 04 Apr 2007 16:45:40 -0600 Bjorn Helgaas wrote:
> > +static int smsc_nopnp;
> > +module_param_named(nopnp, smsc_nopnp, bool, 0);
> > +MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings");
>
> Document this parameter (like you did "legacy_serial.force" in the
> other patch -- thanks).
Thanks for the reminder. Here's an updated patch with documentation.
Subject: smsc-ircc2: add PNP support
Claim devices using PNP, unless the user explicitly specified device
addresses. This can be disabled with the "smsc-ircc2.nopnp" option.
This removes the need for probing legacy addresses and helps untangle
IR devices from serial8250 devices.
Sometimes the SMC device is at a legacy COM port address but does not
use the legacy COM IRQ. In this case, claiming the device using PNP
rather than 8250 legacy probe means we can automatically use the
correct IRQ rather than forcing the user to use "setserial" to set the
IRQ manually.
If the PNP claim doesn't work, make sure you don't have a setserial init
script, e.g., /etc/init.d/setserial, configured to poke in legacy COM
port resources for the IRDA device. That causes the serial driver to
claim resources needed by this driver.
Based on this patch by Ville Syrjälä:
http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/ir260_smsc_pnp.diff
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: w/drivers/net/irda/smsc-ircc2.c
===================================================================
--- w.orig/drivers/net/irda/smsc-ircc2.c 2007-04-04 13:45:18.000000000 -0600
+++ w/drivers/net/irda/smsc-ircc2.c 2007-04-04 13:47:00.000000000 -0600
@@ -79,6 +79,10 @@
MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver");
MODULE_LICENSE("GPL");
+static int smsc_nopnp;
+module_param_named(nopnp, smsc_nopnp, bool, 0);
+MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings");
+
#define DMA_INVAL 255
static int ircc_dma = DMA_INVAL;
module_param(ircc_dma, int, 0);
@@ -362,7 +366,6 @@
iobase + IRCC_MASTER);
}
-#ifdef CONFIG_PNP
/* PNP hotplug support */
static const struct pnp_device_id smsc_ircc_pnp_table[] = {
{ .id = "SMCf010", .driver_data = 0 },
@@ -370,7 +373,35 @@
{ }
};
MODULE_DEVICE_TABLE(pnp, smsc_ircc_pnp_table);
-#endif
+
+static int pnp_driver_registered;
+
+static int __init smsc_ircc_pnp_probe(struct pnp_dev *dev,
+ const struct pnp_device_id *dev_id)
+{
+ unsigned int firbase, sirbase;
+ u8 dma, irq;
+
+ if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) &&
+ pnp_dma_valid(dev, 0) && pnp_irq_valid(dev, 0)))
+ return -EINVAL;
+
+ sirbase = pnp_port_start(dev, 0);
+ firbase = pnp_port_start(dev, 1);
+ dma = pnp_dma(dev, 0);
+ irq = pnp_irq(dev, 0);
+
+ if (smsc_ircc_open(firbase, sirbase, dma, irq))
+ return -ENODEV;
+
+ return 0;
+}
+
+static struct pnp_driver smsc_ircc_pnp_driver = {
+ .name = "smsc-ircc2",
+ .id_table = smsc_ircc_pnp_table,
+ .probe = smsc_ircc_pnp_probe,
+};
/*******************************************************************************
@@ -381,6 +412,35 @@
*
*******************************************************************************/
+static int __init smsc_ircc_legacy_probe(void)
+{
+ int ret = 0;
+
+ if (ircc_fir > 0 && ircc_sir > 0) {
+ IRDA_MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir);
+ IRDA_MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir);
+
+ if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq))
+ ret = -ENODEV;
+ } else {
+ ret = -ENODEV;
+
+ /* try user provided configuration register base address */
+ if (ircc_cfg > 0) {
+ IRDA_MESSAGE(" Overriding configuration address "
+ "0x%04x\n", ircc_cfg);
+ if (!smsc_superio_fdc(ircc_cfg))
+ ret = 0;
+ if (!smsc_superio_lpc(ircc_cfg))
+ ret = 0;
+ }
+
+ if (smsc_ircc_look_for_chips() > 0)
+ ret = 0;
+ }
+ return ret;
+}
+
/*
* Function smsc_ircc_init ()
*
@@ -408,31 +468,20 @@
dev_count = 0;
- if (ircc_fir > 0 && ircc_sir > 0) {
- IRDA_MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir);
- IRDA_MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir);
-
- if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq))
- ret = -ENODEV;
+ if (smsc_nopnp || !pnp_platform_devices ||
+ ircc_cfg || ircc_fir || ircc_sir ||
+ ircc_dma != DMA_INVAL || ircc_irq != IRQ_INVAL) {
+ ret = smsc_ircc_legacy_probe();
} else {
- ret = -ENODEV;
-
- /* try user provided configuration register base address */
- if (ircc_cfg > 0) {
- IRDA_MESSAGE(" Overriding configuration address "
- "0x%04x\n", ircc_cfg);
- if (!smsc_superio_fdc(ircc_cfg))
- ret = 0;
- if (!smsc_superio_lpc(ircc_cfg))
- ret = 0;
- }
-
- if (smsc_ircc_look_for_chips() > 0)
- ret = 0;
+ if (pnp_register_driver(&smsc_ircc_pnp_driver) == 0)
+ pnp_driver_registered = 1;
}
- if (ret)
+ if (ret) {
+ if (pnp_driver_registered)
+ pnp_unregister_driver(&smsc_ircc_pnp_driver);
platform_driver_unregister(&smsc_ircc_driver);
+ }
return ret;
}
@@ -1842,6 +1891,9 @@
smsc_ircc_close(dev_self[i]);
}
+ if (pnp_driver_registered)
+ pnp_unregister_driver(&smsc_ircc_pnp_driver);
+
platform_driver_unregister(&smsc_ircc_driver);
}
Index: w/Documentation/kernel-parameters.txt
===================================================================
--- w.orig/Documentation/kernel-parameters.txt 2007-04-05 11:56:34.000000000 -0600
+++ w/Documentation/kernel-parameters.txt 2007-04-05 12:07:53.000000000 -0600
@@ -1557,6 +1557,17 @@
smart2= [HW]
Format: <io1>[,<io2>[,...,<io8>]]
+ smsc-ircc2.nopnp [HW] Don't use PNP to discover SMC devices
+ smsc-ircc2.ircc_cfg= [HW] Device configuration I/O port
+ smsc-ircc2.ircc_sir= [HW] SIR base I/O port
+ smsc-ircc2.ircc_fir= [HW] FIR base I/O port
+ smsc-ircc2.ircc_irq= [HW] IRQ line
+ smsc-ircc2.ircc_dma= [HW] DMA channel
+ smsc-ircc2.ircc_transceiver= [HW] Transceiver type:
+ 0: Toshiba Satellite 1800 (GP data pin select)
+ 1: Fast pin select (default)
+ 2: ATC IRMode
+
snd-ad1816a= [HW,ALSA]
snd-ad1848= [HW,ALSA]
-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-04-05 18:45 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-04 22:45 [patch 0/5] PNP: convert x86 legacy serial to platform devs, add SMC IR PNP probe Bjorn Helgaas
2007-04-04 22:45 ` [patch 1/5] PNP: notice whether we have PNP devices (PNPBIOS or PNPACPI) Bjorn Helgaas
2007-04-04 22:45 ` [patch 2/5] PNP: workaround HP BIOS defect that leaves SMCF010 device partly enabled Bjorn Helgaas
2007-04-04 22:45 ` [patch 3/5] smsc-ircc2: tidy up module parameter checking Bjorn Helgaas
2007-04-04 22:45 ` [patch 4/5] smsc-ircc2: add PNP support Bjorn Helgaas
2007-04-04 23:16 ` Randy Dunlap
2007-04-05 18:45 ` Bjorn Helgaas
2007-04-04 22:45 ` [patch 5/5] x86, serial: convert legacy COM ports to platform devices Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).