Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Garbage characters instead of prompt on beaglebone




> On Jan 10, 2019, at 10:46 PM, Lwazi Dube <lwazeh%gmail.com@localhost> wrote:
> 
> I found the problem, MDR1 is overwriting LCR. Following diff fixes it for me.
> Thanks,

Oh, nice catch.  That com_std_regmap[] is a little hairy.  Can you try this patch that tidies it up?

Index: arch/mips/alchemy/dev/com_aubus.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/alchemy/dev/com_aubus.c,v
retrieving revision 1.8
diff -u -p -r1.8 com_aubus.c
--- arch/mips/alchemy/dev/com_aubus.c	8 Dec 2018 21:14:36 -0000	1.8
+++ arch/mips/alchemy/dev/com_aubus.c	11 Jan 2019 17:44:49 -0000
@@ -172,6 +172,21 @@ com_aubus_disable(struct com_softc *sc)
 	    AUCOM_MODCTL, 0);
 }
 
+static const bus_size_t com_aubus_regmap[COM_REGMAP_NENTRIES] = {
+	[COM_REG_RXDATA]	=	AUCOM_RXDATA,
+	[COM_REG_TXDATA]	=	AUCOM_TXDATA,
+	[COM_REG_DLBL]		=	AUCOM_DLB,
+	[COM_REG_DLBH]		=	AUCOM_DLB,
+	[COM_REG_IER]		=	AUCOM_IER,
+	[COM_REG_IIR]		=	AUCOM_IIR,
+	[COM_REG_FIFO]		=	AUCOM_FIFO,
+	[COM_REG_TCR]		=	AUCOM_FIFO,
+	[COM_REG_LCR]		=	AUCOM_LCTL,
+	[COM_REG_MCR]		=	AUCOM_MCR,
+	[COM_REG_LSR]		=	AUCOM_LSR,
+	[COM_REG_MSR]		=	AUCOM_MSR,
+};
+
 void
 com_aubus_init_regs(struct com_regs *regsp, bus_space_tag_t bst,
 		    bus_space_handle_t bsh, bus_addr_t addr)
@@ -179,19 +194,8 @@ com_aubus_init_regs(struct com_regs *reg
 
 	com_init_regs(regsp, bst, bsh, addr);
 
+	memcpy(regsp->cr_map, com_aubus_regmap, sizeof(regsp->cr_map));
 	regsp->cr_nports = AUCOM_NPORTS;
-	regsp->cr_map[COM_REG_RXDATA] = AUCOM_RXDATA;
-	regsp->cr_map[COM_REG_TXDATA] = AUCOM_TXDATA;
-	regsp->cr_map[COM_REG_DLBL] = AUCOM_DLB;
-	regsp->cr_map[COM_REG_DLBH] = AUCOM_DLB;
-	regsp->cr_map[COM_REG_IER] = AUCOM_IER;
-	regsp->cr_map[COM_REG_IIR] = AUCOM_IIR;
-	regsp->cr_map[COM_REG_FIFO] = AUCOM_FIFO;
-	regsp->cr_map[COM_REG_EFR] = 0;
-	regsp->cr_map[COM_REG_LCR] = AUCOM_LCTL;
-	regsp->cr_map[COM_REG_MCR] = AUCOM_MCR;
-	regsp->cr_map[COM_REG_LSR] = AUCOM_LSR;
-	regsp->cr_map[COM_REG_MSR] = AUCOM_MSR;
 }
 
 int
Index: arch/mips/ralink/ralink_com.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/ralink/ralink_com.c,v
retrieving revision 1.7
diff -u -p -r1.7 ralink_com.c
--- arch/mips/ralink/ralink_com.c	8 Dec 2018 21:14:36 -0000	1.7
+++ arch/mips/ralink/ralink_com.c	11 Jan 2019 17:44:49 -0000
@@ -367,6 +367,23 @@ ralink_com_attach(device_t parent, devic
 	com_attach_subr(sc);
 }
 
