diff options
author | Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com> | 2011-10-06 14:26:26 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2011-10-29 06:00:51 -0400 |
commit | 4ff895bc8b90e30ff8e89ca7bc6666b229c77e5d (patch) | |
tree | e15b340530a1cdb3254af5bb4fa43bd8cf14691f | |
parent | 7f279601c59b814314083d572e7c0df11d09cad8 (diff) |
i2c-designware: Check component type register
Designware component type register is checked before attaching to the device.
Signed-off-by: Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
-rw-r--r-- | drivers/i2c/busses/i2c-designware.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c index 28335c3717d9..49386951f7fd 100644 --- a/drivers/i2c/busses/i2c-designware.c +++ b/drivers/i2c/busses/i2c-designware.c | |||
@@ -69,6 +69,7 @@ | |||
69 | #define DW_IC_TXFLR 0x74 | 69 | #define DW_IC_TXFLR 0x74 |
70 | #define DW_IC_RXFLR 0x78 | 70 | #define DW_IC_RXFLR 0x78 |
71 | #define DW_IC_COMP_PARAM_1 0xf4 | 71 | #define DW_IC_COMP_PARAM_1 0xf4 |
72 | #define DW_IC_COMP_TYPE 0xfc | ||
72 | #define DW_IC_TX_ABRT_SOURCE 0x80 | 73 | #define DW_IC_TX_ABRT_SOURCE 0x80 |
73 | 74 | ||
74 | #define DW_IC_CON_MASTER 0x1 | 75 | #define DW_IC_CON_MASTER 0x1 |
@@ -710,6 +711,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev) | |||
710 | struct i2c_adapter *adap; | 711 | struct i2c_adapter *adap; |
711 | struct resource *mem, *ioarea; | 712 | struct resource *mem, *ioarea; |
712 | int irq, r; | 713 | int irq, r; |
714 | u32 reg; | ||
713 | 715 | ||
714 | /* NOTE: driver uses the static register mapping */ | 716 | /* NOTE: driver uses the static register mapping */ |
715 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 717 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -756,12 +758,19 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev) | |||
756 | r = -EBUSY; | 758 | r = -EBUSY; |
757 | goto err_unuse_clocks; | 759 | goto err_unuse_clocks; |
758 | } | 760 | } |
759 | { | ||
760 | u32 param1 = dw_readl(dev, DW_IC_COMP_PARAM_1); | ||
761 | 761 | ||
762 | dev->tx_fifo_depth = ((param1 >> 16) & 0xff) + 1; | 762 | reg = dw_readl(dev, DW_IC_COMP_TYPE); |
763 | dev->rx_fifo_depth = ((param1 >> 8) & 0xff) + 1; | 763 | if (reg != 0x44570140) { |
764 | dev_err(&pdev->dev, "Unknown Synopsys component type: " | ||
765 | "0x%08x\n", reg); | ||
766 | r = -ENODEV; | ||
767 | goto err_iounmap; | ||
764 | } | 768 | } |
769 | |||
770 | reg = dw_readl(dev, DW_IC_COMP_PARAM_1); | ||
771 | dev->tx_fifo_depth = ((reg >> 16) & 0xff) + 1; | ||
772 | dev->rx_fifo_depth = ((reg >> 8) & 0xff) + 1; | ||
773 | |||
765 | i2c_dw_init(dev); | 774 | i2c_dw_init(dev); |
766 | 775 | ||
767 | dw_writel(dev, 0, DW_IC_INTR_MASK); /* disable IRQ */ | 776 | dw_writel(dev, 0, DW_IC_INTR_MASK); /* disable IRQ */ |