forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/i2c/busses/i2c-nomadik.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2009 ST-Ericsson SA
34 * Copyright (C) 2009 STMicroelectronics
....@@ -7,10 +8,6 @@
78 *
89 * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
910 * Author: Sachin Verma <sachin.verma@st.com>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License version 2, as
13
- * published by the Free Software Foundation.
1411 */
1512 #include <linux/init.h>
1613 #include <linux/module.h>
....@@ -399,7 +396,7 @@
399396 * 2 whereas it is 3 for fast and fastplus mode of
400397 * operation. TODO - high speed support.
401398 */
402
- div = (dev->clk_freq > 100000) ? 3 : 2;
399
+ div = (dev->clk_freq > I2C_MAX_STANDARD_MODE_FREQ) ? 3 : 2;
403400
404401 /*
405402 * generate the mask for baud rate counters. The controller
....@@ -423,7 +420,7 @@
423420 if (dev->sm > I2C_FREQ_MODE_FAST) {
424421 dev_err(&dev->adev->dev,
425422 "do not support this mode defaulting to std. mode\n");
426
- brcr2 = i2c_clk/(100000 * 2) & 0xffff;
423
+ brcr2 = i2c_clk / (I2C_MAX_STANDARD_MODE_FREQ * 2) & 0xffff;
427424 writel((brcr1 | brcr2), dev->virtbase + I2C_BRCR);
428425 writel(I2C_FREQ_MODE_STANDARD << 4,
429426 dev->virtbase + I2C_CR);
....@@ -952,10 +949,10 @@
952949 {
953950 /* Default to 100 kHz if no frequency is given in the node */
954951 if (of_property_read_u32(np, "clock-frequency", &nmk->clk_freq))
955
- nmk->clk_freq = 100000;
952
+ nmk->clk_freq = I2C_MAX_STANDARD_MODE_FREQ;
956953
957954 /* This driver only supports 'standard' and 'fast' modes of operation. */
958
- if (nmk->clk_freq <= 100000)
955
+ if (nmk->clk_freq <= I2C_MAX_STANDARD_MODE_FREQ)
959956 nmk->sm = I2C_FREQ_MODE_STANDARD;
960957 else
961958 nmk->sm = I2C_FREQ_MODE_FAST;
....@@ -1058,7 +1055,7 @@
10581055 return ret;
10591056 }
10601057
1061
-static int nmk_i2c_remove(struct amba_device *adev)
1058
+static void nmk_i2c_remove(struct amba_device *adev)
10621059 {
10631060 struct resource *res = &adev->res;
10641061 struct nmk_i2c_dev *dev = amba_get_drvdata(adev);
....@@ -1070,10 +1067,7 @@
10701067 /* disable the controller */
10711068 i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE);
10721069 clk_disable_unprepare(dev->clk);
1073
- if (res)
1074
- release_mem_region(res->start, resource_size(res));
1075
-
1076
- return 0;
1070
+ release_mem_region(res->start, resource_size(res));
10771071 }
10781072
10791073 static struct i2c_vendor_data vendor_stn8815 = {
....@@ -1126,6 +1120,7 @@
11261120 subsys_initcall(nmk_i2c_init);
11271121 module_exit(nmk_i2c_exit);
11281122
1129
-MODULE_AUTHOR("Sachin Verma, Srinidhi KASAGAR");
1123
+MODULE_AUTHOR("Sachin Verma");
1124
+MODULE_AUTHOR("Srinidhi KASAGAR");
11301125 MODULE_DESCRIPTION("Nomadik/Ux500 I2C driver");
11311126 MODULE_LICENSE("GPL");