Ejemplo n.º 1
0
static enum MHI_STATUS mhi_create_ctxt(struct mhi_device_ctxt *mhi_dev_ctxt)
{
	int i;
	if (NULL == mhi_dev_ctxt)
		return MHI_STATUS_ALLOC_ERROR;
	mhi_dev_ctxt->mhi_state = MHI_STATE_RESET;
	mhi_dev_ctxt->nr_of_cc = MHI_MAX_CHANNELS;
	mhi_dev_ctxt->nr_of_ec = EVENT_RINGS_ALLOCATED;
	mhi_dev_ctxt->nr_of_cmdc = NR_OF_CMD_RINGS;

	mhi_dev_ctxt->alloced_ev_rings[PRIMARY_EVENT_RING] = 0;
	mhi_dev_ctxt->alloced_ev_rings[SOFTWARE_EV_RING] =
						SOFTWARE_EV_RING;
	mhi_dev_ctxt->alloced_ev_rings[IPA_OUT_EV_RING] =
						MHI_CLIENT_IP_HW_0_OUT;
	mhi_dev_ctxt->alloced_ev_rings[IPA_IN_EV_RING] =
						MHI_CLIENT_IP_HW_0_IN;
	MHI_SET_EVENT_RING_INFO(EVENT_RING_POLLING,
			mhi_dev_ctxt->ev_ring_props[PRIMARY_EVENT_RING],
			MHI_EVENT_POLLING_ENABLED);
	MHI_SET_EVENT_RING_INFO(EVENT_RING_POLLING,
			mhi_dev_ctxt->ev_ring_props[SOFTWARE_EV_RING],
			MHI_EVENT_POLLING_ENABLED);
	MHI_SET_EVENT_RING_INFO(EVENT_RING_POLLING,
			mhi_dev_ctxt->ev_ring_props[IPA_OUT_EV_RING],
			MHI_EVENT_POLLING_ENABLED);
	MHI_SET_EVENT_RING_INFO(EVENT_RING_POLLING,
			mhi_dev_ctxt->ev_ring_props[IPA_IN_EV_RING],
			MHI_EVENT_POLLING_DISABLED);

	for (i = 0; i < MAX_NR_MSI; ++i) {
		MHI_SET_EVENT_RING_INFO(EVENT_RING_MSI_VEC,
				mhi_dev_ctxt->ev_ring_props[i],
				i);
	}
	return MHI_STATUS_SUCCESS;
}
Ejemplo n.º 2
0
/**
 * @brief Add elements to event ring for the device to use
 *
 * @param mhi device context
 *
 * @return MHI_STATUS
 */
MHI_STATUS mhi_add_elements_to_event_rings(mhi_device_ctxt *mhi_dev_ctxt,
					STATE_TRANSITION new_state)
{
	MHI_STATUS ret_val = MHI_STATUS_SUCCESS;
	MHI_EVENT_RING_STATE event_ring_state = MHI_EVENT_RING_UINIT;
	switch (new_state) {
	case STATE_TRANSITION_READY:
		MHI_GET_EVENT_RING_INFO(EVENT_RING_STATE_FIELD,
				mhi_dev_ctxt->ev_ring_props[PRIMARY_EVENT_RING],
				event_ring_state);
		if (MHI_EVENT_RING_UINIT == event_ring_state) {
		ret_val = mhi_init_event_ring(mhi_dev_ctxt,
			   EV_EL_PER_RING,
			   mhi_dev_ctxt->alloced_ev_rings[PRIMARY_EVENT_RING]);
		if (MHI_STATUS_SUCCESS != ret_val) {

			mhi_log(MHI_MSG_ERROR,
				"Failed to add ev el on event ring\n");
			return MHI_STATUS_ERROR;
			}
			MHI_SET_EVENT_RING_INFO(EVENT_RING_STATE_FIELD,
				mhi_dev_ctxt->ev_ring_props[PRIMARY_EVENT_RING],
				MHI_EVENT_RING_INIT);
		}
		mhi_log(MHI_MSG_ERROR,
			"Event ring initialized ringing, EV DB to resume\n");
		ring_ev_db(mhi_dev_ctxt,
			mhi_dev_ctxt->alloced_ev_rings[PRIMARY_EVENT_RING]);
		break;
	case STATE_TRANSITION_AMSS:
		MHI_GET_EVENT_RING_INFO(EVENT_RING_STATE_FIELD,
				mhi_dev_ctxt->ev_ring_props[IPA_OUT_EV_RING],
				event_ring_state);
		if (MHI_EVENT_RING_UINIT == event_ring_state) {
		ret_val = mhi_init_event_ring(mhi_dev_ctxt,
			 EV_EL_PER_RING,
			 mhi_dev_ctxt->alloced_ev_rings[IPA_OUT_EV_RING]);
		if (MHI_STATUS_SUCCESS != ret_val) {

			mhi_log(MHI_MSG_ERROR,
				"Failed to add ev el on event ring\n");
			return MHI_STATUS_ERROR;
		}
		ret_val = mhi_init_event_ring(mhi_dev_ctxt,
			  EV_EL_PER_RING,
			  mhi_dev_ctxt->alloced_ev_rings[IPA_IN_EV_RING]);
		if (MHI_STATUS_SUCCESS != ret_val) {
			mhi_log(MHI_MSG_ERROR,
				"Failed to add ev el on event ring\n");
			return MHI_STATUS_ERROR;
		}
		MHI_SET_EVENT_RING_INFO(EVENT_RING_STATE_FIELD,
				mhi_dev_ctxt->ev_ring_props[IPA_OUT_EV_RING],
				MHI_EVENT_RING_INIT);
		MHI_SET_EVENT_RING_INFO(EVENT_RING_STATE_FIELD,
				mhi_dev_ctxt->ev_ring_props[IPA_IN_EV_RING],
				MHI_EVENT_RING_INIT);
		}
		ring_ev_db(mhi_dev_ctxt,
			mhi_dev_ctxt->alloced_ev_rings[SOFTWARE_EV_RING]);
		ring_ev_db(mhi_dev_ctxt,
			mhi_dev_ctxt->alloced_ev_rings[IPA_OUT_EV_RING]);
		ring_ev_db(mhi_dev_ctxt,
			mhi_dev_ctxt->alloced_ev_rings[IPA_IN_EV_RING]);
	break;
	default:
		mhi_log(MHI_MSG_ERROR,
			"Unrecognized event stage, %d\n", new_state);
		ret_val = MHI_STATUS_ERROR;
		break;
	}
	return ret_val;
}