mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 03:27:03 +02:00
Merge "input: qcom-hv-haptics: update configuration for PATx_MEM mode"
This commit is contained in:
commit
57624c29c3
|
|
@ -140,6 +140,12 @@
|
|||
|
||||
#define HAP_CFG_DRV_DUTY_CFG_REG 0x60
|
||||
#define ADT_DRV_DUTY_EN_BIT BIT(7)
|
||||
#define ADT_BRK_DUTY_EN_BIT BIT(6)
|
||||
#define DRV_DUTY_MASK GENMASK(5, 3)
|
||||
#define DRV_DUTY_62P5_PCT 2
|
||||
#define DRV_DUTY_SHIFT 3
|
||||
#define BRK_DUTY_MASK GENMASK(2, 0)
|
||||
#define BRK_DUTY_75_PCT 6
|
||||
|
||||
#define HAP_CFG_ADT_DRV_DUTY_CFG_REG 0x61
|
||||
#define HAP_CFG_ZX_WIND_CFG_REG 0x62
|
||||
|
|
@ -149,6 +155,7 @@
|
|||
#define AUTORES_EN_DLY_MASK GENMASK(5, 2)
|
||||
#define AUTORES_EN_DLY(cycles) ((cycles) * 2)
|
||||
#define AUTORES_EN_DLY_6_CYCLES AUTORES_EN_DLY(6)
|
||||
#define AUTORES_EN_DLY_7_CYCLES AUTORES_EN_DLY(7)
|
||||
#define AUTORES_EN_DLY_SHIFT 2
|
||||
#define AUTORES_ERR_WINDOW_MASK GENMASK(1, 0)
|
||||
#define AUTORES_ERR_WINDOW_12P5_PERCENT 0x0
|
||||
|
|
@ -1837,7 +1844,10 @@ static int haptics_update_pat_mem_samples(struct haptics_chip *chip,
|
|||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
return haptics_update_memory_data(chip, samples, length);
|
||||
rc = haptics_update_memory_data(chip, samples, length);
|
||||
rc |= haptics_masked_write(chip, chip->ptn_addr_base,
|
||||
HAP_PTN_MEM_OP_ACCESS_REG, MEM_PAT_ACCESS_BIT, 0);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int haptics_get_fifo_fill_status(struct haptics_chip *chip, u32 *fill)
|
||||
|
|
@ -2175,6 +2185,11 @@ static int haptics_load_predefined_effect(struct haptics_chip *chip,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* disable auto resonance for PATx_MEM mode */
|
||||
rc = haptics_enable_autores(chip, false);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
dev_dbg(chip->dev, "Ignore loading data for preload FIFO effect: %d\n",
|
||||
play->effect->id);
|
||||
}
|
||||
|
|
@ -2410,9 +2425,6 @@ static int haptics_load_periodic_effect(struct haptics_chip *chip,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(chip->dev, "upload %s effect %d, vmax=%d\n", primitive ? "primitive" : "predefined",
|
||||
effects[i].id, play->vmax_mv);
|
||||
|
||||
mutex_lock(&chip->play.lock);
|
||||
if (chip->play.in_calibration) {
|
||||
dev_err(chip->dev, "calibration in progress, ignore playing predefined effect\n");
|
||||
|
|
@ -2421,6 +2433,9 @@ static int haptics_load_periodic_effect(struct haptics_chip *chip,
|
|||
}
|
||||
|
||||
play->vmax_mv = (magnitude * effects[i].vmax_mv) / 0x7fff;
|
||||
dev_dbg(chip->dev, "upload %s effect %d, vmax=%d\n", primitive ? "primitive" : "predefined",
|
||||
effects[i].id, play->vmax_mv);
|
||||
|
||||
rc = haptics_load_predefined_effect(chip, &effects[i]);
|
||||
if (rc < 0) {
|
||||
dev_err(chip->dev, "Play predefined effect%d failed, rc=%d\n",
|
||||
|
|
@ -5072,7 +5087,7 @@ static int haptics_detect_lra_impedance(struct haptics_chip *chip)
|
|||
static int haptics_detect_lra_frequency(struct haptics_chip *chip)
|
||||
{
|
||||
int rc;
|
||||
u8 autores_cfg, amplitude;
|
||||
u8 autores_cfg, drv_duty_cfg, amplitude, mask, val;
|
||||
u32 vmax_mv = chip->config.vmax_mv;
|
||||
|
||||
rc = haptics_read(chip, chip->cfg_addr_base,
|
||||
|
|
@ -5082,16 +5097,38 @@ static int haptics_detect_lra_frequency(struct haptics_chip *chip)
|
|||
return rc;
|
||||
}
|
||||
|
||||
rc = haptics_read(chip, chip->cfg_addr_base,
|
||||
HAP_CFG_DRV_DUTY_CFG_REG, &drv_duty_cfg, 1);
|
||||
if (rc < 0) {
|
||||
dev_err(chip->dev, "Read DRV_DUTY_CFG failed, rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (chip->hw_type == HAP525_HV)
|
||||
val = AUTORES_EN_DLY_7_CYCLES << AUTORES_EN_DLY_SHIFT|
|
||||
AUTORES_ERR_WINDOW_25_PERCENT | AUTORES_EN_BIT;
|
||||
else
|
||||
val = AUTORES_EN_DLY_6_CYCLES << AUTORES_EN_DLY_SHIFT|
|
||||
AUTORES_ERR_WINDOW_50_PERCENT | AUTORES_EN_BIT;
|
||||
|
||||
rc = haptics_masked_write(chip, chip->cfg_addr_base,
|
||||
HAP_CFG_AUTORES_CFG_REG, AUTORES_EN_BIT |
|
||||
AUTORES_EN_DLY_MASK | AUTORES_ERR_WINDOW_MASK,
|
||||
AUTORES_EN_DLY_6_CYCLES << AUTORES_EN_DLY_SHIFT
|
||||
| AUTORES_ERR_WINDOW_50_PERCENT | AUTORES_EN_BIT);
|
||||
val);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
if (chip->hw_type == HAP525_HV) {
|
||||
mask = ADT_DRV_DUTY_EN_BIT | ADT_BRK_DUTY_EN_BIT |
|
||||
DRV_DUTY_MASK | BRK_DUTY_MASK;
|
||||
val = DRV_DUTY_62P5_PCT << DRV_DUTY_SHIFT | BRK_DUTY_75_PCT;
|
||||
} else {
|
||||
mask = ADT_DRV_DUTY_EN_BIT;
|
||||
val = 0;
|
||||
}
|
||||
|
||||
rc = haptics_masked_write(chip, chip->cfg_addr_base,
|
||||
HAP_CFG_DRV_DUTY_CFG_REG, ADT_DRV_DUTY_EN_BIT, 0);
|
||||
HAP_CFG_DRV_DUTY_CFG_REG, mask, val);
|
||||
if (rc < 0)
|
||||
goto restore;
|
||||
|
||||
|
|
@ -5150,9 +5187,8 @@ static int haptics_detect_lra_frequency(struct haptics_chip *chip)
|
|||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
rc = haptics_masked_write(chip, chip->cfg_addr_base,
|
||||
HAP_CFG_DRV_DUTY_CFG_REG, ADT_DRV_DUTY_EN_BIT,
|
||||
ADT_DRV_DUTY_EN_BIT);
|
||||
rc = haptics_write(chip, chip->cfg_addr_base,
|
||||
HAP_CFG_DRV_DUTY_CFG_REG, &drv_duty_cfg, 1);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -5647,6 +5683,16 @@ static int haptics_restore(struct device *dev)
|
|||
return rc;
|
||||
|
||||
return haptics_module_enable(chip, true);
|
||||
|
||||
}
|
||||
|
||||
static void haptics_shutdown(struct platform_device *pdev)
|
||||
{
|
||||
struct haptics_chip *chip = platform_get_drvdata(pdev);
|
||||
|
||||
haptics_suspend_config(chip->dev);
|
||||
|
||||
haptics_ds_suspend_config(chip->dev);
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops haptics_pm_ops = {
|
||||
|
|
@ -5676,6 +5722,7 @@ static struct platform_driver haptics_driver = {
|
|||
.pm = &haptics_pm_ops,
|
||||
},
|
||||
.probe = haptics_probe,
|
||||
.shutdown = haptics_shutdown,
|
||||
.remove = haptics_remove,
|
||||
};
|
||||
module_platform_driver(haptics_driver);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user