All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Jonker <jbx6244@gmail.com>
To: kever.yang@rock-chips.com
Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, xypron.glpk@gmx.de,
	yifeng.zhao@rock-chips.com, jon.lin@rock-chips.com,
	u-boot@lists.denx.de, linux-rockchip@lists.infradead.org,
	miquel.raynal@bootlin.com, michael@amarulasolutions.com,
	dario.binacchi@amarulasolutions.com
Subject: [PATCH v2 04/11] rockchip: idb: add info and stop command
Date: Sat, 9 Jul 2022 20:49:38 +0200	[thread overview]
Message-ID: <4fc96b7f-ef3f-f1c3-68ed-e98454006786@gmail.com> (raw)
In-Reply-To: <20220709183130.8039-1-jbx6244@gmail.com>

Add info and stop command to become aware of what goes on
inside the driver and to release some resources.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---

optional
---
 arch/arm/mach-rockchip/rockchip_idb.c | 116 ++++++++++++++++++++++++++
 1 file changed, 116 insertions(+)

diff --git a/arch/arm/mach-rockchip/rockchip_idb.c b/arch/arm/mach-rockchip/rockchip_idb.c
index 832b3251..0692ce1a 100644
--- a/arch/arm/mach-rockchip/rockchip_idb.c
+++ b/arch/arm/mach-rockchip/rockchip_idb.c
@@ -1456,10 +1456,124 @@ int rk_idb_start(void)
 
 #if !defined(CONFIG_SPL_BUILD)
 
+int rk_idb_stop(void)
+{
+	struct udevice *bdev;
+	int ret;
+
+	ret = blk_find_device(IF_TYPE_RK_IDB, 0, &bdev);
+	if (ret) {
+		printf("no IDB blk device found\n");
+		return 0;
+	}
+
+	device_remove(bdev, DM_REMOVE_NORMAL);
+	device_unbind(bdev);
+
+	return 0;
+}
+
+void rk_idb_print_idb_data(u32 *data)
+{
+	struct sector0 *sec0 = (struct sector0 *)data;
+
+	printf("\n");
+
+	printf("magic            : %08x\n"
+	       "rc4_flag         : %08x\n"
+	       "boot_code1_offset: %d\n"
+	       "flash_data_size  : %d\n"
+	       "flash_boot_size  : %d\n",
+	       sec0->magic,
+	       sec0->rc4_flag,
+	       sec0->boot_code1_offset,
+	       sec0->flash_data_size,
+	       sec0->flash_boot_size);
+
+	printf("\n");
+}
+
+static int rk_idb_info(void)
+{
+	struct rk_idb *plat;
+	struct udevice *dev;
+	u32 data[512];
+	u32 spare[2];
+	int ret;
+	int i, j;
+
+	ret = uclass_find_device(UCLASS_RK_IDB, 0, &dev);
+	if (ret) {
+		printf("no IDB device found\n");
+		return CMD_RET_FAILURE;
+	}
+
+	if (!device_active(dev)) {
+		printf("IDB device present but not probed\n");
+		return CMD_RET_FAILURE;
+	}
+
+	plat = dev_get_plat(dev);
+
+	printf("\n##### HARDWARE #####\n");
+
+	printf("REG              : 0x%08x\n", (u32)plat->regs);
+
+	printf("FLASH ID         : %02x %02x %02x %02x %02x %02x\n",
+	       plat->info->nand_id[0],
+	       plat->info->nand_id[1],
+	       plat->info->nand_id[2],
+	       plat->info->nand_id[3],
+	       plat->info->nand_id[4],
+	       plat->info->nand_id[5]);
+
+	printf("page_per_blk     : %d\n", plat->info->page_per_blk);
+	printf("lsb_mode         : %d\n", plat->info->lsb_mode);
+	printf("randomizer       : %d\n", (plat->info->operation_opt >> 7) & 1);
+
+	printf("\n##### BLOCK DEVICE #####\n");
+
+	ret = blk_find_device(IF_TYPE_RK_IDB, 0, &dev);
+	if (ret) {
+		printf("no IDB blk device found\n");
+	} else {
+		struct blk_desc *blk_dev = dev_get_uclass_plat(dev);
+
+		printf("blocks           : %lu\n", (unsigned long)blk_dev->lba);
+	}
+
+	printf("uuid_part_str    : %s\n", plat->uuid_part_str);
+	printf("uuid_disk_str    : %s\n", plat->uuid_disk_str);
+
+	printf("\n##### IDB #####\n");
+	for (i = 0; i < plat->blk_counter; i++) {
+		rk_idb_read_block(plat, j, 4, data, spare);
+
+		for (j = 0; j < 4; j++) {
+			if (j != 1)
+				rk_idb_rc4((char *)data + j * 512, 512);
+		}
+
+		printf("\nblk     : %d\n", plat->idblock[i].blk);
+		printf("ecc     : %d\n", plat->idblock[i].ecc);
+		printf("sectors : %d\n", plat->idblock[i].sectors);
+
+		rk_idb_print_idb_data(data);
+	}
+
+	return 0;
+}
+
 static int rk_idb_do(struct cmd_tbl *cmdtp, int flag, int argc,
 		     char *const argv[])
 {
 	if (argc == 2) {
+		if (!strcmp(argv[1], "info"))
+			return rk_idb_info();
+
+		if (!strcmp(argv[1], "stop"))
+			return rk_idb_stop();
+
 		if (!strcmp(argv[1], "start"))
 			return rk_idb_start();
 	}
@@ -1471,6 +1585,8 @@ U_BOOT_CMD(
 	idb, 5, 1, rk_idb_do,
 	"Rockchip IDB block device",
 	"start - start IDB device\n"
+	"idb stop  - stop IDB blk device\n"
+	"idb info  - show IDB device info\n"
 );
 
 #endif
-- 
2.20.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Johan Jonker <jbx6244@gmail.com>
To: kever.yang@rock-chips.com
Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, xypron.glpk@gmx.de,
	yifeng.zhao@rock-chips.com, jon.lin@rock-chips.com,
	u-boot@lists.denx.de, linux-rockchip@lists.infradead.org,
	miquel.raynal@bootlin.com, michael@amarulasolutions.com,
	dario.binacchi@amarulasolutions.com
Subject: [PATCH v2 04/11] rockchip: idb: add info and stop command
Date: Sat, 9 Jul 2022 20:49:38 +0200	[thread overview]
Message-ID: <4fc96b7f-ef3f-f1c3-68ed-e98454006786@gmail.com> (raw)
In-Reply-To: <20220709183130.8039-1-jbx6244@gmail.com>

Add info and stop command to become aware of what goes on
inside the driver and to release some resources.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---

optional
---
 arch/arm/mach-rockchip/rockchip_idb.c | 116 ++++++++++++++++++++++++++
 1 file changed, 116 insertions(+)

diff --git a/arch/arm/mach-rockchip/rockchip_idb.c b/arch/arm/mach-rockchip/rockchip_idb.c
index 832b3251..0692ce1a 100644
--- a/arch/arm/mach-rockchip/rockchip_idb.c
+++ b/arch/arm/mach-rockchip/rockchip_idb.c
@@ -1456,10 +1456,124 @@ int rk_idb_start(void)
 
 #if !defined(CONFIG_SPL_BUILD)
 
+int rk_idb_stop(void)
+{
+	struct udevice *bdev;
+	int ret;
+
+	ret = blk_find_device(IF_TYPE_RK_IDB, 0, &bdev);
+	if (ret) {
+		printf("no IDB blk device found\n");
+		return 0;
+	}
+
+	device_remove(bdev, DM_REMOVE_NORMAL);
+	device_unbind(bdev);
+
+	return 0;
+}
+
+void rk_idb_print_idb_data(u32 *data)
+{
+	struct sector0 *sec0 = (struct sector0 *)data;
+
+	printf("\n");
+
+	printf("magic            : %08x\n"
+	       "rc4_flag         : %08x\n"
+	       "boot_code1_offset: %d\n"
+	       "flash_data_size  : %d\n"
+	       "flash_boot_size  : %d\n",
+	       sec0->magic,
+	       sec0->rc4_flag,
+	       sec0->boot_code1_offset,
+	       sec0->flash_data_size,
+	       sec0->flash_boot_size);
+
+	printf("\n");
+}
+
+static int rk_idb_info(void)
+{
+	struct rk_idb *plat;
+	struct udevice *dev;
+	u32 data[512];
+	u32 spare[2];
+	int ret;
+	int i, j;
+
+	ret = uclass_find_device(UCLASS_RK_IDB, 0, &dev);
+	if (ret) {
+		printf("no IDB device found\n");
+		return CMD_RET_FAILURE;
+	}
+
+	if (!device_active(dev)) {
+		printf("IDB device present but not probed\n");
+		return CMD_RET_FAILURE;
+	}
+
+	plat = dev_get_plat(dev);
+
+	printf("\n##### HARDWARE #####\n");
+
+	printf("REG              : 0x%08x\n", (u32)plat->regs);
+
+	printf("FLASH ID         : %02x %02x %02x %02x %02x %02x\n",
+	       plat->info->nand_id[0],
+	       plat->info->nand_id[1],
+	       plat->info->nand_id[2],
+	       plat->info->nand_id[3],
+	       plat->info->nand_id[4],
+	       plat->info->nand_id[5]);
+
+	printf("page_per_blk     : %d\n", plat->info->page_per_blk);
+	printf("lsb_mode         : %d\n", plat->info->lsb_mode);
+	printf("randomizer       : %d\n", (plat->info->operation_opt >> 7) & 1);
+
+	printf("\n##### BLOCK DEVICE #####\n");
+
+	ret = blk_find_device(IF_TYPE_RK_IDB, 0, &dev);
+	if (ret) {
+		printf("no IDB blk device found\n");
+	} else {
+		struct blk_desc *blk_dev = dev_get_uclass_plat(dev);
+
+		printf("blocks           : %lu\n", (unsigned long)blk_dev->lba);
+	}
+
+	printf("uuid_part_str    : %s\n", plat->uuid_part_str);
+	printf("uuid_disk_str    : %s\n", plat->uuid_disk_str);
+
+	printf("\n##### IDB #####\n");
+	for (i = 0; i < plat->blk_counter; i++) {
+		rk_idb_read_block(plat, j, 4, data, spare);
+
+		for (j = 0; j < 4; j++) {
+			if (j != 1)
+				rk_idb_rc4((char *)data + j * 512, 512);
+		}
+
+		printf("\nblk     : %d\n", plat->idblock[i].blk);
+		printf("ecc     : %d\n", plat->idblock[i].ecc);
+		printf("sectors : %d\n", plat->idblock[i].sectors);
+
+		rk_idb_print_idb_data(data);
+	}
+
+	return 0;
+}
+
 static int rk_idb_do(struct cmd_tbl *cmdtp, int flag, int argc,
 		     char *const argv[])
 {
 	if (argc == 2) {
+		if (!strcmp(argv[1], "info"))
+			return rk_idb_info();
+
+		if (!strcmp(argv[1], "stop"))
+			return rk_idb_stop();
+
 		if (!strcmp(argv[1], "start"))
 			return rk_idb_start();
 	}
@@ -1471,6 +1585,8 @@ U_BOOT_CMD(
 	idb, 5, 1, rk_idb_do,
 	"Rockchip IDB block device",
 	"start - start IDB device\n"
+	"idb stop  - stop IDB blk device\n"
+	"idb info  - show IDB device info\n"
 );
 
 #endif
-- 
2.20.1


  parent reply	other threads:[~2022-07-09 18:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220709183130.8039-1-jbx6244@gmail.com>
2022-07-09 18:48 ` [PATCH v2 01/11] rockchip: idb: prepare IDB block device Johan Jonker
2022-07-09 18:48   ` Johan Jonker
2022-07-09 18:49 ` [PATCH v2 02/11] rockchip: idb: add basic functions Johan Jonker
2022-07-09 18:49   ` Johan Jonker
2022-07-09 18:49 ` [PATCH v2 03/11] rockchip: idb: add IDB block device Johan Jonker
2022-07-09 18:49   ` Johan Jonker
2022-07-09 18:49 ` Johan Jonker [this message]
2022-07-09 18:49   ` [PATCH v2 04/11] rockchip: idb: add info and stop command Johan Jonker
2022-07-09 18:49 ` [PATCH v2 05/11] rockchip: idb: add sector1 info Johan Jonker
2022-07-09 18:49   ` Johan Jonker
2022-07-09 18:49 ` [PATCH v2 06/11] rockchip: idb: add randomizer option Johan Jonker
2022-07-09 18:49   ` Johan Jonker
2022-07-09 18:50 ` [PATCH v2 07/11] rockchip: spl: allow more boot devices Johan Jonker
2022-07-09 18:50   ` Johan Jonker
2022-07-09 18:50 ` [PATCH v2 08/11] rockchip: rk3066: add Rockchip IDB block device as boot action Johan Jonker
2022-07-09 18:50   ` Johan Jonker
2022-07-09 18:50 ` [PATCH v2 09/11] arm: dts: rockchip: sync rk3066/rk3188 DT files from Linux Johan Jonker
2022-07-09 18:50   ` Johan Jonker
2022-09-04 11:04   ` Johan Jonker
2022-09-09  9:49     ` Kever Yang
2022-07-09 18:50 ` [PATCH v2 10/11] arm: dts: rockchip: enable nfc node in spl for rk3066 mk808 Johan Jonker
2022-07-09 18:50   ` Johan Jonker
2022-07-09 18:51 ` [PATCH v2 11/11] rockchip: configs: mk808: add idb configs Johan Jonker
2022-07-09 18:51   ` Johan Jonker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4fc96b7f-ef3f-f1c3-68ed-e98454006786@gmail.com \
    --to=jbx6244@gmail.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=jon.lin@rock-chips.com \
    --cc=kever.yang@rock-chips.com \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=michael@amarulasolutions.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=yifeng.zhao@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.