+static const bus_size_t ralink_com_regmap[] = {
+	[COM_REG_RXDATA]	=	RA_UART_RBR,
+	[COM_REG_TXDATA]	=	RA_UART_TBR,
+	[COM_REG_DLBL]		=	RA_UART_DLL,
+#if defined(MT7628)
+	[COM_REG_DLBH]		=	RA_UART_DLM,
+#endif
+	[COM_REG_IER]		=	RA_UART_IER,
+	[COM_REG_IIR]		=	RA_UART_IIR,
+	[COM_REG_FIFO]		=	RA_UART_FCR,
+	[COM_REG_TCR]		=	RA_UART_FCR,
+	[COM_REG_LCR]		=	RA_UART_LCR,
+	[COM_REG_MCR]		=	RA_UART_MCR,
+	[COM_REG_LSR]		=	RA_UART_LSR,
+	[COM_REG_MSR]		=	RA_UART_MSR,
+};
+
 static void
 ralink_com_init_regs(struct com_regs *regsp, bus_space_tag_t st,
 		     bus_space_handle_t sh, bus_addr_t addr)
@@ -374,20 +391,7 @@ ralink_com_init_regs(struct com_regs *re
 
 	com_init_regs(regsp, st, sh, addr);
 
-	regsp->cr_map[COM_REG_RXDATA] = RA_UART_RBR;
-	regsp->cr_map[COM_REG_TXDATA] = RA_UART_TBR;
-	regsp->cr_map[COM_REG_DLBL]   = RA_UART_DLL;
-#if defined(MT7628)
-	regsp->cr_map[COM_REG_DLBH]   = RA_UART_DLM;
-#endif
-	regsp->cr_map[COM_REG_IER]    = RA_UART_IER;
-	regsp->cr_map[COM_REG_IIR]    = RA_UART_IIR;
-	regsp->cr_map[COM_REG_FIFO]   = RA_UART_FCR;
-	regsp->cr_map[COM_REG_LCR]    = RA_UART_LCR;
-	regsp->cr_map[COM_REG_MCR]    = RA_UART_MCR;
-	regsp->cr_map[COM_REG_LSR]    = RA_UART_LSR;
-	regsp->cr_map[COM_REG_MSR]    = RA_UART_MSR;
-
+	memcpy(regsp->cr_map, ralink_com_regmap, sizeof(regsp->cr_map));
 	regsp->cr_nports = 32;
 }
 
Index: dev/ic/com.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/com.c,v
retrieving revision 1.354
diff -u -p -r1.354 com.c
--- dev/ic/com.c	11 Dec 2018 06:34:00 -0000	1.354
+++ dev/ic/com.c	11 Jan 2019 17:44:50 -0000
@@ -236,13 +236,27 @@ void	com_kgdb_putc(void *, int);
 #endif /* KGDB */
 
 /* initializer for typical 16550-ish hardware */
-#define	COM_REG_STD { \
-	com_data, com_data, com_dlbl, com_dlbh, com_ier, com_iir, com_fifo, \
-	com_efr, com_lcr, com_mcr, com_lsr, com_msr, 0, 0, 0, 0, 0, 0, 0, 0, \
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, com_usr, com_tfl, com_rfl, \
-	0, 0, 0, 0, 0, 0, 0, com_halt }
-
-static const bus_size_t com_std_map[42] = COM_REG_STD;
+static const bus_size_t com_std_map[COM_REGMAP_NENTRIES] = {
+	[COM_REG_RXDATA]	=	com_data,
+	[COM_REG_TXDATA]	=	com_data,
+	[COM_REG_DLBL]		=	com_dlbl,
+	[COM_REG_DLBH]		=	com_dlbh,
+	[COM_REG_IER]		=	com_ier,
+	[COM_REG_IIR]		=	com_iir,
+	[COM_REG_FIFO]		=	com_fifo,
+	[COM_REG_TCR]		=	com_fifo,
+	[COM_REG_EFR]		=	com_efr,
+	[COM_REG_TLR]		=	com_efr,
+	[COM_REG_LCR]		=	com_lcr,
+	[COM_REG_MCR]		=	com_mcr,
+	[COM_REG_LSR]		=	com_lsr,
+	[COM_REG_MSR]		=	com_msr,
+	[COM_REG_USR]		=	com_usr,
+	[COM_REG_TFL]		=	com_tfl,
+	[COM_REG_RFL]		=	com_rfl,
+	[COM_REG_HALT]		=	com_halt,
+	[COM_REG_MDR1]		=	com_mdr1,
+};
 
 #define	COMDIALOUT_MASK	TTDIALOUT_MASK
 
