mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 12/18] Add dev_WARN_ONCE()
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

dev_WARN_ONCE() is like WARN_ONCE(), but with a struct device *argument
to print device context.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/linux/printk.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index a9d1b05f6f..42c29e04dd 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -205,4 +205,17 @@ static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,
 #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len)	\
 	print_hex_dump_debug(prefix_str, prefix_type, 16, 1, buf, len, true)
 
+#define dev_WARN_ONCE(dev, condition, format...) ({      \
+        static int __warned;			\
+        int __ret_warn_once = !!(condition);	\
+						\
+        if (unlikely(__ret_warn_once)) {	\
+                if (!__warned) { 		\
+                        __warned = 1;		\
+                        dev_warn(dev, format);	\
+                }				\
+        }					\
+        unlikely(__ret_warn_once);		\
+})
+
 #endif
-- 
2.30.2




^ permalink raw reply related

* [PATCH 10/18] usb: gadget: Add super-speed-plus descriptors
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

Linux upstream usb_assign_descriptors() now takes four sets of
descriptors. Add the missing super speed plus descriptors.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/config.c                  | 8 +++++++-
 drivers/usb/gadget/function/dfu.c            | 2 +-
 drivers/usb/gadget/function/f_acm.c          | 2 +-
 drivers/usb/gadget/function/f_fastboot.c     | 2 +-
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 drivers/usb/gadget/function/f_serial.c       | 2 +-
 include/linux/usb/composite.h                | 1 +
 include/linux/usb/gadget.h                   | 3 ++-
 8 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 979cfafa70..27e4dda52f 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -152,7 +152,8 @@ EXPORT_SYMBOL_GPL(usb_copy_descriptors);
 int usb_assign_descriptors(struct usb_function *f,
 		struct usb_descriptor_header **fs,
 		struct usb_descriptor_header **hs,
-		struct usb_descriptor_header **ss)
+		struct usb_descriptor_header **ss,
+		struct usb_descriptor_header **ssp)
 {
 	struct usb_gadget *g = f->config->cdev->gadget;
 
@@ -171,6 +172,11 @@ int usb_assign_descriptors(struct usb_function *f,
 		if (!f->ss_descriptors)
 			goto err;
 	}
+	if (ssp && gadget_is_superspeed_plus(g)) {
+		f->ssp_descriptors = usb_copy_descriptors(ssp);
+		if (!f->ssp_descriptors)
+			goto err;
+	}
 	return 0;
 err:
 	usb_free_all_descriptors(f);
diff --git a/drivers/usb/gadget/function/dfu.c b/drivers/usb/gadget/function/dfu.c
index 930a10b766..e6ba829a85 100644
--- a/drivers/usb/gadget/function/dfu.c
+++ b/drivers/usb/gadget/function/dfu.c
@@ -427,7 +427,7 @@ dfu_bind(struct usb_configuration *c, struct usb_function *f)
 	header[i] = (struct usb_descriptor_header *) &usb_dfu_func;
 	header[i + 1] = NULL;
 
-	status = usb_assign_descriptors(f, header, header, NULL);
+	status = usb_assign_descriptors(f, header, header, NULL, NULL);
 
 	free(desc);
 	free(header);
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
index 1210622d96..3532fd5892 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -678,7 +678,7 @@ acm_bind(struct usb_configuration *c, struct usb_function *f)
 	acm_ss_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress;
 
 	status = usb_assign_descriptors(f, acm_fs_function, acm_hs_function,
-			acm_ss_function);
+			acm_ss_function, acm_ss_function);
 	if (status)
 		goto fail;
 
diff --git a/drivers/usb/gadget/function/f_fastboot.c b/drivers/usb/gadget/function/f_fastboot.c
index 499262a64b..4e9c373796 100644
--- a/drivers/usb/gadget/function/f_fastboot.c
+++ b/drivers/usb/gadget/function/f_fastboot.c
@@ -266,7 +266,7 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
 	f_fb->out_req->complete = rx_handler_command;
 	f_fb->out_req->context = f_fb;
 
-	ret = usb_assign_descriptors(f, fb_fs_descs, fb_hs_descs, NULL);
+	ret = usb_assign_descriptors(f, fb_fs_descs, fb_hs_descs, NULL, NULL);
 	if (ret)
 		goto err_free_in_req;
 
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 61f369bd07..4e9777994e 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2666,7 +2666,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
 	}
 
 	/* Copy descriptors */
-	return usb_assign_descriptors(f, fsg_fs_function, hs_function, NULL);
+	return usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function, NULL, NULL);
 
 autoconf_fail:
 	ERROR(fsg, "unable to autoconfigure all endpoints\n");
diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c
index 494f6c872e..a768c580ea 100644
--- a/drivers/usb/gadget/function/f_serial.c
+++ b/drivers/usb/gadget/function/f_serial.c
@@ -231,7 +231,7 @@ static int gser_bind(struct usb_configuration *c, struct usb_function *f)
 	gser_ss_out_desc.bEndpointAddress = gser_fs_out_desc.bEndpointAddress;
 
 	status = usb_assign_descriptors(f, gser_fs_function, gser_hs_function,
-			gser_ss_function);
+			gser_ss_function, gser_ss_function);
 	if (status)
 		goto fail;
 	DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n",
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 26e6fe5c47..7bd89b1de1 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -125,6 +125,7 @@ struct usb_function {
 	struct usb_descriptor_header	**fs_descriptors;
 	struct usb_descriptor_header	**hs_descriptors;
 	struct usb_descriptor_header	**ss_descriptors;
+	struct usb_descriptor_header	**ssp_descriptors;
 
 	struct usb_configuration	*config;
 
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index a9b45bb824..d4c02cb37c 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -855,7 +855,8 @@ struct usb_function;
 int usb_assign_descriptors(struct usb_function *f,
 		struct usb_descriptor_header **fs,
 		struct usb_descriptor_header **hs,
-		struct usb_descriptor_header **ss);
+		struct usb_descriptor_header **ss,
+		struct usb_descriptor_header **ssp);
 void usb_free_all_descriptors(struct usb_function *f);
 
 struct usb_descriptor_header *usb_otg_descriptor_alloc(
-- 
2.30.2




^ permalink raw reply related

* [PATCH 06/18] phy: Add mode setting support
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/phy/phy-core.c  | 15 +++++++++++++++
 include/linux/phy/phy.h | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index a5dd32e666..1a23f35b95 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -203,6 +203,21 @@ int phy_power_off(struct phy *phy)
 	return 0;
 }
 
