Skip to content

Commit 6296562

Browse files
basuamdJiri Kosina
authored andcommitted
HID: amd_sfh: Extend MP2 register access to SFH
Various MP2 register sets are supported by newer processors. Therefore, extend MP2 register access to SFH. Signed-off-by: Basavaraj Natikar <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 2105e8e commit 6296562

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

drivers/hid/amd-sfh-hid/amd_sfh_common.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4))
2020
#define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4))
2121

22+
#define AMD_C2P_MSG_V1(regno) (0x10900 + ((regno) * 4))
23+
#define AMD_P2C_MSG_V1(regno) (0x10500 + ((regno) * 4))
24+
2225
#define SENSOR_ENABLED 4
2326
#define SENSOR_DISABLED 5
2427

@@ -55,6 +58,7 @@ struct amd_mp2_dev {
5558
struct sfh_dev_status dev_en;
5659
struct work_struct work;
5760
u8 init_done;
61+
u8 rver;
5862
};
5963

6064
struct amd_mp2_ops {
@@ -81,4 +85,14 @@ void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata);
8185
int amd_sfh_irq_init_v2(struct amd_mp2_dev *privdata);
8286
void amd_sfh_clear_intr(struct amd_mp2_dev *privdata);
8387
int amd_sfh_irq_init(struct amd_mp2_dev *privdata);
88+
89+
static inline u64 amd_get_c2p_val(struct amd_mp2_dev *mp2, u32 idx)
90+
{
91+
return mp2->rver == 1 ? AMD_C2P_MSG_V1(idx) : AMD_C2P_MSG(idx);
92+
}
93+
94+
static inline u64 amd_get_p2c_val(struct amd_mp2_dev *mp2, u32 idx)
95+
{
96+
return mp2->rver == 1 ? AMD_P2C_MSG_V1(idx) : AMD_P2C_MSG(idx);
97+
}
8498
#endif

drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ static void amd_stop_all_sensor_v2(struct amd_mp2_dev *privdata)
9999

100100
void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata)
101101
{
102-
if (readl(privdata->mmio + AMD_P2C_MSG(4))) {
103-
writel(0, privdata->mmio + AMD_P2C_MSG(4));
104-
writel(0xf, privdata->mmio + AMD_P2C_MSG(5));
102+
if (readl(privdata->mmio + amd_get_p2c_val(privdata, 4))) {
103+
writel(0, privdata->mmio + amd_get_p2c_val(privdata, 4));
104+
writel(0xf, privdata->mmio + amd_get_p2c_val(privdata, 5));
105105
}
106106
}
107107

@@ -410,6 +410,9 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
410410

411411
privdata->sfh1_1_ops = (const struct amd_sfh1_1_ops *)id->driver_data;
412412
if (privdata->sfh1_1_ops) {
413+
if (boot_cpu_data.x86 >= 0x1A)
414+
privdata->rver = 1;
415+
413416
rc = devm_work_autocancel(&pdev->dev, &privdata->work, sfh1_1_init_work);
414417
if (rc)
415418
return rc;

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
251251
break;
252252
case HPD_IDX:
253253
get_common_inputs(&hpd_input.common_property, report_id);
254-
hpdstatus.val = readl(mp2->mmio + AMD_C2P_MSG(4));
254+
hpdstatus.val = readl(mp2->mmio + amd_get_c2p_val(mp2, 4));
255255
hpd_input.human_presence = hpdstatus.shpd.presence;
256256
report_size = sizeof(hpd_input);
257257
memcpy(input_report, &hpd_input, sizeof(hpd_input));

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
172172
if (rc)
173173
goto cleanup;
174174

175-
writel(0, privdata->mmio + AMD_P2C_MSG(0));
175+
writel(0, privdata->mmio + amd_get_p2c_val(privdata, 0));
176176
mp2_ops->start(privdata, info);
177177
status = amd_sfh_wait_for_response
178178
(privdata, cl_data->sensor_idx[i], ENABLE_SENSOR);
@@ -298,7 +298,7 @@ static void amd_sfh_set_ops(struct amd_mp2_dev *mp2)
298298

299299
int amd_sfh1_1_init(struct amd_mp2_dev *mp2)
300300
{
301-
u32 phy_base = readl(mp2->mmio + AMD_C2P_MSG(22));
301+
u32 phy_base = readl(mp2->mmio + amd_get_c2p_val(mp2, 22));
302302
struct device *dev = &mp2->pdev->dev;
303303
struct sfh_base_info binfo;
304304
int rc;

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static int amd_sfh_wait_response(struct amd_mp2_dev *mp2, u8 sid, u32 cmd_id)
2020
struct sfh_cmd_response cmd_resp;
2121

2222
/* Get response with status within a max of 10000 ms timeout */
23-
if (!readl_poll_timeout(mp2->mmio + AMD_P2C_MSG(0), cmd_resp.resp,
23+
if (!readl_poll_timeout(mp2->mmio + amd_get_p2c_val(mp2, 0), cmd_resp.resp,
2424
(cmd_resp.response.response == 0 &&
2525
cmd_resp.response.cmd_id == cmd_id && (sid == 0xff ||
2626
cmd_resp.response.sensor_id == sid)), 500, 10000000))
@@ -39,7 +39,7 @@ static void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor
3939
cmd_base.cmd.sub_cmd_value = 1;
4040
cmd_base.cmd.sensor_id = info.sensor_idx;
4141

42-
writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG(0));
42+
writel(cmd_base.ul, privdata->mmio + amd_get_c2p_val(privdata, 0));
4343
}
4444

4545
static void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx)
@@ -52,8 +52,8 @@ static void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx)
5252
cmd_base.cmd.sub_cmd_value = 1;
5353
cmd_base.cmd.sensor_id = sensor_idx;
5454

55-
writeq(0x0, privdata->mmio + AMD_C2P_MSG(1));
56-
writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG(0));
55+
writeq(0x0, privdata->mmio + amd_get_c2p_val(privdata, 1));
56+
writel(cmd_base.ul, privdata->mmio + amd_get_c2p_val(privdata, 0));
5757
}
5858

5959
static void amd_stop_all_sensor(struct amd_mp2_dev *privdata)
@@ -66,7 +66,7 @@ static void amd_stop_all_sensor(struct amd_mp2_dev *privdata)
6666
/* 0xf indicates all sensors */
6767
cmd_base.cmd.sensor_id = 0xf;
6868

69-
writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG(0));
69+
writel(cmd_base.ul, privdata->mmio + amd_get_c2p_val(privdata, 0));
7070
}
7171

7272
static struct amd_mp2_ops amd_sfh_ops = {

0 commit comments

Comments
 (0)