Index: dev/ic/comvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/comvar.h,v
retrieving revision 1.91
diff -u -p -r1.91 comvar.h
--- dev/ic/comvar.h	11 Dec 2018 06:34:00 -0000	1.91
+++ dev/ic/comvar.h	11 Jan 2019 17:44:50 -0000
@@ -83,25 +83,27 @@ int com_is_console(bus_space_tag_t, bus_
 #define	COM_REG_IER		4
 #define	COM_REG_IIR		5
 #define	COM_REG_FIFO		6
-#define	COM_REG_TCR		6
-#define	COM_REG_EFR		7
-#define	COM_REG_TLR		7
-#define	COM_REG_LCR		8
-#define	COM_REG_MDR1		8
-#define	COM_REG_MCR		9
-#define	COM_REG_LSR		10
-#define	COM_REG_MSR		11
-#define	COM_REG_USR		31		/* 16750/DW APB */
-#define	COM_REG_TFL		com_tfl		/* DW APB */
-#define	COM_REG_RFL		com_rfl		/* DW APB */
-#define	COM_REG_HALT		com_halt	/* DW APB */
+#define	COM_REG_TCR		7
+#define	COM_REG_EFR		8
+#define	COM_REG_TLR		9
+#define	COM_REG_LCR		10
+#define	COM_REG_MCR		11
+#define	COM_REG_LSR		12
+#define	COM_REG_MSR		13
+#define	COM_REG_MDR1		14		/* TI OMAP */
+#define	COM_REG_USR		15		/* 16750/DW APB */
+#define	COM_REG_TFL		16		/* DW APB */
+#define	COM_REG_RFL		17		/* DW APB */
+#define	COM_REG_HALT		18		/* DW APB */
+
+#define	COM_REGMAP_NENTRIES	19
 
 struct com_regs {
 	bus_space_tag_t		cr_iot;
 	bus_space_handle_t	cr_ioh;
 	bus_addr_t		cr_iobase;
 	bus_size_t		cr_nports;
-	bus_size_t		cr_map[42];
+	bus_size_t		cr_map[COM_REGMAP_NENTRIES];
 };
 
 void	com_init_regs(struct com_regs *, bus_space_tag_t, bus_space_handle_t,
Index: dev/ic/ns16550reg.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/ns16550reg.h,v
retrieving revision 1.12
diff -u -p -r1.12 ns16550reg.h
--- dev/ic/ns16550reg.h	29 Oct 2017 14:06:08 -0000	1.12
+++ dev/ic/ns16550reg.h	11 Jan 2019 17:44:50 -0000
@@ -43,12 +43,18 @@
 #define	com_fifo	2	/* FIFO control (W) */
 #define	com_lctl	3	/* line control register (R/W) */
 #define	com_cfcr	3	/* line control register (R/W) */
+#define	com_lcr		com_cfcr
 #define	com_mcr		4	/* modem control register (R/W) */
 #define	com_lsr		5	/* line status register (R/W) */
 #define	com_msr		6	/* modem status register (R/W) */
 #define	com_scratch	7	/* scratch register (R/W) */
 
 /*
+ * Additional registers present on TI OMAP hardware
+ */
+#define	com_mdr1	8	/* mode definition register 1 (OMAP) */
+
+/*
  * Additional register present in NS16750 
  */
 #define com_usr		31	/* status register (R) (16750/SUNXI) */
-- thorpej



Home | Main Index | Thread Index | Old Index