hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/drivers/i2c/busses/i2c-uniphier.c
....@@ -1,15 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
134 */
145
156 #include <linux/clk.h>
....@@ -44,9 +35,6 @@
4435 #define UNIPHIER_I2C_NOISE 0x1c /* noise filter control */
4536 #define UNIPHIER_I2C_SETUP 0x20 /* setup time control */
4637
47
-#define UNIPHIER_I2C_DEFAULT_SPEED 100000
48
-#define UNIPHIER_I2C_MAX_SPEED 400000
49
-
5038 struct uniphier_i2c_priv {
5139 struct completion comp;
5240 struct i2c_adapter adap;
....@@ -80,7 +68,6 @@
8068 reinit_completion(&priv->comp);
8169
8270 txdata |= UNIPHIER_I2C_DTRM_IRQEN;
83
- dev_dbg(&adap->dev, "write data: 0x%04x\n", txdata);
8471 writel(txdata, priv->membase + UNIPHIER_I2C_DTRM);
8572
8673 time_left = wait_for_completion_timeout(&priv->comp, adap->timeout);
....@@ -90,8 +77,6 @@
9077 }
9178
9279 rxdata = readl(priv->membase + UNIPHIER_I2C_DREC);
93
- dev_dbg(&adap->dev, "read data: 0x%04x\n", rxdata);
94
-
9580 if (rxdatap)
9681 *rxdatap = rxdata;
9782
....@@ -107,14 +92,11 @@
10792 if (ret)
10893 return ret;
10994
110
- if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB)) {
111
- dev_dbg(&adap->dev, "arbitration lost\n");
95
+ if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB))
11296 return -EAGAIN;
113
- }
114
- if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB)) {
115
- dev_dbg(&adap->dev, "could not get ACK\n");
97
+
98
+ if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB))
11699 return -ENXIO;
117
- }
118100
119101 return 0;
120102 }
....@@ -124,7 +106,6 @@
124106 {
125107 int ret;
126108
127
- dev_dbg(&adap->dev, "start condition\n");
128109 ret = uniphier_i2c_send_byte(adap, addr << 1 |
129110 UNIPHIER_I2C_DTRM_STA |
130111 UNIPHIER_I2C_DTRM_NACK);
....@@ -146,7 +127,6 @@
146127 {
147128 int ret;
148129
149
- dev_dbg(&adap->dev, "start condition\n");
150130 ret = uniphier_i2c_send_byte(adap, addr << 1 |
151131 UNIPHIER_I2C_DTRM_STA |
152132 UNIPHIER_I2C_DTRM_NACK |
....@@ -170,7 +150,6 @@
170150
171151 static int uniphier_i2c_stop(struct i2c_adapter *adap)
172152 {
173
- dev_dbg(&adap->dev, "stop condition\n");
174153 return uniphier_i2c_send_byte(adap, UNIPHIER_I2C_DTRM_STO |
175154 UNIPHIER_I2C_DTRM_NACK);
176155 }
....@@ -181,9 +160,6 @@
181160 bool is_read = msg->flags & I2C_M_RD;
182161 bool recovery = false;
183162 int ret;
184
-
185
- dev_dbg(&adap->dev, "%s: addr=0x%02x, len=%d, stop=%d\n",
186
- is_read ? "receive" : "transmit", msg->addr, msg->len, stop);
187163
188164 if (is_read)
189165 ret = uniphier_i2c_rx(adap, msg->addr, msg->len, msg->buf);
....@@ -335,7 +311,6 @@
335311 {
336312 struct device *dev = &pdev->dev;
337313 struct uniphier_i2c_priv *priv;
338
- struct resource *regs;
339314 u32 bus_speed;
340315 unsigned long clk_rate;
341316 int irq, ret;
....@@ -344,21 +319,18 @@
344319 if (!priv)
345320 return -ENOMEM;
346321
347
- regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
348
- priv->membase = devm_ioremap_resource(dev, regs);
322
+ priv->membase = devm_platform_ioremap_resource(pdev, 0);
349323 if (IS_ERR(priv->membase))
350324 return PTR_ERR(priv->membase);
351325
352326 irq = platform_get_irq(pdev, 0);
353
- if (irq < 0) {
354
- dev_err(dev, "failed to get IRQ number\n");
327
+ if (irq < 0)
355328 return irq;
356
- }
357329
358330 if (of_property_read_u32(dev->of_node, "clock-frequency", &bus_speed))
359
- bus_speed = UNIPHIER_I2C_DEFAULT_SPEED;
331
+ bus_speed = I2C_MAX_STANDARD_MODE_FREQ;
360332
361
- if (!bus_speed || bus_speed > UNIPHIER_I2C_MAX_SPEED) {
333
+ if (!bus_speed || bus_speed > I2C_MAX_FAST_MODE_FREQ) {
362334 dev_err(dev, "invalid clock-frequency %d\n", bus_speed);
363335 return -EINVAL;
364336 }