aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 353adc4dc583..e59c63ae4d41 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -81,9 +81,6 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)
81{ 81{
82 struct dw_i2c_dev *dev = platform_get_drvdata(pdev); 82 struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
83 83
84 if (!ACPI_HANDLE(&pdev->dev))
85 return -ENODEV;
86
87 dev->adapter.nr = -1; 84 dev->adapter.nr = -1;
88 dev->tx_fifo_depth = 32; 85 dev->tx_fifo_depth = 32;
89 dev->rx_fifo_depth = 32; 86 dev->rx_fifo_depth = 32;
@@ -123,7 +120,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
123 struct resource *mem; 120 struct resource *mem;
124 struct dw_i2c_platform_data *pdata; 121 struct dw_i2c_platform_data *pdata;
125 int irq, r; 122 int irq, r;
126 u32 clk_freq; 123 u32 clk_freq, ht = 0;
127 124
128 irq = platform_get_irq(pdev, 0); 125 irq = platform_get_irq(pdev, 0);
129 if (irq < 0) { 126 if (irq < 0) {
@@ -146,24 +143,14 @@ static int dw_i2c_probe(struct platform_device *pdev)
146 dev->irq = irq; 143 dev->irq = irq;
147 platform_set_drvdata(pdev, dev); 144 platform_set_drvdata(pdev, dev);
148 145
149 dev->clk = devm_clk_get(&pdev->dev, NULL);
150 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
151
152 if (IS_ERR(dev->clk))
153 return PTR_ERR(dev->clk);
154 clk_prepare_enable(dev->clk);
155
156 /* fast mode by default because of legacy reasons */ 146 /* fast mode by default because of legacy reasons */
157 clk_freq = 400000; 147 clk_freq = 400000;
158 148
159 if (pdev->dev.of_node) { 149 if (ACPI_COMPANION(&pdev->dev)) {
160 u32 ht = 0; 150 dw_i2c_acpi_configure(pdev);
161 u32 ic_clk = dev->get_clk_rate_khz(dev); 151 } else if (pdev->dev.of_node) {
162
163 of_property_read_u32(pdev->dev.of_node, 152 of_property_read_u32(pdev->dev.of_node,
164 "i2c-sda-hold-time-ns", &ht); 153 "i2c-sda-hold-time-ns", &ht);
165 dev->sda_hold_time = div_u64((u64)ic_clk * ht + 500000,
166 1000000);
167 154
168 of_property_read_u32(pdev->dev.of_node, 155 of_property_read_u32(pdev->dev.of_node,
169 "i2c-sda-falling-time-ns", 156 "i2c-sda-falling-time-ns",
@@ -202,9 +189,20 @@ static int dw_i2c_probe(struct platform_device *pdev)
202 dev->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE | 189 dev->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
203 DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST; 190 DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
204 191
205 /* Try first if we can configure the device from ACPI */ 192 dev->clk = devm_clk_get(&pdev->dev, NULL);
206 r = dw_i2c_acpi_configure(pdev); 193 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
207 if (r) { 194 if (IS_ERR(dev->clk))
195 return PTR_ERR(dev->clk);
196 clk_prepare_enable(dev->clk);
197
198 if (!dev->sda_hold_time && ht) {
199 u32 ic_clk = dev->get_clk_rate_khz(dev);
200
201 dev->sda_hold_time = div_u64((u64)ic_clk * ht + 500000,
202 1000000);
203 }
204
205 if (!dev->tx_fifo_depth) {
208 u32 param1 = i2c_dw_read_comp_param(dev); 206 u32 param1 = i2c_dw_read_comp_param(dev);
209 207
210 dev->tx_fifo_depth = ((param1 >> 16) & 0xff) + 1; 208 dev->tx_fifo_depth = ((param1 >> 16) & 0xff) + 1;