2024-01-26 01:22:37 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QCOM_PHY_QMP_COMMON_H_
|
|
|
|
#define QCOM_PHY_QMP_COMMON_H_
|
|
|
|
|
|
|
|
struct qmp_phy_init_tbl {
|
|
|
|
unsigned int offset;
|
|
|
|
unsigned int val;
|
2024-07-31 20:55:48 +05:30
|
|
|
char *name;
|
2024-01-26 01:22:37 +02:00
|
|
|
/*
|
|
|
|
* mask of lanes for which this register is written
|
|
|
|
* for cases when second lane needs different values
|
|
|
|
*/
|
|
|
|
u8 lane_mask;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define QMP_PHY_INIT_CFG(o, v) \
|
|
|
|
{ \
|
|
|
|
.offset = o, \
|
|
|
|
.val = v, \
|
2024-07-31 20:55:48 +05:30
|
|
|
.name = #o, \
|
2024-01-26 01:22:37 +02:00
|
|
|
.lane_mask = 0xff, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define QMP_PHY_INIT_CFG_LANE(o, v, l) \
|
|
|
|
{ \
|
|
|
|
.offset = o, \
|
|
|
|
.val = v, \
|
2024-07-31 20:55:48 +05:30
|
|
|
.name = #o, \
|
2024-01-26 01:22:37 +02:00
|
|
|
.lane_mask = l, \
|
|
|
|
}
|
|
|
|
|
2024-07-31 20:55:48 +05:30
|
|
|
static inline void qmp_configure_lane(struct device *dev, void __iomem *base,
|
|
|
|
const struct qmp_phy_init_tbl tbl[],
|
|
|
|
int num, u8 lane_mask)
|
2024-01-26 01:22:37 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const struct qmp_phy_init_tbl *t = tbl;
|
|
|
|
|
|
|
|
if (!t)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < num; i++, t++) {
|
|
|
|
if (!(t->lane_mask & lane_mask))
|
|
|
|
continue;
|
|
|
|
|
2024-07-31 20:55:48 +05:30
|
|
|
dev_dbg(dev, "Writing Reg: %s Offset: 0x%04x Val: 0x%02x\n",
|
|
|
|
t->name, t->offset, t->val);
|
2024-01-26 01:22:37 +02:00
|
|
|
writel(t->val, base + t->offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-31 20:55:48 +05:30
|
|
|
static inline void qmp_configure(struct device *dev, void __iomem *base,
|
|
|
|
const struct qmp_phy_init_tbl tbl[], int num)
|
2024-01-26 01:22:37 +02:00
|
|
|
{
|
2024-07-31 20:55:48 +05:30
|
|
|
qmp_configure_lane(dev, base, tbl, num, 0xff);
|
2024-01-26 01:22:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|