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

Commit dc8d1194 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: fd: Support dynamic update of clock and bus settings"

parents dc590bb0 d8b57dc0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -252,6 +252,7 @@ struct msm_fd_device {
	struct work_struct work;
	struct completion hw_halt_completion;
	int recovery_mode;
	uint32_t clk_rate_idx;
};

#endif /* __MSM_FD_DEV_H__ */
+45 −0
Original line number Diff line number Diff line
@@ -822,6 +822,45 @@ static int msm_fd_hw_set_clock_rate_idx(struct msm_fd_device *fd,

	return 0;
}

/**
 * msm_fd_hw_update_settings() - API to set clock rate and bus settings
 * @fd: Pointer to fd device.
 * @buf: fd buffer
 */
static int msm_fd_hw_update_settings(struct msm_fd_device *fd,
				struct msm_fd_buffer *buf)
{
	int ret = 0;
	uint32_t clk_rate_idx;

	if (!buf)
		return 0;

	clk_rate_idx = buf->settings.speed;
	if (fd->clk_rate_idx == clk_rate_idx)
		return 0;

	if (fd->bus_client) {
		ret = msm_fd_hw_bus_request(fd, clk_rate_idx);
		if (ret < 0) {
			dev_err(fd->dev, "Fail bus scale update %d\n", ret);
			return -EINVAL;
		}
	}

	ret = msm_fd_hw_set_clock_rate_idx(fd, clk_rate_idx);
	if (ret < 0) {
		dev_err(fd->dev, "Fail to set clock rate idx\n");
		goto end;
	}
	dev_dbg(fd->dev, "set clk %d %d", fd->clk_rate_idx, clk_rate_idx);
	fd->clk_rate_idx = clk_rate_idx;

end:
	return ret;
}

/*
 * msm_fd_hw_get - Get fd hw for performing any hw operation.
 * @fd: Pointer to fd device.
@@ -868,6 +907,8 @@ int msm_fd_hw_get(struct msm_fd_device *fd, unsigned int clock_rate_idx)
		ret = msm_fd_hw_set_dt_parms(fd);
		if (ret < 0)
			goto error_set_dt;

		fd->clk_rate_idx = clock_rate_idx;
	}

	fd->ref_count++;
@@ -1228,6 +1269,8 @@ int msm_fd_hw_schedule_and_start(struct msm_fd_device *fd)

	spin_unlock(&fd->slock);

	msm_fd_hw_update_settings(fd, buf);

	return 0;
}

@@ -1266,5 +1309,7 @@ int msm_fd_hw_schedule_next_buffer(struct msm_fd_device *fd)
	}
	spin_unlock(&fd->slock);

	msm_fd_hw_update_settings(fd, buf);

	return 0;
}