// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2010-2015, The Linux Foundation. All rights reserved.
*/
#include "hdmi.h"
#include <linux/qcom_scm.h>
#define HDCP_REG_ENABLE 0x01
#define HDCP_REG_DISABLE 0x00
#define HDCP_PORT_ADDR 0x74
#define HDCP_INT_STATUS_MASK ( \
HDMI_HDCP_INT_CTRL_AUTH_SUCCESS_INT | \
HDMI_HDCP_INT_CTRL_AUTH_FAIL_INT | \
HDMI_HDCP_INT_CTRL_AUTH_XFER_REQ_INT | \
HDMI_HDCP_INT_CTRL_AUTH_XFER_DONE_INT)
#define AUTH_WORK_RETRIES_TIME 100
#define AUTH_RETRIES_TIME 30
/* QFPROM Registers for HDMI/HDCP */
#define QFPROM_RAW_FEAT_CONFIG_ROW0_LSB 0x000000F8
#define QFPROM_RAW_FEAT_CONFIG_ROW0_MSB 0x000000FC
#define HDCP_KSV_LSB 0x000060D8
#define HDCP_KSV_MSB 0x000060DC
enum DS_TYPE { /* type of downstream device */
DS_UNKNOWN,
DS_RECEIVER,
DS_REPEATER,
};
enum hdmi_hdcp_state {
HDCP_STATE_NO_AKSV,
HDCP_STATE_INACTIVE,
HDCP_STATE_AUTHENTICATING,
HDCP_STATE_AUTHENTICATED,
HDCP_STATE_AUTH_FAILED
};
struct hdmi_hdcp_reg_data {
u32 reg_id;
u32 off;
char *name;
u32 reg_val;
};
struct hdmi_hdcp_ctrl {
struct hdmi *hdmi;
u32 auth_retries;
bool tz_hdcp;
enum hdmi_hdcp_state hdcp_state;
struct work_struct hdcp_auth_work;
struct work_struct hdcp_reauth_work;
#define AUTH_ABORT_EV 1
#define AUTH_RESULT_RDY_EV 2
unsigned long auth_event;
wait_queue_head_t auth_event_queue;
u32 ksv_fifo_w_index;
/*
* store aksv from qfprom
*/
u32 aksv_lsb;
u32 aksv_msb;
bool aksv_valid;
u32 ds_type;
u32 bksv_lsb;
u32 bksv_msb;
u8 dev_count;
u8 depth;
u8 ksv_list[5 * 127];
bool max_cascade_exceeded;
bool max_dev_exceeded;
};
static int msm_hdmi_ddc_read(struct hdmi *hdmi, u16 addr, u8 offset,
u8 *data, u16