Commit 535677e4 authored by Jarkko Nikula's avatar Jarkko Nikula Committed by Andi Shyti

i2c: designware: Uniform initialization flow for polling mode

Currently initialization flow in i2c_dw_probe_master() skips a few steps
and has code duplication for polling mode implementation.

Simplify this by adding a new ACCESS_POLLING flag that is set for those
two platforms that currently use polling mode and use it to skip
interrupt handler setup.
Signed-off-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: default avatarJiawen Wu <jiawenwu@trustnetic.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@kernel.org>
parent a856c9e6
...@@ -303,6 +303,7 @@ struct dw_i2c_dev { ...@@ -303,6 +303,7 @@ struct dw_i2c_dev {
#define ACCESS_INTR_MASK BIT(0) #define ACCESS_INTR_MASK BIT(0)
#define ACCESS_NO_IRQ_SUSPEND BIT(1) #define ACCESS_NO_IRQ_SUSPEND BIT(1)
#define ARBITRATION_SEMAPHORE BIT(2) #define ARBITRATION_SEMAPHORE BIT(2)
#define ACCESS_POLLING BIT(3)
#define MODEL_MSCC_OCELOT BIT(8) #define MODEL_MSCC_OCELOT BIT(8)
#define MODEL_BAIKAL_BT1 BIT(9) #define MODEL_BAIKAL_BT1 BIT(9)
......
...@@ -953,31 +953,6 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev) ...@@ -953,31 +953,6 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev)
return 0; return 0;
} }
static int i2c_dw_poll_adap_quirk(struct dw_i2c_dev *dev)
{
struct i2c_adapter *adap = &dev->adapter;
int ret;
pm_runtime_get_noresume(dev->dev);
ret = i2c_add_numbered_adapter(adap);
if (ret)
dev_err(dev->dev, "Failed to add adapter: %d\n", ret);
pm_runtime_put_noidle(dev->dev);
return ret;
}
static bool i2c_dw_is_model_poll(struct dw_i2c_dev *dev)
{
switch (dev->flags & MODEL_MASK) {
case MODEL_AMD_NAVI_GPU:
case MODEL_WANGXUN_SP:
return true;
default:
return false;
}
}
int i2c_dw_probe_master(struct dw_i2c_dev *dev) int i2c_dw_probe_master(struct dw_i2c_dev *dev)
{ {
struct i2c_adapter *adap = &dev->adapter; struct i2c_adapter *adap = &dev->adapter;
...@@ -1033,9 +1008,6 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev) ...@@ -1033,9 +1008,6 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
adap->dev.parent = dev->dev; adap->dev.parent = dev->dev;
i2c_set_adapdata(adap, dev); i2c_set_adapdata(adap, dev);
if (i2c_dw_is_model_poll(dev))
return i2c_dw_poll_adap_quirk(dev);
if (dev->flags & ACCESS_NO_IRQ_SUSPEND) { if (dev->flags & ACCESS_NO_IRQ_SUSPEND) {
irq_flags = IRQF_NO_SUSPEND; irq_flags = IRQF_NO_SUSPEND;
} else { } else {
...@@ -1049,13 +1021,15 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev) ...@@ -1049,13 +1021,15 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
regmap_write(dev->map, DW_IC_INTR_MASK, 0); regmap_write(dev->map, DW_IC_INTR_MASK, 0);
i2c_dw_release_lock(dev); i2c_dw_release_lock(dev);
ret = devm_request_irq(dev->dev, dev->irq, i2c_dw_isr, irq_flags, if (!(dev->flags & ACCESS_POLLING)) {
dev_name(dev->dev), dev); ret = devm_request_irq(dev->dev, dev->irq, i2c_dw_isr,
irq_flags, dev_name(dev->dev), dev);
if (ret) { if (ret) {
dev_err(dev->dev, "failure requesting irq %i: %d\n", dev_err(dev->dev, "failure requesting irq %i: %d\n",
dev->irq, ret); dev->irq, ret);
return ret; return ret;
} }
}
ret = i2c_dw_init_recovery_info(dev); ret = i2c_dw_init_recovery_info(dev);
if (ret) if (ret)
......
...@@ -154,7 +154,7 @@ static int navi_amd_setup(struct pci_dev *pdev, struct dw_pci_controller *c) ...@@ -154,7 +154,7 @@ static int navi_amd_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
{ {
struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev); struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev);
dev->flags |= MODEL_AMD_NAVI_GPU; dev->flags |= MODEL_AMD_NAVI_GPU | ACCESS_POLLING;
dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ; dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ;
return 0; return 0;
} }
......
...@@ -290,7 +290,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) ...@@ -290,7 +290,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
dev->flags = (uintptr_t)device_get_match_data(&pdev->dev); dev->flags = (uintptr_t)device_get_match_data(&pdev->dev);
if (device_property_present(&pdev->dev, "wx,i2c-snps-model")) if (device_property_present(&pdev->dev, "wx,i2c-snps-model"))
dev->flags = MODEL_WANGXUN_SP; dev->flags = MODEL_WANGXUN_SP | ACCESS_POLLING;
dev->dev = &pdev->dev; dev->dev = &pdev->dev;
dev->irq = irq; dev->irq = irq;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment