示例#1
0
/**
 * arasan_zynqmp_dll_reset - Issue the DLL reset.
 * @deviceid:		Unique Id of device
 */
void zynqmp_dll_reset(u8 deviceid)
{
	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();

	if (!eemi_ops->ioctl)
		return;

	/* Issue DLL Reset */
	if (deviceid == 0)
		eemi_ops->ioctl(NODE_SD_0, IOCTL_SD_DLL_RESET,
			       PM_DLL_RESET_PULSE, 0, NULL);
	else
		eemi_ops->ioctl(NODE_SD_1, IOCTL_SD_DLL_RESET,
			       PM_DLL_RESET_PULSE, 0, NULL);
}
示例#2
0
static ssize_t read_register(char *buf, u32 ioctl_id, u32 reg)
{
	int ret;
	u32 ret_payload[PAYLOAD_ARG_CNT];
	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();

	if (!eemi_ops->ioctl)
		return -EFAULT;

	ret = eemi_ops->ioctl(0, ioctl_id, reg, 0, ret_payload);
	if (ret)
		return ret;

	return sprintf(buf, "0x%x\n", ret_payload[1]);
}
示例#3
0
/*
 * zynqmp_clk_gate_disable - Disable clock
 * @hw: handle between common and hardware-specific interfaces
 */
static void zynqmp_clk_gate_disable(struct clk_hw *hw)
{
	struct zynqmp_clk_gate *gate = to_zynqmp_clk_gate(hw);
	const char *clk_name = clk_hw_get_name(hw);
	u32 clk_id = gate->clk_id;
	int ret = 0;
	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();

	if (!eemi_ops || !eemi_ops->clock_disable)
		return;

	ret = eemi_ops->clock_disable(clk_id);

	if (ret)
		pr_warn_once("%s() clock disable failed for %s, ret = %d\n",
			     __func__, clk_name, ret);
}
示例#4
0
/**
 * zynqmp_clk_gate_is_enable - Check clock state
 * @hw: handle between common and hardware-specific interfaces
 *
 * Return: 1 if enabled, 0 if disabled
 */
static int zynqmp_clk_gate_is_enabled(struct clk_hw *hw)
{
	struct zynqmp_clk_gate *gate = to_zynqmp_clk_gate(hw);
	const char *clk_name = clk_hw_get_name(hw);
	u32 clk_id = gate->clk_id;
	int state, ret;
	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();

	if (!eemi_ops || !eemi_ops->clock_getstate)
		return 0;

	ret = eemi_ops->clock_getstate(clk_id, &state);
	if (ret)
		pr_warn_once("%s() clock get state failed for %s, ret = %d\n",
			     __func__, clk_name, ret);

	return state ? 1 : 0;
}
示例#5
0
/**
 * arasan_zynqmp_set_tap_delay - Program the tap delays.
 * @deviceid:		Unique Id of device
 * @itap_delay:		Input Tap Delay
 * @oitap_delay:	Output Tap Delay
 */
void arasan_zynqmp_set_tap_delay(u8 deviceid, u8 itap_delay, u8 otap_delay)
{
	u32 node_id = (deviceid == 0) ? NODE_SD_0 : NODE_SD_1;
	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();

	if (!eemi_ops->ioctl)
		return;

	/* Set the Input Tap Delay */
	if (itap_delay)
		eemi_ops->ioctl(node_id, IOCTL_SET_SD_TAPDELAY,
				PM_TAPDELAY_INPUT, itap_delay, NULL);

	/* Set the Output Tap Delay */
	if (otap_delay)
		eemi_ops->ioctl(node_id, IOCTL_SET_SD_TAPDELAY,
				PM_TAPDELAY_OUTPUT, otap_delay, NULL);
}
示例#6
0
static ssize_t write_register(const char *buf, size_t count, u32 read_ioctl,
			      u32 write_ioctl, u32 reg)
{
	char *kern_buff, *inbuf, *tok;
	long mask, value;
	int ret;
	u32 ret_payload[PAYLOAD_ARG_CNT];
	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();

	if (!eemi_ops->ioctl)
		return -EFAULT;

	kern_buff = kzalloc(count, GFP_KERNEL);
	if (!kern_buff)
		return -ENOMEM;

	ret = strlcpy(kern_buff, buf, count);
	if (ret < 0) {
		ret = -EFAULT;
		goto err;
	}

	inbuf = kern_buff;

	/* Read the write mask */
	tok = strsep(&inbuf, " ");
	if (!tok) {
		ret = -EFAULT;
		goto err;
	}

	ret = kstrtol(tok, 16, &mask);
	if (ret) {
		ret = -EFAULT;
		goto err;
	}

	/* Read the write value */
	tok = strsep(&inbuf, " ");
	if (!tok) {
		ret = -EFAULT;
		goto err;
	}

	ret = kstrtol(tok, 16, &value);
	if (ret) {
		ret = -EFAULT;
		goto err;
	}

	ret = eemi_ops->ioctl(0, read_ioctl, reg, 0, ret_payload);
	if (ret) {
		ret = -EFAULT;
		goto err;
	}
	ret_payload[1] &= ~mask;
	value &= mask;
	value |= ret_payload[1];

	ret = eemi_ops->ioctl(0, write_ioctl, reg, value, NULL);
	if (ret)
		ret = -EFAULT;

err:
	kfree(kern_buff);
	if (ret)
		return ret;

	return count;
}