input: qcom-hv-haptics: update HW type detection logic
Currently, hw_type is used before it's been set when reading revision registers, correct it. Change-Id: Ic543d8d059492c6a6f656194319e49d2b1eba90e Signed-off-by: Hui Liu <quic_huliu@quicinc.com>
This commit is contained in:
@@ -4425,6 +4425,20 @@ static int haptics_get_revision(struct haptics_chip *chip)
|
||||
|
||||
chip->ptn_revision = val[0];
|
||||
|
||||
if ((chip->cfg_revision == HAP_CFG_V2) &&
|
||||
(chip->ptn_revision == HAP_PTN_V2)) {
|
||||
chip->hw_type = HAP520;
|
||||
} else if ((chip->cfg_revision == HAP_CFG_V3) &&
|
||||
(chip->ptn_revision == HAP_PTN_V3)) {
|
||||
chip->hw_type = HAP520_MV;
|
||||
} else if ((chip->cfg_revision == HAP_CFG_V4) &&
|
||||
(chip->ptn_revision == HAP_PTN_V4)) {
|
||||
chip->hw_type = HAP525_HV;
|
||||
} else {
|
||||
dev_err(chip->dev, "haptics revision is not supported\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
if (is_haptics_external_powered(chip)) {
|
||||
dev_info(chip->dev, "haptics revision: HAP_CFG %#x, HAP_PTN %#x\n",
|
||||
chip->cfg_revision, chip->ptn_revision);
|
||||
@@ -4440,20 +4454,6 @@ static int haptics_get_revision(struct haptics_chip *chip)
|
||||
|
||||
}
|
||||
|
||||
if ((chip->cfg_revision == HAP_CFG_V2) &&
|
||||
(chip->ptn_revision == HAP_PTN_V2)) {
|
||||
chip->hw_type = HAP520;
|
||||
} else if ((chip->cfg_revision == HAP_CFG_V3) &&
|
||||
(chip->ptn_revision == HAP_PTN_V3)) {
|
||||
chip->hw_type = HAP520_MV;
|
||||
} else if ((chip->cfg_revision == HAP_CFG_V4) &&
|
||||
(chip->ptn_revision == HAP_PTN_V4)) {
|
||||
chip->hw_type = HAP525_HV;
|
||||
} else {
|
||||
dev_err(chip->dev, "haptics revision is not supported\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4540,16 +4540,22 @@ static int haptics_parse_dt(struct haptics_chip *chip)
|
||||
rc = -EINVAL;
|
||||
goto free_pbs;
|
||||
}
|
||||
|
||||
chip->cfg_addr_base = be32_to_cpu(*addr);
|
||||
|
||||
addr = of_get_address(node, 1, NULL, NULL);
|
||||
if (!addr) {
|
||||
dev_err(chip->dev, "Read HAPTICS_PATTERN address failed\n");
|
||||
rc = -EINVAL;
|
||||
goto free_pbs;
|
||||
}
|
||||
|
||||
chip->ptn_addr_base = be32_to_cpu(*addr);
|
||||
|
||||
rc = haptics_get_revision(chip);
|
||||
if (rc < 0) {
|
||||
dev_err(chip->dev, "Get revision failed, rc=%d\n", rc);
|
||||
goto free_pbs;
|
||||
}
|
||||
|
||||
addr = of_get_address(node, 2, NULL, NULL);
|
||||
if (!addr && !is_haptics_external_powered(chip)) {
|
||||
dev_err(chip->dev, "Read HAPTICS_HBOOST address failed\n");
|
||||
@@ -4559,12 +4565,6 @@ static int haptics_parse_dt(struct haptics_chip *chip)
|
||||
chip->hbst_addr_base = be32_to_cpu(*addr);
|
||||
}
|
||||
|
||||
rc = haptics_get_revision(chip);
|
||||
if (rc < 0) {
|
||||
dev_err(chip->dev, "Get revision failed, rc=%d\n", rc);
|
||||
goto free_pbs;
|
||||
}
|
||||
|
||||
chip->fifo_empty_irq = platform_get_irq_byname(pdev, "fifo-empty");
|
||||
if (!chip->fifo_empty_irq) {
|
||||
dev_err(chip->dev, "Get fifo-empty IRQ failed\n");
|
||||
|
||||
Reference in New Issue
Block a user