| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2009 ST-Ericsson SA |
|---|
| 3 | 4 | * Copyright (C) 2009 STMicroelectronics |
|---|
| .. | .. |
|---|
| 7 | 8 | * |
|---|
| 8 | 9 | * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> |
|---|
| 9 | 10 | * 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. |
|---|
| 14 | 11 | */ |
|---|
| 15 | 12 | #include <linux/init.h> |
|---|
| 16 | 13 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 399 | 396 | * 2 whereas it is 3 for fast and fastplus mode of |
|---|
| 400 | 397 | * operation. TODO - high speed support. |
|---|
| 401 | 398 | */ |
|---|
| 402 | | - div = (dev->clk_freq > 100000) ? 3 : 2; |
|---|
| 399 | + div = (dev->clk_freq > I2C_MAX_STANDARD_MODE_FREQ) ? 3 : 2; |
|---|
| 403 | 400 | |
|---|
| 404 | 401 | /* |
|---|
| 405 | 402 | * generate the mask for baud rate counters. The controller |
|---|
| .. | .. |
|---|
| 423 | 420 | if (dev->sm > I2C_FREQ_MODE_FAST) { |
|---|
| 424 | 421 | dev_err(&dev->adev->dev, |
|---|
| 425 | 422 | "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; |
|---|
| 427 | 424 | writel((brcr1 | brcr2), dev->virtbase + I2C_BRCR); |
|---|
| 428 | 425 | writel(I2C_FREQ_MODE_STANDARD << 4, |
|---|
| 429 | 426 | dev->virtbase + I2C_CR); |
|---|
| .. | .. |
|---|
| 952 | 949 | { |
|---|
| 953 | 950 | /* Default to 100 kHz if no frequency is given in the node */ |
|---|
| 954 | 951 | 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; |
|---|
| 956 | 953 | |
|---|
| 957 | 954 | /* 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) |
|---|
| 959 | 956 | nmk->sm = I2C_FREQ_MODE_STANDARD; |
|---|
| 960 | 957 | else |
|---|
| 961 | 958 | nmk->sm = I2C_FREQ_MODE_FAST; |
|---|
| .. | .. |
|---|
| 1058 | 1055 | return ret; |
|---|
| 1059 | 1056 | } |
|---|
| 1060 | 1057 | |
|---|
| 1061 | | -static int nmk_i2c_remove(struct amba_device *adev) |
|---|
| 1058 | +static void nmk_i2c_remove(struct amba_device *adev) |
|---|
| 1062 | 1059 | { |
|---|
| 1063 | 1060 | struct resource *res = &adev->res; |
|---|
| 1064 | 1061 | struct nmk_i2c_dev *dev = amba_get_drvdata(adev); |
|---|
| .. | .. |
|---|
| 1070 | 1067 | /* disable the controller */ |
|---|
| 1071 | 1068 | i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE); |
|---|
| 1072 | 1069 | 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)); |
|---|
| 1077 | 1071 | } |
|---|
| 1078 | 1072 | |
|---|
| 1079 | 1073 | static struct i2c_vendor_data vendor_stn8815 = { |
|---|
| .. | .. |
|---|
| 1126 | 1120 | subsys_initcall(nmk_i2c_init); |
|---|
| 1127 | 1121 | module_exit(nmk_i2c_exit); |
|---|
| 1128 | 1122 | |
|---|
| 1129 | | -MODULE_AUTHOR("Sachin Verma, Srinidhi KASAGAR"); |
|---|
| 1123 | +MODULE_AUTHOR("Sachin Verma"); |
|---|
| 1124 | +MODULE_AUTHOR("Srinidhi KASAGAR"); |
|---|
| 1130 | 1125 | MODULE_DESCRIPTION("Nomadik/Ux500 I2C driver"); |
|---|
| 1131 | 1126 | MODULE_LICENSE("GPL"); |
|---|