diff options
author | Dirk Brandewie <dirk.brandewie@gmail.com> | 2011-10-06 14:26:28 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2011-10-29 06:00:52 -0400 |
commit | 4a423a8c8107b983007199c76c8327cd1747f092 (patch) | |
tree | 2eeef3d743d73684a8d8f97e7b4d6ebacb72e608 /drivers/i2c | |
parent | 18c4089e6cd6b3052895481628f478ba8351ac00 (diff) |
i2c-designware: Move checking of IP core version to i2c_dw_init()
Move checking IP core version to i2c_dw_init() in preparation for
splitting i2c-designware.c into core and bus specific portions.
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-designware.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c index 934dfe1e6ce9..a7abbcd3d805 100644 --- a/drivers/i2c/busses/i2c-designware.c +++ b/drivers/i2c/busses/i2c-designware.c | |||
@@ -305,10 +305,24 @@ static u32 i2c_dw_scl_lcnt(u32 ic_clk, u32 tLOW, u32 tf, int offset) | |||
305 | * This function is called during I2C init function, and in case of timeout at | 305 | * This function is called during I2C init function, and in case of timeout at |
306 | * run time. | 306 | * run time. |
307 | */ | 307 | */ |
308 | static void i2c_dw_init(struct dw_i2c_dev *dev) | 308 | static int i2c_dw_init(struct dw_i2c_dev *dev) |
309 | { | 309 | { |
310 | u32 input_clock_khz = clk_get_rate(dev->clk) / 1000; | 310 | u32 input_clock_khz = clk_get_rate(dev->clk) / 1000; |
311 | u32 ic_con, hcnt, lcnt; | 311 | u32 ic_con, hcnt, lcnt; |
312 | u32 reg; | ||
313 | |||
314 | /* Configure register endianess access */ | ||
315 | reg = dw_readl(dev, DW_IC_COMP_TYPE); | ||
316 | if (reg == ___constant_swab32(DW_IC_COMP_TYPE_VALUE)) { | ||
317 | dev->swab = 1; | ||
318 | reg = DW_IC_COMP_TYPE_VALUE; | ||
319 | } | ||
320 | |||
321 | if (reg != DW_IC_COMP_TYPE_VALUE) { | ||
322 | dev_err(dev->dev, "Unknown Synopsys component type: " | ||
323 | "0x%08x\n", reg); | ||
324 | return -ENODEV; | ||
325 | } | ||
312 | 326 | ||
313 | /* Disable the adapter */ | 327 | /* Disable the adapter */ |
314 | dw_writel(dev, 0, DW_IC_ENABLE); | 328 | dw_writel(dev, 0, DW_IC_ENABLE); |
@@ -351,6 +365,7 @@ static void i2c_dw_init(struct dw_i2c_dev *dev) | |||
351 | ic_con = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE | | 365 | ic_con = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE | |
352 | DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST; | 366 | DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST; |
353 | dw_writel(dev, ic_con, DW_IC_CON); | 367 | dw_writel(dev, ic_con, DW_IC_CON); |
368 | return 0; | ||
354 | } | 369 | } |
355 | 370 | ||
356 | /* | 371 | /* |
@@ -770,21 +785,14 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev) | |||
770 | goto err_unuse_clocks; | 785 | goto err_unuse_clocks; |
771 | } | 786 | } |
772 | 787 | ||
773 | reg = dw_readl(dev, DW_IC_COMP_TYPE); | 788 | r = i2c_dw_init(dev); |
774 | if (reg == ___constant_swab32(0x44570140)) | 789 | if (r) |
775 | dev->swab = 1; | 790 | goto err_unuse_clocks; |
776 | else if (reg != 0x44570140) { | ||
777 | dev_err(&pdev->dev, "Unknown Synopsys component type: " | ||
778 | "0x%08x\n", reg); | ||
779 | r = -ENODEV; | ||
780 | goto err_iounmap; | ||
781 | } | ||
782 | 791 | ||
783 | reg = dw_readl(dev, DW_IC_COMP_PARAM_1); | 792 | reg = dw_readl(dev, DW_IC_COMP_PARAM_1); |
784 | dev->tx_fifo_depth = ((reg >> 16) & 0xff) + 1; | 793 | dev->tx_fifo_depth = ((reg >> 16) & 0xff) + 1; |
785 | dev->rx_fifo_depth = ((reg >> 8) & 0xff) + 1; | 794 | dev->rx_fifo_depth = ((reg >> 8) & 0xff) + 1; |
786 | 795 | ||
787 | i2c_dw_init(dev); | ||
788 | 796 | ||
789 | dw_writel(dev, 0, DW_IC_INTR_MASK); /* disable IRQ */ | 797 | dw_writel(dev, 0, DW_IC_INTR_MASK); /* disable IRQ */ |
790 | r = request_irq(dev->irq, i2c_dw_isr, IRQF_DISABLED, pdev->name, dev); | 798 | r = request_irq(dev->irq, i2c_dw_isr, IRQF_DISABLED, pdev->name, dev); |