Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec199ccd authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman
Browse files

greybus: interface: clean up ES3-bootroom-quirk handling



Clean up handling of the ES3-bootrom quirks by adding an interface
quirk-flags field that is set appropriately when we detect that the ES3
bootrom is running.

Note that we need to reserve the DME_DIS_UNIPRO_BOOT_STARTED and
DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED status values for the ES3 bootrom,
which does not support any CPort features (unlike later boot stages).
Add a BOOTROM infix to the defines to make this more clear.

Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 133e366b
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -337,9 +337,12 @@ gb_connection_svc_connection_create(struct gb_connection *connection)


	intf = connection->intf;
	intf = connection->intf;


	/* The ES2/ES3 bootrom requires E2EFC, CSD and CSV to be disabled. */
	/*
	 * Enable either E2EFC or CSD, unless the interface does not support
	 * any CPort features.
	 */
	cport_flags = GB_SVC_CPORT_FLAG_CSV_N;
	cport_flags = GB_SVC_CPORT_FLAG_CSV_N;
	if (intf->boot_over_unipro) {
	if (intf->quirks & GB_INTERFACE_QUIRK_NO_CPORT_FEATURES) {
		cport_flags |= GB_SVC_CPORT_FLAG_CSD_N;
		cport_flags |= GB_SVC_CPORT_FLAG_CSD_N;
	} else if (gb_connection_e2efc_enabled(connection)) {
	} else if (gb_connection_e2efc_enabled(connection)) {
		cport_flags |= GB_SVC_CPORT_FLAG_CSD_N |
		cport_flags |= GB_SVC_CPORT_FLAG_CSD_N |
+1 −2
Original line number Original line Diff line number Diff line
@@ -155,8 +155,7 @@ int gb_control_get_interface_version_operation(struct gb_interface *intf)
	struct gb_connection *connection = intf->control->connection;
	struct gb_connection *connection = intf->control->connection;
	int ret;
	int ret;


	/* The ES3 bootrom fails to boot if this request it sent to it */
	if (intf->quirks & GB_INTERFACE_QUIRK_NO_INTERFACE_VERSION)
	if (intf->boot_over_unipro)
		return 0;
		return 0;


	ret = gb_operation_sync(connection, GB_CONTROL_TYPE_INTERFACE_VERSION,
	ret = gb_operation_sync(connection, GB_CONTROL_TYPE_INTERFACE_VERSION,
+5 −5
Original line number Original line Diff line number Diff line
@@ -897,8 +897,8 @@ struct gb_svc_dme_peer_set_response {
#define DME_DIS_SPI_BOOT_STARTED			0x02
#define DME_DIS_SPI_BOOT_STARTED			0x02
#define DME_DIS_TRUSTED_SPI_BOOT_FINISHED		0x03
#define DME_DIS_TRUSTED_SPI_BOOT_FINISHED		0x03
#define DME_DIS_UNTRUSTED_SPI_BOOT_FINISHED		0x04
#define DME_DIS_UNTRUSTED_SPI_BOOT_FINISHED		0x04
#define DME_DIS_UNIPRO_BOOT_STARTED		0x06
#define DME_DIS_BOOTROM_UNIPRO_BOOT_STARTED		0x06
#define DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED	0x09
#define DME_DIS_BOOTROM_FALLBACK_UNIPRO_BOOT_STARTED	0x09


struct gb_svc_route_create_request {
struct gb_svc_route_create_request {
	__u8	intf1_id;
	__u8	intf1_id;
+13 −4
Original line number Original line Diff line number Diff line
@@ -55,7 +55,7 @@ static int gb_interface_read_and_clear_init_status(struct gb_interface *intf)
	}
	}


	/*
	/*
	 * Check if the interface needs to boot over UniPro.
	 * Extract the init status.
	 *
	 *
	 * For ES2: We need to check lowest 8 bits of 'value'.
	 * For ES2: We need to check lowest 8 bits of 'value'.
	 * For ES3: We need to check highest 8 bits out of 32 of 'value'.
	 * For ES3: We need to check highest 8 bits out of 32 of 'value'.
@@ -67,9 +67,18 @@ static int gb_interface_read_and_clear_init_status(struct gb_interface *intf)
	else
	else
		init_status = value >> 24;
		init_status = value >> 24;


	if (init_status == DME_DIS_UNIPRO_BOOT_STARTED ||
	/*
			init_status == DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED)
	 * Check if the interface is executing the quirky ES3 bootrom that
		intf->boot_over_unipro = true;
	 * requires E2EFC, CSD and CSV to be disabled and that does not
	 * support the interface-version request.
	 */
	switch (init_status) {
	case DME_DIS_BOOTROM_UNIPRO_BOOT_STARTED:
	case DME_DIS_BOOTROM_FALLBACK_UNIPRO_BOOT_STARTED:
		intf->quirks |= GB_INTERFACE_QUIRK_NO_CPORT_FEATURES;
		intf->quirks |= GB_INTERFACE_QUIRK_NO_INTERFACE_VERSION;
		break;
	}


	/* Clear the init status. */
	/* Clear the init status. */
	return gb_svc_dme_peer_set(hd->svc, intf->interface_id, attr,
	return gb_svc_dme_peer_set(hd->svc, intf->interface_id, attr,
+5 −2
Original line number Original line Diff line number Diff line
@@ -10,6 +10,9 @@
#ifndef __INTERFACE_H
#ifndef __INTERFACE_H
#define __INTERFACE_H
#define __INTERFACE_H


#define GB_INTERFACE_QUIRK_NO_CPORT_FEATURES		BIT(0)
#define GB_INTERFACE_QUIRK_NO_INTERFACE_VERSION		BIT(1)

struct gb_interface {
struct gb_interface {
	struct device dev;
	struct device dev;
	struct gb_control *control;
	struct gb_control *control;
@@ -36,8 +39,8 @@ struct gb_interface {


	struct gb_host_device *hd;
	struct gb_host_device *hd;


	/* The interface needs to boot over unipro */
	unsigned long quirks;
	bool boot_over_unipro;

	bool disconnected;
	bool disconnected;
};
};
#define to_gb_interface(d) container_of(d, struct gb_interface, dev)
#define to_gb_interface(d) container_of(d, struct gb_interface, dev)