hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-hix5hd2.c
....@@ -1,11 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) 2014 Linaro Ltd.
34 * Copyright (c) 2014 Hisilicon Limited.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
95 *
106 * Now only support 7 bit address.
117 */
....@@ -71,8 +67,6 @@
7167 #define I2C_ACK_INTR BIT(2)
7268 #define I2C_ARBITRATE_INTR BIT(1)
7369 #define I2C_OVER_INTR BIT(0)
74
-
75
-#define HIX5I2C_MAX_FREQ 400000 /* 400k */
7670
7771 enum hix5hd2_i2c_state {
7872 HIX5I2C_STAT_RW_ERR = -1,
....@@ -394,7 +388,6 @@
394388 {
395389 struct device_node *np = pdev->dev.of_node;
396390 struct hix5hd2_i2c_priv *priv;
397
- struct resource *mem;
398391 unsigned int freq;
399392 int irq, ret;
400393
....@@ -404,27 +397,24 @@
404397
405398 if (of_property_read_u32(np, "clock-frequency", &freq)) {
406399 /* use 100k as default value */
407
- priv->freq = 100000;
400
+ priv->freq = I2C_MAX_STANDARD_MODE_FREQ;
408401 } else {
409
- if (freq > HIX5I2C_MAX_FREQ) {
410
- priv->freq = HIX5I2C_MAX_FREQ;
402
+ if (freq > I2C_MAX_FAST_MODE_FREQ) {
403
+ priv->freq = I2C_MAX_FAST_MODE_FREQ;
411404 dev_warn(priv->dev, "use max freq %d instead\n",
412
- HIX5I2C_MAX_FREQ);
405
+ I2C_MAX_FAST_MODE_FREQ);
413406 } else {
414407 priv->freq = freq;
415408 }
416409 }
417410
418
- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
419
- priv->regs = devm_ioremap_resource(&pdev->dev, mem);
411
+ priv->regs = devm_platform_ioremap_resource(pdev, 0);
420412 if (IS_ERR(priv->regs))
421413 return PTR_ERR(priv->regs);
422414
423415 irq = platform_get_irq(pdev, 0);
424
- if (irq <= 0) {
425
- dev_err(&pdev->dev, "cannot find HS-I2C IRQ\n");
416
+ if (irq < 0)
426417 return irq;
427
- }
428418
429419 priv->clk = devm_clk_get(&pdev->dev, NULL);
430420 if (IS_ERR(priv->clk)) {