+int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode)
+{
+	int ret;
+
+	if (!phy || !phy->ops->set_mode)
+		return 0;
+
+	ret = phy->ops->set_mode(phy, mode, submode);
+	if (!ret)
+		phy->attrs.mode = mode;
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phy_set_mode_ext);
+
 struct usb_phy *phy_to_usbphy(struct phy *phy)
 {
 	if (!phy)
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 5dcc5b108a..9f01bc3e9f 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -20,12 +20,36 @@
 
 struct phy;
 
+enum phy_mode {
+	PHY_MODE_INVALID,
+	PHY_MODE_USB_HOST,
+	PHY_MODE_USB_HOST_LS,
+	PHY_MODE_USB_HOST_FS,
+	PHY_MODE_USB_HOST_HS,
+	PHY_MODE_USB_HOST_SS,
+	PHY_MODE_USB_DEVICE,
+	PHY_MODE_USB_DEVICE_LS,
+	PHY_MODE_USB_DEVICE_FS,
+	PHY_MODE_USB_DEVICE_HS,
+	PHY_MODE_USB_DEVICE_SS,
+	PHY_MODE_USB_OTG,
+	PHY_MODE_UFS_HS_A,
+	PHY_MODE_UFS_HS_B,
+	PHY_MODE_PCIE,
+	PHY_MODE_ETHERNET,
+	PHY_MODE_MIPI_DPHY,
+	PHY_MODE_SATA,
+	PHY_MODE_LVDS,
+	PHY_MODE_DP
+};
+
 /**
  * struct phy_ops - set of function pointers for performing phy operations
  * @init: operation to be performed for initializing phy
  * @exit: operation to be performed while exiting
  * @power_on: powering on the phy
  * @power_off: powering off the phy
+ * @set_mode: set the mode of the phy
  * @owner: the module owner containing the ops
  */
 struct phy_ops {
@@ -33,15 +57,18 @@ struct phy_ops {
 	int	(*exit)(struct phy *phy);
 	int	(*power_on)(struct phy *phy);
 	int	(*power_off)(struct phy *phy);
+	int	(*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
 	struct usb_phy *(*to_usbphy)(struct phy *phy);
 };
 
 /**
  * struct phy_attrs - represents phy attributes
  * @bus_width: Data path width implemented by PHY
+ * @mode: PHY mode
  */
 struct phy_attrs {
 	u32			bus_width;
+	enum phy_mode		mode;
 };
 
 /**
@@ -125,6 +152,9 @@ int phy_init(struct phy *phy);
 int phy_exit(struct phy *phy);
 int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
+int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
+#define phy_set_mode(phy, mode) \
+        phy_set_mode_ext(phy, mode, 0)
 static inline int phy_get_bus_width(struct phy *phy)
 {
 	return phy->attrs.bus_width;
@@ -177,6 +207,17 @@ static inline int phy_power_off(struct phy *phy)
 	return -ENOSYS;
 }
 
+static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
+				   int submode)
+{
+	if (!phy)
+		return 0;
+	return -ENOSYS;
+}
+
+#define phy_set_mode(phy, mode) \
+        phy_set_mode_ext(phy, mode, 0)
+
 static inline int phy_get_bus_width(struct phy *phy)
 {
 	return -ENOSYS;
-- 
2.30.2




^ permalink raw reply related

* [PATCH 16/18] usb: gadget: mass storage: Add super speed descriptors
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

Add super speed descriptors to the USB fastboot gadget. The
necessary bits and pieces are taken from Linux-6.3-rc2.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/function/f_mass_storage.c | 40 ++++++++++++-------
 drivers/usb/gadget/function/storage_common.c | 42 ++++++++++++++++++++
 drivers/usb/gadget/function/storage_common.h |  6 +++
 3 files changed, 74 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 4e9777994e..2c934c621a 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2194,15 +2194,18 @@ reset:
 	fsg = common->fsg;
 
 	/* Enable the endpoints */
-	fsg->bulk_in->desc = fsg_ep_desc(common->gadget,
-					 &fsg_fs_bulk_in_desc, &fsg_hs_bulk_in_desc);
+	rc = config_ep_by_speed(common->gadget, &(fsg->function), fsg->bulk_in);
+	if (rc)
+		goto reset;
 	rc = enable_endpoint(common, fsg->bulk_in);
 	if (rc)
 		goto reset;
 	fsg->bulk_in_enabled = 1;
 
-	fsg->bulk_out->desc = fsg_ep_desc(common->gadget,
-					  &fsg_fs_bulk_out_desc, &fsg_hs_bulk_out_desc);
+	rc = config_ep_by_speed(common->gadget, &(fsg->function),
+				fsg->bulk_out);
+	if (rc)
+		goto reset;
 	rc = enable_endpoint(common, fsg->bulk_out);
 	if (rc)
 		goto reset;
@@ -2615,7 +2618,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
 	struct usb_gadget	*gadget = c->cdev->gadget;
 	int			ret;
 	struct usb_ep		*ep;
-	struct usb_descriptor_header **hs_function = NULL;
+	unsigned		max_burst;
 	struct fsg_common	*common = fsg->common;
 
 	if (!ums_files) {
@@ -2656,17 +2659,26 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
 	ep->driver_data = common;	/* claim the endpoint */
 	fsg->bulk_out = ep;
 
-	if (gadget_is_dualspeed(gadget)) {
-		/* Assume endpoint addresses are the same for both speeds */
-		fsg_hs_bulk_in_desc.bEndpointAddress =
-			fsg_fs_bulk_in_desc.bEndpointAddress;
-		fsg_hs_bulk_out_desc.bEndpointAddress =
-			fsg_fs_bulk_out_desc.bEndpointAddress;
-		hs_function = fsg_hs_function;
-	}
+	/* Assume endpoint addresses are the same for both speeds */
+	fsg_hs_bulk_in_desc.bEndpointAddress =
+		fsg_fs_bulk_in_desc.bEndpointAddress;
+	fsg_hs_bulk_out_desc.bEndpointAddress =
+		fsg_fs_bulk_out_desc.bEndpointAddress;
+
+	/* Calculate bMaxBurst, we know packet size is 1024 */
+	max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15);
+
+	fsg_ss_bulk_in_desc.bEndpointAddress =
+		fsg_fs_bulk_in_desc.bEndpointAddress;
+	fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst;
+
+	fsg_ss_bulk_out_desc.bEndpointAddress =
+		fsg_fs_bulk_out_desc.bEndpointAddress;
+	fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst;
 
 	/* Copy descriptors */
-	return usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function, NULL, NULL);
+	return usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function,
+				      fsg_ss_function, fsg_ss_function);
 
 autoconf_fail:
 	ERROR(fsg, "unable to autoconfigure all endpoints\n");
diff --git a/drivers/usb/gadget/function/storage_common.c b/drivers/usb/gadget/function/storage_common.c
index 69fcd06565..60e0994235 100644
--- a/drivers/usb/gadget/function/storage_common.c
+++ b/drivers/usb/gadget/function/storage_common.c
@@ -104,6 +104,48 @@ struct usb_descriptor_header *fsg_hs_function[] = {
 	NULL,
 };
 
+struct usb_endpoint_descriptor fsg_ss_bulk_in_desc = {
+	.bLength =		USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType =	USB_DT_ENDPOINT,
+
+	/* bEndpointAddress copied from fs_bulk_in_desc during fsg_bind() */
+	.bmAttributes =		USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize =	cpu_to_le16(1024),
+};
+
+struct usb_ss_ep_comp_descriptor fsg_ss_bulk_in_comp_desc = {
+	.bLength =		sizeof(fsg_ss_bulk_in_comp_desc),
+	.bDescriptorType =	USB_DT_SS_ENDPOINT_COMP,
+
+	/*.bMaxBurst =		DYNAMIC, */
+};
+
+struct usb_endpoint_descriptor fsg_ss_bulk_out_desc = {
+	.bLength =		USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType =	USB_DT_ENDPOINT,
+
+	/* bEndpointAddress copied from fs_bulk_out_desc during fsg_bind() */
+	.bmAttributes =		USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize =	cpu_to_le16(1024),
+};
+
+struct usb_ss_ep_comp_descriptor fsg_ss_bulk_out_comp_desc = {
+	.bLength =		sizeof(fsg_ss_bulk_in_comp_desc),
+	.bDescriptorType =	USB_DT_SS_ENDPOINT_COMP,
+
+	/*.bMaxBurst =		DYNAMIC, */
+};
+
+struct usb_descriptor_header *fsg_ss_function[] = {
+	(struct usb_descriptor_header *) &fsg_intf_desc,
+	(struct usb_descriptor_header *) &fsg_ss_bulk_in_desc,
+	(struct usb_descriptor_header *) &fsg_ss_bulk_in_comp_desc,
+	(struct usb_descriptor_header *) &fsg_ss_bulk_out_desc,
+	(struct usb_descriptor_header *) &fsg_ss_bulk_out_comp_desc,
+	NULL,
+};
+EXPORT_SYMBOL_GPL(fsg_ss_function);
+
 /* Maxpacket and other transfer characteristics vary by speed. */
 struct usb_endpoint_descriptor *
 fsg_ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *fs,
diff --git a/drivers/usb/gadget/function/storage_common.h b/drivers/usb/gadget/function/storage_common.h
index 3b98c82ee3..29afe77685 100644
--- a/drivers/usb/gadget/function/storage_common.h
+++ b/drivers/usb/gadget/function/storage_common.h
@@ -232,6 +232,12 @@ extern struct usb_endpoint_descriptor fsg_hs_bulk_in_desc;
 extern struct usb_endpoint_descriptor fsg_hs_bulk_out_desc;
 extern struct usb_descriptor_header *fsg_hs_function[];
 
+extern struct usb_endpoint_descriptor fsg_ss_bulk_in_desc;
+extern struct usb_ss_ep_comp_descriptor fsg_ss_bulk_in_comp_desc;
+extern struct usb_endpoint_descriptor fsg_ss_bulk_out_desc;
+extern struct usb_ss_ep_comp_descriptor fsg_ss_bulk_out_comp_desc;
+extern struct usb_descriptor_header *fsg_ss_function[];
+
 int fsg_lun_open(struct fsg_lun *curlun, unsigned int num_sectors,
 		 const char *filename);
 void fsg_lun_close(struct fsg_lun *curlun);
-- 
2.30.2




^ permalink raw reply related

* [PATCH 17/18] usb: gadget: u_serial: Put back to list if shutdown
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

We have to put the requests back to the read pool, even if they
are shut down, otherwise they are lost.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/function/u_serial.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index ac7a0b589d..ca4e77c5ff 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -155,12 +155,13 @@ static void gs_read_complete(struct usb_ep *ep, struct usb_request *req)
 {
 	struct gs_port	*port = ep->driver_data;
 
+	list_add_tail(&req->list, &port->read_pool);
+	port->read_nb_queued--;
+
 	if (req->status == -ESHUTDOWN)
 		return;
 
 	kfifo_put(port->recv_fifo, req->buf, req->actual);
-	list_add_tail(&req->list, &port->read_pool);
-	port->read_nb_queued--;
 
 	gs_start_rx(port);
 }
-- 
2.30.2




^ permalink raw reply related

* [PATCH 01/18] usb: gadget: fastboot: Allocate IN requests when needed
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

fastboot_download_finished() calls fastboot_tx_print() two times in a
row and waits for completion in between. Additionally this is called
from the completion function from another request. This seems to work
for example on the fsl_udc driver, but leads to problems on the DWC3
controller. Instead of re-using the same request over and over again,
just allocate a new request when needed. This way we no longer have
to poll for its completion before starting a new request.
While fixing fastboot on the DWC3 controller this also makes the
lifetime of a request clearer.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/f_fastboot.c | 54 ++++++++++++---------------------
 1 file changed, 20 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 96924c4cb9..078b37ce54 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -39,7 +39,7 @@ struct f_fastboot {
 
 	/* IN/OUT EP's and corresponding requests */
 	struct usb_ep *in_ep, *out_ep;
-	struct usb_request *in_req, *out_req;
+	struct usb_request *out_req;
 	struct work_queue wq;
 };
 
@@ -134,10 +134,6 @@ static int fastboot_write_usb(struct fastboot *fb, const char *buffer,
 			      unsigned int buffer_size);
 static void fastboot_start_download_usb(struct fastboot *fb);
 
-static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
-{
-}
-
 struct fastboot_work {
 	struct work_struct work;
 	struct f_fastboot *f_fb;
@@ -183,6 +179,17 @@ static struct usb_request *fastboot_alloc_request(struct usb_ep *ep)
 	return req;
 }
 
+static void fastboot_free_request(struct usb_ep *ep, struct usb_request *req)
+{
+	free(req->buf);
+	usb_ep_free_request(ep, req);
+}
+
+static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
+{
+	fastboot_free_request(ep, req);
+}
+
 static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
 {
 	struct usb_composite_dev *cdev = c->cdev;
@@ -259,14 +266,6 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
 	f_fb->out_req->complete = rx_handler_command;
 	f_fb->out_req->context = f_fb;
 
-	f_fb->in_req = fastboot_alloc_request(f_fb->in_ep);
-	if (!f_fb->in_req) {
-		puts("failed alloc req in\n");
-		ret = -EINVAL;
-		goto err_free_out_req;
-	}
-	f_fb->in_req->complete = fastboot_complete;
-
 	ret = usb_assign_descriptors(f, fb_fs_descs, fb_hs_descs, NULL);
 	if (ret)
 		goto err_free_in_req;
@@ -274,9 +273,6 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
 	return 0;
 
 err_free_in_req:
-	free(f_fb->in_req->buf);
-	usb_ep_free_request(f_fb->in_ep, f_fb->in_req);
-err_free_out_req:
 	free(f_fb->out_req->buf);
 	usb_ep_free_request(f_fb->out_ep, f_fb->out_req);
 fb_generic_free:
@@ -291,11 +287,6 @@ static void fastboot_unbind(struct usb_configuration *c, struct usb_function *f)
 {
 	struct f_fastboot *f_fb = func_to_fastboot(f);
 
-	usb_ep_dequeue(f_fb->in_ep, f_fb->in_req);
-	free(f_fb->in_req->buf);
-	usb_ep_free_request(f_fb->in_ep, f_fb->in_req);
-	f_fb->in_req = NULL;
-
 	usb_ep_dequeue(f_fb->out_ep, f_fb->out_req);
 	free(f_fb->out_req->buf);
 	usb_ep_free_request(f_fb->out_ep, f_fb->out_req);
@@ -404,28 +395,23 @@ DECLARE_USB_FUNCTION_INIT(fastboot, fastboot_alloc_instance, fastboot_alloc_func
 static int fastboot_write_usb(struct fastboot *fb, const char *buffer, unsigned int buffer_size)
 {
 	struct f_fastboot *f_fb = container_of(fb, struct f_fastboot, fastboot);
-	struct usb_request *in_req = f_fb->in_req;
-	uint64_t start;
+	struct usb_request *in_req;
 	int ret;
 
+	in_req = fastboot_alloc_request(f_fb->in_ep);
+	if (!in_req)
+		return -ENOMEM;
+
 	memcpy(in_req->buf, buffer, buffer_size);
 	in_req->length = buffer_size;
+	in_req->complete = fastboot_complete;
 
 	ret = usb_ep_queue(f_fb->in_ep, in_req);
-	if (ret)
+	if (ret) {
+		fastboot_free_request(f_fb->in_ep, in_req);
 		pr_err("Error %d on queue\n", ret);
-
-	start = get_time_ns();
-
-	while (in_req->status == -EINPROGRESS) {
-		if (is_timeout(start, 2 * SECOND))
-			return -ETIMEDOUT;
-		usb_gadget_poll();
 	}
 
-	if (in_req->status)
-		pr_err("Failed to send answer: %d\n", in_req->status);
-
 	return 0;
 }
 
-- 
2.30.2




^ permalink raw reply related

* [PATCH 02/18] usb: gadget: drop gadget_chips.h
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

gadget_chips.h is mostly unused and no longer present in upstream Linux,
so drop it from barebox as well. The only thing we still need is
gadget_is_pxa() which is added to epautoconf.c directly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/epautoconf.c   | 42 +----------------------
 drivers/usb/gadget/f_acm.c        |  1 -
 drivers/usb/gadget/f_serial.c     |  1 -
 drivers/usb/gadget/gadget_chips.h | 56 -------------------------------
 drivers/usb/gadget/serial.c       |  1 -
 5 files changed, 1 insertion(+), 100 deletions(-)
 delete mode 100644 drivers/usb/gadget/gadget_chips.h

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index e9f13f4262..2f1b9d1a0b 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -14,7 +14,7 @@
 #include <usb/ch9.h>
 #include <usb/gadget.h>
 
-#include "gadget_chips.h"
+#define gadget_is_pxa(g)                (!strcmp("pxa25x_udc", (g)->name))
 
 /*
  * This should work with endpoints from controller drivers sharing the
@@ -182,18 +182,6 @@ ep_matches (
 	return 1;
 }
 
-static struct usb_ep *
-find_ep (struct usb_gadget *gadget, const char *name)
-{
-	struct usb_ep	*ep;
-
-	list_for_each_entry (ep, &gadget->ep_list, ep_list) {
-		if (0 == strcmp (ep->name, name))
-			return ep;
-	}
-	return NULL;
-}
-
 /**
  * usb_ep_autoconfig_ss() - choose an endpoint matching the ep
  * descriptor and ep companion descriptor
@@ -249,34 +237,6 @@ struct usb_ep *usb_ep_autoconfig_ss(
 
 	type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
 
-	/* First, apply chip-specific "best usage" knowledge.
-	 * This might make a good usb_gadget_ops hook ...
-	 */
-	if (gadget_is_net2280 (gadget) && type == USB_ENDPOINT_XFER_INT) {
-		/* ep-e, ep-f are PIO with only 64 byte fifos */
-		ep = find_ep (gadget, "ep-e");
-		if (ep && ep_matches(gadget, ep, desc, ep_comp))
-			goto found_ep;
-		ep = find_ep (gadget, "ep-f");
-		if (ep && ep_matches(gadget, ep, desc, ep_comp))
-			goto found_ep;
-
-	} else if (gadget_is_goku (gadget)) {
-		if (USB_ENDPOINT_XFER_INT == type) {
-			/* single buffering is enough */
-			ep = find_ep(gadget, "ep3-bulk");
-			if (ep && ep_matches(gadget, ep, desc, ep_comp))
-				goto found_ep;
-		} else if (USB_ENDPOINT_XFER_BULK == type
-				&& (USB_DIR_IN & desc->bEndpointAddress)) {
-			/* DMA may be available */
-			ep = find_ep(gadget, "ep2-bulk");
-			if (ep && ep_matches(gadget, ep, desc,
-					      ep_comp))
-				goto found_ep;
-		}
-	}
-
 	/* Second, look at endpoints until an unclaimed one looks usable */
 	list_for_each_entry (ep, &gadget->ep_list, ep_list) {
 		if (ep_matches(gadget, ep, desc, ep_comp))
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
index 42438947c1..3d2595edd7 100644
--- a/drivers/usb/gadget/f_acm.c
+++ b/drivers/usb/gadget/f_acm.c
@@ -19,7 +19,6 @@
 #include <usb/composite.h>
 
 #include "u_serial.h"
-#include "gadget_chips.h"
 
 
 /*
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c
index 33cf54dc1c..494f6c872e 100644
--- a/drivers/usb/gadget/f_serial.c
+++ b/drivers/usb/gadget/f_serial.c
@@ -12,7 +12,6 @@
 #include <linux/err.h>
 
 #include "u_serial.h"
-#include "gadget_chips.h"
 
 
 /*
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h
deleted file mode 100644
index 78e0601027..0000000000
--- a/drivers/usb/gadget/gadget_chips.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * USB device controllers have lots of quirks.  Use these macros in
- * gadget drivers or other code that needs to deal with them, and which
- * autoconfigures instead of using early binding to the hardware.
- *
- * This SHOULD eventually work like the ARM mach_is_*() stuff, driven by
- * some config file that gets updated as new hardware is supported.
- * (And avoiding all runtime comparisons in typical one-choice configs!)
- *
- * NOTE:  some of these controller drivers may not be available yet.
- * Some are available on 2.4 kernels; several are available, but not
- * yet pushed in the 2.6 mainline tree.
- */
-
-#ifndef __GADGET_CHIPS_H
-#define __GADGET_CHIPS_H
-
-#include <usb/gadget.h>
-
-/*
- * NOTICE: the entries below are alphabetical and should be kept
- * that way.
- *
- * Always be sure to add new entries to the correct position or
- * accept the bashing later.
- *
- * If you have forgotten the alphabetical order let VIM/EMACS
- * do that for you.
- */
-#define gadget_is_at91(g)		(!strcmp("at91_udc", (g)->name))
-#define gadget_is_goku(g)		(!strcmp("goku_udc", (g)->name))
-#define gadget_is_musbhdrc(g)		(!strcmp("musb-hdrc", (g)->name))
-#define gadget_is_net2280(g)		(!strcmp("net2280", (g)->name))
-#define gadget_is_pxa(g)		(!strcmp("pxa25x_udc", (g)->name))
-#define gadget_is_pxa27x(g)		(!strcmp("pxa27x_udc", (g)->name))
-
-/**
- * gadget_supports_altsettings - return true if altsettings work
- * @gadget: the gadget in question
- */
-static inline bool gadget_supports_altsettings(struct usb_gadget *gadget)
-{
-	/* PXA 21x/25x/26x has no altsettings at all */
-	if (gadget_is_pxa(gadget))
-		return false;
-
-	/* PXA 27x and 3xx have *broken* altsetting support */
-	if (gadget_is_pxa27x(gadget))
-		return false;
-
-	/* Everything else is *presumably* fine ... */
-	return true;
-}
-
-#endif /* __GADGET_CHIPS_H */
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 0ef2665b69..6321f3f207 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -18,7 +18,6 @@
 #include <asm/byteorder.h>
 
 #include "u_serial.h"
-#include "gadget_chips.h"
 
 
 /* Defines */
-- 
2.30.2




^ permalink raw reply related

* [PATCH 07/18] driver: Add unregister_driver()
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

Registering drivers is one thing, getting rid of them another. Add
unregister_driver() which is used in the coming USB gadget update.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/base/driver.c | 16 ++++++++++++++++
 include/driver.h      |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index efbffcdddb..719920ec67 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -405,6 +405,22 @@ int register_driver(struct driver *drv)
 }
 EXPORT_SYMBOL(register_driver);
 
+void unregister_driver(struct driver *drv)
+{
+	struct device *dev;
+
+	list_del(&drv->list);
+	list_del(&drv->bus_list);
+
+	bus_for_each_device(drv->bus, dev) {
+		if (dev->driver == drv) {
+			drv->bus->remove(dev);
+			dev->driver = NULL;
+			list_del(&dev->active);
+		}
+	}
+}
+
 struct resource *dev_get_resource(struct device *dev, unsigned long type,
 				  int num)
 {
diff --git a/include/driver.h b/include/driver.h
index 2cf0190699..5605a3db24 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -137,6 +137,8 @@ struct driver {
 /* Register devices and drivers.
  */
 int register_driver(struct driver *);
+void unregister_driver(struct driver *drv);
+
 int register_device(struct device *);
 
 /* manualy probe a device
-- 
2.30.2




^ permalink raw reply related

* [PATCH 18/18] usb: gadget multi: support USB Super Speed
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

Now that all function drivers support super speed, propagate super
speed support in the multi function gadget as well..

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/legacy/multi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c
index 2c9a784cbe..7046a529b1 100644
--- a/drivers/usb/gadget/legacy/multi.c
+++ b/drivers/usb/gadget/legacy/multi.c
@@ -275,7 +275,7 @@ static struct usb_composite_driver multi_driver = {
 	.name		= "g_multi",
 	.dev		= &device_desc,
 	.strings	= dev_strings,
-	.max_speed	= USB_SPEED_HIGH,
+	.max_speed	= USB_SPEED_SUPER,
 	.bind		= multi_bind,
 	.unbind		= multi_unbind,
 	.needs_serial	= 1,
-- 
2.30.2




^ permalink raw reply related

* [PATCH 14/18] usb: gadget: dfu: Assign super speed descriptors
From: Sascha Hauer @ 2023-03-20 15:29 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20230320152941.3155428-1-s.hauer@pengutronix.de>

DFU uses the same descriptors for full speed and high speed already,
just use them for super speed (plus) as well.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/function/dfu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/dfu.c b/drivers/usb/gadget/function/dfu.c
index e6ba829a85..431480094b 100644
--- a/drivers/usb/gadget/function/dfu.c
+++ b/drivers/usb/gadget/function/dfu.c
@@ -427,7 +427,7 @@ dfu_bind(struct usb_configuration *c, struct usb_function *f)
 	header[i] = (struct usb_descriptor_header *) &usb_dfu_func;
 	header[i + 1] = NULL;
 
-	status = usb_assign_descriptors(f, header, header, NULL, NULL);
+	status = usb_assign_descriptors(f, header, header, header, header);
 
 	free(desc);
 	free(header);
-- 
2.30.2




^ permalink raw reply related

* [PATCH] Documentation: imx: improve reboot mode section
From: Roland Hieber @ 2023-03-20 11:41 UTC (permalink / raw)
  To: barebox; +Cc: Roland Hieber

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 Documentation/boards/imx.rst | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/Documentation/boards/imx.rst b/Documentation/boards/imx.rst
index 6c16923340a8..6fbf1554d10e 100644
--- a/Documentation/boards/imx.rst
+++ b/Documentation/boards/imx.rst
@@ -86,8 +86,8 @@ The images can also always be started as second stage on the target:
 BootROM Reboot mode codes (bmode)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-For select SoCs, barebox supports communicating an alternative boot medium
-that BootROM should select after a warm reset::
+For selected SoCs, barebox supports communicating an alternative boot medium
+that the BootROM should select after a warm reset::
 
   barebox@FSL i.MX8MM EVK board:/ devinfo gpr.reboot_mode
   Driver: syscon-reboot-mode
@@ -107,10 +107,17 @@ that BootROM should select after a warm reset::
 
   barebox@FSL i.MX8MM EVK board:/ gpr.reboot_mode.next=serial reset -w
 
-This will cause barebox to fall into serial download mode on an i.MX8MM.
+The example above will cause barebox to jump back into serial download mode on
+an i.MX8MM by writing 0x10 into the *SRC_GPR9* register (offset 0x30390094) and
+0x40000000 into the *SRC_GPR10* register (offset 0x30390098), and then issuing a
+warm :ref:`reset <command_reset>`.
 
 Different SoCs may have more possible reboot modes available.
-See the section on :ref:`Reboot modes<reboot_mode>` for more information.
+Look for documentation of the *SRC_SBMR* and *SRC_GPR* registers in the
+Reference Manual of your SoC; the values for the ``mode-*`` properties often
+correspond directly to the boot fusemap settings.
+
+See the section on :ref:`Reboot modes<reboot_mode>` for general information.
 
 High Assurance Boot
 ^^^^^^^^^^^^^^^^^^^
-- 
2.30.2




^ permalink raw reply related

* Re: [PATCH] arm: rockchip: add support for CM3 on IO board
From: Marco Felsch @ 2023-03-20  8:19 UTC (permalink / raw)
  To: Rouven Czerwinski; +Cc: barebox, Rouven Czerwinski
In-Reply-To: <20230318160635.216749-1-r.czerwinski@pengutronix.de>

Hi Rouven,

On 23-03-18, Rouven Czerwinski wrote:
> From: Rouven Czerwinski <rouven@czerwinskis.de>
> 
> Working:
> - RKBIN DDR training (rk3566_ddr_1056MHz_v1.13.bin)
> - RKBIN TF-A (v1.34) from RKBIN

Can please add the board to Documentation/boards/rockchip.rst?

> - Environment storage
> - DHCP, ping and link detection
> 
> Signed-off-by: Rouven Czerwinski <rouven@czerwinskis.de>
> ---
>  arch/arm/boards/Makefile             |  1 +
>  arch/arm/boards/radxa-cm3/.gitignore |  1 +
>  arch/arm/boards/radxa-cm3/Makefile   |  3 ++
>  arch/arm/boards/radxa-cm3/board.c    | 56 ++++++++++++++++++++++++++++
>  arch/arm/boards/radxa-cm3/lowlevel.c | 50 +++++++++++++++++++++++++
>  arch/arm/dts/Makefile                |  1 +
>  arch/arm/dts/rk3566-cm3-io.dts       | 55 +++++++++++++++++++++++++++
>  arch/arm/mach-rockchip/Kconfig       |  6 +++
>  images/Makefile.rockchip             |  7 ++++
>  9 files changed, 180 insertions(+)
>  create mode 100644 arch/arm/boards/radxa-cm3/.gitignore
>  create mode 100644 arch/arm/boards/radxa-cm3/Makefile
>  create mode 100644 arch/arm/boards/radxa-cm3/board.c
>  create mode 100644 arch/arm/boards/radxa-cm3/lowlevel.c
>  create mode 100644 arch/arm/dts/rk3566-cm3-io.dts

...

> diff --git a/arch/arm/dts/rk3566-cm3-io.dts b/arch/arm/dts/rk3566-cm3-io.dts
> new file mode 100644
> index 0000000000..81f896b943
> --- /dev/null
> +++ b/arch/arm/dts/rk3566-cm3-io.dts
> @@ -0,0 +1,55 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +
> +/dts-v1/;
> +
> +#include <arm64/rockchip/rk3566-radxa-cm3-io.dts>
> +#include "rk356x.dtsi"
> +
> +/ {
> +	chosen: chosen {
> +		environment-sd {
> +			compatible = "barebox,environment";
> +			device-path = &environment_sd;
> +			status = "disabled";
> +		};
> +
> +		environment-emmc {
> +			compatible = "barebox,environment";
> +			device-path = &environment_emmc;
> +			status = "disabled";
> +		};
> +	};
> +
> +	memory@a00000 {
> +		device_type = "memory";
> +		reg = <0x0 0x00a00000 0x0 0x7f600000>;
> +	};

Do we need the memoty node here? I recently encountered issues with it
on a i.MX8MP.

Regards,
  Marco



^ permalink raw reply

* Re: [PATCH 0/3] mtd: nand: atmel: legacy: fix boot on USB-A9G20
From: Wolfram Sang @ 2023-03-19 21:28 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: barebox
In-Reply-To: <ZBdZxskg+JPzUY0t@ravnborg.org>

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]

Hi Sam,

> It is only a few weeks ago I argued that there was no users of the older
> at91sam* boards, and then you prove me wrong here.

At your service ;)

> I will try to remember that you may be able to test should someone
> decide to move the barebox support for qil_a9g20 to DT and add PBL
> support in the process.

I am still new to at91 and barebox, but AFAICS the PBL support is only
for MCI currently? I have an USB-A9G20-C01 and this one does not have SD
exposed. The later version A9G20-LPW has it, but I don't own such a
device, sadly. I really like the Calao USB form factor.

Happy hacking,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: [PATCH 0/3] mtd: nand: atmel: legacy: fix boot on USB-A9G20
From: Sam Ravnborg @ 2023-03-19 18:51 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: barebox
In-Reply-To: <20230319154909.24047-1-wsa@kernel.org>

Hi Wolfram.

On Sun, Mar 19, 2023 at 04:49:06PM +0100, Wolfram Sang wrote:
> While trying to unbrick my Calao USB-A9G20, barebox couldn't read the
> NAND BB tables unlike the binary-only barebox from 2013. The first two
> patches fix that. The third one is a cleanup.

It is only a few weeks ago I argued that there was no users of the older
at91sam* boards, and then you prove me wrong here.

I will try to remember that you may be able to test should someone
decide to move the barebox support for qil_a9g20 to DT and add PBL
support in the process.

	Sam



^ permalink raw reply

* [PATCH 3/3] mtd: nand: atmel: legacy: remove superfluous code
From: Wolfram Sang @ 2023-03-19 15:49 UTC (permalink / raw)
  To: barebox; +Cc: Wolfram Sang
In-Reply-To: <20230319154909.24047-1-wsa@kernel.org>

54bccadddd always populates 'ecc_mode' but forgot to remove the
code which overwrote the previously hardcoded 'NAND_ECC_SOFT'
when needed. This is obsolete now.

Fixes: 54bccadddd ("mtd: atmel_nand: retrieve ecc_mode from pdata")
Signed-off-by: Wolfram Sang <wsa@kernel.org>
---
 drivers/mtd/nand/atmel/legacy.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/drivers/mtd/nand/atmel/legacy.c b/drivers/mtd/nand/atmel/legacy.c
index 184cf465e3..cf402549b8 100644
--- a/drivers/mtd/nand/atmel/legacy.c
+++ b/drivers/mtd/nand/atmel/legacy.c
@@ -1242,21 +1242,12 @@ static int __init atmel_nand_probe(struct device *dev)
 	nand_chip->ecc.strength = pdata->ecc_strength ? : 1;
 	nand_chip->ecc.size = 1 << (pdata->ecc_size_shift ? : 9);
 
-	if (pdata->ecc_mode == NAND_ECC_HW) {
-		nand_chip->ecc.mode = NAND_ECC_HW;
-	}
-
 	if (pdata->ecc_mode == NAND_ECC_SOFT) {
 		nand_chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 	}
 
 	nand_chip->legacy.chip_delay = 40;		/* 40us command delay time */
 
-	if (IS_ENABLED(CONFIG_NAND_ECC_BCH) &&
-			pdata->ecc_mode == NAND_ECC_SOFT_BCH) {
-		nand_chip->ecc.mode = NAND_ECC_SOFT_BCH;
-	}
-
 	if (host->board->bus_width_16) {	/* 16-bit bus width */
 		nand_chip->options |= NAND_BUSWIDTH_16;
 		nand_chip->legacy.read_buf = atmel_read_buf16;
-- 
2.35.1




^ permalink raw reply related

* [PATCH 2/3] mtd: nand: atmel: legacy: use proper ecc_shift
From: Wolfram Sang @ 2023-03-19 15:49 UTC (permalink / raw)
  To: barebox; +Cc: Wolfram Sang
In-Reply-To: <20230319154909.24047-1-wsa@kernel.org>

The logic of the ternary operator is broken because '1 << x' is always
true even if 'x' is 0. Convert the logic to really use either the pdata
value or a sane default. Fixes "WARNING: Total number of ECC bytes
exceeded oobsize" on my USB-A9G20.

Fixes: babffbb193 ("mtd: atmel_nand: Add per board ECC setup")
Signed-off-by: Wolfram Sang <wsa@kernel.org>
---

The other option is to revert babffbb193. I don't see any user. The code
was obviously not enough tested as well.

 drivers/mtd/nand/atmel/legacy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/atmel/legacy.c b/drivers/mtd/nand/atmel/legacy.c
index ea1fd64ad8..184cf465e3 100644
--- a/drivers/mtd/nand/atmel/legacy.c
+++ b/drivers/mtd/nand/atmel/legacy.c
@@ -1240,7 +1240,7 @@ static int __init atmel_nand_probe(struct device *dev)
 
 	nand_chip->ecc.mode = pdata->ecc_mode;
 	nand_chip->ecc.strength = pdata->ecc_strength ? : 1;
-	nand_chip->ecc.size = 1 << pdata->ecc_size_shift ? : 512;
+	nand_chip->ecc.size = 1 << (pdata->ecc_size_shift ? : 9);
 
 	if (pdata->ecc_mode == NAND_ECC_HW) {
 		nand_chip->ecc.mode = NAND_ECC_HW;
-- 
2.35.1




^ permalink raw reply related

* [PATCH 1/3] mtd: nand: atmel: legacy: add 'algo' to use
From: Wolfram Sang @ 2023-03-19 15:49 UTC (permalink / raw)
  To: barebox; +Cc: Wolfram Sang
In-Reply-To: <20230319154909.24047-1-wsa@kernel.org>

Fixes "WARNING: Unsupported ECC algorithm!" on my USB-A9G20.

Fixes: b6bcd96de5 ("mtd: nand: Update to Linux-5.9")
Signed-off-by: Wolfram Sang <wsa@kernel.org>
---

Or maybe we should make HAMMING the default fallback in nand_base.c?

 drivers/mtd/nand/atmel/legacy.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/nand/atmel/legacy.c b/drivers/mtd/nand/atmel/legacy.c
index 44cd4d07e8..ea1fd64ad8 100644
--- a/drivers/mtd/nand/atmel/legacy.c
+++ b/drivers/mtd/nand/atmel/legacy.c
@@ -1246,6 +1246,10 @@ static int __init atmel_nand_probe(struct device *dev)
 		nand_chip->ecc.mode = NAND_ECC_HW;
 	}
 
+	if (pdata->ecc_mode == NAND_ECC_SOFT) {
+		nand_chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
+	}
+
 	nand_chip->legacy.chip_delay = 40;		/* 40us command delay time */
 
 	if (IS_ENABLED(CONFIG_NAND_ECC_BCH) &&
-- 
2.35.1




^ permalink raw reply related

* [PATCH 0/3] mtd: nand: atmel: legacy: fix boot on USB-A9G20
From: Wolfram Sang @ 2023-03-19 15:49 UTC (permalink / raw)
  To: barebox; +Cc: Wolfram Sang

While trying to unbrick my Calao USB-A9G20, barebox couldn't read the
NAND BB tables unlike the binary-only barebox from 2013. The first two
patches fix that. The third one is a cleanup.

Happy hacking!


Wolfram Sang (3):
  mtd: nand: atmel: legacy: add 'algo' to use
  mtd: nand: atmel: legacy: use proper ecc_shift
  mtd: nand: atmel: legacy: remove superfluous code

 drivers/mtd/nand/atmel/legacy.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

-- 
2.35.1




^ permalink raw reply

* [PATCH] commands: edit: fix typo in Kconfig help text
From: Wolfram Sang @ 2023-03-19 15:39 UTC (permalink / raw)
  To: barebox; +Cc: Wolfram Sang

Signed-off-by: Wolfram Sang <wsa@kernel.org>
---
 commands/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index ec15f4e543..27769950d9 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1383,7 +1383,7 @@ config CMD_EDIT
 	depends on CONSOLE_FULL || CONSOLE_SIMPLE
 	prompt "edit"
 	help
-	  A  small fill-screen editor.
+	  A small full-screen editor.
 
 	  Usage: edit FILE
 
-- 
2.35.1




^ permalink raw reply related

* [PATCH] commands: nand: add missing parameters to help
From: Wolfram Sang @ 2023-03-19 15:39 UTC (permalink / raw)
  To: barebox; +Cc: Wolfram Sang

Signed-off-by: Wolfram Sang <wsa@kernel.org>
---
 commands/Kconfig | 4 +++-
 commands/nand.c  | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index 27769950d9..76dfca2dfd 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1950,12 +1950,14 @@ config CMD_NAND
 	help
 	  NAND flash handling
 
-	  Usage: nand [-adb] NANDDEV
+	  Usage: nand [-adbgi] NANDDEV
 
 	  Options:
 		  -a		register a bad block aware device ontop of a normal NAND device
 		  -d		deregister a bad block aware device
 		  -b OFFS	mark block at OFFSet as bad
+		  -g OFFS	mark block at OFFSet as good
+		  -i		info. Show information about bad blocks
 
 config CMD_NANDTEST
 	tristate
diff --git a/commands/nand.c b/commands/nand.c
index 67e43eba30..d07444aee0 100644
--- a/commands/nand.c
+++ b/commands/nand.c
@@ -165,7 +165,7 @@ BAREBOX_CMD_HELP_END
 BAREBOX_CMD_START(nand)
 	.cmd		= do_nand,
 	BAREBOX_CMD_DESC("NAND flash handling")
-	BAREBOX_CMD_OPTS("[-adb] NANDDEV")
+	BAREBOX_CMD_OPTS("[-adbgi] NANDDEV")
 	BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
 	BAREBOX_CMD_HELP(cmd_nand_help)
 BAREBOX_CMD_END
-- 
2.35.1




^ permalink raw reply related

* [PATCH] arm: rockchip: add support for CM3 on IO board
From: Rouven Czerwinski @ 2023-03-18 16:06 UTC (permalink / raw)
  To: barebox; +Cc: Rouven Czerwinski

From: Rouven Czerwinski <rouven@czerwinskis.de>

Working:
- RKBIN DDR training (rk3566_ddr_1056MHz_v1.13.bin)
- RKBIN TF-A (v1.34) from RKBIN
- Environment storage
- DHCP, ping and link detection

Signed-off-by: Rouven Czerwinski <rouven@czerwinskis.de>
---
 arch/arm/boards/Makefile             |  1 +
 arch/arm/boards/radxa-cm3/.gitignore |  1 +
 arch/arm/boards/radxa-cm3/Makefile   |  3 ++
 arch/arm/boards/radxa-cm3/board.c    | 56 ++++++++++++++++++++++++++++
 arch/arm/boards/radxa-cm3/lowlevel.c | 50 +++++++++++++++++++++++++
 arch/arm/dts/Makefile                |  1 +
 arch/arm/dts/rk3566-cm3-io.dts       | 55 +++++++++++++++++++++++++++
 arch/arm/mach-rockchip/Kconfig       |  6 +++
 images/Makefile.rockchip             |  7 ++++
 9 files changed, 180 insertions(+)
 create mode 100644 arch/arm/boards/radxa-cm3/.gitignore
 create mode 100644 arch/arm/boards/radxa-cm3/Makefile
 create mode 100644 arch/arm/boards/radxa-cm3/board.c
 create mode 100644 arch/arm/boards/radxa-cm3/lowlevel.c
 create mode 100644 arch/arm/dts/rk3566-cm3-io.dts

diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 37b1650e63..b204c257f6 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -190,3 +190,4 @@ obj-$(CONFIG_MACH_RK3568_BPI_R2PRO)			+= rockchip-rk3568-bpi-r2pro/
 obj-$(CONFIG_MACH_PINE64_QUARTZ64)		+= pine64-quartz64/
 obj-$(CONFIG_MACH_RADXA_ROCK3)			+= radxa-rock3/
 obj-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP)	+= variscite-dt8mcustomboard-imx8mp/
+obj-$(CONFIG_MACH_RADXA_CM3)			+= radxa-cm3/
diff --git a/arch/arm/boards/radxa-cm3/.gitignore b/arch/arm/boards/radxa-cm3/.gitignore
new file mode 100644
index 0000000000..f458f794b5
--- /dev/null
+++ b/arch/arm/boards/radxa-cm3/.gitignore
@@ -0,0 +1 @@
+sdram-init.bin
diff --git a/arch/arm/boards/radxa-cm3/Makefile b/arch/arm/boards/radxa-cm3/Makefile
new file mode 100644
index 0000000000..b37b6c870b
--- /dev/null
+++ b/arch/arm/boards/radxa-cm3/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-y += board.o
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/radxa-cm3/board.c b/arch/arm/boards/radxa-cm3/board.c
new file mode 100644
index 0000000000..14b6784179
--- /dev/null
+++ b/arch/arm/boards/radxa-cm3/board.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <bootsource.h>
+#include <common.h>
+#include <deep-probe.h>
+#include <init.h>
+#include <mach/rockchip/bbu.h>
+
+struct cm3_model {
+	const char *name;
+	const char *shortname;
+};
+
+static int cm3_probe(struct device *dev)
+{
+	enum bootsource bootsource = bootsource_get();
+	int instance = bootsource_get_instance();
+	const struct cm3_model *model;
+
+	model = device_get_match_data(dev);
+
+	barebox_set_model(model->name);
+	barebox_set_hostname(model->shortname);
+
+	if (bootsource == BOOTSOURCE_MMC && instance == 1)
+		of_device_enable_path("/chosen/environment-sd");
+	else
+		of_device_enable_path("/chosen/environment-emmc");
+
+	rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT,
+				"/dev/mmc0");
+	rk3568_bbu_mmc_register("sd", 0, "/dev/mmc1");
+
+	return 0;
+}
+
+static const struct cm3_model cm3_io = {
+	.name = "Radxa CM3 on IO Board",
+	.shortname = "cm3-io",
+};
+
+static const struct of_device_id cm3_of_match[] = {
+	{
+		.compatible = "radxa,cm3-io",
+		.data = &cm3_io,
+	},
+	{ /* sentinel */ },
+};
+
+static struct driver cm3_io_board_driver = {
+	.name = "board-cm3-io",
+	.probe = cm3_probe,
+	.of_compatible = cm3_of_match,
+};
+coredevice_platform_driver(cm3_io_board_driver);
+
+BAREBOX_DEEP_PROBE_ENABLE(cm3_of_match);
diff --git a/arch/arm/boards/radxa-cm3/lowlevel.c b/arch/arm/boards/radxa-cm3/lowlevel.c
new file mode 100644
index 0000000000..e25ba62bea
--- /dev/null
+++ b/arch/arm/boards/radxa-cm3/lowlevel.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <common.h>
+#include <linux/sizes.h>
+#include <asm/barebox-arm-head.h>
+#include <asm/barebox-arm.h>
+#include <mach/rockchip/hardware.h>
+#include <mach/rockchip/atf.h>
+#include <debug_ll.h>
+#include <mach/rockchip/rockchip.h>
+
+extern char __dtb_rk3566_cm3_io_start[];
+
+static noinline void rk3566_start(void)
+{
+	void *fdt = __dtb_rk3566_cm3_io_start;
+
+	/*
+	 * Enable vccio4 1.8V and vccio6 1.8V
+	 * Needed for GMAC to work.
+	 * FIXME: This is done by the io-domain driver as well, but there
+	 * currently is no mechanism to make sure the driver gets probed
+	 * before its consumers. Remove this setup once this issue is
+	 * resolved.
+	 */
+	writel(RK_SETBITS(0x50), 0xfdc20140);
+
+	if (current_el() == 3) {
+		rk3568_lowlevel_init();
+		rk3568_atf_load_bl31(fdt);
+		/* not reached */
+	}
+
+	barebox_arm_entry(RK3568_DRAM_BOTTOM, 0x80000000 - RK3568_DRAM_BOTTOM, fdt);
+}
+
+ENTRY_FUNCTION(start_radxa_cm3_io, r0, r1, r2)
+{
+	/*
+	 * Image execution starts at 0x0, but this is used for ATF and
+	 * OP-TEE later, so move away from here.
+	 */
+	if (current_el() == 3)
+		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
+	else
+		relocate_to_current_adr();
+
+	setup_c();
+
+	rk3566_start();
+}
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0a7cceb461..220e1617e3 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -109,6 +109,7 @@ lwl-$(CONFIG_MACH_PROTONIC_STM32MP1) += \
 	stm32mp151-prtt1s.dtb.o
 lwl-$(CONFIG_MACH_RADXA_ROCK) += rk3188-radxarock.dtb.o
 lwl-$(CONFIG_MACH_RADXA_ROCK3) += rk3568-rock-3a.dtb.o
+lwl-$(CONFIG_MACH_RADXA_CM3) += rk3566-cm3-io.dtb.o
 lwl-$(CONFIG_MACH_PHYTEC_SOM_RK3288) += rk3288-phycore-som.dtb.o
 lwl-$(CONFIG_MACH_REALQ7) += imx6q-dmo-edmqmx6.dtb.o
 lwl-$(CONFIG_MACH_RK3568_EVB) += rk3568-evb1-v10.dtb.o
diff --git a/arch/arm/dts/rk3566-cm3-io.dts b/arch/arm/dts/rk3566-cm3-io.dts
new file mode 100644
index 0000000000..81f896b943
--- /dev/null
+++ b/arch/arm/dts/rk3566-cm3-io.dts
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+/dts-v1/;
+
+#include <arm64/rockchip/rk3566-radxa-cm3-io.dts>
+#include "rk356x.dtsi"
+
+/ {
+	chosen: chosen {
+		environment-sd {
+			compatible = "barebox,environment";
+			device-path = &environment_sd;
+			status = "disabled";
+		};
+
+		environment-emmc {
+			compatible = "barebox,environment";
+			device-path = &environment_emmc;
+			status = "disabled";
+		};
+	};
+
+	memory@a00000 {
+		device_type = "memory";
+		reg = <0x0 0x00a00000 0x0 0x7f600000>;
+	};
+};
+
+&sdhci {
+	no-sd;
+
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <2>;
+		#size-cells = <2>;
+
+		environment_emmc: partition@408000 {
+			label = "barebox-environment";
+			reg = <0x0 0x408000 0x0 0x8000>;
+		};
+	};
+};
+
+&sdmmc0 {
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <2>;
+		#size-cells = <2>;
+
+		environment_sd: partition@408000 {
+			label = "barebox-environment";
+			reg = <0x0 0x408000 0x0 0x8000>;
+		};
+	};
+};
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 4ac75ab947..0d3bbebaad 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -86,6 +86,12 @@ config MACH_RADXA_ROCK3
        help
 	  Say Y here if you are using a Radxa ROCK3
 
+config MACH_RADXA_CM3
+       select ARCH_RK3568
+       bool "Radxa CM3"
+       help
+	  Say Y here if you are using a Radxa CM3
+
 comment "select board features:"
 
 config ARCH_ROCKCHIP_ATF
diff --git a/images/Makefile.rockchip b/images/Makefile.rockchip
index 33c76caf79..490e1ddb4d 100644
--- a/images/Makefile.rockchip
+++ b/images/Makefile.rockchip
@@ -23,6 +23,9 @@ image-$(CONFIG_MACH_PINE64_QUARTZ64) += barebox-quartz64a.img
 pblb-$(CONFIG_MACH_RADXA_ROCK3) += start_rock3a
 image-$(CONFIG_MACH_RADXA_ROCK3) += barebox-rock3a.img
 
+pblb-$(CONFIG_MACH_RADXA_CM3) += start_radxa-cm3-io.img
+image-$(CONFIG_MACH_RADXA_CM3) += barebox-radxa-cm3-io.img
+
 quiet_cmd_rkimg_image = RK-IMG $@
       cmd_rkimg_image = $(objtree)/scripts/rkimage -o $@ $(word 2,$^) $(word 1,$^)
 
@@ -41,3 +44,7 @@ $(obj)/barebox-quartz64a.img: $(obj)/start_quartz64a.pblb \
 $(obj)/barebox-rock3a.img: $(obj)/start_rock3a.pblb \
                 $(board)/radxa-rock3/sdram-init.bin
 	$(call if_changed,rkimg_image)
+
+$(obj)/barebox-radxa-cm3-io.img: $(obj)/start_radxa_cm3_io.pblb \
+                $(board)/radxa-cm3/sdram-init.bin
+	$(call if_changed,rkimg_image)
-- 
2.39.2




^ permalink raw reply related

* Re: Autoboot when idling at prompt possible?
From: Konstantin Kletschke @ 2023-03-17 17:35 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox
In-Reply-To: <9bcfc2f8-72f4-b994-0c61-07e34ccc22a0@pengutronix.de>

Dear Ahmad,

thanks for your kind support.

On Thu, Mar 16, 2023 at 01:51:39PM +0100, Ahmad Fatoum wrote:

> If you keep ctrl+c pressed during boot, you may abort before init runs,
> even if global.autboot_timeout=0.

Interesting, I double checked "my" barebox for this feature, nice to
know.

> You can enable watchdog before init runs, e.g. in your board code, let's
> say with a timeout of 2 minutes. If you have reason to use the shell, you
> run wd -x manually or set global.autoboot=abort and reset.

This sounds neat and not over complicated. Nice Idea, to have a watchdog
enabled at barebox level, why not. The manual required "wd -x" is fine.

I have a beaglebone board, added CONFIG_WATCHDOG and manual enabling
watchdog via "wd 120" and disabling vie "wd -x" works fine. Now I wonder
how to enable at boot up.

Something like

--- a/arch/arm/boards/beaglebone/board.c
+++ b/arch/arm/boards/beaglebone/board.c
@@ -25,6 +25,8 @@
 #include <linux/err.h>
 #include <mach/bbu.h>

+#include <watchdog.h>
+
 #include "beaglebone.h"

 static int beaglebone_coredevice_init(void)
@@ -84,6 +86,9 @@ static int beaglebone_devices_init(void)
        if (IS_ENABLED(CONFIG_SHELL_NONE))
                return am33xx_of_register_bootdevice();

+       struct watchdog *wd = watchdog_get_default();
+       watchdog_set_timeout(wd, 120);
+
        return 0;
 }
 coredevice_initcall(beaglebone_devices_init);

?

I can't test at the moment because I am remote and cant handle a abused
crashing barebox at the moment. It compiles, though!

The passwort entry approach is kinda neat to, I will investigate this
feature too.

Kind Regards
Konstantin

-- 
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

konstantin.kletschke@inside-m2m.de
http://www.inside-m2m.de 

Geschäftsführung: Michael Emmert, Derek Uhlig
HRB: 111204, AG Hannover




^ permalink raw reply

* Re: [PATCH v2] Documentation: devicetree: list automatic boot argument fixups
From: Ahmad Fatoum @ 2023-03-17 12:41 UTC (permalink / raw)
  To: Johannes Zink, barebox; +Cc: afa, jzi
In-Reply-To: <20230317121937.958131-1-j.zink@pengutronix.de>

On 17.03.23 13:19, Johannes Zink wrote:
> Barebox automatically fixes up several properties to the root and
> chosen node of the device tree passed to the booted system.
> 
> These entries contain information about the hardware, reset source
> and the barebox version string.
> 
> Add documentation on how to query these information from the booted
> linux system.
> 
> Signed-off-by: Johannes Zink <j.zink@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  Changelog:
> 
>  v1 -> v2: Correct errors in content spotted by Ahmad. While at it, fix some typos.
> 
>  Documentation/devicetree/index.rst | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/Documentation/devicetree/index.rst b/Documentation/devicetree/index.rst
> index 36fa69058d1d..f85ce6608d14 100644
> --- a/Documentation/devicetree/index.rst
> +++ b/Documentation/devicetree/index.rst
> @@ -151,3 +151,25 @@ Contents:
>     bindings/regulator/*
>     bindings/rtc/*
>     bindings/watchdog/*
> +
> +Automatic Boot Argument Fixups to the Devicetree
> +------------------------------------------------
> +
> +barebox automatically fixes up some boot and system information in the device tree.
> +
> +In the device tree root, barebox fixes up
> +
> + * serial-number (if available)
> + * machine compatible (if overridden)
> +
> +In the ``chosen``-node, barebox fixes up
> +
> + * barebox-version
> + * reset-source
> + * reset-source-instance (if available)
> + * reset-source-device (node-path, only if available)
> + * bootsource
> + * boot-hartid (only on RISC-V)
> +
> +These values can be read from the booted linux system in ``/proc/device-tree/``
> +or ``/sys/firmware/devicetree/base``.

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply

* [PATCH v2] Documentation: devicetree: list automatic boot argument fixups
From: Johannes Zink @ 2023-03-17 12:19 UTC (permalink / raw)
  To: barebox; +Cc: Johannes Zink, afa, jzi

Barebox automatically fixes up several properties to the root and
chosen node of the device tree passed to the booted system.

These entries contain information about the hardware, reset source
and the barebox version string.

Add documentation on how to query these information from the booted
linux system.

Signed-off-by: Johannes Zink <j.zink@pengutronix.de>
---
 Changelog:

 v1 -> v2: Correct errors in content spotted by Ahmad. While at it, fix some typos.

 Documentation/devicetree/index.rst | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/Documentation/devicetree/index.rst b/Documentation/devicetree/index.rst
index 36fa69058d1d..f85ce6608d14 100644
--- a/Documentation/devicetree/index.rst
+++ b/Documentation/devicetree/index.rst
@@ -151,3 +151,25 @@ Contents:
    bindings/regulator/*
    bindings/rtc/*
    bindings/watchdog/*
+
+Automatic Boot Argument Fixups to the Devicetree
+------------------------------------------------
+
+barebox automatically fixes up some boot and system information in the device tree.
+
+In the device tree root, barebox fixes up
+
+ * serial-number (if available)
+ * machine compatible (if overridden)
+
+In the ``chosen``-node, barebox fixes up
+
+ * barebox-version
+ * reset-source
+ * reset-source-instance (if available)
+ * reset-source-device (node-path, only if available)
+ * bootsource
+ * boot-hartid (only on RISC-V)
+
+These values can be read from the booted linux system in ``/proc/device-tree/``
+or ``/sys/firmware/devicetree/base``.
-- 
2.30.2




^ permalink raw reply related

* Re: [PATCH] Documentation: devicetree: list automatic boot argument fixups
From: Ahmad Fatoum @ 2023-03-17 11:15 UTC (permalink / raw)
  To: Johannes Zink, barebox; +Cc: afa, jzi
In-Reply-To: <20230317110748.835678-1-j.zink@pengutronix.de>

Hello Johannes,

Thanks for documenting this. Some minor suggestions below.

On 17.03.23 12:07, Johannes Zink wrote:
> Barebox automatically fixes up several entries to the root and

s/entries/properties/

> chosen-node of the devicetree passed to the booted system.

chosen node, device tree

> 
> These entries contain information about the hardware, reset source
> and the barebox version string.
> 
> Add documentation on how to query these information from the booted
> linux system.
> 
> Signed-off-by: Johannes Zink <j.zink@pengutronix.de>
> ---
>  Documentation/devicetree/index.rst | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/Documentation/devicetree/index.rst b/Documentation/devicetree/index.rst
> index 36fa69058d1d..92a91dc35a11 100644
> --- a/Documentation/devicetree/index.rst
> +++ b/Documentation/devicetree/index.rst
> @@ -151,3 +151,24 @@ Contents:
>     bindings/regulator/*
>     bindings/rtc/*
>     bindings/watchdog/*
> +
> +automatic boot argument fixups to the devicetree

Title case or at least a capital letter at the beginning?

> +------------------------------------------------
> +
> +Barebox automatically fixes up some arguments in the devicetree.

s/Barebox/barebox/, s/devicetree/device tree/, s/arguments/properties/
or information.

> +
> +In the devicetree root barebox fixes up

, barebox

> +
> + * serial-number (if available)
> + * machine compatible (if available)

s/available/overridden/
There's nearly always a machine compatible.

> +
> +In the ``chosen``-node barebox fixes up

, barebox

> +
> + * barebox-version
> + * reset-source
> + * reset-source-instance (if available)
> + * reset-source-device (phandle, only if available)

node path, not the numeric phandle, compare

 property = &path -> "/path/to/something"

vs.

 property = <&path> -> <0x23>, with &path { phandle = <0x23>; }

> + * bootsource
> + * boot-hartid (only on RISCV)

RISC-V

> +
> +These values can be read from the booted linux system in ``/proc/device-tree/`

"or /sys/firmware/devicetree/base".


Thanks,
Ahmad

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox