hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-lpc2k.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2011 NXP Semiconductors
34 *
....@@ -9,12 +10,6 @@
910 * Anton Protopopov, Emcraft Systems, antonp@emcraft.com
1011 *
1112 * Copyright (C) 2015 Joachim Eastwood <manabian@gmail.com>
12
- *
13
- * This program is free software; you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License as published by
15
- * the Free Software Foundation; either version 2 of the License, or
16
- * (at your option) any later version.
17
- *
1813 */
1914
2015 #include <linux/clk.h>
....@@ -351,7 +346,6 @@
351346 static int i2c_lpc2k_probe(struct platform_device *pdev)
352347 {
353348 struct lpc2k_i2c *i2c;
354
- struct resource *res;
355349 u32 bus_clk_rate;
356350 u32 scl_high;
357351 u32 clkrate;
....@@ -361,16 +355,13 @@
361355 if (!i2c)
362356 return -ENOMEM;
363357
364
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
365
- i2c->base = devm_ioremap_resource(&pdev->dev, res);
358
+ i2c->base = devm_platform_ioremap_resource(pdev, 0);
366359 if (IS_ERR(i2c->base))
367360 return PTR_ERR(i2c->base);
368361
369362 i2c->irq = platform_get_irq(pdev, 0);
370
- if (i2c->irq < 0) {
371
- dev_err(&pdev->dev, "can't get interrupt resource\n");
363
+ if (i2c->irq < 0)
372364 return i2c->irq;
373
- }
374365
375366 init_waitqueue_head(&i2c->wait);
376367
....@@ -401,7 +392,7 @@
401392 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
402393 &bus_clk_rate);
403394 if (ret)
404
- bus_clk_rate = 100000; /* 100 kHz default clock rate */
395
+ bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ;
405396
406397 clkrate = clk_get_rate(i2c->clk);
407398 if (clkrate == 0) {
....@@ -412,9 +403,9 @@
412403
413404 /* Setup I2C dividers to generate clock with proper duty cycle */
414405 clkrate = clkrate / bus_clk_rate;
415
- if (bus_clk_rate <= 100000)
406
+ if (bus_clk_rate <= I2C_MAX_STANDARD_MODE_FREQ)
416407 scl_high = (clkrate * I2C_STD_MODE_DUTY) / 100;
417
- else if (bus_clk_rate <= 400000)
408
+ else if (bus_clk_rate <= I2C_MAX_FAST_MODE_FREQ)
418409 scl_high = (clkrate * I2C_FAST_MODE_DUTY) / 100;
419410 else
420411 scl_high = (clkrate * I2C_FAST_MODE_PLUS_DUTY) / 100;