1 From 4d219b15a7a01a14c1be1eeee9a939732130d30a Mon Sep 17 00:00:00 2001
2 From: Naushir Patuck <naush@raspberrypi.com>
3 Date: Tue, 13 Aug 2024 13:45:54 +0100
4 Subject: [PATCH 1242/1350] spi: rp2040-gpio-bridge: Add debugfs progress
7 Useful for tracking upload progress via userspace.
9 Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
11 drivers/spi/spi-rp2040-gpio-bridge.c | 24 ++++++++++++++++++++++++
12 1 file changed, 24 insertions(+)
14 --- a/drivers/spi/spi-rp2040-gpio-bridge.c
15 +++ b/drivers/spi/spi-rp2040-gpio-bridge.c
19 #include <crypto/hash.h>
20 +#include <linux/debugfs.h>
21 #include <linux/crypto.h>
22 #include <linux/delay.h>
23 #include <linux/firmware.h>
24 @@ -91,6 +92,9 @@ enum rp2040_gbdg_fixed_size_commands {
26 struct spi_controller *controller;
28 + struct dentry *debugfs;
29 + size_t transfer_progress;
31 struct i2c_client *client;
32 struct crypto_shash *shash;
33 struct shash_desc *shash_desc;
34 @@ -702,6 +706,7 @@ static int rp2040_gbdg_transfer_cached(s
38 + priv_data->transfer_progress = 0;
40 unsigned int xfer = min(length, RP2040_GBDG_BLOCK_SIZE);
42 @@ -710,7 +715,9 @@ static int rp2040_gbdg_transfer_cached(s
46 + priv_data->transfer_progress += xfer;
48 + priv_data->transfer_progress = 0;
52 @@ -1016,6 +1023,16 @@ static int rp2040_gbdg_power_on(struct r
56 +static int transfer_progress_show(struct seq_file *s, void *data)
58 + struct rp2040_gbdg *rp2040_gbdg = s->private;
60 + seq_printf(s, "%zu\n", rp2040_gbdg->transfer_progress);
64 +DEFINE_SHOW_ATTRIBUTE(transfer_progress);
66 static int rp2040_gbdg_probe(struct i2c_client *client)
68 struct rp2040_gbdg_device_info info;
69 @@ -1023,6 +1040,7 @@ static int rp2040_gbdg_probe(struct i2c_
70 struct device *dev = &client->dev;
71 struct rp2040_gbdg *rp2040_gbdg;
72 struct device_node *np;
73 + char debugfs_name[128];
77 @@ -1136,6 +1154,12 @@ static int rp2040_gbdg_probe(struct i2c_
79 rp2040_gbdg_parse_dt(rp2040_gbdg);
81 + snprintf(debugfs_name, sizeof(debugfs_name), "rp2040-spi:%s",
83 + rp2040_gbdg->debugfs = debugfs_create_dir(debugfs_name, NULL);
84 + debugfs_create_file("transfer_progress", 0444, rp2040_gbdg->debugfs,
85 + rp2040_gbdg, &transfer_progress_fops);
87 pm_runtime_mark_last_busy(dev);
88 pm_runtime_put_autosuspend(dev);