Skip to contentSkip to conversation

sh: Set gd->malloc_base if MALLOC_F_LEN is set

PATCH New Marek Vasut 1 participant 5 messages May 9, 2020 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 sh: Set gd->malloc_base if MALLOC_F_LEN is set

The gd->malloc_base must be set before the C runtime if the MALLOC_F_LEN is non-zero, otherwise we hit assertion in dlmalloc.c initf_malloc(). So set it.

Cc Nobuhiro Iwamatsu <[email protected]>
---
 arch/sh/lib/start.S | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/sh/lib/start.S +5 -1
index f9f26d3779..d6342a16da 100644
@@ -53,7 +53,10 @@ _start:
 
 	mov.l	._gd_init, r13		/* global data */
 	mov.l	._stack_init, r15	/* stack */
-
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+	mov.l	._gd_malloc_base, r14
+	mov.l	r15, @r14
+#endif
 	mov.l	._sh_generic_init, r0
 	jsr	@r0
 	mov     #0, r4
@@ -70,5 +73,6 @@ loop:
 ._bss_start:		.long	bss_start
 ._bss_end:		.long	bss_end
 ._gd_init:		.long	(_start - GENERATED_GBL_DATA_SIZE)
+._gd_malloc_base:	.long	(_start - GENERATED_GBL_DATA_SIZE + GD_MALLOC_BASE)
 ._stack_init:		.long	(_start - GENERATED_GBL_DATA_SIZE - CONFIG_SYS_MALLOC_LEN - 16)
 ._sh_generic_init:	.long	board_init_f
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/5 serial: sh: Improve FIFO empty check on RX

If the SCIF is receiving data quickly enough, it may happen that the SCxSR_RDxF flag is cleared in sh_serial_getc_generic(), while the FIFO still contains data. If that happens, the serial_getc_check() reports no data in the FIFO as the flag is no longer set. Add one more check, if the SCxSR_RDxF is not set, read out the FIFO level and if there are still characters in the FIFO, permit reading them out.

Cc Nobuhiro Iwamatsu <[email protected]>
---
 drivers/serial/serial_sh.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/serial/serial_sh.c +4 -1
index acfcc2954a..0a4dfdc377 100644
@@ -115,7 +115,10 @@ static int serial_getc_check(struct uart_port *port)
 		handle_error(port);
 	if (sci_in(port, SCLSR) & SCxSR_ORER(port))
 		handle_error(port);
-	return status & (SCIF_DR | SCxSR_RDxF(port));
+	status &= (SCIF_DR | SCxSR_RDxF(port));
+	if (status)
+		return status;
+	return scif_rxfill(port);
 }
 
 static int sh_serial_getc_generic(struct uart_port *port)
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/5 sh: r2dplus: Add SCIF1 to the basic DT

In reply to Marek Vasut

Add simple DT and clock bindings to r2dplus DT to permit U-Boot to bind the SCIF driver via DT probing instead of hard-coded config options.

Cc Nobuhiro Iwamatsu <[email protected]>
---
 arch/sh/dts/sh7751-r2dplus.dts | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
arch/sh/dts/sh7751-r2dplus.dts +23 -0
index efaeb33e36..f0ed0e7d45 100644
@@ -10,6 +10,29 @@
 	model = "R2D";
 	compatible = "renesas,r2d", "renesas,sh7751";
 
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	aliases {
+		serial0 = &scif1;
+	};
+
+	scif_clks: scif60 {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <60000000>;
+		u-boot,dm-pre-reloc;
+	};
+
+	scif1: serial at ffe80000 {
+		compatible = "renesas,scif";
+		reg = <0xffe80000 0x1000>;
+		clocks = <&scif_clks>;
+		clock-names = "fck";
+		status = "okay";
+		u-boot,dm-pre-reloc;
+	};
+
 	pci at fe200000 {
 		compatible = "renesas,pci-sh7751";
 		device_type = "pci";
Signature · 1 line
2.25.1
#3 lore raw

PATCH 4/5 sh: r2dplus: Enable DM_SERIAL and DM_CLK

In reply to Marek Vasut

Switch r2dplus to DM and DT probing for serial and clock.

Cc Nobuhiro Iwamatsu <[email protected]>
---
 configs/r2dplus_defconfig | 5 ++++-
 include/configs/r2dplus.h | 1 -
 2 files changed, 4 insertions(+), 2 deletions(-)
configs/r2dplus_defconfig +4 -1
index 1aed84905f..b770fd2493 100644
@@ -3,7 +3,6 @@ CONFIG_SYS_TEXT_BASE=0x8FE00000
 CONFIG_ENV_SIZE=0x40000
 CONFIG_ENV_SECT_SIZE=0x40000
 CONFIG_TARGET_R2DPLUS=y
-# CONFIG_SYS_MALLOC_F is not set
 CONFIG_BOOTDELAY=-1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttySC0,115200"
@@ -24,6 +23,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sh7751-r2dplus"
 CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_ENV_ADDR=0xA0040000
 CONFIG_DM=y
+CONFIG_CLK=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_CFI=y
@@ -31,5 +31,8 @@ CONFIG_DM_ETH=y
 CONFIG_RTL8139=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DM_SERIAL=y
+CONFIG_SERIAL_RX_BUFFER=y
 CONFIG_SCIF_CONSOLE=y
 CONFIG_USE_PRIVATE_LIBGCC=y
include/configs/r2dplus.h +0 -1
index a8886251e0..4cd22bb407 100644
@@ -37,7 +37,6 @@
  * SuperH Clock setting
  */
 #define CONFIG_SYS_CLK_FREQ	60000000
-#define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define	CONFIG_SYS_PLL_SETTLING_TIME	100/* in us */
 
 /*
Signature · 1 line
2.25.1
#4 lore raw

PATCH 5/5 sh: r2dplus: Enable HUSH

In reply to Marek Vasut

Enable richer HUSH shell to make working with the board more pleasant.

Cc Nobuhiro Iwamatsu <[email protected]>
---
 configs/r2dplus_defconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
configs/r2dplus_defconfig +1 -2
index b770fd2493..25f0f3b0a4 100644
@@ -6,8 +6,7 @@ CONFIG_TARGET_R2DPLUS=y
 CONFIG_BOOTDELAY=-1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttySC0,115200"
-# CONFIG_CMDLINE_EDITING is not set
-# CONFIG_AUTO_COMPLETE is not set
+CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_DM=y
 CONFIG_CMD_IDE=y
Signature · 1 line
2.25.1