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

Commit 3ea36b2e authored by Sagar Dharia's avatar Sagar Dharia Committed by Naveen Kaje
Browse files

slimbus: Add support to specify port config and options



Client should be able to specify port configuration if it differs
from the default configuration

Change-Id: Iecc019de0b10c6931f5c1e521efd4f6fee178fe9
Signed-off-by: default avatarSagar Dharia <sdharia@codeaurora.org>
parent 090e59ba
Loading
Loading
Loading
Loading
+40 −2
Original line number Diff line number Diff line
@@ -1278,6 +1278,39 @@ int slim_dealloc_mgrports(struct slim_device *sb, u32 *hdl, int nports)
}
EXPORT_SYMBOL_GPL(slim_dealloc_mgrports);

/*
 * slim_config_mgrports: Configure manager side ports
 * @sb: device/client handle.
 * @ph: array of port handles for which this configuration is valid
 * @nports: Number of ports in ph
 * @cfg: configuration requested for port(s)
 * Configure port settings if they are different than the default ones.
 * Returns success if the config could be applied. Returns -EISCONN if the
 * port is in use
 */
int slim_config_mgrports(struct slim_device *sb, u32 *ph, int nports,
				struct slim_port_cfg *cfg)
{
	int i;
	struct slim_controller *ctrl;

	if (!sb || !ph || !nports || !sb->ctrl || !cfg)
		return -EINVAL;

	ctrl = sb->ctrl;
	mutex_lock(&ctrl->sched.m_reconf);
	for (i = 0; i < nports; i++) {
		u8 pn = SLIM_HDL_TO_PORT(ph[i]);

		if (ctrl->ports[pn].state == SLIM_P_CFG)
			return -EISCONN;
		ctrl->ports[pn].cfg = *cfg;
	}
	mutex_unlock(&ctrl->sched.m_reconf);
	return 0;
}
EXPORT_SYMBOL(slim_config_mgrports);

/*
 * slim_get_slaveport: Get slave port handle
 * @la: slave device logical address.
@@ -1644,8 +1677,13 @@ static int slim_remove_ch(struct slim_controller *ctrl, struct slim_ich *slc)

	ph = slc->srch;
	la = SLIM_HDL_TO_LA(ph);
	if (la == SLIM_LA_MANAGER)
		ctrl->ports[SLIM_HDL_TO_PORT(ph)].state = SLIM_P_UNCFG;
	if (la == SLIM_LA_MANAGER) {
		u8 pn = SLIM_HDL_TO_PORT(ph);

		ctrl->ports[pn].state = SLIM_P_UNCFG;
		ctrl->ports[pn].cfg.watermark = 0;
		ctrl->ports[pn].cfg.port_opts = 0;
	}

	kfree(slc->sinkh);
	slc->sinkh = NULL;
+30 −7
Original line number Diff line number Diff line
@@ -226,13 +226,13 @@ enum slim_port_req {
};

/*
 * enum slim_port_cfg: Port configuration parameters requested.
 * User can request no configuration, packed data, or MSB aligned data port
 * enum slim_port_opts: Port options requested.
 * User can request no configuration, packed data, and/or MSB aligned data port
 */
enum slim_port_cfg {
	SLIM_CFG_NONE,
	SLIM_CFG_PACKED,
	SLIM_CFG_ALIGN_MSB,
enum slim_port_opts {
	SLIM_OPT_NONE = 0,
	SLIM_OPT_NO_PACK = 1U,
	SLIM_OPT_ALIGN_MSB = 1U << 1,
};

/* enum slim_port_flow: Port flow type (inbound/outbound). */
@@ -250,6 +250,16 @@ enum slim_port_err {
	SLIM_P_NOT_OWNED,
};

/*
 * struct slim_port_cfg: Port config for the manager port
 * port_opts: port options (bit-map) for this port
 * watermark: watermark level set for this port
 */
struct slim_port_cfg {
	u32 port_opts;
	u32 watermark;
};

/*
 * struct slim_port: Internal structure used by framework to manage ports
 * @err: Port error if any for this port. Refer to enum above.
@@ -267,7 +277,7 @@ struct slim_port {
	enum slim_port_err	err;
	enum slim_port_state	state;
	enum slim_port_req	req;
	enum slim_port_cfg	cfg;
	struct slim_port_cfg	cfg;
	enum slim_port_flow	flow;
	struct slim_ch		*ch;
	struct completion	*xcomp;
@@ -834,6 +844,19 @@ extern int slim_alloc_mgrports(struct slim_device *sb, enum slim_port_req req,
/* Deallocate the port(s) allocated using the API above */
extern int slim_dealloc_mgrports(struct slim_device *sb, u32 *hdl, int hsz);

/*
 * slim_config_mgrports: Configure manager side ports
 * @sb: device/client handle.
 * @ph: array of port handles for which this configuration is valid
 * @nports: Number of ports in ph
 * @cfg: configuration requested for port(s)
 * Configure port settings if they are different than the default ones.
 * Returns success if the config could be applied. Returns -EISCONN if the
 * port is in use
 */
extern int slim_config_mgrports(struct slim_device *sb, u32 *ph, int nports,
				struct slim_port_cfg *cfg);

/*
 * slim_port_xfer: Schedule buffer to be transferred/received using port-handle.
 * @sb: client handle