Commit 42ab0012 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Wolfram Sang

i2c: designware: Switch PCI driver to use i2c_dw_configure_master()

Since we have available helper to configure master mode, let's use it
in the PCI driver instead of spread open-coded variant.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 3ebe40ed
...@@ -46,20 +46,14 @@ struct dw_scl_sda_cfg { ...@@ -46,20 +46,14 @@ struct dw_scl_sda_cfg {
struct dw_pci_controller { struct dw_pci_controller {
u32 bus_num; u32 bus_num;
u32 bus_cfg;
u32 tx_fifo_depth; u32 tx_fifo_depth;
u32 rx_fifo_depth; u32 rx_fifo_depth;
u32 clk_khz; u32 clk_khz;
u32 functionality;
u32 flags; u32 flags;
struct dw_scl_sda_cfg *scl_sda_cfg; struct dw_scl_sda_cfg *scl_sda_cfg;
int (*setup)(struct pci_dev *pdev, struct dw_pci_controller *c); int (*setup)(struct pci_dev *pdev, struct dw_pci_controller *c);
}; };
#define INTEL_MID_STD_CFG (DW_IC_CON_MASTER | \
DW_IC_CON_SLAVE_DISABLE | \
DW_IC_CON_RESTART_EN)
/* Merrifield HCNT/LCNT/SDA hold time */ /* Merrifield HCNT/LCNT/SDA hold time */
static struct dw_scl_sda_cfg mrfld_config = { static struct dw_scl_sda_cfg mrfld_config = {
.ss_hcnt = 0x2f8, .ss_hcnt = 0x2f8,
...@@ -88,10 +82,11 @@ static struct dw_scl_sda_cfg hsw_config = { ...@@ -88,10 +82,11 @@ static struct dw_scl_sda_cfg hsw_config = {
static int mfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c) static int mfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
{ {
struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev);
switch (pdev->device) { switch (pdev->device) {
case 0x0817: case 0x0817:
c->bus_cfg &= ~DW_IC_CON_SPEED_MASK; dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ;
c->bus_cfg |= DW_IC_CON_SPEED_STD;
/* fall through */ /* fall through */
case 0x0818: case 0x0818:
case 0x0819: case 0x0819:
...@@ -128,53 +123,41 @@ static int mrfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c) ...@@ -128,53 +123,41 @@ static int mrfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
static struct dw_pci_controller dw_pci_controllers[] = { static struct dw_pci_controller dw_pci_controllers[] = {
[medfield] = { [medfield] = {
.bus_num = -1, .bus_num = -1,
.bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST,
.tx_fifo_depth = 32, .tx_fifo_depth = 32,
.rx_fifo_depth = 32, .rx_fifo_depth = 32,
.functionality = I2C_FUNC_10BIT_ADDR,
.clk_khz = 25000, .clk_khz = 25000,
.setup = mfld_setup, .setup = mfld_setup,
}, },
[merrifield] = { [merrifield] = {
.bus_num = -1, .bus_num = -1,
.bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST,
.tx_fifo_depth = 64, .tx_fifo_depth = 64,
.rx_fifo_depth = 64, .rx_fifo_depth = 64,
.functionality = I2C_FUNC_10BIT_ADDR,
.scl_sda_cfg = &mrfld_config, .scl_sda_cfg = &mrfld_config,
.setup = mrfld_setup, .setup = mrfld_setup,
}, },
[baytrail] = { [baytrail] = {
.bus_num = -1, .bus_num = -1,
.bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST,
.tx_fifo_depth = 32, .tx_fifo_depth = 32,
.rx_fifo_depth = 32, .rx_fifo_depth = 32,
.functionality = I2C_FUNC_10BIT_ADDR,
.scl_sda_cfg = &byt_config, .scl_sda_cfg = &byt_config,
}, },
[haswell] = { [haswell] = {
.bus_num = -1, .bus_num = -1,
.bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST,
.tx_fifo_depth = 32, .tx_fifo_depth = 32,
.rx_fifo_depth = 32, .rx_fifo_depth = 32,
.functionality = I2C_FUNC_10BIT_ADDR,
.scl_sda_cfg = &hsw_config, .scl_sda_cfg = &hsw_config,
}, },
[cherrytrail] = { [cherrytrail] = {
.bus_num = -1, .bus_num = -1,
.bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST,
.tx_fifo_depth = 32, .tx_fifo_depth = 32,
.rx_fifo_depth = 32, .rx_fifo_depth = 32,
.functionality = I2C_FUNC_10BIT_ADDR,
.flags = MODEL_CHERRYTRAIL, .flags = MODEL_CHERRYTRAIL,
.scl_sda_cfg = &byt_config, .scl_sda_cfg = &byt_config,
}, },
[elkhartlake] = { [elkhartlake] = {
.bus_num = -1, .bus_num = -1,
.bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST,
.tx_fifo_depth = 32, .tx_fifo_depth = 32,
.rx_fifo_depth = 32, .rx_fifo_depth = 32,
.functionality = I2C_FUNC_10BIT_ADDR,
.clk_khz = 100000, .clk_khz = 100000,
}, },
}; };
...@@ -250,14 +233,16 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, ...@@ -250,14 +233,16 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
if (r < 0) if (r < 0)
return r; return r;
dev->clk = NULL;
dev->controller = controller; dev->controller = controller;
dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
dev->timings.bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
dev->base = pcim_iomap_table(pdev)[0]; dev->base = pcim_iomap_table(pdev)[0];
dev->dev = &pdev->dev; dev->dev = &pdev->dev;
dev->irq = pci_irq_vector(pdev, 0); dev->irq = pci_irq_vector(pdev, 0);
dev->flags |= controller->flags; dev->flags |= controller->flags;
pci_set_drvdata(pdev, dev);
if (controller->setup) { if (controller->setup) {
r = controller->setup(pdev, controller); r = controller->setup(pdev, controller);
if (r) { if (r) {
...@@ -266,10 +251,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, ...@@ -266,10 +251,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
} }
} }
dev->functionality = controller->functionality | i2c_dw_configure_master(dev);
DW_IC_DEFAULT_FUNCTIONALITY;
dev->master_cfg = controller->bus_cfg;
if (controller->scl_sda_cfg) { if (controller->scl_sda_cfg) {
cfg = controller->scl_sda_cfg; cfg = controller->scl_sda_cfg;
dev->ss_hcnt = cfg->ss_hcnt; dev->ss_hcnt = cfg->ss_hcnt;
...@@ -279,8 +262,6 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, ...@@ -279,8 +262,6 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
dev->sda_hold_time = cfg->sda_hold; dev->sda_hold_time = cfg->sda_hold;
} }
pci_set_drvdata(pdev, dev);
dev->tx_fifo_depth = controller->tx_fifo_depth; dev->tx_fifo_depth = controller->tx_fifo_depth;
dev->rx_fifo_depth = controller->rx_fifo_depth; dev->rx_fifo_depth = controller->rx_fifo_depth;
......
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