[U-Boot,v3,3/9] rockchip: rk3288: implement reading chip version from bootrom code

Message ID 1531393559-28958-4-git-send-email-alberto@amarulasolutions.com
State Changes Requested
Delegated to: Philipp Tomsich
Headers show
Series
  • Improve rockusb support in U-Boot
Related show

Commit Message

Alberto Panizzo July 12, 2018, 11:05 a.m.
This allows rockusb code to reply correctly to K_FW_GET_CHIP_VER
command.

On RK3288 chip version is at 0xffff4ff0 and on tested hardware it
corresponds at the string "320A20140813V200"

Signed-off-by: Alberto Panizzo <alberto@amarulasolutions.com>
---
 arch/arm/mach-rockchip/rk3288/Makefile         |  1 +
 arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c | 30 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c

Comments

Simon Glass July 15, 2018, 9:21 p.m. | #1
On 12 July 2018 at 05:05, Alberto Panizzo <alberto@amarulasolutions.com> wrote:
> This allows rockusb code to reply correctly to K_FW_GET_CHIP_VER
> command.
>
> On RK3288 chip version is at 0xffff4ff0 and on tested hardware it
> corresponds at the string "320A20140813V200"
>
> Signed-off-by: Alberto Panizzo <alberto@amarulasolutions.com>
> ---
>  arch/arm/mach-rockchip/rk3288/Makefile         |  1 +
>  arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c | 30 ++++++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
>  create mode 100644 arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c

Reviewed-by: Simon Glass <sjg@chromium.org>
Philipp Tomsich July 20, 2018, 5:05 p.m. | #2
On Thu, 12 Jul 2018, Alberto Panizzo wrote:

> This allows rockusb code to reply correctly to K_FW_GET_CHIP_VER
> command.
>
> On RK3288 chip version is at 0xffff4ff0 and on tested hardware it
> corresponds at the string "320A20140813V200"
>
> Signed-off-by: Alberto Panizzo <alberto@amarulasolutions.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

See below for requested changes.

> ---
> arch/arm/mach-rockchip/rk3288/Makefile         |  1 +
> arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c | 30 ++++++++++++++++++++++++++
> 2 files changed, 31 insertions(+)
> create mode 100644 arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c
>
> diff --git a/arch/arm/mach-rockchip/rk3288/Makefile b/arch/arm/mach-rockchip/rk3288/Makefile
> index a0033a0..da0eb4a 100644
> --- a/arch/arm/mach-rockchip/rk3288/Makefile
> +++ b/arch/arm/mach-rockchip/rk3288/Makefile
> @@ -7,3 +7,4 @@
> obj-y += clk_rk3288.o
> obj-y += rk3288.o
> obj-y += syscon_rk3288.o
> +obj-$(CONFIG_USB_FUNCTION_ROCKUSB) += rockusb_rk3288.o

This should be conditional on the RK3288.
After all, the below code implements a weak function specifically for the 
RK3288.

We might want to decide on a better architecture (a misc device maybe?) 
that allows us to abstract the various chips' methods to access the device 
id in a more DM-aware way.

> diff --git a/arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c b/arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c
> new file mode 100644
> index 0000000..62057c1
> --- /dev/null
> +++ b/arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c
> @@ -0,0 +1,30 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2018 Amarula Solutions
> + * Written by Alberto Panizzo <alberto@amarulasolutions.com>
> + */
> +
> +#include <config.h>
> +#include <common.h>
> +#include <linux/delay.h>
> +#include <asm/io.h>
> +#include <asm/arch/boot_mode.h>
> +#include <asm/arch/pmu_rk3288.h>
> +
> +#define ROM_PHYS	0xffff0000
> +
> +#define ROM_CHIP_VER_ADDR_ADDR		(ROM_PHYS + 0x4FF0)
> +#define ROM_CHIP_VER_ADDR_SIZE		16
> +
> +int rk_get_bootrom_chip_version(unsigned int *chip_info, int size)
> +{
> +	if (!chip_info)
> +		return -1;
> +	if (size < ROM_CHIP_VER_ADDR_SIZE / sizeof(int))
> +		return -1;

This should use appropriate error-codes.

> +
> +	memcpy((char *)chip_info, (char *)ROM_CHIP_VER_ADDR_ADDR,
> +	       ROM_CHIP_VER_ADDR_SIZE);
> +
> +	return 0;
> +}
>

Patch

diff --git a/arch/arm/mach-rockchip/rk3288/Makefile b/arch/arm/mach-rockchip/rk3288/Makefile
index a0033a0..da0eb4a 100644
--- a/arch/arm/mach-rockchip/rk3288/Makefile
+++ b/arch/arm/mach-rockchip/rk3288/Makefile
@@ -7,3 +7,4 @@ 
 obj-y += clk_rk3288.o
 obj-y += rk3288.o
 obj-y += syscon_rk3288.o
+obj-$(CONFIG_USB_FUNCTION_ROCKUSB) += rockusb_rk3288.o
diff --git a/arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c b/arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c
new file mode 100644
index 0000000..62057c1
--- /dev/null
+++ b/arch/arm/mach-rockchip/rk3288/rockusb_rk3288.c
@@ -0,0 +1,30 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Amarula Solutions
+ * Written by Alberto Panizzo <alberto@amarulasolutions.com>
+ */
+
+#include <config.h>
+#include <common.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <asm/arch/boot_mode.h>
+#include <asm/arch/pmu_rk3288.h>
+
+#define ROM_PHYS	0xffff0000
+
+#define ROM_CHIP_VER_ADDR_ADDR		(ROM_PHYS + 0x4FF0)
+#define ROM_CHIP_VER_ADDR_SIZE		16
+
+int rk_get_bootrom_chip_version(unsigned int *chip_info, int size)
+{
+	if (!chip_info)
+		return -1;
+	if (size < ROM_CHIP_VER_ADDR_SIZE / sizeof(int))
+		return -1;
+
+	memcpy((char *)chip_info, (char *)ROM_CHIP_VER_ADDR_ADDR,
+	       ROM_CHIP_VER_ADDR_SIZE);
+
+	return 0;
+}