.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2014 Linaro Ltd. |
---|
3 | 4 | * 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. |
---|
9 | 5 | * |
---|
10 | 6 | * Now only support 7 bit address. |
---|
11 | 7 | */ |
---|
.. | .. |
---|
71 | 67 | #define I2C_ACK_INTR BIT(2) |
---|
72 | 68 | #define I2C_ARBITRATE_INTR BIT(1) |
---|
73 | 69 | #define I2C_OVER_INTR BIT(0) |
---|
74 | | - |
---|
75 | | -#define HIX5I2C_MAX_FREQ 400000 /* 400k */ |
---|
76 | 70 | |
---|
77 | 71 | enum hix5hd2_i2c_state { |
---|
78 | 72 | HIX5I2C_STAT_RW_ERR = -1, |
---|
.. | .. |
---|
394 | 388 | { |
---|
395 | 389 | struct device_node *np = pdev->dev.of_node; |
---|
396 | 390 | struct hix5hd2_i2c_priv *priv; |
---|
397 | | - struct resource *mem; |
---|
398 | 391 | unsigned int freq; |
---|
399 | 392 | int irq, ret; |
---|
400 | 393 | |
---|
.. | .. |
---|
404 | 397 | |
---|
405 | 398 | if (of_property_read_u32(np, "clock-frequency", &freq)) { |
---|
406 | 399 | /* use 100k as default value */ |
---|
407 | | - priv->freq = 100000; |
---|
| 400 | + priv->freq = I2C_MAX_STANDARD_MODE_FREQ; |
---|
408 | 401 | } 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; |
---|
411 | 404 | dev_warn(priv->dev, "use max freq %d instead\n", |
---|
412 | | - HIX5I2C_MAX_FREQ); |
---|
| 405 | + I2C_MAX_FAST_MODE_FREQ); |
---|
413 | 406 | } else { |
---|
414 | 407 | priv->freq = freq; |
---|
415 | 408 | } |
---|
416 | 409 | } |
---|
417 | 410 | |
---|
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); |
---|
420 | 412 | if (IS_ERR(priv->regs)) |
---|
421 | 413 | return PTR_ERR(priv->regs); |
---|
422 | 414 | |
---|
423 | 415 | 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) |
---|
426 | 417 | return irq; |
---|
427 | | - } |
---|
428 | 418 | |
---|
429 | 419 | priv->clk = devm_clk_get(&pdev->dev, NULL); |
---|
430 | 420 | if (IS_ERR(priv->clk)) { |
---|