autodetect serial console on efika
Subsystems (2)
PATCH 1/1 autodetect serial console on efika
Efika boards have to be booted with console=ttyPSC0 unless there is a graphics card plugged in. Detect if the firmware stdout is the serial connector.
--- arch/powerpc/platforms/52xx/efika.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/powerpc/platforms/52xx/efika.c +26 -0
@@ -21,6 +21,7 @@#include <linux/initrd.h> #include <linux/timer.h> #include <linux/pci.h> +#include <linux/console.h> #include <asm/io.h> #include <asm/irq.h>
@@ -221,12 +222,37 @@ static int __init efika_probe(void)return 1 ; } +static void __init efika_init_early (void ) +{ +#ifdef CONFIG_SERIAL_MPC52xx +struct device_node *stdout_node; +const char *device_type; + +if (strstr (cmd_line,"console=" )) +return ; +/* find the boot console from /chosen/stdout */ +if (!of_chosen) +return ; + device_type =get_property (of_chosen,"linux,stdout-path" ,NULL ); +if (!device_type) +return ; + stdout_node =of_find_node_by_path (device_type); +if (stdout_node) { + device_type =get_property (stdout_node,"device_type" ,NULL ); +if (device_type &&strcmp (device_type,"serial" ) ==0 ) +add_preferred_console ("ttyPSC" ,0 ,NULL ); +of_node_put (stdout_node); + } +#endif +} +define_machine (efika) { .name = EFIKA_PLATFORM_NAME, .probe = efika_probe, .setup_arch = efika_setup_arch, .init = mpc52xx_declare_of_platform_devices, + .init_early = efika_init_early, .show_cpuinfo = efika_show_cpuinfo, .init_IRQ = mpc52xx_init_irq, .get_irq = mpc52xx_get_irq,
Quoted 5 lines · Olaf Hering
Efika boards have to be booted with console=ttyPSC0 unless there is a graphics card plugged in. Detect if the firmware stdout is the serial connector.
Signed-off-by Olaf Hering <[email protected]>
Can I suggest a further update to this patch; the serial redirection should be done on the basis of the node *name* too. The only serial output device that is 'tied' to the serial console that way is the /failsafe node (if this is in fact the chosen stdout/stdin device).
It is entirely possible that a user may redirect the OF console output to the PSC6 controller or another internal or external serial device (PCI serial controller or so). In this case, the boot console will simply switch to the UART on the back, which may be some other custom device and not a valid console.
It is also entirely possible that we move failsafe, too, however. Is it possible to check the PSC numbering and ensure that it only uses ttyPSC0 for the serial console, if it is in fact using the PSC connected to the RS232 port on the back of the board (this is in the device tree isn't it? If not.. can someone suggest how we report this information?? :)
Please tell me if that's an insane suggestion or too much like a fringe benefit for users and not a useful actual feature?
Signature · 2 lines
Matt Sealey <[email protected]> Genesi, Manager, Developer Relations
Quoted 64 lines · Olaf Hering
Efika boards have to be booted with console=ttyPSC0 unless there is a graphics card plugged in. Detect if the firmware stdout is the serial connector.
Signed-off-by Olaf Hering <[email protected]>--- arch/powerpc/platforms/52xx/efika.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)Index:
b/arch/powerpc/platforms/52xx/efika.c
===================================================================arch/powerpc/platforms/52xx/efika.c +26
-0@@ -21,6 +21,7 @@#include <linux/initrd.h> #include <linux/timer.h> #include <linux/pci.h> +#include <linux/console.h> #include <asm/io.h> #include <asm/irq.h> @@ -221,12 +222,37 @@ static int __init efika_probe(void)return 1 ; } +static void __init efika_init_early (void ) +{ +#ifdef CONFIG_SERIAL_MPC52xx +struct device_node *stdout_node; +const char *device_type; + +if (strstr (cmd_line,"console=" )) +return ; +/* find the boot console from /chosen/stdout */ +if (!of_chosen) +return ; + device_type =get_property (of_chosen,"linux,stdout-path" ,NULL ); +if (!device_type) +return ; + stdout_node =of_find_node_by_path (device_type); +if (stdout_node) { + device_type =get_property (stdout_node,"device_type" ,NULL ); +if (device_type &&strcmp (device_type,"serial" ) ==0 ) +add_preferred_console ("ttyPSC" ,0 ,NULL ); +of_node_put (stdout_node); + } +#endif +} +define_machine (efika) { .name = EFIKA_PLATFORM_NAME, .probe = efika_probe, .setup_arch = efika_setup_arch, .init = mpc52xx_declare_of_platform_devices, + .init_early = efika_init_early, .show_cpuinfo = efika_show_cpuinfo, .init_IRQ = mpc52xx_init_irq, .get_irq = mpc52xx_get_irq,_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Quoted 5 lines · Matt Sealey
It is entirely possible that a user may redirect the OF console output to the PSC6 controller or another internal or external serial device (PCI serial controller or so). In this case, the boot console will simply switch to the UART on the back, which may be some other custom device and not a valid console.
How many serial drivers are enabled in the public Efika firmware? With my change, both /failsafe and the /builtin/serial work. Both have device_type == "serial"
Quoted 10 lines · Olaf Hering
Quoted 6 lines · Matt Sealey
It is entirely possible that a user may redirect the OF console output to the PSC6 controller or another internal or external serial device (PCI serial controller or so). In this case, the boot console will simply switch to the UART on the back, which may be some other custom device and not a valid console.
Quoted 4 lines
How many serial drivers are enabled in the public Efika firmware? With my change, both /failsafe and the /builtin/serial work. Both have
device_type== "serial"
If I follow the logic of the patch correctly, as soon as there is no "console=" in the command line and that the linux,stdout-path has a device_type "serial", you add ttyPSC0 as console ?
The user could have plugged a console on the IRDA PSC and used a bootscript to change the OF tree appropriately.
Or he could have put a PCI multi IO card and set the stdout to it ...
In all those cases, the ttyPSC0 is bogus ...
But in those "special cases", I guess it's not too much to ask the user to provide a "console=" in the command line.
Sylvain
Quoted 1 line · Sylvain Munaut
In all those cases, the ttyPSC0 is bogus ...
Thats why I asked for the number of enabled serial console drivers in the firmware. I suspect there is just a single one for the onboard connector.
Quoted 18 lines · Sylvain Munaut
Quoted 9 lines · Olaf Hering
Quoted 6 lines · Matt Sealey
It is entirely possible that a user may redirect the OF console output to the PSC6 controller or another internal or external serial device (PCI serial controller or so). In this case, the boot console will simply switch to the UART on the back, which may be some other custom device and not a valid console.
Quoted 4 lines
How many serial drivers are enabled in the public Efika firmware? With my change, both /failsafe and the /builtin/serial work. Both have
device_type== "serial"If I follow the logic of the patch correctly, as soon as there is no "console=" in the command line and that the linux,stdout-path has a
device_type"serial", you add ttyPSC0 as console ?
Quoted 8 lines
The user could have plugged a console on the IRDA PSC and used a bootscript to change the OF tree appropriately.
Or he could have put a PCI multi IO card and set the stdout to it ...In all those cases, the ttyPSC0 is bogus ...
But in those "special cases", I guess it's not too much to ask the user to provide a "console=" in the command line.
I think in this case, output should not be redirected, it should fail out (the current code doesn't, it only checks device type). It should also be documented that the behaviour only caters for the /failsafe and /builtin/serial devices and any other serial consoles will require a console= line.
This should be enough warning for users who have more 'crazy' serial port setups. Definitely, it is possible these users have something attached to the serial port on the back of the board and have moved the firmware console for a good reason. You do not want Linux spamming the serial port if you did not tell it to, and it is not certain that this is the port they want.
Signature · 2 lines
Matt Sealey <[email protected]> Genesi, Manager, Developer Relations
There are 5 pins on the motherboard for PSC6, which if a driver is enabled for it (and it's put into UART mode) would become a two-wire serial port (it is intended for IrDA though in the current board revision).
In this case, you set the firmware console to this and the early init will redirect the Linux console back to the serial port on the back of the case, just because it shares a serial device type.
There is a big chance that USB serial drivers will be in a later firmware revision, at which point this will redirect any USB serial output desired to the serial port on the back of the system.
Both of these are *wrong* and counter-intuitive.
The only safe serial ports to force "ttyPSC" unit 0 onto are /failsafe (although this may change!) and /builtin/serial. Otherwise you are second-guessing the user's preferences in the firmware.
I would in theory recommend against doing it on /failsafe as it is NOT a predictable device. It simply throws output there in the case of a gross exception and lack of preferred devices, it just happens that this is and always has been the serial port on the Pegasos and Efika. It could be an nvram buffer, a PCI card, a special OLED display, or anything we want it to be depending on the configuration of the Efika and the revision of the firmware. The intention of /failsafe is that the output goes SOMEWHERE, rather than to the Open Firmware equivalent of /dev/null, and there is no special significance to the fact that it is marked as a serial device (i.e. it may not be connected to a serial port, it is just presented as a serial interface).
However, on the current Efikas, it does go to the back serial port, so in this case I would set it to ttyPSC0 anyway. But only in the case of /failsafe and /builtin/serial, any other port present (remember our device tree is dynamically generated on boot, and it maps *ALL* present devices capable of detection - not just the ones in the SoC. Get out of the FDT mindset) should not be redirected using this heuristic unless it gets vastly more intelligent.
Signature · 2 lines
Matt Sealey <[email protected]> Genesi, Manager, Developer Relations
Quoted 11 lines · Olaf Hering
Quoted 5 lines · Matt Sealey
It is entirely possible that a user may redirect the OF console output to the PSC6 controller or another internal or external serial device (PCI serial controller or so). In this case, the boot console will simply switch to the UART on the back, which may be some other custom device and not a valid console.
How many serial drivers are enabled in the public Efika firmware? With my change, both /failsafe and the /builtin/serial work. Both have
device_type== "serial"
Quoted 3 lines · Olaf Hering
Efika boards have to be booted with console=ttyPSC0 unless there is a graphics card plugged in. Detect if the firmware stdout is the serial connector.
Paul, please discard this patch. The optional graphics card may have also device_type 'serial' if it is in VGA mode.
I will send an updated patch later.
That too :D
Signature · 2 lines
Matt Sealey <[email protected]> Genesi, Manager, Developer Relations
Quoted 13 lines · Olaf Hering
Quoted 3 lines · Olaf Hering
Efika boards have to be booted with console=ttyPSC0 unless there is a graphics card plugged in. Detect if the firmware stdout is the serial connector.
Paul, please discard this patch. The optional graphics card may have also
device_type'serial' if it is in VGA mode.
I will send an updated patch later.
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
PATCH 1/1 autodetect serial console on efika
In reply to Olaf HeringEfika boards have to be booted with console=ttyPSC0 unless there is a graphics card plugged in. Detect if the firmware stdout is the serial connector.
--- arch/powerpc/platforms/52xx/efika.c | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
arch/powerpc/platforms/52xx/efika.c +50 -0
@@ -13,6 +13,7 @@#include <linux/utsrelease.h> #include <linux/pci.h> #include <linux/of.h> +#include <linux/console.h> #include <asm/prom.h> #include <asm/time.h> #include <asm/machdep.h>
@@ -208,12 +209,61 @@ static int __init efika_probe(void)return 1 ; } +/* +* Per default, input/output-device points to keyboard/screen +* If no card is installed, the built-in serial port is used as a fallback. +* But unfortunately, the firmware does not connect /chosen/{stdin,stdout} +* the the built-in serial node. Instead, a /failsafe node is created. +* More advanced hardware configurations cant be detected, +* boot with console=xyz123 to point the kernel to the correct device +*/ +static void __init efika_init_early (void ) +{ +#ifdef CONFIG_SERIAL_MPC52xx +struct device_node *stdout_node; +const char *property; + +if (strstr (cmd_line,"console=" )) +return ; +/* find the boot console from /chosen/stdout */ +if (!of_chosen) +return ; + property =of_get_property (of_chosen,"linux,stdout-path" ,NULL ); +if (!property) +return ; + stdout_node =of_find_node_by_path (property); +if (!stdout_node) +return ; + property =of_get_property (stdout_node,"device_type" ,NULL ); +if (property &&strcmp (property,"serial" ) ==0 ) { +/* +* The 9pin connector is either /failsafe or /builtin/serial. +* The optional graphics card has also type 'serial' in VGA mode. +*/ + property =of_get_property (stdout_node,"name" ,NULL ); +if (property) { +if (strcmp (property,"failsafe" ) ==0 ) +add_preferred_console ("ttyPSC" ,0 ,NULL ); +else { +if (strcmp (property,"serial" ) ==0 ) { + property =of_get_property (stdout_node,"model" ,NULL ); +if (property &&strcmp (property,"mpc5200-serial" ) ==0 ) +add_preferred_console ("ttyPSC" ,0 ,NULL ); + } + } + } + } +of_node_put (stdout_node); +#endif +} +define_machine (efika) { .name = EFIKA_PLATFORM_NAME, .probe = efika_probe, .setup_arch = efika_setup_arch, .init = mpc52xx_declare_of_platform_devices, + .init_early = efika_init_early, .show_cpuinfo = efika_show_cpuinfo, .init_IRQ = mpc52xx_init_irq, .get_irq = mpc52xx_get_irq,
PATCH 1/1 autodetect serial console on pegasos2
Autodetect the serial console on Pegasos2.
--- arch/powerpc/platforms/chrp/setup.c | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
arch/powerpc/platforms/chrp/setup.c +52 -0
@@ -251,6 +251,57 @@ static void briq_restart(char *cmd)for (;;); } +/* +* Per default, input/output-device points to the keyboard/screen +* If no card is installed, the built-in serial port is used as a fallback. +* But unfortunately, the firmware does not connect /chosen/{stdin,stdout} +* the the built-in serial node. Instead, a /failsafe node is created. +*/ +static void chrp_init_early (void ) +{ +struct device_node *node; +const char *property; + +if (strstr (cmd_line,"console=" )) +return ; +/* find the boot console from /chosen/stdout */ +if (!of_chosen) +return ; + node =of_find_node_by_path ("/" ); +if (!node) +return ; + property =of_get_property (node,"model" ,NULL ); +if (!property) + goto out_put; +if (strcmp (property,"Pegasos2" )) + goto out_put; +/* this is a Pegasos2 */ + property =of_get_property (of_chosen,"linux,stdout-path" ,NULL ); +if (!property) + goto out_put; +of_node_put (node); + node =of_find_node_by_path (property); +if (!node) +return ; + property =of_get_property (node,"device_type" ,NULL ); +if (!property) + goto out_put; +if (strcmp (property,"serial" )) + goto out_put; +/* +* The 9pin connector is either /failsafe +* or /pci@80000000/isa@C/serial@i2F8 +* The optional graphics card has also type 'serial' in VGA mode. +*/ + property =of_get_property (node,"name" ,NULL ); +if (!property) + goto out_put; +if (!strcmp (property,"failsafe" ) || !strcmp (property,"serial" )) +add_preferred_console ("ttyS" ,0 ,NULL ); +out_put: +of_node_put (node); +} +void __init chrp_setup_arch (void ) {struct device_node *root =of_find_node_by_path ("/" );
@@ -594,6 +645,7 @@ define_machine(chrp) { .probe = chrp_probe, .setup_arch = chrp_setup_arch, .init = chrp_init2, + .init_early = chrp_init_early, .show_cpuinfo = chrp_show_cpuinfo, .init_IRQ = chrp_init_IRQ, .restart = rtas_restart,
Quoted 2 lines · Olaf Hering
+ * But unfortunately, the firmware does not connect /chosen/{stdin,stdout}
+ * the the built-in serial node. Instead, a /failsafe node is created.
^^^
toThe same typo is in the pegasos2 patch.
With kind regards,
Geert Uytterhoeven
Software Architect
Sony Network and Software Technology Center Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
Phone: +32 (0)2 700 8453 Fax: +32 (0)2 700 8622 E-mail: [email protected] Internet: http://www.sony-europe.com/
Sony Network and Software Technology Center Europe
A division of Sony Service Centre (Europe) N.V. Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium VAT BE 0413.825.160 · RPR Brussels
Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619
Quoted 5 lines · Olaf Hering
+/*
+ * Per default, input/output-device points to keyboard/screen
+ * If no card is installed, the built-in serial port is used as a fallback.
+ * But unfortunately, the firmware does not connect /chosen/{stdin,stdout}
+ * the the built-in serial node. Instead, a /failsafe node is created.
s/the the/to the/
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 6 lines · Olaf Hering
Efika boards have to be booted with console=ttyPSC0 unless there is a graphics card plugged in. Detect if the firmware stdout is the serial connector.
Signed-off-by Olaf Hering <[email protected]>
Hrrrum; I think this is a good idea, but I'm not thrilled with the approach. Here are my concerns:
- Determining that linux,stdout-path points to a PSC should should be done in common code. It's useful for all 5200 boards, not just the Efika. (However, if 'failsafe' processing is efika specific, then it can stay in efika.c). This might be best done within the PSC driver itself, but I'm not sure.
- Recognizing a psc node should be done by inspecting the compatible property, not by device_type and model properties.
Thanks,
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Quoted 11 lines · Grant Likely
Quoted 6 lines · Olaf Hering
Efika boards have to be booted with console=ttyPSC0 unless there is a graphics card plugged in. Detect if the firmware stdout is the serial connector.
Signed-off-by Olaf Hering <[email protected]>Hrrrum; I think this is a good idea, but I'm not thrilled with the approach. Here are my concerns:
Quoted 7 lines
- Determining that linux,stdout-path points to a PSC should should be done in common code. It's useful for all 5200 boards, not just the Efika. (However, if 'failsafe' processing is efika specific, then it can stay in
efika.c). This might be best done within the PSC driver itself, but I'm not sure.
- Recognizing a psc node should be done by inspecting the compatible property, not bydevice_typeand model properties.
I dont have any other 5200 hardware to test a different patch. Please improve my version and submit it for inclusion.
Quoted 21 lines · Olaf Hering
Quoted 11 lines · Grant Likely
Quoted 6 lines · Olaf Hering
Efika boards have to be booted with console=ttyPSC0 unless there is a graphics card plugged in. Detect if the firmware stdout is the serial connector.
Signed-off-by Olaf Hering <[email protected]>Hrrrum; I think this is a good idea, but I'm not thrilled with the approach. Here are my concerns:
Quoted 7 lines
- Determining that linux,stdout-path points to a PSC should should be done in common code. It's useful for all 5200 boards, not just the Efika. (However, if 'failsafe' processing is efika specific, then it can stay in
efika.c). This might be best done within the PSC driver itself, but I'm not sure.
- Recognizing a psc node should be done by inspecting the compatible property, not bydevice_typeand model properties.
Quoted 2 lines
I dont have any other 5200 hardware to test a different patch. Please improve my version and submit it for inclusion.
Heh; that's okay, I and others can test on other hardware; but it's still appropriate for you to move the matching code into the PSC driver proper. Otherwise, getting it in to mainline for 2.6.25 depends on how much time I get free in the next 2 weeks.
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.