* [PATCH RESEND 1/4 v2] m68k: toward platform agnostic framebuffer debug logging
2014-04-11 5:27 [PATCH RESEND 0/4] m68k: earlyprintk and debug console improvements Finn Thain
@ 2014-04-11 5:27 ` Finn Thain
2014-04-11 5:27 ` [PATCH RESEND 2/4 v2] m68k: multi-platform EARLY_PRINTK Finn Thain
` (2 subsequent siblings)
3 siblings, 0 replies; 17+ messages in thread
From: Finn Thain @ 2014-04-11 5:27 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Michael Schmitz, linux-m68k
[-- Attachment #1: platform-agnostic-framebuffer-debug-console --]
[-- Type: text/plain, Size: 9367 bytes --]
Code subject to #ifdef CONSOLE is made more generic, as was apparently
intended by the original author.
Remove console_put_stats() routine. If it should be somehow useful, it
should also be useful on platforms without framebuffer debug logging. The
present implementation is only built #if defined CONFIG_MAC && defined
CONSOLE even though puts() works everywhere.
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Tested-by: Stephen N Chivers <schivers@csc.com.au>
---
The CONSOLE_DEBUG and SERIAL_DEBUG macros can be used independently. I
think renaming CONSOLE as CONSOLE_DEBUG makes this apparent. (It is not
clear how to actually enable them independently. That might need to be
controlled from the bootloader.)
This version (v2) makes macro use more consistent: CONSOLE_DEBUG and
SERIAL_DEBUG act on the platform independent code whilst MAC_USE_SCC_{A,B}
act on the platform specific code, like USE_SCC_{A,B}.
---
arch/m68k/kernel/head.S | 112 +++++++++++-------------------------------------
1 file changed, 26 insertions(+), 86 deletions(-)
Index: linux-m68k/arch/m68k/kernel/head.S
===================================================================
--- linux-m68k.orig/arch/m68k/kernel/head.S 2014-03-03 10:29:46.000000000 +1100
+++ linux-m68k/arch/m68k/kernel/head.S 2014-03-03 10:29:47.000000000 +1100
@@ -153,7 +153,7 @@
* ------------
* The console is also able to be turned off. The console in head.S
* is specifically for debugging and can be very useful. It is surrounded by
- * #ifdef CONSOLE/#endif clauses so it doesn't have to ship in known-good
+ * #ifdef / #endif clauses so it doesn't have to ship in known-good
* kernels. It's basic algorithm is to determine the size of the screen
* (in height/width and bit depth) and then use that information for
* displaying an 8x8 font or an 8x16 (widthxheight). I prefer the 8x8 for
@@ -198,9 +198,8 @@
* CONFIG_xxx: These are the obvious machine configuration defines created
* during configuration. These are defined in autoconf.h.
*
- * CONSOLE: There is support for head.S console in this file. This
- * console can talk to a Mac frame buffer, but could easily be extrapolated
- * to extend it to support other platforms.
+ * CONSOLE_DEBUG: Only supports a Mac frame buffer but could easily be
+ * extended to support other platforms.
*
* TEST_MMU: This is a test harness for running on any given machine but
* getting an MMU dump for another class of machine. The classes of machines
@@ -274,7 +273,7 @@
#include <asm/machw.h>
#ifdef CONFIG_FRAMEBUFFER_CONSOLE
-#define CONSOLE
+#define CONSOLE_DEBUG
#endif
#ifdef CONFIG_EARLY_PRINTK
@@ -480,22 +479,21 @@ func_define serial_putc,1
func_define console_putc,1
func_define console_init
-func_define console_put_stats
func_define console_put_penguin
func_define console_plot_pixel,3
func_define console_scroll
.macro putc ch
-#if defined(CONSOLE) || defined(SERIAL_DEBUG)
+#if defined(CONSOLE_DEBUG) || defined(SERIAL_DEBUG)
pea \ch
#endif
-#ifdef CONSOLE
+#ifdef CONSOLE_DEBUG
func_call console_putc
#endif
#ifdef SERIAL_DEBUG
func_call serial_putc
#endif
-#if defined(CONSOLE) || defined(SERIAL_DEBUG)
+#if defined(CONSOLE_DEBUG) || defined(SERIAL_DEBUG)
addql #4,%sp
#endif
.endm
@@ -515,7 +513,7 @@ func_define putn,1
.endm
.macro puts string
-#if defined(CONSOLE) || defined(SERIAL_DEBUG)
+#if defined(CONSOLE_DEBUG) || defined(SERIAL_DEBUG)
__INITDATA
.Lstr\@:
.string "\string"
@@ -651,11 +649,9 @@ ENTRY(__start)
lea %pc@(L(mac_rowbytes)),%a1
movel %a0@,%a1@
-#ifdef SERIAL_DEBUG
get_bi_record BI_MAC_SCCBASE
lea %pc@(L(mac_sccbase)),%a1
movel %a0@,%a1@
-#endif
L(test_notmac):
#endif /* CONFIG_MAC */
@@ -885,13 +881,12 @@ L(nothp):
*/
#ifdef CONFIG_MAC
is_not_mac(L(nocon))
-# ifdef CONSOLE
+# ifdef CONSOLE_DEBUG
console_init
# ifdef CONFIG_LOGO
console_put_penguin
# endif /* CONFIG_LOGO */
- console_put_stats
-# endif /* CONSOLE */
+# endif /* CONSOLE_DEBUG */
L(nocon):
#endif /* CONFIG_MAC */
@@ -1396,15 +1391,13 @@ L(mmu_fixup_done):
andl L(mac_videobase),%d0
addl #VIDEOMEMBASE,%d0
movel %d0,L(mac_videobase)
-#if defined(CONSOLE)
+#ifdef CONSOLE_DEBUG
movel %pc@(L(phys_kernel_start)),%d0
subl #PAGE_OFFSET,%d0
subl %d0,L(console_font)
subl %d0,L(console_font_data)
#endif
-#ifdef SERIAL_DEBUG
orl #0x50000000,L(mac_sccbase)
-#endif
1:
#endif
@@ -2734,7 +2727,11 @@ func_return get_new_page
*/
#ifdef CONFIG_MAC
+/* You may define either or both of these. */
+#define MAC_USE_SCC_A /* Modem port */
+#define MAC_USE_SCC_B /* Printer port */
+#if defined(MAC_USE_SCC_A) || defined(MAC_USE_SCC_B)
L(scc_initable_mac):
.byte 4,0x44 /* x16, 1 stopbit, no parity */
.byte 3,0xc0 /* receiver: 8 bpc */
@@ -2748,6 +2745,7 @@ L(scc_initable_mac):
.byte -1
.even
#endif
+#endif /* CONFIG_MAC */
#ifdef CONFIG_ATARI
/* #define USE_PRINTER */
@@ -2843,6 +2841,7 @@ func_start serial_init,%d0/%d1/%a0/%a1
| movew #61,CUSTOMBASE+C_SERPER-ZTWOBASE
1:
#endif
+
#ifdef CONFIG_ATARI
is_not_atari(4f)
movel %pc@(L(iobase)),%a1
@@ -2877,21 +2876,14 @@ func_start serial_init,%d0/%d1/%a0/%a1
jra L(serial_init_done)
4:
#endif
+
#ifdef CONFIG_MAC
is_not_mac(L(serial_init_not_mac))
-
-#ifdef SERIAL_DEBUG
-
-/* You may define either or both of these. */
-#define MAC_USE_SCC_A /* Modem port */
-#define MAC_USE_SCC_B /* Printer port */
-
+#if defined(MAC_USE_SCC_A) || defined(MAC_USE_SCC_B)
#define mac_scc_cha_b_ctrl_offset 0x0
#define mac_scc_cha_a_ctrl_offset 0x2
#define mac_scc_cha_b_data_offset 0x4
#define mac_scc_cha_a_data_offset 0x6
-
-#if defined(MAC_USE_SCC_A) || defined(MAC_USE_SCC_B)
movel %pc@(L(mac_sccbase)),%a0
/* Reset SCC register pointer */
moveb %a0@(mac_scc_cha_a_ctrl_offset),%d0
@@ -2905,7 +2897,6 @@ func_start serial_init,%d0/%d1/%a0/%a1
subq #1,%d0
jne 5b
#endif
-
#ifdef MAC_USE_SCC_A
/* Initialize channel A */
lea %pc@(L(scc_initable_mac)),%a1
@@ -2916,7 +2907,6 @@ func_start serial_init,%d0/%d1/%a0/%a1
jra 5b
6:
#endif /* MAC_USE_SCC_A */
-
#ifdef MAC_USE_SCC_B
/* Initialize channel B */
lea %pc@(L(scc_initable_mac)),%a1
@@ -2927,9 +2917,6 @@ func_start serial_init,%d0/%d1/%a0/%a1
jra 7b
8:
#endif /* MAC_USE_SCC_B */
-
-#endif /* SERIAL_DEBUG */
-
jra L(serial_init_done)
L(serial_init_not_mac):
#endif /* CONFIG_MAC */
@@ -2998,27 +2985,19 @@ func_start serial_putc,%d0/%d1/%a0/%a1
#ifdef CONFIG_MAC
is_not_mac(5f)
-
-#ifdef SERIAL_DEBUG
-
#if defined(MAC_USE_SCC_A) || defined(MAC_USE_SCC_B)
movel %pc@(L(mac_sccbase)),%a1
#endif
-
#ifdef MAC_USE_SCC_A
3: btst #2,%a1@(mac_scc_cha_a_ctrl_offset)
jeq 3b
moveb %d0,%a1@(mac_scc_cha_a_data_offset)
#endif /* MAC_USE_SCC_A */
-
#ifdef MAC_USE_SCC_B
4: btst #2,%a1@(mac_scc_cha_b_ctrl_offset)
jeq 4b
moveb %d0,%a1@(mac_scc_cha_b_data_offset)
#endif /* MAC_USE_SCC_B */
-
-#endif /* SERIAL_DEBUG */
-
jra L(serial_putc_done)
5:
#endif /* CONFIG_MAC */
@@ -3195,7 +3174,7 @@ func_start puts,%d0/%a0
movel ARG1,%a0
jra 2f
1:
-#ifdef CONSOLE
+#ifdef CONSOLE_DEBUG
console_putc %d0
#endif
#ifdef SERIAL_DEBUG
@@ -3224,7 +3203,7 @@ func_start putn,%d0-%d2
jls 2f
addb #'A'-('9'+1),%d2
2:
-#ifdef CONSOLE
+#ifdef CONSOLE_DEBUG
console_putc %d2
#endif
#ifdef SERIAL_DEBUG
@@ -3256,7 +3235,7 @@ ENTRY(mac_early_print)
movel %sp@(22),%d1 /* fetch parameter */
jra 2f
1:
-#ifdef CONSOLE
+#ifdef CONSOLE_DEBUG
console_putc %d0
#endif
#ifdef SERIAL_DEBUG
@@ -3292,7 +3271,7 @@ func_start set_leds,%d0/%a0
func_return set_leds
#endif
-#ifdef CONSOLE
+#ifdef CONSOLE_DEBUG
/*
* For continuity, see the data alignment
* to which this structure is tied.
@@ -3396,43 +3375,6 @@ L(console_clear_loop):
1:
func_return console_init
-func_start console_put_stats,%a0/%d7
- /*
- * Some of the register usage that follows
- * a0 = pointer to boot_info
- * d7 = value of boot_info fields
- */
- puts "\nMacLinux\n"
-
-#ifdef SERIAL_DEBUG
- puts "\n vidaddr:"
- putn %pc@(L(mac_videobase)) /* video addr. */
-
- puts "\n _stext:"
- lea %pc@(_stext),%a0
- putn %a0
-
- puts "\nbootinfo:"
- lea %pc@(_end),%a0
- putn %a0
-
- puts "\n cpuid:"
- putn %pc@(L(cputype))
-
-# ifdef CONFIG_MAC
- puts "\n sccbase:"
- putn %pc@(L(mac_sccbase))
-# endif
-# ifdef MMU_PRINT
- putc '\n'
- jbsr mmu_print_machine_cpu_types
-# endif
-#endif /* SERIAL_DEBUG */
-
- putc '\n'
-
-func_return console_put_stats
-
#ifdef CONFIG_LOGO
func_start console_put_penguin,%a0-%a1/%d0-%d7
/*
@@ -3774,7 +3716,7 @@ L(white_16):
L(console_plot_pixel_exit):
func_return console_plot_pixel
-#endif /* CONSOLE */
+#endif /* CONSOLE_DEBUG */
__INITDATA
@@ -3787,7 +3729,7 @@ L(iobase):
.long 0
#endif
-#if defined(CONSOLE)
+#ifdef CONSOLE_DEBUG
L(console_globals):
.long 0 /* cursor column */
.long 0 /* cursor row */
@@ -3798,7 +3740,7 @@ L(console_font):
.long 0 /* pointer to console font (struct font_desc) */
L(console_font_data):
.long 0 /* pointer to console font data */
-#endif /* CONSOLE */
+#endif /* CONSOLE_DEBUG */
#if defined(MMU_PRINT)
L(mmu_print_data):
@@ -3856,10 +3798,8 @@ L(mac_dimensions):
.long 0
L(mac_rowbytes):
.long 0
-#ifdef SERIAL_DEBUG
L(mac_sccbase):
.long 0
-#endif
#endif /* CONFIG_MAC */
#if defined (CONFIG_APOLLO)
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RESEND 2/4 v2] m68k: multi-platform EARLY_PRINTK
2014-04-11 5:27 [PATCH RESEND 0/4] m68k: earlyprintk and debug console improvements Finn Thain
2014-04-11 5:27 ` [PATCH RESEND 1/4 v2] m68k: toward platform agnostic framebuffer debug logging Finn Thain
@ 2014-04-11 5:27 ` Finn Thain
2014-04-11 5:28 ` [PATCH RESEND 3/4] m68k/mvme16x: adopt common boot console Finn Thain
2014-04-11 5:28 ` [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console Finn Thain
3 siblings, 0 replies; 17+ messages in thread
From: Finn Thain @ 2014-04-11 5:27 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Michael Schmitz, linux-m68k
[-- Attachment #1: multi-platform-early-printk --]
[-- Type: text/plain, Size: 9360 bytes --]
Make the head.S debug console available to all m68k platforms.
The boot console is subject to the "earlyprintk" command line argument,
which is how most other architectures do this.
This is a change of behaviour for the Mac but does not impact the common
use-case which is not debugging. It is also a change of behaviour for
other platforms, because it means the serial port stays quiet when
CONFIG_EARLY_PRINTK is not enabled, eliminating debugging output that's
not normally needed.
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Tested-by: Stephen N Chivers <schivers@csc.com.au>
---
This patch set is mostly aimed at making Mac-specific code more useful to
other platforms. The early printk code becomes more generic, which is
probably the approach I should have taken when I first implemented it for
Macs.
This should mean that multi-platform configs behave in a more consistent
way.
The use of the Kconfig and kernel command line user interfaces seems more
sensible than having obscure macros buried in asm source files to control
this functionality.
This version (v2) reflects suggestions & corrections to the previous one:
- depends on !SUN3
- "earlyprintk" kernel parameter takes no argument (but see MVME changes
in the next patch)
- documentation update
---
Documentation/kernel-parameters.txt | 2 -
arch/m68k/Kconfig.debug | 9 ++++-
arch/m68k/kernel/Makefile | 2 +
arch/m68k/kernel/early_printk.c | 57 ++++++++++++++++++++++++++++++++++++
arch/m68k/kernel/head.S | 36 +++++++---------------
arch/m68k/mac/config.c | 29 ------------------
6 files changed, 79 insertions(+), 56 deletions(-)
Index: linux-m68k/arch/m68k/Kconfig.debug
===================================================================
--- linux-m68k.orig/arch/m68k/Kconfig.debug 2014-03-03 10:17:44.000000000 +1100
+++ linux-m68k/arch/m68k/Kconfig.debug 2014-03-03 10:29:59.000000000 +1100
@@ -12,12 +12,17 @@ config BOOTPARAM_STRING
config EARLY_PRINTK
bool "Early printk"
- depends on MVME16x || MAC
+ depends on !SUN3
help
Write kernel log output directly to a serial port.
+ Where implemented, output goes to the framebuffer as well.
+ PROM console functionaliy on Sun 3x is not affected by this option.
+
+ Pass "earlyprintk" on the kernel command line to get a
+ boot console.
This is useful for kernel debugging when your machine crashes very
- early before the console code is initialized.
+ early, i.e. before the normal console driver is loaded.
You should normally say N here, unless you want to debug such a crash.
if !MMU
Index: linux-m68k/arch/m68k/kernel/Makefile
===================================================================
--- linux-m68k.orig/arch/m68k/kernel/Makefile 2014-03-03 10:17:44.000000000 +1100
+++ linux-m68k/arch/m68k/kernel/Makefile 2014-03-03 10:29:59.000000000 +1100
@@ -25,3 +25,5 @@ obj-$(CONFIG_HAS_DMA) += dma.o
obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
obj-$(CONFIG_BOOTINFO_PROC) += bootinfo_proc.o
+obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
+
Index: linux-m68k/arch/m68k/kernel/early_printk.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-m68k/arch/m68k/kernel/early_printk.c 2014-03-03 10:29:59.000000000 +1100
@@ -0,0 +1,57 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2014 Finn Thain
+ */
+
+#include <linux/kernel.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <asm/setup.h>
+
+asmlinkage void __init debug_cons_nputs(const char *s, unsigned n);
+
+static void __init debug_cons_write(struct console *c,
+ const char *s, unsigned n)
+{
+ debug_cons_nputs(s, n);
+}
+
+static struct console early_console_instance __initdata = {
+ .name = "debug",
+ .flags = CON_PRINTBUFFER | CON_BOOT,
+ .index = -1
+};
+
+static int __init setup_early_printk(char *buf)
+{
+ /* MVME16x registers an early console after interrupt setup. */
+ if (MACH_IS_MVME16x)
+ return 0;
+
+ if (early_console || buf)
+ return 0;
+
+ early_console_instance.write = debug_cons_write;
+
+ early_console = &early_console_instance;
+ register_console(early_console);
+
+ return 0;
+}
+
+early_param("earlyprintk", setup_early_printk);
+
+static int __init unregister_early_console(void)
+{
+ if (!early_console)
+ return 0;
+
+ /* debug_cons_nputs() can't be used after init sections are discarded */
+ return unregister_console(early_console);
+}
+
+late_initcall(unregister_early_console);
Index: linux-m68k/arch/m68k/kernel/head.S
===================================================================
--- linux-m68k.orig/arch/m68k/kernel/head.S 2014-03-03 10:29:47.000000000 +1100
+++ linux-m68k/arch/m68k/kernel/head.S 2014-03-03 10:29:59.000000000 +1100
@@ -221,7 +221,7 @@
* MMU_PRINT: There is a routine built into head.S that can display the
* MMU data structures. It outputs its result through the serial_putc
* interface. So where ever that winds up driving data, that's where the
- * mmu struct will appear. On the Macintosh that's typically the console.
+ * mmu struct will appear.
*
* SERIAL_DEBUG: There are a series of putc() macro statements
* scattered through out the code to give progress of status to the
@@ -249,8 +249,8 @@
* USE_MFP: Use the ST-MFP port (Modem1) for serial debug.
*
* Macintosh constants:
- * MAC_USE_SCC_A: Use SCC port A (modem) for serial debug and early console.
- * MAC_USE_SCC_B: Use SCC port B (printer) for serial debug and early console.
+ * MAC_USE_SCC_A: Use SCC port A (modem) for serial debug.
+ * MAC_USE_SCC_B: Use SCC port B (printer) for serial debug.
*/
#include <linux/linkage.h>
@@ -267,27 +267,17 @@
#include <asm/pgtable.h>
#include <asm/page.h>
#include <asm/asm-offsets.h>
-
#ifdef CONFIG_MAC
-
-#include <asm/machw.h>
-
-#ifdef CONFIG_FRAMEBUFFER_CONSOLE
-#define CONSOLE_DEBUG
+# include <asm/machw.h>
#endif
#ifdef CONFIG_EARLY_PRINTK
-#define SERIAL_DEBUG
-#else
-#undef SERIAL_DEBUG
+# define SERIAL_DEBUG
+# ifdef CONFIG_MAC
+# define CONSOLE_DEBUG
+# endif
#endif
-#else /* !CONFIG_MAC */
-
-#define SERIAL_DEBUG
-
-#endif /* !CONFIG_MAC */
-
#undef MMU_PRINT
#undef MMU_NOCACHE_KERNEL
#undef DEBUG
@@ -3213,21 +3203,19 @@ func_start putn,%d0-%d2
func_return putn
-#ifdef CONFIG_MAC
+#ifdef CONFIG_EARLY_PRINTK
/*
- * mac_early_print
- *
* This routine takes its parameters on the stack. It then
* turns around and calls the internal routines. This routine
* is used by the boot console.
*
* The calling parameters are:
- * void mac_early_print(const char *str, unsigned length);
+ * void debug_cons_nputs(const char *str, unsigned length)
*
* This routine does NOT understand variable arguments only
* simple strings!
*/
-ENTRY(mac_early_print)
+ENTRY(debug_cons_nputs)
moveml %d0/%d1/%a0,%sp@-
movew %sr,%sp@-
ori #0x0700,%sr
@@ -3249,7 +3237,7 @@ ENTRY(mac_early_print)
movew %sp@+,%sr
moveml %sp@+,%d0/%d1/%a0
rts
-#endif /* CONFIG_MAC */
+#endif /* CONFIG_EARLY_PRINTK */
#if defined(CONFIG_HP300) || defined(CONFIG_APOLLO)
func_start set_leds,%d0/%a0
Index: linux-m68k/arch/m68k/mac/config.c
===================================================================
--- linux-m68k.orig/arch/m68k/mac/config.c 2014-03-03 10:17:44.000000000 +1100
+++ linux-m68k/arch/m68k/mac/config.c 2014-03-03 10:29:59.000000000 +1100
@@ -71,31 +71,6 @@ static void mac_get_model(char *str);
static void mac_identify(void);
static void mac_report_hardware(void);
-#ifdef CONFIG_EARLY_PRINTK
-asmlinkage void __init mac_early_print(const char *s, unsigned n);
-
-static void __init mac_early_cons_write(struct console *con,
- const char *s, unsigned n)
-{
- mac_early_print(s, n);
-}
-
-static struct console __initdata mac_early_cons = {
- .name = "early",
- .write = mac_early_cons_write,
- .flags = CON_PRINTBUFFER | CON_BOOT,
- .index = -1
-};
-
-int __init mac_unregister_early_cons(void)
-{
- /* mac_early_print can't be used after init sections are discarded */
- return unregister_console(&mac_early_cons);
-}
-
-late_initcall(mac_unregister_early_cons);
-#endif
-
static void __init mac_sched_init(irq_handler_t vector)
{
via_init_clock(vector);
@@ -190,10 +165,6 @@ void __init config_mac(void)
mach_beep = mac_mksound;
#endif
-#ifdef CONFIG_EARLY_PRINTK
- register_console(&mac_early_cons);
-#endif
-
/*
* Determine hardware present
*/
Index: linux-m68k/Documentation/kernel-parameters.txt
===================================================================
--- linux-m68k.orig/Documentation/kernel-parameters.txt 2014-03-03 10:17:44.000000000 +1100
+++ linux-m68k/Documentation/kernel-parameters.txt 2014-03-03 10:29:59.000000000 +1100
@@ -845,7 +845,7 @@ bytes respectively. Such letter suffixes
(mmio) or 32-bit (mmio32).
The options are the same as for ttyS, above.
- earlyprintk= [X86,SH,BLACKFIN,ARM]
+ earlyprintk= [X86,SH,BLACKFIN,ARM,M68k]
earlyprintk=vga
earlyprintk=efi
earlyprintk=xen
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RESEND 3/4] m68k/mvme16x: adopt common boot console
2014-04-11 5:27 [PATCH RESEND 0/4] m68k: earlyprintk and debug console improvements Finn Thain
2014-04-11 5:27 ` [PATCH RESEND 1/4 v2] m68k: toward platform agnostic framebuffer debug logging Finn Thain
2014-04-11 5:27 ` [PATCH RESEND 2/4 v2] m68k: multi-platform EARLY_PRINTK Finn Thain
@ 2014-04-11 5:28 ` Finn Thain
2014-04-11 9:19 ` Geert Uytterhoeven
2014-04-11 5:28 ` [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console Finn Thain
3 siblings, 1 reply; 17+ messages in thread
From: Finn Thain @ 2014-04-11 5:28 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Michael Schmitz, linux-m68k
[-- Attachment #1: mvme16x-boot-console --]
[-- Type: text/plain, Size: 4718 bytes --]
In a multi-platform kernel binary we only need one early console instance.
The difficulty here is that the common early console gets started by
early_param(), whereas the MVME16x instance would be started later by
config_mvme16x(). That means some interrupt setup must be done earlier.
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Tested-by: Stephen N Chivers <schivers@csc.com.au>
---
arch/m68k/kernel/early_printk.c | 18 ++++++++++++------
arch/m68k/kernel/head.S | 11 +++++++++++
arch/m68k/mvme16x/config.c | 27 ++-------------------------
3 files changed, 25 insertions(+), 31 deletions(-)
Index: linux-m68k/arch/m68k/kernel/early_printk.c
===================================================================
--- linux-m68k.orig/arch/m68k/kernel/early_printk.c 2014-03-03 10:29:59.000000000 +1100
+++ linux-m68k/arch/m68k/kernel/early_printk.c 2014-03-03 10:30:01.000000000 +1100
@@ -12,6 +12,9 @@
#include <linux/string.h>
#include <asm/setup.h>
+extern void mvme16x_cons_write(struct console *co,
+ const char *str, unsigned count);
+
asmlinkage void __init debug_cons_nputs(const char *s, unsigned n);
static void __init debug_cons_write(struct console *c,
@@ -20,7 +23,11 @@ static void __init debug_cons_write(stru
debug_cons_nputs(s, n);
}
+#ifdef CONFIG_MVME16X
+static struct console early_console_instance = {
+#else
static struct console early_console_instance __initdata = {
+#endif
.name = "debug",
.flags = CON_PRINTBUFFER | CON_BOOT,
.index = -1
@@ -28,14 +35,13 @@ static struct console early_console_inst
static int __init setup_early_printk(char *buf)
{
- /* MVME16x registers an early console after interrupt setup. */
- if (MACH_IS_MVME16x)
- return 0;
-
if (early_console || buf)
return 0;
- early_console_instance.write = debug_cons_write;
+ if (MACH_IS_MVME16x)
+ early_console_instance.write = mvme16x_cons_write;
+ else
+ early_console_instance.write = debug_cons_write;
early_console = &early_console_instance;
register_console(early_console);
@@ -47,7 +53,7 @@ early_param("earlyprintk", setup_early_p
static int __init unregister_early_console(void)
{
- if (!early_console)
+ if (!early_console || MACH_IS_MVME16x)
return 0;
/* debug_cons_nputs() can't be used after init sections are discarded */
Index: linux-m68k/arch/m68k/mvme16x/config.c
===================================================================
--- linux-m68k.orig/arch/m68k/mvme16x/config.c 2014-03-03 10:17:44.000000000 +1100
+++ linux-m68k/arch/m68k/mvme16x/config.c 2014-03-03 10:30:01.000000000 +1100
@@ -213,7 +213,8 @@ static void __init mvme16x_init_IRQ (voi
#define CySCRH (0x22)
#define CyTFTC (0x80)
-static void cons_write(struct console *co, const char *str, unsigned count)
+void mvme16x_cons_write(struct console *co,
+ const char *str, unsigned count)
{
volatile unsigned char *base_addr = (u_char *)CD2401_ADDR;
volatile u_char sink;
@@ -268,20 +269,6 @@ static void cons_write(struct console *c
base_addr[CyIER] = ier;
}
-static struct console cons_info =
-{
- .name = "sercon",
- .write = cons_write,
- .flags = CON_PRINTBUFFER | CON_BOOT,
- .index = -1,
-};
-
-static void __init mvme16x_early_console(void)
-{
- register_console(&cons_info);
-
- printk(KERN_INFO "MVME16x: early console registered\n");
-}
#endif
void __init config_mvme16x(void)
@@ -336,16 +323,6 @@ void __init config_mvme16x(void)
else
{
mvme16x_config = MVME16x_CONFIG_GOT_LP | MVME16x_CONFIG_GOT_CD2401;
-
- /* Dont allow any interrupts from the CD2401 until the interrupt */
- /* handlers are installed */
-
- pcc2chip[PccSCCMICR] = 0x10;
- pcc2chip[PccSCCTICR] = 0x10;
- pcc2chip[PccSCCRICR] = 0x10;
-#ifdef CONFIG_EARLY_PRINTK
- mvme16x_early_console();
-#endif
}
}
Index: linux-m68k/arch/m68k/kernel/head.S
===================================================================
--- linux-m68k.orig/arch/m68k/kernel/head.S 2014-03-03 10:29:59.000000000 +1100
+++ linux-m68k/arch/m68k/kernel/head.S 2014-03-03 10:30:01.000000000 +1100
@@ -2936,6 +2936,15 @@ L(serial_init_not_mac):
2:
#endif
+#ifdef CONFIG_MVME16x
+ is_not_mvme16x(L(serial_init_not_mvme16x))
+ moveb #0x10,M167_PCSCCMICR
+ moveb #0x10,M167_PCSCCTICR
+ moveb #0x10,M167_PCSCCRICR
+ jra L(serial_init_done)
+L(serial_init_not_mvme16x):
+#endif
+
#ifdef CONFIG_APOLLO
/* We count on the PROM initializing SIO1 */
#endif
@@ -3768,7 +3777,9 @@ M167_CYIER = 0xfff45011
M167_CYLICR = 0xfff45026
M167_CYTEOIR = 0xfff45085
M167_CYTDR = 0xfff450f8
+M167_PCSCCMICR = 0xfff4201d
M167_PCSCCTICR = 0xfff4201e
+M167_PCSCCRICR = 0xfff4201f
M167_PCTPIACKR = 0xfff42025
#endif
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 3/4] m68k/mvme16x: adopt common boot console
2014-04-11 5:28 ` [PATCH RESEND 3/4] m68k/mvme16x: adopt common boot console Finn Thain
@ 2014-04-11 9:19 ` Geert Uytterhoeven
2014-04-12 1:40 ` Finn Thain
0 siblings, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2014-04-11 9:19 UTC (permalink / raw)
To: Finn Thain; +Cc: Michael Schmitz, Linux/m68k
Hi Finn,
On Fri, Apr 11, 2014 at 7:28 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> In a multi-platform kernel binary we only need one early console instance.
> The difficulty here is that the common early console gets started by
> early_param(), whereas the MVME16x instance would be started later by
> config_mvme16x(). That means some interrupt setup must be done earlier.
Thanks!
> --- linux-m68k.orig/arch/m68k/kernel/early_printk.c 2014-03-03 10:29:59.000000000 +1100
> +++ linux-m68k/arch/m68k/kernel/early_printk.c 2014-03-03 10:30:01.000000000 +1100
> +#ifdef CONFIG_MVME16X
> +static struct console early_console_instance = {
> +#else
> static struct console early_console_instance __initdata = {
> +#endif
> + if (MACH_IS_MVME16x)
> + early_console_instance.write = mvme16x_cons_write;
> + else
> + early_console_instance.write = debug_cons_write;
> + if (!early_console || MACH_IS_MVME16x)
> return 0;
I don't like these tests for MVME16X in (presumably) generic code.
Is there a way we can avoid this?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 3/4] m68k/mvme16x: adopt common boot console
2014-04-11 9:19 ` Geert Uytterhoeven
@ 2014-04-12 1:40 ` Finn Thain
0 siblings, 0 replies; 17+ messages in thread
From: Finn Thain @ 2014-04-12 1:40 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Michael Schmitz, Linux/m68k
On Fri, 11 Apr 2014, Geert Uytterhoeven wrote:
>
> > +#ifdef CONFIG_MVME16X
> > +static struct console early_console_instance = {
> > +#else
> > static struct console early_console_instance __initdata = {
> > +#endif
>
> > + if (MACH_IS_MVME16x)
> > + early_console_instance.write = mvme16x_cons_write;
> > + else
> > + early_console_instance.write = debug_cons_write;
>
> > + if (!early_console || MACH_IS_MVME16x)
> > return 0;
>
> I don't like these tests for MVME16X in (presumably) generic code.
> Is there a way we can avoid this?
>
Some alternative approaches:
1) Somehow make the tests more precise: "are we running on MVME?"
becomes "is the console output code not in .init.text?"
I don't know that this is feasible.
2) Mark the MVME console output routine __init (making it less useful).
If we make all users of earlyprintk lose the boot console at
__late_initcall() time, then we can call mvme16x_cons_write() from
debug_cons_write().
3) Move all of the head.S console code and data out of .init sections, for
all platforms. Not practical I think.
4) If the bloat is acceptable, maybe we could scrap the __init attributes
for early_console_instance and debug_cons_write(). And call
mvme16x_cons_write() from debug_cons_write(). Then hide all these
routines and the __late_initcall within
#if defined(CONFIG_AMIGA) || defined(CONFIG_ATARI) || ...
#endif
Thoughts?
--
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-04-11 5:27 [PATCH RESEND 0/4] m68k: earlyprintk and debug console improvements Finn Thain
` (2 preceding siblings ...)
2014-04-11 5:28 ` [PATCH RESEND 3/4] m68k/mvme16x: adopt common boot console Finn Thain
@ 2014-04-11 5:28 ` Finn Thain
2014-05-25 9:09 ` Geert Uytterhoeven
2014-05-26 8:56 ` Michael Schmitz
3 siblings, 2 replies; 17+ messages in thread
From: Finn Thain @ 2014-04-11 5:28 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Michael Schmitz, linux-m68k
[-- Attachment #1: atari-scc-serial-debug --]
[-- Type: text/plain, Size: 3640 bytes --]
Fix SCC initialization for Atari as was previously fixed for Mac. It's
probably not practical to share more code but some attempt is made to
align the Mac and Atari variants.
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
This patch needs testing on Atari. It can't be tested without editing
macro definitions to enable SCC debug output (which also means disabling
MFP debug output).
The line rate is changed to 38400 baud to match the Mac code (which
follows the pmac_zilog serial console default). It would be nice to
standardize but I don't know whether this is realistic.
The 7.9872 MHz PCLK used in this patch was inferred from the existing code
as I don't have any hardware data.
---
arch/m68k/kernel/head.S | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
Index: linux-m68k/arch/m68k/kernel/head.S
===================================================================
--- linux-m68k.orig/arch/m68k/kernel/head.S 2014-03-11 22:43:38.000000000 +1100
+++ linux-m68k/arch/m68k/kernel/head.S 2014-03-11 22:43:38.000000000 +1100
@@ -2722,6 +2722,7 @@ func_return get_new_page
#define MAC_USE_SCC_B /* Printer port */
#if defined(MAC_USE_SCC_A) || defined(MAC_USE_SCC_B)
+/* Initialisation table for SCC with 3.6864 MHz PCLK */
L(scc_initable_mac):
.byte 4,0x44 /* x16, 1 stopbit, no parity */
.byte 3,0xc0 /* receiver: 8 bpc */
@@ -2744,17 +2745,14 @@ L(scc_initable_mac):
#define USE_MFP
#if defined(USE_SCC_A) || defined(USE_SCC_B)
-#define USE_SCC
-/* Initialisation table for SCC */
-L(scc_initable):
- .byte 9,12 /* Reset */
- .byte 4,0x44 /* x16, 1 stopbit, no parity */
+/* Initialisation table for SCC with 7.9872 MHz PCLK */
+L(scc_initable_atari):
+ .byte 4,0x04 /* x1, 1 stopbit, no parity */
.byte 3,0xc0 /* receiver: 8 bpc */
.byte 5,0xe2 /* transmitter: 8 bpc, assert dtr/rts */
- .byte 9,0 /* no interrupts */
.byte 10,0 /* NRZ */
.byte 11,0x50 /* use baud rate generator */
- .byte 12,24,13,0 /* 9600 baud */
+ .byte 12,102,13,0 /* 38400 baud */
.byte 14,2,14,3 /* use master clock for BRG, enable */
.byte 3,0xc1 /* enable receiver */
.byte 5,0xea /* enable transmitter */
@@ -2800,7 +2798,7 @@ LMFP_UDR = 0xfffa2f
*/
/*
- * Initialize serial port hardware for 9600/8/1
+ * Initialize serial port hardware
*/
func_start serial_init,%d0/%d1/%a0/%a1
/*
@@ -2810,7 +2808,7 @@ func_start serial_init,%d0/%d1/%a0/%a1
* d0 = boot info offset
* CONFIG_ATARI
* a0 = address of SCC
- * a1 = Liobase address/address of scc_initable
+ * a1 = Liobase address/address of scc_initable_atari
* d0 = init data for serial port
* CONFIG_MAC
* a0 = address of SCC
@@ -2846,9 +2844,21 @@ func_start serial_init,%d0/%d1/%a0/%a1
moveb %a1@(LPSG_READ),%d0
bset #5,%d0
moveb %d0,%a1@(LPSG_WRITE)
-#elif defined(USE_SCC)
+#elif defined(USE_SCC_A) || defined(USE_SCC_B)
lea %a1@(LSCC_CTRL),%a0
- lea %pc@(L(scc_initable)),%a1
+ /* Reset SCC register pointer */
+ moveb %a0@,%d0
+ /* Reset SCC device: write register pointer then register value */
+ moveb #9,%a0@
+ moveb #0xc0,%a0@
+ /* Wait for 5 PCLK cycles, which is about 63 CPU cycles */
+ /* 5 / 7.9872 MHz = approx. 0.63 us = 63 / 100 MHz */
+ movel #32,%d0
+2:
+ subq #1,%d0
+ jne 2b
+ /* Initialize channel */
+ lea %pc@(L(scc_initable_atari)),%a1
2: moveb %a1@+,%d0
jmi 3f
moveb %d0,%a0@
@@ -3017,7 +3027,7 @@ func_start serial_putc,%d0/%d1/%a0/%a1
nop
bset #5,%d0
moveb %d0,%a1@(LPSG_WRITE)
-#elif defined(USE_SCC)
+#elif defined(USE_SCC_A) || defined(USE_SCC_B)
3: btst #2,%a1@(LSCC_CTRL)
jeq 3b
moveb %d0,%a1@(LSCC_DATA)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-04-11 5:28 ` [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console Finn Thain
@ 2014-05-25 9:09 ` Geert Uytterhoeven
2014-05-25 10:37 ` Finn Thain
2014-05-26 1:18 ` Michael Schmitz
2014-05-26 8:56 ` Michael Schmitz
1 sibling, 2 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2014-05-25 9:09 UTC (permalink / raw)
To: Finn Thain; +Cc: Michael Schmitz, Linux/m68k
On Fri, Apr 11, 2014 at 7:28 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> Fix SCC initialization for Atari as was previously fixed for Mac. It's
> probably not practical to share more code but some attempt is made to
> align the Mac and Atari variants.
>
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
>
> ---
> This patch needs testing on Atari. It can't be tested without editing
> macro definitions to enable SCC debug output (which also means disabling
> MFP debug output).
>
> The line rate is changed to 38400 baud to match the Mac code (which
> follows the pmac_zilog serial console default). It would be nice to
> standardize but I don't know whether this is realistic.
>
> The 7.9872 MHz PCLK used in this patch was inferred from the existing code
> as I don't have any hardware data.
Has anyone tested this on Atari?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-05-25 9:09 ` Geert Uytterhoeven
@ 2014-05-25 10:37 ` Finn Thain
2014-05-26 1:23 ` Michael Schmitz
2014-05-26 1:18 ` Michael Schmitz
1 sibling, 1 reply; 17+ messages in thread
From: Finn Thain @ 2014-05-25 10:37 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Michael Schmitz, Linux/m68k
On Sun, 25 May 2014, Geert Uytterhoeven wrote:
> Has anyone tested this on Atari?
The patch doesn't change behaviour. If someone wanted to test it, they'd
also need to make changes like this:
diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S
index 3ab329b..b210a29 100644
--- a/arch/m68k/kernel/head.S
+++ b/arch/m68k/kernel/head.S
@@ -2752,7 +2752,7 @@ L(scc_initable_mac):
#ifdef CONFIG_ATARI
/* #define USE_PRINTER */
/* #define USE_SCC_B */
-/* #define USE_SCC_A */
+#define USE_SCC_A
#define USE_MFP
#if defined(USE_SCC_A) || defined(USE_SCC_B)
That difficulty is one reason why this patch series replaces some other
buried macros with Kconfig symbols...
--
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-05-25 10:37 ` Finn Thain
@ 2014-05-26 1:23 ` Michael Schmitz
2014-05-26 4:30 ` Finn Thain
0 siblings, 1 reply; 17+ messages in thread
From: Michael Schmitz @ 2014-05-26 1:23 UTC (permalink / raw)
To: Finn Thain; +Cc: Geert Uytterhoeven, Michael Schmitz, Linux/m68k
Hi Finn,
On Sun, May 25, 2014 at 10:37 PM, Finn Thain <fthain@telegraphics.com.au> wrote:
>
> On Sun, 25 May 2014, Geert Uytterhoeven wrote:
>
>> Has anyone tested this on Atari?
>
> The patch doesn't change behaviour. If someone wanted to test it, they'd
> also need to make changes like this:
>
> diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S
> index 3ab329b..b210a29 100644
> --- a/arch/m68k/kernel/head.S
> +++ b/arch/m68k/kernel/head.S
> @@ -2752,7 +2752,7 @@ L(scc_initable_mac):
> #ifdef CONFIG_ATARI
> /* #define USE_PRINTER */
> /* #define USE_SCC_B */
> -/* #define USE_SCC_A */
> +#define USE_SCC_A
> #define USE_MFP
>
> #if defined(USE_SCC_A) || defined(USE_SCC_B)
>
> That difficulty is one reason why this patch series replaces some other
> buried macros with Kconfig symbols...
>
Does it even work if both USE_SCC_A and USE_MFP are defined? I've only
ever had defined one or the other.
Would not object to making that change too, if it happens to work OK.
More to test, sigh.
Cheers,
Michael
> --
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-05-26 1:23 ` Michael Schmitz
@ 2014-05-26 4:30 ` Finn Thain
0 siblings, 0 replies; 17+ messages in thread
From: Finn Thain @ 2014-05-26 4:30 UTC (permalink / raw)
To: Michael Schmitz; +Cc: Geert Uytterhoeven, Michael Schmitz, Linux/m68k
On Mon, 26 May 2014, Michael Schmitz wrote:
> On Sun, May 25, 2014 at 10:37 PM, Finn Thain <fthain@telegraphics.com.au> wrote:
>
> >
> > diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S
> > index 3ab329b..b210a29 100644
> > --- a/arch/m68k/kernel/head.S
> > +++ b/arch/m68k/kernel/head.S
> > @@ -2752,7 +2752,7 @@ L(scc_initable_mac):
> > #ifdef CONFIG_ATARI
> > /* #define USE_PRINTER */
> > /* #define USE_SCC_B */
> > -/* #define USE_SCC_A */
> > +#define USE_SCC_A
> > #define USE_MFP
> >
> > #if defined(USE_SCC_A) || defined(USE_SCC_B)
> >
>
> Does it even work if both USE_SCC_A and USE_MFP are defined? I've only
> ever had defined one or the other.
Right, you can't use both. The logic throughout head.S seems to be
consistent --
#if defined(USE_PRINTER)
...
#elif defined(USE_SCC_A) || defined(USE_SCC_B)
...
#elif defined(USE_MFP)
...
#endif
>
> Would not object to making that change too, if it happens to work OK.
Disabling the MFP output might not be desirable, so I'm not actually
proposing that change should be merged.
> More to test, sigh.
I'm sorry for sending untested patches but I didn't really expect anyone
to test this. It amounts to a bug fix in dead code and probably doesn't
need any more testing: it's mostly copied from the Mac SCC code, which has
been tested already.
--
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-05-25 9:09 ` Geert Uytterhoeven
2014-05-25 10:37 ` Finn Thain
@ 2014-05-26 1:18 ` Michael Schmitz
1 sibling, 0 replies; 17+ messages in thread
From: Michael Schmitz @ 2014-05-26 1:18 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Finn Thain, Michael Schmitz, Linux/m68k
Hi Geert,
On Sun, May 25, 2014 at 9:09 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Fri, Apr 11, 2014 at 7:28 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
>> Fix SCC initialization for Atari as was previously fixed for Mac. It's
>> probably not practical to share more code but some attempt is made to
>> align the Mac and Atari variants.
>>
>> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
>>
>> ---
>> This patch needs testing on Atari. It can't be tested without editing
>> macro definitions to enable SCC debug output (which also means disabling
>> MFP debug output).
>>
>> The line rate is changed to 38400 baud to match the Mac code (which
>> follows the pmac_zilog serial console default). It would be nice to
>> standardize but I don't know whether this is realistic.
>>
>> The 7.9872 MHz PCLK used in this patch was inferred from the existing code
>> as I don't have any hardware data.
>
> Has anyone tested this on Atari?
>
Ooops - not yet. Thanks for reminding me.
Cheers,
Michael
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-04-11 5:28 ` [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console Finn Thain
2014-05-25 9:09 ` Geert Uytterhoeven
@ 2014-05-26 8:56 ` Michael Schmitz
2014-05-26 9:28 ` Geert Uytterhoeven
2014-05-26 12:03 ` Finn Thain
1 sibling, 2 replies; 17+ messages in thread
From: Michael Schmitz @ 2014-05-26 8:56 UTC (permalink / raw)
To: Finn Thain; +Cc: Geert Uytterhoeven, linux-m68k
Finn Thain wrote:
> Fix SCC initialization for Atari as was previously fixed for Mac. It's
> probably not practical to share more code but some attempt is made to
> align the Mac and Atari variants.
>
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
>
> ---
> This patch needs testing on Atari. It can't be tested without editing
> macro definitions to enable SCC debug output (which also means disabling
> MFP debug output).
>
> The line rate is changed to 38400 baud to match the Mac code (which
> follows the pmac_zilog serial console default). It would be nice to
> standardize but I don't know whether this is realistic.
>
> The 7.9872 MHz PCLK used in this patch was inferred from the existing code
> as I don't have any hardware data.
>
Might just be my PC not autodetecting this 38400 baud rate right, but
all I get is gibberish from the early console. The original code (still
running at 9600 baud) works.
I'll have to check clock source and rate from the old SCC driver.
> ---
> arch/m68k/kernel/head.S | 34 ++++++++++++++++++++++------------
> 1 file changed, 22 insertions(+), 12 deletions(-)
>
> Index: linux-m68k/arch/m68k/kernel/head.S
> ===================================================================
> --- linux-m68k.orig/arch/m68k/kernel/head.S 2014-03-11 22:43:38.000000000 +1100
> +++ linux-m68k/arch/m68k/kernel/head.S 2014-03-11 22:43:38.000000000 +1100
> @@ -2722,6 +2722,7 @@ func_return get_new_page
> #define MAC_USE_SCC_B /* Printer port */
>
> #if defined(MAC_USE_SCC_A) || defined(MAC_USE_SCC_B)
> +/* Initialisation table for SCC with 3.6864 MHz PCLK */
> L(scc_initable_mac):
> .byte 4,0x44 /* x16, 1 stopbit, no parity */
> .byte 3,0xc0 /* receiver: 8 bpc */
>
That hunk fails to apply when merging this patch alone, i.e. without
applying the other ones from this series first. Probably belongs with
patch 1 where the #if defined() is introduced.
> @@ -2744,17 +2745,14 @@ L(scc_initable_mac):
> #define USE_MFP
>
> #if defined(USE_SCC_A) || defined(USE_SCC_B)
> -#define USE_SCC
> -/* Initialisation table for SCC */
> -L(scc_initable):
> - .byte 9,12 /* Reset */
> - .byte 4,0x44 /* x16, 1 stopbit, no parity */
> +/* Initialisation table for SCC with 7.9872 MHz PCLK */
> +L(scc_initable_atari):
> + .byte 4,0x04 /* x1, 1 stopbit, no parity */
> .byte 3,0xc0 /* receiver: 8 bpc */
> .byte 5,0xe2 /* transmitter: 8 bpc, assert dtr/rts */
> - .byte 9,0 /* no interrupts */
> .byte 10,0 /* NRZ */
> .byte 11,0x50 /* use baud rate generator */
> - .byte 12,24,13,0 /* 9600 baud */
> + .byte 12,102,13,0 /* 38400 baud */
> .byte 14,2,14,3 /* use master clock for BRG, enable */
> .byte 3,0xc1 /* enable receiver */
> .byte 5,0xea /* enable transmitter */
> @@ -2800,7 +2798,7 @@ LMFP_UDR = 0xfffa2f
> */
>
> /*
> - * Initialize serial port hardware for 9600/8/1
> + * Initialize serial port hardware
> */
> func_start serial_init,%d0/%d1/%a0/%a1
> /*
> @@ -2810,7 +2808,7 @@ func_start serial_init,%d0/%d1/%a0/%a1
> * d0 = boot info offset
> * CONFIG_ATARI
> * a0 = address of SCC
> - * a1 = Liobase address/address of scc_initable
> + * a1 = Liobase address/address of scc_initable_atari
> * d0 = init data for serial port
> * CONFIG_MAC
> * a0 = address of SCC
> @@ -2846,9 +2844,21 @@ func_start serial_init,%d0/%d1/%a0/%a1
> moveb %a1@(LPSG_READ),%d0
> bset #5,%d0
> moveb %d0,%a1@(LPSG_WRITE)
> -#elif defined(USE_SCC)
> +#elif defined(USE_SCC_A) || defined(USE_SCC_B)
> lea %a1@(LSCC_CTRL),%a0
> - lea %pc@(L(scc_initable)),%a1
> + /* Reset SCC register pointer */
> + moveb %a0@,%d0
> + /* Reset SCC device: write register pointer then register value */
> + moveb #9,%a0@
> + moveb #0xc0,%a0@
> + /* Wait for 5 PCLK cycles, which is about 63 CPU cycles */
> + /* 5 / 7.9872 MHz = approx. 0.63 us = 63 / 100 MHz */
>
The original Falcon and TT had a 16 MHz CPU clock IIRC.
> + movel #32,%d0
> +2:
> + subq #1,%d0
> + jne 2b
> + /* Initialize channel */
> + lea %pc@(L(scc_initable_atari)),%a1
> 2: moveb %a1@+,%d0
> jmi 3f
> moveb %d0,%a0@
> @@ -3017,7 +3027,7 @@ func_start serial_putc,%d0/%d1/%a0/%a1
> nop
> bset #5,%d0
> moveb %d0,%a1@(LPSG_WRITE)
> -#elif defined(USE_SCC)
> +#elif defined(USE_SCC_A) || defined(USE_SCC_B)
> 3: btst #2,%a1@(LSCC_CTRL)
> jeq 3b
> moveb %d0,%a1@(LSCC_DATA)
>
>
Cheers,
Michael
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-05-26 8:56 ` Michael Schmitz
@ 2014-05-26 9:28 ` Geert Uytterhoeven
2014-05-26 11:43 ` Finn Thain
2014-05-26 12:03 ` Finn Thain
1 sibling, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2014-05-26 9:28 UTC (permalink / raw)
To: Michael Schmitz; +Cc: Finn Thain, Linux/m68k
On Mon, May 26, 2014 at 10:56 AM, Michael Schmitz <schmitzmic@gmail.com> wrote:
>> + /* Wait for 5 PCLK cycles, which is about 63 CPU cycles */
>> + /* 5 / 7.9872 MHz = approx. 0.63 us = 63 / 100 MHz */
>
> The original Falcon and TT had a 16 MHz CPU clock IIRC.
This loop is meant to introduce a minimum delay, right? So assuming
a 100 MHz CPU will only prolong the delay on slower CPUs, which is safe.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-05-26 9:28 ` Geert Uytterhoeven
@ 2014-05-26 11:43 ` Finn Thain
0 siblings, 0 replies; 17+ messages in thread
From: Finn Thain @ 2014-05-26 11:43 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Michael Schmitz, Linux/m68k
On Mon, 26 May 2014, Geert Uytterhoeven wrote:
> On Mon, May 26, 2014 at 10:56 AM, Michael Schmitz <schmitzmic@gmail.com>
> wrote:
> >> + /* Wait for 5 PCLK cycles, which is about 63 CPU cycles */
> >> + /* 5 / 7.9872 MHz = approx. 0.63 us = 63 / 100 MHz */
> >
> > The original Falcon and TT had a 16 MHz CPU clock IIRC.
>
> This loop is meant to introduce a minimum delay, right? So assuming a
> 100 MHz CPU will only prolong the delay on slower CPUs, which is safe.
Right. It's intended to cope with CPU upgrades.
--
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-05-26 8:56 ` Michael Schmitz
2014-05-26 9:28 ` Geert Uytterhoeven
@ 2014-05-26 12:03 ` Finn Thain
2014-05-26 17:44 ` Andreas Schwab
1 sibling, 1 reply; 17+ messages in thread
From: Finn Thain @ 2014-05-26 12:03 UTC (permalink / raw)
To: Michael Schmitz; +Cc: Geert Uytterhoeven, linux-m68k
On Mon, 26 May 2014, Michael Schmitz wrote:
> Finn Thain wrote:
> >
> > The 7.9872 MHz PCLK used in this patch was inferred from the existing
> > code as I don't have any hardware data.
> >
>
> Might just be my PC not autodetecting this 38400 baud rate right, but
> all I get is gibberish from the early console. The original code (still
> running at 9600 baud) works.
>
> I'll have to check clock source and rate from the old SCC driver.
I'll see what I can find also. Do you know of any hardware reference
material available on the web?
--
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 4/4] m68k/atari: fix SCC initialization for debug console
2014-05-26 12:03 ` Finn Thain
@ 2014-05-26 17:44 ` Andreas Schwab
0 siblings, 0 replies; 17+ messages in thread
From: Andreas Schwab @ 2014-05-26 17:44 UTC (permalink / raw)
To: Finn Thain; +Cc: Michael Schmitz, Geert Uytterhoeven, linux-m68k
Finn Thain <fthain@telegraphics.com.au> writes:
> I'll see what I can find also. Do you know of any hardware reference
> material available on the web?
If you can read German then the best reference is probably the Atari
Profibuch (http://atariprofibuch.de/).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 17+ messages in thread